BOSS 7.1.0
BESIII Offline Software System
Loading...
Searching...
No Matches
MdcUtilitySvc Class Reference

#include <MdcUtilitySvc.h>

+ Inheritance diagram for MdcUtilitySvc:

Public Member Functions

 MdcUtilitySvc (const std::string &name, ISvcLocator *svcloc)
 
 ~MdcUtilitySvc ()
 
virtual StatusCode initialize ()
 
virtual StatusCode finalize ()
 
int nLayerTrackPassed (const HepVector helix) const
 
int nLayerTrackPassed (const double helix[5]) const
 
HepVector patPar2BesPar (const HepVector &helixPar) const
 
HepSymMatrix patErr2BesErr (const HepSymMatrix &err) const
 
HepVector besPar2PatPar (const HepVector &helixPar) const
 
HepSymMatrix besErr2PatErr (const HepSymMatrix &err) const
 
double doca (int layer, int cell, const HepVector helix, const HepSymMatrix errMat, bool passCellRequired=true, bool doSag=true) const
 
double doca (int layer, int cell, HepPoint3D eastP, HepPoint3D westP, const HepVector helixBes, const HepSymMatrix errMatBes, bool passCellRequired=true, bool doSag=true) const
 
double doca (int layer, int cell, const MdcSWire *sWire, const HepVector helixPat, const HepSymMatrix errMatPat, bool passCellRequired=true) const
 
double docaPatPar (int layer, int cell, const HepVector helixPat, const HepSymMatrix errMatPat, bool passCellRequired=true, bool doSag=true) const
 
double docaPatPar (int layer, int cell, HepPoint3D eastP, HepPoint3D westP, const HepVector helixBes, const HepSymMatrix errMatBes, bool passCellRequired=true, bool doSag=true) const
 
double docaPatPar (int layer, int cell, const MdcSWire *sWire, const HepVector helixPat, const HepSymMatrix errMatPat, bool passCellRequired=true) const
 
HepPoint3D pointOnHelix (const HepVector helixPar, int lay, int innerOrOuter) const
 
HepPoint3D pointOnHelixPatPar (const HepVector helixPat, int lay, int innerOrOuter) const
 
bool cellTrackPassedByPhi (const HepVector helix, int layer, int &cellId_in, int &cellId_out) const
 
bool cellTrackPassedByPhiPatPar (const HepVector helix, int layer, int &cellId_in, int &cellId_out) const
 
bool cellTrackPassed (const HepVector helix, int layer, int &cellId_in, int &cellId_out) const
 
bool cellTrackPassedPatPar (const HepVector helix, int layer, int &cellId_in, int &cellId_out) const
 
HepPoint3D Hel (HepPoint3D piv, double dr, double phi0, double Alpha_L, double kappa, double dz, double dphi, double tanl) const
 
double p_cms (HepVector helix, int runNo, double mass) const
 
Hep3Vector momentum (const RecMdcTrack *trk) const
 
double probab (const int &ndof, const double &chisq) const
 
MdcDigiVec getMdcDigiVec () const
 
void getHelixOfMcParticle (const Event::McParticle *mcParticle, Helix &helix)
 
float getChargeOfMcParticle (const Event::McParticle *mcParticle)
 
void getMomPosOfMcParticle (const Event::McParticle *mcParticle, HepVector3D &pos, HepVector3D &mom)
 
void getMdcDigiOnMcParticle (int trackIndex, const std::map< int, std::map< MdcDigi *, Event::MdcMcHit * > > mdcMCAssociation, MdcDigiVec &mdcDigiInput, MdcDigiVec &mdcDigiAssociated)
 
void getMdcMCAssoiciation (int trackIndex, const std::vector< MdcDigi * > mdcDigiVecInput, std::map< int, std::map< MdcDigi *, Event::MdcMcHit * > > &mdcMCAssociation)
 Get association of MdcDigi and MdcMcHit according to track id.
 

Detailed Description

Definition at line 40 of file MdcUtilitySvc.h.

Constructor & Destructor Documentation

◆ MdcUtilitySvc()

MdcUtilitySvc::MdcUtilitySvc ( const std::string &  name,
ISvcLocator *  svcloc 
)

Definition at line 24 of file MdcUtilitySvc.cxx.

24 :
25 base_class (name, svcloc) {
26 declareProperty("debug", m_debug = 0);
27 }

◆ ~MdcUtilitySvc()

MdcUtilitySvc::~MdcUtilitySvc ( )

Definition at line 29 of file MdcUtilitySvc.cxx.

29 {
30}

Member Function Documentation

◆ besErr2PatErr()

HepSymMatrix MdcUtilitySvc::besErr2PatErr ( const HepSymMatrix &  err) const

Definition at line 777 of file MdcUtilitySvc.cxx.

777 {
778 //error matrix
779 //std::cout<<" err1 "<<err<<" "<<err.num_row()<<std::endl;
780 //V(Y)=S * V(X) * ST , mS = S , mVy = V(Y) , err() = V(X)
781 //int n = err.num_row();
782 HepSymMatrix mS(err.num_row(),0);
783 mS[0][0]=-1.;//dr0=-d0
784 mS[1][1]=1.;
785 mS[2][2]=Bz()/-333.567;//pxy -> cpa
786 mS[3][3]=1.;
787 mS[4][4]=1.;
788 HepSymMatrix mVy= err.similarity(mS);
789 //std::cout<<" err2 "<<n<<" "<<mVy<<std::endl;
790 return mVy;
791}

Referenced by doca().

◆ besPar2PatPar()

HepVector MdcUtilitySvc::besPar2PatPar ( const HepVector &  helixPar) const

Definition at line 761 of file MdcUtilitySvc.cxx.

761 {
762 HepVector helix(5,0);
763 double d0 = -helixPar[0]; //cm
764 double phi0 = helixPar[1]+ CLHEP::halfpi;
765 double omega = Bz()*helixPar[2]/-333.567;
766 double z0 = helixPar[3]; //cm
767 double tanl = helixPar[4];
768 helix[0] = d0;
769 helix[1] = phi0;
770 helix[2] = omega;
771 helix[3] = z0;
772 helix[4] = tanl;
773 return helix;
774}

Referenced by cellTrackPassedByPhi(), doca(), MdcxCosmicSewer::execute(), nLayerTrackPassed(), and pointOnHelix().

◆ cellTrackPassed()

bool MdcUtilitySvc::cellTrackPassed ( const HepVector  helix,
int  layer,
int &  cellId_in,
int &  cellId_out 
) const

Definition at line 599 of file MdcUtilitySvc.cxx.

