]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ANALYSIS/AliAnalysisTaskSE.cxx
centrality calibration files for lhc10g2a
[u/mrichter/AliRoot.git] / ANALYSIS / AliAnalysisTaskSE.cxx
index c2b82ca9fe576b0f8e25d9c66e8cd7b030aa03dd..679fe1018cdd536f85b780dfc5628af77a2386e6 100644 (file)
@@ -76,7 +76,7 @@ AliAnalysisTaskSE::AliAnalysisTaskSE():
     fTreeA(0x0),
     fCurrentRunNumber(-1),
     fHistosQA(0x0),
-    fSelectCollisions(0)
+    fOfflineTriggerMask(0)
 {
   // Default constructor
 }
@@ -93,7 +93,7 @@ AliAnalysisTaskSE::AliAnalysisTaskSE(const char* name):
     fTreeA(0x0),
     fCurrentRunNumber(-1),
     fHistosQA(0x0),
-    fSelectCollisions(0)
+    fOfflineTriggerMask(0)
 {
   // Default constructor
     DefineInput (0, TChain::Class());
@@ -112,7 +112,7 @@ AliAnalysisTaskSE::AliAnalysisTaskSE(const AliAnalysisTaskSE& obj):
     fTreeA(0x0),
     fCurrentRunNumber(-1),
     fHistosQA(0x0),
-    fSelectCollisions(0)
+    fOfflineTriggerMask(0)
 {
 // Copy constructor
     fDebug            = obj.fDebug;
@@ -143,7 +143,7 @@ AliAnalysisTaskSE& AliAnalysisTaskSE::operator=(const AliAnalysisTaskSE& other)
     fTreeA            = other.fTreeA;    
     fCurrentRunNumber = other.fCurrentRunNumber;
     fHistosQA         = other.fHistosQA;
-    fSelectCollisions = other.fSelectCollisions;
+    fOfflineTriggerMask = other.fOfflineTriggerMask;
     return *this;
 }
 
@@ -186,7 +186,7 @@ void AliAnalysisTaskSE::CreateOutputObjects()
 //  Default AOD
     if (fDebug > 1) printf("AnalysisTaskSE::CreateOutPutData() \n");
 
-    AliAODHandler* handler = (AliAODHandler*) 
+    AliAODHandler* handler = dynamic_cast<AliAODHandler*> 
          ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
     
     Bool_t merging = kFALSE;
@@ -289,8 +289,6 @@ void AliAnalysisTaskSE::CreateOutputObjects()
            // cache the pointerd in the AODEvent
            fOutputAOD->GetStdContent();
        }
-    } else {
-       AliWarning("No AOD Event Handler connected.") ; 
     }
     UserCreateOutputObjects();
 }
@@ -299,28 +297,35 @@ void AliAnalysisTaskSE::Exec(Option_t* option)
 {
 //
 // Exec analysis of one event
-    fDebug = 10;
-    printf("Task is active %5d\n", IsActive());
+    if ( fDebug >= 10)
+      printf("Task is active %5d\n", IsActive());
     
     if (fDebug > 1) AliInfo("AliAnalysisTaskSE::Exec() \n");
 //
-    AliAODHandler* handler = (AliAODHandler*) 
+    AliAODHandler* handler = dynamic_cast<AliAODHandler*> 
        ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
+
     AliAODInputHandler* aodH = dynamic_cast<AliAODInputHandler*>(fInputHandler);
 //
-// Was event selected ?
-    Bool_t isSelected = kTRUE;
-    if( fInputHandler && fInputHandler->GetEventSelection() && fSelectCollisions) {
-      isSelected = fInputHandler->IsEventSelected();
+// Was event selected ? If no event selection mechanism, the event SHOULD be selected (AG)
+    UInt_t isSelected = AliVEvent::kAny;
+    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();
     }
+//  Functionality below moved in the filter tasks (AG)
+//    if (handler) handler->SetFillAOD(isSelected);
 
-    if (handler) handler->SetFillAOD(isSelected);
-
-    if( fInputHandler ) fEntry = fInputHandler->GetReadEntry();
-  
+    if( fInputHandler ) {
+       fEntry = fInputHandler->GetReadEntry();
+       fESDfriend = ((AliESDInputHandler*)fInputHandler)->GetESDfriend();
+    }
+    
 
 // Notify the change of run number
-    if (InputEvent()->GetRunNumber() != fCurrentRunNumber) {
+    if (InputEvent() && (InputEvent()->GetRunNumber() != fCurrentRunNumber)) {
        fCurrentRunNumber = InputEvent()->GetRunNumber();
        NotifyRun();
     }    
@@ -486,8 +491,16 @@ void AliAnalysisTaskSE::Exec(Option_t* option)
     }
 
 // Call the user analysis    
-    if (!fSelectCollisions || isSelected) 
-       UserExec(option);
+    AliMCEventHandler*    mcH = 0;
+    mcH = (AliMCEventHandler*) ((AliAnalysisManager::GetAnalysisManager())->GetMCtruthEventHandler());
+
+    if (!mcH) {
+       if (isSelected) 
+           UserExec(option);
+    } else {
+       if (isSelected && (mcH->InitOk())) 
+           UserExec(option);
+    }
     
 // Added protection in case the derived task is not an AOD producer.
     AliAnalysisDataSlot *out0 = GetOutputSlot(0);
@@ -507,7 +520,7 @@ const char* AliAnalysisTaskSE::CurrentFileName()
 void AliAnalysisTaskSE::AddAODBranch(const char* cname, void* addobj, const char *fname)
 {
     // Add a new branch to the aod tree
-    AliAODHandler* handler = (AliAODHandler*) 
+    AliAODHandler* handler = dynamic_cast<AliAODHandler*> 
        ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
     if (handler) {
        handler->AddBranch(cname, addobj, fname);
@@ -518,7 +531,7 @@ Bool_t AliAnalysisTaskSE::IsStandardAOD() const
 {
 // Check if the output AOD handler is configured for standard or delta AOD.
 // Users should first check that AODEvent() returns non-null.
-    AliAODHandler* handler = (AliAODHandler*) 
+    AliAODHandler* handler = dynamic_cast<AliAODHandler*> 
          ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
     if (!handler) {
        Error("IsStandardAOD", "No AOD handler. Please use AODEvent() to check this first");