308 {
309
310 std::cout << "execute()" << std::endl;
311
312 MsgStream log(
msgSvc(), name());
313 log << MSG::INFO << "in execute()" << endreq;
314
315 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader");
316 int runNo=eventHeader->runNumber();
317 int event=eventHeader->eventNumber();
318 log << MSG::DEBUG <<"run, evtnum = "
320 << event <<endreq;
321 cout<<"event "<<event<<endl;
323
325
326 log << MSG::DEBUG <<"ncharg, nneu, tottks = "
327 << evtRecEvent->totalCharged() << " , "
328 << evtRecEvent->totalNeutral() << " , "
329 << evtRecEvent->totalTracks() <<endreq;
330
332
333
334
335
336 Vint iGood, ipip, ipim;
337 iGood.clear();
338 ipip.clear();
339 ipim.clear();
341 ppip.clear();
342 ppim.clear();
343
344 int nCharge = 0;
345
346 Hep3Vector xorigin(0,0,0);
347
348
350 Gaudi::svcLocator()->service("VertexDbSvc", vtxsvc);
354
355
356 xorigin.setX(dbv[0]);
357 xorigin.setY(dbv[1]);
358 xorigin.setZ(dbv[2]);
359 }
360
361 for(int i = 0; i < evtRecEvent->totalCharged(); i++){
363 if(!(*itTrk)->isMdcTrackValid()) continue;
365 double pch=mdcTrk->
p();
366 double x0=mdcTrk->
x();
367 double y0=mdcTrk->
y();
368 double z0=mdcTrk->
z();
369 double phi0=mdcTrk->
helix(1);
370 double xv=xorigin.x();
371 double yv=xorigin.y();
372 double Rxy=(x0-xv)*
cos(phi0)+(y0-yv)*
sin(phi0);
373 m_vx0 = x0;
374 m_vy0 = y0;
375 m_vz0 = z0;
376 m_vr0 = Rxy;
377
378 HepVector a = mdcTrk->
helix();
379 HepSymMatrix Ea = mdcTrk->
err();
381 HepPoint3D IP(xorigin[0],xorigin[1],xorigin[2]);
383 helixip.pivot(IP);
384 HepVector vecipa = helixip.a();
385 double Rvxy0=fabs(vecipa[0]);
386 double Rvz0=vecipa[3];
387 double Rvphi0=vecipa[1];
388 m_rvxy0=Rvxy0;
389 m_rvz0=Rvz0;
390 m_rvphi0=Rvphi0;
391
392 m_tuple1->write();
393
394
395
396 if(fabs(Rvz0) >= 10.0) continue;
397 if(fabs(Rvxy0) >= 1.0) continue;
398
399 iGood.push_back(i);
400 nCharge += mdcTrk->
charge();
401 }
402
403
404
405
406 int nGood = iGood.size();
407 log << MSG::DEBUG << "ngood, totcharge = " << nGood << " , " << nCharge << endreq;
408 if((nGood != 2)||(nCharge!=0)){
409 return StatusCode::SUCCESS;
410 }
412
414 iGam.clear();
415 for(int i = evtRecEvent->totalCharged(); i< evtRecEvent->totalTracks(); i++) {
417 if(!(*itTrk)->isEmcShowerValid()) continue;
419 Hep3Vector emcpos(emcTrk->
x(), emcTrk->
y(), emcTrk->
z());
420
421 double dthe = 200.;
422 double dphi = 200.;
423 double dang = 200.;
424 for(int j = 0; j < evtRecEvent->totalCharged(); j++) {
426 if(!(*jtTrk)->isExtTrackValid()) continue;
430
431 double angd = extpos.angle(emcpos);
432 double thed = extpos.theta() - emcpos.theta();
433 double phid = extpos.deltaPhi(emcpos);
434 thed = fmod(thed+CLHEP::twopi+CLHEP::twopi+
pi, CLHEP::twopi) - CLHEP::pi;
435 phid = fmod(phid+CLHEP::twopi+CLHEP::twopi+
pi, CLHEP::twopi) - CLHEP::pi;
436 if(angd < dang){
437 dang = angd;
438 dthe = thed;
439 dphi = phid;
440 }
441 }
442 if(dang>=200) continue;
443 double eraw = emcTrk->
energy();
444 dthe = dthe * 180 / (CLHEP::pi);
445 dphi = dphi * 180 / (CLHEP::pi);
446 dang = dang * 180 / (CLHEP::pi);
447 m_dthe = dthe;
448 m_dphi = dphi;
449 m_dang = dang;
450 m_eraw = eraw;
451 m_tuple2->write();
452 if(eraw < m_energyThreshold) continue;
453
454 if(fabs(dang) < m_gammaAngleCut) continue;
455
456
457
458 iGam.push_back(i);
459 }
460
461
462
463
464 int nGam = iGam.size();
465
466 log << MSG::DEBUG << "num Good Photon " << nGam << " , " <<evtRecEvent->totalNeutral()<<endreq;
467 if(nGam<2){
468 return StatusCode::SUCCESS;
469 }
471
472
473
474
475
476
477
478
479
480 if(m_checkDedx == 1) {
481 for(int i = 0; i < nGood; i++) {
483 if(!(*itTrk)->isMdcTrackValid()) continue;
484 if(!(*itTrk)->isMdcDedxValid())continue;
487 m_ptrk = mdcTrk->
p();
488
489 m_chie = dedxTrk->
chiE();
490 m_chimu = dedxTrk->
chiMu();
491 m_chipi = dedxTrk->
chiPi();
492 m_chik = dedxTrk->
chiK();
493 m_chip = dedxTrk->
chiP();
496 m_probPH = dedxTrk->
probPH();
497 m_normPH = dedxTrk->
normPH();
498 m_tuple7->write();
499 }
500 }
501
502
503
504
505
506
507 if(m_checkTof == 1) {
508 for(int i = 0; i < nGood; i++) {
510 if(!(*itTrk)->isMdcTrackValid()) continue;
511 if(!(*itTrk)->isTofTrackValid()) continue;
512
514 SmartRefVector<RecTofTrack> tofTrkCol = (*itTrk)->tofTrack();
515
516 double ptrk = mdcTrk->
p();
517
518 SmartRefVector<RecTofTrack>::iterator iter_tof = tofTrkCol.begin();
519 for(;iter_tof != tofTrkCol.end(); iter_tof++ ) {
521 status->
setStatus((*iter_tof)->status());
524 if( status->
layer()!=0 )
continue;
525 double path=(*iter_tof)->path();
526 double tof = (*iter_tof)->tof();
527 double ph = (*iter_tof)->ph();
528 double rhit = (*iter_tof)->zrhit();
529 double qual = 0.0 + (*iter_tof)->quality();
530 double cntr = 0.0 + (*iter_tof)->tofID();
531 double texp[5];
532 for(int j = 0; j < 5; j++) {
533 double gb = ptrk/
xmass[j];
534 double beta = gb/sqrt(1+gb*gb);
535 texp[j] = 10 * path /beta/
velc;
536 }
537 m_cntr_etof = cntr;
538 m_ptot_etof = ptrk;
539 m_ph_etof = ph;
540 m_rhit_etof = rhit;
541 m_qual_etof = qual;
542 m_te_etof = tof - texp[0];
543 m_tmu_etof = tof - texp[1];
544 m_tpi_etof = tof - texp[2];
545 m_tk_etof = tof - texp[3];
546 m_tp_etof = tof - texp[4];
547 m_tuple8->write();
548 }
549 else {
551 if(status->
layer()==1){
552 double path=(*iter_tof)->path();
553 double tof = (*iter_tof)->tof();
554 double ph = (*iter_tof)->ph();
555 double rhit = (*iter_tof)->zrhit();
556 double qual = 0.0 + (*iter_tof)->quality();
557 double cntr = 0.0 + (*iter_tof)->tofID();
558 double texp[5];
559 for(int j = 0; j < 5; j++) {
560 double gb = ptrk/
xmass[j];
561 double beta = gb/sqrt(1+gb*gb);
562 texp[j] = 10 * path /beta/
velc;
563 }
564
565 m_cntr_btof1 = cntr;
566 m_ptot_btof1 = ptrk;
567 m_ph_btof1 = ph;
568 m_zhit_btof1 = rhit;
569 m_qual_btof1 = qual;
570 m_te_btof1 = tof - texp[0];
571 m_tmu_btof1 = tof - texp[1];
572 m_tpi_btof1 = tof - texp[2];
573 m_tk_btof1 = tof - texp[3];
574 m_tp_btof1 = tof - texp[4];
575 m_tuple9->write();
576 }
577
578 if(status->
layer()==2){
579 double path=(*iter_tof)->path();
580 double tof = (*iter_tof)->tof();
581 double ph = (*iter_tof)->ph();
582 double rhit = (*iter_tof)->zrhit();
583 double qual = 0.0 + (*iter_tof)->quality();
584 double cntr = 0.0 + (*iter_tof)->tofID();
585 double texp[5];
586 for(int j = 0; j < 5; j++) {
587 double gb = ptrk/
xmass[j];
588 double beta = gb/sqrt(1+gb*gb);
589 texp[j] = 10 * path /beta/
velc;
590 }
591
592 m_cntr_btof2 = cntr;
593 m_ptot_btof2 = ptrk;
594 m_ph_btof2 = ph;
595 m_zhit_btof2 = rhit;
596 m_qual_btof2 = qual;
597 m_te_btof2 = tof - texp[0];
598 m_tmu_btof2 = tof - texp[1];
599 m_tpi_btof2 = tof - texp[2];
600 m_tk_btof2 = tof - texp[3];
601 m_tp_btof2 = tof - texp[4];
602 m_tuple10->write();
603 }
604 }
605
606 delete status;
607 }
608 }
609 }
610
611
612
613
614
615
617 pGam.clear();
618 for(int i = 0; i < nGam; i++) {
621 double eraw = emcTrk->
energy();
622 double phi = emcTrk->
phi();
623 double the = emcTrk->
theta();
624 HepLorentzVector ptrk;
625 ptrk.setPx(eraw*
sin(the)*
cos(phi));
626 ptrk.setPy(eraw*
sin(the)*
sin(phi));
627 ptrk.setPz(eraw*
cos(the));
628 ptrk.setE(eraw);
629
630
631
632 pGam.push_back(ptrk);
633 }
634 cout<<"before pid"<<endl;
635
636
637
639 for(int i = 0; i < nGood; i++) {
641
644
645
650
651
655 m_ptrk_pid = mdcTrk->
p();
661 m_tuple11->write();
662
663
664 if(pid->
probPion() < 0.001)
continue;
665
666
669
670 if(mdcKalTrk->
charge() >0) {
671 ipip.push_back(iGood[i]);
672 HepLorentzVector ptrk;
673 ptrk.setPx(mdcKalTrk->
px());
674 ptrk.setPy(mdcKalTrk->
py());
675 ptrk.setPz(mdcKalTrk->
pz());
676 double p3 = ptrk.mag();
677 ptrk.setE(sqrt(p3*p3+
mpi*
mpi));
678
679
680
681 ppip.push_back(ptrk);
682 } else {
683 ipim.push_back(iGood[i]);
684 HepLorentzVector ptrk;
685 ptrk.setPx(mdcKalTrk->
px());
686 ptrk.setPy(mdcKalTrk->
py());
687 ptrk.setPz(mdcKalTrk->
pz());
688 double p3 = ptrk.mag();
689 ptrk.setE(sqrt(p3*p3+
mpi*
mpi));
690
691
692
693 ppim.push_back(ptrk);
694 }
695 }
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723 int npip = ipip.size();
724 int npim = ipim.size();
725 if(npip*npim != 1) return SUCCESS;
726
728
729
730
731
732
733
734 HepLorentzVector pTot;
735 for(int i = 0; i < nGam - 1; i++){
736 for(int j = i+1; j < nGam; j++) {
737 HepLorentzVector p2g = pGam[i] + pGam[j];
738 pTot = ppip[0] + ppim[0];
739 pTot += p2g;
740 m_m2gg = p2g.m();
741 m_etot = pTot.e();
742 m_tuple3 -> write();
743
744 }
745 }
746
747
748 RecMdcKalTrack *pipTrk = (*(evtRecTrkCol->begin()+ipip[0]))->mdcKalTrack();
749 RecMdcKalTrack *pimTrk = (*(evtRecTrkCol->begin()+ipim[0]))->mdcKalTrack();
750
754
755
756
757
758
759
760
761
762
763
764
766 HepSymMatrix Evx(3, 0);
767 double bx = 1E+6;
768 double by = 1E+6;
769 double bz = 1E+6;
770 Evx[0][0] = bx*bx;
771 Evx[1][1] = by*by;
772 Evx[2][2] = bz*bz;
773
777
783 if(!vtxfit->
Fit(0))
return SUCCESS;
785
788
789
791
792
793
794
795 cout<<"before 4c"<<endl;
796 if(m_test4C==1) {
797
798 HepLorentzVector
ecms(0.034,0,0,3.097);
799
800 double chisq = 9999.;
801 int ig1 = -1;
802 int ig2 = -1;
803 for(int i = 0; i < nGam-1; i++) {
804 RecEmcShower *g1Trk = (*(evtRecTrkCol->begin()+iGam[i]))->emcShower();
805 for(int j = i+1; j < nGam; j++) {
806 RecEmcShower *g2Trk = (*(evtRecTrkCol->begin()+iGam[j]))->emcShower();
813 bool oksq = kmfit->
Fit();
814 if(oksq) {
815 double chi2 = kmfit->
chisq();
816 if(chi2 < chisq) {
817 chisq = chi2;
818 ig1 = iGam[i];
819 ig2 = iGam[j];
820 }
821 }
822 }
823 }
824
825 if(chisq < 200) {
826
827 RecEmcShower *g1Trk = (*(evtRecTrkCol->begin()+ig1))->emcShower();
828 RecEmcShower *g2Trk = (*(evtRecTrkCol->begin()+ig2))->emcShower();
835 bool oksq = kmfit->
Fit();
836 if(oksq) {
837 HepLorentzVector ppi0 = kmfit->
pfit(2) + kmfit->
pfit(3);
838 m_mpi0 = ppi0.m();
839 m_chi1 = kmfit->
chisq();
840 m_tuple4->write();
842 }
843 }
844 }
845
846
847
848
849
850
851 if(m_test5C==1) {
852
853 HepLorentzVector
ecms(0.034,0,0,3.097);
854 double chisq = 9999.;
855 int ig1 = -1;
856 int ig2 = -1;
857 for(int i = 0; i < nGam-1; i++) {
858 RecEmcShower *g1Trk = (*(evtRecTrkCol->begin()+iGam[i]))->emcShower();
859 for(int j = i+1; j < nGam; j++) {
860 RecEmcShower *g2Trk = (*(evtRecTrkCol->begin()+iGam[j]))->emcShower();
868 if(!kmfit->
Fit(0))
continue;
869 if(!kmfit->
Fit(1))
continue;
870 bool oksq = kmfit->
Fit();
871 if(oksq) {
872 double chi2 = kmfit->
chisq();
873 if(chi2 < chisq) {
874 chisq = chi2;
875 ig1 = iGam[i];
876 ig2 = iGam[j];
877 }
878 }
879 }
880 }
881
882
883 log << MSG::INFO << " chisq = " << chisq <<endreq;
884
885 if(chisq < 200) {
886 RecEmcShower* g1Trk = (*(evtRecTrkCol->begin()+ig1))->emcShower();
887 RecEmcShower* g2Trk = (*(evtRecTrkCol->begin()+ig2))->emcShower();
888
896 bool oksq = kmfit->
Fit();
897 if(oksq){
898 HepLorentzVector ppi0 = kmfit->
pfit(2) + kmfit->
pfit(3);
899 HepLorentzVector prho0 = kmfit->
pfit(0) + kmfit->
pfit(1);
900 HepLorentzVector prhop = ppi0 + kmfit->
pfit(0);
901 HepLorentzVector prhom = ppi0 + kmfit->
pfit(1);
902
903 m_chi2 = kmfit->
chisq();
904 m_mrh0 = prho0.m();
905 m_mrhp = prhop.m();
906 m_mrhm = prhom.m();
907 double eg1 = (kmfit->
pfit(2)).e();
908 double eg2 = (kmfit->
pfit(3)).e();
909 double fcos =
abs(eg1-eg2)/ppi0.rho();
910 m_tuple5->write();
912
913
914
915
916 if(fabs(prho0.m()-0.770)<0.150) {
917 if(fabs(fcos)<0.99) {
918 m_fcos = (eg1-eg2)/ppi0.rho();
919 m_elow = (eg1 < eg2) ? eg1 : eg2;
920 m_tuple6->write();
922 }
923 }
924 }
925 }
926 }
927 return StatusCode::SUCCESS;
928}
double sin(const BesAngle a)
double cos(const BesAngle a)
double abs(const EvtComplex &c)
EvtRecTrackCol::iterator EvtRecTrackIterator
std::vector< HepLorentzVector > Vp4
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
......
virtual bool isVertexValid()=0
virtual double * SigmaPrimaryVertex()=0
virtual double * PrimaryVertex()=0
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
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 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