Possibility to modify the tree buffer size (Marco)
authorhristov <hristov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 19 Aug 2013 16:37:02 +0000 (16:37 +0000)
committerhristov <hristov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 19 Aug 2013 16:37:02 +0000 (16:37 +0000)
STEER/AOD/AliAODExtension.cxx
STEER/AOD/AliAODExtension.h

index 49ee0f8..65d4d0a 100644 (file)
@@ -29,7 +29,8 @@ ClassImp(AliAODExtension)
 //______________________________________________________________________________
 AliAODExtension::AliAODExtension() : TNamed(), 
 fAODEvent(0), fTreeE(0), fFileE(0), fNtotal(0), fNpassed(0), 
-fSelected(kFALSE), fRepFiMap(0x0), fRepFiList(0x0), fEnableReferences(kTRUE), fObjectList(0x0)
+fSelected(kFALSE), fTreeBuffSize(30000000), fMemCountAOD(0),
+fRepFiMap(0x0), fRepFiList(0x0), fEnableReferences(kTRUE)
 {
   // default ctor
 }
@@ -43,6 +44,8 @@ fFileE(0),
 fNtotal(0), 
 fNpassed(0),
 fSelected(kFALSE),
+fTreeBuffSize(30000000),
+fMemCountAOD(0),
 fRepFiMap(0x0),
 fRepFiList(0x0),
 fEnableReferences(kTRUE),
@@ -139,7 +142,7 @@ Bool_t AliAODExtension::FinishEvent()
   fNtotal++;
   if (!IsFilteredAOD()) {
     fAODEvent->MakeEntriesReferencable();
-    fTreeE->Fill();
+    FillTree();
     return kTRUE;
   }  
   // Filtered AOD. Fill only if event is selected.
@@ -154,12 +157,34 @@ Bool_t AliAODExtension::FinishEvent()
     repfi->ReplicateAndFilter(*fAODEvent);
   }
   fNpassed++;
-  fTreeE->Fill();
+  FillTree();
   fSelected = kFALSE; // so that next event will not be selected unless demanded
   return kTRUE;
 }  
 
 //______________________________________________________________________________
+void AliAODExtension::FillTree() 
+{
+  //
+  //   Fill AOD extension tree and check AutoFlush settings
+  //
+  
+  Long64_t nbf = fTreeE->Fill();
+  
+  // Check buffer size and set autoflush if fTreeBuffSize is reached
+  if (fTreeBuffSize>0 && fTreeE->GetAutoFlush()<0 && 
+      (fMemCountAOD += nbf)>fTreeBuffSize ) { // default limit is still not reached
+    nbf = fTreeE->GetZipBytes();
+    if (nbf>0) nbf = -nbf;
+    else       nbf = fTreeE->GetEntries();
+    fTreeE->SetAutoFlush(nbf);
+    AliInfo(Form("Calling fTreeE->SetAutoFlush(%lld) | W:%lld T:%lld Z:%lld", 
+                nbf,fMemCountAOD,fTreeE->GetTotBytes(),fTreeE->GetZipBytes()));  
+    
+  }
+}
+
+//______________________________________________________________________________
 Bool_t AliAODExtension::Init(Option_t *option)
 {
   // Initialize IO.
index a6bbe54..4f19d59 100644 (file)
@@ -50,6 +50,7 @@ public:
   void                 SelectEvent(Bool_t flag=kTRUE)  {fSelected = flag;}
   void                 SetEvent(AliAODEvent* event);
   void                 SetOutputFileName(const char* fname) {TNamed::SetName(fname);}
+  void                 SetTreeBuffSize(Long64_t sz=30000000) {fTreeBuffSize = sz;}
   Bool_t               TerminateIO();
   
   void Print(Option_t* opt="") const;
@@ -70,6 +71,7 @@ public:
   void EnableReferences() { fEnableReferences=kTRUE; }
   
   void AddAODtoTreeUserInfo();
+  void FillTree();
   
 private:
   AliAODExtension(const AliAODExtension&);             // Not implemented
@@ -82,14 +84,16 @@ private:
   Int_t                    fNtotal;                 //! Number of processed events
   Int_t                    fNpassed;                //! Number of events that passed the filter
   Bool_t                   fSelected;               //! Select current event for filtered AOD's. Made false at event start.
+  Long64_t                 fTreeBuffSize;            // Requested buffer size for AOD tree
+  Long64_t                 fMemCountAOD;             // Number of bytes filled in tree (accumulates until requested bytes reached)
   
   TMap*                    fRepFiMap; // which branch(es) to filter out / and or replicate
   TList*                   fRepFiList; // list of unique filter/replicator
   
   Bool_t                   fEnableReferences; // whether or not to enable the TRefTable branch
   TList*                   fObjectList; //! internal list of which objects to keep 
-  
-  ClassDef(AliAODExtension, 2) // Support for extra AOD branches in a separate AOD file
+
+  ClassDef(AliAODExtension, 3) // Support for extra AOD branches in a separate AOD file
 };
 
 #endif