# Creating c++ file to extract data from root output

**URL:** <https://root-forum.cern.ch/t/creating-c-file-to-extract-data-from-root-output/41240>\
**Category:** Newbie\
**Created:** [September 1, 2020, 12:54pm UTC](https://root-forum.cern.ch/t/creating-c-file-to-extract-data-from-root-output/41240 "2020-09-01T12:54:44Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nkuba1982](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/n/dbc845/32.png) [@Nkuba1982](https://root-forum.cern.ch/u/Nkuba1982)\
**Post date:** [September 1, 2020, 12:54pm UTC](https://root-forum.cern.ch/t/creating-c-file-to-extract-data-from-root-output/41240/1 "2020-09-01T12:54:44Z")

</div>

Hello  
I have a root file from simulation, and wanted a C++ file to extract from it several information including number of coincidences, trues coincidences, scatter and random coincidences. What energy between gamma1 and 2 experience more scatters, the energy deposited in a Crystal number x and its Neighbors crystals?  
But also to track the photons that scatters and those passing the material without scatter

* * *

---

<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 1, 2020, 3:41pm UTC](https://root-forum.cern.ch/t/creating-c-file-to-extract-data-from-root-output/41240/2 "2020-09-01T15:41:32Z")

</div>

> [@Nkuba1982](#):
>
> I have a root file from simulation,

you mean you have TTree in a ROOT file ?

---

<div class="post-metadata">

**Author:** ![Nkuba1982](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/n/dbc845/32.png) [@Nkuba1982](https://root-forum.cern.ch/u/Nkuba1982)\
**Post date:** [September 1, 2020, 6:15pm UTC](https://root-forum.cern.ch/t/creating-c-file-to-extract-data-from-root-output/41240/3 "2020-09-01T18:15:25Z")

</div>

Yes, a TTree

---

<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 2, 2020, 2:27pm UTC](https://root-forum.cern.ch/t/creating-c-file-to-extract-data-from-root-output/41240/4 "2020-09-02T14:27:12Z")

</div>

Does TTree::Draw help in that case ?

---

<div class="post-metadata">

**Author:** ![Nkuba1982](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/n/dbc845/32.png) [@Nkuba1982](https://root-forum.cern.ch/u/Nkuba1982)\
**Post date:** [September 2, 2020, 6:03pm UTC](https://root-forum.cern.ch/t/creating-c-file-to-extract-data-from-root-output/41240/5 "2020-09-02T18:03:43Z")

</div>

I did not understand.

But as I said, i have a root file ( 2 Hits folders, 2 Singles folders, 2 Coincidence folders, one delay and optical folder), and wanted to extract from root file the number of singles which are in coincidence (prompt, random, true and scatter)…and bse i am having two gamma lines, i want to know how much of the photons form gamma 1 reach the detector without scatter and for gamma 2 as well.

---

<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 3, 2020, 6:57am UTC](https://root-forum.cern.ch/t/creating-c-file-to-extract-data-from-root-output/41240/6 "2020-09-03T06:57:18Z")

</div>

may be @pcanal has an idea.

---

<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 8, 2020, 5:14pm UTC](https://root-forum.cern.ch/t/creating-c-file-to-extract-data-from-root-output/41240/7 "2020-09-08T17:14:37Z")

</div>

What did you try so far?