599 {
600 int charge,type,nCell;
601 double dr0,phi0,kappa,dz0,tanl;
602 double ALPHA_loc,rho,phi,cosphi0,sinphi0,x_hc,y_hc,z_hc;
603 double dphi0,IO_phi,C_alpha,xx,yy;
604 double inlow,inup,outlow,outup,phi_in,phi_out,phi_bin;
605 double rCize1,rCize2,rLay,length,phioffset,slant,shift;
606 double m_crio[2], phi_io[2], stphi[2],phioff[2],dphi[2];
607
608 dr0 = helixBes[0];
609 phi0 = helixBes[1];
610 kappa = helixBes[2];
611 dz0 = helixBes[3];
612 tanl = helixBes[4];
613
614 ALPHA_loc = 1000/(2.99792458*Bz()); //magnetic field const
615 charge = ( kappa >=0 ) ? 1 : -1 ;
616 rho = ALPHA_loc/kappa ;
617 double pi = Constants::pi;
618 phi = fmod(phi0 + 4*pi , 2*pi);
619 cosphi0 = cos(phi);
620 sinphi0 = (1.0 - cosphi0 ) * (1.0 + cosphi0 );
621 sinphi0 = sqrt(( sinphi0 > 0.) ? sinphi0 : 0.);
622 if( phi > pi ) sinphi0 = -sinphi0 ;
623
624 x_hc = 0. + ( dr0 + rho ) * cosphi0;
625 y_hc = 0. + ( dr0 + rho ) * sinphi0;
626 z_hc = 0. + dz0;
627
628
629 HepPoint3D piv(0.,0.,0.);
630 HepPoint3D hcenter(x_hc,y_hc,0.0);
631
632 double m_c_perp(hcenter.perp());
633 Hep3Vector m_c_unit((HepPoint3D)hcenter.unit());
634 HepPoint3D IO = (-1) * charge * m_c_unit;
635
636 dphi0 = fmod(IO.phi()+4*pi, 2*pi) - phi;
637 IO_phi = fmod(IO.phi()+4*pi, 2*pi);
638
639 if(dphi0 > pi) dphi0 -= 2*pi;
640 else if(dphi0 < -pi) dphi0 += 2*pi;
641
642 phi_io[0] = -(1+charge)*pi/2 - charge*dphi0;
643 phi_io[1] = phi_io[0]+1.5*pi;
644
645
646 bool outFlag = false;
647 //retrieve Mdc geometry information
648 rCize1 = 0.1 * m_mdcGeomSvc->Layer(lay)->RCSiz1(); //mm -> cm
649 rCize2 = 0.1 * m_mdcGeomSvc->Layer(lay)->RCSiz2(); //mm -> cm
650 rLay = 0.1 * m_mdcGeomSvc->Layer(lay)->Radius(); //mm -> cm
651 length = 0.1 * m_mdcGeomSvc->Layer(lay)->Length(); //mm -> cm
652 //double halfLength=length/2.;
653 //(conversion of the units mm(mc)->cm(rec))
654 nCell = m_mdcGeomSvc->Layer(lay)->NCell();
655 phioffset = m_mdcGeomSvc->Layer(lay)->Offset();
656 slant = m_mdcGeomSvc->Layer(lay)->Slant();
657 shift = m_mdcGeomSvc->Layer(lay)->Shift();
658 type = m_mdcGeomSvc->Layer(lay)->Sup()->Type();
659
660 m_crio[0] = rLay - rCize1 ; //radius of inner field wir ( beam pipe)
661 m_crio[1] = rLay + rCize2 ; //radius of outer field wir ( beam pipe)
662
663 int sign = -1; //assumed the first half circle
664
665 Hep3Vector iocand[2];
666 Hep3Vector cell_IO[2];
667
668 for(int ii =0; ii<2; ii++){
669 // By law of cosines to calculate the alpha(up and down field wir_Ge)
670 double cos_alpha = (m_c_perp*m_c_perp + m_crio[ii]*m_crio[ii] - rho*rho)
671 / ( 2 * m_c_perp * m_crio[ii] );
672 if(fabs(cos_alpha)>1&&(ii==0)){
673 cos_alpha = -1;
674 outFlag=true;
675 }
676 if(fabs(cos_alpha)>1&&(ii==1)){
677 cos_alpha = (m_c_perp*m_c_perp + m_crio[0]*m_crio[0] - rho*rho)
678 / ( 2 * m_c_perp * m_crio[0] );
679 C_alpha = 2*pi - acos( cos_alpha);
680 }else {
681 C_alpha = acos( cos_alpha );
682 }
683
684 iocand[ii] = m_c_unit;
685 iocand[ii].rotateZ( charge*sign*C_alpha );
686 iocand[ii] *= m_crio[ii];
687
688 xx = iocand[ii].x() - x_hc ;
689 yy = iocand[ii].y() - y_hc ;
690
691 dphi[ii] = atan2(yy,xx) - phi0 - 0.5*pi*(1-charge);
692 dphi[ii] = fmod( dphi[ii] + 8.0*pi,2*pi);
693
694
695 if( dphi[ii] < phi_io[0] ) {
696 dphi[ii] += 2*pi;
697 }else if( dphi[ii] > phi_io[1] ){ //very very nausea
698 dphi[ii] -= 2*pi;
699 }
700
701 cell_IO[ii] = Hel(piv, dr0, phi, ALPHA_loc, kappa,dz0, dphi[ii], tanl);
702
703 //cout<<" cell_IO["<<ii<<"] : "<<cell_IO[ii]<<endl;
704 if( (cell_IO[ii].x()==0 ) && (cell_IO[ii].y()==0) && (cell_IO[ii].z()==0)) continue;
705 }
706 //if(((fabs(cell_IO[0].z())*10-halfLength)>-7.) && ((fabs(cell_IO[1].z())*10-halfLength)>-7.))return true; //Out sensitive area
707
708 cellId_in = cellId_out = -1 ;
709 phi_in = cell_IO[0].phi();
710 phi_in = fmod ( phi_in + 4 * pi, 2 * pi );
711 phi_out = cell_IO[1].phi();
712 phi_out = fmod ( phi_out + 4 * pi, 2 * pi );
713 phi_bin = 2.0 * pi / nCell ;
714
715 //determine the in/out cell id
716 stphi[0] = shift * phi_bin * (0.5 - cell_IO[0].z()/length);
717 stphi[1] = shift * phi_bin * (0.5 - cell_IO[1].z()/length);
718 //stphi[0],stphi[1] to position fo z axis ,the angle of deflxsion in x_Y
719
720 phioff[0] = phioffset + stphi[0];
721 phioff[1] = phioffset + stphi[1];
722
723 for(int kk = 0; kk<nCell ; kk++){
724 //for stereo layer
725 inlow = phioff[0] + phi_bin*kk - phi_bin*0.5;
726 inlow = fmod( inlow + 4.0 * pi , 2.0 * pi);
727 inup = phioff[0] + phi_bin*kk + phi_bin*0.5;
728 inup = fmod( inup + 4.0 * pi , 2.0 * pi);
729 outlow = phioff[1] + phi_bin*kk - phi_bin*0.5;
730 outlow = fmod( outlow + 4.0 * pi ,2.0 * pi);
731 outup = phioff[1] + phi_bin*kk + phi_bin*0.5;
732 outup = fmod( outup + 4.0 * pi , 2.0 * pi);
733
734 if((phi_in>=inlow && phi_in<=inup)) cellId_in = kk;
735 if((phi_out>=outlow&&phi_out<outup)) cellId_out = kk;
736 if(inlow > inup ){
737 if((phi_in>=inlow&&phi_in<2.0*pi)||(phi_in>=0.0&&phi_in<inup)) cellId_in = kk;
738 }
739 if(outlow>outup){
740 if((phi_out>=outlow&&phi_out<=2.0*pi)||(phi_out>=0.0&&phi_out<outup)) cellId_out = kk;
741 }
742 }//end of nCell loop
743
744 return (cellId_in==cellId_out);
745}
double cos(const BesAngle a)
Definition: BesAngle.h:213
Double_t x[10]
static const double pi
Definition: Constants.h:38
double Radius(void) const
Definition: MdcGeoLayer.h:160
double Slant(void) const
Definition: MdcGeoLayer.h:158
double RCSiz2(void) const
Definition: MdcGeoLayer.h:163
double Length(void) const
Definition: MdcGeoLayer.h:161
MdcGeoSuper * Sup(void) const
Definition: MdcGeoLayer.h:174
double Shift(void) const
Definition: MdcGeoLayer.h:167
double RCSiz1(void) const
Definition: MdcGeoLayer.h:162
int NCell(void) const
Definition: MdcGeoLayer.h:165
double Offset(void) const
Definition: MdcGeoLayer.h:166
int Type(void) const
Definition: MdcGeoSuper.h:35
const MdcGeoLayer *const Layer(unsigned id)
Definition: MdcGeomSvc.cxx:782
HepPoint3D Hel(HepPoint3D piv, double dr, double phi0, double Alpha_L, double kappa, double dz, double dphi, double tanl) const
double y[1000]
float charge
const float pi
Definition: vector3.h:133

