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 "AliAnalysisTaskSE.h"
26 #include "AliAnalysisManager.h"
27 #include "AliESDEvent.h"
29 #include "AliAODEvent.h"
30 #include "AliVEvent.h"
31 #include "AliAODHandler.h"
32 #include "AliMCEventHandler.h"
33 #include "AliInputEventHandler.h"
34 #include "AliMCEvent.h"
39 ClassImp(AliAnalysisTaskSE)
41 ////////////////////////////////////////////////////////////////////////
43 AliAnalysisTaskSE::AliAnalysisTaskSE():
53 // Default constructor
56 AliAnalysisTaskSE::AliAnalysisTaskSE(const char* name):
57 AliAnalysisTask(name, "AnalysisTaskSE"),
66 // Default constructor
67 DefineInput (0, TChain::Class());
68 DefineOutput(0, TTree::Class());
71 AliAnalysisTaskSE::AliAnalysisTaskSE(const AliAnalysisTaskSE& obj):
84 fInputEvent = obj.fInputEvent;
85 fInputHandler = obj.fInputHandler;
86 fOutputAOD = obj.fOutputAOD;
87 fMCEvent = obj.fMCEvent;
89 printf("Constructor (3) \n");
93 AliAnalysisTaskSE& AliAnalysisTaskSE::operator=(const AliAnalysisTaskSE& other)
96 AliAnalysisTask::operator=(other);
97 fDebug = other.fDebug;
98 fEntry = other.fEntry;
99 fInputEvent = other.fInputEvent;
100 fInputHandler = other.fInputHandler;
101 fOutputAOD = other.fOutputAOD;
102 fMCEvent = other.fMCEvent;
103 fTreeA = other.fTreeA;
108 void AliAnalysisTaskSE::ConnectInputData(Option_t* /*option*/)
110 // Connect the input data
111 if (fDebug > 1) printf("AnalysisTaskSE::ConnectInputData() \n");
115 fInputHandler = (AliInputEventHandler*)
116 ((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
120 AliMCEventHandler* mcH = 0;
121 mcH = (AliMCEventHandler*) ((AliAnalysisManager::GetAnalysisManager())->GetMCtruthEventHandler());
122 if (mcH) fMCEvent = mcH->MCEvent();
126 fInputEvent = fInputHandler->GetEvent();
127 } else if( fMCEvent ) {
128 AliWarning("No Input Event Handler connected, only MC Truth Event Handler") ;
130 AliError("No Input Event Handler connected") ;
135 void AliAnalysisTaskSE::CreateOutputObjects()
137 // Create the output container
140 if (fDebug > 1) printf("AnalysisTaskSE::CreateOutPutData() \n");
142 AliAODHandler* handler = (AliAODHandler*)
143 ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
146 fOutputAOD = handler->GetAOD();
147 fTreeA = handler->GetTree();
149 AliWarning("No AOD Event Handler connected.") ;
151 UserCreateOutputObjects();
154 void AliAnalysisTaskSE::Exec(Option_t* option)
157 // Exec analysis of one event
158 if (fDebug > 1) AliInfo("AliAnalysisTaskSE::Exec() \n");
160 fEntry = fInputHandler->GetReadEntry();
162 fEntry = fMCEvent->Header()->GetEvent();
163 if ( !((Entry()-1)%100) && fDebug > 0)
164 AliInfo(Form("%s ----> Processing event # %lld", CurrentFileName(), Entry()));
166 // Call the user analysis
172 const char* AliAnalysisTaskSE::CurrentFileName()
174 // Returns the current file name
176 return fInputHandler->GetTree()->GetCurrentFile()->GetName();
178 return ((AliMCEventHandler*) ((AliAnalysisManager::GetAnalysisManager())->GetMCtruthEventHandler()))->TreeK()->GetCurrentFile()->GetName();
182 void AliAnalysisTaskSE::AddAODBranch(const char* cname, void* addobj)
184 // Add a new branch to the aod tree
185 AliAODHandler* handler = (AliAODHandler*)
186 ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
188 handler->AddBranch(cname, addobj);