I’d like to use a TCut inside an event loop but it looks there is no easy/simple way. Few info below:
I can’t use a fChain->Draw(“>>eventlist”,aCut) because I need all events and then do different things if an event pass or not the cut
I found a suggestion in a very old thread (more than 20 years ago) here [0] and it’s ok but the execution time increase a lot and I wonder if it depends on the complexity of the cut or it’s just not an efficient solution.
I know RDataFrame could be an option but it looks to me that because I need to calculate many quantities and, depending on the success or not of the cut, do so many things, is not really a good option.
So I wonder if there is a different approach because I don’t want to implement 20 or more if in my loop and it would be great if there is a more simple and above all efficient way to just check if an event pass a cut or not.
Just to give you some number… if I use the solution given in [0] above, for 200K loops it takes 180s while if I copy & paste the TCut expression taken from the GetTitle method (it’s a string longer than 400 characters), it takes less than 1 sec… so the solution given in [0] is definitely not useful. So back to the original question: is there any other method?
do you mind elaborating a bit on what exactly you are trying to achieve? I take it you have a TTree (or a TChain) and you want to select its entries that satisfy a TCut expression? And what do you mean exactly by
I can’t use a fChain->Draw(">>eventlist",aCut) because I need all events
I have a TChain and as you correctly understood, I’d like to do something like this:
TCut aCut("some expression");
for (Long64_t i = 0 ; i < fChain->GetEntries() ; ++i) {
fChain->GetEntry(i);
if(aCut) { do something... }
else { do something else... }
}
When there is no else condition I could simply use fChain->Draw(">>eventlist",aCut) and get a list of events which pass the aCut cut and loop on the list. That’s easy, but if I have the else condition what can I do?