]>
Commit | Line | Data |
---|---|---|
5eb970a4 | 1 | // |
2 | // Class AliRsnVAnalysisTaskSE | |
3 | // | |
4 | // Virtual Class derivated from AliAnalysisTaskSE which will be base class | |
5 | // for all RSN SE tasks | |
6 | // | |
7 | // authors: Martin Vala (martin.vala@cern.ch) | |
8 | // Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it) | |
9 | // | |
10 | ||
11 | #include "AliRsnVAnalysisTaskSE.h" | |
12 | ||
13 | ClassImp(AliRsnVAnalysisTaskSE) | |
14 | ||
15 | //_____________________________________________________________________________ | |
16 | AliRsnVAnalysisTaskSE::AliRsnVAnalysisTaskSE(const char *name) : | |
17 | AliAnalysisTaskSE(name), | |
18 | fLogType(AliLog::kInfo), | |
19 | fLogClassesString(""), | |
20 | fESDEvent(0x0), | |
21 | fMCEvent(0x0), | |
22 | fAODEventIn(0x0), | |
23 | fAODEventOut(0x0), | |
24 | fOutList(0x0), | |
25 | fTaskInfo(name) | |
26 | { | |
27 | // | |
28 | // Default constructor. | |
29 | // Define the output slot for histograms. | |
30 | // | |
31 | ||
32 | AliDebug(AliLog::kDebug+2,"<-"); | |
33 | ||
34 | DefineOutput(1, TList::Class()); | |
35 | ||
36 | AliDebug(AliLog::kDebug+2,"->"); | |
37 | } | |
38 | ||
39 | //_____________________________________________________________________________ | |
40 | AliRsnVAnalysisTaskSE::AliRsnVAnalysisTaskSE(const AliRsnVAnalysisTaskSE& copy) : | |
41 | AliAnalysisTaskSE(copy), | |
42 | fLogType(copy.fLogType), | |
43 | fLogClassesString(copy.fLogClassesString), | |
44 | fESDEvent(copy.fESDEvent), | |
45 | fMCEvent(copy.fMCEvent), | |
46 | fAODEventIn(copy.fAODEventIn), | |
47 | fAODEventOut(copy.fAODEventOut), | |
48 | fOutList(copy.fOutList), | |
49 | fTaskInfo(copy.fTaskInfo) | |
50 | { | |
51 | // | |
52 | // Copy constructor. | |
53 | // Defined for coding conventions compliance but never used. | |
54 | // | |
55 | ||
56 | AliDebug(AliLog::kDebug+2, "<-"); | |
57 | AliDebug(AliLog::kDebug+2, "->"); | |
58 | } | |
59 | ||
60 | //_____________________________________________________________________________ | |
61 | void AliRsnVAnalysisTaskSE::LocalInit() | |
62 | { | |
63 | // | |
64 | // Local initialization. | |
65 | // Defines the debug message level and calls the mother class LocalInit(). | |
66 | // | |
67 | ||
68 | AliLog::SetClassDebugLevel(GetName(), fLogType); | |
69 | SetDebugForOtherClasses(); | |
70 | ||
71 | AliDebug(AliLog::kDebug+2, "<-"); | |
72 | AliAnalysisTaskSE::LocalInit(); | |
73 | AliDebug(AliLog::kDebug+2, "->"); | |
74 | } | |
75 | ||
76 | //_____________________________________________________________________________ | |
77 | Bool_t AliRsnVAnalysisTaskSE::Notify() | |
78 | { | |
79 | // | |
80 | // Calls the mother class Notify() | |
81 | // | |
82 | ||
83 | AliDebug(AliLog::kDebug+2,"<-"); | |
84 | AliDebug(AliLog::kDebug+2,"->"); | |
85 | ||
86 | return AliAnalysisTaskSE::Notify(); | |
87 | } | |
88 | ||
89 | //_____________________________________________________________________________ | |
90 | void AliRsnVAnalysisTaskSE::ConnectInputData(Option_t *opt) | |
91 | { | |
92 | // | |
93 | // Connect input data. | |
94 | // Links the data member pointers to any possible AliVEvenb input | |
95 | // to the appropriate object belonging to the mother class, | |
96 | // for a fast retrieval of informations from it through the | |
97 | // data interface classes provided in this package. | |
98 | // Makes use of dynamic_cast, in order to know the kind of input | |
99 | // just checking if the casted pointers are NULL or not. | |
100 | // | |
101 | ||
102 | AliDebug(AliLog::kDebug+2,"<-"); | |
103 | AliAnalysisTaskSE::ConnectInputData(opt); | |
104 | ||
105 | // getting AliESDEvent | |
106 | fESDEvent = dynamic_cast<AliESDEvent *> (fInputEvent); | |
107 | ||
108 | if (fESDEvent) { | |
109 | AliInfo(Form("Input is ESD (%p)", fESDEvent)); | |
110 | ||
111 | // getting AliMCEvent | |
112 | fMCEvent = (AliMCEvent*) MCEvent(); | |
113 | if (fMCEvent) AliInfo(Form("Input is MC (%p)", fMCEvent)); | |
114 | } | |
115 | ||
116 | // getting AliAODEvent from input | |
117 | fAODEventIn = dynamic_cast<AliAODEvent *> (fInputEvent); | |
118 | if (fAODEventIn) AliInfo(Form("Input is AOD INPUT (%p)",fAODEventIn)); | |
119 | ||
120 | // getting AliAODEvent if it is output from previous task | |
121 | fAODEventOut = dynamic_cast<AliAODEvent *> (AODEvent()); | |
122 | if (fAODEventOut) AliInfo(Form("Input is AOD OUTPUT (%p)",fAODEventOut)); | |
123 | ||
124 | AliDebug(AliLog::kDebug+2,"->"); | |
125 | } | |
126 | ||
127 | //_____________________________________________________________________________ | |
128 | void AliRsnVAnalysisTaskSE::RsnUserCreateOutputObjects() | |
129 | { | |
130 | // | |
131 | // Define here all instructions to create output objects. | |
132 | // This method will be called inside the "UserCreateOutputObjects" | |
133 | // in the used task. | |
134 | // | |
135 | ||
136 | AliDebug(AliLog::kDebug+2,"<-"); | |
137 | AliDebug(AliLog::kDebug+2,"->"); | |
138 | } | |
139 | ||
140 | //_____________________________________________________________________________ | |
141 | void AliRsnVAnalysisTaskSE::UserCreateOutputObjects() | |
142 | { | |
143 | // | |
144 | // Creates and links to task all output objects. | |
145 | // They are all stored inside a unique TList which will be saved | |
146 | // in output slot #1. | |
147 | // | |
148 | ||
149 | AliLog::SetClassDebugLevel(GetName(), fLogType); | |
150 | ||
151 | SetDebugForOtherClasses(); | |
152 | ||
153 | AliDebug(AliLog::kDebug+2, "<-"); | |
154 | ||
155 | fOutList = new TList(); | |
156 | fOutList->SetOwner(); | |
157 | ||
158 | fOutList->Add(fTaskInfo.GenerateInfoList()); | |
159 | ||
160 | RsnUserCreateOutputObjects(); | |
161 | ||
162 | AliDebug(AliLog::kDebug+2,"<-"); | |
163 | } | |
164 | ||
165 | //_____________________________________________________________________________ | |
166 | void AliRsnVAnalysisTaskSE::UserExec(Option_t* opt) | |
167 | { | |
168 | ||
169 | AliDebug(AliLog::kDebug+2,"<-"); | |
170 | ||
171 | RsnUserExec(opt); | |
172 | ||
173 | FillInfo(); | |
174 | ||
175 | fTaskInfo.PrintInfo(fEntry); | |
176 | ||
177 | PostData(1, fOutList); | |
178 | ||
179 | AliDebug(AliLog::kDebug+2,"->"); | |
180 | } | |
181 | ||
182 | //_____________________________________________________________________________ | |
183 | void AliRsnVAnalysisTaskSE::RsnUserExec(Option_t* ) | |
184 | { | |
185 | ||
186 | if (fESDEvent) { | |
187 | AliDebug(AliLog::kDebug+1, Form("fESDEvent is %p", fESDEvent)); | |
188 | AliDebug(AliLog::kDebug, Form("ESD tracks %d", fESDEvent->GetNumberOfTracks())); | |
189 | } | |
190 | if (fMCEvent) { | |
191 | AliDebug(AliLog::kDebug+1, Form("fMCEvent is %p", fMCEvent)); | |
192 | AliDebug(AliLog::kDebug, Form("MC tracks %d", fMCEvent->GetNumberOfTracks())); | |
193 | } | |
194 | if (fAODEventIn) { | |
195 | AliDebug(AliLog::kDebug+1, Form("fAODEventIn is %p", fAODEventIn)); | |
196 | AliDebug(AliLog::kDebug, Form("AOD (in) tracks %d", fAODEventIn->GetNumberOfTracks())); | |
197 | } | |
198 | ||
199 | if (fAODEventOut) { | |
200 | AliDebug(AliLog::kDebug+1, Form("fAODEventOut if %p", fAODEventOut)); | |
201 | AliDebug(AliLog::kDebug, Form("AOD (out) tracks %d", fAODEventOut->GetNumberOfTracks())); | |
202 | } | |
203 | } | |
204 | ||
205 | //_____________________________________________________________________________ | |
206 | void AliRsnVAnalysisTaskSE::Terminate(Option_t* opt) | |
207 | { | |
208 | // | |
209 | // Termination routines. | |
210 | // Stores all histograms (after checking they exist) | |
211 | // and includes to the TList all task informations. | |
212 | // | |
213 | ||
214 | AliDebug(AliLog::kDebug+2,"<-"); | |
215 | AliAnalysisTask::Terminate(); | |
216 | ||
217 | fOutList = dynamic_cast<TList*>(GetOutputData(1)); | |
218 | if (!fOutList) { | |
219 | AliError(Form("At end of analysis, fOutList is %p", fOutList)); | |
220 | return; | |
221 | } | |
222 | ||
223 | RsnTerminate(opt); | |
224 | ||
225 | TList* lEventInfo = (TList*) fOutList->FindObject(fTaskInfo.GetName()); | |
226 | ||
227 | TH1I *hEventInfo = (TH1I*) lEventInfo->FindObject(fTaskInfo.GetEventHistogramName()); | |
228 | if (!hEventInfo) { | |
229 | AliError(Form("hEventInfo is %p",hEventInfo)); | |
230 | return; | |
231 | } | |
232 | ||
233 | AliInfo(Form("=== %s ==================",GetName())); | |
234 | AliInfo(Form("Number Of Events Processed : %10d",(Long64_t)hEventInfo->Integral())); | |
235 | AliInfo(Form("Number Of Events Accepted : %10d",(Long64_t)hEventInfo->GetBinContent(2))); | |
236 | AliInfo(Form("Number Of Events Skipped : %10d",(Long64_t)hEventInfo->GetBinContent(1))); | |
237 | AliInfo(Form("=== end %s ==============",GetName())); | |
238 | ||
239 | AliDebug(AliLog::kDebug+2, "->"); | |
240 | } | |
241 | ||
242 | //_____________________________________________________________________________ | |
243 | void AliRsnVAnalysisTaskSE::RsnTerminate(Option_t* ) | |
244 | { | |
245 | // | |
246 | // Overload this to add additional termination operations | |
247 | // | |
248 | ||
249 | AliDebug(AliLog::kDebug+2, "<-"); | |
250 | AliDebug(AliLog::kDebug+2, "->"); | |
251 | } | |
252 | ||
253 | //_____________________________________________________________________________ | |
254 | void AliRsnVAnalysisTaskSE::FillInfo() | |
255 | { | |
256 | // | |
257 | // Fill information object with statistics of analysis | |
258 | // | |
259 | ||
260 | AliDebug(AliLog::kDebug+2, "<-"); | |
261 | if (fAODEventOut) { | |
262 | fTaskInfo.SetNumberOfTracks(fAODEventOut->GetNumberOfTracks()); | |
263 | } | |
264 | else if (fESDEvent) { | |
265 | fTaskInfo.SetNumberOfTracks(fESDEvent->GetNumberOfTracks()); | |
266 | } | |
267 | else if (fAODEventIn) { | |
268 | fTaskInfo.SetNumberOfTracks(fAODEventIn->GetNumberOfTracks()); | |
269 | } | |
270 | ||
271 | fTaskInfo.FillInfo(); | |
272 | AliDebug(AliLog::kDebug+2,"->"); | |
273 | } | |
274 | ||
275 | //_____________________________________________________________________________ | |
276 | void AliRsnVAnalysisTaskSE::SetLogType(AliLog::EType_t type, TString otherClasses) | |
277 | { | |
278 | // | |
279 | // Set Log level for this and other classes (list of their names) | |
280 | // | |
281 | ||
282 | AliDebug(AliLog::kDebug+2,"<-"); | |
283 | fLogType = type; | |
284 | fLogClassesString = otherClasses; | |
285 | AliDebug(AliLog::kDebug+2,"->"); | |
286 | } | |
287 | ||
288 | //_____________________________________________________________________________ | |
289 | void AliRsnVAnalysisTaskSE::SetDebugForOtherClasses() | |
290 | { | |
291 | // | |
292 | // Set debug level for all classes for which it is required | |
293 | // | |
294 | ||
295 | AliDebug(AliLog::kDebug+2, "<-"); | |
296 | TObjArray* array = fLogClassesString.Tokenize(":"); | |
297 | TObjString *str; | |
298 | TString strr; | |
299 | for (Int_t i=0;i< array->GetEntriesFast();i++) { | |
300 | str = (TObjString *) array->At(i); | |
301 | strr = str->GetString(); | |
302 | AliLog::SetClassDebugLevel(strr.Data(), fLogType); | |
303 | } | |
304 | AliDebug(AliLog::kDebug+2,"->"); | |
305 | } |