32 for(
unsigned int i=0; i<5; i++ ) {
39 if( m_tofData1.size()>0 ) {
42 if( m_tofData2.size()>0 ) {
45 if( m_tofData3.size()>0 ) {
48 if( m_tofData4.size()>0 ) {
51 if( m_tofData5.size()>0 ) {
54 if( m_tofData6.size()>0 ) {
77 for(
unsigned int i=0; i<5; i++ ) {
108 for(
unsigned int i=0; i<5; i++ ) {
109 m_texpInner[i] = -99.0;
110 m_texpOuter[i] = -99.0;
130 if( m_tofData1.size()>0 ) {
133 if( m_tofData2.size()>0 ) {
136 if( m_tofData3.size()>0 ) {
139 if( m_tofData4.size()>0 ) {
142 if( m_tofData5.size()>0 ) {
145 if( m_tofData6.size()>0 ) {
201 if( iExist1 == -1 ) { iExist1 = 2; }
202 if( iExist2 == -1 ) { iExist2 = 2; }
211 m_id1 =
tofId1 - 176 + 48;
221 m_id1 =
tofId1 - 176 - 48;
231 m_id1 =
tofId1 - 176 - 96;
232 m_istrip1 = m_id1%12;
266 else if( m_hitCase==
NoHit ) {
271 m_id2 =
tofId2 - 176 - 96;
272 m_istrip2 = m_id2%12;
298 m_trackId = extTrack->
trackId();
306 m_path1 = extTrack->
tof1Path(iExist1);
309 for(
unsigned int i=0; i<5; i++ ) {
310 m_texpInner[i] = extTrack->
tof1(i);
311 if( fabs(m_texpInner[i]+99.0)<1.0e-6 ) {
312 double beta =
p[iExist1]/sqrt(
p[iExist1]*
p[iExist1]+
mass[iExist1]*
mass[iExist1]);
313 double betaNew =
p[i]/sqrt(
p[i]*
p[i]+
mass[i]*
mass[i]);
314 m_texpInner[i] = beta*extTrack->
tof1(iExist1)/betaNew;
322 for(
unsigned int i=0; i<5; i++ ) {
325 if( fabs(m_zr1[i]+99.0)<1.0e-6 ) {
327 m_ezr1[i] = m_errzr1;
336 for(
unsigned int i=0; i<5; i++ ) {
339 if( fabs(m_zr1[i]+99.0)<1.0e-6 ) {
341 m_ezr1[i] = m_errzr1;
350 for(
unsigned int i=0; i<5; i++ ) {
353 if( fabs(m_zr1[i]+99.0)<1.0e-6 ) {
355 m_ezr1[i] = m_errzr1;
359 for(
unsigned int i=0; i<5; i++ ) {
360 m_texpOuter[i] = m_texpInner[i] * 136.573/133.673;
367 m_path2 = extTrack->
tof2Path(iExist2);
370 for(
unsigned int i=0; i<5; i++ ) {
371 m_texpOuter[i] = extTrack->
tof2(i);
372 if( fabs(m_texpOuter[i]+99.0)<1.0e-6 ) {
373 double beta =
p[iExist2]/sqrt(
p[iExist2]*
p[iExist2]+
mass[iExist2]*
mass[iExist2]);
374 double betaNew =
p[i]/sqrt(
p[i]*
p[i]+
mass[i]*
mass[i]);
375 m_texpOuter[i] = beta*extTrack->
tof2(iExist2)/betaNew;
383 for(
unsigned int i=0; i<5; i++ ) {
386 if( fabs(m_zr2[i]+99.0)<1.0e-6 ) {
388 m_ezr2[i] = m_errzr2;
397 for(
unsigned int i=0; i<5; i++ ) {
400 if( fabs(m_zr2[i]+99.0)<1.0e-6 ) {
402 m_ezr2[i] = m_errzr2;
406 for(
unsigned int i=0; i<5; i++ ) {
407 m_texpInner[i] = m_texpOuter[i] * 133.673/136.573;
413 if( m_hitCase ==
NoHit ) { m_quality = 11; }
415 for(
unsigned int i=0; i<5; i++ ) {
430 if( (
abs(m_id1-track->
id1())<=1 ) || ( m_id1==0 && track->
id1()==87 ) || ( m_id1==87 && track->
id1()==0 ) ) {
432 m_quality1 = ( m_quality1 | 0x400 );
437 if( (
abs(m_id2-track->
id2())<=1 ) || ( m_id2==88 && track->
id2()==175 ) || ( m_id2==175 && track->
id2()==88 ) ) {
439 m_quality2 = ( m_quality2 | 0x400 );
446 if( (
abs(m_id1-track->
id1())<=1 ) || ( m_id1==0 && track->
id1()==47 ) || ( m_id1==47 && track->
id1()==0 ) ) {
448 m_quality1 = ( m_quality1 | 0x400 );
454 if( (
abs(m_id1-track->
id1())<=1 ) || ( m_id1==48 && track->
id1()==95 ) || ( m_id1==95 && track->
id1()==48 ) ) {
456 m_quality1 = ( m_quality1 | 0x400 );
463 if( ( m_id1==track->
id1() ) &&
abs(m_istrip1-track->
strip1())<=1 ) {
465 m_quality1 = ( m_quality1 | 0x400 );
469 if( ( m_id2==track->
id2() ) &&
abs(m_istrip2-track->
strip2())<=1 ) {
471 m_quality1 = ( m_quality1 | 0x400 );
488 if( m_hitCase ==
NoHit )
return;
490 unsigned int identify[11];
491 unsigned int count[11];
492 for(
unsigned int i=0; i<11; i++ ) {
493 identify[i] = 0x0000c000;
496 unsigned int countTot1 = 0;
497 unsigned int countTot2 = 0;
502 count[0] = tofDataMap.count( identify[0] );
503 int tofid1 = tofid0 - 1;
504 if( tofid1 == -1 ) { tofid1 = 87; }
506 count[1] = tofDataMap.count( identify[1] );
507 int tofid2 = tofid0 + 1;
508 if( tofid2 == 88 ) { tofid2 = 0; }
510 count[2] = tofDataMap.count( identify[2] );
514 unsigned int whichEndcap = 0;
521 count[0] = tofDataMap.count( identify[0] );
522 int tofid1 = tofid0 - 1;
523 if( tofid1 == -1 ) { tofid1 = 47; }
525 count[1] = tofDataMap.count( identify[1] );
526 int tofid2 = tofid0 + 1;
527 if( tofid2 == 48 ) { tofid2 = 0; }
529 count[2] = tofDataMap.count( identify[2] );
534 for( ;
iter != tofDataMap.end();
iter++ ) {
538 if( m_id1 ==
tof->tofId() &&
abs( m_istrip1 -
tof->strip() )<=
abs(m_delStrip1) ) {
539 m_delStrip1 = m_istrip1 -
tof->strip();
541 if( (
abs( m_id1 -
tof->tofId() )==1 || ( m_id1==0 &&
tof->tofId()==35 ) || ( m_id1==35 &&
tof->tofId()==0 ) || ( m_id1==36 &&
tof->tofId()==71 ) || ( m_id1==71 &&
tof->tofId()==36 ) ) &&
abs( m_istrip1 -
tof->strip() )<=
abs(m_delStrip1) ) {
542 m_delStrip2 = m_istrip1 -
tof->strip();
547 unsigned int whichEndcap = 0;
553 int strip0 = m_istrip1;
556 int strip3 = strip0 - 2;
557 int strip4 = strip0 + 2;
558 int tofid1 = tofid0 - 1;
559 if( tofid1 == -1 ) { tofid1 = 35; }
560 int tofid2 = tofid0 + 1;
561 if( tofid2 == 36 ) { tofid2 = 0; }
564 count[0] = tofDataMap.count( identify[0] );
566 count[5] = tofDataMap.count( identify[5] );
568 count[6] = tofDataMap.count( identify[6] );
577 count[1] = tofDataMap.count( identify[1] );
579 count[7] = tofDataMap.count( identify[7] );
581 count[9] = tofDataMap.count( identify[9] );
591 count[2] = tofDataMap.count( identify[2] );
593 count[8] = tofDataMap.count( identify[8] );
595 count[10] = tofDataMap.count( identify[10] );
597 if( strip3 == -1 || strip3 == -2 ) {
count[3] = 0; }
600 count[3] = tofDataMap.count( identify[3] );
602 if( strip4 == 12 || strip4 == 13 ) {
count[4] = 0; }
605 count[4] = tofDataMap.count( identify[4] );
609 for(
unsigned int i=0; i<11; i++ ) {
611 pair< IterTofDataMap, IterTofDataMap > range = tofDataMap.equal_range( identify[i] );
613 for(
unsigned int j=0; j<
count[i]; j++,
iter++ ) {
617 else if( i==1 || i==2 ) {
625 countTot1 = countTot1 +
count[i];
628 if( countTot1 == 0 ) {
641 for(
unsigned int i=0; i<11; i++ ) {
642 identify[i] = 0x0000c000;
646 int tofid0 = m_id2 - 88;
648 count[0] = tofDataMap.count( identify[0] );
649 int tofid1 = tofid0 - 1;
650 if( tofid1 == -1 ) { tofid1 = 87; }
652 count[1] = tofDataMap.count( identify[1] );
653 int tofid2 = tofid0 + 1;
654 if( tofid2 == 88 ) { tofid2 = 0; }
656 count[2] = tofDataMap.count( identify[2] );
658 for(
unsigned int i=0; i<3; i++ ) {
660 pair< IterTofDataMap, IterTofDataMap > range = tofDataMap.equal_range( identify[i] );
662 for(
unsigned int j=0; j<
count[i]; j++,
iter++ ) {
671 countTot2 = countTot2 +
count[i];
674 if( countTot2 == 0 ) {
687 for( ;
iter != tofDataMap.end();
iter++ ) {
691 if( m_id2 ==
tof->tofId() &&
abs( m_istrip2 -
tof->strip() )<=
abs(m_delStrip1) ) {
692 m_delStrip1 = m_istrip2 -
tof->strip();
694 if( (
abs( m_id2 -
tof->tofId() )==1 || ( m_id2==0 &&
tof->tofId()==35 ) || ( m_id2==35 &&
tof->tofId()==0 ) || ( m_id2==36 &&
tof->tofId()==71 ) || ( m_id2==71 &&
tof->tofId()==36 ) ) &&
abs( m_istrip2 -
tof->strip() )<=
abs(m_delStrip2) ) {
695 m_delStrip2 = m_istrip2 -
tof->strip();
700 unsigned int whichEndcap = 0;
706 int strip0 = m_istrip2;
709 int strip3 = strip0 - 2;
710 int strip4 = strip0 + 2;
711 int tofid1 = tofid0 - 1;
712 if( tofid1 == -1 ) { tofid1 = 35; }
713 int tofid2 = tofid0 + 1;
714 if( tofid2 == 36 ) { tofid2 = 0; }
717 count[0] = tofDataMap.count( identify[0] );
719 count[5] = tofDataMap.count( identify[5] );
721 count[6] = tofDataMap.count( identify[6] );
730 count[1] = tofDataMap.count( identify[1] );
732 count[7] = tofDataMap.count( identify[7] );
734 count[9] = tofDataMap.count( identify[9] );
744 count[2] = tofDataMap.count( identify[2] );
746 count[8] = tofDataMap.count( identify[8] );
748 count[10] = tofDataMap.count( identify[10] );
750 if( strip3 == -1 || strip3 == -2 ) {
count[3] = 0; }
753 count[3] = tofDataMap.count( identify[3] );
755 if( strip4 == 12 || strip4 == 13 ) {
count[4] = 0; }
758 count[4] = tofDataMap.count( identify[4] );
761 for(
unsigned int i=0; i<11; i++ ) {
763 pair< IterTofDataMap, IterTofDataMap > range = tofDataMap.equal_range( identify[i] );
765 for(
unsigned int j=0; j<
count[i]; j++,
iter++ ) {
769 else if( i==1 || i==2 ) {
777 countTot2 = countTot2 +
count[i];
781 if( countTot1==0 && countTot2==0 ) {
795 unsigned int qual =
tof->quality();
797 if( ( qual & 0x10 ) == 0 ) {
798 qual = ( qual | 0x10 );
799 if(
tof->barrel() ||
tof->is_mrpc() ) {
800 if( (
tof->quality() == 0x7 ) || (
tof->quality() == 0xd ) ) {
801 qual = ( qual | 0x20 );
804 if( (
tof->quality() == 0xb ) || (
tof->quality() == 0xe ) ) {
805 qual = ( qual | 0x40 );
808 if( (
tof->quality() == 0x3 ) || (
tof->quality() == 0xc ) ) {
809 qual = ( qual | 0x80 );
812 if(
tof->barrel() ) {
813 if( (
tof->quality() & 0x5 ) == 0x5 ) {
815 tof->setZTdc( ztdc );
818 if( (
tof->quality() & 0xa ) == 0xa ) {
820 tof->setZAdc( zadc );
823 if(
tof->is_mrpc() ) {
824 if( (
tof->quality() & 0x5 ) == 0x5 ) {
826 tof->setZTdc( ztdc );
829 tof->setQuality( qual );
832 if( iflag == 1 ) { m_tofData1.push_back(
tof ); }
833 else if( iflag == 2 ) { m_tofData2.push_back(
tof ); }
834 else if( iflag == 3 ) { m_tofData3.push_back(
tof ); }
835 else if( iflag == 4 ) { m_tofData4.push_back(
tof ); }
836 else if( iflag == 5 ) { m_tofData5.push_back(
tof ); }
837 else if( iflag == 6 ) { m_tofData6.push_back(
tof ); }
839 cout <<
"TofRec::TofTrack::TofDataAnalylsis: the Flag should be 1-4, out of the Range!" << endl;
849void TofTrack::match(
bool forCalibration, std::vector<int> deadId, std::vector<TofTrack*>*& tofTrackVec ) {
851 if( m_hitCase ==
NoHit )
return;
855 if( ( m_quality1 & 0x10 ) == 0 ) { m_hitCase =
NoHit; }
859 if( ( m_quality2 & 0x10 ) == 0 ) { m_hitCase =
NoHit; }
863 if( ( m_quality1 & 0x10 ) == 0 ) { m_hitCase =
OuterLayer; }
865 if( ( m_quality2 & 0x10 ) == 0 ) {
873 cout <<
"TofRec::TofTrack::match: 2- Impossible!" << endl;
881 findEtfData( m_tofData1, m_tofData2, m_tofData3, m_zrhit1, 1 );
882 findEtfData( m_tofData4, m_tofData5, m_tofData6, m_zrhit2, 2 );
885 cout <<
"TofRec::TofTrack::match: 1- Impossible!" << endl;
888 if( forCalibration ) {
891 if( ( ( m_quality1 & 0xf ) == 0xf ) && ( ( m_quality2 & 0xf ) == 0xf ) ) {
892 m_quality1 = ( m_quality1 | 0x800 );
893 m_quality2 = ( m_quality2 | 0x800 );
896 std::vector<int>::iterator
iter = deadId.begin();
897 for( ;
iter != deadId.end();
iter++ ) {
905 if( m_tofId1 == tofId ) {
906 if( ( m_quality2 & 0xf ) == 0xf ) {
907 if( ( ( east == 0 ) && ( ( ( m_quality1 & 0xf ) == 0x3 ) || ( ( m_quality1 & 0xf ) == 0x7 ) || ( ( m_quality1 & 0xf ) == 0xb ) ) ) || ( ( east == 1 ) && ( ( ( m_quality1 & 0xf ) == 0xc ) || ( ( m_quality1 & 0xf ) == 0xd ) || ( ( m_quality1 & 0xf ) == 0xe ) ) ) ) {
908 m_quality1 = ( m_quality1 | 0x800 );
909 m_quality2 = ( m_quality2 | 0x800 );
915 else if( layer == 1 ) {
916 if( m_tofId2 == (tofId+88) ) {
917 if( ( m_quality1 & 0xf ) == 0xf ) {
918 if( ( ( east == 0 ) && ( ( ( m_quality2 & 0xf ) == 0x3 ) || ( ( m_quality2 & 0xf ) == 0x7 ) || ( ( m_quality2 & 0xf ) == 0xb ) ) ) || ( ( east == 1 ) && ( ( ( m_quality2 & 0xf ) == 0xc ) || ( ( m_quality2 & 0xf ) == 0xd ) || ( ( m_quality2 & 0xf ) == 0xe ) ) ) ) {
919 m_quality1 = ( m_quality1 | 0x800 );
920 m_quality2 = ( m_quality2 | 0x800 );
931 if( ( m_quality1 & 0xf ) == 0xf ) {
932 m_quality1 = ( m_quality1 | 0x800 );
935 std::vector<int>::iterator
iter = deadId.begin();
936 for( ;
iter != deadId.end();
iter++ ) {
944 if( m_tofId1 == tofId ) {
945 if( ( ( east == 0 ) && ( ( ( m_quality1 & 0xf ) == 0x3 ) || ( ( m_quality1 & 0xf ) == 0x7 ) || ( ( m_quality1 & 0xf ) == 0xb ) ) ) || ( ( east == 1 ) && ( ( ( m_quality1 & 0xf ) == 0xc ) || ( ( m_quality1 & 0xf ) == 0xd ) || ( ( m_quality1 & 0xf ) == 0xe ) ) ) ) {
946 m_quality1 = ( m_quality1 | 0x800 );
956 if( ( ( m_hitCase ==
EastEndcap ) || ( m_hitCase ==
WestEndcap ) ) && ( ( m_quality1 & 0xf ) == 0xc ) ) {
957 m_quality1 = ( m_quality1 | 0x800 );
962 if( ( ( m_quality1 & 0xf000 ) == 0x1000 ) || ( ( m_quality1 & 0xf000 ) == 0x2000 ) ) {
963 if( ( m_quality1 & 0xf ) == 0xf ) {
964 m_quality1 = ( m_quality1 | 0x800 );
967 else if( ( ( m_quality1 & 0xf000 ) == 0x4000 ) ) {
968 std::vector<int>::iterator
iter = deadId.begin();
969 for( ;
iter != deadId.end();
iter++ ) {
971 if( ( m_tofId1==3 && ( m_strip1==1 || m_strip1==3 || ( m_strip1>=5 && m_strip1<=11 ) ) ) || ( m_tofId1==13 && m_strip1==7 ) ) {
972 if( ( m_quality1 & 0xf ) == 0xc ) {
973 m_quality1 = ( m_quality1 | 0x800 );
976 if( m_tofId1==13 && m_strip1==5 ) {
977 if( ( m_quality1 & 0xf ) == 0x3 ) {
978 m_quality1 = ( m_quality1 | 0x800 );
990 if( ( m_tofId1 == ( endcap*36 + tofid ) ) && ( m_strip1 == strip ) ) {
991 if( ( ( east == 0 ) && ( ( ( m_quality1 & 0xf ) == 0x3 ) || ( ( m_quality1 & 0xf ) == 0x7 ) || ( ( m_quality1 & 0xf ) == 0xb ) ) ) || ( ( east == 1 ) && ( ( ( m_quality1 & 0xf ) == 0xc ) || ( ( m_quality1 & 0xf ) == 0xd ) || ( ( m_quality1 & 0xf ) == 0xe ) ) ) ) {
992 m_quality1 = ( m_quality1 | 0x800 );
1000 if( ( ( m_quality2 & 0xf000 ) == 0x1000 ) || ( ( m_quality2 & 0xf000 ) == 0x2000 ) ) {
1001 if( ( m_quality2 & 0xf ) == 0xf ) {
1002 m_quality2 = ( m_quality2 | 0x800 );
1005 else if( ( m_quality2 & 0xf000 ) == 0x4000 ) {
1006 std::vector<int>::iterator
iter = deadId.begin();
1007 for( ;
iter != deadId.end();
iter++ ) {
1009 if( m_tofId2==34 && ( m_strip2>=0 && m_strip1<=5 ) ) {
1010 if( ( m_quality2 & 0xf ) == 0x3 ) {
1011 m_quality2 = ( m_quality2 | 0x800 );
1023 if( ( m_tofId2 == ( endcap*36 + tofid ) ) && ( m_strip2 == strip ) ) {
1024 if( ( ( east == 0 ) && ( ( ( m_quality2 & 0xf ) == 0x3 ) || ( ( m_quality2 & 0xf ) == 0x7 ) || ( ( m_quality2 & 0xf ) == 0xb ) ) ) || ( ( east == 1 ) && ( ( ( m_quality2 & 0xf ) == 0xc ) || ( ( m_quality2 & 0xf ) == 0xd ) || ( ( m_quality2 & 0xf ) == 0xe ) ) ) ) {
1025 m_quality2 = ( m_quality2 | 0x800 );
1043void TofTrack::findTofDataBarrel( std::vector<TofData*> tofDataVec1, std::vector<TofData*> tofDataVec2,
double zrhit,
unsigned int iflag, std::vector<TofTrack*>*& tofTrackVec ) {
1045 unsigned int qual = 0xf;
1047 if( tofDataVec2.size() == 0 ) {
1048 if( tofDataVec1.size() == 0 ) {
1051 else if( tofDataVec1.size() == 1 ) {
1052 std::vector<TofData*>::iterator iter1 = tofDataVec1.begin();
1056 else if( tofDataVec1.size() > 1 ) {
1061 cout <<
"TofRec::TofTrack::findTofDataBarrel: 1- Impossible!" << endl;
1064 else if( ( tofDataVec2.size() == 1 ) ) {
1065 if( tofDataVec1.size() == 0 ) {
1066 std::vector<TofData*>::iterator iter2 = tofDataVec2.begin();
1070 else if( tofDataVec1.size() == 1 ) {
1071 std::vector<TofData*>::iterator iter1 = tofDataVec1.begin();
1072 if( ((*iter1)->quality()&0x1ff)==0x01f &&
abs((*iter1)->ztdc()-zrhit)<
ztdc_Cut ) {
1076 std::vector<TofData*>::iterator iter2 = tofDataVec2.begin();
1081 else if( tofDataVec1.size() > 1 ) {
1087 std::vector<TofData*>::iterator iter2 = tofDataVec2.begin();
1093 cout <<
"TofRec::TofTrack::findTofDataBarrel: 2- Impossible!" << endl;
1096 else if( ( tofDataVec2.size() > 1 ) ) {
1097 if( tofDataVec1.size() == 0 ) {
1101 else if( tofDataVec1.size() == 1 ) {
1102 std::vector<TofData*>::iterator iter1 = tofDataVec1.begin();
1103 if( ((*iter1)->quality()&0x1ff)==0x01f &&
abs((*iter1)->ztdc()-zrhit)<
ztdc_Cut ) {
1112 else if( tofDataVec1.size() > 1 ) {
1124 cout <<
"TofRec::TofTrack::findTofDataBarrel: 3- Impossible!" << endl;
1129 if( !(
tof->used()) ) {
1133 bool z1=
false, z2=
false;
1134 bool zc1=
false, zc2=
false;
1138 zc1 = ( m_zrhit1 >
tof->ztdc() );
1139 std::vector<TofTrack*>::iterator
iter = tofTrackVec->begin();
1140 for( ;
iter!=tofTrackVec->end();
iter++ ) {
1142 if(
tof->tofId()==(*iter)->tofId1() ) {
1145 zc2 = ( (*iter)->zrhit1() >
tof->ztdc() );
1149 else if( iflag==2 ) {
1151 zc1 = ( m_zrhit2 >
tof->ztdc() );
1152 std::vector<TofTrack*>::iterator
iter = tofTrackVec->begin();
1153 for( ;
iter!=tofTrackVec->end();
iter++ ) {
1155 if(
tof->tofId()==(*iter)->tofId2() ) {
1158 zc2 = ( (*iter)->zrhit2() >
tof->ztdc() );
1163 if( ( z1 && z2 )||( (!z1) && (!z2) ) ) {
1168 else if( !zc1 && zc2 ) {
1173 else if( z1 && !z2 ) {
1177 else if( !z1 && z2 ) {
1184 if( ( iflag == 1 ) || ( iflag == 3 ) ) {
1185 m_quality1 = ( m_quality1 | 0x300 );
1187 else if( iflag == 2 ) {
1188 m_quality2 = ( m_quality2 | 0x300 );
1191 cout <<
"TofRec::TofTrack::findTofDataBarrel: the 1- IFLAG is Out of Range!" << endl;
1195 qual = ( qual << 12 );
1196 if( ( iflag == 1 ) || ( iflag == 3 ) ) {
1197 m_quality1 = ( m_quality1 | qual );
1199 else if( iflag == 2 ) {
1200 m_quality2 = ( m_quality2 | qual );
1203 cout <<
"TofRec::TofTrack::findTofDataBarrel: the 2- IFLAG is Out of Range!" << endl;
1216 if( tofDataVec.size() == 0 ) {
1217 cout <<
"TofRec::TofTrack::ChooseTofData: Size of TofData Vector is Zero!" << endl;
1220 std::vector<TofData*>::iterator igood = tofDataVec.begin();
1221 if( tofDataVec.size() > 1 ) {
1222 double deltaZ = 1000.0;
1223 std::vector<TofData*>::iterator
iter = tofDataVec.begin();
1225 for( ;
iter != tofDataVec.end();
iter++ ) {
1226 if( ( (*iter)->quality() & 0x5 ) == 0x5 ) {
1227 if(
abs( (*iter)->ztdc() - zrhit ) < deltaZ ) {
1228 deltaZ =
abs( (*iter)->ztdc() - zrhit );
1234 if( deltaZ > 999.0 ) {
1235 iter = tofDataVec.begin();
1236 for( ;
iter != tofDataVec.end();
iter++ ) {
1237 if( ( (*iter)->quality() & 0xa ) == 0xa ) {
1238 if(
abs( (*iter)->zadc() - zrhit ) < deltaZ ) {
1239 deltaZ =
abs( (*iter)->zadc() - zrhit );
1246 if( deltaZ > 999.0 ) {
1247 unsigned int ibad = 0xf0;
1248 iter = tofDataVec.begin();
1249 for( ;
iter != tofDataVec.end();
iter++ ) {
1250 if( ( (*iter)->quality() & 0xf0 ) < ibad ) {
1252 ibad = ( (*iter)->quality() & 0xf0 );
1254 else if( ( (*iter)->quality() & 0xf0 ) == ibad ) {
1255 if( ( (*iter)->adc1() + (*iter)->adc2() ) > ( (*igood)->adc1() + (*igood)->adc2() ) ) {
1257 ibad = ( (*iter)->quality() & 0xf0 );
1296 unsigned int iflag = 3;
1297 unsigned int qual = 0xf;
1299 if( tofDataVec2.size() == 0 ) {
1300 if( tofDataVec1.size() == 0 ) {
1303 else if( tofDataVec1.size() == 1 ) {
1304 std::vector<TofData*>::iterator iter1 = tofDataVec1.begin();
1308 else if( tofDataVec1.size() > 1 ) {
1313 cout <<
"TofRec::TofTrack::findTofDataEndcap: 1- Impossible!" << endl;
1316 else if( ( tofDataVec2.size() == 1 ) ) {
1317 if( tofDataVec1.size() == 0 ) {
1318 std::vector<TofData*>::iterator iter2 = tofDataVec2.begin();
1322 else if( tofDataVec1.size() == 1 ) {
1323 std::vector<TofData*>::iterator iter1 = tofDataVec1.begin();
1324 std::vector<TofData*>::iterator iter2 = tofDataVec2.begin();
1328 else if( tofDataVec1.size() > 1 ) {
1330 std::vector<TofData*>::iterator iter2 = tofDataVec2.begin();
1335 cout <<
"TofRec::TofTrack::findTofDataBarrel: 2- Impossible!" << endl;
1338 else if( ( tofDataVec2.size() > 1 ) ) {
1339 if( tofDataVec1.size() == 0 ) {
1343 else if( tofDataVec1.size() == 1 ) {
1344 std::vector<TofData*>::iterator iter1 = tofDataVec1.begin();
1349 else if( tofDataVec1.size() > 1 ) {
1356 cout <<
"TofRec::TofTrack::findTofDataBarrel: 3- Impossible!" << endl;
1361 m_quality1 = ( m_quality1 | 0x300 );
1364 qual = ( qual << 12 );
1365 m_quality1 = ( m_quality1 | qual );
1376 if( tofDataVec.size() == 0 ) {
1377 cout <<
"TofRec::TofTrack::ChooseTofData: Size of TofData Vector is Zero!" << endl;
1380 std::vector<TofData*>::iterator igood = tofDataVec.begin();
1381 if( tofDataVec.size() > 1 ) {
1382 bool multihit =
false;
1383 std::vector<TofData*>::iterator
iter = tofDataVec.begin();
1384 for( ;
iter != tofDataVec.end();
iter++ ) {
1385 if( (*iter)->qtimes1()>1 ) { multihit =
true; }
1387 iter = tofDataVec.begin();
1389 double tcorr = -999.0;
1390 double deltaTMin = 999.0;
1391 for( ;
iter != tofDataVec.end();
iter++ ) {
1392 tcorr =
tofCaliSvc->
ETime( (*iter)->adc(), (*iter)->tdc()-m_estime,
zr1[2], (*iter)->tofId() );
1393 for(
unsigned int i=0; i<5; i++ ) {
1394 if(
abs(tcorr-m_texpInner[i]) < deltaTMin ) {
1395 deltaTMin =
abs(tcorr-m_texpInner[i]);
1403 for( ;
iter != tofDataVec.end();
iter++ ) {
1404 if( (*iter)->adc() > maxQ ) {
1405 maxQ = (*iter)->adc();
1431void TofTrack::findEtfData( std::vector<TofData*> tofDataVec1, std::vector<TofData*> tofDataVec2, std::vector<TofData*> tofDataVec3,
double zrhit,
unsigned int iflag ) {
1437 bool findSignal =
false;
1439 if( tofDataVec1.size()==0 && tofDataVec2.size()==0 && tofDataVec3.size()==0 ) {
1441 m_quality1 = ( m_quality1 | 0x300 );
1443 else if( iflag == 2 ) {
1444 m_quality2 = ( m_quality2 | 0x300 );
1448 if( tofDataVec1.size()>0 ) {
1450 if( (
tof1->quality() & 0xf ) == 0xf ) {
1455 if( !findSignal && tofDataVec2.size() > 0 ) {
1457 if( (
tof2->quality() & 0xf ) == 0xf ) {
1462 if( !findSignal && tofDataVec3.size() > 0 ) {
1464 if( ( tof3->
quality() & 0xf ) == 0xf ) {
1469 if( !findSignal && tofDataVec1.size()>0 ) {
1470 if( ( (
tof1->quality() & 0xf ) == 0xc ) || ( (
tof1->quality() & 0xf ) == 0x3 ) ) {
1475 if( !findSignal && tofDataVec2.size() > 0 ) {
1476 if( ( (
tof2->quality() & 0xf ) == 0xc ) || ( (
tof2->quality() & 0xf ) == 0x3 ) ) {
1481 if( !findSignal && tofDataVec3.size() > 0 ) {
1482 if( ( ( tof3->
quality() & 0xf ) == 0xc ) || ( ( tof3->
quality() & 0xf ) == 0x3 ) ) {
1489 m_quality1 = ( m_quality1 | 0x300 );
1491 else if( iflag == 2 ) {
1492 m_quality2 = ( m_quality2 | 0x300 );
1504 if( tofDataVec.size() == 0 ) {
1507 std::vector<TofData*>::iterator igood = tofDataVec.begin();
1508 if( tofDataVec.size() == 1 ) {
1511 else if( tofDataVec.size() > 1 ) {
1512 double deltaZ = 1000.0;
1513 std::vector<TofData*>::iterator
iter = tofDataVec.begin();
1514 for( ;
iter != tofDataVec.end();
iter++ ) {
1515 if( ( (*iter)->quality() & 0xf ) == 0xf ) {
1516 if(
abs( (*iter)->ztdc() - zrhit ) < deltaZ ) {
1517 deltaZ =
abs( (*iter)->ztdc() - zrhit );
1523 if( deltaZ > 999.0 ) {
1525 iter = tofDataVec.begin();
1526 for( ;
iter != tofDataVec.end();
iter++ ) {
1527 if( ( (*iter)->quality() & 0xc ) == 0xc ) {
1528 if( (*iter)->adc1() > maxQ ) {
1529 maxQ = (*iter)->adc1();
1533 else if( ( (*iter)->quality() & 0x3 ) == 0x3 ) {
1534 if( (*iter)->adc2() > maxQ ) {
1535 maxQ = (*iter)->adc2();
1550 if( tofDataVec.size() == 0 ) {
1553 std::vector<TofData*>::iterator igood = tofDataVec.begin();
1554 if( tofDataVec.size() == 1 ) {
1557 else if( tofDataVec.size() > 1 ) {
1559 std::vector<TofData*>::iterator
iter = tofDataVec.begin();
1560 for( ;
iter != tofDataVec.end();
iter++ ) {
1561 if( ( (*iter)->quality() & 0xc ) == 0xc ) {
1562 if( (*iter)->adc1() > maxQ ) {
1563 maxQ = (*iter)->adc1();
1567 else if( ( (*iter)->quality() & 0x3 ) == 0x3 ) {
1568 if( (*iter)->adc2() > maxQ ) {
1569 maxQ = (*iter)->adc2();
1585 m_tofId1 =
tof->tofId();
1586 m_strip1 =
tof->strip();
1588 m_qch1 =
tof->qtc1();
1591 m_qch1 =
tof->adcChannelEast();
1593 m_adc1 =
tof->adc1();
1594 m_tdc1 =
tof->tdc1();
1596 m_qch2 =
tof->qtc2();
1599 m_qch2 =
tof->adcChannelWest();
1601 m_adc2 =
tof->adc2();
1602 m_tdc2 =
tof->tdc2();
1603 m_ztdc1 =
tof->ztdc();
1604 m_zadc1 =
tof->zadc();
1605 m_quality1 = ( m_quality1 | ( 0x1f &
tof->quality() ) );
1606 if( ( (
tof->quality() & 0x5 ) != 0x5 ) || ( ( (
tof->quality() & 0x5 ) == 0x5 ) && (
abs(
tof->ztdc() - m_zrhit1 ) >
ztdc_Cut ) ) ) {
1607 m_quality1 = ( m_quality1 | 0x100 );
1609 if( ( (
tof->quality() & 0xa ) != 0xa ) || ( ( (
tof->quality() & 0xa ) == 0xa ) && (
abs(
tof->zadc() - m_zrhit1 ) >
zadc_Cut ) ) ) {
1610 m_quality1 = ( m_quality1 | 0x200 );
1613 else if( iflag == 2 ) {
1614 m_tofId2 =
tof->tofId();
1615 m_strip2 =
tof->strip();
1617 m_qch3 =
tof->qtc1();
1620 m_qch3 =
tof->adcChannelEast();
1622 m_adc3 =
tof->adc1();
1623 m_tdc3 =
tof->tdc1();
1625 m_qch4 =
tof->qtc2();
1628 m_qch4 =
tof->adcChannelWest();
1630 m_adc4 =
tof->adc2();
1631 m_tdc4 =
tof->tdc2();
1632 m_ztdc2 =
tof->ztdc();
1633 m_zadc2 =
tof->zadc();
1634 m_quality2 = ( m_quality2 | ( 0x1f &
tof->quality() ) );
1635 if( ( (
tof->quality() & 0x5 ) != 0x5 ) || ( ( (
tof->quality() & 0x5 ) == 0x5 ) && (
abs(
tof->ztdc() - m_zrhit2 ) >
ztdc_Cut ) ) ) {
1636 m_quality2 = ( m_quality2 | 0x100 );
1638 if( ( (
tof->quality() & 0xa ) != 0xa ) || ( ( (
tof->quality() & 0xa ) == 0xa ) && (
abs(
tof->zadc() - m_zrhit2 ) >
zadc_Cut ) ) ) {
1639 m_quality2 = ( m_quality2 | 0x200 );
1642 else if( iflag == 3 ) {
1643 m_tofId1 =
tof->tofId();
1645 m_qch1 =
tof->qtc();
1648 m_qch1 =
tof->adcChannel();
1650 m_adc1 =
tof->adc();
1651 m_tdc1 =
tof->tdc();
1652 m_quality1 = ( m_quality1 | ( 0x1f &
tof->quality() ) );
1653 m_quality1 = ( m_quality1 | 0x300 );
1656 cout <<
"TofRec::TofTrack::getTofData: Flag which sign the Barrel/Endcap or Inner/Outer is wrong! Please check it!" << endl;
1669 m_tofId1 =
tof->tofId();
1670 m_strip1 =
tof->strip();
1672 m_qch1 =
tof->qtc1();
1675 m_qch1 =
tof->adcChannelEast();
1677 m_adc1 =
tof->adc1();
1678 m_tdc1 =
tof->tdc1();
1682 m_ztdc1 =
tof->ztdc();
1683 m_zadc1 =
tof->zadc();
1684 m_quality1 = ( ( m_quality1 & 0xfffffff0 ) | ( 0x1c &
tof->quality() ) );
1685 if( ( (
tof->quality() & 0x5 ) != 0x5 ) || ( ( (
tof->quality() & 0x5 ) == 0x5 ) && (
abs(
tof->ztdc() - m_zrhit1 ) >
ztdc_Cut ) ) ) {
1686 m_quality1 = ( m_quality1 | 0x100 );
1688 if( ( (
tof->quality() & 0xa ) != 0xa ) || ( ( (
tof->quality() & 0xa ) == 0xa ) && (
abs(
tof->zadc() - m_zrhit1 ) >
zadc_Cut ) ) ) {
1689 m_quality1 = ( m_quality1 | 0x200 );
1692 else if( iflag == 2 ) {
1693 m_tofId2 =
tof->tofId();
1695 m_qch3 =
tof->qtc1();
1698 m_qch3 =
tof->adcChannelEast();
1700 m_adc3 =
tof->adc1();
1701 m_tdc3 =
tof->tdc1();
1705 m_ztdc2 =
tof->ztdc();
1706 m_zadc2 =
tof->zadc();
1707 m_quality2 = ( ( m_quality2 & 0xfffffff0 ) | ( 0x1c &
tof->quality() ) );
1708 if( ( (
tof->quality() & 0x5 ) != 0x5 ) || ( ( (
tof->quality() & 0x5 ) == 0x5 ) && (
abs(
tof->ztdc() - m_zrhit2 ) >
ztdc_Cut ) ) ) {
1709 m_quality2 = ( m_quality2 | 0x100 );
1711 if( ( (
tof->quality() & 0xa ) != 0xa ) || ( ( (
tof->quality() & 0xa ) == 0xa ) && (
abs(
tof->zadc() - m_zrhit2 ) >
zadc_Cut ) ) ) {
1712 m_quality2 = ( m_quality2 | 0x200 );
1716 cout <<
"TofRec::TofTrack::getTofDataEast: Flag which sign the Barrel/Endcap or Inner/Outer is wrong! Please check it!" << endl;
1729 m_tofId1 =
tof->tofId();
1730 m_strip1 =
tof->strip();
1735 m_qch2 =
tof->qtc2();
1738 m_qch2 =
tof->adcChannelWest();
1740 m_adc2 =
tof->adc2();
1741 m_tdc2 =
tof->tdc2();
1742 m_ztdc1 =
tof->ztdc();
1743 m_zadc1 =
tof->zadc();
1744 m_quality1 = ( ( m_quality1 & 0xfffffff0 ) | ( 0x13 &
tof->quality() ) );
1745 if( ( (
tof->quality() & 0x5 ) != 0x5 ) || ( ( (
tof->quality() & 0x5 ) == 0x5 ) && (
abs(
tof->ztdc() - m_zrhit1 ) >
ztdc_Cut ) ) ) {
1746 m_quality1 = ( m_quality1 | 0x100 );
1748 if( ( (
tof->quality() & 0xa ) != 0xa ) || ( ( (
tof->quality() & 0xa ) == 0xa ) && (
abs(
tof->zadc() - m_zrhit1 ) >
zadc_Cut ) ) ) {
1749 m_quality1 = ( m_quality1 | 0x200 );
1752 else if( iflag == 2 ) {
1753 m_tofId2 =
tof->tofId();
1758 m_qch4 =
tof->qtc2();
1761 m_qch4 =
tof->adcChannelWest();
1763 m_adc4 =
tof->adc2();
1764 m_tdc4 =
tof->tdc2();
1765 m_ztdc2 =
tof->ztdc();
1766 m_zadc2 =
tof->zadc();
1767 m_quality2 = ( ( m_quality2 & 0xfffffff0 ) | ( 0x13 &
tof->quality() ) );
1768 if( ( (
tof->quality() & 0x5 ) != 0x5 ) || ( ( (
tof->quality() & 0x5 ) == 0x5 ) && (
abs(
tof->ztdc() - m_zrhit2 ) >
ztdc_Cut ) ) ) {
1769 m_quality2 = ( m_quality2 | 0x100 );
1771 if( ( (
tof->quality() & 0xa ) != 0xa ) || ( ( (
tof->quality() & 0xa ) == 0xa ) && (
abs(
tof->zadc() - m_zrhit2 ) >
zadc_Cut ) ) ) {
1772 m_quality2 = ( m_quality2 | 0x200 );
1776 cout <<
"TofRec::TofTrack::getTofDataWest: Flag which sign the Barrel/Endcap or Inner/Outer is wrong! Please check it!" << endl;
1799 m_quality1 = ( m_quality1 & 0x700 );
1803 else if( iflag == 2 ) {
1813 m_quality2 = ( m_quality2 & 0x700 );
1818 cout <<
"TofRec::TofTrack::getTofData: Flag which sign the Barrel/Endcap or Inner/Outer is wrong! Please check it!" << endl;
1830 if( iflag == 1 &&
tof->tofId() != m_id2 ) {
1831 m_tofId1 =
tof->tofId();
1832 m_strip1 =
tof->strip();
1833 m_qch1 =
tof->adcChannelEast();
1834 m_adc1 =
tof->adc1();
1835 m_tdc1 =
tof->tdc1();
1836 m_qch2 =
tof->adcChannelWest();
1837 m_adc2 =
tof->adc2();
1838 m_tdc2 =
tof->tdc2();
1839 m_ztdc1 =
tof->ztdc();
1840 m_zadc1 =
tof->zadc();
1841 m_quality1 = ( m_quality1 | ( 0x1f &
tof->quality() ) );
1842 if( ( (
tof->quality() & 0x5 ) != 0x5 ) || ( ( (
tof->quality() & 0x5 ) == 0x5 ) && (
abs(
tof->ztdc() - m_zrhit1 ) >
ztdc_Cut ) ) ) {
1843 m_quality1 = ( m_quality1 | 0x100 );
1845 if( ( (
tof->quality() & 0xa ) != 0xa ) || ( ( (
tof->quality() & 0xa ) == 0xa ) && (
abs(
tof->zadc() - m_zrhit1 ) >
zadc_Cut ) ) ) {
1846 m_quality1 = ( m_quality1 | 0x200 );
1848 m_quality1 = ( m_quality1 | ( qual << 12 ) );
1850 if(
abs(
tof->tofId()-m_id1)== 1 || (
tof->tofId()==0 && m_id1==35 ) || (
tof->tofId()==35 && m_id1==0 ) || (
tof->tofId()==36 && m_id1==71 ) || (
tof->tofId()==71 && m_id1==36 ) ) {
1851 for(
unsigned int i=0; i<5; i++ ) {
1852 m_texpInner[i] = m_texpOuter[i];
1856 else if( iflag == 2 &&
tof->tofId() != m_id1 ) {
1857 m_tofId2 =
tof->tofId();
1858 m_strip2 =
tof->strip();
1859 m_qch3 =
tof->adcChannelEast();
1860 m_adc3 =
tof->adc1();
1861 m_tdc3 =
tof->tdc1();
1862 m_qch4 =
tof->adcChannelWest();
1863 m_adc4 =
tof->adc2();
1864 m_tdc4 =
tof->tdc2();
1865 m_ztdc2 =
tof->ztdc();
1866 m_zadc2 =
tof->zadc();
1867 m_quality2 = ( m_quality2 | ( 0x1f &
tof->quality() ) );
1868 if( ( (
tof->quality() & 0x5 ) != 0x5 ) || ( ( (
tof->quality() & 0x5 ) == 0x5 ) && (
abs(
tof->ztdc() - m_zrhit2 ) >
ztdc_Cut ) ) ) {
1869 m_quality2 = ( m_quality2 | 0x100 );
1871 if( ( (
tof->quality() & 0xa ) != 0xa ) || ( ( (
tof->quality() & 0xa ) == 0xa ) && (
abs(
tof->zadc() - m_zrhit2 ) >
zadc_Cut ) ) ) {
1872 m_quality2 = ( m_quality2 | 0x200 );
1874 m_quality2 = ( m_quality2 | ( qual << 12 ) );
1876 if(
abs(
tof->tofId()-m_id2)== 1 || (
tof->tofId()==0 && m_id2==35 ) || (
tof->tofId()==35 && m_id2==0 ) || (
tof->tofId()==36 && m_id2==71 ) || (
tof->tofId()==71 && m_id2==36 ) ) {
1877 for(
unsigned int i=0; i<5; i++ ) {
1878 m_texpOuter[i] = m_texpInner[i];
1898 bool innerEast = ( ( m_quality1 & 0xc ) == 0xc );
1899 bool innerWest = ( ( m_quality1 & 0x3 ) == 0x3 );
1900 bool outerEast = ( ( m_quality2 & 0xc ) == 0xc );
1901 bool outerWest = ( ( m_quality2 & 0x3 ) == 0x3 );
1902 bool innerLayer = ( ( m_quality1 & 0xf ) == 0xf );
1903 bool outerLayer = ( ( m_quality2 & 0xf ) == 0xf );
1905 bool endcapData = ( ( m_quality1 & 0xc ) == 0xc );
1908 for(
unsigned int i=0; i<5; i++ ) {
1909 m_texp[i] =
tofCaliSvc->
BTimeCluster( m_texpInner[i], m_texpOuter[i], m_zr1[i], m_zr2[i], m_tofId1, m_tofId2 );
1916 for(
unsigned int i=0; i<5; i++ ) {
1917 m_tof11[i] =
tofCaliSvc->
BTime1( m_adc1, m_tdc1-m_estime, m_zr1[i], m_tofId1, m_estime );
1924 for(
unsigned int i=0; i<5; i++ ) {
1925 m_tof12[i] =
tofCaliSvc->
BTime2( m_adc2, m_tdc2-m_estime, m_zr1[i], m_tofId1, m_estime );
1932 for(
unsigned int i=0; i<5; i++ ) {
1940 for(
unsigned int i=0; i<5; i++ ) {
1941 m_tof21[i] =
tofCaliSvc->
BTime1( m_adc3, m_tdc3-m_estime, m_zr2[i], m_tofId2, m_estime );
1948 for(
unsigned int i=0; i<5; i++ ) {
1949 m_tof22[i] =
tofCaliSvc->
BTime2( m_adc4, m_tdc4-m_estime, m_zr2[i], m_tofId2, m_estime );
1956 for(
unsigned int i=0; i<5; i++ ) {
1963 if( innerLayer && outerLayer ) {
1964 for(
unsigned int i=0; i<5; i++ ) {
1974 for(
unsigned int i=0; i<5; i++ ) {
1975 m_tof11[i] =
tofCaliSvc->
ETime( m_adc1, m_tdc1-m_estime, m_zr1[i], m_tofId1 );
1980 if( (m_quality1&0xa000)!=0 ) { m_quality = 4; }
1987 for(
unsigned int i=0; i<5; i++ ) {
1989 m_tof11[i] =
tofCaliSvc->
EtfTime1( m_adc1, m_tdc1-m_estime, m_zr1[i], m_tofId1, m_strip1, m_estime );
1992 m_tof11[i] =
tofCaliSvc->
EtfTimeMC1( m_adc1, m_tdc1-m_estime, m_zr1[i], m_tofId1, m_strip1, m_estime );
2000 for(
unsigned int i=0; i<5; i++ ) {
2002 m_tof12[i] =
tofCaliSvc->
EtfTime2( m_adc2, m_tdc2-m_estime, m_zr1[i], m_tofId1, m_strip1, m_estime );
2005 m_tof12[i] =
tofCaliSvc->
EtfTimeMC2( m_adc2, m_tdc2-m_estime, m_zr1[i], m_tofId1, m_strip1, m_estime );
2013 for(
unsigned int i=0; i<5; i++ ) {
2015 m_tof21[i] =
tofCaliSvc->
EtfTime1( m_adc3, m_tdc3-m_estime, m_zr2[i], m_tofId2, m_strip2, m_estime );
2018 m_tof21[i] =
tofCaliSvc->
EtfTimeMC1( m_adc3, m_tdc3-m_estime, m_zr2[i], m_tofId2, m_strip2, m_estime );
2026 for(
unsigned int i=0; i<5; i++ ) {
2028 m_tof22[i] =
tofCaliSvc->
EtfTime2( m_adc4, m_tdc4-m_estime, m_zr2[i], m_tofId2, m_strip2, m_estime );
2031 m_tof22[i] =
tofCaliSvc->
EtfTimeMC2( m_adc4, m_tdc4-m_estime, m_zr2[i], m_tofId2, m_strip2, m_estime );
2047 for(
unsigned int i=1; i<5; i++ ) {
2048 m_tof1[i] = m_tof1[0];
2050 m_ph1 = ( m_adc1 + m_adc2 )/2.0;
2062 for(
unsigned int i=1; i<5; i++ ) {
2063 m_tof2[i] = m_tof2[0];
2065 m_ph2 = ( m_adc3 + m_adc4 )/2.0;
2074 if( innerLayer && outerLayer ) {
2079 if( innerLayer || outerLayer ) {
2084 if( innerEast || innerWest || outerEast || outerWest ) {
2091 if( ( (m_quality1&0xa000)!=0 ) || ( (m_quality2&0xa000)!=0 ) ) {
2092 m_quality = m_quality + 3;
2096 if( ( (m_quality1&0x100)==0x100 ) || ( (m_quality2&0x100)==0x100 ) ) {
2097 if( ( m_quality == 1 ) || ( m_quality == 4 ) ) { m_quality = 7; }
2098 else if( ( m_quality == 2 ) || ( m_quality == 5 ) ) { m_quality = 8; }
2099 else if( ( m_quality == 3 ) || ( m_quality == 6 ) ) { m_quality = 9; }
2101 cout <<
"TofRec::TofTrack::setCalibration: Impossible!" << endl;
2118 bool innerEast = ( ( m_quality1 & 0xc ) == 0xc );
2119 bool innerWest = ( ( m_quality1 & 0x3 ) == 0x3 );
2120 bool outerEast = ( ( m_quality2 & 0xc ) == 0xc );
2121 bool outerWest = ( ( m_quality2 & 0x3 ) == 0x3 );
2137 if( outerEast && outerWest ) {
2145 cout <<
"TofRec::TofTrack:convert2RecTofTrackCol: 11- Impossible!" << endl;
2150 recTofTrackCol->push_back( atrack11 );
2165 if( outerEast && outerWest ) {
2173 cout <<
"TofRec::TofTrack:convert2RecTofTrackCol: 12- Impossible!" << endl;
2178 recTofTrackCol->push_back( atrack12 );
2181 if( innerEast && innerWest ) {
2189 if( outerEast && outerWest ) {
2197 cout <<
"TofRec::TofTrack:convert2RecTofTrackCol: 1- Impossible!" << endl;
2201 recTofTrackCol->push_back( atrack1 );
2216 if( innerEast || innerWest ) {
2224 cout <<
"TofRec::TofTrack:convert2RecTofTrackCol: 21- Impossible!" << endl;
2229 recTofTrackCol->push_back( atrack21 );
2244 if( innerEast || innerWest ) {
2252 cout <<
"TofRec::TofTrack:convert2RecTofTrackCol: 22- Impossible!" << endl;
2257 recTofTrackCol->push_back( atrack22 );
2260 if( outerEast && outerWest ) {
2268 if( innerEast && innerWest ) {
2276 cout <<
"TofRec::TofTrack:convert2RecTofTrackCol: 2- Impossible!" << endl;
2280 recTofTrackCol->push_back( atrack2 );
2283 if( innerEast && innerWest && outerEast && outerWest ) {
2290 recTofTrackCol->push_back( atrack );
2306 cout <<
"TofRec::TofTrack:convert2RecTofTrackCol: endcap- Impossible!" << endl;
2310 recTofTrackCol->push_back( atrack );
2315 if( innerEast || innerWest ) {
2329 recTofTrackCol->push_back( atrack1 );
2344 recTofTrackCol->push_back( atrack2 );
2347 if( innerEast && innerWest ) {
2359 recTofTrackCol->push_back( atrack );
2377 recTofTrackCol->push_back( atrack1 );
2392 recTofTrackCol->push_back( atrack2 );
2395 if( outerEast && outerWest ) {
2407 recTofTrackCol->push_back( atrack );
2414 if( m_hitCase ==
NoHit ) {
2421 recTofTrackCol->push_back( atrack );
2438 for(
int i=0; i<6; i++ ) {
2443 track->
setT0( m_estime );
2450 if( ( layerorend == 11 ) || ( layerorend == 12 ) || ( layerorend == 1 ) ) {
2455 track->
setTofID( 12*m_tofId1+m_strip1 );
2460 track->
setTexp( m_texpInner );
2465 if( ( layerorend==21 ) || ( layerorend==22 ) || ( layerorend==2 ) ) {
2470 track->
setTofID( 12*m_tofId2+m_strip2 );
2475 track->
setTexp( m_texpOuter );
2480 if( layerorend==0 ) {
2490 if( layerorend == 3 ) {
2495 track->
setTofID( 12*m_id1 + m_strip1 );
2500 track->
setTexp( m_texpInner );
2510 for(
unsigned int i=0; i<6; i++ ) {
2514 if( layerorend == 0 ) {
2515 track->
setPh( m_ph );
2516 track->
setTof( m_tof[0] );
2518 for(
unsigned int i=0; i<5; i++ ) {
2519 toffset[i] = m_tof[0] - m_tof[i];
2522 track->
setBeta( m_path/m_tof[0]/30.0 );
2524 else if( layerorend == 1 ) {
2525 track->
setPh( m_ph1 );
2526 track->
setTof( m_tof1[0] );
2528 for(
unsigned int i=0; i<5; i++ ) {
2529 toffset[i] = m_tof1[0] - m_tof1[i];
2532 track->
setBeta( m_path1/m_tof1[0]/30.0 );
2534 else if( layerorend == 2 ) {
2535 track->
setPh( m_ph2 );
2536 track->
setTof( m_tof2[0] );
2538 for(
unsigned int i=0; i<5; i++ ) {
2539 toffset[i] = m_tof2[0] - m_tof2[i];
2542 track->
setBeta( m_path2/m_tof2[0]/30.0 );
2544 else if( layerorend == 11 ) {
2545 track->
setPh( m_ph11 );
2546 track->
setTof( m_tof11[0] );
2548 for(
unsigned int i=0; i<5; i++ ) {
2549 toffset[i] = m_tof11[0] - m_tof11[i];
2552 track->
setBeta( m_path1/m_tof11[0]/30.0 );
2554 else if( layerorend == 12 ) {
2555 track->
setPh( m_ph12 );
2556 track->
setTof( m_tof12[0] );
2558 for(
unsigned int i=0; i<5; i++ ) {
2559 toffset[i] = m_tof12[0] - m_tof12[i];
2562 track->
setBeta( m_path1/m_tof12[0]/30.0 );
2564 else if( layerorend == 21 ) {
2565 track->
setPh( m_ph21 );
2566 track->
setTof( m_tof21[0] );
2568 for(
unsigned int i=0; i<5; i++ ) {
2569 toffset[i] = m_tof21[0] - m_tof21[i];
2572 track->
setBeta( m_path2/m_tof21[0]/30.0 );
2574 else if( layerorend == 22 ) {
2575 track->
setPh( m_ph22 );
2576 track->
setTof( m_tof22[0] );
2578 for(
unsigned int i=0; i<5; i++ ) {
2579 toffset[i] = m_tof22[0] - m_tof22[i];
2582 track->
setBeta( m_path2/m_tof22[0]/30.0 );
2585 cout <<
"TofRec TofTrack::SetRecTofTrack layerorend = " << layerorend << endl;
2593 if( ( m_quality1 & 0x800 ) == 0x800 ) {
2596 ahit->
setRun( runNumber );
2598 ahit->
setMod( m_tofId1 );
2602 for(
int i=0; i<5; i++ ) {
2603 ahit->
setTpred( i, m_texpInner[i] );
2605 if( calibData ==
"Dimu" ) {
2616 ahit->
setTdc1( m_tdc1-m_estime );
2617 ahit->
setTdc2( m_tdc2-m_estime );
2624 ahit->
setP( m_momentum );
2625 ahit->
setQ( m_ph1 );
2628 btofCalHitCol->push_back( ahit );
2630 if( ( m_quality2 & 0x800 ) == 0x800 ) {
2633 bhit->
setRun( runNumber );
2635 bhit->
setMod( m_tofId2 );
2639 for(
int i=0; i<5; i++ ) {
2640 bhit->
setTpred( i, m_texpOuter[i] );
2642 if( calibData ==
"Dimu" ) {
2653 bhit->
setTdc1( m_tdc3-m_estime );
2654 bhit->
setTdc2( m_tdc4-m_estime );
2661 bhit->
setP( m_momentum );
2662 bhit->
setQ( m_ph2 );
2667 btofCalHitCol->push_back( bhit );
2678 if( ( m_quality1 & 0x800 ) != 0x800 )
return;
2681 chit->
setRun( runNumber );
2683 chit->
setMod( m_tofId1 );
2686 for(
int i=0; i<5; i++ ) {
2687 chit->
setTpred( i, m_texpInner[i] );
2689 if( calibData ==
"Dimu" ) {
2700 chit->
setTdc( m_tdc1-m_estime );
2706 chit->
setQ( m_ph1 );
2707 chit->
setP( m_momentum );
2710 etofCalHitCol->push_back( chit );
2718 if( ( m_quality1 & 0x800 ) == 0x800 ) {
2721 ahit->
setRun( runNumber );
2723 ahit->
setMod( m_tofId1 );
2727 for(
int i=0; i<5; i++ ) {
2728 ahit->
setTpred( i, m_texpInner[i] );
2730 if( calibData ==
"Dimu" ) {
2739 ahit->
setTdc1( m_tdc1-m_estime );
2740 ahit->
setTdc2( m_tdc2-m_estime );
2745 ahit->
setP( m_momentum );
2746 ahit->
setQ( m_ph1 );
2749 btofCalHitCol->push_back( ahit );
2752 if( ( m_quality2 & 0x800 ) == 0x800 ) {
2755 bhit->
setRun( runNumber );
2757 bhit->
setMod( m_tofId2 );
2761 for(
int i=0; i<5; i++ ) {
2762 bhit->
setTpred( i, m_texpOuter[i] );
2764 if( calibData ==
"Dimu" ) {
2773 bhit->
setTdc1( m_tdc3-m_estime );
2774 bhit->
setTdc2( m_tdc4-m_estime );
2779 bhit->
setP( m_momentum );
2780 bhit->
setQ( m_ph2 );
2783 btofCalHitCol->push_back( bhit );
DOUBLE_PRECISION count[3]
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 tof2PosSigmaAlongX() 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 int QElec()=0
virtual const double EtfTime1(double ADC, double TDC, double zHit, unsigned id, unsigned strip, double t0)=0
virtual const double EtfTime2(double ADC, double TDC, double zHit, unsigned id, unsigned strip, 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 EtfTimeMC2(double ADC, double TDC, double zHit, unsigned id, unsigned strip, double t0)=0
virtual const double BSigmaCluster(double zHit1, double zHit2, unsigned id1, unsigned id2)=0
virtual const double EtfTime(double ADC1, double ADC2, double TDC1, double TDC2, unsigned int id, unsigned int strip, double t0)=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 EtfZTDC(double tleft, double tright, unsigned int id, unsigned int strip)=0
virtual const double EtfTimeMC1(double ADC, double TDC, double zHit, unsigned id, unsigned strip, double t0)=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 quality() const
void setMRPCReadout(bool east)
unsigned int value() const
void setMRPCCluster(bool cluster, bool east)
void setBarrelReadout(unsigned int layer, bool east)
void setEndcapCluster(bool east)
void setBarrelCounter(unsigned int layer)
void setBarrelCluster(unsigned int layer)
static int endcap(const Identifier &id)
static int strip(const Identifier &id)
static Identifier cell_id(int barrel_ec, int layer, int phi_module, int end)
For a single crystal.
static int end(const Identifier &id)
static bool is_mrpc(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)
static int module(const Identifier &id)
void setTofData(TofDataMap tofDataMap)
double tof2(unsigned int i) const
std::vector< TofData * > tofData1() const
TofData * chooseTofDataEndcap(std::vector< TofData * > tofDataVec, double zr1[5])
ExtTrackCase hitCase() const
double zr1(unsigned int i) const
int kal(unsigned int i) const
void getEtfData(TofData *tof, unsigned int iflag, unsigned int qual)
unsigned int quality1() const
double tof(unsigned int i) const
void convert2RecTofTrackCol(RecTofTrackCol *recTofTrackCol)
void tofDataAnalysis(TofData *tof, unsigned int iflag)
void findEtfData(std::vector< TofData * > tofDataVec1, std::vector< TofData * > tofDataVec2, std::vector< TofData * > tofDataVec3, double zrhit, 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])
TofData * chooseEtfData2(std::vector< TofData * > tofDataVec, double zrhit)
double tof1(unsigned int i) const
void setQuality1(int qual1)
TofTrack(int run, int event)
void setRecTofTrack(RecTofTrack *track, int layerorend)
void convert2RecBTofCalHitColBarrel(int runNumber, int eventNumber, RecBTofCalHitCol *btofCalHitCol, std::string calibData)
void convert2RecETofCalHitCol(int runNumber, int eventNumber, RecETofCalHitCol *etofCalHitCol, std::string calibData)
void convert2RecBTofCalHitColETF(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)
TofData * chooseEtfData1(std::vector< TofData * > tofDataVec, double zrhit)
void getMultiHit(TofTrack *&)
void setQuality2(int qual2)
TofData * compareTofDataEndcap(TofData *tofData1, TofData *tofData2)
std::vector< TofData * > tofData2() const
unsigned int barrel() const
void setExtTrack(RecExtTrack *extTrack, double costheta, double p[5], int kal[5], double t0, int t0Stat)
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