]>
Commit | Line | Data |
---|---|---|
8449e3e0 | 1 | #ifndef __CINT__ |
2 | # include "SummaryDrawer.C" | |
3 | # include "AliFMDCorrAcceptance.h" | |
4 | # include "AliFMDCorrSecondaryMap.h" | |
5 | # include "AliFMDCorrELossFit.h" | |
6 | # include "AliForwardUtil.h" | |
7 | # include "AliForwardCorrectionManager.h" | |
8 | # include "AliLog.h" | |
9 | # include <TString.h> | |
10 | # include <TError.h> | |
11 | #else | |
12 | class SummaryDrawer; | |
13 | class TAxis; | |
14 | class AliFMDCorrAcceptance; | |
15 | class AliFMDCorrSecondaryMap; | |
16 | class AliFMDCorrELossFit; | |
17 | #endif | |
18 | ||
19 | class CorrDrawer : public SummaryDrawer | |
20 | { | |
21 | public: | |
22 | /** | |
23 | * Constructor | |
24 | * | |
25 | * @param out Output file name | |
26 | */ | |
27 | CorrDrawer() | |
28 | { | |
29 | } | |
30 | /** | |
31 | * Destructor. Closes the PDF | |
32 | */ | |
33 | ~CorrDrawer() | |
34 | { | |
35 | CloseCanvas(); | |
36 | } | |
37 | /** | |
38 | * Create output file name | |
39 | * | |
40 | * @param out Output file name on return | |
41 | * @param prefix Prefix of the file name | |
42 | * @param runNo Run Number | |
43 | * @param sys Collision system | |
44 | * @param sNN Center of mass energy | |
45 | * @param field L3 Field | |
46 | * @param mc Simulations or not | |
47 | * @param sat Satellite interactions or not | |
48 | */ | |
49 | static void MakeFileName(TString& out, | |
50 | const TString& prefix, | |
51 | ULong_t runNo, | |
52 | UShort_t sys, | |
53 | UShort_t sNN, | |
54 | UShort_t field, | |
55 | Bool_t mc=false, | |
56 | Bool_t sat=false) | |
57 | { | |
58 | out = TString::Format("%s_run%09d_%s_%04dGeV_%c%dkG_%s_%s.pdf", | |
59 | prefix.Data(), runNo, | |
60 | (sys == 1 ? "pp" : | |
61 | sys == 2 ? "PbPb" : | |
62 | sys == 3 ? "pPb" : "unknown"), sNN, | |
63 | (field >= 0 ? 'p' : 'm'), TMath::Abs(field), | |
64 | (mc ? "MC" : "real"), | |
65 | (sat ? "satellite" : "nominal")); | |
66 | } | |
67 | /** | |
68 | * Draw corrections using the correction manager to get them | |
69 | * | |
70 | * @param what What to draw | |
71 | * @param out Output file name on return | |
72 | * @param prefix Prefix of the file name | |
73 | * @param runNo Run Number | |
74 | * @param sys Collision system | |
75 | * @param sNN Center of mass energy | |
76 | * @param field L3 Field | |
77 | * @param mc Simulations or not | |
78 | * @param sat Satellite interactions or not | |
79 | * @param options Options | |
80 | * @param local Local database file | |
81 | */ | |
82 | void Run(const Char_t* what, | |
83 | ULong_t runNo, | |
84 | const Char_t* sys, | |
85 | UShort_t sNN, | |
86 | UShort_t field, | |
87 | Bool_t mc=false, | |
88 | Bool_t sat=false, | |
89 | Option_t* options="", | |
90 | const char* local="") | |
91 | { | |
92 | Run(AliForwardCorrectionManager::ParseFields(what), | |
93 | runNo, AliForwardUtil::ParseCollisionSystem(sys), | |
94 | sNN, field, mc, sat, options, local); | |
95 | } | |
96 | /** | |
97 | * Draw corrections using the correction manager to get them | |
98 | * | |
99 | * @param what What to draw | |
100 | * @param out Output file name on return | |
101 | * @param prefix Prefix of the file name | |
102 | * @param runNo Run Number | |
103 | * @param sys Collision system | |
104 | * @param sNN Center of mass energy | |
105 | * @param field L3 Field | |
106 | * @param mc Simulations or not | |
107 | * @param sat Satellite interactions or not | |
108 | * @param options Options | |
109 | * @param local Local database file | |
110 | */ | |
111 | void Run(UShort_t what, | |
112 | ULong_t runNo, | |
113 | UShort_t sys, | |
114 | UShort_t sNN, | |
115 | UShort_t field, | |
116 | Bool_t mc=false, | |
117 | Bool_t sat=false, | |
118 | Option_t* options="", | |
119 | const char* local="") | |
120 | { | |
121 | AliForwardCorrectionManager& mgr = AliForwardCorrectionManager::Instance(); | |
122 | mgr.SetDebug(true); | |
123 | UShort_t flags = 0; | |
124 | ||
125 | if (what & AliForwardCorrectionManager::kSecondaryMap) { | |
126 | flags |= AliForwardCorrectionManager::kSecondaryMap; | |
127 | if (local) mgr.SetSecondaryMapPath(local); | |
128 | } | |
129 | if (what & AliForwardCorrectionManager::kAcceptance) { | |
130 | flags |= AliForwardCorrectionManager::kAcceptance; | |
131 | if (local) mgr.SetAcceptancePath(local); | |
132 | } | |
133 | if (what & AliForwardCorrectionManager::kELossFits) { | |
134 | flags |= AliForwardCorrectionManager::kELossFits; | |
135 | if (local) mgr.SetELossFitsPath(local); | |
136 | } | |
137 | if (what & AliForwardCorrectionManager::kVertexBias) | |
138 | Warning("CorrDrawer","Vertex bias not implemented yet"); | |
139 | if (what & AliForwardCorrectionManager::kDoubleHit) | |
140 | Warning("CorrDrawer","Double hit not implemented yet"); | |
141 | if (what & AliForwardCorrectionManager::kMergingEfficiency) | |
142 | Warning("CorrDrawer","Merging efficiency not implemented yet"); | |
143 | ||
144 | if (!mgr.Init(runNo, sys, sNN, field, mc, sat, flags, true)) { | |
145 | Error("CorrDrawer", "Failed to initialize for flags=0x%02x" | |
146 | "run=%lu, sys=%hu, sNN=%hu, field=%hd, mc=%d, sat=%d", | |
147 | flags, runNo, sys, sNN, field, mc, sat); | |
148 | return; | |
149 | } | |
150 | ||
151 | TString out; | |
152 | MakeFileName(out, "corrs", runNo, sys, sNN, field, mc, sat); | |
153 | CreateCanvas(out); | |
154 | ||
155 | fBody->cd(); | |
156 | Double_t y = .8; | |
157 | DrawParameter(y, "Run #", Form("%lu", runNo)); | |
158 | DrawParameter(y, "System", AliForwardUtil::CollisionSystemString(sys)); | |
159 | DrawParameter(y, "#sqrt{s_{NN}}", | |
160 | AliForwardUtil::CenterOfMassEnergyString(sys)); | |
161 | DrawParameter(y, "L3 field", AliForwardUtil::MagneticFieldString(field)); | |
162 | DrawParameter(y, "Simulation", Form("%s", mc ? "yes" : "no")); | |
163 | DrawParameter(y, "Satellite", Form("%s", sat ? "yes" : "no")); | |
164 | PrintCanvas("Title"); | |
165 | ||
166 | if (what & AliForwardCorrectionManager::kSecondaryMap) { | |
167 | const AliFMDCorrSecondaryMap* sec = mgr.GetSecondaryMap(); | |
168 | if (!sec) | |
169 | Warning("CorrDrawer","No secondary map available"); | |
170 | else | |
171 | DrawIt(sec, true); | |
172 | } | |
173 | if (what & AliForwardCorrectionManager::kAcceptance) { | |
174 | const AliFMDCorrAcceptance* acc = mgr.GetAcceptance(); | |
175 | if (!acc) | |
176 | Warning("CorrDrawer","No acceptance available"); | |
177 | else | |
178 | DrawIt(acc, true); | |
179 | } | |
180 | if (what & AliForwardCorrectionManager::kELossFits) { | |
181 | const AliFMDCorrELossFit* fit = mgr.GetELossFit(); | |
182 | if (!fit) | |
183 | Warning("CorrDrawer","No energy loss fits available"); | |
184 | else | |
185 | DrawIt(fit, true); | |
186 | } | |
187 | CloseCanvas(); | |
188 | } | |
189 | /** | |
190 | * Fall-back method | |
191 | * | |
192 | * @param o Object to draw | |
193 | */ | |
194 | void Draw(const TObject* o) | |
195 | { | |
196 | if (!o) return; | |
197 | Warning("CorrDrawer", "Don't know how to draw a %s object", | |
198 | o->ClassName()); | |
199 | } | |
200 | /** | |
201 | * Draw a single plot of the mean acceptance correction | |
202 | * | |
203 | * @param acc Acceptance correction | |
204 | */ | |
205 | void Draw(const AliFMDCorrAcceptance* acc) { Summarize(acc, false); } | |
206 | /** | |
207 | * Draw a single plot of the mean secondary correction | |
208 | * | |
209 | * @param sec Secondary correction | |
210 | */ | |
211 | void Draw(const AliFMDCorrSecondaryMap* sec) { Summarize(sec, false); } | |
212 | /** | |
213 | * Draw a single plot summarizing the energy loss fits | |
214 | * | |
215 | * @param sec Energy loss fits | |
216 | */ | |
217 | void Draw(const AliFMDCorrELossFit* fits) { Summarize(fits, false); } | |
218 | /** | |
219 | * A generalized entry to the summarization functions | |
220 | * | |
221 | * @param what What to show - only one field | |
222 | * @param runNo Run number | |
223 | * @param sys System | |
224 | * @param sNN Center of mass energy in GeV | |
225 | * @param field L3 magnetic field | |
226 | * @param mc Simulation flag | |
227 | * @param sat Satellite interaction flag | |
228 | * @param options Options | |
229 | * @param local Local storage | |
230 | */ | |
231 | void Summarize(const TString& what, | |
232 | ULong_t runNo, | |
233 | UShort_t sys, | |
234 | UShort_t sNN, | |
235 | UShort_t field, | |
236 | Bool_t mc=false, | |
237 | Bool_t sat=false, | |
238 | Option_t* options="", | |
239 | const char* local="") | |
240 | { | |
241 | Summarize(AliForwardCorrectionManager::ParseFields(what), | |
242 | runNo, AliForwardUtil::ParseCollisionSystem(sys), | |
243 | sNN, field, mc, sat, options, local); | |
244 | } | |
245 | /** | |
246 | * A generalized entry to the summarization functions | |
247 | * | |
248 | * @param what What to show - only one field | |
249 | * @param runNo Run number | |
250 | * @param sys System | |
251 | * @param sNN Center of mass energy in GeV | |
252 | * @param field L3 magnetic field | |
253 | * @param mc Simulation flag | |
254 | * @param sat Satellite interaction flag | |
255 | * @param options Options | |
256 | * @param local Local storage | |
257 | */ | |
258 | void Summarize(UShort_t what, | |
259 | ULong_t runNo, | |
260 | UShort_t sys, | |
261 | UShort_t sNN, | |
262 | UShort_t field, | |
263 | Bool_t mc=false, | |
264 | Bool_t sat=false, | |
265 | Option_t* options="", | |
266 | const char* local="") | |
267 | { | |
268 | AliForwardCorrectionManager& mgr = AliForwardCorrectionManager::Instance(); | |
269 | mgr.SetDebug(true); | |
270 | if (local) mgr.SetPrefix(gSystem->DirName(local)); | |
271 | UShort_t flag = 0; | |
272 | ||
273 | if (what & AliForwardCorrectionManager::kSecondaryMap) | |
274 | flag = AliForwardCorrectionManager::kSecondaryMap; | |
275 | if (what & AliForwardCorrectionManager::kAcceptance) | |
276 | flag = AliForwardCorrectionManager::kAcceptance; | |
277 | if (what & AliForwardCorrectionManager::kELossFits) | |
278 | flag = AliForwardCorrectionManager::kELossFits; | |
279 | if (what & AliForwardCorrectionManager::kVertexBias) | |
280 | Warning("CorrDrawer","Vertex bias not implemented yet"); | |
281 | if (what & AliForwardCorrectionManager::kDoubleHit) | |
282 | Warning("CorrDrawer","Double hit not implemented yet"); | |
283 | if (what & AliForwardCorrectionManager::kMergingEfficiency) | |
284 | Warning("CorrDrawer","Merging efficiency not implemented yet"); | |
285 | if (flag == 0) { | |
286 | Warning("CorrDrawer", "Nothing to draw"); | |
287 | return; | |
288 | } | |
289 | ||
290 | if (!mgr.Init(runNo, sys, sNN, field, mc, sat, flag, true)) { | |
291 | Error("CorrDrawer", "Failed to initialize for flags=0x%02x" | |
292 | "run=%lu, sys=%hu, sNN=%hu, field=%hd, mc=%d, sat=%d", | |
293 | flags, runNo, sys, sNN, field, mc, sat); | |
294 | return; | |
295 | } | |
296 | ||
297 | TString prefix; | |
298 | if (flag == AliForwardCorrectionManager::kSecondaryMap) | |
299 | prefix = "secondarymap"; | |
300 | else if (flag == AliForwardCorrectionManager::kAcceptance) | |
301 | prefix = "acceptance"; | |
302 | else if (flag == AliForwardCorrectionManager::kELossFits) | |
303 | prefix = "elossfits"; | |
304 | else | |
305 | prefix = "unknown"; | |
306 | TString out; | |
307 | MakeFileName(out, prefix, runNo, sys, sNN, field, mc, sat); | |
308 | CreateCanvas(out); | |
309 | ||
310 | fBody->cd(); | |
311 | Double_t y = .8; | |
312 | DrawParameter(y, "Run #", Form("%lu", runNo)); | |
313 | DrawParameter(y, "System", AliForwardUtil::CollisionSystemString(sys)); | |
314 | DrawParameter(y, "#sqrt{s_{NN}}", | |
315 | AliForwardUtil::CenterOfMassEnergyString(sys)); | |
316 | DrawParameter(y, "L3 field", AliForwardUtil::MagneticFieldString(field)); | |
317 | DrawParameter(y, "Simulation", Form("%s", mc ? "yes" : "no")); | |
318 | DrawParameter(y, "Satellite", Form("%s", sat ? "yes" : "no")); | |
319 | PrintCanvas("Title"); | |
320 | ||
321 | if (flag == AliForwardCorrectionManager::kSecondaryMap) { | |
322 | const AliFMDCorrSecondaryMap* sec = mgr.GetSecondaryMap(); | |
323 | if (!sec) | |
324 | Warning("CorrDrawer","No secondary map available"); | |
325 | else | |
326 | DrawIt(sec, true); | |
327 | } | |
328 | else if (flag == AliForwardCorrectionManager::kAcceptance) { | |
329 | const AliFMDCorrAcceptance* acc = mgr.GetAcceptance(); | |
330 | if (!acc) | |
331 | Warning("CorrDrawer","No acceptance available"); | |
332 | else | |
333 | DrawIt(acc, true); | |
334 | } | |
335 | if (flag == AliForwardCorrectionManager::kELossFits) { | |
336 | const AliFMDCorrELossFit* fit = mgr.GetELossFit(); | |
337 | if (!fit) | |
338 | Warning("CorrDrawer","No energy loss fits available"); | |
339 | else | |
340 | DrawIt(fit, true); | |
341 | } | |
342 | CloseCanvas(); | |
343 | } | |
344 | /** | |
345 | * Fall-back method | |
346 | * | |
347 | * @param o Object to draw | |
348 | * @param pdf Not used | |
349 | */ | |
350 | void Summarize(const TObject* o, Bool_t pdf) | |
351 | { | |
352 | if (!o) return; | |
353 | Warning("CorrDrawer", "Don't know how to draw a %s object", | |
354 | o->ClassName()); | |
355 | } | |
356 | /** | |
357 | * Draw a single summary plot or multiple plots of the acceptance | |
358 | * correction. A new Canvas is created for this. | |
359 | * | |
360 | * @param acc Acceptance correction | |
361 | * @param pdf If true, do multiple plots. Otherwise a single summary plot | |
362 | */ | |
363 | void Summarize(const AliFMDCorrAcceptance* acc, Bool_t pdf) | |
364 | { | |
365 | CreateCanvas("acceptance.pdf", false, pdf); | |
366 | DrawIt(acc, pdf); | |
367 | if (pdf) CloseCanvas(); | |
368 | } | |
369 | /** | |
370 | * Draw a single summary plot multiple plots of the secondary | |
371 | * correction. A new canvas is created for this. | |
372 | * | |
373 | * @param sec Secondary correction | |
374 | * @param pdf If true, do multiple plots. Otherwise a single summary plot | |
375 | */ | |
376 | void Summarize(const AliFMDCorrSecondaryMap* sec, Bool_t pdf) | |
377 | { | |
378 | CreateCanvas("scondarymap.pdf", false, pdf); | |
379 | DrawIt(sec, pdf); | |
380 | if (pdf) CloseCanvas(); | |
381 | } | |
382 | /** | |
383 | * Draw a single summary plot multiple plots of the energy loss | |
384 | * fits. A new canvas is created for this. | |
385 | * | |
386 | * @param sec Energy loss fits | |
387 | * @param pdf If true, do multiple plots. Otherwise a single summary plot | |
388 | */ | |
389 | void Summarize(const AliFMDCorrELossFit* fits, Bool_t pdf=true) | |
390 | { | |
391 | CreateCanvas("elossfits.pdf", false, pdf); | |
392 | DrawIt(fits, pdf); | |
393 | if (pdf) CloseCanvas(); | |
394 | } | |
395 | protected: | |
396 | /** | |
397 | * Fall-back method | |
398 | * | |
399 | * @param o Object to summarize | |
400 | */ | |
401 | void DrawIt(const TObject* o) | |
402 | { | |
403 | if (!o) return; | |
404 | Warning("CorrDrawer", "Don't know how to summarize a %s object", | |
405 | o->ClassName()); | |
406 | } | |
407 | /** | |
408 | * Draw the acceptance correction | |
409 | * | |
410 | * @param corr Correction | |
411 | * @param details If true, make a multipage PDF, otherwise plot the mean. | |
412 | */ | |
413 | void DrawIt(const AliFMDCorrAcceptance* corr, Bool_t details=true) | |
414 | { | |
415 | if (!corr || !fCanvas) return; | |
416 | ||
417 | // --- Get vertex axis --------------------------------------------- | |
418 | const TAxis& vtxAxis = corr->GetVertexAxis(); | |
419 | Int_t nVtx = vtxAxis.GetNbins(); | |
420 | ||
421 | // --- Create stacks for summaries --------------------------------- | |
422 | TObjArray* stacks = CreateVtxStacks(vtxAxis); | |
423 | TObjArray* stacks2 = (corr->HasOverflow() && details | |
424 | ? CreateVtxStacks(vtxAxis) : 0); | |
425 | ||
426 | //__________________________________________________________________ | |
427 | // Create a title page | |
428 | if (details) { | |
429 | fBody->cd(); | |
430 | TLatex* ll = new TLatex(.5,.8, fCanvas->GetTitle()); | |
431 | ll->SetTextAlign(22); | |
432 | ll->SetTextSize(0.03); | |
433 | ll->SetNDC(); | |
434 | ll->Draw(); | |
435 | ||
436 | TLatex* l = new TLatex(.5,.8, ""); | |
437 | l->SetNDC(); | |
438 | l->SetTextSize(0.03); | |
439 | l->SetTextFont(132); | |
440 | l->SetTextAlign(12); | |
441 | l->DrawLatex(0.2, 0.70, "Acceptance due to dead channels"); | |
442 | l->SetTextAlign(22); | |
443 | l->DrawLatex(0.5, 0.55, "c_{v,r}(#eta,#phi) = #frac{" | |
444 | "#sum active strips #in (#eta,#phi)}{" | |
445 | "#sum strips #in (#eta,#phi)}"); | |
446 | ||
447 | PrintCanvas("Acceptance"); | |
448 | } | |
449 | ||
450 | // --- Loop over vertex ------------------------------------------ | |
451 | for (UShort_t v=1; v <= nVtx; v++) { | |
452 | Double_t vzMin = vtxAxis.GetBinLowEdge(v); | |
453 | Double_t vzMax = vtxAxis.GetBinUpEdge(v); | |
454 | ||
455 | if (details) DivideForRings(true, true); | |
456 | ||
457 | // --- Loop over detectors ------------------------------------- | |
458 | for (UShort_t d = 1; d <= 3; d++) { | |
459 | UShort_t nQ = (d == 1 ? 1 : 2); | |
460 | for (UShort_t q = 0; q < nQ; q++) { | |
461 | Char_t r = (q == 0 ? 'I' : 'O'); | |
462 | ||
463 | TH2* h2 = corr->GetCorrection(d, r, v); | |
464 | if (!h2) { | |
465 | Warning("DrawCorrAcc", "No correction for FMD%d%c, v=%d", d, r, v); | |
466 | continue; | |
467 | } | |
468 | ||
469 | if (details) DrawInRingPad(d, r, h2, "colz"); | |
470 | ||
471 | Int_t nY = h2->GetNbinsY(); | |
472 | TH1* hh = h2->ProjectionX(Form("FMD%d%c", d, r), 1, nY); | |
473 | hh->Scale(1. / nY); | |
474 | hh->SetDirectory(0); | |
475 | hh->SetMarkerColor(AliForwardUtil::RingColor(d, r)); | |
476 | hh->SetLineColor(AliForwardUtil::RingColor(d, r)); | |
477 | hh->SetFillColor(AliForwardUtil::RingColor(d, r)); | |
478 | hh->SetFillStyle(3001); | |
479 | ||
480 | THStack* stack = static_cast<THStack*>(stacks->At(v-1)); | |
481 | if (!stack) { | |
482 | Error("", "No stack at v=%d", v-1); | |
483 | continue; | |
484 | } | |
485 | stack->Add(hh); | |
486 | ||
487 | if (!stacks2) { | |
488 | Warning("", "No phi acceptance defined"); | |
489 | continue; | |
490 | } | |
491 | stack = static_cast<THStack*>(stacks2->At(v-1)); | |
492 | if (!stack) { | |
493 | Error("", "No stack at v=%d", v-1); | |
494 | continue; | |
495 | } | |
496 | TH1* hp = corr->GetPhiAcceptance(d, r, v); | |
497 | if (!hp) { | |
498 | Error("", "No phi acceptance at v=%d", v-1); | |
499 | continue; | |
500 | } | |
501 | hp->SetDirectory(0); | |
502 | hp->SetMarkerColor(AliForwardUtil::RingColor(d, r)); | |
503 | hp->SetLineColor(AliForwardUtil::RingColor(d, r)); | |
504 | hp->SetFillColor(AliForwardUtil::RingColor(d, r)); | |
505 | hp->SetFillStyle(3001); | |
506 | // Info("", "Adding phi acceptance plot %d", Int_t(hp->GetEntries())); | |
507 | stack->Add(hp); | |
508 | ||
509 | } | |
510 | } | |
511 | if (details) | |
512 | PrintCanvas(Form("%+5.1fcm<IP_{z}<%+5.1fcm", vzMin, vzMax)); | |
513 | } | |
514 | if (DrawVtxStacks(stacks2, 1.2)) { | |
515 | PrintCanvas("#phi acceptance"); | |
516 | } | |
517 | if (DrawVtxStacks(stacks, 1.2)) { | |
518 | PrintCanvas("#LTacceptance#GT"); | |
519 | } | |
520 | } | |
521 | /** | |
522 | * Draw the secondary correction | |
523 | * | |
524 | * @param corr Correction | |
525 | * @param details If true, make a multipage PDF, otherwise plot the mean. | |
526 | */ | |
527 | void DrawIt(const AliFMDCorrSecondaryMap* corr, bool details=true) | |
528 | { | |
529 | if (!corr || !fCanvas) return; | |
530 | ||
531 | const TAxis& vtxAxis = corr->GetVertexAxis(); | |
532 | Int_t nVtx = vtxAxis.GetNbins(); | |
533 | TObjArray* stacks = CreateVtxStacks(vtxAxis); | |
534 | ||
535 | //__________________________________________________________________ | |
536 | // Create a title page | |
537 | if (details) { | |
538 | fBody->cd(); | |
539 | TLatex* ll = new TLatex(.5,.8, fCanvas->GetTitle()); | |
540 | ll->SetTextAlign(22); | |
541 | ll->SetTextSize(0.03); | |
542 | ll->SetNDC(); | |
543 | ll->Draw(); | |
544 | ||
545 | TLatex* l = new TLatex(.5,.8, ""); | |
546 | l->SetNDC(); | |
547 | l->SetTextSize(0.03); | |
548 | l->SetTextFont(132); | |
549 | l->SetTextAlign(12); | |
550 | l->DrawLatex(0.2, 0.70, "Secondary map"); | |
551 | l->SetTextAlign(22); | |
552 | l->DrawLatex(0.5, 0.60, "c_{v,r}(#eta,#phi)=#frac{" | |
553 | "#sum N_{ch,primary,i}(#eta,#phi)}{" | |
554 | "#sum N_{ch,FMD,i}(#eta,#phi)}"); | |
555 | l->SetTextAlign(12); | |
556 | l->DrawLatex(0.2, 0.50, "N: Number of events"); | |
557 | l->DrawLatex(0.2, 0.45, "N_{ch,primary,i}(#eta,#phi): Number of charged, " | |
558 | "primary particles in (#eta,#phi) bin"); | |
559 | l->DrawLatex(0.2, 0.40, "N_{ch,primary,i}(#eta,#phi): Number of charged, " | |
560 | "particles that hit the FMD in (#eta,#phi) bin"); | |
561 | l->DrawLatex(0.2, 0.35, "All quantities determined in MC"); | |
562 | ||
563 | PrintCanvas("Secondary maps"); | |
564 | } | |
565 | ||
566 | // --- Loop over vertex ------------------------------------------ | |
567 | for (UShort_t v=1; v <= nVtx; v++) { | |
568 | Double_t vzMin = vtxAxis.GetBinLowEdge(v); | |
569 | Double_t vzMax = vtxAxis.GetBinUpEdge(v); | |
570 | ||
571 | if (details) DivideForRings(true, true); | |
572 | ||
573 | // --- Loop over detectors ------------------------------------- | |
574 | for (UShort_t d = 1; d <= 3; d++) { | |
575 | UShort_t nQ = (d == 1 ? 1 : 2); | |
576 | for (UShort_t q = 0; q < nQ; q++) { | |
577 | Char_t r = (q == 0 ? 'I' : 'O'); | |
578 | ||
579 | TH2* h2 = corr->GetCorrection(d, r, v); | |
580 | if (!h2) { | |
581 | Warning("DrawCorrSec", "No correction for FMD%d%c, v=%d", d, r, v); | |
582 | continue; | |
583 | } | |
584 | ||
585 | if (details) DrawInRingPad(d, r, h2, "colz"); | |
586 | ||
587 | Int_t nY = h2->GetNbinsY(); | |
588 | TH1* hh = h2->ProjectionX(Form("FMD%d%c", d, r), 1, nY); | |
589 | hh->Scale(1. / nY); | |
590 | hh->SetDirectory(0); | |
591 | hh->SetMarkerColor(AliForwardUtil::RingColor(d, r)); | |
592 | hh->SetLineColor(AliForwardUtil::RingColor(d, r)); | |
593 | hh->SetFillColor(AliForwardUtil::RingColor(d, r)); | |
594 | hh->SetFillStyle(3001); | |
595 | ||
596 | THStack* stack = static_cast<THStack*>(stacks->At(v-1)); | |
597 | if (!stack) { | |
598 | Error("", "No stack at v=%d", v-1); | |
599 | continue; | |
600 | } | |
601 | stack->Add(hh); | |
602 | } | |
603 | } | |
604 | if (details) | |
605 | PrintCanvas(Form("%+5.1fcm<IP_{z}<%+5.1fcm", vzMin, vzMax)); | |
606 | } | |
607 | if (DrawVtxStacks(stacks, 3.5)) { | |
608 | PrintCanvas("#LTsecondary map#GT"); | |
609 | } | |
610 | } | |
611 | /** | |
612 | * Draw the energy loss fits correction | |
613 | * | |
614 | * @param corr Correction | |
615 | * @param details If true, make a multipage PDF, | |
616 | * otherwise plot the parameters. | |
617 | */ | |
618 | void DrawIt(const AliFMDCorrELossFit* corr, bool details=true) | |
619 | { | |
620 | if (!corr || !fCanvas) return; | |
621 | ||
622 | AliFMDCorrELossFit* fits = const_cast<AliFMDCorrELossFit*>(corr); | |
623 | fits->CacheBins(8); | |
624 | fits->Print("C"); | |
625 | TList* fitter = 0; | |
626 | if (details) { | |
627 | TFile* hists = 0; | |
628 | TDirectory* savDir = gDirectory; | |
629 | if (!gSystem->AccessPathName("forward_eloss.root")) { | |
630 | hists = TFile::Open("forward_eloss.root", "READ"); | |
631 | // Info("", "Opened forward_eloss.root -> %p", hists); | |
632 | } | |
633 | if (hists) { | |
634 | TList* fr = static_cast<TList*>(hists->Get("ForwardResults")); | |
635 | // Info("", "Got forward results -> %p", fr); | |
636 | if (fr) { | |
637 | fitter = static_cast<TList*>(fr->FindObject("fmdEnergyFitter")); | |
638 | // Info("", "Got fitter -> %p", fitter); | |
639 | } | |
640 | hists->Close(); | |
641 | savDir->cd(); | |
642 | } | |
643 | fBody->cd(); | |
644 | TLatex* ll = new TLatex(.5,.8, fCanvas->GetTitle()); | |
645 | ll->SetTextAlign(22); | |
646 | ll->SetTextSize(0.05); | |
647 | ll->SetNDC(); | |
648 | ll->Draw(); | |
649 | ||
650 | TLatex* l = new TLatex(.5,.8, ""); | |
651 | l->SetNDC(); | |
652 | l->SetTextSize(0.03); | |
653 | l->SetTextFont(132); | |
654 | l->SetTextAlign(12); | |
655 | l->DrawLatex(0.2, 0.70, "1^{st} page is a summary of fit parameters"); | |
656 | l->DrawLatex(0.2, 0.67, "2^{nd} page is a summary of relative errors"); | |
657 | l->DrawLatex(0.2, 0.64, "Subsequent pages shows the fitted functions"); | |
658 | l->DrawLatex(0.3, 0.60, "Black line is the full fitted function"); | |
659 | l->DrawLatex(0.3, 0.57, "Coloured lines are the individual N-mip comp."); | |
660 | l->DrawLatex(0.3, 0.54, "Full drawn lines correspond to used components"); | |
661 | l->DrawLatex(0.3, 0.51, "Dashed lines correspond to ignored components"); | |
662 | l->DrawLatex(0.2, 0.47, "Each component has the form"); | |
663 | l->DrawLatex(0.3, 0.42, "f_{n}(x; #Delta, #xi, #sigma') = " | |
664 | "#int_{-#infty}^{+#infty}d#Delta' " | |
665 | "landau(x; #Delta', #xi)gaus(#Delta'; #Delta, #sigma')"); | |
666 | l->DrawLatex(0.2, 0.37, "The full function is given by"); | |
667 | l->DrawLatex(0.3, 0.32, "f_{N}(x; #Delta, #xi, #sigma', #bf{a}) = " | |
668 | "C #sum_{i=1}^{N} a_{i} " | |
669 | "f_{i}(x; #Delta_{i}, #xi_{i}, #sigma_{i}')"); | |
670 | l->DrawLatex(0.3, 0.26, "#Delta_{i} = i (#Delta_{1} + #xi_{1} log(i))"); | |
671 | l->DrawLatex(0.3, 0.23, "#xi_{i} = i #xi_{1}"); | |
672 | l->DrawLatex(0.3, 0.20, "#sigma_{i} = #sqrt{i} #sigma_{1}"); | |
673 | l->DrawLatex(0.3, 0.17, "#sigma_{n} #dot{=} 0"); | |
674 | l->DrawLatex(0.3, 0.14, "#sigma_{i}'^{2} = #sigma^{2}_{n} + #sigma_{i}^{2}"); | |
675 | l->DrawLatex(0.3, 0.11, "a_{1} #dot{=} 1"); | |
676 | PrintCanvas("Energy loss fits"); | |
677 | } | |
678 | ||
679 | fBody->cd(); | |
680 | fits->Draw("error"); | |
681 | PrintCanvas("Fit overview"); | |
682 | if (!details) return; | |
683 | ||
684 | //__________________________________________________________________ | |
685 | // Draw relative parameter errors | |
686 | fBody->cd(); | |
687 | fits->Draw("relative"); | |
688 | PrintCanvas("Relative parameter errors"); | |
689 | ||
690 | //__________________________________________________________________ | |
691 | // Draw all fits individually | |
692 | for (UShort_t d=1; d<=3; d++) { | |
693 | UShort_t nQ = (d == 1 ? 1 : 2); | |
694 | for (UShort_t q = 0; q < nQ; q++) { | |
695 | Char_t r = (q == 0 ? 'I' : 'O'); | |
696 | TList* dists = 0; | |
697 | if (fitter) { | |
698 | // Info("", "Fitter: %s", fitter->GetName()); | |
699 | TList* dl = | |
700 | static_cast<TList*>(fitter->FindObject(Form("FMD%d%c",d,r))); | |
701 | // Info("", "Got detector list -> %p", dl); | |
702 | if (dl) { | |
703 | // Info("", "Detector list: %s", dl->GetName()); | |
704 | dists = static_cast<TList*>(dl->FindObject("EDists")); | |
705 | // Info("", "Got distributions -> %p", dists); | |
706 | } | |
707 | } | |
708 | ||
709 | printf("FMD%d%c ", d, r); | |
710 | ClearCanvas(); | |
711 | TObjArray* ra = fits->GetRingArray(d, r); | |
712 | if (!ra) continue; | |
713 | DrawELossFits(d, r, ra, dists); | |
714 | } | |
715 | } | |
716 | } | |
717 | /** | |
718 | * CINT does too much when optimizing on a loop, so we take this out | |
719 | * to force CINT to not optimize the third nested loop. | |
720 | * | |
721 | * @param d | |
722 | * @param r | |
723 | * @param ra | |
724 | */ | |
725 | void DrawELossFits(UShort_t d, Char_t r, TObjArray* ra, TList* dists) | |
726 | { | |
727 | Int_t nPad = 6; | |
728 | AliFMDCorrELossFit::ELossFit* fit = 0; | |
729 | TIter next(ra); | |
730 | Int_t i = 0; | |
731 | Int_t j = 0; | |
732 | while ((fit = static_cast<AliFMDCorrELossFit::ELossFit*>(next()))) { | |
733 | j = i % nPad; | |
734 | Bool_t last = j == nPad-1; | |
735 | if (j == 0) DivideForRings(true, true); | |
736 | ||
737 | Bool_t same = false; | |
738 | if (dists) { | |
739 | // Info("", "Distributions: %s", dists->GetName()); | |
740 | TH1* dist = | |
741 | static_cast<TH1*>(dists->FindObject(Form("FMD%d%c_etabin%03d", | |
742 | d,r,fit->GetBin()))); | |
743 | // Info("", "Got histogram -> %p", dist); | |
744 | if (dist) { | |
745 | // Info("", "Histogram: %s", dist->GetName()); | |
746 | DrawInPad(fBody, j+1, dist, "HIST", 0x2); | |
747 | same = true; | |
748 | } | |
749 | } | |
750 | // if (same) | |
751 | DrawInPad(fBody, j+1, fit, | |
752 | Form("comp good values legend %s %s", | |
753 | (same ? "same" : "")), | |
754 | 0x2); | |
755 | if (fit->GetQuality() < 8) { | |
756 | TLatex* ltx = new TLatex(.2, .2, "NOT USED"); | |
757 | ltx->SetNDC(); | |
758 | ltx->SetTextFont(62); | |
759 | ltx->SetTextColor(kRed+1); | |
760 | ltx->SetTextAngle(30); | |
761 | ltx->SetTextSize(0.2); | |
762 | DrawInPad(fBody, j+1, ltx, "", 0); | |
763 | // ltx->Draw(); | |
764 | } | |
765 | ||
766 | // else | |
767 | // DrawInPad(fBody, j+1, fit, "comp good values legend", 0x2); | |
768 | printf("."); | |
769 | ||
770 | if (last) | |
771 | PrintCanvas(Form("FMD%d%c page %d", d, r, (i/nPad)+1)); | |
772 | i++; | |
773 | } | |
774 | j = i % nPad; | |
775 | if (j != 0) | |
776 | PrintCanvas(Form("FMD%d%c page %d", d, r, (i/nPad)+1)); | |
777 | printf(" done\n"); | |
778 | } | |
779 | ||
780 | /** | |
781 | * Create an array of per-vertex bin stacks | |
782 | * | |
783 | * @param vtxAxis Vertex axis | |
784 | * | |
785 | * @return Array of stacks | |
786 | */ | |
787 | TObjArray* CreateVtxStacks(const TAxis& vtxAxis) | |
788 | { | |
789 | // --- Create stacks for summaries --------------------------------- | |
790 | Int_t nVtx = vtxAxis.GetNbins(); | |
791 | TObjArray* stacks = new TObjArray(nVtx); | |
792 | for (UShort_t v = 1; v <= nVtx; v++) { | |
793 | THStack* stack = new THStack(Form("vtx%02d", v), | |
794 | Form("%+5.1f<v_{z}<%+5.1f", | |
795 | vtxAxis.GetBinLowEdge(v), | |
796 | vtxAxis.GetBinUpEdge(v))); | |
797 | stacks->AddAt(stack, v-1); | |
798 | } | |
799 | return stacks; | |
800 | } | |
801 | /** | |
802 | * Draw the vertex stacks in the canvas | |
803 | * | |
804 | * @param stacks Stacks to draw | |
805 | * @param max Possible maximum of the stacks | |
806 | * | |
807 | * @return true on success | |
808 | */ | |
809 | Bool_t DrawVtxStacks(TObjArray* stacks, Double_t max=-1) | |
810 | { | |
811 | if (!stacks) return false; | |
812 | // --- Make summary page ------------------------------------------- | |
813 | Int_t nVtx = 10; // stacks->GetEntries(); | |
814 | ||
815 | fBody->Divide(3, (nVtx+2)/3, 0, 0); | |
816 | Int_t ipad = 0; | |
817 | for (UShort_t v = 1; v <= nVtx; v++) { | |
818 | ipad++; | |
819 | ||
820 | if (ipad == 1 || ipad == 12) ipad++; | |
821 | ||
822 | THStack* stack = static_cast<THStack*>(stacks->At(v-1)); | |
823 | if (!stack) { | |
824 | Error("", "No stack at v=%d", v-1); | |
825 | continue; | |
826 | } | |
827 | TVirtualPad* pad = fBody->cd(ipad); | |
828 | if (!pad) { | |
829 | Error("", "No pad at %d", ipad); | |
830 | continue; | |
831 | } | |
832 | pad->SetFillColor(kWhite); | |
833 | ||
834 | if (max > 0) stack->SetMaximum(max); | |
835 | stack->Draw("nostack hist"); | |
836 | } | |
837 | return true; | |
838 | } | |
839 | ||
840 | }; | |
841 | ||
842 | ||
843 | ||
844 | // | |
845 | // EOF | |
846 | // |