203 {
205 char filename1[256];
206 sprintf( filename1, "%s/barrel%i.root", dir.c_str(), count );
207 TFile
f1(filename1,
"RECREATE");
208 TTree* ntbarrel = new TTree( "btrk", "barrel data after calibration" );
209
210 int run;
211 int event;
212 int tofid;
213 double qleft;
214 double qright;
215 double tleft;
216 double tright;
217 double zrhit;
218 double texp;
219 double path;
220 double phi;
221 double theta;
222 double p;
223 double t0;
224 double q0;
225 int hitcase;
226
227 ntbarrel->Branch( "run", &run, "run/I" );
228 ntbarrel->Branch( "event", &event, "event/I" );
229 ntbarrel->Branch( "tofid", &tofid, "tofid/I" );
230 ntbarrel->Branch( "qleft", &qleft, "qleft/D" );
231 ntbarrel->Branch( "qright", &qright, "qright/D" );
232 ntbarrel->Branch( "tleft", &tleft, "tleft/D" );
233 ntbarrel->Branch( "tright", &tright, "tright/D" );
234 ntbarrel->Branch( "zrhit", &zrhit, "zrhit/D" );
235 ntbarrel->Branch( "texp", &texp, "texp/D" );
236 ntbarrel->Branch( "path", &path, "path/D" );
237 ntbarrel->Branch( "phi", &phi, "phi/D" );
238 ntbarrel->Branch( "theta", &theta, "theta/D" );
239 ntbarrel->Branch( "p", &p, "p/D" );
240 ntbarrel->Branch( "t0", &t0, "t0/D" );
241 ntbarrel->Branch( "q0", &q0, "q0/D" );
242 ntbarrel->Branch( "hitcase",&hitcase,"hitcase/I");
243
244 int counter = 0;
245 std::cout << "begin to write..." << filename1 << std::endl;
246 for(
unsigned int i=0; i<
NBarrel; i++ ) {
247 std::cout <<
"\r\b Writing record ... " << (int((++counter)*100./
NBarrel)) <<
"%";
249 std::vector<Record*>::iterator
iter = barrelData->begin();
250 for( ;
iter!=barrelData->end();
iter++ ) {
251 run = (*iter)->run();
252 event = (*iter)->event();
253 tofid = (*iter)->tofid();
254 qleft = (*iter)->qleft();
255 qright = (*iter)->qright();
256 tleft = (*iter)->tleft();
257 tright = (*iter)->tright();
258 zrhit = (*iter)->zrhit();
259 texp = (*iter)->texp();
260 path = (*iter)->path();
261 phi = (*iter)->phi();
262 theta = (*iter)->theta();
263 p = (*iter)->p();
264 t0 = (*iter)->t0();
265 q0 = (*iter)->q0();
266 hitcase = (*iter)->hitcase();
267 ntbarrel->Fill();
268 }
269 }
270 std::cout << std::endl;
271 ntbarrel->Write();
272 delete ntbarrel;
274
275 char filename2[256];
276 sprintf( filename2, "%s/endcap%i.root", dir.c_str(), count );
277 TFile f2(filename2,"RECREATE");
278 TTree* ntendcap = new TTree( "etrk", "endcap data after calibration" );
279
280 ntendcap->Branch( "run", &run, "run/I" );
281 ntendcap->Branch( "event", &event, "event/I" );
282 ntendcap->Branch( "tofid", &tofid, "tofid/I" );
283 ntendcap->Branch( "qleft", &qleft, "qleft/D" );
284 ntendcap->Branch( "qright", &qright, "qright/D" );
285 ntendcap->Branch( "tleft", &tleft, "tleft/D" );
286 ntendcap->Branch( "tright", &tright, "tright/D" );
287 ntendcap->Branch( "zrhit", &zrhit, "zrhit/D" );
288 ntendcap->Branch( "texp", &texp, "texp/D" );
289 ntendcap->Branch( "path", &path, "path/D" );
290 ntendcap->Branch( "phi", &phi, "phi/D" );
291 ntendcap->Branch( "theta", &theta, "theta/D" );
292 ntendcap->Branch( "p", &p, "p/D" );
293 ntendcap->Branch( "t0", &t0, "t0/D" );
294 ntendcap->Branch( "q0", &q0, "q0/D" );
295 ntendcap->Branch( "hitcase",&hitcase,"hitcase/I");
296
297 counter = 0;
298 std::cout << "begin to write..." << filename2 << std::endl;
299 for(
unsigned int i=0; i<
NEndcap; i++ ) {
300 std::cout <<
"\r\b Writing record ... " << (int((++counter)*100./
NEndcap)) <<
"%";
302 std::vector<Record*>::iterator
iter = endcapData->begin();
303 for( ;
iter!=endcapData->end();
iter++ ) {
304 run = (*iter)->run();
305 event = (*iter)->event();
306 tofid = (*iter)->tofid();
307 qleft = (*iter)->qleft();
308 qright = (*iter)->qright();
309 tleft = (*iter)->tleft();
310 tright = (*iter)->tright();
311 zrhit = (*iter)->zrhit();
312 texp = (*iter)->texp();
313 path = (*iter)->path();
314 phi = (*iter)->phi();
315 theta = (*iter)->theta();
316 p = (*iter)->p();
317 t0 = (*iter)->t0();
318 q0 = (*iter)->q0();
319 hitcase = (*iter)->hitcase();
320 ntendcap->Fill();
321 }
322 }
323 std::cout << std::endl;
324 ntendcap->Write();
325 delete ntendcap;
326 f2.Close();
327
328
329 if( !calibration_barrel_item.empty() ) {
330 std::vector<TofCalibFit*>::iterator
iter = calibration_barrel_item.begin();
331 for( ;
iter != calibration_barrel_item.end();
iter++ ) {
332 string fname = dir + string("/") + (*iter)->name() + string(".root");
333 (*iter)->fillRoot( fname.c_str() );
334 }
335 }
336 if( !calibration_barrel_item2.empty() ) {
337 std::vector<TofCalibFit*>::iterator
iter = calibration_barrel_item2.begin();
338 for( ;
iter != calibration_barrel_item2.end();
iter++ ) {
339 string fname = dir + string("/") + (*iter)->name() + string(".root");
340 (*iter)->fillRoot( fname.c_str() );
341 }
342 }
343
344 if( !calibration_endcap_item.empty() ) {
345 std::vector<TofCalibFit*>::iterator
iter = calibration_endcap_item.begin();
346 for( ;
iter != calibration_endcap_item.end();
iter++ ) {
347 string fname = dir + string("/") + (*iter)->name() + string(".root");
348 (*iter)->fillRoot( fname.c_str() );
349 }
350 }
351
352 return;
353}