Possibility to limit the memory allocated for the output AOD tree.
authorshahoian <shahoian@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 19 Aug 2013 13:18:00 +0000 (13:18 +0000)
committershahoian <shahoian@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 19 Aug 2013 13:18:00 +0000 (13:18 +0000)
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
STEER/AOD/AliAODHandler.h

index b10e87e..c481f60 100644 (file)
@@ -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()));        
+  }
 }
 
 //______________________________________________________________________________
index a69c88e..fc9b74f 100644 (file)
@@ -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