Referenced by cellTrackPassedPatPar().

◆ cellTrackPassedByPhi()

bool MdcUtilitySvc::cellTrackPassedByPhi ( const HepVector  helix,
int  layer,
int &  cellId_in,
int &  cellId_out 
) const

Definition at line 552 of file MdcUtilitySvc.cxx.

552 {
553 HepVector helixPat = besPar2PatPar(helixBes);
554 return cellTrackPassedByPhiPatPar(helixPat, layer, cellId_in, cellId_out);
555}
HepVector besPar2PatPar(const HepVector &helixPar) const
bool cellTrackPassedByPhiPatPar(const HepVector helix, int layer, int &cellId_in, int &cellId_out) const

◆ cellTrackPassedByPhiPatPar()

bool MdcUtilitySvc::cellTrackPassedByPhiPatPar ( const HepVector  helix,
int  layer,
int &  cellId_in,
int &  cellId_out 
) const

Definition at line 561 of file MdcUtilitySvc.cxx.

561 {
562 int nCell = m_mdcGeomSvc->Layer(layer)->NCell();
563
564 double dPhiz = (m_mdcGeomSvc->Wire(layer,0)->Forward().phi() - m_mdcGeomSvc->Wire(layer,0)->Backward().phi())*0.5;
565 double rEnd = m_mdcGeomSvc->Wire(layer,0)->Backward().rho()/10.;//mm2cm
566 double rMid = rEnd * cos(dPhiz);
567 //std::cout<<"( cell "<<0<<" westPphi "<<m_mdcGeomSvc->Wire(layer,0)->Forward().phi() <<" eastPphi "
568 //<<m_mdcGeomSvc->Wire(layer,0)->Backward().phi()<<" twist "<<dPhiz<<" rend "<<rEnd<<std::endl;
569 double fltLenIn = rMid;
570 double phiIn = helixPat[1] + helixPat[2]*fltLenIn;//phi0 + omega * L
571
572 double phiEPOffset = m_mdcGeomSvc->Wire(layer,0)->Backward().phi();//east.phi()= BackWard.phi
573 BesAngle tmp(phiIn - phiEPOffset);
574 if(m_debug) std::cout<<"cellTrackPassed nCell "<<nCell<<" layer "<<layer<<" fltLenIn "<<fltLenIn<<" phiEPOffset "<<phiEPOffset<<std::endl;
575 //BesAngle tmp(phiIn - layPtr->phiEPOffset());
576 int wlow = (int)floor(nCell * tmp.rad() / twopi );
577 int wbig = (int)ceil(nCell * tmp.rad() / twopi );
578 if (tmp == 0 ){ wlow = -1; wbig = 1; }
579
580 if ((wlow%nCell)< 0) wlow += nCell;
581 cellId_in = wlow;
582
583 if ((wbig%nCell)< 0) wbig += nCell;
584 cellId_out = wbig;
585
586 bool passedOneCell = (cellId_in == cellId_out);
587
588 return passedOneCell;//pass more than one cell
589}
HepPoint3D Forward(void) const
Definition: MdcGeoWire.h:129
HepPoint3D Backward(void) const
Definition: MdcGeoWire.h:128
const MdcGeoWire *const Wire(unsigned id)
Definition: MdcGeomSvc.cxx:766

Referenced by cellTrackPassedByPhi(), and docaPatPar().

◆ cellTrackPassedPatPar()

bool MdcUtilitySvc::cellTrackPassedPatPar ( const HepVector  helix,
int  layer,
int &  cellId_in,
int &  cellId_out 
) const

Definition at line 592 of file MdcUtilitySvc.cxx.

592 {
593 HepVector helixBes = patPar2BesPar(helixPat);
594 return cellTrackPassed(helixBes, layer, cellId_in, cellId_out);
595}
HepVector patPar2BesPar(const HepVector &helixPar) const
bool cellTrackPassed(const HepVector helix, int layer, int &cellId_in, int &cellId_out) const

◆ doca() [1/3]

double MdcUtilitySvc::doca ( int  layer,
int  cell,
const HepVector  helix,
const HepSymMatrix  errMat,
bool  passCellRequired = true,
bool  doSag = true 
) const

Definition at line 390 of file MdcUtilitySvc.cxx.

