]>
Commit | Line | Data |
---|---|---|
5232d0de | 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 "AliAnalysisTaskSE.h" | |
26 | #include "AliAnalysisManager.h" | |
27 | #include "AliESDEvent.h" | |
28 | #include "AliESD.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" | |
35 | #include "AliStack.h" | |
4d0a82af | 36 | #include "AliLog.h" |
5232d0de | 37 | |
38 | ||
39 | ClassImp(AliAnalysisTaskSE) | |
40 | ||
41 | //////////////////////////////////////////////////////////////////////// | |
42 | ||
43 | AliAnalysisTaskSE::AliAnalysisTaskSE(): | |
44 | AliAnalysisTask(), | |
45 | fDebug(0), | |
80d13558 | 46 | fEntry(0), |
5232d0de | 47 | fInputEvent(0x0), |
80d13558 | 48 | fInputHandler(0x0), |
5232d0de | 49 | fOutputAOD(0x0), |
50 | fMCEvent(0x0), | |
51 | fTreeA(0x0) | |
52 | { | |
53 | // Default constructor | |
54 | } | |
55 | ||
56 | AliAnalysisTaskSE::AliAnalysisTaskSE(const char* name): | |
57 | AliAnalysisTask(name, "AnalysisTaskSE"), | |
58 | fDebug(0), | |
80d13558 | 59 | fEntry(0), |
5232d0de | 60 | fInputEvent(0x0), |
80d13558 | 61 | fInputHandler(0x0), |
5232d0de | 62 | fOutputAOD(0x0), |
63 | fMCEvent(0x0), | |
64 | fTreeA(0x0) | |
65 | { | |
66 | // Default constructor | |
67 | DefineInput (0, TChain::Class()); | |
68 | DefineOutput(0, TTree::Class()); | |
69 | } | |
70 | ||
26f071d8 | 71 | AliAnalysisTaskSE::AliAnalysisTaskSE(const AliAnalysisTaskSE& obj): |
72 | AliAnalysisTask(obj), | |
73 | fDebug(0), | |
80d13558 | 74 | fEntry(0), |
26f071d8 | 75 | fInputEvent(0x0), |
80d13558 | 76 | fInputHandler(0x0), |
26f071d8 | 77 | fOutputAOD(0x0), |
78 | fMCEvent(0x0), | |
79 | fTreeA(0x0) | |
80 | { | |
81 | // Copy constructor | |
80d13558 | 82 | fDebug = obj.fDebug; |
83 | fEntry = obj.fEntry; | |
84 | fInputEvent = obj.fInputEvent; | |
85 | fInputHandler = obj.fInputHandler; | |
86 | fOutputAOD = obj.fOutputAOD; | |
87 | fMCEvent = obj.fMCEvent; | |
88 | fTreeA = obj.fTreeA; | |
f0b15803 | 89 | printf("Constructor (3) \n"); |
26f071d8 | 90 | } |
91 | ||
92 | ||
93 | AliAnalysisTaskSE& AliAnalysisTaskSE::operator=(const AliAnalysisTaskSE& other) | |
94 | { | |
95 | // Assignment | |
96 | AliAnalysisTask::operator=(other); | |
80d13558 | 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; | |
26f071d8 | 104 | return *this; |
105 | } | |
5232d0de | 106 | |
107 | ||
108 | void AliAnalysisTaskSE::ConnectInputData(Option_t* /*option*/) | |
109 | { | |
110 | // Connect the input data | |
111 | if (fDebug > 1) printf("AnalysisTaskSE::ConnectInputData() \n"); | |
112 | // | |
113 | // ESD | |
114 | // | |
f0b15803 | 115 | fInputHandler = (AliInputEventHandler*) |
259b7a8a | 116 | ((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler()); |
5232d0de | 117 | // |
118 | // Monte Carlo | |
119 | // | |
120 | AliMCEventHandler* mcH = 0; | |
121 | mcH = (AliMCEventHandler*) ((AliAnalysisManager::GetAnalysisManager())->GetMCtruthEventHandler()); | |
122 | if (mcH) fMCEvent = mcH->MCEvent(); | |
259b7a8a | 123 | |
124 | ||
125 | if (fInputHandler) { | |
126 | fInputEvent = fInputHandler->GetEvent(); | |
127 | } else if( fMCEvent ) { | |
128 | AliWarning("No Input Event Handler connected, only MC Truth Event Handler") ; | |
129 | } else { | |
130 | AliError("No Input Event Handler connected") ; | |
131 | return ; | |
132 | } | |
5232d0de | 133 | } |
134 | ||
135 | void AliAnalysisTaskSE::CreateOutputObjects() | |
136 | { | |
137 | // Create the output container | |
138 | // | |
139 | // Default AOD | |
140 | if (fDebug > 1) printf("AnalysisTaskSE::CreateOutPutData() \n"); | |
141 | ||
142 | AliAODHandler* handler = (AliAODHandler*) | |
259b7a8a | 143 | ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler()); |
5232d0de | 144 | |
145 | fOutputAOD = handler->GetAOD(); | |
146 | fTreeA = handler->GetTree(); | |
147 | UserCreateOutputObjects(); | |
148 | } | |
149 | ||
150 | void AliAnalysisTaskSE::Exec(Option_t* option) | |
151 | { | |
152 | // | |
153 | // Exec analysis of one event | |
259b7a8a | 154 | if (fDebug > 1) AliInfo("AliAnalysisTaskSE::Exec() \n"); |
155 | if( fInputHandler ) | |
156 | fEntry = fInputHandler->GetReadEntry(); | |
157 | else if( fMCEvent ) | |
158 | fEntry = fMCEvent->Header()->GetEvent(); | |
4d0a82af | 159 | if ( !((Entry()-1)%100) && fDebug > 0) |
259b7a8a | 160 | AliInfo(Form("%s ----> Processing event # %lld", CurrentFileName(), Entry())); |
161 | ||
4d0a82af | 162 | // Call the user analysis |
5232d0de | 163 | UserExec(option); |
2d108f6e | 164 | PostData(0, fTreeA); |
165 | ||
5232d0de | 166 | } |
167 | ||
4d0a82af | 168 | const char* AliAnalysisTaskSE::CurrentFileName() |
169 | { | |
170 | // Returns the current file name | |
259b7a8a | 171 | if( fInputHandler ) |
172 | return fInputHandler->GetTree()->GetCurrentFile()->GetName(); | |
173 | else if( fMCEvent ) | |
174 | return ((AliMCEventHandler*) ((AliAnalysisManager::GetAnalysisManager())->GetMCtruthEventHandler()))->TreeK()->GetCurrentFile()->GetName(); | |
175 | else ""; | |
4d0a82af | 176 | } |
5232d0de | 177 |