Hi,
I have two root files which have same tree name and same branch name (only one branch). Most of the leaves inside the branches in both root files have same name except few of them.
I am processing both root files in one script file. If I access leaves with the same name in both files then there is no problem. But if I try to access the leaves with different name then one of the leaves can’t be accessed. Here is a simplified code:
int main(int argc, char** argv)
{
readChain1();
cout << "--------------------------------------" << endl;
readChain2();
}
void readChain1()
{
TChain *chain = new TChain("cmeEvent");
chain->Add("test1.root");
double area;
TBranch *b_cme_area;
chain->SetMakeClass(1);
chain->SetBranchStatus("*", 0);
chain->SetBranchStatus("area", 1);
chain->SetBranchAddress("area", &area, &b_cme_area);
for(int i=0; i<chain->GetEntries(); i++) {
chain->GetEntry(i, 0);
if(TMath::IsNaN(area)) continue;
cout << area << endl;
}
delete chain;
chain = 0; b_cme_area = 0;
}
void readChain2()
{
TChain *chain = new TChain("cmeEvent");
chain->Add("test2.root");
double eccentPart;
TBranch *b_cme_eccentPart;
chain->SetMakeClass(1);
chain->SetBranchStatus("*", 0);
chain->SetBranchStatus("eccentPart", 1);
chain->SetBranchAddress("eccentPart", &eccentPart, &b_cme_eccentPart);
for(int i=0; i<chain->GetEntries(); i++) {
chain->GetEntry(i, 0);
if(TMath::IsNaN(eccentPart)) continue;
cout << eccentPart << endl;
}
delete chain;
chain = 0; b_cme_eccentPart = 0;
}
~
Here readChain2() can’t access the leaf, it prints 6.9144e-310 which is not because I have checked it by opening the file with browser. Could anybody point me out where I am doing wrong?
Thanks.