]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ANALYSIS/AliAnalysisSelector.cxx
warnings fixed
[u/mrichter/AliRoot.git] / ANALYSIS / AliAnalysisSelector.cxx
index 7568c1c4afc676edf321e31fc7aa6789daa81b6c..cce1ef211940c70fafd65b0f9ec507a698708ac8 100644 (file)
 
 ClassImp(AliAnalysisSelector)
 
+//______________________________________________________________________________
+AliAnalysisSelector::AliAnalysisSelector()
+                    :TSelector(), 
+                     fInitialized(kFALSE), 
+                     fAnalysis(NULL)
+{
+// Dummy ctor.
+   fAnalysis = AliAnalysisManager::GetAnalysisManager();
+   if (fAnalysis) fAnalysis->SetSelector(this);
+}   
+
 //______________________________________________________________________________
 AliAnalysisSelector::AliAnalysisSelector(AliAnalysisManager *mgr)
                     :TSelector(),
@@ -39,6 +50,7 @@ AliAnalysisSelector::AliAnalysisSelector(AliAnalysisManager *mgr)
 {
 // Constructor. Called by AliAnalysisManager which registers itself on the
 // selector running on the master.
+   mgr->SetSelector(this);
 }
 
 //______________________________________________________________________________
@@ -56,18 +68,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()>0) {
+   if (fAnalysis->GetDebugLevel()>1) {
       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()>0) {
+   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,7 +98,7 @@ void AliAnalysisSelector::Begin(TTree *)
 {
 // Assembly the input list.
    RestoreAnalysisManager();
-   if (fAnalysis && fAnalysis->GetDebugLevel()>0) {
+   if (fAnalysis && fAnalysis->GetDebugLevel()>1) {
       cout << "->AliAnalysisSelector->Begin: Analysis manager restored" << endl;
    }
 }
@@ -88,11 +109,11 @@ void AliAnalysisSelector::SlaveBegin(TTree *tree)
 // Called on each worker. We "unpack" analysis manager here and call InitAnalysis.
    RestoreAnalysisManager();
    if (fAnalysis) {
-      if (fAnalysis->GetDebugLevel()>0) {
+      if (fAnalysis->GetDebugLevel()>1) {
          cout << "->AliAnalysisSelector->SlaveBegin() after Restore" << endl;
       }   
       fAnalysis->SlaveBegin(tree);   
-      if (fAnalysis->GetDebugLevel()>0) {
+      if (fAnalysis->GetDebugLevel()>1) {
          cout << "<-AliAnalysisSelector->SlaveBegin()" << endl;
       }   
    }   
@@ -114,14 +135,14 @@ Bool_t AliAnalysisSelector::Notify()
 Bool_t AliAnalysisSelector::Process(Long64_t entry)
 {
 // Event loop.
-   if (fAnalysis->GetDebugLevel() > 0) {
+   if (fAnalysis->GetDebugLevel() > 1) {
       cout << "->AliAnalysisSelector::Process()" << endl;
    }
    Int_t nobjCount = TProcessID::GetObjectCount();
    fAnalysis->GetEntry(entry);
    fAnalysis->ExecAnalysis();
    TProcessID::SetObjectCount(nobjCount);
-   if (fAnalysis->GetDebugLevel() > 0) {
+   if (fAnalysis->GetDebugLevel() > 1) {
       cout << "<-AliAnalysisSelector::Process()" << endl;
    }   
    return kTRUE;
@@ -138,7 +159,7 @@ void AliAnalysisSelector::RestoreAnalysisManager()
          if (obj->IsA() == AliAnalysisManager::Class()) {
             fAnalysis = (AliAnalysisManager*)obj;
             fAnalysis->SetSelector(this);
-            if (fAnalysis->GetDebugLevel()>0) {
+            if (fAnalysis->GetDebugLevel()>1) {
                cout << "->AliAnalysisSelector->RestoreAnalysisManager: Analysis manager restored" << endl;
             }   
             break;
@@ -157,11 +178,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() > 0) {
+   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() > 0) {
+   if (fAnalysis->GetDebugLevel() > 1) {
       cout << "<-AliAnalysisSelector::SlaveTerminate()" << endl;
    }   
 }  
@@ -172,16 +195,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 analysis manager!!!");
       return;
    }   
-   if (fAnalysis->GetDebugLevel() > 0) {
+   // 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() > 0) {
+   if (fAnalysis->GetDebugLevel() > 1) {
       cout << "<-AliAnalysisSelector::Terminate()" << endl;
    }   
 }