]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGLF/FORWARD/analysis2/scripts/SummaryMultDistsDrawer.C
upated for flattering
[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 {
9 kLandscape = 0x20,
10 kPause = 0x40,
11 kNormal = 0xF
12 };
13 SummaryMultDistsDrawer()
14 : SummaryDrawer()
15 {}
16 //____________________________________________________________________
17 void Run(const char* fname="forward_multdists.root", UShort_t flags=kNormal)
18 {
19 // --- Open the file -----------------------------------------------
20 TString filename(fname);
21 TFile* file = TFile::Open(filename.Data(), "READ");
22 if (!file) {
23 Error("Run", "Failed to open \"%s\"", filename.Data());
24 return;
25 }
26 fPause = flags & kPause;
27
28 // --- Make our canvas ---------------------------------------------
29 TString pdfName(filename);
30 pdfName.ReplaceAll(".root", ".pdf");
31 CreateCanvas(pdfName, flags & kLandscape);
32
33 // --- Make a Title page -------------------------------------------
34 DrawTitlePage();
35
36 // --- Force MB for pp ---------------------------------------------
37 TCollection* c = GetCollection(file, "ForwardMultSums");
38
281a2bf8 39 fBody->Divide(1,3);
40 DrawInPad(fBody, 1, GetH1(c, "triggers"), "hist text30");
41 DrawInPad(fBody, 2, GetH1(c, "status"), "hist text30");
42 DrawInPad(fBody, 3, GetH1(c, "diagnostics"),"colz text");
bfab35d9 43 PrintCanvas("Overview");
44
45 DrawSumCollection(c, "symmetric");
46 DrawSumCollection(c, "negative");
47 DrawSumCollection(c, "positive");
48 DrawSumCollection(c, "other");
49
50 c = GetCollection(file, "ForwardMultResults");
51 if (!c) {
52 CloseCanvas();
53 return;
54 }
55
56 DrawResCollection(c, "symmetric");
57 DrawResCollection(c, "negative");
58 DrawResCollection(c, "positive");
59 DrawResCollection(c, "other");
60
61 CloseCanvas();
62 }
63
64protected:
65 TCollection* GetEtaBin(TObject* o, Double_t& etaMin, Double_t& etaMax)
66 {
67 const char* re = "[pm][0-9]*d[0-9]*_[pm][0-9]*d[0-9]*";
68 TRegexp check(re);
69
70 if (!o->IsA()->InheritsFrom(TCollection::Class())) {
71 Warning("GetEtaBin", "Don't know how to deal with %s - a %s",
72 o->GetName(), o->ClassName());
73 return 0;;
74 }
75 TString oN(o->GetName());
76 if (oN.Index(check) == kNPOS) {
77 Warning("GetEtaBin", "Collection %s does not match %s",
78 oN.Data(), re);
79 return 0;
80 }
81 Int_t ul = oN.Index("_");
82 TString sMin = oN(0, ul);
83 TString sMax = oN(ul+1, oN.Length()-ul-1);
84 sMin.ReplaceAll("p", "+");
85 sMin.ReplaceAll("m", "-");
86 sMin.ReplaceAll("d", ".");
87 sMax.ReplaceAll("p", "+");
88 sMax.ReplaceAll("m", "-");
89 sMax.ReplaceAll("d", ".");
90 etaMin = sMin.Atof();
91 etaMax = sMax.Atof();
92
93 return static_cast<TCollection*>(o);
94 }
95 //____________________________________________________________________
96 void DrawSumCollection(TCollection* top, const TString& name)
97 {
98 TCollection* c = GetCollection(top, name);
99 if (!c) return;
100
101 PrintCanvas(Form("Sums - %s", name.Data()));
102
103 TIter next(c);
104 TObject* o = 0;
105 while ((o = next())) {
106 Double_t etaMin = 999;
107 Double_t etaMax = 999;
108 TCollection* bin = GetEtaBin(o, etaMin, etaMax);
109 if (!bin) continue;
110
111 fBody->Divide(2,2);
281a2bf8 112 DrawInPad(fBody, 1, GetH1(bin, "rawDist"), "", kLogy);
113 DrawInPad(fBody, 1, GetH1(bin, "truthAccepted"),"same", kLogy);
114 DrawInPad(fBody, 1, GetH1(bin, "truth"), "same", kLogy|kLegend);
bfab35d9 115 DrawInPad(fBody, 2, GetH1(bin, "coverage"));
116 DrawInPad(fBody, 3, GetH2(bin, "corr"), "colz");
117 DrawInPad(fBody, 4, GetH2(bin, "response"), "colz", kLogz);
118
119 PrintCanvas(Form("%+5.1f < #eta < %+5.1f", etaMin, etaMax));
120 }
121 }
122 //____________________________________________________________________
123 void DrawResCollection(TCollection* top, const TString& name)
124 {
125 TCollection* c = GetCollection(top, name);
126 if (!c) return;
127
128 THStack* s = GetStack(c, "all");
129 s->SetTitle("");
130 DrawInPad(fBody, 0, s, "nostack", kLogy);
131 TLegend* l = new TLegend(.5, .75, .98, .98, "P(#it{N}_{ch})");
132 l->SetBorderSize(0);
133 // l->SetBorderMode(0);
134 l->SetFillColor(0);
135 l->SetFillStyle(0);
136 TIter next(s->GetHists());
137 TH1* h = 0;
138 Bool_t hasTrue = false;
139 while ((h = static_cast<TH1*>(next()))) {
140 TString n(h->GetTitle());
141 if (n.BeginsWith("True")) { hasTrue = true; continue; }
142 n.ReplaceAll("Raw P(#it{N}_{ch}) in ", "");
143 TLegendEntry* e = l->AddEntry("dummy", n, "p");
144 e->SetMarkerStyle(h->GetMarkerStyle());
145 }
146 if (hasTrue) {
147 TLegendEntry* e = l->AddEntry("dummy", "Raw", "p");
148 e->SetMarkerStyle(20);
149 e->SetMarkerColor(kRed+1);
150 e = l->AddEntry("dummy", "MC truth", "p");
151 e->SetMarkerStyle(24);
152 e->SetMarkerColor(kBlue+1);
281a2bf8 153 e = l->AddEntry("dummy", "MC truth selected", "p");
154 e->SetMarkerStyle(24);
155 e->SetMarkerColor(kOrange+1);
bfab35d9 156 }
157 fBody->cd();
158 l->Draw();
159
160 PrintCanvas(Form("%s results", name.Data()));
161
281a2bf8 162 // return;
bfab35d9 163
164 TIter nextO(c);
165 TObject* o = 0;
166 while ((o = nextO())) {
167 Double_t etaMin = 999;
168 Double_t etaMax = 999;
169 TCollection* bin = GetEtaBin(o, etaMin, etaMax);
170 if (!bin) continue;
171
281a2bf8 172 fBody->Divide(2,3);
173 DrawInPad(fBody, 1, GetH1(bin, "rawDist"), "", kLogy);
174 DrawInPad(fBody, 1, GetH1(bin, "truthAccepted"),"same", kLogy);
175 DrawInPad(fBody, 1, GetH1(bin, "truth"), "same", kLogy|kLegend);
bfab35d9 176 DrawInPad(fBody, 2, GetH1(bin, "coverage"));
177 DrawInPad(fBody, 3, GetH2(bin, "corr"), "colz");
178 DrawInPad(fBody, 4, GetH2(bin, "response"), "colz", kLogz);
281a2bf8 179 DrawInPad(fBody, 5, GetH1(bin, "triggerVertex"));
bfab35d9 180
181 PrintCanvas(Form("%+5.1f < #eta < %+5.1f", etaMin, etaMax));
182 }
183 }
184 //____________________________________________________________________
185 void DrawTitlePage()
186 {
187 fBody->cd();
188
189 Double_t y = .9;
190 TLatex* ltx = new TLatex(.5, y, "P(#it{N}_{ch} )");
191 ltx->SetTextSize(0.07);
192 ltx->SetTextFont(22);
193 ltx->SetTextAlign(22);
194 ltx->SetNDC();
195 ltx->Draw();
196
197 PrintCanvas("Multiplicity Distributions");
198 }
199};
200//
201// EOF
202//