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