28 for(
unsigned int i=0; i<5; i++ ) {
35 if( m_tofData1.size()>0 ) {
36 std::vector<TofData*>::iterator iter1 = m_tofData1.begin();
39 if( m_tofData2.size()>0 ) {
40 std::vector<TofData*>::iterator iter2 = m_tofData2.begin();
43 if( m_tofData3.size()>0 ) {
44 std::vector<TofData*>::iterator iter3 = m_tofData3.begin();
47 if( m_tofData4.size()>0 ) {
48 std::vector<TofData*>::iterator iter4 = m_tofData4.begin();
66 for(
unsigned int i=0; i<5; i++ ) {
97 for(
unsigned int i=0; i<5; i++ ) {
98 m_texpInner[i] = -999.0;
99 m_texpOuter[i] = -999.0;
119 if( m_tofData1.size()>0 ) {
120 std::vector<TofData*>::iterator iter1 = m_tofData1.begin();
123 if( m_tofData2.size()>0 ) {
124 std::vector<TofData*>::iterator iter2 = m_tofData2.begin();
127 if( m_tofData3.size()>0 ) {
128 std::vector<TofData*>::iterator iter3 = m_tofData3.begin();
131 if( m_tofData4.size()>0 ) {
132 std::vector<TofData*>::iterator iter4 = m_tofData4.begin();
159 m_id1 =
tofId1 - 176 + 48;
164 m_id1 =
tofId1 - 176 - 48;
179 else if( m_hitCase==
NoHit ) {
184 m_trackId = extTrack->
trackId();
188 for(
unsigned int i=0; i<5; i++ ) {
189 m_texpInner[i] = extTrack->
tof1(i);
196 for(
unsigned int i=0; i<5; i++ ) {
202 for(
unsigned int i=0; i<5; i++ ) {
203 m_texpInner[i] = extTrack->
tof1(i);
210 for(
unsigned int i=0; i<5; i++ ) {
217 for(
unsigned int i=0; i<5; i++ ) {
218 m_texpOuter[i] = extTrack->
tof2(i);
225 for(
unsigned int i=0; i<5; i++ ) {
231 if( m_hitCase ==
NoHit ) { m_quality = 11; }
233 for(
unsigned int i=0; i<5; i++ ) {
248 if( (
abs(m_id1-track->
id1())<=1 ) || ( m_id1==0 && track->
id1()==87 ) || ( m_id1==87 && track->
id1()==0 ) ) {
250 m_quality1 = ( m_quality1 | 0x400 );
255 if( (
abs(m_id2-track->
id2())<=1 ) || ( m_id2==88 && track->
id2()==175 ) || ( m_id2==175 && track->
id2()==88 ) ) {
257 m_quality2 = ( m_quality2 | 0x400 );
264 if( (
abs(m_id1-track->
id1())<=1 ) || ( m_id1==0 && track->
id1()==47 ) || ( m_id1==47 && track->
id1()==0 ) ) {
266 m_quality1 = ( m_quality1 | 0x400 );
272 if( (
abs(m_id1-track->
id1())<=1 ) || ( m_id1==48 && track->
id1()==95 ) || ( m_id1==95 && track->
id1()==48 ) ) {
274 m_quality1 = ( m_quality1 | 0x400 );
290 if( m_hitCase ==
NoHit )
return;
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;
302 count0 = tofDataMap.count( identify0 );
303 int tofid1 = tofid0 - 1;
304 if( tofid1 == -1 ) { tofid1 = 87; }
306 count1 = tofDataMap.count( identify1 );
307 int tofid2 = tofid0 + 1;
308 if( tofid2 == 88 ) { tofid2 = 0; }
310 count2 = tofDataMap.count( identify2 );
313 if( ( m_hitCase ==
EastEndcap ) && ( m_id1 > -1 ) ) {
316 count0 = tofDataMap.count( identify0 );
317 int tofid1 = tofid0 - 1;
318 if( tofid1 == -1 ) { tofid1 = 47; }
320 count1 = tofDataMap.count( identify1 );
321 int tofid2 = tofid0 + 1;
322 if( tofid2 == 48 ) { tofid2 = 0; }
324 count2 = tofDataMap.count( identify2 );
327 if( ( m_hitCase ==
WestEndcap ) && ( m_id1 > -1 ) ) {
328 int tofid0 = m_id1 - 48;
330 count0 = tofDataMap.count( identify0 );
331 int tofid1 = tofid0 - 1;
332 if( tofid1 == -1 ) { tofid1 = 47; }
334 count1 = tofDataMap.count( identify1 );
335 int tofid2 = tofid0 + 1;
336 if( tofid2 == 48 ) { tofid2 = 0; }
338 count2 = tofDataMap.count( identify2 );
342 pair< IterTofDataMap, IterTofDataMap > range = tofDataMap.equal_range( identify0 );
344 for(
unsigned int i = 0; i < count0; i++,
iter++ ) {
349 pair< IterTofDataMap, IterTofDataMap > range = tofDataMap.equal_range( identify1 );
351 for(
unsigned int i = 0; i < count1; i++,
iter++ ) {
356 pair< IterTofDataMap, IterTofDataMap > range = tofDataMap.equal_range( identify2 );
358 for(
unsigned int i = 0; i < count2; i++,
iter++ ) {
363 if( ( count0 == 0 ) && ( count1 == 0 ) && ( count2 == 0 ) ) {
374 int tofid0 = m_id2 - 88;
376 count0 = tofDataMap.count( identify0 );
377 int tofid1 = tofid0 - 1;
378 if( tofid1 == -1 ) { tofid1 = 87; }
380 count1 = tofDataMap.count( identify1 );
381 int tofid2 = tofid0 + 1;
382 if( tofid2 == 88 ) { tofid2 = 0; }
384 count2 = tofDataMap.count( identify2 );
387 pair< IterTofDataMap, IterTofDataMap > range = tofDataMap.equal_range( identify0 );
389 for(
unsigned int i = 0; i < count0; i++,
iter++ ) {
394 pair< IterTofDataMap, IterTofDataMap > range = tofDataMap.equal_range( identify1 );
396 for(
unsigned int i = 0; i < count1; i++,
iter++ ) {
401 pair< IterTofDataMap, IterTofDataMap > range = tofDataMap.equal_range( identify2 );
403 for(
unsigned int i = 0; i < count2; i++,
iter++ ) {
408 if( ( count0 == 0 ) && ( count1 == 0 ) && ( count2 == 0 ) ) {
428 unsigned int qual =
tof->quality();
430 if( ( qual & 0x10 ) == 0 ) {
433 qual = ( qual | 0x10 );
435 if(
tof->barrel() ) {
436 if( (
tof->quality() == 0x7 ) || (
tof->quality() == 0xd ) ) {
437 qual = ( qual | 0x20 );
440 if( (
tof->quality() == 0xb ) || (
tof->quality() == 0xe ) ) {
441 qual = ( qual | 0x40 );
444 if( (
tof->quality() == 0x3 ) || (
tof->quality() == 0xc ) ) {
445 qual = ( qual | 0x80 );
448 if( (
tof->quality() & 0x5 ) == 0x5 ) {
450 tof->setZTdc( ztdc );
461 if( (
tof->quality() & 0xa ) == 0xa ) {
463 tof->setZAdc( zadc );
475 tof->setQuality( qual );
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 );
483 cout <<
"TofRec::TofTrack::TofDataAnalylsis: the Flag should be 1-4, out of the Range!" << endl;
493void TofTrack::match(
bool forCalibration, std::vector<int> deadId, std::vector<TofTrack*>*& tofTrackVec ) {
495 if( m_hitCase ==
NoHit )
return;
499 if( ( m_quality1 & 0x10 ) == 0 ) { m_hitCase =
NoHit; }
503 if( ( m_quality2 & 0x10 ) == 0 ) { m_hitCase =
NoHit; }
507 if( ( m_quality1 & 0x10 ) == 0 ) { m_hitCase =
OuterLayer; }
509 if( ( m_quality2 & 0x10 ) == 0 ) {
517 cout <<
"TofRec::TofTrack::match: 2- Impossible!" << endl;
525 cout <<
"TofRec::TofTrack::match: 1- Impossible!" << endl;
528 if( forCalibration ) {
531 if( ( ( m_quality1 & 0xf ) == 0xf ) && ( ( m_quality2 & 0xf ) == 0xf ) ) {
532 m_quality1 = ( m_quality1 | 0x800 );
533 m_quality2 = ( m_quality2 | 0x800 );
536 std::vector<int>::iterator
iter = deadId.begin();
537 for( ;
iter != deadId.end();
iter++ ) {
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 );
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 );
571 if( ( m_quality1 & 0xf ) == 0xf ) {
572 m_quality1 = ( m_quality1 | 0x800 );
575 std::vector<int>::iterator
iter = deadId.begin();
576 for( ;
iter != deadId.end();
iter++ ) {
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 );
596 if( ( ( m_hitCase ==
EastEndcap ) || ( m_hitCase ==
WestEndcap ) ) && ( ( m_quality1 & 0xf ) == 0xc ) ) {
597 m_quality1 = ( m_quality1 | 0x800 );
609void TofTrack::findTofDataBarrel( std::vector<TofData*> tofDataVec1, std::vector<TofData*> tofDataVec2,
double zrhit,
unsigned int iflag, std::vector<TofTrack*>*& tofTrackVec ) {
611 unsigned int qual = 0xf;
613 if( tofDataVec2.size() == 0 ) {
614 if( tofDataVec1.size() == 0 ) {
617 else if( tofDataVec1.size() == 1 ) {
618 std::vector<TofData*>::iterator iter1 = tofDataVec1.begin();
622 else if( tofDataVec1.size() > 1 ) {
627 cout <<
"TofRec::TofTrack::findTofDataBarrel: 1- Impossible!" << endl;
630 else if( ( tofDataVec2.size() == 1 ) ) {
631 if( tofDataVec1.size() == 0 ) {
632 std::vector<TofData*>::iterator iter2 = tofDataVec2.begin();
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 ) {
642 std::vector<TofData*>::iterator iter2 = tofDataVec2.begin();
647 else if( tofDataVec1.size() > 1 ) {
653 std::vector<TofData*>::iterator iter2 = tofDataVec2.begin();
659 cout <<
"TofRec::TofTrack::findTofDataBarrel: 2- Impossible!" << endl;
662 else if( ( tofDataVec2.size() > 1 ) ) {
663 if( tofDataVec1.size() == 0 ) {
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 ) {
678 else if( tofDataVec1.size() > 1 ) {
690 cout <<
"TofRec::TofTrack::findTofDataBarrel: 3- Impossible!" << endl;
695 if( !(
tof->used()) ) {
699 bool z1=
false, z2=
false;
700 bool zc1=
false, zc2=
false;
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() ) {
710 zc2 = ( (*iter)->zrhit1() >
tof->ztdc() );
714 else if( iflag==2 ) {
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() ) {
722 zc2 = ( (*iter)->zrhit2() >
tof->ztdc() );
727 if( ( z1 && z2 )||( (!z1) && (!z2) ) ) {
732 else if( !zc1 && zc2 ) {
737 else if( z1 && !z2 ) {
740 cout << iflag <<
" " << track->
quality1() <<
" " << track->
quality2() << endl;
742 else if( !z1 && z2 ) {
749 if( ( iflag == 1 ) || ( iflag == 3 ) ) {
750 m_quality1 = ( m_quality1 | 0x300 );
752 else if( iflag == 2 ) {
753 m_quality2 = ( m_quality2 | 0x300 );
756 cout <<
"TofRec::TofTrack::findTofDataBarrel: the 1- IFLAG is Out of Range!" << endl;
760 qual = ( qual << 12 );
761 if( ( iflag == 1 ) || ( iflag == 3 ) ) {
762 m_quality1 = ( m_quality1 | qual );
764 else if( iflag == 2 ) {
765 m_quality2 = ( m_quality2 | qual );
768 cout <<
"TofRec::TofTrack::findTofDataBarrel: the 2- IFLAG is Out of Range!" << endl;
781 if( tofDataVec.size() == 0 ) {
782 cout <<
"TofRec::TofTrack::ChooseTofData: Size of TofData Vector is Zero!" << endl;
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();
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 );
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 );
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 ) {
817 ibad = ( (*iter)->quality() & 0xf0 );
819 else if( ( (*iter)->quality() & 0xf0 ) == ibad ) {
820 if( ( (*iter)->adc1() + (*iter)->adc2() ) > ( (*igood)->adc1() + (*igood)->adc2() ) ) {
822 ibad = ( (*iter)->quality() & 0xf0 );
861 unsigned int iflag = 3;
862 unsigned int qual = 0xf;
864 if( tofDataVec2.size() == 0 ) {
865 if( tofDataVec1.size() == 0 ) {
868 else if( tofDataVec1.size() == 1 ) {
869 std::vector<TofData*>::iterator iter1 = tofDataVec1.begin();
873 else if( tofDataVec1.size() > 1 ) {
878 cout <<
"TofRec::TofTrack::findTofDataEndcap: 1- Impossible!" << endl;
881 else if( ( tofDataVec2.size() == 1 ) ) {
882 if( tofDataVec1.size() == 0 ) {
883 std::vector<TofData*>::iterator iter2 = tofDataVec2.begin();
887 else if( tofDataVec1.size() == 1 ) {
888 std::vector<TofData*>::iterator iter1 = tofDataVec1.begin();
889 std::vector<TofData*>::iterator iter2 = tofDataVec2.begin();
893 else if( tofDataVec1.size() > 1 ) {
895 std::vector<TofData*>::iterator iter2 = tofDataVec2.begin();
900 cout <<
"TofRec::TofTrack::findTofDataBarrel: 2- Impossible!" << endl;
903 else if( ( tofDataVec2.size() > 1 ) ) {
904 if( tofDataVec1.size() == 0 ) {
908 else if( tofDataVec1.size() == 1 ) {
909 std::vector<TofData*>::iterator iter1 = tofDataVec1.begin();
914 else if( tofDataVec1.size() > 1 ) {
921 cout <<
"TofRec::TofTrack::findTofDataBarrel: 3- Impossible!" << endl;
926 m_quality1 = ( m_quality1 | 0x300 );
929 qual = ( qual << 12 );
930 m_quality1 = ( m_quality1 | qual );
941 if( tofDataVec.size() == 0 ) {
942 cout <<
"TofRec::TofTrack::ChooseTofData: Size of TofData Vector is Zero!" << endl;
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; }
952 iter = tofDataVec.begin();
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]);
968 for( ;
iter != tofDataVec.end();
iter++ ) {
969 if( (*iter)->adc() > maxQ ) {
970 maxQ = (*iter)->adc();
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 );
1011 if( ( (
tof->quality() & 0xa ) != 0xa ) || ( ( (
tof->quality() & 0xa ) == 0xa ) && ( abs(
tof->zadc() - m_zrhit1 ) >
zadc_Cut ) ) ) {
1012 m_quality1 = ( m_quality1 | 0x200 );
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 );
1029 if( ( (
tof->quality() & 0xa ) != 0xa ) || ( ( (
tof->quality() & 0xa ) == 0xa ) && ( abs(
tof->zadc() - m_zrhit2 ) >
zadc_Cut ) ) ) {
1030 m_quality2 = ( m_quality2 | 0x200 );
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 );
1042 cout <<
"TofRec::TofTrack::getTofData: Flag which sign the Barrel/Endcap or Inner/Outer is wrong! Please check it!" << endl;
1055 m_tofId1 =
tof->tofId();
1056 m_qch1 =
tof->adcChannelEast();
1057 m_adc1 =
tof->adc1();
1058 m_tdc1 =
tof->tdc1();
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 );
1068 if( ( (
tof->quality() & 0xa ) != 0xa ) || ( ( (
tof->quality() & 0xa ) == 0xa ) && ( abs(
tof->zadc() - m_zrhit1 ) >
zadc_Cut ) ) ) {
1069 m_quality1 = ( m_quality1 | 0x200 );
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();
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 );
1086 if( ( (
tof->quality() & 0xa ) != 0xa ) || ( ( (
tof->quality() & 0xa ) == 0xa ) && ( abs(
tof->zadc() - m_zrhit2 ) >
zadc_Cut ) ) ) {
1087 m_quality2 = ( m_quality2 | 0x200 );
1091 cout <<
"TofRec::TofTrack::getTofDataEast: Flag which sign the Barrel/Endcap or Inner/Outer is wrong! Please check it!" << endl;
1104 m_tofId1 =
tof->tofId();
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 );
1117 if( ( (
tof->quality() & 0xa ) != 0xa ) || ( ( (
tof->quality() & 0xa ) == 0xa ) && ( abs(
tof->zadc() - m_zrhit1 ) >
zadc_Cut ) ) ) {
1118 m_quality1 = ( m_quality1 | 0x200 );
1121 else if( iflag == 2 ) {
1122 m_tofId2 =
tof->tofId();
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 );
1135 if( ( (
tof->quality() & 0xa ) != 0xa ) || ( ( (
tof->quality() & 0xa ) == 0xa ) && ( abs(
tof->zadc() - m_zrhit2 ) >
zadc_Cut ) ) ) {
1136 m_quality2 = ( m_quality2 | 0x200 );
1140 cout <<
"TofRec::TofTrack::getTofDataWest: Flag which sign the Barrel/Endcap or Inner/Outer is wrong! Please check it!" << endl;
1162 m_quality1 = ( m_quality1 & 0x700 );
1166 else if( iflag == 2 ) {
1176 m_quality2 = ( m_quality2 & 0x700 );
1181 cout <<
"TofRec::TofTrack::getTofData: Flag which sign the Barrel/Endcap or Inner/Outer is wrong! Please check it!" << endl;
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 );
1205 bool endcapData = ( ( m_quality1 & 0xc ) == 0xc );
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 );
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 );
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 );
1232 for(
unsigned int i=0; i<5; i++ ) {
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 );
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 );
1264 for(
unsigned int i=0; i<5; i++ ) {
1280 for(
unsigned int i=0; i<5; i++ ) {
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 );
1296 if( (m_quality1&0xa000)!=0 ) { m_quality = 4; }
1314 if( innerEast || innerWest || outerEast || outerWest ) {
1321 if( ( (m_quality1&0xa000)!=0 ) || ( (m_quality2&0xa000)!=0 ) ) {
1322 m_quality = m_quality + 3;
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; }
1331 cout <<
"TofRec::TofTrack::setCalibration: Impossible!" << endl;
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 );
1367 if( outerEast && outerWest ) {
1375 cout <<
"TofRec::TofTrack:convert2RecTofTrackCol: 11- Impossible!" << endl;
1380 recTofTrackCol->push_back( atrack11 );
1395 if( outerEast && outerWest ) {
1403 cout <<
"TofRec::TofTrack:convert2RecTofTrackCol: 12- Impossible!" << endl;
1408 recTofTrackCol->push_back( atrack12 );
1411 if( innerEast && innerWest ) {
1419 if( outerEast && outerWest ) {
1427 cout <<
"TofRec::TofTrack:convert2RecTofTrackCol: 1- Impossible!" << endl;
1431 recTofTrackCol->push_back( atrack1 );
1446 if( innerEast || innerWest ) {
1454 cout <<
"TofRec::TofTrack:convert2RecTofTrackCol: 21- Impossible!" << endl;
1459 recTofTrackCol->push_back( atrack21 );
1474 if( innerEast || innerWest ) {
1482 cout <<
"TofRec::TofTrack:convert2RecTofTrackCol: 22- Impossible!" << endl;
1487 recTofTrackCol->push_back( atrack22 );
1490 if( outerEast && outerWest ) {
1498 if( innerEast && innerWest ) {
1506 cout <<
"TofRec::TofTrack:convert2RecTofTrackCol: 2- Impossible!" << endl;
1510 recTofTrackCol->push_back( atrack2 );
1513 if( innerEast && innerWest && outerEast && outerWest ) {
1520 recTofTrackCol->push_back( atrack );
1536 cout <<
"TofRec::TofTrack:convert2RecTofTrackCol: endcap- Impossible!" << endl;
1540 recTofTrackCol->push_back( atrack );
1543 if( m_hitCase ==
NoHit ) {
1550 recTofTrackCol->push_back( atrack );
1567 for(
int i=0; i<6; i++ ) {
1572 track->
setT0( m_estime );
1579 if( ( layerorend == 11 ) || ( layerorend == 12 ) || ( layerorend == 1 ) ) {
1584 track->
setTexp( m_texpInner );
1589 if( ( layerorend==21 ) || ( layerorend==22 ) || ( layerorend==2 ) ) {
1594 track->
setTexp( m_texpOuter );
1599 if( layerorend==0 ) {
1609 if( layerorend == 3 ) {
1614 track->
setTexp( m_texpInner );
1624 for(
unsigned int i=0; i<6; i++ ) {
1628 if( layerorend == 0 ) {
1629 track->
setPh( m_ph );
1630 track->
setTof( m_tof[0] );
1632 for(
unsigned int i=0; i<5; i++ ) {
1633 toffset[i] = m_tof[0] - m_tof[i];
1636 track->
setBeta( m_path/m_tof[0]/30.0 );
1638 else if( layerorend == 1 ) {
1639 track->
setPh( m_ph1 );
1640 track->
setTof( m_tof1[0] );
1642 for(
unsigned int i=0; i<5; i++ ) {
1643 toffset[i] = m_tof1[0] - m_tof1[i];
1646 track->
setBeta( m_path1/m_tof1[0]/30.0 );
1648 else if( layerorend == 2 ) {
1649 track->
setPh( m_ph2 );
1650 track->
setTof( m_tof2[0] );
1652 for(
unsigned int i=0; i<5; i++ ) {
1653 toffset[i] = m_tof2[0] - m_tof2[i];
1656 track->
setBeta( m_path2/m_tof2[0]/30.0 );
1658 else if( layerorend == 11 ) {
1659 track->
setPh( m_ph11 );
1660 track->
setTof( m_tof11[0] );
1662 for(
unsigned int i=0; i<5; i++ ) {
1663 toffset[i] = m_tof11[0] - m_tof11[i];
1666 track->
setBeta( m_path1/m_tof11[0]/30.0 );
1668 else if( layerorend == 12 ) {
1669 track->
setPh( m_ph12 );
1670 track->
setTof( m_tof12[0] );
1672 for(
unsigned int i=0; i<5; i++ ) {
1673 toffset[i] = m_tof12[0] - m_tof12[i];
1676 track->
setBeta( m_path1/m_tof12[0]/30.0 );
1678 else if( layerorend == 21 ) {
1679 track->
setPh( m_ph21 );
1680 track->
setTof( m_tof21[0] );
1682 for(
unsigned int i=0; i<5; i++ ) {
1683 toffset[i] = m_tof21[0] - m_tof21[i];
1686 track->
setBeta( m_path2/m_tof21[0]/30.0 );
1688 else if( layerorend == 22 ) {
1689 track->
setPh( m_ph22 );
1690 track->
setTof( m_tof22[0] );
1692 for(
unsigned int i=0; i<5; i++ ) {
1693 toffset[i] = m_tof22[0] - m_tof22[i];
1696 track->
setBeta( m_path2/m_tof22[0]/30.0 );
1699 cout <<
"TofRec TofTrack::SetRecTofTrack layerorend = " << layerorend << endl;
1707 if( ( m_quality1 & 0x800 ) == 0x800 ) {
1710 ahit->
setRun( runNumber );
1712 ahit->
setMod( m_tofId1 );
1715 for(
int i=0; i<5; i++ ) {
1716 ahit->
setTpred( i, m_texpInner[i] );
1718 if( calibData ==
"Dimu" ) {
1729 ahit->
setTdc1( m_tdc1-m_estime );
1730 ahit->
setTdc2( m_tdc2-m_estime );
1737 ahit->
setP( m_momentum );
1738 ahit->
setQ( m_ph1 );
1741 btofCalHitCol->push_back( ahit );
1743 if( ( m_quality2 & 0x800 ) == 0x800 ) {
1746 bhit->
setRun( runNumber );
1748 bhit->
setMod( m_tofId2 );
1751 for(
int i=0; i<5; i++ ) {
1752 bhit->
setTpred( i, m_texpOuter[i] );
1754 if( calibData ==
"Dimu" ) {
1765 bhit->
setTdc1( m_tdc3-m_estime );
1766 bhit->
setTdc2( m_tdc4-m_estime );
1773 bhit->
setP( m_momentum );
1774 bhit->
setQ( m_ph2 );
1779 btofCalHitCol->push_back( bhit );
1790 if( ( m_quality1 & 0x800 ) != 0x800 )
return;
1793 chit->
setRun( runNumber );
1795 chit->
setMod( m_tofId1 );
1798 for(
int i=0; i<5; i++ ) {
1799 chit->
setTpred( i, m_texpInner[i] );
1801 if( calibData ==
"Dimu" ) {
1812 chit->
setTdc( m_tdc1-m_estime );
1818 chit->
setQ( m_ph1 );
1819 chit->
setP( m_momentum );
1822 etofCalHitCol->push_back( chit );
double abs(const EvtComplex &c)
bool innerLayer(HoughHit hit1, HoughHit hit2)
ObjectVector< RecBTofCalHit > RecBTofCalHitCol
ObjectVector< RecETofCalHit > RecETofCalHitCol
ObjectVector< RecTofTrack > RecTofTrackCol
std::multimap< unsigned int, TofData * > TofDataMap
std::multimap< unsignedint, TofData * >::iterator IterTofDataMap
const double tof1Path() const
const Hep3Vector tof1Position() const
const int tof1VolumeNumber() const
const double tof1() const
const Hep3Vector tof2Momentum() const
const Hep3Vector tof1Momentum() const
const double tof2() const
const double tof2PosSigmaAlongZ() const
const double tof1PosSigmaAlongX() const
const double tof2Path() const
const int trackId() const
const double tof1PosSigmaAlongY() const
const double tof1PosSigmaAlongZ() const
const int tof2VolumeNumber() const
const Hep3Vector tof2Position() const
void setStatus(unsigned int status)
void setSigma(double sigma[6])
void setToffset(double toffset[6])
void setEnergy(double energy)
void setPath(double path)
void setTofTrackID(int tofTrackID)
void setQuality(int quality)
void setZrHit(double zrhit)
void setErrTof(double etof)
void setErrT0(double errt0)
void setTexp(double texp[5])
void setBeta(double beta)
void setErrEnergy(double errenergy)
void setTrackID(int trackID)
void setErrZ(double errz)
void setErrPhi(double errphi)
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 setdZHit(double dzHit)
void setAdc2(double adc2)
void setTdc1(double tdc1)
void setZHit(double zHit)
void setDeltaPhi(double deltaPhi)
void setTpred(int idx, double t)
void setAdc1(double adc1)
void setdRHit(double drHit)
void setDeltaPhi(double deltaPhi)
void setRHit(double rHit)
void setcosTheta(double cost)
void setTpred(int idx, double t)
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)
static int phi_module(const Identifier &id)
static int barrel_ec(const Identifier &id)
Values of different levels (failure returns 0)
static value_type getIntID(int barrel_ec, int layer, int phi_module, int end)
static int layer(const Identifier &id)
void setTofData(TofDataMap tofDataMap)
std::vector< TofData * > tofData1() const
void setExtTrack(RecExtTrack *extTrack, int kal[5], double t0, int t0Stat)
TofData * chooseTofDataEndcap(std::vector< TofData * > tofDataVec, double zr1[5])
ExtTrackCase hitCase() const
int kal(unsigned int i) const
unsigned int quality1() const
double tof(unsigned int i) const
void convert2RecTofTrackCol(RecTofTrackCol *recTofTrackCol)
void tofDataAnalysis(TofData *tof, unsigned int iflag)
void buildRecTofTrack(RecTofTrack *track, int layerorend)
void getTofData(TofData *tof, unsigned int iflag)
void match(bool forCalibration, std::vector< int > deadId, std::vector< TofTrack * > *&tofTrackVec)
void findTofDataEndcap(std::vector< TofData * > tofDataVec1, std::vector< TofData * > tofDataVec2, double zr1[5])
void setQuality1(int qual1)
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)
void getTofDataNohit(unsigned int iflag)
TofData * chooseTofData(std::vector< TofData * > tofDataVec, double zrhit)
void getTofDataWest(TofData *tof, unsigned int iflag)
void getMultiHit(TofTrack *&)
void setQuality2(int qual2)
TofData * compareTofDataEndcap(TofData *tofData1, TofData *tofData2)
std::vector< TofData * > tofData2() const
unsigned int barrel() const
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)
unsigned int quality2() const