# Analysing a specific dataset from geant4

**URL:** <https://root-forum.cern.ch/t/analysing-a-specific-dataset-from-geant4/57454>\
**Category:** Newbie\
**Created:** [December 8, 2023, 11:21am UTC](https://root-forum.cern.ch/t/analysing-a-specific-dataset-from-geant4/57454 "2023-12-08T11:21:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![utkarsh-2000](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/u/e47774/32.png) [@utkarsh-2000](https://root-forum.cern.ch/u/utkarsh-2000)\
**Post date:** [December 8, 2023, 11:21am UTC](https://root-forum.cern.ch/t/analysing-a-specific-dataset-from-geant4/57454/1 "2023-12-08T11:21:50Z")

</div>

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)

```auto
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.

---

<div class="post-metadata">

**Author:** ![Danilo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/danilo/32/34528_2.png) [@Danilo](https://root-forum.cern.ch/u/Danilo)\
**Post date:** [December 8, 2023, 2:09pm UTC](https://root-forum.cern.ch/t/analysing-a-specific-dataset-from-geant4/57454/2 "2023-12-08T14:09:36Z")

</div>

Hi,

Thanks for the question.  
I could propose that you also involve the G4 experts through the G4 Forum [https://geant4-forum.web.cern.ch/](https://geant4-forum.web.cern.ch/) for all the doubts relative to that particular tool.  
As far as ROOT is concerned, could you perhaps be more specific and ask a technical question, complemented by code, that we could answer in a helpful way? I am struggling in figuring out what is being actually asked.

Cheers,  
Danilo

---

<div class="post-metadata">

**Author:** ![utkarsh-2000](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/u/e47774/32.png) [@utkarsh-2000](https://root-forum.cern.ch/u/utkarsh-2000)\
**Post date:** [December 9, 2023, 2:42pm UTC](https://root-forum.cern.ch/t/analysing-a-specific-dataset-from-geant4/57454/3 "2023-12-09T14:42:20Z")

</div>

Thanks for your response,  
I am sorry for not being able to describe my query succinctly. I will get back here (and the Geant4 forum as well) with a more concise description of the issue.
