User defined distribution from file

Hello guys,

I am trying to run particles from an input beam file.
The necessary messenger command was created for PrimaryGeneratorAction to define file name.
But I can’t understand how to pass an initial argc variable from main to this class.

I have tried runManager->SetUserAction(new PrimaryGeneratorAction(G4String fileName))
but got the next warning due to multithreading:

G4MTRunManager::SetUserAction()
For multi-threaded version, define G4VUserPrimaryGeneratorAction in G4VUserActionInitialization

Any suggestions?

Best regards,

Volodymyr

Hello,

in Geant4 MT in each thread a new instamce of PrimaryGenerator is used. I see a following possibilities to read external data on primary particle:

  1. design a dispature class which will use mutex lock and at each call will provide the next primary event from this file.
  2. split input file in N imput files (where N equel to number of threads) and each thread should read from defined independent input input file.
  3. use MT mode with 1 thread only.

VI

Hello Vladimir,

I did that.
ifstream infile(filename);
while (infile >>x >> y >>z>> px>> py>> pz>> id)
{
y_vec[my_pos] = y;
x_vec[my_pos] = x;
z_vec[my_pos] = z;

The new my_pos value is defined within mutex lock

The question is how to provide the input filename variable from the main .cc file or macros before Run initialization?

Currently, I am modifying it in the source code.

Best regards