]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGLF/FORWARD/analysis2/DrawdNdetaSummary.C
Renamed some member functions for more logical names
[u/mrichter/AliRoot.git] / PWGLF / FORWARD / analysis2 / DrawdNdetaSummary.C
CommitLineData
9869e55c 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#ifndef __CINT__
11# include <TCollection.h>
12# include <TH1.h>
13# include <TH2.h>
14# include <THStack.h>
15# include <TParameter.h>
16# include <TFile.h>
17# include <TCanvas.h>
18# include <TStyle.h>
19# include <TError.h>
20# include <TLegend.h>
21# include <TLatex.h>
22# include <TLegendEntry.h>
23# include <TPaveText.h>
24# include <TMath.h>
25# include <TSystem.h>
26#else
27class TCollection;
28class TDirectory;
29class TH1;
30class TH2;
31class THStack;
32class TCanvas;
33class TLatex;
34class TVirtualPad;
35class TLegend;
36class TAxis;
37#endif
38
39//____________________________________________________________________
40/**
41 * Find an object in a collection
42 *
43 * @param parent Parent list
44 * @param name Name of object
45 *
46 * @return Pointer to object or null
47 */
48TObject* GetObject(const TCollection* parent, const TString& name)
49{
50 // Info("GetObject", "Getting object %s from %p", name.Data(), parent);
51 // --- Check parent ------------------------------------------------
52 if (!parent) {
53 Warning("GetObject", "No parent list");
54 return 0;
55 }
56 // --- Check name --------------------------------------------------
57 if (name.IsNull()) {
58 Warning("GetObject", "No name specified");
59 return 0;
60 }
61 // --- Find the object ---------------------------------------------
62 TObject* o = parent->FindObject(name);
63 if (!o) {
64 Warning("GetObject", "Object \"%s\" not found in parent \"%s\"",
65 name.Data(), parent->GetName());
66 return 0;
67 }
68 return o;
69}
70//____________________________________________________________________
71/**
72 * Find an object in a directory
73 *
74 * @param parent Parent directory
75 * @param name Name of object
76 *
77 * @return Pointer to object or null
78 */
79TObject* GetObject(TDirectory* parent, const TString& name)
80{
81 // Info("GetObject", "Getting object %s from %p", name.Data(), parent);
82 // --- Check parent ------------------------------------------------
83 if (!parent) {
84 Warning("GetObject", "No parent directory");
85 return 0;
86 }
87 // --- Check name --------------------------------------------------
88 if (name.IsNull()) {
89 Warning("GetObject", "No name specified");
90 return 0;
91 }
92 // --- Find the object ---------------------------------------------
93 TObject* o = parent->Get(name);
94 if (!o) {
95 Warning("GetObject", "Object \"%s\" not found in parent \"%s\"",
96 name.Data(), parent->GetName());
97 return 0;
98 }
99 return o;
100}
101
102//____________________________________________________________________
103/**
104 * Check the type of a found object
105 *
106 * @param o Object
107 * @param cl Class
108 * @param src Source of object
109 *
110 * @return true on success, false otherwise
111 */
112Bool_t CheckType(const TObject* o, const TClass* cl, const TString& src)
113{
114 // Info("CheckType", "Checking type of %s vs %s", o->GetName(), cl->GetName());
115 if (!o->IsA()->InheritsFrom(cl)) {
116 Warning("CheckType", "Object \"%s\" retrieved from \"%s\" is not a "
117 "%s but a %s", o->GetName(), src.Data(), cl->GetName(),
118 o->ClassName());
119 return false;
120 }
121 return true;
122}
123
124//_____________________________________________________________________
125void GetParameter(const TCollection* c, const TString& name, UShort_t& value)
126{
127 // Info("GetParameter", "Getting parameter of %s from %p", name.Data(), c);
128 TObject* o = GetObject(c, name);
129 if (!o) return;
130 value = o->GetUniqueID();
131}
132//_____________________________________________________________________
133void GetParameter(const TCollection* c, const TString& name, Int_t& value)
134{
135 // Info("GetParameter", "Getting parameter of %s from %p", name.Data(), c);
136 TObject* o = GetObject(c, name);
137 if (!o) return;
138 value = o->GetUniqueID();
139}
140//_____________________________________________________________________
141void GetParameter(const TCollection* c, const TString& name, Double_t& value)
142{
143 // Info("GetParameter", "Getting parameter of %s from %p", name.Data(), c);
144 TObject* o = GetObject(c, name);
145 if (!o) return;
146 UInt_t i = o->GetUniqueID();
147 Float_t v = *reinterpret_cast<Float_t*>(&i);
148 value = v;
149}
150//_____________________________________________________________________
151void GetParameter(const TCollection* c, const TString& name, Bool_t& value)
152{
153 // Info("GetParameter", "Getting parameter of %s from %p", name.Data(), c);
154 TObject* o = GetObject(c, name);
155 if (!o) return;
156 value = o->GetUniqueID();
157}
158
159//____________________________________________________________________
160/**
161 * Find a collection in another collection
162 *
163 * @param parent Parent collection
164 * @param name Name of the collection
165 *
166 * @return pointer to collection on success, otherwise null
167 */
168TCollection* GetCollection(const TCollection* parent, const TString& name)
169{
170 // Info("GetCollection", "Getting collection of %s from %p", name.Data(), c);
171 // --- Find the object ---------------------------------------------
172 TObject* o = GetObject(parent, name);
173 if (!o) return 0;
174
175 // --- Check type of found object ----------------------------------
176 if (!CheckType(o, TCollection::Class(), parent->GetName())) return 0;
177
178 // --- Return the collection ---------------------------------------
179 return static_cast<TCollection*>(o);
180}
181
182//____________________________________________________________________
183/**
184 * Find a collection in a directory
185 *
186 * @param parent Parent directory
187 * @param name Name of the collection
188 *
189 * @return pointer to collection on success, otherwise null
190 */
191TCollection* GetCollection(TDirectory* parent, const TString& name)
192{
193 // Info("GetCollection", "Getting collection of %s from %p",
194 // name.Data(), parent);
195 // --- Find the object ---------------------------------------------
196 TObject* o = GetObject(parent, name);
197 if (!o) return 0;
198
199 // --- Check the type of object ------------------------------------
200 if (!CheckType(o, TCollection::Class(), parent->GetName())) return 0;
201
202 // --- Return the collection ---------------------------------------
203 return static_cast<TCollection*>(o);
204}
205
206//____________________________________________________________________
207/**
208 * Get a 1D histogram from a collection
209 *
210 * @param parent Parent collection
211 * @param name Name of histogram
212 *
213 * @return pointer or null
214 */
215TH1* GetH1(const TCollection* parent, const TString& name)
216{
217 // Info("GetH1", "Getting 1D histogram of %s from %p", name.Data(), c);
218 // --- Find the object ---------------------------------------------
219 TObject* o = GetObject(parent, name);
220 if (!o) return 0;
221
222 // --- Check the type of object ------------------------------------
223 if (!CheckType(o, TH1::Class(), parent->GetName())) return 0;
224
225 // --- Return the collection ---------------------------------------
226 return static_cast<TH1*>(o);
227}
228//____________________________________________________________________
229/**
230 * Get a 2D histogram from a collection
231 *
232 * @param parent Parent collection
233 * @param name Name of histogram
234 *
235 * @return pointer or null
236 */
237TH2* GetH2(const TCollection* parent, const TString& name)
238{
239 // Info("GetH2", "Getting 2D histogram of %s from %p", name.Data(), c);
240 // --- Find the object ---------------------------------------------
241 TObject* o = GetObject(parent, name);
242 if (!o) return 0;
243
244 // --- Check the type of object ------------------------------------
245 if (!CheckType(o, TH2::Class(), parent->GetName())) return 0;
246
247 // --- Return the collection ---------------------------------------
248 return static_cast<TH2*>(o);
249}
250//____________________________________________________________________
251/**
252 * Get a histogram stack from a collection
253 *
254 * @param parent Parent collection
255 * @param name Name of histogram
256 *
257 * @return pointer or null
258 */
259THStack* GetStack(const TCollection* parent, const TString& name,
260 const char* sub=0)
261{
262 // Info("GetStack", "Getting histogram stack %s from %p", name.Data(), parent);
263 // --- Find the object ---------------------------------------------
264 TObject* o = GetObject(parent, name);
265 if (!o) return 0;
266
267 // --- Check the type of object ------------------------------------
268 if (!CheckType(o, THStack::Class(), parent->GetName())) return 0;
269
270 THStack* stack = static_cast<THStack*>(o);
271 if (sub == 0) return stack;
272
273 if (stack->GetHists()->GetEntries() <= 0 ||stack->GetMaximum() < 1) {
274 stack->GetHists()->Delete();
275 const char* subs[] = { "FMD1I", "FMD2I", "FMD2O", "FMD3O", "FMD3I", 0 };
276 const char** ptr = subs;
277 while (*ptr) {
278 TCollection* sc = GetCollection(parent, *ptr);
279 if (!sc) { ptr++; continue; }
280
281 TH2* h = GetH2(sc, sub);
282 if (!h) continue;
283 TH1* p = h->ProjectionX(*ptr, 1, h->GetNbinsY(), "e");
284 p->Scale(1., "width");
285 p->SetTitle(*ptr);
286 p->SetDirectory(0);
287 stack->Add(p);
288 ptr++;
289 }
290 }
291 // --- Return the collection ---------------------------------------
292 return stack;
293}
294
295//____________________________________________________________________
296void Pause()
297{
298 printf("Press enter to continue");
299 std::cin.get();
300}
301
302//____________________________________________________________________
303/**
304 * Clear canvas
305 *
306 * @param c Canvas to clear
307 *
308 * @ingroup pwglf_forward_scripts_corr
309 */
310void
311ClearCanvas(TCanvas* c)
312{
313 // Info("ClearCanvas", "Clearing canvas");
314 c->SetLeftMargin(.1);
315 c->SetRightMargin(.05);
316 c->SetBottomMargin(.1);
317 c->SetTopMargin(.05);
318 c->Clear();
319
320 Float_t dy = .05;
321 TPad* p1 = new TPad("top", "Top", 0, 1-dy, 1, 1, 0, 0);
322 p1->SetNumber(1);
323 p1->SetFillColor(kBlue-5);
324 p1->SetBorderSize(0);
325 p1->SetBorderMode(0);
326 c->cd();
327 p1->Draw();
328
329 TPad* p2 = new TPad("body", "Body", 0, 0, 1, 1-dy, 0, 0);
330 p2->SetNumber(2);
331 p2->SetFillColor(0);
332 p2->SetFillStyle(0);
333 p2->SetBorderSize(0);
334 p2->SetBorderMode(0);
5934a3e3 335 p2->SetRightMargin(0.02);
336 p2->SetTopMargin(0.02);
9869e55c 337 c->cd();
338 p2->Draw();
339 p2->cd();
340
341}
342//____________________________________________________________________
343/**
344 * Create a canvas
345 *
346 * @param pname Name of PDF file to make
347 *
348 * @return Created canvas
349 */
350TCanvas* CreateCanvas(const TString& pname)
351{
352 // Info("CreateCanvas", "Creating canvas");
353 Int_t size = 1000;
354 TCanvas* c = new TCanvas("c", pname.Data(), size / TMath::Sqrt(2), size);
355 c->SetFillColor(0);
356 c->SetBorderSize(0);
357 c->SetBorderMode(0);
358 c->Print(Form("%s[", pname.Data()));
359
360 gStyle->SetOptStat(0);
361 gStyle->SetTitleColor(0);
362 gStyle->SetTitleStyle(0);
363 gStyle->SetTitleBorderSize(0);
364 gStyle->SetTitleX(.5);
365 gStyle->SetTitleY(1);
366 gStyle->SetTitleW(.8);
367 gStyle->SetTitleH(.09);
368 gStyle->SetFrameFillColor(kWhite);
369 gStyle->SetFrameBorderSize(1);
370 gStyle->SetFrameBorderMode(1);
371 gStyle->SetPalette(1);
372
373 ClearCanvas(c);
374
375 return c;
376}
377
378//____________________________________________________________________
379/**
380 * Close the PDF
381 *
382 * @param c Canvas
383 */
384void CloseCanvas(TCanvas* c)
385{
386 // Info("CloseCanvas", "Closing canvas");
387 ClearCanvas(c);
388 c->Print(Form("%s]", c->GetTitle()));
389}
390
391//____________________________________________________________________
392/**
393 * Print the canvas
394 *
395 * @param c Canvas
396 * @param title Title
397 */
398void PrintCanvas(TCanvas* c, const TString& title,
399 Float_t size=.7, Bool_t pause=false)
400{
401 // Info("PrintCanvas", "Printing page %s", title.Data());
402 TString tit;
403 tit.Form("Title:%s", title.Data());
404
405 c->cd(1);
406 TLatex* ltx = new TLatex(.5, .5, title);
407 ltx->SetNDC();
408 ltx->SetTextAlign(22);
409 ltx->SetTextSize(size);
410 ltx->SetTextColor(kWhite);
411 ltx->SetTextFont(62);
412 ltx->Draw();
413
414 c->Modified();
415 c->Update();
416 c->cd();
417 gSystem->RedirectOutput("/dev/null");
418 c->Print(c->GetTitle(), tit);
419 gSystem->RedirectOutput(0);
420
421 // std::cin.peek();
422 if (pause) Pause();
423
424 ClearCanvas(c);
425}
426//____________________________________________________________________
427/**
428 * Make a chapter page
429 *
430 * @param c Canvas
431 * @param title Title
432 */
433void MakeChapter(TCanvas* c, const TString& title)
434{
435 c->cd(2);
436
437 // Info("MakeChapter", "Making chapter %s", title.Data());
438 TLatex* ltx = new TLatex(.5, .5, title);
439 ltx->SetNDC();
440 ltx->SetTextAlign(22);
441 ltx->Draw();
442
443 PrintCanvas(c, title);
444}
445//____________________________________________________________________
446void DrawInPad(TVirtualPad* c, Int_t padNo, TObject* h, Option_t* opts="",
447 UShort_t flags=0x0)
448{
449 // Info("DrawInPad", "Drawing %p in pad # %d of %p w/options %s, flags 0x%x",
450 // h, padNo, c, opts, flags);
451 TVirtualPad* p = c->cd(padNo);
452 if (!p) {
453 Warning("DrawInPad", "Pad # %d not found in %s", padNo, c->GetName());
454 return;
455 }
456 if (flags & 0x1) p->SetLogx();
457 if (flags & 0x2) p->SetLogy();
458 if (flags & 0x4) p->SetLogz();
459 p->SetFillColor(0);
460 TString o(opts);
461 if (o.Contains("colz", TString::kIgnoreCase))
462 p->SetRightMargin(0.15);
463 if (o.Contains("text", TString::kIgnoreCase)) {
464 TH1* hh = static_cast<TH1*>(h);
465 hh->SetMaximum(1.1*hh->GetMaximum());
466 hh->SetMarkerSize(2);
467 o.Append("30");
468 }
469
470 if (!h) {
471 Warning("DrawInPad", "Nothing to draw in pad # %d", padNo);
472 return;
473 }
474 h->Draw(o);
475
476 if (flags& 0x10) {
477 TLegend* l = p->BuildLegend();
478 l->SetFillColor(0);
479 l->SetFillStyle(0);
480 l->SetBorderSize(0);
481 }
482 p->Modified();
483 p->Update();
484 p->cd();
485}
486//____________________________________________________________________
487void CreateTemplates(TLatex*& name, TLatex*& value, Float_t size=.03)
488{
489 Double_t x1 = .1;
490 Double_t x2 = .6;
491 Double_t y = .8;
492 name = new TLatex(x1, y, "");
493 name->SetTextAlign(13);
494 name->SetNDC();
495 name->SetTextSize(size);
496
497 value = new TLatex(x2, y, "");
498 value->SetTextAlign(13);
499 value->SetNDC();
500 value->SetTextSize(size);
501}
502
503//____________________________________________________________________
504void DrawParameter(TLatex* name, TLatex* value, Double_t& y,
505 const TString& sName, const TString& sValue)
506{
507 if (sName.IsNull() && sValue.IsNull()) return;
508 if (!sName.IsNull())
509 name->DrawLatex(name->GetX(), y, Form("%s:", sName.Data()));
510 if (!sValue.IsNull())
511 value->DrawLatex(value->GetX(), y, sValue.Data());
512 y -= name->GetTextSize() + .02;
513}
514
515
516//____________________________________________________________________
517void DrawCentSum(const TCollection* sums, TCanvas* can, const TString& base,
518 Int_t cLow, Int_t cHigh)
519{
520 TString folder;
521 if (cLow < 0 || cHigh < 0 || cLow >= cHigh) {
522 folder = "all";
523 cHigh *= -1;
524 }
525 else folder.Form("cent%03d_%03d", cLow, cHigh);
526
527 TCollection* c = GetCollection(sums, folder);
528 if (!c) return;
529
530 TVirtualPad* body = can->cd(2);
531 body->Divide(2, 2);
532
533 DrawInPad(body, 1, GetH1(c, "triggers"), "HIST TEXT");
534 DrawInPad(body, 2, GetH1(c, Form("%sEvents",base.Data())), "HIST TEXT");
535 DrawInPad(body, 3, GetH2(c, base.Data()), "colz");
536 DrawInPad(body, 4, GetH2(c, Form("%s0", base.Data())), "colz");
537
538 PrintCanvas(can, Form("%s sums: %3d%% - %3d%%", base.Data(), cLow, cHigh));
539}
540
541//____________________________________________________________________
542void DrawSums(TDirectory* top, const TString& base, TCanvas* can, bool onlyMB)
543{
544 TCollection* c = GetCollection(top, Form("%sSums", base.Data()));
545 if (!c) return;
546
547 TAxis* centAxis = static_cast<TAxis*>(GetObject(c, "centAxis"));
548
549 TVirtualPad* body = can->cd(2);
550 body->Divide(1, 2);
551
552 body->cd(1);
553 TLatex* name;
554 TLatex* value;
555 Double_t y = .8;
556 CreateTemplates(name, value);
557 for (Int_t i = 1; i <= centAxis->GetNbins(); i++) {
558 DrawParameter(name, value, y, (i == 1 ? "Centrality classes" : ""),
559 Form("%3d%% - %3d%%",
560 Int_t(centAxis->GetBinLowEdge(i)),
561 Int_t(centAxis->GetBinUpEdge(i))));
562 }
563 Int_t sys, sNN, scheme, trigger;
564 GetParameter(c, "sNN", sNN);
565 GetParameter(c, "sys", sys);
566 GetParameter(c, "scheme", scheme);
567 GetParameter(c, "trigger", trigger);
568 DrawParameter(name, value, y, "Collision system",
569 (sys == 1 ? "pp" : (sys == 2 ? "PbPb" : (sys == 3 ? "pPb" :
570 "unknown"))));
571 DrawParameter(name, value, y, "#sqrt{s_{NN}}", Form("%4dGeV", sNN));
572 DrawParameter(name, value, y, "Normalization scheme", Form("0x%x", scheme));
573 DrawParameter(name, value, y, "Triggers", Form("0x%x", trigger));
574
575 DrawInPad(body, 2, GetH1(c, "cent"));
576
577 PrintCanvas(can, Form("%s sums", base.Data()));
578
579 DrawCentSum(c, can, base, centAxis->GetXmin(), -centAxis->GetXmax());
580 if (onlyMB) return;
581
582 for (Int_t i = 1; i <= centAxis->GetNbins(); i++)
583 DrawCentSum(c, can, base, centAxis->GetBinLowEdge(i),
584 centAxis->GetBinUpEdge(i));
585}
586
587//____________________________________________________________________
5934a3e3 588THStack* CleanStack(const THStack* stack, TLegend* l, const TAxis* axis)
9869e55c 589{
5934a3e3 590 THStack* ret = new THStack(stack->GetName(), stack->GetTitle());
591 TList* hists = stack->GetHists();
592 TIter next(hists);
593 TH1* h = 0;
594 Int_t j = 0;
595 while ((h = static_cast<TH1*>(next()))) {
596 TString name(h->GetName());
597 if (name.Contains("_mirror")) continue;
598 if (l) {
599 j++;
600 name.Form("%3d%% - %3d%%",
601 Int_t(axis->GetBinLowEdge(j)),
602 Int_t(axis->GetBinUpEdge(j)));
603 TLegendEntry* e = l->AddEntry("dummy", name, "f");
604 e->SetFillStyle(1001);
605 e->SetFillColor(h->GetMarkerColor());
606 }
607 ret->Add(h);
608 }
609 return ret;
610#if 0
611 // There's no dictinary for TObjLink
9869e55c 612 TObjLink* lnk = hists->FirstLink();
613 Int_t j = 0;
614 while (lnk) {
615 TH1* h = static_cast<TH1*>(lnk->GetObject());
616 bool remove = false;
617 TString name(h->GetName());
618 if (name.Contains("_mirror")) {
619 // AliWarning(Form("No entries in %s - removing", h->GetName()));
620 remove = true;
621 }
622 else if (l) {
623 j++;
624 name.Form("%3d%% - %3d%%",
625 Int_t(axis->GetBinLowEdge(j)),
626 Int_t(axis->GetBinUpEdge(j)));
627 TLegendEntry* e = l->AddEntry("dummy", name, "f");
628 e->SetFillStyle(1001);
629 e->SetFillColor(h->GetMarkerColor());
630 }
631 if (remove) {
632 TObjLink* keep = lnk->Next();
633 hists->Remove(lnk);
634 lnk = keep;
635 continue;
636 }
637 lnk = lnk->Next();
638 }
5934a3e3 639#endif
9869e55c 640}
641
642//____________________________________________________________________
643void DrawCentRes(const TCollection* sums, TCanvas* can, const TString& base,
644 Int_t cLow, Int_t cHigh)
645{
646 TString folder;
647 if (cLow < 0 || cHigh < 0 || cLow >= cHigh) {
648 folder = "all";
649 cHigh *= -1;
650 }
651 else folder.Form("cent%03d_%03d", cLow, cHigh);
652
653 TCollection* c = GetCollection(sums, folder);
654 if (!c) return;
655
656 TVirtualPad* body = can->cd(2);
5934a3e3 657 body->Divide(2, 3, 0.05, 0);
9869e55c 658
5934a3e3 659 Int_t trP = 1;
660 TVirtualPad* p = body->GetPad(trP);
661 p->SetBottomMargin(0.15);
662 p->SetLeftMargin(0.15);
663 if (trP > 2) p->SetTopMargin(0.05);
664
665 DrawInPad(body, trP, GetH1(c, "triggers"), "HIST TEXT");
666 DrawInPad(body, 2, GetH1(c, Form("norm%s",base.Data())));
667 DrawInPad(body, 4, GetH1(c, Form("dndeta%s",base.Data())));
668 DrawInPad(body, 6, GetH1(c, Form("dndeta%s_rebin05",base.Data())));
9869e55c 669 DrawInPad(body, 5, GetH2(c, Form("d2Ndetadphi%s", base.Data())),"colz");
670
5934a3e3 671 body->GetPad(2)->SetGridx(); body->GetPad(2)->SetLeftMargin(0.15);
672 body->GetPad(4)->SetGridx(); body->GetPad(4)->SetLeftMargin(0.15);
673 body->GetPad(6)->SetGridx(); body->GetPad(6)->SetLeftMargin(0.15);
674
9869e55c 675 TObject* normCalc = GetObject(c, "normCalc");
676 TString calc = normCalc->GetTitle();
677 TObjArray* lines = calc.Tokenize("\n");
678 TPaveText* disp = new TPaveText(.1,.1,.9,.9, "NDC");
679 TIter next(lines);
680 TObject* line = 0;
681 while ((line = next()))
682 disp->AddText(line->GetName());
683 disp->SetBorderSize(0);
684 disp->SetBorderSize(0);
685 disp->SetFillStyle(0);
5934a3e3 686 DrawInPad(body, 3, disp);
9869e55c 687
688 PrintCanvas(can, Form("%s result: %3d%% - %3d%%", base.Data(), cLow, cHigh));
689}
690
691//____________________________________________________________________
692THStack*
693DrawRes(TDirectory* top, const TString& base, TCanvas* can, Bool_t onlyMB)
694{
695 TCollection* c = GetCollection(top, Form("%sResults", base.Data()));
696 if (!c) return 0;
697
698 TAxis* centAxis = static_cast<TAxis*>(GetObject(c, "centAxis"));
699
700 can->cd(2);
701
702 TLatex* name;
703 TLatex* value;
704 Double_t y = .9;
705 CreateTemplates(name, value, .02);
706 for (Int_t i = 1; i <= centAxis->GetNbins(); i++) {
707 DrawParameter(name, value, y, (i == 1 ? "Centrality classes" : ""),
708 Form("%3d%% - %3d%%",
709 Int_t(centAxis->GetBinLowEdge(i)),
710 Int_t(centAxis->GetBinUpEdge(i))));
711 }
712
713 DrawParameter(name, value, y, "Collision system",
714 GetObject(c, "sys")->GetTitle());
715 DrawParameter(name, value, y, "#sqrt{s_{NN}}",GetObject(c,"sNN")->GetTitle());
716 DrawParameter(name, value, y, "trigger",GetObject(c,"trigger")->GetTitle());
717 DrawParameter(name, value, y, "scheme", GetObject(c,"scheme")->GetTitle());
718
719 Double_t epsT, epsT0;
720 GetParameter(c, "triggerEff", epsT);
721 GetParameter(c, "triggerEff0", epsT0);
722 DrawParameter(name, value, y, "#epsilon_{T}", Form("%f", epsT));
723 DrawParameter(name, value, y, "#epsilon_{T,zero bin}", Form("%f", epsT0));
724
725 PrintCanvas(can, Form("%s results", base.Data()));
726
727 TVirtualPad* body = can->cd(2);
5934a3e3 728 body->Divide(1, 3, 0, 0);
9869e55c 729
730 TLegend* l = new TLegend(0.1, 0.1, 0.9, 0.9, "Centralities");
731 l->SetNColumns(2);
732 l->SetFillStyle(0);
733 l->SetBorderSize(0);
5934a3e3 734 THStack* dndeta_ = GetStack(c, "dndeta");
735 THStack* dndeta = CleanStack(dndeta_, l, centAxis);
736 THStack* dndeta5_ = GetStack(c, "dndeta_rebin05");
737 THStack* dndeta5 = CleanStack(dndeta5_, 0, 0);
738
739 DrawInPad(body, 1, l, "");
740 DrawInPad(body, 2, dndeta, "nostack");
741 DrawInPad(body, 3, dndeta5, "nostack");
742 body->GetPad(2)->SetGridx();
743 body->GetPad(3)->SetGridx();
9869e55c 744
745 PrintCanvas(can, Form("%s results - stacks", base.Data()));
746
747 DrawCentRes(c, can, base, centAxis->GetXmin(), -centAxis->GetXmax());
748 if (onlyMB) return dndeta;
749
750 for (Int_t i = 1; i <= centAxis->GetNbins(); i++)
751 DrawCentRes(c, can, base, centAxis->GetBinLowEdge(i),
752 centAxis->GetBinUpEdge(i));
753
754 return dndeta;
755}
756
757
758//____________________________________________________________________
759void DrawdNdetaSummary(const char* fname="forward_dndeta.root",
760 bool onlyMB=true)
761{
762 // --- Open the file -----------------------------------------------
763 TString filename(fname);
764 TFile* file = TFile::Open(filename.Data(), "READ");
765 if (!file) {
766 Error("DrawAODSummary", "Failed to open \"%s\"", filename.Data());
767 return;
768 }
769
770 // --- Make our canvas ---------------------------------------------
771 TString pdfName(filename);
772 pdfName.ReplaceAll(".root", ".pdf");
773
774 TCanvas* c = CreateCanvas(pdfName);
775
776 // --- Do each sub-algorithm ---------------------------------------
777 DrawSums(file, "Forward", c, onlyMB);
778 THStack* rF = DrawRes(file, "Forward", c, onlyMB);
779
780 DrawSums(file, "Central", c, onlyMB);
781 THStack* rC = DrawRes(file, "Central", c, onlyMB);
782
783 TIter next(rF->GetHists());
784 TH1* h = 0;
785 while ((h = static_cast<TH1*>(next()))) rC->Add(h);
786
787 rC->Draw("nostack");
788 PrintCanvas(c, "Both");
789
790 CloseCanvas(c);
791}
792
793
794