]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGLF/FORWARD/analysis2/DrawdNdetaSummary.C
Updated the summary generators - added one for dNdeta
[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);
335 c->cd();
336 p2->Draw();
337 p2->cd();
338
339}
340//____________________________________________________________________
341/**
342 * Create a canvas
343 *
344 * @param pname Name of PDF file to make
345 *
346 * @return Created canvas
347 */
348TCanvas* CreateCanvas(const TString& pname)
349{
350 // Info("CreateCanvas", "Creating canvas");
351 Int_t size = 1000;
352 TCanvas* c = new TCanvas("c", pname.Data(), size / TMath::Sqrt(2), size);
353 c->SetFillColor(0);
354 c->SetBorderSize(0);
355 c->SetBorderMode(0);
356 c->Print(Form("%s[", pname.Data()));
357
358 gStyle->SetOptStat(0);
359 gStyle->SetTitleColor(0);
360 gStyle->SetTitleStyle(0);
361 gStyle->SetTitleBorderSize(0);
362 gStyle->SetTitleX(.5);
363 gStyle->SetTitleY(1);
364 gStyle->SetTitleW(.8);
365 gStyle->SetTitleH(.09);
366 gStyle->SetFrameFillColor(kWhite);
367 gStyle->SetFrameBorderSize(1);
368 gStyle->SetFrameBorderMode(1);
369 gStyle->SetPalette(1);
370
371 ClearCanvas(c);
372
373 return c;
374}
375
376//____________________________________________________________________
377/**
378 * Close the PDF
379 *
380 * @param c Canvas
381 */
382void CloseCanvas(TCanvas* c)
383{
384 // Info("CloseCanvas", "Closing canvas");
385 ClearCanvas(c);
386 c->Print(Form("%s]", c->GetTitle()));
387}
388
389//____________________________________________________________________
390/**
391 * Print the canvas
392 *
393 * @param c Canvas
394 * @param title Title
395 */
396void PrintCanvas(TCanvas* c, const TString& title,
397 Float_t size=.7, Bool_t pause=false)
398{
399 // Info("PrintCanvas", "Printing page %s", title.Data());
400 TString tit;
401 tit.Form("Title:%s", title.Data());
402
403 c->cd(1);
404 TLatex* ltx = new TLatex(.5, .5, title);
405 ltx->SetNDC();
406 ltx->SetTextAlign(22);
407 ltx->SetTextSize(size);
408 ltx->SetTextColor(kWhite);
409 ltx->SetTextFont(62);
410 ltx->Draw();
411
412 c->Modified();
413 c->Update();
414 c->cd();
415 gSystem->RedirectOutput("/dev/null");
416 c->Print(c->GetTitle(), tit);
417 gSystem->RedirectOutput(0);
418
419 // std::cin.peek();
420 if (pause) Pause();
421
422 ClearCanvas(c);
423}
424//____________________________________________________________________
425/**
426 * Make a chapter page
427 *
428 * @param c Canvas
429 * @param title Title
430 */
431void MakeChapter(TCanvas* c, const TString& title)
432{
433 c->cd(2);
434
435 // Info("MakeChapter", "Making chapter %s", title.Data());
436 TLatex* ltx = new TLatex(.5, .5, title);
437 ltx->SetNDC();
438 ltx->SetTextAlign(22);
439 ltx->Draw();
440
441 PrintCanvas(c, title);
442}
443//____________________________________________________________________
444void DrawInPad(TVirtualPad* c, Int_t padNo, TObject* h, Option_t* opts="",
445 UShort_t flags=0x0)
446{
447 // Info("DrawInPad", "Drawing %p in pad # %d of %p w/options %s, flags 0x%x",
448 // h, padNo, c, opts, flags);
449 TVirtualPad* p = c->cd(padNo);
450 if (!p) {
451 Warning("DrawInPad", "Pad # %d not found in %s", padNo, c->GetName());
452 return;
453 }
454 if (flags & 0x1) p->SetLogx();
455 if (flags & 0x2) p->SetLogy();
456 if (flags & 0x4) p->SetLogz();
457 p->SetFillColor(0);
458 TString o(opts);
459 if (o.Contains("colz", TString::kIgnoreCase))
460 p->SetRightMargin(0.15);
461 if (o.Contains("text", TString::kIgnoreCase)) {
462 TH1* hh = static_cast<TH1*>(h);
463 hh->SetMaximum(1.1*hh->GetMaximum());
464 hh->SetMarkerSize(2);
465 o.Append("30");
466 }
467
468 if (!h) {
469 Warning("DrawInPad", "Nothing to draw in pad # %d", padNo);
470 return;
471 }
472 h->Draw(o);
473
474 if (flags& 0x10) {
475 TLegend* l = p->BuildLegend();
476 l->SetFillColor(0);
477 l->SetFillStyle(0);
478 l->SetBorderSize(0);
479 }
480 p->Modified();
481 p->Update();
482 p->cd();
483}
484//____________________________________________________________________
485void CreateTemplates(TLatex*& name, TLatex*& value, Float_t size=.03)
486{
487 Double_t x1 = .1;
488 Double_t x2 = .6;
489 Double_t y = .8;
490 name = new TLatex(x1, y, "");
491 name->SetTextAlign(13);
492 name->SetNDC();
493 name->SetTextSize(size);
494
495 value = new TLatex(x2, y, "");
496 value->SetTextAlign(13);
497 value->SetNDC();
498 value->SetTextSize(size);
499}
500
501//____________________________________________________________________
502void DrawParameter(TLatex* name, TLatex* value, Double_t& y,
503 const TString& sName, const TString& sValue)
504{
505 if (sName.IsNull() && sValue.IsNull()) return;
506 if (!sName.IsNull())
507 name->DrawLatex(name->GetX(), y, Form("%s:", sName.Data()));
508 if (!sValue.IsNull())
509 value->DrawLatex(value->GetX(), y, sValue.Data());
510 y -= name->GetTextSize() + .02;
511}
512
513
514//____________________________________________________________________
515void DrawCentSum(const TCollection* sums, TCanvas* can, const TString& base,
516 Int_t cLow, Int_t cHigh)
517{
518 TString folder;
519 if (cLow < 0 || cHigh < 0 || cLow >= cHigh) {
520 folder = "all";
521 cHigh *= -1;
522 }
523 else folder.Form("cent%03d_%03d", cLow, cHigh);
524
525 TCollection* c = GetCollection(sums, folder);
526 if (!c) return;
527
528 TVirtualPad* body = can->cd(2);
529 body->Divide(2, 2);
530
531 DrawInPad(body, 1, GetH1(c, "triggers"), "HIST TEXT");
532 DrawInPad(body, 2, GetH1(c, Form("%sEvents",base.Data())), "HIST TEXT");
533 DrawInPad(body, 3, GetH2(c, base.Data()), "colz");
534 DrawInPad(body, 4, GetH2(c, Form("%s0", base.Data())), "colz");
535
536 PrintCanvas(can, Form("%s sums: %3d%% - %3d%%", base.Data(), cLow, cHigh));
537}
538
539//____________________________________________________________________
540void DrawSums(TDirectory* top, const TString& base, TCanvas* can, bool onlyMB)
541{
542 TCollection* c = GetCollection(top, Form("%sSums", base.Data()));
543 if (!c) return;
544
545 TAxis* centAxis = static_cast<TAxis*>(GetObject(c, "centAxis"));
546
547 TVirtualPad* body = can->cd(2);
548 body->Divide(1, 2);
549
550 body->cd(1);
551 TLatex* name;
552 TLatex* value;
553 Double_t y = .8;
554 CreateTemplates(name, value);
555 for (Int_t i = 1; i <= centAxis->GetNbins(); i++) {
556 DrawParameter(name, value, y, (i == 1 ? "Centrality classes" : ""),
557 Form("%3d%% - %3d%%",
558 Int_t(centAxis->GetBinLowEdge(i)),
559 Int_t(centAxis->GetBinUpEdge(i))));
560 }
561 Int_t sys, sNN, scheme, trigger;
562 GetParameter(c, "sNN", sNN);
563 GetParameter(c, "sys", sys);
564 GetParameter(c, "scheme", scheme);
565 GetParameter(c, "trigger", trigger);
566 DrawParameter(name, value, y, "Collision system",
567 (sys == 1 ? "pp" : (sys == 2 ? "PbPb" : (sys == 3 ? "pPb" :
568 "unknown"))));
569 DrawParameter(name, value, y, "#sqrt{s_{NN}}", Form("%4dGeV", sNN));
570 DrawParameter(name, value, y, "Normalization scheme", Form("0x%x", scheme));
571 DrawParameter(name, value, y, "Triggers", Form("0x%x", trigger));
572
573 DrawInPad(body, 2, GetH1(c, "cent"));
574
575 PrintCanvas(can, Form("%s sums", base.Data()));
576
577 DrawCentSum(c, can, base, centAxis->GetXmin(), -centAxis->GetXmax());
578 if (onlyMB) return;
579
580 for (Int_t i = 1; i <= centAxis->GetNbins(); i++)
581 DrawCentSum(c, can, base, centAxis->GetBinLowEdge(i),
582 centAxis->GetBinUpEdge(i));
583}
584
585//____________________________________________________________________
586void CleanStack(THStack* stack, TLegend* l, const TAxis* axis)
587{
588 TList* hists = stack->GetHists();
589 // Clean up list of histogram. Histograms with no entries or
590 // no functions are deleted. We have to do this using the TObjLink
591 // objects stored in the list since ROOT cannot guaranty the validity
592 // of iterators when removing from a list - tsck. Should just implement
593 // TIter::Remove().
594 TObjLink* lnk = hists->FirstLink();
595 Int_t j = 0;
596 while (lnk) {
597 TH1* h = static_cast<TH1*>(lnk->GetObject());
598 bool remove = false;
599 TString name(h->GetName());
600 if (name.Contains("_mirror")) {
601 // AliWarning(Form("No entries in %s - removing", h->GetName()));
602 remove = true;
603 }
604 else if (l) {
605 j++;
606 name.Form("%3d%% - %3d%%",
607 Int_t(axis->GetBinLowEdge(j)),
608 Int_t(axis->GetBinUpEdge(j)));
609 TLegendEntry* e = l->AddEntry("dummy", name, "f");
610 e->SetFillStyle(1001);
611 e->SetFillColor(h->GetMarkerColor());
612 }
613 if (remove) {
614 TObjLink* keep = lnk->Next();
615 hists->Remove(lnk);
616 lnk = keep;
617 continue;
618 }
619 lnk = lnk->Next();
620 }
621}
622
623//____________________________________________________________________
624void DrawCentRes(const TCollection* sums, TCanvas* can, const TString& base,
625 Int_t cLow, Int_t cHigh)
626{
627 TString folder;
628 if (cLow < 0 || cHigh < 0 || cLow >= cHigh) {
629 folder = "all";
630 cHigh *= -1;
631 }
632 else folder.Form("cent%03d_%03d", cLow, cHigh);
633
634 TCollection* c = GetCollection(sums, folder);
635 if (!c) return;
636
637 TVirtualPad* body = can->cd(2);
638 body->Divide(2, 3);
639
640 DrawInPad(body, 1, GetH1(c, "triggers"), "HIST TEXT");
641 DrawInPad(body, 2, GetH1(c, Form("norm%s",base.Data())));
642 DrawInPad(body, 3, GetH1(c, Form("dndeta%s",base.Data())));
643 DrawInPad(body, 4, GetH1(c, Form("dndeta%s_rebin05",base.Data())));
644 DrawInPad(body, 5, GetH2(c, Form("d2Ndetadphi%s", base.Data())),"colz");
645
646 TObject* normCalc = GetObject(c, "normCalc");
647 TString calc = normCalc->GetTitle();
648 TObjArray* lines = calc.Tokenize("\n");
649 TPaveText* disp = new TPaveText(.1,.1,.9,.9, "NDC");
650 TIter next(lines);
651 TObject* line = 0;
652 while ((line = next()))
653 disp->AddText(line->GetName());
654 disp->SetBorderSize(0);
655 disp->SetBorderSize(0);
656 disp->SetFillStyle(0);
657 DrawInPad(body, 6, disp);
658
659 PrintCanvas(can, Form("%s result: %3d%% - %3d%%", base.Data(), cLow, cHigh));
660}
661
662//____________________________________________________________________
663THStack*
664DrawRes(TDirectory* top, const TString& base, TCanvas* can, Bool_t onlyMB)
665{
666 TCollection* c = GetCollection(top, Form("%sResults", base.Data()));
667 if (!c) return 0;
668
669 TAxis* centAxis = static_cast<TAxis*>(GetObject(c, "centAxis"));
670
671 can->cd(2);
672
673 TLatex* name;
674 TLatex* value;
675 Double_t y = .9;
676 CreateTemplates(name, value, .02);
677 for (Int_t i = 1; i <= centAxis->GetNbins(); i++) {
678 DrawParameter(name, value, y, (i == 1 ? "Centrality classes" : ""),
679 Form("%3d%% - %3d%%",
680 Int_t(centAxis->GetBinLowEdge(i)),
681 Int_t(centAxis->GetBinUpEdge(i))));
682 }
683
684 DrawParameter(name, value, y, "Collision system",
685 GetObject(c, "sys")->GetTitle());
686 DrawParameter(name, value, y, "#sqrt{s_{NN}}",GetObject(c,"sNN")->GetTitle());
687 DrawParameter(name, value, y, "trigger",GetObject(c,"trigger")->GetTitle());
688 DrawParameter(name, value, y, "scheme", GetObject(c,"scheme")->GetTitle());
689
690 Double_t epsT, epsT0;
691 GetParameter(c, "triggerEff", epsT);
692 GetParameter(c, "triggerEff0", epsT0);
693 DrawParameter(name, value, y, "#epsilon_{T}", Form("%f", epsT));
694 DrawParameter(name, value, y, "#epsilon_{T,zero bin}", Form("%f", epsT0));
695
696 PrintCanvas(can, Form("%s results", base.Data()));
697
698 TVirtualPad* body = can->cd(2);
699 body->Divide(1, 3);
700
701 TLegend* l = new TLegend(0.1, 0.1, 0.9, 0.9, "Centralities");
702 l->SetNColumns(2);
703 l->SetFillStyle(0);
704 l->SetBorderSize(0);
705 THStack* dndeta = GetStack(c, "dndeta");
706 CleanStack(dndeta, l, centAxis);
707 THStack* dndeta5 = GetStack(c, "dndeta_rebin05");
708 CleanStack(dndeta5, 0, 0);
709
710 DrawInPad(body, 1, dndeta, "nostack");
711 DrawInPad(body, 2, dndeta5, "nostack");
712 DrawInPad(body, 3, l, "");
713
714 PrintCanvas(can, Form("%s results - stacks", base.Data()));
715
716 DrawCentRes(c, can, base, centAxis->GetXmin(), -centAxis->GetXmax());
717 if (onlyMB) return dndeta;
718
719 for (Int_t i = 1; i <= centAxis->GetNbins(); i++)
720 DrawCentRes(c, can, base, centAxis->GetBinLowEdge(i),
721 centAxis->GetBinUpEdge(i));
722
723 return dndeta;
724}
725
726
727//____________________________________________________________________
728void DrawdNdetaSummary(const char* fname="forward_dndeta.root",
729 bool onlyMB=true)
730{
731 // --- Open the file -----------------------------------------------
732 TString filename(fname);
733 TFile* file = TFile::Open(filename.Data(), "READ");
734 if (!file) {
735 Error("DrawAODSummary", "Failed to open \"%s\"", filename.Data());
736 return;
737 }
738
739 // --- Make our canvas ---------------------------------------------
740 TString pdfName(filename);
741 pdfName.ReplaceAll(".root", ".pdf");
742
743 TCanvas* c = CreateCanvas(pdfName);
744
745 // --- Do each sub-algorithm ---------------------------------------
746 DrawSums(file, "Forward", c, onlyMB);
747 THStack* rF = DrawRes(file, "Forward", c, onlyMB);
748
749 DrawSums(file, "Central", c, onlyMB);
750 THStack* rC = DrawRes(file, "Central", c, onlyMB);
751
752 TIter next(rF->GetHists());
753 TH1* h = 0;
754 while ((h = static_cast<TH1*>(next()))) rC->Add(h);
755
756 rC->Draw("nostack");
757 PrintCanvas(c, "Both");
758
759 CloseCanvas(c);
760}
761
762
763