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, Bool_t mcOnly) :
22 AliAnalysisTaskSE(name),
23 fLogType(AliLog::kInfo),
24 fLogClassesString(""),
35 // Default constructor.
36 // Define the output slot for histograms.
39 AliDebug(AliLog::kDebug+2,"<-");
41 DefineOutput(1, TList::Class());
42 DefineOutput(2, TList::Class());
44 AliDebug(AliLog::kDebug+2,"->");
47 //_____________________________________________________________________________
48 AliRsnVAnalysisTaskSE::AliRsnVAnalysisTaskSE(const AliRsnVAnalysisTaskSE& copy) :
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),
59 fTaskInfo(copy.fTaskInfo)
63 // Defined for coding conventions compliance but never used.
66 AliDebug(AliLog::kDebug+2, "<-");
67 AliDebug(AliLog::kDebug+2, "->");
70 //_____________________________________________________________________________
71 void AliRsnVAnalysisTaskSE::LocalInit()
74 // Local initialization.
75 // Defines the debug message level and calls the mother class LocalInit().
78 SetDebugForAllClasses();
80 AliDebug(AliLog::kDebug+2, "<-");
81 AliAnalysisTaskSE::LocalInit();
82 AliDebug(AliLog::kDebug+2, "->");
85 //_____________________________________________________________________________
86 Bool_t AliRsnVAnalysisTaskSE::UserNotify()
89 // Calls the mother class Notify()
92 AliDebug(AliLog::kDebug+2,"<-");
93 AliDebug(AliLog::kDebug+2,"->");
95 return AliAnalysisTaskSE::UserNotify();
98 //_____________________________________________________________________________
99 void AliRsnVAnalysisTaskSE::ConnectInputData(Option_t *opt)
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.
111 AliDebug(AliLog::kDebug+2,"<-");
112 AliAnalysisTaskSE::ConnectInputData(opt);
114 // getting AliESDEvent
115 fESDEvent = dynamic_cast<AliESDEvent *>(fInputEvent);
118 AliInfo(Form("Input is ESD (%p)", fESDEvent));
120 // getting AliMCEvent
121 fMCEvent = (AliMCEvent*) MCEvent();
122 if (fMCEvent) AliInfo(Form("Input is MC (%p)", fMCEvent));
125 // getting AliAODEvent from input
126 fAODEventIn = dynamic_cast<AliAODEvent *>(fInputEvent);
127 if (fAODEventIn) AliInfo(Form("Input is AOD INPUT (%p)",fAODEventIn));
129 // getting AliAODEvent if it is output from previous task
130 fAODEventOut = dynamic_cast<AliAODEvent *>(AODEvent());
131 if (fAODEventOut) AliInfo(Form("Input is AOD OUTPUT (%p)",fAODEventOut));
133 AliDebug(AliLog::kDebug+2,"->");
136 //_____________________________________________________________________________
137 void AliRsnVAnalysisTaskSE::RsnUserCreateOutputObjects()
140 // Define here all instructions to create output objects.
141 // This method will be called inside the "UserCreateOutputObjects"
145 AliDebug(AliLog::kDebug+2,"<-");
146 AliDebug(AliLog::kDebug+2,"->");
149 //_____________________________________________________________________________
150 void AliRsnVAnalysisTaskSE::UserCreateOutputObjects()
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.
158 SetDebugForAllClasses();
160 AliDebug(AliLog::kDebug+2, "<-");
162 fInfoList = new TList();
163 fInfoList->SetOwner();
164 fTaskInfo.GenerateInfoList(fInfoList);
165 RsnUserCreateOutputObjects();
167 PostData(1, fInfoList);
169 AliDebug(AliLog::kDebug+2,"<-");
172 //_____________________________________________________________________________
173 void AliRsnVAnalysisTaskSE::UserExec(Option_t* opt)
179 AliDebug(AliLog::kDebug+2,"<-");
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)
187 fRsnEvent.SetRef (fMCEvent);
188 fRsnEvent.SetRefMC(fMCEvent);
192 fRsnEvent.SetRef (fESDEvent);
193 fRsnEvent.SetRefMC(fMCEvent);
195 else if (fAODEventOut)
197 fRsnEvent.SetRef (fAODEventOut);
198 fRsnEvent.SetRefMC(fAODEventOut);
200 else if (fAODEventIn)
202 fRsnEvent.SetRef (fAODEventIn);
203 fRsnEvent.SetRefMC(fAODEventIn);
206 AliError("NO ESD or AOD object!!! Skipping ...");
214 fTaskInfo.PrintInfo(fTaskInfo.GetNumerOfEventsProcessed());
216 PostData(1, fInfoList);
218 AliDebug(AliLog::kDebug+2,"->");
221 //_____________________________________________________________________________
222 void AliRsnVAnalysisTaskSE::RsnUserExec(Option_t*)
229 AliDebug(AliLog::kDebug+1, Form("fESDEvent is %p", fESDEvent));
230 AliDebug(AliLog::kDebug, Form("ESD tracks %d", fESDEvent->GetNumberOfTracks()));
233 AliDebug(AliLog::kDebug+1, Form("fMCEvent is %p", fMCEvent));
234 AliDebug(AliLog::kDebug, Form("MC tracks %d", fMCEvent->GetNumberOfTracks()));
237 AliDebug(AliLog::kDebug+1, Form("fAODEventIn is %p", fAODEventIn));
238 AliDebug(AliLog::kDebug, Form("AOD (in) tracks %d", fAODEventIn->GetNumberOfTracks()));
242 AliDebug(AliLog::kDebug+1, Form("fAODEventOut if %p", fAODEventOut));
243 AliDebug(AliLog::kDebug, Form("AOD (out) tracks %d", fAODEventOut->GetNumberOfTracks()));
247 //_____________________________________________________________________________
248 void AliRsnVAnalysisTaskSE::Terminate(Option_t* opt)
251 // Termination routines.
252 // Stores all histograms (after checking they exist)
253 // and includes to the TList all task informations.
256 AliDebug(AliLog::kDebug+2,"<-");
257 AliAnalysisTask::Terminate();
259 TList* list = dynamic_cast<TList*>(GetOutputData(1));
261 AliError(Form("At end of analysis, fOutList is %p", list));
267 TH1I *hEventInfo = (TH1I*) list->FindObject(fTaskInfo.GetEventHistogramName());
269 AliError(Form("hEventInfo is %p",hEventInfo));
273 AliInfo(Form("=== %s ==================",GetName()));
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)));
277 AliInfo(Form("=== end %s ==============",GetName()));
279 AliDebug(AliLog::kDebug+2, "->");
282 //_____________________________________________________________________________
283 void AliRsnVAnalysisTaskSE::RsnTerminate(Option_t*)
286 // Overload this to add additional termination operations
289 AliDebug(AliLog::kDebug+2, "<-");
290 AliDebug(AliLog::kDebug+2, "->");
293 //_____________________________________________________________________________
294 void AliRsnVAnalysisTaskSE::FillInfo()
297 // Fill information object with statistics of analysis
300 AliDebug(AliLog::kDebug+2, "<-");
302 fTaskInfo.FillInfo();
304 AliDebug(AliLog::kDebug+2,"->");
307 //_____________________________________________________________________________
308 void AliRsnVAnalysisTaskSE::SetLogType(AliLog::EType_t type, TString allClasses)
311 // Set Log level for this and other classes (list of their names)
314 AliDebug(AliLog::kDebug+2,"<-");
316 fLogClassesString = allClasses;
317 AliDebug(AliLog::kDebug+2,"->");
320 //_____________________________________________________________________________
321 void AliRsnVAnalysisTaskSE::SetDebugForAllClasses()
324 // Set debug level for all classes for which it is required
327 AliDebug(AliLog::kDebug+2, "<-");
328 TObjArray* array = fLogClassesString.Tokenize(":");
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);
335 AliInfo(Form("Setting Debug to %s",strr.Data()));
337 AliDebug(AliLog::kDebug+2,"->");