From fc2a2963aefe1cd97361571a8f3f510e8d4dab40 Mon Sep 17 00:00:00 2001 From: ekryshen Date: Thu, 17 Jul 2014 11:41:16 +0200 Subject: [PATCH] Bug fix. Detection of pass name moved to AliPhysicsSelection::DetectPassName instead of AliPhysicsSelectionTask::NotifyRun. --- ANALYSIS/AliPhysicsSelection.cxx | 52 ++++++++++++++++++++++++++++ ANALYSIS/AliPhysicsSelection.h | 1 + ANALYSIS/AliPhysicsSelectionTask.cxx | 48 ------------------------- ANALYSIS/AliPhysicsSelectionTask.h | 1 - 4 files changed, 53 insertions(+), 49 deletions(-) diff --git a/ANALYSIS/AliPhysicsSelection.cxx b/ANALYSIS/AliPhysicsSelection.cxx index d09fc37b0f3..a7a9314ca51 100644 --- a/ANALYSIS/AliPhysicsSelection.cxx +++ b/ANALYSIS/AliPhysicsSelection.cxx @@ -124,6 +124,8 @@ #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,52 @@ void AliPhysicsSelection::AddBGTriggerClass(const char* className){ fUsingCustomClasses = kTRUE; } + + +void AliPhysicsSelection::DetectPassName(){ + if (fMC) return; + AliInputEventHandler* handler = dynamic_cast (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()); + if (!handler) return; + TObject* prodInfoData = handler->GetUserInfo()->FindObject("alirootVersion"); + TString filePath; + if (prodInfoData) { + // 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; + } else { + // guess name from the input filename + // may be a problem for local analysis + filePath = handler->GetTree()->GetCurrentFile()->GetName(); + } + + 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; + + 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; +} diff --git a/ANALYSIS/AliPhysicsSelection.h b/ANALYSIS/AliPhysicsSelection.h index 540510dc061..da254272459 100644 --- a/ANALYSIS/AliPhysicsSelection.h +++ b/ANALYSIS/AliPhysicsSelection.h @@ -106,6 +106,7 @@ public: static const char * GetOADBFileName() { static TString filename; filename.Form("%s/COMMON/PHYSICSSELECTION/data/physicsSelection.root", AliAnalysisManager::GetOADBPath()); return filename.Data();}; void SetPassName(const TString passName) { fPassName = passName; } + void DetectPassName(); Bool_t IsMC() const { return fMC; } protected: UInt_t CheckTriggerClass(const AliESDEvent* aEsd, const char* trigger, Int_t& triggerLogic) const; diff --git a/ANALYSIS/AliPhysicsSelectionTask.cxx b/ANALYSIS/AliPhysicsSelectionTask.cxx index 3e0616c62db..b89b8e540df 100644 --- a/ANALYSIS/AliPhysicsSelectionTask.cxx +++ b/ANALYSIS/AliPhysicsSelectionTask.cxx @@ -139,51 +139,3 @@ void AliPhysicsSelectionTask::Terminate(Option_t *) Printf("Writing result to event_stat.root"); } - -void AliPhysicsSelectionTask::NotifyRun(){ - if (fPhysicsSelection->IsMC()) return; - TObject* prodInfoData = fInputHandler->GetUserInfo()->FindObject("alirootVersion"); - TString filePath; - if (prodInfoData) { - // 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; - } else { - // guess name from the input filename - // may be a problem for local analysis - filePath = fInputHandler->GetTree()->GetCurrentFile()->GetName(); - } - - 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; - - if (!passName.Contains("pass")){ - AliError(" ******** Failed to find reconstruction pass name *********"); - AliError(" ******** Default parameters loaded: parameters unreliable ******"); - AliError(" --> If these are MC data: please set kTRUE first argument of AddTaskPhysicsSelection"); - AliError(" --> If these are real data: "); - AliError(" (a) please insert pass number inside the path of your local file OR"); - AliError(" (b) specify reconstruction pass number when adding physics selection task"); - AliError(" Using default pass parameters for physics selection (PS will probably fail for LHC10h pass1 and pass2 data)!"); - } - fPhysicsSelection->SetPassName(passName); -} diff --git a/ANALYSIS/AliPhysicsSelectionTask.h b/ANALYSIS/AliPhysicsSelectionTask.h index c29c9f1931e..42aff097df3 100644 --- a/ANALYSIS/AliPhysicsSelectionTask.h +++ b/ANALYSIS/AliPhysicsSelectionTask.h @@ -22,7 +22,6 @@ class AliPhysicsSelectionTask : public AliAnalysisTaskSE { virtual void UserExec(Option_t*); virtual void FinishTaskOutput(); virtual void Terminate(Option_t*); - virtual void NotifyRun(); void SetOption(const char* opt) { fOption = opt; } -- 2.39.3