Error: Can't call TChain::GetBranchAddress("dth",&dth) in current scope eldth2.cpp:37:
Possible candidates are...
(in TChain)
(in TTree)
(class G__CINT_ENDL)27103488
*** Interpreter error recovered ***
Does anyone know how to solve it? Or is there the other way to get data by TChain? I really want to know.
My ROOT version is 5.34/36.
for (unsigned int iFile=0; iFile<FileList.size(); ++iFile)
{
m_f = TFile::Open(FileList[iFile].c_str());
TChain *mychain = new TChain("mychain");
mychain->Add("FileList[iFile].c_str()");
}
TChain::mychain->GetBranchAddress("dth",&dth);
std::cout<< *dth << std::endl;
But it didn’t work out…
Error in <TFile::Open>: no url specified
Error: Can't call TChain::GetBranchAddress("dth",&dth) in current scope eldth2.cpp:37:
Possible candidates are...
(in TChain)
(in TTree)
*** Interpreter error recovered ***
but this is not exactly what my snippet does … For example you again request a file called “FileList[iFile].c_str()” rather than running that code. Perhaps you can use directly my code?
Sorry, I forgot to change the code in brackets…
Then…
TChain *mychain = new TChain("mychain");
for (unsigned int iFile=0; iFile<FileList.size(); ++iFile){
mychain->Add("FileList[iFile].c_str()");
}
TChain::mychain->GetBranchAddress("dth",&dth);
std::cout<< *dth << std::endl;
m_f->Close();
I got:
Processing eldth2.cpp...
Error: Can't call TChain::GetBranchAddress("dth",&dth) in current scope eldth2.cpp:37:
Possible candidates are...
(in TChain)
(in TTree)
*** Interpreter error recovered ***
Thanks. I replaced it.
But when it runs std::cout<< dth << std::endl;
I got: 0. (there should have 45 numbers.) I still have something wrong on this…
And I’m confused…I want to get every data in in every entry in every root file (branch’dth’ is a 9X5 array and I have 32 root files). How can I do that without putting mychain->SetBranchAddress("dth",&dth); std::cout<< dth << std::endl; inside the loop?