From efd53803332c911984354bca63f24b9817d72e32 Mon Sep 17 00:00:00 2001 From: agheata Date: Fri, 4 May 2007 11:48:19 +0000 Subject: [PATCH] - Fixed path for AliAnalysisSelector.cxx in the local case - Added flags for discriminating event-by-event vs. one-shot analysis (Mihaela) --- ANALYSIS/AliAnalysisManager.cxx | 32 ++++++++++++++++++++++++++------ ANALYSIS/AliAnalysisManager.h | 6 ++++++ ANALYSIS/AliAnalysisTask.cxx | 23 +++++++++++++++++++++-- ANALYSIS/AliAnalysisTask.h | 2 +- 4 files changed, 54 insertions(+), 9 deletions(-) diff --git a/ANALYSIS/AliAnalysisManager.cxx b/ANALYSIS/AliAnalysisManager.cxx index 9bb0f221d08..531e3b52311 100644 --- a/ANALYSIS/AliAnalysisManager.cxx +++ b/ANALYSIS/AliAnalysisManager.cxx @@ -581,16 +581,36 @@ void AliAnalysisManager::StartAnalysis(const char *type, TTree *tree) Warning("StartAnalysis", "GRID analysis mode not implemented. Running local."); fMode = kLocalAnalysis; } - char line[128]; - // Disable by default all branches - if (tree) tree->SetBranchStatus("*",0); + char line[128]; + SetEventLoop(kFALSE); + // Disable by default all branches and set event loop mode + if (tree) { + tree->SetBranchStatus("*",0); + SetEventLoop(kTRUE); + } + AliAnalysisDataContainer *cont = 0; + TIter nextc(fInputs); + // Force top containers have the same event loop type as the analysis + while ((cont=(AliAnalysisDataContainer*)nextc())) cont->SetEventByEvent(IsEventLoop()); + AliAnalysisDataContainer *cont_top = (AliAnalysisDataContainer*)fInputs->First(); + TChain *chain = dynamic_cast(tree); // Initialize locally all tasks TIter next(fTasks); AliAnalysisTask *task; - while ((task=(AliAnalysisTask*)next())) task->LocalInit(); - + while ((task=(AliAnalysisTask*)next())) { + for (Int_t islot=0; islotGetNinputs(); islot++) { + cont = task->GetInputSlot(islot)->GetContainer(); + if (cont==cont_top) break; + cont = 0; + } + // All tasks feeding from the top containers must have the same event loop type + if (cont) task->SetExecPerEvent(IsEventLoop()); + else task->SetExecPerEvent(task->IsExecPerEvent()); + task->LocalInit(); + } + switch (fMode) { case kLocalAnalysis: if (!tree) { @@ -607,7 +627,7 @@ void AliAnalysisManager::StartAnalysis(const char *type, TTree *tree) return; } // Run tree-based analysis via AliAnalysisSelector - gROOT->ProcessLine(".L AliAnalysisSelector.cxx+"); + gROOT->ProcessLine(".L $ALICE_ROOT/ANALYSIS/AliAnalysisSelector.cxx+"); cout << "===== RUNNING LOCAL ANALYSIS " << GetName() << " ON TREE " << tree->GetName() << endl; sprintf(line, "AliAnalysisSelector *selector = new AliAnalysisSelector((AliAnalysisManager*)0x%lx);",(ULong_t)this); gROOT->ProcessLine(line); diff --git a/ANALYSIS/AliAnalysisManager.h b/ANALYSIS/AliAnalysisManager.h index a6021dcd722..fe363c61e95 100644 --- a/ANALYSIS/AliAnalysisManager.h +++ b/ANALYSIS/AliAnalysisManager.h @@ -38,6 +38,10 @@ enum EAliAnalysisExecMode { kGridAnalysis = 2 }; +enum EAliAnalysisFlags { + kEventLoop = BIT(14) +}; + AliAnalysisManager(); AliAnalysisManager(const char *name, const char *title=""); virtual ~AliAnalysisManager(); @@ -96,6 +100,7 @@ enum EAliAnalysisExecMode { // Analysis initialization and execution, status Bool_t InitAnalysis(); Bool_t IsInitialized() const {return fInitOK;} + Bool_t IsEventLoop() const {return TObject::TestBit(kEventLoop);} void ResetAnalysis(); void ExecAnalysis(Option_t *option=""); void FinishAnalysis(); @@ -103,6 +108,7 @@ enum EAliAnalysisExecMode { protected: void ImportWrappers(TList *source); + void SetEventLoop(Bool_t flag=kTRUE) {TObject::SetBit(kEventLoop,flag);} private: TTree *fTree; //! Input tree in case of TSelector model diff --git a/ANALYSIS/AliAnalysisTask.cxx b/ANALYSIS/AliAnalysisTask.cxx index e901b9ddb70..5ce8219ca88 100644 --- a/ANALYSIS/AliAnalysisTask.cxx +++ b/ANALYSIS/AliAnalysisTask.cxx @@ -233,8 +233,12 @@ void AliAnalysisTask::CheckNotify(Bool_t init) // accordingly. This method is called automatically for all tasks connected // to a container where the data was published. if (init) fInitialized = kFALSE; + Bool_t execperevent = IsExecPerEvent(); + AliAnalysisDataContainer *cinput; for (Int_t islot=0; islotGetContainer(); + if (!cinput) return; + if (!cinput->GetData() || execperevent!=cinput->IsEventByEvent()) { SetActive(kFALSE); return; } @@ -547,6 +551,21 @@ void AliAnalysisTask::PrintContainers(Option_t *option, Int_t indent) const Int_t islot; for (islot=0; islotGetContainer(); - cont->PrintContainer(option, indent); + if (cont) cont->PrintContainer(option, indent); } } + +//______________________________________________________________________________ +void AliAnalysisTask::SetExecPerEvent(Bool_t flag) +{ +// Set the task execution mode - run in a event loop or single shot. All output +// containers of this task will get the same type. + TObject::SetBit(kTaskEvtByEvt,flag); + AliAnalysisDataContainer *cont; + Int_t islot; + for (islot=0; islotGetContainer(); + if (cont) cont->SetEventByEvent(flag); + } +} + diff --git a/ANALYSIS/AliAnalysisTask.h b/ANALYSIS/AliAnalysisTask.h index ba744c7bd32..f0c79509294 100644 --- a/ANALYSIS/AliAnalysisTask.h +++ b/ANALYSIS/AliAnalysisTask.h @@ -115,7 +115,7 @@ public: void PrintTask(Option_t *option="all", Int_t indent=0) const; void PrintContainers(Option_t *option="all", Int_t indent=0) const; void SetChecked(Bool_t flag=kTRUE) {TObject::SetBit(kTaskChecked,flag);} - void SetExecPerEvent(Bool_t flag=kTRUE) {TObject::SetBit(kTaskEvtByEvt,flag);} + void SetExecPerEvent(Bool_t flag=kTRUE); void SetUsed(Bool_t flag=kTRUE); void SetZombie(Bool_t flag=kTRUE) {TObject::SetBit(kTaskZombie,flag);} // Main task execution -- 2.39.3