I am simulating a 60keV photon pencil beam passing normal through a 10cm water cube and I am scoring the photon fluence entering another cube a few cm behind it. In order to discriminate between primary photons and secondaries I tried to use the GetParentID() and the GetTrackID() methods in the SteppingAction class however they always give me zero and one respectively which indicates that there are no secondary photons and all of them are primaries. I access the methods by means of
The energies and positions of the detected photons tell me that I do have secondaries. However, the two methods cannot discriminate them from primaries. Is this a particular to having photon primaries? If so, how can I get the “generation index” of each photon?
This is strange. Can you try killing secondaries in the water phantom and see if this reduces the fluence in the cube? The difference being the primary and secondary photons in the detector. I don’t know if this will circumvent the issue and give you a temporary solution.
If you have figured out the issue, I would be happy to know what may have caused the problem.
MyTrackingAction::PostUserTrackingAction(const G4Track* aTrack) I use the
G4TrackingManager::GimmeSecondaries() method, it returns only electrons for Compton scattering events. So if a photon undergoes 5 Compton scattering events and ends up at the detector, it is still considered a primary photon.
So I ended up updating that information manually using the
TrackingAction classes in combination with the
SteppingAction class. Specifically, I created a
G4int to count the generation index and avoided changing the
ParentID to also avoid potentially messing the kernel.