310 MsgStream log(
msgSvc(), name() );
311 log << MSG::INFO <<
" tof " << endmsg;
315 double offset = 0, t_quality = 0, tOffset_b = 0, tOffset_e = 0;
316 int idtof, tofid_helix[30] = { -9 }, idmatch[3][88] = { 0 }, idmatch_emc[3][88] = { 0 },
317 idt[15] = { 0 }, particleId[30] = { 0 }, tofid_emc[2] = { 0 },
module[20] = { 0 };
318 int idetf, etfid_helix[30] = { -9 }, idetfmatch[3][36] = { -9 },
319 idmatch_etf_emc[3][36] = { 0 }, etfid_emc[2] = { 0 };
320 int ntot = 0, in = -1, out = -1, emcflag1 = 0, emcflag2 = 0, tof_flag = 0;
322 double meant[15] = { 0. }, adc[15] = { 0. },
momentum[15] = { 0. }, r_endtof[15] = { 0. };
323 double ttof[30] = { 0. }, helztof[30] = { 0.0 }, mcztof = 0.0, forevtime = 0.0,
324 backevtime = 0.0, meantev[500] = { 0. }, meantevup[500] = { 0.0 },
325 meantevdown[500] = { 0.0 };
326 double t0forward = 0, t0backward = 0, t0forward_trk = 0, t0backward_trk = 0;
327 double t0forward_add = 0, t0backward_add = 0, t_Est = -999;
328 double thetaemc_rec[20] = { 0. }, phiemc_rec[20] = { 0. }, energy_rec[20] = { 0. },
329 xemc_rec[20] = { 0. }, yemc_rec[20] = { 0. }, zemc_rec[20] = { 0. };
330 double r_endetf[30] = { 0. }, tetf[30] = { 0. }, helzetf[30] = { 0. },
331 helpathetf[36] = { 0. }, abmom2etf[36] = { 0. };
333 int nmatch1 = 0, nmatch2 = 0, nmatch_barrel = 0, nmatch_end = 0, nmatch_mdc = 0,
334 nmatch_barrel_1 = 0, nmatch_barrel_2 = 0, nmatch = 0, ntofup = 0, ntofdown = 0;
335 double sum_EstimeMdc = 0, sum_EstimeMdcMC = 0;
336 int nbunch = 0, tEstFlag = 0,
runNo = 0;
337 double helpath[88] = { 0. }, helz[88] = { 0. }, abmom2[88] = { 0. };
338 double mcTestime = 0, trigtiming = 0;
339 double mean_tdc_btof[2][88] = { 0. }, mean_tdc_etof[3][48] = { 0. },
340 mean_tdc_etf[3][36][12] = { 0. };
343 double Testime_fzisan = -999.;
344 int TestimeFlag_fzisan = -999;
345 double TestimeQuality_fzisan = -999.;
346 double Tof_t0Arr[500] = { -999. };
348 bool useEtofScin = (
m_phase < 3 );
349 bool useEtofMRPC = (
m_phase > 2 );
352 SmartDataPtr<Event::EventHeader> eventHeader( eventSvc(),
"/Event/EventHeader" );
355 log << MSG::FATAL <<
"Could not find Event Header" << endmsg;
356 return StatusCode::FAILURE;
358 int eventNo = eventHeader->eventNumber();
359 runNo = eventHeader->runNumber();
360 log << MSG::INFO <<
"EsTimeAlg: retrieved event: " <<
eventNo <<
" run: " <<
runNo
427 if (
m_evtNo == 1 && m_pass[0] % 1000 == 0 )
428 { cout <<
"------------------- Events-----------------: " << m_pass[0] << endl; }
429 if (
m_debug == 4 ) cout <<
"m_userawtime: " << m_userawtime << endl;
430 if (
m_debug == 4 ) cout <<
"EstTofCalibSvc est flag: " << tofCaliSvc->ValidInfo() << endl;
432 if ( tofCaliSvc->chooseConstants(
runNo,
eventNo ) == StatusCode::FAILURE )
434 log << MSG::ERROR <<
"EstTof Calibration Const is NOT correct! " << endmsg;
435 return StatusCode::FAILURE;
439 log << MSG::ERROR <<
"EstTof Calibration Const is Invalid! " << endmsg;
440 return StatusCode::FAILURE;
442 if ( tofCaliSvc->ValidInfo() == 0 ||
m_userawtime_opt == 1 ) m_userawtime = 1;
443 else m_userawtime = 0;
445 SmartDataPtr<RecEsTimeCol> aRecestimeCol( eventSvc(),
"/Event/Recon/RecEsTimeCol" );
446 if ( !aRecestimeCol || aRecestimeCol->size() == 0 )
449 log << MSG::INFO <<
"Could not find RecEsTimeCol from fzsian" << endmsg;
453 RecEsTimeCol::iterator it_evt = aRecestimeCol->begin();
454 for ( ; it_evt != aRecestimeCol->end(); it_evt++ )
456 Testime_fzisan = ( *it_evt )->getTest();
457 TestimeFlag_fzisan = ( *it_evt )->getStat();
458 TestimeQuality_fzisan = ( *it_evt )->getQuality();
460 log << MSG::INFO <<
"fzisan : Test = " << ( *it_evt )->getTest()
461 <<
", Status = " << ( *it_evt )->getStat() << endmsg;
463 if (
m_ntupleflag && m_tuple2 ) g_Testime_fzisan = Testime_fzisan;
467 static std::string fullPath =
"/Calib/EsTimeCal";
468 SmartDataPtr<CalibData::EsTimeCalibData> TEst( m_pCalibDataSvc, fullPath );
469 if ( !TEst ) { cout <<
"ERROR EsTimeCalibData" << endl; }
472 int no = TEst->getTestCalibConstNo();
478 unsigned int inumber = 0;
479 unsigned int calibNo = TEst->getSize();
482 for (
unsigned int i = 0; i < calibNo; i++, inumber++ )
484 if ( ( TEst->getRunTo( i ) != -1 ) && ( TEst->getRunTo( i ) < TEst->getRunFrom( i ) ) )
486 log << MSG::ERROR <<
"EsTimeCal -- The " << inumber
487 <<
"th calibration constatns is ABNORMAL! Run From is LARGER than RUN To!"
489 return StatusCode::FAILURE;
491 if ( ( TEst->getRunFrom( i ) == TEst->getRunTo( i ) ) &&
492 ( TEst->getEventFrom( i ) != -1 ) && ( TEst->getEventTo( i ) != -1 ) &&
493 ( TEst->getEventFrom( i ) > TEst->getEventTo( i ) ) )
495 log << MSG::ERROR <<
"EsTimeCal -- The " << inumber
496 <<
"th calibration constatns is ABNORMAL! Event From is LARGER than Event To!"
498 return StatusCode::FAILURE;
504 for (
unsigned int i = 0; i < calibNo; i++, inumber++ )
506 int runFrom = TEst->getRunFrom( i );
507 int runTo = TEst->getRunTo( i );
508 int eventFrom = TEst->getEventFrom( i );
509 int eventTo = TEst->getEventTo( i );
510 if ( (
runNo == runFrom ) && ( ( eventFrom == -1 ) || (
eventNo >= eventFrom ) ) )
512 if ( (
runNo < runTo ) ||
513 ( (
runNo == runTo ) && ( ( eventTo == -1 ) || (
eventNo <= eventTo ) ) ) )
519 if (
runNo > runFrom )
521 if ( (
runNo < runTo ) ||
522 ( (
runNo == runTo ) && ( ( eventTo == -1 ) || (
eventNo <= eventTo ) ) ) )
531 log << MSG::ERROR <<
"EsTimeCal -- For run number:" <<
runNo
532 <<
", NO suitable calibration constant is found!" << endmsg;
533 return StatusCode::FAILURE;
537 log << MSG::INFO <<
"offset barrel t0=" << TEst->getToffsetb( inumber )
538 <<
", offset endcap t0=" << TEst->getToffsete( inumber )
539 <<
", bunch time =" << TEst->getBunchTime( inumber ) << endmsg;
540 tOffset_b = TEst->getToffsetb( inumber );
541 tOffset_e = TEst->getToffsete( inumber );
542 bunchtime = TEst->getBunchTime( inumber );
567 SmartDataPtr<McParticleCol> mcParticleCol( eventSvc(),
"/Event/MC/McParticleCol" );
568 if ( !mcParticleCol ) { log << MSG::INFO <<
"Could not find McParticle" << endmsg; }
571 McParticleCol::iterator iter_mc = mcParticleCol->begin();
576 for ( ; iter_mc != mcParticleCol->end(); iter_mc++, digiId++ )
578 int statusFlags = ( *iter_mc )->statusFlags();
579 int pid = ( *iter_mc )->particleProperty();
580 log << MSG::INFO <<
" MC ParticleId = " << pid <<
" statusFlags = " << statusFlags
581 <<
" PrimaryParticle = " << ( *iter_mc )->primaryParticle() << endmsg;
584 g_theta0MC[ntrkMC] = ( *iter_mc )->initialFourMomentum().theta();
585 g_phi0MC[ntrkMC] = ( *iter_mc )->initialFourMomentum().phi();
586 g_pxMC[ntrkMC] = ( *iter_mc )->initialFourMomentum().px() / 1000;
587 g_pyMC[ntrkMC] = ( *iter_mc )->initialFourMomentum().py() / 1000;
588 g_pzMC[ntrkMC] = ( *iter_mc )->initialFourMomentum().pz() / 1000;
589 g_ptMC[ntrkMC] = sqrt( ( ( *iter_mc )->initialFourMomentum().px() ) *
590 ( ( *iter_mc )->initialFourMomentum().px() ) +
591 ( ( *iter_mc )->initialFourMomentum().py() ) *
592 ( ( *iter_mc )->initialFourMomentum().py() ) ) /
597 if ( m_particleTable->particle( pid ) )
598 charge = m_particleTable->particle( pid )->charge();
602 if ( m_particleTable->particle( -pid ) )
604 charge = m_particleTable->particle( -pid )->charge();
608 else { log << MSG::WARNING <<
"wrong particle id, please check data" << endmsg; }
609 log << MSG::DEBUG <<
"MC ParticleId = " << pid <<
" charge = " << charge << endmsg;
610 if ( charge != 0 &&
abs(
cos( ( *iter_mc )->initialFourMomentum().theta() ) ) < 0.93 )
612 if ( ( ( *iter_mc )->primaryParticle() ) &&
m_ntupleflag && m_tuple2 )
614 g_mcTestime = ( *iter_mc )->initialPosition().t();
615 mcTestime = ( *iter_mc )->initialPosition().t();
621 if (
m_debug ) cout <<
"bunchtime: " << bunchtime << endl;
623 SmartDataPtr<RecMdcTrackCol> newtrkCol( eventSvc(),
"/Event/Recon/RecMdcTrackCol" );
624 if ( !newtrkCol || newtrkCol->size() == 0 )
625 { log << MSG::INFO <<
"Could not find RecMdcTrackCol" << endmsg; }
628 log << MSG::INFO <<
"Begin to check RecMdcTrackCol" << endmsg;
629 RecMdcTrackCol::iterator iter_trk = newtrkCol->begin();
630 for ( ; iter_trk != newtrkCol->end(); iter_trk++ )
632 log << MSG::DEBUG <<
"retrieved MDC track:"
633 <<
" Track Id: " << ( *iter_trk )->trackId()
634 <<
" Phi0: " << ( *iter_trk )->helix( 0 ) <<
" kappa: " << ( *iter_trk )->helix( 2 )
635 <<
" Tanl: " << ( *iter_trk )->helix( 4 )
636 <<
" Phi terminal: " << ( *iter_trk )->getFiTerm() << endmsg
637 <<
"Number of hits: " << ( *iter_trk )->getNhits() <<
" Number of stereo hits "
638 << ( *iter_trk )->nster() << endmsg;
639 double kappa = ( *iter_trk )->helix( 2 );
640 double tanl = ( *iter_trk )->helix( 4 );
641 if ( ( *iter_trk )->helix( 3 ) > 50.0 )
continue;
643 if ( ntot > 14 )
break;
644 momentum[ntot] = 1. / fabs( kappa ) * sqrt( 1. + tanl * tanl );
650 SmartDataPtr<RecEmcShowerCol> aShowerCol( eventSvc(),
"/Event/Recon/RecEmcShowerCol" );
651 if ( !aShowerCol || aShowerCol->size() == 0 )
652 { log << MSG::WARNING <<
"Could not find RecEmcShowerCol" << endmsg; }
655 RecEmcShowerCol::iterator iShowerCol = aShowerCol->begin();
656 for ( ; iShowerCol != aShowerCol->end(); iShowerCol++, emctrk++ )
658 if ( emctrk > 19 )
break;
659 phiemc_rec[emctrk] = ( *iShowerCol )->position().phi();
660 thetaemc_rec[emctrk] = ( *iShowerCol )->position().theta();
661 energy_rec[emctrk] = ( *iShowerCol )->energy();
662 xemc_rec[emctrk] = ( *iShowerCol )->x();
663 yemc_rec[emctrk] = ( *iShowerCol )->y();
664 zemc_rec[emctrk] = ( *iShowerCol )->z();
665 module[emctrk] = ( *iShowerCol )->module();
668 for (
int i = 0; i < 2; i++ )
670 double fi_endtof = atan2( yemc_rec[i], xemc_rec[i] );
671 if ( fi_endtof < 0 ) { fi_endtof = 2 * 3.141593 + fi_endtof; }
672 if ( module[i] == 1 )
674 int Tofid = (int)( fi_endtof / ( 3.141593 / 44 ) );
675 if ( Tofid > 87 ) Tofid = Tofid - 88;
676 tofid_emc[i] = Tofid;
677 idmatch_emc[1][Tofid] = 1;
683 int Tofid = (int)( fi_endtof / ( 3.141593 / 24 ) );
684 if ( Tofid > 47 ) Tofid = Tofid - 48;
685 tofid_emc[i] = Tofid;
686 if ( module[i] == 2 ) idmatch_emc[2][Tofid] = 1;
687 if ( module[i] == 0 ) idmatch_emc[0][Tofid] = 1;
691 int Tofid = (int)( fi_endtof / ( 3.141593 / 18 ) );
692 if ( Tofid > 35 ) Tofid = Tofid - 36;
693 etfid_emc[i] = Tofid;
694 if ( module[i] == 2 ) idmatch_etf_emc[2][Tofid] = 1;
695 if ( module[i] == 0 ) idmatch_etf_emc[0][Tofid] = 1;
703 RecMdcTrackCol::iterator iter_trk = newtrkCol->begin();
704 for (
int idfztrk = 0; iter_trk != newtrkCol->end(); iter_trk++, idfztrk++ )
707 mdcftrk[0] = ( *iter_trk )->helix( 0 );
708 mdcftrk[1] = ( *iter_trk )->helix( 1 );
709 mdcftrk[2] = -( *iter_trk )->helix( 2 );
710 mdcftrk[3] = ( *iter_trk )->helix( 3 );
711 mdcftrk[4] = ( *iter_trk )->helix( 4 );
713 if ( optCosmic == 0 )
721 if ( EmcHit.
Emc_Get( sqrt(
RCEMC2 ), idfztrk, mdcftrk ) > 0 )
723 double z_emc = EmcHit.
Z_emc;
725 double phiemc_ext = EmcHit.
phi_emc;
727 double kappa = ( *iter_trk )->helix( 2 );
728 double tanl = ( *iter_trk )->helix( 4 );
729 double _momentum = 1. / fabs( kappa ) * sqrt( 1. + tanl * tanl );
730 for (
int t = 0;
t < emctrk;
t++ )
732 if ( ( thetaemc_ext >= ( thetaemc_rec[
t] - 0.1 ) ) &&
733 ( thetaemc_ext <= ( thetaemc_rec[
t] + 0.1 ) ) &&
734 ( phiemc_ext >= ( phiemc_rec[
t] - 0.1 ) ) &&
735 ( phiemc_ext <= ( phiemc_rec[
t] + 0.1 ) ) )
737 if ( ( energy_rec[
t] ) >= ( 0.85 * _momentum ) ) particleId[idfztrk] = 1;
742 if ( particleId[idfztrk] != 1 )
745 SmartDataPtr<RecMdcDedxCol> newdedxCol( eventSvc(),
"/Event/Recon/RecMdcDedxCol" );
746 if ( !newdedxCol || newdedxCol->size() == 0 )
747 { log << MSG::WARNING <<
"Could not find RecMdcDedxCol" << endmsg; }
750 RecMdcDedxCol::iterator it_dedx = newdedxCol->begin();
751 for (
int npid = 0; it_dedx != newdedxCol->end(); it_dedx++, npid++ )
753 log << MSG::INFO <<
"retrieved MDC dE/dx: "
754 <<
"dEdx Id: " << ( *it_dedx )->trackId()
755 <<
" particle Id: " << ( *it_dedx )->particleType() << endmsg;
756 if ( ( *it_dedx )->particleType() ==
proton ) { particleId[npid] = 5; }
757 if (
m_debug == 4 ) cout <<
"dedx pid: " << particleId[npid] << endl;
775 if ( tofpart < 0 )
continue;
778 bool useBarrelScin = ( tofpart == 1 );
779 bool useEndcapScin = ( ( tofpart == 0 || tofpart == 2 ) &&
781 bool useEndcapMRPC = ( ( tofpart == 0 || tofpart == 2 ) &&
784 if ( useBarrelScin || useEndcapScin )
786 idtof = TofHit.
Tofid;
787 tofid_helix[idfztrk] = TofHit.
Tofid;
791 idetf = TofHit.
Etfid;
792 etfid_helix[idfztrk] = TofHit.
Etfid;
795 log << MSG::INFO <<
"helix to tof hit part: " << tofpart <<
" tof id: " << idtof
796 <<
" etf id:" << idetf << endmsg;
798 cout <<
"helix to tof hit part, Id: " << tofpart <<
" , " << idtof << endl;
799 if ( ( useBarrelScin && idtof >= 0 && idtof <= 87 ) ||
800 ( useEndcapScin && idtof >= 0 && idtof <= 47 ) ||
801 ( useEndcapMRPC && idetf >= 0 && idetf <= 35 ) )
807 idetfmatch[tofpart][idetf] = 1;
808 helpathetf[idetf] = TofHit.
Path_etf;
809 helz[idetf] = TofHit.
Z_etf;
810 abmom = 1. / fabs( TofHit.
Kappa ) * sqrt( 1. + TofHit.
Tanl * TofHit.
Tanl );
811 if ( abmom < 0.1 )
continue;
812 abmom2etf[idetf] = abmom * abmom;
813 r_endetf[idfztrk] = TofHit.
r_etf;
814 helzetf[idfztrk] = helz[idetf];
817 if ( useBarrelScin || useEndcapScin )
819 idmatch[tofpart][idtof] = 1;
820 helpath[idtof] = TofHit.
Pathl;
821 helz[idtof] = TofHit.
Z_tof;
822 abmom = 1. / fabs( TofHit.
Kappa ) * sqrt( 1. + TofHit.
Tanl * TofHit.
Tanl );
823 if ( abmom < 0.1 )
continue;
824 abmom2[idtof] = abmom * abmom;
825 r_endtof[idfztrk] = TofHit.
r_endtof;
826 helztof[idfztrk] = helz[idtof];
831 cout <<
"Scintillator info trk number=" << idfztrk <<
" tofpart=" << tofpart
832 <<
" idtof=" << idtof <<
" helpath=" << helpath[idtof]
833 <<
" helz=" << helz[idtof] <<
" abmom=" << abmom2[idtof]
834 <<
" r=" << r_endtof[idfztrk] <<
" helztof=" << helz[idtof] << endl;
835 cout <<
"MRPC info trk number=" << idfztrk <<
" tofpart=" << tofpart
836 <<
" idetf=" << idetf <<
" helpath=" << helpathetf[idetf]
837 <<
" helz=" << helzetf[idetf] <<
" abmom=" << abmom2etf[idetf]
838 <<
" r=" << r_endetf[idfztrk] <<
" helztof=" << helzetf[idetf] << endl;
842 if ( optCosmic == 0 )
847 if ( particleId[idfztrk] == 1 )
850 sqrt(
ELMAS2 / abmom2etf[idetf] + 1 ) * helpathetf[idetf] /
VLIGHT;
853 else if ( particleId[idfztrk] == 5 )
862 sqrt(
PIMAS2 / abmom2etf[idetf] + 1 ) * helpathetf[idetf] /
VLIGHT;
867 if ( useBarrelScin || useEndcapScin )
869 if ( particleId[idfztrk] == 1 )
871 ttof[idfztrk] = sqrt(
ELMAS2 / abmom2[idtof] + 1 ) * helpath[idtof] /
VLIGHT;
874 else if ( particleId[idfztrk] == 5 )
876 ttof[idfztrk] = sqrt(
PROTONMAS2 / abmom2[idtof] + 1 ) * helpath[idtof] /
VLIGHT;
881 ttof[idfztrk] = sqrt(
PIMAS2 / abmom2[idtof] + 1 ) * helpath[idtof] /
VLIGHT;
891 tetf[idfztrk] = sqrt(
MUMAS2 / abmom2etf[idetf] + 1 ) * helpathetf[idetf] /
VLIGHT;
895 if ( useBarrelScin || useEndcapMRPC )
897 ttof[idfztrk] = sqrt(
MUMAS2 / abmom2[idtof] + 1 ) * helpath[idtof] /
VLIGHT;
904 g_vel[idfztrk] = vel;
905 g_abmom[idfztrk] = abmom;
906 if ( useEndcapMRPC ) { g_ttof[idfztrk] = tetf[idfztrk]; }
907 if ( useBarrelScin || useEndcapScin ) { g_ttof[idfztrk] = ttof[idfztrk]; }
908 g_pid[idfztrk] = particleId[idfztrk];
920 SmartDataPtr<TofMcHitCol> tofmcHitCol( eventSvc(),
"/Event/MC/TofMcHitCol" );
923 log << MSG::ERROR <<
"Could not find McParticle" << endmsg;
928 TofMcHitCol::iterator iter_mctof = tofmcHitCol->begin();
930 for ( ; iter_mctof != tofmcHitCol->end(); iter_mctof++, digiId++ )
932 log << MSG::INFO <<
" TofMcHit Flight Time = " << ( *iter_mctof )->getFlightTime()
933 <<
" zPosition = " << ( ( *iter_mctof )->getPositionZ() ) / 10
934 <<
" xPosition = " << ( ( *iter_mctof )->getPositionX() ) / 10
935 <<
" yPosition = " << ( ( *iter_mctof )->getPositionY() ) / 10 << endmsg;
941 TofDataVector tofDigiVec = m_rawDataProviderSvc->tofDataVectorEstime();
943 for ( TofDataVector::iterator iter2 = tofDigiVec.begin(); iter2 != tofDigiVec.end();
951 if ( !( ( *iter2 )->is_mrpc() ) )
953 if ( ( *iter2 )->barrel() )
956 tofid = ( *iter2 )->tofId();
957 layerid = ( *iter2 )->layer();
958 if ( layerid == 1 ) tofid = tofid - 88;
959 if ( ( ( *iter2 )->quality() & 0x5 ) == 0x5 && ( *iter2 )->times() == 1 )
961 double ftdc = ( *iter2 )->tdc1();
962 double btdc = ( *iter2 )->tdc2();
963 mean_tdc_btof[layerid][tofid] = ( ftdc + btdc ) / 2;
965 else if ( ( ( *iter2 )->quality() & 0x5 ) == 0x5 && ( *iter2 )->times() > 1 )
967 double ftdc = ( *iter2 )->tdc1();
968 double btdc = ( *iter2 )->tdc2();
969 mean_tdc_btof[layerid][tofid] = ( ftdc + btdc ) / 2;
974 tofid = ( *iter2 )->tofId();
975 if ( tofid < 48 ) barrelid = 0;
976 if ( tofid > 47 ) barrelid = 2;
977 if ( barrelid == 2 ) tofid = tofid - 48;
979 if ( ( *iter2 )->times() == 1 )
981 double ftdc = ( *iter2 )->tdc();
982 mean_tdc_etof[barrelid][tofid] = ftdc;
984 else if ( ( ( *iter2 )->times() > 1 ) && ( ( *iter2 )->times() < 5 ) )
986 double ftdc = ( *iter2 )->tdc();
987 mean_tdc_etof[barrelid][tofid] = ftdc;
993 tofid = ( *iter2 )->tofId();
994 strip = ( *iter2 )->strip();
995 if ( tofid < 36 ) barrelid = 0;
996 if ( tofid > 35 ) barrelid = 2;
997 if ( barrelid == 2 ) tofid = tofid - 36;
998 if ( ( ( *iter2 )->quality() & 0x5 ) == 0x5 && ( *iter2 )->times() == 1 )
1000 double ftdc = ( *iter2 )->tdc1();
1001 double btdc = ( *iter2 )->tdc2();
1002 mean_tdc_etf[barrelid][tofid][strip] = ( ftdc + btdc ) / 2;
1004 else if ( ( ( *iter2 )->quality() & 0x5 ) == 0x5 && ( *iter2 )->times() > 1 )
1006 double ftdc = ( *iter2 )->tdc1();
1007 double btdc = ( *iter2 )->tdc2();
1008 mean_tdc_etf[barrelid][tofid][strip] = ( ftdc + btdc ) / 2;
1013 double difftof_b = 100, difftof_e = 100;
1014 int tofid1 = tofid_emc[0];
1015 int tofid2 = tofid_emc[1];
1016 if ( module[0] == 1 && module[1] == 1 )
1018 for (
int i = 0; i < 2; i++ )
1020 for (
int m = 0; m < 2; m++ )
1022 for (
int j = -2; j < 3; j++ )
1024 for (
int k = -2; k < 3; k++ )
1028 if ( p < 0 ) p = p + 88;
1029 if ( p > 87 ) p = p - 88;
1030 if (
q < 0 )
q =
q + 88;
1031 if (
q > 87 )
q =
q + 88;
1032 if ( mean_tdc_btof[i][p] == 0 || mean_tdc_btof[m][
q] == 0 )
continue;
1033 double difftof_b_temp = mean_tdc_btof[i][p] - mean_tdc_btof[m][
q];
1034 if (
abs( difftof_b_temp ) <
abs( difftof_b ) ) difftof_b = difftof_b_temp;
1035 if (
m_ntupleflag && m_tuple2 ) g_difftof_b = difftof_b;
1044 if ( module[0] != 1 && module[1] != 1 )
1046 tofid1 = etfid_emc[0];
1047 tofid2 = etfid_emc[1];
1048 for (
int i = -1; i < 2; i++ )
1050 for (
int j = -1; j < 2; j++ )
1054 if ( m < 0 ) m = 36 + m;
1055 if ( m > 35 ) m = m - 36;
1056 if (
n < 0 )
n = 36 +
n;
1057 if (
n > 35 )
n =
n - 36;
1058 if ( mean_tdc_etf[0][m] && mean_tdc_etf[2][
n] )
1060 double difftof_e_temp = mean_tdc_etf[0][m] - mean_tdc_etf[2][
n];
1061 if (
abs( difftof_e_temp ) <
abs( difftof_e ) ) difftof_e = difftof_e_temp;
1062 if (
m_ntupleflag && m_tuple2 ) g_difftof_e = difftof_e;
1071 if ( module[0] != 1 && module[1] != 1 )
1073 for (
int i = -1; i < 2; i++ )
1075 for (
int j = -1; j < 2; j++ )
1079 if ( m < 0 ) m = 48 + m;
1080 if ( m > 47 ) m = m - 48;
1081 if (
n < 0 )
n = 48 +
n;
1082 if (
n > 47 )
n =
n - 48;
1083 if ( mean_tdc_etof[0][m] && mean_tdc_etof[2][
n] )
1085 double difftof_e_temp = mean_tdc_etof[0][m] - mean_tdc_etof[2][
n];
1086 if (
abs( difftof_e_temp ) <
abs( difftof_e ) ) difftof_e = difftof_e_temp;
1087 if (
m_ntupleflag && m_tuple2 ) g_difftof_e = difftof_e;
1099 unsigned int barrelid;
1100 unsigned int layerid;
1103 TofDataVector::iterator iter2 = tofDigiVec.begin();
1104 for ( ; iter2 != tofDigiVec.end(); iter2++, digiId++ )
1106 log << MSG::INFO <<
"TOF digit No: " << digiId << endmsg;
1107 barrelid = ( *iter2 )->barrel();
1108 if ( ( *iter2 )->barrel() == 0 )
continue;
1109 if ( ( ( *iter2 )->quality() & 0x5 ) == 0x5 && ( *iter2 )->times() == 1 )
1111 tofid = ( *iter2 )->tofId();
1112 layerid = ( *iter2 )->layer();
1113 if ( layerid == 1 ) tofid = tofid - 88;
1114 log << MSG::INFO <<
" TofId = " << tofid <<
" barrelid = " << barrelid
1115 <<
" layerid = " << layerid <<
" ForwordADC = " << ( *iter2 )->adc1()
1116 <<
" ForwordTDC = " << ( *iter2 )->tdc1()
1117 <<
" BackwordADC = " << ( *iter2 )->adc2()
1118 <<
" BackwordTDC = " << ( *iter2 )->tdc2() << endmsg;
1120 double ftdc = ( *iter2 )->tdc1();
1121 double btdc = ( *iter2 )->tdc2();
1123 cout <<
"barrel 1 ::layer, barrel, tofid, ftdc, btdc: " << layerid <<
" , " << barrelid
1124 <<
" , " << tofid <<
" , " << ftdc <<
" , " << btdc << endl;
1125 double fadc = ( *iter2 )->adc1();
1126 double badc = ( *iter2 )->adc2();
1127 int idptof = ( ( tofid - 1 ) == -1 ) ? 87 : tofid - 1;
1128 int idntof = ( ( tofid + 1 ) == 88 ) ? 0 : tofid + 1;
1129 double ztof = fabs( ( ftdc - btdc ) / 2 ) * 17.7, ztof2 = ztof * ztof;
1130 double mean_tdc = 0.5 * ( btdc + ftdc );
1133 if ( idmatch[barrelid][tofid] == 1 || idmatch[barrelid][idptof] == 1 ||
1134 idmatch[barrelid][idntof] == 1 )
1136 for (
int i = 0; i < ntot; i++ )
1138 if ( ttof[i] != 0 && ftdc > 0 )
1140 if ( ( tofid_helix[i] == tofid ) || ( tofid_helix[i] == idntof ) ||
1141 ( tofid_helix[i] == idptof ) )
1143 if ( barrelid == 1 && helztof[i] < 117 && helztof[i] > -117 )
1145 if ( optCosmic && tofid < 44 )
1147 backevtime = -ttof[i] + ( 115 + helztof[i] ) * 0.0566 + 12.;
1148 forevtime = -ttof[i] + ( 115 - helztof[i] ) * 0.0566 + 12.;
1149 meantevup[ntofup] = ( backevtime + forevtime ) / 2;
1154 backevtime = ttof[i] + ( 115 + helztof[i] ) * 0.0566 + 12.;
1155 forevtime = ttof[i] + ( 115 - helztof[i] ) * 0.0566 + 12.;
1156 meantevdown[ntofdown] = ( backevtime + forevtime ) / 2;
1159 if ( ( *iter2 )->adc1() < 0.0 || ( *iter2 )->adc2() < 0.0 || m_userawtime )
1161 t0forward_trk = ftdc - forevtime;
1162 t0backward_trk = btdc - backevtime;
1166 t0forward_trk = tofCaliSvc->BTime1( ( *iter2 )->adc1(), ( *iter2 )->tdc1(),
1167 helztof[i], ( *iter2 )->tofId() ) -
1169 t0backward_trk = tofCaliSvc->BTime2( ( *iter2 )->adc2(), ( *iter2 )->tdc2(),
1170 helztof[i], ( *iter2 )->tofId() ) -
1172 if ( optCosmic && tofid < 44 )
1174 t0forward_trk = tofCaliSvc->BTime1( ( *iter2 )->adc1(), ( *iter2 )->tdc1(),
1175 helztof[i], ( *iter2 )->tofId() ) +
1178 tofCaliSvc->BTime2( ( *iter2 )->adc2(), ( *iter2 )->tdc2(), helztof[i],
1179 ( *iter2 )->tofId() ) +
1184 if ( t0forward_trk < -3 || t0backward_trk < -3 ||
1185 fabs( t0forward_trk - t0backward_trk ) > 15.0 )
1187 if ( !
m_TofOpt && nmatch_barrel != 0 &&
1188 fabs( ( t0forward_trk + t0backward_trk ) / 2 -
1189 ( t0backward_add + t0forward_add ) / 2 / nmatch_barrel ) > 11 )
1192 cout <<
" t0forward_trk, t0backward_trk: " << t0forward_trk <<
" , "
1193 << t0backward_trk << endl;
1196 g_t0for[nmatch1] = t0forward_trk;
1197 g_t0back[nmatch2] = t0backward_trk;
1198 g_meantdc = ( ftdc + btdc ) / 2;
1199 if ( tofid < 44 ) g_ntofup1++;
1202 t0forward_add += t0forward_trk;
1203 t0backward_add += t0backward_trk;
1204 if ( nmatch > 499 )
break;
1205 meantev[nmatch] = ( backevtime + forevtime ) / 2;
1206 Tof_t0Arr[nmatch] = ( t0forward_trk + t0backward_trk ) / 2.0;
1208 nmatch1 = nmatch1 + 1;
1209 nmatch2 = nmatch2 + 1;
1219 if ( nmatch_barrel != 0 )
1222 { g_t0barrelTof = ( t0forward_add / nmatch_barrel + t0backward_add / nmatch_barrel ) / 2; }
1227 if ( nmatch_barrel == 0 )
1232 for ( TofDataVector::iterator iter2 = tofDigiVec.begin(); iter2 != tofDigiVec.end();
1235 log << MSG::INFO <<
"TOF digit No: " << digiId << endmsg;
1236 barrelid = ( *iter2 )->barrel();
1237 if ( ( *iter2 )->barrel() == 0 )
continue;
1238 if ( ( ( *iter2 )->quality() & 0x5 ) == 0x5 && ( *iter2 )->times() > 1 )
1240 tofid = ( *iter2 )->tofId();
1241 layerid = ( *iter2 )->layer();
1242 if ( layerid == 1 ) tofid = tofid - 88;
1243 log << MSG::INFO <<
" TofId = " << tofid <<
" barrelid = " << barrelid
1244 <<
" layerid = " << layerid <<
" ForwordADC = " << ( *iter2 )->adc1()
1245 <<
" ForwordTDC = " << ( *iter2 )->tdc1() << endmsg;
1246 double ftdc = ( *iter2 )->tdc1();
1247 double btdc = ( *iter2 )->tdc2();
1248 double fadc = ( *iter2 )->adc1();
1249 double badc = ( *iter2 )->adc2();
1251 cout <<
"barrel 2 ::layer, barrel, tofid, ftdc, btdc: " << layerid <<
" , "
1252 << barrelid <<
" , " << tofid <<
" , " << ftdc <<
" , " << btdc << endl;
1253 int idptof = ( ( tofid - 1 ) == -1 ) ? 87 : tofid - 1;
1254 int idntof = ( ( tofid + 1 ) == 88 ) ? 0 : tofid + 1;
1255 if ( idmatch[barrelid][tofid] == 1 || idmatch[barrelid][idptof] == 1 ||
1256 idmatch[barrelid][idntof] == 1 )
1258 for (
int i = 0; i < ntot; i++ )
1260 if ( ttof[i] != 0 && ftdc > 0 )
1262 if ( tofid_helix[i] == tofid || ( tofid_helix[i] == idptof ) ||
1263 ( tofid_helix[i] == idntof ) )
1265 if ( barrelid == 1 && helztof[i] < 117 && helztof[i] > -117 )
1267 if ( optCosmic && tofid < 44 )
1269 backevtime = -ttof[i] + ( 115 + helztof[i] ) * 0.0566 + 12.;
1270 forevtime = -ttof[i] + ( 115 - helztof[i] ) * 0.0566 + 12.;
1271 meantevup[ntofup] = ( backevtime + forevtime ) / 2;
1276 backevtime = ttof[i] + ( 115 + helztof[i] ) * 0.0566 + 12.;
1277 forevtime = ttof[i] + ( 115 - helztof[i] ) * 0.0566 + 12.;
1278 meantevdown[ntofdown] = ( backevtime + forevtime ) / 2;
1281 if ( ( *iter2 )->adc1() < 0.0 || ( *iter2 )->adc2() < 0.0 || m_userawtime )
1283 t0forward_trk = ftdc - forevtime;
1284 t0backward_trk = btdc - backevtime;
1288 t0forward_trk = tofCaliSvc->BTime1( ( *iter2 )->adc1(), ( *iter2 )->tdc1(),
1289 helztof[i], ( *iter2 )->tofId() ) -
1292 tofCaliSvc->BTime2( ( *iter2 )->adc2(), ( *iter2 )->tdc2(), helztof[i],
1293 ( *iter2 )->tofId() ) -
1295 if ( optCosmic && tofid < 44 )
1298 tofCaliSvc->BTime1( ( *iter2 )->adc1(), ( *iter2 )->tdc1(),
1299 helztof[i], ( *iter2 )->tofId() ) +
1302 tofCaliSvc->BTime2( ( *iter2 )->adc2(), ( *iter2 )->tdc2(),
1303 helztof[i], ( *iter2 )->tofId() ) +
1308 if ( t0forward_trk < -3 || t0backward_trk < -3 ||
1309 fabs( t0forward_trk - t0backward_trk ) > 15.0 )
1311 if ( !
m_TofOpt && nmatch_barrel != 0 &&
1312 fabs( ( t0forward_trk + t0backward_trk ) / 2 -
1313 ( t0backward_add + t0forward_add ) / 2 / nmatch_barrel ) > 11 )
1316 cout <<
"t0forward_trk, t0backward_trk: " << t0forward_trk <<
" , "
1317 << t0backward_trk << endl;
1320 g_t0for[nmatch1] = t0forward_trk;
1321 g_t0back[nmatch2] = t0backward_trk;
1322 g_meantdc = ( ftdc + btdc ) / 2;
1323 if ( tofid < 44 ) g_ntofup1++;
1326 t0forward_add += t0forward_trk;
1327 t0backward_add += t0backward_trk;
1328 if ( nmatch > 499 )
break;
1329 meantev[nmatch] = ( backevtime + forevtime ) / 2;
1330 Tof_t0Arr[nmatch] = ( t0forward_trk + t0backward_trk ) / 2.0;
1332 nmatch1 = nmatch1 + 1;
1333 nmatch2 = nmatch2 + 1;
1342 if ( nmatch_barrel ) tof_flag = 2;
1345 if ( ntot == 0 || nmatch_barrel == 0 )
1347 for ( TofDataVector::iterator iter2 = tofDigiVec.begin(); iter2 != tofDigiVec.end();
1350 log << MSG::INFO <<
"TOF digit No: " << digiId << endmsg;
1351 barrelid = ( *iter2 )->barrel();
1352 if ( ( *iter2 )->barrel() == 0 )
continue;
1353 if ( ( ( *iter2 )->quality() & 0x5 ) == 0x5 && ( *iter2 )->times() == 1 )
1355 tofid = ( *iter2 )->tofId();
1356 layerid = ( *iter2 )->layer();
1357 if ( layerid == 1 ) tofid = tofid - 88;
1358 log << MSG::INFO <<
" TofId = " << tofid <<
" barrelid = " << barrelid
1359 <<
" layerid = " << layerid <<
" ForwordADC = " << ( *iter2 )->adc1()
1360 <<
" ForwordTDC = " << ( *iter2 )->tdc1() << endmsg;
1361 double ftdc = ( *iter2 )->tdc1();
1362 double btdc = ( *iter2 )->tdc2();
1363 double fadc = ( *iter2 )->adc1();
1364 double badc = ( *iter2 )->adc2();
1366 cout <<
"barrel 3 ::layer, barrel, tofid, ftdc, btdc: " << layerid <<
" , "
1367 << barrelid <<
" , " << tofid <<
" , " << ftdc <<
" , " << btdc << endl;
1368 int idptof = ( ( tofid - 1 ) == -1 ) ? 87 : tofid - 1;
1369 int idntof = ( ( tofid + 1 ) == 88 ) ? 0 : tofid + 1;
1370 for (
int i = 0; i < 2; i++ )
1372 if ( tofid_emc[i] == tofid || tofid_emc[i] == idptof || tofid_emc[i] == idntof )
1374 if ( zemc_rec[0] || zemc_rec[1] )
1376 if ( tofid == tofid_emc[i] || tofid_emc[i] == idntof || tofid_emc[i] == idptof )
1378 if ( ftdc > 2000. || module[i] != 1 )
continue;
1380 sqrt( xemc_rec[i] * xemc_rec[i] + yemc_rec[i] * yemc_rec[i] +
1381 zemc_rec[i] * zemc_rec[i] ) /
1383 if ( optCosmic == 1 && tofid < 44 )
1385 backevtime = -ttof[i] + ( 115 + zemc_rec[i] ) * 0.0566 + 12.;
1386 forevtime = -ttof[i] + ( 115 - zemc_rec[i] ) * 0.0566 + 12.;
1387 meantevup[ntofup] = ( backevtime + forevtime ) / 2;
1392 backevtime = ttof[i] + ( 115 + zemc_rec[i] ) * 0.0566 + 12.;
1393 forevtime = ttof[i] + ( 115 - zemc_rec[i] ) * 0.0566 + 12.;
1394 meantevdown[ntofdown] = ( backevtime + forevtime ) / 2;
1397 if ( ( *iter2 )->adc1() < 0.0 || ( *iter2 )->adc2() < 0.0 || m_userawtime )
1399 t0forward_trk = ftdc - forevtime;
1400 t0backward_trk = btdc - backevtime;
1404 t0forward_trk = tofCaliSvc->BTime1( ( *iter2 )->adc1(), ( *iter2 )->tdc1(),
1405 helztof[i], ( *iter2 )->tofId() ) -
1407 t0backward_trk = tofCaliSvc->BTime2( ( *iter2 )->adc2(), ( *iter2 )->tdc2(),
1408 helztof[i], ( *iter2 )->tofId() ) -
1410 if ( optCosmic && tofid < 44 )
1412 t0forward_trk = tofCaliSvc->BTime1( ( *iter2 )->adc1(), ( *iter2 )->tdc1(),
1413 helztof[i], ( *iter2 )->tofId() ) +
1416 tofCaliSvc->BTime2( ( *iter2 )->adc2(), ( *iter2 )->tdc2(), helztof[i],
1417 ( *iter2 )->tofId() ) +
1422 if ( t0forward_trk < -1 || t0backward_trk < -1 ||
1423 fabs( t0forward_trk - t0backward_trk ) > 15.0 )
1425 if ( !
m_TofOpt && nmatch_barrel != 0 &&
1426 fabs( ( t0forward_trk + t0backward_trk ) / 2 -
1427 ( t0backward_add + t0forward_add ) / 2 / nmatch_barrel ) > 11 )
1430 cout <<
"t0forward_trk, t0backward_trk: " << t0forward_trk <<
" , "
1431 << t0backward_trk << endl;
1432 t0forward_add += t0forward_trk;
1433 t0backward_add += t0backward_trk;
1434 if ( nmatch > 499 )
break;
1435 meantev[nmatch] = ( backevtime + forevtime ) / 2;
1436 Tof_t0Arr[nmatch] = ( t0forward_trk + t0backward_trk ) / 2.0;
1446 if ( nmatch_barrel ) tof_flag = 3;
1449 if ( nmatch_barrel != 0 )
1451 t0forward = t0forward_add / nmatch_barrel;
1452 t0backward = t0backward_add / nmatch_barrel;
1453 if ( optCosmic == 0 )
1457 t_Est = EST_Trimmer( Opt_new( Tof_t0Arr, nmatch,
m_TofOpt_Cut ), tOffset_b,
1461 t_Est = EST_Trimmer( ( t0forward + t0backward ) / 2, tOffset_b,
toffset_rawtime,
1463 if ( t_Est < 0 ) t_Est = 0;
1464 if ( tof_flag == 1 ) tEstFlag = 111;
1465 else if ( tof_flag == 2 ) tEstFlag = 121;
1466 else if ( tof_flag == 3 ) tEstFlag = 131;
1470 t_Est = ( t0forward + t0backward ) / 2;
1471 if ( tof_flag == 1 ) tEstFlag = 211;
1472 else if ( tof_flag == 2 ) tEstFlag = 221;
1473 else if ( tof_flag == 3 ) tEstFlag = 231;
1475 if (
m_ntupleflag && m_tuple2 ) g_meant0 = ( t0forward + t0backward ) / 2;
1482 if ( nmatch_barrel == 0 )
1484 for ( TofDataVector::iterator iter2 = tofDigiVec.begin(); iter2 != tofDigiVec.end();
1487 log << MSG::INFO <<
"TOF digit No: " << digiId << endmsg;
1488 barrelid = ( *iter2 )->barrel();
1489 if ( ( *iter2 )->barrel() == 0 )
continue;
1490 if ( ( ( *iter2 )->quality() & 0x5 ) == 0x4 )
1492 tofid = ( *iter2 )->tofId();
1493 layerid = ( *iter2 )->layer();
1494 if ( layerid == 1 ) tofid = tofid - 88;
1495 log << MSG::INFO <<
" TofId = " << tofid <<
" barrelid = " << barrelid
1496 <<
" layerid = " << layerid <<
" ForwordADC = " << ( *iter2 )->adc1()
1497 <<
" ForwordTDC = " << ( *iter2 )->tdc1() << endmsg;
1499 double ftdc = ( *iter2 )->tdc1();
1500 double fadc = ( *iter2 )->adc1();
1502 cout <<
"barrel 4 ::layer, barrel, tofid, ftdc: " << layerid <<
" , " << barrelid
1503 <<
" , " << tofid <<
" , " << ftdc << endl;
1504 int idptof = ( ( tofid - 1 ) == -1 ) ? 87 : tofid - 1;
1505 int idntof = ( ( tofid + 1 ) == 88 ) ? 0 : tofid + 1;
1506 if ( idmatch[barrelid][tofid] == 1 || idmatch[barrelid][idptof] == 1 ||
1507 idmatch[barrelid][idntof] == 1 )
1509 for (
int i = 0; i < ntot; i++ )
1511 if ( ttof[i] != 0 && ftdc > 0 )
1513 if ( tofid_helix[i] == tofid || ( tofid_helix[i] == idptof ) ||
1514 ( tofid_helix[i] == idntof ) )
1516 if ( barrelid == 1 && helztof[i] < 117 && helztof[i] > -117 )
1518 if ( optCosmic && tofid < 44 )
1520 forevtime = -ttof[i] + ( 115 - helztof[i] ) * 0.0566 + 12.;
1521 meantevup[ntofup] = forevtime;
1526 forevtime = ttof[i] + ( 115 - helztof[i] ) * 0.0566 + 12.;
1527 meantevdown[ntofdown] = forevtime;
1530 if ( ( *iter2 )->adc1() < 0.0 || m_userawtime )
1531 { t0forward_trk = ftdc - forevtime; }
1534 t0forward_trk = tofCaliSvc->BTime1( ( *iter2 )->adc1(), ( *iter2 )->tdc1(),
1535 helztof[i], ( *iter2 )->tofId() ) -
1539 if ( t0forward_trk < -1 )
continue;
1540 if ( !
m_TofOpt && nmatch_barrel_1 != 0 &&
1541 fabs( ( t0forward_trk ) - ( t0forward_add ) / nmatch_barrel_1 ) > 11 )
1543 if (
m_debug == 4 ) cout <<
"t0forward_trk: " << t0forward_trk << endl;
1546 g_t0for[nmatch1] = t0forward_trk;
1548 if ( tofid < 44 ) g_ntofup1++;
1551 t0forward_add += t0forward_trk;
1553 if ( nmatch > 499 )
break;
1554 meantev[nmatch] = forevtime;
1555 Tof_t0Arr[nmatch] = t0forward_trk;
1565 else if ( ( ( *iter2 )->quality() & 0x5 ) == 0x1 )
1567 tofid = ( *iter2 )->tofId();
1568 layerid = ( *iter2 )->layer();
1569 if ( layerid == 1 ) tofid = tofid - 88;
1570 log << MSG::INFO <<
" TofId = " << tofid <<
" barrelid = " << barrelid
1571 <<
" layerid = " << layerid <<
" BackwordADC = " << ( *iter2 )->adc2()
1572 <<
" BackwordTDC = " << ( *iter2 )->tdc2() << endmsg;
1574 double btdc = ( *iter2 )->tdc2();
1576 cout <<
"barrel 5 ::layer, barrel, tofid, btdc: " << layerid <<
" , " << barrelid
1577 <<
" , " << tofid <<
" , " << btdc << endl;
1578 double badc = ( *iter2 )->adc2();
1579 int idptof = ( ( tofid - 1 ) == -1 ) ? 87 : tofid - 1;
1580 int idntof = ( ( tofid + 1 ) == 88 ) ? 0 : tofid + 1;
1581 if ( idmatch[barrelid][tofid] == 1 || idmatch[barrelid][idptof] == 1 ||
1582 idmatch[barrelid][idntof] == 1 )
1584 for (
int i = 0; i < ntot; i++ )
1586 if ( ttof[i] != 0 && btdc > 0 )
1588 if ( ( tofid_helix[i] == tofid ) || ( tofid_helix[i] == idntof ) ||
1589 ( tofid_helix[i] == idptof ) )
1591 if ( barrelid == 1 && helztof[i] < 117 && helztof[i] > -117 )
1593 if ( optCosmic && tofid < 44 )
1595 backevtime = -ttof[i] + ( 115 + helztof[i] ) * 0.0566 + 12.;
1596 meantevup[ntofup] = backevtime;
1601 backevtime = ttof[i] + ( 115 + helztof[i] ) * 0.0566 + 12.;
1602 meantevdown[ntofdown] = backevtime;
1606 if ( ( *iter2 )->adc2() < 0.0 || m_userawtime )
1607 { t0backward_trk = btdc - backevtime; }
1611 tofCaliSvc->BTime2( ( *iter2 )->adc2(), ( *iter2 )->tdc2(), helztof[i],
1612 ( *iter2 )->tofId() ) -
1616 if ( t0backward_trk < -1 )
continue;
1617 if ( !
m_TofOpt && nmatch_barrel_2 != 0 &&
1618 fabs( ( t0backward_trk ) - ( t0backward_add ) / nmatch_barrel_2 ) > 11 )
1620 if (
m_debug == 4 ) cout <<
"t0backward_trk: " << t0backward_trk << endl;
1623 g_t0back[nmatch2] = t0backward_trk;
1625 if ( tofid < 44 ) g_ntofup1++;
1628 t0backward_add += t0backward_trk;
1629 if ( nmatch > 499 )
break;
1630 meantev[nmatch] = backevtime;
1631 Tof_t0Arr[nmatch] = t0backward_trk;
1643 if ( nmatch_barrel_1 != 0 )
1645 t0forward = t0forward_add / nmatch_barrel_1;
1646 if ( optCosmic == 0 )
1650 t_Est = EST_Trimmer( Opt_new( Tof_t0Arr, nmatch,
m_TofOpt_Cut ), tOffset_b,
1654 if ( t_Est < 0 ) t_Est = 0;
1664 if ( nmatch_barrel_2 != 0 )
1666 t0backward = t0backward_add / nmatch_barrel_2;
1667 if ( optCosmic == 0 )
1671 t_Est = EST_Trimmer( Opt_new( Tof_t0Arr, nmatch,
m_TofOpt_Cut ), tOffset_b,
1675 if ( t_Est < 0 ) t_Est = 0;
1689 if ( nmatch_barrel == 0 )
1691 for ( TofDataVector::iterator iter2 = tofDigiVec.begin(); iter2 != tofDigiVec.end();
1694 log << MSG::INFO <<
"TOF digit No: " << digiId << endmsg;
1695 barrelid = ( *iter2 )->barrel();
1696 if ( ( *iter2 )->barrel() != 0 )
continue;
1697 if ( ( *iter2 )->times() != 1 )
continue;
1698 tofid = ( *iter2 )->tofId();
1700 if ( !( ( *iter2 )->is_mrpc() ) )
1702 if ( tofid < 48 ) { barrelid = 0; }
1703 if ( tofid > 47 ) { barrelid = 2; }
1704 if ( barrelid == 2 ) { tofid = tofid - 48; }
1707 else if ( ( *iter2 )->is_mrpc() )
1712 if ( barrelid == 2 ) { tofid = tofid - 36; }
1715 log << MSG::INFO <<
" is_mrpc = " << ( *iter2 )->is_mrpc() <<
" TofId = " << tofid
1716 <<
" barrelid = " << barrelid << endmsg <<
" ForwordADC = " << ( *iter2 )->adc()
1717 <<
" ForwordTDC = " << ( *iter2 )->tdc() << endmsg;
1718 double ftdc = ( *iter2 )->tdc();
1719 double fadc = ( *iter2 )->adc();
1721 cout <<
"endcap::single hit,barrelid,tofid,tdc: " << barrelid <<
" , " << tofid
1722 <<
" , " << ftdc << endl;
1725 if ( !( ( *iter2 )->is_mrpc() ) && useEtofScin )
1727 int idptof = ( ( tofid - 1 ) == -1 ) ? 47 : tofid - 1;
1728 int idntof = ( ( tofid + 1 ) == 48 ) ? 0 : tofid + 1;
1730 if ( idmatch[barrelid][tofid] == 1 || idmatch[barrelid][idptof] == 1 ||
1731 idmatch[barrelid][idntof] == 1 )
1733 for (
int i = 0; i < ntot; i++ )
1735 if ( ttof[i] != 0 && ftdc > 0 && ftdc < 2000. )
1737 if ( ( tofid_helix[i] == tofid ) || ( tofid_helix[i] == idntof ) ||
1738 ( tofid_helix[i] == idptof ) )
1740 if ( barrelid == 0 || barrelid == 2 )
1742 if ( r_endtof[i] >= 41 && r_endtof[i] <= 90 )
1744 if ( optCosmic && ( tofid < 24 || ( tofid > 48 && tofid < 71 ) ) )
1746 forevtime = -ttof[i] + r_endtof[i] * 0.09 + 12.2;
1747 meantevup[ntofup] = forevtime;
1752 forevtime = ttof[i] + r_endtof[i] * 0.09 + 12.2;
1753 meantevdown[ntofdown] = forevtime;
1756 if ( ( *iter2 )->adc() < 0.0 || m_userawtime )
1757 { t0forward_trk = ftdc - forevtime; }
1760 t0forward_trk = tofCaliSvc->ETime( ( *iter2 )->adc(), ( *iter2 )->tdc(),
1761 r_endtof[i], ( *iter2 )->tofId() ) -
1765 if ( t0forward_trk < -1. )
continue;
1766 if ( !
m_TofOpt && nmatch_end != 0 &&
1767 fabs( t0forward_trk - t0forward_add / nmatch_end ) > 9 )
1769 t0forward_add += t0forward_trk;
1770 if ( nmatch > 499 )
break;
1771 Tof_t0Arr[nmatch] = t0forward_trk;
1772 meantev[nmatch] = forevtime / 2;
1778 if (
m_debug == 4 ) { cout <<
"t0forward_trk:" << t0forward_trk << endl; }
1784 if ( ( *iter2 )->is_mrpc() && useEtofMRPC )
1786 if ( ( ( *iter2 )->quality() & 0x5 ) != 0x5 )
continue;
1787 double btdc = ( *iter2 )->tdc2();
1788 double badc = ( *iter2 )->adc2();
1789 int idptof = ( ( tofid - 1 ) == -1 ) ? 35 : tofid - 1;
1790 int idntof = ( ( tofid + 1 ) == 36 ) ? 0 : tofid + 1;
1792 if ( idetfmatch[barrelid][tofid] == 1 || idetfmatch[barrelid][idptof] == 1 ||
1793 idetfmatch[barrelid][idntof] == 1 )
1795 for (
int i = 0; i < ntot; i++ )
1797 if ( tetf[i] != 0 && ftdc > 0 && ftdc < 2000. )
1799 if ( etfid_helix[i] == tofid || etfid_helix[i] == idntof ||
1800 etfid_helix[i] == idptof )
1802 if ( barrelid == 0 || barrelid == 2 )
1804 if ( r_endetf[i] >= 41 && r_endetf[i] <= 90 )
1806 if ( optCosmic && ( tofid < 18 || ( tofid > 35 && tofid < 54 ) ) )
1808 forevtime = -tetf[i] + 17.7;
1809 meantevup[ntofup] = forevtime;
1814 forevtime = tetf[i] + 17.7;
1815 meantevdown[ntofdown] = forevtime;
1820 double fbtdc = ( ftdc + btdc ) / 2.0;
1821 if ( ftdc > 0 && btdc < 0 ) { fbtdc = ftdc; }
1822 else if ( ftdc < 0 && btdc > 0 ) { fbtdc = btdc; }
1823 else if ( ftdc < 0 && btdc < 0 )
continue;
1824 t0forward_trk = fbtdc - forevtime;
1829 tofCaliSvc->EtfTime( ( *iter2 )->tdc1(), ( *iter2 )->tdc2(),
1830 ( *iter2 )->tofId(), ( *iter2 )->strip() ) -
1834 if ( t0forward_trk < -1 )
continue;
1835 if (
m_TofOpt && nmatch_end != 0 &&
1836 fabs( t0forward_trk - t0forward_add / nmatch_end ) > 9 )
1838 if (
m_debug == 4 ) { cout <<
"t0forward_trk:" << t0forward_trk << endl; }
1839 t0forward_add += t0forward_trk;
1840 if ( nmatch > 499 )
break;
1841 Tof_t0Arr[nmatch] = t0forward_trk;
1842 meantev[nmatch] = forevtime;
1853 if ( nmatch_end ) { tof_flag = 5; }
1856 if ( nmatch_barrel == 0 && nmatch_end == 0 )
1858 for ( TofDataVector::iterator iter2 = tofDigiVec.begin(); iter2 != tofDigiVec.end();
1861 barrelid = ( *iter2 )->barrel();
1862 if ( ( *iter2 )->barrel() != 0 )
continue;
1863 if ( ( *iter2 )->times() != 1 )
continue;
1864 tofid = ( *iter2 )->tofId();
1866 if ( !( ( *iter2 )->is_mrpc() ) )
1868 if ( tofid < 48 ) { barrelid = 0; }
1869 if ( tofid > 47 ) { barrelid = 2; }
1870 if ( barrelid == 2 ) { tofid = tofid - 48; }
1873 else if ( ( *iter2 )->is_mrpc() )
1878 if ( barrelid == 2 ) { tofid = tofid - 36; }
1881 log << MSG::INFO <<
" is_mrpc = " << ( *iter2 )->is_mrpc() <<
" TofId = " << tofid
1882 <<
" barrelid = " << barrelid << endmsg <<
" ForwordADC = " << ( *iter2 )->adc()
1883 <<
" ForwordTDC = " << ( *iter2 )->tdc() << endmsg;
1884 double ftdc = ( *iter2 )->tdc();
1885 double fadc = ( *iter2 )->adc();
1887 cout <<
"endcap::single hit,barrelid,tofid,tdc: " << barrelid <<
" , " << tofid
1888 <<
" , " << ftdc << endl;
1891 if ( !( ( *iter2 )->is_mrpc() ) && useEtofScin )
1893 int idptof = ( ( tofid - 1 ) == -1 ) ? 47 : tofid - 1;
1894 int idntof = ( ( tofid + 1 ) == 48 ) ? 0 : tofid + 1;
1895 for (
int i = 0; i < 2; i++ )
1897 if ( zemc_rec[0] || zemc_rec[1] )
1899 if ( tofid == tofid_emc[i] || tofid_emc[i] == idntof || tofid_emc[i] == idptof )
1901 if ( ftdc > 2000. || module[i] == 1 )
continue;
1904 sqrt( xemc_rec[i] * xemc_rec[i] + yemc_rec[i] * yemc_rec[i] + 133 * 133 ) /
1906 r_endtof[i] = sqrt( xemc_rec[i] * xemc_rec[i] + yemc_rec[i] * yemc_rec[i] );
1907 if ( optCosmic && ( tofid < 24 || ( tofid > 48 && tofid < 71 ) ) )
1909 forevtime = -ttof[i] + r_endtof[i] * 0.09 + 12.2;
1910 meantevup[ntofup] = forevtime;
1915 forevtime = ttof[i] + r_endtof[i] * 0.09 + 12.2;
1916 meantevdown[ntofdown] = forevtime;
1919 if ( ( *iter2 )->adc() < 0.0 || m_userawtime )
1920 { t0forward_trk = ftdc - forevtime; }
1923 t0forward_trk = tofCaliSvc->ETime( ( *iter2 )->adc(), ( *iter2 )->tdc(),
1924 r_endtof[i], ( *iter2 )->tofId() ) -
1927 cout <<
"emc flag t0forward_trk: " << t0forward_trk << endl;
1930 if ( t0forward_trk < -1. )
continue;
1931 if ( !
m_TofOpt && nmatch_end != 0 &&
1932 fabs( t0forward_trk - t0forward_add / nmatch_end ) > 9 )
1934 t0forward_add += t0forward_trk;
1935 if ( nmatch > 499 )
break;
1936 meantev[nmatch] = forevtime;
1937 Tof_t0Arr[nmatch] = t0forward_trk;
1946 if ( ( *iter2 )->is_mrpc() && useEtofMRPC )
1948 double btdc = ( *iter2 )->tdc2();
1949 double badc = ( *iter2 )->adc2();
1950 int idptof = ( ( tofid - 1 ) == -1 ) ? 35 : tofid - 1;
1951 int idntof = ( ( tofid + 1 ) == 36 ) ? 0 : tofid + 1;
1952 for (
int i = 0; i < 2; i++ )
1954 if ( zemc_rec[0] || zemc_rec[1] )
1956 if ( tofid == etfid_emc[i] || etfid_emc[i] == idntof || etfid_emc[i] == idptof )
1959 if ( ftdc > 2000. || module[i] == 1 )
continue;
1962 sqrt( xemc_rec[i] * xemc_rec[i] + yemc_rec[i] * yemc_rec[i] + 133 * 133 ) /
1964 r_endetf[i] = sqrt( xemc_rec[i] * xemc_rec[i] + yemc_rec[i] * yemc_rec[i] );
1965 if ( optCosmic && ( tofid < 18 || ( tofid > 35 && tofid < 54 ) ) )
1967 forevtime = -tetf[i] + 17.7;
1968 meantevup[ntofup] = forevtime;
1973 forevtime = tetf[i] + 17.7;
1974 meantevdown[ntofdown] = forevtime;
1980 double fbtdc = ( ftdc + btdc ) / 2.0;
1981 if ( ftdc > 0 && btdc < 0 ) { fbtdc = ftdc; }
1982 else if ( ftdc < 0 && btdc > 0 ) { fbtdc = btdc; }
1983 else if ( ftdc < 0 && btdc < 0 )
continue;
1984 t0forward_trk = fbtdc - forevtime;
1989 tofCaliSvc->EtfTime( ( *iter2 )->tdc1(), ( *iter2 )->tdc2(),
1990 ( *iter2 )->tofId(), ( *iter2 )->strip() ) -
1994 if ( t0forward_trk < -1 )
continue;
1995 if ( !
m_TofOpt && nmatch_end != 0 &&
1996 fabs( t0forward_trk - t0forward_add / nmatch_end ) > 9 )
1998 if (
m_debug == 4 ) { cout <<
"t0forward_trk:" << t0forward_trk << endl; }
1999 t0forward_add += t0forward_trk;
2000 if ( nmatch > 499 )
break;
2001 Tof_t0Arr[nmatch] = t0forward_trk;
2010 if ( nmatch_end ) { tof_flag = 5; }
2013 if ( nmatch_barrel == 0 && nmatch_end == 0 )
2015 for ( TofDataVector::iterator iter2 = tofDigiVec.begin(); iter2 != tofDigiVec.end();
2018 log << MSG::INFO <<
"TOF digit No: " << digiId << endmsg;
2019 barrelid = ( *iter2 )->barrel();
2020 if ( ( *iter2 )->barrel() != 0 )
continue;
2021 if ( ( *iter2 )->times() > 1 && ( *iter2 )->times() < 5 )
2023 tofid = ( *iter2 )->tofId();
2025 if ( !( ( *iter2 )->is_mrpc() ) )
2027 if ( tofid < 48 ) { barrelid = 0; }
2028 if ( tofid > 47 ) { barrelid = 2; }
2029 if ( barrelid == 2 ) { tofid = tofid - 48; }
2032 else if ( ( *iter2 )->is_mrpc() )
2038 if ( barrelid == 2 ) { tofid = tofid - 36; }
2040 log << MSG::INFO <<
" TofId = " << tofid <<
" barrelid = " << barrelid << endmsg
2041 <<
" ForwordADC = " << ( *iter2 )->adc() <<
" ForwordTDC = " << ( *iter2 )->tdc()
2043 double ftdc = ( *iter2 )->tdc();
2044 double fadc = ( *iter2 )->adc();
2047 cout <<
"endcap::multi hit,barrelid,tofid,tdc: " << barrelid <<
" , " << tofid
2048 <<
" , " << ftdc << endl;
2052 if ( !( ( *iter2 )->is_mrpc() ) && useEtofScin )
2054 int idptof = ( ( tofid - 1 ) == -1 ) ? 47 : tofid - 1;
2055 int idntof = ( ( tofid + 1 ) == 48 ) ? 0 : tofid + 1;
2057 if ( idmatch[barrelid][tofid] == 1 || idmatch[barrelid][idptof] == 1 ||
2058 idmatch[barrelid][idntof] == 1 )
2060 for (
int i = 0; i < ntot; i++ )
2062 if ( ttof[i] != 0 && ftdc > 0 )
2064 if ( ( tofid_helix[i] == tofid ) || ( tofid_helix[i] == idntof ) ||
2065 ( tofid_helix[i] == idptof ) )
2067 if ( barrelid == 0 || barrelid == 2 )
2069 if ( r_endtof[i] >= 41 && r_endtof[i] <= 90 )
2071 if ( optCosmic && ( tofid < 24 || ( tofid > 48 && tofid < 71 ) ) )
2073 forevtime = -ttof[i] + r_endtof[i] * 0.09 + 12.2;
2074 meantevup[ntofup] = forevtime;
2079 forevtime = ttof[i] + r_endtof[i] * 0.09 + 12.2;
2080 meantevdown[ntofdown] = forevtime;
2083 if ( ( *iter2 )->adc() < 0.0 || m_userawtime )
2084 { t0forward_trk = ftdc - forevtime; }
2088 tofCaliSvc->ETime( ( *iter2 )->adc(), ( *iter2 )->tdc(),
2089 r_endtof[i], ( *iter2 )->tofId() ) -
2093 if ( t0forward_trk < -1. )
continue;
2094 if ( !
m_TofOpt && nmatch_end != 0 &&
2095 fabs( t0forward_trk - t0forward_add / nmatch_end ) > 9 )
2097 t0forward_add += t0forward_trk;
2098 if ( nmatch > 499 )
break;
2099 meantev[nmatch] = forevtime;
2100 Tof_t0Arr[nmatch] = t0forward_trk;
2105 if (
m_debug == 4 ) { cout <<
"t0forward_trk:" << t0forward_trk << endl; }
2112 if ( ( *iter2 )->is_mrpc() && useEtofMRPC )
2114 double btdc = ( *iter2 )->tdc2();
2115 double badc = ( *iter2 )->adc2();
2116 int idptof = ( ( tofid - 1 ) == -1 ) ? 35 : tofid - 1;
2117 int idntof = ( ( tofid + 1 ) == 36 ) ? 0 : tofid + 1;
2119 if ( idetfmatch[barrelid][tofid] == 1 || idetfmatch[barrelid][idptof] == 1 ||
2120 idetfmatch[barrelid][idntof] == 1 )
2122 for (
int i = 0; i < ntot; i++ )
2124 if ( tetf[i] != 0 && ftdc > 0 && ftdc < 2000. )
2126 if ( etfid_helix[i] == tofid || etfid_helix[i] == idntof ||
2127 etfid_helix[i] == idptof )
2129 if ( barrelid == 0 || barrelid == 2 )
2131 if ( r_endetf[i] >= 41 && r_endetf[i] <= 90 )
2133 if ( optCosmic && ( tofid < 18 || ( tofid > 35 && tofid < 54 ) ) )
2135 forevtime = -tetf[i] + 17.7;
2136 meantevup[ntofup] = forevtime;
2141 forevtime = tetf[i] + 17.7;
2142 meantevdown[ntofdown] = forevtime;
2147 double fbtdc = ( ftdc + btdc ) / 2.0;
2148 if ( ftdc > 0 && btdc < 0 ) { fbtdc = ftdc; }
2149 else if ( ftdc < 0 && btdc > 0 ) { fbtdc = btdc; }
2150 else if ( ftdc < 0 && btdc < 0 )
continue;
2151 t0forward_trk = fbtdc - forevtime;
2156 tofCaliSvc->EtfTime( ( *iter2 )->tdc1(), ( *iter2 )->tdc2(),
2157 ( *iter2 )->tofId(), ( *iter2 )->strip() ) -
2161 if ( t0forward_trk < -1 )
continue;
2162 if ( !
m_TofOpt && nmatch_end != 0 &&
2163 fabs( t0forward_trk - t0forward_add / nmatch_end ) > 9 )
2166 { cout <<
"t0forward_trk:" << t0forward_trk << endl; }
2167 t0forward_add += t0forward_trk;
2168 if ( nmatch > 499 )
break;
2169 Tof_t0Arr[nmatch] = t0forward_trk;
2170 meantev[nmatch] = forevtime;
2182 if ( nmatch_end ) { tof_flag = 7; }
2187 g_nmatchbarrel = nmatch_barrel;
2188 g_nmatchbarrel_1 = nmatch_barrel_1;
2189 g_nmatchbarrel_2 = nmatch_barrel_2;
2190 g_nmatchend = nmatch_end;
2193 if ( nmatch_end != 0 )
2195 t0forward = t0forward_add / nmatch_end;
2196 if ( optCosmic == 0 )
2200 t_Est = EST_Trimmer( Opt_new( Tof_t0Arr, nmatch,
m_TofOpt_Cut ), tOffset_e,
2225 if ( t_Est < 0 ) t_Est = 0;
2226 if ( tof_flag == 5 ) tEstFlag = 151;
2227 else if ( tof_flag == 7 ) tEstFlag = 171;
2228 if ( emcflag2 == 1 ) tEstFlag = 161;
2241 if ( tof_flag == 5 ) tEstFlag = 251;
2242 else if ( tof_flag == 7 ) tEstFlag = 271;
2243 if ( emcflag2 == 1 ) tEstFlag = 261;
2248 double t0_comp = -999;
2251 if ( nmatch_barrel == 0 && nmatch_end == 0 &&
m_flag == 1 )
2253 double mhit[43][300] = { 0. };
2254 SmartDataPtr<MdcDigiCol> mdcDigiCol( eventSvc(),
"/Event/Digi/MdcDigiCol" );
2257 log << MSG::INFO <<
"Could not find MDC digi" << endmsg;
2258 return StatusCode::FAILURE;
2262 StatusCode sc = service(
"MdcGeomSvc", mdcGeomSvc );
2263 if ( sc != StatusCode::SUCCESS ) {
return StatusCode::FAILURE; }
2265 MdcDigiCol::iterator iter1 = mdcDigiCol->begin();
2271 for ( ; iter1 != mdcDigiCol->end(); iter1++, digiId++ )
2273 mdcId = ( *iter1 )->identify();
2278 mhit[layerId][wireId] -= 1.28 * ( mdcGeomSvc->
Layer( layerId )->Radius() ) / 299.8;
2280 mdcGeomSvc->
Wire( layerId, wireId );
2286 int Iused[43][300] = { 0 }, tmp = 0;
2287 bool Lpat, Lpat11, Lpat12, Lpat2, Lpat31, Lpat32;
2288 double t0_all = 0, t0_mean = 0;
2289 double r[4] = { 0. };
2290 double chi2 = 999.0;
2291 double phi[4] = { 0. }, corr[4] = { 0. }, driftt[4] = { 0. };
2293 double mchisq = 50000;
2296 for (
int i = 5; i < 10; i++ )
2299 double T1 = 0.5 * 0.1 * ( mdcGeomSvc->
Layer( 4 * i + 0 )->PCSiz() ) / 0.004;
2300 double T2 = 0.5 * 0.1 * ( mdcGeomSvc->
Layer( 4 * i + 1 )->PCSiz() ) / 0.004;
2301 double T3 = 0.5 * 0.1 * ( mdcGeomSvc->
Layer( 4 * i + 2 )->PCSiz() ) / 0.004;
2302 double T4 = 0.5 * 0.1 * ( mdcGeomSvc->
Layer( 4 * i + 3 )->PCSiz() ) / 0.004;
2303 r[0] = ( mdcGeomSvc->
Layer( 4 * i + 0 )->Radius() ) * 0.1;
2304 r[1] = ( mdcGeomSvc->
Layer( 4 * i + 1 )->Radius() ) * 0.1;
2305 r[2] = ( mdcGeomSvc->
Layer( 4 * i + 2 )->Radius() ) * 0.1;
2306 r[3] = ( mdcGeomSvc->
Layer( 4 * i + 3 )->Radius() ) * 0.1;
2307 double r0 = r[0] - r[1] - ( r[2] - r[1] ) / 2;
2308 double r1 = -( r[2] - r[1] ) / 2;
2309 double r2 = ( r[2] - r[1] ) / 2;
2310 double r3 = r[3] - r[2] + ( r[2] - r[1] ) / 2;
2312 for (
int j = 0; j < mdcGeomSvc->
Layer( i * 4 + 3 )->NCell(); j++ )
2317 if ( Icp < 0 ) Icp = mdcGeomSvc->
Layer( i * 4 + 3 )->
NCell();
2319 Lpat = ( mhit[4 * i][j] != 0 ) && ( mhit[4 * i][Icp] == 0 ) &&
2320 ( mhit[4 * i][j + 1] == 0 ) && ( Iused[4 * i][j] == 0 );
2323 Lpat11 = ( mhit[4 * i + 1][Icp] == 0 ) && ( Iused[4 * i + 1][j] == 0 ) &&
2324 ( mhit[4 * i + 1][j] != 0 ) && ( mhit[4 * i + 1][j + 1] == 0 );
2325 Lpat12 = ( mhit[4 * i + 1][j] == 0 ) && ( Iused[4 * i + 1][j + 1] == 0 ) &&
2326 ( mhit[4 * i + 1][j + 1] != 0 ) && ( mhit[4 * i + 1][j + 2] == 0 );
2327 Lpat2 = ( mhit[4 * i + 2][Icp] == 0 ) && ( Iused[4 * i + 2][j] == 0 ) &&
2328 ( mhit[4 * i + 2][j] != 0 ) && ( mhit[4 * i + 2][j + 1] == 0 );
2329 Lpat31 = ( mhit[4 * i + 3][Icp] == 0 ) && ( Iused[4 * i + 3][j] == 0 ) &&
2330 ( mhit[4 * i + 3][j] != 0 ) && ( mhit[4 * i + 3][j + 1] == 0 );
2331 Lpat32 = ( mhit[4 * i + 3][j] == 0 ) && ( Iused[4 * i + 3][j + 1] == 0 ) &&
2332 ( mhit[4 * i + 3][j + 1] != 0 ) && ( mhit[4 * i + 3][j + 2] == 0 );
2334 if ( Lpat11 && Lpat2 && Lpat31 )
2337 Iused[4 * i + 0][j] = 1;
2338 Iused[4 * i + 1][j] = 1;
2339 Iused[4 * i + 2][j] = 1;
2340 Iused[4 * i + 3][j] = 1;
2341 double t_i = mhit[4 * i + 0][j] + mhit[4 * i + 2][j];
2342 double t_j = mhit[4 * i + 1][j] + mhit[4 * i + 3][j];
2343 double l_j = T2 + T4;
2344 double r_i = r0 + r2;
2345 double r_j = r1 + r3;
2346 double r_2k = r0 * r0 + r1 * r1 + r2 * r2 + r3 * r3;
2347 double rt_i = r0 * mhit[4 * i + 0][j] + r2 * mhit[4 * i + 2][j];
2348 double rt_j = r1 * mhit[4 * i + 1][j] + r3 * mhit[4 * i + 3][j];
2349 double rl_j = r1 * T2 + r3 * T4;
2351 double deno = 4 * r_2k - 2 * ( r_i * r_i + r_j * r_j );
2355 double Pa = ( 4 * ( rt_i - rt_j + rl_j ) - ( t_i + t_j - l_j ) * ( r_i - r_j ) -
2356 ( t_i - t_j + l_j ) * ( r_i + r_j ) ) /
2358 double Pb = 0.25 * ( t_i - t_j + l_j - ( r_i + r_j ) * Pa );
2359 double Ang = fabs( 90. - fabs( atan( Pa ) * 180. / 3.141593 ) );
2361 t0_all += ( -0.25 * ( ( r_i - r_j ) * Pa - t_i - t_j + l_j ) );
2364 for (
int t0c = 0; t0c < 17; t0c += 8 )
2366 chi2_tmp = ( mhit[4 * i + 0][j] - t0c - r0 * Pa - Pb ) *
2367 ( mhit[4 * i + 0][j] - t0c - r0 * Pa - Pb ) +
2368 ( T2 - mhit[4 * i + 1][j] + t0c - r1 * Pa - Pb ) *
2369 ( T2 - mhit[4 * i + 1][j] + t0c - r1 * Pa - Pb ) +
2370 ( mhit[4 * i + 2][j] - t0c - r2 * Pa - Pb ) *
2371 ( mhit[4 * i + 2][j] - t0c - r2 * Pa - Pb ) +
2372 ( T4 - mhit[4 * i + 3][j] + t0c - r3 * Pa - Pb ) *
2373 ( T4 - mhit[4 * i + 3][j] + t0c - r3 * Pa - Pb );
2374 if ( chi2_tmp < chi2 )
2384 for (
int tmpT0 = 0; tmpT0 < 17; tmpT0 += 8 )
2386 driftt[0] = mhit[4 * i + 0][j] - tmpT0;
2387 driftt[1] = mhit[4 * i + 1][j] - tmpT0;
2388 driftt[2] = mhit[4 * i + 2][j] - tmpT0;
2389 driftt[3] = mhit[4 * i + 3][j] - tmpT0;
2391 phi[0] = j * 2 * 3.14159265 / ( mdcGeomSvc->
Layer( i * 4 )->NCell() ) +
2392 2 * 3.14159265 / ( mdcGeomSvc->
Layer( i * 4 + 1 )->NCell() ) / 2;
2393 phi[1] = j * 2 * 3.14159265 / ( mdcGeomSvc->
Layer( i * 4 + 1 )->NCell() );
2394 phi[2] = j * 2 * 3.14159265 / ( mdcGeomSvc->
Layer( i * 4 + 2 )->NCell() ) +
2395 2 * 3.14159265 / ( mdcGeomSvc->
Layer( i * 4 + 1 )->NCell() ) / 2;
2396 phi[3] = j * 2 * 3.14159265 / ( mdcGeomSvc->
Layer( i * 4 + 3 )->NCell() );
2397 phi[0] -= ambig * driftt[0] * 0.004 / r[0];
2398 phi[1] += ambig * driftt[1] * 0.004 / r[1];
2399 phi[2] -= ambig * driftt[2] * 0.004 / r[2];
2400 phi[3] += ambig * driftt[3] * 0.004 / r[3];
2401 double s1, sx, sy, sxx, sxy;
2402 double delinv, denom;
2411 s1 = sx = sy = sxx = sxy = 0.0;
2413 for (
int ihit = 0; ihit < 4; ihit++ )
2415 weight = 1. / ( sigma * sigma );
2418 sy += phi[ihit] *
weight;
2419 sxx += x[ihit] * ( x[ihit] *
weight );
2420 sxy += phi[ihit] * ( x[ihit] *
weight );
2422 double resid[4] = { 0. };
2424 denom = s1 * sxx - sx * sx;
2425 delinv = ( denom == 0.0 ) ? 1.e20 : 1. / denom;
2426 double intercept = ( sy * sxx - sx * sxy ) * delinv;
2427 double slope = ( s1 * sxy - sx * sy ) * delinv;
2430 for (
int ihit = 0; ihit < 4; ihit++ )
2432 resid[ihit] = ( phi[ihit] - intercept - slope * x[ihit] );
2433 chisq += resid[ihit] * resid[ihit] / ( sigma * sigma );
2435 if ( chisq < mchisq )
2442 if ( Lpat12 && Lpat2 && Lpat32 )
2444 Iused[4 * i + 0][j] = 1;
2445 Iused[4 * i + 1][j + 1] = 1;
2446 Iused[4 * i + 2][j] = 1;
2447 Iused[4 * i + 3][j + 1] = 1;
2449 double t_i = mhit[4 * i + 0][j] + mhit[4 * i + 2][j];
2450 double t_j = mhit[4 * i + 1][j + 1] + mhit[4 * i + 3][j + 1];
2451 double l_j = T2 + T4;
2452 double r_i = r0 + r2;
2453 double r_j = r1 + r3;
2454 double r_2k = r0 * r0 + r1 * r1 + r2 * r2 + r3 * r3;
2455 double rt_i = r0 * mhit[4 * i + 0][j] + r2 * mhit[4 * i + 2][j];
2456 double rt_j = r1 * mhit[4 * i + 1][j + 1] + r3 * mhit[4 * i + 3][j + 1];
2457 double rl_j = r1 * T2 + r3 * T4;
2458 double deno = 4 * r_2k - 2 * ( r_i * r_i + r_j * r_j );
2462 double Pa = ( 4 * ( rt_i - rt_j + rl_j ) - ( t_i + t_j - l_j ) * ( r_i - r_j ) -
2463 ( t_i - t_j + l_j ) * ( r_i + r_j ) ) /
2465 double Pb = 0.25 * ( t_i - t_j + l_j - ( r_i + r_j ) * Pa );
2466 double Ang = fabs( 90. - fabs( atan( Pa ) * 180. / 3.141593 ) );
2467 t0_all += ( -0.25 * ( ( r_i - r_j ) * Pa - t_i - t_j + l_j ) );
2471 for (
int t0c = 0; t0c < 17; t0c += 8 )
2473 chi2_tmp = ( mhit[4 * i + 0][j] - t0c - r0 * Pa - Pb ) *
2474 ( mhit[4 * i + 0][j] - t0c - r0 * Pa - Pb ) +
2475 ( T2 - mhit[4 * i + 1][j + 1] + t0c - r1 * Pa - Pb ) *
2476 ( T2 - mhit[4 * i + 1][j + 1] + t0c - r1 * Pa - Pb ) +
2477 ( mhit[4 * i + 2][j] - t0c - r2 * Pa - Pb ) *
2478 ( mhit[4 * i + 2][j] - t0c - r2 * Pa - Pb ) +
2479 ( T4 - mhit[4 * i + 3][j + 1] + t0c - r3 * Pa - Pb ) *
2480 ( T4 - mhit[4 * i + 3][j + 1] + t0c - r3 * Pa - Pb );
2482 if ( chi2_tmp < chi2 )
2492 for (
int tmpT0 = 0; tmpT0 < 17; tmpT0 += 8 )
2494 driftt[0] = mhit[4 * i + 0][j] - tmpT0;
2495 driftt[1] = mhit[4 * i + 1][j + 1] - tmpT0;
2496 driftt[2] = mhit[4 * i + 2][j] - tmpT0;
2497 driftt[3] = mhit[4 * i + 3][j + 1] - tmpT0;
2499 phi[0] = j * 2 * 3.14159265 / ( mdcGeomSvc->
Layer( i * 4 )->NCell() ) +
2500 2 * 3.14159265 / ( mdcGeomSvc->
Layer( i * 4 + 1 )->NCell() ) / 2;
2501 phi[1] = j * 2 * 3.14159265 / ( mdcGeomSvc->
Layer( i * 4 + 1 )->NCell() );
2502 phi[2] = j * 2 * 3.14159265 / ( mdcGeomSvc->
Layer( i * 4 + 2 )->NCell() ) +
2503 2 * 3.14159265 / ( mdcGeomSvc->
Layer( i * 4 + 1 )->NCell() ) / 2;
2504 phi[3] = j * 2 * 3.14159265 / ( mdcGeomSvc->
Layer( i * 4 + 3 )->NCell() );
2505 phi[0] -= ambig * driftt[0] * 0.004 / r[0];
2506 phi[1] += ambig * driftt[1] * 0.004 / r[1];
2507 phi[2] -= ambig * driftt[2] * 0.004 / r[2];
2508 phi[3] += ambig * driftt[3] * 0.004 / r[3];
2509 double s1, sx, sy, sxx, sxy;
2510 double delinv, denom;
2519 s1 = sx = sy = sxx = sxy = 0.0;
2521 for (
int ihit = 0; ihit < 4; ihit++ )
2523 weight = 1. / ( sigma * sigma );
2526 sy += phi[ihit] *
weight;
2527 sxx += x[ihit] * ( x[ihit] *
weight );
2528 sxy += phi[ihit] * ( x[ihit] *
weight );
2530 double resid[4] = { 0. };
2532 denom = s1 * sxx - sx * sx;
2533 delinv = ( denom == 0.0 ) ? 1.e20 : 1. / denom;
2534 double intercept = ( sy * sxx - sx * sxy ) * delinv;
2535 double slope = ( s1 * sxy - sx * sy ) * delinv;
2538 for (
int ihit = 0; ihit < 4; ihit++ )
2540 resid[ihit] = ( phi[ihit] - intercept - slope * x[ihit] );
2541 chisq += resid[ihit] * resid[ihit] / ( sigma * sigma );
2544 if ( chisq < mchisq )
2555 if ( tmp != 0 ) { t0_mean = t0_all / tmp; }
2558 t_Est = T0 + tOffset_b;
2566 if ( nmatch_barrel == 0 && nmatch_end == 0 && nmatch_barrel_1 == 0 && nmatch_barrel_2 == 0 &&
2567 m_mdcCalibFunSvc &&
m_flag == 2 )
2570 log << MSG::INFO <<
" mdc " << endmsg;
2587 double t0_minus_TDC[
MXWIRE];
2589 double T0_cal = -230;
2590 double Mdc_t0Arr[500];
2603 if ( !newtrkCol || newtrkCol->size() == 0 )
2605 log << MSG::INFO <<
"Could not find RecMdcTrackCol" << endmsg;
2606 return StatusCode::SUCCESS;
2608 log << MSG::INFO <<
"Begin to check RecMdcTrackCol" << endmsg;
2610 RecMdcTrackCol::iterator iter_trk = newtrkCol->begin();
2612 for (
int tempntrack = 0; iter_trk != newtrkCol->end(); iter_trk++, tempntrack++ )
2614 log << MSG::DEBUG <<
"retrieved MDC track:"
2615 <<
" Track Id: " << ( *iter_trk )->trackId() <<
" Dr: " << ( *iter_trk )->helix( 0 )
2616 <<
" Phi0: " << ( *iter_trk )->helix( 1 ) <<
" kappa: " << ( *iter_trk )->helix( 2 )
2617 <<
" Dz: " << ( *iter_trk )->helix( 3 ) <<
" Tanl: " << ( *iter_trk )->helix( 4 )
2618 <<
" Phi terminal: " << ( *iter_trk )->getFiTerm() << endmsg
2619 <<
"Number of hits: " << ( *iter_trk )->getNhits() <<
" Number of stereo hits "
2620 << ( *iter_trk )->nster() << endmsg;
2623 const HepPoint3D pivot0( 0., 0., 0. );
2624 HepVector a( 5, 0 );
2626 a[0] = ( *iter_trk )->helix( 0 );
2627 a[1] = ( *iter_trk )->helix( 1 );
2628 a[2] = ( *iter_trk )->helix( 2 );
2629 a[3] = ( *iter_trk )->helix( 3 );
2630 a[4] = ( *iter_trk )->helix( 4 );
2634 abs( a[4] ) > 500. )
2638 double kappa =
abs( a[2] );
2639 double dirmag = sqrt( 1. + a[4] * a[4] );
2641 double mom =
abs( dirmag / kappa );
2642 double beta = mom / sqrt( mom * mom +
PIMAS2 );
2643 if ( particleId[tempntrack] == 1 ) { beta = mom / sqrt( mom * mom +
ELMAS2 ); }
2644 if ( particleId[tempntrack] == 5 ) { beta = mom / sqrt( mom * mom +
PROTONMAS2 ); }
2647 Helix helix0( pivot0, a );
2648 double rho = helix0.
radius();
2649 double unit_s =
abs( rho * dirmag );
2652 HepPoint3D hcen = helix0.
center();
2653 double xc = hcen( 0 );
2654 double yc = hcen( 1 );
2656 if ( xc == 0.0 && yc == 0.0 )
continue;
2658 double direction = 1.;
2659 if ( optCosmic != 0 )
2661 double phi = atan2( helix0.
momentum( 0. ).y(), helix0.
momentum( 0. ).x() );
2662 if ( phi > 0. && phi <=
M_PI ) direction = -1.;
2666 StatusCode sc = service(
"MdcGeomSvc", mdcGeomSvc );
2669 double m_vp[43] = { 0. }, m_zst[43] = { 0. };
2670 for (
int lay = 0; lay < 43; lay++ )
2672 zwest = mdcGeomSvc->
Wire( lay, 0 )->
Forward().z();
2676 if ( lay < 8 ) m_vp[lay] = 220.0;
2677 else m_vp[lay] = 240.0;
2679 if ( 0 == ( lay % 2 ) )
2690 log << MSG::DEBUG <<
"hitList of this track:" << endmsg;
2691 HitRefVec gothits = ( *iter_trk )->getVecHits();
2692 HitRefVec::iterator it_gothit = gothits.begin();
2693 for ( ; it_gothit != gothits.end(); it_gothit++ )
2696 log << MSG::DEBUG <<
"hits Id: " << ( *it_gothit )->getId()
2697 <<
" hits MDC layerId wireId " <<
MdcID::layer( ( *it_gothit )->getMdcId() )
2698 <<
" " <<
MdcID::wire( ( *it_gothit )->getMdcId() ) << endmsg <<
" hits TDC "
2699 << ( *it_gothit )->getTdc() << endmsg;
2701 int layer =
MdcID::layer( ( *it_gothit )->getMdcId() );
2702 int wid =
MdcID::wire( ( *it_gothit )->getMdcId() );
2703 double tdc = ( *it_gothit )->getTdc();
2706 double trkchi2 = ( *iter_trk )->chi2();
2707 if ( trkchi2 > 100 )
continue;
2708 double hitChi2 = ( *it_gothit )->getChisqAdd();
2709 HepVector helix_par = ( *iter_trk )->helix();
2710 HepSymMatrix helixErr = ( *iter_trk )->err();
2712 if ( ( layer >= 8 && layer <= 19 ) || ( layer >= 36 && layer <= 42 ) )
2729 if ( Estparam.
MDC_Inner() == 0 && layer <= 3 )
continue;
2731 double xw = GeoRef->
Forward().x() / 10;
2732 double yw = GeoRef->
Forward().y() / 10;
2734 HepPoint3D pivot1( xw, yw, 0. );
2735 helix0.
pivot( pivot1 );
2736 double zw = helix0.
a()[3];
2739 double dphi = ( -xc * ( xw - xc ) - yc * ( yw - yc ) ) /
2740 sqrt( ( xc * xc + yc * yc ) *
2741 ( ( xw - xc ) * ( xw - xc ) + ( yw - yc ) * ( yw - yc ) ) );
2742 dphi = acos( dphi );
2743 double pathtof =
abs( unit_s * dphi );
2744 if ( kappa != 0 ) { toft = pathtof /
VLIGHT / beta; }
2745 else { toft = pathtof /
VLIGHT; }
2751 if ( zw > ( GeoRef->
Backward().z() ) / 10 ) zw = ( GeoRef->
Backward().z() ) / 10;
2752 if ( zw < ( GeoRef->
Forward().z() ) / 10 ) zw = ( GeoRef->
Forward().z() ) / 10;
2754 double slant = GeoRef->
Slant();
2779 dist = ( m_mdcUtilitySvc->doca( layer, wid, helix_par, helixErr ) ) * 10.0;
2781 if ( dist < 0. ) lr = 1;
2783 dist = fabs( dist );
2784 if ( dist > 0.4 * ( mdcGeomSvc->
Layer( layer ) )->PCSiz() )
continue;
2807 double entrance = ( *it_gothit )->getEntra();
2808 driftt = m_mdcCalibFunSvc->distToDriftTime( dist, layer, wid, lr, entrance );
2812 T0_cal = m_mdcCalibFunSvc->getT0( layer, wid ) +
2813 m_mdcCalibFunSvc->getTimeWalk( layer, tdc );
2816 double zprop = fabs( zw - m_zst[layer] );
2817 double tp = zprop / m_vp[layer];
2819 if ( driftt > tdc )
continue;
2820 double difft = tdc - driftt - toft - tp - T0_cal;
2821 if ( ndriftt >= 500 )
break;
2822 if (
difft < -10 )
continue;
2823 Mdc_t0Arr[ndriftt] =
difft;
2826 sum_EstimeMdc = sum_EstimeMdc +
difft;
2837 double tev = -t0_minus_TDC[wid] + driftt;
2838 if ( Estparam.
MDC_Tof() != 0 ) tev += direction * toft;
2839 if ( Estparam.
MDC_Prop() != 0 ) tev += prop;
2845 tev_ax[nhits_ax - 1] = tev;
2847 if ( Estparam.
MDC_Debug() != 0 ) log << MSG::INFO <<
"*** tev ***" << tev << endmsg;
2848 double driftt_mea = t0_minus_TDC[wid];
2850 if (
abs( driftt - driftt_mea ) < 75. )
2855 log << MSG::INFO <<
"*** tev2 ***" << tev << endmsg;
2860 else if ( ( ( layer >= 4 && layer <= 7 ) || ( layer >= 20 && layer <= 35 ) ) &&
2865 StatusCode sc = service(
"MdcGeomSvc", mdcGeomSvc );
2871 double bx = GeoRef->
Backward().x() / 10;
2872 double by = GeoRef->
Backward().y() / 10;
2873 double bz = GeoRef->
Backward().z() / 10;
2874 double fx = GeoRef->
Forward().x() / 10;
2875 double fy = GeoRef->
Forward().y() / 10;
2876 double fz = GeoRef->
Forward().z() / 10;
2882 HepPoint3D fwd( fx, fy, fz );
2883 HepPoint3D bck( bx, by, bz );
2885 Hep3Vector wire = (CLHEP::Hep3Vector)bck - (CLHEP::Hep3Vector)fwd;
2886 HepPoint3D try1 = ( fwd + bck ) * .5;
2887 helix0.
pivot( try1 );
2888 HepPoint3D try2 = ( helix0.
x( 0 ).z() - bck.z() ) / wire.z() * wire + bck;
2889 helix0.
pivot( try2 );
2890 HepPoint3D try3 = ( helix0.
x( 0 ).z() - bck.z() ) / wire.z() * wire + bck;
2891 helix0.
pivot( try3 );
2893 double xh = helix0.
x( 0. ).x();
2894 double yh = helix0.
x( 0. ).y();
2895 double z = helix0.
x( 0. ).z();
2898 double dphi = ( -xc * ( xh - xc ) - yc * ( yh - yc ) ) /
2899 sqrt( ( xc * xc + yc * yc ) *
2900 ( ( xh - xc ) * ( xh - xc ) + ( yh - yc ) * ( yh - yc ) ) );
2901 dphi = acos( dphi );
2902 double pathtof =
abs( unit_s * dphi );
2903 if ( kappa != 0 ) { toft = pathtof /
VLIGHT / beta; }
2904 else { toft = pathtof /
VLIGHT; }
2911 if ( z < fz ) z = fz;
2913 if ( z > bz ) z = bz;
2914 double slant = GeoRef->
Slant();
2929 double xw = fx + ( bx - fx ) / ( bz - fz ) * ( z - fz );
2930 double yw = fy + ( by - fy ) / ( bz - fz ) * ( z - fz );
2932 HepPoint3D pivot1( xw, yw, z );
2933 helix0.
pivot( pivot1 );
2935 double zw = helix0.
a()[3];
2951 dist = ( m_mdcUtilitySvc->doca( layer, wid, helix_par, helixErr ) ) * 10.0;
2953 if ( dist < 0. ) lr = 1;
2955 dist = fabs( dist );
2956 if ( dist > 0.4 * ( mdcGeomSvc->
Layer( layer ) )->PCSiz() )
continue;
2977 double entrance = ( *it_gothit )->getEntra();
2978 driftt = m_mdcCalibFunSvc->distToDriftTime( dist, layer, wid, lr, entrance );
2982 T0_cal = m_mdcCalibFunSvc->getT0( layer, wid ) +
2983 m_mdcCalibFunSvc->getTimeWalk( layer, tdc );
2986 double zprop = fabs( zw - m_zst[layer] );
2987 double tp = zprop / m_vp[layer];
2989 if ( driftt > tdc )
continue;
2990 double difft = tdc - driftt - toft - tp - T0_cal;
2991 if (
difft < -10 )
continue;
2992 if ( ndriftt >= 500 )
break;
2993 Mdc_t0Arr[ndriftt] =
difft;
2997 sum_EstimeMdc = sum_EstimeMdc +
difft;
3002 double tev = -t0_minus_TDC[wid] + driftt;
3003 if ( Estparam.
MDC_Tof() != 0 ) tev += direction * toft;
3004 if ( Estparam.
MDC_Prop() != 0 ) tev += prop;
3012 tev_st[nhits_st - 1] = tev;
3015 log << MSG::INFO <<
"*** tev_st ***" << tev << endmsg;
3016 double driftt_mea = t0_minus_TDC[wid];
3018 if (
abs( driftt - driftt_mea ) < 75. )
3023 log << MSG::INFO <<
"*** tev_st2 ***" << tev << endmsg;
3031 if (
m_ntupleflag && m_tuple2 ) g_nmatchmdc = nmatch_mdc;
3034 if (
m_mdcopt ) { sum_EstimeMdc = Opt_new( Mdc_t0Arr, ndriftt, 400.0 ); }
3035 else { sum_EstimeMdc = sum_EstimeMdc / ndriftt; }
3036 if (
m_ntupleflag && m_tuple2 ) g_EstimeMdc = sum_EstimeMdc;
3037 t_Est = sum_EstimeMdc + tOffset_b;
3038 if ( t_Est < 0 ) t_Est = 0;
3039 if ( optCosmic == 0 )
3042 nbunch = ( (int)( t_Est - offset ) ) / bunchtime;
3044 if ( ( t_Est - offset - nbunch * bunchtime ) > ( bunchtime / 2 ) ) nbunch = nbunch + 1;
3045 t_Est = nbunch * bunchtime + offset + tOffset_b;
3056 t_Est = sum_EstimeMdc;
3063 if ( t_Est != -999 )
3066 if ( ( !
m_beforrec ) && ( Testime_fzisan != t_Est ) )
3068 if ( tEstFlag == 211 ) tEstFlag = 213;
3069 if ( tEstFlag == 212 ) tEstFlag = 216;
3070 if ( tEstFlag == 111 ) tEstFlag = 113;
3071 if ( tEstFlag == 112 ) tEstFlag = 116;
3076 StatusCode scStoreTds = storeTDS( t_Est, tEstFlag, t_quality );
3077 if ( scStoreTds != StatusCode::SUCCESS ) {
return scStoreTds; }
3079 else if ( !optCosmic )
3081 StatusCode scStoreTds = storeTDS( t_Est, tEstFlag, t_quality );
3082 if ( scStoreTds != StatusCode::SUCCESS ) {
return scStoreTds; }
3092 double segTest = Testime_fzisan + tOffset_b;
3093 int segFlag = TestimeFlag_fzisan;
3094 double segQuality = TestimeQuality_fzisan;
3095 StatusCode scStoreTds = storeTDS( segTest, segFlag, segQuality );
3096 if ( scStoreTds != StatusCode::SUCCESS ) {
return scStoreTds; }
3102 SmartDataPtr<RecEsTimeCol> arecestimeCol( eventSvc(),
"/Event/Recon/RecEsTimeCol" );
3103 if ( !arecestimeCol )
3105 if (
m_debug == 4 ) log << MSG::WARNING <<
"Could not find RecEsTimeCol" << endmsg;
3106 return ( StatusCode::SUCCESS );
3108 RecEsTimeCol::iterator iter_evt = arecestimeCol->begin();
3109 for ( ; iter_evt != arecestimeCol->end(); iter_evt++ )
3111 log << MSG::INFO <<
"Test = " << ( *iter_evt )->getTest()
3112 <<
", Status = " << ( *iter_evt )->getStat() << endmsg;
3113 if (
m_ntupleflag && m_tuple2 ) { g_Testime = ( *iter_evt )->getTest(); }
3121 for ( g_ntofdown = 0; g_ntofdown < ntofdown; g_ntofdown++ )
3122 { g_meantevdown[g_ntofdown] = meantevdown[g_ntofdown]; }
3123 for ( g_ntofup = 0; g_ntofup < ntofup; g_ntofup++ )
3124 { g_meantevup[g_ntofup] = meantevup[g_ntofup]; }
3125 g_nmatch_tot = nmatch;
3126 m_estFlag = tEstFlag;
3128 StatusCode status = m_tuple2->write();
3129 if ( !status.isSuccess() ) { log << MSG::ERROR <<
"Can't fill ntuple!" << endmsg; }
3133 for ( g_nmatch = 0; g_nmatch < nmatch; g_nmatch++ )
3134 { g_meantev[g_nmatch] = meantev[g_nmatch]; }
3135 StatusCode status = m_tuple9->write();
3136 if ( !status.isSuccess() ) { log << MSG::ERROR <<
"Can't fill ntuple!" << endmsg; }
3139 return StatusCode::SUCCESS;