// AliAnalysisManager to handle analysis.
//==============================================================================
-#include "Riostream.h"
+#include <Riostream.h>
+#include <TProcessID.h>
#include "AliAnalysisManager.h"
#include "AliAnalysisTask.h"
ClassImp(AliAnalysisSelector)
+//______________________________________________________________________________
+AliAnalysisSelector::AliAnalysisSelector()
+ :TSelector(),
+ fInitialized(kFALSE),
+ fAnalysis(NULL)
+{
+// Dummy ctor.
+ fAnalysis = AliAnalysisManager::GetAnalysisManager();
+ if (fAnalysis) fAnalysis->SetSelector(this);
+}
+
//______________________________________________________________________________
AliAnalysisSelector::AliAnalysisSelector(AliAnalysisManager *mgr)
:TSelector(),
{
// Constructor. Called by AliAnalysisManager which registers itself on the
// selector running on the master.
+ mgr->SetSelector(this);
}
//______________________________________________________________________________
// 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) {
}
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;
}
// 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) {
cout << "<-AliAnalysisSelector->SlaveBegin()" << endl;
}
}
-}
+}
//______________________________________________________________________________
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;
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;
}
// 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;
}
}
// 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;
}
}