How to determine when the particle tracks end for information extraction

Hi,

I want to know how to determine if a track has ended in order to record total energy deposition of the track, the particle decay time and so on. I’ve tried two methods so far: one looks at the track ID - if the track ID of the current step is not equal to the previous step, it is said that the track has ended; the other one uses track status - if the status of the current track equals to fStopAndKill then the track has ended. Two methods produce completely different results and I’m very confused about which one is correct. (The second method gives me ~55% neutrons created in water being captured by nuclei but the first one doesn’t have neutrons captured at all.)

I’ve also made aware today the following:

Blockquote
Primary tracks have a track ID = 1, secondary tracks have an ID > 1. NOTE: Primary tracks of hadrons may “lose” their ID in some inelastic hadronic interactions, since they are considered as secondary products due to the fact that the interaction partners are indistinguishable. However, particles like electrons do not “lose” their ID. https://www.ge.infn.it/geant4/training/ptb_2009/day4/solutions_day4_partIII.html

I’m more confused after reading this. How do I work around this when I want to record the hadron information?

I thought my question is quite trivial but I can’t find answer anywhere on the internet…

Many thanks in advance,
Joanna

I want to know how to determine if a track has ended in order to record total energy deposition of the track, the particle decay time and so on.

The track status of “fStopAndKill” is a good one, if you’re doing this in a SteppingAction.

Comparing track ID’s is not a good solution, because a particular active track can be “paused” (put back on the stack) and a different track processed first, before going back to the previous one. This is a method used by processes which can generate very large numbers of secondaries, such as G4Cerenkov.

Another method would be for you to use a TrackingAction. PostUserTrackingAction is called for each track when that track is completed, but before it is deleted from memory.