# Retracting primary particles from a root tree

**URL:** <https://root-forum.cern.ch/t/retracting-primary-particles-from-a-root-tree/51647>\
**Category:** Newbie\
**Tags:** tree, root\
**Created:** [September 21, 2022, 8:22pm UTC](https://root-forum.cern.ch/t/retracting-primary-particles-from-a-root-tree/51647 "2022-09-21T20:22:20Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![azinbeigi](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/a/919ad9/32.png) [@azinbeigi](https://root-forum.cern.ch/u/azinbeigi)\
**Post date:** [September 21, 2022, 8:22pm UTC](https://root-forum.cern.ch/t/retracting-primary-particles-from-a-root-tree/51647/1 "2022-09-21T20:22:20Z")

</div>

Hi everyone,

I have a question regarding my data that is stored in root trees. In my simulations, I start from electrons and I score bremsstrahlung photons somewhere at the outer layer of my x-ray tube. I get output root files from each simulation which is done in a computing cluster and then merge the root files into one combined root file to use it in further analysis and simulations. For a part of my calculations I need my x-ray tube efficiency. However, I do not know if all my simulations (I have more than 2000 of iterations each with 1000000 particles.) complete and all my root trees supposedly contain all the data from 1000000 initiated electrons, and because I score only the photons, I don’t have any apparent data that show me if all the simulations ran completely and I have the spectrum of photons generated from 1000000 electrons. I was wondering if you guys know of any way I could retract the number of particles started.

Thank you!

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [September 22, 2022, 9:02am UTC](https://root-forum.cern.ch/t/retracting-primary-particles-from-a-root-tree/51647/2 "2022-09-22T09:02:08Z")

</div>

I am not sure what you mean by “retract”. May be @pcanal has an idea.

---

<div class="post-metadata">

**Author:** ![yus](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/y/9fc348/32.png) [@yus](https://root-forum.cern.ch/u/yus)\
**Post date:** [September 22, 2022, 9:07am UTC](https://root-forum.cern.ch/t/retracting-primary-particles-from-a-root-tree/51647/3 "2022-09-22T09:07:59Z")

</div>

Retract = retrieve?

---

<div class="post-metadata">

**Author:** ![pcanal](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pcanal/32/12439_2.png) [@pcanal](https://root-forum.cern.ch/u/pcanal)\
**Post date:** [September 22, 2022, 7:21pm UTC](https://root-forum.cern.ch/t/retracting-primary-particles-from-a-root-tree/51647/4 "2022-09-22T19:21:33Z")

</div>

You seems to be saying: " I start from electrons … [looking for] the number of particles started." and also “all my root trees supposedly contain all the data from 1000000 initiated electrons” So it would be the total number of “initial” electrons in the TTree.

However, I do not know in your TTree there is also produced electrons. If there is no produced electrons then all you need to do is count the number of electrons. If there is produced electrons, you can get your answer only if there is some marker to distinguish the generated from the initial electrons.

---

<div class="post-metadata">

**Author:** ![azinbeigi](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/a/919ad9/32.png) [@azinbeigi](https://root-forum.cern.ch/u/azinbeigi)\
**Post date:** [September 22, 2022, 8:15pm UTC](https://root-forum.cern.ch/t/retracting-primary-particles-from-a-root-tree/51647/5 "2022-09-22T20:15:50Z")

</div>

Thank you, but I start from electrons and I score and save the generated photons by those electrons. What I store in the files are not the electrons. That is why I am wondering about retrieving.

Thank you

---

<div class="post-metadata">

**Author:** ![azinbeigi](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/a/919ad9/32.png) [@azinbeigi](https://root-forum.cern.ch/u/azinbeigi)\
**Post date:** [September 22, 2022, 8:17pm UTC](https://root-forum.cern.ch/t/retracting-primary-particles-from-a-root-tree/51647/6 "2022-09-22T20:17:21Z")

</div>

Yes. I mean I score the bremsstrahlung and characteristic photon phase spaces and save them in root trees, but not the primary electrons. Is there a way to be able to know how many electrons generated those spectra?

---

<div class="post-metadata">

**Author:** ![pcanal](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pcanal/32/12439_2.png) [@pcanal](https://root-forum.cern.ch/u/pcanal)\
**Post date:** [September 22, 2022, 8:44pm UTC](https://root-forum.cern.ch/t/retracting-primary-particles-from-a-root-tree/51647/7 "2022-09-22T20:44:56Z")

</div>

I am not sure, that depends on what information you actually stored in the file (but it sounds unlikely).
