Thanks a lot, @mkelsey, for your detailed explanation; it is very helpful for me.
Yes, correct. Sorry for my mistake.
Yes as you pointed out I think to sum the energies considering the direct and indirect parent-daughter associations is a bit tricky for me. I will try to follow some logic for that.
Here is a sample output for one event (number of primaries = 5)
ParentID: 1, TrackID: 7, t: 0.728001, Particle Name: e-, Energy: 0.0731583, Crystal: 4
ParentID: 1, TrackID: 7, t: 0.728148, Particle Name: e-, Energy: 0.156043, Crystal: 4
ParentID: 7, TrackID: 8, t: 0.728148, Particle Name: gamma, Energy: 9.298e-05, Crystal: 4
ParentID: 8, TrackID: 17, t: 0.72837, Particle Name: e-, Energy: 2.54e-05, Crystal: 4
ParentID: 8, TrackID: 16, t: 0.72837, Particle Name: e-, Energy: 9.26e-06, Crystal: 4
ParentID: 8, TrackID: 15, t: 0.72837, Particle Name: e-, Energy: 1.712e-05, Crystal: 4
ParentID: 8, TrackID: 14, t: 0.72837, Particle Name: e-, Energy: 8.63e-06, Crystal: 4
ParentID: 8, TrackID: 13, t: 0.72837, Particle Name: e-, Energy: 4.797e-05, Crystal: 4
ParentID: 8, TrackID: 12, t: 0.72837, Particle Name: e-, Energy: 4.86e-05, Crystal: 4
ParentID: 8, TrackID: 11, t: 0.72837, Particle Name: e-, Energy: 0.00097284, Crystal: 4
ParentID: 8, TrackID: 10, t: 0.72837, Particle Name: gamma, Energy: 4.864e-05, Crystal: 4
ParentID: 10, TrackID: 22, t: 0.728519, Particle Name: e-, Energy: 1.712e-05, Crystal: 4
ParentID: 10, TrackID: 21, t: 0.728519, Particle Name: e-, Energy: 1.712e-05, Crystal: 4
ParentID: 10, TrackID: 20, t: 0.728519, Particle Name: e-, Energy: 8.029e-05, Crystal: 4
ParentID: 10, TrackID: 19, t: 0.728519, Particle Name: e-, Energy: 1.608e-05, Crystal: 4
ParentID: 10, TrackID: 18, t: 0.728519, Particle Name: e-, Energy: 0.00966495, Crystal: 4
ParentID: 8, TrackID: 9, t: 0.72837, Particle Name: e-, Energy: 0.0172548, Crystal: 4
ParentID: 1, TrackID: 6, t: 0.64038, Particle Name: e-, Energy: 0.413284, Crystal: 4
I acknowledge that this question is not related to geant4 but mainly algorithmic. Do you have any suggestions/hints for doing this kind of summing? It will be very helpful.
At the moment, all I can think of is for each event
1.start with the smallest parentID, extract its event ID
2. Loop through the other parents ID and nested loop through the Track ID’s having same parent ID.
But I am clearly confused as how to control (exit) these statements for the loop.
Thank You