#include "TTree.h"
#include "TClass.h"
#include "TObject.h"
+#include "TObjectTable.h"
/** ROOT macro for the implementation of ROOT specific class methods */
ClassImp(AliHLTEsdManager)
AliHLTEsdManager::~AliHLTEsdManager()
{
// see header file for class documentation
+ for (unsigned int i=0; i<fESDs.size(); i++) {
+ if (fESDs[i]) {
+ delete fESDs[i];
+ }
+ fESDs[i]=NULL;
+ }
}
AliHLTEsdManager::AliHLTEsdListEntry* AliHLTEsdManager::Find(AliHLTComponentDataType dt) const
// see header file for class documentation
AliHLTEsdListEntry* pEntry=NULL;
for (unsigned int i=0; i<fESDs.size(); i++) {
- if (fESDs[i]==dt) {
- pEntry=const_cast<AliHLTEsdListEntry*>(&fESDs[i]);
+ if (fESDs[i] && *(fESDs[i])==dt) {
+ pEntry=const_cast<AliHLTEsdListEntry*>(fESDs[i]);
}
}
return pEntry;
if (pESD) {
AliHLTEsdListEntry* entry=Find(dt);
if (!entry) {
- AliHLTEsdListEntry newEntry(dt);
+ AliHLTEsdListEntry* newEntry=new AliHLTEsdListEntry(dt);
fESDs.push_back(newEntry);
}
if (tgtesd) {
// see header file for class documentation
}
-AliHLTEsdManager::AliHLTEsdListEntry::AliHLTEsdListEntry(const AliHLTEsdListEntry& src)
- :
- AliHLTLogging(),
- fName(src.fName),
- fpFile(src.fpFile),
- fpTree(src.fpTree),
- fpEsd(src.fpEsd),
- fDt(src.fDt)
-{
- // copy constructor copies everything including pointers
-}
-
-AliHLTEsdManager::AliHLTEsdListEntry& AliHLTEsdManager::AliHLTEsdListEntry::operator=(const AliHLTEsdListEntry& src)
-{
- // assignment operator copies everything including pointers
- fName=src.fName;
- fpFile=src.fpFile;
- fpTree=src.fpTree;
- fpEsd=src.fpEsd;
- fDt=src.fDt;
- return *this;
-}
-
AliHLTEsdManager::AliHLTEsdListEntry::~AliHLTEsdListEntry()
{
// see header file for class documentation
if (fpTree) {
+ fpTree->GetUserInfo()->Clear();
delete fpTree;
fpTree=NULL;
}
- if (fpEsd) {
+ // due to the Root garbage collection the ESD object might already be
+ // deleted since the pTree->GetUserInfo()->Add(pESD) adds the ESD object to
+ // an internal list which is cleaned when the tree is deleted
+ if (fpEsd && gObjectTable->PtrIsValid(fpEsd)) {
delete fpEsd;
- fpEsd=NULL;
}
+ fpEsd=NULL;
if (fpFile) {
fpFile->Close();
fpTree=new TTree("esdTree", "Tree with HLT ESD objects");
if (!fpTree) {
iResult=-ENOMEM;
+ } else {
+ fpTree->SetDirectory(0);
}
}
if (fpTree && iResult>=0) {
fpEsd=new AliESDEvent;
if (fpEsd) {
fpEsd->CreateStdContent();
- fpEsd->WriteToTree(fpTree);
+ fpTree->GetUserInfo()->Add(fpEsd);
} else {
iResult=-ENOMEM;
}
// used for filling
TTree* dummy=new TTree("dummy","dummy");
if (dummy) {
+ /*
+ dummy->SetDirectory(0);
pESD->WriteToTree(dummy);
dummy->Fill();
+ dummy->GetUserInfo()->Add(pESD);
fpEsd->ReadFromTree(dummy);
dummy->GetEvent(0);
+ */
+ fpEsd->WriteToTree(fpTree);
fpTree->Fill();
+ dummy->GetUserInfo()->Clear();
delete dummy;
} else {
iResult=-ENOMEM;