Please fill out the following information to help in answering your question, and also see tips for posting code snippets
_Geant4 Version:_10.7
_Operating System:_ubuntu20.04
_Compiler/Version:_9.4.0
I wanted to achieve the PrimaryGeneratorAction class using the data in a file, the key codes are below:
namespace{
G4Mutex GammaSpectrum=G4MUTEX_INITIALIZER;
}
G4AutoLock lock(&GammaSpectrum);
G4String line;
for(G4int i=0;i<1000;i++)
{
getline(ifile,line);
}
lock.unlock();
there are 1000 lines data in the file, but the projection read “1000 * Number of threads” lines, so the error occured, the “strlen(line)” was printed for checking the how many lines were read.