]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGLF/FORWARD/analysis2/scripts/SummaryAODDrawer.C
Fixed up scripts to use same flags for Pause and Landscape.
[u/mrichter/AliRoot.git] / PWGLF / FORWARD / analysis2 / scripts / SummaryAODDrawer.C
CommitLineData
2955f67c 1#include "SummaryDrawer.C"
2
8449e3e0 3/**
4 * Class to draw a summary of the AOD production
5 *
6 * @par Input:
7 * - The merged <tt>forward.root</tt> file.
8 * If the file isn't merged, it should still work.
9 *
10 * @par Output:
11 * - A PDF file named after the input, but with <tt>.root</tt>
12 * replaced with <tt>pdf</tt>
13 *
14 */
2955f67c 15class SummaryAODDrawer : public SummaryDrawer
16{
17public:
8449e3e0 18 enum EFlags {
19 kEventInspector = 0x001,
20 kSharingFilter = 0x002,
21 kDensityCalculator = 0x004,
22 kCorrector = 0x008,
23 kHistCollector = 0x010,
24 kSteps = 0x020,
25 kResults = 0x040,
fba5d22d 26 kCentral = 0x080,
27 kNormal = 0x0FF
8449e3e0 28 };
2955f67c 29 SummaryAODDrawer()
30 : SummaryDrawer(),
31 fSums(0),
32 fResults(0)
33 {}
34
35 //__________________________________________________________________
36 /**
37 *
38 *
39 * @param fname
40 * @param what
41 */
8449e3e0 42 void Run(const char* fname, UShort_t what=kNormal)
2955f67c 43 {
44 // --- Open the file ---------------------------------------------
45 TString filename(fname);
46 TFile* file = TFile::Open(filename, "READ");
47 if (!file) {
48 Error("Run", "Failed to open \"%s\"", filename.Data());
49 return;
50 }
bfab35d9 51
8449e3e0 52
2955f67c 53 // --- Get top-level collection ----------------------------------
54 fSums = GetCollection(file, "Forward");
55 if (!fSums) return;
56
bfab35d9 57 // --- Do the results ----------------------------------------------
58 fResults = GetCollection(file, "ForwardResults");
59 if (!fResults) fResults = fSums; // Old-style
60
2955f67c 61 // --- Make our canvas -------------------------------------------
62 TString pdfName(filename);
63 pdfName.ReplaceAll(".root", ".pdf");
bfab35d9 64 CreateCanvas(pdfName, what & kLandscape);
65 DrawTitlePage(file);
8449e3e0 66
67 // --- Possibly make a chapter here ------------------------------
68 if (what & kCentral && GetCollection(file, "Central"))
69 MakeChapter("Forward");
2955f67c 70
71 // --- Set pause flag --------------------------------------------
bfab35d9 72 fPause = what & kPause;
2955f67c 73
74 // --- Do each sub-algorithm -------------------------------------
bfab35d9 75 if (what & kEventInspector) DrawEventInspector(fSums);
76 if (what & kSharingFilter) DrawSharingFilter();
77 if (what & kDensityCalculator) DrawDensityCalculator();
78 if (what & kCorrector) DrawCorrector();
79 if (what & kHistCollector) DrawHistCollector();
2955f67c 80
2955f67c 81
bfab35d9 82 if (what & kSteps) DrawSteps();
83 if (what & kResults) DrawResults();
8449e3e0 84
85 // --- SPD clusters ----------------------------------------------
bfab35d9 86 if (what & kCentral) {
8449e3e0 87 // --- Get top-level collection --------------------------------
88 fSums = GetCollection(file, "Central");
89 if (fSums) {
90 MakeChapter("Central");
91 DrawCentral();
bfab35d9 92 if (what & kEventInspector) DrawEventInspector(fSums);
93 }
94 fResults = GetCollection(file, "CentralResults");
95 if (fResults && (what & kResults)) {
96 DrawCentralResults();
8449e3e0 97 }
bfab35d9 98
99 if (what & kResults) DrawBoth(file);
8449e3e0 100 }
101
bfab35d9 102
2955f67c 103 CloseCanvas();
104 }
105protected:
106 //____________________________________________________________________
bfab35d9 107 void DrawTitlePage(TFile* f)
2955f67c 108 {
2955f67c 109 fBody->cd();
110
bfab35d9 111 TLatex* ltx = new TLatex(.5, .7, "ESD #rightarrow AOD filtering");
112 ltx->SetNDC();
113 ltx->SetTextSize(0.07);
114 ltx->SetTextAlign(22);
115 ltx->Draw();
116
117 TCollection* fwd = GetCollection(f, "Forward");
118 TCollection* cen = GetCollection(f, "Central");
119 Double_t y = .6;
120
2955f67c 121 Double_t save = fParName->GetTextSize();
122 fParName->SetTextSize(0.03);
123 fParVal->SetTextSize(0.03);
8449e3e0 124
bfab35d9 125 DrawParameter(y, "Tasks", (fwd ? "Forward" : ""));
126 DrawParameter(y, "", (cen ? "Central" : ""));
127
128 if (fwd) {
129 TCollection* ei = GetCollection(fwd, "fmdEventInspector");
130 if (ei) {
131
fba5d22d 132 UShort_t sys=0, sNN=0;
133 Int_t field=0;
134 ULong_t runNo=0;
bfab35d9 135 Bool_t mc=false;
fba5d22d 136 GetParameter(ei, "sys", sys);
137 GetParameter(ei, "sNN", sNN);
138 GetParameter(ei, "field", field);
139 GetParameter(ei, "runNo", runNo);
140 if (!GetParameter(ei, "mc", mc, false)) mc = false;
141
142 TString sysString; SysString(sys, sysString);
143 TString sNNString; SNNString(sNN, sNNString);
bfab35d9 144
fba5d22d 145 DrawParameter(y, "System", sysString);
146 DrawParameter(y, "#sqrt{s_{NN}}", sNNString);
147 DrawParameter(y, "L3 B field", Form("%+2dkG", field));
148 DrawParameter(y, "Run #", Form("%6lu", runNo));
bfab35d9 149 DrawParameter(y, "Simulation", (mc ? "yes" : "no"));
150 }
151 }
152 PrintCanvas("Title page");
2955f67c 153 fParName->SetTextSize(save);
154 fParVal->SetTextSize(save);
2955f67c 155 }
156 //____________________________________________________________________
157 void DrawSharingFilter()
158 {
bfab35d9 159 Info("DrawSharingFilter", "Drawing sharing filter");
2955f67c 160 TCollection* c = GetCollection(fSums, "fmdSharingFilter");
161 if (!c) return;
bfab35d9 162 TCollection* rc = GetCollection(fResults, "fmdSharingFilter");
163 if (!rc) rc = c;
2955f67c 164
165 fBody->Divide(1, 3);
166 fBody->cd(1);
167
168 Double_t y = .8;
169 Bool_t angle=false, lowSignal=false, simple=false;
bfab35d9 170
8449e3e0 171 if (GetParameter(c, "angle", angle))
172 DrawParameter(y, "Angle correct", (angle ? "yes" : "no"));
173 if (GetParameter(c, "lowSignal", lowSignal))
174 DrawParameter(y, "Lower signal", (lowSignal ? "yes" : "no"));
bfab35d9 175
8449e3e0 176 if (GetParameter(c, "simple", simple))
177 DrawParameter(y, "Simple method", (simple ? "yes" : "no"));
bfab35d9 178 TParameter<int>* nFiles =
179 static_cast<TParameter<int>*>(GetObject(c, "nFiles"));
180 if (nFiles)
181 DrawParameter(y, "# files merged", Form("%d", nFiles->GetVal()));
2955f67c 182
bfab35d9 183
184 TCollection* lc = GetCollection(c, "lCuts");
185 TCollection* hc = GetCollection(c, "hCuts");
186 Int_t lm, hm;
187 if (GetParameter(lc, "method", lm))
188 DrawParameter(y, "Low cut method", (lm == 0 ? "fixed" :
189 lm == 1 ? "fraction of MPV" :
190 lm == 2 ? "fit range" :
191 lm == 3 ? "Landau width" :
192 "unknown"));
193 if (GetParameter(hc, "method", hm))
194 DrawParameter(y, "High cut method", (hm == 0 ? "fixed" :
195 hm == 1 ? "fraction of MPV" :
196 hm == 2 ? "fit range" :
197 hm == 3 ? "Landau width" :
198 "unknown"));
199
200
201 TH2* hLow = GetH2(c, "lowCuts");
202 TH2* hHigh = GetH2(c, "highCuts");
203 if (hLow && nFiles) hLow->Scale(1. / nFiles->GetVal());
204 if (hHigh && nFiles) hHigh->Scale(1. / nFiles->GetVal());
205 DrawInPad(fBody, 2, hLow, "colz");
206 DrawInPad(fBody, 3, hHigh, "colz");
2955f67c 207
208 PrintCanvas("Sharing filter");
209
210 const char* subs[] = { "FMD1I", "FMD2I", "FMD2O", "FMD3O", "FMD3I", 0 };
211 const char** ptr = subs;
212 while (*ptr) {
213 TCollection* sc = GetCollection(c, *ptr);
214 if (!sc) { ptr++; continue; }
215
216 fBody->Divide(2,3);
fba5d22d 217 DrawInPad(fBody, 1, GetH1(sc, "esdEloss"), "", kLogy,
079fd669 218 "#Delta/#Delta_{mip} reconstructed and merged");
fba5d22d 219 DrawInPad(fBody, 1, GetH1(sc, "anaEloss"), "same", kLogy|kLegend);
220 DrawInPad(fBody, 2, GetH1(sc, "singleEloss"), "", kLogy,
079fd669 221 "#Delta/#Delta_{mip} for single, double, and tripple hits");
fba5d22d 222 DrawInPad(fBody, 2, GetH1(sc, "doubleEloss"), "same", kLogy);
223 DrawInPad(fBody, 2, GetH1(sc, "tripleEloss"), "same", kLogy|kLegend);
224 DrawInPad(fBody, 3, GetH2(sc, "singlePerStrip"), "colz", kLogz);
8449e3e0 225 // DrawInPad(fBody, 4, GetH1(sc, "distanceBefore"), "", 0x2);
226 // DrawInPad(fBody, 4, GetH1(sc, "distanceAfter"), "same", 0x12);
227 DrawInPad(fBody, 4, GetH2(sc, "summed"), "colz", 0x0);
2955f67c 228
229 TH2* nB = GetH2(sc, "neighborsBefore");
230 if (nB) {
231 nB->GetXaxis()->SetRangeUser(0,8);
232 nB->GetYaxis()->SetRangeUser(0,8);
233 }
fba5d22d 234 DrawInPad(fBody, 5, nB, "colz", kLogz);
235 DrawInPad(fBody, 5, GetH2(sc, "neighborsAfter"), "p same", kLogz,
079fd669 236 "Correlation of neighbors before and after merging");
fba5d22d 237 DrawInPad(fBody, 6, GetH2(sc, "beforeAfter"), "colz", kLogz);
2955f67c 238
239 PrintCanvas(Form("Sharing filter - %s", *ptr));
240 ptr++;
241 }
242
243 // --- MC --------------------------------------------------------
244 TCollection* cc = GetCollection(c, "esd_mc_comparion", false); // Spelling!
245 if (!cc) return; // Not MC
246
247 DivideForRings(false, false);
fba5d22d 248 DrawInRingPad(1, 'I', GetH2(cc, "FMD1i_corr"), "colz", kLogz);
249 DrawInRingPad(2, 'I', GetH2(cc, "FMD2i_corr"), "colz", kLogz);
250 DrawInRingPad(2, 'O', GetH2(cc, "FMD2o_corr"), "colz", kLogz);
251 DrawInRingPad(3, 'I', GetH2(cc, "FMD3i_corr"), "colz", kLogz);
252 DrawInRingPad(3, 'O', GetH2(cc, "FMD3o_corr"), "colz", kLogz);
2955f67c 253
254 PrintCanvas("Sharing filter - MC vs Reco");
255
256 // --- MC --------------------------------------------------------
bfab35d9 257 DrawTrackDensity(c);
2955f67c 258 }
259
260 //____________________________________________________________________
261 void DrawDensityCalculator()
262 {
263 Info("DrawDensityCalculator", "Drawing density calculator");
264 TCollection* c = GetCollection(fSums, "fmdDensityCalculator");
265 if (!c) return;
266
267 fBody->Divide(2, 2);
268 fBody->cd(1);
269
270 Double_t y = .8;
271 Int_t maxParticles=0, phiAcceptance=0, etaLumping=0, phiLumping=0;
272 Bool_t method=false, recalcEta=false, recalcPhi=false;
8449e3e0 273 Double_t size = fLandscape ? 0.06 : 0.04;
2955f67c 274
8449e3e0 275 GetParameter(c, "maxParticle", maxParticles);
276
277 if (GetParameter(c, "phiAcceptance", phiAcceptance))
278 DrawParameter(y, "#phi acceptance method",
279 (phiAcceptance == 1 ? "N_{ch}" :
280 phiAcceptance == 2 ? "#DeltaE" : "none"), size);
281
282 if (GetParameter(c, "etaLumping", etaLumping) &&
283 GetParameter(c, "phiLumping", phiLumping))
284 DrawParameter(y, "Region size (sector#timesstrip)",
285 Form("%2d #times %2d", phiLumping, etaLumping), size);
286
287 if (GetParameter(c, "method", method))
288 DrawParameter(y, "Method", (method ? "Poisson" : "#DeltaE"), size);
289
290 if (GetParameter(c, "recalcEta", recalcEta))
291 DrawParameter(y, "Recalculate #eta",(recalcEta ? "yes" : "no"),size);
292
293 if (GetParameter(c, "recalcPhi", recalcPhi))
294 DrawParameter(y, "Recalculate #phi",(recalcPhi ? "yes" : "no"),size);
bfab35d9 295 TParameter<int>* nFiles =
296 static_cast<TParameter<int>*>(GetObject(c, "nFiles"));
297 if (nFiles)
298 DrawParameter(y, "# files merged", Form("%d", nFiles->GetVal()));
8449e3e0 299
bfab35d9 300 TCollection* lc = GetCollection(c, "lCuts");
301 Int_t lm;
302 if (GetParameter(lc, "method", lm))
303 DrawParameter(y, "Low cut method", (lm == 0 ? "fixed" :
304 lm == 1 ? "fraction of MPV" :
305 lm == 2 ? "fit range" :
306 lm == 3 ? "Landau width" :
307 "unknown"));
2955f67c 308
2955f67c 309
310 TVirtualPad* p = fBody; // fBody->cd(2);
311 // p->Divide(3,1);
312
313 TH1* accI = GetH1(c, "accI");
314 TH1* accO = GetH1(c, "accO");
315 if (accI) {
316 Double_t scale = 1./accI->GetMaximum();
317 accI->Scale(scale);
318 accO->Scale(scale);
319 accI->SetMinimum(0);
320 }
bfab35d9 321 TH2* lCuts = GetH2(c, "lowCuts");
322 TH2* maxW = GetH2(c, "maxWeights");
323 if (nFiles && lCuts) lCuts->Scale(1. / nFiles->GetVal());
324 if (nFiles && maxW) maxW->Scale(1. / nFiles->GetVal());
2955f67c 325 DrawInPad(p, 2, accI);
fba5d22d 326 DrawInPad(p, 2, accO, "same", kLegend);
bfab35d9 327 DrawInPad(p, 3, lCuts, "colz");
328 DrawInPad(p, 4, maxW, "colz");
2955f67c 329
330 PrintCanvas("Density calculator");
331
332 const char* subs[] = { "FMD1I", "FMD2I", "FMD2O", "FMD3O", "FMD3I", 0 };
333 const char** ptr = subs;
334 while (*ptr) {
335 TCollection* sc = GetCollection(c, *ptr);
336 if (!sc) { ptr++; continue; }
337
338 fBody->Divide(2,3);
339
fba5d22d 340 DrawInPad(fBody, 1, GetH2(sc, "elossVsPoisson"), "colz", kLogz);
341 DrawInPad(fBody, 2, GetH1(sc, "diffElossPoisson"), "HIST E", kLogy);
342 DrawInPad(fBody, 3, GetH1(sc, "occupancy"), "", kLogy);
343 DrawInPad(fBody, 4, GetH1(sc, "eloss"), "", kLogy,
079fd669 344 "#Delta/#Delta_{mip} before and after cuts");
fba5d22d 345 DrawInPad(fBody, 4, GetH1(sc, "elossUsed"), "same",kLogy|kLegend);
2955f67c 346 TH1* phiB = GetH1(sc, "phiBefore");
347 TH1* phiA = GetH1(sc, "phiAfter");
348 if (phiB && phiA) {
349 phiA->Add(phiB, -1);
350 phiA->Divide(phiB);
351 phiA->SetTitle("#Delta#phi from Ip (x,y) correction");
352 phiA->SetYTitle("(#phi_{after}-#phi_{before})/#phi_{before}");
353 }
354 DrawInPad(fBody, 5, phiA);
fba5d22d 355 DrawInPad(fBody, 6, GetH2(sc, "phiAcc"), "colz", kLogz);
2955f67c 356
357 PrintCanvas(Form("Density calculator - %s", *ptr));
358 ptr++;
359 }
360
361 TCollection* cc = GetCollection(c, "esd_mc_comparison", false);
362 if (!cc) return; // Not MC
363
364 fBody->Divide(2,5);
fba5d22d 365 DrawInPad(fBody, 1, GetH2(cc, "FMD1I_corr_mc_esd"), "colz", kLogz);
366 DrawInPad(fBody, 3, GetH2(cc, "FMD2I_corr_mc_esd"), "colz", kLogz);
367 DrawInPad(fBody, 5, GetH2(cc, "FMD2O_corr_mc_esd"), "colz", kLogz);
368 DrawInPad(fBody, 7, GetH2(cc, "FMD3O_corr_mc_esd"), "colz", kLogz);
369 DrawInPad(fBody, 9, GetH2(cc, "FMD3I_corr_mc_esd"), "colz", kLogz);
370 DrawInPad(fBody, 2, GetH1(cc, "FMD1I_diff_mc_esd"), "", kLogy);
371 DrawInPad(fBody, 4, GetH1(cc, "FMD2I_diff_mc_esd"), "", kLogy);
372 DrawInPad(fBody, 6, GetH1(cc, "FMD2O_diff_mc_esd"), "", kLogy);
373 DrawInPad(fBody, 8, GetH1(cc, "FMD3O_diff_mc_esd"), "", kLogy);
374 DrawInPad(fBody, 10, GetH1(cc, "FMD3I_diff_mc_esd"), "", kLogy);
2955f67c 375
376 PrintCanvas("Density calculator - MC vs Reco");
377 }
378
379 //____________________________________________________________________
380 void DrawCorrector()
381 {
382 Info("DrawCorrector", "Drawing corrector");
383 TCollection* c = GetCollection(fSums, "fmdCorrector");
384 if (!c) return;
385
386 fBody->cd();
387
388 Double_t y = .8;
389 Bool_t secondary=false, vertexBias=false, acceptance=false, merging=false;
8449e3e0 390 if (GetParameter(c, "secondary", secondary))
391 DrawParameter(y, "Secondary corr.", secondary ? "yes" : "no");
392 if (GetParameter(c, "acceptance", acceptance))
393 DrawParameter(y, "Acceptance corr.", acceptance ? "yes" : "no");
394 if (GetParameter(c, "vertexBias", vertexBias))
395 DrawParameter(y, "Vertex bias corr.", vertexBias ? "yes" : "no");
396 if (GetParameter(c, "merging", merging))
397 DrawParameter(y, "Merging eff.", merging ? "yes" : "no");
2955f67c 398
399 PrintCanvas("Corrector");
400
401 TCollection* cc = GetCollection(c, "esd_mc_comparison", false);
402 if (!cc) return; // Not MC
403
404 DivideForRings(false, false);
405
406 DrawInRingPad(1, 'I', GetH2(cc, "FMD1I_esd_vs_mc"), "colz", 0x0);
407 DrawInRingPad(2, 'I', GetH2(cc, "FMD2I_esd_vs_mc"), "colz", 0x0);
408 DrawInRingPad(2, 'O', GetH2(cc, "FMD2O_esd_vs_mc"), "colz", 0x0);
409 DrawInRingPad(3, 'O', GetH2(cc, "FMD3O_esd_vs_mc"), "colz", 0x0);
410 DrawInRingPad(3, 'I', GetH2(cc, "FMD3I_esd_vs_mc"), "colz", 0x0);
411
412 PrintCanvas("Corrector - MC vs Reco");
413 }
414
415 //____________________________________________________________________
416 void DrawHistCollector()
417 {
418 Info("DrawHistCollector", "Drawing histogram collector");
419 TCollection* c = GetCollection(fSums, "fmdHistCollector");
420 if (!c) return;
421
422 fBody->Divide(1, 3);
423 fBody->cd(1);
424
425 Double_t y = .8;
426 Int_t nCutBins=0, fiducial=0, merge=0, skipRings=0;
427 Double_t fiducialCut=0.;
428 Bool_t bgAndHits=false;
429
8449e3e0 430 if (GetParameter(c, "nCutBins", nCutBins))
431 DrawParameter(y, "# of bins to cut", Form("%d", nCutBins));
432
433 if (GetParameter(c, "skipRings", skipRings)) {
434 TString skipped;
435 if (skipRings & 0x05) skipped.Append("FMD1i ");
436 if (skipRings & 0x09) skipped.Append("FMD2i ");
437 if (skipRings & 0x0a) skipped.Append("FMD2o ");
438 if (skipRings & 0x11) skipped.Append("FMD3i ");
439 if (skipRings & 0x12) skipped.Append("FMD3o ");
440 DrawParameter(y, "Skipped rings", skipped);
441 }
442
443 if (GetParameter(c, "bgAndHits", bgAndHits))
444 DrawParameter(y, "Bg & hit maps stored.", bgAndHits?"yes":"no");
445
446 if (GetParameter(c, "merge", merge))
447 DrawParameter(y, "Merge method",
448 (merge == 0 ? "straight mean" :
449 merge == 1 ? "straight mean, no zeroes" :
450 merge == 2 ? "weighted mean" :
451 merge == 3 ? "least error" :
452 merge == 4 ? "sum" : "unknown"));
453
454 if (GetParameter(c, "fiducial", fiducial))
455 DrawParameter(y, "Fiducial method.",
456 fiducial == 0 ? "cut" : "distance");
457
458 if (GetParameter(c, "fiducialCut", fiducialCut))
459 DrawParameter(y, "Fiducial cut.", Form("%f", fiducialCut));
460
2955f67c 461
462 DrawInPad(fBody, 2, GetH2(c, "sumRings"), "colz");
463 DrawInPad(fBody, 3, GetH2(c, "coverage"), "colz");
464
465 fBody->cd(1)->Modified();
466 fBody->cd(2)->Modified();
467 fBody->cd(3)->Modified();
468 fBody->cd(1)->Update();
469 fBody->cd(2)->Update();
470 fBody->cd(3)->Update();
471 PrintCanvas("Histogram collector");
8449e3e0 472
473
474 TIter next(c);
475 TObject* o = 0;
476 TRegexp regexp("[pm][0-9]+_[pm][0-9]+");
477 while ((o = next())) {
478 TString name(o->GetName());
479 if (name.Index(regexp) == kNPOS) continue;
480
481 TList* vl = static_cast<TList*>(o);
482
483 DivideForRings(false, false);
484
485 DrawInRingPad(1, 'I', GetH2(vl, "secMapFMD1I"), "colz", 0x0);
486 DrawInRingPad(2, 'I', GetH2(vl, "secMapFMD2I"), "colz", 0x0);
487 DrawInRingPad(2, 'O', GetH2(vl, "secMapFMD2O"), "colz", 0x0);
488 DrawInRingPad(3, 'O', GetH2(vl, "secMapFMD3O"), "colz", 0x0);
489 DrawInRingPad(3, 'I', GetH2(vl, "secMapFMD3I"), "colz", 0x0);
490 DrawInRingPad(1, 'I', GetH2(vl, "hitMapFMD1I"), "box same", 0x0);
491 DrawInRingPad(2, 'I', GetH2(vl, "hitMapFMD2I"), "box same", 0x0);
492 DrawInRingPad(2, 'O', GetH2(vl, "hitMapFMD2O"), "box same", 0x0);
493 DrawInRingPad(3, 'O', GetH2(vl, "hitMapFMD3O"), "box same", 0x0);
494 DrawInRingPad(3, 'I', GetH2(vl, "hitMapFMD3I"), "box same", 0x0);
495
496 PrintCanvas(Form("Histogram Collector - Vertex bin %s", vl->GetName()));
497 }
498
499 o = c->FindObject("byCentrality");
500 if (!o) return;
501 TList* bc = static_cast<TList*>(o);
502
503 DrawInPad(fBody, GetH3(bc, "FMD1I"), "box", 0);
504 DrawInPad(fBody, GetH3(bc, "FMD2I"), "box same", 0);
505 DrawInPad(fBody, GetH3(bc, "FMD2O"), "box same", 0);
506 DrawInPad(fBody, GetH3(bc, "FMD3O"), "box same", 0);
fba5d22d 507 DrawInPad(fBody, GetH3(bc, "FMD3I"), "box same", kLegend);
2955f67c 508 }
8449e3e0 509
510 //____________________________________________________________________
511 void DrawCentral()
512 {
513 Info("DrawCentral", "Drawing central (SPD)");
514 TCollection* c = fSums;
515 if (!c) return;
516
517 fBody->Divide(1, 3);
518 fBody->cd(1);
519
520
079fd669 521 DrawInPad(fBody, 1, GetH2(c, "coverage"), "col", 0,
522 "#eta coverage per v_{z}");
fba5d22d 523 DrawInPad(fBody, 2, GetH2(c, "nClusterVsnTracklet"), "colz", kLogx|kLogy,
079fd669 524 "Correlation of # of tracklets and clusters");
525 DrawInPad(fBody, 3, GetH2(c, "clusterPerTracklet"), "colz", 0x0,
526 "# clusters per tracklet vs #eta");
8449e3e0 527
528 fBody->cd(1)->Modified();
529 fBody->cd(2)->Modified();
530 fBody->cd(3)->Modified();
531 fBody->cd(1)->Update();
532 fBody->cd(2)->Update();
533 fBody->cd(3)->Update();
534 PrintCanvas("Central - overview");
535
536
537 TIter next(c);
538 TObject* o = 0;
539 TRegexp regexp("[pm][0-9]+_[pm][0-9]+");
540 while ((o = next())) {
541 TString name(o->GetName());
542 if (name.Index(regexp) == kNPOS) continue;
543
544 TList* vl = static_cast<TList*>(o);
545
546 fBody->Divide(1, 3);
547
548 DrawInPad(fBody, 1, GetH1(vl, "acceptance"), "", 0);
549
550 TH1* sec = GetH1(vl, "secondary");
551 sec->SetMarkerStyle(21);
552 sec->SetMarkerSize(1.2);
553 DrawInPad(fBody, 2, sec, "", 0);
554 DrawInPad(fBody, 2, GetH1(vl, "secondaryFiducial"), "same", 0x0);
555 DrawInPad(fBody, 3, GetH2(vl, "secondaryMapFiducial"), "colz", 0);
556 DrawInPad(fBody, 3, GetH2(vl, "hitMap"), "box same", 0x0);
557
558 fBody->cd(1)->Modified();
559 fBody->cd(2)->Modified();
560 fBody->cd(3)->Modified();
561 fBody->cd(1)->Update();
562 fBody->cd(2)->Update();
563 fBody->cd(3)->Update();
564 PrintCanvas(Form("Central - Vertex bin %s", vl->GetName()));
565 }
566 }
567
2955f67c 568
569 //____________________________________________________________________
570 void AddToAll(THStack* all, const THStack* stack, Int_t curr, Int_t step)
571 {
572 if (!stack) return;
573
574 TIter next(stack->GetHists());
575 TH1* h = 0;
576 while ((h = static_cast<TH1*>(next()))) {
577 TH1* copy = static_cast<TH1*>(h->Clone(Form("%s_copy", h->GetName())));
578 copy->SetDirectory(0);
579 if (curr != step) {
580 copy->SetMarkerColor(kGray);
581 copy->SetLineColor(kGray);
582 }
583 all->Add(copy);
584 }
585 }
586 //____________________________________________________________________
587 void AddToAll(THStack* all, const THStack* stack)
588 {
589 if (!stack) return;
590
591 TIter next(stack->GetHists());
592 TH1* h = 0;
593 while ((h = static_cast<TH1*>(next()))) {
594 TH1* copy = static_cast<TH1*>(h->Clone(Form("%s_copy", h->GetName())));
595 copy->SetDirectory(0);
596 copy->SetMarkerColor(kGray);
597 copy->SetLineColor(kGray);
598 all->Add(copy);
599 }
600 }
601
602 //____________________________________________________________________
603 void DrawStep(Int_t step,
604 THStack* all,
605 TObject* cur,
606 TLegend* leg,
607 const char* title,
608 TVirtualPad* can)
609 {
8449e3e0 610 if (all->GetHists()->GetEntries() <= 0 || !cur) return;
611
2955f67c 612 // Info("", "Drawing step # %d", step);
613 Bool_t left = (step % 2) == 1;
614 TVirtualPad* p = can->cd(step);
615 gStyle->SetOptTitle(0);
616 p->SetTitle(Form("Step # %d", step));
617 p->SetFillColor(kWhite);
618 p->SetRightMargin(left ? 0 : 0.02);
619 p->SetTopMargin(0); // 0.02);
620
621 p->cd();
622 all->Draw("nostack");
623 all->GetHistogram()->SetXTitle("#eta");
624 all->GetHistogram()->SetYTitle("signal");
625
626 // p->cd();
627 gROOT->SetSelectedPad(p);
628 cur->DrawClone("same nostack");
629 leg->DrawClone("");
630
631 TLatex* ltx = new TLatex(.97, .97, title);
632 ltx->SetNDC();
633 ltx->SetTextSize(.06);
634 ltx->SetTextAlign(33);
635 ltx->Draw();
636
637 ltx = new TLatex((left ? .12 : .02), .97, p->GetTitle());
638 ltx->SetNDC();
639 ltx->SetTextSize(.06);
640 ltx->SetTextAlign(13);
641 ltx->Draw();
642
643 p->Modified();
644 p->Update();
645 p->cd();
079fd669 646
647 gStyle->SetOptTitle(1);
2955f67c 648 }
649
650 //____________________________________________________________________
651 void FixStack(THStack* stack, const TString& title,
652 const TString& extra, Int_t marker)
653 {
654 if (!stack) return;
655 stack->SetTitle(title);
656 TIter next(stack->GetHists());
657 TH1* h = 0;
658 while ((h = static_cast<TH1*>(next()))) {
659 h->SetMarkerStyle(marker);
660 TString tit(h->GetTitle());
661 tit.ReplaceAll("cache", "");
662 tit.Append(extra);
663 h->SetTitle(tit);
664 }
665 }
8449e3e0 666 void AddLegendEntry(TLegend* l,
667 const TH1* h,
668 const TString& title)
669 {
670 if (!h) return;
671
672 TLegendEntry* e = l->AddEntry("dummy", title.Data(), "pl");
673 e->SetMarkerStyle(h->GetMarkerStyle());
674 e->SetMarkerColor(kGray);
675 e->SetLineColor(kGray);
676 e->SetTextColor(kGray);
677 }
678
679
2955f67c 680 //____________________________________________________________________
681 void DrawSteps()
682 {
683 // MakeChapter(can, "Steps");
684
685 THStack* deltas = GetStack(GetCollection(fResults, "fmdSharingFilter"),
686 "sums", "summed");
687 THStack* nchs = GetStack(GetCollection(fResults,
688 "fmdDensityCalculator"),
689 "sums", "inclDensity");
690 THStack* prims = GetStack(GetCollection(fResults, "fmdCorrector"),
691 "sums", "primaryDensity");
692 THStack* rings = GetStack(GetCollection(fResults, "ringResults"), "all");
693 THStack* mcRings = GetStack(GetCollection(fResults, "mcRingResults", false),
694 "all","dndeta_eta", false);
695 TH1* dndeta = GetH1(fResults, "dNdeta");
8449e3e0 696 if (dndeta) dndeta->SetMarkerColor(kBlack);
2955f67c 697
698 FixStack(deltas, "#sum_{} #Delta/#Delta_{mip}", "", 20);
699 FixStack(nchs, "#sum_{} N_{ch,incl}", "", 21);
700 FixStack(prims, "#sum_{} N_{ch,primary}", "", 22);
701 FixStack(rings, "dN/d#eta per ring", "", 23);
702 FixStack(mcRings,"dN/d#eta per ring (MC)", "(MC)", 34);
703
704 THStack* all = new THStack;
705 AddToAll(all, mcRings);
706 AddToAll(all, deltas);
707 AddToAll(all, nchs);
708 AddToAll(all, prims);
709 AddToAll(all, rings);
710
8449e3e0 711 TH1* res = 0;
712 if (dndeta) {
713 res = static_cast<TH1*>(dndeta->Clone("dNdeta"));
714 res->SetTitle("dN/d#eta");
715 res->SetMarkerColor(kGray);
716 res->SetLineColor(kGray);
717 res->SetDirectory(0);
718 all->Add(res);
719 }
2955f67c 720
721 TLegend* l = new TLegend(.35, .2, .55, .9);
722 l->SetFillColor(kWhite);
723 l->SetFillStyle(0);
724 l->SetBorderSize(0);
725 TLegendEntry* e = 0;
726
727 TH1* h = 0;
728 if (mcRings) {
729 h = static_cast<TH1*>(mcRings->GetHists()->At(0));
8449e3e0 730 AddLegendEntry(l, h, mcRings->GetTitle());
2955f67c 731 }
732
8449e3e0 733 if (deltas) {
734 h = static_cast<TH1*>(deltas->GetHists()->At(0));
735 AddLegendEntry(l, h, deltas->GetTitle());
736 }
737
738 if (nchs) {
739 h = static_cast<TH1*>(nchs->GetHists()->At(0));
740 AddLegendEntry(l, h, nchs->GetTitle());
741 }
742
743 if (prims) {
744 h = static_cast<TH1*>(prims->GetHists()->At(0));
745 AddLegendEntry(l, h, prims->GetTitle());
746 }
747
748 if (rings) {
749 h = static_cast<TH1*>(rings->GetHists()->At(0));
750 AddLegendEntry(l, h, rings->GetTitle());
751 }
752
753 if (res) {
754 h = res;
755 AddLegendEntry(l, h, h->GetTitle());
756 }
2955f67c 757
758 TObject* objs[] = { mcRings,
759 deltas,
760 nchs,
761 prims,
762 rings,
763 dndeta };
764 const char* titles[] = { "MC",
765 "After merging",
766 "After particle counting",
767 "After corrections",
768 "After normalization",
769 "After combining" };
770
771 fBody->Divide(2, 3, 0, 0); // mcRings ? 4 : 3, 0, 0);
772 Int_t step = 0;
773 for (Int_t i = 0; i < 6; i++) {
774 TObject* obj = objs[i];
775 if (!obj) continue;
776 e = static_cast<TLegendEntry*>(l->GetListOfPrimitives()->At(step));
777 e->SetMarkerColor(kBlack);
778 e->SetLineColor(kBlack);
779 e->SetTextColor(kBlack);
780 step++;
781
782 DrawStep(step, all, obj, l, titles[i], fBody);
783 e->SetMarkerColor(kGray);
784 e->SetLineColor(kGray);
785 e->SetTextColor(kGray);
786 }
787
8449e3e0 788 if (!mcRings && deltas) {
2955f67c 789 fBody->cd(6);
790 TLegend* ll = new TLegend(0.01, 0.11, 0.99, 0.99);
791 // ll->SetNDC();
792 ll->SetFillColor(kWhite);
793 ll->SetFillStyle(0);
794 ll->SetBorderSize(0);
795
796 TIter next(deltas->GetHists());
797 TH1* hh = 0;
798 while ((hh = static_cast<TH1*>(next()))) {
799 e = ll->AddEntry("dummy", hh->GetTitle(), "pl");
800 e->SetMarkerColor(hh->GetMarkerColor());
801 e->SetMarkerStyle(hh->GetMarkerStyle());
802 e->SetLineColor(kBlack);
803 }
804 ll->Draw();
805 }
806 PrintCanvas("Steps");
807 }
808
809
810 //____________________________________________________________________
811 void DrawResults()
812 {
813 // MakeChapter(can, "Results");
814
815 fBody->Divide(2,2);
816
817 TCollection* c = GetCollection(fResults, "ringResults");
818 if (!c) return;
819
820 THStack* mcRings = GetStack(GetCollection(fResults, "mcRingResults", false),
821 "all", "dndeta_eta", false);
822
823 TH1* dndeta_phi = GetH1(fResults, "dNdeta");
824 TH1* dndeta_eta = GetH1(fResults, "dNdeta_");
825 dndeta_phi->SetTitle("1/N_{ev}dN_{ch}/d#eta (#varphi norm)");
826 dndeta_eta->SetTitle("1/N_{ev}dN_{ch}/d#eta (#eta norm)");
827 dndeta_eta->SetMarkerSize(0.7);
828
bfab35d9 829 THStack* allPhi = new THStack("phiAcc", "#varphi Acceptance");
830 THStack* allEta = new THStack("etaCov", "#eta Coverage");
831 const char* rings[] = { "FMD1I", "FMD2I", "FMD2O", "FMD3I", "FMD3O", 0 };
832 const char** pring = rings;
833
834 while ((*pring)) {
835 TCollection* cc = GetCollection(c, *pring);
836 TH1* etaCov = GetH1(cc, "etaCov");
837 TH1* phiAcc = GetH1(cc, "phiAcc");
838 TH1* dndeta = GetH1(cc, "dndeta_phi");
839 Int_t color = kBlack;
840 if (dndeta) color = dndeta->GetMarkerColor();
841 if (etaCov) {
842 etaCov->SetTitle(*pring);
843 etaCov->SetFillColor(color);
844 etaCov->SetLineColor(color);
845 allEta->Add(etaCov);
846 }
847 if (phiAcc) {
848 phiAcc->SetFillColor(color);
849 phiAcc->SetLineColor(color);
850 allPhi->Add(phiAcc);
851 }
852 pring++;
853 }
fba5d22d 854 DrawInPad(fBody, 1, GetStack(c, "all"), "nostack", mcRings ? 0 : kLegend,
079fd669 855 "Individual ring results");
fba5d22d 856 DrawInPad(fBody, 1, mcRings, "nostack same", kLegend);
079fd669 857 DrawInPad(fBody, 2, dndeta_phi,
858 "1/#it{N}_{ev} d#it{N}_{ch}/d#it{#eta}");
fba5d22d 859 DrawInPad(fBody, 2, dndeta_eta, "Same", kLegend);
860 DrawInPad(fBody, 3, allEta, "nostack hist", kLegend,
079fd669 861 "#phi acceptance and #eta coverage per ring");
bfab35d9 862 DrawInPad(fBody, 3, allPhi, "nostack hist same", 0x0);
079fd669 863 DrawInPad(fBody, 4, GetH1(fResults, "norm"), "", 0x0,
864 "Total #phi acceptance and #eta coverage");
fba5d22d 865 DrawInPad(fBody, 4, GetH1(fResults, "phi"), "same", kLegend);
bfab35d9 866 // DrawInPad(fBody, 4, GetH1(fSums, "d2Ndetadphi"), "colz");
2955f67c 867
079fd669 868 // fBody->cd(1);
869 // TLatex* l = new TLatex(.5, .2, "Ring results");
870 // l->SetNDC();
871 // l->SetTextAlign(21);
872 // l->Draw();
2955f67c 873
079fd669 874 // fBody->cd(2);
875 // l->DrawLatex(.5, .2, "1/N_{ev}dN_{ch}/d#eta");
2955f67c 876
877 // fBody->cd(3);
878 // l->DrawLatex(.5, .2, "1/N_{ev}dN_{ch}/d#eta (#vta norm.)");
879
880 PrintCanvas("Results");
881 }
882
bfab35d9 883 //____________________________________________________________________
884 void DrawCentralResults()
885 {
886 // MakeChapter(can, "Results");
887 Info("DrawCentralResults", "Drawing central results");
888
889 fBody->Divide(1,2,0,0);
890
891 TH1* dndeta_ = GetH1(fResults, "dNdeta_");
892 TH1* dndeta = GetH1(fResults, "dNdeta");
893 THStack* stack = new THStack("dndetas",
894 "d#it{N}_{ch}/d#it{#eta} - central");
895 stack->Add(dndeta_);
896 stack->Add(dndeta);
897
898 DrawInPad(fBody, 1, stack, "nostack");
899 stack->GetHistogram()->SetXTitle("#it{#eta}");
900 stack->GetHistogram()->SetYTitle("#frac{d#it{N}_{ch}}{d#it{#eta}}");
901 fBody->cd(1);
902 TLegend* l = new TLegend(.3, .05, .7, .4);
903 l->SetFillColor(0);
904 l->SetFillStyle(0);
905 l->SetBorderSize(0);
906 l->AddEntry(dndeta_, "Normalized to coverage", "lp");
907 l->AddEntry(dndeta, "Normalized to #phi acceptance", "lp");
908 l->Draw();
909
910 DrawInPad(fBody, 2, GetH1(fResults, "norm"));
911 DrawInPad(fBody, 2, GetH1(fResults, "phi"), "same", kLegend);
912
913 PrintCanvas("Central Results");
914
915 }
916 void DrawBoth(TFile* file)
917 {
918 Info("DrawBoth", "Drawing central & forward results");
919 TCollection* central = GetCollection(file, "CentralResults");
920 TCollection* forward = GetCollection(file, "ForwardResults");
921
922 if (!central || !forward) {
923 Warning("DrawBoth", "central %p or forward %p results not found",
924 central, forward);
925 return;
926 }
927
928 TH1* f1 = GetH1(forward, "dNdeta_");
929 TH1* c1 = GetH1(central, "dNdeta_");
930 TH1* f2 = GetH1(forward, "dNdeta");
931 TH1* c2 = GetH1(central, "dNdeta");
932 f1->SetLineColor(kBlack);
933 f2->SetLineColor(kBlack);
934 c1->SetLineColor(kBlack);
935 c2->SetLineColor(kBlack);
936 f1->SetMarkerColor(f2->GetMarkerColor());
937 f1->SetMarkerStyle(24);
938 c1->SetMarkerStyle(24);
939 c2->SetMarkerStyle(20);
940 c2->SetMarkerColor(c1->GetMarkerColor());
941 THStack* s = new THStack("dndetas", "d#it{N}_{ch}/d#it{#eta}");
942 s->Add(f1);
943 s->Add(c1);
944 s->Add(f2);
945 s->Add(c2);
946
947 fBody->Divide(1, 2, 0, 0);
948 DrawInPad(fBody, 1, s, "nostack");
949 s->GetHistogram()->SetXTitle("#it{#eta}");
950 s->GetHistogram()->SetYTitle("#frac{d#it{N}_{ch}}{d#it{#eta}}");
951
952 fBody->cd(1);
953 TLegend* l = new TLegend(.4, .05, .8, .4);
954 l->SetFillColor(0);
955 l->SetFillStyle(0);
956 l->SetBorderSize(0);
957 TLegendEntry* entry = l->AddEntry("dummy", "Forward", "f");
958 entry->SetFillColor(f1->GetMarkerColor());
959 entry->SetLineColor(f1->GetMarkerColor());
960 entry->SetFillStyle(1001);
961 entry->SetLineWidth(0);
962 entry = l->AddEntry("dummy", "Central", "f");
963 entry->SetFillColor(c1->GetMarkerColor());
964 entry->SetLineColor(c1->GetMarkerColor());
965 entry->SetLineWidth(0);
966 entry->SetFillStyle(1001);
967 entry = l->AddEntry("dummy", "Normalized to coverage", "lp");
968 entry->SetMarkerStyle(f1->GetMarkerStyle());
969 entry = l->AddEntry("dummy", "Normalized to #phi acceptance", "lp");
970 entry->SetMarkerStyle(f2->GetMarkerStyle());
971 l->Draw();
972
973 TH1* f3 = GetH1(forward, "norm");
974 TH1* c3 = GetH1(central, "norm");
975 TH1* f4 = GetH1(forward, "phi");
976 TH1* c4 = GetH1(central, "phi");
977 f3->SetFillColor(f1->GetMarkerColor());
978 f4->SetFillColor(f1->GetMarkerColor());
979 c3->SetFillColor(c1->GetMarkerColor());
980 c4->SetFillColor(c1->GetMarkerColor());
981 f3->SetLineColor(f1->GetMarkerColor());
982 f4->SetLineColor(f1->GetMarkerColor());
983 c3->SetLineColor(c1->GetMarkerColor());
984 c4->SetLineColor(c1->GetMarkerColor());
985
986 THStack* a = new THStack("norms", "Normalizations");
987 a->Add(f3);
988 a->Add(c3);
989 a->Add(f4);
990 a->Add(c4);
991
992 a->SetMaximum(a->GetMaximum("nostack")*1.2);
993 DrawInPad(fBody, 2, a, "nostack");
994 a->GetHistogram()->SetXTitle("#it{#eta}");
995 a->GetHistogram()->SetYTitle("Normalization (coverage or acceptance)");
996
997 fBody->cd(2);
998 l = new TLegend(.2, .94, .9, .99);
999 l->SetFillColor(0);
1000 l->SetFillStyle(0);
1001 l->SetBorderSize(0);
1002 l->SetNColumns(2);
1003 // entry = l->AddEntry("dummy", "Forward", "f");
1004 // entry->SetFillColor(f1->GetMarkerColor());
1005 // entry->SetLineColor(f1->GetMarkerColor());
1006 // entry->SetFillStyle(1001);
1007 // entry->SetLineWidth(0);
1008 // entry = l->AddEntry("dummy", "Central", "f");
1009 // entry->SetFillColor(c1->GetMarkerColor());
1010 // entry->SetLineColor(c1->GetMarkerColor());
1011 // entry->SetLineWidth(0);
1012 // entry->SetFillStyle(1001);
1013 entry = l->AddEntry("dummy", "#eta Coverage", "f");
1014 entry->SetFillStyle(f3->GetFillStyle());
1015 entry->SetFillColor(kBlack);
1016 entry = l->AddEntry("dummy", "#phi Acceptance", "f");
1017 entry->SetFillStyle(f4->GetFillStyle());
1018 entry->SetFillColor(kBlack);
1019 l->Draw();
1020
1021 PrintCanvas("Both results");
1022 }
2955f67c 1023 TCollection* fSums;
1024 TCollection* fResults;
1025};
1026
1027// #endif