Adding histograms from all root files in a directory


I have a directory containing all large number of root files, each of which contains the same set of histograms. What I’d like to do is merge all these files into one. I found the macro hadd.C, which adds the histograms together very nicely, but I was wondering if there’s a way to use wildcards to build the list of files? I know, for example, that using a TChain I can do ch->Add("*.root"); Is there something analogous that works here?

Thanks a lot!

Hi Heather,

Use the hadd utility in $ROOTSYS/bin
hadd -f result.root xxx*.root


1 Like