Merge trees parallelly

I have a ROOT file containing two trees with different branches inside but same size (i.e. same number of events). Now I would like to merge these trees in such a way that I have all the branches from the former two in just one tree with the same event size as before. Everything I tried so far only resulted in the methods wanting to add up the events and giving error messages due to the mismatch of branch contents.

Thanks for helping!

We do not have a parallel merge facility as you request. But it is better to use TTree::AddFriend and use your 2 Trees as if they were one single Tree.


Ok thanks, but in fact I already tried this… Maybe I’m still doing something wrong: I want to use the MakeClass method to produce C++ code to loop over all events and have the variables from all branches of the two trees available. When I add one tree as a friend to the other and use MakeClass on the former one, the variables from the friend tree’s branches are still not available.


You need to create a MakeClass skeleton for the friend tree and tie it to the main tree’s MakeClass.


Hi again,
sorry but I don’t exactly know what you mean with “tie it to the main tree’s MakeClass”?