AliPhysics  d219d63 (d219d63)
SummarydNdetaDrawer.C
Go to the documentation of this file.
1 #include "SummaryDrawer.C"
2 #include <TPaveText.h>
3 #include <TMultiGraph.h>
4 
6 {
7 public:
8  enum {
9  kForward = 0x01,
10  kCentral = 0x02,
11  kSums = 0x04,
12  kResults = 0x08,
13  kMinBias = 0x10,
14  kMC = 0x80,
15  kNormal = 0x0F
16  };
18  : SummaryDrawer()
19  {}
20  const char* ColName(const char* prefix, bool results=false)
21  {
22  return Form("%sdNdeta%s", prefix, results ? "Results" : "Sums");
23  }
24  //____________________________________________________________________
25  void Run(const char* fname="forward_dndeta.root", UShort_t flags=kNormal)
26  {
27  // --- Open the file -----------------------------------------------
28  TString filename(fname);
29  TFile* file = TFile::Open(filename.Data(), "READ");
30  if (!file) {
31  Error("Run", "Failed to open \"%s\"", filename.Data());
32  return;
33  }
34  // Options
35  Bool_t forward = flags & kForward;
36  Bool_t central = flags & kCentral;
37  Bool_t sums = flags & kSums;
38  Bool_t results = flags & kResults;
39  Bool_t onlyMB = flags & kMinBias;
40  Bool_t mc = flags & kMC;
41  fPause = flags & kPause;
42 
43  // --- Force MB for pp ---------------------------------------------
44  UShort_t sys = 0;
45  TCollection* c = GetCollection(file, ColName("Forward", false));
46  GetParameter(c, "sys", sys);
47  if (sys == 1) {
48  // onlyMB = true;
49  // Info("Run", "Found sys==1 -> Forcing MB");
50  }
51 
52  // --- Test of MC --------------------------------------------------
53  TCollection* mcC = GetCollection(file, ColName("MCTruth"), false);
54  if (mcC) {
55  TCollection* mcAll = GetCollection(mcC, "all");
56  if (mcAll && GetObject(mcAll, "sum")) {
57  Info("Run", "Found MC truth output");
58  mc = true;
59  }
60  }
61  // --- Make our canvas ---------------------------------------------
62  TString pdfName(filename);
63  pdfName.ReplaceAll(".root", ".pdf");
64  CreateCanvas(pdfName, flags & kLandscape);
65 
66  // --- Make a Title page -------------------------------------------
67  DrawTitlePage(file, mc, onlyMB);
68 
69  // --- Do each sub-algorithm ---------------------------------------
70  THStack* rF = 0;
71  if (forward && sums) DrawSums(file, "Forward", onlyMB);
72  if (forward && results) rF = DrawRes(file, "Forward", onlyMB);
73 
74  THStack* rC = 0;
75  if (central && sums) DrawSums(file, "Central", onlyMB);
76  if (central && results) rC = DrawRes(file, "Central", onlyMB);
77 
78  THStack* rM = 0;
79  if (mc && sums) DrawSums(file, "MCTruth", onlyMB);
80  if (mc && results) rM = DrawRes(file, "MCTruth", onlyMB);
81 
82  if (rC && rF && results) DrawBoth(rC, rF, rM, file, onlyMB);
83 
84  CloseCanvas();
85  }
86 
87 protected:
88  //____________________________________________________________________
89  TAxis* GetCentAxis(const TCollection* parent, Bool_t verbose=false)
90  {
91  TObject* cO = GetObject(parent, "centAxis", verbose);
92  TAxis* cA = 0;
93  if (!cO) return 0;
94 
95  if (cO->IsA()->InheritsFrom(TAxis::Class()))
96  cA = static_cast<TAxis*>(cO);
97  else if (cO->IsA()->InheritsFrom(TH1::Class())) {
98  TH1* cH = static_cast<TH1*>(cO);
99  cA = cH->GetXaxis();
100  }
101  // if (cA) cA->Dump();
102  if (!cA || !cA->GetXbins() || !cA->GetXbins()->GetArray() ||
103  cA->GetXmin() > cA->GetXmax()) return 0;
104  return cA;
105  }
106  //____________________________________________________________________
108  const TString& base,
109  Float_t cLow,
110  Float_t cHigh,
111  TString& title)
112  {
113  TString folder;
114  title = TString::Format("%s %s: ", base.Data(), title.Data());
115  if (cLow < 0 || cHigh < 0 || cLow >= cHigh) {
116  folder = "all";
117  title.Append("All selected events");
118  }
119  else {
120  folder.Form("cent%03dd%02d_%03dd%02d",
121  Int_t(cLow), Int_t(cLow*100) % 100,
122  Int_t(cHigh), Int_t(cHigh*100) % 100);
123  title.Append(Form("%6.2f%% - %6.2f%%", cLow, cHigh));
124  }
125 
126  return GetCollection(sums, folder);
127 
128  }
129  //____________________________________________________________________
130  void DrawTitlePage(TFile* file, Bool_t mc, Bool_t onlyMB)
131  {
132  TCollection* c = GetCollection(file, ColName("Forward", true));
133 
134  fBody->cd();
135 
136  Double_t y = .9;
137  TLatex* ltx = new TLatex(.5, y,
138  "#frac{1}{#it{N}}#kern[.1]"
139  "{#frac{d#it{N_{ch}}}{d#it{#eta}}}");
140  ltx->SetTextSize(0.07);
141  ltx->SetTextFont(42);
142  ltx->SetTextAlign(22);
143  ltx->SetNDC();
144  ltx->Draw();
145  y -= .075;
146 
147  TObject* tN = GetObject(file, "trainName");
148  if (!tN) tN = GetObject(c, "trainName");
149 
150  if (tN) {
151  TLatex* ltN = new TLatex(.5, y, Form("(%s)", tN->GetTitle()));
152  ltN->SetTextSize(0.05);
153  ltN->SetTextFont(82);
154  ltN->SetTextAlign(22);
155  ltN->SetNDC();
156  ltN->Draw();
157  y -= .055;
158  }
159  if (mc) {
160  ltx = new TLatex(.5, y, "Simulation input");
161  ltx->SetNDC();
162  ltx->SetTextAlign(23);
163  ltx->SetTextFont(42);
164  ltx->SetTextSize(.03);
165  ltx->Draw();
166  y -= .035;
167  }
168  if (onlyMB) {
169  ltx = new TLatex(.5, y, "No centrality");
170  ltx->SetNDC();
171  ltx->SetTextAlign(23);
172  ltx->SetTextFont(42);
173  ltx->SetTextSize(.03);
174  ltx->Draw();
175  y -= .035;
176  }
177 
178  DrawResTitle(c, y, onlyMB);
179 
180  PrintCanvas("1/N dN/d#eta");
181  }
182  //____________________________________________________________________
183  void DrawBoth(THStack* rC, THStack* rF, THStack* rM,
184  TFile* file, Bool_t onlyMB)
185  {
186  fBody->cd();
187  Double_t y1 = fLandscape ? 0 : .3;
188  Double_t x2 = fLandscape ? .7 : 1;
189  Double_t x1 = fLandscape ? x2 : 0;
190  Double_t y2 = fLandscape ? 1 : y1;
191  TPad* p1 = new TPad("p1", "p1", 0, y1, x2, 1, 0, 0);
192  TPad* p2 = new TPad("p2", "p2", x1, 0, 1, y2, 0, 0);
193 
194  fBody->cd();
195  p1->Draw();
196  p1->cd();
197 
198  TH1* h = 0;
199  if (rM) {
200  TIter nextM(rM->GetHists());
201  while ((h = static_cast<TH1*>(nextM()))) rC->Add(h);
202  }
203 
204  TIter next(rF->GetHists());
205  while ((h = static_cast<TH1*>(next()))) rC->Add(h);
206 
207 
208  rC->Draw("nostack");
209 
210  TCollection* fS = GetCollection(file, ColName("Forward", false));
211  UShort_t sys, sNN;
212  ULong_t trigger;
213  GetParameter(fS, "sNN", sNN);
214  GetParameter(fS, "sys", sys);
215  GetParameter(fS, "trigger", trigger);
216  TAxis* centAxis = GetCentAxis(fS);
217  UShort_t cLow = centAxis && !onlyMB ? centAxis->GetXmin() : 0;
218  UShort_t cHigh = centAxis && !onlyMB ? centAxis->GetXmax() : 100;
219 
220  // CompileScript("OtherData.C", "", "RefData", false);
221 
222  // If we have V0AND trigger, get NSD other data
223  TMultiGraph* other = 0;
224 #if 0
225  if (!centAxis) {
226  Int_t oT = (trigger == 0x2000) ? 0x4 : trigger;
227  TString oC = Form("RefData::GetData(%hu,%hu,%hu,%hu,%hu,0xF)",
228  sys, sNN, oT, cLow, cHigh);
229  other = reinterpret_cast<TMultiGraph*>(gROOT->ProcessLine(oC));
230  }
231  else {
232  other = new TMultiGraph("other", "");
233  Int_t nCent = centAxis->GetNbins();
234  for (Int_t i = 1; i <= nCent; i++) {
235  TString oC = Form("RefData::GetData(%hu,%hu,%hu,%hu,%hu,0xF)",
236  sys, sNN, 0, UShort_t(centAxis->GetBinLowEdge(i)),
237  UShort_t(centAxis->GetBinUpEdge(i)));
238  TMultiGraph* oM =
239  reinterpret_cast<TMultiGraph*>(gROOT->ProcessLine(oC));
240  if (oM) other->Add(oM);
241  }
242  }
243 #endif
244  if (other) {
245  // p1->Clear();
246  // other->Draw("ap");
247  // Double_t oMax = other->GetHistogram()->GetMaximum();
248  // Double_t rMax = rC->GetMaximum("nostack");
249  // other->SetMaximum(1.2*TMath::Max(oMax, rMax));
250  // rC->Draw("same nostack");
251  TObject* g = 0;
252  TIter nextG(other->GetListOfGraphs());
253  while ((g = nextG())) {
254  // Printf("Drawing %s/%s", g->GetName(), g->GetTitle());
255  g->DrawClone("same p");
256  }
257  }
258 
259  fBody->cd();
260  p2->Draw();
261  p2->cd();
262 
263 
264  TLegend* l = new TLegend(0.01, 0.1, 0.99, 0.99,
265  onlyMB || !centAxis ? "" : "Centralities");
266  l->SetNColumns(fLandscape ? 1 : 2);
267  l->SetFillStyle(0);
268  l->SetBorderSize(0);
269  CleanStack(rC, l, onlyMB ? 0 : centAxis);
270  TString seen;
271  if (other) {
272  TIter nextG(other->GetListOfGraphs());
273  TObject* g = 0;
274  while ((g = nextG())) {
275  if (seen.Index(g->GetTitle()) != kNPOS) continue;
276  seen.Append(Form("|%s", g->GetTitle()));
277  TLegendEntry* e = l->AddEntry("dummy", g->GetTitle(), "p");
278  TGraph* gg = static_cast<TGraph*>(g);
279  e->SetMarkerStyle(gg->GetMarkerStyle());
280  e->SetMarkerSize(gg->GetMarkerSize());
281  e->SetMarkerColor(kBlack);
282  }
283  }
284  l->Draw();
285 
286  PrintCanvas("Both");
287  }
288  //____________________________________________________________________
289  void DrawSums(TDirectory* top, const TString& base, bool onlyMB)
290  {
291  TCollection* c = GetCollection(top, ColName(base));
292  if (!c) return;
293 
294  TAxis* centAxis = (onlyMB ? 0 : GetCentAxis(c));
295  if (centAxis && centAxis->GetNbins() < 1) centAxis = 0;
296 
297  Int_t txtPad = 0;
298  Double_t xSave = fParVal->GetX();
299  Double_t size = 0.05;
300  fParVal->SetX(.45);
301  Double_t y = .8;
302 
303  if (!onlyMB && centAxis) {
304  size = 0.03;
305  fBody->Divide(1, 2);
306  txtPad = 1;
307 
308  fBody->cd(1);
309  for (Int_t i = 1; i <= centAxis->GetNbins(); i++) {
310  DrawParameter(y, (i == 1 ? "Centrality classes" : ""),
311  Form("%3d%% - %3d%%",
312  Int_t(centAxis->GetBinLowEdge(i)),
313  Int_t(centAxis->GetBinUpEdge(i))), size);
314  }
315 
316  TH1* cent = GetH1(c, "cent");
317  cent->GetXaxis()->SetRangeUser(0,100);
318  cent->SetFillColor(kRed+1);
319  cent->SetFillStyle(3002);
320  cent->SetXTitle("Centrality [%]");
321  cent->SetYTitle("Events");
322  cent->SetMaximum(1.3*cent->GetMaximum());
323  TH1* centAcc = GetH1(c, "centAcc");
324  centAcc->SetFillStyle(3002);
325 
326  TLatex* overUnder = new TLatex(0.15, .88,
327  Form("#splitline{<0: %d}{>100: %d}",
328  int(cent->GetBinContent(1)),
329  int(cent->GetBinContent(102))));
330  overUnder->SetTextColor(kRed+1);
331  overUnder->SetNDC();
332  overUnder->SetTextAlign(13);
333  overUnder->SetTextFont(42);
334  TLatex* overUnderAcc = new TLatex(0.3, .88,
335  Form("#splitline{<0: %d}{>100: %d}",
336  int(centAcc->GetBinContent(1)),
337  int(centAcc->GetBinContent(102))));
338  overUnderAcc->SetTextColor(kGreen+1);
339  overUnderAcc->SetNDC();
340  overUnderAcc->SetTextAlign(13);
341  overUnderAcc->SetTextFont(42);
342 
343  DrawInPad(fBody, 2, cent);
344  DrawInPad(fBody, 2, centAcc, "same", kLegend);
345  DrawInPad(fBody, 2, overUnder, "same");
346  DrawInPad(fBody, 2, overUnderAcc, "same");
347 
348  }
349  fBody->cd(txtPad);
350 
351  UShort_t sys, sNN, scheme;
352  ULong_t trigger;
353  GetParameter(c, "sNN", sNN);
354  GetParameter(c, "sys", sys);
355  GetParameter(c, "scheme", scheme);
356  GetParameter(c, "trigger", trigger);
357 
358  TString schemeString;
359  if (scheme == 0) schemeString = "1/N_{accepted}";
360  if (scheme & 0x1) schemeString.Append("1/#epsilon_{V}1/#epsilon_{T}");
361  if (scheme & 0x2) schemeString.Append("Shape ");
362  if (scheme & 0x4) schemeString.Append("A+C-E ");
363  if (scheme & 0x8) schemeString.Append("#epsilon_{T,MC} ");
364  if (scheme & 0x10) schemeString.Append("0-bin");
365 
366  TString trigString; TriggerString(trigger, trigString);
367  TString sysString; SysString(sys, sysString);
368  TString sNNString; SNNString(sNN, sNNString);
369 
370  DrawParameter(y, "Collision system", sysString, size);
371  DrawParameter(y, "#sqrt{s_{NN}}", sNNString, size);
372  DrawParameter(y, "Normalization scheme", schemeString,size);
373  DrawParameter(y, "Triggers", trigString, size);
374 
375  fParVal->SetX(xSave);
376 
377  PrintCanvas(Form("%s sums", base.Data()));
378 
379  Int_t cLow = centAxis ? centAxis->GetXmin() : 0;
380  Int_t cHigh = centAxis ? -centAxis->GetXmax() : -100;
381  DrawCentSum(c, base, cLow, cHigh);
382  if (onlyMB || !centAxis) return;
383 
384  for (Int_t i = 1; i <= centAxis->GetNbins(); i++)
385  DrawCentSum(c, base, centAxis->GetBinLowEdge(i),
386  centAxis->GetBinUpEdge(i));
387  }
388  //____________________________________________________________________
389  void DrawCentSum(const TCollection* sums, const TString& base,
390  Float_t cLow, Float_t cHigh)
391  {
392  // Info("DrawCentSum", "Drawing centrality sum [%d,%d] in %s (%s)",
393  // cLow, cHigh, sums->GetName(), base.Data());
394  TString title("sums");
395  TCollection* c = GetCentCollection(sums, base, cLow, cHigh, title);
396  if (!c) return;
397 
398  TH2* bin = GetH2(c, "sum");
399  TH2* bin0 = GetH2(c, "sum0");
400  TH1* type = GetH1(c, "events");
401  TH1* trig = GetH1(c, "triggers");
402  TH1* stat = GetH1(c, "status");
403  if (!bin0 || !bin || !trig || !type) return;
404 
405  type->SetFillStyle(3001);
406  type->SetFillColor(kGreen+1);
407 
408  fBody->Divide(2, 2);
409 
410  DrawInPad(fBody, 1, trig, "HIST TEXT");
411  DrawInPad(fBody, 2, type, "HIST TEXT");
412  DrawInPad(fBody, 3, bin, "colz");
413 
414  if (bin0->GetEntries() <= 0) {
415  DrawInPad(fBody, 4, stat, "HIST TEXT");
416  // fBody->cd(4);
417  // TLatex* l = new TLatex(0.5, 0.5, "No 0-bin events");
418  // l->SetNDC();
419  // l->SetTextAlign(22);
420  // l->Draw();
421  }
422  else
423  DrawInPad(fBody, 4, bin0, "colz");
424 
425  PrintCanvas(title);
426  }
427  //____________________________________________________________________
429  {
430  Double_t xSave = fParVal->GetX();
431  Double_t size = 0.05;
432  fParVal->SetX(.5);
433  // Double_t y = .9;
434  TAxis* centAxis = GetCentAxis(c);
435  if (!onlyMB && centAxis) {
436  size = 0.03;
437  for (Int_t i = 1; i <= centAxis->GetNbins(); i++) {
438  DrawParameter(y, (i == 1 ? "Centrality classes" : ""),
439  Form("%6.2f%% - %6.2f%%",
440  centAxis->GetBinLowEdge(i),
441  centAxis->GetBinUpEdge(i)), size);
442  }
443  }
444  TObject* oSNN = GetObject(c, "sNN");
445  TString tSNN; SNNString(oSNN->GetUniqueID(), tSNN);
446  TObject* oTrg = GetObject(c,"trigger");
447  DrawParameter(y, "Collision system", GetObject(c, "sys")->GetTitle(), size);
448  DrawParameter(y, "#sqrt{s_{NN}}",tSNN, size);
449  DrawParameter(y, "Trigger",(oTrg ? oTrg->GetTitle() : "?"), size);
450  TObject* oscheme = GetObject(c,"scheme");
451  TString scheme = oscheme ? oscheme->GetTitle() : "";
452  if (scheme.IsNull()) scheme = "1/N_{accepted}";
453  DrawParameter(y, "Normalization scheme", scheme, size);
454 
455  Double_t epsT = 0, epsT0 = 0;
456  GetParameter(c, "triggerEff", epsT);
457  GetParameter(c, "triggerEff0", epsT0);
458  DrawParameter(y, "#epsilon_{T}", Form("%5.3f", epsT), size);
459  DrawParameter(y, "#epsilon_{T,zero bin}", Form("%5.3f", epsT0), size);
460  Double_t deltaIP =0;
461  GetParameter(c, "deltaIP", deltaIP);
462  DrawParameter(y, "IP #delta_{xy}", Form("%5.3fmm", deltaIP), size);
463 
464  TObject* options = GetObject(c, "options");
465  TString opts(options->GetTitle());
466  TObjArray* tokens = opts.Tokenize(",");
467  TObjString* opt = 0;;
468  TIter oNext(tokens);
469  Bool_t first = true;
470  while ((opt = static_cast<TObjString*>(oNext()))) {
471  DrawParameter(y, (first ? "options" : ""),
472  opt->String().Strip(TString::kBoth), size);
473  first = false;
474  }
475 
476  fParVal->SetX(xSave);
477  }
478 
479  //____________________________________________________________________
480  THStack* DrawRes(TDirectory* top, const TString& base, Bool_t onlyMB)
481  {
482  // Info("DrawRes", "Drawing results for %s", base.Data());
483  TCollection* c = GetCollection(top, ColName(base, true));
484  if (!c) return 0;
485  TCollection* s = GetCollection(top, ColName(base, false));
486  // if (!s) return 0;
487 
488  fBody->cd();
489  Double_t y = .9;
490  DrawResTitle(c, y, onlyMB);
491  PrintCanvas(Form("%s results", base.Data()));
492 
493  Int_t sys = GetObject(c, "sys")->GetUniqueID();
494  TObject* emp = GetObject(c, "empirical");
495  // TH1* emp = GetH1(c, "empirical");
496  TF1* dc = static_cast<TF1*>(GetObject(c,"deltaCorr"));
497  TF1* vw = static_cast<TF1*>(GetObject(s,"ipZw"));
498  TProfile* sc = static_cast<TProfile*>(GetObject(s,"sumVsC"));
499  if (vw) vw->SetRange(-4,6);
500  Int_t nPad = 0;
501  if (emp) nPad++;
502  if (dc) nPad++;
503  if (vw) nPad++;
504  if (sc) nPad++;
505  if (nPad > 0) {
506  fBody->Divide(nPad,1);
507  Int_t iPad = 1;
508  if (emp) DrawInPad(fBody, iPad++, emp, "", 0, "Empirical");
509  if (dc) DrawInPad(fBody, iPad++, dc, "", 0, "\\hbox{IP} \\delta_{xy}");
510  if (vw) {
511  DrawInPad(fBody, iPad++, vw, "", 0, "\\hbox{IP} \\delta_{z}");
512  Double_t y = .95;
513  DrawParameter(y, "#mu_{Z}", Form("%5.3f", vw->GetParameter(0)));
514  DrawParameter(y, "#sigma_{Z}", Form("%5.3f", vw->GetParameter(1)));
515  DrawParameter(y, "#mu_{Z,ref}", Form("%5.3f", vw->GetParameter(2)));
516  DrawParameter(y, "#sigma_{Z,ref}", Form("%5.3f", vw->GetParameter(3)));
517  }
518  if (sc) DrawInPad(fBody, iPad, sc, "", 0, "#LT#Sigma signal#GT");
519  PrintCanvas(Form("%s results - corrections", base.Data()));
520  }
521 
522  TAxis* centAxis = (onlyMB ? 0 : GetCentAxis(c));
523  if (centAxis && centAxis->GetNbins() < 1) centAxis = 0;
524 
525  THStack* dndeta_ = GetStack(c, "dndeta");
526  if (!dndeta_ || !dndeta_->GetHists() ||
527  dndeta_->GetHists()->GetEntries() < 0) return 0;
528 
529  TLegend* l = new TLegend(0.1, 0.1, 0.9, 0.9,
530  onlyMB || !centAxis? "" : "Centralities");
531  l->SetNColumns(fLandscape ? 1 : 2);
532  l->SetFillStyle(0);
533  l->SetBorderSize(0);
534  THStack* dndeta = CleanStack(dndeta_, l, centAxis);
535 
536  THStack* dndetaEmp = GetStack(c, "dndetaEmp");
537  if (!dndetaEmp || !dndetaEmp->GetHists() ||
538  dndetaEmp->GetHists()->GetEntries() < 0) dndetaEmp = 0;
539 
540  THStack* leftRight = GetStack(c, "leftRight");
541  if (!leftRight || !leftRight->GetHists() ||
542  leftRight->GetHists()->GetEntries() < 0) leftRight = 0;
543  if (leftRight) { leftRight->SetMinimum(0.8); leftRight->SetMaximum(1.2); }
544 
545  if (!onlyMB) {
546  Double_t y1 = fLandscape ? 0 : .3;
547  Double_t x2 = fLandscape ? .7 : 1;
548  Double_t x1 = fLandscape ? x2 : 0;
549  Double_t y2 = fLandscape ? 1 : y1;
550  TPad* p1 = new TPad("p1", "p1", 0, y1, x2, 1, 0, 0);
551  TPad* p2 = new TPad("p2", "p2", x1, 0, 1, y2, 0, 0);
552  fBody->cd();
553  p1->Draw();
554  p1->cd();
555  fBody->cd();
556  p2->Draw();
557  p2->cd();
558  p1->Divide(1,3,0,0);
559 
560  // fBody->Divide(1, 3, 0, 0);
561 
562  DrawInPad(p2, 0, l, "");
563  DrawInPad(p1, 1, dndeta, "nostack", 0,
564  "\\mathrm{d}N_{\\mathrm{ch}}/\\mathrm{d}\\eta|"
565  "_{\\mathrm{incl}}");
566  DrawInPad(p1, 2, dndetaEmp, "nostack", (sys == 2 ? kLogy : 0),
567  "\\mathrm{d}N_{\\mathrm{ch}}/\\mathrm{d}\\eta|"
568  "_{\\mathrm{prim}}");
569  DrawInPad(p1, 3, leftRight, "nostack", 0, "Left/Right");
570  p1->GetPad(1)->SetGridx();
571  p1->GetPad(2)->SetGridx();
572  p1->GetPad(3)->SetGridx();
573  p1->GetPad(1)->SetGridy();
574  p1->GetPad(2)->SetGridy();
575  p1->GetPad(3)->SetGridy();
576 
577  PrintCanvas(Form("%s results - stacks", base.Data()));
578  }
579 
580  Int_t cLow = centAxis ? centAxis->GetXmin() : 0;
581  Int_t cHigh = centAxis ? -centAxis->GetXmax() : -100;
582  DrawCentRes(c, base, cLow, cHigh);
583  if (onlyMB || !centAxis) {
584  // Info("", "Returning dndeta for MB");
585  dndeta = MakeMBStack(c, base);
586  return dndeta;
587  }
588 
589  for (Int_t i = 1; i <= centAxis->GetNbins(); i++)
590  DrawCentRes(c, base, centAxis->GetBinLowEdge(i),
591  centAxis->GetBinUpEdge(i));
592 
593  return dndeta;
594  }
595  //____________________________________________________________________
596  THStack* MakeMBStack(const TCollection* sums, const TString& base)
597  {
598  TString title("results");
599  TCollection* c = GetCentCollection(sums, base, 0, -1, title);
600  if (!c) return 0;
601 
602  TH1* dndeta = GetH1(c, Form("dndeta%s",base.Data()));
603  if (!dndeta) return 0;
604 
605  THStack* ret = new THStack("dndetaMB", title);
606  ret->Add(dndeta);
607 
608  if (base.EqualTo("MCTruth")) {
609  dndeta = GetH1(c, "dndetaTruth");
610  if (dndeta) ret->Add(dndeta);
611  }
612  return ret;
613  }
614 
615  //____________________________________________________________________
616  void DrawCentRes(const TCollection* sums, const TString& base,
617  Float_t cLow, Float_t cHigh)
618  {
619  // Info("DrawCentRes", "Drawing centrality results [%d,%d] in %s (%s)",
620  // cLow, cHigh, sums->GetName(), base.Data());
621  TString title("results");
622  TCollection* c = GetCentCollection(sums, base, cLow, cHigh, title);
623  if (!c) return;
624 
625 
626  TH1* trig = GetH1(c, "triggers");
627  TH1* norm = GetH1(c, Form("norm%s",base.Data()));
628  TH1* dndeta = GetH1(c, Form("dndeta%s",base.Data()));
629  TH1* dndetaEmp = GetH1(c, Form("dndeta%sEmp",base.Data()));
630  TH2* d2ndetadphi = GetH2(c, Form("d2Ndetadphi%s", base.Data()));
631  if (!trig || !norm || !dndeta || !d2ndetadphi) return;
632  if (norm->GetEntries() <= 0) return;
633 
634  norm->SetFillColor(kGreen+1);
635  norm->SetFillStyle(3001);
636 
637 
638  fBody->Divide(2, (dndetaEmp ? 4 : 3), 0.05, 0);
639 
640  Int_t trP = 1;
641  TVirtualPad* p = fBody->GetPad(trP);
642  p->SetBottomMargin(0.15);
643  p->SetLeftMargin(0.15);
644  if (trP > 2) p->SetTopMargin(0.05);
645 
646  DrawInPad(fBody, trP, trig, "HIST TEXT");
647  DrawInPad(fBody, 2, d2ndetadphi, "colz", 0,
648  "d^{2}#it{N}/d#it{#eta}d#it{phi}|_{incl}");
649  DrawInPad(fBody, 4, norm, "", 0, "Normalization");
650  DrawInPad(fBody, 6, dndeta, "", 0,
651  "d#it{N}_{ch}/d#it{#eta}|_{incl}");
652 
653  fBody->GetPad(2)->SetGridx();
654  fBody->GetPad(4)->SetGridx();
655  fBody->GetPad(6)->SetGridx();
656  fBody->GetPad(2)->SetLeftMargin(0.15);
657  fBody->GetPad(4)->SetLeftMargin(0.15);
658  fBody->GetPad(6)->SetLeftMargin(0.15);
659  fBody->GetPad(4)->SetRightMargin(0.15);
660  fBody->GetPad(6)->SetRightMargin(0.15);
661  if (dndetaEmp) {
662  DrawInPad(fBody, 8, dndetaEmp, "", 0,
663  "d#it{N}_{ch}/d#it{#eta}|_{prim}");
664  fBody->GetPad(8)->SetGridx();
665  fBody->GetPad(8)->SetLeftMargin(0.15);
666  fBody->GetPad(8)->SetRightMargin(0.15);
667  }
668 
669  TObject* normCalc = GetObject(c, "normCalc");
670  TString calc = normCalc ? normCalc->GetTitle() : "?";
671 
672  // Beautify the text
673  calc.ReplaceAll("beta", "#beta");
674  calc.ReplaceAll("eps", "#varepsilon");
675  const char* sufs[] = { "all", "acc", "trg", "vtx", "B", "A", "C", "E",
676  "V", "T", 0 };
677  const char** suf = sufs;
678  while (*suf) {
679  calc.ReplaceAll(Form("_%s", *suf), Form("_{%s}", *suf));
680  suf++;
681  }
682 
683  p = fBody->cd(3);
684  p->SetPad(p->GetXlowNDC(), 0,
685  p->GetXlowNDC()+p->GetWNDC(), p->GetYlowNDC()+p->GetHNDC());
686  fBody->GetPad(5)->Delete();
687  if (dndetaEmp) fBody->GetPad(7)->Delete();
688  TObjArray* lines = calc.Tokenize("\n");
689  // TPaveText* disp = new TPaveText(.1,.1,.9,.9, "NDC");
690  TIter next(lines);
691  TObjString* sline = 0;
692  Double_t y = .95;
693  Double_t xSave = fParName->GetX();
694  Int_t aSave = fParName->GetTextAlign();
695  Double_t tSave = fParVal->GetTextSize();
696  fParName->SetTextAlign(33);
697  fParName->SetX(fParVal->GetX()-.05);
698  while ((sline = static_cast<TObjString*>(next()))) {
699  // disp->AddText(line->GetName());
700  TString& line = sline->String();
701  Ssiz_t eq = line.Last('=');
702  if (eq == kNPOS) {
703  DrawParameter(y, line, "", .6*tSave);
704  continue;
705  }
706  TString name = line(0, eq);
707  TString val = line(eq+1,line.Length()-eq-1);
708  DrawParameter(y, name.Strip(TString::kBoth),
709  val.Strip(TString::kBoth),
710  .6*tSave);
711 
712  }
713  fParName->SetTextAlign(aSave);
714  fParName->SetX(xSave);
715  // disp->SetBorderSize(0);
716  // disp->SetBorderSize(0);
717  // disp->SetFillStyle(0);
718  // DrawInPad(fBody, 3, disp);
719  // fBody->cd();
720 
721  PrintCanvas(title);
722 
723  DrawCentResDetails(c, title);
724  }
725  //____________________________________________________________________
726  void DrawCentResDetails(const TCollection* sums, const TString& base)
727  {
728  TString title = TString::Format("%s - details: ", base.Data());
729 
730  TCollection* c = GetCollection(sums, "partial");
731  if (!c) {
732  Warning("", "Collection partical not found in %s", sums->GetName());
733  sums->ls();
734  return;
735  }
736 
737  fBody->Divide(3, 1, 0.05, 0);
738 
739  const char* typs[] = { "", "0", "All" };
740  const char* tits[] = { "Non-zero events", "Zero events", "Weighted sum" };
741  for (Int_t i = 1; i <= 3; i++) {
742  const char* suf = typs[i-1];
743  TVirtualPad* p = fBody->cd(i);
744  p->SetTopMargin(0.10);
745 
746  TLatex* ltx = new TLatex(0.5, .99, tits[i-1]);
747  ltx->SetNDC();
748  ltx->SetTextAlign(23);
749  ltx->SetTextSize(0.05);
750  ltx->Draw();
751 
752  TH1* sum = GetH2(c, Form("sum%s", suf));
753  TH1* norm = GetH1(c, Form("norm%s", suf));
754  TH1* phi = GetH1(c, Form("phi%s", suf));
755 
756  norm->SetFillColor(kGreen+1);
757  norm->SetFillStyle(3002);
758  phi->SetFillColor(kBlue+1);
759  phi->SetFillStyle(3001);
760 
761  p->Divide(1, 3, 0, 0);
762  DrawInPad(p, 1, sum, sum->Integral()>0 ? "col" : "", 0,
763  "d^{2}#it{N}_{ch}/d#it{#varphi}d#it{#eta}");
764  DrawInPad(p, 2, GetH1(c, Form("average%s", suf)), "", 0,
765  "d#it{N}_{ch}/d#it{#eta}");
766  DrawInPad(p, 3, norm, "", 0, "#eta-coverage/#varphi-acceptance");
767  DrawInPad(p, 3, phi, "same", kLegend);
768  }
769  PrintCanvas(title);
770  }
771 
772  //____________________________________________________________________
773  THStack* CleanStack(const THStack* stack, TLegend* l, const TAxis* axis)
774  {
775  if (!stack) return 0;
776  THStack* ret = new THStack(stack->GetName(), stack->GetTitle());
777  TList* hists = stack->GetHists();
778  TIter next(hists);
779  TH1* h = 0;
780  Int_t j = 0;
781  Bool_t ok = false;
782  while ((h = static_cast<TH1*>(next()))) {
783  TString name(h->GetTitle());
784  TString nme(h->GetName());
785  if (nme.Contains("_mirror", TString::kIgnoreCase)) {
786  // Printf("Ignore %s/%s in stack", nme.Data(), name.Data());
787  continue;
788  }
789  if (l && !ok) {
790  j++;
791  if (axis) {
792  Int_t bin = j; // axis ? TMath::Min(j, axis->GetNbins()) : 1;
793  if (j > axis->GetNbins())
794  name = "0% - 100%";
795  else
796  name.Form("%3d%% - %3d%%",
797  Int_t(axis->GetBinLowEdge(bin)),
798  Int_t(axis->GetBinUpEdge(bin)));
799  ok = axis->GetBinUpEdge(bin) > 100;
800  }
801  else {
802  name.ReplaceAll("ALICE", "");
803  name.ReplaceAll("dNdeta", " - work in progress");
804  }
805  // Printf("Adding entry %d: %s/%s", j, nme.Data(), name.Data());
806  TLegendEntry* e = l->AddEntry("dummy", name, "f");
807  e->SetFillStyle(1001);
808  e->SetFillColor(h->GetMarkerColor());
809  }
810  ret->Add(h);
811  }
812  return ret;
813  }
814 };
815 //
816 // EOF
817 //
const char * filename
Definition: TestFCM.C:1
THStack * DrawRes(TDirectory *top, const TString &base, Bool_t onlyMB)
TLatex * fParName
double Double_t
Definition: External.C:58
Base class for classes to draw summaries.
const char * title
Definition: MakeQAPdf.C:27
static TH1 * GetH1(const TObject *parent, const TString &name, Bool_t verb=true)
TAxis * GetCentAxis(const TCollection *parent, Bool_t verbose=false)
static TH2 * GetH2(const TObject *parent, const TString &name, Bool_t verb=true)
static void TriggerString(ULong_t trigger, TString &str)
TCanvas * c
Definition: TestFitELoss.C:172
TCollection * GetCentCollection(const TCollection *sums, const TString &base, Float_t cLow, Float_t cHigh, TString &title)
void DrawCentResDetails(const TCollection *sums, const TString &base)
void DrawBoth(THStack *rC, THStack *rF, THStack *rM, TFile *file, Bool_t onlyMB)
AliStack * stack
void Run(const char *fname="forward_dndeta.root", UShort_t flags=kNormal)
static void SysString(UShort_t sys, TString &str)
Int_t cH
Definition: Combine.C:26
void DrawSums(TDirectory *top, const TString &base, bool onlyMB)
int Int_t
Definition: External.C:63
float Float_t
Definition: External.C:68
const char * ColName(const char *prefix, bool results=false)
static Bool_t GetParameter(const TObject *c, const TString &name, Short_t &value, Bool_t verb=true)
static TObject * GetObject(const TObject *parent, const TString &name, Bool_t verb=true)
unsigned long ULong_t
Definition: External.C:38
const char * pdfName
Definition: DrawAnaELoss.C:30
void CreateCanvas(const TString &pname, Bool_t landscape=false, Bool_t pdf=true, Bool_t useTop=true)
void DrawParameter(Double_t &y, const TString &name, const TString &value, Double_t size=0)
void DrawResTitle(TCollection *c, Double_t &y, Bool_t onlyMB)
void PrintCanvas(const TString &title, Float_t size=.7)
static void SNNString(UShort_t sNN, TString &str)
void CloseCanvas()
THStack * MakeMBStack(const TCollection *sums, const TString &base)
TLatex * fParVal
Definition: External.C:220
void DrawTitlePage(TFile *file, Bool_t mc, Bool_t onlyMB)
TFile * file
TList with histograms for a given trigger.
unsigned short UShort_t
Definition: External.C:28
TObject * DrawInPad(TVirtualPad *c, Int_t padNo, TObject *h, Option_t *opts="", UInt_t flags=0x0, const char *title="")
bool Bool_t
Definition: External.C:53
static TCollection * GetCollection(const TObject *parent, const TString &name, Bool_t verb=true)
THStack * CleanStack(const THStack *stack, TLegend *l, const TAxis *axis)
Definition: External.C:196
void DrawCentRes(const TCollection *sums, const TString &base, Float_t cLow, Float_t cHigh)
static THStack * GetStack(const TObject *parent, const TString &name, const char *sub=0, Bool_t verb=true)
void DrawCentSum(const TCollection *sums, const TString &base, Float_t cLow, Float_t cHigh)