]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG2/RESONANCES/AliRsnVAnalysisTaskME.cxx
Macro to add the energy distribution task to the train
[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//_____________________________________________________________________________
2dab9030 23AliRsnVAnalysisTaskME::AliRsnVAnalysisTaskME(const char *name) :
5eb970a4 24 AliAnalysisTaskME(name),
25 fLogType(AliLog::kInfo),
26 fLogClassesString(""),
27 fESDEvent(0x0),
28 fMCEvent(0x0),
29 fAODEvent(0x0),
2dab9030 30 fInfoList(0x0),
5eb970a4 31 fTaskInfo(name)
32{
33//
34// Default constructor
35//
36 AliDebug(AliLog::kDebug+2,"<-");
9477aa42 37
5eb970a4 38 DefineOutput(1, TList::Class());
9477aa42 39
5eb970a4 40 AliDebug(AliLog::kDebug+2,"->");
41}
42
43AliRsnVAnalysisTaskME::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),
2dab9030 49 fInfoList(0x0),
5eb970a4 50 fTaskInfo(copy.fTaskInfo)
51{
52 AliDebug(AliLog::kDebug+2,"<-");
53 AliDebug(AliLog::kDebug+2,"->");
54}
55
56//_____________________________________________________________________________
57void AliRsnVAnalysisTaskME::LocalInit()
58{
59//
60// LocalInit()
61//
4fbb2459 62
9477aa42 63 SetDebugForAllClasses();
5eb970a4 64 AliDebug(AliLog::kDebug+2,"<-");
65 AliAnalysisTaskME::LocalInit();
66 AliDebug(AliLog::kDebug+2,"->");
67}
68
69//_____________________________________________________________________________
70Bool_t AliRsnVAnalysisTaskME::Notify()
71{
72//
73// Notify()
74//
9477aa42 75
5eb970a4 76 AliDebug(AliLog::kDebug+2,"<-");
9477aa42 77 if (!AliAnalysisTaskME::Notify()) return kFALSE;
5eb970a4 78 AliDebug(AliLog::kDebug+2,"->");
9477aa42 79
80 return kTRUE;
5eb970a4 81}
82
83
84//_____________________________________________________________________________
85void AliRsnVAnalysisTaskME::ConnectInputData(Option_t *opt)
86{
4fbb2459 87//
9477aa42 88// ConnectInputData
4fbb2459 89//
90
9477aa42 91 SetDebugForAllClasses();
5eb970a4 92
9477aa42 93 AliDebug(AliLog::kDebug+2,"<-");
5eb970a4 94
9477aa42 95 AliAnalysisTaskME::ConnectInputData(opt);
5eb970a4 96
97 AliDebug(AliLog::kDebug+2,"->");
98}
99
100//_____________________________________________________________________________
101void AliRsnVAnalysisTaskME::RsnUserCreateOutputObjects()
102{
4fbb2459 103//
9477aa42 104// Rsn User Create Output Objects
4fbb2459 105//
106
5eb970a4 107 AliDebug(AliLog::kDebug+2,"<-");
108
109 AliDebug(AliLog::kDebug+2,"->");
110}
111
112
113//_____________________________________________________________________________
114void AliRsnVAnalysisTaskME::UserCreateOutputObjects()
115{
4fbb2459 116//
9477aa42 117// User Create Output Objects
4fbb2459 118//
119
9477aa42 120 SetDebugForAllClasses();
4fbb2459 121
5eb970a4 122 AliDebug(AliLog::kDebug+2,"<-");
123
2dab9030 124 fInfoList = new TList();
125 fInfoList->SetOwner();
126 fTaskInfo.GenerateInfoList(fInfoList);
5eb970a4 127 RsnUserCreateOutputObjects();
128
2dab9030 129 PostData(1, fInfoList);
130
5eb970a4 131 AliDebug(AliLog::kDebug+2,"<-");
132}
133
134//_____________________________________________________________________________
135void AliRsnVAnalysisTaskME::UserExec(Option_t* opt)
136{
4fbb2459 137//
9477aa42 138// User Exec
4fbb2459 139//
5eb970a4 140
141 AliDebug(AliLog::kDebug+2,"<-");
142
143 RsnUserExec(opt);
144
145 FillInfo();
146
147 fTaskInfo.PrintInfo(fEntry);
148
2dab9030 149 PostData(1, fInfoList);
5eb970a4 150
151 AliDebug(AliLog::kDebug+2,"->");
152}
153
154//_____________________________________________________________________________
4fbb2459 155void AliRsnVAnalysisTaskME::RsnUserExec(Option_t*)
5eb970a4 156{
4fbb2459 157//
9477aa42 158// Rsn User Exec
4fbb2459 159//
160
5eb970a4 161 AliDebug(AliLog::kDebug+2,"<-");
9477aa42 162
163 if (!CheckAndPrintEvents()) return;
164
5eb970a4 165 AliDebug(AliLog::kDebug+2,"->");
166}
167
9477aa42 168//_____________________________________________________________________________
169Bool_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
6256671b 177 AliInfo(Form("Current Entry %lld", Entry()));
9477aa42 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 }
9477aa42 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 }
9477aa42 203 } else {
204 AliWarning("Unknown input format");
205 return kFALSE;
206 }
207
208 return kTRUE;
209}
210
5eb970a4 211//_____________________________________________________________________________
212void AliRsnVAnalysisTaskME::Terminate(Option_t* opt)
213{
4fbb2459 214//
9477aa42 215// Terminate
4fbb2459 216//
217
5eb970a4 218 AliDebug(AliLog::kDebug+2,"<-");
219 AliAnalysisTask::Terminate();
220
2dab9030 221 fInfoList = dynamic_cast<TList*>(GetOutputData(1));
222 if (!fInfoList) {
223 AliError(Form("At end of analysis, fOutList is %p", fInfoList));
5eb970a4 224 return;
225 }
226
227 RsnTerminate(opt);
228
2dab9030 229 TH1I *hEventInfo = (TH1I*) fInfoList->FindObject(fTaskInfo.GetEventHistogramName());
5eb970a4 230 if (!hEventInfo) {
9477aa42 231 AliError(Form("hEventInfo is %p", hEventInfo));
5eb970a4 232 return;
233 }
234
9477aa42 235 AliInfo(Form("=== %s ==================", GetName()));
6256671b 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)));
9477aa42 239 AliInfo(Form("=== end %s ==============", GetName()));
5eb970a4 240
241 AliDebug(AliLog::kDebug+2,"->");
242}
243
244//_____________________________________________________________________________
4fbb2459 245void AliRsnVAnalysisTaskME::RsnTerminate(Option_t*)
5eb970a4 246{
4fbb2459 247//
9477aa42 248// RsnTerminate
4fbb2459 249//
250
5eb970a4 251 AliDebug(AliLog::kDebug+2,"<-");
252 AliDebug(AliLog::kDebug+2,"->");
253}
254
255//_____________________________________________________________________________
256void AliRsnVAnalysisTaskME::FillInfo()
257{
4fbb2459 258//
9477aa42 259// Fills Info
4fbb2459 260//
5eb970a4 261
5eb970a4 262 fTaskInfo.FillInfo();
263}
264
265//_____________________________________________________________________________
9477aa42 266void AliRsnVAnalysisTaskME::SetLogType(AliLog::EType_t type, TString allClasses)
5eb970a4 267{
4fbb2459 268//
9477aa42 269// Sets Log Type
4fbb2459 270//
271
5eb970a4 272 AliDebug(AliLog::kDebug+2,"<-");
273 fLogType = type;
9477aa42 274 fLogClassesString = allClasses;
5eb970a4 275 AliDebug(AliLog::kDebug+2,"->");
276}
277//_____________________________________________________________________________
9477aa42 278void AliRsnVAnalysisTaskME::SetDebugForAllClasses()
5eb970a4 279{
4fbb2459 280//
9477aa42 281// Set Debug For All Classes
4fbb2459 282//
283
5eb970a4 284 AliDebug(AliLog::kDebug+2,"<-");
285 TObjArray* array = fLogClassesString.Tokenize(":");
286 TObjString *str;
287 TString strr;
9477aa42 288 for (Int_t i = 0;i < array->GetEntriesFast();i++) {
5eb970a4 289 str = (TObjString *) array->At(i);
290 strr = str->GetString();
291 AliLog::SetClassDebugLevel(strr.Data(), fLogType);
9477aa42 292 AliInfo(Form("Setting Debug to %s", strr.Data()));
5eb970a4 293 }
294 AliDebug(AliLog::kDebug+2,"->");
295}
2dab9030 296