CGEM BOSS 6.6.5.i
BESIII Offline Software System
Loading...
Searching...
No Matches
TofTrack.cxx
Go to the documentation of this file.
2#include "Identifier/TofID.h"
4// #include "TofQCorrSvc/ITofQCorrSvc.h"
5// #include "TofQElecSvc/ITofQElecSvc.h"
8#include "TofRec/TofTrack.h"
9
11// extern ITofQCorrSvc* tofQCorrSvc;
12// extern ITofQElecSvc* tofQElecSvc;
13
15 m_trackId = -1;
16 m_tofTrackId = -1;
17 m_id1 = -99;
18 m_id2 = -99;
19 m_hitCase = NoHit;
20 m_momentum = -99.0;
21 m_path = 0.0;
22 m_path1 = 0.0;
23 m_path2 = 0.0;
24 m_zrhit1 = 9999.0;
25 m_errzr1 = 9999.0;
26 m_zrhit2 = 9999.0;
27 m_errzr2 = 9999.0;
28 for( unsigned int i=0; i<5; i++ ) {
29 m_kal[i] = -1;
30 m_zr1[i] = 9999.0;
31 m_zr2[i] = 9999.0;
32 m_ezr1[i] = 9999.0;
33 m_ezr2[i] = 9999.0;
34 }
35 if( m_tofData1.size()>0 ) {
36 std::vector<TofData*>::iterator iter1 = m_tofData1.begin();
37 m_tofData1.clear();
38 }
39 if( m_tofData2.size()>0 ) {
40 std::vector<TofData*>::iterator iter2 = m_tofData2.begin();
41 m_tofData2.clear();
42 }
43 if( m_tofData3.size()>0 ) {
44 std::vector<TofData*>::iterator iter3 = m_tofData3.begin();
45 m_tofData3.clear();
46 }
47 if( m_tofData4.size()>0 ) {
48 std::vector<TofData*>::iterator iter4 = m_tofData4.begin();
49 m_tofData4.clear();
50 }
51 m_quality1 = 0;
52 m_quality2 = 0;
53 m_quality = 10;
54
55 m_tofId1 = -99;
56 m_tofId2 = -99;
57
58 m_ph11 = -999.0;
59 m_ph12 = -999.0;
60 m_ph21 = -999.0;
61 m_ph22 = -999.0;
62 m_ph1 = -999.0;
63 m_ph2 = -999.0;
64 m_ph = -999.0;
65
66 for( unsigned int i=0; i<5; i++ ) {
67 m_tof11[i] = 0.0;
68 m_tof12[i] = 0.0;
69 m_tof21[i] = 0.0;
70 m_tof22[i] = 0.0;
71 m_tof1[i] = 0.0;
72 m_tof2[i] = 0.0;
73 m_tof[i] = 0.0;
74 }
75
76 m_sigma11 = -999.0;
77 m_sigma12 = -999.0;
78 m_sigma21 = -999.0;
79 m_sigma22 = -999.0;
80 m_sigma1 = -999.0;
81 m_sigma2 = -999.0;
82 m_sigma = -999.0;
83
84 m_qch1 = -999.0;
85 m_qch2 = -999.0;
86 m_qch3 = -999.0;
87 m_qch4 = -999.0;
88 m_adc1 = -999.0;
89 m_adc2 = -999.0;
90 m_adc3 = -999.0;
91 m_adc4 = -999.0;
92 m_tdc1 = -999.0;
93 m_tdc2 = -999.0;
94 m_tdc3 = -999.0;
95 m_tdc4 = -999.0;
96
97 for( unsigned int i=0; i<5; i++ ) {
98 m_texpInner[i] = -999.0;
99 m_texpOuter[i] = -999.0;
100 m_texp[i] = -999.0;
101 }
102
103 m_ztdc1 = -999.0;
104 m_ztdc2 = -999.0;
105 m_zadc1 = -999.0;
106 m_zadc2 = -999.0;
107
108 m_estime = -999.0;
109 m_tdiff1 = -999.0;
110 m_tdiff2 = -999.0;
111
112 m_flag = 0;
113
114 return;
115}
116
117
119 if( m_tofData1.size()>0 ) {
120 std::vector<TofData*>::iterator iter1 = m_tofData1.begin();
121 m_tofData1.clear();
122 }
123 if( m_tofData2.size()>0 ) {
124 std::vector<TofData*>::iterator iter2 = m_tofData2.begin();
125 m_tofData2.clear();
126 }
127 if( m_tofData3.size()>0 ) {
128 std::vector<TofData*>::iterator iter3 = m_tofData3.begin();
129 m_tofData3.clear();
130 }
131 if( m_tofData4.size()>0 ) {
132 std::vector<TofData*>::iterator iter4 = m_tofData4.begin();
133 m_tofData4.clear();
134 }
135 return;
136}
137
138//------- setExtTrack ----------------------------------------------
139// get information from RecExtTrackCol
140// tofId1(), tofId2(), hitCase(),
141// p(), path1(), path2(), zrhit1(), zrhit2(), errz1(), errz2()
142// quality() = 3 ( no hit )
143//
144void TofTrack::setExtTrack( RecExtTrack* extTrack, int kal[5], double t0, int t0Stat ) {
145
146 m_estime = t0;
147 m_t0Stat = t0Stat;
148
149 int tofId1 = extTrack->tof1VolumeNumber();
150 int tofId2 = extTrack->tof2VolumeNumber();
151
152 m_barrel = 3;
153 if( tofId1>=0 && tofId1<=87 ) {
154 m_id1 = tofId1;
155 m_barrel = 1;
156 m_hitCase = InnerLayer;
157 }
158 else if( tofId1>=176 && tofId1<=223 ) {
159 m_id1 = tofId1 - 176 + 48;
160 m_barrel = 2;
161 m_hitCase = WestEndcap;
162 }
163 else if( tofId1>=224 && tofId1<=271 ) {
164 m_id1 = tofId1 - 176 - 48;
165 m_barrel = 0;
166 m_hitCase = EastEndcap;
167 }
168 else {
169 m_barrel = 3;
170 m_hitCase = NoHit;
171 }
172
173 if( tofId2>=88 && tofId2<=175 ) {
174 m_id2 = tofId2;
175 m_barrel = 1;
176 if( m_hitCase == InnerLayer ) {
177 m_hitCase = DoubleLayer;
178 }
179 else if( m_hitCase==NoHit ) {
180 m_hitCase = OuterLayer;
181 }
182 }
183
184 m_trackId = extTrack->trackId();
185
186 m_momentum = extTrack->tof1Momentum().r();
187 if( m_hitCase == InnerLayer || m_hitCase == DoubleLayer ) {
188 for( unsigned int i=0; i<5; i++ ) {
189 m_texpInner[i] = extTrack->tof1(i);
190 }
191 m_path1 = extTrack->tof1Path();
192 m_zrhit1 = extTrack->tof1Position().z();
193 m_errzr1 = extTrack->tof1PosSigmaAlongZ();
194 m_theta1 = extTrack->tof1Momentum().rho()/extTrack->tof1Momentum().r();
195 m_phi1 = extTrack->tof1Position().phi();
196 for( unsigned int i=0; i<5; i++ ) {
197 m_zr1[i] = extTrack->tof1Position(i).z();
198 m_ezr1[i] = extTrack->tof1PosSigmaAlongZ(i);
199 }
200 }
201 else if( m_hitCase == EastEndcap || m_hitCase == WestEndcap ) {
202 for( unsigned int i=0; i<5; i++ ) {
203 m_texpInner[i] = extTrack->tof1(i);
204 }
205 m_path1 = extTrack->tof1Path();
206 m_zrhit1 = extTrack->tof1Position().rho();
207 m_errzr1 = sqrt( extTrack->tof1PosSigmaAlongX()*extTrack->tof1PosSigmaAlongX() + extTrack->tof1PosSigmaAlongY()*extTrack->tof1PosSigmaAlongY() );
208 m_theta1 = extTrack->tof1Momentum().z()/extTrack->tof1Momentum().r();
209 m_phi1 = extTrack->tof1Position().phi();
210 for( unsigned int i=0; i<5; i++ ) {
211 m_zr1[i] = extTrack->tof1Position(i).rho();
212 m_ezr1[i] = sqrt( extTrack->tof1PosSigmaAlongX(i)*extTrack->tof1PosSigmaAlongX(i) + extTrack->tof1PosSigmaAlongY(i)*extTrack->tof1PosSigmaAlongY(i) );
213 }
214 }
215
216 if( m_hitCase == OuterLayer || m_hitCase == DoubleLayer ) {
217 for( unsigned int i=0; i<5; i++ ) {
218 m_texpOuter[i] = extTrack->tof2(i);
219 }
220 m_path2 = extTrack->tof2Path();
221 m_zrhit2 = extTrack->tof2Position().z();
222 m_errzr2 = extTrack->tof2PosSigmaAlongZ();
223 m_theta2 = extTrack->tof2Momentum().rho()/extTrack->tof2Momentum().r();
224 m_phi2 = extTrack->tof2Position().phi();
225 for( unsigned int i=0; i<5; i++ ) {
226 m_zr2[i] = extTrack->tof2Position(i).z();
227 m_ezr2[i] = extTrack->tof2PosSigmaAlongZ(i);
228 }
229 }
230
231 if( m_hitCase == NoHit ) { m_quality = 11; }
232
233 for( unsigned int i=0; i<5; i++ ) {
234 m_kal[i] = kal[i];
235 }
236
237 return;
238}
239
240
241//------- get Multi hit ----------------------------------------------
242// get Multi-hit of one TOF Counter
243//
245 if( m_hitCase == InnerLayer || m_hitCase == OuterLayer || m_hitCase == DoubleLayer ) {
246
247 if( ( m_hitCase==InnerLayer || m_hitCase==DoubleLayer ) && ( track->hitCase()==InnerLayer || track->hitCase()==DoubleLayer ) ) {
248 if( ( abs(m_id1-track->id1())<=1 ) || ( m_id1==0 && track->id1()==87 ) || ( m_id1==87 && track->id1()==0 ) ) {
249 track->setQuality1( ( track->quality1() | 0x400 ) );
250 m_quality1 = ( m_quality1 | 0x400 );
251 }
252 }
253
254 if( ( m_hitCase==OuterLayer || m_hitCase==DoubleLayer ) && ( track->hitCase()==OuterLayer || track->hitCase()==DoubleLayer ) ) {
255 if( ( abs(m_id2-track->id2())<=1 ) || ( m_id2==88 && track->id2()==175 ) || ( m_id2==175 && track->id2()==88 ) ) {
256 track->setQuality2( ( track->quality2() | 0x400 ) );
257 m_quality2 = ( m_quality2 | 0x400 );
258 }
259 }
260
261 }
262 else if( m_hitCase == EastEndcap ) {
263 if( track->hitCase()==EastEndcap ) {
264 if( ( abs(m_id1-track->id1())<=1 ) || ( m_id1==0 && track->id1()==47 ) || ( m_id1==47 && track->id1()==0 ) ) {
265 track->setQuality1( ( track->quality1() | 0x400 ) );
266 m_quality1 = ( m_quality1 | 0x400 );
267 }
268 }
269 }
270 else if( m_hitCase == WestEndcap ) {
271 if( track->hitCase()==WestEndcap ) {
272 if( ( abs(m_id1-track->id1())<=1 ) || ( m_id1==48 && track->id1()==95 ) || ( m_id1==95 && track->id1()==48 ) ) {
273 track->setQuality1( ( track->quality1() | 0x400 ) );
274 m_quality1 = ( m_quality1 | 0x400 );
275 }
276 }
277 }
278
279 return;
280}
281
282
283//------- setTofData --------------------------------------------
284// do TOF hits and extrapolated track match
285// tofTrackId(), tofMod1(), tofMod2()
286// quality() = 3 ( no hit )
287//
289
290 if( m_hitCase == NoHit ) return;
291
292 unsigned int identify0 = 0x0000c000;
293 unsigned int identify1 = 0x0000c000;
294 unsigned int identify2 = 0x0000c000;
295 unsigned int count0 = 0;
296 unsigned int count1 = 0;
297 unsigned int count2 = 0;
298
299 if( ( ( m_hitCase == InnerLayer ) || ( m_hitCase == DoubleLayer ) ) && ( m_id1 > -1 ) ) {
300 int tofid0 = m_id1;
301 identify0 = TofID::getIntID( 1, 0, tofid0, 0 );
302 count0 = tofDataMap.count( identify0 );
303 int tofid1 = tofid0 - 1;
304 if( tofid1 == -1 ) { tofid1 = 87; }
305 identify1 = TofID::getIntID( 1, 0, tofid1, 0 );
306 count1 = tofDataMap.count( identify1 );
307 int tofid2 = tofid0 + 1;
308 if( tofid2 == 88 ) { tofid2 = 0; }
309 identify2 = TofID::getIntID( 1, 0, tofid2, 0 );
310 count2 = tofDataMap.count( identify2 );
311 }
312
313 if( ( m_hitCase == EastEndcap ) && ( m_id1 > -1 ) ) {
314 int tofid0 = m_id1;
315 identify0 = TofID::getIntID( 0, 0, tofid0, 0 );
316 count0 = tofDataMap.count( identify0 );
317 int tofid1 = tofid0 - 1;
318 if( tofid1 == -1 ) { tofid1 = 47; }
319 identify1 = TofID::getIntID( 0, 0, tofid1, 0 );
320 count1 = tofDataMap.count( identify1 );
321 int tofid2 = tofid0 + 1;
322 if( tofid2 == 48 ) { tofid2 = 0; }
323 identify2 = TofID::getIntID( 0, 0, tofid2, 0 );
324 count2 = tofDataMap.count( identify2 );
325 }
326
327 if( ( m_hitCase == WestEndcap ) && ( m_id1 > -1 ) ) {
328 int tofid0 = m_id1 - 48;
329 identify0 = TofID::getIntID( 2, 0, tofid0, 0 );
330 count0 = tofDataMap.count( identify0 );
331 int tofid1 = tofid0 - 1;
332 if( tofid1 == -1 ) { tofid1 = 47; }
333 identify1 = TofID::getIntID( 2, 0, tofid1, 0 );
334 count1 = tofDataMap.count( identify1 );
335 int tofid2 = tofid0 + 1;
336 if( tofid2 == 48 ) { tofid2 = 0; }
337 identify2 = TofID::getIntID( 2, 0, tofid2, 0 );
338 count2 = tofDataMap.count( identify2 );
339 }
340
341 if( count0 > 0 ) {
342 pair< IterTofDataMap, IterTofDataMap > range = tofDataMap.equal_range( identify0 );
343 IterTofDataMap iter = range.first;
344 for( unsigned int i = 0; i < count0; i++, iter++ ) {
345 tofDataAnalysis( (*iter).second, 1 );
346 }
347 }
348 if( count1 > 0 ) {
349 pair< IterTofDataMap, IterTofDataMap > range = tofDataMap.equal_range( identify1 );
350 IterTofDataMap iter = range.first;
351 for( unsigned int i = 0; i < count1; i++, iter++ ) {
352 tofDataAnalysis( (*iter).second, 2 );
353 }
354 }
355 if( count2 > 0 ) {
356 pair< IterTofDataMap, IterTofDataMap > range = tofDataMap.equal_range( identify2 );
357 IterTofDataMap iter = range.first;
358 for( unsigned int i = 0; i < count2; i++, iter++ ) {
359 tofDataAnalysis( (*iter).second, 2 );
360 }
361 }
362
363 if( ( count0 == 0 ) && ( count1 == 0 ) && ( count2 == 0 ) ) {
364 if( m_hitCase != DoubleLayer ) {
365 m_hitCase = NoHit;
366 m_quality = 12;
367 }
368 else {
369 m_hitCase = OuterLayer;
370 }
371 }
372
373 if( ( ( m_hitCase == OuterLayer ) || ( m_hitCase == DoubleLayer ) ) && ( m_id2 > 87 ) ) {
374 int tofid0 = m_id2 - 88;
375 identify0 = TofID::getIntID( 1, 1, tofid0, 0 );
376 count0 = tofDataMap.count( identify0 );
377 int tofid1 = tofid0 - 1;
378 if( tofid1 == -1 ) { tofid1 = 87; }
379 identify1 = TofID::getIntID( 1, 1, tofid1, 0 );
380 count1 = tofDataMap.count( identify1 );
381 int tofid2 = tofid0 + 1;
382 if( tofid2 == 88 ) { tofid2 = 0; }
383 identify2 = TofID::getIntID( 1, 1, tofid2, 0 );
384 count2 = tofDataMap.count( identify2 );
385
386 if( count0 > 0 ) {
387 pair< IterTofDataMap, IterTofDataMap > range = tofDataMap.equal_range( identify0 );
388 IterTofDataMap iter = range.first;
389 for( unsigned int i = 0; i < count0; i++, iter++ ) {
390 tofDataAnalysis( (*iter).second, 3 );
391 }
392 }
393 if( count1 > 0 ) {
394 pair< IterTofDataMap, IterTofDataMap > range = tofDataMap.equal_range( identify1 );
395 IterTofDataMap iter = range.first;
396 for( unsigned int i = 0; i < count1; i++, iter++ ) {
397 tofDataAnalysis( (*iter).second, 4 );
398 }
399 }
400 if( count2 > 0 ) {
401 pair< IterTofDataMap, IterTofDataMap > range = tofDataMap.equal_range( identify2 );
402 IterTofDataMap iter = range.first;
403 for( unsigned int i = 0; i < count2; i++, iter++ ) {
404 tofDataAnalysis( (*iter).second, 4 );
405 }
406 }
407
408 if( ( count0 == 0 ) && ( count1 == 0 ) && ( count2 == 0 ) ) {
409 if( m_hitCase != DoubleLayer ) {
410 m_hitCase = NoHit;
411 m_quality = 12;
412 }
413 else {
414 m_hitCase = InnerLayer;
415 }
416 }
417 }
418
419 return;
420}
421
422
423//------- tofDataAnalysis ----------------------------------------
424// analysis tof data
425//
426void TofTrack::tofDataAnalysis( TofData* tof, unsigned int iflag ) {
427
428 unsigned int qual = tof->quality();
429
430 if( ( qual & 0x10 ) == 0 ) {
431
432 // qual = ( qual | 0x310 ); // zadc, ztdc unmatched, and track matched
433 qual = ( qual | 0x10 ); // zadc, ztdc unmatched, and track matched
434
435 if( tof->barrel() ) { // Barrel, Endcap has been done
436 if( ( tof->quality() == 0x7 ) || ( tof->quality() == 0xd ) ) {
437 qual = ( qual | 0x20 ); // lost one Q
438 }
439
440 if( ( tof->quality() == 0xb ) || ( tof->quality() == 0xe ) ) {
441 qual = ( qual | 0x40 ); // lost one T
442 }
443
444 if( ( tof->quality() == 0x3 ) || ( tof->quality() == 0xc ) ) {
445 qual = ( qual | 0x80 ); // single end
446 }
447
448 if( ( tof->quality() & 0x5 ) == 0x5 ) {
449 double ztdc = tofCaliSvc->ZTDC( tof->tdc1(), tof->tdc2(), tof->tofId() );
450 tof->setZTdc( ztdc );
451 /*
452 if( ( ( (iflag==1) || (iflag==2) ) && ( abs(ztdc-m_zrhit1)<ztdc_Cut ) ) || ( ( (iflag==3) || (iflag==4) ) && ( abs(ztdc-m_zrhit2)<ztdc_Cut ) ) ) {
453 qual = ( qual & 0xeffffeff ); // Z_tdc un-matched.
454 }
455 else {
456 qual = ( qual | 0x100 );
457 }
458 */
459 }
460
461 if( ( tof->quality() & 0xa ) == 0xa ) {
462 double zadc = tofCaliSvc->ZADC( tof->adc1(), tof->adc2(), tof->tofId() );
463 tof->setZAdc( zadc );
464 /*
465 if( ( ( (iflag==1) || (iflag==2) ) && ( abs(zadc-m_zrhit1)<zadc_Cut ) ) || ( ( (iflag==3) || (iflag==4) ) && ( abs(zadc-m_zrhit2)<zadc_Cut ) ) ) {
466 qual = ( qual & 0xeffffbff ); // Z_adc un-matched.
467 }
468 else {
469 qual = ( qual | 0x200 );
470 }
471 */
472 }
473 }
474
475 tof->setQuality( qual );
476 }
477
478 if( iflag == 1 ) m_tofData1.push_back( tof );
479 else if( iflag == 2 ) m_tofData2.push_back( tof );
480 else if( iflag == 3 ) m_tofData3.push_back( tof );
481 else if( iflag == 4 ) m_tofData4.push_back( tof );
482 else {
483 cout << "TofRec::TofTrack::TofDataAnalylsis: the Flag should be 1-4, out of the Range!" << endl;
484 }
485
486 return;
487}
488
489
490//------- match --------------------------------------------------
491// Tof Data - Extrapolated Track Match
492//
493void TofTrack::match( bool forCalibration, std::vector<int> deadId, std::vector<TofTrack*>*& tofTrackVec ) {
494
495 if( m_hitCase == NoHit ) return;
496
497 if( m_hitCase == InnerLayer ) {
498 findTofDataBarrel( m_tofData1, m_tofData2, m_zrhit1, 1, tofTrackVec );
499 if( ( m_quality1 & 0x10 ) == 0 ) { m_hitCase = NoHit; }
500 }
501 else if( m_hitCase == OuterLayer ) {
502 findTofDataBarrel( m_tofData3, m_tofData4, m_zrhit2, 2, tofTrackVec );
503 if( ( m_quality2 & 0x10 ) == 0 ) { m_hitCase = NoHit; }
504 }
505 else if( m_hitCase == DoubleLayer ) {
506 findTofDataBarrel( m_tofData1, m_tofData2, m_zrhit1, 1, tofTrackVec );
507 if( ( m_quality1 & 0x10 ) == 0 ) { m_hitCase = OuterLayer; }
508 findTofDataBarrel( m_tofData3, m_tofData4, m_zrhit2, 2, tofTrackVec );
509 if( ( m_quality2 & 0x10 ) == 0 ) {
510 if( m_hitCase == DoubleLayer ) {
511 m_hitCase = InnerLayer;
512 }
513 else if( m_hitCase == OuterLayer ) {
514 m_hitCase = NoHit;
515 }
516 else {
517 cout << "TofRec::TofTrack::match: 2- Impossible!" << endl;
518 }
519 }
520 }
521 else if( ( m_hitCase == EastEndcap ) || ( m_hitCase == WestEndcap ) ) {
522 findTofDataEndcap( m_tofData1, m_tofData2, m_zr1 );
523 }
524 else {
525 cout << "TofRec::TofTrack::match: 1- Impossible!" << endl;
526 }
527
528 if( forCalibration ) {
529 // set Data Sample for Calibration, double layer, only one hit for counter, T and Q.
530 if( m_hitCase == DoubleLayer ) {
531 if( ( ( m_quality1 & 0xf ) == 0xf ) && ( ( m_quality2 & 0xf ) == 0xf ) ) {
532 m_quality1 = ( m_quality1 | 0x800 ); // Calibration Sample
533 m_quality2 = ( m_quality2 | 0x800 ); // Calibration Sample
534 }
535 else {
536 std::vector<int>::iterator iter = deadId.begin();
537 for( ; iter != deadId.end(); iter++ ) {
538 Identifier iden = Identifier(*iter);
539 int barrel = TofID::barrel_ec(iden);
540 int layer = TofID::layer(iden);
541 int tofId = TofID::phi_module(iden);
542 int east = TofID::end(iden);
543 if( barrel == 1 ) {
544 if( layer==0 ) {
545 if( m_tofId1 == tofId ) {
546 if( ( m_quality2 & 0xf ) == 0xf ) {
547 if( ( ( east == 0 ) && ( ( m_quality1 & 0xf ) == 0x3 ) ) || ( ( east == 1 ) && ( ( m_quality1 & 0xf ) == 0xc ) ) ) {
548 m_quality1 = ( m_quality1 | 0x800 );
549 m_quality2 = ( m_quality2 | 0x800 );
550
551 }
552 }
553 }
554 }
555 else if( layer == 1 ) {
556 if( m_tofId2 == (tofId+88) ) {
557 if( ( m_quality1 & 0xf ) == 0xf ) {
558 if( ( ( east == 0 ) && ( ( m_quality2 & 0xf ) == 0x3 ) ) || ( ( east == 1 ) && ( ( m_quality2 & 0xf ) == 0xc ) ) ) {
559 m_quality1 = ( m_quality1 | 0x800 );
560 m_quality2 = ( m_quality2 | 0x800 );
561 }
562 }
563 }
564 }
565 }
566 }
567 }
568 }
569 // set Data Sample for Calibration, only one hit for counter, T and Q.
570 else if( m_hitCase == InnerLayer ) {
571 if( ( m_quality1 & 0xf ) == 0xf ) {
572 m_quality1 = ( m_quality1 | 0x800 ); // Calibration Sample
573 }
574 else {
575 std::vector<int>::iterator iter = deadId.begin();
576 for( ; iter != deadId.end(); iter++ ) {
577 Identifier iden = Identifier(*iter);
578 int barrel = TofID::barrel_ec(iden);
579 int layer = TofID::layer(iden);
580 int tofId = TofID::phi_module(iden);
581 int east = TofID::end(iden);
582 if( barrel == 1 ) {
583 if( layer==0 ) {
584 if( m_tofId1 == tofId ) {
585 if( ( ( east == 0 ) && ( ( m_quality1 & 0xf ) == 0x3 ) ) || ( ( east == 1 ) && ( ( m_quality1 & 0xf ) == 0xc ) ) ) {
586 m_quality1 = ( m_quality1 | 0x800 );
587 }
588 }
589 }
590 }
591 }
592 }
593 }
594
595 // set Data Sample for Calibration, only one hit for counter, T and Q.
596 if( ( ( m_hitCase == EastEndcap ) || ( m_hitCase == WestEndcap ) ) && ( ( m_quality1 & 0xf ) == 0xc ) ) {
597 m_quality1 = ( m_quality1 | 0x800 ); // Calibration Sample
598 }
599 }
600
601 return;
602}
603
604
605//------- findTofDataBarrel ----------------------------------------
606// find the right TOF information in TOF data vector
607// of the exact TOF ID and of the neighbor
608//
609void TofTrack::findTofDataBarrel( std::vector<TofData*> tofDataVec1, std::vector<TofData*> tofDataVec2, double zrhit, unsigned int iflag, std::vector<TofTrack*>*& tofTrackVec ) {
610
611 unsigned int qual = 0xf;
612 TofData* tof = 0;
613 if( tofDataVec2.size() == 0 ) {
614 if( tofDataVec1.size() == 0 ) {
615 qual = 0;
616 }
617 else if( tofDataVec1.size() == 1 ) {
618 std::vector<TofData*>::iterator iter1 = tofDataVec1.begin();
619 tof = (*iter1);
620 qual = 0x1;
621 }
622 else if( tofDataVec1.size() > 1 ) {
623 tof= chooseTofData( tofDataVec1, zrhit );
624 qual = 0x2;
625 }
626 else {
627 cout << "TofRec::TofTrack::findTofDataBarrel: 1- Impossible!" << endl;
628 }
629 }
630 else if( ( tofDataVec2.size() == 1 ) ) {
631 if( tofDataVec1.size() == 0 ) {
632 std::vector<TofData*>::iterator iter2 = tofDataVec2.begin();
633 tof = (*iter2);
634 qual = 0x4;
635 }
636 else if( tofDataVec1.size() == 1 ) {
637 std::vector<TofData*>::iterator iter1 = tofDataVec1.begin();
638 if( ((*iter1)->quality()&0x1ff)==0x01f && abs((*iter1)->ztdc()-zrhit)<ztdc_Cut ) {
639 tof = (*iter1);
640 }
641 else {
642 std::vector<TofData*>::iterator iter2 = tofDataVec2.begin();
643 tof = compareTofData( (*iter1), (*iter2), zrhit );
644 }
645 qual = 0x5;
646 }
647 else if( tofDataVec1.size() > 1 ) {
648 TofData* tofData1 = chooseTofData( tofDataVec1, zrhit );
649 if( (tofData1->quality()&0x1ff)==0x01f && abs(tofData1->ztdc()-zrhit)<ztdc_Cut ) {
650 tof = tofData1;
651 }
652 else {
653 std::vector<TofData*>::iterator iter2 = tofDataVec2.begin();
654 tof = compareTofData( tofData1, (*iter2), zrhit );
655 }
656 qual = 0x6;
657 }
658 else {
659 cout << "TofRec::TofTrack::findTofDataBarrel: 2- Impossible!" << endl;
660 }
661 }
662 else if( ( tofDataVec2.size() > 1 ) ) {
663 if( tofDataVec1.size() == 0 ) {
664 tof = chooseTofData( tofDataVec2, zrhit );
665 qual = 0x8;
666 }
667 else if( tofDataVec1.size() == 1 ) {
668 std::vector<TofData*>::iterator iter1 = tofDataVec1.begin();
669 if( ((*iter1)->quality()&0x1ff)==0x01f && abs((*iter1)->ztdc()-zrhit)<ztdc_Cut ) {
670 tof = (*iter1);
671 }
672 else {
673 TofData* tofData2 = chooseTofData( tofDataVec2, zrhit );
674 tof = compareTofData( (*iter1), tofData2, zrhit );
675 }
676 qual = 0x9;
677 }
678 else if( tofDataVec1.size() > 1 ) {
679 TofData* tofData1 = chooseTofData( tofDataVec1, zrhit );
680 if( (tofData1->quality()&0x1ff)==0x01f && abs(tofData1->ztdc()-zrhit)<ztdc_Cut ) {
681 tof = tofData1;
682 }
683 else {
684 TofData* tofData2 = chooseTofData( tofDataVec2, zrhit );
685 tof = compareTofData( tofData1, tofData2, zrhit );
686 }
687 qual = 0xa;
688 }
689 else {
690 cout << "TofRec::TofTrack::findTofDataBarrel: 3- Impossible!" << endl;
691 }
692 }
693
694 if( qual != 0 ) {
695 if( !(tof->used()) ) {
696 getTofData( tof, iflag );
697 }
698 else {
699 bool z1=false, z2=false;
700 bool zc1=false, zc2=false;
701 TofTrack* track=0;
702 if( iflag==1 ) {
703 z1 = ( abs( m_zrhit1 - tof->ztdc() ) < ztdc_Cut );
704 zc1 = ( m_zrhit1 > tof->ztdc() );
705 std::vector<TofTrack*>::iterator iter = tofTrackVec->begin();
706 for( ; iter!=tofTrackVec->end(); iter++ ) {
707 if( tof->tofId()==(*iter)->tofId1() ) {
708 track = (*iter);
709 z2 = ( abs( (*iter)->zrhit1() - tof->ztdc() ) < ztdc_Cut );
710 zc2 = ( (*iter)->zrhit1() > tof->ztdc() );
711 }
712 }
713 }
714 else if( iflag==2 ) {
715 z1 = ( abs( m_zrhit2 - tof->ztdc() ) < ztdc_Cut );
716 zc1 = ( m_zrhit2 > tof->ztdc() );
717 std::vector<TofTrack*>::iterator iter = tofTrackVec->begin();
718 for( ; iter!=tofTrackVec->end(); iter++ ) {
719 if( tof->tofId()==(*iter)->tofId2() ) {
720 track = (*iter);
721 z2 = ( abs( (*iter)->zrhit2() - tof->ztdc() ) < ztdc_Cut );
722 zc2 = ( (*iter)->zrhit2() > tof->ztdc() );
723 }
724 }
725 }
726
727 if( ( z1 && z2 )||( (!z1) && (!z2) ) ) {
728 if( zc1 && !zc2 ) {
729 getTofDataEast( tof, iflag );
730 track->getTofDataWest( tof, iflag );
731 }
732 else if( !zc1 && zc2 ) {
733 getTofDataWest( tof, iflag );
734 track->getTofDataEast( tof, iflag );
735 }
736 }
737 else if( z1 && !z2 ) {
738 getTofData( tof, iflag );
739 track->getTofDataNohit( iflag );
740 cout << iflag << " " << track->quality1() << " " << track->quality2() << endl;
741 }
742 else if( !z1 && z2 ) {
743 qual = 0;
744 }
745 }
746 }
747
748 if( qual == 0 ) {
749 if( ( iflag == 1 ) || ( iflag == 3 ) ) {
750 m_quality1 = ( m_quality1 | 0x300 );
751 }
752 else if( iflag == 2 ) {
753 m_quality2 = ( m_quality2 | 0x300 );
754 }
755 else {
756 cout << "TofRec::TofTrack::findTofDataBarrel: the 1- IFLAG is Out of Range!" << endl;
757 }
758 }
759 else {
760 qual = ( qual << 12 );
761 if( ( iflag == 1 ) || ( iflag == 3 ) ) {
762 m_quality1 = ( m_quality1 | qual );
763 }
764 else if( iflag == 2 ) {
765 m_quality2 = ( m_quality2 | qual );
766 }
767 else {
768 cout << "TofRec::TofTrack::findTofDataBarrel: the 2- IFLAG is Out of Range!" << endl;
769 }
770 }
771
772 return;
773}
774
775
776//------- chooseTofData -------------------------------------------
777// choose the most possible TofData from TofDataVector
778// ZTDC, ZADC, SingleEnd/NoQ/NoT are jugded.
779//
780TofData* TofTrack::chooseTofData( std::vector<TofData*> tofDataVec, double zrhit ) {
781 if( tofDataVec.size() == 0 ) {
782 cout << "TofRec::TofTrack::ChooseTofData: Size of TofData Vector is Zero!" << endl;
783 return 0;
784 }
785 std::vector<TofData*>::iterator igood = tofDataVec.begin();
786 if( tofDataVec.size() > 1 ) {
787 double deltaZ = 1000.0;
788 std::vector<TofData*>::iterator iter = tofDataVec.begin();
789 // ZTDC compare
790 for( ; iter != tofDataVec.end(); iter++ ) {
791 if( ( (*iter)->quality() & 0x5 ) == 0x5 ) {
792 if( abs( (*iter)->ztdc() - zrhit ) < deltaZ ) {
793 deltaZ = abs( (*iter)->ztdc() - zrhit );
794 igood = iter;
795 }
796 }
797 }
798 // ZADC compare
799 if( deltaZ > 999.0 ) {
800 iter = tofDataVec.begin();
801 for( ; iter != tofDataVec.end(); iter++ ) {
802 if( ( (*iter)->quality() & 0xa ) == 0xa ) {
803 if( abs( (*iter)->zadc() - zrhit ) < deltaZ ) {
804 deltaZ = abs( (*iter)->zadc() - zrhit );
805 igood = iter;
806 }
807 }
808 }
809 }
810 // Max Q
811 if( deltaZ > 999.0 ) {
812 unsigned int ibad = 0xf0;
813 iter = tofDataVec.begin();
814 for( ; iter != tofDataVec.end(); iter++ ) {
815 if( ( (*iter)->quality() & 0xf0 ) < ibad ) {
816 igood = iter;
817 ibad = ( (*iter)->quality() & 0xf0 );
818 }
819 else if( ( (*iter)->quality() & 0xf0 ) == ibad ) {
820 if( ( (*iter)->adc1() + (*iter)->adc2() ) > ( (*igood)->adc1() + (*igood)->adc2() ) ) {
821 igood = iter;
822 ibad = ( (*iter)->quality() & 0xf0 );
823 }
824 }
825 }
826 }
827 }
828
829 return (*igood);
830}
831
832
833//------- compareTofData -------------------------------------------
834// choose the most possible TofData from TofDataVector
835// ZTDC, ZADC, SingleEnd/NoQ/NoT are jugded.
836//
837TofData* TofTrack::compareTofData( TofData* tofData1, TofData* tofData2, double zrhit ) {
839 // ZTDC compare
840 if( abs(tofData1->ztdc() - zrhit ) > abs(tofData2->ztdc() - zrhit ) ) {
841 // SingleEnd/NoT/NoQ compare
842 if( ( tofData1->quality() & 0xf0 ) >= ( tofData1->quality() & 0xf0 ) ) {
843 // QDC compare
844 // if( ( tofData1->adc1() + tofData1->adc2() ) < ( tofData2->adc1() + tofData2->adc2() ) ) {
845 tof = tofData2;
846 // }
847 }
848 // }
849 }
850
851 return tof;
852}
853
854
855//------- findTofDataEndcap --------------------------------------
856// find the right TOF information in TOF data vector
857// of the exact TOF ID and of the neighbor
858//
859void TofTrack::findTofDataEndcap( std::vector<TofData*> tofDataVec1, std::vector<TofData*> tofDataVec2, double zr1[5] ) {
860
861 unsigned int iflag = 3;
862 unsigned int qual = 0xf;
863
864 if( tofDataVec2.size() == 0 ) {
865 if( tofDataVec1.size() == 0 ) {
866 qual = 0;
867 }
868 else if( tofDataVec1.size() == 1 ) {
869 std::vector<TofData*>::iterator iter1 = tofDataVec1.begin();
870 getTofData( (*iter1), iflag );
871 qual = 0x1;
872 }
873 else if( tofDataVec1.size() > 1 ) {
874 getTofData( chooseTofDataEndcap( tofDataVec1, zr1 ), iflag );
875 qual = 0x2;
876 }
877 else {
878 cout << "TofRec::TofTrack::findTofDataEndcap: 1- Impossible!" << endl;
879 }
880 }
881 else if( ( tofDataVec2.size() == 1 ) ) {
882 if( tofDataVec1.size() == 0 ) {
883 std::vector<TofData*>::iterator iter2 = tofDataVec2.begin();
884 getTofData( (*iter2), iflag );
885 qual = 0x4;
886 }
887 else if( tofDataVec1.size() == 1 ) {
888 std::vector<TofData*>::iterator iter1 = tofDataVec1.begin();
889 std::vector<TofData*>::iterator iter2 = tofDataVec2.begin();
890 getTofData( compareTofDataEndcap( (*iter1), (*iter2) ), iflag );
891 qual = 0x5;
892 }
893 else if( tofDataVec1.size() > 1 ) {
894 TofData* tofData1 = chooseTofDataEndcap( tofDataVec1, zr1 );
895 std::vector<TofData*>::iterator iter2 = tofDataVec2.begin();
896 getTofData( compareTofDataEndcap( tofData1, (*iter2) ), iflag );
897 qual = 0x6;
898 }
899 else {
900 cout << "TofRec::TofTrack::findTofDataBarrel: 2- Impossible!" << endl;
901 }
902 }
903 else if( ( tofDataVec2.size() > 1 ) ) {
904 if( tofDataVec1.size() == 0 ) {
905 getTofData( chooseTofDataEndcap( tofDataVec2, zr1 ), iflag );
906 qual = 0x8;
907 }
908 else if( tofDataVec1.size() == 1 ) {
909 std::vector<TofData*>::iterator iter1 = tofDataVec1.begin();
910 TofData* tofData2 = chooseTofDataEndcap( tofDataVec2, zr1 );
911 getTofData( compareTofDataEndcap( (*iter1), tofData2 ), iflag );
912 qual = 0x9;
913 }
914 else if( tofDataVec1.size() > 1 ) {
915 TofData* tofData1 = chooseTofDataEndcap( tofDataVec1, zr1 );
916 TofData* tofData2 = chooseTofDataEndcap( tofDataVec2, zr1 );
918 qual = 0xa;
919 }
920 else {
921 cout << "TofRec::TofTrack::findTofDataBarrel: 3- Impossible!" << endl;
922 }
923 }
924
925 if( qual == 0 ) {
926 m_quality1 = ( m_quality1 | 0x300 );
927 }
928 else {
929 qual = ( qual << 12 );
930 m_quality1 = ( m_quality1 | qual );
931 }
932
933 return;
934}
935
936
937//------- chooseTofDataEndcap --------------------------------
938// choose the most possible TofData from TofDataVector
939//
940TofData* TofTrack::chooseTofDataEndcap( std::vector<TofData*> tofDataVec, double zr1[5] ) {
941 if( tofDataVec.size() == 0 ) {
942 cout << "TofRec::TofTrack::ChooseTofData: Size of TofData Vector is Zero!" << endl;
943 return 0;
944 }
945 std::vector<TofData*>::iterator igood = tofDataVec.begin();
946 if( tofDataVec.size() > 1 ) {
947 bool multihit = false;
948 std::vector<TofData*>::iterator iter = tofDataVec.begin();
949 for( ; iter != tofDataVec.end(); iter++ ) {
950 if( (*iter)->qtimes1()>1 ) { multihit = true; }
951 }
952 iter = tofDataVec.begin();
953 if( multihit ) {
954 double tcorr = -999.0;
955 double deltaTMin = 999.0;
956 for( ; iter != tofDataVec.end(); iter++ ) {
957 tcorr = tofCaliSvc->ETime( (*iter)->adc(), (*iter)->tdc()-m_estime, zr1[2], (*iter)->tofId() );
958 for( unsigned int i=0; i<5; i++ ) {
959 if( abs(tcorr-m_texpInner[i]) < deltaTMin ) {
960 deltaTMin = abs(tcorr-m_texpInner[i]);
961 igood = iter;
962 }
963 }
964 }
965 }
966 else {
967 double maxQ = 0.0;
968 for( ; iter != tofDataVec.end(); iter++ ) {
969 if( (*iter)->adc() > maxQ ) {
970 maxQ = (*iter)->adc();
971 igood = iter;
972 }
973 }
974 }
975 }
976 return (*igood);
977}
978
979
980//------- compareTofDataEndcap -------------------------------
981// choose the most possible TofData from TofDataVector
982//
985 if( tof->adc() < tofData2->adc() ) {
986 tof = tofData2;
987 }
988 return tof;
989}
990
991
992//------- getTofData -----------------------------------------
993// set Tof Data of Inner / Outer Layer Barrel TOF and Endcap TOF
994//
995void TofTrack::getTofData( TofData* tof, unsigned int iflag ) {
996
997 if( iflag == 1 ) {
998 m_tofId1 = tof->tofId();
999 m_qch1 = tof->adcChannelEast();
1000 m_adc1 = tof->adc1();
1001 m_tdc1 = tof->tdc1();
1002 m_qch2 = tof->adcChannelWest();
1003 m_adc2 = tof->adc2();
1004 m_tdc2 = tof->tdc2();
1005 m_ztdc1 = tof->ztdc();
1006 m_zadc1 = tof->zadc();
1007 m_quality1 = ( m_quality1 | ( 0x1f & tof->quality() ) );
1008 if( ( ( tof->quality() & 0x5 ) != 0x5 ) || ( ( ( tof->quality() & 0x5 ) == 0x5 ) && ( abs( tof->ztdc() - m_zrhit1 ) > ztdc_Cut ) ) ) {
1009 m_quality1 = ( m_quality1 | 0x100 );
1010 }
1011 if( ( ( tof->quality() & 0xa ) != 0xa ) || ( ( ( tof->quality() & 0xa ) == 0xa ) && ( abs( tof->zadc() - m_zrhit1 ) > zadc_Cut ) ) ) {
1012 m_quality1 = ( m_quality1 | 0x200 );
1013 }
1014 }
1015 else if( iflag == 2 ) {
1016 m_tofId2 = tof->tofId();
1017 m_qch3 = tof->adcChannelEast();
1018 m_adc3 = tof->adc1();
1019 m_tdc3 = tof->tdc1();
1020 m_qch4 = tof->adcChannelWest();
1021 m_adc4 = tof->adc2();
1022 m_tdc4 = tof->tdc2();
1023 m_ztdc2 = tof->ztdc();
1024 m_zadc2 = tof->zadc();
1025 m_quality2 = ( m_quality2 | ( 0x1f & tof->quality() ) );
1026 if( ( ( tof->quality() & 0x5 ) != 0x5 ) || ( ( ( tof->quality() & 0x5 ) == 0x5 ) && ( abs( tof->ztdc() - m_zrhit2 ) > ztdc_Cut ) ) ) {
1027 m_quality2 = ( m_quality2 | 0x100 );
1028 }
1029 if( ( ( tof->quality() & 0xa ) != 0xa ) || ( ( ( tof->quality() & 0xa ) == 0xa ) && ( abs( tof->zadc() - m_zrhit2 ) > zadc_Cut ) ) ) {
1030 m_quality2 = ( m_quality2 | 0x200 );
1031 }
1032 }
1033 else if( iflag == 3 ) {
1034 m_tofId1 = tof->tofId();
1035 m_qch1 = tof->adcChannel();
1036 m_adc1 = tof->adc();
1037 m_tdc1 = tof->tdc();
1038 m_quality1 = ( m_quality1 | ( 0x1f & tof->quality() ) );
1039 m_quality1 = ( m_quality1 | 0x300 );
1040 }
1041 else {
1042 cout << "TofRec::TofTrack::getTofData: Flag which sign the Barrel/Endcap or Inner/Outer is wrong! Please check it!" << endl;
1043 }
1044 tof->setUsed();
1045 return;
1046}
1047
1048
1049//------- getTofDataEast ------------------------------------
1050// set Tof Data of Inner / Outer Layer Barrel TOF and Endcap TOF
1051//
1052void TofTrack::getTofDataEast( TofData* tof, unsigned int iflag ) {
1053
1054 if( iflag == 1 ) {
1055 m_tofId1 = tof->tofId();
1056 m_qch1 = tof->adcChannelEast();
1057 m_adc1 = tof->adc1();
1058 m_tdc1 = tof->tdc1();
1059 m_qch2 = -999.0;
1060 m_adc2 = -999.0;
1061 m_tdc2 = -999.0;
1062 m_ztdc1 = tof->ztdc();
1063 m_zadc1 = tof->zadc();
1064 m_quality1 = ( ( m_quality1 & 0xfffffff0 ) | ( 0x1c & tof->quality() ) );
1065 if( ( ( tof->quality() & 0x5 ) != 0x5 ) || ( ( ( tof->quality() & 0x5 ) == 0x5 ) && ( abs( tof->ztdc() - m_zrhit1 ) > ztdc_Cut ) ) ) {
1066 m_quality1 = ( m_quality1 | 0x100 );
1067 }
1068 if( ( ( tof->quality() & 0xa ) != 0xa ) || ( ( ( tof->quality() & 0xa ) == 0xa ) && ( abs( tof->zadc() - m_zrhit1 ) > zadc_Cut ) ) ) {
1069 m_quality1 = ( m_quality1 | 0x200 );
1070 }
1071 }
1072 else if( iflag == 2 ) {
1073 m_tofId2 = tof->tofId();
1074 m_qch3 = tof->adcChannelEast();
1075 m_adc3 = tof->adc1();
1076 m_tdc3 = tof->tdc1();
1077 m_qch4 = -999.0;
1078 m_adc4 = -999.0;
1079 m_tdc4 = -999.0;
1080 m_ztdc2 = tof->ztdc();
1081 m_zadc2 = tof->zadc();
1082 m_quality2 = ( ( m_quality2 & 0xfffffff0 ) | ( 0x1c & tof->quality() ) );
1083 if( ( ( tof->quality() & 0x5 ) != 0x5 ) || ( ( ( tof->quality() & 0x5 ) == 0x5 ) && ( abs( tof->ztdc() - m_zrhit2 ) > ztdc_Cut ) ) ) {
1084 m_quality2 = ( m_quality2 | 0x100 );
1085 }
1086 if( ( ( tof->quality() & 0xa ) != 0xa ) || ( ( ( tof->quality() & 0xa ) == 0xa ) && ( abs( tof->zadc() - m_zrhit2 ) > zadc_Cut ) ) ) {
1087 m_quality2 = ( m_quality2 | 0x200 );
1088 }
1089 }
1090 else {
1091 cout << "TofRec::TofTrack::getTofDataEast: Flag which sign the Barrel/Endcap or Inner/Outer is wrong! Please check it!" << endl;
1092 }
1093 tof->setUsed();
1094 return;
1095}
1096
1097
1098//------- getTofDataWest ------------------------------------
1099// set Tof Data of Inner / Outer Layer Barrel TOF and Endcap TOF
1100//
1101void TofTrack::getTofDataWest( TofData* tof, unsigned int iflag ) {
1102
1103 if( iflag == 1 ) {
1104 m_tofId1 = tof->tofId();
1105 m_qch1 = -999.0;
1106 m_adc1 = -999.0;
1107 m_tdc1 = -999.0;
1108 m_qch2 = tof->adcChannelWest();
1109 m_adc2 = tof->adc2();
1110 m_tdc2 = tof->tdc2();
1111 m_ztdc1 = tof->ztdc();
1112 m_zadc1 = tof->zadc();
1113 m_quality1 = ( ( m_quality1 & 0xfffffff0 ) | ( 0x13 & tof->quality() ) );
1114 if( ( ( tof->quality() & 0x5 ) != 0x5 ) || ( ( ( tof->quality() & 0x5 ) == 0x5 ) && ( abs( tof->ztdc() - m_zrhit1 ) > ztdc_Cut ) ) ) {
1115 m_quality1 = ( m_quality1 | 0x100 );
1116 }
1117 if( ( ( tof->quality() & 0xa ) != 0xa ) || ( ( ( tof->quality() & 0xa ) == 0xa ) && ( abs( tof->zadc() - m_zrhit1 ) > zadc_Cut ) ) ) {
1118 m_quality1 = ( m_quality1 | 0x200 );
1119 }
1120 }
1121 else if( iflag == 2 ) {
1122 m_tofId2 = tof->tofId();
1123 m_qch3 = -999.0;
1124 m_adc3 = -999.0;
1125 m_tdc3 = -999.0;
1126 m_qch4 = tof->adcChannelWest();
1127 m_adc4 = tof->adc2();
1128 m_tdc4 = tof->tdc2();
1129 m_ztdc2 = tof->ztdc();
1130 m_zadc2 = tof->zadc();
1131 m_quality2 = ( ( m_quality2 & 0xfffffff0 ) | ( 0x13 & tof->quality() ) );
1132 if( ( ( tof->quality() & 0x5 ) != 0x5 ) || ( ( ( tof->quality() & 0x5 ) == 0x5 ) && ( abs( tof->ztdc() - m_zrhit2 ) > ztdc_Cut ) ) ) {
1133 m_quality2 = ( m_quality2 | 0x100 );
1134 }
1135 if( ( ( tof->quality() & 0xa ) != 0xa ) || ( ( ( tof->quality() & 0xa ) == 0xa ) && ( abs( tof->zadc() - m_zrhit2 ) > zadc_Cut ) ) ) {
1136 m_quality2 = ( m_quality2 | 0x200 );
1137 }
1138 }
1139 else {
1140 cout << "TofRec::TofTrack::getTofDataWest: Flag which sign the Barrel/Endcap or Inner/Outer is wrong! Please check it!" << endl;
1141 }
1142 tof->setUsed();
1143 return;
1144}
1145
1146
1147//------- getTofData -----------------------------------------
1148// set Tof Data of Inner / Outer Layer Barrel TOF and Endcap TOF
1149//
1150void TofTrack::getTofDataNohit( unsigned int iflag ) {
1151
1152 if( iflag == 1 ) {
1153 m_tofId1 = -99;
1154 m_qch1 = -999.0;
1155 m_adc1 = -999.0;
1156 m_tdc1 = -999.0;
1157 m_qch2 = -999.0;
1158 m_adc2 = -999.0;
1159 m_tdc2 = -999.0;
1160 m_ztdc1 = -999.0;
1161 m_zadc1 = -999.0;
1162 m_quality1 = ( m_quality1 & 0x700 );
1163 if( m_hitCase == InnerLayer ) { m_hitCase = NoHit; }
1164 else if( m_hitCase == DoubleLayer ) { m_hitCase = OuterLayer; }
1165 }
1166 else if( iflag == 2 ) {
1167 m_tofId2 = -99;
1168 m_qch3 = -999.0;
1169 m_adc3 = -999.0;
1170 m_tdc3 = -999.0;
1171 m_qch4 = -999.0;
1172 m_adc4 = -999.0;
1173 m_tdc4 = -999.0;
1174 m_ztdc2 = -999.0;
1175 m_zadc2 = -999.0;
1176 m_quality2 = ( m_quality2 & 0x700 );
1177 if( m_hitCase == OuterLayer ) { m_hitCase = NoHit; }
1178 else if( m_hitCase == DoubleLayer ) { m_hitCase = InnerLayer; }
1179 }
1180 else {
1181 cout << "TofRec::TofTrack::getTofData: Flag which sign the Barrel/Endcap or Inner/Outer is wrong! Please check it!" << endl;
1182 }
1183
1184 return;
1185}
1186
1187
1188//------- setCalibration() ----------------------------------------
1189// get calibration constants
1190// ph11() - ph22(), tof11() -- tof22()
1191// ph1() ph2() ph(), tof1() tof2() tof()
1192//
1194
1195 bool barrel = ( ( m_hitCase == InnerLayer ) || ( m_hitCase == OuterLayer ) || ( m_hitCase == DoubleLayer ) );
1196 bool endcap = ( ( m_hitCase == EastEndcap ) || ( m_hitCase == WestEndcap ) );
1197
1198 bool innerEast = ( ( m_quality1 & 0xc ) == 0xc );
1199 bool innerWest = ( ( m_quality1 & 0x3 ) == 0x3 );
1200 bool outerEast = ( ( m_quality2 & 0xc ) == 0xc );
1201 bool outerWest = ( ( m_quality2 & 0x3 ) == 0x3 );
1202 bool innerLayer = ( ( m_quality1 & 0xf ) == 0xf );
1203 bool outerLayer = ( ( m_quality2 & 0xf ) == 0xf );
1204
1205 bool endcapData = ( ( m_quality1 & 0xc ) == 0xc );
1206
1207 if( m_hitCase == DoubleLayer ) {
1208 for( unsigned int i=0; i<5; i++ ) {
1209 m_texp[i] = tofCaliSvc->BTimeCluster( m_texpInner[i], m_texpOuter[i], m_zr1[i], m_zr2[i], m_tofId1, m_tofId2 );
1210 }
1211 m_path = tofCaliSvc->BTimeCluster( m_path1, m_path2, m_zrhit1, m_zrhit2, m_tofId1, m_tofId2 );
1212 }
1213
1214 if( barrel ) {
1215 if( innerEast ) {
1216 for( unsigned int i=0; i<5; i++ ) {
1217 m_tof11[i] = tofCaliSvc->BTime1( m_adc1, m_tdc1-m_estime, m_zr1[i], m_tofId1, m_estime );
1218 }
1219 m_sigma11 = tofCaliSvc->BSigma1( m_zrhit1, m_tofId1 );
1220 m_ph11 = m_adc1;
1221 }
1222
1223 if( innerWest ) {
1224 for( unsigned int i=0; i<5; i++ ) {
1225 m_tof12[i] = tofCaliSvc->BTime2( m_adc2, m_tdc2-m_estime, m_zr1[i], m_tofId1, m_estime );
1226 }
1227 m_sigma12 = tofCaliSvc->BSigma2( m_zrhit1, m_tofId1 );
1228 m_ph12 = m_adc2;
1229 }
1230
1231 if( innerLayer ) {
1232 for( unsigned int i=0; i<5; i++ ) {
1233 m_tof1[i] = tofCaliSvc->BTimeCounter( m_tof11[i], m_tof12[i], m_zr1[i], m_tofId1 );
1234 }
1235 m_sigma1 = tofCaliSvc->BSigmaCounter( m_zrhit1, m_tofId1 );
1236 m_ph1 = tofCaliSvc->BPulseHeight( m_adc1, m_adc2, m_zrhit1, m_theta1, m_tofId1 );
1237 /*
1238 if( m_hitCase == InnerLayer ) {
1239 for( unsigned int i=0; i<5; i++ ) {
1240 m_tof[i] = m_tof1[i];
1241 }
1242 m_sigma = m_sigma1;
1243 }
1244 */
1245 }
1246
1247 if( outerEast ) {
1248 for( unsigned int i=0; i<5; i++ ) {
1249 m_tof21[i] = tofCaliSvc->BTime1( m_adc3, m_tdc3-m_estime, m_zr2[i], m_tofId2, m_estime );
1250 }
1251 m_sigma21 = tofCaliSvc->BSigma1( m_zrhit2, m_tofId2 );
1252 m_ph21 = m_adc3;
1253 }
1254
1255 if( outerWest ) {
1256 for( unsigned int i=0; i<5; i++ ) {
1257 m_tof22[i] = tofCaliSvc->BTime2( m_adc4, m_tdc4-m_estime, m_zr2[i], m_tofId2, m_estime );
1258 }
1259 m_sigma22 = tofCaliSvc->BSigma2( m_zrhit2, m_tofId2 );
1260 m_ph22 = m_adc4;
1261 }
1262
1263 if( outerLayer ) {
1264 for( unsigned int i=0; i<5; i++ ) {
1265 m_tof2[i] = tofCaliSvc->BTimeCounter( m_tof21[i], m_tof22[i], m_zr2[i], m_tofId2 );
1266 }
1267 m_sigma2 = tofCaliSvc->BSigmaCounter( m_zrhit2, m_tofId2 );
1268 m_ph2 = tofCaliSvc->BPulseHeight( m_adc3, m_adc4, m_zrhit2, m_theta2, m_tofId2 );
1269 /*
1270 if( m_hitCase == OuterLayer ) {
1271 for( unsigned int i=0; i<5; i++ ) {
1272 m_tof[i] = m_tof2[i];
1273 }
1274 m_sigma = m_sigma2;
1275 }
1276 */
1277 }
1278
1279 if( innerLayer && outerLayer ) {
1280 for( unsigned int i=0; i<5; i++ ) {
1281 m_tof[i] = tofCaliSvc->BTimeCluster( m_tof1[i], m_tof2[i], m_zr1[i], m_zr2[i], m_tofId1, m_tofId2 );
1282 }
1283 m_sigma = tofCaliSvc->BSigmaCluster( m_zrhit1, m_zrhit2, m_tofId1, m_tofId2 );
1284 m_ph = tofCaliSvc->BTimeCluster( m_ph1, m_ph2, m_zrhit1, m_zrhit2, m_tofId1, m_tofId2 );
1285 }
1286 }
1287
1288 if( endcap ) {
1289 if( endcapData ) {
1290 for( unsigned int i=0; i<5; i++ ) {
1291 m_tof11[i] = tofCaliSvc->ETime( m_adc1, m_tdc1-m_estime, m_zr1[i], m_tofId1 );
1292 }
1293 m_sigma11 = tofCaliSvc->ESigma( m_zrhit1, m_tofId1 );
1294 m_ph11 = tofCaliSvc->EPulseHeight( m_adc1, m_zrhit1, m_theta1, m_tofId1 );
1295 m_quality = 1;
1296 if( (m_quality1&0xa000)!=0 ) { m_quality = 4; }
1297 }
1298 }
1299
1300 // set Quality of Barrel TOF
1301 if( barrel ) {
1302
1303 // double layer
1304 if( innerLayer && outerLayer ) {
1305 m_quality = 1;
1306 }
1307 else {
1308 // single layer
1309 if( innerLayer || outerLayer ) {
1310 m_quality = 2;
1311 }
1312 else {
1313 // single-end of one layer
1314 if( innerEast || innerWest || outerEast || outerWest ) {
1315 m_quality = 3;
1316 }
1317 }
1318 }
1319
1320 // multi-hit
1321 if( ( (m_quality1&0xa000)!=0 ) || ( (m_quality2&0xa000)!=0 ) ) {
1322 m_quality = m_quality + 3;
1323 }
1324
1325 // ztdc and extrapolated zhit is not matched
1326 if( ( (m_quality1&0x100)==0x100 ) || ( (m_quality2&0x100)==0x100 ) ) {
1327 if( ( m_quality == 1 ) || ( m_quality == 4 ) ) { m_quality = 7; }
1328 else if( ( m_quality == 2 ) || ( m_quality == 5 ) ) { m_quality = 8; }
1329 else if( ( m_quality == 3 ) || ( m_quality == 6 ) ) { m_quality = 9; }
1330 else {
1331 cout << "TofRec::TofTrack::setCalibration: Impossible!" << endl;
1332 }
1333 }
1334
1335 }
1336
1337 return;
1338}
1339
1340
1341//------- convert2RecTofTrackCol() -----------------------------------
1342// generate RecTofTrackCol
1343//
1345
1346 bool barrel = ( ( m_hitCase == InnerLayer ) || ( m_hitCase == OuterLayer ) || ( m_hitCase == DoubleLayer ) );
1347
1348 bool innerEast = ( ( m_quality1 & 0xc ) == 0xc );
1349 bool innerWest = ( ( m_quality1 & 0x3 ) == 0x3 );
1350 bool outerEast = ( ( m_quality2 & 0xc ) == 0xc );
1351 bool outerWest = ( ( m_quality2 & 0x3 ) == 0x3 );
1352
1353 if( barrel ) {
1354
1355 if( innerEast ) {
1356 RecTofTrack* atrack11 = new RecTofTrack;
1357 buildRecTofTrack( atrack11, 11 ); // innerlayer east readout
1358 TofHitStatus* hitStatus11 = new TofHitStatus;
1359 if( innerWest ) {
1360 hitStatus11->setBarrelReadout( 1, true ); // innerlayer east readout
1361 }
1362 else {
1363 if( m_hitCase == InnerLayer ) {
1364 hitStatus11->setBarrelCluster( 11 ); // innerlayer east cluster
1365 }
1366 else if( m_hitCase == DoubleLayer ) {
1367 if( outerEast && outerWest ) {
1368 hitStatus11->setBarrelCounter( 11 ); // innerlayer east counter
1369 }
1370 else {
1371 hitStatus11->setBarrelCluster( 11 ); // innerlayer east cluster
1372 }
1373 }
1374 else {
1375 cout << "TofRec::TofTrack:convert2RecTofTrackCol: 11- Impossible!" << endl;
1376 }
1377 }
1378 atrack11->setStatus( hitStatus11->value() );
1379 delete hitStatus11;
1380 recTofTrackCol->push_back( atrack11 );
1381 }
1382
1383 if( innerWest ) {
1384 RecTofTrack* atrack12 = new RecTofTrack;
1385 buildRecTofTrack( atrack12, 12 ); // innerlayer west readout
1386 TofHitStatus* hitStatus12 = new TofHitStatus;
1387 if( innerEast ) {
1388 hitStatus12->setBarrelReadout( 1, false ); // innerlayer west
1389 }
1390 else {
1391 if( m_hitCase == InnerLayer ) {
1392 hitStatus12->setBarrelCluster( 12 ); // innerlayer west cluster
1393 }
1394 else if( m_hitCase == DoubleLayer ) {
1395 if( outerEast && outerWest ) {
1396 hitStatus12->setBarrelCounter( 12 ); // innerlayer west counter
1397 }
1398 else {
1399 hitStatus12->setBarrelCluster( 12 ); // innerlayer west cluster
1400 }
1401 }
1402 else {
1403 cout << "TofRec::TofTrack:convert2RecTofTrackCol: 12- Impossible!" << endl;
1404 }
1405 }
1406 atrack12->setStatus( hitStatus12->value() );
1407 delete hitStatus12;
1408 recTofTrackCol->push_back( atrack12 );
1409 }
1410
1411 if( innerEast && innerWest ) {
1412 RecTofTrack* atrack1 = new RecTofTrack;
1413 buildRecTofTrack( atrack1, 1 ); // innerlayer counter
1414 TofHitStatus* hitStatus1 = new TofHitStatus;
1415 if( m_hitCase == InnerLayer ) {
1416 hitStatus1->setBarrelCluster( 1 ); // innerlayer cluster and counter
1417 }
1418 else if( m_hitCase == DoubleLayer ) {
1419 if( outerEast && outerWest ) {
1420 hitStatus1->setBarrelCounter( 1 ); // innerlayer counter
1421 }
1422 else {
1423 hitStatus1->setBarrelCluster( 1 ); // innerlayer cluster and counter
1424 }
1425 }
1426 else {
1427 cout << "TofRec::TofTrack:convert2RecTofTrackCol: 1- Impossible!" << endl;
1428 }
1429 atrack1->setStatus( hitStatus1->value() );
1430 delete hitStatus1;
1431 recTofTrackCol->push_back( atrack1 );
1432 }
1433
1434 if( outerEast ) {
1435 RecTofTrack* atrack21 = new RecTofTrack;
1436 buildRecTofTrack( atrack21, 21 ); // outerlayer east readout
1437 TofHitStatus* hitStatus21 = new TofHitStatus;
1438 if( outerWest ) {
1439 hitStatus21->setBarrelReadout( 2, true ); // outerlayer east readout
1440 }
1441 else {
1442 if( m_hitCase == OuterLayer ) {
1443 hitStatus21->setBarrelCluster( 21 ); // outerlayer east cluster
1444 }
1445 else if( m_hitCase == DoubleLayer ) {
1446 if( innerEast || innerWest ) {
1447 hitStatus21->setBarrelCounter( 21 ); // outerlayer east counter
1448 }
1449 // else {
1450 // hitStatus21->setBarrelCluster( 21 ); // outerlayer east cluster
1451 // }
1452 }
1453 else {
1454 cout << "TofRec::TofTrack:convert2RecTofTrackCol: 21- Impossible!" << endl;
1455 }
1456 }
1457 atrack21->setStatus( hitStatus21->value() );
1458 delete hitStatus21;
1459 recTofTrackCol->push_back( atrack21 );
1460 }
1461
1462 if( outerWest ) {
1463 RecTofTrack* atrack22 = new RecTofTrack;
1464 buildRecTofTrack( atrack22, 22 ); // outerlayer west readout
1465 TofHitStatus* hitStatus22 = new TofHitStatus;
1466 if( outerEast ) {
1467 hitStatus22->setBarrelReadout( 2, false ); // outerlayer west readout
1468 }
1469 else {
1470 if( m_hitCase == OuterLayer ) {
1471 hitStatus22->setBarrelCluster( 22 ); // outerlayer west cluster
1472 }
1473 else if( m_hitCase == DoubleLayer ) {
1474 if( innerEast || innerWest ) {
1475 hitStatus22->setBarrelCounter( 22 ); // outerlayer west counter
1476 }
1477 // else {
1478 // hitStatus22->setBarrelCluster( 22 ); // outerlayer west cluster
1479 // }
1480 }
1481 else {
1482 cout << "TofRec::TofTrack:convert2RecTofTrackCol: 22- Impossible!" << endl;
1483 }
1484 }
1485 atrack22->setStatus( hitStatus22->value() );
1486 delete hitStatus22;
1487 recTofTrackCol->push_back( atrack22 );
1488 }
1489
1490 if( outerEast && outerWest ) {
1491 RecTofTrack* atrack2 = new RecTofTrack;
1492 buildRecTofTrack( atrack2, 2 ); // outerlayer counter
1493 TofHitStatus* hitStatus2 = new TofHitStatus;
1494 if( m_hitCase == OuterLayer ) {
1495 hitStatus2->setBarrelCluster( 2 ); // outerlayer cluster and counter
1496 }
1497 else if( m_hitCase == DoubleLayer ) {
1498 if( innerEast && innerWest ) {
1499 hitStatus2->setBarrelCounter( 2 ); // outerlayer counter
1500 }
1501 else {
1502 hitStatus2->setBarrelCluster( 2 ); // outerlayer cluster and counter
1503 }
1504 }
1505 else {
1506 cout << "TofRec::TofTrack:convert2RecTofTrackCol: 2- Impossible!" << endl;
1507 }
1508 atrack2->setStatus( hitStatus2->value() );
1509 delete hitStatus2;
1510 recTofTrackCol->push_back( atrack2 );
1511 }
1512
1513 if( innerEast && innerWest && outerEast && outerWest ) {
1514 RecTofTrack* atrack = new RecTofTrack;
1515 buildRecTofTrack( atrack, 0 ); // doublelayer cluster
1516 TofHitStatus* hitStatus = new TofHitStatus;
1517 hitStatus->setBarrelCluster( 3 ); // doublelayer cluster
1518 atrack->setStatus( hitStatus->value() );
1519 delete hitStatus;
1520 recTofTrackCol->push_back( atrack );
1521 }
1522
1523 }
1524
1525 if( ( m_hitCase == EastEndcap ) || ( m_hitCase == WestEndcap ) ) {
1526 RecTofTrack* atrack = new RecTofTrack;
1527 buildRecTofTrack( atrack, 11 ); // eastendcap counter
1528 TofHitStatus* hitStatus = new TofHitStatus;
1529 if( m_hitCase == EastEndcap ) {
1530 hitStatus->setEndcapCluster( true ); // east endcap cluster counter readout
1531 }
1532 else if( m_hitCase == WestEndcap ) {
1533 hitStatus->setEndcapCluster( false ); // west endcap cluster counter readout
1534 }
1535 else {
1536 cout << "TofRec::TofTrack:convert2RecTofTrackCol: endcap- Impossible!" << endl;
1537 }
1538 atrack->setStatus( hitStatus->value() );
1539 delete hitStatus;
1540 recTofTrackCol->push_back( atrack );
1541 }
1542
1543 if( m_hitCase == NoHit ) {
1544 RecTofTrack* atrack = new RecTofTrack;
1545 buildRecTofTrack( atrack, 3 ); // no hit
1546 TofHitStatus* hitStatus = new TofHitStatus;
1547 hitStatus->setNoHit(); // no hit
1548 atrack->setStatus( hitStatus->value() );
1549 delete hitStatus;
1550 recTofTrackCol->push_back( atrack );
1551 }
1552
1553 return;
1554}
1555
1556
1557
1558void TofTrack::buildRecTofTrack( RecTofTrack* track, int layerorend ) {
1559
1560 track->setTofTrackID( m_tofTrackId );
1561 track->setTrackID( m_trackId );
1562
1563 track->setErrTof( 0.0 );
1564 track->setBeta( 0.0 );
1565
1566 double sigma[6];
1567 for( int i=0; i<6; i++ ) {
1568 sigma[i] = 0.0;
1569 }
1570 track->setSigma( sigma );
1571 track->setQuality( m_quality );
1572 track->setT0( m_estime );
1573 track->setErrT0( 0.0 );
1574 track->setPhi( 9999.0 );
1575 track->setErrPhi( 9999.0 );
1576 track->setEnergy( 9999.0 );
1577 track->setErrEnergy( 9999.0 );
1578
1579 if( ( layerorend == 11 ) || ( layerorend == 12 ) || ( layerorend == 1 ) ) {
1580 track->setTofID( m_tofId1 );
1581 track->setPath( m_path1 );
1582 track->setZrHit( m_zrhit1 );
1583 track->setErrZ( m_errzr1 );
1584 track->setTexp( m_texpInner );
1585
1586 setRecTofTrack( track, layerorend );
1587 }
1588
1589 if( ( layerorend==21 ) || ( layerorend==22 ) || ( layerorend==2 ) ) {
1590 track->setTofID( m_tofId2 );
1591 track->setPath( m_path2 );
1592 track->setZrHit( m_zrhit2 );
1593 track->setErrZ( m_errzr2 );
1594 track->setTexp( m_texpOuter );
1595
1596 setRecTofTrack( track, layerorend );
1597 }
1598
1599 if( layerorend==0 ) {
1600 track->setTofID( m_tofId1 );
1601 track->setPath( m_path2 );
1602 track->setZrHit( m_zrhit2 );
1603 track->setErrZ( m_errzr2 );
1604 track->setTexp( m_texp );
1605
1606 setRecTofTrack( track, layerorend );
1607 }
1608
1609 if( layerorend == 3 ) {
1610 track->setTofID( m_id1 );
1611 track->setPath( m_path1 );
1612 track->setZrHit( m_zrhit1 );
1613 track->setErrZ( m_errzr1 );
1614 track->setTexp( m_texpInner );
1615 }
1616
1617 return;
1618}
1619
1620
1621void TofTrack::setRecTofTrack( RecTofTrack* track, int layerorend ) {
1622
1623 double toffset[6];
1624 for( unsigned int i=0; i<6; i++ ) {
1625 toffset[i] = 0.0;
1626 }
1627
1628 if( layerorend == 0 ) { // cluster or double layer hit
1629 track->setPh( m_ph );
1630 track->setTof( m_tof[0] );
1631 track->setSigmaElectron( m_sigma );
1632 for( unsigned int i=0; i<5; i++ ) {
1633 toffset[i] = m_tof[0] - m_tof[i];
1634 }
1635 track->setToffset( toffset );
1636 track->setBeta( m_path/m_tof[0]/30.0 );
1637 }
1638 else if( layerorend == 1 ) { // inner layer
1639 track->setPh( m_ph1 );
1640 track->setTof( m_tof1[0] );
1641 track->setSigmaElectron( m_sigma1 );
1642 for( unsigned int i=0; i<5; i++ ) {
1643 toffset[i] = m_tof1[0] - m_tof1[i];
1644 }
1645 track->setToffset( toffset );
1646 track->setBeta( m_path1/m_tof1[0]/30.0 );
1647 }
1648 else if( layerorend == 2 ) { // outer layer
1649 track->setPh( m_ph2 );
1650 track->setTof( m_tof2[0] );
1651 track->setSigmaElectron( m_sigma2 );
1652 for( unsigned int i=0; i<5; i++ ) {
1653 toffset[i] = m_tof2[0] - m_tof2[i];
1654 }
1655 track->setToffset( toffset );
1656 track->setBeta( m_path2/m_tof2[0]/30.0 );
1657 }
1658 else if( layerorend == 11 ) { // inner layer east end readout
1659 track->setPh( m_ph11 );
1660 track->setTof( m_tof11[0] );
1661 track->setSigmaElectron( m_sigma11 );
1662 for( unsigned int i=0; i<5; i++ ) {
1663 toffset[i] = m_tof11[0] - m_tof11[i];
1664 }
1665 track->setToffset( toffset );
1666 track->setBeta( m_path1/m_tof11[0]/30.0 );
1667 }
1668 else if( layerorend == 12 ) { // inner layer west end readout
1669 track->setPh( m_ph12 );
1670 track->setTof( m_tof12[0] );
1671 track->setSigmaElectron( m_sigma12 );
1672 for( unsigned int i=0; i<5; i++ ) {
1673 toffset[i] = m_tof12[0] - m_tof12[i];
1674 }
1675 track->setToffset( toffset );
1676 track->setBeta( m_path1/m_tof12[0]/30.0 );
1677 }
1678 else if( layerorend == 21 ) { // outer layer east end readout
1679 track->setPh( m_ph21 );
1680 track->setTof( m_tof21[0] );
1681 track->setSigmaElectron( m_sigma21 );
1682 for( unsigned int i=0; i<5; i++ ) {
1683 toffset[i] = m_tof21[0] - m_tof21[i];
1684 }
1685 track->setToffset( toffset );
1686 track->setBeta( m_path2/m_tof21[0]/30.0 );
1687 }
1688 else if( layerorend == 22 ) { // outer layer west end readout
1689 track->setPh( m_ph22 );
1690 track->setTof( m_tof22[0] );
1691 track->setSigmaElectron( m_sigma22 );
1692 for( unsigned int i=0; i<5; i++ ) {
1693 toffset[i] = m_tof22[0] - m_tof22[i];
1694 }
1695 track->setToffset( toffset );
1696 track->setBeta( m_path2/m_tof22[0]/30.0 );
1697 }
1698 else{
1699 cout << "TofRec TofTrack::SetRecTofTrack layerorend = " << layerorend << endl;
1700 }
1701 return;
1702}
1703
1704
1705void TofTrack::convert2RecBTofCalHitCol( int runNumber, int eventNumber, RecBTofCalHitCol* btofCalHitCol, std::string calibData ) {
1706
1707 if( ( m_quality1 & 0x800 ) == 0x800 ) {
1708
1709 RecBTofCalHit* ahit = new RecBTofCalHit;
1710 ahit->setRun( runNumber );
1711 ahit->setEvent( eventNumber );
1712 ahit->setMod( m_tofId1 );
1713 ahit->setQual( m_hitCase );
1714
1715 for( int i=0; i<5; i++ ) {
1716 ahit->setTpred( i, m_texpInner[i] );
1717 }
1718 if( calibData == "Dimu" ) {
1719 ahit->setTpred( m_texpInner[1] );
1720 ahit->setZHit( m_zr1[1] );
1721 ahit->setdZHit( m_ezr1[1] );
1722 }
1723 else {
1724 ahit->setTpred( m_texpInner[0] );
1725 ahit->setZHit( m_zr1[0] );
1726 ahit->setdZHit( m_ezr1[0] );
1727 }
1728
1729 ahit->setTdc1( m_tdc1-m_estime );
1730 ahit->setTdc2( m_tdc2-m_estime );
1731 ahit->setAdc1( m_adc1 );
1732 ahit->setAdc2( m_adc2 );
1733 // ahit->setZHit( m_zrhit1 );
1734 // ahit->setdZHit( m_errzr1 );
1735 ahit->setDeltaPhi( m_estime );
1736 ahit->setsinTheta( m_theta1 );
1737 ahit->setP( m_momentum );
1738 ahit->setQ( m_ph1 );
1739 ahit->setPath( m_path1 );
1740
1741 btofCalHitCol->push_back( ahit );
1742
1743 if( ( m_quality2 & 0x800 ) == 0x800 ) {
1744
1745 RecBTofCalHit* bhit = new RecBTofCalHit;
1746 bhit->setRun( runNumber );
1747 bhit->setEvent( eventNumber );
1748 bhit->setMod( m_tofId2 );
1749 bhit->setQual( m_hitCase );
1750
1751 for( int i=0; i<5; i++ ) {
1752 bhit->setTpred( i, m_texpOuter[i] );
1753 }
1754 if( calibData == "Dimu" ) {
1755 bhit->setTpred( m_texpOuter[1] );
1756 bhit->setZHit( m_zr2[1] );
1757 bhit->setdZHit( m_ezr2[1] );
1758 }
1759 else {
1760 bhit->setTpred( m_texpOuter[0] );
1761 bhit->setZHit( m_zr2[0] );
1762 bhit->setdZHit( m_ezr2[0] );
1763 }
1764
1765 bhit->setTdc1( m_tdc3-m_estime );
1766 bhit->setTdc2( m_tdc4-m_estime );
1767 bhit->setAdc1( m_adc3 );
1768 bhit->setAdc2( m_adc4 );
1769 // bhit->setZHit( m_zrhit2 );
1770 // bhit->setdZHit( m_errzr2 );
1771 bhit->setDeltaPhi( m_estime );
1772 bhit->setsinTheta( m_theta2 );
1773 bhit->setP( m_momentum );
1774 bhit->setQ( m_ph2 );
1775 bhit->setPath( m_path2 );
1776
1777 ahit->setnext(bhit);
1778
1779 btofCalHitCol->push_back( bhit );
1780
1781 }
1782 }
1783
1784 return;
1785}
1786
1787
1788void TofTrack::convert2RecETofCalHitCol( int runNumber, int eventNumber, RecETofCalHitCol* etofCalHitCol, std::string calibData ) {
1789
1790 if( ( m_quality1 & 0x800 ) != 0x800 ) return;
1791
1792 RecETofCalHit* chit = new RecETofCalHit;
1793 chit->setRun( runNumber );
1794 chit->setEvent( eventNumber );
1795 chit->setMod( m_tofId1 );
1796 chit->setQual( m_hitCase );
1797
1798 for( int i=0; i<5; i++ ) {
1799 chit->setTpred( i, m_texpInner[i] );
1800 }
1801 if( calibData == "Dimu" ) {
1802 chit->setTpred( m_texpInner[1] );
1803 chit->setRHit( m_zr1[1] );
1804 chit->setdRHit( m_ezr1[1] );
1805 }
1806 else {
1807 chit->setTpred( m_texpInner[0] );
1808 chit->setRHit( m_zr1[0] );
1809 chit->setdRHit( m_ezr1[0] );
1810 }
1811
1812 chit->setTdc( m_tdc1-m_estime );
1813 chit->setAdc( m_adc1 );
1814 // chit->setRHit( m_zrhit1 );
1815 // chit->setdRHit( m_errzr1 );
1816 chit->setDeltaPhi( m_estime );
1817 chit->setcosTheta( m_theta1 );
1818 chit->setQ( m_ph1 );
1819 chit->setP( m_momentum );
1820 chit->setPath( m_path1 );
1821
1822 etofCalHitCol->push_back( chit );
1823
1824 return;
1825}
1826
1827// set Quality using quality1 and quality2
1829
1830 return;
1831}
int east[11]
double abs(const EvtComplex &c)
EvtStreamInputIterator< typename Generator::result_type > iter(Generator gen, int N=0)
bool innerLayer(HoughHit hit1, HoughHit hit2)
ObjectVector< RecBTofCalHit > RecBTofCalHitCol
ObjectVector< RecETofCalHit > RecETofCalHitCol
ObjectVector< RecTofTrack > RecTofTrackCol
Definition RecTofTrack.h:33
std::multimap< unsigned int, TofData * > TofDataMap
Definition TofData.h:244
std::multimap< unsignedint, TofData * >::iterator IterTofDataMap
Definition TofData.h:245
ITofCaliSvc * tofCaliSvc
ITofCaliSvc * tofCaliSvc
void qualityAnalysis()
const double zadc_Cut
Definition TofTrack.h:15
@ WestEndcap
Definition TofTrack.h:18
@ OuterLayer
Definition TofTrack.h:18
@ InnerLayer
Definition TofTrack.h:18
@ EastEndcap
Definition TofTrack.h:18
@ DoubleLayer
Definition TofTrack.h:18
@ NoHit
Definition TofTrack.h:18
const double ztdc_Cut
Definition TofTrack.h:12
const double tof1Path() const
Definition DstExtTrack.h:68
const Hep3Vector tof1Position() const
Definition DstExtTrack.h:58
const int tof1VolumeNumber() const
Definition DstExtTrack.h:64
const double tof1() const
Definition DstExtTrack.h:66
const Hep3Vector tof2Momentum() const
Definition DstExtTrack.h:96
const Hep3Vector tof1Momentum() const
Definition DstExtTrack.h:60
const double tof2() const
const double tof2PosSigmaAlongZ() const
const double tof1PosSigmaAlongX() const
Definition DstExtTrack.h:74
const double tof2Path() const
const int trackId() const
Definition DstExtTrack.h:43
const double tof1PosSigmaAlongY() const
Definition DstExtTrack.h:76
const double tof1PosSigmaAlongZ() const
Definition DstExtTrack.h:70
const int tof2VolumeNumber() const
const Hep3Vector tof2Position() const
Definition DstExtTrack.h:94
void setStatus(unsigned int status)
Definition DstTofTrack.h:92
void setSigma(double sigma[6])
void setToffset(double toffset[6])
void setEnergy(double energy)
void setPath(double path)
Definition DstTofTrack.h:94
void setTofTrackID(int tofTrackID)
Definition DstTofTrack.h:89
void setPh(double ph)
Definition DstTofTrack.h:96
void setQuality(int quality)
void setZrHit(double zrhit)
Definition DstTofTrack.h:95
void setTof(double tof)
Definition DstTofTrack.h:97
void setPhi(double phi)
void setErrTof(double etof)
Definition DstTofTrack.h:98
void setErrT0(double errt0)
void setTexp(double texp[5])
void setBeta(double beta)
Definition DstTofTrack.h:99
void setErrEnergy(double errenergy)
void setTrackID(int trackID)
Definition DstTofTrack.h:90
void setT0(double t0)
void setErrZ(double errz)
void setErrPhi(double errphi)
void setTofID(int tofID)
Definition DstTofTrack.h:91
void setSigmaElectron(double se)
virtual const double BSigmaCounter(double zHit, unsigned id)=0
virtual const double BSigma2(double zHit, unsigned id)=0
virtual const double BTimeCluster(double tlayer1, double tlayer2, double z1, double z2, unsigned id1, unsigned int id2)=0
virtual const double EPulseHeight(double ADC, double rHit, double cost, unsigned int id)=0
virtual const double BTime2(double ADC, double TDC, double zHit, unsigned id, double t0)=0
virtual const double BTime1(double ADC, double TDC, double zHit, unsigned id, double t0)=0
virtual const double BTimeCounter(double tleft, double tright, double z, unsigned id)=0
virtual const double ZTDC(double tleft, double tright, unsigned id)=0
virtual const double BSigmaCluster(double zHit1, double zHit2, unsigned id1, unsigned id2)=0
virtual const double BPulseHeight(double ADC1, double ADC2, double zHit, double sint, unsigned int id)=0
virtual const double BSigma1(double zHit, unsigned id)=0
virtual const double ESigma(double rHit, unsigned id)=0
virtual const double ZADC(double qleft, double qright, unsigned id)=0
virtual const double ETime(double ADC, double TDC, double rHit, unsigned id)=0
void setsinTheta(double sint)
void setnext(RecBTofCalHit *n)
void setTdc2(double tdc2)
void setRun(int run)
void setP(double p)
void setQ(double q)
void setdZHit(double dzHit)
void setPath(double l)
void setAdc2(double adc2)
void setTdc1(double tdc1)
void setMod(int imod)
void setZHit(double zHit)
void setQual(int qual)
void setDeltaPhi(double deltaPhi)
void setEvent(int event)
void setTpred(int idx, double t)
void setAdc1(double adc1)
void setEvent(int event)
void setdRHit(double drHit)
void setDeltaPhi(double deltaPhi)
void setTdc(double tdc)
void setRHit(double rHit)
void setRun(int run)
void setPath(double l)
void setMod(int imod)
void setP(double p)
void setAdc(double adc)
void setcosTheta(double cost)
void setQ(double q)
void setQual(int qual)
void setTpred(int idx, double t)
void setUsed()
Definition TofData.cxx:945
unsigned int value() const
void setBarrelReadout(unsigned int layer, bool east)
void setEndcapCluster(bool east)
void setBarrelCounter(unsigned int layer)
void setBarrelCluster(unsigned int layer)
static int end(const Identifier &id)
Definition TofID.cxx:129
static int phi_module(const Identifier &id)
Definition TofID.cxx:117
static int barrel_ec(const Identifier &id)
Values of different levels (failure returns 0)
Definition TofID.cxx:95
static value_type getIntID(int barrel_ec, int layer, int phi_module, int end)
Definition TofID.cxx:200
static int layer(const Identifier &id)
Definition TofID.cxx:109
void setTofData(TofDataMap tofDataMap)
Definition TofTrack.cxx:288
std::vector< TofData * > tofData1() const
Definition TofTrack.h:44
void setExtTrack(RecExtTrack *extTrack, int kal[5], double t0, int t0Stat)
Definition TofTrack.cxx:144
TofData * chooseTofDataEndcap(std::vector< TofData * > tofDataVec, double zr1[5])
Definition TofTrack.cxx:940
ExtTrackCase hitCase() const
Definition TofTrack.h:30
int t0Stat() const
Definition TofTrack.h:103
int kal(unsigned int i) const
Definition TofTrack.h:39
unsigned int quality1() const
Definition TofTrack.h:54
double tof(unsigned int i) const
Definition TofTrack.h:75
void convert2RecTofTrackCol(RecTofTrackCol *recTofTrackCol)
int id2() const
Definition TofTrack.h:28
void tofDataAnalysis(TofData *tof, unsigned int iflag)
Definition TofTrack.cxx:426
void buildRecTofTrack(RecTofTrack *track, int layerorend)
void getTofData(TofData *tof, unsigned int iflag)
Definition TofTrack.cxx:995
void match(bool forCalibration, std::vector< int > deadId, std::vector< TofTrack * > *&tofTrackVec)
Definition TofTrack.cxx:493
void findTofDataEndcap(std::vector< TofData * > tofDataVec1, std::vector< TofData * > tofDataVec2, double zr1[5])
Definition TofTrack.cxx:859
int tofId1() const
Definition TofTrack.h:58
void setQuality1(int qual1)
Definition TofTrack.h:110
void setCalibration()
void setRecTofTrack(RecTofTrack *track, int layerorend)
void convert2RecETofCalHitCol(int runNumber, int eventNumber, RecETofCalHitCol *etofCalHitCol, std::string calibData)
void convert2RecBTofCalHitCol(int runNumber, int eventNumber, RecBTofCalHitCol *btofCalHitCol, std::string calibData)
TofData * compareTofData(TofData *tofData1, TofData *tofData2, double zrhit)
Definition TofTrack.cxx:837
void getTofDataNohit(unsigned int iflag)
TofData * chooseTofData(std::vector< TofData * > tofDataVec, double zrhit)
Definition TofTrack.cxx:780
void getTofDataWest(TofData *tof, unsigned int iflag)
void getMultiHit(TofTrack *&)
Definition TofTrack.cxx:244
int tofId2() const
Definition TofTrack.h:59
void setQuality2(int qual2)
Definition TofTrack.h:111
TofData * compareTofDataEndcap(TofData *tofData1, TofData *tofData2)
Definition TofTrack.cxx:983
std::vector< TofData * > tofData2() const
Definition TofTrack.h:45
unsigned int barrel() const
Definition TofTrack.h:29
void getTofDataEast(TofData *tof, unsigned int iflag)
void findTofDataBarrel(std::vector< TofData * > tofDataVec1, std::vector< TofData * > tofDataVec2, double zrhit, unsigned int iflag, std::vector< TofTrack * > *&tofTrackVec)
Definition TofTrack.cxx:609
unsigned int quality2() const
Definition TofTrack.h:55
int id1() const
Definition TofTrack.h:27