390 {
391 HepVector helixPat = besPar2PatPar(helixBes);
392 HepSymMatrix errMatPat= besErr2PatErr(errMatBes);
393
394 return docaPatPar(layer, cell, helixPat, errMatPat, passCellRequired, doSag);//call 4.
395}
HepSymMatrix besErr2PatErr(const HepSymMatrix &err) const
double docaPatPar(int layer, int cell, const HepVector helixPat, const HepSymMatrix errMatPat, bool passCellRequired=true, bool doSag=true) const

Referenced by docaPatPar(), and EsTimeAlg::execute().

◆ doca() [2/3]

double MdcUtilitySvc::doca ( int  layer,
int  cell,
const MdcSWire sWire,
const HepVector  helixPat,
const HepSymMatrix  errMatPat,
bool  passCellRequired = true 
) const

Definition at line 408 of file MdcUtilitySvc.cxx.

408 {
409 HepVector helixPat = besPar2PatPar(helixBes);
410 HepSymMatrix errMatPat= besErr2PatErr(errMatBes);
411
412 return docaPatPar(layer, cell, sWire, helixPat, errMatPat, passCellRequired);//call 6.
413}

◆ doca() [3/3]

double MdcUtilitySvc::doca ( int  layer,
int  cell,
HepPoint3D  eastP,
HepPoint3D  westP,
const HepVector  helixBes,
const HepSymMatrix  errMatBes,
bool  passCellRequired = true,
bool  doSag = true 
) const

Definition at line 399 of file MdcUtilitySvc.cxx.

399 {
400 HepVector helixPat = besPar2PatPar(helixBes);
401 HepSymMatrix errMatPat= besErr2PatErr(errMatBes);
402
403 return docaPatPar(layer, cell, eastP, westP, helixPat, errMatPat, passCellRequired, doSag);//call 5.
404}

◆ docaPatPar() [1/3]

double MdcUtilitySvc::docaPatPar ( int  layer,
int  cell,
const HepVector  helixPat,
const HepSymMatrix  errMatPat,
bool  passCellRequired = true,
bool  doSag = true 
) const

Definition at line 417 of file MdcUtilitySvc.cxx.

417 {
418
419 const MdcGeoWire *geowir = m_mdcGeomSvc->Wire(layer,cell);
420 int id = geowir->Id();
421 double sag = 0.;
422 if(doSag) sag = geowir->Sag()/10.;//mm2cm
423 HepPoint3D eastP = geowir->Backward()/10.0;//mm2cm
424 HepPoint3D westP = geowir->Forward() /10.0;//mm2cm
425 const MdcSWire* sWire = new MdcSWire(eastP, westP, sag, id , cell);
426
427 double doca = docaPatPar(layer, cell, sWire, helixPat, errMat, passCellRequired);//call 6.
428
429 delete sWire;
430 return doca;
431}
const double Sag(void) const
Definition: MdcGeoWire.cxx:12
int Id(void) const
Definition: MdcGeoWire.h:127
double doca(int layer, int cell, const HepVector helix, const HepSymMatrix errMat, bool passCellRequired=true, bool doSag=true) const

Referenced by doca(), docaPatPar(), and MdcxCosmicSewer::execute().

◆ docaPatPar() [2/3]

double MdcUtilitySvc::docaPatPar ( int  layer,
int  cell,
const MdcSWire sWire,
const HepVector  helixPat,
const HepSymMatrix  errMatPat,
bool  passCellRequired = true 
) const

Definition at line 451 of file MdcUtilitySvc.cxx.

451 {
452
453 if(m_debug) std::cout<<" helixPat "<<helixPat<<std::endl;
454 if(m_debug) std::cout<<" layer "<<layer<<" cell "<<cell<<std::endl;
455 //-----cell track passed
456 int cellId_in = -1;
457 int cellId_out = -1;
458
459 //cellTrackPassedPatPar(helixPat,layer,cellId_in,cellId_out);//yzhang FIXME 2012-07-11
460 cellTrackPassedByPhiPatPar(helixPat,layer,cellId_in,cellId_out);//yzhang FIXME 2012-07-11
461
462 if(m_debug) {
463 std::cout<<" cellId in "<<cellId_in<<" out "<<cellId_out <<std::endl;
464 cout << "cell = " << cell << ", cellId_in = " << cellId_in << ", cellId_out = " << cellId_out << endl;
465 }
466 if (passCellRequired &&(cell < cellId_in && cell > cellId_out)) return -999.;
467
468 //-----helix trajectory
469 HelixTraj* helixTraj = new HelixTraj(helixPat,errMat);
470 const Trajectory* trajHelix = dynamic_cast<const Trajectory*> (helixTraj);
471
472 //-----pointOnHelix
473 int innerOrOuter = 1;
474 Hep3Vector cell_IO = pointOnHelixPatPar(helixPat,layer,innerOrOuter);
475 double fltTrack = 0.1 * m_mdcGeomSvc -> Layer(layer)->Radius();
476 if(m_debug) {
477 std::cout<<" cell_IO "<<cell_IO<<std::endl;
478 std::cout<<" fltTrack "<<fltTrack<<std::endl;
479 }
480
481 //------wire trajectory
482 const MdcSagTraj* m_wireTraj = sWire->getTraj();
483 const Trajectory* trajWire = dynamic_cast<const Trajectory*> (m_wireTraj);
484 const HepPoint3D* start_In = sWire->getEastPoint();
485 //const HepPoint3D* stop_In = sWire->getWestPoint();
486 if(m_debug){
487 std::cout<<" sag "<<m_wireTraj->sag()<<std::endl;
488 std::cout<< " east -------- "<< start_In->x()<<","<<start_In->y()<<","<<start_In->z()<<std::endl;
489 }
490 //std::cout<< " west -------- "<< stop_In->x()<<","<<stop_In->y()<<","<<stop_In->z() <<std::endl;
491
492 //------calc poca
493 double doca = -999.;
494 TrkPoca* trkPoca;
495 double zWire = cell_IO.z();
496 //HepPoint3D pos_in(zWire,sWire->xWireDC(zWire),sWire->yWireDC(zWire)) ;
497 HepPoint3D pos_in(sWire->xWireDC(zWire),sWire->yWireDC(zWire),zWire) ;
498 if(m_debug) std::cout<<" zWire "<<zWire<<" zEndDC "<<sWire->zEndDC()<<std::endl;
499 //if(m_debug) std::cout<<"pos_in "<<pos_in<<" fltWire "<<fltWire<<std::endl;
500
501 double fltWire = sqrt( (pos_in.x()-start_In->x())*(pos_in.x()-start_In->x()) +
502 (pos_in.y()-start_In->y())*(pos_in.y()-start_In->y()) +
503 (pos_in.z()-start_In->z())*(pos_in.z()-start_In->z()) );
504 trkPoca = new TrkPoca(*trajHelix, fltTrack, *trajWire, fltWire);
505 doca = trkPoca->doca();
506
507 double hitLen = trkPoca->flt2();
508 double startLen = trajWire->lowRange() - 5.;
509 double endLen = trajWire->hiRange() + 5.;
510 if(hitLen < startLen || hitLen > endLen) {
511 if(m_debug) std::cout<<"WARNING MdcUtilitySvc::docaPatPar() isBeyondEndflange! hitLen="<<hitLen <<" startLen="<<startLen<<" endLen "<<endLen<<std::endl;
512 doca = -998.;
513 }
514 //std::cout<<" hitLen "<<hitLen<<" startLen "<<startLen<<" endLen "<<endLen <<" doca "<<doca<<std::endl;
515
516 if(m_debug) std::cout<<" doca "<<doca<<std::endl;
517 delete helixTraj;
518 delete trkPoca;
519
520 return doca;
521
522} //----------end of calculatng the doca ---------------------------------//
double yWireDC(double z) const
Definition: MdcSWire.h:62
double xWireDC(double z) const
Definition: MdcSWire.h:61
double zEndDC(void) const
Definition: MdcSWire.h:49
const MdcSagTraj * getTraj(void) const
Definition: MdcSWire.h:34
const HepPoint3D * getEastPoint(void) const
Definition: MdcSWire.h:32
double sag(void) const
Definition: MdcSagTraj.h:80
HepPoint3D pointOnHelixPatPar(const HepVector helixPat, int lay, int innerOrOuter) const
double lowRange() const
Definition: Trajectory.h:91
double hiRange() const
Definition: Trajectory.h:92
double flt2() const
Definition: TrkPocaBase.h:68
double doca() const
Definition: TrkPoca.h:56

