Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
plot_comparisons_purity.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file plot_comparisons_purity.C
1 #include <TH2D.h>
2 #include <TFile.h>
3 #include <TF1.h>
4 #include <TF2.h>
5 #include <TGraph.h>
6 #include <TCanvas.h>
7 #include <TROOT.h>
8 #include <TStyle.h>
9 #include <TLegend.h>
10 #include <TLatex.h>
11 #include <TLine.h>
12 #include <TColor.h>
13 
14 #include "sPhenixStyle.C"
15 
17 {
18 
20 
21  /*
22  gROOT->SetStyle("Plain");
23  gStyle->SetOptStat(0);
24  gStyle->SetOptFit(0);
25  gStyle->SetOptTitle(0);
26  */
27 
28  bool toymodel = false;
29 
30  static const int NPLOTS = 2;
31  double hptmax = 40.0;
32 
33  TFile *fin[NPLOTS];
34 
35  char label[NPLOTS][500];
36 
37 
38  //fin[0] = new TFile("root_files/mar1_100pions_1ups_look_purity_out.root");
39 
40 
41 
42 
43  /*
44  fin[0] = new TFile("root_files/mar1_100pions_1ups_look_purity_out.root");
45  fin[1] = new TFile("root_files/mar3_100pions_nomvtx_primvtxfit_look_purity_out.root");
46  sprintf(label[0], "100 pions only");
47  sprintf(label[1], "100 pions only, no MVTX");
48  */
49 
50  fin[0] = new TFile("root_files/look_purity_out_100pions_80ns_baseline_noMVTX.root");
51  fin[1] = new TFile("root_files/look_purity_out_central_167khz_80ns_1-5");
52  sprintf(label[0], "100pions");
53  sprintf(label[1], "Central+store average lumi+100pions");
54 
55 
56 
57 
58 
59  TGraph *gdca[NPLOTS];
60  TGraph *gdcaZ[NPLOTS];
61  TGraph *geff[NPLOTS];
62  TGraph *grdpt[NPLOTS];
63 
64  int col[3] = {kRed, kBlue, kBlack};
65 
66  for(int i=0;i<NPLOTS;i++)
67  {
68  if(!fin[i])
69  {
70  cout << "Did not find file " << i << " quit!" << endl;
71  exit(1);
72  }
73 
74  fin[i]->GetObject("single_track_efficiency",geff[i]);
75  fin[i]->GetObject("dca2d_resolution",gdca[i]);
76  fin[i]->GetObject("dcaZ_resolution",gdcaZ[i]);
77  fin[i]->GetObject("pt_resolution",grdpt[i]);
78 
79  if(!geff[i])
80  {
81  cout << "Failed to find geff for " << i << endl;
82  //exit(1);
83  }
84 
85  if(!gdca[i])
86  {
87  cout << "Failed to find gdca for " << i << endl;
88  exit(1);
89  }
90  if(!gdcaZ[i])
91  {
92  cout << "Failed to find gdcaZ for " << i << endl;
93  exit(1);
94  }
95  if(!grdpt[i])
96  {
97  cout << "Failed to find grdpt for " << i << endl;
98  exit(1);
99  }
100  }
101 
102 
103  char lab[500];
104  //sprintf(lab,"Au+Au HIJING b=0-12 fm, 100 kHz pileup");
105  //sprintf(lab,"Au+Au HIJING b=0-12 fm");
106  sprintf(lab,"100 pion events");
107 
108 
109  TCanvas *ceff = new TCanvas("ceff","ceff",50,50,800,800);
110  //ceff->SetLeftMargin(0.12);
111 
112  TH1F *hd = new TH1F("hd","hd",100, 0.0, hptmax);
113  hd->SetMinimum(0.0);
114  hd->SetMaximum(1.1);
115  hd->GetXaxis()->SetTitle("p_{T} (GeV/c)");
116  hd->GetXaxis()->SetTitleOffset(1.15);
117  hd->GetYaxis()->SetTitle("Single track efficiency");
118  hd->GetYaxis()->SetTitleOffset(1.3);
119  hd->Draw();
120 
121  for(int i=0;i<NPLOTS;i++)
122  {
123  geff[i]->SetMarkerColor(col[i]);
124 
125  if(i==0)
126  geff[i]->Draw("p");
127  else
128  geff[i]->Draw("same p");
129  }
130 
131  TLegend *lpd = new TLegend(0.30, 0.45, 0.95, 0.65, "", "NDC");
132  lpd->SetBorderSize(0);
133  lpd->SetFillColor(0);
134  lpd->SetFillStyle(0);
135  for(int i=0;i<NPLOTS;i++)
136  {
137  lpd->AddEntry(geff[i],label[i], "p");
138  }
139  lpd->Draw();
140 
141  TLine *unit = new TLine(0,1.0,40,1.0);
142  unit->SetLineStyle(3);
143  unit->SetLineWidth(1);
144  unit->Draw();
145 
146  //for(int i=0;i<2;i++)
147  //lmax[i]->Draw();
148 
149  TCanvas *cdca = new TCanvas("cdca","cdca",50,50,800,800);
150  //cdca->SetLeftMargin(0.15);
151 
152 
153  TH1F *hdca = new TH1F("hdca","hdca",100, 0.0, hptmax);
154  hdca->SetMinimum(0.0003);
155  hdca->SetMaximum(0.02);
156  hdca->GetXaxis()->SetTitle("p_{T} (GeV/c)");
157  hdca->GetXaxis()->SetTitleOffset(1.25);
158  hdca->GetYaxis()->SetTitle("DCA(r#phi) resolution (cm)");
159  hdca->GetYaxis()->SetTitleOffset(1.4);
160  hdca->Draw();
161 
162  gPad->SetLogy(1);
163 
164  for(int i=0;i<NPLOTS;i++)
165  {
166  gdca[i]->SetMarkerColor(col[i]);
167 
168  if(i==0)
169  gdca[i]->Draw("p");
170  else
171  gdca[i]->Draw("same p");
172  }
173 
174  TLegend *lpd1 = new TLegend(0.30, 0.7, 0.95, 0.92, "", "NDC");
175  lpd1->SetBorderSize(0);
176  lpd1->SetFillColor(0);
177  lpd1->SetFillStyle(0);
178  for(int i=0;i<NPLOTS;i++)
179  {
180  lpd1->AddEntry(gdca[i],label[i], "p");
181  }
182 
183  lpd1->Draw();
184 
185  TCanvas *cdcaz = new TCanvas("cdcaz","cdcaz",50,50,800,800);
186  //cdcaz->SetLeftMargin(0.15);
187 
188  TH1F *hdcaz = new TH1F("hdcaz","hdcaz",100, 0.0, hptmax);
189  hdcaz->SetMinimum(0.0003);
190  hdcaz->SetMaximum(0.02);
191  hdcaz->GetXaxis()->SetTitle("p_{T} (GeV/c)");
192  hdcaz->GetXaxis()->SetTitleOffset(1.25);
193  hdcaz->GetYaxis()->SetTitle("DCA(Z) resolution (cm)");
194  hdcaz->GetYaxis()->SetTitleOffset(1.4);
195  hdcaz->Draw();
196 
197  gPad->SetLogy(1);
198 
199  for(int i=0;i<NPLOTS;i++)
200  {
201  gdcaZ[i]->SetMarkerColor(col[i]);
202 
203  if(i==0)
204  gdcaZ[i]->Draw("p");
205  else
206  gdcaZ[i]->Draw("same p");
207  }
208 
209  TLegend *lpd1z = new TLegend(0.30, 0.70, 0.95, 0.92, "", "NDC");
210  lpd1z->SetBorderSize(0);
211  lpd1z->SetFillColor(0);
212  lpd1z->SetFillStyle(0);
213  lpd1z->AddEntry(geff[0],label[0], "p");
214  lpd1z->AddEntry(geff[1], label[1], "p");
215  lpd1z->Draw();
216 
217 
218  double hdptmax = 40.0;
219  //double hdptmax = 39.0;
220 
221  TCanvas *crdpt = new TCanvas("crdpt","crdpt",50,50,800,800);
222  //crdpt->SetLeftMargin(0.15);
223 
224  TH1F *hrdpt = new TH1F("hrdpt","hrdpt",100, 0.0, hdptmax);
225  hrdpt->SetMinimum(0.0);
226  hrdpt->SetMaximum(0.11);
227  hrdpt->GetXaxis()->SetTitle("p_{T} (GeV/c)");
228  hrdpt->GetXaxis()->SetTitleOffset(1.25);
229  hrdpt->GetYaxis()->SetTitle("#Delta p_{T} / p_{T}");
230  hrdpt->GetYaxis()->SetTitleOffset(1.5);
231  hrdpt->Draw();
232 
233  for(int i=0;i<NPLOTS;i++)
234  {
235  grdpt[i]->SetMarkerColor(col[i]);
236 
237  if(i==0)
238  grdpt[i]->Draw("p");
239  else
240  grdpt[i]->Draw("same p");
241  }
242 
243  TLegend *lpd2 = new TLegend(0.15, 0.72, 0.85, 0.87, "", "NDC");
244  lpd2->SetBorderSize(0);
245  lpd2->SetFillColor(0);
246  lpd2->SetFillStyle(0);
247  lpd2->AddEntry(grdpt[0], label[0], "p");
248  lpd2->AddEntry(grdpt[1], label[1], "p");
249  lpd2->Draw();
250 
251  /*
252  // draw the ratio of momentum resolution histograms
253 
254  TCanvas *cdptratio = new TCanvas("cdptratio","cdptratio",50,50,800,600);
255  //cdptratio->SetLeftMargin(0.15);
256 
257  TH1F *hdptratio = new TH1F("hdptratio","hdptratio",100, 0.0, hptmax);
258  hdptratio->SetMinimum(0.8);
259  hdptratio->SetMaximum(1.4);
260  hdptratio->GetXaxis()->SetTitle("p_{T} (GeV/c)");
261  hdptratio->GetXaxis()->SetTitleOffset(1.15);
262  hdptratio->GetYaxis()->SetTitle("#Delta p_{T} ratio");
263  hdptratio->GetYaxis()->SetTitleOffset(1.8);
264  hdptratio->Draw();
265 
266  int N = grdpt[0]->GetN();
267  int N2 = grdpt[1]->GetN();
268  cout << "grdpt[0] has " << N << " points, " << " grdpt[1] has " << N2 << " points" << endl;
269 
270  TGraph *gratio = new TGraph(N-1);
271  gratio->SetMarkerStyle(20);
272  gratio->SetMarkerSize(1);
273  for(int i=0;i<N-1;i++)
274  {
275  double x1 = 0;
276  double y1=0;
277  grdpt[0]->GetPoint(i, x1, y1);
278  double x2 = 0;
279  double y2=0;
280  grdpt[1]->GetPoint(i, x2, y2);
281  double ratio = y2/y1;
282  gratio->SetPoint(i,x1,ratio);
283  }
284 
285  gratio->Draw("p");
286  */
287 
288  /*
289 
290  // now the upsilon spectra
291 
292  TFile *fin_ups[NPLOTS_UPS];
293 
294  fin_ups[0] = new TFile("look_quarkonia_histos_2mpas+4maps_out.root");
295  fin_ups[1] = new TFile("look_quarkonia_histos_2pixels+4maps_out.root");
296 
297  TH1D *recomass[NPLOTS_UPS];
298 
299  for(int i=0;i<NPLOTS_UPS;i++)
300  {
301  fin_ups[i]->GetObject("recomass",recomass[i]);
302  }
303 
304  TCanvas *cups = new TCanvas("cups","cups",50,50,1000,600);
305  cups->SetLeftMargin(0.12);
306 
307  for(int i=0;i<NPLOTS_UPS;i++)
308  {
309  recomass[i]->SetMarkerColor(col[i]);
310  recomass[i]->SetLineColor(col[i]);
311  recomass[i]->SetMarkerStyle(20);
312  recomass[i]->SetMarkerSize(1.2);
313 
314  if(i==0)
315  recomass[i]->Draw("p");
316  else
317  recomass[i]->Draw("same p");
318  }
319 
320  TLegend *lpq = new TLegend(0.15, 0.55, 0.40, 0.80,"Inner barrel","NDC");
321  lpq->SetBorderSize(0);
322  lpq->SetFillColor(0);
323  lpq->SetFillStyle(0);
324  lpq->AddEntry(recomass[0], "2 maps", "p");
325  lpq->AddEntry(recomass[1], "2 pixels", "p");
326 
327  lpq->Draw();
328  */
329 
330 }