It seems that you want to get the beginning point of gamma ray from the source.
As far as I know, “parentID” is the track ID of the creator track.
And the primary particles have 0 of parentID.
Please refer to G4GeneralParticleSource.cc in GEANT4 source to understand about gps.
I want to suggest that you should use “/tracking/verbose 1” in your macro file to see if gammas really have parentID as 0. Or you can print out by your StackingAction source.
If I simulate the radioactive decay, the parentID can’t be 0 because gammas are produced by radioactive decay…then the parentID==0 is the ion.
Indeed, I printed the parentID of the gamma
if (track->GetCreatorProcess()) {
G4cout <<"Creator process is " << track->GetCreatorProcess() << G4endl;
}
else {
G4cout << "No creator process type "<< G4endl;
}
and the track->GetCreatorProcess() works as you can see in the attached file
in which he says to check both the creatorProcess and the GetProcessName…then I tried to print
if (track->GetCreatorProcess()) {
G4cout <<"Creator process is " << track->GetCreatorProcess() << G4endl;
if (track->GetCreatorProcess()->GetProcessName()){
G4cout <<"Process Name is is " << track->GetCreatorProcess()->GetProcessName() << G4endl;
}
else {
G4cout << "No process name "<< G4endl;
}
}
else {
G4cout << "No creator process type "<< G4endl;
}
and it works without crashing…
G4WT0 > Process Name is is phot
G4WT1 > Creator process is 000001DA0A0B8030
G4WT0 > Creator process is 000001DA0C585450
G4WT1 > Process Name is is RadioactiveDecayBase
G4WT0 > Process Name is is phot
G4WT1 > Creator process is 000001DA0A0B8030
G4WT0 > Creator process is 000001DA0C585450
G4WT1 > Process Name is is RadioactiveDecayBase
G4WT0 > Process Name is is phot
G4WT1 > Creator process is 000001DA0A0B8030
G4WT0 > Creator process is 000001DA0C585450
G4WT0 > Process Name is is phot
G4WT1 > Process Name is is RadioactiveDecayBase
G4WT0 > No creator process type
but it prints "RadioactiveDecayBase " instead of “RadioactiveDecay”
Are there differences between "RadioactiveDecayBase " and “RadioactiveDecay”?
The process name changed in different releases as the developers made decisions about how to organize the code. It makes writing your application more complicated