◆ docaPatPar() [3/3]

double MdcUtilitySvc::docaPatPar ( int  layer,
int  cell,
HepPoint3D  eastP,
HepPoint3D  westP,
const HepVector  helixBes,
const HepSymMatrix  errMatBes,
bool  passCellRequired = true,
bool  doSag = true 
) const

Definition at line 435 of file MdcUtilitySvc.cxx.

435 {
436
437 const MdcGeoWire *geowir = m_mdcGeomSvc->Wire(layer,cell);
438 int id = geowir->Id();
439 double sag = 0.;
440 if(doSag) sag = geowir->Sag()/10.;//mm2cm
441 const MdcSWire* sWire = new MdcSWire(eastP, westP, sag, id , cell);//cm
442
443 double doca = docaPatPar(layer, cell, sWire, helixPat, errMat, passCellRequired);//call 6.
444
445 delete sWire;
446 return doca;
447}

◆ finalize()

StatusCode MdcUtilitySvc::finalize ( )
virtual

Definition at line 70 of file MdcUtilitySvc.cxx.

70 {
71 MsgStream log(messageService(), name());
72 log << MSG::INFO << "MdcUtilitySvc::finalize()" << endreq;
73
74 return StatusCode::SUCCESS;
75}

◆ getChargeOfMcParticle()

float MdcUtilitySvc::getChargeOfMcParticle ( const Event::McParticle mcParticle)

Definition at line 895 of file MdcUtilitySvc.cxx.

895 {
896 // get PartPropSvc
897 IPartPropSvc* partPropSvc;
898 static const bool CREATEIFNOTTHERE(true);
899 StatusCode sc=service("PartPropSvc",partPropSvc,CREATEIFNOTTHERE);
900 if(!sc.isSuccess()||nullptr==partPropSvc){
901 cout<< " Could not initialize Particle Properties Service" << endl;
902 }
903 HepPDT::ParticleDataTable* particleTable = partPropSvc->PDT();
904 if(particleTable->particle(mcParticle->particleProperty())){
905 return particleTable->particle(mcParticle->particleProperty())->charge();
906 }
907 return -1e6;
908}
StdHepId particleProperty() const
Retrieve particle property.
Definition: McParticle.cxx:7

Referenced by getHelixOfMcParticle().

◆ getHelixOfMcParticle()

void MdcUtilitySvc::getHelixOfMcParticle ( const Event::McParticle mcParticle,
Helix helix 
)

Definition at line 920 of file MdcUtilitySvc.cxx.

920 {
921 if(nullptr==mcParticle) return;
922 Hep3Vector pos,mom;
923 pos.setX(mcParticle->initialPosition().x());
924 pos.setY(mcParticle->initialPosition().y());
925 pos.setZ(mcParticle->initialPosition().z());
926 mom.setX(mcParticle->initialFourMomentum().px());
927 mom.setY(mcParticle->initialFourMomentum().py());
928 mom.setZ(mcParticle->initialFourMomentum().pz());
929
930 Helix helixTemp(pos,mom,
931 getChargeOfMcParticle(mcParticle));
932 helixTemp.pivot(HepPoint3D(0,0,0));
933 helix.set(helixTemp.pivot(),helixTemp.a(),helixTemp.Ea());
934}
HepGeom::Point3D< double > HepPoint3D
Definition: MdcUtilitySvc.h:32
const HepLorentzVector & initialPosition() const
Retrieve pointer to the start, end vertex positions.
Definition: McParticle.cxx:95
const HepLorentzVector & initialFourMomentum() const
Definition: McParticle.cxx:103
void set(const HepPoint3D &pivot, const HepVector &a, const HepSymMatrix &Ea)
sets helix pivot position, parameters, and error matrix.
float getChargeOfMcParticle(const Event::McParticle *mcParticle)

◆ getMdcDigiOnMcParticle()

void MdcUtilitySvc::getMdcDigiOnMcParticle ( int  trackIndex,
const std::map< int, std::map< MdcDigi *, Event::MdcMcHit * > >  mdcMCAssociation,
MdcDigiVec mdcDigiInput,
MdcDigiVec mdcDigiAssociated 
)

Definition at line 936 of file MdcUtilitySvc.cxx.

