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;
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++ ){
29 sprintf( ebrname,
"ebrId%d", i );
30 sprintf( iebrname,
"ebrId%d/I",i );
31 t0->Branch(ebrname,&itofid[i],iebrname);
32 sprintf( wbrname,
"wbrId%d", i );
33 sprintf( iwbrname,
"wbrId%d/I",i );
34 t0->Branch(wbrname,&itofid[i+5],iwbrname);
35 sprintf( ecname,
"ecId%d", i );
36 sprintf( iecname,
"ecId%d/I", i );
37 t0->Branch(ecname,&itofid[i+10],iecname);
41 unsigned int barrel, layer, tofid, end;
44 const char* file=
"calib_info.txt";
45 inf.open(file,ios::in);
50 std::cerr<<
"file: "<<file <<
" can't be found!"<<std::endl;
54 inf >> run1 >> run2 >> version;
55 inf >> qCorr >> qElec >> misLable;
56 for(
unsigned int i=0; i<15; i++ ) {
59 tofid =
unsigned int( itmp );
64 else if( i>=5 && i<=9 ) {
68 if( itmp>=0 && itmp<=87 ) {
71 else if( itmp>=88 && itmp<=175 ) {
76 std::cout <<
"1 impossible tofid!" << std::endl;
78 itofid[i] = ( 0x20000000 | (barrel<<14) | (layer<<8) | (tofid<<1) | end );
80 else if( i>=10 && i<=14 ) {
84 if( itmp>=48 && itmp<=95 ) {
88 itofid[i] = ( 0x20000000 | (barrel<<14) | (layer<<8) | (tofid<<1) | end );
91 std::cout <<
"impossible tofid!" << std::endl;
95 itofid[i] = 0x2fffffff;
104 TFile f(
"CalibInfo.root",
"RECREATE");
116 TTree* t1 =
new TTree(
"BarTofPar",
"barrel parameters" );
121 for(
int i=0;i<20;i++){
122 sprintf( brname,
"P%d", i );
123 sprintf( ptname,
"p%d/D", i );
124 t1->Branch(brname,&p[i],ptname);
127 double bunch0_poff[40]={1.},bunch1_poff[40]={1.},bunch2_poff[40]={1.},bunch3_poff[40]={1.};
130 for(
int i=0;i<40;i++){
131 sprintf( broffname,
"Bunch0_Poff%d", i );
132 sprintf( ptoffname,
"bunch0_poff%d/D", i );
133 t1->Branch( broffname, &bunch0_poff[i], ptoffname );
135 for(
int i=0;i<40;i++){
136 sprintf( broffname,
"Bunch1_Poff%d", i );
137 sprintf( ptoffname,
"bunch1_poff%d/D", i );
138 t1->Branch( broffname, &bunch1_poff[i], ptoffname );
140 for(
int i=0;i<40;i++){
141 sprintf( broffname,
"Bunch2_Poff%d", i );
142 sprintf( ptoffname,
"bunch2_poff%d/D", i );
143 t1->Branch( broffname, &bunch2_poff[i], ptoffname );
145 for(
int i=0;i<40;i++){
146 sprintf( broffname,
"Bunch3_Poff%d", i );
147 sprintf( ptoffname,
"bunch3_poff%d/D", i );
148 t1->Branch( broffname, &bunch3_poff[i], ptoffname );
151 double fitfun[20]={0.};;
152 char fbrname1[5], fptname1[5], fbrname2[5], fptname2[5];
153 char fbrname3[10], fptname3[10];
154 for(
int i=0;i<5;i++){
155 sprintf( fbrname1,
"FLeft%d", i );
156 sprintf( fptname1,
"fleft%d/D", i );
157 t1->Branch( fbrname1, &fitfun[i], fptname1 );
158 sprintf( fbrname2,
"FRight%d", i );
159 sprintf( fptname2,
"fright%d/D", i );
160 t1->Branch( fbrname2, &fitfun[5+i], fptname2 );
162 for(
int i=0;i<10;i++){
163 sprintf( fbrname3,
"FCounter%d", i );
164 sprintf( fptname3,
"fcounter%d/D", i );
165 t1->Branch( fbrname3, &fitfun[10+i], fptname3 );
168 double Atten[8]={1.};
169 for(
int i=0;i<8;i++){
170 sprintf( brname,
"Atten%d", i );
171 sprintf( ptname,
"Atten%d/D", i );
172 t1->Branch(brname, &Atten[i], ptname);
175 double Speed[2]={1.};
176 t1->Branch(
"Speed0", &Speed[0],
"Speed0/D" );
177 t1->Branch(
"Speed1", &Speed[1],
"Speed1/D" );
181 bool is_open[N]={
false};
182 const char* filelist[N]={
183 "calib_barrel_left.txt",
184 "calib_barrel_right.txt",
185 "calib_barrel_left_offset1_bunch0.txt",
186 "calib_barrel_left_offset2_bunch0.txt",
187 "calib_barrel_right_offset1_bunch0.txt",
188 "calib_barrel_right_offset2_bunch0.txt",
189 "calib_barrel_left_offset1_bunch1.txt",
190 "calib_barrel_left_offset2_bunch1.txt",
191 "calib_barrel_right_offset1_bunch1.txt",
192 "calib_barrel_right_offset2_bunch1.txt",
193 "calib_barrel_left_offset1_bunch2.txt",
194 "calib_barrel_left_offset2_bunch2.txt",
195 "calib_barrel_right_offset1_bunch2.txt",
196 "calib_barrel_right_offset2_bunch2.txt",
197 "calib_barrel_left_offset1_bunch3.txt",
198 "calib_barrel_left_offset2_bunch3.txt",
199 "calib_barrel_right_offset1_bunch3.txt",
200 "calib_barrel_right_offset2_bunch3.txt",
201 "calib_barrel_sigma.txt",
202 "calib_barrel_atten.txt",
203 "calib_barrel_q0.txt",
204 "calib_barrel_veff.txt",
205 "calib_barrel_common.txt"
207 for(
int m=0;m<N;m++){
208 inf[m].open(filelist[m],ios::in);
212 std::cerr<<
"file: "<<filelist[N]<<
" can't be found!"<<std::endl;
216 for(
int k=0;k<176;k++){
218 if(is_open[0]&&is_open[1]){
219 for(
int j=0;j<7;j++) {
225 if(is_open[2]&&is_open[3]&&is_open[4]&&is_open[5]){
226 for(
int j=0;j<7;j++) {
227 inf[2]>>bunch0_poff[j];
228 inf[3]>>bunch0_poff[j+10];
229 inf[4]>>bunch0_poff[j+20];
230 inf[5]>>bunch0_poff[j+30];
234 if(is_open[6]&&is_open[7]&&is_open[8]&&is_open[9]){
235 for(
int j=0;j<7;j++) {
236 inf[6]>>bunch1_poff[j];
237 inf[7]>>bunch1_poff[j+10];
238 inf[8]>>bunch1_poff[j+20];
239 inf[9]>>bunch1_poff[j+30];
244 if(is_open[10]&&is_open[11]&&is_open[12]&&is_open[13]){
245 for(
int j=0;j<7;j++) {
246 inf[10]>>bunch2_poff[j];
247 inf[11]>>bunch2_poff[j+10];
248 inf[12]>>bunch2_poff[j+20];
249 inf[13]>>bunch2_poff[j+30];
252 if(is_open[14]&&is_open[15]&&is_open[16]&&is_open[17]){
253 for(
int j=0;j<7;j++) {
254 inf[14]>>bunch3_poff[j];
255 inf[15]>>bunch3_poff[j+10];
256 inf[16]>>bunch3_poff[j+20];
257 inf[17]>>bunch3_poff[j+30];
262 for(
int j=0; j<15; j++) {
263 inf[18] >> fitfun[j];
268 for(
int j=0;j<2;j++){
271 Atten[0]=1./Atten[0];
275 for(
int j=2;j<5;j++){
281 for(
int j=0;j<2;j++){
284 Speed[0]=1./Speed[0];
292 TTree* t2 =
new TTree(
"BarTofParCommon",
"common part of barrel" );
293 double t0Offset[2]={0.},sigmaCorr[8]={0.};
294 for(
int i=0;i<2;i++){
295 sprintf(brname,
"t0offset%d",i);
296 sprintf(ptname,
"t0offset%d/D",i);
297 t2->Branch(brname,&t0Offset[i],ptname);
299 for(
int i=0;i<8;i++){
300 sprintf(brname,
"sigmaCorr%d",i);
301 sprintf(ptname,
"sigmaCorr%d/D",i);
302 t2->Branch(brname,&sigmaCorr[i],ptname);
306 inf[10] >> sigmaCorr[0] >> sigmaCorr[1] >> t0Offset[0] >> t0Offset[1];
313 for(
int m=0;m<N;m++) { inf[m].close(); }
315 TFile f(
"BarTofPar.root",
"RECREATE");
335 TTree*
t =
new TTree(
"EndTofPar",
"endcap parameters" );
339 for(
int i=0;i<8;i++){
340 sprintf( brname,
"P%d", i );
341 sprintf( ptname,
"p%d/D", i );
342 t->Branch( brname, &p[i], ptname );
344 double fcounter[5]={0.},Atten[5]={0.},Speed[4]={0.};
345 for(
int i=0;i<5;i++){
346 sprintf( brname,
"FCounter%d", i );
347 sprintf( ptname,
"fcounter%d/D", i );
348 t->Branch( brname, &fcounter[i], ptname );
349 sprintf( brname,
"Atten%d", i );
350 sprintf( ptname,
"Atten%d/D", i );
351 t->Branch( brname, &Atten[i], ptname );
353 for(
int i=0;i<4;i++){
354 sprintf( brname,
"Speed%d", i );
355 sprintf( ptname,
"Speed%d/D", i );
356 t->Branch( brname, &Speed[i], ptname );
361 bool is_open[N]={
false};
362 const char* filelist[N]={
363 "calib_endcap_left.txt",
364 "calib_endcap_sigma.txt",
365 "calib_endcap_atten.txt",
366 "calib_endcap_veff.txt"
368 for(
int m=0;m<N;m++){
369 inf[m].open(filelist[m],ios::in);
373 std::cerr<<
"File: "<<filelist[m]<<
" can't be opened"<<std::endl;
377 for(
int k=0;k<96;k++){
379 if(is_open[0]&&is_open[1]){
380 for(
int j=0;j<7;j++){
386 for(
int j=0;j<3;j++){
392 for(
int j=0;j<5;j++){
398 for(
int j=0;j<4;j++){
410 TFile f(
"EndTofPar.root",
"RECREATE");