LCOV - code coverage report
Current view: top level - ANALYSIS/ANALYSISalice - AliAnalysisTaskME.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 106 0.9 %
Date: 2016-06-14 17:26:59 Functions: 1 14 7.1 %

          Line data    Source code
       1             : /**************************************************************************
       2             :  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
       3             :  *                                                                        *
       4             :  * Author: The ALICE Off-line Project.                                    *
       5             :  * Contributors are mentioned in the code where appropriate.              *
       6             :  *                                                                        *
       7             :  * Permission to use, copy, modify and distribute this software and its   *
       8             :  * documentation strictly for non-commercial purposes is hereby granted   *
       9             :  * without fee, provided that the above copyright notice appears in all   *
      10             :  * copies and that both the copyright notice and this permission notice   *
      11             :  * appear in the supporting documentation. The authors make no claims     *
      12             :  * about the suitability of this software for any purpose. It is          *
      13             :  * provided "as is" without express or implied warranty.                  *
      14             :  **************************************************************************/
      15             : 
      16             : /* $Id$ */
      17             :  
      18             : #include <TROOT.h>
      19             : #include <TSystem.h>
      20             : #include <TInterpreter.h>
      21             : #include <TChain.h>
      22             : #include <TFile.h>
      23             : #include <TList.h>
      24             : 
      25             : #include "AliAnalysisTaskME.h"
      26             : #include "AliAnalysisManager.h"
      27             : #include "AliAnalysisDataSlot.h"
      28             : #include "AliAODEvent.h"
      29             : #include "AliVEvent.h"
      30             : #include "AliAODHandler.h"
      31             : #include "AliMultiEventInputHandler.h"
      32             : #include "AliLog.h"
      33             : 
      34             : 
      35         170 : ClassImp(AliAnalysisTaskME)
      36             : 
      37             : ////////////////////////////////////////////////////////////////////////
      38             : 
      39             : AliAnalysisTaskME::AliAnalysisTaskME():
      40           0 :     AliAnalysisTask(),
      41           0 :     fDebug(0),
      42           0 :     fEntry(0),
      43           0 :     fFreshBufferOnly(kFALSE),
      44           0 :     fInputHandler(0x0),
      45           0 :     fOutputAOD(0x0),
      46           0 :     fTreeA(0x0),
      47           0 :     fOfflineTriggerMask(0)
      48           0 : {
      49             :   // Default constructor
      50           0 : }
      51             : 
      52             : AliAnalysisTaskME::AliAnalysisTaskME(const char* name):
      53           0 :     AliAnalysisTask(name, "AnalysisTaskME"),
      54           0 :     fDebug(0),
      55           0 :     fEntry(0),
      56           0 :     fFreshBufferOnly(kFALSE),
      57           0 :     fInputHandler(0x0),
      58           0 :     fOutputAOD(0x0),
      59           0 :     fTreeA(0x0),
      60           0 :     fOfflineTriggerMask(0)
      61           0 : {
      62             :   // Default constructor
      63           0 :     DefineInput (0, TChain::Class());
      64           0 :     DefineOutput(0,  TTree::Class());
      65           0 : }
      66             : 
      67             : AliAnalysisTaskME::AliAnalysisTaskME(const AliAnalysisTaskME& obj):
      68           0 :     AliAnalysisTask(obj),
      69           0 :     fDebug(0),
      70           0 :     fEntry(0),
      71           0 :     fFreshBufferOnly(kFALSE),
      72           0 :     fInputHandler(0x0),
      73           0 :     fOutputAOD(0x0),
      74           0 :     fTreeA(0x0),
      75           0 :     fOfflineTriggerMask(0)
      76           0 : {
      77             : // Copy constructor
      78           0 :     fDebug        = obj.fDebug;
      79           0 :     fEntry        = obj.fEntry;
      80           0 :     fInputHandler = obj.fInputHandler;
      81           0 :     fOutputAOD    = obj.fOutputAOD;
      82           0 :     fTreeA        = obj.fTreeA; 
      83           0 :     fOfflineTriggerMask = obj.fOfflineTriggerMask;
      84           0 : }
      85             : 
      86             : 
      87             : AliAnalysisTaskME& AliAnalysisTaskME::operator=(const AliAnalysisTaskME& other)
      88             : {
      89             : // Assignment
      90           0 :     if (this != &other) {
      91           0 :         AliAnalysisTask::operator=(other);
      92           0 :         fDebug           = other.fDebug;
      93           0 :         fEntry           = other.fEntry;
      94           0 :         fFreshBufferOnly = other.fFreshBufferOnly;
      95           0 :         fInputHandler    = other.fInputHandler;
      96           0 :         fOutputAOD       = other.fOutputAOD;
      97           0 :         fTreeA           = other.fTreeA;    
      98           0 :         fOfflineTriggerMask = other.fOfflineTriggerMask;
      99           0 :     }
     100           0 :     return *this;
     101             : }
     102             : 
     103             : 
     104             : void AliAnalysisTaskME::ConnectInputData(Option_t* /*option*/)
     105             : {
     106             : // Connect the input data
     107           0 :     if (fDebug > 1) printf("AnalysisTaskME::ConnectInputData() \n");
     108             : //
     109             : //  Multi AOD
     110             : //
     111           0 :     fInputHandler = dynamic_cast<AliMultiEventInputHandler*> 
     112           0 :         ((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
     113           0 :     if (fInputHandler == 0) {
     114           0 :         AliFatal("Event Handler has to be MultiEventInputHandler !");
     115           0 :     } else {
     116             :         // Check that we have an event pool
     117           0 :         if (!fInputHandler->GetEventPool()) {
     118           0 :             fInputHandler->SetEventPool(AliAnalysisManager::GetAnalysisManager()->GetEventPool());
     119           0 :             if (!fInputHandler->GetEventPool()) 
     120           0 :                 AliFatal("MultiEventInputHandler has no EventPool connected !");
     121             :         }
     122             :     }
     123           0 : }
     124             : 
     125             : void AliAnalysisTaskME::CreateOutputObjects()
     126             : {
     127             : // Create the output container
     128             : //
     129             : //  Default AOD
     130           0 :     if (fDebug > 1) printf("AnalysisTaskME::CreateOutPutData() \n");
     131             : 
     132           0 :     AliAODHandler* handler = (AliAODHandler*) 
     133           0 :         ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
     134             :     
     135           0 :     if (handler) {
     136           0 :         fOutputAOD   = handler->GetAOD();
     137           0 :         fTreeA = handler->GetTree();
     138           0 :     } else {
     139           0 :         AliWarning("No AOD Event Handler connected.") ; 
     140             :     }
     141           0 :     UserCreateOutputObjects();
     142           0 : }
     143             : 
     144             : void AliAnalysisTaskME::Exec(Option_t* option)
     145             : {
     146             : //
     147             : // Exec analysis of one event
     148             : 
     149           0 :     if (fDebug > 1) AliInfo("AliAnalysisTaskME::Exec() \n");
     150           0 :     if( fInputHandler ) 
     151           0 :        fEntry = fInputHandler->GetReadEntry();
     152           0 :     if ( !((Entry()-1)%100) && fDebug > 0) 
     153           0 :          AliInfo(Form("%s ----> Processing event # %lld", CurrentFileName(), Entry()));
     154             : 
     155           0 :     AliAODHandler* outputHandler = (AliAODHandler*) 
     156           0 :         ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());         
     157             : //
     158             : // Was event selected ? If no event selection mechanism, the event SHOULD be selected (AG)
     159             :     UInt_t isSelected = AliVEvent::kAny;
     160           0 :     if(fInputHandler && fInputHandler->GetEventSelection()) {
     161             :       // Get the actual offline trigger mask for the event and AND it with the
     162             :       // requested mask. If no mask requested select by default the event.
     163           0 :       if (fOfflineTriggerMask)
     164           0 :         isSelected = fOfflineTriggerMask & fInputHandler->IsEventSelected();
     165             :     }
     166             :     
     167           0 :     if (!isSelected) { 
     168           0 :         if (fDebug > 1) AliInfo("Event rejected \n");
     169           0 :         fInputHandler->EventSkipped();
     170           0 :         return;
     171             :     }
     172             : // Call the user analysis    
     173             :     
     174           0 :     if (fInputHandler && fInputHandler->IsBufferReady()) {
     175           0 :         if ((fFreshBufferOnly && fInputHandler->IsFreshBuffer()) || !fFreshBufferOnly)
     176             :         {
     177           0 :             if (outputHandler) outputHandler->SetFillAOD(kTRUE);
     178           0 :             UserExec(option);
     179             :             // Added protection in case the derived task is not an AOD producer.
     180           0 :             AliAnalysisDataSlot *out0 = GetOutputSlot(0);
     181           0 :             if (out0 && out0->IsConnected()) PostData(0, fTreeA);
     182           0 :         } else {
     183           0 :             if (outputHandler) outputHandler->SetFillAOD(kFALSE);
     184             :         }
     185             :     } else {
     186           0 :         AliInfo(Form("Waiting for buffer to be ready !\n"));
     187             :     }
     188           0 : }
     189             : 
     190             : const char* AliAnalysisTaskME::CurrentFileName()
     191             : {
     192             : // Returns the current file name    
     193           0 :     if(fInputHandler )
     194           0 :         return fInputHandler->GetTree()->GetCurrentFile()->GetName();
     195           0 :     else return "";
     196           0 : }
     197             : 
     198             : void AliAnalysisTaskME::AddAODBranch(const char* cname, void* addobj, const char *fname)
     199             : {
     200             :     // Add a new branch to the aod tree
     201           0 :     AliAODHandler* handler = (AliAODHandler*) 
     202           0 :         ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
     203           0 :     if (handler) {
     204           0 :         handler->AddBranch(cname, addobj, fname);
     205           0 :     }
     206           0 : }
     207             : 
     208             : AliVEvent*  AliAnalysisTaskME::GetEvent(Int_t iev)
     209             : {
     210             :     // Get an event from the input handler
     211           0 :     return (fInputHandler->GetEvent(iev));
     212             : }
     213             : 

Generated by: LCOV version 1.11