I have a code that was build on a skeleton of makeClass using a ROOT file with a single Tree.
Recently the ROOT files has been expanded with the addition of an additional Tree. I’d like to be able to access both Trees from my current code. The way I understand this, it is possible to do this using the AddFriend() method. Everything “seems” to be working fine until I try to access the second tree variables. Although no warning or crash occurs the variable values are not correct but instead have their initialisation values (=0). This implies that their values are not picked up by SetBranchAddress() etc… Here’s a summary of what I am doing:
Chain* primaryChain = new TChain(“TDirectoryName1/TreeName1”);
TChain* friendChain = new TChain(“TDirectoryName2/TreeName2”);
primaryChain->AddFriend(friendChain);
I have simplified the problem by starting from scratch with makeClass and a single ROOT file.
A minimum working example is found here [1] with all files included.
i think i saw a post where it is mentioned that you create two makeClass and then copy/paste by hand. If you look at the code this is exactly what I did. In particular, the branch addresses of the second Tree are added by hand to the first makeClass. Then I add the friendship between the two trees. Is that correct?
can you please be more specific. That line (L 393 in TreeReaderReco.h) is already there. So if you I must disable it, i just tested it and the result is the same. i.e. the “friend” tree branches are not read but instead have their initialised values. Unless I misunderstood something?
As I said above, I have put a minimal working code on lxplus.
So when you loop over the tree (.x run.cc) I print branches values from both trees. Those from the primary tree have correct values and those from the friends tree have their initialised values => their values are not read correctly (or at all). Commenting out
fChain->SetMakeClass(1);
make no difference.
Can you access the code i have put on lxplus? I can also attach it here if it is preferred.