# Make sort file for entries in one detector

**URL:** <https://root-forum.cern.ch/t/make-sort-file-for-entries-in-one-detector/43817>\
**Category:** Newbie\
**Created:** [March 4, 2021, 8:37am UTC](https://root-forum.cern.ch/t/make-sort-file-for-entries-in-one-detector/43817 "2021-03-04T08:37:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zhassulan](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/zhassulan/32/20693_2.png) [@Zhassulan](https://root-forum.cern.ch/u/Zhassulan)\
**Post date:** [March 4, 2021, 8:37am UTC](https://root-forum.cern.ch/t/make-sort-file-for-entries-in-one-detector/43817/1 "2021-03-04T08:37:59Z")

</div>

Hi. I have the root file (443mev.root) with 18 detector where name of detectors e1, e2,…,e9 in the front and c1, c2, … c9 in the back position. And I’d like to make such a sorting file that would make it possible to separate the entries that hit only in the e5 detector and not included in the others. And then draw e5 with the already sorted entries. I’ve some idea in sort.C, but it doesn’t give me what I want. Could you please help me?[sort.C](https://root-forum.cern.ch/uploads/short-url/m1NR1LwdzjZcMC2zRPvazJ33EeN.C) (2.1 KB) [443mev.root](https://root-forum.cern.ch/uploads/short-url/9FVIGkZxuihv0SIc356ZZGh6FCY.root) (899.4 KB)

---

<div class="post-metadata">

**Author:** ![jalopezg](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/jalopezg/32/25844_2.png) [@jalopezg](https://root-forum.cern.ch/u/jalopezg)\
**Post date:** [March 4, 2021, 6:21pm UTC](https://root-forum.cern.ch/t/make-sort-file-for-entries-in-one-detector/43817/2 "2021-03-04T18:21:17Z")

</div>

Hi @Zhassulan,

A quick review of the provided `sort.C` file reveals several issues. Particularly, I don’t understand the following conditional statement -that doesn’t match the description in your post-.

```auto
     if(e5=e1||e2||e3||e4||e6||e7||e8||e9) Event->Fill(e5);

```

Maybe you meant something of the form:

```auto
     if(e5 && !e1 && !e2 && !e3 && !e4 && !e6 && !e7 && !e8 && !e9) /* ... */

```

Other than that, you could have used the array that you define in line 31, instead of individual variables of type `Double_t`. Additionally, you are creating the `ofile` TFile, which is never used.

Regarding the histogram, I recommend to take a look at the tutorials [here](https://root.cern.ch/doc/master/group __tutorial__ hist.html).

In any case, this could be better accomplished using RDataFrame. I am inviting @swunsch to this thread; he might give you some directions for that.

Cheers,  
J.

---

<div class="post-metadata">

**Author:** ![Zhassulan](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/zhassulan/32/20693_2.png) [@Zhassulan](https://root-forum.cern.ch/u/Zhassulan)\
**Post date:** [March 4, 2021, 7:15pm UTC](https://root-forum.cern.ch/t/make-sort-file-for-entries-in-one-detector/43817/4 "2021-03-04T19:15:31Z")

</div>

Thank you @jalopezg for your reply  
In fact, I need a code that will allow me to make an anti-compton. For example, when a gamma with some amount of energy enters at the e5 detector and is reflected in any other decector, these events need to be removed from the e5 already created leaf. But those gammas that were completely absorbed by the e5 detector and the gammas that got into e5 but left it in empty space should be recorded in a separate histogram.

It seems ridiculous 😅. But I’ve explained the situation as clearly as I can.  
No matter how hard I try, I don’t have enough knowledge to implement this project.

 ![anti-compton](https://root-forum.cern.ch/uploads/default/original/3X/c/e/ced94e778f86e80b9feafdf3d33905ece8c0bd46.png)

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [March 4, 2021, 7:22pm UTC](https://root-forum.cern.ch/t/make-sort-file-for-entries-in-one-detector/43817/5 "2021-03-04T19:22:35Z")

</div>

So, the condition proposed by @jalopezg seems fine for your use case. It will fire only when `e5 != 0` and all other `e{12346789} == 0`.

BTW. @jalopezg The “`Event`” histogram is saved in the “`ofile`”.
