X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=ANALYSIS%2FAliAnalysisSelector.cxx;h=2738386ffeb5b1403823e460c922ec4c4489d7e0;hb=4ff7775147f6e0971411816860e37e3b2e497f97;hp=3d2870f56a247feb4cfcd62b9065d4353283da12;hpb=d8a5ee9442124a10f7af22936cc85f82f2b116a6;p=u%2Fmrichter%2FAliRoot.git diff --git a/ANALYSIS/AliAnalysisSelector.cxx b/ANALYSIS/AliAnalysisSelector.cxx index 3d2870f56a2..2738386ffeb 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" @@ -30,6 +31,17 @@ ClassImp(AliAnalysisSelector) +//______________________________________________________________________________ +AliAnalysisSelector::AliAnalysisSelector() + :TSelector(), + fInitialized(kFALSE), + fAnalysis(NULL) +{ +// Dummy ctor. + fAnalysis = AliAnalysisManager::GetAnalysisManager(); + if (fAnalysis) fAnalysis->SetSelector(this); +} + //______________________________________________________________________________ AliAnalysisSelector::AliAnalysisSelector(AliAnalysisManager *mgr) :TSelector(), @@ -38,6 +50,7 @@ AliAnalysisSelector::AliAnalysisSelector(AliAnalysisManager *mgr) { // Constructor. Called by AliAnalysisManager which registers itself on the // selector running on the master. + mgr->SetSelector(this); } //______________________________________________________________________________ @@ -55,6 +68,8 @@ 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()>1) { @@ -62,10 +77,17 @@ void AliAnalysisSelector::Init(TTree *tree) } 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()>1) { cout << "<-AliAnalysisSelector->Init()" << endl; } @@ -77,14 +99,15 @@ void AliAnalysisSelector::Begin(TTree *) // Assembly the input list. RestoreAnalysisManager(); if (fAnalysis && fAnalysis->GetDebugLevel()>1) { - cout << "->AliAnalysisSelector->Init: Analysis manager restored" << endl; - } + cout << "->AliAnalysisSelector->Begin: Analysis manager restored" << endl; + } } //______________________________________________________________________________ void AliAnalysisSelector::SlaveBegin(TTree *tree) { // Called on each worker. We "unpack" analysis manager here and call InitAnalysis. + TObject::SetObjectStat(kFALSE); RestoreAnalysisManager(); if (fAnalysis) { if (fAnalysis->GetDebugLevel()>1) { @@ -95,7 +118,7 @@ void AliAnalysisSelector::SlaveBegin(TTree *tree) cout << "<-AliAnalysisSelector->SlaveBegin()" << endl; } } -} +} //______________________________________________________________________________ Bool_t AliAnalysisSelector::Notify() @@ -107,18 +130,29 @@ Bool_t AliAnalysisSelector::Notify() // 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 ) { + if (fAnalysis->GetDebugLevel() > 1) { cout << "->AliAnalysisSelector::Process()" << endl; + } + Int_t nobjCount = TProcessID::GetObjectCount(); + Int_t returnCode = fAnalysis->GetEntry(entry); + if (returnCode <= 0) { + cout << "Error retrieving event:" << entry << " Skipping ..." << endl; + fAnalysis->CountEvent(1,0,1,0); + // Try to skip file + Abort("Bad stream to file. Trying next image.", kAbortFile); + return kFALSE; + } else { + fAnalysis->ExecAnalysis(); + if (returnCode<100000000) fAnalysis->CountEvent(1,1,0,0); } - fAnalysis->GetEntry(entry); // Not needed anymore in version 2 - fAnalysis->ExecAnalysis(); - if (fAnalysis->GetDebugLevel() >1 ) { + TProcessID::SetObjectCount(nobjCount); + if (fAnalysis->GetDebugLevel() > 1) { cout << "<-AliAnalysisSelector::Process()" << endl; } return kTRUE; @@ -134,6 +168,7 @@ void AliAnalysisSelector::RestoreAnalysisManager() while ((obj=next())) { if (obj->IsA() == AliAnalysisManager::Class()) { fAnalysis = (AliAnalysisManager*)obj; + fAnalysis->SetSelector(this); if (fAnalysis->GetDebugLevel()>1) { cout << "->AliAnalysisSelector->RestoreAnalysisManager: Analysis manager restored" << endl; } @@ -153,11 +188,13 @@ 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 ) { + if (fStatus == -1) return; // TSelector won't abort... + if (fAnalysis->GetAnalysisType() == AliAnalysisManager::kMixingAnalysis) return; + if (fAnalysis->GetDebugLevel() > 1) { cout << "->AliAnalysisSelector::SlaveTerminate()" << endl; } fAnalysis->PackOutput(fOutput); - if (fAnalysis->GetDebugLevel() >1 ) { + if (fAnalysis->GetDebugLevel() > 1) { cout << "<-AliAnalysisSelector::SlaveTerminate()" << endl; } } @@ -168,16 +205,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 ) { + // No Terminate() in case of event mixing + if (fAnalysis->GetAnalysisType() == AliAnalysisManager::kMixingAnalysis) return; + if (fAnalysis->GetDebugLevel() > 1) { cout << "->AliAnalysisSelector::Terminate()" << endl; } fAnalysis->UnpackOutput(fOutput); fAnalysis->Terminate(); - if (fAnalysis->GetDebugLevel() >1 ) { + if (fAnalysis->GetDebugLevel() > 1) { cout << "<-AliAnalysisSelector::Terminate()" << endl; } }