Hi,
> MCchain.GetEntries() returns 0
This should not happen in well formed TTrees. It indicates that the TChain things that either none of the file exist or all the file that do exist contains empty trees.
Since you also have:
> jetInfoBranch[*]->GetEntries() return the number of entries of the last file...
I think that what happened is that there is indeed data of the file but instead of calling
TTree::Fill, TBranch::Fill have been called. Calling TBranch::Fill tell the branch to put
data in itself but do not inform the TTree object that it has been filled.
I.e. in your writing code replace:
branch1->Fill();
branch2->Fill();
with
tree->Fill();
Cheers,
Philippe.
PS. There are other ways to work around this issues, however they are harder to use.
-----Original Message-----
From: owner-roottalk@pcroot.cern.ch
[mailto:owner-roottalk@pcroot.cern.ch]On Behalf Of Alain Romeyer
Sent: Wednesday, May 26, 2004 7:57 AM
To: roottalk@pcroot.cern.ch
Subject: [ROOT] question concerning TChain
Dear ROOTers,
I'm trying to chain root files with the following comands (with root 3.10):
TChain MCchain("Calib Tree","Calib Tree");
const int size = 2;
TBranch* jetInfoBranch[size];
MCchain.Add(filename1);
MCchain.Add(filename2);
MCchain.Add(filename3);
MCchain.Add(filename4);
MCchain.Add(filename5);
MCchain.Add(filename6);
MCchain.Add(filename7);
MCchain.Add(filename8);
MCchain.Add(filename9);
MCchain.Add(filename10);
MCchain.SetBranchStatus("*",0);
MCchain.SetBranchStatus("bJetsBranch",1);
MCchain.SetBranchStatus("OtherJetsBranch",1);
MCchain.SetBranchAddress("bJetsBranch",&jetInfo);
MCchain.SetBranchAddress("OtherJetsBranch",&jetInfo2);
cout << "MC chain entries : " << (MCchain.GetBranch("bJetsBranch"))->GetEntries() << endl;
jetInfoBranch[0] = MCchain.GetBranch("bJetsBranch");
cout << "Jet entries : " << jetInfoBranch[0]->GetEntries() << endl;
jetInfoBranch[1] = MCchain.GetBranch("OtherJetsBranch");
cout << "Jet 2 entries : " << jetInfoBranch[1]->GetEntries() << endl;
cout << "MC chain entries : " << MCchain.GetEntries() << endl;
[/i]
Unfortunatelly the (MCchain.GetBranch("bJetsBranch"))->GetEntries() or MCchain.GetEntries() returns 0 and the jetInfoBranch[*]->GetEntries() return the number of entries of the last file...
so where is my error ?
Best regards,
Alain
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Alain Romeyer
Service de Physique des Particules Elémentaires
19 Avenue Maistriau Tél : +32 (0) 65.37.33.93
B-7000 MONS Belgium Email : alain.romeyer@umh.ac.be
-----------------------------------------
http://membres.lycos.fr/aromeyer
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:08 MET