Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Compare_ntp_gtrack.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file Compare_ntp_gtrack.C
1 #include "../CommonTools.h"
2 
3 /*
4  * This macro compares two versions of ntp_gtrack and makes plots that
5  * compare typical tracking physics performance. It is called with the
6  * two file names as arguments, e.g.
7  * root -l -b -q Compare_ntp_gtrack.C'("file1.root","file2.root")'
8  * where both root files are the SvtxEvaluator output with ntp_gtrack
9  *
10  * The output is some canvases which compare benchmark physics performance
11  *
12  */
13 
15 {
16  gStyle->SetOptStat(0);
17  TFile *df = TFile::Open(file1.c_str());
18 
19  TFile *nf = TFile::Open(file2.c_str());
20 
21  TNtuple *dt = (TNtuple*)df->Get("ntp_gtrack");
22  TNtuple *nt = (TNtuple*)nf->Get("ntp_gtrack");
23 
24  dt->Draw("gpt>>dtruth(40,0,20)");
25  nt->Draw("gpt>>ntruth(40,0,20)");
26  dt->Draw("gpt>>dreco(40,0,20)","quality<10 && ntpc>30");
27  nt->Draw("gpt>>nreco(40,0,20)","quality<10 && ntpc>30");
28  dt->Draw("gpt>>drecomaps(40,0,20)","quality<10 && nmaps>2 && ntpc>30");
29  nt->Draw("gpt>>nrecomaps(40,0,20)","quality<10 && nmaps>2 && ntpc>30");
30 
31  TH1* dtruth = (TH1F*)gDirectory->Get("dtruth");
32  TH1 *ntruth = (TH1F*)gDirectory->Get("ntruth");
33  TH1 *dreco = (TH1F*)gDirectory->Get("dreco");
34  TH1 *nreco = (TH1F*)gDirectory->Get("nreco");
35  TH1 *drecomaps = (TH1F*)gDirectory->Get("drecomaps");
36  TH1 *nrecomaps = (TH1F*)gDirectory->Get("nrecomaps");
37 
38  dt->Draw("pt/gpt:gpt>>dpt(40,0,40,400,0.5,1.5)","quality<10","colz");
39  nt->Draw("pt/gpt:gpt>>npt(40,0,40,400,0.5,1.5)","quality<10","colz");
40 
41  TH2* dpt = (TH2F*)gDirectory->Get("dpt");
42  TH2* npt = (TH2F*)gDirectory->Get("npt");
43 
44 
45  dpt->FitSlicesY();
46  npt->FitSlicesY();
47  TH1* dptw = (TH1F*)gDirectory->Get("dpt_2");
48  TH1* dpts = (TH1F*)gDirectory->Get("dpt_1");
49  TH1* nptw = (TH1F*)gDirectory->Get("npt_2");
50  TH1 *npts = (TH1F*)gDirectory->Get("npt_1");
51 
52  dt->Draw("dca3dxy:gpt>>ddcax(60,0,20,50,-0.01,0.01)","quality<10","colz");
53  nt->Draw("dca3dxy:gpt>>ndcax(60,0,20,50,-0.01,0.01)","quality<10","colz");
54  dt->Draw("dca3dz:gpt>>ddcaz(60,0,20,50,-0.01,0.01)","quality<10","colz");
55  nt->Draw("dca3dz:gpt>>ndcaz(60,0,20,50,-0.01,0.01)","quality<10","colz");
56 
57  dt->Draw("ntpc:gpt>>dntpc(20,0,20,60,0,60)","quality<10","colz");
58  dt->Draw("nintt:gpt>>dnintt(20,0,20,8,0,8)","quality<10","colz");
59  dt->Draw("nmaps:gpt>>dnmaps(20,0,20,5,0,5)","quality<10","colz");
60  nt->Draw("ntpc:gpt>>nntpc(20,0,20,60,0,60)","quality<10","colz");
61  nt->Draw("nintt:gpt>>nnintt(20,0,20,8,0,8)","quality<10","colz");
62  nt->Draw("nmaps:gpt>>nnmaps(20,0,20,5,0,5)","quality<10","colz");
63 
64  dt->Draw("ntpc>>dntpc1(60,0,60)","quality<10","colz");
65  dt->Draw("nintt>>dnintt1(6,0,6)","quality<10","colz");
66  dt->Draw("nmaps>>dnmaps1(6,0,6)","quality<10","colz");
67  nt->Draw("ntpc>>nntpc1(60,0,60)","quality<10","colz");
68  nt->Draw("nintt>>nnintt1(6,0,6)","quality<10","colz");
69  nt->Draw("nmaps>>nnmaps1(6,0,6)","quality<10","colz");
70 
71  TH1 *dntpc1 = (TH1F*)gDirectory->Get("dntpc1");
72  TH1 *dnintt1 = (TH1F*)gDirectory->Get("dnintt1");
73  TH1 *dnmaps1 = (TH1F*)gDirectory->Get("dnmaps1");
74  TH1 *nntpc1 = (TH1F*)gDirectory->Get("nntpc1");
75  TH1 *nnintt1 = (TH1F*)gDirectory->Get("nnintt1");
76  TH1 *nnmaps1 = (TH1F*)gDirectory->Get("nnmaps1");
77 
78  TH2 *dntpc = (TH2F*)gDirectory->Get("dntpc");
79  TH2 *dnintt = (TH2F*)gDirectory->Get("dnintt");
80  TH2 *dnmaps = (TH2F*)gDirectory->Get("dnmaps");
81  TH2 *nntpc = (TH2F*)gDirectory->Get("nntpc");
82  TH2 *nnintt = (TH2F*)gDirectory->Get("nnintt");
83  TH2 *nnmaps = (TH2F*)gDirectory->Get("nnmaps");
84 
85  TCanvas *tpc1can = new TCanvas("tpc1can","tpc1can",200,200,600,600);
86  nntpc1->SetLineColor(kRed);
87  dntpc1->Scale(1./dntpc1->GetEntries());
88  nntpc1->Scale(1./nntpc1->GetEntries());
89  dntpc1->Draw("hist");
90  nntpc1->Draw("histsame");
91 
92  TCanvas *intt1can = new TCanvas("intt1can","intt1can",200,200,600,600);
93  nnintt1->SetLineColor(kRed);
94  dnintt1->Scale(1./dnintt1->GetEntries());
95  nnintt1->Scale(1./nnintt1->GetEntries());
96  dnintt1->Draw("hist");
97  nnintt1->Draw("histsame");
98 
99  TCanvas *maps1can = new TCanvas("maps1can","maps1can",200,200,600,600);
100  nnmaps1->SetLineColor(kRed);
101  dnmaps1->Scale(1./dnmaps1->GetEntries());
102  nnmaps1->Scale(1./nnmaps1->GetEntries());
103  dnmaps1->Draw("hist");
104  nnmaps1->Draw("histsame");
105 
106  TCanvas *tpccan = new TCanvas("tpccan","tpccan",200,200,600,600);
107  tpccan->Divide(2,1);
108  tpccan->cd(1);
109  dntpc->GetYaxis()->SetTitle("ntpc");
110  dntpc->GetXaxis()->SetTitle("gpt");
111  dntpc->Draw("colz");
112  tpccan->cd(2);
113  nntpc->Draw("colz");
114 
115  TCanvas *inttcan = new TCanvas("inttcan","inttcan",200,200,600,600);
116  inttcan->Divide(2,1);
117  inttcan->cd(1);
118  dnintt->GetYaxis()->SetTitle("nintt");
119  dnintt->GetXaxis()->SetTitle("gpt");
120  dnintt->Draw("colz");
121  inttcan->cd(2);
122  nnintt->Draw("colz");
123 
124  TCanvas *mapscan = new TCanvas("mapscan","mapscan",200,200,600,600);
125  mapscan->Divide(2,1);
126  mapscan->cd(1);
127  dnmaps->GetYaxis()->SetTitle("nmaps");
128  dnmaps->GetXaxis()->SetTitle("gpt");
129  dnmaps->Draw("colz");
130  mapscan->cd(2);
131  nnmaps->Draw("colz");
132 
133  TH2 *ddcax = (TH2F*)gDirectory->Get("ddcax");
134  TH2 *ddcaz = (TH2F*)gDirectory->Get("ddcaz");
135  TH2 *ndcax = (TH2F*)gDirectory->Get("ndcax");
136  TH2 *ndcaz = (TH2F*)gDirectory->Get("ndcaz");
137 
138  ddcax->FitSlicesY();
139  ddcaz->FitSlicesY();
140  ndcax->FitSlicesY();
141  ndcaz->FitSlicesY();
142 
143  TH1 *ddcaxw = (TH1F*)gDirectory->Get("ddcax_2");
144  TH1 *ddcazw = (TH1F*)gDirectory->Get("ddcaz_2");
145  TH1 *ndcaxw = (TH1F*)gDirectory->Get("ndcax_2");
146  TH1 *ndcazw = (TH1F*)gDirectory->Get("ndcaz_2");
147 
148  nptw->SetMarkerColor(kRed); nptw->SetLineColor(kRed);
149  npts->SetMarkerColor(kRed); npts->SetLineColor(kRed);
150  ndcaxw->SetMarkerColor(kRed); ndcaxw->SetLineColor(kRed);
151  ndcazw->SetMarkerColor(kRed); ndcazw->SetLineColor(kRed);
152 
153  TCanvas *ptcan = new TCanvas("ptcan","ptcan",200,200,600,600);
154  ptcan->Divide(2,1);
155  ptcan->cd(1);
156  dpt->Draw("colz");
157  myText(0.1,0.03,kBlack,"File 1");
158  ptcan->cd(2);
159  npt->Draw("colz");
160  myText(0.1,0.03,kBlack,"File 2");
161 
162  TCanvas *dcaxcan2 = new TCanvas("dcaxcan2","dcaxcan2",200,200,600,600);
163  dcaxcan2->Divide(2,1);
164  dcaxcan2->cd(1);
165 
166  ddcax->Draw("colz");
167  myText(0.1,0.03,kBlack,"File 1");
168  dcaxcan2->cd(2);
169  ndcax->Draw("colz");
170  myText(0.1,0.03,kBlack,"File 2");
171 
172  TCanvas *dcazcan2 = new TCanvas("dcazcan2","dcazcan2",200,200,600,600);
173  dcazcan2->Divide(2,1);
174  dcazcan2->cd(1);
175  ddcaz->Draw("colz");
176  myText(0.1,0.03,kBlack,"File 1");
177  dcazcan2->cd(2);
178  ndcaz->Draw("colz");
179  myText(0.1,0.03,kBlack,"File 2");
180 
181  TCanvas *ptwcan = new TCanvas("ptwcan","ptwcan",200,200,600,600);
182  nptw->GetYaxis()->SetTitle("#sigma(p_{T})/p_{T}");
183  nptw->GetXaxis()->SetTitle("p_{T} [GeV]");
184  //nptw->Divide(dptw);
185  nptw->Draw("ep");
186  dptw->Draw("epsame");
187  myText(0.21,0.85,kBlack,"File 1");
188  myText(0.21,0.77,kRed,"File 2");
189 
190 
191  TCanvas *ptscan = new TCanvas("ptscan","ptscan",200,200,600,600);
192  npts->GetYaxis()->SetTitle("#LTp_{T}^{true}/p_{T}^{reco}#GT");
193  npts->GetXaxis()->SetTitle("p_{T} [GeV]");
194  npts->Draw("ep");
195  dpts->Draw("epsame");
196  myText(0.21,0.85,kBlack,"File 1");
197  myText(0.21,0.77,kRed,"File 2");
198 
199 
200  TCanvas *dcaxcan = new TCanvas("dcaxcan","dcaxcan",200,200,600,600);
201  ndcaxw->GetYaxis()->SetTitle("#sigma(DCA_{xy}) [cm]");
202  ndcaxw->GetXaxis()->SetTitle("p_{T} [GeV]");
203  ndcaxw->Draw("ep");
204  ddcaxw->Draw("epsame");
205  myText(0.21,0.85,kBlack,"File 1");
206  myText(0.21,0.77,kRed,"File 2");
207 
208 
209  TCanvas *dcazcan = new TCanvas("dcazcan","dcazcan",200,200,600,600);
210  ndcazw->GetYaxis()->SetTitle("#sigma(DCA_{z}) [cm]");
211  ndcazw->GetXaxis()->SetTitle("p_{T} [GeV]");
212  ndcazw->Draw("ep");
213  ddcazw->Draw("epsame");
214  myText(0.21,0.85,kBlack,"File 1");
215  myText(0.21,0.77,kRed,"File 2");
216 
217 
218 
219  dtruth->GetYaxis()->SetTitle("Eff");
220  dtruth->GetXaxis()->SetTitle("p_{T} [GeV]");
221  dtruth->GetYaxis()->SetRangeUser(0,1);
222  TEfficiency *deff = new TEfficiency(*dreco,*dtruth);
223  TEfficiency *neff = new TEfficiency(*nreco,*ntruth);
224  TEfficiency *deffmaps = new TEfficiency(*drecomaps,*dtruth);
225  TEfficiency *neffmaps = new TEfficiency(*nrecomaps,*ntruth);
226 
227 
228  TCanvas *effcan = new TCanvas("effcan","effcan",200,200,600,600);
229  neff->SetMarkerColor(kRed); neff->SetLineColor(kRed);
230  neffmaps->SetMarkerColor(kRed); neffmaps->SetLineColor(kRed);
231  neffmaps->SetMarkerStyle(24); deffmaps->SetMarkerStyle(24);
232 
233  deff->Draw("ap");
234  neff->Draw("psame");
235  deffmaps->Draw("psame");
236  neffmaps->Draw("psame");
237  TLegend *effleg = new TLegend(0.4,0.4,0.6,0.7);
238  effleg->AddEntry(deff,"File 1 qual<10","P");
239  effleg->AddEntry(neff,"File 2 qual<10","p");
240  effleg->AddEntry(deffmaps,"File 1 nmaps>2","P");
241  effleg->AddEntry(neffmaps,"File 2 nmaps>2","P");
242 
243  effleg->Draw("same");
244 
245 
246 
247 
248  TFile *outfile = new TFile("compoutfile.root","recreate");
249  dpt->Write();
250  npt->Write();
251  outfile->Close();
252 }