Hi,
I produced a class with the MakeClass function.
In the Init(TTree tree) I read some histograms from a root file and I store
them into a
vector<TH1D> refHisto*
In my main; to use this class I just do something like:
TChain* bckgT = new TChain("TreeB");
bckgT->AddFile("bckg.root");
TChain* signT = new TChain("TreeS");
signT->AddFile("sign.root");
// BCKG
Boosted *bckg = new Boosted(bckgT);
bckg->Loop();
// SIGN
Boosted *sign = new Boosted(signT);
sign->Loop();
delete bckg;
delete sign;
return 0;
I am compiling it with g++
the first problem is the usual:
Warning in TDirectoryFile::Append: Replacing existing TH1: histo0 (Potential memory leak).
that appears when I call the second constructor but I guess there is nothing I can really do since I am really creating two object with the same
name. They will be stored in a public member of the class so I don’t think I have a memory leak.
The real problem is that it crashes at the end of the main (after the delete sign;) with this error
#10 0x0025e4bd in TString::TString(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) () from /afs/cern.ch/atlas/software/releases/17.0.4/LCGCMT/LCGCMT_60d/InstallArea/i686-slc5-gcc43-opt/lib/libCore.so
#11 0x002e06b2 in ROOT::TGenericClassInfo::CreateRuleSet(std::vector<ROOT::TSchemaHelper, std::allocator<ROOT::TSchemaHelper> >&, bool) () from /afs/cern.ch/atlas/software/releases/17.0.4/LCGCMT/LCGCMT_60d/InstallArea/i686-slc5-gcc43-opt/lib/libCore.so
#12 0x002e0b49 in ROOT::TGenericClassInfo::GetClass() () from /afs/cern.ch/atlas/software/releases/17.0.4/LCGCMT/LCGCMT_60d/InstallArea/i686-slc5-gcc43-opt/lib/libCore.so
#13 0x02fa76c4 in TProfile::Class() () from /afs/cern.ch/atlas/software/releases/17.0.4/LCGCMT/LCGCMT_60d/InstallArea/i686-slc5-gcc43-opt/lib/libHist.so
#14 0x02dc0c37 in TProfile::IsA() const () from /afs/cern.ch/atlas/software/releases/17.0.4/LCGCMT/LCGCMT_60d/InstallArea/i686-slc5-gcc43-opt/lib/libHist.so
#15 0x00238474 in TObject::InheritsFrom(TClass const*) const () from /afs/cern.ch/atlas/software/releases/17.0.4/LCGCMT/LCGCMT_60d/InstallArea/i686-slc5-gcc43-opt/lib/libCore.so
#16 0x010270c5 in TDirectoryFile::Save() () from /afs/cern.ch/atlas/software/releases/17.0.4/LCGCMT/LCGCMT_60d/InstallArea/i686-slc5-gcc43-opt/lib/libRIO.so
#17 0x0102711b in TDirectoryFile::Save() () from /afs/cern.ch/atlas/software/releases/17.0.4/LCGCMT/LCGCMT_60d/InstallArea/i686-slc5-gcc43-opt/lib/libRIO.so
#18 0x0102230b in TDirectoryFile::Close(char const*) () from /afs/cern.ch/atlas/software/releases/17.0.4/LCGCMT/LCGCMT_60d/InstallArea/i686-slc5-gcc43-opt/lib/libRIO.so
#19 0x0103e7d4 in TFile::Close(char const*) () from /afs/cern.ch/atlas/software/releases/17.0.4/LCGCMT/LCGCMT_60d/InstallArea/i686-slc5-gcc43-opt/lib/libRIO.so
#20 0x0103eb84 in TFile::~TFile() () from /afs/cern.ch/atlas/software/releases/17.0.4/LCGCMT/LCGCMT_60d/InstallArea/i686-slc5-gcc43-opt/lib/libRIO.so
#21 0x002a4c2d in TCollection::GarbageCollect(TObject*) () from /afs/cern.ch/atlas/software/releases/17.0.4/LCGCMT/LCGCMT_60d/InstallArea/i686-slc5-gcc43-opt/lib/libCore.so
#22 0x002abbd0 in TList::Delete(char const*) () from /afs/cern.ch/atlas/software/releases/17.0.4/LCGCMT/LCGCMT_60d/InstallArea/i686-slc5-gcc43-opt/lib/libCore.so
#23 0x00254c81 in TROOT::~TROOT() () from /afs/cern.ch/atlas/software/releases/17.0.4/LCGCMT/LCGCMT_60d/InstallArea/i686-slc5-gcc43-opt/lib/libCore.so
#24 0x01a084b9 in __cxa_finalize () from /lib/i686/nosegneg/libc.so.6
#25 0x002020c4 in __do_global_dtors_aux () from /afs/cern.ch/atlas/software/releases/17.0.4/LCGCMT/LCGCMT_60d/InstallArea/i686-slc5-gcc43-opt/lib/libCore.so
#26 0x0068d810 in _fini () from /afs/cern.ch/atlas/software/releases/17.0.4/LCGCMT/LCGCMT_60d/InstallArea/i686-slc5-gcc43-opt/lib/libCore.so
#27 0x0098a956 in _dl_fini () from /lib/ld-linux.so.2
#28 0x01a08209 in exit () from /lib/i686/nosegneg/libc.so.6
#29 0x019f1ea4 in __libc_start_main () from /lib/i686/nosegneg/libc.so.6
#30 0x0804b8a1 in _start ()
it is clear that it’s a problem of deleting the TFile I opened. I tried different solutions, i.e. deleting the file in the descructor but it didn’t help.
How am I supposed to delete the file?
I have never had this problem when doing this in macros.
cheers,
delo