]>
Commit | Line | Data |
---|---|---|
2955f67c | 1 | #include "SummaryDrawer.C" |
77f97e3f CHC |
2 | #ifndef __CINT__ |
3 | # include <TGraph.h> | |
4 | # include <TGraphErrors.h> | |
5 | # include <TF1.h> | |
6 | # include <TArrow.h> | |
7 | #else | |
8 | class TGraph; | |
06963733 | 9 | class TFile; |
77f97e3f | 10 | #endif |
2955f67c | 11 | |
8449e3e0 | 12 | /** |
13 | * Class to draw a summary of the AOD production | |
14 | * | |
15 | * @par Input: | |
16 | * - The merged <tt>forward.root</tt> file. | |
17 | * If the file isn't merged, it should still work. | |
18 | * | |
19 | * @par Output: | |
20 | * - A PDF file named after the input, but with <tt>.root</tt> | |
21 | * replaced with <tt>pdf</tt> | |
22 | * | |
23 | */ | |
2955f67c | 24 | class SummaryAODDrawer : public SummaryDrawer |
25 | { | |
26 | public: | |
8449e3e0 | 27 | enum EFlags { |
28 | kEventInspector = 0x001, | |
29 | kSharingFilter = 0x002, | |
30 | kDensityCalculator = 0x004, | |
31 | kCorrector = 0x008, | |
32 | kHistCollector = 0x010, | |
33 | kSteps = 0x020, | |
34 | kResults = 0x040, | |
fba5d22d | 35 | kCentral = 0x080, |
24338c03 | 36 | kESDFixer = 0x100, |
37 | kNormal = 0x1FF | |
8449e3e0 | 38 | }; |
2955f67c | 39 | SummaryAODDrawer() |
40 | : SummaryDrawer(), | |
41 | fSums(0), | |
42 | fResults(0) | |
43 | {} | |
2955f67c | 44 | //__________________________________________________________________ |
06963733 | 45 | TFile* Init(const char* fname) |
2955f67c | 46 | { |
47 | // --- Open the file --------------------------------------------- | |
48 | TString filename(fname); | |
49 | TFile* file = TFile::Open(filename, "READ"); | |
50 | if (!file) { | |
51 | Error("Run", "Failed to open \"%s\"", filename.Data()); | |
06963733 | 52 | return 0; |
2955f67c | 53 | } |
8449e3e0 | 54 | |
2955f67c | 55 | // --- Get top-level collection ---------------------------------- |
c8b1a7db | 56 | fSums = GetCollection(file, "ForwardSums"); |
b767da2c | 57 | if (!fSums) { |
58 | Info("Run", "Trying old name Forward"); | |
59 | fSums = GetCollection(file, "Forward"); | |
06963733 | 60 | if (!fSums) return 0; |
b767da2c | 61 | } |
2955f67c | 62 | |
bfab35d9 | 63 | // --- Do the results ---------------------------------------------- |
64 | fResults = GetCollection(file, "ForwardResults"); | |
65 | if (!fResults) fResults = fSums; // Old-style | |
66 | ||
06963733 | 67 | return file; |
68 | } | |
69 | void SummarizeSharing(const char* fname, UShort_t what=0) | |
70 | { | |
71 | // --- Initialize ------------------------------------------------ | |
72 | TFile* file = 0; | |
73 | if (!(file = Init(fname))) return; | |
74 | ||
75 | // --- Make our canvas ------------------------------------------- | |
76 | TString pdfName("sharing.pdf"); | |
77 | pdfName.ReplaceAll(".root", ".pdf"); | |
78 | CreateCanvas(pdfName, what & kLandscape, true, false); | |
79 | ||
80 | TCollection* c = GetCollection(fSums, "fmdSharingFilter"); | |
81 | if (!c) return; | |
82 | TCollection* rc = GetCollection(fResults, "fmdSharingFilter"); | |
83 | if (!rc) rc = c; | |
84 | ||
85 | Int_t nFiles = 0; | |
86 | TParameter<int>* pnFiles = | |
87 | static_cast<TParameter<int>*>(GetObject(c, "nFiles")); | |
88 | if (pnFiles) { | |
89 | nFiles = pnFiles->GetVal(); | |
90 | } | |
91 | ||
92 | TCollection* lc = GetCollection(c, "lCuts"); | |
93 | TCollection* hc = GetCollection(c, "hCuts"); | |
94 | Int_t lm = 0; | |
95 | Int_t hm = 0; | |
96 | TH2* hLow = GetH2(c, "lowCuts"); | |
97 | TH2* hHigh = GetH2(c, "highCuts"); | |
98 | GetParameter(lc, "method", lm); | |
99 | GetParameter(hc, "method", hm); | |
100 | if (hLow && nFiles > 0 && !hLow->TestBit(BIT(20))) | |
101 | hLow->Scale(1. / nFiles); | |
102 | if (hHigh && nFiles > 0 && !hHigh->TestBit(BIT(20))) | |
103 | hHigh->Scale(1. / nFiles); | |
104 | ||
105 | DivideForRings(true,true); | |
106 | const char** ptr = GetRingNames(false); | |
107 | UShort_t iq = 1; | |
108 | while (*ptr) { | |
109 | TCollection* sc = GetCollection(c, *ptr); | |
110 | if (!sc) { ptr++; iq++; continue; } | |
111 | UShort_t d = Int_t((*ptr)[3])-48; | |
112 | Char_t r = (*ptr)[4]; | |
113 | ||
114 | TH1* esdELoss = GetH1(sc, "esdEloss"); | |
115 | TH1* anaELoss = GetH1(sc, "anaEloss"); | |
116 | TGraph* lowCut = CreateCutGraph(lm, iq, hLow, esdELoss, kYellow+1); | |
117 | TGraph* highCut = CreateCutGraph(hm, iq, hHigh, esdELoss, kCyan+1); | |
118 | // Double_t ignCut = TMath::Max(lowCut->GetX()[3],0.); | |
119 | // Int_t esdLow = esdELoss->FindBin(ignCut); | |
120 | // Int_t anaLow = anaELoss->FindBin(ignCut); | |
121 | // Double_t esdInt = esdELoss->Integral(esdLow,esdELoss->GetNbinsX()+1); | |
122 | // Double_t anaInt = anaELoss->Integral(anaLow,anaELoss->GetNbinsX()+1); | |
123 | // Double_t frac = esdInt > 0 ? (esdInt-anaInt)/esdInt : 1; | |
124 | esdELoss->GetXaxis()->SetRangeUser(-.1, 2); | |
125 | ||
126 | DrawInRingPad(d,r, esdELoss, "", kLogy, *ptr); | |
127 | // "#Delta/#Delta_{mip} reconstructed and merged"); | |
128 | DrawInRingPad(d, r, anaELoss, "same"); | |
129 | DrawInRingPad(d, r, lowCut, "lf same"); | |
130 | DrawInRingPad(d, r, highCut, "lf same"); | |
131 | ptr++; | |
132 | iq++; | |
133 | } | |
134 | TVirtualPad* p = RingPad(0,0); | |
135 | p->cd(); | |
136 | TLegend* l = new TLegend(0.1, 0.1, 0.98, 0.98, ""); | |
137 | l->SetFillStyle(0); | |
138 | l->SetFillColor(0); | |
139 | l->SetBorderSize(0); | |
140 | TLegendEntry* e = 0; | |
141 | e = l->AddEntry("dummy", "ESD signal", "f"); | |
142 | e->SetFillStyle(3002); | |
143 | e->SetFillColor(kBlack); | |
144 | e = l->AddEntry("dummy", "Merged signal", "f"); | |
145 | e->SetFillStyle(3001); | |
146 | e->SetFillColor(kBlack); | |
147 | e = l->AddEntry("dummy", "Low cut", "f"); | |
148 | e->SetFillStyle(3002); | |
149 | e->SetFillColor(kYellow+1); | |
150 | e->SetLineWidth(0); | |
151 | e->SetLineColor(kWhite); | |
152 | e = l->AddEntry("dummy", "High cut", "f"); | |
153 | e->SetFillStyle(3002); | |
154 | e->SetFillColor(kCyan+1); | |
155 | e->SetLineWidth(0); | |
156 | e->SetLineColor(kWhite); | |
157 | l->Draw(); | |
158 | ||
159 | PrintCanvas("Summary of sharing filter"); | |
160 | CloseCanvas(); | |
161 | ||
162 | } | |
163 | void SummarizeSteps(const char* fname, UShort_t what=0) | |
164 | { | |
165 | // --- Initialize ------------------------------------------------ | |
166 | TFile* file = 0; | |
167 | if (!(file = Init(fname))) return; | |
168 | ||
169 | // --- Make our canvas ------------------------------------------- | |
170 | TString pdfName("steps.pdf"); | |
171 | pdfName.ReplaceAll(".root", ".pdf"); | |
172 | CreateCanvas(pdfName, what & kLandscape, true, false); | |
173 | DrawSteps(); | |
174 | CloseCanvas(); | |
175 | } | |
176 | ||
177 | //__________________________________________________________________ | |
178 | /** | |
179 | * | |
180 | * | |
181 | * @param fname | |
182 | * @param what | |
183 | */ | |
184 | void Run(const char* fname, UShort_t what=kNormal) | |
185 | { | |
186 | // --- Initialize ------------------------------------------------ | |
187 | TFile* file = 0; | |
188 | if (!(file = Init(fname))) return; | |
189 | ||
2955f67c | 190 | // --- Make our canvas ------------------------------------------- |
06963733 | 191 | TString pdfName(fname); |
2955f67c | 192 | pdfName.ReplaceAll(".root", ".pdf"); |
bfab35d9 | 193 | CreateCanvas(pdfName, what & kLandscape); |
194 | DrawTitlePage(file); | |
8449e3e0 | 195 | |
196 | // --- Possibly make a chapter here ------------------------------ | |
b767da2c | 197 | TCollection* centralSums = GetCollection(file, "CentralSums", false); |
77f97e3f CHC |
198 | if (!centralSums) { |
199 | Info("Run", "Trying old name \"Central\""); | |
b767da2c | 200 | centralSums = GetCollection(file, "Central", false); |
77f97e3f | 201 | } |
b767da2c | 202 | if (what & kCentral && centralSums) |
8449e3e0 | 203 | MakeChapter("Forward"); |
2955f67c | 204 | |
205 | // --- Set pause flag -------------------------------------------- | |
bfab35d9 | 206 | fPause = what & kPause; |
2955f67c | 207 | |
29dc6eb3 | 208 | // Plot status if found |
7c844559 | 209 | TH1* hStatus = GetH1(fSums, "status", false); |
29dc6eb3 | 210 | if (hStatus) { |
211 | hStatus->SetMaximum(hStatus->GetMaximum()*1.2); | |
212 | fBody->SetRightMargin(0.10); | |
213 | DrawInPad(fBody,0,hStatus, "hist text30"); | |
214 | PrintCanvas("Status"); | |
215 | } | |
216 | ||
2955f67c | 217 | // --- Do each sub-algorithm ------------------------------------- |
bfab35d9 | 218 | if (what & kEventInspector) DrawEventInspector(fSums); |
24338c03 | 219 | if (what & kESDFixer) DrawESDFixer(fSums); |
bfab35d9 | 220 | if (what & kSharingFilter) DrawSharingFilter(); |
221 | if (what & kDensityCalculator) DrawDensityCalculator(); | |
222 | if (what & kCorrector) DrawCorrector(); | |
223 | if (what & kHistCollector) DrawHistCollector(); | |
2955f67c | 224 | |
2955f67c | 225 | |
bfab35d9 | 226 | if (what & kSteps) DrawSteps(); |
227 | if (what & kResults) DrawResults(); | |
8449e3e0 | 228 | |
229 | // --- SPD clusters ---------------------------------------------- | |
bfab35d9 | 230 | if (what & kCentral) { |
8449e3e0 | 231 | // --- Get top-level collection -------------------------------- |
c8b1a7db | 232 | fSums = GetCollection(file, "CentralSums"); |
77f97e3f CHC |
233 | if (!fSums) |
234 | fSums = GetCollection(file, "Central"); | |
8449e3e0 | 235 | if (fSums) { |
236 | MakeChapter("Central"); | |
237 | DrawCentral(); | |
bfab35d9 | 238 | if (what & kEventInspector) DrawEventInspector(fSums); |
239 | } | |
240 | fResults = GetCollection(file, "CentralResults"); | |
241 | if (fResults && (what & kResults)) { | |
242 | DrawCentralResults(); | |
8449e3e0 | 243 | } |
bfab35d9 | 244 | |
245 | if (what & kResults) DrawBoth(file); | |
8449e3e0 | 246 | } |
247 | ||
bfab35d9 | 248 | |
2955f67c | 249 | CloseCanvas(); |
250 | } | |
251 | protected: | |
252 | //____________________________________________________________________ | |
bfab35d9 | 253 | void DrawTitlePage(TFile* f) |
2955f67c | 254 | { |
2955f67c | 255 | fBody->cd(); |
256 | ||
bfab35d9 | 257 | TLatex* ltx = new TLatex(.5, .7, "ESD #rightarrow AOD filtering"); |
258 | ltx->SetNDC(); | |
259 | ltx->SetTextSize(0.07); | |
260 | ltx->SetTextAlign(22); | |
261 | ltx->Draw(); | |
262 | ||
b767da2c | 263 | TCollection* fwd = fSums; // GetCollection(f, "ForwardSums"); |
c8b1a7db | 264 | TCollection* cen = GetCollection(f, "CentralSums"); |
bfab35d9 | 265 | Double_t y = .6; |
266 | ||
2955f67c | 267 | Double_t save = fParName->GetTextSize(); |
268 | fParName->SetTextSize(0.03); | |
269 | fParVal->SetTextSize(0.03); | |
8449e3e0 | 270 | |
bfab35d9 | 271 | DrawParameter(y, "Tasks", (fwd ? "Forward" : "")); |
272 | DrawParameter(y, "", (cen ? "Central" : "")); | |
273 | ||
274 | if (fwd) { | |
275 | TCollection* ei = GetCollection(fwd, "fmdEventInspector"); | |
276 | if (ei) { | |
277 | ||
fba5d22d | 278 | UShort_t sys=0, sNN=0; |
279 | Int_t field=0; | |
280 | ULong_t runNo=0; | |
bfab35d9 | 281 | Bool_t mc=false; |
fba5d22d | 282 | GetParameter(ei, "sys", sys); |
283 | GetParameter(ei, "sNN", sNN); | |
284 | GetParameter(ei, "field", field); | |
285 | GetParameter(ei, "runNo", runNo); | |
286 | if (!GetParameter(ei, "mc", mc, false)) mc = false; | |
287 | ||
288 | TString sysString; SysString(sys, sysString); | |
289 | TString sNNString; SNNString(sNN, sNNString); | |
bfab35d9 | 290 | |
fba5d22d | 291 | DrawParameter(y, "System", sysString); |
292 | DrawParameter(y, "#sqrt{s_{NN}}", sNNString); | |
293 | DrawParameter(y, "L3 B field", Form("%+2dkG", field)); | |
294 | DrawParameter(y, "Run #", Form("%6lu", runNo)); | |
bfab35d9 | 295 | DrawParameter(y, "Simulation", (mc ? "yes" : "no")); |
296 | } | |
297 | } | |
298 | PrintCanvas("Title page"); | |
2955f67c | 299 | fParName->SetTextSize(save); |
300 | fParVal->SetTextSize(save); | |
2955f67c | 301 | } |
77f97e3f CHC |
302 | TGraph* CreateCutGraph(Int_t method, Int_t iy, TH2* cuts, TH1* eloss, |
303 | Int_t color) | |
304 | { | |
305 | TGraph* ret = new TGraph(4); | |
306 | Double_t y0 = TMath::Max(eloss->GetMinimum(),1.); | |
307 | Double_t y1 = eloss->GetMaximum(); | |
308 | Double_t min = 1000; | |
309 | Double_t max = 0; | |
29dc6eb3 | 310 | Int_t iiy = (iy == 4 ? 5 : iy == 5 ? 4 : iy); |
77f97e3f | 311 | if (method == 0) { // Fixed value |
29dc6eb3 | 312 | max = cuts->GetBinContent(1, iiy); |
77f97e3f CHC |
313 | min = eloss->GetXaxis()->GetXmin(); |
314 | } | |
315 | else { | |
316 | for (Int_t ix=1; ix <= cuts->GetNbinsX(); ix++) { | |
29dc6eb3 | 317 | Double_t c = cuts->GetBinContent(ix, iiy); |
77f97e3f CHC |
318 | if (c <= 0.0001) continue; |
319 | min = TMath::Min(c, min); | |
320 | max = TMath::Max(c, max); | |
321 | } | |
322 | } | |
323 | // Printf("Cuts between %f,%f @%f, %f", min, max, y0,y1); | |
324 | ret->SetPoint(0, min, y0); | |
325 | ret->SetPoint(1, min, y1); | |
326 | ret->SetPoint(2, max, y1); | |
327 | ret->SetPoint(3, max, y0); | |
328 | ret->SetFillColor(color); | |
329 | ret->SetFillStyle(3002); | |
330 | ret->SetLineColor(kBlack); | |
331 | ret->SetLineStyle(2); | |
332 | ret->SetName(Form("g%s", cuts->GetName())); | |
333 | ret->SetTitle(cuts->GetTitle()); | |
334 | ||
335 | return ret; | |
336 | } | |
7095962e CHC |
337 | //____________________________________________________________________ |
338 | const Char_t* CutMethodName(Int_t lm) const | |
339 | { | |
340 | switch (lm) { | |
a19faec0 | 341 | case 0: return "c=X"; |
342 | case 1: return "c=X#times#Delta_{p}"; | |
343 | case 2: return "c:Lower bound of fit range"; | |
344 | case 3: return "c=#Delta_{p}-X#times#xi"; | |
345 | case 4: return "c=#Delta_{p}-X#times(#xi+#sigma)"; | |
346 | case 5: return "c:P(#Delta<c)<X"; | |
7095962e CHC |
347 | } |
348 | return "unknown"; | |
349 | } | |
350 | //____________________________________________________________________ | |
351 | Int_t PrintCut(const TCollection* c, Double_t& y, const Char_t* name, | |
352 | Double_t size=0) | |
353 | { | |
354 | if (!c) return -1; | |
355 | ||
356 | Int_t method = 0; | |
357 | if (!GetParameter(c, "method", method)) return -1; | |
70849dc0 | 358 | DrawParameter(y, name, CutMethodName(method), size); |
359 | ||
360 | TString params; | |
361 | const char* cuts[] = { "fmd1i", "fmd2i", "fmd2o", "fmd3i", "fmd3o", 0 }; | |
362 | const char** pcut = cuts; | |
363 | while (*pcut) { | |
364 | Double_t cut; | |
7c844559 | 365 | GetParameter(c, *pcut, cut, false); |
70849dc0 | 366 | if (pcut != cuts) params.Append(", "); |
367 | params.Append(Form("%5.2f", cut)); | |
368 | pcut++; | |
7095962e | 369 | } |
7c844559 | 370 | if (params.IsNull()) { |
371 | Double_t frac = 0; | |
372 | GetParameter(c, "frac", frac); | |
373 | params = Form("%f", frac); | |
374 | } | |
70849dc0 | 375 | DrawParameter(y, "Parameters", params, size); |
7095962e CHC |
376 | return method; |
377 | } | |
2955f67c | 378 | //____________________________________________________________________ |
a19faec0 | 379 | void DrawCut(TVirtualPad* parent, Int_t sub, TH2* cuts) |
380 | { | |
381 | if (!cuts) return; | |
382 | THStack* stack = new THStack(cuts,"x"); | |
383 | stack->SetTitle(cuts->GetTitle()); | |
384 | for (Int_t i = 1; i <= cuts->GetNbinsY(); i++) { | |
385 | TH1* hist = static_cast<TH1*>(stack->GetHists()->At(i-1)); | |
386 | TString name(cuts->GetYaxis()->GetBinLabel(i)); | |
387 | UShort_t det = UShort_t(name[3]-48); | |
388 | Char_t rng = name[4]; | |
389 | Color_t col = RingColor(det, rng); | |
24338c03 | 390 | hist->SetDirectory(0); |
a19faec0 | 391 | hist->SetTitle(name); |
392 | hist->SetMarkerStyle(20); | |
393 | hist->SetMarkerColor(col); | |
394 | hist->SetLineColor(col); | |
395 | hist->SetFillColor(col); | |
396 | hist->SetLineWidth(0); | |
397 | hist->SetFillStyle(0); | |
398 | hist->SetXTitle("#eta"); | |
399 | hist->SetYTitle(cuts->GetZaxis()->GetTitle()); | |
400 | } | |
401 | DrawInPad(parent, sub, stack, "nostack p", kLegend|kCenter|kSouth); | |
402 | } | |
403 | //____________________________________________________________________ | |
2955f67c | 404 | void DrawSharingFilter() |
405 | { | |
bfab35d9 | 406 | Info("DrawSharingFilter", "Drawing sharing filter"); |
2955f67c | 407 | TCollection* c = GetCollection(fSums, "fmdSharingFilter"); |
408 | if (!c) return; | |
bfab35d9 | 409 | TCollection* rc = GetCollection(fResults, "fmdSharingFilter"); |
410 | if (!rc) rc = c; | |
2955f67c | 411 | |
7095962e | 412 | // --- Draw summary information ---------------------------------- |
77f97e3f | 413 | fBody->Divide(1, 3, 0, 0); |
2955f67c | 414 | fBody->cd(1); |
415 | ||
70849dc0 | 416 | Double_t y = .95; |
7095962e | 417 | Bool_t angle=false, lowSignal=false, disabled=false; |
24338c03 | 418 | Int_t nFiles = 0; |
8449e3e0 | 419 | if (GetParameter(c, "angle", angle)) |
420 | DrawParameter(y, "Angle correct", (angle ? "yes" : "no")); | |
421 | if (GetParameter(c, "lowSignal", lowSignal)) | |
422 | DrawParameter(y, "Lower signal", (lowSignal ? "yes" : "no")); | |
24338c03 | 423 | TParameter<int>* pnFiles = |
bfab35d9 | 424 | static_cast<TParameter<int>*>(GetObject(c, "nFiles")); |
24338c03 | 425 | if (pnFiles) { |
426 | nFiles = pnFiles->GetVal(); | |
427 | DrawParameter(y, "# files merged", Form("%d", nFiles)); | |
428 | } | |
7c844559 | 429 | if (GetParameter(c, "disabled", disabled, false)) |
7095962e CHC |
430 | DrawParameter(y, "Merging disabled", (disabled ? "yes" : "no")); |
431 | ||
432 | Int_t lm = 0; | |
433 | Int_t hm = 0; | |
434 | TH2* hLow = 0; | |
435 | TH2* hHigh = 0; | |
436 | if (!disabled) { | |
437 | Bool_t simple=false, three=false; | |
438 | if (GetParameter(c, "simple", simple)) | |
439 | DrawParameter(y, "Simple method", (simple ? "yes" : "no")); | |
440 | if (GetParameter(c, "sumThree", three)) | |
441 | DrawParameter(y, "3-strip merging", (three ? "yes" : "no")); | |
24338c03 | 442 | |
7095962e CHC |
443 | TCollection* lc = GetCollection(c, "lCuts"); |
444 | TCollection* hc = GetCollection(c, "hCuts"); | |
445 | lm = PrintCut(lc, y, "Low cut"); | |
446 | hm = PrintCut(hc, y, "High cut"); | |
447 | hLow = GetH2(c, "lowCuts"); | |
448 | hHigh = GetH2(c, "highCuts"); | |
29dc6eb3 | 449 | if (hLow && nFiles > 0 && !hLow->TestBit(BIT(20))) |
450 | hLow->Scale(1. / nFiles); | |
451 | if (hHigh && nFiles > 0 && !hHigh->TestBit(BIT(20))) | |
452 | hHigh->Scale(1. / nFiles); | |
a19faec0 | 453 | DrawCut(fBody, 2, hLow); |
454 | DrawCut(fBody, 3, hHigh); | |
7095962e | 455 | } |
2955f67c | 456 | PrintCanvas("Sharing filter"); |
457 | ||
7095962e CHC |
458 | if (!disabled) { |
459 | // --- Draw rings individually ----------------------------------- | |
460 | Double_t savX = fParVal->GetX(); | |
461 | Double_t savY = fParVal->GetY(); | |
462 | fParVal->SetX(0.6); | |
463 | fParVal->SetY(0.6); | |
464 | const char** ptr = GetRingNames(false); | |
465 | UShort_t iq = 1; | |
466 | while (*ptr) { | |
467 | TCollection* sc = GetCollection(c, *ptr); | |
468 | if (!sc) { ptr++; iq++; continue; } | |
469 | ||
470 | if (fLandscape) fBody->Divide(3, 2); | |
471 | else fBody->Divide(2,3); | |
472 | ||
473 | TH1* esdELoss = GetH1(sc, "esdEloss"); | |
70849dc0 | 474 | TH1* anaELoss = GetH1(sc, "anaEloss"); |
7095962e CHC |
475 | TGraph* lowCut = CreateCutGraph(lm, iq, hLow, esdELoss, kYellow+1); |
476 | TGraph* highCut = CreateCutGraph(hm, iq, hHigh, esdELoss, kCyan+1); | |
29dc6eb3 | 477 | Double_t ignCut = TMath::Max(lowCut->GetX()[3],0.); |
478 | Int_t esdLow = esdELoss->FindBin(ignCut); | |
479 | Int_t anaLow = anaELoss->FindBin(ignCut); | |
480 | Double_t esdInt = esdELoss->Integral(esdLow,esdELoss->GetNbinsX()+1); | |
481 | Double_t anaInt = anaELoss->Integral(anaLow,anaELoss->GetNbinsX()+1); | |
482 | Double_t frac = esdInt > 0 ? (esdInt-anaInt)/esdInt : 1; | |
483 | esdELoss->GetXaxis()->SetRangeUser(-.1, 2); | |
7095962e CHC |
484 | |
485 | DrawInPad(fBody, 1, esdELoss, "", kLogy, | |
486 | "#Delta/#Delta_{mip} reconstructed and merged"); | |
70849dc0 | 487 | DrawInPad(fBody, 1, anaELoss, "same"); |
7095962e | 488 | DrawInPad(fBody, 1, lowCut, "lf same"); |
a19faec0 | 489 | DrawInPad(fBody, 1, highCut, "lf same", kLogy|kLegend|kNorth|kWest); |
70849dc0 | 490 | TVirtualPad* p = fBody->GetPad(1); |
491 | p->cd(); | |
492 | TLatex* l = new TLatex(1-p->GetRightMargin(), | |
493 | 0.5, Form("Loss: %5.1f%%", frac*100)); | |
494 | l->SetNDC(); | |
495 | l->SetTextAlign(32); | |
496 | l->Draw(); | |
29dc6eb3 | 497 | l->DrawLatex(1-p->GetRightMargin(), 0.45, |
498 | Form("%f #rightarrow #infty", ignCut)); | |
a19faec0 | 499 | |
500 | TH1* singles = GetH1(sc, "singleEloss"); | |
501 | TH1* doubles = GetH1(sc, "doubleEloss"); | |
502 | TH1* tripples = GetH1(sc, "tripleEloss"); | |
503 | Double_t int1 = singles->Integral(0,singles->GetNbinsX()+1); | |
504 | Double_t int2 = doubles->Integral(0,doubles->GetNbinsX()+1); | |
505 | Double_t int3 = tripples->Integral(0,tripples->GetNbinsX()+1); | |
506 | Double_t intT = int1 + int2 + int3; | |
507 | Double_t f1 = intT > 0 ? int1 / intT : 0; | |
508 | Double_t f2 = intT > 0 ? int2 / intT : 0; | |
509 | Double_t f3 = intT > 0 ? int3 / intT : 0; | |
510 | ||
511 | singles->GetXaxis()->SetRangeUser(-.1, 2); | |
512 | DrawInPad(fBody, 2, singles, "", kLogy, | |
7095962e | 513 | "#Delta/#Delta_{mip} for single, double, and tripple hits"); |
a19faec0 | 514 | DrawInPad(fBody, 2, doubles, "same", kLogy); |
515 | DrawInPad(fBody, 2, tripples, "same", kLogy); | |
516 | DrawInPad(fBody, 2, lowCut, "lf same", kLogy); | |
517 | DrawInPad(fBody, 2, highCut, "lf same", kLogy|kLegend|kNorth|kWest); | |
7095962e | 518 | |
a19faec0 | 519 | fBody->cd(2); |
520 | Double_t nameX = fParName->GetX(); | |
521 | Double_t valX = fParVal->GetX(); | |
522 | Double_t intY = 0.4; | |
523 | fParName->SetX(0.5); | |
524 | fParVal->SetX(0.7); | |
525 | DrawParameter(intY, "Singles", Form("%5.1f%%", 100*f1), 0.05); | |
526 | DrawParameter(intY, "Doubles", Form("%5.1f%%", 100*f2), 0.05); | |
527 | DrawParameter(intY, "Tripples", Form("%5.1f%%", 100*f3), 0.05); | |
528 | fParName->SetX(nameX); | |
529 | fParVal->SetX(valX); | |
530 | ||
7095962e CHC |
531 | DrawInPad(fBody, 3, GetH2(sc, "singlePerStrip"), "colz",kLogz); |
532 | // DrawInPad(fBody, 4, GetH1(sc, "distanceBefore"), "", 0x2); | |
533 | // DrawInPad(fBody, 4, GetH1(sc, "distanceAfter"), "same", 0x12); | |
534 | DrawInPad(fBody, 4, GetH2(sc, "summed"), "colz",0x0); | |
535 | ||
536 | TH2* nB = GetH2(sc, "neighborsBefore"); | |
537 | if (nB) { | |
a19faec0 | 538 | nB->GetXaxis()->SetRangeUser(0,2); |
539 | nB->GetYaxis()->SetRangeUser(0,2); | |
7095962e | 540 | } |
29dc6eb3 | 541 | DrawInPad(fBody, 5, nB, "colz cont3", kLogz, |
542 | "Correlation of neighbors before merging"); | |
543 | ||
544 | TH2* nA = GetH2(sc, "neighborsAfter"); | |
545 | if (nA) { | |
546 | nA->GetXaxis()->SetRangeUser(0,2); | |
547 | nA->GetYaxis()->SetRangeUser(0,2); | |
548 | } | |
549 | DrawInPad(fBody, 6, nA, "colz cont3", kLogz, | |
550 | "Correlation of neighbors after merging"); | |
24338c03 | 551 | |
29dc6eb3 | 552 | // DrawInPad(fBody, 6, GetH2(sc, "beforeAfter"), "colz", kLogz); |
7095962e CHC |
553 | |
554 | PrintCanvas(Form("Sharing filter - %s", *ptr)); | |
555 | ptr++; | |
556 | iq++; | |
2955f67c | 557 | } |
7095962e CHC |
558 | fParVal->SetX(savX); |
559 | fParVal->SetY(savY); | |
2955f67c | 560 | } |
561 | ||
562 | // --- MC -------------------------------------------------------- | |
563 | TCollection* cc = GetCollection(c, "esd_mc_comparion", false); // Spelling! | |
7c844559 | 564 | if (!cc) { |
565 | cc = GetCollection(c, "esd_mc_comparison", false); // Spelling! | |
566 | if (!cc) return; // Not MC | |
567 | } | |
2955f67c | 568 | |
569 | DivideForRings(false, false); | |
7095962e CHC |
570 | const char** ptr = GetRingNames(false); |
571 | while (*ptr) { | |
7c844559 | 572 | TString nam(Form("%s_corr", *ptr)); |
573 | TH2* hc = GetH2(cc, nam, false); | |
574 | if (!hc) { | |
575 | nam[4] = (nam[4] == 'I' ? 'i' : 'o'); | |
576 | hc = GetH2(cc, nam, false); | |
577 | if (!hc) { | |
578 | ptr++; | |
579 | continue; | |
580 | } | |
581 | } | |
582 | DrawInRingPad(hc, "colz", kLogz); | |
7095962e CHC |
583 | ptr++; |
584 | } | |
2955f67c | 585 | |
586 | PrintCanvas("Sharing filter - MC vs Reco"); | |
587 | ||
588 | // --- MC -------------------------------------------------------- | |
bfab35d9 | 589 | DrawTrackDensity(c); |
2955f67c | 590 | } |
70849dc0 | 591 | //__________________________________________________________________ |
592 | /** | |
593 | * Draw a slice fit on a 2D histogram | |
594 | * | |
595 | * @param inY Whether to slice in Y | |
596 | * @param h 2D histogram | |
597 | * @param nVar Number of variances | |
598 | * @param p Master pad to draw in | |
599 | * @param sub Sub pad number | |
600 | * @param flags Flags | |
601 | * @param cut Cut value | |
602 | */ | |
77f97e3f CHC |
603 | void ShowSliceFit(Bool_t inY, TH2* h, Double_t nVar, |
604 | TVirtualPad* p, Int_t sub, UShort_t flags=0, | |
605 | Double_t cut=-1) | |
606 | { | |
607 | if (!h) return; | |
7c844559 | 608 | TAxis* indep = (inY ? h->GetXaxis() : h->GetYaxis()); |
609 | TAxis* dep = (inY ? h->GetYaxis() : h->GetXaxis()); | |
610 | ||
77f97e3f CHC |
611 | |
612 | TObjArray* fits = new TObjArray; | |
613 | fits->SetOwner(); | |
7c844559 | 614 | // FitSlicesX sets onX to true. If onX is true, then it calls |
615 | // ProjectionX for each Y bin. That is, we fit each X slice. | |
616 | Int_t minB = dep->FindBin(0.)+1; | |
617 | Int_t maxB = dep->GetNbins(); | |
618 | Info("", "Bin range: %d - %d", minB, maxB); | |
619 | if (inY) h->FitSlicesY(0, minB, maxB, 10, "QN", fits); | |
620 | else h->FitSlicesX(0, minB, maxB, 10, "QN", fits); | |
77f97e3f CHC |
621 | if (!fits) { |
622 | Warning("ShowSliceFit", "No fits returned"); | |
623 | return; | |
624 | } | |
7c844559 | 625 | |
626 | // If inY is true then this is the mean,variance as a function of X | |
77f97e3f CHC |
627 | TH1* mean = static_cast<TH1*>(fits->At(1)); |
628 | TH1* var = static_cast<TH1*>(fits->At(2)); | |
629 | if (!mean || !var) { | |
630 | Warning("ShowSliceFit", "Didn't get histograms"); | |
631 | fits->Delete(); | |
632 | return; | |
633 | } | |
7c844559 | 634 | #if 0 |
635 | TH1* hh[] = { mean, var, 0 }; | |
636 | for (Int_t ib=1; ib<=mean->GetNbinsX();ib++) { | |
637 | TH1** hp = hh; | |
638 | while (*hp) { | |
639 | if ((*hp)->GetBinContent(ib) <= 0) { | |
640 | (*hp)->SetBinContent(ib,0); | |
641 | (*hp)->SetBinError(ib,0); | |
642 | } | |
643 | hp++; | |
644 | } | |
645 | } | |
646 | #endif | |
647 | ||
648 | // If inY is true then this is the mean,variance as a function of X | |
77f97e3f CHC |
649 | TF1* fmean = new TF1("mean", "pol1"); |
650 | TF1* fvar = new TF1("var", "pol1"); | |
651 | mean->Fit(fmean, "Q0+"); | |
652 | var->Fit(fvar, "Q0+"); | |
653 | if (!fmean || !fvar) { | |
654 | Warning("ShowSliceFit", "No functions returned"); | |
655 | fits->Delete(); | |
656 | return; | |
657 | } | |
658 | ||
659 | TGraphErrors* g = new TGraphErrors(h->GetNbinsX()); | |
660 | g->SetName(Form("g%s", h->GetName())); | |
7c844559 | 661 | TString xTit = indep->GetTitle(); |
662 | TString yTit = dep->GetTitle(); | |
663 | g->SetTitle(Form("Correlation of %s and %s",xTit.Data(),yTit.Data())); | |
77f97e3f CHC |
664 | g->SetFillColor(kBlue-10); |
665 | g->SetFillStyle(3001); | |
7c844559 | 666 | TGraph* up = (cut > 0 ? new TGraph(indep->GetNbins()) : 0); |
667 | TGraph* low = (cut > 0 ? new TGraph(indep->GetNbins()) : 0); | |
77f97e3f CHC |
668 | if (up) { |
669 | up ->SetLineColor(kBlack); | |
670 | up ->SetLineWidth(2); | |
671 | up ->SetLineStyle(2); | |
672 | } | |
673 | if (low) { | |
674 | low->SetLineColor(kBlack); | |
675 | low->SetLineWidth(2); | |
676 | low->SetLineStyle(2); | |
677 | } | |
678 | for (Int_t i = 1; i <= h->GetNbinsX(); i++) { | |
7c844559 | 679 | Double_t x = indep->GetBinCenter(i); |
77f97e3f CHC |
680 | Double_t y = fmean->Eval(x); |
681 | Double_t e = fvar->Eval(x); | |
7c844559 | 682 | // Double_t y = mean->GetBinContent(i); |
683 | // Double_t e = var->GetBinContent(i); | |
77f97e3f CHC |
684 | Double_t ee = nVar * e; |
685 | if (flags & 0x8000) ee *= e > 0 ? TMath::Log10(e) : 1; | |
7c844559 | 686 | if (inY) { |
687 | g->SetPoint(i-1, x, y); | |
688 | g->SetPointError(i-1, 0, ee); | |
689 | } | |
690 | else { | |
691 | g->SetPoint(i-1, y, x); | |
692 | g->SetPointError(i-1, ee, 0); | |
693 | } | |
694 | if (up) { | |
695 | if (inY) up->SetPoint(i-1,x,x+cut*x); | |
696 | else up->SetPoint(i-1,y+cut*y,y); | |
697 | } | |
698 | if (low) { | |
699 | if (inY) low->SetPoint(i-1,x,x-cut*x); | |
700 | else low->SetPoint(i-1,y-cut*y,y); | |
701 | } | |
77f97e3f CHC |
702 | } |
703 | DrawInPad(p, sub, g, "3", flags); | |
704 | if (up) DrawInPad(p, sub, up, "l", flags); | |
705 | if (low) DrawInPad(p, sub, low, "l", flags); | |
7c844559 | 706 | fmean->SetRange(indep->GetXmin(), indep->GetXmax()); |
77f97e3f CHC |
707 | fmean->SetLineWidth(2); |
708 | DrawInPad(p, sub, fmean, "same", flags); | |
709 | ||
710 | TVirtualPad* pp = p->GetPad(sub); | |
711 | Double_t y = 1-pp->GetTopMargin()-.01; | |
712 | TLatex* l = new TLatex(.15, y, | |
713 | Form("#LT%s#GT(%s) = " | |
714 | "%f + %f %s", | |
715 | yTit.Data(), xTit.Data(), | |
716 | fmean->GetParameter(0), | |
717 | fmean->GetParameter(1), xTit.Data())); | |
718 | l->SetNDC(); | |
719 | l->SetTextAlign(13); | |
7c844559 | 720 | l->SetTextSize(fParVal->GetTextSize()); |
77f97e3f CHC |
721 | l->SetTextFont(42); |
722 | l->Draw(); | |
723 | l->DrawLatex(0.15, y-0.07, | |
724 | Form("#sigma_{%s}(%s) = " | |
725 | "%f + %f %s", | |
726 | yTit.Data(), xTit.Data(), | |
727 | fvar->GetParameter(0), | |
728 | fvar->GetParameter(1), xTit.Data())); | |
729 | l->DrawLatex(0.15, y-0.14, Form("#delta = %3.1f %s #sigma", | |
730 | nVar, | |
731 | flags & 0x8000 ? "log_{10}(#sigma)" : "")); | |
732 | fits->Delete(); | |
733 | } | |
734 | ||
2955f67c | 735 | //____________________________________________________________________ |
736 | void DrawDensityCalculator() | |
737 | { | |
738 | Info("DrawDensityCalculator", "Drawing density calculator"); | |
739 | TCollection* c = GetCollection(fSums, "fmdDensityCalculator"); | |
740 | if (!c) return; | |
741 | ||
742 | fBody->Divide(2, 2); | |
743 | fBody->cd(1); | |
744 | ||
70849dc0 | 745 | Double_t y = .9; |
2955f67c | 746 | Int_t maxParticles=0, phiAcceptance=0, etaLumping=0, phiLumping=0; |
24338c03 | 747 | Bool_t method=false, recalcPhi=false; |
7c844559 | 748 | Double_t maxOutliers=0, outlierCut=-1; |
70849dc0 | 749 | Double_t size = fLandscape ? 0.05 : 0.03; |
2955f67c | 750 | |
8449e3e0 | 751 | GetParameter(c, "maxParticle", maxParticles); |
752 | ||
753 | if (GetParameter(c, "phiAcceptance", phiAcceptance)) | |
754 | DrawParameter(y, "#phi acceptance method", | |
755 | (phiAcceptance == 1 ? "N_{ch}" : | |
756 | phiAcceptance == 2 ? "#DeltaE" : "none"), size); | |
8449e3e0 | 757 | if (GetParameter(c, "etaLumping", etaLumping) && |
758 | GetParameter(c, "phiLumping", phiLumping)) | |
759 | DrawParameter(y, "Region size (sector#timesstrip)", | |
760 | Form("%2d #times %2d", phiLumping, etaLumping), size); | |
8449e3e0 | 761 | if (GetParameter(c, "method", method)) |
762 | DrawParameter(y, "Method", (method ? "Poisson" : "#DeltaE"), size); | |
8449e3e0 | 763 | if (GetParameter(c, "recalcPhi", recalcPhi)) |
764 | DrawParameter(y, "Recalculate #phi",(recalcPhi ? "yes" : "no"),size); | |
7c844559 | 765 | if (GetParameter(c, "maxOutliers", maxOutliers, false)) |
77f97e3f CHC |
766 | DrawParameter(y, "Max relative N_{outlier}", |
767 | Form("%5.3f",maxOutliers),size); | |
7c844559 | 768 | Bool_t hasOutCut = false; |
769 | if ((hasOutCut = GetParameter(c, "outlierCut", outlierCut, false))) | |
7095962e | 770 | DrawParameter(y, "Max relative deviation",Form("%5.3f",outlierCut),size); |
77f97e3f CHC |
771 | |
772 | ||
bfab35d9 | 773 | TParameter<int>* nFiles = |
774 | static_cast<TParameter<int>*>(GetObject(c, "nFiles")); | |
775 | if (nFiles) | |
77f97e3f | 776 | DrawParameter(y, "# files merged", Form("%d", nFiles->GetVal()), size); |
8449e3e0 | 777 | |
bfab35d9 | 778 | TCollection* lc = GetCollection(c, "lCuts"); |
70849dc0 | 779 | Int_t tm = PrintCut(lc, y, "Threshold", size); |
2955f67c | 780 | |
781 | TVirtualPad* p = fBody; // fBody->cd(2); | |
782 | // p->Divide(3,1); | |
783 | ||
784 | TH1* accI = GetH1(c, "accI"); | |
785 | TH1* accO = GetH1(c, "accO"); | |
786 | if (accI) { | |
787 | Double_t scale = 1./accI->GetMaximum(); | |
788 | accI->Scale(scale); | |
789 | accO->Scale(scale); | |
790 | accI->SetMinimum(0); | |
a19faec0 | 791 | accI->SetMaximum(1.3); |
2955f67c | 792 | } |
bfab35d9 | 793 | TH2* lCuts = GetH2(c, "lowCuts"); |
794 | TH2* maxW = GetH2(c, "maxWeights"); | |
7095962e | 795 | if (lCuts) lCuts->SetTitle("Thresholds"); |
bfab35d9 | 796 | if (nFiles && lCuts) lCuts->Scale(1. / nFiles->GetVal()); |
797 | if (nFiles && maxW) maxW->Scale(1. / nFiles->GetVal()); | |
2955f67c | 798 | DrawInPad(p, 2, accI); |
a19faec0 | 799 | DrawInPad(p, 2, accO, "same", kLegend|kNorth|kCenter); |
800 | DrawCut(p, 3, lCuts); | |
a19faec0 | 801 | DrawCut(p, 4, maxW); |
2955f67c | 802 | |
803 | PrintCanvas("Density calculator"); | |
7c844559 | 804 | Float_t save = fParVal->GetTextSize(); |
805 | fParVal->SetTextSize(0.03); | |
2955f67c | 806 | |
70849dc0 | 807 | UShort_t iq = 1; |
7095962e | 808 | const char** ptr = GetRingNames(false); |
2955f67c | 809 | while (*ptr) { |
810 | TCollection* sc = GetCollection(c, *ptr); | |
811 | if (!sc) { ptr++; continue; } | |
812 | ||
77f97e3f CHC |
813 | if (fLandscape) fBody->Divide(3,2); |
814 | else fBody->Divide(2,3); | |
2955f67c | 815 | |
77f97e3f | 816 | TH2* corr = GetH2(sc, "elossVsPoisson"); |
7c844559 | 817 | TH2* corrOut = GetH2(sc, "elossVsPoissonOutlier", false); |
77f97e3f | 818 | TH1* diff = GetH1(sc, "diffElossPoisson"); |
7c844559 | 819 | TH1* diffOut = GetH1(sc, "diffElossPoissonOutlier", false); |
77f97e3f CHC |
820 | TH1* eloss = GetH1(sc, "eloss"); |
821 | TH1* elossUsed = GetH1(sc, "elossUsed"); | |
822 | TH1* occ = GetH1(sc, "occupancy"); | |
823 | if (eloss) eloss ->SetLineWidth(1); | |
824 | if (elossUsed) elossUsed->SetLineWidth(1); | |
a19faec0 | 825 | if (eloss) eloss->GetXaxis()->SetRangeUser(0.05, 2); |
77f97e3f | 826 | |
7c844559 | 827 | corr->SetXTitle("N_{ch,#Delta}"); |
828 | corr->SetYTitle("N_{ch,Poisson}"); | |
829 | DrawInPad(fBody, 1, corr, "colz", kLogz); | |
830 | if (corrOut) | |
831 | DrawInPad(fBody,1, corrOut, "same", kLogz); | |
24338c03 | 832 | ShowSliceFit(true, corr, 10, fBody, 1, kLogz, outlierCut); |
833 | ||
7c844559 | 834 | DrawInPad(fBody, 2, diff, "HIST E", kLogy); |
835 | if (diffOut) | |
836 | DrawInPad(fBody,2, diffOut, "HIST E SAME", kLogy|kLegend|kNorth|kWest); | |
837 | DrawInPad(fBody, 3, occ, "", kLogy); | |
838 | DrawInPad(fBody, 4, eloss, "", kLogy, | |
079fd669 | 839 | "#Delta/#Delta_{mip} before and after cuts"); |
70849dc0 | 840 | DrawInPad(fBody, 4, elossUsed, "same", kLogy); |
841 | TGraph* thres = CreateCutGraph(tm, iq, lCuts, eloss, kYellow+1); | |
a19faec0 | 842 | DrawInPad(fBody, 4, thres, "lf same", kLogy|kLegend|kNorth|kWest); |
70849dc0 | 843 | |
844 | if (eloss && elossUsed) { | |
845 | Int_t lowBin = eloss->GetXaxis()->FindBin(0.)+1; | |
846 | Int_t upBin = eloss->GetNbinsX()+1; | |
847 | Double_t beforeInt = eloss->Integral(lowBin,upBin); | |
848 | Double_t afterInt = elossUsed->Integral(lowBin,upBin); | |
849 | Double_t frac = beforeInt > 0 ? (beforeInt-afterInt)/beforeInt : 1; | |
850 | TVirtualPad* pp = fBody->GetPad(4); | |
851 | pp->cd(); | |
852 | TLatex* l = new TLatex(1-pp->GetRightMargin(), | |
853 | 0.5, Form("Loss: %5.1f%%", frac*100)); | |
854 | l->SetNDC(); | |
855 | l->SetTextAlign(32); | |
856 | l->Draw(); | |
857 | } | |
858 | ||
859 | ||
2955f67c | 860 | TH1* phiB = GetH1(sc, "phiBefore"); |
861 | TH1* phiA = GetH1(sc, "phiAfter"); | |
7c844559 | 862 | TH1* outliers = GetH1(sc, "outliers", false); |
77f97e3f CHC |
863 | if (outliers) |
864 | DrawInPad(fBody, 5, outliers, "hist", kLogy); | |
865 | else if (phiB && phiA) { | |
2955f67c | 866 | phiA->Add(phiB, -1); |
867 | phiA->Divide(phiB); | |
868 | phiA->SetTitle("#Delta#phi from Ip (x,y) correction"); | |
869 | phiA->SetYTitle("(#phi_{after}-#phi_{before})/#phi_{before}"); | |
77f97e3f CHC |
870 | DrawInPad(fBody, 5, phiA); |
871 | } | |
872 | else { | |
873 | fBody->cd(5); | |
874 | TLatex* ltx = new TLatex(0.5, 0.5, "No outliers or #phi corrections"); | |
875 | ltx->SetTextAlign(22); | |
876 | ltx->SetTextSize(0.07); | |
877 | ltx->SetNDC(); | |
878 | ltx->Draw(); | |
2955f67c | 879 | } |
fba5d22d | 880 | DrawInPad(fBody, 6, GetH2(sc, "phiAcc"), "colz", kLogz); |
2955f67c | 881 | |
77f97e3f CHC |
882 | |
883 | if (diff && diffOut) { | |
884 | fBody->cd(2); | |
885 | Double_t in = diff->GetEntries(); | |
886 | Double_t out = diffOut->GetEntries(); | |
7095962e CHC |
887 | if ((in+out) > 0) { |
888 | TLatex* ltx = new TLatex(0.11, 0.89, | |
889 | Form("Fraction: %7.3f%%", | |
890 | 100*out/(in+out))); | |
891 | ltx->SetNDC(); | |
892 | ltx->SetTextAlign(13); | |
893 | ltx->SetTextSize(0.06); | |
894 | ltx->Draw(); | |
895 | } | |
77f97e3f | 896 | } |
2955f67c | 897 | PrintCanvas(Form("Density calculator - %s", *ptr)); |
898 | ptr++; | |
70849dc0 | 899 | iq++; |
2955f67c | 900 | } |
901 | ||
902 | TCollection* cc = GetCollection(c, "esd_mc_comparison", false); | |
7c844559 | 903 | if (!cc) { |
904 | fParVal->SetTextSize(save); | |
905 | return; // Not MC | |
906 | } | |
2955f67c | 907 | |
7095962e | 908 | ptr = GetRingNames(false); |
7c844559 | 909 | THStack* profiles = new THStack("profiles", "MC-ESD"); |
910 | // Int_t cnt = 0; | |
7095962e | 911 | while (*ptr) { |
7c844559 | 912 | fBody->Divide(2,1); |
913 | ||
914 | TH2* corr = GetH2(cc, Form("%s_corr_mc_esd", *ptr)); | |
915 | if (corr) { | |
916 | // corr->GetXaxis()->SetRangeUser(-1,51); | |
917 | // corr->GetYaxis()->SetRangeUser(-1,51); | |
918 | corr->SetXTitle("MC"); | |
919 | corr->SetYTitle("ANA"); | |
920 | TH1* h = new TH1F("",Form("Correlation of N_{ch,incl} for %s", *ptr), | |
921 | corr->GetNbinsX(), | |
922 | corr->GetXaxis()->GetXmin(), | |
923 | corr->GetXaxis()->GetXmax()); | |
924 | h->SetMinimum(corr->GetYaxis()->GetXmin()); | |
925 | h->SetMaximum(1.2*corr->GetYaxis()->GetXmax()); | |
926 | h->SetXTitle("MC"); // corr->GetXaxis()->GetTitle()); | |
927 | h->SetYTitle(corr->GetYaxis()->GetTitle()); | |
928 | DrawInPad(fBody, 1, h, "", kLogz); | |
929 | DrawInPad(fBody, 1, corr, "colz same", kLogz); | |
930 | ShowSliceFit(true, corr, 1, fBody, 1, 0, -1); | |
931 | } | |
932 | TH1* diff = GetH1(cc, Form("%s_diff_mc_esd", *ptr)); | |
933 | if (diff && diff->GetEntries() > 0) { | |
934 | // diff->Rebin(2); | |
935 | diff->Smooth(3); | |
936 | diff->Scale(1./diff->GetEntries(), "width"); | |
937 | TF1* f = new TF1(Form("%s_tri", *ptr), | |
938 | "[0]*TMath::Exp(-TMath::Abs(x-[1])/[2])",-20,20); | |
939 | f->SetParNames("A", "x_{0}", "w"); | |
940 | f->SetParameters(1, diff->GetMean(), diff->GetRMS()); | |
941 | diff->Fit(f,"RQ0+"); | |
942 | DrawInPad(fBody, 2, diff, "", kLogy); | |
943 | DrawInPad(fBody, 2, f, "same", kLogy); | |
944 | Double_t py = .88; | |
945 | TLatex* l = new TLatex(.89, py, "Ae^{-|x-x_{0}|/w}"); | |
946 | l->SetTextAlign(33); | |
947 | l->SetTextSize(fParVal->GetTextSize()); | |
948 | l->SetTextFont(42); | |
949 | l->SetNDC(); | |
950 | l->Draw(); | |
951 | py -= fParVal->GetTextSize(); | |
952 | l->DrawLatex(.89, py, Form("#chi^{2}/#nu=%f", f->GetNDF()>0 ? | |
953 | f->GetChisquare()/f->GetNDF() : 0)); | |
954 | for (Int_t i = 0; i < 3; i++) { | |
955 | py -= fParVal->GetTextSize(); | |
956 | l->DrawLatex(.89, py, Form("%s: %f #pm %f", f->GetParName(i), | |
957 | f->GetParameter(i), f->GetParError(i))); | |
958 | } | |
959 | } | |
960 | TH2* vs = GetH2(cc, Form("%s_esd_vs_mc", *ptr)); | |
961 | if (vs) { | |
962 | const Double_t lVs = -0.3; | |
963 | const Double_t hVs = +0.4; | |
964 | Int_t nX = vs->GetNbinsX(); | |
965 | Int_t nY = vs->GetNbinsY(); | |
966 | TProfile* vsp = new TProfile(Form("%s_esd_vs_mc_px", *ptr), *ptr, | |
967 | nX, vs->GetXaxis()->GetXmin(), | |
968 | vs->GetXaxis()->GetXmax()); | |
969 | vsp->SetXTitle(vs->GetXaxis()->GetTitle()); | |
970 | vsp->SetYTitle("#LT#deltaN_{ch}#GT"); | |
971 | vsp->SetLineColor(diff->GetLineColor()); | |
972 | vsp->SetMarkerColor(diff->GetLineColor()); | |
973 | vsp->SetFillColor(diff->GetLineColor()); | |
974 | vsp->SetDirectory(0); | |
975 | Bool_t hasSome = false; | |
976 | for (Int_t ix = 1; ix <= nX; ix++) { | |
977 | Double_t vsx = vs->GetXaxis()->GetBinCenter(ix); | |
978 | for (Int_t iy = 1; iy <= nY; iy++) { | |
979 | Double_t vsc = vs->GetBinContent(ix, iy); | |
980 | Double_t vse = vs->GetBinError(ix, iy); | |
981 | if (vsc < lVs || vsc > hVs) continue; | |
982 | hasSome = true; | |
983 | vsp->Fill(vsx, vsc, vse); | |
984 | } | |
985 | } | |
986 | if (hasSome) profiles->Add(vsp); | |
987 | else delete vsp; | |
988 | } | |
989 | PrintCanvas(Form("Density calculator - MC vs Reco - %s", *ptr)); | |
7095962e | 990 | ptr++; |
7c844559 | 991 | // cnt++; |
7095962e | 992 | } |
7c844559 | 993 | if (profiles->GetHists() && profiles->GetHists()->GetEntries() > 0) { |
994 | Double_t pmax = profiles->GetMaximum("nostack")*1.3; | |
995 | profiles->SetMaximum(+pmax); | |
996 | profiles->SetMinimum(-pmax); | |
997 | DrawInPad(fBody, 0, profiles, "nostack"); | |
998 | PrintCanvas("Density calculator - MC vs Reco - All"); | |
999 | } | |
1000 | ||
1001 | fParVal->SetTextSize(save); | |
2955f67c | 1002 | } |
1003 | ||
1004 | //____________________________________________________________________ | |
1005 | void DrawCorrector() | |
1006 | { | |
1007 | Info("DrawCorrector", "Drawing corrector"); | |
1008 | TCollection* c = GetCollection(fSums, "fmdCorrector"); | |
1009 | if (!c) return; | |
1010 | ||
1011 | fBody->cd(); | |
1012 | ||
1013 | Double_t y = .8; | |
1014 | Bool_t secondary=false, vertexBias=false, acceptance=false, merging=false; | |
8449e3e0 | 1015 | if (GetParameter(c, "secondary", secondary)) |
1016 | DrawParameter(y, "Secondary corr.", secondary ? "yes" : "no"); | |
1017 | if (GetParameter(c, "acceptance", acceptance)) | |
1018 | DrawParameter(y, "Acceptance corr.", acceptance ? "yes" : "no"); | |
1019 | if (GetParameter(c, "vertexBias", vertexBias)) | |
1020 | DrawParameter(y, "Vertex bias corr.", vertexBias ? "yes" : "no"); | |
1021 | if (GetParameter(c, "merging", merging)) | |
1022 | DrawParameter(y, "Merging eff.", merging ? "yes" : "no"); | |
2955f67c | 1023 | |
1024 | PrintCanvas("Corrector"); | |
1025 | ||
1026 | TCollection* cc = GetCollection(c, "esd_mc_comparison", false); | |
1027 | if (!cc) return; // Not MC | |
1028 | ||
1029 | DivideForRings(false, false); | |
7095962e CHC |
1030 | const char** ptr = GetRingNames(false); |
1031 | while (*ptr) { | |
1032 | DrawInRingPad(GetH2(cc, Form("%s_esd_vs_mc", *ptr)), "colz", 0x0); | |
1033 | ptr++; | |
1034 | } | |
2955f67c | 1035 | |
1036 | PrintCanvas("Corrector - MC vs Reco"); | |
1037 | } | |
1038 | ||
1039 | //____________________________________________________________________ | |
1040 | void DrawHistCollector() | |
1041 | { | |
1042 | Info("DrawHistCollector", "Drawing histogram collector"); | |
1043 | TCollection* c = GetCollection(fSums, "fmdHistCollector"); | |
1044 | if (!c) return; | |
1045 | ||
77f97e3f CHC |
1046 | fBody->Divide(2, 1); |
1047 | TVirtualPad* p = fBody->cd(1); | |
1048 | p->Divide(1,2); | |
1049 | p->cd(1); | |
2955f67c | 1050 | |
1051 | Double_t y = .8; | |
1052 | Int_t nCutBins=0, fiducial=0, merge=0, skipRings=0; | |
1053 | Double_t fiducialCut=0.; | |
1054 | Bool_t bgAndHits=false; | |
77f97e3f | 1055 | Double_t size = fLandscape ? 0.06 : 0.04; |
8449e3e0 | 1056 | if (GetParameter(c, "nCutBins", nCutBins)) |
77f97e3f | 1057 | DrawParameter(y, "# of bins to cut", Form("%d", nCutBins),size); |
8449e3e0 | 1058 | |
1059 | if (GetParameter(c, "skipRings", skipRings)) { | |
1060 | TString skipped; | |
1061 | if (skipRings & 0x05) skipped.Append("FMD1i "); | |
1062 | if (skipRings & 0x09) skipped.Append("FMD2i "); | |
1063 | if (skipRings & 0x0a) skipped.Append("FMD2o "); | |
1064 | if (skipRings & 0x11) skipped.Append("FMD3i "); | |
1065 | if (skipRings & 0x12) skipped.Append("FMD3o "); | |
77f97e3f CHC |
1066 | if (skipped.IsNull()) skipped = "none"; |
1067 | DrawParameter(y, "Skipped rings", skipped, size); | |
8449e3e0 | 1068 | } |
8449e3e0 | 1069 | if (GetParameter(c, "bgAndHits", bgAndHits)) |
77f97e3f | 1070 | DrawParameter(y, "Bg & hit maps stored.", bgAndHits?"yes":"no",size); |
8449e3e0 | 1071 | if (GetParameter(c, "merge", merge)) |
1072 | DrawParameter(y, "Merge method", | |
1073 | (merge == 0 ? "straight mean" : | |
1074 | merge == 1 ? "straight mean, no zeroes" : | |
1075 | merge == 2 ? "weighted mean" : | |
1076 | merge == 3 ? "least error" : | |
77f97e3f | 1077 | merge == 4 ? "sum" : "unknown"),size); |
8449e3e0 | 1078 | if (GetParameter(c, "fiducial", fiducial)) |
1079 | DrawParameter(y, "Fiducial method.", | |
77f97e3f | 1080 | fiducial == 0 ? "cut" : "distance", size); |
8449e3e0 | 1081 | if (GetParameter(c, "fiducialCut", fiducialCut)) |
77f97e3f CHC |
1082 | DrawParameter(y, "Fiducial cut.", Form("%f", fiducialCut), size); |
1083 | ||
1084 | // p->cd(2); | |
67a4bb96 | 1085 | // Printf("Drawing skipped"); |
7c844559 | 1086 | TH1* skipped = GetH1(c, "skipped", false); |
77f97e3f CHC |
1087 | if (skipped) { |
1088 | skipped->SetFillColor(kRed+1); | |
1089 | skipped->SetFillStyle(3001); | |
1090 | } | |
1091 | DrawInPad(p, 2, skipped, "hist"); | |
2955f67c | 1092 | |
77f97e3f CHC |
1093 | p = fBody->cd(2); |
1094 | p->Divide(1,2,0,0); | |
1095 | ||
67a4bb96 | 1096 | // Printf("Drawing sumRings"); |
77f97e3f | 1097 | DrawInPad(p, 1, GetH2(c, "sumRings"), "colz"); |
67a4bb96 | 1098 | // Printf("Drawing coverage"); |
77f97e3f | 1099 | DrawInPad(p, 2, GetH2(c, "coverage"), "colz"); |
67a4bb96 | 1100 | // Printf("Done drawing for now"); |
2955f67c | 1101 | PrintCanvas("Histogram collector"); |
8449e3e0 | 1102 | |
1103 | ||
1104 | TIter next(c); | |
1105 | TObject* o = 0; | |
1106 | TRegexp regexp("[pm][0-9]+_[pm][0-9]+"); | |
1107 | while ((o = next())) { | |
1108 | TString name(o->GetName()); | |
1109 | if (name.Index(regexp) == kNPOS) continue; | |
1110 | ||
1111 | TList* vl = static_cast<TList*>(o); | |
77f97e3f | 1112 | if (!vl) continue; |
8449e3e0 | 1113 | |
1114 | DivideForRings(false, false); | |
7095962e CHC |
1115 | const char** ptr = GetRingNames(false); |
1116 | while (*ptr) { | |
1117 | DrawInRingPad(GetH2(vl, Form("secMap%s", *ptr)), "colz", 0x0); | |
1118 | DrawInRingPad(GetH2(vl, Form("hitMap%s", *ptr)), "box same", 0x0); | |
1119 | ptr++; | |
1120 | } | |
8449e3e0 | 1121 | PrintCanvas(Form("Histogram Collector - Vertex bin %s", vl->GetName())); |
1122 | } | |
1123 | ||
1124 | o = c->FindObject("byCentrality"); | |
1125 | if (!o) return; | |
1126 | TList* bc = static_cast<TList*>(o); | |
1127 | ||
1128 | DrawInPad(fBody, GetH3(bc, "FMD1I"), "box", 0); | |
1129 | DrawInPad(fBody, GetH3(bc, "FMD2I"), "box same", 0); | |
1130 | DrawInPad(fBody, GetH3(bc, "FMD2O"), "box same", 0); | |
1131 | DrawInPad(fBody, GetH3(bc, "FMD3O"), "box same", 0); | |
fba5d22d | 1132 | DrawInPad(fBody, GetH3(bc, "FMD3I"), "box same", kLegend); |
2955f67c | 1133 | } |
8449e3e0 | 1134 | |
1135 | //____________________________________________________________________ | |
1136 | void DrawCentral() | |
1137 | { | |
1138 | Info("DrawCentral", "Drawing central (SPD)"); | |
1139 | TCollection* c = fSums; | |
1140 | if (!c) return; | |
1141 | ||
77f97e3f | 1142 | fBody->Divide(2, 2); |
8449e3e0 | 1143 | fBody->cd(1); |
77f97e3f CHC |
1144 | Double_t y = .7; |
1145 | Bool_t secondary=false, acceptance=false; | |
1146 | if (GetParameter(c, "secondary", secondary)) | |
1147 | DrawParameter(y, "Secondary corr.", secondary ? "yes" : "no"); | |
1148 | if (GetParameter(c, "acceptance", acceptance)) | |
1149 | DrawParameter(y, "Acceptance corr.", acceptance ? "yes" : "no"); | |
8449e3e0 | 1150 | |
1151 | ||
77f97e3f | 1152 | DrawInPad(fBody, 2, GetH2(c, "coverage"), "col", 0, |
079fd669 | 1153 | "#eta coverage per v_{z}"); |
77f97e3f CHC |
1154 | TH2* cvst = GetH2(c, "nClusterVsnTracklet"); |
1155 | if (cvst) { | |
1156 | // cvst->Scale(1, "width"); | |
1157 | cvst->GetXaxis()->SetTitle("N_{free cluster}"); | |
1158 | cvst->GetYaxis()->SetTitle("N_{tracklet}"); | |
1159 | cvst->GetXaxis()->SetRangeUser(1,10000); | |
1160 | cvst->GetYaxis()->SetRangeUser(1,10000); | |
1161 | } | |
1162 | DrawInPad(fBody, 3, cvst, "colz", kLogx|kLogy|kLogz, | |
079fd669 | 1163 | "Correlation of # of tracklets and clusters"); |
77f97e3f | 1164 | DrawInPad(fBody, 4, GetH2(c, "clusterPerTracklet"), "colz", 0x0, |
079fd669 | 1165 | "# clusters per tracklet vs #eta"); |
77f97e3f | 1166 | ShowSliceFit(true, cvst, 3, fBody, 3, 0x8000|kLogz); |
8449e3e0 | 1167 | |
1168 | fBody->cd(1)->Modified(); | |
1169 | fBody->cd(2)->Modified(); | |
1170 | fBody->cd(3)->Modified(); | |
77f97e3f | 1171 | fBody->cd(4)->Modified(); |
8449e3e0 | 1172 | fBody->cd(1)->Update(); |
1173 | fBody->cd(2)->Update(); | |
1174 | fBody->cd(3)->Update(); | |
77f97e3f | 1175 | fBody->cd(4)->Update(); |
8449e3e0 | 1176 | PrintCanvas("Central - overview"); |
1177 | ||
1178 | ||
1179 | TIter next(c); | |
1180 | TObject* o = 0; | |
1181 | TRegexp regexp("[pm][0-9]+_[pm][0-9]+"); | |
1182 | while ((o = next())) { | |
1183 | TString name(o->GetName()); | |
1184 | if (name.Index(regexp) == kNPOS) continue; | |
1185 | ||
1186 | TList* vl = static_cast<TList*>(o); | |
1187 | ||
1188 | fBody->Divide(1, 3); | |
1189 | ||
1190 | DrawInPad(fBody, 1, GetH1(vl, "acceptance"), "", 0); | |
1191 | ||
1192 | TH1* sec = GetH1(vl, "secondary"); | |
1193 | sec->SetMarkerStyle(21); | |
1194 | sec->SetMarkerSize(1.2); | |
1195 | DrawInPad(fBody, 2, sec, "", 0); | |
1196 | DrawInPad(fBody, 2, GetH1(vl, "secondaryFiducial"), "same", 0x0); | |
1197 | DrawInPad(fBody, 3, GetH2(vl, "secondaryMapFiducial"), "colz", 0); | |
1198 | DrawInPad(fBody, 3, GetH2(vl, "hitMap"), "box same", 0x0); | |
1199 | ||
1200 | fBody->cd(1)->Modified(); | |
1201 | fBody->cd(2)->Modified(); | |
1202 | fBody->cd(3)->Modified(); | |
1203 | fBody->cd(1)->Update(); | |
1204 | fBody->cd(2)->Update(); | |
1205 | fBody->cd(3)->Update(); | |
1206 | PrintCanvas(Form("Central - Vertex bin %s", vl->GetName())); | |
1207 | } | |
1208 | } | |
1209 | ||
2955f67c | 1210 | |
1211 | //____________________________________________________________________ | |
1212 | void AddToAll(THStack* all, const THStack* stack, Int_t curr, Int_t step) | |
1213 | { | |
1214 | if (!stack) return; | |
1215 | ||
1216 | TIter next(stack->GetHists()); | |
1217 | TH1* h = 0; | |
1218 | while ((h = static_cast<TH1*>(next()))) { | |
1219 | TH1* copy = static_cast<TH1*>(h->Clone(Form("%s_copy", h->GetName()))); | |
1220 | copy->SetDirectory(0); | |
1221 | if (curr != step) { | |
1222 | copy->SetMarkerColor(kGray); | |
1223 | copy->SetLineColor(kGray); | |
1224 | } | |
1225 | all->Add(copy); | |
1226 | } | |
1227 | } | |
1228 | //____________________________________________________________________ | |
1229 | void AddToAll(THStack* all, const THStack* stack) | |
1230 | { | |
1231 | if (!stack) return; | |
1232 | ||
1233 | TIter next(stack->GetHists()); | |
1234 | TH1* h = 0; | |
1235 | while ((h = static_cast<TH1*>(next()))) { | |
1236 | TH1* copy = static_cast<TH1*>(h->Clone(Form("%s_copy", h->GetName()))); | |
1237 | copy->SetDirectory(0); | |
1238 | copy->SetMarkerColor(kGray); | |
1239 | copy->SetLineColor(kGray); | |
1240 | all->Add(copy); | |
1241 | } | |
1242 | } | |
1243 | ||
1244 | //____________________________________________________________________ | |
1245 | void DrawStep(Int_t step, | |
1246 | THStack* all, | |
1247 | TObject* cur, | |
1248 | TLegend* leg, | |
1249 | const char* title, | |
77f97e3f CHC |
1250 | TVirtualPad* can, |
1251 | Int_t sub, | |
1252 | Int_t nCol) | |
2955f67c | 1253 | { |
8449e3e0 | 1254 | if (all->GetHists()->GetEntries() <= 0 || !cur) return; |
1255 | ||
2955f67c | 1256 | // Info("", "Drawing step # %d", step); |
77f97e3f CHC |
1257 | Bool_t left = sub % nCol == 1; |
1258 | Bool_t right= sub % nCol == 0; | |
1259 | Bool_t top = (sub-1) / nCol == 0; | |
1260 | TVirtualPad* p = can->cd(sub); | |
2955f67c | 1261 | gStyle->SetOptTitle(0); |
1262 | p->SetTitle(Form("Step # %d", step)); | |
1263 | p->SetFillColor(kWhite); | |
77f97e3f CHC |
1264 | p->SetRightMargin(right ? 0.02 : 0); |
1265 | p->SetTopMargin(top ? 0.02 : 0); // 0.02); | |
1266 | // Info("", "Drawing step %d in sub-pad %d (%s)", | |
1267 | // step, sub, (left?"left":"right")); | |
2955f67c | 1268 | |
1269 | p->cd(); | |
1270 | all->Draw("nostack"); | |
1271 | all->GetHistogram()->SetXTitle("#eta"); | |
1272 | all->GetHistogram()->SetYTitle("signal"); | |
1273 | ||
77f97e3f CHC |
1274 | TLegendEntry* e = |
1275 | static_cast<TLegendEntry*>(leg->GetListOfPrimitives()->At(step-1)); | |
7095962e CHC |
1276 | if (e) { |
1277 | e->SetMarkerColor(kBlack); | |
1278 | e->SetLineColor(kBlack); | |
1279 | e->SetTextColor(kBlack); | |
1280 | } | |
77f97e3f | 1281 | |
2955f67c | 1282 | // p->cd(); |
1283 | gROOT->SetSelectedPad(p); | |
1284 | cur->DrawClone("same nostack"); | |
1285 | leg->DrawClone(""); | |
1286 | ||
1287 | TLatex* ltx = new TLatex(.97, .97, title); | |
1288 | ltx->SetNDC(); | |
1289 | ltx->SetTextSize(.06); | |
1290 | ltx->SetTextAlign(33); | |
1291 | ltx->Draw(); | |
1292 | ||
1293 | ltx = new TLatex((left ? .12 : .02), .97, p->GetTitle()); | |
1294 | ltx->SetNDC(); | |
1295 | ltx->SetTextSize(.06); | |
1296 | ltx->SetTextAlign(13); | |
1297 | ltx->Draw(); | |
1298 | ||
77f97e3f CHC |
1299 | if (step > 1) { |
1300 | Double_t x1 = 0.5*(p->GetUxmax()+p->GetUxmin()); | |
1301 | Double_t x2 = x1; | |
1302 | Double_t y1 = p->GetUymax(); | |
1303 | Double_t y2 = 0.92*y1; | |
1304 | Double_t sz = 0.05; | |
1305 | if (fLandscape) { | |
1306 | x1 = 0.99*p->GetUxmin(); | |
1307 | x2 = 0.80*x1; | |
1308 | y1 = .5*(p->GetUymax()+p->GetUymin()); | |
1309 | y2 = y1; | |
1310 | sz = 0.034; | |
1311 | } | |
1312 | // Info("", "Arrow at (x1,y1)=%f,%f (x2,y2)=%f,%f", x1, y1, x2, y2); | |
1313 | TArrow* a = new TArrow(x1, y1, x2, y2, sz, "|>"); | |
1314 | // (fLandscape ? "<|" : "|>")); | |
1315 | a->SetFillColor(kGray+1); | |
1316 | a->SetLineColor(kGray+1); | |
1317 | a->Draw(); | |
1318 | } | |
2955f67c | 1319 | p->Modified(); |
1320 | p->Update(); | |
1321 | p->cd(); | |
079fd669 | 1322 | |
7095962e CHC |
1323 | if (e) { |
1324 | e->SetMarkerColor(kGray); | |
1325 | e->SetLineColor(kGray); | |
1326 | e->SetTextColor(kGray); | |
1327 | } | |
079fd669 | 1328 | gStyle->SetOptTitle(1); |
2955f67c | 1329 | } |
1330 | ||
1331 | //____________________________________________________________________ | |
1332 | void FixStack(THStack* stack, const TString& title, | |
1333 | const TString& extra, Int_t marker) | |
1334 | { | |
1335 | if (!stack) return; | |
1336 | stack->SetTitle(title); | |
1337 | TIter next(stack->GetHists()); | |
1338 | TH1* h = 0; | |
1339 | while ((h = static_cast<TH1*>(next()))) { | |
1340 | h->SetMarkerStyle(marker); | |
1341 | TString tit(h->GetTitle()); | |
1342 | tit.ReplaceAll("cache", ""); | |
1343 | tit.Append(extra); | |
1344 | h->SetTitle(tit); | |
1345 | } | |
1346 | } | |
8449e3e0 | 1347 | void AddLegendEntry(TLegend* l, |
1348 | const TH1* h, | |
1349 | const TString& title) | |
1350 | { | |
1351 | if (!h) return; | |
1352 | ||
1353 | TLegendEntry* e = l->AddEntry("dummy", title.Data(), "pl"); | |
1354 | e->SetMarkerStyle(h->GetMarkerStyle()); | |
1355 | e->SetMarkerColor(kGray); | |
1356 | e->SetLineColor(kGray); | |
1357 | e->SetTextColor(kGray); | |
1358 | } | |
1359 | ||
1360 | ||
2955f67c | 1361 | //____________________________________________________________________ |
1362 | void DrawSteps() | |
1363 | { | |
1364 | // MakeChapter(can, "Steps"); | |
1365 | ||
77f97e3f | 1366 | THStack* esds = GetStack(GetCollection(fResults, "fmdSharingFilter"), |
7c844559 | 1367 | "sumsESD", "summedESD",false); |
2955f67c | 1368 | THStack* deltas = GetStack(GetCollection(fResults, "fmdSharingFilter"), |
7c844559 | 1369 | "sums", "summed",false); |
2955f67c | 1370 | THStack* nchs = GetStack(GetCollection(fResults, |
1371 | "fmdDensityCalculator"), | |
7c844559 | 1372 | "sums", "inclDensity",false); |
2955f67c | 1373 | THStack* prims = GetStack(GetCollection(fResults, "fmdCorrector"), |
7c844559 | 1374 | "sums", "primaryDensity",false); |
1375 | THStack* rings = GetStack(GetCollection(fResults, "ringResults"), | |
1376 | "all",0, false); | |
2955f67c | 1377 | THStack* mcRings = GetStack(GetCollection(fResults, "mcRingResults", false), |
1378 | "all","dndeta_eta", false); | |
7c844559 | 1379 | TH1* dndeta = GetH1(fResults, "dNdeta", false); |
8449e3e0 | 1380 | if (dndeta) dndeta->SetMarkerColor(kBlack); |
7c844559 | 1381 | if (!(esds || deltas || nchs || prims || rings)) return; |
2955f67c | 1382 | |
77f97e3f CHC |
1383 | FixStack(esds, "#sum_{s} #Delta/#Delta_{mip}", "", 20); |
1384 | FixStack(deltas, "#sum_{c} #Delta/#Delta_{mip}", "", 21); | |
1385 | FixStack(nchs, "#sum_{b} N_{ch,incl}", "", 22); | |
1386 | FixStack(prims, "#sum_{b} N_{ch,primary}", "", 23); | |
1387 | FixStack(rings, "dN/d#eta per ring", "", 33); | |
2955f67c | 1388 | FixStack(mcRings,"dN/d#eta per ring (MC)", "(MC)", 34); |
1389 | ||
1390 | THStack* all = new THStack; | |
1391 | AddToAll(all, mcRings); | |
77f97e3f | 1392 | AddToAll(all, esds); |
2955f67c | 1393 | AddToAll(all, deltas); |
1394 | AddToAll(all, nchs); | |
1395 | AddToAll(all, prims); | |
1396 | AddToAll(all, rings); | |
1397 | ||
8449e3e0 | 1398 | TH1* res = 0; |
1399 | if (dndeta) { | |
1400 | res = static_cast<TH1*>(dndeta->Clone("dNdeta")); | |
1401 | res->SetTitle("dN/d#eta"); | |
1402 | res->SetMarkerColor(kGray); | |
1403 | res->SetLineColor(kGray); | |
1404 | res->SetDirectory(0); | |
1405 | all->Add(res); | |
1406 | } | |
2955f67c | 1407 | |
1408 | TLegend* l = new TLegend(.35, .2, .55, .9); | |
1409 | l->SetFillColor(kWhite); | |
1410 | l->SetFillStyle(0); | |
1411 | l->SetBorderSize(0); | |
1412 | TLegendEntry* e = 0; | |
1413 | ||
7c844559 | 1414 | THStack* stacks[] = { mcRings, |
1415 | esds, | |
1416 | deltas, | |
1417 | nchs, | |
1418 | prims, | |
1419 | rings }; | |
1420 | ||
1421 | Int_t nHist = 0; | |
1422 | for (Int_t i = 0; i < 6; i++) { | |
1423 | if (!stacks[i]) continue; | |
1424 | TH1* h = static_cast<TH1*>(stacks[i]->GetHists()->At(0)); | |
1425 | AddLegendEntry(l, h, stacks[i]->GetTitle()); | |
1426 | nHist++; | |
8449e3e0 | 1427 | } |
8449e3e0 | 1428 | if (res) { |
7c844559 | 1429 | AddLegendEntry(l, res, res->GetTitle()); |
1430 | nHist++; | |
8449e3e0 | 1431 | } |
2955f67c | 1432 | |
7c844559 | 1433 | TObject* objs[] = { stacks[0], |
1434 | stacks[1], | |
1435 | stacks[2], | |
1436 | stacks[3], | |
1437 | stacks[4], | |
1438 | stacks[5], | |
2955f67c | 1439 | dndeta }; |
77f97e3f CHC |
1440 | const char* titles[] = { /* 1 */ "MC", |
1441 | /* 2 */ "ESD input", | |
1442 | /* 3 */ "After merging", | |
1443 | /* 4 */ "After particle counting", | |
1444 | /* 5 */ "After corrections", | |
1445 | /* 6 */ "After normalization", | |
1446 | /* 7 */ "After combining" }; | |
7c844559 | 1447 | Int_t nY = nHist > 6 ? 4 : 3; |
77f97e3f CHC |
1448 | Int_t nX = 2; |
1449 | if (fLandscape) { | |
1450 | Int_t tmp = nX; | |
1451 | nX = nY; | |
1452 | nY = tmp; | |
1453 | } | |
1454 | fBody->Divide(nX, nY, 0, 0); | |
2955f67c | 1455 | |
2955f67c | 1456 | Int_t step = 0; |
77f97e3f | 1457 | for (Int_t i = 0; i < 7; i++) { |
2955f67c | 1458 | TObject* obj = objs[i]; |
1459 | if (!obj) continue; | |
77f97e3f | 1460 | |
2955f67c | 1461 | step++; |
77f97e3f CHC |
1462 | Int_t padNo = step; |
1463 | if (!fLandscape) { | |
1464 | switch (step) { | |
1465 | case 1: padNo = 1; break; | |
1466 | case 2: padNo = 3; break; | |
1467 | case 3: padNo = 5; break; | |
1468 | case 4: padNo = (mcRings ? 7 : 2); break; | |
1469 | case 5: padNo = (mcRings ? 2 : 4); break; | |
1470 | case 6: padNo = (mcRings ? 4 : 6); break; | |
1471 | case 7: padNo = (mcRings ? 6 : 8); break; | |
1472 | } | |
1473 | } | |
1474 | //Printf("Drawing step %d in sub-pad %d (%s)",step,padNo,obj->GetTitle()); | |
1475 | DrawStep(step, all, obj, l, titles[i], fBody, padNo, nX); | |
2955f67c | 1476 | } |
1477 | ||
77f97e3f | 1478 | if (!esds && !mcRings && deltas) { |
2955f67c | 1479 | fBody->cd(6); |
1480 | TLegend* ll = new TLegend(0.01, 0.11, 0.99, 0.99); | |
1481 | // ll->SetNDC(); | |
1482 | ll->SetFillColor(kWhite); | |
1483 | ll->SetFillStyle(0); | |
1484 | ll->SetBorderSize(0); | |
1485 | ||
1486 | TIter next(deltas->GetHists()); | |
1487 | TH1* hh = 0; | |
1488 | while ((hh = static_cast<TH1*>(next()))) { | |
1489 | e = ll->AddEntry("dummy", hh->GetTitle(), "pl"); | |
1490 | e->SetMarkerColor(hh->GetMarkerColor()); | |
1491 | e->SetMarkerStyle(hh->GetMarkerStyle()); | |
1492 | e->SetLineColor(kBlack); | |
1493 | } | |
1494 | ll->Draw(); | |
1495 | } | |
67a4bb96 | 1496 | // Printf("Done drawing steps"); |
2955f67c | 1497 | PrintCanvas("Steps"); |
1498 | } | |
1499 | ||
1500 | ||
1501 | //____________________________________________________________________ | |
1502 | void DrawResults() | |
1503 | { | |
1504 | // MakeChapter(can, "Results"); | |
1505 | ||
77f97e3f | 1506 | fBody->Divide(2,1); |
2955f67c | 1507 | |
1508 | TCollection* c = GetCollection(fResults, "ringResults"); | |
1509 | if (!c) return; | |
1510 | ||
1511 | THStack* mcRings = GetStack(GetCollection(fResults, "mcRingResults", false), | |
1512 | "all", "dndeta_eta", false); | |
1513 | ||
1514 | TH1* dndeta_phi = GetH1(fResults, "dNdeta"); | |
1515 | TH1* dndeta_eta = GetH1(fResults, "dNdeta_"); | |
1516 | dndeta_phi->SetTitle("1/N_{ev}dN_{ch}/d#eta (#varphi norm)"); | |
1517 | dndeta_eta->SetTitle("1/N_{ev}dN_{ch}/d#eta (#eta norm)"); | |
1518 | dndeta_eta->SetMarkerSize(0.7); | |
1519 | ||
bfab35d9 | 1520 | THStack* allPhi = new THStack("phiAcc", "#varphi Acceptance"); |
1521 | THStack* allEta = new THStack("etaCov", "#eta Coverage"); | |
7095962e | 1522 | const char** pring = GetRingNames(false); |
bfab35d9 | 1523 | |
1524 | while ((*pring)) { | |
1525 | TCollection* cc = GetCollection(c, *pring); | |
1526 | TH1* etaCov = GetH1(cc, "etaCov"); | |
1527 | TH1* phiAcc = GetH1(cc, "phiAcc"); | |
1528 | TH1* dndeta = GetH1(cc, "dndeta_phi"); | |
1529 | Int_t color = kBlack; | |
1530 | if (dndeta) color = dndeta->GetMarkerColor(); | |
1531 | if (etaCov) { | |
1532 | etaCov->SetTitle(*pring); | |
1533 | etaCov->SetFillColor(color); | |
1534 | etaCov->SetLineColor(color); | |
1535 | allEta->Add(etaCov); | |
1536 | } | |
1537 | if (phiAcc) { | |
1538 | phiAcc->SetFillColor(color); | |
1539 | phiAcc->SetLineColor(color); | |
1540 | allPhi->Add(phiAcc); | |
1541 | } | |
1542 | pring++; | |
1543 | } | |
77f97e3f CHC |
1544 | Double_t savX = fParVal->GetX(); |
1545 | Double_t savY = fParVal->GetY(); | |
1546 | fParVal->SetX(.3); | |
1547 | fParVal->SetY(.2); | |
1548 | TVirtualPad* p = fBody->cd(1); | |
1549 | p->Divide(1,2,0,0); | |
1550 | DrawInPad(p, 1, GetStack(c, "all"), "nostack", mcRings ? 0 : kLegend, | |
079fd669 | 1551 | "Individual ring results"); |
77f97e3f CHC |
1552 | DrawInPad(p, 1, mcRings, "nostack same", kLegend|kSilent); |
1553 | DrawInPad(p, 2, allEta, "nostack hist", kLegend, | |
079fd669 | 1554 | "#phi acceptance and #eta coverage per ring"); |
77f97e3f CHC |
1555 | DrawInPad(p, 2, allPhi, "nostack hist same", 0x0); |
1556 | ||
1557 | p = fBody->cd(2); | |
1558 | p->Divide(1,2,0,0); | |
1559 | DrawInPad(p, 1, dndeta_phi, "", 0x0, | |
1560 | "1/#it{N}_{ev} d#it{N}_{ch}/d#it{#eta}"); | |
1561 | DrawInPad(p, 1, dndeta_eta, "Same", kLegend); | |
1562 | DrawInPad(p, 2, GetH1(fResults, "norm"), "", 0x0, | |
079fd669 | 1563 | "Total #phi acceptance and #eta coverage"); |
77f97e3f | 1564 | DrawInPad(p, 2, GetH1(fResults, "phi"), "same", kLegend); |
bfab35d9 | 1565 | // DrawInPad(fBody, 4, GetH1(fSums, "d2Ndetadphi"), "colz"); |
2955f67c | 1566 | |
079fd669 | 1567 | // fBody->cd(1); |
1568 | // TLatex* l = new TLatex(.5, .2, "Ring results"); | |
1569 | // l->SetNDC(); | |
1570 | // l->SetTextAlign(21); | |
1571 | // l->Draw(); | |
2955f67c | 1572 | |
079fd669 | 1573 | // fBody->cd(2); |
1574 | // l->DrawLatex(.5, .2, "1/N_{ev}dN_{ch}/d#eta"); | |
2955f67c | 1575 | |
1576 | // fBody->cd(3); | |
1577 | // l->DrawLatex(.5, .2, "1/N_{ev}dN_{ch}/d#eta (#vta norm.)"); | |
1578 | ||
77f97e3f CHC |
1579 | fParVal->SetX(savX); |
1580 | fParVal->SetY(savY); | |
2955f67c | 1581 | PrintCanvas("Results"); |
1582 | } | |
1583 | ||
bfab35d9 | 1584 | //____________________________________________________________________ |
1585 | void DrawCentralResults() | |
1586 | { | |
1587 | // MakeChapter(can, "Results"); | |
1588 | Info("DrawCentralResults", "Drawing central results"); | |
1589 | ||
1590 | fBody->Divide(1,2,0,0); | |
1591 | ||
1592 | TH1* dndeta_ = GetH1(fResults, "dNdeta_"); | |
1593 | TH1* dndeta = GetH1(fResults, "dNdeta"); | |
1594 | THStack* stack = new THStack("dndetas", | |
1595 | "d#it{N}_{ch}/d#it{#eta} - central"); | |
1596 | stack->Add(dndeta_); | |
1597 | stack->Add(dndeta); | |
1598 | ||
1599 | DrawInPad(fBody, 1, stack, "nostack"); | |
77f97e3f CHC |
1600 | TH1* h = stack->GetHistogram(); |
1601 | if (h) { | |
1602 | h->SetXTitle("#it{#eta}"); | |
1603 | h->SetYTitle("#frac{d#it{N}_{ch}}{d#it{#eta}}"); | |
1604 | } | |
bfab35d9 | 1605 | fBody->cd(1); |
1606 | TLegend* l = new TLegend(.3, .05, .7, .4); | |
1607 | l->SetFillColor(0); | |
1608 | l->SetFillStyle(0); | |
1609 | l->SetBorderSize(0); | |
1610 | l->AddEntry(dndeta_, "Normalized to coverage", "lp"); | |
1611 | l->AddEntry(dndeta, "Normalized to #phi acceptance", "lp"); | |
1612 | l->Draw(); | |
1613 | ||
1614 | DrawInPad(fBody, 2, GetH1(fResults, "norm")); | |
1615 | DrawInPad(fBody, 2, GetH1(fResults, "phi"), "same", kLegend); | |
1616 | ||
1617 | PrintCanvas("Central Results"); | |
1618 | ||
1619 | } | |
1620 | void DrawBoth(TFile* file) | |
1621 | { | |
1622 | Info("DrawBoth", "Drawing central & forward results"); | |
1623 | TCollection* central = GetCollection(file, "CentralResults"); | |
1624 | TCollection* forward = GetCollection(file, "ForwardResults"); | |
1625 | ||
1626 | if (!central || !forward) { | |
1627 | Warning("DrawBoth", "central %p or forward %p results not found", | |
1628 | central, forward); | |
1629 | return; | |
1630 | } | |
1631 | ||
1632 | TH1* f1 = GetH1(forward, "dNdeta_"); | |
1633 | TH1* c1 = GetH1(central, "dNdeta_"); | |
1634 | TH1* f2 = GetH1(forward, "dNdeta"); | |
1635 | TH1* c2 = GetH1(central, "dNdeta"); | |
24338c03 | 1636 | if (!f1 || !c1 || !f2 || !c2) return; |
bfab35d9 | 1637 | f1->SetLineColor(kBlack); |
1638 | f2->SetLineColor(kBlack); | |
1639 | c1->SetLineColor(kBlack); | |
1640 | c2->SetLineColor(kBlack); | |
1641 | f1->SetMarkerColor(f2->GetMarkerColor()); | |
1642 | f1->SetMarkerStyle(24); | |
1643 | c1->SetMarkerStyle(24); | |
1644 | c2->SetMarkerStyle(20); | |
1645 | c2->SetMarkerColor(c1->GetMarkerColor()); | |
1646 | THStack* s = new THStack("dndetas", "d#it{N}_{ch}/d#it{#eta}"); | |
1647 | s->Add(f1); | |
1648 | s->Add(c1); | |
1649 | s->Add(f2); | |
1650 | s->Add(c2); | |
1651 | ||
1652 | fBody->Divide(1, 2, 0, 0); | |
1653 | DrawInPad(fBody, 1, s, "nostack"); | |
1654 | s->GetHistogram()->SetXTitle("#it{#eta}"); | |
1655 | s->GetHistogram()->SetYTitle("#frac{d#it{N}_{ch}}{d#it{#eta}}"); | |
1656 | ||
1657 | fBody->cd(1); | |
1658 | TLegend* l = new TLegend(.4, .05, .8, .4); | |
1659 | l->SetFillColor(0); | |
1660 | l->SetFillStyle(0); | |
1661 | l->SetBorderSize(0); | |
1662 | TLegendEntry* entry = l->AddEntry("dummy", "Forward", "f"); | |
1663 | entry->SetFillColor(f1->GetMarkerColor()); | |
1664 | entry->SetLineColor(f1->GetMarkerColor()); | |
1665 | entry->SetFillStyle(1001); | |
1666 | entry->SetLineWidth(0); | |
1667 | entry = l->AddEntry("dummy", "Central", "f"); | |
1668 | entry->SetFillColor(c1->GetMarkerColor()); | |
1669 | entry->SetLineColor(c1->GetMarkerColor()); | |
1670 | entry->SetLineWidth(0); | |
1671 | entry->SetFillStyle(1001); | |
1672 | entry = l->AddEntry("dummy", "Normalized to coverage", "lp"); | |
1673 | entry->SetMarkerStyle(f1->GetMarkerStyle()); | |
1674 | entry = l->AddEntry("dummy", "Normalized to #phi acceptance", "lp"); | |
1675 | entry->SetMarkerStyle(f2->GetMarkerStyle()); | |
1676 | l->Draw(); | |
1677 | ||
1678 | TH1* f3 = GetH1(forward, "norm"); | |
1679 | TH1* c3 = GetH1(central, "norm"); | |
1680 | TH1* f4 = GetH1(forward, "phi"); | |
1681 | TH1* c4 = GetH1(central, "phi"); | |
1682 | f3->SetFillColor(f1->GetMarkerColor()); | |
1683 | f4->SetFillColor(f1->GetMarkerColor()); | |
1684 | c3->SetFillColor(c1->GetMarkerColor()); | |
1685 | c4->SetFillColor(c1->GetMarkerColor()); | |
1686 | f3->SetLineColor(f1->GetMarkerColor()); | |
1687 | f4->SetLineColor(f1->GetMarkerColor()); | |
1688 | c3->SetLineColor(c1->GetMarkerColor()); | |
1689 | c4->SetLineColor(c1->GetMarkerColor()); | |
1690 | ||
1691 | THStack* a = new THStack("norms", "Normalizations"); | |
1692 | a->Add(f3); | |
1693 | a->Add(c3); | |
1694 | a->Add(f4); | |
1695 | a->Add(c4); | |
1696 | ||
1697 | a->SetMaximum(a->GetMaximum("nostack")*1.2); | |
1698 | DrawInPad(fBody, 2, a, "nostack"); | |
1699 | a->GetHistogram()->SetXTitle("#it{#eta}"); | |
1700 | a->GetHistogram()->SetYTitle("Normalization (coverage or acceptance)"); | |
1701 | ||
1702 | fBody->cd(2); | |
1703 | l = new TLegend(.2, .94, .9, .99); | |
1704 | l->SetFillColor(0); | |
1705 | l->SetFillStyle(0); | |
1706 | l->SetBorderSize(0); | |
1707 | l->SetNColumns(2); | |
1708 | // entry = l->AddEntry("dummy", "Forward", "f"); | |
1709 | // entry->SetFillColor(f1->GetMarkerColor()); | |
1710 | // entry->SetLineColor(f1->GetMarkerColor()); | |
1711 | // entry->SetFillStyle(1001); | |
1712 | // entry->SetLineWidth(0); | |
1713 | // entry = l->AddEntry("dummy", "Central", "f"); | |
1714 | // entry->SetFillColor(c1->GetMarkerColor()); | |
1715 | // entry->SetLineColor(c1->GetMarkerColor()); | |
1716 | // entry->SetLineWidth(0); | |
1717 | // entry->SetFillStyle(1001); | |
1718 | entry = l->AddEntry("dummy", "#eta Coverage", "f"); | |
1719 | entry->SetFillStyle(f3->GetFillStyle()); | |
1720 | entry->SetFillColor(kBlack); | |
1721 | entry = l->AddEntry("dummy", "#phi Acceptance", "f"); | |
1722 | entry->SetFillStyle(f4->GetFillStyle()); | |
1723 | entry->SetFillColor(kBlack); | |
1724 | l->Draw(); | |
1725 | ||
1726 | PrintCanvas("Both results"); | |
1727 | } | |
2955f67c | 1728 | TCollection* fSums; |
1729 | TCollection* fResults; | |
1730 | }; | |
1731 | ||
1732 | // #endif |