Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FDC_Efficiency.C
Go to the documentation of this file.
1 
2 void FDC_Efficiency(bool save = 0){
3 
4  gStyle->SetPalette(1);
5 
6  //gDirectory->cd();
7  //TDirectory *gDirectory = TFile::Open("hd_root.root");
8  TDirectory *dir = (TDirectory*)gDirectory->FindObjectAny("FDC_Efficiency");
9  if(!dir) return;
10  dir->cd();
11 
12  gDirectory->cd("Track_Quality");
13  TCanvas *cTrackQuality = new TCanvas("cTrackQuality", "Track Quality Histograms", 900, 800);
14  cTrackQuality->Divide(3,2);
15 
16  cTrackQuality->cd(1);
17  TH1 *tmom = (TH1*) gDirectory->Get("hMom");
18  TH1 *tmom_acc = (TH1*) gDirectory->Get("hMom_accepted");
19  tmom->Draw();
20  tmom_acc->SetLineColor(2);
21  tmom_acc->Draw("same");
22 
23  cTrackQuality->cd(2);
24  TH1 *ttheta = (TH1*) gDirectory->Get("hTheta");
25  TH1 *ttheta_acc = (TH1*) gDirectory->Get("hTheta_accepted");
26  ttheta->Draw();
27  ttheta_acc->SetLineColor(2);
28  ttheta_acc->Draw("same");
29 
30  cTrackQuality->cd(3);
31  TH1 *tphi = (TH1*) gDirectory->Get("hPhi");
32  TH1 *tphi_acc = (TH1*) gDirectory->Get("hPhi_accepted");
33  tphi->SetMinimum(0.0);
34  tphi->Draw();
35  tphi_acc->SetLineColor(2);
36  tphi_acc->Draw("same");
37 
38  cTrackQuality->cd(4);
39  TH1 *tchi = (TH1*) gDirectory->Get("hChi2OverNDF");
40  TH1 *tchi_acc = (TH1*) gDirectory->Get("hChi2OverNDF_accepted");
41  tchi->Draw();
42  tchi_acc->SetLineColor(2);
43  tchi_acc->Draw("same");
44 
45  cTrackQuality->cd(5);
46  TH1 *tcells = (TH1*) gDirectory->Get("hCellsHit");
47  TH1 *tcells_acc = (TH1*) gDirectory->Get("hCellsHit_accepted");
48  tcells->Draw();
49  tcells_acc->SetLineColor(2);
50  tcells_acc->Draw("same");
51 
52  cTrackQuality->cd(6);
53  TH1 *trings = (TH1*) gDirectory->Get("hRingsHit");
54  TH1 *trings_acc = (TH1*) gDirectory->Get("hRingsHit_accepted");
55  trings->Draw();
56  trings_acc->SetLineColor(2);
57  trings_acc->Draw("same");
58 
59  Float_t minScale = 0.8;
60  Float_t maxScale = 1.0;
61 
62  gDirectory->cd("../FDC_View");
63  TCanvas *cEfficiency_Wire = new TCanvas("cEfficiency_Wire", "Wire Efficiency", 1200, 800);
64  cEfficiency_Wire->Divide(6,4);
65 
66  TGraphAsymmErrors *EffWire[24];
67 
68  for(unsigned int icell=1; icell<=24; icell++){
69  cEfficiency_Wire->cd(icell);
70  char hname1[256];
71  sprintf(hname1, "fdc_wire_measured_cell[%d]", icell);
72  TH1 *h1 = (TH1*)(gDirectory->Get(hname1));
73  char hname2[256];
74  sprintf(hname2, "fdc_wire_expected_cell[%d]", icell);
75  TH1 *h2 = (TH1*)(gDirectory->Get(hname2));
76 
77  if(h1 && h2){
78  EffWire[icell-1] = new TGraphAsymmErrors(h1, h2, "ac");
79  EffWire[icell-1]->Draw("ap");
80  EffWire[icell-1]->SetMinimum(minScale);
81  EffWire[icell-1]->SetMaximum(maxScale);
82  EffWire[icell-1]->SetTitle("");
83  EffWire[icell-1]->GetXaxis()->SetTitle("Wire Number");
84  EffWire[icell-1]->GetYaxis()->SetTitle("Efficiency");
85  EffWire[icell-1]->GetYaxis()->SetTitleOffset(1.15);
86  EffWire[icell-1]->SetMinimum(minScale);
87  EffWire[icell-1]->SetMaximum(maxScale);
88  }
89  }
90  if (save) cEfficiency_Wire->SaveAs("cEfficiencyWire.pdf");
91 
92  TCanvas *cEfficiency_Pseudo = new TCanvas("cEfficiency_Pseudo", "Pseudo Hit Efficiency", 1200, 800);
93  cEfficiency_Pseudo->Divide(6,4);
94  double eff[24];
95  double tot = 0;
96 
97  for(unsigned int icell=1; icell<=24; icell++){
98  cEfficiency_Pseudo->cd(icell);
99  char hname3[256];
100  sprintf(hname3, "fdc_pseudo_measured_cell[%d]", icell);
101  TH2 *h3 = (TH2*)(gDirectory->Get(hname3));
102  char hname4[256];
103  sprintf(hname4, "fdc_pseudo_expected_cell[%d]", icell);
104  TH2 *h4 = (TH2*)(gDirectory->Get(hname4));
105 
106  if(h3 && h4){
107  eff[icell-1] = (double) h3->GetEntries();
108  eff[icell-1] /= (double) h4->GetEntries();
109 
110  h3->Divide(h4);
111  h3->SetMinimum(minScale);
112  h3->SetMaximum(maxScale);
113  h3->GetXaxis()->SetTitle("X Position (cm)");
114  h3->GetYaxis()->SetTitle("Y Position (cm)");
115  h3->SetStats(0);
116  h3->Draw("colz");
117 
118  cout << "Pseudo-Efficiency of cell " << icell << " : " << eff[icell-1] << endl;
119  tot += eff[icell-1];
120  }
121  }
122 
123  cout << "Total : " << tot/24. << endl;
124 
125  dir->cd();
126 
127  TCanvas *cEfficiency_vs = new TCanvas("cEfficiency_vs", "Efficiency vs Things", 900, 600);
128  cEfficiency_vs->Divide(3,2);
129 
130  cEfficiency_vs->cd(1);
131  TH1I *MeasDOCA = (TH1I*)(gDirectory->Get("Offline/Measured Hits Vs DOCA"));
132  TH1I *ExpDOCA = (TH1I*)(gDirectory->Get("Offline/Expected Hits Vs DOCA"));
133  if(MeasDOCA && ExpDOCA){
134  TGraphAsymmErrors *EffDOCA = new TGraphAsymmErrors(MeasDOCA, ExpDOCA, "ac");
135  EffDOCA->Draw("ap");
136  EffDOCA->SetMinimum(minScale);
137  EffDOCA->SetMaximum(maxScale);
138  EffDOCA->SetTitle("FDC Per Wire Efficiency Vs. DOCA");
139  EffDOCA->GetXaxis()->SetTitle("Closest distance between track and wire [cm]");
140  EffDOCA->GetYaxis()->SetTitle("Efficiency");
141  TLine *lcut = new TLine(0.5,minScale,0.5,maxScale);
142  lcut->SetLineColor(2);
143  lcut->SetLineStyle(2);
144  lcut->SetLineWidth(2);
145  lcut->Draw();
146  }
147 
148  cEfficiency_vs->cd(2);
149  TH1I *MeasTrackingFOM = (TH1I*)(gDirectory->Get("Offline/Measured Hits Vs Tracking FOM"));
150  TH1I *ExpTrackingFOM = (TH1I*)(gDirectory->Get("Offline/Expected Hits Vs Tracking FOM"));
151  if(MeasTrackingFOM && ExpTrackingFOM){
152  TGraphAsymmErrors *EffTrackingFOM = new TGraphAsymmErrors(MeasTrackingFOM, ExpTrackingFOM, "ac");
153  EffTrackingFOM->Draw("ap");
154  EffTrackingFOM->SetMinimum(minScale);
155  EffTrackingFOM->SetMaximum(maxScale);
156  EffTrackingFOM->SetTitle("FDC Per Wire Efficiency Vs. Tracking FOM");
157  EffTrackingFOM->GetXaxis()->SetTitle("Tracking FOM");
158  EffTrackingFOM->GetYaxis()->SetTitle("Efficiency");
159  }
160 
161  cEfficiency_vs->cd(3);
162  TH1I *Meastheta = (TH1I*)(gDirectory->Get("Offline/Measured Hits Vs theta"));
163  TH1I *Exptheta = (TH1I*)(gDirectory->Get("Offline/Expected Hits Vs theta"));
164  if(Meastheta && Exptheta){
165  TGraphAsymmErrors *Efftheta = new TGraphAsymmErrors(Meastheta, Exptheta, "ac");
166  Efftheta->Draw("ap");
167  Efftheta->SetMinimum(minScale);
168  Efftheta->SetMaximum(maxScale);
169  Efftheta->SetTitle("FDC Per Wire Efficiency Vs. #theta");
170  Efftheta->GetXaxis()->SetTitle("Track #theta [deg.]");
171  Efftheta->GetYaxis()->SetTitle("Efficiency");
172  }
173 
174  cEfficiency_vs->cd(4);
175  TH1I *Measphi = (TH1I*)(gDirectory->Get("Offline/Measured Hits Vs phi"));
176  TH1I *Expphi = (TH1I*)(gDirectory->Get("Offline/Expected Hits Vs phi"));
177  if(Measphi && Expphi){
178  TGraphAsymmErrors *Effphi = new TGraphAsymmErrors(Measphi, Expphi, "ac");
179  Effphi->Draw("ap");
180  Effphi->SetMinimum(minScale);
181  Effphi->SetMaximum(maxScale);
182  Effphi->SetTitle("FDC Per Wire Efficiency Vs. #phi");
183  Effphi->GetXaxis()->SetTitle("Track #phi [deg.]");
184  Effphi->GetYaxis()->SetTitle("Efficiency");
185  }
186 
187  cEfficiency_vs->cd(5);
188  TH1I *Measp = (TH1I*)(gDirectory->Get("Offline/Measured Hits Vs p"));
189  TH1I *Expp = (TH1I*)(gDirectory->Get("Offline/Expected Hits Vs p"));
190  if(Measp && Expp){
191  TGraphAsymmErrors *Effp = new TGraphAsymmErrors(Measp, Expp, "ac");
192  Effp->Draw("ap");
193  Effp->SetMinimum(minScale);
194  Effp->SetMaximum(maxScale);
195  Effp->SetTitle("FDC Per Wire Efficiency Vs. p");
196  Effp->GetXaxis()->SetTitle("Track Momentum [GeV/c]");
197  Effp->GetYaxis()->SetTitle("Efficiency");
198  }
199 
200  cEfficiency_vs->cd(6);
201  TH1I *Meascells = (TH1I*)(gDirectory->Get("Offline/Measured Hits Vs Hit Cells"));
202  TH1I *Expcells = (TH1I*)(gDirectory->Get("Offline/Expected Hits Vs Hit Cells"));
203  if(Meascells && Expcells){
204  TGraphAsymmErrors *Effcells = new TGraphAsymmErrors(Meascells, Expcells, "ac");
205  Effcells->Draw("ap");
206  Effcells->SetMinimum(minScale);
207  Effcells->SetMaximum(maxScale);
208  Effcells->SetTitle("FDC Per Wire Efficiency Vs. Contributing Cells");
209  Effcells->GetXaxis()->SetTitle("FDC Cells");
210  Effcells->GetYaxis()->SetTitle("Efficiency");
211  }
212 
213  if (save) cEfficiency_vs->SaveAs("cEfficiency_vs.pdf");
214 
215  dir->cd();
216  gDirectory->cd("Residuals");
217 
218 
219  TCanvas *cResidual_Pseudo = new TCanvas("cResidual_Pseudo", "Pseudo Hit Resolution", 1000, 800);
220  cResidual_Pseudo->Divide(6,4);
221 
222  double meanV[24];
223  double meanV_err[24];
224  double meanU[24];
225  double meanU_err[24];
226 
227  for(unsigned int icell=1; icell<=24; icell++){
228  cResidual_Pseudo->cd(icell);
229  char hname5[256];
230  sprintf(hname5, "hPseudoResV_cell[%d]", icell);
231  TH1 *h5 = (TH1*)(gDirectory->Get(hname5));
232  char hname6[256];
233  sprintf(hname6, "hPseudoResU_cell[%d]", icell);
234  TH1 *h6 = (TH1*)(gDirectory->Get(hname6));
235 
236  h5->GetXaxis()->SetTitle("Position Resolution (cm)");
237  h5->GetXaxis()->SetRangeUser(-1,1);
238  h5->Draw();
239  h5->Fit("gaus","q0");
240  TF1 *fgaus5 = h5->GetFunction("gaus");
241  meanV[icell-1] = fgaus5->GetParameter(1);
242  //mean_err[icell-1] = fgaus5->GetParError(1) * fgaus->GetChisquare()/(fgaus->GetNDF()-1);
243  meanV_err[icell-1] = fgaus5->GetParameter(2);
244 
245  h6->SetLineColor(2);
246  h6->Draw("same");
247  h6->Fit("gaus","q0");
248  TF1 *fgaus6 = h6->GetFunction("gaus");
249  meanU[icell-1] = fgaus6->GetParameter(1);
250  //mean_err[icell-1] = fgaus6->GetParError(1) * fgaus->GetChisquare()/(fgaus->GetNDF()-1);
251  meanU_err[icell-1] = fgaus6->GetParameter(2);
252 
253  }
254 
255  const unsigned int rad = 1;
256 
257  TCanvas *cResidual_Pseudo2 = new TCanvas("cResidual_Pseudo2", "Pseudo Hit Resolution 2D", 1000, 800);
258  cResidual_Pseudo2->Divide(6,4);
259 
260  for(unsigned int icell=1; icell<=24; icell++){
261  cResidual_Pseudo2->cd(icell);
262  for (unsigned int r=0; r<rad; r++){
263  char hname7[256];
264  sprintf(hname7, "hPseudoResUvsV_cell[%d]_radius[%d]", icell, (r+1)*(45/rad));
265  TH2 *h7 = (TH2*)(gDirectory->Get(hname7));
266 
267  if (h7){
268  h7->GetYaxis()->SetTitle("Position reconstructed along Wire (cm)");
269  h7->GetYaxis()->SetRangeUser(-0.5,0.5);
270  h7->GetXaxis()->SetTitle("Position perp. to Wire (cm)");
271  h7->GetXaxis()->SetRangeUser(-0.5,0.5);
272  h7->Draw("col");
273  h7->ProfileY();
274  }
275  }
276  }
277 
278  double slope[rad][24];
279  double slope_err[rad][24];
280  double cell[rad][24];
281  double cell_err[rad][24];
282  TCanvas *cResidual_Profile = new TCanvas("cResidual_Profile", "Pseudo Resolution Profile", 1000, 800);
283  cResidual_Profile->Divide(6,4);
284 
285  for(unsigned int icell=1; icell<=24; icell++){
286  cResidual_Profile->cd(icell);
287  for (unsigned int r=0; r<rad; r++){
288  cell[r][icell-1] = icell + 0.1*r;
289  cell_err[r][icell-1] = 0;
290  char hname8[256];
291  sprintf(hname8, "hPseudoResUvsV_cell[%d]_radius[%d]_pfy", icell, (r+1)*(45/rad));
292  TH1 *h8 = (TH1*)(gDirectory->Get(hname8));
293 
294  if (h8){
295  h8->GetXaxis()->SetTitle("Position reconstructed along Wire (cm)");
296  h8->GetXaxis()->SetRangeUser(-0.15,0.15);
297  h8->GetYaxis()->SetTitle("Position perp. to Wire (cm)");
298  h8->GetYaxis()->SetRangeUser(-0.5,0.5);
299  h8->GetYaxis()->SetTitleFont(42);
300  h8->GetYaxis()->SetTitleSize(0.035);
301  h8->GetYaxis()->SetLabelFont(42);
302  h8->GetYaxis()->SetLabelSize(0.035);
303  h8->SetLineColor(r+1);
304  if (r == 0)
305  h8->Draw();
306  else
307  h8->Draw("same");
308 
309  TF1 *fp1 = new TF1("fp1","[0]+x*[1]",-0.08,0.08);
310  fp1->SetLineColor(r+1);
311  h8->Fit("fp1","qr");
312  slope[r][icell-1] = fp1->GetParameter(1);
313  slope_err[r][icell-1] = fp1->GetParError(1);
314  }
315  else {
316  // histograms not present
317  slope[r][icell-1] = 0;
318  slope_err[r][icell-1] = 0;
319  }
320  }
321  }
322 
323  TCanvas *cAlignment = new TCanvas("cAlignment", "Alignment", 1200, 1000);
324  cAlignment->Divide(2,2);
325 
326  cAlignment->cd(1);
327  TGraphErrors *galignV = new TGraphErrors(24, cell[0], meanV, cell_err[0], meanV_err);
328  galignV->SetTitle("Alignment along Wire (Error Bars: Sigma); Cell # ; V_{Hit} - V_{Track} (cm)");
329  galignV->SetMarkerColor(1);
330  galignV->SetMarkerStyle(2);
331  galignV->Draw("AP");
332 
333  TLine *lpack12 = new TLine(6.5, -0.1, 6.5, 0.1);
334  lpack12->SetLineColor(2);
335  lpack12->SetLineStyle(2);
336  lpack12->SetLineWidth(2);
337  lpack12->Draw();
338  TLine *lpack23 = new TLine(12.5, -0.1, 12.5, 0.1);
339  lpack23->SetLineColor(2);
340  lpack23->SetLineStyle(2);
341  lpack23->SetLineWidth(2);
342  lpack23->Draw();
343  TLine *lpack34 = new TLine(18.5, -0.1, 18.5, 0.1);
344  lpack34->SetLineColor(2);
345  lpack34->SetLineStyle(2);
346  lpack34->SetLineWidth(2);
347  lpack34->Draw();
348 
349  cAlignment->cd(2);
350  TGraphErrors *galignU = new TGraphErrors(24, cell[0], meanU, cell_err[0], meanU_err);
351  galignU->SetTitle("Alignment perp. to Wire (Error Bars: Sigma); Cell # ; U_{Hit} - U_{Track} (cm)");
352  galignU->SetMarkerColor(1);
353  galignU->SetMarkerStyle(2);
354  galignU->Draw("AP");
355 
356  lpack12->Draw();
357  lpack23->Draw();
358  lpack34->Draw();
359 
360  cAlignment->cd(3);
361  TGraphErrors *gmagnet[rad];
362  for (unsigned int r=0; r<rad; r++){
363  gmagnet[r] = new TGraphErrors(24, cell[r], slope[r], cell_err[r], slope_err[r]);
364  gmagnet[r]->SetTitle("Value for slope of magnetic deflection; Cell # ; Slope (cm^{-1})");
365  gmagnet[r]->SetMarkerColor(r+1);
366  gmagnet[r]->SetMarkerStyle(2);
367  if (r==0)
368  gmagnet[r]->Draw("AP");
369  else
370  gmagnet[r]->Draw("Psame");
371  }
372 }
Float_t maxScale
void FDC_Efficiency(bool save=0)
Definition: FDC_Efficiency.C:2
sprintf(text,"Post KinFit Cut")
const unsigned int rad
TH1I * Expp
TH1I * Exptheta
TH1I * Meastheta
TH1I * Measp
TH1I * MeasDOCA
TH1I * MeasTrackingFOM
TH1I * ExpDOCA
TDirectory * dir
Definition: bcal_hist_eff.C:31
TH1I * ExpTrackingFOM
Float_t minScale