]>
Commit | Line | Data |
---|---|---|
c484014f | 1 | /* |
2 | * | |
3 | ||
4 | .L $ALICE_ROOT/TPC/Upgrade/macros/finalPlots.C+g | |
5 | finalPlots("eps10/medStat/*.debug.root","eps20/medStat/*.debug.root") | |
6 | ||
7 | finalPlots("eps10/medStat/*.debug.root","eps20/medStat/*.debug.root","/data/Work/software/svncern/papers/TDR/08-Monitoring_calib/figs") | |
8 | ||
9 | ||
10 | */ | |
11 | ||
12 | #include "TLegend.h" | |
13 | #include "TCanvas.h" | |
14 | #include "TString.h" | |
15 | #include "TStyle.h" | |
16 | #include "TColor.h" | |
17 | #include "TPaveStats.h" | |
18 | #include "TH1.h" | |
19 | #include "TFile.h" | |
20 | #include "TTree.h" | |
21 | #include "TROOT.h" | |
22 | #include "TSystem.h" | |
23 | #include "AliToyMCReconstruction.h" | |
24 | ||
25 | void SetStyle(); | |
26 | TCanvas *GetCanvas(TString name, TString title, Float_t nx=1, Float_t ny=1); | |
27 | void SaveCanvas(TCanvas *c); | |
28 | void DrawOnTop(TPad *c, TObjArray &arrHists, Bool_t stats); | |
29 | ||
30 | TString fSaveDir; | |
31 | ||
32 | void finalPlots(const char* filesEps10, const char* filesEps20, TString saveDir="") | |
33 | { | |
34 | fSaveDir=saveDir; | |
35 | ||
36 | TString idealUndistorted("t1_0_0_130_10."); | |
37 | TString idealDistorted("t1_1_3_130_10."); | |
38 | TString distorted("t0_1_0_130_10."); | |
39 | TString realTracking("t0_1_2_130_10."); | |
40 | ||
41 | SetStyle(); | |
42 | ||
43 | TTree *tEps10=AliToyMCReconstruction::ConnectTrees(filesEps10); | |
44 | TTree *tEps20=AliToyMCReconstruction::ConnectTrees(filesEps20); | |
45 | ||
46 | TString test(tEps10->GetCurrentFile()->GetName()); | |
47 | if (!test.Contains("0_0_0_")) { | |
48 | printf("ERROR: default file is not '0_0_0'\n"); | |
49 | return; | |
50 | } | |
51 | ||
52 | if (tEps10->GetListOfFriends()->GetEntries()!=5 || tEps20->GetListOfFriends()->GetEntries()!=5) { | |
53 | printf("ERROR: wrong number of entries in the friends, not default\n"); | |
54 | return; | |
55 | } | |
56 | ||
57 | TString drawStr; | |
58 | ||
59 | // | |
60 | // T0seed resolution | |
61 | // | |
62 | TCanvas *cT0res=GetCanvas("T0seedResolution","T0 seed resolution"); | |
63 | //ideal undistorted | |
64 | TH1F *hT0resI = new TH1F("hT0resI","T0 resolution;(#it{t}_{0}^{seed}-#it{t}_{0}) #upoint #it{v}_{drift};#tracks",100,-50.1,50.1); | |
65 | drawStr=Form("(%sfTime0-t0)*vDrift",idealUndistorted.Data()); | |
66 | tEps20->Draw(drawStr+">>hT0resI","","goff"); | |
67 | //fully distorted | |
68 | TH1F *hT0resD = new TH1F("hT0resD","T0 resolution;(#it{t}_{0}^{seed}-#it{t}_{0}) #upoint #it{v}_{drift};#tracks",100,-50.1,50.1); | |
69 | hT0resD->SetLineColor(kRed); | |
70 | drawStr=Form("(%sfTime0-t0)*vDrift",distorted.Data()); | |
71 | tEps20->Draw(drawStr+">>hT0resD","","goff"); | |
72 | //distorted and average correction | |
73 | TH1F *hT0resDC = new TH1F("hT0resDC","T0 resolution;(#it{t}_{0}^{seed}-#it{t}_{0}) #upoint #it{v}_{drift};#tracks",100,-50.1,50.1); | |
74 | // hT0resDC->SetLineColor(kGreen+2); | |
75 | drawStr=Form("(%sfTime0-t0)*vDrift",realTracking.Data()); | |
76 | tEps20->Draw(drawStr+">>hT0resDC","","goff"); | |
77 | ||
78 | // hT0resI->Draw(); | |
79 | // hT0resD->Draw("same"); | |
80 | hT0resDC->Draw(/*"same"*/); | |
81 | ||
82 | SaveCanvas(cT0res); | |
83 | ||
84 | // | |
85 | // Track parameter resolution (y) with ideal clusters at the ITS and inner wall of the TPC | |
86 | // | |
87 | TCanvas *cYresComparison=GetCanvas("YresComparison","Comparison of Yres for ideal clusters"); | |
88 | //ideal clusters at the ITS outermost point | |
89 | TH1F *hYresITS = new TH1F("hYresITS",";#it{y}_{TPC}-#it{y}_{ITS};#tracks",100,-0.21,0.21); | |
90 | drawStr=Form("%strackITS.fP[0]-%stRealITS.fP[0]",idealUndistorted.Data(),idealUndistorted.Data()); | |
91 | tEps20->Draw(drawStr+">>hYresITS","","goff"); | |
92 | hYresITS->SetLineColor(kRed); | |
93 | ||
94 | TH1F *hYresTPC = new TH1F("hYresTPC",";#it{y}_{TPC}-#it{y}_{ITS};#tracks",100,-0.21,0.21); | |
95 | drawStr=Form("%strackITS2.fP[0]-%stRealITS2.fP[0]",idealUndistorted.Data(),idealUndistorted.Data()); | |
96 | tEps20->Draw(drawStr+">>hYresTPC","","goff"); | |
97 | ||
98 | hYresTPC->Draw(); | |
99 | hYresITS->Draw("same"); | |
100 | ||
101 | SaveCanvas(cYresComparison); | |
102 | ||
103 | // | |
104 | // Track parameter resolution (y) with fully distorted clusters at the inner wall of the TPC | |
105 | // | |
106 | ||
107 | TCanvas *cYresDistorted=GetCanvas("YresDistorted","Yres for fully distorted clusters"); | |
108 | //ideal clusters at the ITS outermost point | |
109 | TH1F *hYresDist = new TH1F("hYresDist",";#it{y}_{TPC}-#it{y}_{ITS};#tracks",100,-15.5,15.5); | |
110 | drawStr=Form("%strackITS2.fP[0]-%stRealITS2.fP[0]",distorted.Data(),distorted.Data()); | |
111 | tEps20->Draw(drawStr+">>hYresDist","","goff"); | |
112 | ||
113 | hYresDist->Draw(); | |
114 | ||
115 | SaveCanvas(cYresDistorted); | |
116 | ||
117 | // | |
118 | // Track parameter resolution (y) with fully distorted and corrected clusters (Tzero seed) | |
119 | // at the inner wall of the TPC | |
120 | // | |
121 | ||
122 | TCanvas *cYresDistCorrTzeroSeed=GetCanvas("YresDistCorrTzeroSeed","Yres for fully distorted/corrected clusters (Tzero seed)"); | |
123 | //ideal clusters at the ITS outermost point | |
124 | TH1F *hYresDistCorrTzeroSeed = new TH1F("hYresDistCorrTzeroSeed",";#it{y}_{TPC}-#it{y}_{ITS};#tracks",100,-.5,1.5); | |
125 | drawStr=Form("%strackITS2.fP[0]-%stRealITS2.fP[0]",realTracking.Data(),realTracking.Data()); | |
126 | tEps20->Draw(drawStr+">>hYresDistCorrTzeroSeed","","goff"); | |
127 | ||
128 | hYresDistCorrTzeroSeed->Draw(); | |
129 | ||
130 | SaveCanvas(cYresDistCorrTzeroSeed); | |
131 | ||
132 | // | |
133 | // Track parameter resolution (y) with fully distorted and corrected clusters (Tzero seed) | |
134 | // at the inner wall of the TPC | |
135 | // | |
136 | ||
137 | TCanvas *cYresDistCorrTzero=GetCanvas("YresDistCorrTzero","Yres for fully distorted/corrected clusters (Tzero)"); | |
138 | //ideal clusters at the ITS outermost point | |
139 | TH1F *hYresDistCorrTzero = new TH1F("hYresDistCorrTzero",";#it{y}_{TPC}-#it{y}_{ITS};#tracks",100,-.5,1.5); | |
140 | drawStr=Form("%strackITS2.fP[0]-%stRealITS2.fP[0]",idealDistorted.Data(),idealDistorted.Data()); | |
141 | tEps20->Draw(drawStr+">>hYresDistCorrTzero","","goff"); | |
142 | ||
143 | hYresDistCorrTzero->Draw(); | |
144 | ||
145 | SaveCanvas(cYresDistCorrTzero); | |
146 | ||
147 | ||
148 | // | |
149 | // plot all params | |
150 | // | |
151 | ||
152 | TString titles[5]={"#it{y}_{TPC}-#it{y}_{ITS}","#it{z}_{TPC}-#it{z}_{ITS}","sin(#it{#alpha})_{TPC}-sin(#it{#alpha})_{ITS}","tan(#it{#lambda})_{TPC}-tan(#it{#lambda})_{ITS}","1/#it{p}_{T TPC}-1/#it{p}_{T ITS}"}; | |
153 | Double_t min[5]={-.5,-0.199,-.009,-.0019,-.039}; | |
154 | Double_t max[5]={1.5, 0.199, .009, .0019, .09}; | |
155 | TString type[3]={idealUndistorted,idealDistorted,realTracking}; | |
156 | Int_t colors[3]={kBlack,kGreen-2,kRed}; | |
157 | ||
158 | TLegend *leg=new TLegend(.1,.55,.95,.95); | |
159 | leg->SetTextSize(0.075); | |
160 | leg->SetBorderSize(1); | |
161 | leg->SetFillColor(10); | |
162 | TCanvas *cResParams=GetCanvas("ResParams","Resolution of parameters",1.2,1.8); | |
163 | cResParams->Divide(2,3); | |
164 | for (Int_t i=0;i<5;++i){ | |
165 | TPad *pad=(TPad*)cResParams->cd(i+1); | |
166 | TObjArray arr; | |
167 | for (Int_t it=0; it<3; ++it) { | |
168 | TH1F *hResParams=new TH1F(Form("hResParams_%d_%d",i,it), | |
169 | Form(";%s;#tracks",titles[i].Data()), | |
170 | 100,min[i],max[i]); | |
171 | drawStr=Form("%strackITS2.fP[%d]-tRealITS2.fP[%d]",type[it].Data(),i,i); | |
172 | tEps20->Draw(drawStr+Form(">>hResParams_%d_%d",i,it),"","goff"); | |
173 | hResParams->SetLineColor(colors[it]); | |
174 | arr.Add(hResParams); | |
175 | } | |
176 | if (i==0) { | |
177 | leg->AddEntry(arr.At(0),"no distortions (ideal)","l"); | |
178 | leg->AddEntry(arr.At(1),"distorted/corrected (t_{0})","l"); | |
179 | leg->AddEntry(arr.At(2),"distorted/corrected (t_{0}^{seed})","l"); | |
180 | } | |
181 | DrawOnTop(pad,arr,kTRUE); | |
182 | } | |
183 | ||
184 | cResParams->cd(6); | |
185 | leg->Draw(); | |
186 | SaveCanvas(cResParams); | |
187 | } | |
188 | ||
189 | ||
190 | TCanvas *GetCanvas(TString name, TString title, Float_t nx, Float_t ny) | |
191 | { | |
192 | TCanvas *c=(TCanvas*)gROOT->GetListOfCanvases()->FindObject(name.Data()); | |
193 | if (!c) c=new TCanvas(name,title,nx*700,ny*500); | |
194 | c->Clear(); | |
195 | c->cd(); | |
196 | return c; | |
197 | } | |
198 | ||
199 | void SaveCanvas(TCanvas *c) | |
200 | { | |
201 | // | |
202 | // | |
203 | // | |
204 | ||
205 | if (fSaveDir.IsNull()) return; | |
206 | ||
207 | c->SaveAs(Form("/tmp/%s.eps",c->GetName())); | |
208 | gSystem->Exec(Form("ps2pdf -dEPSCrop /tmp/%s.eps %s/%s.pdf",c->GetName(),fSaveDir.Data(),c->GetName())); | |
209 | } | |
210 | ||
211 | void DrawOnTop(TPad *c, TObjArray &arrHists, Bool_t /*stats*/) | |
212 | { | |
213 | Double_t min=0,max=0; | |
214 | Double_t ystatMax=gStyle->GetStatY(); | |
215 | Double_t ystatH =gStyle->GetStatH()*2./3.; | |
216 | const Int_t nHists=arrHists.GetEntriesFast(); | |
217 | for (Int_t iHist=0; iHist<nHists; ++iHist) { | |
218 | TH1 *h=(TH1*)arrHists.UncheckedAt(iHist); | |
219 | TPad *pad = new TPad(Form("%s_%d",c->GetName(),iHist+1),"",0,0,1,1); | |
220 | pad->SetFillStyle(4000); | |
221 | pad->SetFrameFillStyle(0); | |
222 | pad->Draw(); | |
223 | pad->cd(); | |
224 | if (iHist>0) { | |
225 | h->SetMinimum(min); | |
226 | h->SetMaximum(max); | |
227 | pad->SetTicky(0); | |
228 | pad->SetTickx(0); | |
229 | } | |
230 | h->Draw((iHist==0)?"":"AH"); | |
231 | pad->Update(); | |
232 | if (iHist==0){ | |
233 | min=pad->GetUymin(); | |
234 | max=pad->GetUymax(); | |
235 | printf("min: %.2f %.2f\n",min,max); | |
236 | } | |
237 | TPaveStats *ps = (TPaveStats*)h->GetListOfFunctions()->FindObject("stats"); | |
238 | if (!ps) printf("shitttt %s\n",h->GetName()); | |
239 | else { | |
240 | ps->SetTextColor(h->GetLineColor()); | |
241 | ps->SetY2NDC(ystatMax-iHist*ystatH); | |
242 | ps->SetY1NDC(ystatMax-(iHist+1)*ystatH);} | |
243 | } | |
244 | } | |
245 | ||
246 | void SetStyle() | |
247 | { | |
248 | const Int_t NCont=255; | |
249 | //const Int_t NCont=50; | |
250 | ||
251 | TStyle *st = new TStyle("mystyle","mystyle"); | |
252 | gROOT->GetStyle("Plain")->Copy((*st)); | |
253 | st->SetTitleX(0.1); | |
254 | st->SetTitleW(0.8); | |
255 | st->SetTitleH(0.08); | |
256 | st->SetStatX(.95); | |
257 | st->SetStatY(.95); | |
258 | st->SetStatW(.25); | |
259 | st->SetStatH(.25); | |
260 | st->SetNumberContours(NCont); | |
261 | st->SetPalette(1,0); | |
262 | st->SetOptStat("rm"); | |
263 | st->SetOptTitle(0); | |
264 | st->SetOptFit(0); | |
265 | st->SetGridColor(kGray+1); | |
266 | // st->SetPadGridX(kTRUE); | |
267 | // st->SetPadGridY(kTRUE); | |
268 | st->SetPadTickX(kTRUE); | |
269 | st->SetPadTickY(kTRUE); | |
270 | st->SetMarkerStyle(20); | |
271 | st->SetMarkerSize(.5); | |
272 | ||
273 | st->SetPadLeftMargin(0.12); | |
274 | st->SetPadBottomMargin(0.12); | |
275 | st->SetPadRightMargin(0.05); | |
276 | st->SetPadTopMargin(0.05); | |
277 | st->cd(); | |
278 | ||
279 | Int_t nimTPCFont=42; //or 62 for sans serif font | |
280 | //default definitions | |
281 | st->SetTextFont(nimTPCFont); | |
282 | st->SetTitleFont(nimTPCFont, "T"); | |
283 | st->SetTitleFont(nimTPCFont, "XYZ"); | |
284 | st->SetLabelFont(nimTPCFont,"XYZ"); | |
285 | st->SetLabelSize(0.045,"XYZ"); | |
286 | st->SetTitleSize(0.05,"XYZ"); | |
287 | st->SetTitleOffset(1.1,"XZ"); | |
288 | st->SetTitleOffset(1.3,"Y"); | |
289 | st->SetStatFont(nimTPCFont); | |
290 | st->SetOptTitle(0); | |
291 | st->SetPalette(1,0); | |
292 | st->SetStatBorderSize(1); | |
293 | new TColor(2001,1,1,1); | |
294 | st->SetFillColor(2001); | |
295 | st->SetTickLength(gStyle->GetTickLength()/696.*472.,"y"); | |
296 | ||
297 | const Int_t NRGBs = 5; | |
298 | Double_t stops[NRGBs] = { 0.00, 0.34, 0.61, 0.84, 1.00 }; | |
299 | Double_t red[NRGBs] = { 0.00, 0.00, 0.87, 1.00, 0.51 }; | |
300 | Double_t green[NRGBs] = { 0.00, 0.81, 1.00, 0.20, 0.00 }; | |
301 | Double_t blue[NRGBs] = { 0.51, 1.00, 0.12, 0.00, 0.00 }; | |
302 | //grey | |
303 | // Double_t stops[5] = {0.00, 0.34, 0.61, 0.84, 1.00}; | |
304 | // Double_t red[5] = {1.00, 0.84, 0.61, 0.34, 0.00}; | |
305 | // Double_t green[5] = {1.00, 0.84, 0.61, 0.34, 0.00}; | |
306 | // Double_t blue[5] = {1.00, 0.84, 0.61, 0.34, 0.00}; | |
307 | ||
308 | TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont); | |
309 | ||
310 | st->cd(); | |
311 | } | |
312 |