938 {
939 MdcDigiVec::iterator iter=mdcDigiInput.begin();
940 //auto iter=mdcDigiVecInput.begin();
941 for(;iter!=mdcDigiInput.end();iter++){
942 std::map<int, std::map<MdcDigi*,MdcMcHit*> >::const_iterator itMap0=
943 mdcMCAssociation.find(trackIndex);
944 if(itMap0!=mdcMCAssociation.end()){
945 std::map<MdcDigi*,MdcMcHit*>::const_iterator itMap=
946 (*itMap0).second.find(*iter);
947 MdcMcHit* mcHit;
948 if(itMap!=(*itMap0).second.end()){ mcHit=itMap->second; }
949 if( (trackIndex==mcHit->getTrackIndex())
950 && (mcHit->getCreatorProcess()=="Generator"||
951 mcHit->getCreatorProcess()=="Decay") ){
952 mdcDigiAssociated.push_back(*iter);
953 }
954 }
955 }
956}
EvtStreamInputIterator< typename Generator::result_type > iter(Generator gen, int N=0)
std::string getCreatorProcess() const
Definition: MdcMcHit.h:79
unsigned int getTrackIndex() const
Definition: MdcMcHit.cxx:28

◆ getMdcDigiVec()

vector< MdcDigi * > MdcUtilitySvc::getMdcDigiVec ( ) const

Definition at line 77 of file MdcUtilitySvc.cxx.

78{
79 uint32_t getDigiFlag = 0;
80
81 MdcDigiVec mdcDigiVec = m_RawDataProviderSvc->getMdcDigiVec(getDigiFlag);
82 cout<<"MdcUtilitySvc::getMdcDigiVec() get "<<mdcDigiVec.size()<<" MDC digis from RawDataProviderSvc"<<endl;
83
84 return mdcDigiVec;
85}
std::vector< MdcDigi * > MdcDigiVec
MdcDigiVec & getMdcDigiVec(uint32_t control=0)

◆ getMdcMCAssoiciation()

void MdcUtilitySvc::getMdcMCAssoiciation ( int  trackIndex,
const std::vector< MdcDigi * >  mdcDigiVecInput,
std::map< int, std::map< MdcDigi *, Event::MdcMcHit * > > &  mdcMCAssociation 
)

Get association of MdcDigi and MdcMcHit according to track id.

—get MDC MC hits and make a map vs wire id

loop over MdcDigi

Definition at line 958 of file MdcUtilitySvc.cxx.

960 {
961
962 ///---get MDC MC hits and make a map vs wire id
963 IDataProviderSvc* eventSvc = NULL;
964 Gaudi::svcLocator()->service("EventDataSvc", eventSvc);
965 SmartDataPtr<Event::MdcMcHitCol> mdcMcHitCol(eventSvc,"/Event/MC/MdcMcHitCol");
966 if(!mdcMcHitCol){
967 std::cout<<"MdcUtilitySvc::getMdcMCAssoiciation() does not find MdcMcHitCol!"<<std::endl;
968 return;
969 }
970 std::map<int,Event::MdcMcHit*> mdcMcHitMap;
971 Event::MdcMcHitCol::iterator iterMdcMcHit=mdcMcHitCol->begin();
972 for(;iterMdcMcHit!=mdcMcHitCol->end();iterMdcMcHit++ )
973 {
974 int id=m_mdcGeomSvc->Wire(MdcID::layer((*iterMdcMcHit)->identify()),
975 MdcID::wire((*iterMdcMcHit)->identify()))->Id();
976 mdcMcHitMap.insert(std::pair<int,Event::MdcMcHit*>(id,*iterMdcMcHit));
977 }
978
979 ///loop over MdcDigi
980 MdcDigiVec::const_iterator iterMdcDigi=mdcDigiVecInput.begin();
981 for(;iterMdcDigi!=mdcDigiVecInput.end();iterMdcDigi++){
982 int digiTrackIndex=(*iterMdcDigi)->getTrackIndex();
983 std::cout<<__FILE__<<" "<<__LINE__<<" "<<digiTrackIndex<<std::endl;
984 if(digiTrackIndex>999) digiTrackIndex-=1000;//FIXME
985 if(digiTrackIndex!=digiTrackIndex) continue;
986 int id=m_mdcGeomSvc->Wire(MdcID::layer((*iterMdcMcHit)->identify()),
987 MdcID::wire((*iterMdcMcHit)->identify()))->Id();
988 std::map<MdcDigi*, MdcMcHit*> temp;
989 std::map<int,Event::MdcMcHit*>::iterator itMdcMcHit=mdcMcHitMap.find(id);
990 if(itMdcMcHit!=mdcMcHitMap.end()){
991 temp.insert(make_pair(*iterMdcDigi,(*itMdcMcHit).second));
992 mdcMCAssociation.insert(make_pair(trackIndex, temp));
993 //mdcMCAssociation.insert(std::pair<int,std::map<MdcDigi*,MdcMcHit*> >
994 //(trackIndex,make_pair(*iterMdcDigi,mdcMcHitMap[id])));
995 }
996 }
997
998}//end of getMdcMCAssoiciation
#define NULL
static int layer(const Identifier &id)
Values of different levels (failure returns 0)
Definition: MdcID.cxx:49
static int wire(const Identifier &id)
Definition: MdcID.cxx:54

◆ getMomPosOfMcParticle()

void MdcUtilitySvc::getMomPosOfMcParticle ( const Event::McParticle mcParticle,
HepVector3D pos,
HepVector3D mom 
)

Definition at line 910 of file MdcUtilitySvc.cxx.

910 {
911 if(nullptr==mcParticle) return;
912 pos.setX(mcParticle->initialPosition().x());
913 pos.setY(mcParticle->initialPosition().y());
914 pos.setZ(mcParticle->initialPosition().z());
915 mom.setX(mcParticle->initialFourMomentum().px());
916 mom.setY(mcParticle->initialFourMomentum().py());
917 mom.setZ(mcParticle->initialFourMomentum().pz());
918}

◆ Hel()

HepPoint3D MdcUtilitySvc::Hel ( HepPoint3D  piv,
double  dr,
double  phi0,
double  Alpha_L,
double  kappa,
double  dz,
double  dphi,
double  tanl 
) const

Definition at line 747 of file MdcUtilitySvc.cxx.

747 {
748 double x = piv.x() + dr*cos(phi0) + (Alpha_L/kappa) * (cos(phi0) - cos(phi0+dphi));
749 double y = piv.y() + dr*sin(phi0) + (Alpha_L/kappa) * (sin(phi0) - sin(phi0+dphi));
750 double z = piv.z() + dz - (Alpha_L/kappa) * dphi * tanl;
751 //cout<<"HepPoint3D(x, y, z) = "<<HepPoint3D(x, y, z)<<endl;
752 if((x>-1000. && x<1000.) || (y >-1000. && y <1000. ) ||(z>-1000. && z<1000.)){
753 return HepPoint3D(x, y, z);
754 }else{
755 return HepPoint3D(0,0,0);
756 }
757}
double sin(const BesAngle a)
Definition: BesAngle.h:210

Referenced by cellTrackPassed().

◆ initialize()

