12 TTree*
t =
new TTree(
"SimConstants",
"threshold and gain constants" );
13 double blth = 50., bhth = 50., elth = 50., ehth = 50.;
14 double bgain = 5.E5, egain = 2.5E5;
15 double bconst = 1.0, econst = 1.0;
18 t->Branch(
"BarLowThres", &blth,
"BarLowThres/D" );
19 t->Branch(
"BarHighThres", &bhth,
"BarHighThres/D" );
20 t->Branch(
"EndLowThres", &elth,
"EndLowThres/D" );
21 t->Branch(
"EndHighThres", &ehth,
"EndHighThres/D" );
22 t->Branch(
"BarPMTGain", &bgain,
"BarPMTGain/D" );
23 t->Branch(
"EndPMTGain", &egain,
"EndPMTGain/D" );
24 t->Branch(
"BarConstant", &bconst,
"BarConst/D" );
25 t->Branch(
"EndConstant", &econst,
"EndConst/D" );
26 t->Branch(
"EndNoiseSwitch", &eswitch,
"EndNoiseSwitch/D" );
30 const char*
file =
"SimConstants.txt";
31 inf.open(
file, ios::in );
32 if ( inf.good() ) { is_open =
true; }
33 else { std::cerr <<
"file: " <<
file <<
" can't be found!" << std::endl; }
49 TFile
f(
"TofSimConst.root",
"RECREATE" );
59 double gain = 0.0, ratio = 0.0, length = 1.0;
60 TTree*
t =
new TTree(
"BTofSim",
"barrel attenuation length and gain" );
61 t->Branch(
"Gain", &gain,
"Gain/D" );
62 t->Branch(
"Ratio", &ratio,
"Ratio/D" );
63 t->Branch(
"AttenLength", &length,
"AttenLength/D" );
65 double a1overa2 = 1.0, a2 = 1.0;
66 double qmean = 0.0, qsigma = 0.0;
68 bool is_open1 =
false, is_open2 =
false;
69 const char* file1 =
"calib_barrel_atten.txt";
70 const char* file2 =
"calib_barrel_q0.txt";
71 inf1.open( file1, ios::in );
72 inf2.open( file2, ios::in );
73 if ( inf1.good() ) { is_open1 =
true; }
74 else { std::cerr <<
"file: " << file1 <<
" can't be found!" << std::endl; }
75 if ( inf2.good() ) { is_open2 =
true; }
76 else { std::cerr <<
"file: " << file2 <<
" can't be found!" << std::endl; }
80 if ( is_open1 && is_open2 )
82 for (
unsigned int i = 0; i < 176; i++ )
84 inf1 >> length >> ratio;
85 if ( fabs( length ) < 1.0e-6 ) { length = 1.0; }
86 length = 1.0 / length;
88 inf2 >> gain >> qmean >> qsigma;
99 TFile
f(
"BarTofSim.root",
"RECREATE" );
109 double gain = 0.0, length = 1.0, noisesmear = 0.;
110 double scin, mean, errmean, sigma, errsigma;
112 TTree*
t =
new TTree(
"ETofSim",
"endcap attenuation length and gain" );
113 t->Branch(
"Gain", &gain,
"Gain/D" );
114 t->Branch(
"AttenLength", &length,
"AttenLength/D" );
115 t->Branch(
"NoiseSmear", &noisesmear,
"NoiseSmear/D" );
117 double length2 = 1.0;
118 ifstream inf1, inf2, inf3;
119 bool is_open1 =
false, is_open2 =
false, is_open3 =
false;
120 const char* file1 =
"calib_endcap_atten.txt";
121 const char* file2 =
"tEndRes.txt";
122 const char* file3 =
"Endcap_mc_tEndRes.txt";
123 inf1.open( file1, ios::in );
124 inf2.open( file2, ios::in );
125 inf3.open( file3, ios::in );
126 if ( inf1.good() ) is_open1 =
true;
127 else { std::cerr <<
"File: " << file1 <<
" can't be opened" << std::endl; }
128 if ( inf2.good() ) is_open2 =
true;
129 else { std::cerr <<
"File: " << file2 <<
" can't be opened" << std::endl; }
130 if ( inf3.good() ) is_open3 =
true;
131 else { std::cerr <<
"File: " << file3 <<
" can't be opened" << std::endl; }
134 if ( is_open1 && is_open2 && is_open3 )
136 for (
int i = 0; i < 96; i++ )
138 inf1 >> gain >> length >> length2;
139 inf2 >> scin >> mean >> errmean >> sigma >> errsigma;
141 if ( mc_sigma > sigma ) { noisesmear = 0.; }
142 else { noisesmear = sqrt( sigma * sigma - mc_sigma * mc_sigma ); }
153 TFile
f(
"EndTofSim.root",
"RECREATE" );