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