Dear Rooters,
I’m dealing with a already solved ROOT problem, I guess, but I’m getting that problem again. I’m using ROOT 5.28/00d and a class which derives from TSelector, to loop over events in an input TTree. When writing my TTree into a TFile ( in Terminate() ) I get a “std::bad_alloc”. I attached some pieces of my code - I don’t know what parts you exactly you would need to help me out.
Header:
class FastWenuEoverP : public TSelector {
public :
...
private :
TTree t_etat_tot;
...
Implementation:
void FastWenuEoverP::SlaveBegin(TTree * tree)
{
t_etat_tot.SetNameTitle("treeAll","Wenu");
t_etat_tot.Branch("EoverEtruth", &m_EoverEtruth);
t_etat_tot.Branch("PtruthoverP", &m_PtruthoverP);
t_etat_tot.Branch("EoverP", &m_EoverP);
t_etat_tot.Branch("el_Phi", &m_el_Phi);
....
}
void FastWenuEoverP::Terminate()
{
std::cout << "---- Terminate()" << std::endl;
std::cout << "---- create File" << std::endl;
TFile* file = new TFile("/tmp/fat/test.root","RECREATE");
t_etat_tot.FlushBaskets();
std::cout << "---- write TTree " << std::endl;
t_etat_tot.Write();
std::cout << "---- write File" << std::endl;
file->Write();
std::cout << "---- close TTree" << std::endl;
file->Close();
delete file;
std::cout << "---- Terminate() --- THE END" << std::endl;
}
And the Ouput, after finishing the event loop and calling Terminate()
---- Terminate()
---- create File
---- write TTree
terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
It seems to me a memory problem and depending on the size of the TTree I want to write to the file, the less Branches the Tree has and the less events I loop over the less is the chance this to happen. I am really a bit lost, since I read somewhere that this issue should be solved vor version greater than 5.27.
What could be checked to find a solution ?
Thanks a lot,
Florian