some more updates
[u/mrichter/AliRoot.git] / PWGPP / macros / MakeVtxEffPlots.C
CommitLineData
6fc4a904 1#if !defined(__CINT__) || defined(__MAKECINT__)
2#include "TSystem.h"
3#include "TROOT.h"
4#include <TString.h>
5#include <TH1.h>
6#include <TGraphAsymmErrors.h>
7#include <TCanvas.h>
8#include <TLegend.h>
9#include <TMath.h>
10#include <TFile.h>
11#endif
12
13
14void setDrawAtt(Int_t markerstyle,Int_t markercolor,Int_t markersize,Int_t linecolor,Int_t linewidth,TGraphAsymmErrors *h1)
15{
16 h1->SetMarkerStyle(markerstyle);
17 h1->SetMarkerColor(markercolor);
18 h1->SetMarkerSize(markersize);
19 h1->SetLineColor(linecolor);
20 h1->SetLineWidth(linewidth);
21 }
22void setDrawAtt(Int_t markerstyle,Int_t markercolor,Int_t markersize,Int_t linecolor,Int_t linewidth,TH1 *h1)
23{
24 h1->SetMarkerStyle(markerstyle);
25 h1->SetMarkerColor(markercolor);
26 h1->SetMarkerSize(markersize);
27 h1->SetLineColor(linecolor);
28 h1->SetLineWidth(linewidth);
29 }
30
31void MakeVtxEffPlots(TString foldname="",Bool_t savefile=kFALSE){
d0bbaf02 32
33 //Make efficiency plots for SPD vertex, TRK Vertex and TPC Vertex
34 // Author:
35 // L. Milano, milano@to.infn.it
6fc4a904 36
37 TFile *infil=new TFile(Form("%sAnalysisResults.root",foldname.Data()),"read");
38 TDirectory *dirFile=(TDirectory*)infil->Get("Vertex_Performance");
39 TList *cOutput = (TList*)dirFile->Get("cOutputVtxESD");
40
41 TH1F *fhTriggeredTrklets=(TH1F*)cOutput->FindObject("fhTriggeredTrklets");
42 TH1F *fhSPDZTrklets=(TH1F*)cOutput->FindObject("fhSPDZTrklets");
43 TH1F *fhSPD3DTrklets=(TH1F*)cOutput->FindObject("fhSPD3DTrklets");
44 TH1F *fhTRKTrklets=(TH1F*)cOutput->FindObject("fhTRKTrklets");
45 TH1F *fhTRKcTrklets=(TH1F*)cOutput->FindObject("fhTRKcTrklets");
46 TH1F *fhTRKncTrklets=(TH1F*)cOutput->FindObject("fhTRKncTrklets");
d0bbaf02 47 TH1F *fhTPCTrklets=(TH1F*)cOutput->FindObject("fhTPCTrklets");
48 TH1F *fhTPCcTrklets=(TH1F*)cOutput->FindObject("fhTPCcTrklets");
49 TH1F *fhTPCncTrklets=(TH1F*)cOutput->FindObject("fhTPCncTrklets");
6fc4a904 50 TH1F *fhSPDZZreco=(TH1F*)cOutput->FindObject("fhSPDZZreco");
51 TH1F *fhSPD3DZreco=(TH1F*)cOutput->FindObject("fhSPD3DZreco");
52
53 TGraphAsymmErrors *fhSPDZEffTrklets=new TGraphAsymmErrors(fhSPDZTrklets,fhTriggeredTrklets,"w");
54 fhSPDZEffTrklets->SetName("fhSPDZEffTrklets");
55 fhSPDZEffTrklets->SetDrawOption("AP");
56 TGraphAsymmErrors *fhSPD3DEffTrklets=new TGraphAsymmErrors(fhSPD3DTrklets,fhTriggeredTrklets,"w");
57 fhSPD3DEffTrklets->SetName("fhSPD3DEffTrklets");
58 TH1F * fhSPDOverallTrklets=(TH1F*)fhSPDZTrklets->Clone("fhSPDOverallTrklets");
59 fhSPDOverallTrklets->Add(fhSPD3DTrklets);
60 TGraphAsymmErrors *fhSPDOverallEffTrklets=new TGraphAsymmErrors(fhSPDOverallTrklets,fhTriggeredTrklets,"w");
61 fhSPDOverallEffTrklets->SetName("fhSPDOverallEffTrklets");
62 TGraphAsymmErrors *fhTRKEffTrklets=new TGraphAsymmErrors(fhTRKTrklets,fhTriggeredTrklets,"w");
63 fhTRKEffTrklets->SetName("fhTRKEffTrklets");
64 TGraphAsymmErrors *fhTRKcEffTrklets=new TGraphAsymmErrors(fhTRKcTrklets,fhTriggeredTrklets,"w");
65 fhTRKcEffTrklets->SetName("fhTRKcEffTrklets");
66 TGraphAsymmErrors *fhTRKncEffTrklets=new TGraphAsymmErrors(fhTRKncTrklets,fhTriggeredTrklets,"w");
67 fhTRKncEffTrklets->SetName("fhTRKncEffTrklets");
d0bbaf02 68 TGraphAsymmErrors *fhTPCEffTrklets=new TGraphAsymmErrors(fhTPCTrklets,fhTriggeredTrklets,"w");
69 fhTPCEffTrklets->SetName("fhTPCEffTrklets");
70 TGraphAsymmErrors *fhTPCcEffTrklets=new TGraphAsymmErrors(fhTPCcTrklets,fhTriggeredTrklets,"w");
71 fhTPCcEffTrklets->SetName("fhTPCcEffTrklets");
72 TGraphAsymmErrors *fhTPCncEffTrklets=new TGraphAsymmErrors(fhTPCncTrklets,fhTriggeredTrklets,"w");
73 fhTPCncEffTrklets->SetName("fhTPCncEffTrklets");
6fc4a904 74 TH1F * fhSPDOverallZreco=(TH1F*)fhSPDZZreco->Clone("fhSPDOverallZreco");
75 fhSPDOverallZreco->Add(fhSPD3DZreco);
76 TGraphAsymmErrors *fhSPDEffZreco=new TGraphAsymmErrors(fhSPD3DZreco,fhSPDOverallZreco,"w");
77 fhSPDEffZreco->SetName("fhSPDEffZreco");
78
d0bbaf02 79 TH1F *fhEff = new TH1F("hEff","hEff",9,0.5,9.5);
6fc4a904 80 Int_t count=1;
81 if(fhSPDZTrklets->GetEntries()!=0 && fhTriggeredTrklets->GetEntries()!=0){
82 fhEff->Fill(count,fhSPDZTrklets->GetEntries()/fhTriggeredTrklets->GetEntries());
83 fhEff->SetBinError(count,fhEff->GetBinContent(count)*TMath::Sqrt(1/fhSPDZTrklets->GetEntries()+1/fhTriggeredTrklets->GetEntries()));
84 }
85 fhEff->GetXaxis()->SetBinLabel(count,"SPDZ");
86
87 count++;
88 if(fhSPD3DTrklets->GetEntries()!=0 && fhTriggeredTrklets->GetEntries()!=0){
89 fhEff->Fill(count,fhSPD3DTrklets->GetEntries()/fhTriggeredTrklets->GetEntries());
90 fhEff->SetBinError(count,fhEff->GetBinContent(count)*TMath::Sqrt(1/fhSPD3DTrklets->GetEntries()+1/fhTriggeredTrklets->GetEntries()));
91 }
92 fhEff->GetXaxis()->SetBinLabel(count,"SPD3D");
93
94 count++;
95 if(fhSPDOverallTrklets->GetEntries()!=0 && fhTriggeredTrklets->GetEntries()!=0){
96 fhEff->Fill(count,fhSPDOverallTrklets->GetEntries()/fhTriggeredTrklets->GetEntries());
97 fhEff->SetBinError(count,fhEff->GetBinContent(count)*TMath::Sqrt(1/fhSPDOverallTrklets->GetEntries()+1/fhTriggeredTrklets->GetEntries()));
98 }
99 fhEff->GetXaxis()->SetBinLabel(count,"SPD Overall");
100
101 count++;
102 if(fhTRKTrklets->GetEntries()!=0 && fhTriggeredTrklets->GetEntries()!=0){
103 fhEff->Fill(count,fhTRKTrklets->GetEntries()/fhTriggeredTrklets->GetEntries());
104 fhEff->SetBinError(count,fhEff->GetBinContent(count)*TMath::Sqrt(1/fhTRKTrklets->GetEntries()+1/fhTriggeredTrklets->GetEntries()));
105 }
106 fhEff->GetXaxis()->SetBinLabel(count,"TRK");
107
108 count++;
109 if(fhTRKcTrklets->GetEntries()!=0 && fhTriggeredTrklets->GetEntries()!=0){
110 fhEff->Fill(count,fhTRKcTrklets->GetEntries()/fhTriggeredTrklets->GetEntries());
111 fhEff->SetBinError(count,fhEff->GetBinContent(count)*TMath::Sqrt(1/fhTRKcTrklets->GetEntries()+1/fhTriggeredTrklets->GetEntries()));
112 }
113 fhEff->GetXaxis()->SetBinLabel(count,"TRKc");
114
115 count++;
116 if(fhTRKncTrklets->GetEntries()!=0 && fhTriggeredTrklets->GetEntries()!=0){
117 fhEff->Fill(count,fhTRKncTrklets->GetEntries()/fhTriggeredTrklets->GetEntries());
118 fhEff->SetBinError(count,fhEff->GetBinContent(count)*TMath::Sqrt(1/fhTRKncTrklets->GetEntries()+1/fhTriggeredTrklets->GetEntries()));
119 }
120 fhEff->GetXaxis()->SetBinLabel(count,"TRKnc");
121
122 count++;
d0bbaf02 123 if(fhTPCTrklets->GetEntries()!=0 && fhTriggeredTrklets->GetEntries()!=0){
124 fhEff->Fill(count,fhTPCTrklets->GetEntries()/fhTriggeredTrklets->GetEntries());
125 fhEff->SetBinError(count,fhEff->GetBinContent(count)*TMath::Sqrt(1/fhTPCTrklets->GetEntries()+1/fhTriggeredTrklets->GetEntries()));
126 }
127 fhEff->GetXaxis()->SetBinLabel(count,"TPC");
128
129 count++;
130 if(fhTPCcTrklets->GetEntries()!=0 && fhTriggeredTrklets->GetEntries()!=0){
131 fhEff->Fill(count,fhTPCcTrklets->GetEntries()/fhTriggeredTrklets->GetEntries());
132 fhEff->SetBinError(count,fhEff->GetBinContent(count)*TMath::Sqrt(1/fhTPCcTrklets->GetEntries()+1/fhTriggeredTrklets->GetEntries()));
133 }
134 fhEff->GetXaxis()->SetBinLabel(count,"TPCc");
135
136 count++;
137 if(fhTPCncTrklets->GetEntries()!=0 && fhTriggeredTrklets->GetEntries()!=0){
138 fhEff->Fill(count,fhTPCncTrklets->GetEntries()/fhTriggeredTrklets->GetEntries());
139 fhEff->SetBinError(count,fhEff->GetBinContent(count)*TMath::Sqrt(1/fhTPCncTrklets->GetEntries()+1/fhTriggeredTrklets->GetEntries()));
140 }
141 fhEff->GetXaxis()->SetBinLabel(count,"TPCnc");
6fc4a904 142
143 TCanvas *canvSPDTrklets=new TCanvas("canvSPDTrklets","SPD Eff vs tracklet multiplicy");
144 canvSPDTrklets->SetBottomMargin(0.14);
145 canvSPDTrklets->SetTopMargin(0.08);
146 canvSPDTrklets->SetLeftMargin(0.14);
147 canvSPDTrklets->SetRightMargin(0.08);
148 fhSPDZEffTrklets->SetMinimum(0);
149 fhSPDZEffTrklets->SetMaximum(1.2);
6fc4a904 150 fhSPDZEffTrklets->GetXaxis()->SetTitle("tracklet multiplicity");
151 fhSPDZEffTrklets->GetXaxis()->SetTitleSize(0.05);
152 fhSPDZEffTrklets->GetYaxis()->SetTitle("efficiency");
153 fhSPDZEffTrklets->GetYaxis()->SetTitleSize(0.05);
154 setDrawAtt(22,4,2,4,2,fhSPDZEffTrklets);
155 setDrawAtt(23,2,2,2,2,fhSPD3DEffTrklets);
156 setDrawAtt(24,1,2,1,2,fhSPDOverallEffTrklets);
157 fhSPDZEffTrklets->SetTitle("SPDZ efficiency");
158 fhSPDZEffTrklets->Draw("ALP");
159 fhSPD3DEffTrklets->Draw("PLSAME");
160 fhSPDOverallEffTrklets->Draw("PLSAME");
161 TLegend *legSPD=new TLegend(0.6,0.2,0.9,0.4);
162 legSPD->AddEntry(fhSPD3DEffTrklets,"SPD3D","P");
163 legSPD->AddEntry(fhSPDZEffTrklets,"SPDZ","P");
164 legSPD->AddEntry(fhSPDOverallEffTrklets,"SPDZ + SPD3D","P");
165 legSPD->Draw();
166
167 TCanvas *canvTRKTrklets=new TCanvas("canvTRKTrklets","TRK Eff vs tracklet multiplicy");
168 canvTRKTrklets->SetBottomMargin(0.14);
169 canvTRKTrklets->SetTopMargin(0.08);
170 canvTRKTrklets->SetLeftMargin(0.14);
171 canvTRKTrklets->SetRightMargin(0.08);
172 fhTRKEffTrklets->SetMinimum(0);
173 fhTRKEffTrklets->SetMaximum(1.2);
6fc4a904 174 fhTRKEffTrklets->GetXaxis()->SetTitle("tracklet multiplicity");
175 fhTRKEffTrklets->GetXaxis()->SetTitleSize(0.05);
176 fhTRKEffTrklets->GetYaxis()->SetTitle("efficiency");
177 fhTRKEffTrklets->GetYaxis()->SetTitleSize(0.05);
178 setDrawAtt(22,4,2,4,2,fhTRKEffTrklets);
179 setDrawAtt(23,2,2,2,2,fhTRKcEffTrklets);
180 setDrawAtt(24,1,2,1,2,fhTRKncEffTrklets);
181 fhTRKEffTrklets->SetTitle("TRK efficiency");
182 fhTRKEffTrklets->Draw("ALP");
183 fhTRKcEffTrklets->Draw("PLSAME");
184 fhTRKncEffTrklets->Draw("PLSAME");
185 TLegend *legTRK=new TLegend(0.6,0.2,0.9,0.4);
186 legTRK->AddEntry(fhTRKEffTrklets,"TRK","P");
187 legTRK->AddEntry(fhTRKcEffTrklets,"TRKc","P");
188 legTRK->AddEntry(fhTRKncEffTrklets,"TRKnc","P");
189 legTRK->Draw();
190
d0bbaf02 191 TCanvas *canvTPCTrklets=new TCanvas("canvTPCTrklets","TPC Eff vs tracklet multiplicy");
192 canvTPCTrklets->SetBottomMargin(0.14);
193 canvTPCTrklets->SetTopMargin(0.08);
194 canvTPCTrklets->SetLeftMargin(0.14);
195 canvTPCTrklets->SetRightMargin(0.08);
196 fhTPCEffTrklets->SetMinimum(0);
197 fhTPCEffTrklets->SetMaximum(1.2);
198 fhTPCEffTrklets->GetXaxis()->SetTitle("tracklet multiplicity");
199 fhTPCEffTrklets->GetXaxis()->SetTitleSize(0.05);
200 fhTPCEffTrklets->GetYaxis()->SetTitle("efficiency");
201 fhTPCEffTrklets->GetYaxis()->SetTitleSize(0.05);
202 setDrawAtt(22,4,2,4,2,fhTPCEffTrklets);
203 setDrawAtt(23,2,2,2,2,fhTPCcEffTrklets);
204 setDrawAtt(24,1,2,1,2,fhTPCncEffTrklets);
205 fhTPCEffTrklets->SetTitle("TPC efficiency");
206 fhTPCEffTrklets->Draw("ALP");
207 fhTPCcEffTrklets->Draw("PLSAME");
208 fhTPCncEffTrklets->Draw("PLSAME");
209 TLegend *legTPC=new TLegend(0.6,0.2,0.9,0.4);
210 legTPC->AddEntry(fhTPCEffTrklets,"TPC","P");
211 legTPC->AddEntry(fhTPCcEffTrklets,"TPCc","P");
212 legTPC->AddEntry(fhTPCncEffTrklets,"TPCnc","P");
213 legTPC->Draw();
214
6fc4a904 215 TCanvas *canvZ=new TCanvas("canvZ","3D/reco vs Z");
216 canvZ->SetBottomMargin(0.14);
217 canvZ->SetTopMargin(0.08);
218 canvZ->SetLeftMargin(0.14);
219 canvZ->SetRightMargin(0.08);
220 fhSPDEffZreco->SetMinimum(0);
221 fhSPDEffZreco->SetMaximum(1.2);
222 fhSPDEffZreco->GetXaxis()->SetTitle("Z - <Z> [cm]");
223 fhSPDEffZreco->GetXaxis()->SetTitleSize(0.05);
224 fhSPDEffZreco->GetYaxis()->SetTitle("3D rec / (3D+Z rec)");
225 fhSPDEffZreco->GetYaxis()->SetTitleSize(0.05);
226 setDrawAtt(22,4,2,4,2,fhSPDEffZreco);
227 fhSPDEffZreco->SetTitle("SPD3D/(SPD3D+Z) vs Zreco");
228 fhSPDEffZreco->Draw("AP");
229 TLegend *legZ=new TLegend(0.6,0.2,0.9,0.4);
230 legZ->AddEntry(fhSPDEffZreco,"SPD3D/(SPD3D+Z) vs Zreco","P");
231 legZ->Draw();
232
233 TCanvas *canvOverall=new TCanvas("canvOverall","Eff integrated over multiplicy");
234 canvOverall->SetBottomMargin(0.14);
235 canvOverall->SetTopMargin(0.08);
236 canvOverall->SetLeftMargin(0.14);
237 canvOverall->SetRightMargin(0.08);
238 fhEff->SetMinimum(0);
239 fhEff->SetMaximum(1.2);
6fc4a904 240 fhEff->GetXaxis()->SetTitleSize(0.05);
241 fhEff->GetYaxis()->SetTitle("efficiency");
242 fhEff->GetYaxis()->SetTitleSize(0.05);
243 fhEff->SetTitle("integrated over multiplicity");
244 fhEff->Draw("");
245
246 if(savefile){
247 TFile* fileEff = new TFile("VtxEff.root","recreate");
248 fhSPDZEffTrklets->Write();
249 fhSPD3DEffTrklets->Write();
250 fhSPDOverallEffTrklets->Write();
251 fhTRKEffTrklets->Write();
252 fhTRKcEffTrklets->Write();
253 fhTRKncEffTrklets->Write();
254 fhSPDEffZreco->Write();
255 fhEff->Write();
256 fileEff->Close();
257 delete fileEff;
258 }
259
260
261}
262
263
264