X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=ANALYSIS%2FAliAnalysisSelector.cxx;h=580c322940ad53bfd19aecd9f652f1f09b7d1142;hb=4600462476efa22103ce64cf1aa1dc0af11a50c8;hp=a585053ad12c540dce33884d789268f2b959a92f;hpb=c52c2132edf0525e05b46ca57d7715be79ddb52c;p=u%2Fmrichter%2FAliRoot.git diff --git a/ANALYSIS/AliAnalysisSelector.cxx b/ANALYSIS/AliAnalysisSelector.cxx index a585053ad12..580c322940a 100644 --- a/ANALYSIS/AliAnalysisSelector.cxx +++ b/ANALYSIS/AliAnalysisSelector.cxx @@ -21,7 +21,8 @@ // AliAnalysisManager to handle analysis. //============================================================================== -#include "Riostream.h" +#include +#include #include "AliAnalysisManager.h" #include "AliAnalysisTask.h" @@ -55,14 +56,29 @@ void AliAnalysisSelector::Init(TTree *tree) // Is Init called on workers in case of PROOF. if (!fAnalysis) { Error("Init", "Analysis manager NULL !"); + Abort("Cannot initialize without analysis manager. Aborting."); + SetStatus(-1); return; } + if (fAnalysis->GetDebugLevel()>0) { + cout << "->AliAnalysisSelector->Init()" << endl; + } if (!tree) { Error("Init", "Input tree is NULL !"); + Abort("Cannot initialize without tree. Aborting."); + SetStatus(-1); return; } - fAnalysis->Init(tree); - fInitialized = kTRUE; + fInitialized = fAnalysis->Init(tree); + if (!fInitialized) { + Error("Init", "Some error occured during analysis manager initialization. Aborting."); + Abort("Error during AliAnalysisManager::Init()"); + SetStatus(-1); + return; + } + if (fAnalysis->GetDebugLevel()>0) { + cout << "<-AliAnalysisSelector->Init()" << endl; + } } //______________________________________________________________________________ @@ -70,6 +86,9 @@ void AliAnalysisSelector::Begin(TTree *) { // Assembly the input list. RestoreAnalysisManager(); + if (fAnalysis && fAnalysis->GetDebugLevel()>0) { + cout << "->AliAnalysisSelector->Begin: Analysis manager restored" << endl; + } } //______________________________________________________________________________ @@ -77,18 +96,43 @@ void AliAnalysisSelector::SlaveBegin(TTree *tree) { // Called on each worker. We "unpack" analysis manager here and call InitAnalysis. RestoreAnalysisManager(); - if (fAnalysis) fAnalysis->SlaveBegin(tree); -} + if (fAnalysis) { + if (fAnalysis->GetDebugLevel()>0) { + cout << "->AliAnalysisSelector->SlaveBegin() after Restore" << endl; + } + fAnalysis->SlaveBegin(tree); + if (fAnalysis->GetDebugLevel()>0) { + cout << "<-AliAnalysisSelector->SlaveBegin()" << endl; + } + } +} + +//______________________________________________________________________________ +Bool_t AliAnalysisSelector::Notify() +{ + // The Notify() function is called when a new file is opened. This + // can be either for a new TTree in a TChain or when when a new TTree + // is started when using PROOF. It is normaly not necessary to make changes + // to the generated code, but the routine can be extended by the + // user if needed. The return value is currently not used. + if (fAnalysis) return fAnalysis->Notify(); + return kFALSE; +} //______________________________________________________________________________ Bool_t AliAnalysisSelector::Process(Long64_t entry) { // Event loop. - if (fAnalysis->GetDebugLevel() >1 ) { - printf("AliAnalysisSelector::Process()\n"); - } - fAnalysis->GetEntry(entry); // Not needed anymore in version 2 + if (fAnalysis->GetDebugLevel() > 0) { + cout << "->AliAnalysisSelector::Process()" << endl; + } + Int_t nobjCount = TProcessID::GetObjectCount(); + fAnalysis->GetEntry(entry); fAnalysis->ExecAnalysis(); + TProcessID::SetObjectCount(nobjCount); + if (fAnalysis->GetDebugLevel() > 0) { + cout << "<-AliAnalysisSelector::Process()" << endl; + } return kTRUE; } @@ -102,6 +146,10 @@ void AliAnalysisSelector::RestoreAnalysisManager() while ((obj=next())) { if (obj->IsA() == AliAnalysisManager::Class()) { fAnalysis = (AliAnalysisManager*)obj; + fAnalysis->SetSelector(this); + if (fAnalysis->GetDebugLevel()>0) { + cout << "->AliAnalysisSelector->RestoreAnalysisManager: Analysis manager restored" << endl; + } break; } } @@ -118,10 +166,15 @@ void AliAnalysisSelector::SlaveTerminate() // The SlaveTerminate() function is called after all entries or objects // have been processed. When running with PROOF SlaveTerminate() is called // on each slave server. - if (fAnalysis->GetDebugLevel() >1 ) { - printf("AliAnalysisSelector::SlaveTerminate()\n"); + if (fStatus == -1) return; // TSelector won't abort... + if (fAnalysis->GetAnalysisType() == AliAnalysisManager::kMixingAnalysis) return; + if (fAnalysis->GetDebugLevel() > 0) { + cout << "->AliAnalysisSelector::SlaveTerminate()" << endl; } fAnalysis->PackOutput(fOutput); + if (fAnalysis->GetDebugLevel() > 0) { + cout << "<-AliAnalysisSelector::SlaveTerminate()" << endl; + } } //______________________________________________________________________________ @@ -130,13 +183,19 @@ void AliAnalysisSelector::Terminate() // The Terminate() function is the last function to be called during // a query. It always runs on the client, it can be used to present // the results graphically or save the results to file. + if (fStatus == -1) return; // TSelector won't abort... if (!fAnalysis) { - Error("Terminate","AliAnalysisSelector::Terminate: No analysisManager!!!"); + Error("Terminate","AliAnalysisSelector::Terminate: No analysis manager!!!"); return; } - if (fAnalysis->GetDebugLevel() >1 ) { - printf("AliAnalysisSelector::Terminate()\n"); + // No Terminate() in case of event mixing + if (fAnalysis->GetAnalysisType() == AliAnalysisManager::kMixingAnalysis) return; + if (fAnalysis->GetDebugLevel() > 0) { + cout << "->AliAnalysisSelector::Terminate()" << endl; } fAnalysis->UnpackOutput(fOutput); fAnalysis->Terminate(); + if (fAnalysis->GetDebugLevel() > 0) { + cout << "<-AliAnalysisSelector::Terminate()" << endl; + } }