]>
Commit | Line | Data |
---|---|---|
063a7579 | 1 | /** |
2 | * @file DrawAODSummary.C | |
3 | * @author Christian Holm Christensen <cholm@master.hehi.nbi.dk> | |
4 | * @date Tue Oct 30 09:47:30 2012 | |
5 | * | |
6 | * @brief Script to draw summary of AOD pass into a PDF | |
7 | * | |
8 | * | |
9 | */ | |
10 | ||
11 | //____________________________________________________________________ | |
12 | /** | |
13 | * Find an object in a collection | |
14 | * | |
15 | * @param parent Parent list | |
16 | * @param name Name of object | |
17 | * | |
18 | * @return Pointer to object or null | |
19 | */ | |
20 | TObject* GetObject(const TCollection* parent, const TString& name) | |
21 | { | |
9869e55c | 22 | // Info("GetObject", "Getting object %s from %p", name.Data(), parent); |
063a7579 | 23 | // --- Check parent ------------------------------------------------ |
24 | if (!parent) { | |
25 | Warning("GetObject", "No parent list"); | |
26 | return 0; | |
27 | } | |
28 | // --- Check name -------------------------------------------------- | |
29 | if (name.IsNull()) { | |
30 | Warning("GetObject", "No name specified"); | |
31 | return 0; | |
32 | } | |
33 | // --- Find the object --------------------------------------------- | |
34 | TObject* o = parent->FindObject(name); | |
35 | if (!o) { | |
36 | Warning("GetObject", "Object \"%s\" not found in parent \"%s\"", | |
37 | name.Data(), parent->GetName()); | |
38 | return 0; | |
39 | } | |
40 | return o; | |
41 | } | |
42 | //____________________________________________________________________ | |
43 | /** | |
44 | * Find an object in a directory | |
45 | * | |
46 | * @param parent Parent directory | |
47 | * @param name Name of object | |
48 | * | |
49 | * @return Pointer to object or null | |
50 | */ | |
51 | TObject* GetObject(const TDirectory* parent, const TString& name) | |
52 | { | |
9869e55c | 53 | // Info("GetObject", "Getting object %s from %p", name.Data(), parent); |
063a7579 | 54 | // --- Check parent ------------------------------------------------ |
55 | if (!parent) { | |
56 | Warning("GetObject", "No parent directory"); | |
57 | return 0; | |
58 | } | |
59 | // --- Check name -------------------------------------------------- | |
60 | if (name.IsNull()) { | |
61 | Warning("GetObject", "No name specified"); | |
62 | return 0; | |
63 | } | |
64 | // --- Find the object --------------------------------------------- | |
65 | TObject* o = parent->Get(name); | |
66 | if (!o) { | |
67 | Warning("GetObject", "Object \"%s\" not found in parent \"%s\"", | |
68 | name.Data(), parent->GetName()); | |
69 | return 0; | |
70 | } | |
71 | return o; | |
72 | } | |
73 | ||
74 | //____________________________________________________________________ | |
75 | /** | |
76 | * Check the type of a found object | |
77 | * | |
78 | * @param o Object | |
79 | * @param cl Class | |
80 | * @param src Source of object | |
81 | * | |
82 | * @return true on success, false otherwise | |
83 | */ | |
84 | Bool_t CheckType(const TObject* o, const TClass* cl, const TString& src) | |
85 | { | |
9869e55c | 86 | // Info("CheckType", "Checking type of %s vs %s", o->GetName(), cl->GetName()); |
063a7579 | 87 | if (!o->IsA()->InheritsFrom(cl)) { |
88 | Warning("CheckType", "Object \"%s\" retrieved from \"%s\" is not a " | |
89 | "%s but a %s", o->GetName(), src.Data(), cl->GetName(), | |
90 | o->ClassName()); | |
91 | return false; | |
92 | } | |
93 | return true; | |
94 | } | |
95 | ||
96 | //_____________________________________________________________________ | |
97 | void GetParameter(const TCollection* c, const TString& name, UShort_t& value) | |
98 | { | |
9869e55c | 99 | // Info("GetParameter", "Getting parameter of %s from %p", name.Data(), c); |
063a7579 | 100 | TObject* o = GetObject(c, name); |
101 | if (!o) return; | |
102 | value = o->GetUniqueID(); | |
103 | } | |
104 | //_____________________________________________________________________ | |
105 | void GetParameter(const TCollection* c, const TString& name, Int_t& value) | |
106 | { | |
9869e55c | 107 | // Info("GetParameter", "Getting parameter of %s from %p", name.Data(), c); |
063a7579 | 108 | TObject* o = GetObject(c, name); |
109 | if (!o) return; | |
110 | value = o->GetUniqueID(); | |
111 | } | |
112 | //_____________________________________________________________________ | |
113 | void GetParameter(const TCollection* c, const TString& name, Double_t& value) | |
114 | { | |
9869e55c | 115 | // Info("GetParameter", "Getting parameter of %s from %p", name.Data(), c); |
063a7579 | 116 | TObject* o = GetObject(c, name); |
117 | if (!o) return; | |
118 | UInt_t i = o->GetUniqueID(); | |
119 | Float_t v = *reinterpret_cast<Float_t*>(&i); | |
120 | value = v; | |
121 | } | |
122 | //_____________________________________________________________________ | |
123 | void GetParameter(const TCollection* c, const TString& name, Bool_t& value) | |
124 | { | |
9869e55c | 125 | // Info("GetParameter", "Getting parameter of %s from %p", name.Data(), c); |
063a7579 | 126 | TObject* o = GetObject(c, name); |
127 | if (!o) return; | |
128 | value = o->GetUniqueID(); | |
129 | } | |
130 | ||
131 | //____________________________________________________________________ | |
132 | /** | |
133 | * Find a collection in another collection | |
134 | * | |
135 | * @param parent Parent collection | |
136 | * @param name Name of the collection | |
137 | * | |
138 | * @return pointer to collection on success, otherwise null | |
139 | */ | |
140 | TCollection* GetCollection(const TCollection* parent, const TString& name) | |
141 | { | |
9869e55c | 142 | // Info("GetCollection", "Getting collection of %s from %p", name.Data(), c); |
063a7579 | 143 | // --- Find the object --------------------------------------------- |
144 | TObject* o = GetObject(parent, name); | |
145 | if (!o) return 0; | |
146 | ||
147 | // --- Check type of found object ---------------------------------- | |
148 | if (!CheckType(o, TCollection::Class(), parent->GetName())) return 0; | |
149 | ||
150 | // --- Return the collection --------------------------------------- | |
151 | return static_cast<TCollection*>(o); | |
152 | } | |
153 | ||
154 | //____________________________________________________________________ | |
155 | /** | |
156 | * Find a collection in a directory | |
157 | * | |
158 | * @param parent Parent directory | |
159 | * @param name Name of the collection | |
160 | * | |
161 | * @return pointer to collection on success, otherwise null | |
162 | */ | |
163 | TCollection* GetCollection(const TDirectory* parent, const TString& name) | |
164 | { | |
9869e55c | 165 | // Info("GetCollection", "Getting collection of %s from %p", |
166 | // name.Data(), parent); | |
063a7579 | 167 | // --- Find the object --------------------------------------------- |
168 | TObject* o = GetObject(parent, name); | |
169 | if (!o) return 0; | |
170 | ||
171 | // --- Check the type of object ------------------------------------ | |
172 | if (!CheckType(o, TCollection::Class(), parent->GetName())) return 0; | |
173 | ||
174 | // --- Return the collection --------------------------------------- | |
175 | return static_cast<TCollection*>(o); | |
176 | } | |
177 | ||
178 | //____________________________________________________________________ | |
179 | /** | |
180 | * Get a 1D histogram from a collection | |
181 | * | |
182 | * @param parent Parent collection | |
183 | * @param name Name of histogram | |
184 | * | |
185 | * @return pointer or null | |
186 | */ | |
187 | TH1* GetH1(const TCollection* parent, const TString& name) | |
188 | { | |
9869e55c | 189 | // Info("GetH1", "Getting 1D histogram of %s from %p", name.Data(), c); |
063a7579 | 190 | // --- Find the object --------------------------------------------- |
191 | TObject* o = GetObject(parent, name); | |
192 | if (!o) return 0; | |
193 | ||
194 | // --- Check the type of object ------------------------------------ | |
195 | if (!CheckType(o, TH1::Class(), parent->GetName())) return 0; | |
196 | ||
197 | // --- Return the collection --------------------------------------- | |
198 | return static_cast<TH1*>(o); | |
199 | } | |
200 | //____________________________________________________________________ | |
201 | /** | |
202 | * Get a 2D histogram from a collection | |
203 | * | |
204 | * @param parent Parent collection | |
205 | * @param name Name of histogram | |
206 | * | |
207 | * @return pointer or null | |
208 | */ | |
209 | TH2* GetH2(const TCollection* parent, const TString& name) | |
210 | { | |
9869e55c | 211 | // Info("GetH2", "Getting 2D histogram of %s from %p", name.Data(), c); |
063a7579 | 212 | // --- Find the object --------------------------------------------- |
213 | TObject* o = GetObject(parent, name); | |
214 | if (!o) return 0; | |
215 | ||
216 | // --- Check the type of object ------------------------------------ | |
217 | if (!CheckType(o, TH2::Class(), parent->GetName())) return 0; | |
218 | ||
219 | // --- Return the collection --------------------------------------- | |
220 | return static_cast<TH2*>(o); | |
221 | } | |
222 | //____________________________________________________________________ | |
223 | /** | |
224 | * Get a histogram stack from a collection | |
225 | * | |
226 | * @param parent Parent collection | |
227 | * @param name Name of histogram | |
228 | * | |
229 | * @return pointer or null | |
230 | */ | |
231 | THStack* GetStack(const TCollection* parent, const TString& name, | |
232 | const char* sub=0) | |
233 | { | |
9869e55c | 234 | // Info("GetStack", "Getting histogram stack %s from %p", name.Data(), parent); |
063a7579 | 235 | // --- Find the object --------------------------------------------- |
236 | TObject* o = GetObject(parent, name); | |
237 | if (!o) return 0; | |
238 | ||
239 | // --- Check the type of object ------------------------------------ | |
240 | if (!CheckType(o, THStack::Class(), parent->GetName())) return 0; | |
241 | ||
242 | THStack* stack = static_cast<THStack*>(o); | |
243 | if (sub == 0) return stack; | |
244 | ||
245 | if (stack->GetHists()->GetEntries() <= 0 ||stack->GetMaximum() < 1) { | |
246 | stack->GetHists()->Delete(); | |
247 | const char* subs[] = { "FMD1I", "FMD2I", "FMD2O", "FMD3O", "FMD3I", 0 }; | |
248 | const char** ptr = subs; | |
249 | while (*ptr) { | |
250 | TCollection* sc = GetCollection(parent, *ptr); | |
251 | if (!sc) { ptr++; continue; } | |
252 | ||
253 | TH2* h = GetH2(sc, sub); | |
254 | if (!h) continue; | |
255 | TH1* p = h->ProjectionX(*ptr, 1, h->GetNbinsY(), "e"); | |
256 | p->Scale(1., "width"); | |
257 | p->SetTitle(*ptr); | |
258 | p->SetDirectory(0); | |
259 | stack->Add(p); | |
260 | ptr++; | |
261 | } | |
262 | } | |
263 | // --- Return the collection --------------------------------------- | |
264 | return stack; | |
265 | } | |
266 | ||
267 | //____________________________________________________________________ | |
268 | void Pause() | |
269 | { | |
270 | printf("Press enter to continue"); | |
271 | std::cin.get(); | |
272 | } | |
273 | ||
274 | //____________________________________________________________________ | |
275 | /** | |
276 | * Clear canvas | |
277 | * | |
278 | * @param c Canvas to clear | |
279 | * | |
280 | * @ingroup pwglf_forward_scripts_corr | |
281 | */ | |
282 | void | |
283 | ClearCanvas(TCanvas* c) | |
284 | { | |
9869e55c | 285 | // Info("ClearCanvas", "Clearing canvas"); |
063a7579 | 286 | c->SetLeftMargin(.1); |
287 | c->SetRightMargin(.05); | |
288 | c->SetBottomMargin(.1); | |
289 | c->SetTopMargin(.05); | |
290 | c->Clear(); | |
291 | ||
292 | Float_t dy = .05; | |
293 | TPad* p1 = new TPad("top", "Top", 0, 1-dy, 1, 1, 0, 0); | |
294 | p1->SetNumber(1); | |
295 | p1->SetFillColor(kBlue-5); | |
296 | p1->SetBorderSize(0); | |
297 | p1->SetBorderMode(0); | |
298 | c->cd(); | |
299 | p1->Draw(); | |
300 | ||
301 | TPad* p2 = new TPad("body", "Body", 0, 0, 1, 1-dy, 0, 0); | |
302 | p2->SetNumber(2); | |
303 | p2->SetFillColor(0); | |
304 | p2->SetFillStyle(0); | |
305 | p2->SetBorderSize(0); | |
306 | p2->SetBorderMode(0); | |
307 | c->cd(); | |
308 | p2->Draw(); | |
309 | p2->cd(); | |
310 | ||
311 | } | |
312 | //____________________________________________________________________ | |
313 | /** | |
314 | * Create a canvas | |
315 | * | |
316 | * @param pname Name of PDF file to make | |
317 | * | |
318 | * @return Created canvas | |
319 | */ | |
320 | TCanvas* CreateCanvas(const TString& pname) | |
321 | { | |
9869e55c | 322 | // Info("CreateCanvas", "Creating canvas"); |
063a7579 | 323 | Int_t size = 1000; |
324 | TCanvas* c = new TCanvas("c", pname.Data(), size / TMath::Sqrt(2), size); | |
325 | c->SetFillColor(0); | |
326 | c->SetBorderSize(0); | |
327 | c->SetBorderMode(0); | |
328 | c->Print(Form("%s[", pname.Data())); | |
329 | ||
330 | gStyle->SetOptStat(0); | |
331 | gStyle->SetTitleColor(0); | |
332 | gStyle->SetTitleStyle(0); | |
333 | gStyle->SetTitleBorderSize(0); | |
334 | gStyle->SetTitleX(.5); | |
335 | gStyle->SetTitleY(1); | |
336 | gStyle->SetTitleW(.8); | |
337 | gStyle->SetTitleH(.09); | |
338 | gStyle->SetFrameFillColor(kWhite); | |
339 | gStyle->SetFrameBorderSize(1); | |
340 | gStyle->SetFrameBorderMode(1); | |
341 | gStyle->SetPalette(1); | |
342 | ||
343 | ClearCanvas(c); | |
344 | ||
345 | return c; | |
346 | } | |
347 | ||
348 | //____________________________________________________________________ | |
349 | /** | |
350 | * Close the PDF | |
351 | * | |
352 | * @param c Canvas | |
353 | */ | |
354 | void CloseCanvas(TCanvas* c) | |
355 | { | |
9869e55c | 356 | // Info("CloseCanvas", "Closing canvas"); |
063a7579 | 357 | ClearCanvas(c); |
358 | c->Print(Form("%s]", c->GetTitle())); | |
359 | } | |
360 | ||
361 | //____________________________________________________________________ | |
362 | /** | |
363 | * Print the canvas | |
364 | * | |
365 | * @param c Canvas | |
366 | * @param title Title | |
367 | */ | |
368 | void PrintCanvas(TCanvas* c, const TString& title, | |
369 | Float_t size=.7, Bool_t pause=false) | |
370 | { | |
9869e55c | 371 | // Info("PrintCanvas", "Printing page %s", title.Data()); |
063a7579 | 372 | TString tit; |
373 | tit.Form("Title:%s", title.Data()); | |
374 | ||
375 | c->cd(1); | |
376 | TLatex* ltx = new TLatex(.5, .5, title); | |
377 | ltx->SetNDC(); | |
378 | ltx->SetTextAlign(22); | |
379 | ltx->SetTextSize(size); | |
380 | ltx->SetTextColor(kWhite); | |
381 | ltx->SetTextFont(62); | |
382 | ltx->Draw(); | |
383 | ||
384 | c->Modified(); | |
385 | c->Update(); | |
386 | c->cd(); | |
9869e55c | 387 | gSystem->RedirectOutput("/dev/null"); |
063a7579 | 388 | c->Print(c->GetTitle(), tit); |
9869e55c | 389 | gSystem->RedirectOutput(0); |
063a7579 | 390 | |
391 | // std::cin.peek(); | |
392 | if (pause) Pause(); | |
393 | ||
394 | ClearCanvas(c); | |
395 | } | |
396 | //____________________________________________________________________ | |
397 | /** | |
398 | * Make a chapter page | |
399 | * | |
400 | * @param c Canvas | |
401 | * @param title Title | |
402 | */ | |
403 | void MakeChapter(TCanvas* c, const TString& title) | |
404 | { | |
405 | c->cd(2); | |
406 | ||
9869e55c | 407 | // Info("MakeChapter", "Making chapter %s", title.Data()); |
063a7579 | 408 | TLatex* ltx = new TLatex(.5, .5, title); |
409 | ltx->SetNDC(); | |
410 | ltx->SetTextAlign(22); | |
411 | ltx->Draw(); | |
412 | ||
413 | PrintCanvas(c, title); | |
414 | } | |
415 | //____________________________________________________________________ | |
416 | void DrawInPad(TVirtualPad* c, Int_t padNo, TObject* h, Option_t* opts="", | |
417 | UShort_t flags=0x0) | |
418 | { | |
9869e55c | 419 | // Info("DrawInPad", "Drawing %p in pad # %d of %p w/options %s, flags 0x%x", |
420 | // h, padNo, c, opts, flags); | |
063a7579 | 421 | TVirtualPad* p = c->cd(padNo); |
422 | if (!p) { | |
423 | Warning("DrawInPad", "Pad # %d not found in %s", padNo, c->GetName()); | |
424 | return; | |
425 | } | |
426 | if (flags & 0x1) p->SetLogx(); | |
427 | if (flags & 0x2) p->SetLogy(); | |
428 | if (flags & 0x4) p->SetLogz(); | |
429 | p->SetFillColor(0); | |
430 | TString o(opts); | |
431 | if (o.Contains("colz", TString::kIgnoreCase)) | |
432 | p->SetRightMargin(0.15); | |
433 | ||
434 | if (!h) { | |
435 | Warning("DrawInPad", "Nothing to draw in pad # %d", padNo); | |
436 | return; | |
437 | } | |
438 | h->Draw(opts); | |
439 | ||
440 | if (flags& 0x10) { | |
441 | TLegend* l = p->BuildLegend(); | |
442 | l->SetFillColor(0); | |
443 | l->SetFillStyle(0); | |
444 | l->SetBorderSize(0); | |
445 | } | |
446 | p->Modified(); | |
447 | p->Update(); | |
448 | p->cd(); | |
449 | } | |
450 | //____________________________________________________________________ | |
451 | void CreateTemplates(TLatex*& name, TLatex*& value, Float_t size=.03) | |
452 | { | |
453 | Double_t x1 = .1; | |
454 | Double_t x2 = .6; | |
455 | Double_t y = .8; | |
456 | name = new TLatex(x1, y, ""); | |
457 | name->SetTextAlign(13); | |
458 | name->SetNDC(); | |
459 | name->SetTextSize(size); | |
460 | ||
461 | value = new TLatex(x2, y, ""); | |
462 | value->SetTextAlign(13); | |
463 | value->SetNDC(); | |
464 | value->SetTextSize(size); | |
465 | } | |
466 | ||
467 | //____________________________________________________________________ | |
468 | void DrawParameter(TLatex* name, TLatex* value, Double_t& y, | |
469 | const TString& sName, const TString& sValue) | |
470 | { | |
471 | name->DrawLatex(name->GetX(), y, Form("%s:", sName.Data())); | |
472 | value->DrawLatex(value->GetX(), y, sValue.Data()); | |
473 | y -= name->GetTextSize() + .02; | |
474 | } | |
475 | ||
476 | ||
477 | //____________________________________________________________________ | |
478 | void DrawEventInspector(const TCollection* forward, TCanvas* can) | |
479 | { | |
480 | Info("DrawEventInspector", "Drawing event inspector from %p", | |
481 | forward); | |
482 | TCollection* c = GetCollection(forward, "fmdEventInspector"); | |
483 | if (!c) return; | |
484 | ||
485 | can->cd(2); | |
486 | ||
487 | TLatex* name; | |
488 | TLatex* value; | |
489 | Double_t y = .8; | |
490 | CreateTemplates(name, value); | |
491 | ||
492 | Int_t sys, sNN, field, runNo, lowFlux, nPileUp; | |
493 | Bool_t fpVtx, v0and; | |
494 | Double_t dPileUp; | |
495 | ||
496 | GetParameter(c, "sys", sys); | |
497 | GetParameter(c, "sNN", sNN); | |
498 | GetParameter(c, "field", field); | |
499 | GetParameter(c, "runNo", runNo); | |
500 | GetParameter(c, "lowFlux", lowFlux); | |
501 | GetParameter(c, "fpVtx", fpVtx); | |
502 | GetParameter(c, "v0and", v0and); | |
503 | GetParameter(c, "nPileUp", nPileUp); | |
9869e55c | 504 | GetParameter(c, "dPileup", dPileUp); |
063a7579 | 505 | |
506 | DrawParameter(name, value, y, "System", (sys == 1 ? "pp" : | |
507 | sys == 2 ? "PbPb" : | |
508 | sys == 3 ? "pPb" : "unknown")); | |
509 | DrawParameter(name, value, y, "#sqrt{s_{NN}}", Form("%5dGeV", sNN)); | |
510 | DrawParameter(name, value, y, "L3 B field", Form("%+2dkG", field)); | |
511 | DrawParameter(name, value, y, "Run #", Form("%6d", runNo)); | |
512 | DrawParameter(name, value, y, "Low flux cut", Form("%6d", lowFlux)); | |
513 | DrawParameter(name, value, y, "Use PWG-UD vertex", (fpVtx ? "yes" : "no")); | |
514 | DrawParameter(name, value, y, "Use V0AND for NSD", (v0and ? "yes" : "no")); | |
515 | DrawParameter(name, value, y, "Least # of pile-up vertex", | |
516 | Form("%d", nPileUp)); | |
517 | DrawParameter(name, value, y, "Least distance of pile-up vertex", | |
518 | Form("%fcm", dPileUp)); | |
519 | ||
520 | PrintCanvas(can, "Event Inspector"); | |
9869e55c | 521 | |
063a7579 | 522 | TVirtualPad* body = can->cd(2); |
523 | body->Divide(2,4); | |
9869e55c | 524 | |
525 | TH1* nEventsTr = GetH1(c, "nEventsTr"); | |
526 | TH1* nEventsTrVtx = GetH1(c, "nEventsTrVtx"); | |
527 | if (nEventsTr) nEventsTr->Rebin(2); | |
528 | if (nEventsTrVtx) nEventsTrVtx->Rebin(2); | |
529 | DrawInPad(body, 1, nEventsTr); | |
530 | DrawInPad(body, 1, nEventsTrVtx, "same"); | |
531 | DrawInPad(body, 1, GetH1(c, "nEventsAccepted"), "same", 0x10); | |
532 | ||
533 | ||
534 | DrawInPad(body, 2, GetH2(c, "nEventsAcceptedXY"), "colz", 0x4); | |
535 | DrawInPad(body, 3, GetH1(c, "triggers"), "hist text"); | |
536 | DrawInPad(body, 4, GetH2(c, "triggerCorr"), "colz", 0x4); | |
537 | DrawInPad(body, 5, GetH1(c, "status"), "hist text"); | |
538 | DrawInPad(body, 6, GetH1(c, "type"), "hist text"); | |
539 | DrawInPad(body, 7, GetH1(c, "cent")); | |
540 | DrawInPad(body, 8, GetH2(c, "centVsQuality"), "colz", 0x4); | |
541 | ||
542 | PrintCanvas(can, "EventInspector - Histograms"); | |
063a7579 | 543 | } |
544 | ||
545 | //____________________________________________________________________ | |
546 | void DrawSharingFilter(const TCollection* forward, TCanvas* can) | |
547 | { | |
548 | Info("DrawEventInspector", "Drawing sharing filter from %p", | |
549 | forward); | |
550 | TCollection* c = GetCollection(forward, "fmdSharingFilter"); | |
551 | if (!c) return; | |
552 | ||
553 | TVirtualPad* body = can->cd(2); | |
554 | body->Divide(1, 3); | |
555 | body->cd(1); | |
556 | ||
557 | TLatex* name; | |
558 | TLatex* value; | |
559 | Double_t y = .8; | |
560 | CreateTemplates(name, value, .05); | |
561 | ||
562 | Bool_t angle, lowSignal, simple; | |
563 | ||
564 | GetParameter(c, "angle", angle); | |
565 | GetParameter(c, "lowSignal", lowSignal); | |
566 | GetParameter(c, "simple", simple); | |
567 | ||
568 | DrawParameter(name, value, y, "Angle correct", (angle ? "yes" : "no")); | |
569 | DrawParameter(name, value, y, "Lower signal", (lowSignal ? "yes" : "no")); | |
570 | DrawParameter(name, value, y, "Simple method", (simple ? "yes" : "no")); | |
571 | ||
572 | DrawInPad(body, 2, GetH2(c, "lowCuts"), "colz"); | |
573 | DrawInPad(body, 3, GetH2(c, "highCuts"), "colz"); | |
574 | ||
575 | PrintCanvas(can, "Sharing filter"); | |
576 | ||
577 | const char* subs[] = { "FMD1I", "FMD2I", "FMD2O", "FMD3O", "FMD3I", 0 }; | |
578 | const char** ptr = subs; | |
579 | while (*ptr) { | |
580 | TCollection* sc = GetCollection(c, *ptr); | |
581 | if (!sc) { ptr++; continue; } | |
582 | ||
583 | body = can->cd(2); | |
584 | body->Divide(2,3); | |
585 | DrawInPad(body, 1, GetH1(sc, "esdEloss"), "", 0x2); | |
586 | DrawInPad(body, 1, GetH1(sc, "anaEloss"), "same", 0x12); | |
587 | DrawInPad(body, 2, GetH1(sc, "singleEloss"), "", 0x2); | |
588 | DrawInPad(body, 2, GetH1(sc, "doubleEloss"), "same", 0x2); | |
589 | DrawInPad(body, 2, GetH1(sc, "tripleEloss"), "same", 0x12); | |
590 | DrawInPad(body, 3, GetH2(sc, "singlePerStrip"), "colz", 0x4); | |
591 | DrawInPad(body, 4, GetH1(sc, "distanceBefore"), "", 0x2); | |
592 | DrawInPad(body, 4, GetH1(sc, "distanceAfter"), "same", 0x12); | |
593 | ||
594 | TH2D* nB = GetH2(sc, "neighborsBefore"); | |
595 | if (nB) { | |
596 | nB->GetXaxis()->SetRangeUser(0,8); | |
597 | nB->GetYaxis()->SetRangeUser(0,8); | |
598 | } | |
599 | DrawInPad(body, 5, nB, "colz", 0x4); | |
600 | DrawInPad(body, 5, GetH2(sc, "neighborsAfter"), "p same", 0x4); | |
601 | DrawInPad(body, 6, GetH2(sc, "beforeAfter"), "colz", 0x4); | |
602 | ||
603 | PrintCanvas(can, Form("Sharing filter - %s", *ptr)); | |
604 | ptr++; | |
605 | } | |
606 | } | |
607 | ||
608 | //____________________________________________________________________ | |
609 | void DrawDensityCalculator(const TCollection* forward, TCanvas* can) | |
610 | { | |
611 | Info("DrawEventInspector", "Drawing density calculator from %p", | |
612 | forward); | |
613 | TCollection* c = GetCollection(forward, "fmdDensityCalculator"); | |
614 | if (!c) return; | |
615 | ||
616 | TVirtualPad* body = can->cd(2); | |
617 | body->Divide(2, 2); | |
618 | body->cd(1); | |
619 | ||
620 | TLatex* name; | |
621 | TLatex* value; | |
622 | Double_t y = .8; | |
623 | CreateTemplates(name, value, .05); | |
624 | ||
625 | Int_t maxParticles, phiAcceptance, etaLumping, phiLumping; | |
626 | Bool_t method, recalcEta, recalcPhi; | |
627 | ||
9869e55c | 628 | GetParameter(c, "maxParticle", maxParticles); |
063a7579 | 629 | GetParameter(c, "phiAcceptance", phiAcceptance); |
630 | GetParameter(c, "etaLumping", etaLumping); | |
631 | GetParameter(c, "phiLumping", phiLumping); | |
632 | GetParameter(c, "method", method); | |
633 | GetParameter(c, "recalcEta", recalcEta); | |
634 | GetParameter(c, "recalcPhi", recalcPhi); | |
635 | ||
636 | DrawParameter(name, value, y, "Method", (method ? "Poisson" : "#DeltaE")); | |
637 | DrawParameter(name, value, y, "Recalculate #eta",(recalcEta ? "yes" : "no")); | |
638 | DrawParameter(name, value, y, "Recalculate #phi",(recalcPhi ? "yes" : "no")); | |
639 | DrawParameter(name, value, y, "#phi acceptance method", | |
640 | (phiAcceptance == 1 ? "N_{ch}" : | |
641 | phiAcceptance == 2 ? "#DeltaE" : none)); | |
642 | DrawParameter(name, value, y, "Region size (sector#timesstrip)", | |
643 | Form("%2d #times %2d", phiLumping, etaLumping)); | |
644 | ||
645 | TVirtualPad* p = body; // body->cd(2); | |
646 | // p->Divide(3,1); | |
647 | ||
648 | TH1* accI = GetH1(c, "accI"); | |
649 | if (accI) { accI->SetMaximum(60); accI->SetMinimum(0); } | |
650 | DrawInPad(p, 2, accI); | |
651 | DrawInPad(p, 2, GetH1(c, "accO"), "same", 0x10); | |
652 | DrawInPad(p, 3, GetH2(c, "lowCuts"), "colz"); | |
653 | DrawInPad(p, 4, GetH2(c, "maxWeights"), "colz"); | |
654 | ||
655 | PrintCanvas(can, "Density calculator"); | |
656 | ||
657 | const char* subs[] = { "FMD1I", "FMD2I", "FMD2O", "FMD3O", "FMD3I", 0 }; | |
658 | const char** ptr = subs; | |
659 | while (*ptr) { | |
660 | TCollection* sc = GetCollection(c, *ptr); | |
661 | if (!sc) { ptr++; continue; } | |
662 | ||
663 | body = can->cd(2); | |
664 | body->Divide(2,3); | |
665 | ||
666 | DrawInPad(body, 1, GetH2(sc, "elossVsPoisson"), "colz", 0x4); | |
667 | DrawInPad(body, 2, GetH1(sc, "diffElossPoisson"), "", 0x2); | |
668 | DrawInPad(body, 3, GetH1(sc, "occupancy"), "", 0x2); | |
669 | DrawInPad(body, 4, GetH1(sc, "eloss"), "", 0x2); | |
670 | DrawInPad(body, 4, GetH1(sc, "elossUsed"), "same", 0x12); | |
671 | TH1* phiB = GetH1(sc, "phiBefore"); | |
672 | TH1* phiA = GetH1(sc, "phiAfter"); | |
673 | if (phiB && phiA) { | |
674 | phiA->Add(phiB, -1); | |
675 | phiA->Divide(phiB); | |
676 | phiA->SetTitle("#Delta#phi from Ip (x,y) correction"); | |
677 | phiA->SetYTitle("(#phi_{after}-#phi_{before})/#phi_{before}"); | |
678 | } | |
679 | DrawInPad(body, 5, phiA); | |
680 | DrawInPad(body, 6, GetH2(sc, "phiAcc"), "colz", 0x4); | |
681 | ||
682 | PrintCanvas(can, Form("Density calculator - %s", *ptr)); | |
683 | ptr++; | |
684 | } | |
685 | } | |
686 | ||
687 | //____________________________________________________________________ | |
688 | void DrawCorrector(const TCollection* forward, TCanvas* can) | |
689 | { | |
690 | Info("DrawEventInspector", "Drawing corrector from %p", forward); | |
691 | TCollection* c = GetCollection(forward, "fmdCorrector"); | |
692 | if (!c) return; | |
693 | ||
694 | TVirtualPad* body = can->cd(2); | |
695 | body->cd(); | |
696 | ||
697 | TLatex* name; | |
698 | TLatex* value; | |
699 | Double_t y = .8; | |
700 | CreateTemplates(name, value, .05); | |
701 | ||
702 | Bool_t secondary, vertexBias, acceptance, merging; | |
703 | GetParameter(c, "secondary", secondary); | |
704 | GetParameter(c, "acceptance", acceptance); | |
705 | GetParameter(c, "vertexBias", vertexBias); | |
706 | GetParameter(c, "merging", merging); | |
707 | ||
708 | DrawParameter(name, value, y, "Secondary corr.", secondary ? "yes" : "no"); | |
709 | DrawParameter(name, value, y, "Acceptance corr.", acceptance ? "yes" : "no"); | |
710 | DrawParameter(name, value, y, "Vertex bias corr.", vertexBias ? "yes" : "no"); | |
711 | DrawParameter(name, value, y, "Merging eff.", merging ? "yes" : "no"); | |
712 | ||
713 | PrintCanvas(can, "Corrector"); | |
714 | } | |
715 | ||
716 | //____________________________________________________________________ | |
717 | void DrawHistCollector(const TCollection* forward, TCanvas* can) | |
718 | { | |
719 | Info("DrawEventInspector", "Drawing histogram collector from %p", forward); | |
720 | TCollection* c = GetCollection(forward, "fmdHistCollector"); | |
721 | if (!c) return; | |
722 | ||
723 | TVirtualPad* body = can->cd(2); | |
9869e55c | 724 | body->Divide(1, 3); |
063a7579 | 725 | body->cd(1); |
726 | ||
9869e55c | 727 | TLatex* name; |
728 | TLatex* value; | |
729 | Double_t y = .8; | |
730 | CreateTemplates(name, value, .05); | |
731 | ||
732 | Int_t nCutBins, fiducial, merge, skipRings; | |
733 | Float_t fiducialCut; | |
734 | Bool_t bgAndHits; | |
735 | ||
736 | GetParameter(c, "nCutBins", nCutBins); | |
737 | GetParameter(c, "skipRings", skipRings); | |
738 | GetParameter(c, "bgAndHits", bgAndHits); | |
739 | GetParameter(c, "merge", merge); | |
740 | GetParameter(c, "fiducial", fiducial); | |
741 | GetParameter(c, "correctionCut", fiducialCut); | |
742 | ||
743 | DrawParameter(name, value, y, "# of bins to cut", Form("%d", nCutBins)); | |
744 | DrawParameter(name, value, y, "Bg & hit maps stored.", bgAndHits?"yes":"no"); | |
745 | DrawParameter(name, value, y, "Fiducial method.", | |
746 | fiducial == 0 ? "cut" : "distance"); | |
747 | DrawParameter(name, value, y, "Fiducial cut.", Form("%f", fiducialCut)); | |
748 | DrawParameter(name, value, y, "Merge method", | |
749 | (merge == 0 ? "straight mean" : | |
750 | merge == 1 ? "straight mean, no zeroes" : | |
751 | merge == 2 ? "weighted mean" : | |
752 | merge == 3 ? "least error" : | |
753 | merge == 4 ? "sum" : "unknown")); | |
754 | TString skipped; | |
755 | if (skipRings & 0x11) skipped.Append("FMD1i "); | |
756 | if (skipRings & 0x21) skipped.Append("FMD2i "); | |
757 | if (skipRings & 0x22) skipped.Append("FMD2o "); | |
758 | if (skipRings & 0x31) skipped.Append("FMD3i "); | |
759 | if (skipRings & 0x32) skipped.Append("FMD3o "); | |
760 | DrawParameter(name, value, y, "Skipped rings", skipped); | |
761 | ||
762 | DrawInPad(body, 2, GetH2(c, "sumRings"), "colz"); | |
763 | DrawInPad(body, 3, GetH2(c, "coverage"), "colz"); | |
063a7579 | 764 | |
765 | PrintCanvas(can, "Histogram collector"); | |
766 | } | |
767 | ||
768 | //____________________________________________________________________ | |
769 | void DrawStep(THStack* delta, | |
770 | THStack* nchs, | |
771 | THStack* prims, | |
772 | THStack* rings, | |
773 | TH1* dndeta, | |
774 | TVirtualPad* can, | |
775 | Int_t step) | |
776 | { | |
777 | THStack* all = 0; | |
778 | if (step < 6) { | |
779 | all = new THStack; | |
780 | if (step != 1) AddToAll(all, delta, step, 1); | |
781 | if (step != 2) AddToAll(all, nchs, step, 2); | |
782 | if (step != 3) AddToAll(all, prims, step, 3); | |
783 | if (step != 4) AddToAll(all, rings, step, 4); | |
784 | TH1* res = static_cast<TH1*>(dndeta->Clone("dNdeta")); | |
785 | res->SetTitle("dN/d#eta"); | |
786 | res->SetMarkerColor(step == 5 ? kBlack : kGray); | |
787 | res->SetLineColor(step == 5 ? kBlack : kGray); | |
788 | res->SetDirectory(0); | |
789 | all->Add(res); | |
790 | if (step == 1) AddToAll(all, delta, step, 1); | |
791 | if (step == 2) AddToAll(all, nchs, step, 2); | |
792 | if (step == 3) AddToAll(all, prims, step, 3); | |
793 | if (step == 4) AddToAll(all, rings, step, 4); | |
794 | } | |
795 | ||
796 | TVirtualPad* p = can->cd(step); | |
797 | p->SetFillColor(kWhite); | |
798 | p->SetRightMargin(0.02); | |
799 | p->SetTopMargin(0.02); | |
800 | ||
801 | if (all) { | |
802 | all->Draw("nostack"); | |
803 | all->GetHistogram()->SetXTitle("#eta"); | |
804 | all->GetHistogram()->SetYTitle("signal"); | |
805 | // all->GetHistogram()->GetXaxis()->SetLabelFont(132); | |
806 | // all->GetHistogram()->GetXaxis()->SetTitleFont(132); | |
807 | // all->GetHistogram()->GetYaxis()->SetLabelFont(132); | |
808 | // all->GetHistogram()->GetYaxis()->SetTitleFont(132); | |
809 | } | |
810 | ||
811 | TLegend* l = 0; | |
812 | if (step < 6) | |
813 | l = new TLegend(.33, .2, .53, .9); | |
814 | else | |
815 | l = new TLegend(0.1, 0.1, .9, .9); | |
816 | l->SetFillColor(kWhite); | |
817 | l->SetFillStyle(0); | |
818 | l->SetBorderSize(0); | |
819 | TLegendEntry* e = 0; | |
820 | ||
821 | TIter next(delta->GetHists()); | |
822 | TH1* h = 0; | |
823 | if (step == 6) { | |
824 | while ((h = static_cast<TH1*>(next()))) { | |
825 | e = l->AddEntry("dummy", h->GetTitle(), "pl"); | |
826 | e->SetMarkerStyle(20); | |
827 | e->SetMarkerColor(h->GetMarkerColor()); | |
828 | } | |
829 | } | |
830 | else { | |
831 | h = static_cast<TH1*>(delta->GetHists()->At(0)); | |
832 | e = l->AddEntry("dummy", delta->GetTitle(), "pl"); | |
833 | e->SetMarkerStyle(h->GetMarkerStyle()); | |
834 | e->SetMarkerColor(step != 1 ? kGray : kBlack); | |
835 | e->SetLineColor(e->GetMarkerColor()); | |
836 | ||
837 | h = static_cast<TH1*>(nchs->GetHists()->At(0)); | |
838 | e = l->AddEntry("dummy", nchs->GetTitle(), "pl"); | |
839 | e->SetMarkerStyle(h->GetMarkerStyle()); | |
840 | e->SetMarkerColor(step != 2 ? kGray : kBlack); | |
841 | e->SetLineColor(e->GetMarkerColor()); | |
842 | ||
843 | h = static_cast<TH1*>(prims->GetHists()->At(0)); | |
844 | e = l->AddEntry("dummy", prims->GetTitle(), "pl"); | |
845 | e->SetMarkerStyle(h->GetMarkerStyle()); | |
846 | e->SetMarkerColor(step != 3 ? kGray : kBlack); | |
847 | e->SetLineColor(e->GetMarkerColor()); | |
848 | ||
849 | h = static_cast<TH1*>(rings->GetHists()->At(0)); | |
850 | e = l->AddEntry("dummy", rings->GetTitle(), "pl"); | |
851 | e->SetMarkerStyle(h->GetMarkerStyle()); | |
852 | e->SetMarkerColor(step != 4 ? kGray : kBlack); | |
853 | e->SetLineColor(e->GetMarkerColor()); | |
854 | ||
855 | h = res; | |
856 | e = l->AddEntry("dummy", h->GetTitle(), "pl"); | |
857 | e->SetMarkerStyle(h->GetMarkerStyle()); | |
858 | e->SetMarkerColor(step != 5 ? kGray : kBlack); | |
859 | e->SetLineColor(e->GetMarkerColor()); | |
860 | } | |
861 | ||
862 | l->Draw("nostack"); | |
863 | ||
864 | TString what; | |
865 | if (step > 0) { | |
866 | switch (step) { | |
867 | case 1: | |
868 | what = "After merging"; | |
869 | break; | |
870 | case 2: | |
871 | what = "After particle counting"; | |
872 | break; | |
873 | case 3: | |
874 | what = "After corrections"; | |
875 | break; | |
876 | case 4: | |
877 | what = "After normalisation"; | |
878 | break; | |
879 | case 5: | |
880 | what = "Result"; | |
881 | break; | |
882 | case 6: | |
883 | break; | |
884 | default: | |
885 | Error("DrawStep", "Unknown step: %d (must be in 1-4)"); | |
886 | break; | |
887 | } | |
888 | } | |
889 | TLatex* ltx = new TLatex(.97, .97, what); | |
890 | ltx->SetNDC(); | |
891 | ltx->SetTextSize(.06); | |
892 | ltx->SetTextAlign(33); | |
893 | // ltx->SetTextFont(132); | |
894 | ltx->Draw(); | |
895 | ||
896 | if (step < 6) | |
897 | ltx->DrawLatex(.32, .97, Form("Step %d", step)); | |
898 | ||
899 | ||
900 | } | |
901 | ||
902 | //____________________________________________________________________ | |
903 | void FixStack(THStack* stack, const TString& title, Int_t marker) | |
904 | { | |
905 | if (!stack) return; | |
906 | stack->SetTitle(title); | |
907 | TIter next(stack->GetHists()); | |
908 | TH1* h = 0; | |
909 | while ((h = static_cast<TH1*>(next()))) h->SetMarkerStyle(marker); | |
910 | } | |
911 | //____________________________________________________________________ | |
912 | void AddToAll(THStack* all, const THStack* stack, Int_t curr, Int_t step) | |
913 | { | |
914 | if (!stack) return; | |
915 | ||
916 | TIter next(stack->GetHists()); | |
917 | TH1* h = 0; | |
918 | while ((h = static_cast<TH1*>(next()))) { | |
919 | TH1* copy = static_cast<TH1*>(h->Clone(Form("%s_copy", h->GetName()))); | |
920 | copy->SetDirectory(0); | |
921 | if (curr != step) { | |
922 | copy->SetMarkerColor(kGray); | |
923 | copy->SetLineColor(kGray); | |
924 | } | |
925 | all->Add(copy); | |
926 | } | |
927 | } | |
928 | //____________________________________________________________________ | |
929 | void DrawSteps(const TCollection* forward, TCanvas* can) | |
930 | { | |
931 | // MakeChapter(can, "Steps"); | |
932 | ||
933 | THStack* deltas = GetStack(GetCollection(forward, "fmdSharingFilter"), | |
934 | "sums", "summed"); | |
935 | THStack* nchs = GetStack(GetCollection(forward, "fmdDensityCalculator"), | |
936 | "sums", "inclDensity"); | |
937 | THStack* prims = GetStack(GetCollection(forward, "fmdCorrector"), | |
938 | "sums", "primaryDensity"); | |
939 | THStack* rings = GetStack(GetCollection(forward, "ringResults"), "all"); | |
940 | TH1* dndeta = GetH1(forward, "dNdeta"); | |
941 | ||
942 | FixStack(deltas, "#sum_{} #Delta/#Delta_{mip}", 25); | |
943 | FixStack(nchs, "#sum_{} N_{ch,incl}", 21); | |
944 | FixStack(prims, "#sum_{} N_{ch,primary}", 22); | |
945 | FixStack(rings, "dN/d#eta per ring", 23); | |
946 | ||
947 | TVirtualPad* body = can->cd(2); | |
948 | body->Divide(2,3); | |
949 | for (Int_t step = 1; step <= 6; step++) { | |
950 | DrawStep(deltas, nchs, prims, rings, dndeta, body, step); | |
951 | } | |
952 | PrintCanvas(can, "Steps"); | |
953 | } | |
954 | ||
955 | ||
956 | //____________________________________________________________________ | |
957 | void DrawResults(const TCollection* forward, TCanvas* can) | |
958 | { | |
959 | // MakeChapter(can, "Results"); | |
960 | ||
961 | TVirtualPad* body = can->cd(2); | |
962 | body->Divide(2,3); | |
963 | ||
964 | TCollection* c = GetCollection(forward, "ringResults"); | |
965 | if (!c) return; | |
966 | ||
967 | DrawInPad(body, 1, GetStack(c, "all"), "nostack"); | |
968 | DrawInPad(body, 2, GetH1(forward, "dNdeta")); | |
969 | DrawInPad(body, 3, GetH1(forward, "dNdeta_")); | |
970 | DrawInPad(body, 4, GetH1(forward, "norm")); | |
971 | DrawInPad(body, 4, GetH1(forward, "phi"), "same", 0x10); | |
972 | DrawInPad(body, 5, GetH1(forward, "d2Ndetadphi"), "colz"); | |
973 | ||
974 | PrintCanvas(can, "Results"); | |
975 | } | |
976 | ||
977 | ||
978 | //____________________________________________________________________ | |
979 | void DrawAODSummary(const TString& filename="forward.root") | |
980 | { | |
981 | // --- Open the file ----------------------------------------------- | |
982 | TFile* file = TFile::Open(filename.Data(), "READ"); | |
983 | if (!file) { | |
984 | Error("DrawAODSummary", "Failed to open \"%s\"", filename.Data()); | |
985 | return; | |
986 | } | |
987 | ||
988 | // --- Get top-level collection ------------------------------------ | |
989 | TCollection* forward = GetCollection(file, "Forward"); | |
990 | if (!forward) return; | |
991 | ||
992 | // --- Make our canvas --------------------------------------------- | |
993 | TString pdfName(filename); | |
994 | pdfName.ReplaceAll(".root", ".pdf"); | |
995 | ||
996 | TCanvas* c = CreateCanvas(pdfName); | |
997 | ||
998 | // --- Do each sub-algorithm --------------------------------------- | |
999 | DrawEventInspector(forward,c); | |
1000 | DrawSharingFilter(forward,c); | |
1001 | DrawDensityCalculator(forward, c); | |
1002 | DrawCorrector(forward, c); | |
1003 | DrawHistCollector(forward, c); | |
1004 | ||
1005 | // --- Do the results ---------------------------------------------- | |
1006 | DrawSteps(forward, c); | |
1007 | DrawResults(forward, c); | |
1008 | ||
1009 | CloseCanvas(c); | |
1010 | } | |
1011 | ||
1012 | ||
1013 |