]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGLF/FORWARD/analysis2/scripts/SummaryMultDistsDrawer.C
Added scripts for Casper/Valentina style P(N_{ch}) analysis
[u/mrichter/AliRoot.git] / PWGLF / FORWARD / analysis2 / scripts / SummaryMultDistsDrawer.C
CommitLineData
bfab35d9 1#include "SummaryDrawer.C"
2#include <TPaveText.h>
3#include <TMultiGraph.h>
4
5class SummaryMultDistsDrawer : public SummaryDrawer
6{
7public:
8 enum {
bfab35d9 9 kNormal = 0xF
10 };
11 SummaryMultDistsDrawer()
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
bfab35d9 31 // --- Force MB for pp ---------------------------------------------
32 TCollection* c = GetCollection(file, "ForwardMultSums");
fba5d22d 33
34 // --- Make a Title page -------------------------------------------
35 DrawTitlePage(c);
36
37 // --- Overview plots ----------------------------------------------
281a2bf8 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");
bfab35d9 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
63protected:
64 TCollection* GetEtaBin(TObject* o, Double_t& etaMin, Double_t& etaMax)
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())) {
fba5d22d 70 // Warning("GetEtaBin", "Don't know how to deal with %s - a %s",
71 // o->GetName(), o->ClassName());
72 return 0;
bfab35d9 73 }
74 TString oN(o->GetName());
75 if (oN.Index(check) == kNPOS) {
fba5d22d 76 // Warning("GetEtaBin", "Collection %s does not match %s",
77 // oN.Data(), re);
bfab35d9 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 {
fba5d22d 97 TCollection* c = GetCollection(top, name, false);
bfab35d9 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);
281a2bf8 111 DrawInPad(fBody, 1, GetH1(bin, "rawDist"), "", kLogy);
fba5d22d 112 DrawInPad(fBody, 1, GetH1(bin, "truthAccepted",false),"same", kLogy);
113 DrawInPad(fBody, 1, GetH1(bin, "truth",false), "same", kLogy|kLegend);
bfab35d9 114 DrawInPad(fBody, 2, GetH1(bin, "coverage"));
115 DrawInPad(fBody, 3, GetH2(bin, "corr"), "colz");
fba5d22d 116 DrawInPad(fBody, 4, GetH2(bin, "response",false), "colz", kLogz);
bfab35d9 117
118 PrintCanvas(Form("%+5.1f < #eta < %+5.1f", etaMin, etaMax));
119 }
120 }
121 //____________________________________________________________________
122 void DrawResCollection(TCollection* top, const TString& name)
123 {
fba5d22d 124 TCollection* c = GetCollection(top, name, false);
bfab35d9 125 if (!c) return;
126
127 THStack* s = GetStack(c, "all");
128 s->SetTitle("");
129 DrawInPad(fBody, 0, s, "nostack", kLogy);
130 TLegend* l = new TLegend(.5, .75, .98, .98, "P(#it{N}_{ch})");
131 l->SetBorderSize(0);
132 // l->SetBorderMode(0);
133 l->SetFillColor(0);
134 l->SetFillStyle(0);
135 TIter next(s->GetHists());
136 TH1* h = 0;
137 Bool_t hasTrue = false;
138 while ((h = static_cast<TH1*>(next()))) {
139 TString n(h->GetTitle());
140 if (n.BeginsWith("True")) { hasTrue = true; continue; }
141 n.ReplaceAll("Raw P(#it{N}_{ch}) in ", "");
142 TLegendEntry* e = l->AddEntry("dummy", n, "p");
143 e->SetMarkerStyle(h->GetMarkerStyle());
144 }
145 if (hasTrue) {
146 TLegendEntry* e = l->AddEntry("dummy", "Raw", "p");
147 e->SetMarkerStyle(20);
148 e->SetMarkerColor(kRed+1);
149 e = l->AddEntry("dummy", "MC truth", "p");
150 e->SetMarkerStyle(24);
151 e->SetMarkerColor(kBlue+1);
281a2bf8 152 e = l->AddEntry("dummy", "MC truth selected", "p");
153 e->SetMarkerStyle(24);
154 e->SetMarkerColor(kOrange+1);
bfab35d9 155 }
156 fBody->cd();
157 l->Draw();
158
159 PrintCanvas(Form("%s results", name.Data()));
160
281a2bf8 161 // return;
bfab35d9 162
163 TIter nextO(c);
164 TObject* o = 0;
165 while ((o = nextO())) {
166 Double_t etaMin = 999;
167 Double_t etaMax = 999;
168 TCollection* bin = GetEtaBin(o, etaMin, etaMax);
169 if (!bin) continue;
170
281a2bf8 171 fBody->Divide(2,3);
172 DrawInPad(fBody, 1, GetH1(bin, "rawDist"), "", kLogy);
173 DrawInPad(fBody, 1, GetH1(bin, "truthAccepted"),"same", kLogy);
174 DrawInPad(fBody, 1, GetH1(bin, "truth"), "same", kLogy|kLegend);
bfab35d9 175 DrawInPad(fBody, 2, GetH1(bin, "coverage"));
176 DrawInPad(fBody, 3, GetH2(bin, "corr"), "colz");
177 DrawInPad(fBody, 4, GetH2(bin, "response"), "colz", kLogz);
281a2bf8 178 DrawInPad(fBody, 5, GetH1(bin, "triggerVertex"));
bfab35d9 179
180 PrintCanvas(Form("%+5.1f < #eta < %+5.1f", etaMin, etaMax));
181 }
182 }
183 //____________________________________________________________________
fba5d22d 184 void DrawTitlePage(const TCollection* c)
bfab35d9 185 {
186 fBody->cd();
187
fba5d22d 188 Double_t y = .7;
189 TLatex* ltx = new TLatex(.5, y, "AOD #rightarrow P(#it{N}_{ch} )");
bfab35d9 190 ltx->SetTextSize(0.07);
fba5d22d 191 ltx->SetTextFont(62);
bfab35d9 192 ltx->SetTextAlign(22);
193 ltx->SetNDC();
194 ltx->Draw();
fba5d22d 195
196 Bool_t mc = GetObject(c, "mcVertex", false) != 0;
197 if (mc) {
198 y -= 0.05;
199 TLatex* sub = new TLatex(.5, y, "(Simulation input)");
200 sub->SetTextSize(0.04);
201 sub->SetTextFont(42);
202 sub->SetTextAlign(22);
203 sub->SetNDC();
204 sub->Draw();
205 }
206
207 Double_t save = fParName->GetTextSize();
208 fParName->SetTextSize(0.03);
209 fParVal->SetTextSize(0.03);
210 y = .6;
211
212 UShort_t sys;
213 UShort_t sNN;
214 ULong_t trig;
215 Double_t minIpZ;
216 Double_t maxIpZ;
217 GetParameter(c, "sys", sys);
218 GetParameter(c, "snn", sNN);
219 GetParameter(c, "trigger", trig);
220 GetParameter(c, "minIpZ", minIpZ);
221 GetParameter(c, "maxIpZ", maxIpZ);
bfab35d9 222
fba5d22d 223 TString tT; TriggerString(trig, tT); DrawParameter(y, "Trigger", tT);
224 TString tS; SysString(sys, tS); DrawParameter(y, "System", tS);
225 TString tE; SNNString(sNN, tE); DrawParameter(y, "#sqrt{s_{NN}}", tE);
226 DrawParameter(y, "IP_{z} range", Form("%+5.2fcm - %+5.2fcm",
227 minIpZ, maxIpZ));
228
229 PrintCanvas("Title page");
230 fParName->SetTextSize(save);
231 fParVal->SetTextSize(save);
232
bfab35d9 233 }
234};
235//
236// EOF
237//