I have one root file with multiple trees. I want to use MakeClass to generate a code skeleton that contains both trees. I cannot figure out how to do this.
yes I do want to use MakeClass and not MakeSelector nor TreeReader. There are many many reasons for this, I would like the answer addressing the use of MakeClass.
I have spent 3 hours looking through any permutation of MakeClass, multiple trees, chains, etc you can think of on this help forum before posting
this question is posted many times and a good portion of the answers are just links to TTree, TChain, and MakeClass, or say “use blah instead” without any further reasoning. I did spend awhile carefully going over those pages but do not see anything that will help me for this specific situation
I did try TChain & AddFriend, but MakeClass seems to only see what’s in the first chain and not what is in the friends of the chain, contrary to a few solutions in posts.
in my file.root I have a tree pulses and a tree rawData. From the ROOT prompt I have done:
As you noticed, MakeClass does not support friend per se. To handle you need to:
a) Call MakeClass for the first/main chain
b) Call MakeClass for the second/friend chain.
c) “Connect” the two resulting files.
One way to connect them is to have the first MakeClass header file to include the 2nd one and to add a new data member to the first MakeClass that is an object of the 2nd MakeClass type (or a pointer).
Then you would tweak the initialization routine to properly pass the friend chain to the 2nd MakeClass initialization. (for example by passing ((TFriendElement*)chain->GetListOfFriends()->At(0))->GetTree()) to the Init routine).
After that when calling LoadTree/GetEntry on the first/main chain, the corresponding entry in the friend should be loaded and the address set correctly.
Sorry for the delay, holidays & travel here in US.
There isn’t any error. It generates a .C and .h class just fine. The problem is only that using chains and friends doesn’t matter - the generated .h class only includes members of the first tree, not any vars from the chained-in friend trees.