]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGLF/FORWARD/analysis2/scripts/SummaryMultDistsDrawer.C
Merge branch 'feature-movesplit'
[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);
b767da2c 112 DrawInPad(fBody, 1, GetH1(bin, "truthAccepted",false),"same",
113 kLogy|kSilent);
114 DrawInPad(fBody, 1, GetH1(bin, "truth",false), "same",
115 kLogy|kLegend|kSilent);
bfab35d9 116 DrawInPad(fBody, 2, GetH1(bin, "coverage"));
117 DrawInPad(fBody, 3, GetH2(bin, "corr"), "colz");
b767da2c 118 DrawInPad(fBody, 4, GetH2(bin, "response",false), "colz",kLogz|kSilent);
bfab35d9 119
120 PrintCanvas(Form("%+5.1f < #eta < %+5.1f", etaMin, etaMax));
121 }
122 }
123 //____________________________________________________________________
124 void DrawResCollection(TCollection* top, const TString& name)
125 {
fba5d22d 126 TCollection* c = GetCollection(top, name, false);
bfab35d9 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);
281a2bf8 154 e = l->AddEntry("dummy", "MC truth selected", "p");
155 e->SetMarkerStyle(24);
156 e->SetMarkerColor(kOrange+1);
bfab35d9 157 }
158 fBody->cd();
159 l->Draw();
160
161 PrintCanvas(Form("%s results", name.Data()));
162
281a2bf8 163 // return;
bfab35d9 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
281a2bf8 173 fBody->Divide(2,3);
174 DrawInPad(fBody, 1, GetH1(bin, "rawDist"), "", kLogy);
b767da2c 175 DrawInPad(fBody, 1, GetH1(bin, "truthAccepted", false),
176 "same", kSilent);
177 DrawInPad(fBody, 1, GetH1(bin, "truth", false),"same", kSilent|kLegend);
bfab35d9 178 DrawInPad(fBody, 2, GetH1(bin, "coverage"));
c8b1a7db 179 DrawInPad(fBody, 3, GetH2(bin, "corr"), "colz");
b767da2c 180 DrawInPad(fBody, 4, GetH2(bin, "response", false), "colz", kLogz|kSilent);
181 DrawInPad(fBody, 5, GetH1(bin, "triggerVertex", false), "", kSilent);
bfab35d9 182
183 PrintCanvas(Form("%+5.1f < #eta < %+5.1f", etaMin, etaMax));
184 }
185 }
186 //____________________________________________________________________
fba5d22d 187 void DrawTitlePage(const TCollection* c)
bfab35d9 188 {
189 fBody->cd();
190
fba5d22d 191 Double_t y = .7;
192 TLatex* ltx = new TLatex(.5, y, "AOD #rightarrow P(#it{N}_{ch} )");
bfab35d9 193 ltx->SetTextSize(0.07);
fba5d22d 194 ltx->SetTextFont(62);
bfab35d9 195 ltx->SetTextAlign(22);
196 ltx->SetNDC();
197 ltx->Draw();
fba5d22d 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);
c8b1a7db 221 GetParameter(c, "sNN", sNN);
fba5d22d 222 GetParameter(c, "trigger", trig);
223 GetParameter(c, "minIpZ", minIpZ);
224 GetParameter(c, "maxIpZ", maxIpZ);
bfab35d9 225
fba5d22d 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
bfab35d9 236 }
237};
238//
239// EOF
240//