]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG2/RESONANCES/AliRsnVAnalysisTaskSE.cxx
fix for bug #70582 (change from L. Molnar)
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnVAnalysisTaskSE.cxx
CommitLineData
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
11#include "AliRsnVAnalysisTaskSE.h"
12
4fbb2459 13#include "AliESDEvent.h"
14#include "AliMCEvent.h"
15#include "AliAODEvent.h"
16
5eb970a4 17ClassImp(AliRsnVAnalysisTaskSE)
18
19//_____________________________________________________________________________
4fbb2459 20AliRsnVAnalysisTaskSE::AliRsnVAnalysisTaskSE
21(const char *name, Int_t numOfOutputs, Bool_t mcOnly) :
22 AliAnalysisTaskSE(name),
23 fLogType(AliLog::kInfo),
24 fLogClassesString(""),
25 fESDEvent(0x0),
26 fMCEvent(0x0),
27 fAODEventIn(0x0),
28 fAODEventOut(0x0),
29 fMCOnly(mcOnly),
30 fRsnEvent(),
31 fRsnPIDIndex(),
32 fNumberOfOutputs(numOfOutputs),
33 fTaskInfo(name)
5eb970a4 34{
35//
36// Default constructor.
37// Define the output slot for histograms.
38//
39
40 AliDebug(AliLog::kDebug+2,"<-");
41
4fbb2459 42 if (fNumberOfOutputs<0) fNumberOfOutputs = 0;
43 if (fNumberOfOutputs>kMaxNumberOfOutputs) {
44 AliWarning(Form("We support only %d outputs. If you need more ask for it.",kMaxNumberOfOutputs));
45 AliWarning(Form("For now we are setting it to %d.",kMaxNumberOfOutputs));
46 fNumberOfOutputs = kMaxNumberOfOutputs;
47 }
48
5eb970a4 49 DefineOutput(1, TList::Class());
50
51 AliDebug(AliLog::kDebug+2,"->");
52}
53
54//_____________________________________________________________________________
4fbb2459 55AliRsnVAnalysisTaskSE::AliRsnVAnalysisTaskSE(const AliRsnVAnalysisTaskSE& copy) :
56 AliAnalysisTaskSE(copy),
57 fLogType(copy.fLogType),
58 fLogClassesString(copy.fLogClassesString),
59 fESDEvent(copy.fESDEvent),
60 fMCEvent(copy.fMCEvent),
61 fAODEventIn(copy.fAODEventIn),
62 fAODEventOut(copy.fAODEventOut),
63 fMCOnly(copy.fMCOnly),
64 fRsnEvent(),
65 fRsnPIDIndex(),
66 fNumberOfOutputs(copy.fNumberOfOutputs),
67 fTaskInfo(copy.fTaskInfo)
5eb970a4 68{
69//
70// Copy constructor.
71// Defined for coding conventions compliance but never used.
72//
73
74 AliDebug(AliLog::kDebug+2, "<-");
75 AliDebug(AliLog::kDebug+2, "->");
76}
77
78//_____________________________________________________________________________
79void AliRsnVAnalysisTaskSE::LocalInit()
80{
81//
82// Local initialization.
83// Defines the debug message level and calls the mother class LocalInit().
84//
85
9477aa42 86 SetDebugForAllClasses();
5eb970a4 87
88 AliDebug(AliLog::kDebug+2, "<-");
89 AliAnalysisTaskSE::LocalInit();
90 AliDebug(AliLog::kDebug+2, "->");
91}
92
93//_____________________________________________________________________________
94Bool_t AliRsnVAnalysisTaskSE::Notify()
95{
96//
97// Calls the mother class Notify()
98//
99
100 AliDebug(AliLog::kDebug+2,"<-");
101 AliDebug(AliLog::kDebug+2,"->");
102
103 return AliAnalysisTaskSE::Notify();
104}
105
106//_____________________________________________________________________________
107void AliRsnVAnalysisTaskSE::ConnectInputData(Option_t *opt)
108{
109//
110// Connect input data.
111// Links the data member pointers to any possible AliVEvenb input
112// to the appropriate object belonging to the mother class,
113// for a fast retrieval of informations from it through the
114// data interface classes provided in this package.
115// Makes use of dynamic_cast, in order to know the kind of input
116// just checking if the casted pointers are NULL or not.
117//
118
119 AliDebug(AliLog::kDebug+2,"<-");
120 AliAnalysisTaskSE::ConnectInputData(opt);
121
122 // getting AliESDEvent
4fbb2459 123 fESDEvent = dynamic_cast<AliESDEvent *>(fInputEvent);
5eb970a4 124
125 if (fESDEvent) {
126 AliInfo(Form("Input is ESD (%p)", fESDEvent));
127
128 // getting AliMCEvent
129 fMCEvent = (AliMCEvent*) MCEvent();
130 if (fMCEvent) AliInfo(Form("Input is MC (%p)", fMCEvent));
131 }
132
133 // getting AliAODEvent from input
4fbb2459 134 fAODEventIn = dynamic_cast<AliAODEvent *>(fInputEvent);
5eb970a4 135 if (fAODEventIn) AliInfo(Form("Input is AOD INPUT (%p)",fAODEventIn));
136
137 // getting AliAODEvent if it is output from previous task
4fbb2459 138 fAODEventOut = dynamic_cast<AliAODEvent *>(AODEvent());
5eb970a4 139 if (fAODEventOut) AliInfo(Form("Input is AOD OUTPUT (%p)",fAODEventOut));
140
141 AliDebug(AliLog::kDebug+2,"->");
142}
143
144//_____________________________________________________________________________
145void AliRsnVAnalysisTaskSE::RsnUserCreateOutputObjects()
146{
147//
148// Define here all instructions to create output objects.
149// This method will be called inside the "UserCreateOutputObjects"
150// in the used task.
151//
152
153 AliDebug(AliLog::kDebug+2,"<-");
154 AliDebug(AliLog::kDebug+2,"->");
155}
156
157//_____________________________________________________________________________
158void AliRsnVAnalysisTaskSE::UserCreateOutputObjects()
159{
160//
161// Creates and links to task all output objects.
162// They are all stored inside a unique TList which will be saved
163// in output slot #1.
164//
165
9477aa42 166 SetDebugForAllClasses();
5eb970a4 167
168 AliDebug(AliLog::kDebug+2, "<-");
169
4fbb2459 170 fOutList[0] = new TList();
171 fOutList[0]->SetOwner();
172 fTaskInfo.GenerateInfoList(fOutList[0]);
5eb970a4 173 RsnUserCreateOutputObjects();
174
175 AliDebug(AliLog::kDebug+2,"<-");
176}
177
178//_____________________________________________________________________________
179void AliRsnVAnalysisTaskSE::UserExec(Option_t* opt)
180{
4fbb2459 181//
182//
183//
5eb970a4 184
185 AliDebug(AliLog::kDebug+2,"<-");
186
4fbb2459 187 // sets properly the RSN package event interface:
188 // if an ESD event is available, it has priority,
189 // otherwise the AOD event is used;
190 // if the MC information is available, it is linked
191 if (fMCOnly && fMCEvent)
192 fRsnEvent.SetRef(fMCEvent, fMCEvent);
193 else if (fESDEvent)
194 fRsnEvent.SetRef(fESDEvent, fMCEvent);
195 else if (fAODEventOut)
196 fRsnEvent.SetRef(fAODEventOut);
197 else if (fAODEventIn)
198 fRsnEvent.SetRef(fAODEventIn);
199 else {
200 AliError("NO ESD or AOD object!!! Skipping ...");
201 return;
202 }
203
204 // sort tracks w.r. to PID...
205 fRsnPIDIndex.FillFromEvent(&fRsnEvent);
206
5eb970a4 207 RsnUserExec(opt);
208
209 FillInfo();
210
4fbb2459 211 fTaskInfo.PrintInfo(fTaskInfo.GetNumerOfEventsProcessed());
5eb970a4 212
4fbb2459 213 PostData(1, fOutList[0]);
5eb970a4 214
215 AliDebug(AliLog::kDebug+2,"->");
216}
217
218//_____________________________________________________________________________
4fbb2459 219void AliRsnVAnalysisTaskSE::RsnUserExec(Option_t*)
5eb970a4 220{
4fbb2459 221//
222//
223//
5eb970a4 224
225 if (fESDEvent) {
226 AliDebug(AliLog::kDebug+1, Form("fESDEvent is %p", fESDEvent));
227 AliDebug(AliLog::kDebug, Form("ESD tracks %d", fESDEvent->GetNumberOfTracks()));
228 }
229 if (fMCEvent) {
230 AliDebug(AliLog::kDebug+1, Form("fMCEvent is %p", fMCEvent));
231 AliDebug(AliLog::kDebug, Form("MC tracks %d", fMCEvent->GetNumberOfTracks()));
232 }
233 if (fAODEventIn) {
234 AliDebug(AliLog::kDebug+1, Form("fAODEventIn is %p", fAODEventIn));
235 AliDebug(AliLog::kDebug, Form("AOD (in) tracks %d", fAODEventIn->GetNumberOfTracks()));
236 }
237
238 if (fAODEventOut) {
239 AliDebug(AliLog::kDebug+1, Form("fAODEventOut if %p", fAODEventOut));
240 AliDebug(AliLog::kDebug, Form("AOD (out) tracks %d", fAODEventOut->GetNumberOfTracks()));
241 }
242}
243
244//_____________________________________________________________________________
245void AliRsnVAnalysisTaskSE::Terminate(Option_t* opt)
246{
247//
248// Termination routines.
249// Stores all histograms (after checking they exist)
250// and includes to the TList all task informations.
251//
252
253 AliDebug(AliLog::kDebug+2,"<-");
254 AliAnalysisTask::Terminate();
255
4fbb2459 256 TList* list = dynamic_cast<TList*>(GetOutputData(1));
257 if (!list) {
258 AliError(Form("At end of analysis, fOutList is %p", list));
5eb970a4 259 return;
260 }
261
262 RsnTerminate(opt);
263
4fbb2459 264 TH1I *hEventInfo = (TH1I*) list->FindObject(fTaskInfo.GetEventHistogramName());
5eb970a4 265 if (!hEventInfo) {
266 AliError(Form("hEventInfo is %p",hEventInfo));
267 return;
268 }
269
270 AliInfo(Form("=== %s ==================",GetName()));
37dcaaad 271 AliInfo(Form("Number Of Events Processed : %10d",(Int_t)hEventInfo->Integral()));
272 AliInfo(Form("Number Of Events Accepted : %10d",(Int_t)hEventInfo->GetBinContent(2)));
273 AliInfo(Form("Number Of Events Skipped : %10d",(Int_t)hEventInfo->GetBinContent(1)));
5eb970a4 274 AliInfo(Form("=== end %s ==============",GetName()));
275
276 AliDebug(AliLog::kDebug+2, "->");
277}
278
279//_____________________________________________________________________________
4fbb2459 280void AliRsnVAnalysisTaskSE::RsnTerminate(Option_t*)
5eb970a4 281{
282//
283// Overload this to add additional termination operations
284//
285
286 AliDebug(AliLog::kDebug+2, "<-");
287 AliDebug(AliLog::kDebug+2, "->");
288}
289
290//_____________________________________________________________________________
291void AliRsnVAnalysisTaskSE::FillInfo()
292{
293//
294// Fill information object with statistics of analysis
295//
296
297 AliDebug(AliLog::kDebug+2, "<-");
4fbb2459 298
5eb970a4 299 fTaskInfo.FillInfo();
4fbb2459 300
5eb970a4 301 AliDebug(AliLog::kDebug+2,"->");
302}
303
304//_____________________________________________________________________________
9477aa42 305void AliRsnVAnalysisTaskSE::SetLogType(AliLog::EType_t type, TString allClasses)
5eb970a4 306{
307//
308// Set Log level for this and other classes (list of their names)
309//
310
311 AliDebug(AliLog::kDebug+2,"<-");
312 fLogType = type;
9477aa42 313 fLogClassesString = allClasses;
5eb970a4 314 AliDebug(AliLog::kDebug+2,"->");
315}
316
317//_____________________________________________________________________________
9477aa42 318void AliRsnVAnalysisTaskSE::SetDebugForAllClasses()
5eb970a4 319{
320//
321// Set debug level for all classes for which it is required
322//
323
324 AliDebug(AliLog::kDebug+2, "<-");
325 TObjArray* array = fLogClassesString.Tokenize(":");
326 TObjString *str;
327 TString strr;
328 for (Int_t i=0;i< array->GetEntriesFast();i++) {
329 str = (TObjString *) array->At(i);
330 strr = str->GetString();
331 AliLog::SetClassDebugLevel(strr.Data(), fLogType);
9477aa42 332 AliInfo(Form("Setting Debug to %s",strr.Data()));
5eb970a4 333 }
334 AliDebug(AliLog::kDebug+2,"->");
335}