]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ANALYSIS/AliAnalysisSelector.cxx
Disable automatic prefered SE based on alien_CLOSE_SE. Use rather AliAnalysisAlien...
[u/mrichter/AliRoot.git] / ANALYSIS / AliAnalysisSelector.cxx
index 0cd1ac115ef3cbc26b0215d2c8674ec942c08e52..580c322940ad53bfd19aecd9f652f1f09b7d1142 100644 (file)
@@ -21,7 +21,8 @@
 // AliAnalysisManager to handle analysis.
 //==============================================================================
 
-#include "Riostream.h"
+#include <Riostream.h>
+#include <TProcessID.h>
 
 #include "AliAnalysisManager.h"
 #include "AliAnalysisTask.h"
@@ -55,18 +56,27 @@ 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) {
+   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;
-   if (fAnalysis->GetDebugLevel()>1) {
+   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;
    }   
 }
@@ -76,9 +86,9 @@ void AliAnalysisSelector::Begin(TTree *)
 {
 // Assembly the input list.
    RestoreAnalysisManager();
-   if (fAnalysis && fAnalysis->GetDebugLevel()>1) {
-      cout << "->AliAnalysisSelector->Init: Analysis manager restored" << endl;
-   }   
+   if (fAnalysis && fAnalysis->GetDebugLevel()>0) {
+      cout << "->AliAnalysisSelector->Begin: Analysis manager restored" << endl;
+   }
 }
 
 //______________________________________________________________________________
@@ -87,15 +97,15 @@ void AliAnalysisSelector::SlaveBegin(TTree *tree)
 // Called on each worker. We "unpack" analysis manager here and call InitAnalysis.
    RestoreAnalysisManager();
    if (fAnalysis) {
-      if (fAnalysis->GetDebugLevel()>1) {
+      if (fAnalysis->GetDebugLevel()>0) {
          cout << "->AliAnalysisSelector->SlaveBegin() after Restore" << endl;
       }   
       fAnalysis->SlaveBegin(tree);   
-      if (fAnalysis->GetDebugLevel()>1) {
+      if (fAnalysis->GetDebugLevel()>0) {
          cout << "<-AliAnalysisSelector->SlaveBegin()" << endl;
       }   
    }   
-}      
+}
 
 //______________________________________________________________________________
 Bool_t AliAnalysisSelector::Notify()
@@ -105,19 +115,22 @@ Bool_t AliAnalysisSelector::Notify()
    // 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) fAnalysis->Notify();
-}   
+   if (fAnalysis) return fAnalysis->Notify();
+   return kFALSE;
+}
 
 //______________________________________________________________________________
 Bool_t AliAnalysisSelector::Process(Long64_t entry)
 {
 // Event loop.
-   if (fAnalysis->GetDebugLevel() >) {
+   if (fAnalysis->GetDebugLevel() > 0) {
       cout << "->AliAnalysisSelector::Process()" << endl;
-   }   
-   fAnalysis->GetEntry(entry); // Not needed anymore in version 2
+   }
+   Int_t nobjCount = TProcessID::GetObjectCount();
+   fAnalysis->GetEntry(entry);
    fAnalysis->ExecAnalysis();
-   if (fAnalysis->GetDebugLevel() >1 ) {
+   TProcessID::SetObjectCount(nobjCount);
+   if (fAnalysis->GetDebugLevel() > 0) {
       cout << "<-AliAnalysisSelector::Process()" << endl;
    }   
    return kTRUE;
@@ -133,7 +146,8 @@ void AliAnalysisSelector::RestoreAnalysisManager()
       while ((obj=next())) {
          if (obj->IsA() == AliAnalysisManager::Class()) {
             fAnalysis = (AliAnalysisManager*)obj;
-            if (fAnalysis->GetDebugLevel()>1) {
+            fAnalysis->SetSelector(this);
+            if (fAnalysis->GetDebugLevel()>0) {
                cout << "->AliAnalysisSelector->RestoreAnalysisManager: Analysis manager restored" << endl;
             }   
             break;
@@ -152,11 +166,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() > 0) {
       cout << "->AliAnalysisSelector::SlaveTerminate()" << endl;
    }   
    fAnalysis->PackOutput(fOutput);
-   if (fAnalysis->GetDebugLevel() >) {
+   if (fAnalysis->GetDebugLevel() > 0) {
       cout << "<-AliAnalysisSelector::SlaveTerminate()" << endl;
    }   
 }  
@@ -167,16 +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 ) {
+   // 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() >) {
+   if (fAnalysis->GetDebugLevel() > 0) {
       cout << "<-AliAnalysisSelector::Terminate()" << endl;
    }   
 }