From b952ebda22e6b363846f02bf249a31909e87afbb Mon Sep 17 00:00:00 2001 From: richterm Date: Wed, 22 Oct 2008 14:22:39 +0000 Subject: [PATCH] handling of non-std ESD content --- HLT/rec/AliHLTEsdManagerImplementation.cxx | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/HLT/rec/AliHLTEsdManagerImplementation.cxx b/HLT/rec/AliHLTEsdManagerImplementation.cxx index c5649319545..5ac70e35075 100644 --- a/HLT/rec/AliHLTEsdManagerImplementation.cxx +++ b/HLT/rec/AliHLTEsdManagerImplementation.cxx @@ -281,9 +281,11 @@ int AliHLTEsdManagerImplementation::AliHLTEsdListEntry::WriteESD(AliESDEvent* pS fpFile=new TFile(fName, "RECREATE"); fpTree=new TTree("esdTree", "Tree with HLT ESD objects"); + fpTree->SetDirectory(0); fpEsd=new AliESDEvent; if (fpEsd) { fpEsd->CreateStdContent(); + *fpEsd=*pSrcESD; if (fpTree) { fpEsd->WriteToTree(fpTree); } @@ -303,7 +305,37 @@ int AliHLTEsdManagerImplementation::AliHLTEsdListEntry::WriteESD(AliESDEvent* pS } if (iResult>=0 && pSrcESD) { + int nofObjects=fpEsd->GetList()->GetEntries(); *fpEsd=*pSrcESD; + if (nofObjects!=fpEsd->GetList()->GetEntries()) { + // The source ESD contains object not present in the target ESD + // before. Those objects will not be written to the tree since + // the branch layout has been created earlier. + // Create new tree with the additional branches, copy the entries + // of the current tree into the new tree, and continue. + TTree* pNewTree=new TTree("esdTree", "Tree with HLT ESD objects"); + pNewTree->SetDirectory(0); + AliESDEvent* readESD=new AliESDEvent; + readESD->CreateStdContent(); + readESD->ReadFromTree(fpTree); + fpEsd->Reset(); + fpEsd->WriteToTree(pNewTree); + HLTDebug("cloning tree with %d entries", fpTree->GetEntries()); + for (int event=0; eventGetEntries(); event++) { + fpTree->GetEntry(event); + *fpEsd=*readESD; + pNewTree->Fill(); + fpEsd->Reset(); + } + fpFile->Close(); + delete fpFile; + delete readESD; + delete fpTree; + fpFile=new TFile(fName, "RECREATE"); + fpTree=pNewTree; + *fpEsd=*pSrcESD; + HLTDebug("new ESD with %d objects", fpEsd->GetList()->GetEntries()); + } fpTree->Fill(); iResult=1; // indicate tree to be written } -- 2.43.0