Energy deposition per particle

I am fairly new to Geant4, I have designed a calorimeter as a sensitive detector with several crystals.
I am saving the energy deposit in each crystal (this process is based on basic example B5).

My question is, when generating two primary particles, is it possible to save energy deposits separately for each of them? Meaning, making two hit collections, where in one of them will be saved all the energy deposits from secondaries that came from the first initial particle and in the second collection - from the second initial particle.

I understand, that that’s not how real detector operates, but it would be very useful for me. I didn’t find any relevant information in the Geant4 guides or on this forum, apologies if it was already discussed.

Thank you for any help!

Hi Polina,

This should be possible. I believe the first and second initial particles should have a unique parent ID. I think the B5 example has a sensitive detector with access to each step. For each step where there is an energy deposition, access the track from the step. Then record the parent ID of the track. I think that by tagging the parent ID for each energy deposition you can tally up the total energy deposited by the first and second primary particle, given that they should have two unique parent IDs.

There might be a more elegant way of doing this, but this is likely how I would start tackling your problem. Let me know if this works for you. If you need any additional assistance please feel free to message me.

Happy coding!


Hello Charles,

Thank you very much for the advice!

I am having trouble with it, though, as my understanding is that parent ID is mostly to show whether it is a primary particle (parent ID = 0) or secondary. From what I understood all the primary particles whould have the same parent id which equals 0 and, thus, would be indistinguishable in such way. Is this correct?

Thank you for your help,