Merging many root files together with the same ntuple

Hello ,
I need to merge more than 1000 files together to be one root file to be able to work with. is there any way to use hadd without typing all the input files?
and if there is a away please can you give me an example
for ex. i have Data2016C_103.root till Data2016C_900.root

thanks,

Mai

Hi,
Use Form inside the Add comand, it works like printf
And you cam use a for


for(int i=0; i<1000;i++)
ch->Add(Form("Data2016C_%d.root",i));

Cheers
Stefano

You could create a single file using:

hadd Data2016C.root `ls Data2016C_*.root`

But maybe it would be more convenient to use a TChain instead.

I am sorry i didnt get where to write that.

Stefano proposes to use a TChain to process all files.
See, for example:

ROOT User’s Guide -> Trees -> Chains

ROOT Primer -> File I/O and Parallel Analysis -> N-tuples in ROOT -> Processing N-tuples Spanning over Several Files

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