15 TTree* t0 =
new TTree(
"CalibInfo",
"run number and version number" );
16 int run1 = 0, run2 = 0, version = 0;
17 int qCorr = 1, qElec = 1, misLable = 1;
18 int itofid[15] = { 0 };
19 char ebrname[5], wbrname[5], ecname[5];
20 char iebrname[5], iwbrname[5], iecname[5];
21 t0->Branch(
"Run1", &run1,
"Run1/I" );
22 t0->Branch(
"Run2", &run2,
"Run2/I" );
23 t0->Branch(
"Version", &version,
"Version/I" );
24 t0->Branch(
"qCorr", &qCorr,
"qCorr/I" );
25 t0->Branch(
"qElec", &qElec,
"qElec/I" );
26 t0->Branch(
"misLable", &misLable,
"misLable/I" );
28 for (
unsigned int i = 0; i < 5; i++ )
30 sprintf( ebrname,
"ebrId%d", i );
31 sprintf( iebrname,
"ebrId%d/I", i );
32 t0->Branch( ebrname, &itofid[i], iebrname );
33 sprintf( wbrname,
"wbrId%d", i );
34 sprintf( iwbrname,
"wbrId%d/I", i );
35 t0->Branch( wbrname, &itofid[i + 5], iwbrname );
37 sprintf( iecname,
"ecId%d/I", i );
38 t0->Branch( ecname, &itofid[i + 10], iecname );
42 unsigned int barrel, layer, tofid, end;
45 const char*
file =
"calib_info.txt";
46 inf.open(
file, ios::in );
47 if ( inf.good() ) { is_open =
true; }
48 else { std::cerr <<
"file: " <<
file <<
" can't be found!" << std::endl; }
53 inf >> run1 >> run2 >> version;
54 inf >> qCorr >> qElec >> misLable;
55 for (
unsigned int i = 0; i < 15; i++ )
60 tofid =
unsigned int( itmp );
61 if ( i >= 0 && i <= 9 )
63 if ( i >= 0 && i <= 4 ) { end = 0; }
64 else if ( i >= 5 && i <= 9 ) { end = 1; }
66 if ( itmp >= 0 && itmp <= 87 ) { layer = 0; }
67 else if ( itmp >= 88 && itmp <= 175 )
72 else { std::cout <<
"1 impossible tofid!" << std::endl; }
74 ( 0x20000000 | ( barrel << 14 ) | ( layer << 8 ) | ( tofid << 1 ) | end );
76 else if ( i >= 10 && i <= 14 )
83 if ( itmp >= 48 && itmp <= 95 )
89 ( 0x20000000 | ( barrel << 14 ) | ( layer << 8 ) | ( tofid << 1 ) | end );
91 else if ( version == 1 )
94 end =
unsigned int( itmp / 10000 );
95 tofid =
unsigned int( ( itmp - end * 10000 ) / 100 );
96 unsigned int strip =
unsigned int( itmp % 100 );
97 unsigned int endcap = 0;
98 if ( tofid >= 36 && tofid <= 71 )
103 itofid[i] = ( 0x20000000 | ( barrel << 14 ) | ( endcap << 11 ) | ( tofid << 5 ) |
104 ( strip << 1 ) | end );
106 else if ( version == 2 ) { itofid[i] = itmp; }
108 else { std::cout <<
"impossible tofid!" << std::endl; }
110 else { itofid[i] = 0x2fffffff; }
117 TFile
f(
"CalibInfo.root",
"RECREATE" );
128 TTree* t1 =
new TTree(
"BarTofPar",
"barrel parameters" );
130 double p[20] = { 1. };
133 for (
int i = 0; i < 20; i++ )
137 t1->Branch( brname, &p[i], ptname );
140 double bunch0_poff[40] = { 1. }, bunch1_poff[40] = { 1. }, bunch2_poff[40] = { 1. },
141 bunch3_poff[40] = { 1. };
144 for (
int i = 0; i < 40; i++ )
146 sprintf( broffname,
"Bunch0_Poff%d", i );
147 sprintf( ptoffname,
"bunch0_poff%d/D", i );
148 t1->Branch( broffname, &bunch0_poff[i], ptoffname );
150 for (
int i = 0; i < 40; i++ )
152 sprintf( broffname,
"Bunch1_Poff%d", i );
153 sprintf( ptoffname,
"bunch1_poff%d/D", i );
154 t1->Branch( broffname, &bunch1_poff[i], ptoffname );
156 for (
int i = 0; i < 40; i++ )
158 sprintf( broffname,
"Bunch2_Poff%d", i );
159 sprintf( ptoffname,
"bunch2_poff%d/D", i );
160 t1->Branch( broffname, &bunch2_poff[i], ptoffname );
162 for (
int i = 0; i < 40; i++ )
164 sprintf( broffname,
"Bunch3_Poff%d", i );
165 sprintf( ptoffname,
"bunch3_poff%d/D", i );
166 t1->Branch( broffname, &bunch3_poff[i], ptoffname );
169 double fitfun[20] = { 0. };
171 char fbrname1[5], fptname1[5], fbrname2[5], fptname2[5];
172 char fbrname3[10], fptname3[10];
173 for (
int i = 0; i < 5; i++ )
175 sprintf( fbrname1,
"FLeft%d", i );
176 sprintf( fptname1,
"fleft%d/D", i );
177 t1->Branch( fbrname1, &fitfun[i], fptname1 );
178 sprintf( fbrname2,
"FRight%d", i );
179 sprintf( fptname2,
"fright%d/D", i );
180 t1->Branch( fbrname2, &fitfun[5 + i], fptname2 );
182 for (
int i = 0; i < 10; i++ )
184 sprintf( fbrname3,
"FCounter%d", i );
185 sprintf( fptname3,
"fcounter%d/D", i );
186 t1->Branch( fbrname3, &fitfun[10 + i], fptname3 );
189 double Atten[8] = { 1. };
190 for (
int i = 0; i < 8; i++ )
192 sprintf( brname,
"Atten%d", i );
193 sprintf( ptname,
"Atten%d/D", i );
194 t1->Branch( brname, &Atten[i], ptname );
197 double Speed[2] = { 1. };
198 t1->Branch(
"Speed0", &Speed[0],
"Speed0/D" );
199 t1->Branch(
"Speed1", &Speed[1],
"Speed1/D" );
203 bool is_open[N] = {
false };
204 const char* filelist[N] = {
205 "calib_barrel_left.txt",
206 "calib_barrel_right.txt",
207 "calib_barrel_left_offset1_bunch0.txt",
208 "calib_barrel_left_offset2_bunch0.txt",
209 "calib_barrel_right_offset1_bunch0.txt",
210 "calib_barrel_right_offset2_bunch0.txt",
211 "calib_barrel_left_offset1_bunch1.txt",
212 "calib_barrel_left_offset2_bunch1.txt",
213 "calib_barrel_right_offset1_bunch1.txt",
214 "calib_barrel_right_offset2_bunch1.txt",
215 "calib_barrel_left_offset1_bunch2.txt",
216 "calib_barrel_left_offset2_bunch2.txt",
217 "calib_barrel_right_offset1_bunch2.txt",
218 "calib_barrel_right_offset2_bunch2.txt",
219 "calib_barrel_left_offset1_bunch3.txt",
220 "calib_barrel_left_offset2_bunch3.txt",
221 "calib_barrel_right_offset1_bunch3.txt",
222 "calib_barrel_right_offset2_bunch3.txt",
223 "calib_barrel_sigma.txt",
224 "calib_barrel_atten.txt",
225 "calib_barrel_q0.txt",
226 "calib_barrel_veff.txt",
227 "calib_barrel_common.txt"
229 for (
int m = 0; m < N; m++ )
231 inf[m].open( filelist[m], ios::in );
232 if ( inf[m].good() ) is_open[m] =
true;
233 else std::cerr <<
"file: " << filelist[m] <<
" can't be found!" << std::endl;
238 for (
int k = 0; k < 176; k++ )
241 if ( is_open[0] && is_open[1] )
243 for (
int j = 0; j < 7; j++ )
250 if ( is_open[2] && is_open[3] && is_open[4] && is_open[5] )
252 for (
int j = 0; j < 7; j++ )
254 inf[2] >> bunch0_poff[j];
255 inf[3] >> bunch0_poff[j + 10];
256 inf[4] >> bunch0_poff[j + 20];
257 inf[5] >> bunch0_poff[j + 30];
261 if ( is_open[6] && is_open[7] && is_open[8] && is_open[9] )
263 for (
int j = 0; j < 7; j++ )
265 inf[6] >> bunch1_poff[j];
266 inf[7] >> bunch1_poff[j + 10];
267 inf[8] >> bunch1_poff[j + 20];
268 inf[9] >> bunch1_poff[j + 30];
273 if ( is_open[10] && is_open[11] && is_open[12] && is_open[13] )
275 for (
int j = 0; j < 7; j++ )
277 inf[10] >> bunch2_poff[j];
278 inf[11] >> bunch2_poff[j + 10];
279 inf[12] >> bunch2_poff[j + 20];
280 inf[13] >> bunch2_poff[j + 30];
283 if ( is_open[14] && is_open[15] && is_open[16] && is_open[17] )
285 for (
int j = 0; j < 7; j++ )
287 inf[14] >> bunch3_poff[j];
288 inf[15] >> bunch3_poff[j + 10];
289 inf[16] >> bunch3_poff[j + 20];
290 inf[17] >> bunch3_poff[j + 30];
296 for (
int j = 0; j < 15; j++ ) { inf[18] >> fitfun[j]; }
301 for (
int j = 0; j < 2; j++ ) { inf[19] >> Atten[j]; }
302 Atten[0] = 1. / Atten[0];
307 for (
int j = 2; j < 5; j++ ) { inf[20] >> Atten[j]; }
312 for (
int j = 0; j < 2; j++ ) { inf[21] >> Speed[j]; }
313 Speed[0] = 1. / Speed[0];
320 TTree* t2 =
new TTree(
"BarTofParCommon",
"common part of barrel" );
321 double t0Offset[2] = { 0. }, sigmaCorr[8] = { 0. };
322 for (
int i = 0; i < 2; i++ )
324 sprintf( brname,
"t0offset%d", i );
325 sprintf( ptname,
"t0offset%d/D", i );
326 t2->Branch( brname, &t0Offset[i], ptname );
328 for (
int i = 0; i < 8; i++ )
330 sprintf( brname,
"sigmaCorr%d", i );
331 sprintf( ptname,
"sigmaCorr%d/D", i );
332 t2->Branch( brname, &sigmaCorr[i], ptname );
337 { inf[22] >> sigmaCorr[0] >> sigmaCorr[1] >> t0Offset[0] >> t0Offset[1]; }
342 for (
int m = 0; m < N; m++ ) { inf[m].close(); }
344 TFile
f(
"BarTofPar.root",
"RECREATE" );
408 TTree*
t =
new TTree(
"EtfTofPar",
"etf parameters" );
409 TTree* t1 =
new TTree(
"EtfTofBunch",
"etf parameters" );
413 double p[60] = { 1. };
414 for (
int i = 0; i < 60; i++ )
418 t->Branch( brname, &p[i], ptname );
420 double Speed[4] = { 1. };
421 for (
int i = 0; i < 4; i++ )
423 sprintf( brname,
"Speed%d", i );
424 sprintf( ptname,
"Speed%d/D", i );
425 t->Branch( brname, &Speed[i], ptname );
428 double pBunch[4] = { 1. };
429 for (
int i = 0; i < 4; i++ )
431 sprintf( brname,
"pbunch%d", i );
432 sprintf( ptname,
"pbunch%d/D", i );
433 t1->Branch( brname, &pBunch[i], ptname );
438 bool is_open[K] = {
false };
439 const char* filelist[K] = {
"calib_etf_combine.txt",
"calib_etf_left.txt",
440 "calib_etf_right.txt",
"calib_etf_veff.txt",
441 "calib_etf_bunch.txt" };
442 for (
int i = 0; i < K; i++ )
444 inf[i].open( filelist[i], ios::in );
445 if ( inf[i].good() ) is_open[i] =
true;
446 else { std::cerr <<
"File: " << filelist[i] <<
" can't be opened" << std::endl; }
450 for (
int i = 0; i < 72; i++ )
452 for (
int j = 0; j < 12; j++ )
455 if ( is_open[0] && is_open[1] && is_open[2] )
457 for (
int k = 0; k < 7; k++ ) { inf[0] >> p[k]; }
458 for (
int k = 0; k < 13; k++ )
467 for (
int k = 0; k < 4; k++ ) { inf[3] >> Speed[k]; }
475 for (
int k = 0; k < 4; k++ ) { inf[4] >> pBunch[k] >> tmp; }
481 for (
int i = 0; i < K; i++ ) { inf[i].close(); }
483 TFile
f(
"EtfTofPar.root",
"RECREATE" );