Hi,
I need to read more than one data file (all of them with the same structure), so I would like to use TChain, but I have some problems.
What I usually do with only one file is:
TFile fIn = TFile::Open(“rfio:/castor/file.root”);
TTree * events = dynamic_cast<TTree>( fIn->Get( “Events” ) );
TBranch * solsBranch;
solsBranch = events->GetBranch(“TtSemiEvtSolutions_solutions__TtEventReco.obj” );
vector sols;
solsBranch -> SetAddress( & sols );
and then loop over the events:
int nev = events->GetEntries();
for( int ev = 0; ev < nev; ++ ev ) {
solsBranch -> GetEntry( ev );
cout << “sols.size” << " " << sols.size() << endl;
}
Now I tried to translate the previous commands using TChain, but the sols vector is always empty (sols.size=0). This is what I wrote:
TChain *fIn = new TChain(“Events”);
fIn->Add(“rfio:/castor/file.root”);
vector sols;
fIn->SetBranchAddress( “TtSemiEvtSolutions_solutions__TtEventReco.obj”, & sols );
int nev = fIn->GetEntries();
for( int ev = 0; ev < nev; ++ ev ) {
fIn -> GetEntry( ev );
cout << “sols.size” << " " << sols.size() << endl;
}
Any idea of what I am doing wrong?
I also tried using
fIn -> SetBranchStatus("*", 0);
fIn -> SetBranchStatus(“TtSemiEvtSolutions_solutions__TtEventReco.obj”, 1);
after SetBranchAddress, without success.
Ah, I am using Root 5.12.00e on a SLC3 machine.
Thanks a lot for any hint.
Cheers,
Laura