Loop over all hits

Hello, I use this macro

calotb21.cpp (4.2 KB)

to select particles moving trough the x range -210<x<-160 on the subdetector 37. Now I need one more cut…i.e. I need to select particles moving through -210<x<-160 on the subdetector 37 and also hitting the subdetector 51.
I can’t simply add

int subnumbHorsa=51; //HORSA
TCut subHorsa = TString::Format(“subdet==%d”, subnumbHorsa).Data();
t->Draw(henestring, Idp && Ipart && sub && xmincut && xmaxcut && subHorsa);

because it would find events simultaneously hitting the subdetectors 37 and 51 (that is impossible)…I know it would need a loop over the all the hits…but how can I do it?

Please read tips for efficient and successful posting and posting code

ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided

That goes beyond what TTree::Draw() was designed for. Time for you to move to RDataFrame! And btw that’s why we recommend against the use of TTree::Draw() for analyses: you cannot grow and analysis out of simple expressions with TTree::Draw(), but you can do that with a simple RDataFrame statement. It also gives you multi-threading, much more maintainable code, etc. Let us know if you get stuck somewhere.

Hello @Axel , is there any example to follow?

Hello @axel is there any example to follower?

-------- Messaggio originale --------

Certainly! We have wonderful tutorials at $ROOTSYS/tutorials/dataframe/, for C++ and Python!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.