Add root files only if selection cut

Hello,

I have a large number of root files, with various trees and histograms. One of the trees has an entry (branch) called weight which is always between 0 and 1.

I would like to add these files into one file, but select only those files for which weight < 1, so to remove those files which have any entries with weight==1.

Is there a relatively easy way of doing this?

Thank you,

Cristian

Hello Cristian,

You will need to iterate over the trees and check the content of their entries, and discard a particular file if its tree has an entry with weight==1.

Then for those files that fulfil your condition you could use hadd:

root.cern.ch/how/how-merge-histogram-files

Cheers,

Enric

Hello Enric,

Yes, you are right, I just did that over the weekend. I was just hoping there is an easy and quicker way to add files with selection cuts in hadd. It would be useful I think to add it sometime in the future. I actually found this link heplife.blogspot.co.uk/2012/12/b … trees.html but it works only with histograms, and not trees… Still there might be people who find it useful.

Best wishes,

Cristian