From 4fa368856bb9971a2a7d727096dfffc5fc28cc5e Mon Sep 17 00:00:00 2001 From: shahoian Date: Mon, 19 Aug 2013 13:18:00 +0000 Subject: [PATCH] Possibility to limit the memory allocated for the output AOD tree. Use aodhnadler->SetTreeBuffSize(xxx) from the task configuration to change the memory in bytes (by default 30mb is set at tree creation) --- STEER/AOD/AliAODHandler.cxx | 16 +++++++++++++++- STEER/AOD/AliAODHandler.h | 7 +++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/STEER/AOD/AliAODHandler.cxx b/STEER/AOD/AliAODHandler.cxx index b10e87ecd46..c481f605d47 100644 --- a/STEER/AOD/AliAODHandler.cxx +++ b/STEER/AOD/AliAODHandler.cxx @@ -75,6 +75,8 @@ AliAODHandler::AliAODHandler() : fNeedsDimuonsBranchReplication(kFALSE), fNeedsHMPIDBranchReplication(kFALSE), fAODIsReplicated(kFALSE), + fTreeBuffSize(30000000), + fMemCountAOD(0), fAODEvent(NULL), fMCEventH(NULL), fTreeA(NULL), @@ -110,6 +112,8 @@ AliAODHandler::AliAODHandler(const char* name, const char* title): fNeedsDimuonsBranchReplication(kFALSE), fNeedsHMPIDBranchReplication(kFALSE), fAODIsReplicated(kFALSE), + fTreeBuffSize(30000000), + fMemCountAOD(0), fAODEvent(NULL), fMCEventH(NULL), fTreeA(NULL), @@ -599,6 +603,7 @@ void AliAODHandler::CreateTree(Int_t flag) fTreeA = new TTree("aodTree", "AliAOD tree"); fTreeA->Branch(fAODEvent->GetList()); if (flag == 0) fTreeA->SetDirectory(0); + fMemCountAOD = 0; } //______________________________________________________________________________ @@ -606,7 +611,16 @@ void AliAODHandler::FillTree() { // Fill the AOD Tree - fTreeA->Fill(); + Long64_t nbf = fTreeA->Fill(); + if (fTreeBuffSize>0 && fTreeA->GetAutoFlush()<0 && (fMemCountAOD += nbf)>fTreeBuffSize ) { // default limit is still not reached + nbf = fTreeA->GetZipBytes(); + if (nbf>0) nbf = -nbf; + else nbf = fTreeA->GetEntries(); + fTreeA->SetAutoFlush(nbf); + AliInfo(Form("Calling fTreeA->SetAutoFlush(%lld) | W:%lld T:%lld Z:%lld", + nbf,fMemCountAOD,fTreeA->GetTotBytes(),fTreeA->GetZipBytes())); + } + } //______________________________________________________________________________ diff --git a/STEER/AOD/AliAODHandler.h b/STEER/AOD/AliAODHandler.h index a69c88e208a..fc9b74ff9d7 100644 --- a/STEER/AOD/AliAODHandler.h +++ b/STEER/AOD/AliAODHandler.h @@ -104,7 +104,7 @@ class AliAODHandler : public AliVEventHandler { void SetInputTree(TTree* /*tree*/) {;} void SetMCEventHandler(AliMCEventHandler* mcH) {fMCEventH = mcH;} // For internal use void StoreMCParticles(); // Store MC particles, only to be called from AliAnalyisTaskMCParticleFilter - + void SetTreeBuffSize(Long64_t sz=30000000) {fTreeBuffSize = sz;} Bool_t HasExtensions() const; void Print(Option_t* opt="") const; @@ -137,6 +137,9 @@ class AliAODHandler : public AliVEventHandler { Bool_t fNeedsDimuonsBranchReplication; // Flag for Dimuons replication Bool_t fNeedsHMPIDBranchReplication; // Flag for HMPID replication Bool_t fAODIsReplicated; // Flag true if replication as been executed + // Counters for SetAutoFlush configuration + Long64_t fTreeBuffSize; // allowed uncompressed buffer size per tree + Long64_t fMemCountAOD; //! accumulated AOD size before AutoSave AliAODEvent *fAODEvent; //! Pointer to the AOD event AliMCEventHandler *fMCEventH; //! Pointer to mc event handler needed not to depend on the manager TTree *fTreeA; //! tree for AOD persistency @@ -145,7 +148,7 @@ class AliAODHandler : public AliVEventHandler { TObjArray *fExtensions; // List of extensions TObjArray *fFilters; // List of filtered AOD's - ClassDef(AliAODHandler, 7) + ClassDef(AliAODHandler, 8) }; #endif -- 2.39.3