Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FDC_Timing.C
Go to the documentation of this file.
1 
2 void FDC_Timing(bool save = 0){
3 
4  TDirectory *dir = (TDirectory*)gDirectory->FindObjectAny("FDC_Efficiency");
5  if(!dir) return;
6  dir->cd();
7 
8  gDirectory->cd("Residuals");
9 
10  TCanvas *cWireTiming = new TCanvas("cWireTiming", "WireTiming", 1000, 800);
11  cWireTiming->Divide(6,4);
12 
13  double cell[24];
14  double cell_err[24];
15  double wire[24];
16  double wire_err[24];
17 
18  double cath[24];
19  double cath_err[24];
20 
21  double delta[24];
22  double delta_err[24];
23 
24  double pull[24];
25  double pull_err[24];
26 
27  for(unsigned int icell=1; icell<=24; icell++){
28  cWireTiming->cd(icell);
29 
30  cell[icell-1] = icell;
31  cell_err[icell-1] = 0;
32 
33  char hname[256];
34  sprintf(hname, "hWireTime_cell[%d]", icell);
35  TH1 *hWire = (TH1*)(gDirectory->Get(hname));
36 
37  hWire->GetXaxis()->SetTitle("Wire Time (ns)");
38  //hWire->Draw();
39 
40  int tzero_bin = hWire->GetMaximumBin();
41  double tzero = hWire->GetXaxis()->GetBinCenter(tzero_bin);
42 
43  TF1 *fwire = new TF1("fwire", "gaus(0)", tzero - 10, tzero + 10);
44  fwire->SetLineColor(2);
45  fwire->SetNpx(600);
46  fwire->SetParameter(1,tzero);
47  hWire->Fit("fwire","q0r");
48  wire[icell-1] = fwire->GetParameter(1);
49  wire_err[icell-1] = fwire->GetParError(1);
50 
51  sprintf(hname, "hCathodeTime_cell[%d]", icell);
52  TH1 *hCathode = (TH1*)(gDirectory->Get(hname));
53 
54  hCathode->GetXaxis()->SetTitle("Cathode Time (ns)");
55  //hCathode->Draw();
56 
57  tzero_bin = hCathode->GetMaximumBin();
58  tzero = hCathode->GetXaxis()->GetBinCenter(tzero_bin);
59  hCathode->GetXaxis()->SetRangeUser(tzero-40,tzero+40);
60 
61  TF1 *fcath = new TF1("fcath", "gaus(0)", tzero - 20, tzero + 20);
62  fcath->SetLineColor(2);
63  fcath->SetNpx(600);
64  fcath->SetParameter(1,tzero);
65  hCathode->Fit("fcath","qr");
66  cath[icell-1] = fcath->GetParameter(1);
67  cath_err[icell-1] = fcath->GetParError(1);
68 
69  sprintf(hname, "hDeltaTime_cell[%d]", icell);
70  TH1 *hDelta = (TH1*)(gDirectory->Get(hname));
71 
72  hDelta->GetXaxis()->SetTitle("Wire Time - Cathode Time (ns)");
73  hDelta->Draw();
74 
75  tzero_bin = hDelta->GetMaximumBin();
76  tzero = hDelta->GetXaxis()->GetBinCenter(tzero_bin);
77 
78  TF1 *fdelta = new TF1("fdelta", "gaus(0)", tzero - 5, tzero + 5);
79  fdelta->SetLineColor(2);
80  fdelta->SetNpx(600);
81  fdelta->SetParameter(1,tzero);
82  hDelta->Fit("fdelta","qr");
83  delta[icell-1] = fdelta->GetParameter(1);
84  delta_err[icell-1] = fdelta->GetParError(1);
85 
86  sprintf(hname, "hPullTime_cell[%d]", icell);
87  TH1 *hPull = (TH1*)(gDirectory->Get(hname));
88 
89  hPull->GetXaxis()->SetTitle("Pseudo Time (from pull) (ns)");
90  //hPull->Draw();
91 
92  tzero_bin = hPull->GetMaximumBin();
93  tzero = hPull->GetXaxis()->GetBinCenter(tzero_bin);
94  hPull->GetXaxis()->SetRangeUser(tzero-10,tzero+10);
95 
96  TF1 *fpull = new TF1("fpull", "gaus(0)", tzero - 5, tzero + 3);
97  fpull->SetLineColor(2);
98  fpull->SetNpx(600);
99  fpull->SetParameter(1,tzero);
100  hPull->Fit("fpull","q0r");
101  pull[icell-1] = fpull->GetParameter(1);
102  pull_err[icell-1] = fpull->GetParError(1);
103 
104  }
105 
106  TCanvas *cTiming = new TCanvas("cTiming", "Timing", 1400, 1000);
107  cTiming->Divide(2,2);
108  cTiming->cd(1);
109 
110  TGraphErrors *gWireTiming = new TGraphErrors(24, cell, wire, cell_err, wire_err);
111  gWireTiming->SetTitle("; Cell # ; Wire Timing (ns)");
112  gWireTiming->SetMarkerColor(1);
113  gWireTiming->SetMarkerStyle(8);
114  gWireTiming->Draw("AP");
115 
116  cTiming->cd(2);
117  TGraphErrors *gCathTiming = new TGraphErrors(24, cell, cath, cell_err, cath_err);
118  gCathTiming->SetTitle("; Cell # ; Cathode Timing (ns)");
119  gCathTiming->SetMarkerColor(2);
120  gCathTiming->SetMarkerStyle(8);
121  gCathTiming->Draw("AP");
122 
123  cTiming->cd(3);
124  TGraphErrors *gDelta = new TGraphErrors(24, cell, delta, cell_err, delta_err);
125  gDelta->SetTitle("; Cell # ; Wire - Cathode Timing (ns)");
126  gDelta->SetMarkerColor(4);
127  gDelta->SetMarkerStyle(8);
128  gDelta->Draw("AP");
129 
130  cTiming->cd(4);
131  TGraphErrors *gPull = new TGraphErrors(24, cell, pull, cell_err, pull_err);
132  gPull->SetTitle("; Cell # ; Pseudo Time from Pull (ns)");
133  gPull->SetMarkerColor(6);
134  gPull->SetMarkerStyle(8);
135  gPull->Draw("AP");
136 }
sprintf(text,"Post KinFit Cut")
TDirectory * dir
Definition: bcal_hist_eff.C:31