Ways of adding friend trees

Hello,

I have a chain of trees and a separate tree that I want to add as a friend to the chain (or vice versa). If I do this in the following way:

TChain * chain = new TChain("h11");
chain->Add("signal_*.root");
// add the other tree as friend of the chain
chain->AddFriend("f11", "ana060912.root");

the “h11” tree I obtain works fine both when using TTree::Draw and when manually iterating through the tree with a script.

However, I noticed that if I reverse the order and try to add the chain to the f11 tree in the following way:

TFile * f = new TFile("ana060912.root", "READ");
TTree * f11 = (TTree *)f->Get("f11");

TChain * chain = new TChain("h11");
chain->Add("signal_*.root");
// add the chain as friend of the f11 tree
f11->AddFriend(chain);

then in case of manually reading the f11 tree with TTree::SetBranchAddress and GetEntry, values in some of the branches of the chain are not loaded correctly, although the same branches read with TTree::Draw are correct.

Moreover, if I change the above code so that I don’t use a TFile explicitly:

// creating a chain with a sigle file - not to use a TFile and TFile::Get()
TChain * f11 = new TChain("f11");
f11->Add("ana060912.root");

TChain * chain = new TChain("h11");
chain->Add("signal_*.root");
// add the chain as friend of the f11 tree
f11->AddFriend(chain);                                                          

then again the tree is read properly in all ways.
Do you have an idea what is the reason for this strange behaviour in the second case? Am I doing something wrong?

Thank you in advance!

Hi,

[quote]Do you have an idea what is the reason for this strange behaviour in the second case? Am I doing something wrong?[/quote]not really. I recommend you report this issue via JIRA with a reproducer.

Thanks,
Philippe.