I have a root file with a TTree and branches. I pass it through a python code where I apply cuts on some parameters (param1, param2,…) of the root file and other parameters computed by the python code ( cpar1, cpar2,…) in the following way
loop events:
if (param1 > cut1):
continue
if (param2 > cut2):
continue
if(cparm1 > cut3):
continue
…
I’d like to know if there’s a good way to create a new root file similar to the old one with same branches and same names without cut events.
You would apply your cuts with Filter and save your new ROOT file that has the same branches but less events by means of Snapshot. We are happy to guide you through that process if necessary.
Thank you for your reply, I finally managed to solve it getting each value “by hand” from tree input in the loop events and Fill a new tree in a new root file after the cuts ( like that https://wiki.physik.uzh.ch/cms/root:example_ttree ). Which was really tedious because there were many branches.
However, your answer looks interesting, I’ll keep it.