]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ANALYSIS/AliAnalysisTaskME.cxx
prettier logs
[u/mrichter/AliRoot.git] / ANALYSIS / AliAnalysisTaskME.cxx
index 2670db7c69f4f59ce2313f40193a0f661bf7efde..6900da35b982c8d917a05f235d978173b20ef6cb 100644 (file)
@@ -24,6 +24,7 @@
 
 #include "AliAnalysisTaskME.h"
 #include "AliAnalysisManager.h"
+#include "AliAnalysisDataSlot.h"
 #include "AliAODEvent.h"
 #include "AliVEvent.h"
 #include "AliAODHandler.h"
@@ -31,7 +32,7 @@
 #include "AliLog.h"
 
 
-ClassImp(AliAnalysisTaskME);
+ClassImp(AliAnalysisTaskME)
 
 ////////////////////////////////////////////////////////////////////////
 
@@ -86,14 +87,16 @@ AliAnalysisTaskME::AliAnalysisTaskME(const AliAnalysisTaskME& obj):
 AliAnalysisTaskME& AliAnalysisTaskME::operator=(const AliAnalysisTaskME& other)
 {
 // Assignment
-    AliAnalysisTask::operator=(other);
-    fDebug           = other.fDebug;
-    fEntry           = other.fEntry;
-    fFreshBufferOnly = other.fFreshBufferOnly;
-    fInputHandler    = other.fInputHandler;
-    fOutputAOD       = other.fOutputAOD;
-    fTreeA           = other.fTreeA;    
-    fOfflineTriggerMask = other.fOfflineTriggerMask;
+    if (this != &other) {
+       AliAnalysisTask::operator=(other);
+       fDebug           = other.fDebug;
+       fEntry           = other.fEntry;
+       fFreshBufferOnly = other.fFreshBufferOnly;
+       fInputHandler    = other.fInputHandler;
+       fOutputAOD       = other.fOutputAOD;
+       fTreeA           = other.fTreeA;    
+       fOfflineTriggerMask = other.fOfflineTriggerMask;
+    }
     return *this;
 }
 
@@ -154,12 +157,13 @@ void AliAnalysisTaskME::Exec(Option_t* option)
 //
 // Was event selected ? If no event selection mechanism, the event SHOULD be selected (AG)
     UInt_t isSelected = AliVEvent::kAny;
-    if( fInputHandler && fInputHandler->GetEventSelection()) {
+    if(fInputHandler && fInputHandler->GetEventSelection()) {
       // Get the actual offline trigger mask for the event and AND it with the
       // requested mask. If no mask requested select by default the event.
       if (fOfflineTriggerMask)
        isSelected = fOfflineTriggerMask & fInputHandler->IsEventSelected();
     }
+    
     if (!isSelected) { 
        if (fDebug > 1) AliInfo("Event rejected \n");
        fInputHandler->EventSkipped();
@@ -167,12 +171,14 @@ void AliAnalysisTaskME::Exec(Option_t* option)
     }
 // Call the user analysis    
     
-    if (fInputHandler->IsBufferReady()) {
+    if (fInputHandler && fInputHandler->IsBufferReady()) {
        if ((fFreshBufferOnly && fInputHandler->IsFreshBuffer()) || !fFreshBufferOnly)
        {
            if (outputHandler) outputHandler->SetFillAOD(kTRUE);
            UserExec(option);
-           PostData(0, fTreeA);
+           // Added protection in case the derived task is not an AOD producer.
+           AliAnalysisDataSlot *out0 = GetOutputSlot(0);
+           if (out0 && out0->IsConnected()) PostData(0, fTreeA);
        } else {
            if (outputHandler) outputHandler->SetFillAOD(kFALSE);
        }