From 9b33830a51351fc5446876772bccc0fa2a83204a Mon Sep 17 00:00:00 2001 From: agheata Date: Wed, 2 May 2007 12:13:59 +0000 Subject: [PATCH] The method LocalInit() may be implemented to call locally (on the client) all initialization methods of the class. It is not mandatory and was created in order to minimize the complexity and readability of the analysis macro. DO NOT create in this method the histigrams or task output objects that will go in the task output containers. Use CreateOutputObjects() method for that. --- ANALYSIS/AliAnalysisManager.cxx | 6 ++++++ ANALYSIS/AliAnalysisTask.cxx | 18 +++++++++++++++++- ANALYSIS/AliAnalysisTask.h | 2 ++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/ANALYSIS/AliAnalysisManager.cxx b/ANALYSIS/AliAnalysisManager.cxx index 7e29eb7b95f..f235c35d636 100644 --- a/ANALYSIS/AliAnalysisManager.cxx +++ b/ANALYSIS/AliAnalysisManager.cxx @@ -582,6 +582,12 @@ void AliAnalysisManager::StartAnalysis(const char *type, TTree *tree) // Disable by default all branches if (tree) tree->SetBranchStatus("*",0); TChain *chain = dynamic_cast(tree); + + // Initialize locally all tasks + TIter next(fTasks); + AliAnalysisTask *task; + while ((task=(AliAnalysisTask*)next())) task->LocalInit(); + switch (fMode) { case kLocalAnalysis: if (!tree) { diff --git a/ANALYSIS/AliAnalysisTask.cxx b/ANALYSIS/AliAnalysisTask.cxx index b35021ceeb7..2f8db1be3d1 100644 --- a/ANALYSIS/AliAnalysisTask.cxx +++ b/ANALYSIS/AliAnalysisTask.cxx @@ -62,7 +62,13 @@ // } // } // -// The method CreateOutputObjects() has to be overloaded an will contain the +// The method LocalInit() may be implemented to call locally (on the client) +// all initialization methods of the class. It is not mandatory and was created +// in order to minimize the complexity and readability of the analysis macro. +// DO NOT create in this method the histigrams or task output objects that will +// go in the task output containers. Use CreateOutputObjects for that. +// +// The method CreateOutputObjects() has to be implemented an will contain the // objects that should be created only once per session (e.g. output // histograms) // @@ -377,6 +383,16 @@ void AliAnalysisTask::ConnectInputData(Option_t *) // Overload and connect your branches here. } +//______________________________________________________________________________ +void AliAnalysisTask::LocalInit() +{ +// The method LocalInit() may be implemented to call locally (on the client) +// all initialization methods of the class. It is not mandatory and was created +// in order to minimize the complexity and readability of the analysis macro. +// DO NOT create in this method the histigrams or task output objects that will +// go in the task output containers. Use CreateOutputObjects for that. +} + //______________________________________________________________________________ void AliAnalysisTask::CreateOutputObjects() { diff --git a/ANALYSIS/AliAnalysisTask.h b/ANALYSIS/AliAnalysisTask.h index 2303583662e..34c4c2c38d0 100644 --- a/ANALYSIS/AliAnalysisTask.h +++ b/ANALYSIS/AliAnalysisTask.h @@ -79,6 +79,8 @@ public: //===================================================================== // === OVERLOAD THIS AND CREATE YOUR OUTPUT OBJECTS (HISTOGRAMS,DATA) HERE virtual void CreateOutputObjects(); + // === OVERLOAD THIS IF YOU NEED TO INITIALIZE YOUR CLASS ON THE CLIENT + virtual void LocalInit(); // === OVERLOAD THIS IF YOU NEED TO TREAT INPUT FILE CHANGE virtual Bool_t Notify(); // Conect inputs/outputs to data containers (by AliAnalysisModule) -- 2.39.3