Append one tree to another

Can I append one tree to another without copying the tree contents?

You might be looking for TChain:

TChain c("treename");
c.Add("file1.root");
c.Add("file2.root");
// use it as a TTree, it will loop over the trees in both files transparently

Hope this helps!

No, it doesn’t help as my trees are in the same file, have different names but have the same structure.

You can add two trees from the same file, as per TChain::Add docs:

TChain c("treename");
c.Add("file.root/tree1");
c.Add("file.root/tree2");
// use `c` as you would use a TTree
1 Like

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