60 double gain=0.0, ratio=0.0,
length=1.0;
61 TTree*
t=
new TTree(
"BTofSim",
"barrel attenuation length and gain");
62 t->Branch(
"Gain", &gain,
"Gain/D");
63 t->Branch(
"Ratio", &ratio,
"Ratio/D");
64 t->Branch(
"AttenLength", &
length,
"AttenLength/D");
66 double a1overa2 = 1.0, a2 = 1.0;
67 double qmean = 0.0, qsigma = 0.0;
69 bool is_open1=
false, is_open2=
false;
70 const char* file1=
"calib_barrel_atten.txt";
71 const char* file2=
"calib_barrel_q0.txt";
72 inf1.open(file1,ios::in);
73 inf2.open(file2,ios::in);
78 std::cerr<<
"file: "<<file1 <<
" can't be found!"<<std::endl;
84 std::cerr<<
"file: "<<file2 <<
" can't be found!"<<std::endl;
88 if( is_open1 && is_open2 ) {
89 for(
unsigned int i=0; i<176; i++ ) {
94 inf2 >> gain >> qmean >> qsigma;
106 TFile f(
"BarTofSim.root",
"RECREATE");
116 double gain=0.0,
length=1.0, noisesmear=0.;
117 double scin, mean, errmean, sigma, errsigma;
119 TTree*
t=
new TTree(
"ETofSim",
"endcap attenuation length and gain");
120 t->Branch(
"Gain", &gain,
"Gain/D" );
121 t->Branch(
"AttenLength", &
length,
"AttenLength/D");
122 t->Branch(
"NoiseSmear", &noisesmear,
"NoiseSmear/D" );
125 ifstream inf1, inf2, inf3;
126 bool is_open1=
false, is_open2=
false, is_open3=
false;
127 const char* file1=
"calib_endcap_atten.txt";
128 const char* file2=
"tEndRes.txt";
129 const char* file3=
"Endcap_mc_tEndRes.txt";
130 inf1.open(file1,ios::in);
131 inf2.open(file2,ios::in);
132 inf3.open(file3,ios::in);
136 std::cerr<<
"File: "<<file1<<
" can't be opened"<<std::endl;
141 std::cerr<<
"File: "<<file2<<
" can't be opened"<<std::endl;
146 std::cerr<<
"File: "<<file3<<
" can't be opened"<<std::endl;
149 if( is_open1 && is_open2 && is_open3) {
150 for(
int i=0;i<96;i++) {
151 inf1 >> gain >>
length >> length2;
152 inf2 >> scin >> mean >> errmean >> sigma >> errsigma;
154 if ( mc_sigma > sigma ) {noisesmear = 0.;}
155 else { noisesmear = sqrt(sigma*sigma - mc_sigma*mc_sigma);}
167 TFile f(
"EndTofSim.root",
"RECREATE");