I’m using ROOT 5.26b or 5.26e or 5.28h to read datafiles that contains 3 TTree called “T1”,“T2” and “T3”
I use to make them friends:
pT1->AddFriend("T2"); //or pT1->AddFriend(pT2) after getting T2 from file
pT1->AddFriend("T3"); //or pT1->AddFriend(pT3) after getting T3 from file
I noticed that on some new datafile the friendship relation is ALREADY SAVED in the root file (In other words, I discovered that the friendship relation is preserved when TTree are written in the root file).
For such files I can just TFile::Get(“T1”) and pT1 has access to T2 and T3 variables and pT1->GetListOfFriends()->Print() correctly reports that T2 and T3 are friends.
Now the weird thing is when I make a TChain of several root files with the above mentioned structure:
TChain ch1("T1") ;
The chain get access to T2 and T3 variables without specifying again the friendship, but:
- ch1.GetListOfFriends() is null.
- ch1.Print(“all”) printout T1 variables, then T2, T3, then AGAIN T3 and finally again T2
Is it intended? Is it affecting the way Draw makes plots?
What happen if I anyway specify again the friendship:
TChain ch2("T2") ; TChain ch3("T3") ;
ch2.Add("file1.root") ; ch3.Add("file1.root") ; //etc
Thanks a lot for your clarification.
[quote]Is it intended?
[/quote]Not really, but I can see why it would be that way. (The TChain itself has no direct friends).
[quote]Is it affecting the way Draw makes plots?[/quote]No, it should not be affected.
[quote]What happen if I anyway specify again the friendship:[/quote]The TTrees would then be friend twice leading to possible name ambiguity.
thanks for your reply.
I’d like to ask more on this:
What does name ambiguity imply? It is especially important to me understand if, e.g. with a TTree::Draw() or TTree::Scan(), just the first matching branch is taken and values are not processed twice, in particular when branches contain indexed values like vector or vector<vector>.
I made some tests and it seems that no duplications are made, but I’d like to ask for a confirmation also from experts since I didn’t try all possible varexpr/cut combinations.
Thanks a lot
[quote]What does name ambiguity imply? It is especially important to me understand if, e.g. with a TTree::Draw() or TTree::Scan(), just the first matching branch is taken and values are not processed twice[/quote]That is correct.
If you do MakeProxy on the chain with automatically added friends, these friends does not appear in the generated class, while if you add them manually, they appear.