Remnants after fKillTrackAndSecondaries

I would like to simulate the interaction of photon (511 keV) with the plastic scintillator. In plastic, as we know most likely the incoming photon will transfer part of its energy to the electron and gets scattered. I want to terminate the event and don’t consider the contribution if the deposited energy in the first interaction by the primary particle is less than say 100 keV. For that, I am killing the tracks and secondaries using fKillTrackAndSecondaries just after the check.

However, after applying that there is still some contribution left ( for < 100 keV) and visible in energy deposition spectra.
If there some global way so that one can apply such a cut directly. Any help will be highly appreciated.


if you need to kill primary particle, then you can use G4UserSteppingAction where corresponding flag may be set for the G4TRack.

If you need filter out a secondary particle, then you need implement this in G4UserStackingAction.

An example of Stacking action is in $G4INSTALL/examples/extended/electromagnetic/TestEm5