]>
Commit | Line | Data |
---|---|---|
5eb970a4 | 1 | // |
2 | // Class AliRsnVAnalysisTaskSE | |
3 | // | |
4 | // Virtual Class derivated from AliAnalysisTaskSE which will be base class | |
5 | // for all RSN SE tasks | |
6 | // | |
7 | // authors: Martin Vala (martin.vala@cern.ch) | |
8 | // Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it) | |
9 | // | |
10 | ||
e5207445 | 11 | #include <Riostream.h> |
12 | ||
4fbb2459 | 13 | #include "AliESDEvent.h" |
14 | #include "AliMCEvent.h" | |
15 | #include "AliAODEvent.h" | |
968abd78 | 16 | #include "AliRsnEvent.h" |
5faf5a07 | 17 | #include "AliRsnTarget.h" |
18 | ||
19 | #include "AliRsnVAnalysisTaskSE.h" | |
4fbb2459 | 20 | |
5eb970a4 | 21 | ClassImp(AliRsnVAnalysisTaskSE) |
22 | ||
23 | //_____________________________________________________________________________ | |
4fbb2459 | 24 | AliRsnVAnalysisTaskSE::AliRsnVAnalysisTaskSE |
2dab9030 | 25 | (const char *name, Bool_t mcOnly) : |
2a1c7696 | 26 | AliAnalysisTaskSE(name), |
27 | fLogType(AliLog::kInfo), | |
28 | fLogClassesString(""), | |
29 | fESDEvent(0x0), | |
30 | fMCEvent(0x0), | |
31 | fAODEventIn(0x0), | |
32 | fAODEventOut(0x0), | |
33 | fMCOnly(mcOnly), | |
34 | fRsnEvent(), | |
35 | fInfoList(0x0), | |
36 | fTaskInfo(name) | |
5eb970a4 | 37 | { |
38 | // | |
39 | // Default constructor. | |
40 | // Define the output slot for histograms. | |
41 | // | |
42 | ||
2a1c7696 | 43 | DefineOutput(1, TList::Class()); |
44 | DefineOutput(2, TList::Class()); | |
5eb970a4 | 45 | } |
46 | ||
47 | //_____________________________________________________________________________ | |
4fbb2459 | 48 | AliRsnVAnalysisTaskSE::AliRsnVAnalysisTaskSE(const AliRsnVAnalysisTaskSE& copy) : |
2a1c7696 | 49 | AliAnalysisTaskSE(copy), |
50 | fLogType(copy.fLogType), | |
51 | fLogClassesString(copy.fLogClassesString), | |
52 | fESDEvent(copy.fESDEvent), | |
53 | fMCEvent(copy.fMCEvent), | |
54 | fAODEventIn(copy.fAODEventIn), | |
55 | fAODEventOut(copy.fAODEventOut), | |
56 | fMCOnly(copy.fMCOnly), | |
57 | fRsnEvent(), | |
58 | fInfoList(0x0), | |
59 | fTaskInfo(copy.fTaskInfo) | |
5eb970a4 | 60 | { |
61 | // | |
62 | // Copy constructor. | |
63 | // Defined for coding conventions compliance but never used. | |
64 | // | |
5eb970a4 | 65 | } |
66 | ||
67 | //_____________________________________________________________________________ | |
68 | void AliRsnVAnalysisTaskSE::LocalInit() | |
69 | { | |
70 | // | |
71 | // Local initialization. | |
72 | // Defines the debug message level and calls the mother class LocalInit(). | |
73 | // | |
74 | ||
2a1c7696 | 75 | AliAnalysisTaskSE::LocalInit(); |
76 | SetDebugForAllClasses(); | |
5eb970a4 | 77 | } |
78 | ||
79 | //_____________________________________________________________________________ | |
cf4668f7 | 80 | Bool_t AliRsnVAnalysisTaskSE::UserNotify() |
5eb970a4 | 81 | { |
82 | // | |
83 | // Calls the mother class Notify() | |
84 | // | |
85 | ||
2a1c7696 | 86 | return AliAnalysisTaskSE::UserNotify(); |
5eb970a4 | 87 | } |
88 | ||
89 | //_____________________________________________________________________________ | |
90 | void AliRsnVAnalysisTaskSE::ConnectInputData(Option_t *opt) | |
91 | { | |
92 | // | |
5faf5a07 | 93 | // Connect input data, which consist in initializing properly |
94 | // the pointer to the input event, which is dynamically casted | |
95 | // to all available types, and this allows to know its type. | |
96 | // Calls also the mother class omonyme method. | |
2a1c7696 | 97 | // |
98 | ||
99 | AliAnalysisTaskSE::ConnectInputData(opt); | |
100 | ||
101 | // get AliESDEvent and, if successful | |
102 | // retrieve the corresponding MC if exists | |
103 | fESDEvent = dynamic_cast<AliESDEvent *>(fInputEvent); | |
104 | if (fESDEvent) { | |
105 | fMCEvent = (AliMCEvent*) MCEvent(); | |
106 | AliInfo(Form("Input event is of type ESD (%p)", fESDEvent)); | |
107 | if (fMCEvent) AliInfo(Form("Input has an associated MC (%p)", fMCEvent)); | |
108 | } | |
109 | ||
110 | // get AliAODEvent from input and, if successful | |
111 | // it will contain both the reconstructed and MC informations | |
112 | fAODEventIn = dynamic_cast<AliAODEvent *>(fInputEvent); | |
113 | if (fAODEventIn) { | |
114 | AliInfo(Form("Input event if of type native AOD (%p)", fAODEventIn)); | |
115 | } | |
116 | ||
117 | // get AliAODEvent from output of previous task | |
118 | fAODEventOut = dynamic_cast<AliAODEvent *>(AODEvent()); | |
119 | if (fAODEventOut) { | |
120 | AliInfo(Form("Input event if of type produced AOD from previous step (%p)", fAODEventOut)); | |
121 | } | |
5eb970a4 | 122 | } |
123 | ||
124 | //_____________________________________________________________________________ | |
125 | void AliRsnVAnalysisTaskSE::UserCreateOutputObjects() | |
126 | { | |
127 | // | |
128 | // Creates and links to task all output objects. | |
5faf5a07 | 129 | // Does explicitly the initialization for the event info class, |
130 | // and then calls the customized function which must be overloaded | |
131 | // in the applications of this base class. | |
5eb970a4 | 132 | // |
133 | ||
2a1c7696 | 134 | SetDebugForAllClasses(); |
5eb970a4 | 135 | |
2a1c7696 | 136 | // set event info outputs |
137 | fInfoList = new TList(); | |
138 | fInfoList->SetOwner(); | |
139 | fTaskInfo.GenerateInfoList(fInfoList); | |
5eb970a4 | 140 | |
2a1c7696 | 141 | // create customized outputs |
142 | RsnUserCreateOutputObjects(); | |
143 | ||
144 | PostData(1, fInfoList); | |
5eb970a4 | 145 | } |
146 | ||
147 | //_____________________________________________________________________________ | |
148 | void AliRsnVAnalysisTaskSE::UserExec(Option_t* opt) | |
149 | { | |
4fbb2459 | 150 | // |
5faf5a07 | 151 | // Prepares for execution, setting the correct pointers of the |
152 | // RSN package event interface, which will point to the not NULL | |
153 | // objects obtained from dynamic-casts called in ConnectInputData(). | |
4fbb2459 | 154 | // |
5eb970a4 | 155 | |
2a1c7696 | 156 | if (fMCOnly && fMCEvent) { |
157 | fRsnEvent.SetRef(fMCEvent); | |
158 | fRsnEvent.SetRefMC(fMCEvent); | |
159 | } else if (fESDEvent) { | |
160 | fRsnEvent.SetRef(fESDEvent); | |
161 | fRsnEvent.SetRefMC(fMCEvent); | |
162 | } else if (fAODEventOut) { | |
163 | fRsnEvent.SetRef(fAODEventOut); | |
164 | fRsnEvent.SetRefMC(fAODEventOut); | |
165 | } else if (fAODEventIn) { | |
166 | fRsnEvent.SetRef(fAODEventIn); | |
167 | fRsnEvent.SetRefMC(fAODEventIn); | |
168 | } else { | |
169 | AliError("Unknown input event format. Skipping"); | |
170 | return; | |
171 | } | |
172 | ||
173 | // since this class is for single-event analysis | |
174 | // both static pointers of AliRsnEvent class | |
175 | // will point to the same unique datamember | |
176 | AliRsnEvent::SetCurrentEvent1(&fRsnEvent, fEntry); | |
177 | AliRsnEvent::SetCurrentEvent2(&fRsnEvent, fEntry); | |
178 | AliRsnTarget::SwitchToFirst(); | |
179 | ||
180 | // call event preprocessing... | |
181 | Bool_t preCheck = EventProcess(); | |
182 | // ...then fill the information object and print informations... | |
183 | fTaskInfo.FillInfo(); | |
184 | fTaskInfo.PrintInfo(fTaskInfo.GetNumerOfEventsProcessed()); | |
185 | // ...and return if event did not pass selections | |
186 | if (!preCheck) { | |
187 | AliDebug(AliLog::kDebug, "Event preprocessing has failed. Skipping event"); | |
188 | return; | |
189 | } | |
190 | ||
191 | ||
192 | // call customized implementation for execution | |
193 | RsnUserExec(opt); | |
194 | ||
195 | // post outputs for the info object | |
196 | // (eventually others are done in the derived classes) | |
197 | PostData(1, fInfoList); | |
5eb970a4 | 198 | } |
199 | ||
200 | //_____________________________________________________________________________ | |
201 | void AliRsnVAnalysisTaskSE::Terminate(Option_t* opt) | |
202 | { | |
203 | // | |
204 | // Termination routines. | |
205 | // Stores all histograms (after checking they exist) | |
206 | // and includes to the TList all task informations. | |
207 | // | |
208 | ||
2a1c7696 | 209 | AliAnalysisTask::Terminate(); |
210 | ||
211 | TList* list = dynamic_cast<TList*>(GetOutputData(1)); | |
212 | if (!list) { | |
213 | AliError(Form("At end of analysis, fOutList is %p", list)); | |
214 | return; | |
215 | } | |
216 | ||
217 | RsnTerminate(opt); | |
218 | ||
219 | TH1I *hEventInfo = (TH1I*) list->FindObject(fTaskInfo.GetEventHistogramName()); | |
220 | if (!hEventInfo) { | |
221 | AliError(Form("hEventInfo is %p", hEventInfo)); | |
222 | return; | |
223 | } | |
224 | AliInfo(Form("=== %s ==================", GetName())); | |
225 | AliInfo(Form("Number Of Events Processed : %10lld", (Long64_t)hEventInfo->Integral())); | |
226 | AliInfo(Form("Number Of Events Accepted : %10lld", (Long64_t)hEventInfo->GetBinContent(2))); | |
227 | AliInfo(Form("Number Of Events Skipped : %10lld", (Long64_t)hEventInfo->GetBinContent(1))); | |
228 | AliInfo(Form("=== end %s ==============", GetName())); | |
229 | ||
230 | AliDebug(AliLog::kDebug + 2, "->"); | |
5eb970a4 | 231 | } |
232 | ||
233 | //_____________________________________________________________________________ | |
5faf5a07 | 234 | void AliRsnVAnalysisTaskSE::RsnUserCreateOutputObjects() |
5eb970a4 | 235 | { |
236 | // | |
5faf5a07 | 237 | // Define here all instructions to create output objects. |
238 | // This method will be called inside the "UserCreateOutputObjects" | |
239 | // in the used task. | |
5eb970a4 | 240 | // |
241 | ||
2a1c7696 | 242 | AliWarning("Implement this in derived classes"); |
5eb970a4 | 243 | } |
244 | ||
245 | //_____________________________________________________________________________ | |
5faf5a07 | 246 | void AliRsnVAnalysisTaskSE::RsnUserExec(Option_t*) |
5eb970a4 | 247 | { |
248 | // | |
5faf5a07 | 249 | // |
5eb970a4 | 250 | // |
251 | ||
2a1c7696 | 252 | AliWarning("Implement this in derived classes"); |
5eb970a4 | 253 | } |
254 | ||
fec82aba | 255 | //_____________________________________________________________________________ |
5faf5a07 | 256 | void AliRsnVAnalysisTaskSE::RsnTerminate(Option_t*) |
fec82aba | 257 | { |
258 | // | |
5faf5a07 | 259 | // Overload this to add additional termination operations |
fec82aba | 260 | // |
5faf5a07 | 261 | |
2a1c7696 | 262 | AliWarning("Implement this in derived classes"); |
fec82aba | 263 | } |
264 | ||
5eb970a4 | 265 | //_____________________________________________________________________________ |
5faf5a07 | 266 | Bool_t AliRsnVAnalysisTaskSE::EventProcess() |
5eb970a4 | 267 | { |
268 | // | |
5faf5a07 | 269 | // Performs some pre-processing of current event, |
2a1c7696 | 270 | // which is useful for all the operations which |
5faf5a07 | 271 | // need to be done only once for each event. |
5eb970a4 | 272 | // |
2a1c7696 | 273 | |
274 | // in this case, return always a success | |
275 | return kTRUE; | |
5eb970a4 | 276 | } |
277 | ||
278 | //_____________________________________________________________________________ | |
9477aa42 | 279 | void AliRsnVAnalysisTaskSE::SetDebugForAllClasses() |
5eb970a4 | 280 | { |
281 | // | |
282 | // Set debug level for all classes for which it is required | |
283 | // | |
284 | ||
2a1c7696 | 285 | TObjArray *array = fLogClassesString.Tokenize(":"); |
286 | TObjString *objStr; | |
287 | TString str; | |
288 | Int_t i, n = array->GetEntriesFast(); | |
289 | ||
290 | for (i = 0; i < n; i++) { | |
291 | objStr = (TObjString*)array->At(i); | |
292 | str = objStr->GetString(); | |
293 | AliLog::SetClassDebugLevel(str.Data(), fLogType); | |
294 | AliInfo(Form("Setting Debug to %s", str.Data())); | |
295 | } | |
5eb970a4 | 296 | } |
2dab9030 | 297 |