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