]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ANALYSIS/AliPhysicsSelection.cxx
minor bug fixes
[u/mrichter/AliRoot.git] / ANALYSIS / AliPhysicsSelection.cxx
index d09fc37b0f3470f524c0a867bf3e8eda8dd9d32c..fc6e185dc2441c3dc8f8f934face92457f2c713c 100644 (file)
 #include "AliOADBPhysicsSelection.h"
 #include "AliOADBFillingScheme.h"
 #include "AliOADBTriggerAnalysis.h"
+#include "AliInputEventHandler.h"
+#include "AliAnalysisManager.h"
 
 using std::cout;
 using std::endl;
@@ -878,6 +880,7 @@ UInt_t AliPhysicsSelection::IsCollisionCandidate(const AliESDEvent* aEsd)
 
 Bool_t AliPhysicsSelection::Initialize(const AliESDEvent* aEsd)
 {
+  DetectPassName();
   // initializes the object for the given ESD
   
   AliInfo(Form("Initializing for beam type: %s", aEsd->GetESDRun()->GetBeamType()));
@@ -1956,3 +1959,64 @@ void AliPhysicsSelection::AddBGTriggerClass(const char* className){
   fUsingCustomClasses = kTRUE;
 
 }       
+
+
+void AliPhysicsSelection::DetectPassName(){
+  if (fMC) return;
+  AliInputEventHandler* handler = dynamic_cast<AliInputEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
+  if (!handler) return;
+  TObject* prodInfoData = handler->GetUserInfo()->FindObject("alirootVersion");
+  TString filePath = handler->GetTree()->GetCurrentFile()->GetName();
+  if (prodInfoData) {
+    // try to take filePath from UserInfo - available only from ~LHC12d period
+    TString str(prodInfoData->GetTitle());
+    TObjArray* tokens = str.Tokenize(";");
+    for (Int_t i=0;i<=tokens->GetLast();i++) {
+      TObjString* stObj = (TObjString*) tokens->At(i);
+      TString s = stObj->GetString();
+      if (s.Contains("OutputDir")) {
+        filePath = s;
+        break;
+      }
+    }
+    delete tokens;
+  } 
+
+  TString passName="";
+
+  TObjArray* tokens = filePath.Tokenize("/");
+  for (Int_t i=0;i<=tokens->GetLast();i++) {
+    TObjString* stObj = (TObjString*) tokens->At(i);
+    TString s = stObj->GetString();
+    if (s.Contains("pass")) {
+      passName = s;
+      break;
+    }
+  }
+  delete tokens;
+  //
+  // temporary patch for LEGO train runners
+  //
+  if (passName.Contains("_pass")){ // try with "_" as a fallback (as it is the case in the test data of the LEGO train) and do further tokenize
+    TObjArray* tokens2 = filePath.Tokenize("_");
+    for (Int_t i=0;i<=tokens2->GetLast();i++) {
+      TObjString* stObj = (TObjString*) tokens2->At(i);
+      TString s = stObj->GetString();
+      if (s.Contains("pass")) {
+       passName = s;
+       break;
+      }
+    }
+    delete tokens2;
+  }
+
+
+  if (!passName.Contains("pass")){
+    AliError(" Failed to find reconstruction pass name:");
+    AliError(" --> If these are MC data: please set kTRUE first argument of AddTaskPhysicsSelection");
+    AliFatal(" --> If these are real data: please insert pass name inside the path of your local file, e.g. /your_path/pass2/AliESDs.root");
+  }
+
+  AliInfo(Form("pass name: %s\n",passName.Data()));
+  fPassName = passName;
+}