I have problem in reading multiple files having same tree name.
I would like to read three root files, each consist of 20 thousand event and total of 60000 event.
when I used ch->Add(“filename1”)
ch->Add(“filename2”)
ch->Add(“filename3”)
but it is reading only first file and start plotting the histograms, not reading the event from next two files.
Hi,
That’s odd. When I do anything like this I use:
TChain * myChain = new TChain("TreeName");
myChain->Add("/somewhere/myfile1.root");
myChain->Add("/somewhere/myfile2.root");
myChain->Add("/somewhere/myfile3.root");
for (Int_t i=0;i<(Int_t)myChain->GetEntries();i++)
{
myChain->GetEntry(i);
//here is the code that does something with each entry in a loop
}
[quote]I am using fchain to get entries in the loop.[/quote]Which loop and using with value. Most likely your are passing to fChain->GetEntry( value ), a value that must be passed to fChain->GetTree()->GetEntry( value ) … (because it is the entry number within the local tree rather than the entry number within the chain).