Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
st_prop_time_corr_v1.C
Go to the documentation of this file.
1 // File: st_tw_fits.C
2 // Last Modified: 01/12/2016
3 // Creator: Mahmoud Kamel mkame006@fiu.edu
4 // Purpose: Displaying histograms for propagation time corrections
5 #include "TH1.h"
6 #include <TH2I.h>
7 #include <TH1D.h>
8 #include "TF1.h"
9 #include "TROOT.h"
10 #include "TStyle.h"
11 #include "TMath.h"
12 #include "TFile.h"
13 #include "TCanvas.h"
14 #include "TAxis.h"
15 #include <TDirectory.h>
16 #include <TLine.h>
17 #include <TPaveLabel.h>
18 #include <TPaletteAxis.h>
19 #include <stdio.h>
20 #include <stdint.h>
21 #include <fstream>
22 using namespace std;
23 using std::string;
24 // ***************** define constants and varibles*************************
25 const Int_t NCHANNELS = 30;
26 // Double_t sudo_mpv_chan[NCHANNELS];
27 Double_t t_ss_fit[NCHANNELS][3];
28 Double_t t_ss_fit_err[NCHANNELS][3];
29 Double_t t_bs_fit[NCHANNELS][3];
30 Double_t t_bs_fit_err[NCHANNELS][3];
31 Double_t t_ns_fit[NCHANNELS][3];
32 Double_t t_ns_fit_err[NCHANNELS][3];
33 Double_t t_total_fit[NCHANNELS][3];
35 Double_t ex[NCHANNELS];
36 
37 Double_t t_bin[NCHANNELS];
38 Double_t t_max[NCHANNELS];
39 Double_t t_min[NCHANNELS];
40 Double_t tns_max[NCHANNELS];
41 Double_t tns_min[NCHANNELS];
42 Double_t tbs_max[NCHANNELS];
43 Double_t tbs_min[NCHANNELS];
44 Double_t tss_max[NCHANNELS];
45 Double_t tss_min[NCHANNELS];
46 
47 Float_t bins[210];
48 Float_t binsss[210];
49 Float_t binsbs[210];
50 Float_t binsns[210];
51 //******************************** Cut Parameters **********************
52 Double_t low_cut = 0.00 ; // set bin content to zero if bin content is below low_cut
53 //**** Declare 1D Histogram ******************************************
54 TH1D *py[NCHANNELS];
55 // Declare canvas
56 TCanvas *PT_can[30];
57 TDirectory* TopDirectory;
58 TH2I* h2_ss;
59 TH2I* h2_bs;
60 TH2I* h2_ns;
61 TH2I* h2_total;
62 
63 void st_prop_time_corr_v1(char const* input_filename)
64 //void st_tw_fits()
65 {
66  TFile *df = new TFile(input_filename);
67  std::ofstream st_prop_time_constants;
68  st_prop_time_constants.open ("st_prop_timeCorr.txt", std::ofstream::out);
69  //*****************************************************************
70  //*********** Grab the histograms from the root file **************
71  //*****************************************************************
72  for (unsigned int j = 0; j < 30; j++)
73  {
74  //Create the canvas
75  PT_can[j] = new TCanvas( Form("PT_can_%i",j+1), Form("PT_can_%i",j+1), 800, 450);
76  PT_can[j]->Divide(2, 2);
77  // The top directory
78  TopDirectory = (TDirectory*) df->FindObjectAny("ST_Propagation_Time");
79  TopDirectory->cd();
80  // Grab the histograms
81  char* ss = Form("h2_PropTimeCorr_z_SS_chan_%i",j+1);
82  h2_ss = (TH2I*) TopDirectory->FindObjectAny(ss);
83  char* bs = Form("h2_PropTimeCorr_z_BS_chan_%i",j+1);
84  h2_bs = (TH2I*) TopDirectory->FindObjectAny(bs);
85  char* ns = Form("h2_PropTimeCorr_z_NS_chan_%i",j+1);
86  h2_ns = (TH2I*) TopDirectory->FindObjectAny(ns);
87  char* total = Form("h2_CorrectedTime_z_%i",j+1);
88  h2_total = (TH2I*) TopDirectory->FindObjectAny(total);
89  //*****************************************************************
90  //*********** Plot stt vs z SS ******************
91  //*****************************************************************
92  PT_can[j]->cd(1);
93  gStyle->SetOptStat(10);
94  gStyle->SetOptFit(0111);
95  gStyle->SetErrorX(0);
96  gPad->SetTicks();
97  gPad->SetGrid();
98  h2_ss->Draw("colz");
99  h2_ss->SetTitle("Straight Section Corrected Time");
100  h2_ss->SetXTitle("Z (cm)");
101  h2_ss->SetYTitle("SC Time (ns)");
102  h2_ss->GetZaxis()->SetRangeUser(0,4);
103  h2_ss->GetXaxis()->SetRangeUser(0,40);
104  h2_ss->GetYaxis()->SetRangeUser(-5.0,5.0);
105  gPad->Update();
106  //*****************************************************************
107  //*********** Plot stt vs z BS ******************
108  //*****************************************************************
109  PT_can[j]->cd(2);
110  gStyle->SetOptStat(10);
111  gStyle->SetErrorX(0);
112  gPad->SetTicks();
113  gPad->SetGrid();
114 
115  h2_bs->Draw("colz");
116  h2_bs->SetTitle("Bend Section Corrected Time");
117  h2_bs->SetXTitle("Z (cm)");
118  h2_bs->SetYTitle("SC Time (ns)");
119  h2_bs->GetZaxis()->SetRangeUser(0,4);
120  h2_bs->GetXaxis()->SetRangeUser(39,43);
121  h2_bs->GetYaxis()->SetRangeUser(-5.0,5.0);
122  gPad->Update();
123  //*****************************************************************
124  //*********** Plot stt vs z NS ******************
125  //*****************************************************************
126  PT_can[j]->cd(3);
127  gStyle->SetOptStat(10);
128  gStyle->SetErrorX(0);
129  gPad->SetTicks();
130  gPad->SetGrid();
131 
132  h2_ns->Draw("colz");
133  h2_ns->SetTitle("Nose Section Corrected Time");
134  h2_ns->SetXTitle("Z (cm)");
135  h2_ns->SetYTitle("SC Time (ns)");
136  h2_ns->GetZaxis()->SetRangeUser(0,4);
137  h2_ns->GetXaxis()->SetRangeUser(43,60);
138  h2_ns->GetYaxis()->SetRangeUser(-5.0,5.0);
139  gPad->Update();
140  //*****************************************************************
141  //*********** Plot Total corrected time from each division *******
142  //*****************************************************************
143  PT_can[j]->cd(4);
144  gStyle->SetOptStat(10);
145  gStyle->SetErrorX(0);
146  gPad->SetTicks();
147  gPad->SetGrid();
148 
149  h2_total->Draw("colz");
150  h2_total->SetTitle("Paddle Corrected Time");
151  h2_total->SetXTitle("Z (cm)");
152  h2_total->SetYTitle("SC Time (ns)");
153  h2_total->GetZaxis()->SetRangeUser(0,4);
154  h2_total->GetXaxis()->SetRangeUser(0,60);
155  h2_total->GetYaxis()->SetRangeUser(-5.0,5.0);
156  gPad->Update();
157  }
158  // Close the output file
159  st_prop_time_constants.close();
160 }
161 
Double_t tns_min[NCHANNELS]
Double_t t_bs_fit_err[NCHANNELS][3]
Double_t low_cut
Definition: SC_PTC.C:78
Double_t t_bs_fit[NCHANNELS][3]
TFile * df
Definition: ST_slices_eff.C:17
const Int_t NCHANNELS
double total
Definition: FitGains.C:151
char string[256]
Double_t tbs_min[NCHANNELS]
Double_t t_total_fit[NCHANNELS][3]
TH2I * h2_ns
Definition: SC_PTC.C:45
Double_t t_min[NCHANNELS]
Double_t tbs_max[NCHANNELS]
TDirectory * TopDirectory
Double_t t_ns_fit_err[NCHANNELS][3]
Double_t ex[NCHANNELS]
Double_t tss_min[NCHANNELS]
Float_t t_bin[NCHANNELS]
Double_t t_total_fit_err[NCHANNELS][3]
TH2I * h2_ss
Definition: SC_PTC.C:43
Double_t t_ns_fit[NCHANNELS][3]
TH1D * py[NCHANNELS]
TCanvas * PT_can[30]
Double_t t_ss_fit_err[NCHANNELS][3]
void st_prop_time_corr_v1(char const *input_filename)
Double_t tns_max[NCHANNELS]
Double_t t_ss_fit[NCHANNELS][3]
TH2I * h2_bs
Definition: SC_PTC.C:44
Double_t t_max[NCHANNELS]
Double_t tss_max[NCHANNELS]