For some calculations, I would want to track only selected particles (gammas and neutrons in my case). I have been trying to look into the different ways of doing this, and I am not quite sure what is the best way to go. These are the things I looked into:
- Using particle cuts.
- Not suitable, because cuts can only be applied to gammas, electrons, positrons and protons.
- Creating a custom process similar to
G4NeutronKiller
.- This would work perfectly, but it would have to be attached to all potential particles which should not be tracked.
- Killing tracks in
G4UserTrackingAction::PreUserTrackingAction()
.- This in principle works, but there are two issues:
- It requires a
const_cast
, which suggests that this is not the right way to do it:
const_cast<G4Track*>(track)->SetTrackStatus(fStopAndKill);
- The remaining energy is not deposited (pretty much a non-issue, but there’s one thing I wanted to check).
- It requires a
- This in principle works, but there are two issues:
Is this correct? Any other option I am missing? Does anyone have other suggestions?