Communicating between EventAction and RunAction

I’m having a problem communicating between the RunAction and the EventAction.

In the RunAction.cc I have set up a new file which reads a file for a new type of Gadolinum cascade. The code for that is as follows:

void RunAction::BeginOfRunAction(const G4Run* aRun){

//setting up the gadolinium dice box
cout << “setting up Gd 157 cascadeModel” << endl;

fGd157Model->setFile("../data/Gd157DiceBoxTable.txt");
fGd157Model->setMultiplicityString("mul");
fGd157Model->setMultiplicityCdfString("mul_cdf");
fGd157Model->setEnergyString("erg");
fGd157Model->setParticleString("par");

cout << "set up of Gd 157 cascadeModel Compleate" << endl;

In the EventAction.cc I have the code that is supposed to produce the particles and energies associated with the Dice box. I have the following:

void EventAction::BeginOfEventAction(const G4Event* anEvent){

struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts); //set up the random seed generator
srand((time_t)ts.tv_nsec);

double randomProb = ((double) rand() / (RAND_MAX)); //give me a random value 0-1
RunAction().GetGd157Model()->setRandomCdfNo(randomProb);
cout << "random Prob is " << randomProb << endl;
cout << "Number of particles is: " << RunAction().GetGd157Model()->getParticles().size() << endl ;
cout << "Number of Energies is: " << RunAction().GetGd157Model()->getEnergies().size() << endl;

But it produces no particles or energies…

In RunAction.hh I have The accessors and class definition for the new Gadolinium model:

public:
RunAction();
virtual ~RunAction(){};
void BeginOfRunAction(const G4Run*);
void EndOfRunAction(const G4Run*);

GdModel * GetGd157Model(){return fGd157Model;};

private:

GdModel * fGd157Model = new GdModel();

If I run the following code in RunAction.cc :

struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts); //set up the random seed generator
srand((time_t)ts.tv_nsec);

double randomProb = ((double) rand() / (RAND_MAX)); //give me a random value 0-1
fGd157Model()->setRandomCdfNo(randomProb);
cout << "random Prob is " << randomProb << endl;
cout << "Number of particles is: " << fGd157Model()->getParticles().size() << endl ;
cout << "Number of Energies is: " <<fGd157Model()->getEnergies().size() << endl;

It will produce particles and energies, but of course, this will only work for the setting up of each Run and so is not useful for an event by event basis. I cannot run the setup in the EventAction because that would take far too much time and compute power. The Table is 5 MB large so the setup takes 3-4 seconds to setup I want to run 1e6 particles, that time taken is not acceptable. I only want to set up once and then roll dice after that.

To conclude I know that my class can produce the particles necessary but cannot be accessed through the Event action for some reason… Does anyone know why this is? Also sorry for the long question. I tried to include all the relevant parts.

Hello,

RunAction and EventAction classes assume to work as kind observers, which allow print/score/save information about run and event.

Physics of Geant4 is implemented inside physics process classes. Please, have a look into basic paper: Nuclear Instruments and Methods in Physics Research A 506 (2003) 250-303, and Application developer manual: http://geant4-userdoc.web.cern.ch/geant4-userdoc/UsersGuides/ForApplicationDeveloper/html/index.html

VI