21 if( !calib_barrel_item.empty() ) {
22 std::vector<TofCalib*>::iterator
iter = calib_barrel_item.begin();
23 for( ;
iter != calib_barrel_item.end();
iter++ ) {
24 if( (*
iter) )
delete (*iter);
26 calib_barrel_item.clear();
28 if( !calib_endcap_item.empty() ) {
29 std::vector<TofCalib*>::iterator
iter = calib_endcap_item.begin();
30 for( ;
iter != calib_endcap_item.end();
iter++ ) {
31 if( (*
iter) )
delete (*iter);
33 calib_endcap_item.clear();
35 if( !calibration_barrel_item.empty() ) {
36 std::vector<TofCalibFit*>::iterator
iter = calibration_barrel_item.begin();
37 for( ;
iter != calibration_barrel_item.end();
iter++ ) {
38 if( (*
iter) )
delete (*iter);
40 calibration_barrel_item.clear();
42 if( !calibration_barrel_item2.empty() ) {
43 std::vector<TofCalibFit*>::iterator
iter = calibration_barrel_item2.begin();
44 for( ;
iter != calibration_barrel_item2.end();
iter++ ) {
45 if( (*
iter) )
delete (*iter);
47 calibration_barrel_item2.clear();
49 if( !calibration_endcap_item.empty() ) {
50 std::vector<TofCalibFit*>::iterator
iter = calibration_endcap_item.begin();
51 for( ;
iter != calibration_endcap_item.end();
iter++ ) {
52 if( (*
iter) )
delete (*iter);
54 calibration_endcap_item.clear();
64 calib_barrel_item.push_back(cal_item1);
67 calib_endcap_item.push_back(cal_item1);
75 if( cal_item2->
name()==
"calib_barrel_sigma" ) {
76 calibration_barrel_item2.push_back(cal_item2);
79 calibration_barrel_item.push_back(cal_item2);
83 calibration_endcap_item.push_back(cal_item2);
91 if( !calib_barrel_item.empty() || !calibration_barrel_item.empty() ) {
92 std::cout <<
"Begin barrel counters calibration..." << std::endl;
93 std::cout << setiosflags(ios::left) << setw(10) <<
"TOF ID" << setw(8) <<
"Entries" << setw(30) <<
"What Calibration" << std::endl;
94 HepVector tcorrelation;
95 for(
unsigned int i=0; i<
NBarrel; i++ ) {
97 if( !calib_barrel_item.empty() ) {
98 std::vector<TofCalib*>::iterator iter1 = calib_barrel_item.begin();
99 for( ; iter1!=calib_barrel_item.end(); iter1++ ) {
101 (*iter1)->calculate( barrelData, i );
104 if( !calibration_barrel_item.empty() ) {
105 std::vector<TofCalibFit*>::iterator iter2 = calibration_barrel_item.begin();
106 for( ; iter2!=calibration_barrel_item.end(); iter2++ ) {
107 (*iter2)->calculate( barrelData, i );
109 if( (*iter2)->name()==
"calib_barrel_common" ) {
110 tcorrelation = (*iter2)->tcorrelation();
117 for(
unsigned int i=0; i<
NBarrel; i++ ) {
119 if( !calibration_barrel_item2.empty() ) {
120 std::vector<TofCalibFit*>::iterator iter2 = calibration_barrel_item2.begin();
121 for( ; iter2!=calibration_barrel_item2.end(); iter2++ ) {
123 if( (*iter2)->name()==
"calib_barrel_sigma" ) {
124 (*iter2)->setTCorrelation( tcorrelation );
127 (*iter2)->calculate( barrelData, i );
133 if( !calib_endcap_item.empty() || !calibration_endcap_item.empty() ) {
134 std::cout <<
"Begin endcap counters calibration..." << std::endl;
135 std::cout << setiosflags(ios::left) << setw(10)<<
"TOF ID" << setw(8) <<
"Entries" << setw(30) <<
"What Calibration" << std::endl;
136 for(
unsigned int i=0; i<
NEndcap; i++ ) {
138 if( !calib_endcap_item.empty() ) {
139 std::vector<TofCalib*>::iterator iter1 = calib_endcap_item.begin();
140 for( ; iter1!=calib_endcap_item.end(); iter1++ ) {
142 (*iter1)->calculate( endcapData, i );
145 if( !calibration_endcap_item.empty() ) {
146 std::vector<TofCalibFit*>::iterator iter2 = calibration_endcap_item.begin();
147 for( ; iter2!=calibration_endcap_item.end(); iter2++ ) {
148 (*iter2)->calculate( endcapData, i );
160 if( !calib_barrel_item.empty() ) {
161 std::vector<TofCalib*>::iterator
iter = calib_barrel_item.begin();
162 for( ;
iter != calib_barrel_item.end();
iter++ ) {
163 string fname = dir + string(
"/") + (*iter)->name() + string(
".txt");
164 (*iter)->fillTxt( fname.c_str() );
168 if( !calib_endcap_item.empty() ) {
169 std::vector<TofCalib*>::iterator
iter = calib_endcap_item.begin();
170 for( ;
iter != calib_endcap_item.end();
iter++ ) {
171 string fname = dir + string(
"/") + (*iter)->name() + string(
".txt");
172 (*iter)->fillTxt( fname.c_str() );
176 if( !calibration_barrel_item.empty() ) {
177 std::vector<TofCalibFit*>::iterator
iter = calibration_barrel_item.begin();
178 for( ;
iter != calibration_barrel_item.end();
iter++ ) {
179 string fname = dir + string(
"/") + (*iter)->name() + string(
".txt");
180 (*iter)->fillTxt( fname.c_str() );
183 if( !calibration_barrel_item2.empty() ) {
184 std::vector<TofCalibFit*>::iterator
iter = calibration_barrel_item2.begin();
185 for( ;
iter != calibration_barrel_item2.end();
iter++ ) {
186 string fname = dir + string(
"/") + (*iter)->name() + string(
".txt");
187 (*iter)->fillTxt( fname.c_str() );
191 if( !calibration_endcap_item.empty() ) {
192 std::vector<TofCalibFit*>::iterator
iter = calibration_endcap_item.begin();
193 for( ;
iter != calibration_endcap_item.end();
iter++ ) {
194 string fname = dir + string(
"/") + (*iter)->name() + string(
".txt");
195 (*iter)->fillTxt( fname.c_str() );
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" );
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");
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();
266 hitcase = (*iter)->hitcase();
270 std::cout << std::endl;
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" );
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");
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();
319 hitcase = (*iter)->hitcase();
323 std::cout << std::endl;
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() );
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() );
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() );
std::vector< Record * > RecordSet
const unsigned int NBarrel
const unsigned int NEndcap
const string & name() const
void addCalib(TofCalib *cal_item1, bool isbarrel)
static TofCalibManager * getManager()
void fillRoot(string &dir)
void fillTxt(string &dir)
RecordSet * getEndcapData(unsigned int i) const
RecordSet * getBarrelData(unsigned int i) const