]>
Commit | Line | Data |
---|---|---|
96624385 | 1 | // |
2 | // Calculate the multiplicity in the forward regions event-by-event | |
3 | // | |
4 | // Inputs: | |
5 | // - AliESDEvent | |
6 | // | |
7 | // Outputs: | |
8 | // - AliAODForwardMult | |
9 | // | |
10 | // Histograms | |
11 | // | |
12 | // Corrections used | |
13 | // | |
14 | #include "AliForwardQATask.h" | |
15 | #include "AliForwardUtil.h" | |
16 | #include "AliTriggerAnalysis.h" | |
17 | #include "AliPhysicsSelection.h" | |
18 | #include "AliLog.h" | |
19 | #include "AliESDEvent.h" | |
20 | #include "AliAODHandler.h" | |
21 | #include "AliMultiplicity.h" | |
22 | #include "AliInputEventHandler.h" | |
23 | #include "AliForwardCorrectionManager.h" | |
24 | #include "AliAnalysisManager.h" | |
25 | #include "AliAODForwardMult.h" | |
26 | #include <TH1.h> | |
27 | #include <TDirectory.h> | |
28 | #include <TTree.h> | |
29 | #include <TROOT.h> | |
e2213ed5 | 30 | #include <TStopwatch.h> |
96624385 | 31 | |
32 | //==================================================================== | |
33 | AliForwardQATask::AliForwardQATask() | |
34 | : AliAnalysisTaskSE(), | |
35 | fEnableLowFlux(false), | |
36 | fFirstEvent(true), | |
37 | fCorrManager(0), | |
38 | fESDFMD(), | |
39 | fHistos(), | |
40 | fEventInspector(), | |
41 | fEnergyFitter(), | |
42 | fSharingFilter(), | |
43 | fDensityCalculator(), | |
9b2f2e39 | 44 | fList(0), |
45 | fDebug(0) | |
96624385 | 46 | { |
47 | // | |
48 | // Constructor | |
49 | // | |
50 | } | |
51 | ||
52 | //____________________________________________________________________ | |
53 | AliForwardQATask::AliForwardQATask(const char* name) | |
54 | : AliAnalysisTaskSE(name), | |
55 | fEnableLowFlux(false), | |
56 | fFirstEvent(true), | |
57 | fCorrManager(0), | |
58 | fESDFMD(), | |
59 | fHistos(), | |
60 | fEventInspector("event"), | |
61 | fEnergyFitter("energy"), | |
62 | fSharingFilter("sharing"), | |
63 | fDensityCalculator("density"), | |
9b2f2e39 | 64 | fList(0), |
65 | fDebug(0) | |
96624385 | 66 | { |
67 | // | |
68 | // Constructor | |
69 | // | |
70 | // Parameters: | |
71 | // name Name of task | |
72 | // | |
73 | DefineOutput(1, TList::Class()); | |
74 | DefineOutput(2, TList::Class()); | |
75 | fCorrManager = &AliForwardCorrectionManager::Instance(); | |
76 | fEnergyFitter.SetNParticles(1); // Just find the 1st peak | |
77 | fEnergyFitter.SetDoMakeObject(false); | |
78 | fEnergyFitter.SetUseIncreasingBins(true); | |
79 | fEnergyFitter.SetDoFits(kTRUE); | |
80 | fEnergyFitter.SetLowCut(0.4); | |
81 | fEnergyFitter.SetFitRangeBinWidth(4); | |
82 | fEnergyFitter.SetMinEntries(1000); | |
83 | } | |
84 | ||
85 | //____________________________________________________________________ | |
86 | AliForwardQATask::AliForwardQATask(const AliForwardQATask& o) | |
87 | : AliAnalysisTaskSE(o), | |
88 | fEnableLowFlux(o.fEnableLowFlux), | |
89 | fFirstEvent(o.fFirstEvent), | |
90 | fCorrManager(o.fCorrManager), | |
91 | fESDFMD(o.fESDFMD), | |
92 | fHistos(o.fHistos), | |
93 | fEventInspector(o.fEventInspector), | |
94 | fEnergyFitter(o.fEnergyFitter), | |
95 | fSharingFilter(o.fSharingFilter), | |
96 | fDensityCalculator(o.fDensityCalculator), | |
9b2f2e39 | 97 | fList(o.fList), |
98 | fDebug(o.fDebug) | |
96624385 | 99 | { |
100 | // | |
101 | // Copy constructor | |
102 | // | |
103 | // Parameters: | |
104 | // o Object to copy from | |
105 | // | |
106 | DefineOutput(1, TList::Class()); | |
107 | DefineOutput(2, TList::Class()); | |
108 | } | |
109 | ||
110 | //____________________________________________________________________ | |
111 | AliForwardQATask& | |
112 | AliForwardQATask::operator=(const AliForwardQATask& o) | |
113 | { | |
114 | // | |
115 | // Assignment operator | |
116 | // | |
117 | // Parameters: | |
118 | // o Object to assign from | |
119 | // | |
120 | // Return: | |
121 | // Reference to this object | |
122 | // | |
d015ecfe | 123 | if (&o == this) return *this; |
96624385 | 124 | AliAnalysisTaskSE::operator=(o); |
125 | ||
126 | fEnableLowFlux = o.fEnableLowFlux; | |
127 | fFirstEvent = o.fFirstEvent; | |
128 | fCorrManager = o.fCorrManager; | |
129 | fEventInspector = o.fEventInspector; | |
130 | fEnergyFitter = o.fEnergyFitter; | |
131 | fSharingFilter = o.fSharingFilter; | |
132 | fDensityCalculator = o.fDensityCalculator; | |
133 | fHistos = o.fHistos; | |
134 | fList = o.fList; | |
9b2f2e39 | 135 | fDebug = o.fDebug; |
96624385 | 136 | |
137 | return *this; | |
138 | } | |
139 | ||
140 | //____________________________________________________________________ | |
141 | void | |
142 | AliForwardQATask::SetDebug(Int_t dbg) | |
143 | { | |
144 | // | |
145 | // Set debug level | |
146 | // | |
147 | // Parameters: | |
148 | // dbg Debug level | |
149 | // | |
9b2f2e39 | 150 | fDebug = dbg; |
96624385 | 151 | fEventInspector.SetDebug(dbg); |
152 | fEnergyFitter.SetDebug(dbg); | |
153 | fSharingFilter.SetDebug(dbg); | |
154 | fDensityCalculator.SetDebug(dbg); | |
155 | } | |
156 | ||
157 | //____________________________________________________________________ | |
158 | Bool_t | |
159 | AliForwardQATask::CheckCorrections(UInt_t what) const | |
160 | { | |
161 | // | |
162 | // Check if all needed corrections are there and accounted for. If not, | |
163 | // do a Fatal exit | |
164 | // | |
165 | // Parameters: | |
166 | // what Which corrections is needed | |
167 | // | |
168 | // Return: | |
169 | // true if all present, false otherwise | |
170 | // | |
171 | ||
172 | AliForwardCorrectionManager& fcm = AliForwardCorrectionManager::Instance(); | |
173 | // Check that we have the energy loss fits, needed by | |
174 | // AliFMDSharingFilter | |
175 | // AliFMDDensityCalculator | |
176 | if (what & AliForwardCorrectionManager::kELossFits && !fcm.GetELossFit()) { | |
460a5c02 | 177 | AliWarning("No energy loss fits"); |
96624385 | 178 | return false; |
179 | } | |
180 | return true; | |
181 | } | |
182 | ||
183 | //____________________________________________________________________ | |
184 | Bool_t | |
185 | AliForwardQATask::ReadCorrections(const TAxis*& pe, | |
186 | const TAxis*& pv, | |
187 | Bool_t mc) | |
188 | { | |
189 | // | |
190 | // Read corrections | |
191 | // | |
192 | // | |
193 | UInt_t what = AliForwardCorrectionManager::kAll; | |
194 | what ^= AliForwardCorrectionManager::kDoubleHit; | |
195 | what ^= AliForwardCorrectionManager::kVertexBias; | |
196 | what ^= AliForwardCorrectionManager::kAcceptance; | |
197 | what ^= AliForwardCorrectionManager::kMergingEfficiency; | |
198 | ||
199 | AliForwardCorrectionManager& fcm = AliForwardCorrectionManager::Instance(); | |
200 | if (!fcm.Init(GetEventInspector().GetCollisionSystem(), | |
201 | GetEventInspector().GetEnergy(), | |
202 | GetEventInspector().GetField(), | |
203 | mc, | |
204 | what)) return false; | |
460a5c02 | 205 | if (!CheckCorrections(what)) { |
206 | return false; | |
207 | } | |
96624385 | 208 | |
209 | // Sett our persistency pointer | |
210 | // fCorrManager = &fcm; | |
211 | ||
212 | // Get the eta axis from the secondary maps - if read in | |
213 | if (!pe) { | |
214 | pe = fcm.GetEtaAxis(); | |
215 | if (!pe) AliFatal("No eta axis defined"); | |
216 | } | |
217 | // Get the vertex axis from the secondary maps - if read in | |
218 | if (!pv) { | |
219 | pv = fcm.GetVertexAxis(); | |
220 | if (!pv) AliFatal("No vertex axis defined"); | |
221 | } | |
222 | ||
223 | return true; | |
224 | } | |
225 | ||
226 | //____________________________________________________________________ | |
227 | AliESDEvent* | |
228 | AliForwardQATask::GetESDEvent() | |
229 | { | |
230 | // | |
231 | // Get the ESD event. IF this is the first event, initialise | |
232 | // | |
6ff251d8 | 233 | if (IsZombie()) return 0; |
96624385 | 234 | AliESDEvent* esd = dynamic_cast<AliESDEvent*>(InputEvent()); |
235 | if (!esd) { | |
236 | AliWarning("No ESD event found for input event"); | |
237 | return 0; | |
238 | } | |
239 | ||
240 | // On the first event, initialize the parameters | |
241 | if (fFirstEvent && esd->GetESDRun()) { | |
242 | GetEventInspector().ReadRunDetails(esd); | |
243 | ||
422a78c8 | 244 | AliInfoF("Initializing with parameters from the ESD:\n" |
245 | " AliESDEvent::GetBeamEnergy() ->%f\n" | |
246 | " AliESDEvent::GetBeamType() ->%s\n" | |
247 | " AliESDEvent::GetCurrentL3() ->%f\n" | |
248 | " AliESDEvent::GetMagneticField()->%f\n" | |
6ff251d8 | 249 | " AliESDEvent::GetRunNumber() ->%d", |
422a78c8 | 250 | esd->GetBeamEnergy(), |
251 | esd->GetBeamType(), | |
252 | esd->GetCurrentL3(), | |
253 | esd->GetMagneticField(), | |
254 | esd->GetRunNumber()); | |
96624385 | 255 | |
96624385 | 256 | |
422a78c8 | 257 | if (!InitializeSubs()) { |
258 | AliWarning("Initialisation of sub algorithms failed!"); | |
6ff251d8 | 259 | SetZombie(true); |
260 | esd = 0; | |
422a78c8 | 261 | return 0; |
262 | } | |
460a5c02 | 263 | AliInfoF("Clearing first event flag from %s to false", |
264 | fFirstEvent ? "true" : "false"); | |
265 | fFirstEvent = false; | |
96624385 | 266 | } |
267 | return esd; | |
268 | } | |
269 | //____________________________________________________________________ | |
422a78c8 | 270 | Bool_t |
96624385 | 271 | AliForwardQATask::InitializeSubs() |
272 | { | |
273 | // | |
274 | // Initialise the sub objects and stuff. Called on first event | |
275 | // | |
276 | // | |
277 | const TAxis* pe = 0; | |
278 | const TAxis* pv = 0; | |
279 | ||
460a5c02 | 280 | if (!ReadCorrections(pe,pv)) { |
281 | AliWarning("Failed to read corrections"); | |
282 | return false; | |
283 | } | |
96624385 | 284 | |
285 | fHistos.Init(*pe); | |
286 | ||
287 | fEventInspector.Init(*pv); | |
288 | fEnergyFitter.Init(*pe); | |
289 | fSharingFilter.Init(); | |
290 | fDensityCalculator.Init(*pe); | |
291 | ||
292 | this->Print(); | |
422a78c8 | 293 | |
294 | return true; | |
96624385 | 295 | } |
296 | ||
297 | //____________________________________________________________________ | |
298 | void | |
299 | AliForwardQATask::UserCreateOutputObjects() | |
300 | { | |
301 | // | |
302 | // Create output objects | |
303 | // | |
304 | // | |
305 | fList = new TList; | |
306 | fList->SetOwner(); | |
307 | ||
308 | fEventInspector.DefineOutput(fList); | |
309 | fEnergyFitter.DefineOutput(fList); | |
310 | fSharingFilter.DefineOutput(fList); | |
311 | fDensityCalculator.DefineOutput(fList); | |
312 | ||
313 | PostData(1, fList); | |
314 | } | |
315 | //____________________________________________________________________ | |
316 | void | |
317 | AliForwardQATask::UserExec(Option_t*) | |
318 | { | |
319 | // | |
320 | // Process each event | |
321 | // | |
322 | // Parameters: | |
323 | // option Not used | |
324 | // | |
325 | ||
326 | // static Int_t cnt = 0; | |
327 | // cnt++; | |
328 | // Get the input data | |
329 | AliESDEvent* esd = GetESDEvent(); | |
422a78c8 | 330 | if (!esd) { |
331 | AliWarning("Got no ESD event"); | |
332 | return; | |
333 | } | |
460a5c02 | 334 | if (fFirstEvent) { |
335 | // If the first event flag wasn't cleared in the above call to | |
336 | // GetESDEvent, we should not do anything, since nothing has been | |
337 | // initialised yet, so we opt out here (with a warning) | |
338 | AliWarning("Nothing has been initialized yet, opt'ing out"); | |
339 | return; | |
340 | } | |
96624385 | 341 | |
342 | // Clear stuff | |
343 | fHistos.Clear(); | |
344 | fESDFMD.Clear(); | |
345 | ||
346 | Bool_t lowFlux = kFALSE; | |
347 | UInt_t triggers = 0; | |
348 | UShort_t ivz = 0; | |
349 | Double_t vz = 0; | |
350 | Double_t cent = -1; | |
351 | UShort_t nClusters = 0; | |
352 | UInt_t found = fEventInspector.Process(esd, triggers, lowFlux, | |
353 | ivz, vz, cent, nClusters); | |
354 | ||
355 | if (found & AliFMDEventInspector::kNoEvent) return; | |
356 | if (found & AliFMDEventInspector::kNoTriggers) return; | |
357 | if (found & AliFMDEventInspector::kNoSPD) return; | |
358 | if (found & AliFMDEventInspector::kNoFMD) return; | |
359 | if (found & AliFMDEventInspector::kNoVertex) return; | |
360 | if (triggers & AliAODForwardMult::kPileUp) return; | |
361 | if (found & AliFMDEventInspector::kBadVertex) return; | |
362 | ||
363 | // We we do not want to use low flux specific code, we disable it here. | |
364 | if (!fEnableLowFlux) lowFlux = false; | |
365 | ||
366 | // Get FMD data | |
367 | AliESDFMD* esdFMD = esd->GetFMDData(); | |
368 | ||
369 | // Run the energy loss fitter | |
370 | if (!fEnergyFitter.Accumulate(*esdFMD, cent, | |
371 | triggers & AliAODForwardMult::kEmpty)) { | |
372 | AliWarning("Energy fitter failed"); | |
373 | return; | |
374 | } | |
375 | ||
376 | // // Apply the sharing filter (or hit merging or clustering if you like) | |
6f4a5c0d | 377 | if (!fSharingFilter.Filter(*esdFMD, lowFlux, fESDFMD, vz)) { |
96624385 | 378 | AliWarning("Sharing filter failed!"); |
379 | return; | |
380 | } | |
381 | ||
382 | // Calculate the inclusive charged particle density | |
383 | if (!fDensityCalculator.Calculate(fESDFMD, fHistos, ivz, lowFlux)) { | |
384 | // if (!fDensityCalculator.Calculate(*esdFMD, fHistos, ivz, lowFlux)) { | |
385 | AliWarning("Density calculator failed!"); | |
386 | return; | |
387 | } | |
388 | PostData(1, fList); | |
389 | } | |
390 | ||
391 | //____________________________________________________________________ | |
392 | void | |
393 | AliForwardQATask::Terminate(Option_t*) | |
394 | { | |
395 | // | |
396 | // End of job | |
397 | // | |
398 | // Parameters: | |
399 | // option Not used | |
400 | // | |
9b2f2e39 | 401 | if (fDebug) AliInfo("In Forwards terminate"); |
e2213ed5 | 402 | TStopwatch swt; |
403 | swt.Start(); | |
96624385 | 404 | |
405 | TList* list = dynamic_cast<TList*>(GetOutputData(1)); | |
406 | if (!list) { | |
407 | AliError(Form("No output list defined (%p)", GetOutputData(1))); | |
408 | if (GetOutputData(1)) GetOutputData(1)->Print(); | |
409 | return; | |
410 | } | |
411 | ||
412 | // Get our histograms from the container | |
413 | TH1I* hEventsTr = 0;//static_cast<TH1I*>(list->FindObject("nEventsTr")); | |
414 | TH1I* hEventsTrVtx = 0;//static_cast<TH1I*>(list->FindObject("nEventsTrVtx")); | |
415 | TH1I* hTriggers = 0; | |
416 | if (!fEventInspector.FetchHistograms(list, hEventsTr, | |
417 | hEventsTrVtx, hTriggers)) { | |
418 | AliError(Form("Didn't get histograms from event selector " | |
419 | "(hEventsTr=%p,hEventsTrVtx=%p)", | |
420 | hEventsTr, hEventsTrVtx)); | |
421 | return; | |
422 | } | |
423 | ||
e2213ed5 | 424 | TStopwatch swf; |
425 | swf.Start(); | |
96624385 | 426 | fEnergyFitter.Fit(list); |
e2213ed5 | 427 | swf.Stop(); |
428 | AliInfoF("Fitting took %d real-time seconds, and %f CPU seconds", | |
429 | Int_t(swf.RealTime()), swf.CpuTime()); | |
96624385 | 430 | |
431 | fSharingFilter.ScaleHistograms(list,Int_t(hEventsTr->Integral())); | |
432 | fDensityCalculator.ScaleHistograms(list,Int_t(hEventsTrVtx->Integral())); | |
433 | ||
434 | // Make a deep copy and post that as output 2 | |
435 | TList* list2 = static_cast<TList*>(list->Clone(Form("%sResults", | |
436 | list->GetName()))); | |
9b2f2e39 | 437 | if (fDebug) AliInfoF("Posting post processing results to %s", |
438 | list2->GetName()); | |
96624385 | 439 | list2->SetOwner(); |
440 | PostData(2, list2); | |
441 | ||
e2213ed5 | 442 | swt.Stop(); |
443 | AliInfoF("Terminate took %d real-time seconds, and %f CPU seconds", | |
444 | Int_t(swt.RealTime()), swt.CpuTime()); | |
445 | ||
96624385 | 446 | } |
447 | ||
448 | //____________________________________________________________________ | |
449 | void | |
450 | AliForwardQATask::Print(Option_t* option) const | |
451 | { | |
452 | // | |
453 | // Print information | |
454 | // | |
455 | // Parameters: | |
456 | // option Not used | |
457 | // | |
458 | ||
459 | std::cout << ClassName() << ": " << GetName() << "\n" | |
460 | << " Enable low flux code: " << (fEnableLowFlux ? "yes" : "no") | |
461 | << "\n" | |
462 | << " Off-line trigger mask: 0x" | |
463 | << std::hex << std::setfill('0') | |
464 | << std::setw (8) << fOfflineTriggerMask | |
465 | << std::dec << std::setfill (' ') << std::endl; | |
466 | gROOT->IncreaseDirLevel(); | |
467 | if (fCorrManager) fCorrManager->Print(); | |
468 | else | |
469 | std::cout << " Correction manager not set yet" << std::endl; | |
470 | GetEventInspector() .Print(option); | |
471 | GetEnergyFitter() .Print(option); | |
472 | GetSharingFilter() .Print(option); | |
473 | gROOT->DecreaseDirLevel(); | |
474 | } | |
475 | ||
476 | // | |
477 | // EOF | |
478 | // |