StatusCode MdcUtilitySvc::initialize ( )
virtual

Definition at line 32 of file MdcUtilitySvc.cxx.

32 {
33 MsgStream log(messageService(), name());
34 log << MSG::INFO << "MdcUtilitySvc::initialize()" << endreq;
35
36 StatusCode sc = Service::initialize();
37 if( sc.isFailure() ) {
38 log << MSG::ERROR << "Service::initialize() failure" << endreq;
39 return sc;
40 }
41
42 //Initalze magnetic flied
43
44 sc = service("MagneticFieldSvc", m_pIMF);
45 if(! m_pIMF){
46 log << MSG::FATAL <<" ERROR Unable to open Magnetic field service "<< endreq;
47 return StatusCode::FAILURE;
48 }
49
50 // Initialize MdcGeomSvc
51 IMdcGeomSvc* imdcGeomSvc;
52 sc = service("MdcGeomSvc", imdcGeomSvc);
53 m_mdcGeomSvc = dynamic_cast<MdcGeomSvc*> (imdcGeomSvc);
54 if(!imdcGeomSvc){
55 log << MSG::FATAL <<" Could not load MdcGeomSvc! "<< endreq;
56 return StatusCode::FAILURE;
57 }
58
59 IRawDataProviderSvc* irawDataProviderSvc;
60 sc = service ("RawDataProviderSvc", irawDataProviderSvc);
61 m_RawDataProviderSvc = dynamic_cast<RawDataProviderSvc*> (irawDataProviderSvc);
62 if ( sc.isFailure() ){
63 log << MSG::FATAL << name()<<" Could not load RawDataProviderSvc!" << endreq;
64 return StatusCode::FAILURE;
65 }
66
67 return StatusCode::SUCCESS;
68}

◆ momentum()

Hep3Vector MdcUtilitySvc::momentum ( const RecMdcTrack trk) const

Definition at line 825 of file MdcUtilitySvc.cxx.

825 {
826 // double dr = trk->helix(0);
827 double fi0 = trk->helix(1);
828 double cpa = trk->helix(2);
829 double tanl = trk->helix(4);
830
831 double pxy = 0.;
832 if(cpa != 0) pxy = 1/fabs(cpa);
833
834 double px = pxy * (-sin(fi0));
835 double py = pxy * cos(fi0);
836 double pz = pxy * tanl;
837
838 Hep3Vector p;
839 p.set(px, py, pz); // MeV/c
840 return p;
841}
const HepVector helix() const
......

◆ nLayerTrackPassed() [1/2]

int MdcUtilitySvc::nLayerTrackPassed ( const double  helix[5]) const

Definition at line 251 of file MdcUtilitySvc.cxx.

251 {
252
253 HepVector helixBesParam(5,0);
254 for(int i=0; i<5; ++i) helixBesParam[i] = helixBes[i];
255
256 return nLayerTrackPassed(helixBesParam);
257}
int nLayerTrackPassed(const HepVector helix) const

◆ nLayerTrackPassed() [2/2]

int MdcUtilitySvc::nLayerTrackPassed ( const HepVector  helix) const

Definition at line 260 of file MdcUtilitySvc.cxx.

260 {
261 HepVector helix= besPar2PatPar(helixBes);
262
263 int nLayer = 0;
264
265 for(unsigned iLayer=0; iLayer<43; iLayer++){
266 //flightLength is the path length of track in the x-y plane
267 //guess flightLength by the radius in middle of the wire.
268 double rMidLayer = m_mdcGeomSvc->Layer(iLayer)->Radius();
269 double flightLength = rMidLayer;
270
271 HepPoint3D pivot(0.,0.,0.);
272 double dz = helix[3];
273 double c = CLHEP::c_light * 100.; //unit from m/s to cm/s
274 double alpha = 1/(c * Bz());//~333.567
275 double kappa = helix[2];
276 double rc = (-1.)*alpha/kappa;
277 //std::cout<<"MdcUtilitySvc alpha "<<alpha<<std::endl;
278 double tanl = helix[4];
279 double phi0 = helix[1];
280 double phi = flightLength/rc + phi0;//turning angle
281 double z = pivot.z() + dz - (alpha/kappa) * tanl * phi;
282
283 double layerHalfLength = m_mdcGeomSvc->Layer(iLayer)->Length()/2.;
284
285 //std::cout<<"MdcUtilitySvc length "<<layerHalfLength<<std::endl;
286
287 if (fabs(z) < fabs(layerHalfLength)) ++nLayer;
288 }
289
290 return nLayer;
291}
const double alpha

Referenced by nLayerTrackPassed().

◆ p_cms()

double MdcUtilitySvc::p_cms ( HepVector  helix,
int  runNo,
double  mass 
) const

Definition at line 793 of file MdcUtilitySvc.cxx.

793 {
794 HepLorentzVector p4;
795 p4.setPx(- sin(helix[1]) / fabs(helix[2]));
796 p4.setPy(cos(helix[1]) / fabs(helix[2]));
797 p4.setPz(helix[4] / fabs(helix[2]));
798 double p3 = p4.mag();
799 mass = 0.000511;
800 p4.setE(sqrt(p3 * p3 + mass * mass));
801
802 double ecm;
803 if (runNo > 9815) {
804 ecm = 3.097;
805 }else{
806 ecm = 3.68632;
807 }
808 double zboost = 0.0075;
809 //HepLorentzVector psip(0.011 * 3.68632, 0, 0.0075, 3.68632);
810 HepLorentzVector psip(0.011 * ecm, 0, zboost, ecm);
811 //cout << setw(15) << ecm << setw(15) << zboost << endl;
812 Hep3Vector boostv = psip.boostVector();
813
814 //std::cout<<__FILE__<<" boostv "<<boostv<< std::endl;
815 p4.boost(- boostv);
816
817 //std::cout<<__FILE__<<" p4 "<<p4<< std::endl;
818 double p_cms = p4.rho();
819 //phicms = p4.phi();
820 //p4.boost(boostv);
821
822 return p_cms;
823}
double mass
int runNo
Definition: DQA_TO_DB.cxx:12
double p_cms(HepVector helix, int runNo, double mass) const
double double double * p4
Definition: qcdloop1.h:77
double double * p3
Definition: qcdloop1.h:76

Referenced by p_cms().

◆ patErr2BesErr()

HepSymMatrix MdcUtilitySvc::patErr2BesErr ( const HepSymMatrix &  err) const

Definition at line 311 of file MdcUtilitySvc.cxx.

