338 {
339
340
341
342 MsgStream log(
msgSvc(), name() );
343 log << MSG::INFO << "in execute()" << endmsg;
344
345 SmartDataPtr<Event::EventHeader> eventHeader( eventSvc(), "/Event/EventHeader" );
346 int runNo = eventHeader->runNumber();
347 int event = eventHeader->eventNumber();
348 log << MSG::DEBUG <<
"run, evtnum = " <<
runNo <<
" , " <<
event << endmsg;
349 cout << "event " << event << endl;
351
353
354 log << MSG::DEBUG << "ncharg, nneu, tottks = " << evtRecEvent->totalCharged() << " , "
355 << evtRecEvent->totalNeutral() << " , " << evtRecEvent->totalTracks() << endmsg;
356
358
359
360
361
362 Vint iGood, ipip, ipim;
363 iGood.clear();
364 ipip.clear();
365 ipim.clear();
367 ppip.clear();
368 ppim.clear();
369
370 int nCharge = 0;
371
372 Hep3Vector xorigin( 0, 0, 0 );
373
374
375
376
377
378
379
380
381
382
383 SmartIF<IVertexDbSvc> m_vtxSvc;
384 m_vtxSvc = serviceLocator()->service( "VertexDbSvc" );
385 if ( m_vtxSvc->isVertexValid() )
386 {
387
388 double* dbv = m_vtxSvc->PrimaryVertex();
389 double* vv = m_vtxSvc->SigmaPrimaryVertex();
390 xorigin.setX( dbv[0] );
391 xorigin.setY( dbv[1] );
392 xorigin.setZ( dbv[2] );
393 }
394
395 for ( int i = 0; i < evtRecEvent->totalCharged(); i++ )
396 {
398 if ( !( *itTrk )->isMdcTrackValid() ) continue;
399 RecMdcTrack* mdcTrk = ( *itTrk )->mdcTrack();
400 double pch = mdcTrk->
p();
401 double x0 = mdcTrk->
x();
402 double y0 = mdcTrk->
y();
403 double z0 = mdcTrk->
z();
404 double theta0 = mdcTrk->
theta();
405 double phi0 = mdcTrk->
helix( 1 );
406 double xv = xorigin.x();
407 double yv = xorigin.y();
408 double Rxy = ( x0 - xv ) *
cos( phi0 ) + ( y0 - yv ) *
sin( phi0 );
409 m_vx0 = x0;
410 m_vy0 = y0;
411 m_vz0 = z0;
412 m_vr0 = Rxy;
413
414 HepVector a = mdcTrk->
helix();
415 HepSymMatrix Ea = mdcTrk->
err();
417 HepPoint3D IP( xorigin[0], xorigin[1], xorigin[2] );
418 VFHelix helixip( point0, a, Ea );
419 helixip.pivot( IP );
420 HepVector vecipa = helixip.a();
421 double Rvxy0 = fabs( vecipa[0] );
422 double Rvz0 = vecipa[3];
423 double Rvphi0 = vecipa[1];
424 m_rvxy0 = Rvxy0;
425 m_rvz0 = Rvz0;
426 m_rvphi0 = Rvphi0;
427
428 m_tuple1->write();
429
430
431
432 if ( fabs( Rvz0 ) >= 10.0 ) continue;
433 if ( fabs( Rvxy0 ) >= 1.0 ) continue;
434 if ( fabs(
cos( theta0 ) ) >= 0.93 )
continue;
435
436 iGood.push_back( i );
437 nCharge += mdcTrk->
charge();
438 }
439
440
441
442
443 int nGood = iGood.size();
444 log << MSG::DEBUG << "ngood, totcharge = " << nGood << " , " << nCharge << endmsg;
445 if ( ( nGood != 2 ) || ( nCharge != 0 ) ) { return StatusCode::SUCCESS; }
447
449 iGam.clear();
450 for ( int i = evtRecEvent->totalCharged(); i < evtRecEvent->totalTracks(); i++ )
451 {
453 if ( !( *itTrk )->isEmcShowerValid() ) continue;
454 RecEmcShower* emcTrk = ( *itTrk )->emcShower();
455 Hep3Vector emcpos( emcTrk->
x(), emcTrk->
y(), emcTrk->
z() );
456
457 double dthe = 200.;
458 double dphi = 200.;
459 double dang = 200.;
460 for ( int j = 0; j < evtRecEvent->totalCharged(); j++ )
461 {
463 if ( !( *jtTrk )->isExtTrackValid() ) continue;
464 RecExtTrack* extTrk = ( *jtTrk )->extTrack();
467
468 double angd = extpos.angle( emcpos );
469 double thed = extpos.theta() - emcpos.theta();
470 double phid = extpos.deltaPhi( emcpos );
471 thed = fmod( thed + CLHEP::twopi + CLHEP::twopi +
pi, CLHEP::twopi ) - CLHEP::pi;
472 phid = fmod( phid + CLHEP::twopi + CLHEP::twopi +
pi, CLHEP::twopi ) - CLHEP::pi;
473 if ( angd < dang )
474 {
475 dang = angd;
476 dthe = thed;
477 dphi = phid;
478 }
479 }
480 if ( dang >= 200 ) continue;
481 double eraw = emcTrk->
energy();
484 dthe = dthe * 180 / ( CLHEP::pi );
485 dphi = dphi * 180 / ( CLHEP::pi );
486 dang = dang * 180 / ( CLHEP::pi );
487 m_dthe = dthe;
488 m_dphi = dphi;
489 m_dang = dang;
490 m_eraw = eraw;
491 m_tuple2->write();
492
494 {
495 if ( eraw <= ( m_energyThreshold / 2 ) ) continue;
496 }
498 {
499 if ( eraw <= m_energyThreshold ) continue;
500 }
501 else continue;
502
503
504 if ( fabs( dang ) < m_gammaAngleCut ) continue;
505
507
508
509
510
511 iGam.push_back( i );
512 }
513
514
515
516
517 int nGam = iGam.size();
518
519 log << MSG::DEBUG << "num Good Photon " << nGam << " , " << evtRecEvent->totalNeutral()
520 << endmsg;
521 if ( nGam < 2 ) { return StatusCode::SUCCESS; }
523
524
525
526
527
528
529
530 if ( m_checkDedx == 1 )
531 {
532 for ( int i = 0; i < nGood; i++ )
533 {
535 if ( !( *itTrk )->isMdcTrackValid() ) continue;
536 if ( !( *itTrk )->isMdcDedxValid() ) continue;
537 RecMdcTrack* mdcTrk = ( *itTrk )->mdcTrack();
538 RecMdcDedx* dedxTrk = ( *itTrk )->mdcDedx();
539 m_ptrk = mdcTrk->
p();
540
541 m_chie = dedxTrk->
chiE();
542 m_chimu = dedxTrk->
chiMu();
543 m_chipi = dedxTrk->
chiPi();
544 m_chik = dedxTrk->
chiK();
545 m_chip = dedxTrk->
chiP();
548 m_probPH = dedxTrk->
probPH();
549 m_normPH = dedxTrk->
normPH();
550 m_tuple7->write();
551 }
552 }
553
554
555
556
557
558 if ( m_checkTof == 1 )
559 {
560 for ( int i = 0; i < nGood; i++ )
561 {
563 if ( !( *itTrk )->isMdcTrackValid() ) continue;
564 if ( !( *itTrk )->isTofTrackValid() ) continue;
565
566 RecMdcTrack* mdcTrk = ( *itTrk )->mdcTrack();
567 SmartRefVector<RecTofTrack> tofTrkCol = ( *itTrk )->tofTrack();
568
569 double ptrk = mdcTrk->
p();
570
571 SmartRefVector<RecTofTrack>::iterator iter_tof = tofTrkCol.begin();
572 for ( ; iter_tof != tofTrkCol.end(); iter_tof++ )
573 {
574 TofHitStatus* status = new TofHitStatus;
575 status->
setStatus( ( *iter_tof )->status() );
577 {
579 if ( status->
layer() != 0 )
continue;
580 double path = ( *iter_tof )->path();
581 double tof = ( *iter_tof )->tof();
582 double ph = ( *iter_tof )->ph();
583 double rhit = ( *iter_tof )->zrhit();
584 double qual = 0.0 + ( *iter_tof )->quality();
585 double cntr = 0.0 + ( *iter_tof )->tofID();
586 double texp[5];
587 for ( int j = 0; j < 5; j++ )
588 {
589 double gb = ptrk /
xmass[j];
590 double beta = gb / sqrt( 1 + gb * gb );
591 texp[j] = 10 * path / beta /
velc;
592 }
593 m_cntr_etof = cntr;
594 m_ptot_etof = ptrk;
595 m_ph_etof = ph;
596 m_rhit_etof = rhit;
597 m_qual_etof = qual;
598 m_te_etof = tof - texp[0];
599 m_tmu_etof = tof - texp[1];
600 m_tpi_etof = tof - texp[2];
601 m_tk_etof = tof - texp[3];
602 m_tp_etof = tof - texp[4];
603 m_tuple8->write();
604 }
605 else
606 {
608 if ( status->
layer() == 1 )
609 {
610 double path = ( *iter_tof )->path();
611 double tof = ( *iter_tof )->tof();
612 double ph = ( *iter_tof )->ph();
613 double rhit = ( *iter_tof )->zrhit();
614 double qual = 0.0 + ( *iter_tof )->quality();
615 double cntr = 0.0 + ( *iter_tof )->tofID();
616 double texp[5];
617 for ( int j = 0; j < 5; j++ )
618 {
619 double gb = ptrk /
xmass[j];
620 double beta = gb / sqrt( 1 + gb * gb );
621 texp[j] = 10 * path / beta /
velc;
622 }
623
624 m_cntr_btof1 = cntr;
625 m_ptot_btof1 = ptrk;
626 m_ph_btof1 = ph;
627 m_zhit_btof1 = rhit;
628 m_qual_btof1 = qual;
629 m_te_btof1 = tof - texp[0];
630 m_tmu_btof1 = tof - texp[1];
631 m_tpi_btof1 = tof - texp[2];
632 m_tk_btof1 = tof - texp[3];
633 m_tp_btof1 = tof - texp[4];
634 m_tuple9->write();
635 }
636
637 if ( status->
layer() == 2 )
638 {
639 double path = ( *iter_tof )->path();
640 double tof = ( *iter_tof )->tof();
641 double ph = ( *iter_tof )->ph();
642 double rhit = ( *iter_tof )->zrhit();
643 double qual = 0.0 + ( *iter_tof )->quality();
644 double cntr = 0.0 + ( *iter_tof )->tofID();
645 double texp[5];
646 for ( int j = 0; j < 5; j++ )
647 {
648 double gb = ptrk /
xmass[j];
649 double beta = gb / sqrt( 1 + gb * gb );
650 texp[j] = 10 * path / beta /
velc;
651 }
652
653 m_cntr_btof2 = cntr;
654 m_ptot_btof2 = ptrk;
655 m_ph_btof2 = ph;
656 m_zhit_btof2 = rhit;
657 m_qual_btof2 = qual;
658 m_te_btof2 = tof - texp[0];
659 m_tmu_btof2 = tof - texp[1];
660 m_tpi_btof2 = tof - texp[2];
661 m_tk_btof2 = tof - texp[3];
662 m_tp_btof2 = tof - texp[4];
663 m_tuple10->write();
664 }
665 }
666
667 delete status;
668 }
669 }
670 }
671
672
673
674
675
677 pGam.clear();
678 for ( int i = 0; i < nGam; i++ )
679 {
681 RecEmcShower* emcTrk = ( *itTrk )->emcShower();
682 double eraw = emcTrk->
energy();
683 double phi = emcTrk->
phi();
684 double the = emcTrk->
theta();
685 HepLorentzVector ptrk;
686 ptrk.setPx( eraw *
sin( the ) *
cos( phi ) );
687 ptrk.setPy( eraw *
sin( the ) *
sin( phi ) );
688 ptrk.setPz( eraw *
cos( the ) );
689 ptrk.setE( eraw );
690
691
692
693 pGam.push_back( ptrk );
694 }
695
696
697
698
700 for ( int i = 0; i < nGood; i++ )
701 {
703
706
707
710
711
714
715
718 RecMdcTrack* mdcTrk = ( *itTrk )->mdcTrack();
719 m_ptrk_pid = mdcTrk->
p();
720 m_cost_pid =
cos( mdcTrk->
theta() );
721 m_dedx_pid = pid->
chiDedx( 2 );
722 m_tof1_pid = pid->
chiTof1( 2 );
723 m_tof2_pid = pid->
chiTof2( 2 );
725 m_tuple11->write();
726
728 continue;
729
730
731
732
733 RecMdcKalTrack* mdcKalTrk =
734 ( *itTrk )->mdcKalTrack();
735
737
738
739
740 if ( mdcKalTrk->
charge() > 0 )
741 {
742 ipip.push_back( iGood[i] );
743 HepLorentzVector ptrk;
744 ptrk.setPx( mdcKalTrk->
px() );
745 ptrk.setPy( mdcKalTrk->
py() );
746 ptrk.setPz( mdcKalTrk->
pz() );
747 double p3 = ptrk.mag();
748 ptrk.setE( sqrt( p3 * p3 +
mpi *
mpi ) );
749
750
751
752 ppip.push_back( ptrk );
753 }
754 else
755 {
756 ipim.push_back( iGood[i] );
757 HepLorentzVector ptrk;
758 ptrk.setPx( mdcKalTrk->
px() );
759 ptrk.setPy( mdcKalTrk->
py() );
760 ptrk.setPz( mdcKalTrk->
pz() );
761 double p3 = ptrk.mag();
762 ptrk.setE( sqrt( p3 * p3 +
mpi *
mpi ) );
763
764
765
766 ppim.push_back( ptrk );
767 }
768 }
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796 int npip = ipip.size();
797 int npim = ipim.size();
798 if ( npip * npim != 1 ) return StatusCode::SUCCESS;
799
801
802
803
804
805
806 HepLorentzVector pTot;
807 for ( int i = 0; i < nGam - 1; i++ )
808 {
809 for ( int j = i + 1; j < nGam; j++ )
810 {
811 HepLorentzVector p2g = pGam[i] + pGam[j];
812 pTot = ppip[0] + ppim[0];
813 pTot += p2g;
814 m_m2gg = p2g.m();
815 m_etot = pTot.e();
816 m_tuple3->write();
817 }
818 }
819
820 RecMdcKalTrack* pipTrk = ( *( evtRecTrkCol->begin() + ipip[0] ) )->mdcKalTrack();
821 RecMdcKalTrack* pimTrk = ( *( evtRecTrkCol->begin() + ipim[0] ) )->mdcKalTrack();
822
823 WTrackParameter wvpipTrk, wvpimTrk;
826
827
828
829
830
831
832
833
834
835
836
838 HepSymMatrix Evx( 3, 0 );
839 double bx = 1E+6;
840 double by = 1E+6;
841 double bz = 1E+6;
842 Evx[0][0] = bx * bx;
843 Evx[1][1] = by * by;
844 Evx[2][2] = bz * bz;
845
846 VertexParameter vxpar;
849
855 if ( !vtxfit->
Fit( 0 ) )
return StatusCode::SUCCESS;
857
858 WTrackParameter wpip = vtxfit->
wtrk( 0 );
859 WTrackParameter wpim = vtxfit->
wtrk( 1 );
860
861
863
864
865
866
867
868 if ( m_test4C == 1 )
869 {
870
871 HepLorentzVector
ecms( 0.034, 0, 0, 3.097 );
872
873 double chisq = 9999.;
874 int ig1 = -1;
875 int ig2 = -1;
876 for ( int i = 0; i < nGam - 1; i++ )
877 {
878 RecEmcShower* g1Trk = ( *( evtRecTrkCol->begin() + iGam[i] ) )->emcShower();
879 for ( int j = i + 1; j < nGam; j++ )
880 {
881 RecEmcShower* g2Trk = ( *( evtRecTrkCol->begin() + iGam[j] ) )->emcShower();
888 bool oksq = kmfit->
Fit();
889 if ( oksq )
890 {
891 double chi2 = kmfit->
chisq();
892 if ( chi2 < chisq )
893 {
894 chisq = chi2;
895 ig1 = iGam[i];
896 ig2 = iGam[j];
897 }
898 }
899 }
900 }
901
902 if ( chisq < 200 )
903 {
904
905 RecEmcShower* g1Trk = ( *( evtRecTrkCol->begin() + ig1 ) )->emcShower();
906 RecEmcShower* g2Trk = ( *( evtRecTrkCol->begin() + ig2 ) )->emcShower();
913 bool oksq = kmfit->
Fit();
914 if ( oksq )
915 {
916 HepLorentzVector ppi0 = kmfit->
pfit( 2 ) + kmfit->
pfit( 3 );
917 m_mpi0 = ppi0.m();
918 m_chi1 = kmfit->
chisq();
919 m_tuple4->write();
921 }
922 }
923 }
924
925
926
927
928
929
930 if ( m_test5C == 1 )
931 {
932
933 HepLorentzVector
ecms( 0.034, 0, 0, 3.097 );
934 double chisq = 9999.;
935 int ig1 = -1;
936 int ig2 = -1;
937 for ( int i = 0; i < nGam - 1; i++ )
938 {
939 RecEmcShower* g1Trk = ( *( evtRecTrkCol->begin() + iGam[i] ) )->emcShower();
940 for ( int j = i + 1; j < nGam; j++ )
941 {
942 RecEmcShower* g2Trk = ( *( evtRecTrkCol->begin() + iGam[j] ) )->emcShower();
950 if ( !kmfit->
Fit( 0 ) )
continue;
951 if ( !kmfit->
Fit( 1 ) )
continue;
952 bool oksq = kmfit->
Fit();
953 if ( oksq )
954 {
955 double chi2 = kmfit->
chisq();
956 if ( chi2 < chisq )
957 {
958 chisq = chi2;
959 ig1 = iGam[i];
960 ig2 = iGam[j];
961 }
962 }
963 }
964 }
965
966 log << MSG::INFO << " chisq = " << chisq << endmsg;
967
968 if ( chisq < 200 )
969 {
970 RecEmcShower* g1Trk = ( *( evtRecTrkCol->begin() + ig1 ) )->emcShower();
971 RecEmcShower* g2Trk = ( *( evtRecTrkCol->begin() + ig2 ) )->emcShower();
972
980 bool oksq = kmfit->
Fit();
981 if ( oksq )
982 {
983 HepLorentzVector ppi0 = kmfit->
pfit( 2 ) + kmfit->
pfit( 3 );
984 HepLorentzVector prho0 = kmfit->
pfit( 0 ) + kmfit->
pfit( 1 );
985 HepLorentzVector prhop = ppi0 + kmfit->
pfit( 0 );
986 HepLorentzVector prhom = ppi0 + kmfit->
pfit( 1 );
987
988 m_chi2 = kmfit->
chisq();
989 m_mrh0 = prho0.m();
990 m_mrhp = prhop.m();
991 m_mrhm = prhom.m();
992 double eg1 = ( kmfit->
pfit( 2 ) ).e();
993 double eg2 = ( kmfit->
pfit( 3 ) ).e();
994 double fcos =
abs( eg1 - eg2 ) / ppi0.rho();
995 m_tuple5->write();
997
998
999
1000
1001 if ( fabs( prho0.m() - 0.770 ) < 0.150 )
1002 {
1003 if ( fabs( fcos ) < 0.99 )
1004 {
1005 m_fcos = ( eg1 - eg2 ) / ppi0.rho();
1006 m_elow = ( eg1 < eg2 ) ? eg1 : eg2;
1007 m_tuple6->write();
1009 }
1010 }
1011 }
1012 }
1013 }
1014 return StatusCode::SUCCESS;
1015}
HepGeom::Point3D< double > HepPoint3D
EvtRecTrackCol::iterator EvtRecTrackIterator
std::vector< HepLorentzVector > Vp4
double sin(const BesAngle a)
double cos(const BesAngle a)
const Hep3Vector emcPosition() const
const int emcVolumeNumber() const
static void setPidType(PidType pidType)
const double theta() const
const HepSymMatrix err() const
const HepVector helix() const
......
void AddFourMomentum(int number, HepLorentzVector p4)
HepLorentzVector pfit(int n) const
void AddResonance(int number, double mres, std::vector< int > tlis)
static KalmanKinematicFit * instance()
int methodProbability() const
int onlyPionKaonProton() const
void setChiMinCut(const double chi=4)
void setRecTrack(EvtRecTrack *trk)
void setMethod(const int method)
double chiTof2(int n) const
void identify(const int pidcase)
void usePidSys(const int pidsys)
static ParticleID * instance()
bool IsPidInfoValid() const
double chiTof1(int n) const
double probProton() const
double chiDedx(int n) const
const HepVector & getZHelix() const
const HepSymMatrix & getZError() const
unsigned int layer() const
void setStatus(unsigned int status)
void AddTrack(const int number, const double mass, const RecMdcTrack *trk)
WTrackParameter wtrk(int n) const
void AddVertex(int number, VertexParameter vpar, std::vector< int > lis)
static VertexFit * instance()
void setEvx(const HepSymMatrix &eVx)
void setVx(const HepPoint3D &vx)
_EXTERN_ std::string EvtRecEvent
_EXTERN_ std::string EvtRecTrackCol