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 MultiAODInputHandler !");
107 // Check that we have an event pool
108 if (!fInputHandler->GetEventPool()) {
109 fInputHandler->SetEventPool(AliAnalysisManager::GetAnalysisManager()->GetEventPool());
110 if (!fInputHandler->GetEventPool())
111 AliFatal("MultiAODInputHandler has no EventPool connected !");
116 void AliAnalysisTaskME::CreateOutputObjects()
118 // Create the output container
121 if (fDebug > 1) printf("AnalysisTaskME::CreateOutPutData() \n");
123 AliAODHandler* handler = (AliAODHandler*)
124 ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
127 fOutputAOD = handler->GetAOD();
128 fTreeA = handler->GetTree();
130 AliWarning("No AOD Event Handler connected.") ;
132 UserCreateOutputObjects();
135 void AliAnalysisTaskME::Exec(Option_t* option)
138 // Exec analysis of one event
140 if (fDebug > 1) AliInfo("AliAnalysisTaskME::Exec() \n");
142 fEntry = fInputHandler->GetReadEntry();
143 if ( !((Entry()-1)%100) && fDebug > 0)
144 AliInfo(Form("%s ----> Processing event # %lld", CurrentFileName(), Entry()));
146 // Call the user analysis
147 if (fInputHandler->IsBufferReady()) {
148 if ((fFreshBufferOnly && fInputHandler->IsFreshBuffer()) || !fFreshBufferOnly)
154 AliInfo(Form("Waiting for buffer to be ready !\n"));
158 const char* AliAnalysisTaskME::CurrentFileName()
160 // Returns the current file name
162 return fInputHandler->GetTree()->GetCurrentFile()->GetName();
166 void AliAnalysisTaskME::AddAODBranch(const char* cname, void* addobj)
168 // Add a new branch to the aod tree
169 AliAODHandler* handler = (AliAODHandler*)
170 ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
172 handler->AddBranch(cname, addobj);
176 AliAODEvent* AliAnalysisTaskME::GetEvent(Int_t iev)
178 // Get an event from the input handler
179 return (fInputHandler->GetEvent(iev));