]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/RESONANCES/AliRsnVAnalysisTaskME.cxx
Missing macro commented out
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnVAnalysisTaskME.cxx
1 //
2 // Class AliRsnVAnalysisTaskME
3 //
4 // Virtual Class derivated from AliAnalysisTaskME which will be base class
5 // for all RSN ME tasks
6 //
7 // authors: Martin Vala (martin.vala@cern.ch)
8 //          Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
9 //
10
11 #include <TH1.h>
12 #include <AliLog.h>
13 #include "AliESDEvent.h"
14 #include "AliMCEvent.h"
15 #include "AliAODEvent.h"
16 #include "AliAODTrack.h"
17 #include "AliMultiEventInputHandler.h"
18 #include "AliRsnVAnalysisTaskME.h"
19
20 ClassImp(AliRsnVAnalysisTaskME)
21
22 //_____________________________________________________________________________
23 AliRsnVAnalysisTaskME::AliRsnVAnalysisTaskME(const char *name) :
24     AliAnalysisTaskME(name),
25     fLogType(AliLog::kInfo),
26     fLogClassesString(""),
27     fESDEvent(0x0),
28     fMCEvent(0x0),
29     fAODEvent(0x0),
30     fInfoList(0x0),
31     fTaskInfo(name)
32 {
33 //
34 // Default constructor
35 //
36   AliDebug(AliLog::kDebug+2,"<-");
37
38   DefineOutput(1, TList::Class());
39
40   AliDebug(AliLog::kDebug+2,"->");
41 }
42
43 AliRsnVAnalysisTaskME::AliRsnVAnalysisTaskME(const AliRsnVAnalysisTaskME& copy) : AliAnalysisTaskME(copy),
44     fLogType(copy.fLogType),
45     fLogClassesString(copy.fLogClassesString),
46     fESDEvent(copy.fESDEvent),
47     fMCEvent(copy.fMCEvent),
48     fAODEvent(copy.fAODEvent),
49     fInfoList(0x0),
50     fTaskInfo(copy.fTaskInfo)
51 {
52   AliDebug(AliLog::kDebug+2,"<-");
53   AliDebug(AliLog::kDebug+2,"->");
54 }
55
56 //_____________________________________________________________________________
57 void AliRsnVAnalysisTaskME::LocalInit()
58 {
59 //
60 // LocalInit()
61 //
62
63   SetDebugForAllClasses();
64   AliDebug(AliLog::kDebug+2,"<-");
65   AliAnalysisTaskME::LocalInit();
66   AliDebug(AliLog::kDebug+2,"->");
67 }
68
69 //_____________________________________________________________________________
70 Bool_t AliRsnVAnalysisTaskME::Notify()
71 {
72 //
73 // Notify()
74 //
75
76   AliDebug(AliLog::kDebug+2,"<-");
77   if (!AliAnalysisTaskME::Notify()) return kFALSE;
78   AliDebug(AliLog::kDebug+2,"->");
79
80   return kTRUE;
81 }
82
83
84 //_____________________________________________________________________________
85 void AliRsnVAnalysisTaskME::ConnectInputData(Option_t *opt)
86 {
87 //
88 // ConnectInputData
89 //
90
91   SetDebugForAllClasses();
92
93   AliDebug(AliLog::kDebug+2,"<-");
94
95   AliAnalysisTaskME::ConnectInputData(opt);
96
97   AliDebug(AliLog::kDebug+2,"->");
98 }
99
100 //_____________________________________________________________________________
101 void AliRsnVAnalysisTaskME::RsnUserCreateOutputObjects()
102 {
103 //
104 // Rsn User Create Output Objects
105 //
106
107   AliDebug(AliLog::kDebug+2,"<-");
108
109   AliDebug(AliLog::kDebug+2,"->");
110 }
111
112
113 //_____________________________________________________________________________
114 void AliRsnVAnalysisTaskME::UserCreateOutputObjects()
115 {
116 //
117 // User Create Output Objects
118 //
119
120   SetDebugForAllClasses();
121
122   AliDebug(AliLog::kDebug+2,"<-");
123
124   fInfoList = new TList();
125   fInfoList->SetOwner();
126   fTaskInfo.GenerateInfoList(fInfoList);
127   RsnUserCreateOutputObjects();
128
129   PostData(1, fInfoList);
130
131   AliDebug(AliLog::kDebug+2,"<-");
132 }
133
134 //_____________________________________________________________________________
135 void AliRsnVAnalysisTaskME::UserExec(Option_t* opt)
136 {
137 //
138 // User Exec
139 //
140
141   AliDebug(AliLog::kDebug+2,"<-");
142
143   RsnUserExec(opt);
144
145   FillInfo();
146
147   fTaskInfo.PrintInfo(fEntry);
148
149   PostData(1, fInfoList);
150
151   AliDebug(AliLog::kDebug+2,"->");
152 }
153
154 //_____________________________________________________________________________
155 void AliRsnVAnalysisTaskME::RsnUserExec(Option_t*)
156 {
157 //
158 // Rsn User Exec
159 //
160
161   AliDebug(AliLog::kDebug+2,"<-");
162
163   if (!CheckAndPrintEvents()) return;
164
165   AliDebug(AliLog::kDebug+2,"->");
166 }
167
168 //_____________________________________________________________________________
169 Bool_t AliRsnVAnalysisTaskME::CheckAndPrintEvents()
170 {
171 //
172 // Check for supported events
173 // return false in the case of unkown format
174 // or number of events is less or equal 1
175 //
176
177   AliInfo(Form("Current Entry %lld", Entry()));
178   Int_t nEvents = fInputHandler->GetBufferSize();
179   if (nEvents <= 1) return kFALSE;
180   fESDEvent = dynamic_cast<AliESDEvent*>(GetEvent(0));
181   fAODEvent = dynamic_cast<AliAODEvent*>(GetEvent(0));
182
183   if (fESDEvent) {
184     AliESDEvent **allESDEvents = new AliESDEvent*[nEvents];
185     for (Int_t i = 0; i < nEvents; i++) {
186       allESDEvents[i] = dynamic_cast<AliESDEvent*>(GetEvent(i));
187       if (!allESDEvents[i]) {
188         AliWarning(Form("Null ESD event in index %d", i));
189         continue;
190       }
191       AliDebug(AliLog::kDebug, Form("ESD event %d has %d tracks", i, allESDEvents[i]->GetNumberOfTracks()));
192     }
193   } else if (fAODEvent) {
194     AliAODEvent **allAODEvents = new AliAODEvent*[nEvents];
195     for (Int_t i = 0; i < nEvents; i++) {
196       allAODEvents[i] = dynamic_cast<AliAODEvent*>(GetEvent(i));
197       if (!allAODEvents[i]) {
198         AliWarning(Form("Null AOD event in index %d", i));
199         continue;
200       }
201       AliDebug(AliLog::kDebug, Form("AOD event %d has %d tracks", i, allAODEvents[i]->GetNumberOfTracks()));
202     }
203   } else {
204     AliWarning("Unknown input format");
205     return kFALSE;
206   }
207
208   return kTRUE;
209 }
210
211 //_____________________________________________________________________________
212 void AliRsnVAnalysisTaskME::Terminate(Option_t* opt)
213 {
214 //
215 // Terminate
216 //
217
218   AliDebug(AliLog::kDebug+2,"<-");
219   AliAnalysisTask::Terminate();
220
221   fInfoList = dynamic_cast<TList*>(GetOutputData(1));
222   if (!fInfoList) {
223     AliError(Form("At end of analysis, fOutList is %p", fInfoList));
224     return;
225   }
226
227   RsnTerminate(opt);
228
229   TH1I *hEventInfo = (TH1I*) fInfoList->FindObject(fTaskInfo.GetEventHistogramName());
230   if (!hEventInfo) {
231     AliError(Form("hEventInfo is %p", hEventInfo));
232     return;
233   }
234
235   AliInfo(Form("=== %s ==================", GetName()));
236   AliInfo(Form("Number Of Events Processed : %10lld", (Long64_t)hEventInfo->Integral()));
237   AliInfo(Form("Number Of Events Accepted  : %10lld", (Long64_t)hEventInfo->GetBinContent(2)));
238   AliInfo(Form("Number Of Events Skipped   : %10lld", (Long64_t)hEventInfo->GetBinContent(1)));
239   AliInfo(Form("=== end %s ==============", GetName()));
240
241   AliDebug(AliLog::kDebug+2,"->");
242 }
243
244 //_____________________________________________________________________________
245 void AliRsnVAnalysisTaskME::RsnTerminate(Option_t*)
246 {
247 //
248 // RsnTerminate
249 //
250
251   AliDebug(AliLog::kDebug+2,"<-");
252   AliDebug(AliLog::kDebug+2,"->");
253 }
254
255 //_____________________________________________________________________________
256 void AliRsnVAnalysisTaskME::FillInfo()
257 {
258 //
259 // Fills Info
260 //
261
262   fTaskInfo.FillInfo();
263 }
264
265 //_____________________________________________________________________________
266 void AliRsnVAnalysisTaskME::SetLogType(AliLog::EType_t type, TString allClasses)
267 {
268 //
269 // Sets Log Type
270 //
271
272   AliDebug(AliLog::kDebug+2,"<-");
273   fLogType = type;
274   fLogClassesString = allClasses;
275   AliDebug(AliLog::kDebug+2,"->");
276 }
277 //_____________________________________________________________________________
278 void AliRsnVAnalysisTaskME::SetDebugForAllClasses()
279 {
280 //
281 // Set Debug For All Classes
282 //
283
284   AliDebug(AliLog::kDebug+2,"<-");
285   TObjArray* array = fLogClassesString.Tokenize(":");
286   TObjString *str;
287   TString strr;
288   for (Int_t i = 0;i < array->GetEntriesFast();i++) {
289     str = (TObjString *) array->At(i);
290     strr = str->GetString();
291     AliLog::SetClassDebugLevel(strr.Data(), fLogType);
292     AliInfo(Form("Setting Debug to %s", strr.Data()));
293   }
294   AliDebug(AliLog::kDebug+2,"->");
295 }
296