Make sort file for entries in one detector

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 (2.1 KB) 443mev.root (899.4 KB)

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

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

Maybe you meant something of the form:

     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.

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.

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 :sweat_smile:. 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.

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”.