311 {
312 //error matrix
313 //std::cout<<" err1 "<<err<<" "<<err.num_row()<<std::endl;
314 //V(Y)=S * V(X) * ST , mS = S , mVy = V(Y) , err() = V(X)
315 //int n = err.num_row();
316 HepSymMatrix mS(err.num_row(),0);
317 mS[0][0]=-1.;//dr0=-d0
318 mS[1][1]=1.;
319
320 mS[2][2]=Bz()/-333.567;//pxy -> cpa
321 mS[3][3]=1.;
322 mS[4][4]=1.;
323 HepSymMatrix mVy= err.similarity(mS);
324 //std::cout<<" err2 "<<n<<" "<<mVy<<std::endl;
325 return mVy;
326}

◆ patPar2BesPar()

HepVector MdcUtilitySvc::patPar2BesPar ( const HepVector &  helixPar) const

Definition at line 294 of file MdcUtilitySvc.cxx.

294 {
295 HepVector helix(5,0);
296 double d0 = -helixPar[0]; //cm
297 double phi0 = helixPar[1]+ CLHEP::halfpi;
298 double omega = Bz()*helixPar[2]/-333.567;
299 double z0 = helixPar[3]; //cm
300 double tanl = helixPar[4];
301 helix[0] = d0;
302 helix[1] = phi0;
303 helix[2] = omega;
304 helix[3] = z0;
305 helix[4] = tanl;
306 //std::cout<<"helix "<<helix<<std::endl;
307 return helix;
308}

Referenced by cellTrackPassedPatPar().

◆ pointOnHelix()

HepPoint3D MdcUtilitySvc::pointOnHelix ( const HepVector  helixPar,
int  lay,
int  innerOrOuter 
) const

Definition at line 330 of file MdcUtilitySvc.cxx.

330 {
331 HepVector helixPat= besPar2PatPar(helixBes);
332 return pointOnHelixPatPar(helixPat, layer, innerOrOuter);
333}

◆ pointOnHelixPatPar()

HepPoint3D MdcUtilitySvc::pointOnHelixPatPar ( const HepVector  helixPat,
int  lay,
int  innerOrOuter 
) const

Definition at line 337 of file MdcUtilitySvc.cxx.

337 {
338
339 double rInner,rOuter;
340 //retrieve Mdc geometry information
341 double rCize1 =0.1* m_mdcGeomSvc->Layer(layer)->RCSiz1(); //mm -> cm
342 double rCize2 =0.1* m_mdcGeomSvc->Layer(layer)->RCSiz2(); //mm -> cm
343 double rLay =0.1* m_mdcGeomSvc->Layer(layer)->Radius(); //mm -> cm
344
345 //(conversion of the units mm(mc)->cm(rec))
346 rInner = rLay - rCize1 ; //radius of inner field wire
347 rOuter = rLay + rCize2 ; //radius of outer field wire
348
349 //int sign = -1; //assumed the first half circle
350 HepPoint3D piv(0.,0.,0.);
351 double r;
352 if (innerOrOuter) r = rInner;
353 else r = rOuter;
354
355 double d0 = helixPat[0];
356 double phi0 = helixPat[1];
357 double omega = helixPat[2];
358 double z0 = helixPat[3];
359 double tanl = helixPat[4];
360
361 double rc;
362 if (abs(omega) <Constants::epsilon) rc = 9999.;
363 else rc = 1./omega;
364 double xc = piv.x() + ( d0 + rc) * cos(phi0);
365 double yc = piv.y() + ( d0 + rc) * sin(phi0);
366 HepPoint3D helixCenter(xc,yc,0.0);
367 rc = sqrt(xc*xc + yc*yc);//?
368 double a,b,c;
369 a = r;
370 b = d0 + rc;
371 c = rc;
372 double dphi = acos((a*a-b*b-c*c)/(-2.*b*c));
373 double fltlen = dphi * rc;
374 double phi = phi0 * omega * fltlen;
375 double x = piv.x()+d0*sin(phi) - (rc+d0)*sin(phi0);
376 double y = piv.y()+d0*cos(phi) + (rc+d0)*cos(phi0);
377 double z = piv.z()+ z0 + fltlen*tanl;
378 //std::cout<<" xc yc "<<xc<<" "<<yc
379 if(m_debug) {
380 std::cout<<" abc "<<a<<" "<<b<<" "<<c<<" omega "<<omega<<" r "<<r<<" rc "<<rc<<" dphi "<<dphi<<" piv "<<piv.z()
381 <<" z0 "<<z0<<" fltlen "<<fltlen<<" tanl "<<tanl<<std::endl;
382 std::cout<<" pointOnHelixPatPar in Hel "<<helixPat<<std::endl;
383 cout<<"HepPoint3D(x, y, z) = "<<HepPoint3D(x, y, z)<<endl;
384 }
385 return HepPoint3D(x, y, z);
386}
static const double epsilon
Definition: Constants.h:46
const double b
Definition: slope.cxx:9

Referenced by docaPatPar(), and pointOnHelix().

◆ probab()

double MdcUtilitySvc::probab ( const int &  ndof,
const double &  chisq 
) const

Definition at line 843 of file MdcUtilitySvc.cxx.

843 {
844
845 //constants
846 double srtopi=2.0/sqrt(2.0*M_PI);
847 double upl=100.0;
848
849 double prob=0.0;
850 if(ndof<=0) {return prob;}
851 if(chisq<0.0) {return prob;}
852 if(ndof<=60) {
853 //full treatment
854 if(chisq>upl) {return prob;}
855 double sum=exp(-0.5*chisq);
856 double term=sum;
857
858 int m=ndof/2;
859 if(2*m==ndof){
860 if(m==1){return sum;}
861 for(int i=2; i<=m;i++){
862 term=0.5*term*chisq/(i-1);
863 sum+=term;
864 }//(int i=2; i<=m)
865 return sum;
866 //even
867
868 }else{
869 //odd
870 double srty=sqrt(chisq);
871 double temp=srty/M_SQRT2;
872 prob=erfc(temp);
873 if(ndof==1) {return prob;}
874 if(ndof==3) {return (srtopi*srty*sum+prob);}
875 m=m-1;
876 for(int i=1; i<=m; i++){
877 term=term*chisq/(2*i+1);
878 sum+=term;
879 }//(int i=1; i<=m; i++)
880 return (srtopi*srty*sum+prob);
881
882 }//(2*m==ndof)
883
884 }else{
885 //asymtotic Gaussian approx
886 double srty=sqrt(chisq)-sqrt(ndof-0.5);
887 if(srty<12.0) {prob=0.5*erfc(srty);};
888
889 }//ndof<30
890
891 return prob;
892}//endof probab
EvtComplex exp(const EvtComplex &c)
Definition: EvtComplex.hh:252
#define M_PI
Definition: TConstant.h:4

The documentation for this class was generated from the following files: