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:
TFile *f = new TFile("file.root");
- if it is 100% impossible pigs will fly to do this with MakeClass, would you please explain why?
_ROOT Version: v6.08.00
Sorry this seems to be such an underwhelming experience… Could you post the error you get / what happens versus what you would expect to happen?
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.
aha, thank you Philippe! This sounds easy and I will try it. Today is a non-teaching coding day!
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.