2 // Class AliRsnVAnalysisTaskSE
4 // Virtual Class derivated from AliAnalysisTaskSE which will be base class
5 // for all RSN SE tasks
7 // authors: Martin Vala (martin.vala@cern.ch)
8 // Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
11 #include "AliRsnVAnalysisTaskSE.h"
13 #include "AliESDEvent.h"
14 #include "AliMCEvent.h"
15 #include "AliAODEvent.h"
17 ClassImp(AliRsnVAnalysisTaskSE)
19 //_____________________________________________________________________________
20 AliRsnVAnalysisTaskSE::AliRsnVAnalysisTaskSE
21 (const char *name, Int_t numOfOutputs, Bool_t mcOnly) :
22 AliAnalysisTaskSE(name),
23 fLogType(AliLog::kInfo),
24 fLogClassesString(""),
32 fNumberOfOutputs(numOfOutputs),
36 // Default constructor.
37 // Define the output slot for histograms.
40 AliDebug(AliLog::kDebug+2,"<-");
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;
49 DefineOutput(1, TList::Class());
51 AliDebug(AliLog::kDebug+2,"->");
54 //_____________________________________________________________________________
55 AliRsnVAnalysisTaskSE::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),
66 fNumberOfOutputs(copy.fNumberOfOutputs),
67 fTaskInfo(copy.fTaskInfo)
71 // Defined for coding conventions compliance but never used.
74 AliDebug(AliLog::kDebug+2, "<-");
75 AliDebug(AliLog::kDebug+2, "->");
78 //_____________________________________________________________________________
79 void AliRsnVAnalysisTaskSE::LocalInit()
82 // Local initialization.
83 // Defines the debug message level and calls the mother class LocalInit().
86 SetDebugForAllClasses();
88 AliDebug(AliLog::kDebug+2, "<-");
89 AliAnalysisTaskSE::LocalInit();
90 AliDebug(AliLog::kDebug+2, "->");
93 //_____________________________________________________________________________
94 Bool_t AliRsnVAnalysisTaskSE::Notify()
97 // Calls the mother class Notify()
100 AliDebug(AliLog::kDebug+2,"<-");
101 AliDebug(AliLog::kDebug+2,"->");
103 return AliAnalysisTaskSE::Notify();
106 //_____________________________________________________________________________
107 void AliRsnVAnalysisTaskSE::ConnectInputData(Option_t *opt)
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.
119 AliDebug(AliLog::kDebug+2,"<-");
120 AliAnalysisTaskSE::ConnectInputData(opt);
122 // getting AliESDEvent
123 fESDEvent = dynamic_cast<AliESDEvent *>(fInputEvent);
126 AliInfo(Form("Input is ESD (%p)", fESDEvent));
128 // getting AliMCEvent
129 fMCEvent = (AliMCEvent*) MCEvent();
130 if (fMCEvent) AliInfo(Form("Input is MC (%p)", fMCEvent));
133 // getting AliAODEvent from input
134 fAODEventIn = dynamic_cast<AliAODEvent *>(fInputEvent);
135 if (fAODEventIn) AliInfo(Form("Input is AOD INPUT (%p)",fAODEventIn));
137 // getting AliAODEvent if it is output from previous task
138 fAODEventOut = dynamic_cast<AliAODEvent *>(AODEvent());
139 if (fAODEventOut) AliInfo(Form("Input is AOD OUTPUT (%p)",fAODEventOut));
141 AliDebug(AliLog::kDebug+2,"->");
144 //_____________________________________________________________________________
145 void AliRsnVAnalysisTaskSE::RsnUserCreateOutputObjects()
148 // Define here all instructions to create output objects.
149 // This method will be called inside the "UserCreateOutputObjects"
153 AliDebug(AliLog::kDebug+2,"<-");
154 AliDebug(AliLog::kDebug+2,"->");
157 //_____________________________________________________________________________
158 void AliRsnVAnalysisTaskSE::UserCreateOutputObjects()
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.
166 SetDebugForAllClasses();
168 AliDebug(AliLog::kDebug+2, "<-");
170 fOutList[0] = new TList();
171 fOutList[0]->SetOwner();
172 fTaskInfo.GenerateInfoList(fOutList[0]);
173 RsnUserCreateOutputObjects();
175 AliDebug(AliLog::kDebug+2,"<-");
178 //_____________________________________________________________________________
179 void AliRsnVAnalysisTaskSE::UserExec(Option_t* opt)
185 AliDebug(AliLog::kDebug+2,"<-");
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);
194 fRsnEvent.SetRef(fESDEvent, fMCEvent);
195 else if (fAODEventOut)
196 fRsnEvent.SetRef(fAODEventOut);
197 else if (fAODEventIn)
198 fRsnEvent.SetRef(fAODEventIn);
200 AliError("NO ESD or AOD object!!! Skipping ...");
204 // sort tracks w.r. to PID...
205 fRsnPIDIndex.FillFromEvent(&fRsnEvent);
211 fTaskInfo.PrintInfo(fTaskInfo.GetNumerOfEventsProcessed());
213 PostData(1, fOutList[0]);
215 AliDebug(AliLog::kDebug+2,"->");
218 //_____________________________________________________________________________
219 void AliRsnVAnalysisTaskSE::RsnUserExec(Option_t*)
226 AliDebug(AliLog::kDebug+1, Form("fESDEvent is %p", fESDEvent));
227 AliDebug(AliLog::kDebug, Form("ESD tracks %d", fESDEvent->GetNumberOfTracks()));
230 AliDebug(AliLog::kDebug+1, Form("fMCEvent is %p", fMCEvent));
231 AliDebug(AliLog::kDebug, Form("MC tracks %d", fMCEvent->GetNumberOfTracks()));
234 AliDebug(AliLog::kDebug+1, Form("fAODEventIn is %p", fAODEventIn));
235 AliDebug(AliLog::kDebug, Form("AOD (in) tracks %d", fAODEventIn->GetNumberOfTracks()));
239 AliDebug(AliLog::kDebug+1, Form("fAODEventOut if %p", fAODEventOut));
240 AliDebug(AliLog::kDebug, Form("AOD (out) tracks %d", fAODEventOut->GetNumberOfTracks()));
244 //_____________________________________________________________________________
245 void AliRsnVAnalysisTaskSE::Terminate(Option_t* opt)
248 // Termination routines.
249 // Stores all histograms (after checking they exist)
250 // and includes to the TList all task informations.
253 AliDebug(AliLog::kDebug+2,"<-");
254 AliAnalysisTask::Terminate();
256 TList* list = dynamic_cast<TList*>(GetOutputData(1));
258 AliError(Form("At end of analysis, fOutList is %p", list));
264 TH1I *hEventInfo = (TH1I*) list->FindObject(fTaskInfo.GetEventHistogramName());
266 AliError(Form("hEventInfo is %p",hEventInfo));
270 AliInfo(Form("=== %s ==================",GetName()));
271 AliInfo(Form("Number Of Events Processed : %10d",(Long64_t)hEventInfo->Integral()));
272 AliInfo(Form("Number Of Events Accepted : %10d",(Long64_t)hEventInfo->GetBinContent(2)));
273 AliInfo(Form("Number Of Events Skipped : %10d",(Long64_t)hEventInfo->GetBinContent(1)));
274 AliInfo(Form("=== end %s ==============",GetName()));
276 AliDebug(AliLog::kDebug+2, "->");
279 //_____________________________________________________________________________
280 void AliRsnVAnalysisTaskSE::RsnTerminate(Option_t*)
283 // Overload this to add additional termination operations
286 AliDebug(AliLog::kDebug+2, "<-");
287 AliDebug(AliLog::kDebug+2, "->");
290 //_____________________________________________________________________________
291 void AliRsnVAnalysisTaskSE::FillInfo()
294 // Fill information object with statistics of analysis
297 AliDebug(AliLog::kDebug+2, "<-");
299 fTaskInfo.FillInfo();
301 AliDebug(AliLog::kDebug+2,"->");
304 //_____________________________________________________________________________
305 void AliRsnVAnalysisTaskSE::SetLogType(AliLog::EType_t type, TString allClasses)
308 // Set Log level for this and other classes (list of their names)
311 AliDebug(AliLog::kDebug+2,"<-");
313 fLogClassesString = allClasses;
314 AliDebug(AliLog::kDebug+2,"->");
317 //_____________________________________________________________________________
318 void AliRsnVAnalysisTaskSE::SetDebugForAllClasses()
321 // Set debug level for all classes for which it is required
324 AliDebug(AliLog::kDebug+2, "<-");
325 TObjArray* array = fLogClassesString.Tokenize(":");
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);
332 AliInfo(Form("Setting Debug to %s",strr.Data()));
334 AliDebug(AliLog::kDebug+2,"->");