mrxak
December 7, 2020, 1:09pm
1
Initial example is TestmEm0. If I use macro
/gun/particle ion
/gun/ion 6 12
and simply
fParticleGun->GeneratePrimaryVertex(anEvent);
in PrimaryGeneratorAction everything works fine.
But if I comment lines in macro file and want to use ion directly (pretty the same way what the macro file do looking the Messenger code):
fParticleGun->SetParticleDefinition(G4IonTable::GetIonTable()->GetIon(6, 12, 0));
fParticleGun->SetParticleCharge(6);
than it fails and uses e- as default particle (e- is defined in SetDefaultKinematic of TestEm0).
What is the problem with setting ions directly in GeneratePrimaries?
I’m using Geant4.10.6-p02.
maire
December 7, 2020, 1:37pm
2
in example radioactivedecay/rdecay01, you will find :
G4int Z = 10, A = 24;
G4double ionCharge = 0.*eplus;
G4double excitEnergy = 0.*keV;
G4ParticleDefinition* ion
= G4IonTable::GetIonTable()->GetIon(Z,A,excitEnergy);
fParticleGun->SetParticleDefinition(ion);
fParticleGun->SetParticleCharge(ionCharge);
//create vertex
//
fParticleGun->GeneratePrimaryVertex(anEvent);
mrxak
December 7, 2020, 3:27pm
3
I’ve just coppied this entire part into PrimaryGeneratorAction.cc of TestEm0 and it still don’t work (it sees e-).
maire
December 9, 2020, 9:31am
4
As said in Readme, TestEm0 is a special exercice : there is no tracking. In particular, the function GeneratePrimaries( ) is never called.
A solution is to put commands in the main via the function ApplyCommand( ). For example, at end of TestEm0.cc :
UImanager->ApplyCommand("/gun/particle ion");
UImanager->ApplyCommand("/gun/ion 6 12");
UImanager->ApplyCommand("/run/beamOn 1");
mrxak
December 9, 2020, 11:52am
5
I got the idea. Thank you for the explaination.