One Root file, two trees

Hi!

I have the following problem:
I have a root file with two trees with similar branches (MyRecoTree and MyTruthTree).
I tried to create two chains :

TChain *tree = new TChain("MyRecoTree");
TChain *truth_tree = new TChain("MyTruthTree");
tree->Add("1.root");
truth_tree->Add("1.root");
truth_tree->SetBranchAddress("trk_pz", &mc_trk_pz);
tree->SetBranchAddress("trk_pz", &trk_pz);
tree->AddFriend("MyTruthTree");
for (int ientries = 0; ientries < nentries; ientries++)
    {
      tree->LoadTree(ientries);
      if (ientry < 0) break;
      if (tree->GetEntry(ientries) == 0) break;
      //Do stuff
    }

That works fine, but my program runs three times over the one file… Do I use the “AddFriend” correctly?

Thanks,

Tobias

solved

Rather than:tree->AddFriend("MyTruthTree");you should usetree->AddFriend(MyTruthTree);

Cheers,
Philippe.