Hi,
When I try to add a root file named as “xxx.root.2” to a TChain, I get an error later: “Error in TFile::TFile: xxx.root.2/tree does not exist”. However, it works if I create an soft link of the file, but name it as “xxx.root”.
Is it true that TChain::Add does not work for root files with a name not ended with “.root”? Or it’s due to some mistakes in my code? Thanks.
Dongliang
Update:
Seems the problem appears in root6 (6.06.02-x86_64-slc6-gcc49-opt) but not in 5.34.25-x86_64-slc6-gcc48-opt.
Dongliang, do you give the tree name at the end of the filename?
Unfortunately I believe there is a regression; there is a form with this suffix that isn’t accepted now. If you confirm that is indeed how you need to use it then I think this will explain the problem you’ve discovered. I’ll fix it in a subsequent release. As a workaround for now you could either
give the tree name in the TChain constructor, not as a part of each filename, e.g.
TChain c(“tree”);
c.Add(“xxx.root.2”);
or use TChain::AddFile, giving the tree name as the third argument, e.g.
I’m seeing a similiar issue in case the directory name of the file i want to add contains “.root”. Unfortunately in this case i can’t solve it by using the function without treename.
Example:
root -l -q $ROOTSYS/tutorials/tree/ntuple1.C
mv hsimple.root hsimple.root.2
mkdir hsimple.root
mv hsimple.root.2 hsimple.root
root -l
TChain* c = new TChain()
(TChain *) 0x2f13fb0
root [1] c->AddFile("hsimple.root/hsimple.root.2")
(int) 1
root [2] c->Print()
******************************************************************************
*Chain : : hsimple.root *
******************************************************************************
SysError in <TFile::ReadBuffer>: error reading from file hsimple.root (Is a directory)
Error in <TFile::Init>: hsimple.root failed to read the file type data.
This seems to work at first, but if i actually do something with the TChain i get the same error:
root [0] TChain* c = new TChain("ntuple")
(TChain *) 0x20f8ae0
root [1] c->AddFile("hsimple.root/hsimple.root.2")
(int) 1
root [2] c->Print()
******************************************************************************
*Chain :ntuple : hsimple.root *
******************************************************************************
SysError in <TFile::ReadBuffer>: error reading from file hsimple.root (Is a directory)
Error in <TFile::Init>: hsimple.root failed to read the file type data.
root [3] c->Draw("px")
SysError in <TFile::ReadBuffer>: error reading from file hsimple.root (Is a directory)
Error in <TFile::Init>: hsimple.root failed to read the file type data.