1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
20 #include <TInterpreter.h>
25 #include "AliAnalysisTaskME.h"
26 #include "AliAnalysisManager.h"
27 #include "AliAODEvent.h"
28 #include "AliAODHandler.h"
29 #include "AliMultiAODInputHandler.h"
33 ClassImp(AliAnalysisTaskME)
35 ////////////////////////////////////////////////////////////////////////
37 AliAnalysisTaskME::AliAnalysisTaskME():
41 fFreshBufferOnly(kFALSE),
46 // Default constructor
49 AliAnalysisTaskME::AliAnalysisTaskME(const char* name):
50 AliAnalysisTask(name, "AnalysisTaskME"),
53 fFreshBufferOnly(kFALSE),
58 // Default constructor
59 DefineInput (0, TChain::Class());
60 DefineOutput(0, TTree::Class());
63 AliAnalysisTaskME::AliAnalysisTaskME(const AliAnalysisTaskME& obj):
67 fFreshBufferOnly(kFALSE),
75 fInputHandler = obj.fInputHandler;
76 fOutputAOD = obj.fOutputAOD;
81 AliAnalysisTaskME& AliAnalysisTaskME::operator=(const AliAnalysisTaskME& other)
84 AliAnalysisTask::operator=(other);
85 fDebug = other.fDebug;
86 fEntry = other.fEntry;
87 fFreshBufferOnly = other.fFreshBufferOnly;
88 fInputHandler = other.fInputHandler;
89 fOutputAOD = other.fOutputAOD;
90 fTreeA = other.fTreeA;
95 void AliAnalysisTaskME::ConnectInputData(Option_t* /*option*/)
97 // Connect the input data
98 if (fDebug > 1) printf("AnalysisTaskME::ConnectInputData() \n");
102 fInputHandler = dynamic_cast<AliMultiAODInputHandler*>
103 ((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
104 if (fInputHandler == 0)
105 AliFatal("Event Handler has to be MultiAODHandler !");
108 void AliAnalysisTaskME::CreateOutputObjects()
110 // Create the output container
113 if (fDebug > 1) printf("AnalysisTaskME::CreateOutPutData() \n");
115 AliAODHandler* handler = (AliAODHandler*)
116 ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
119 fOutputAOD = handler->GetAOD();
120 fTreeA = handler->GetTree();
122 AliWarning("No AOD Event Handler connected.") ;
124 UserCreateOutputObjects();
127 void AliAnalysisTaskME::Exec(Option_t* option)
130 // Exec analysis of one event
131 if (fDebug > 1) AliInfo("AliAnalysisTaskME::Exec() \n");
133 fEntry = fInputHandler->GetReadEntry();
134 if ( !((Entry()-1)%100) && fDebug > 0)
135 AliInfo(Form("%s ----> Processing event # %lld", CurrentFileName(), Entry()));
137 // Call the user analysis
138 if (fInputHandler->IsBufferReady()) {
139 if ((fFreshBufferOnly && fInputHandler->IsFreshBuffer()) || !fFreshBufferOnly)
147 const char* AliAnalysisTaskME::CurrentFileName()
149 // Returns the current file name
151 return fInputHandler->GetTree()->GetCurrentFile()->GetName();
155 void AliAnalysisTaskME::AddAODBranch(const char* cname, void* addobj)
157 // Add a new branch to the aod tree
158 AliAODHandler* handler = (AliAODHandler*)
159 ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
161 handler->AddBranch(cname, addobj);
165 AliAODEvent* AliAnalysisTaskME::GetEvent(Int_t iev)
167 // Get an event from the input handler
168 return (fInputHandler->GetEvent(iev));