Please fill out the following information to help in answering your question, and also see tips for posting code snippets. If you don’t provide this information it will take more time to help with your problem!
Dear All,
I am using the NeutronSource example. and I want to change the particle generator to GPS (It is gun type)
therefore I have replaced the PrimaryGeneratorAction.cc and PrimaryGeneratorAction.hh
I copied the new two files from the B1 example
I just copied and past without changing.
Now I have issues with the error: no matching constructor for initialization of ‘PrimaryGeneratorAction’
** PrimaryGeneratorAction* primary = new PrimaryGeneratorAction(fDetector);**
Do I need to change the ActionInitialization.cc and ActionInitialization.hh
That error’s because the primary generator action in example B1 has a constructor with no arguments:
whilst that in NeutronSource takes a pointer to the detector construction. Just update any instantiations of PrimaryGeneratorAction to use the no-argument form, e.g.
// wrong:
// PrimaryGeneratorAction* primary = new PrimaryGeneratorAction(fDetector);**
//should work
PrimaryGeneratorAction* primary = new PrimaryGeneratorAction();
Thanks a lot,
In the “ActionInitialization.cc” I replaced the
PrimaryGeneratorAction* primary = new PrimaryGeneratorAction(fDetector);
SetUserAction(primary);
To
PrimaryGeneratorAction* primary = new PrimaryGeneratorAction();
SetUserAction(primary);
But currently I have issues with the run manager, it is defined as gunparticle. Do I need to delete this definition??
“src/RunAction.cc:81:19: error: no member named ‘GetParticleGun’ in ‘PrimaryGeneratorAction’
= fPrimary->GetParticleGun()->GetParticleDefinition();
~~~~~~~~ ^
/Users/kafaal-khasawneh/JRTR/untitled folder/NeutronSource/src/RunAction.cc:82:33: error: no member named ‘GetParticleGun’ in ‘PrimaryGeneratorAction’
G4double energy = fPrimary->GetParticleGun()->GetParticleEnergy();”