Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
tw_corr.C
Go to the documentation of this file.
1 // ROOT fitting macro for the PSC time-walk corrections
2 // Created 8/18/2015
3 // Updated 9/26/2016
4 // Alex Barnes
5 // University of Connecticut
6 //
7 // Notes:
8 // 1) the input file must be changed if not using the current directory's
9 // hd_root.root file
10 // 2) Change #define GLOBAL_FIT to 0 or 1 if you want individual
11 // or global fits, respectively
12 //
13 // Example usage:
14 // > root -l -b -q 'tw_corr.C("hd_root.root")'
15 //
16 // Functions:
17 // tw_plot(): This function takes the original root file branches and fills
18 // the initial histograms
19 // tw_proj(): This function takes the initial histograms and makes y projections
20 // and fits these projections with a Gaussian. The means and sigmas
21 // are used to make points on a TGraph
22 // tw_fit(): This function takes the tw_proj() TGraph and fits it following Elton's
23 // method
24 // tw_corr(): This function uses the results of tw_fit() to perform a time-walk
25 // correction on the data and fill corrected histograms
26 // fitf(): This function provides the timewalk fit function for tw_fit()
27 
28 #include <TDirectory.h>
29 #include <TH1.h>
30 #include <TH2.h>
31 #include <TF1.h>
32 #include <TMath.h>
33 #include <TCanvas.h>
34 #include <TProfile.h>
35 #include <TFitResult.h>
36 #include <TFitResultPtr.h>
37 #include <TString.h>
38 
39 #include <fstream>
40 
41 #define DEBUG false
42 #define OUTPUT false
43 
44 // Declare files
45 TFile *infile; // input ROOT file,
46 TFile *outfile; // output ROOT file
47 
48 // Declare constants
49 const Int_t NMODULES = 8; // Modules per arm
50 const Double_t THRESHOLD = 16; // discriminator threshold in ADC counts (40 mV)
51 const Int_t BINS_PP = 1000; // number of bins for the pulse peak axis
52 const Int_t PP_MAX = 1000; // maximum pulse peak for histograms
53 const Int_t PP_MIN = 0; // minimum pulse peak for histograms
54 const Int_t BINS_DT = 100; // number of bins for the time difference axis
55 const Int_t DT_MAX = 5; // maximum time difference for histograms
56 const Int_t DT_MIN = -5; // minimum time difference for histograms
57 const Int_t PROF_WIDTH = 82; // number of bins for the TProfiles
58 const Int_t PROF_MIN = 180; // minimum TProfile axis value
59 const Int_t PROF_MAX = 1000; // maximum TProfile axis value
60 
61 // Declare variables
62 Double_t dtMeanL[NMODULES] = {0}; // used to center the time dist. for the left modules
63 Double_t dtMeanR[NMODULES] = {0}; // used to center the time dist. for the right modules
64 Double_t mpv[2][NMODULES] = { {0},{0} };// used to find the most probable value for the pulse peaks
65 
66 // Individual time walk fit parameters
67 Double_t c0[2][NMODULES] = { {0},{0} }; // constant paramter for each module
68 Double_t c1[2][NMODULES] = { {0},{0} }; // linear parameter for each module
69 Double_t c2[2][NMODULES] = { {0},{0} }; // exponent parameter for each module
70 
71 // Declare 1D histograms
72 TH1D *h_dt_l[NMODULES]; // timing dist for each left module against the RF
73 TH1D *h_dt_r[NMODULES]; // timing dist for each right module against the RF
74 TH1D *h_dt_l_corr[NMODULES]; // timing dist for each left module against the RF
75 TH1D *h_dt_r_corr[NMODULES]; // timing dist for each right module against the RF
76 TH1D *h_pp_l[NMODULES]; // pulse peak distribution for the left modules
77 TH1D *h_pp_r[NMODULES]; // pulse peak distribution for the right modules
78 
79 // Declare calibration check histograms
80 TH1D* h_means_b; // means of each counter before corrections
81 TH1D* h_sigmas_b; // sigmas of each counter before corrections
82 TH1D* h_means_a; // means of each counter after corrections
83 TH1D* h_sigmas_a; // sigmas of each counter after corrections
84 
85 // Declare 2D histograms
86 TH2F *h_dt_vs_pp_l[NMODULES]; // dt vs pp for each left module
87 TH2F *h_dt_vs_pp_r[NMODULES]; // dt vs pp for each right module
88 TH2F *h_dt_vs_pp_l_corr[NMODULES]; // dt vs pp for each left module after corrections
89 TH2F *h_dt_vs_pp_r_corr[NMODULES]; // dt vs pp for each right module after corrections
90 
91 //TProfile *g_dt_vs_pp;
92 TProfile *g_dt_vs_pp_l[NMODULES]; // dt vs pp plot converted into TProfile
93 TProfile *g_dt_vs_pp_r[NMODULES]; // dt vs pp plot converted into TProfile
94 
95 // Define the fit function, fitf
96 Double_t fitf(Double_t *x, Double_t *par) {
97  Float_t xx = x[0];
98  Double_t f = par[0] + par[1]*pow((xx/THRESHOLD),par[2]);
99  return f;
100 }
101 
102 // Individual tw_fit()
103 void tw_fit(TProfile *h_tw, int arm, int module) {
104 
105  TF1 *ftw = new TF1("ftw",fitf,100.,1000.,3);
106 #if DEBUG
107  std::cout << "Defined time-walk fit function" << std::endl;
108 #endif
109 
110  ftw->SetParameter(0,-1.9);
111  ftw->SetParameter(1,4.8);
112  ftw->SetParameter(2,-0.4);
113  ftw->SetParName(0,"c0");
114  ftw->SetParName(1,"c1");
115  ftw->SetParName(2,"c2");
116 
117  h_tw->Fit("ftw","RWq");
118 #if DEBUG
119  std::cout << "Fit histogram" << std::endl;
120 #endif
121 
122  c0[arm][module] = ftw->GetParameter("c0");
123  c1[arm][module] = ftw->GetParameter("c1");
124  c2[arm][module] = ftw->GetParameter("c2");
125 #if OUTPUT
126  std::cout << "c0: " << c0[arm][module] << std::endl;
127  std::cout << "c1: " << c1[arm][module] << std::endl;
128  std::cout << "c2: " << c2[arm][module] << std::endl;
129 #endif
130 }
131 
132 
133 void tw_plot(char const *inputFile) {
134 
135  // Get input file, make output file
136  infile = new TFile(inputFile);
137  outfile = new TFile("results.root","RECREATE");
138 
139  // Create directories
140 #if DEBUG
141  std::cout << "Creating output file directories" << std::endl;
142 #endif
143  outfile->mkdir("dt_vs_pp");
144  outfile->mkdir("dt_vs_pp/dt_vs_pp_L");
145  outfile->mkdir("dt_vs_pp/dt_vs_pp_R");
146  outfile->mkdir("dt_vs_pp_corr");
147  outfile->mkdir("dt_vs_pp_corr/dt_vs_pp_corr_L");
148  outfile->mkdir("dt_vs_pp_corr/dt_vs_pp_corr_R");
149  outfile->mkdir("dt_vs_pp_profile");
150  outfile->mkdir("dt_vs_pp_profile/dt_vs_pp_profile_L");
151  outfile->mkdir("dt_vs_pp_profile/dt_vs_pp_profile_R");
152 
153  // Make canvas
154  TCanvas *c = (TCanvas*)gROOT->FindObject("c");
155  if (c == 0) {
156  c = new TCanvas("c","c",0,20,600,500);
157  }
158 
159  // Make histograms
160 #if DEBUG
161  std::cout << "Naming histograms" << std::endl;
162 #endif
163  // Per module histograms
164  for (Int_t i = 0; i < NMODULES; ++i) {
165  // left module
166  h_dt_l[i] = new TH1D(Form("dt_l_%i",i+1),
167  Form("Time difference;PSC_L_%i - RF_L (ns)",i+1),
169  h_pp_l[i] = new TH1D(Form("pp_l_%i",i+1),
170  Form("Pulse peak;PSC_L_%i pulse peak (adc counts)",i+1),
172  h_dt_vs_pp_l[i] = (TH2F*)infile->Get(Form("PSC_TW/tdc-rf/h_dt_vs_pp_tdc_l_%i",i+1));
173  h_dt_vs_pp_l_corr[i] = new TH2F(Form("h_dt_vs_pp_L_corr_%i",i+1),
174  Form("Time difference vs pulse peak for PSC_L_%i",i+1),
176  g_dt_vs_pp_l[i] = new TProfile(Form("g_dt_vs_pp_L_%i",i+1),
177  Form("Time difference vs pulse peak for PSC_L_%i",i+1),
179  g_dt_vs_pp_l[i]->SetMinimum(DT_MIN);
180  g_dt_vs_pp_l[i]->SetMaximum(DT_MAX);
181 
182  // right module
183  h_dt_r[i] = new TH1D(Form("dt_r_%i",i+1),
184  Form("Time difference;PSC_R_%i - RF_R (ns)",i+1),
186  h_pp_r[i] = new TH1D(Form("pp_r_%i",i+1),
187  Form("Pulse peak;PSC_R_%i pulse peak (adc counts)",i+1),
189  h_dt_vs_pp_r[i] = (TH2F*)infile->Get(Form("PSC_TW/tdc-rf/h_dt_vs_pp_tdc_r_%i",i+1));
190  h_dt_vs_pp_r_corr[i] = new TH2F(Form("h_dt_vs_pp_R_corr_%i",i+1),
191  Form("Time difference vs pulse peak for PSC_R_%i",i+1),
193  g_dt_vs_pp_r[i] = new TProfile(Form("g_dt_vs_pp_R_%i",i+1),
194  Form("Time difference vs pulse peak for PSC_R_%i",i+1),
196  g_dt_vs_pp_r[i]->SetMinimum(DT_MIN);
197  g_dt_vs_pp_r[i]->SetMaximum(DT_MAX);
198  }
199  h_means_b = new TH1D("means_dt_b",
200  "Mean time difference for each PSC counter before corrections;\
201  Counter (1-8 left, 9-16 right);\
202  #Deltat (PSC - RF) [ns]",
203  2*NMODULES,1.0,2*NMODULES+1.0);
204  h_means_b->SetMinimum(-1.0);
205  h_means_b->SetMaximum(1.0);
206  h_means_b->GetYaxis()->SetTitleOffset(1.2);
207  h_sigmas_b = new TH1D("sigmas_dt_b",
208  "Sigmas for time difference for each PSC counter before corrections;\
209  Counter (1-8 left, 9-16);\
210  Sigma [ns]",
211  2*NMODULES,1.0,2*NMODULES+1.0);
212  h_sigmas_b->SetMinimum(0.08);
213  h_sigmas_b->SetMaximum(0.22);
214  h_sigmas_b->GetYaxis()->SetTitleOffset(1.2);
215  h_means_a = new TH1D("means_dt_a",
216  "Mean time difference for each PSC counter after corrections;\
217  Counter (1-8 left, 9-16 right);\
218  #Deltat (PSC - RF) [ns]",
219  2*NMODULES,1.0,2*NMODULES+1.0);
220  h_means_a->SetMinimum(-1.0);
221  h_means_a->SetMaximum(1.0);
222  h_means_a->GetYaxis()->SetTitleOffset(1.2);
223  h_sigmas_a = new TH1D("sigmas_dt_a",
224  "Sigmas for time difference for each PSC counter after corrections;\
225  Counter (1-8 left, 9-16);\
226  Sigma [ns]",
227  2*NMODULES,1.0,2*NMODULES+1.0);
228  h_sigmas_a->SetMinimum(0.08);
229  h_sigmas_a->SetMaximum(0.22);
230  h_sigmas_a->GetYaxis()->SetTitleOffset(1.2);
231 
232 #if DEBUG
233  std::cout << "Fitting initial timing distributions" << std::endl;
234 #endif
235  for (Int_t i = 0; i < NMODULES; ++i) {
236  // left module
237  h_dt_l[i] = h_dt_vs_pp_l[i]->ProjectionY();
238  TFitResultPtr resultpL0 = h_dt_l[i]->Fit("gaus","sq");
239  double meanL = resultpL0->Parameter(1);
240  double sigmaL = resultpL0->Parameter(2);
241 
242  // fit a second time using the mean and sigma of the initial fit
243  TFitResultPtr resultpL = h_dt_l[i]->Fit("gaus","sq","",meanL-2*sigmaL,meanL+2*sigmaL);
244  dtMeanL[i] = resultpL->Parameter(1);
245  h_means_b->Fill(i+1,dtMeanL[i]);
246  h_means_b->SetBinError(i+1,resultpL->ParError(1));
247  h_sigmas_b->Fill(i+1,resultpL->Parameter(2));
248  h_sigmas_b->SetBinError(i+1,resultpL->ParError(2));
249 #if OUTPUT
250  std::cout << "Sigma for left module " << i+1 << " is " << 1000*resultpL->Parameter(2) << std::endl;
251 #endif
252 
253  h_dt_l[i]->Reset();
254 
255  // right module
256  h_dt_r[i] = h_dt_vs_pp_r[i]->ProjectionY();
257  TFitResultPtr resultpR0 = h_dt_r[i]->Fit("gaus","sq");
258  double meanR = resultpR0->Parameter(1);
259  double sigmaR = resultpR0->Parameter(2);
260 
261  // fit a second time using the mean and sigma of the initial fit
262  TFitResultPtr resultpR = h_dt_r[i]->Fit("gaus","sq","",meanR-2*sigmaR,meanR+2*sigmaR);
263  dtMeanR[i] = resultpR->Parameter(1);
264  h_means_b->Fill(i+NMODULES+1,dtMeanR[i]);
265  h_means_b->SetBinError(i+NMODULES+1,resultpR->ParError(1));
266  h_sigmas_b->Fill(i+NMODULES+1,resultpR->Parameter(2));
267  h_sigmas_b->SetBinError(i+NMODULES+1,resultpR->ParError(2));
268 #if OUTPUT
269  std::cout << "Sigma for right module " << i+1 << " is " << 1000*resultpR->Parameter(2) << std::endl;
270 #endif
271 
272  h_dt_r[i]->Reset();
273  }
274  outfile->cd();
275  h_means_b->Write();
276  h_sigmas_b->Write();
277 
278 #if DEBUG
279  std::cout << "Making TProfile" << std::endl;
280 #endif
281  for (Int_t m = 0; m < NMODULES; ++m) {
282  for (Int_t i = 1; i <= 1000; ++i) {
283  for (Int_t j = 1; j <= 100; ++j) {
284  // left module
285  Double_t content_l = h_dt_vs_pp_l[m]->GetBinContent(i,j);
286  double t_shift_l = -5 + 0.1*j - dtMeanL[m];
287  if (content_l > 0 && t_shift_l < -2)
288  g_dt_vs_pp_l[m]->Fill(i,t_shift_l+4,content_l);
289  else if (content_l > 0 && t_shift_l > 2)
290  g_dt_vs_pp_l[m]->Fill(i,t_shift_l-4,content_l);
291  else
292  g_dt_vs_pp_l[m]->Fill(i,t_shift_l,content_l);
293 
294  // right module
295  Double_t content_r = h_dt_vs_pp_r[m]->GetBinContent(i,j);
296  double t_shift_r = -5 + 0.1*j - dtMeanR[m];
297  if (content_r > 0 && t_shift_r < -2)
298  g_dt_vs_pp_r[m]->Fill(i,t_shift_r+4,content_r);
299  else if (content_r > 0 && t_shift_r > 2)
300  g_dt_vs_pp_r[m]->Fill(i,t_shift_r-4,content_r);
301  else
302  g_dt_vs_pp_r[m]->Fill(i,t_shift_r,content_r);
303  }
304  }
305  }
306 
307 #if DEBUG
308  std::cout << "Getting most probable value" << std::endl;
309 #endif
310  // Get the most probable value of the pulse peak distribution for each module
311  for (Int_t i = 0; i < NMODULES; ++i) {
312  // left module
313  h_pp_l[i] = h_dt_vs_pp_l[i]->ProjectionX();
314  TFitResultPtr ptrL1 = h_pp_l[i]->Fit("landau","sq");
315  double mpv_L = ptrL1->Parameter(1);
316  double sigma_pp_L = ptrL1->Parameter(2);
317  TFitResultPtr ptrL2 = h_pp_l[i]->Fit("landau","sq","",mpv_L-1.5*sigma_pp_L,mpv_L+1.5*sigma_pp_L);
318  mpv[0][i] = ptrL2->Parameter(1);
319 
320  // right module
321  h_pp_r[i] = h_dt_vs_pp_r[i]->ProjectionX();
322  TFitResultPtr ptrR1 = h_pp_r[i]->Fit("landau","sq");
323  double mpv_R = ptrR1->Parameter(1);
324  double sigma_pp_R = ptrR1->Parameter(2);
325  TFitResultPtr ptrR2 = h_pp_r[i]->Fit("landau","sq","",mpv_R-1.5*sigma_pp_R,mpv_R+1.5*sigma_pp_R);
326  mpv[1][i] = ptrR2->Parameter(1);
327  }
328 
329 #if DEBUG
330  std::cout << "Writing to file ..." << std::endl;
331 #endif
332  for (Int_t i = 0; i < NMODULES; ++i) {
333  // left module
334  outfile->cd("dt_vs_pp/dt_vs_pp_L");
335  h_dt_vs_pp_l[i]->Write();
336 
337  outfile->cd("dt_vs_pp_profile/dt_vs_pp_profile_L");
338  g_dt_vs_pp_l[i]->Write();
339 
340  // right module
341  outfile->cd("dt_vs_pp/dt_vs_pp_R");
342  h_dt_vs_pp_r[i]->Write();
343 
344  outfile->cd("dt_vs_pp_profile/dt_vs_pp_profile_L");
345  g_dt_vs_pp_l[i]->Write();
346 
347  outfile->cd();
348  }
349 
350  for (int j = 0; j < NMODULES; ++j) {
351 #if DEBUG
352  std::cout << "Calling tw_fit() for modules " << j << std::endl;
353 #endif
354  // left module
355  tw_fit(g_dt_vs_pp_l[j],0,j);
356 
357  // right module
358  tw_fit(g_dt_vs_pp_r[j],1,j);
359  }
360 }
361 
362 void tw_corr(char const *inputFile) {
363 
364  std::cout << "Input file: " << inputFile << std::endl;
365 
366  tw_plot(inputFile);
367 
368 #if DEBUG
369  std::cout << "Writing psc_tw_parms.out" << std::endl;
370 #endif
371  // Writing parameters to psc_tw_parms.out for use in CCDB
372  std::ofstream flog("psc_tw_parms.out");
373  for (Int_t i = 0; i < 2; ++i) {
374  for (Int_t j = 0; j < NMODULES; ++j) {
375  flog << i << std::setw(15)
376  << j+1 << std::setw(15)
377  << c0[i][j] << std::setw(15)
378  << c1[i][j] << std::setw(15)
379  << c2[i][j] << std::setw(15)
380  << THRESHOLD << std::setw(15)
381  << mpv[i][j] << std::endl;
382  }
383  }
384 
385 #if DEBUG
386  std::cout << "About to fill corrected histograms" << std::endl;
387 #endif
388  for (Int_t i = 0; i < NMODULES; ++i) {
389  for (Int_t j = 0; j < 1000; ++j) {
390  for (Int_t k = 0; k < 100; ++k) {
391  // left module
392  double content_l = h_dt_vs_pp_l[i]->GetBinContent(j,k);
393  double t_shift_l = -5 + 0.1*k - dtMeanL[i];
394  if (content_l > 0 && t_shift_l > 2)
395  t_shift_l -= 4;
396  else if (content_l > 0 && t_shift_l < -2)
397  t_shift_l += 4;
398  t_shift_l -= c1[0][i]*pow((j/THRESHOLD),c2[0][i]) - c1[0][i]*pow(mpv[0][i]/THRESHOLD,c2[0][i]);
399  h_dt_vs_pp_l_corr[i]->Fill(j,t_shift_l,content_l);
400 
401  // right module
402  double content_r = h_dt_vs_pp_r[i]->GetBinContent(j,k);
403  double t_shift_r = -5 + 0.1*k - dtMeanR[i];
404  if (content_r > 0 && t_shift_r > 2)
405  t_shift_r -= 4;
406  else if (content_r > 0 && t_shift_r < -2)
407  t_shift_r += 4;
408  t_shift_r -= c1[1][i]*pow((j/THRESHOLD),c2[1][i]) - c1[1][i]*pow(mpv[1][i]/THRESHOLD,c2[1][i]);
409  h_dt_vs_pp_r_corr[i]->Fill(j,t_shift_r,content_r);
410  }
411  }
412  }
413 
414  for (Int_t i = 0; i < NMODULES; ++i) {
415  // left module
416  outfile->cd("dt_vs_pp_corr/dt_vs_pp_corr_L");
417  h_dt_vs_pp_l_corr[i]->Write();
418 
419  // right module
420  outfile->cd("dt_vs_pp_corr/dt_vs_pp_corr_R");
421  h_dt_vs_pp_r_corr[i]->Write();
422  }
423 
424  // calculate new sigmas
425  double avg = 0;
426  double avgL = 0;
427  double avgR = 0;
428 
429  std::ofstream flogsig("sigmas.out");
430  flogsig << "Arm\t" << "Module\t" << "Sigma (ps)" << std::endl;
431 
432  for (Int_t i = 0; i < NMODULES; ++i) {
433  // left module
434  h_dt_l_corr[i] = h_dt_vs_pp_l_corr[i]->ProjectionY();
435  TFitResultPtr ptrL = h_dt_l_corr[i]->Fit("gaus","sq");
436  double mean = ptrL->Parameter(1);
437  double sigma = ptrL->Parameter(2);
438  ptrL = h_dt_l_corr[i]->Fit("gaus","sq","",mean-2*sigma,mean+2*sigma);
439  mean = ptrL->Parameter(1);
440  sigma = ptrL->Parameter(2);
441  h_means_a->Fill(i+1,mean);
442  h_means_a->SetBinError(i+1,ptrL->ParError(1));
443  h_sigmas_a->Fill(i+1,sigma);
444  h_sigmas_a->SetBinError(i+1,ptrL->ParError(2));
445 #if OUTPUT
446  std::cout << "Sigma for left module " << i+1 << ": " << sigma*1000 << std::endl;
447 #endif
448  avgL += sigma*1000;
449  avg += sigma*1000;
450  flogsig << "0\t" << i+1 << "\t" << sigma*1000 << std::endl;
451 
452  // right module
453  h_dt_r_corr[i] = h_dt_vs_pp_r_corr[i]->ProjectionY();
454  TFitResultPtr ptrR = h_dt_r_corr[i]->Fit("gaus","sq");
455  mean = ptrR->Parameter(1);
456  sigma = ptrR->Parameter(2);
457  ptrR = h_dt_r_corr[i]->Fit("gaus","sq","",mean-2*sigma,mean+2*sigma);
458  mean = ptrR->Parameter(1);
459  sigma = ptrR->Parameter(2);
460  h_means_a->Fill(i+NMODULES+1,mean);
461  h_means_a->SetBinError(i+NMODULES+1,ptrR->ParError(1));
462  h_sigmas_a->Fill(i+NMODULES+1,sigma);
463  h_sigmas_a->SetBinError(i+NMODULES+1,ptrR->ParError(2));
464 #if OUTPUT
465  std::cout << "Sigma for right module " << i+1 << ": " << sigma*1000 << std::endl;
466 #endif
467  avgR += sigma*1000;
468  avg += sigma*1000;
469  flogsig << "1\t" << i+1 << "\t" << sigma*1000 << std::endl;
470  }
471  outfile->cd();
472  h_means_a->Write();
473  h_sigmas_a->Write();
474 
475  // Make canvas
476  TCanvas *c = NULL;
477  if (TVirtualPad::Pad() == NULL)
478  c = new TCanvas("PSC_TW","PSC_TW",1200,600);
479  else
480  c = gPad->GetCanvas();
481 
482  c->Clear();
483  c->Divide(2,2);
484  gStyle->SetOptStat(0);
485 
486  c->cd(1);
487  TPad* pad = (TPad*)c->GetPad(1);
488  pad->SetLeftMargin(0.15);
489  if (h_means_b != NULL)
490  h_means_b->Draw("E");
491 
492  c->cd(2);
493  pad = (TPad*)c->GetPad(2);
494  pad->SetLeftMargin(0.15);
495  if (h_means_a != NULL)
496  h_means_a->Draw("E");
497 
498  c->cd(3);
499  pad = (TPad*)c->GetPad(3);
500  pad->SetLeftMargin(0.15);
501  if (h_sigmas_b != NULL)
502  h_sigmas_b->Draw("E");
503 
504  c->cd(4);
505  pad = (TPad*)c->GetPad(4);
506  pad->SetLeftMargin(0.15);
507  if (h_sigmas_a != NULL)
508  h_sigmas_a->Draw("E");
509 
510  c->Print("CalibCheck.pdf","pdf");
511 
512  avgL /= 8;
513  avgR /= 8;
514  avg /= 16;
515 
516 #if OUTPUT
517  std::cout << "avgL: " << avgL << std::endl;
518  std::cout << "avgR: " << avgR << std::endl;
519  std::cout << "avg: " << avg << std::endl;
520 #endif
521 
522 }
523 
std::ofstream flog("tagm_tw_parms_defaults.out")
TH2F * h_dt_vs_pp_r[NMODULES]
Definition: tw_corr.C:87
Double_t c0[2][NMODULES]
Definition: tw_corr.C:67
TH1D * h_sigmas_a
Definition: tw_corr.C:83
const Double_t THRESHOLD
Definition: tw_corr.C:50
TH1D * h_means_b
Definition: tw_corr.C:80
void tw_corr(char const *inputFile)
Definition: tw_corr.C:362
TPad * pad
Definition: psc_mon.C:73
Double_t x[NCHANNELS]
Definition: st_tw_resols.C:39
TH1D * h_sigmas_b
Definition: tw_corr.C:81
#define c
const Int_t PROF_MAX
Definition: tw_corr.C:59
const Int_t PP_MIN
Definition: tw_corr.C:53
TH1D * h_dt_r_corr[NMODULES]
Definition: tw_corr.C:75
TH2F * h_dt_vs_pp_l[NMODULES]
Definition: tw_corr.C:86
TH1D * h_dt_l_corr[NMODULES]
Definition: tw_corr.C:74
TH2I * h_tw[102]
Definition: display.C:12
TFile * infile
Definition: tw_corr.C:45
Double_t fitf(Double_t *x, Double_t *par)
Definition: tw_corr.C:96
Double_t c1[2][NMODULES]
Definition: tw_corr.C:68
TF1 * f
Definition: FitGains.C:21
void tw_plot(char const *inputFile)
Definition: tw_corr.C:133
TProfile * g_dt_vs_pp_r[NMODULES]
Definition: tw_corr.C:93
TH1D * h_pp_l[NMODULES]
Definition: tw_corr.C:76
Double_t c2[2][NMODULES]
Definition: tw_corr.C:69
Double_t dtMeanL[NMODULES]
Definition: tw_corr.C:62
const Int_t BINS_DT
Definition: tw_corr.C:54
TH1D * h_dt_l[NMODULES]
Definition: tw_corr.C:72
Double_t dtMeanR[NMODULES]
Definition: tw_corr.C:63
TFile * outfile
Definition: tw_corr.C:46
const Int_t BINS_PP
Definition: tw_corr.C:51
TH1D * h_dt_r[NMODULES]
Definition: tw_corr.C:73
Double_t sigma[NCHANNELS]
Definition: st_tw_resols.C:37
const Int_t PP_MAX
Definition: tw_corr.C:52
const Int_t PROF_WIDTH
Definition: tw_corr.C:57
TH1D * h_pp_r[NMODULES]
Definition: tw_corr.C:77
TProfile * g_dt_vs_pp_l[NMODULES]
Definition: tw_corr.C:92
const Int_t DT_MAX
Definition: tw_corr.C:55
const uint32_t NMODULES
void tw_fit(TProfile *h_tw, int arm, int module)
Definition: tw_corr.C:103
const Int_t PROF_MIN
Definition: tw_corr.C:58
TH1D * h_means_a
Definition: tw_corr.C:82
TH2F * h_dt_vs_pp_l_corr[NMODULES]
Definition: tw_corr.C:88
const Int_t DT_MIN
Definition: tw_corr.C:56
Double_t mpv[2][NMODULES]
Definition: tw_corr.C:64
TH2F * h_dt_vs_pp_r_corr[NMODULES]
Definition: tw_corr.C:89