add a robust run number guessing scheme that works also on the lego train where the...
authormkrzewic <mkrzewic@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 4 Nov 2013 17:24:46 +0000 (17:24 +0000)
committermkrzewic <mkrzewic@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 4 Nov 2013 17:24:46 +0000 (17:24 +0000)
PWGPP/TPC/AliTaskConfigOCDB.cxx
PWGPP/TPC/AliTaskConfigOCDB.h

index 4d069f0..bc8170a 100644 (file)
@@ -19,6 +19,7 @@
 #include <TFile.h>
 #include <TGeoGlobalMagField.h>
 #include "TGeoManager.h"
+#include <TRegexp.h>
  
 #include "AliAnalysisManager.h"
 #include "AliGeomManager.h"
@@ -173,6 +174,31 @@ void AliTaskConfigOCDB::Exec(Option_t* /*option*/)
 //______________________________________________________________________________
 void AliTaskConfigOCDB::Terminate(Option_t *)
 {
-// Initialize CDB also in Terminate
-//   CreateOutputObjects();
+  // Initialize CDB also in Terminate
+  //   CreateOutputObjects();
 }
+
+Int_t AliTaskConfigOCDB::guessRunNumber(TString path)
+{
+  //guess the runnumber from datapath
+  //works also on the LEGO train where the data path looks like this:
+  //workdir/testdata/__alice__data__2010__LHC10b__000114924__ESDs__pass2_root_archive_AliESDs_2/10000114924018.100/root_archive.zip
+  TObjArray* a = path.Tokenize("/_");
+  TRegexp r("^000[0-9][0-9][0-9][0-9][0-9][0-9]$");
+  TString sub;
+  for (Int_t i=0; i<a->GetEntries();i++)
+  {
+    TObjString* subobj = (TObjString*)a->At(i);
+    TString subtmp = subobj->GetString();
+    if (subtmp.Contains(r)) 
+    {
+      sub=subtmp;
+      break;
+    }
+  }
+  Int_t runNumber=sub.Atoi();
+  AliInfo(Form("guessed run: %i\n",runNumber));
+  a->Delete();
+  delete a;
+  return runNumber;
+}       
index 393de3b..e93c9d2 100644 (file)
@@ -42,6 +42,7 @@ public:
   virtual Bool_t            Notify();
   virtual void              Exec(Option_t *option);
   virtual void              Terminate(Option_t *option);
+  Int_t guessRunNumber(TString path);
     
   ClassDef(AliTaskConfigOCDB,1)  // Class giving CDB connectivity
 };