Possibility to limit the memory allocated for trees created in the reconstruction
authorshahoian <shahoian@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 19 Aug 2013 11:55:12 +0000 (11:55 +0000)
committershahoian <shahoian@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 19 Aug 2013 11:55:12 +0000 (11:55 +0000)
Use reco.SetTreeBuffSize(xxx) from the rec.C to change the memory in bytes
(by default: 30mb per tree)

STEER/STEER/AliReconstruction.cxx
STEER/STEER/AliReconstruction.h

index 4446c6c..fa8deb1 100644 (file)
@@ -317,6 +317,12 @@ AliReconstruction::AliReconstruction(const char* gAliceFilename) :
   fSspecie(0),
   fNhighPt(0),
   fShighPt(0),
+  //
+  fTreeBuffSize(30000000),
+  fMemCountESD(0),
+  fMemCountESDF(0),
+  fMemCountESDHLT(0),
+  //
   fUpgradeModule(""),
   fAnalysisMacro(),
   fAnalysis(0),
@@ -442,6 +448,12 @@ AliReconstruction::AliReconstruction(const AliReconstruction& rec) :
   fSspecie(0),
   fNhighPt(0),
   fShighPt(0),
+  //
+  fTreeBuffSize(rec.fTreeBuffSize),
+  fMemCountESD(0),
+  fMemCountESDF(0),
+  fMemCountESDHLT(0),
+  //
   fUpgradeModule(""),
   fAnalysisMacro(rec.fAnalysisMacro),
   fAnalysis(0),
@@ -615,6 +627,12 @@ AliReconstruction& AliReconstruction::operator = (const AliReconstruction& rec)
   fSspecie = 0;
   fNhighPt = 0;
   fShighPt = 0;
+  //
+  fTreeBuffSize = rec.fTreeBuffSize;
+  fMemCountESD = 0;
+  fMemCountESDF = 0;
+  fMemCountESDHLT = 0;
+  //
   fUpgradeModule="";
   fAnalysisMacro = rec.fAnalysisMacro;
   fAnalysis = 0;
@@ -2358,7 +2376,16 @@ Bool_t AliReconstruction::ProcessEvent(Int_t iEvent)
   
   }
   //
-  ftree->Fill();
+  Long64_t nbf;
+  nbf = ftree->Fill();
+  if (fTreeBuffSize>0 && ftree->GetAutoFlush()<0 && (fMemCountESD += nbf)>fTreeBuffSize ) { // default limit is still not reached
+    nbf = ftree->GetZipBytes();
+    if (nbf>0) nbf = -nbf;
+    else       nbf = ftree->GetEntries();
+    ftree->SetAutoFlush(nbf);
+    AliInfo(Form("Calling ftree->SetAutoFlush(%lld) | W:%lld T:%lld Z:%lld",
+                nbf,fMemCountESD,ftree->GetTotBytes(),ftree->GetZipBytes()));        
+  }
   AliSysInfo::AddStamp(Form("ESDFill_%d",iEvent), 0,0,iEvent);     
   //
   if (fWriteESDfriend) {
@@ -2372,8 +2399,18 @@ Bool_t AliReconstruction::ProcessEvent(Int_t iEvent)
     ftree->AutoSave("SaveSelf");
     if (fWriteESDfriend) ftreeF->AutoSave("SaveSelf");
   }
-    // write HLT ESD
-    fhlttree->Fill();
+  // write HLT ESD
+  
+  nbf = fhlttree->Fill();
+  if (fTreeBuffSize>0 && fhlttree->GetAutoFlush()<0 && (fMemCountESDHLT += nbf)>fTreeBuffSize ) { // default limit is still not reached
+    nbf = fhlttree->GetZipBytes();
+    if (nbf>0) nbf = -nbf;
+    else       nbf = fhlttree->GetEntries();
+    fhlttree->SetAutoFlush(nbf);
+    AliInfo(Form("Calling fhlttree->SetAutoFlush(%lld) | W:%lld T:%lld Z:%lld",
+                nbf,fMemCountESDHLT,fhlttree->GetTotBytes(),fhlttree->GetZipBytes()));        
+  }
+    
 
     // call AliEVE
     if (fRunAliEVE) RunAliEVE();
@@ -4359,7 +4396,16 @@ void AliReconstruction::WriteESDfriend() {
     fesdf->SetSkipBit(kTRUE);
   }
   //
-  ftreeF->Fill();
+  Long64_t nbf = ftreeF->Fill();
+  if (fTreeBuffSize>0 && ftreeF->GetAutoFlush()<0 && (fMemCountESDF += nbf)>fTreeBuffSize ) { // default limit is still not reached
+    nbf = ftreeF->GetZipBytes();
+    if (nbf>0) nbf = -nbf;
+    else       nbf = ftreeF->GetEntries();
+    ftreeF->SetAutoFlush(nbf);
+    AliInfo(Form("Calling ftreeF->SetAutoFlush(%lld) | W:%lld T:%lld Z:%lld",
+                nbf,fMemCountESDF,ftreeF->GetTotBytes(),ftreeF->GetZipBytes()));        
+  }
+  
 }
 
 //_________________________________________________________________
index 309f685..207149f 100644 (file)
@@ -91,6 +91,7 @@ public:
   void           SetLoadAlignData(const char* detectors) 
     {fLoadAlignData = detectors;};
 
+  void           SetTreeBuffSize(Long64_t sz=30000000) {fTreeBuffSize = sz;}
   //*** Global reconstruction flag setters
   void SetRunMultFinder(Bool_t flag=kTRUE) {fRunMultFinder=flag;};
   void SetRunVertexFinder(Bool_t flag=kTRUE) {fRunVertexFinder=flag;};
@@ -374,6 +375,12 @@ private:
   Int_t fNhighPt; //! Number of events, selected by IsHighPt 
   Int_t fShighPt; //! Number of events, sampled from fNhighPt
  
+  // Counters for SetAutoFlush configuration
+  Long64_t fTreeBuffSize;   //  allowed uncompressed buffer size per tree
+  Long64_t fMemCountESD;    //! accumulated ESD size before AutoSave 
+  Long64_t fMemCountESDF;   //! accumulated ESD size before AutoSave 
+  Long64_t fMemCountESDHLT; //! accumulated ESD size before AutoSave 
+  //
   // Upgrade detector reconstruction
   TString fUpgradeModule;
   Bool_t  fUpgradeMask[kNDetectors];
@@ -388,7 +395,7 @@ private:
   Int_t                fMaxVMEM;        //  max VMEM memory, MB
   static const char*   fgkStopEvFName;  //  filename for stop.event stamp
   //
-  ClassDef(AliReconstruction, 45)      // class for running the reconstruction
+  ClassDef(AliReconstruction, 46)      // class for running the reconstruction
 };
 
 #endif