Hello everyone,

I am trying to analyze the following dataset using ROOT. I agree that this is not directly related to ROOT, but if someone has gone through a similar procedure, are there some examples for newbies? It will be of great help.

Brief description: It is data from one event in geant4. The various rows represent tracks in the event.

The parentID represents the trackid of the parent of a given track. The trackID lists the trackID of the current track. The Energy is the energy of the track.

I am trying to sum the energies under the parents and all their daughters, granddaughters, etc.

Specifically, suppose for `ParentID 1`

, I am trying to sum energy in `TrackID=7 `

+ energies in `TrackID=8`

(daughter) + energies in `TrackID=[10,11...17] (`

granddaughters) + energies in `TrackID=[19,20..22]`

(great granddaughters)

```
ParentID: 1, TrackID: 7, t: 0.728001, Particle Name: e-, Energy: 0.0731583
ParentID: 1, TrackID: 7, t: 0.728148, Particle Name: e-, Energy: 0.156043
ParentID: 7, TrackID: 8, t: 0.728148, Particle Name: gamma, Energy: 9.298e-05
ParentID: 8, TrackID: 17, t: 0.72837, Particle Name: e-, Energy: 2.54e-05
ParentID: 8, TrackID: 16, t: 0.72837, Particle Name: e-, Energy: 9.26e-06
ParentID: 8, TrackID: 15, t: 0.72837, Particle Name: e-, Energy: 1.712e-05
ParentID: 8, TrackID: 14, t: 0.72837, Particle Name: e-, Energy: 8.63e-06
ParentID: 8, TrackID: 13, t: 0.72837, Particle Name: e-, Energy: 4.797e-05
ParentID: 8, TrackID: 12, t: 0.72837, Particle Name: e-, Energy: 4.86e-05
ParentID: 8, TrackID: 11, t: 0.72837, Particle Name: e-, Energy: 0.00097284
ParentID: 8, TrackID: 10, t: 0.72837, Particle Name: gamma, Energy: 4.864e-05
ParentID: 10, TrackID: 22, t: 0.728519, Particle Name: e-, Energy: 1.712e-05
ParentID: 10, TrackID: 21, t: 0.728519, Particle Name: e-, Energy: 1.712e-05
ParentID: 10, TrackID: 20, t: 0.728519, Particle Name: e-, Energy: 8.029e-05
ParentID: 10, TrackID: 19, t: 0.728519, Particle Name: e-, Energy: 1.608e-05
ParentID: 10, TrackID: 18, t: 0.728519, Particle Name: e-, Energy: 0.00966495
ParentID: 8, TrackID: 9, t: 0.72837, Particle Name: e-, Energy: 0.0172548,
ParentID: 1, TrackID: 6, t: 0.64038, Particle Name: e-, Energy: 0.413284
```

I have this data in separate vectors corresponding to each column above. I have some sketch of going about this to loop through the smallest ParentID and then nested loop for the various daughters and granddaughtersâ€¦etc. However, I am confused about how to control the entry and exit of the loops, as to where and when exactly the search should stop.

I am a new user of C and ROOT, and any help/hint regarding this will be highly appreciated.

Thanks a lot for your time and efforts. Please let me know in case of any clarification.