AliPhysics  97344c9 (97344c9)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SummaryMultDistsDrawer.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  kNormal = 0xF
10  };
12  : SummaryDrawer()
13  {}
14  //____________________________________________________________________
15  void Run(const char* fname="forward_multdists.root", UShort_t flags=kNormal)
16  {
17  // --- Open the file -----------------------------------------------
18  TString filename(fname);
19  TFile* file = TFile::Open(filename.Data(), "READ");
20  if (!file) {
21  Error("Run", "Failed to open \"%s\"", filename.Data());
22  return;
23  }
24  fPause = flags & kPause;
25 
26  // --- Make our canvas ---------------------------------------------
27  TString pdfName(filename);
28  pdfName.ReplaceAll(".root", ".pdf");
29  CreateCanvas(pdfName, flags & kLandscape);
30 
31  // --- Force MB for pp ---------------------------------------------
32  TCollection* c = GetCollection(file, "ForwardMultSums");
33 
34  // --- Make a Title page -------------------------------------------
35  DrawTitlePage(c);
36 
37  // --- Overview plots ----------------------------------------------
38  fBody->Divide(1,3);
39  DrawInPad(fBody, 1, GetH1(c, "triggers"), "hist text30");
40  DrawInPad(fBody, 2, GetH1(c, "status"), "hist text30");
41  DrawInPad(fBody, 3, GetH1(c, "diagnostics"),"colz text");
42  PrintCanvas("Overview");
43 
44  DrawSumCollection(c, "symmetric");
45  DrawSumCollection(c, "negative");
46  DrawSumCollection(c, "positive");
47  DrawSumCollection(c, "other");
48 
49  c = GetCollection(file, "ForwardMultResults");
50  if (!c) {
51  CloseCanvas();
52  return;
53  }
54 
55  DrawResCollection(c, "symmetric");
56  DrawResCollection(c, "negative");
57  DrawResCollection(c, "positive");
58  DrawResCollection(c, "other");
59 
60  CloseCanvas();
61  }
62 
63 protected:
65  {
66  const char* re = "[pm][0-9]*d[0-9]*_[pm][0-9]*d[0-9]*";
67  TRegexp check(re);
68 
69  if (!o->IsA()->InheritsFrom(TCollection::Class())) {
70  // Warning("GetEtaBin", "Don't know how to deal with %s - a %s",
71  // o->GetName(), o->ClassName());
72  return 0;
73  }
74  TString oN(o->GetName());
75  if (oN.Index(check) == kNPOS) {
76  // Warning("GetEtaBin", "Collection %s does not match %s",
77  // oN.Data(), re);
78  return 0;
79  }
80  Int_t ul = oN.Index("_");
81  TString sMin = oN(0, ul);
82  TString sMax = oN(ul+1, oN.Length()-ul-1);
83  sMin.ReplaceAll("p", "+");
84  sMin.ReplaceAll("m", "-");
85  sMin.ReplaceAll("d", ".");
86  sMax.ReplaceAll("p", "+");
87  sMax.ReplaceAll("m", "-");
88  sMax.ReplaceAll("d", ".");
89  etaMin = sMin.Atof();
90  etaMax = sMax.Atof();
91 
92  return static_cast<TCollection*>(o);
93  }
94  //____________________________________________________________________
95  void DrawSumCollection(TCollection* top, const TString& name)
96  {
97  TCollection* c = GetCollection(top, name, false);
98  if (!c) return;
99 
100  PrintCanvas(Form("Sums - %s", name.Data()));
101 
102  TIter next(c);
103  TObject* o = 0;
104  while ((o = next())) {
105  Double_t etaMin = 999;
106  Double_t etaMax = 999;
107  TCollection* bin = GetEtaBin(o, etaMin, etaMax);
108  if (!bin) continue;
109 
110  fBody->Divide(2,2);
111  DrawInPad(fBody, 1, GetH1(bin, "rawDist"), "", kLogy);
112  DrawInPad(fBody, 1, GetH1(bin, "truthAccepted",false),"same",
113  kLogy|kSilent);
114  DrawInPad(fBody, 1, GetH1(bin, "truth",false), "same",
116  DrawInPad(fBody, 2, GetH1(bin, "coverage"));
117  DrawInPad(fBody, 3, GetH2(bin, "corr"), "colz");
118  DrawInPad(fBody, 4, GetH2(bin, "response",false), "colz",kLogz|kSilent);
119 
120  PrintCanvas(Form("%+5.1f < #eta < %+5.1f", etaMin, etaMax));
121  }
122  }
123  //____________________________________________________________________
124  void DrawResCollection(TCollection* top, const TString& name)
125  {
126  TCollection* c = GetCollection(top, name, false);
127  if (!c) return;
128 
129  THStack* s = GetStack(c, "all");
130  s->SetTitle("");
131  DrawInPad(fBody, 0, s, "nostack", kLogy);
132  TLegend* l = new TLegend(.5, .75, .98, .98, "P(#it{N}_{ch})");
133  l->SetBorderSize(0);
134  // l->SetBorderMode(0);
135  l->SetFillColor(0);
136  l->SetFillStyle(0);
137  TIter next(s->GetHists());
138  TH1* h = 0;
139  Bool_t hasTrue = false;
140  while ((h = static_cast<TH1*>(next()))) {
141  TString n(h->GetTitle());
142  if (n.BeginsWith("True")) { hasTrue = true; continue; }
143  n.ReplaceAll("Raw P(#it{N}_{ch}) in ", "");
144  TLegendEntry* e = l->AddEntry("dummy", n, "p");
145  e->SetMarkerStyle(h->GetMarkerStyle());
146  }
147  if (hasTrue) {
148  TLegendEntry* e = l->AddEntry("dummy", "Raw", "p");
149  e->SetMarkerStyle(20);
150  e->SetMarkerColor(kRed+1);
151  e = l->AddEntry("dummy", "MC truth", "p");
152  e->SetMarkerStyle(24);
153  e->SetMarkerColor(kBlue+1);
154  e = l->AddEntry("dummy", "MC truth selected", "p");
155  e->SetMarkerStyle(24);
156  e->SetMarkerColor(kOrange+1);
157  }
158  fBody->cd();
159  l->Draw();
160 
161  PrintCanvas(Form("%s results", name.Data()));
162 
163  // return;
164 
165  TIter nextO(c);
166  TObject* o = 0;
167  while ((o = nextO())) {
168  Double_t etaMin = 999;
169  Double_t etaMax = 999;
170  TCollection* bin = GetEtaBin(o, etaMin, etaMax);
171  if (!bin) continue;
172 
173  fBody->Divide(2,3);
174  DrawInPad(fBody, 1, GetH1(bin, "rawDist"), "", kLogy);
175  DrawInPad(fBody, 1, GetH1(bin, "truthAccepted", false),
176  "same", kSilent);
177  DrawInPad(fBody, 1, GetH1(bin, "truth", false),"same", kSilent|kLegend);
178  DrawInPad(fBody, 2, GetH1(bin, "coverage"));
179  DrawInPad(fBody, 3, GetH2(bin, "corr"), "colz");
180  DrawInPad(fBody, 4, GetH2(bin, "response", false), "colz", kLogz|kSilent);
181  DrawInPad(fBody, 5, GetH1(bin, "triggerVertex", false), "", kSilent);
182 
183  PrintCanvas(Form("%+5.1f < #eta < %+5.1f", etaMin, etaMax));
184  }
185  }
186  //____________________________________________________________________
188  {
189  fBody->cd();
190 
191  Double_t y = .7;
192  TLatex* ltx = new TLatex(.5, y, "AOD #rightarrow P(#it{N}_{ch} )");
193  ltx->SetTextSize(0.07);
194  ltx->SetTextFont(62);
195  ltx->SetTextAlign(22);
196  ltx->SetNDC();
197  ltx->Draw();
198 
199  Bool_t mc = GetObject(c, "mcVertex", false) != 0;
200  if (mc) {
201  y -= 0.05;
202  TLatex* sub = new TLatex(.5, y, "(Simulation input)");
203  sub->SetTextSize(0.04);
204  sub->SetTextFont(42);
205  sub->SetTextAlign(22);
206  sub->SetNDC();
207  sub->Draw();
208  }
209 
210  Double_t save = fParName->GetTextSize();
211  fParName->SetTextSize(0.03);
212  fParVal->SetTextSize(0.03);
213  y = .6;
214 
215  UShort_t sys;
216  UShort_t sNN;
217  ULong_t trig;
218  Double_t minIpZ;
219  Double_t maxIpZ;
220  GetParameter(c, "sys", sys);
221  GetParameter(c, "sNN", sNN);
222  GetParameter(c, "trigger", trig);
223  GetParameter(c, "minIpZ", minIpZ);
224  GetParameter(c, "maxIpZ", maxIpZ);
225 
226  TString tT; TriggerString(trig, tT); DrawParameter(y, "Trigger", tT);
227  TString tS; SysString(sys, tS); DrawParameter(y, "System", tS);
228  TString tE; SNNString(sNN, tE); DrawParameter(y, "#sqrt{s_{NN}}", tE);
229  DrawParameter(y, "IP_{z} range", Form("%+5.2fcm - %+5.2fcm",
230  minIpZ, maxIpZ));
231 
232  PrintCanvas("Title page");
233  fParName->SetTextSize(save);
234  fParVal->SetTextSize(save);
235 
236  }
237 };
238 //
239 // EOF
240 //
const char * filename
Definition: TestFCM.C:1
TLatex * fParName
double Double_t
Definition: External.C:58
Base class for classes to draw summaries.
static TH1 * GetH1(const TObject *parent, const TString &name, Bool_t verb=true)
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
static void SysString(UShort_t sys, TString &str)
int Int_t
Definition: External.C:63
TCollection * GetEtaBin(TObject *o, Double_t &etaMin, Double_t &etaMax)
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 PrintCanvas(const TString &title, Float_t size=.7)
void DrawTitlePage(const TCollection *c)
static void SNNString(UShort_t sNN, TString &str)
void CloseCanvas()
void DrawResCollection(TCollection *top, const TString &name)
TLatex * fParVal
TFile * file
void DrawSumCollection(TCollection *top, const TString &name)
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)
void Run(const char *fname="forward_multdists.root", UShort_t flags=kNormal)
Definition: External.C:196
static THStack * GetStack(const TObject *parent, const TString &name, const char *sub=0, Bool_t verb=true)