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;
17 t->Branch(
"BarLowThres", &blth,
"BarLowThres/D" );
18 t->Branch(
"BarHighThres", &bhth,
"BarHighThres/D");
19 t->Branch(
"EndLowThres", &elth,
"EndLowThres/D" );
20 t->Branch(
"EndHighThres", &ehth,
"EndHighThres/D");
21 t->Branch(
"BarPMTGain", &bgain,
"BarPMTGain/D" );
22 t->Branch(
"EndPMTGain", &egain,
"EndPMTGain/D" );
23 t->Branch(
"BarConstant", &bconst,
"BarConst/D" );
24 t->Branch(
"EndConstant", &econst,
"EndConst/D" );
25 t->Branch(
"EndNoiseSwitch",&eswitch,
"EndNoiseSwitch/D" );
29 const char*
file=
"SimConstants.txt";
30 inf.open(
file,ios::in);
35 std::cerr<<
"file: "<<
file <<
" can't be found!"<<std::endl;
50 TFile
f(
"TofSimConst.root",
"RECREATE");
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++ ) {
90 inf1 >> length >> ratio;
91 if( fabs(length)<1.0e-6 ) { length = 1.0; }
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");
178 TFile
f1(
"TofSimConst.root");
179 TTree* t1=(TTree*)
f1.Get(
"SimConstants");
180 if(0==t1) { std::cerr<<
" can't get tree :SimConstants in file TofSimConst.root"<<std::endl;
return false;}
181 TFile f2(
"BarTofSim.root");
182 TTree* t2=(TTree*)f2.Get(
"BTofSim");
183 if(0==t2) { std::cerr<<
" can't get tree :BTofSim in file BarTofSim.root"<<std::endl;
return false;}
184 TFile f3(
"EndTofSim.root");
185 TTree* t3=(TTree*)f3.Get(
"ETofSim");
186 if(0==t3) { std::cerr<<
" can't get tree :ETofSim in file EndTofSim.root"<<std::endl;
return false;}
188 TFile fnew(
"TofSimConst.root",
"RECREATE");
TFile f("ana_bhabha660a_dqa_mcPat_zy_old.root")