126 {
127
128 TTree* t1 = new TTree( "BarTofPar", "barrel parameters" );
129
130 double p[20] = { 1. };
131 char brname[20];
132 char ptname[20];
133 for ( int i = 0; i < 20; i++ )
134 {
137 t1->Branch( brname, &p[i], ptname );
138 }
139
140 double bunch0_poff[40] = { 1. }, bunch1_poff[40] = { 1. }, bunch2_poff[40] = { 1. },
141 bunch3_poff[40] = { 1. };
142 char broffname[40];
143 char ptoffname[40];
144 for ( int i = 0; i < 40; i++ )
145 {
146 sprintf( broffname,
"Bunch0_Poff%d", i );
147 sprintf( ptoffname,
"bunch0_poff%d/D", i );
148 t1->Branch( broffname, &bunch0_poff[i], ptoffname );
149 }
150 for ( int i = 0; i < 40; i++ )
151 {
152 sprintf( broffname,
"Bunch1_Poff%d", i );
153 sprintf( ptoffname,
"bunch1_poff%d/D", i );
154 t1->Branch( broffname, &bunch1_poff[i], ptoffname );
155 }
156 for ( int i = 0; i < 40; i++ )
157 {
158 sprintf( broffname,
"Bunch2_Poff%d", i );
159 sprintf( ptoffname,
"bunch2_poff%d/D", i );
160 t1->Branch( broffname, &bunch2_poff[i], ptoffname );
161 }
162 for ( int i = 0; i < 40; i++ )
163 {
164 sprintf( broffname,
"Bunch3_Poff%d", i );
165 sprintf( ptoffname,
"bunch3_poff%d/D", i );
166 t1->Branch( broffname, &bunch3_poff[i], ptoffname );
167 }
168
169 double fitfun[20] = { 0. };
170 ;
171 char fbrname1[5], fptname1[5], fbrname2[5], fptname2[5];
172 char fbrname3[10], fptname3[10];
173 for ( int i = 0; i < 5; i++ )
174 {
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 );
181 }
182 for ( int i = 0; i < 10; i++ )
183 {
184 sprintf( fbrname3,
"FCounter%d", i );
185 sprintf( fptname3,
"fcounter%d/D", i );
186 t1->Branch( fbrname3, &fitfun[10 + i], fptname3 );
187 }
188
189 double Atten[8] = { 1. };
190 for ( int i = 0; i < 8; i++ )
191 {
192 sprintf( brname,
"Atten%d", i );
193 sprintf( ptname,
"Atten%d/D", i );
194 t1->Branch( brname, &Atten[i], ptname );
195 }
196
197 double Speed[2] = { 1. };
198 t1->Branch( "Speed0", &Speed[0], "Speed0/D" );
199 t1->Branch( "Speed1", &Speed[1], "Speed1/D" );
200
201 const int N = 23;
202 ifstream inf[N];
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"
228 };
229 for ( int m = 0; m < N; m++ )
230 {
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;
234 }
235
236 try
237 {
238 for ( int k = 0; k < 176; k++ )
239 {
240
241 if ( is_open[0] && is_open[1] )
242 {
243 for ( int j = 0; j < 7; j++ )
244 {
245 inf[0] >> p[j];
246 inf[1] >> p[j + 10];
247 }
248 }
249
250 if ( is_open[2] && is_open[3] && is_open[4] && is_open[5] )
251 {
252 for ( int j = 0; j < 7; j++ )
253 {
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];
258 }
259 }
260
261 if ( is_open[6] && is_open[7] && is_open[8] && is_open[9] )
262 {
263 for ( int j = 0; j < 7; j++ )
264 {
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];
269 }
270 }
271
272
273 if ( is_open[10] && is_open[11] && is_open[12] && is_open[13] )
274 {
275 for ( int j = 0; j < 7; j++ )
276 {
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];
281 }
282 }
283 if ( is_open[14] && is_open[15] && is_open[16] && is_open[17] )
284 {
285 for ( int j = 0; j < 7; j++ )
286 {
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];
291 }
292 }
293
294 if ( is_open[18] )
295 {
296 for ( int j = 0; j < 15; j++ ) { inf[18] >> fitfun[j]; }
297 }
298
299 if ( is_open[19] )
300 {
301 for ( int j = 0; j < 2; j++ ) { inf[19] >> Atten[j]; }
302 Atten[0] = 1. / Atten[0];
303 }
304
305 if ( is_open[20] )
306 {
307 for ( int j = 2; j < 5; j++ ) { inf[20] >> Atten[j]; }
308 }
309
310 if ( is_open[21] )
311 {
312 for ( int j = 0; j < 2; j++ ) { inf[21] >> Speed[j]; }
313 Speed[0] = 1. / Speed[0];
314 }
315 t1->Fill();
316 }
317 } catch ( ... )
318 { return false; }
319
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++ )
323 {
324 sprintf( brname,
"t0offset%d", i );
325 sprintf( ptname,
"t0offset%d/D", i );
326 t2->Branch( brname, &t0Offset[i], ptname );
327 }
328 for ( int i = 0; i < 8; i++ )
329 {
330 sprintf( brname,
"sigmaCorr%d", i );
331 sprintf( ptname,
"sigmaCorr%d/D", i );
332 t2->Branch( brname, &sigmaCorr[i], ptname );
333 }
334 try
335 {
336 if ( is_open[22] )
337 { inf[22] >> sigmaCorr[0] >> sigmaCorr[1] >> t0Offset[0] >> t0Offset[1]; }
338 t2->Fill();
339 } catch ( ... )
340 { return false; }
341
342 for ( int m = 0; m < N; m++ ) { inf[m].close(); }
343
344 TFile
f(
"BarTofPar.root",
"RECREATE" );
345 t1->Write();
346 t2->Write();
348 delete t1;
349 delete t2;
350 t1 = NULL;
351 t2 = NULL;
352
353 return true;
354}
sprintf(cut, "kal_costheta0_em>-0.93&&kal_costheta0_em<0.93&&kal_pxy0_em>=0.05+%d*0.1&&kal_" "pxy0_em<0.15+%d*0.1&&NGch>=2", j, j)
TFile f("ana_bhabha660a_dqa_mcPat_zy_old.root")