Combining different trees in one root file

Hello;
i have two root files, each has a single tree.
i.e. file1.root…tree1
file2.root…tree2

now i want to combine these trees in a single root file. means one root file containg these two separate trees.

best regards

Hello,

ROOT comes with the binary hadd, which can combine ROOT files. You can use hadd -h to see the command line syntax.

Cheers,
Jakob

1 Like

Thanks for your response.
can you please show me with an example.

For instance

hadd combined.root file1.root file2.root

(Note that the output file comes first and then all the input files)

1 Like

when write this command in root prompt i got

There is something wrong with your ROOT installation, I think. Please post your ROOT version, OS version, and how you installed ROOT.

1 Like

my root version = 6.19/02
using Ubuntu 19.10

Can you open the ROOT prompt with root? And root-config --features, root-config --config?

1 Like

yes i can open ROOT prompt by typing root

with root-config --config it gives

and

with
root-config --config
it gives

That looks all rights. Let’s see if the problem is related to hadd or to the specific trees. Can you run

hadd test.root https://root.cern.ch/files/LHCb002_data_v1.root

If that works, could you make a copy of the ROOT files available that you’d like to merge?

image

Actually the files are very heavy. can you please provide me your email id so that i will share with you there?

thanks

I cannot reproduce any problem when merging the two files. The trees in the two files have the same layout and the same name, which means that in the merged ROOT file there is a single tree that contains the entries of both input trees.

To make merging work on your node, I’d suggest to install the pre-compiled binary distribution of our latest 6.24 release.

Solved.
Thanks sir

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