CGEM BOSS 6.6.5.i
BESIII Offline Software System
Loading...
Searching...
No Matches
CgemHitOnTrack Class Reference

#include <CgemHitOnTrack.h>

+ Inheritance diagram for CgemHitOnTrack:

Public Member Functions

 CgemHitOnTrack (const RecCgemCluster &baseHit, double fittime)
 
virtual ~CgemHitOnTrack ()
 
double entranceAngleHit () const
 
double entranceAngle () const
 
double entranceAngle (const HepPoint3D pos, const Hep3Vector dir) const
 
double dipAngle () const
 
double fitTime () const
 
double drift (double dca) const
 
double dcaToWire () const
 
double rawTime () const
 
virtual const TrajectoryhitTraj () const
 
virtual bool timeResid (double &t, double &tErr) const
 
virtual bool timeAbsolute (double &t, double &tErr) const
 
unsigned tdcIndex () const
 
unsigned status () const
 
unsigned layerNumber () const
 
double charge () const
 
TrkEnums::TrkViewInfo whatView () const
 
void setT0 (double t0)
 
virtual TrkHitOnTrkclone (TrkRep *, const TrkDifTraj *trkTraj=0) const
 
void setCgemGeomSvc (const CgemGeomSvc *svc)
 
void setCgemCalibFunSvc (const CgemCalibFunSvc *svc)
 
void print (std::ostream &) const
 
const RecCgemClusterbaseHit () const
 
TrkErrCode getFitStuff (HepVector &derivs, HepVector &derivs2, double &sigma1, double &sigma2, double &deltaChi1, double &deltaChi2) const
 
TrkErrCode getFitStuff (double &sigma1, double &sigma2, double &deltaChi1, double &deltaChi2) const
 
TrkErrCode getFitStuff (HepVector &Xderivs, double &XdeltaChi, HepVector &Vderivs, double &VdeltaChi) const
 
TrkErrCode getFitStuff (double &XdeltaChi, double &VdeltaChi) const
 
- Public Member Functions inherited from TrkHitOnTrk
 TrkHitOnTrk (const TrkFundHit *, double tolerance)
 
virtual ~TrkHitOnTrk ()
 
const TrkRecoTrkgetParentTrack () const
 
const TrkRepgetParentRep () const
 
PdtPid::PidType particleType () const
 
const TrkFundHithit () const
 
TrkFundHithit ()
 
const TrkDifTrajtrkTraj () const
 
virtual const MdcHitOnTrackmdcHitOnTrack () const
 
virtual const SvtHitOnTrack * svtHitOnTrack () const
 
bool isActive () const
 
bool isUsable () const
 
bool mustUse () const
 
double hitRms () const
 
double weight () const
 
double fltLen () const
 
double hitLen () const
 
virtual int ambig () const
 
virtual void setAmbig (int newambig)
 
bool operator== (const TrkHitOnTrk &) const
 
bool operator< (const TrkHitOnTrk &rhs) const
 
bool hasResidual () const
 
TrkErrCode getFitStuff (HepVector &derivs, double &deltaChi) const
 
TrkErrCode getFitStuff (double &deltaChi) const
 
double resid (bool exclude=false) const
 
bool resid (double &resid, double &residErr, bool exclude=false) const
 
double residual () const
 
TrkRecoTrkparentTrack () const
 
void setActivity (bool turnOn)
 
void setUsability (int usability)
 
void setFltLen (double f)
 
void setHitRms (double newRms)
 
virtual void printAll (std::ostream &) const
 

Protected Member Functions

 CgemHitOnTrack (const TrkFundHit *baseHit, int ambig, double fittime, int layer, int wire)
 
 CgemHitOnTrack (const CgemHitOnTrack &hitToBeCopied, TrkRep *newRep, const TrkDifTraj *trkTraj, const RecCgemCluster *hb=0)
 
bool isBeyondEndflange () const
 
bool updateAmbiguity (double dca)
 
virtual TrkErrCode updateMeasurement (const TrkDifTraj *traj, bool maintainAmbiguity)
 
void changeBase (RecCgemCluster *newBase)
 
- Protected Member Functions inherited from TrkHitOnTrk
 TrkHitOnTrk (const TrkHitOnTrk &hitToBeCopied, TrkRep *newRep, const TrkDifTraj *trkTraj=0)
 
void setHitResid (double newResid)
 
TrkRepparentRep () const
 
void setHitLen (double h)
 
void setUsedHit ()
 
void setUnusedHit ()
 
TrkErrCode updatePoca (const TrkDifTraj *trkTraj, bool maintainAmbiguity)
 

Additional Inherited Members

- Public Types inherited from TrkHitOnTrk
typedef std::unary_function< TrkHitOnTrk, boolpredicate_type
 
- Protected Attributes inherited from TrkHitOnTrk
TrkRep_parentRep
 
TrkFundHit_theHit
 
bool _isActive
 
int _isUsable
 
double _hitRms
 
double _trkLen
 
double _hitLen
 
double _resid
 
const TrkDifTraj_trkTraj
 
TrkPoca_poca
 
double _tolerance
 

Detailed Description

Definition at line 44 of file CgemHitOnTrack.h.

Constructor & Destructor Documentation

◆ CgemHitOnTrack() [1/3]

CgemHitOnTrack::CgemHitOnTrack ( const RecCgemCluster & baseHit,
double fittime )

Definition at line 40 of file CgemHitOnTrack.cxx.

43: TrkHitOnTrk(NULL,10.e-4),
44 //: TrkHitOnTrk(&fundHit,10.e-4),
45 //_hitTraj(baseHit.hitTraj()), //yzhang FIXME add hitTraj of this Cluster ?
46 //_fitTime(baseHit.rawTime()-t0*1e-9),
47 _fitTime(t0*1e-9),//yzhang FIXME
48 _dHit(&baseHit)
49{
50 ICgemGeomSvc* icgemGeomSvc = NULL;
51 StatusCode sc = Gaudi::svcLocator()->service("CgemGeomSvc", icgemGeomSvc);
52 CgemGeomSvc* cgemGeomSvc = dynamic_cast<CgemGeomSvc*> (icgemGeomSvc);
53 if(sc==StatusCode::SUCCESS && cgemGeomSvc!=NULL){
54 _clusterr = cgemGeomSvc->getCgemLayer(baseHit.getlayerid())->getMiddleROfGapD()/10.;//r[baseHit.getlayerid()];
55 //std::cout<<__FILE__<<" "<<__LINE__<<" _clusterr "<<_clusterr<<std::endl;
56 }else{
57 _clusterr = -999;
58 //std::cout<<__FILE__<<" "<<__LINE__<<" _clusterr Could not find CgemGeomSvc "<<_clusterr<<std::endl;
59 }
60 //hitTraj not implemented
61 // need to flag somehow that that we haven't computed things yet...
62 // now, we know that _drift[0] is for ambig <0, and _drift[1] is ambig >0
63 // and _drift is signed according to ambig. Thus _drift[0] should be -tive
64 // and _drift[1] should be +tive. To indicate this are not yet initialized,
65 // put 'impossible' values here...
66 //_drift[0] = +9999;
67 //_drift[1] = -9999;
68 setHitResid(-21212121.0);
69 setHitRms( 0.02 );
70 //setHitLen(0.5 * baseHit.layer()->zLength());//yzhang FIXME
71 setFltLen(0.);
72 //layer
73 double length = cgemGeomSvc->getCgemLayer(baseHit.getlayerid())->getLengthOfCgemLayer();
74 //_startLen = hitTraj()->lowRange() - 5.;//lowRange?
75 //_endLen = hitTraj()->hiRange() + 5.;
76 _startLen = -1.*length/2. - 5.;
77 _endLen = length/2. + 5.;
78
79 //double r[3] = {7.9838 ,12.5104 ,16.7604};//cm
80}
double length
double getMiddleROfGapD() const
double getLengthOfCgemLayer() const
CgemGeoLayer * getCgemLayer(int i) const
Definition CgemGeomSvc.h:48
const RecCgemCluster * baseHit() const
int getlayerid(void) const
void setHitResid(double newResid)
void setHitRms(double newRms)
TrkHitOnTrk(const TrkFundHit *, double tolerance)
void setFltLen(double f)

Referenced by clone().

◆ ~CgemHitOnTrack()

CgemHitOnTrack::~CgemHitOnTrack ( )
virtual

Definition at line 129 of file CgemHitOnTrack.cxx.

130{ ; }

◆ CgemHitOnTrack() [2/3]

CgemHitOnTrack::CgemHitOnTrack ( const TrkFundHit * baseHit,
int ambig,
double fittime,
int layer,
int wire )
protected

◆ CgemHitOnTrack() [3/3]

CgemHitOnTrack::CgemHitOnTrack ( const CgemHitOnTrack & hitToBeCopied,
TrkRep * newRep,
const TrkDifTraj * trkTraj,
const RecCgemCluster * hb = 0 )
protected

Definition at line 115 of file CgemHitOnTrack.cxx.

117: TrkHitOnTrk(hot,newRep,trkTraj)
118{
119 _hitTraj = hot._hitTraj;
120 _fitTime = hot._fitTime;
121 _drift[0] = hot._drift[0];
122 _drift[1] = hot._drift[1];
123 _startLen = hot._startLen;
124 _endLen = hot._endLen;
125 _dHit = (hb==0?hot._dHit:hb);
126 _clusterr = hot._clusterr;
127}
const TrkDifTraj * trkTraj() const
Definition TrkHitOnTrk.h:77

Member Function Documentation

◆ baseHit()

◆ changeBase()

void CgemHitOnTrack::changeBase ( RecCgemCluster * newBase)
protected

Definition at line 376 of file CgemHitOnTrack.cxx.

377{
378 _dHit = newBase;
379}

◆ charge()

double CgemHitOnTrack::charge ( ) const

Definition at line 360 of file CgemHitOnTrack.cxx.

361 {
362 return _dHit->getenergydeposit();
363 }
double getenergydeposit(void) const

◆ clone()

TrkHitOnTrk * CgemHitOnTrack::clone ( TrkRep * rep,
const TrkDifTraj * trkTraj = 0 ) const
virtual

Implements TrkHitOnTrk.

Definition at line 83 of file CgemHitOnTrack.cxx.

84{
85 return new CgemHitOnTrack(*this,rep,trkTraj);
86}
CgemHitOnTrack(const RecCgemCluster &baseHit, double fittime)

◆ dcaToWire()

double CgemHitOnTrack::dcaToWire ( ) const

Definition at line 140 of file CgemHitOnTrack.cxx.

141{
142 double dca = -9999.;
143 if ( getParentRep() == 0 ) {
144 // cout << "no parent rep" << endl;
145 return dca;
146 }
147 // WARNING: cannot use the internal _poca, as it lags one iteration
148 // behind the fit... therfore use _EXTERNAL_ residual
149 //if (isActive()) { // FIXME: currently can only use 'resid()' if isActive..
150 // dca = resid()+drift();
151 //} else {
152 // TrkPoca poca(getParentRep()->traj(), fltLen(), *hitTraj(), hitLen(),
153 // _tolerance);
154 // if (poca.status().success()) dca = poca.doca();
155 //}
156 //yzhang FIXME
157 return dca;
158}
const TrkRep * getParentRep() const
Definition TrkHitOnTrk.h:73

◆ dipAngle()

double CgemHitOnTrack::dipAngle ( ) const

Definition at line 196 of file CgemHitOnTrack.cxx.

197{
198 return getParentRep()==0?0:Constants::pi/2-getParentRep()->traj().direction(fltLen()).theta();
199}
static const double pi
Definition Constants.h:38
virtual Hep3Vector direction(double) const =0
virtual const TrkDifTraj & traj() const =0
double fltLen() const
Definition TrkHitOnTrk.h:91

◆ drift()

double CgemHitOnTrack::drift ( double dca) const
inline

Definition at line 80 of file CgemHitOnTrack.h.

80{ return _drift[dca<0?0:1]; }

◆ entranceAngle() [1/2]

double CgemHitOnTrack::entranceAngle ( ) const

Definition at line 172 of file CgemHitOnTrack.cxx.

173{
174 static Hep3Vector dir;
175 static HepPoint3D pos;
176 if (getParentRep() == 0) return 0.;
177 getParentRep()->traj().getInfo(fltLen(), pos, dir);
178
179 return entranceAngle(pos, dir);
180}
double entranceAngle() const
virtual void getInfo(double fltLen, HepPoint3D &pos, Hep3Vector &direction) const =0

Referenced by entranceAngle().

◆ entranceAngle() [2/2]

double CgemHitOnTrack::entranceAngle ( const HepPoint3D pos,
const Hep3Vector dir ) const

Definition at line 183 of file CgemHitOnTrack.cxx.

184{
185 double angle = EntranceAngle(dir.phi() - _dHit->getrecphi());
186 return angle;
187}
double getrecphi(void) const

◆ entranceAngleHit()

double CgemHitOnTrack::entranceAngleHit ( ) const

Definition at line 161 of file CgemHitOnTrack.cxx.

162{
163 static Hep3Vector dir;
164 static HepPoint3D pos;
165 if (getParentRep() == 0) return 0.;
166 getParentRep()->traj().getInfo(fltLen(), pos, dir);
167
168 return BesAngle(dir.phi() - pos.phi());
169}

◆ fitTime()

double CgemHitOnTrack::fitTime ( ) const
inline

Definition at line 74 of file CgemHitOnTrack.h.

74{ return _fitTime; }

◆ getFitStuff() [1/4]

TrkErrCode CgemHitOnTrack::getFitStuff ( double & sigma1,
double & sigma2,
double & deltaChi1,
double & deltaChi2 ) const

Definition at line 489 of file CgemHitOnTrack.cxx.

490{
491 assert (_trkTraj == &(getParentRep()->traj()));
492 double vec_phi = _dHit->getrecphi() ;
493 double vec_z = _dHit->getRecZ() ;
494 double flt=0;
495 HepVector trkpar = getParentRep()->traj().localTrajectory(0.,flt)->parameters()->parameter(); //get para??????
496 IMdcUtilitySvc* m_mdcUtilitySvc;
497 Gaudi::svcLocator()->service("MdcUtilitySvc",m_mdcUtilitySvc);
498 if (m_mdcUtilitySvc == NULL) cout<< " Can not load MdcUtilitySvc"<<endl;
499 HepVector trkparbes = m_mdcUtilitySvc->patPar2BesPar(trkpar);
500 trkparbes[2]=-trkparbes[2]; // modification for the reversed sign in TrackUtil/Helix
501
502 HepPoint3D pivot(0., 0., 0.);
503 Helix cgem_helix_0(pivot, trkparbes);
504 HepSymMatrix V(2,0), W(2,0) ;
505 HepVector dm(2);
506 int layer = _dHit->getlayerid() ;
507 double rl, R, x_reso, v_reso, a_stero;
508 if(layer==0) { rl=79.838/10. ; R=87.5026/10.; x_reso=0.1372/10.; v_reso=0.1273/10.;a_stero=45.94*3.1415926/180;}
509 else if (layer==1) { rl=125.104/10. ; R=132.7686/10.; x_reso=0.1476/10.;v_reso=0.1326/10.;a_stero=31.10*3.1415926/180;}
510 else { rl=167.604/10.; R=175.2686/10.; x_reso=0.1412/10.;v_reso=0.1378/10.;a_stero=32.99*3.1415926/180;} //cm
511 double d_phi = cgem_helix_0.IntersectCylinder(rl); //const can only call const
512 HepPoint3D pos = cgem_helix_0.x(d_phi);
513
514 double x = pos.x();
515 double y = pos.y();
516 double z = pos.z();
517 double r2 = x*x+y*y;
518 double tmp_phi = atan2(y, x); //[-pi,pi), return azimuthal angle
519 double dphi = vec_phi - tmp_phi;
520 if(dphi < -M_PI) dphi += 2*M_PI;
521 if(dphi >= M_PI) dphi -= 2*M_PI;
522
523 dm[0]=dphi*rl*sin(vec_phi);
524 dm[1]=-(vec_z-z);
525 V(1,1)=rl*rl/R/R*sin(vec_phi)*sin(vec_phi)*x_reso*x_reso;
526 V(2,1)=rl/R*sin(vec_phi)/tan(a_stero)*x_reso*x_reso;
528 W=V;
529 int ifail=99;
530 V.invert(ifail);
531 if (ifail) {
533 }
534
535 sigma1=sqrt(W(1,1));
536 sigma2=sqrt(W(2,2));
537 deltaChi1=dm[0]; //V(1,2)=V(2,1)
538 deltaChi2=dm[1];
539
541}
double tan(const BesAngle a)
Definition BesAngle.h:216
double sin(const BesAngle a)
Definition BesAngle.h:210
const double a_stero[3]
double sigma2(0)
Double_t x[10]
const double x_reso[3]
const double v_reso[3]
#define M_PI
Definition TConstant.h:4
HepVector & parameter()
Definition DifIndepPar.h:51
virtual HepVector patPar2BesPar(const HepVector &helixPar) const =0
double getRecZ(void) const
virtual const TrkSimpTraj * localTrajectory(double fltLen, double &localFlt) const =0
const TrkDifTraj * _trkTraj
TrkParams * parameters()
Definition TrkSimpTraj.h:80
complex_t R(double Q2, double M2, double G, double Mp2, double Mm2)
Definition TUtil.h:27

◆ getFitStuff() [2/4]

TrkErrCode CgemHitOnTrack::getFitStuff ( double & XdeltaChi,
double & VdeltaChi ) const

Definition at line 671 of file CgemHitOnTrack.cxx.

672{
673 //---get infomation from cluster
674 int layer = _dHit->getlayerid();
675 int sheet = _dHit->getsheetid();
676 double phi_cluster = _dHit->getrecphi();
677 double z_cluster = _dHit->getRecZ()/10;
678 double Q = _dHit->getenergydeposit();
679
680 //---get geometry parameters from CgemGeomSvc
681 CgemGeoReadoutPlane* readoutPlane = _cgemGeomSvc->getReadoutPlane(layer,sheet);
682 double r_X = readoutPlane->getRX()/10;
683 double r_V = readoutPlane->getRV()/10;
684 double r_M = readoutPlane->getMidRAtGap()/10;
685 double a_stero = readoutPlane->getStereoAngle();
686
687 //---calculate the intersection of cgem layer and helix track
688 double flt=0;
689 HepVector trkpar = getParentRep()->traj().localTrajectory(0.,flt)->parameters()->parameter(); //get para??????
690 HepPoint3D pivot(0,0,0);
691 //cout<<"barbar parameters:"<<trkpar[0]<<" "<<trkpar[1]<<" "<<trkpar[2]<<" "<<trkpar[3]<<" "<<trkpar[4]<<endl;
692 trkpar[0] = -trkpar[0];// BarBar d0 -> BESIII dr
693 trkpar[1] = trkpar[1]-M_PI/2;// BarBar phi0 -> BESIII phi0
694 trkpar[2] = 333.567*trkpar[2];// BarBar omega -> BESIII kappa
695 trkpar[2] = -trkpar[2]; // modification for the reversed sign in TrackUtil/Helix
696 trkpar[3] = trkpar[3];
697 trkpar[4] = trkpar[4];
698 while(trkpar[1] < 0) trkpar[1] += 2*M_PI;
699 while(trkpar[1] >= 2*M_PI) trkpar[1] -= 2*M_PI;
700 //cout<<"besIII parameters:"<<trkpar[0]<<" "<<trkpar[1]<<" "<<trkpar[2]<<" "<<trkpar[3]<<" "<<trkpar[4]<<endl;
701 Helix cgem_helix_0(pivot, trkpar);
702 double dPhi = cgem_helix_0.IntersectCylinder(r_M);
703 HepPoint3D pos = cgem_helix_0.x(dPhi);
704 double x_cross = pos.x();
705 double y_cross = pos.y();
706 double z_cross = pos.z();
707 double phi_cross = pos.phi(); //[-pi,pi)
708 while( phi_cross < 0) phi_cross += 2*M_PI;
709 while( phi_cross >= 2*M_PI) phi_cross -= 2*M_PI;
710 double r2 = pos.perp2();
711 //double dphi = phi_cluster - phi_cross;
712 double dphi = phi_cross - phi_cluster;
713 while(dphi < -M_PI) dphi += 2*M_PI;
714 while(dphi >= M_PI) dphi -= 2*M_PI;
715
716 //---get sigma of X and V strip from CgemCalibFunSvc
717 int iView(0), mode(1);//FIXME
718 double T(100);//FIXME
719 double Phi_tangent = cgem_helix_0.direction(dPhi).phi();
720 double Phi_position = phi_cross;//FIXME
721 double delta_phi=Phi_tangent - Phi_position;
722 while(delta_phi>M_PI) delta_phi-=CLHEP::twopi;
723 while(delta_phi<-M_PI) delta_phi+=CLHEP::twopi;
724 double sigma_X = _cgemCalibFunSvc->getSigma(layer,0,mode,delta_phi,Q,T)/10;// mm->cm
725 double sigma_V = _cgemCalibFunSvc->getSigma(layer,1,mode,delta_phi,Q,T)/10;// mm->cm
726
727 //---return the partial derivatives and residuals of X and V
728 int nPar = getParentRep()->traj().localTrajectory(0.,flt)->nPar();
729 XdeltaChi = dphi*r_X/sigma_X;//delta X
730 //VdeltaChi = ((z_cluster-z_cross)*sin(a_stero)+r_V*cos(a_stero)*dphi)/sigma_V;
731 VdeltaChi = ((z_cross-z_cluster)*sin(a_stero)+r_V*cos(a_stero)*dphi)/sigma_V;
732 //cout<<"X:"<<phi_cluster<<" "<<phi_cross<<" "<<sigma_V<<endl;
733 //cout<<"V:"<<z_cluster<<" "<<z_cross<<" "<<sigma_V<<endl;
734 if(nPar == 3){
735 VdeltaChi = 0;
736 }
738}
double cos(const BesAngle a)
Definition BesAngle.h:213
double getSigma(int layer, int xvFlag, int readoutMode, double angle, double Q, double T) const
CgemGeoReadoutPlane * getReadoutPlane(int iLayer, int iSheet) const
int getsheetid(void) const
virtual int nPar() const
Definition TrkSimpTraj.h:88

◆ getFitStuff() [3/4]

TrkErrCode CgemHitOnTrack::getFitStuff ( HepVector & derivs,
HepVector & derivs2,
double & sigma1,
double & sigma2,
double & deltaChi1,
double & deltaChi2 ) const

Definition at line 398 of file CgemHitOnTrack.cxx.

399{
400 //std::cout<<__FILE__<<" "<<__LINE__<<" CgemHitOnTrack::getFitStuff implemented"<<std::endl;
401 if (_poca==0 || _poca->status().failure()) {
403 }
404 double vec_phi = _dHit->getrecphi() ;
405 double vec_z = _dHit->getRecZ() ;
406 double flt=0;
407 HepVector trkpar = getParentRep()->traj().localTrajectory(0.,flt)->parameters()->parameter(); //get para??????
408 IMdcUtilitySvc* m_mdcUtilitySvc;
409 Gaudi::svcLocator()->service("MdcUtilitySvc",m_mdcUtilitySvc);
410 if (m_mdcUtilitySvc == NULL) cout<< " Can not load MdcUtilitySvc"<<endl;
411 HepVector trkparbes = m_mdcUtilitySvc->patPar2BesPar(trkpar);
412 trkparbes[2]=-trkparbes[2]; // modification for the reversed sign in TrackUtil/Helix
413
414 HepPoint3D pivot(0., 0., 0.);
415 Helix cgem_helix_0(pivot, trkparbes);
416 HepMatrix J_dmdx(2,3,0), J_dxda(3,5,0), J(2,5,0) ;
417 HepSymMatrix V(2,0), W(2,0) ;
418 HepVector a_new(5), dm(2);
419 J_dmdx(1,1)= 1. ;
420 J_dmdx(2,3)= 1. ;
421 int layer = _dHit->getlayerid() ;
422 double rl, R, x_reso, v_reso, a_stero;
423
424 if(layer==0) { rl=79.838/10. ; R=87.5026/10.; x_reso=0.1372/10.; v_reso=0.1273/10.;a_stero=45.94*3.1415926/180;}
425 else if (layer==1) { rl=125.104/10. ; R=132.7686/10.; x_reso=0.1476/10.;v_reso=0.1326/10.;a_stero=31.10*3.1415926/180;}
426 else { rl=167.604/10.; R=175.2686/10.; x_reso=0.1412/10.;v_reso=0.1378/10.;a_stero=32.99*3.1415926/180;} //cm
427 double d_phi = cgem_helix_0.IntersectCylinder(rl); //const can only call const
428 HepPoint3D pos = cgem_helix_0.x(d_phi);
429 double x = pos.x();
430 double y = pos.y();
431 double z = pos.z();
432 double r2 = x*x+y*y;
433 double tmp_phi = atan2(y, x); //[-pi,pi), return azimuthal angle
434 double dphi = vec_phi - tmp_phi;
435 if(dphi < -M_PI) dphi += 2*M_PI;
436 if(dphi >= M_PI) dphi -= 2*M_PI;
437 dm[0]=-dphi*rl*sin(vec_phi);
438 dm[1]=vec_z-z;
439 J_dxda=cgem_helix_0.delXDelA(d_phi); //3X5; derivative of x,y,z to 5 paras
440 J=J_dmdx*J_dxda;
441 for (int i=0;i<5;i++){
442 derivs2[i]=J(1,i) ;
443 derivs2[i+5]=J(2,i) ;
444 }
445 V(1,1)=rl*rl/R/R*sin(vec_phi)*sin(vec_phi)*x_reso*x_reso;
446 V(2,1)=rl/R*sin(vec_phi)/tan(a_stero)*x_reso*x_reso;
448 W=V;
449
450 int ifail=99;
451 V.invert(ifail);
452 if (ifail) {
454 }
455 J=V*J;
456
457 for (int i=0;i<5;i++){
458 derivs[i]=J(1,i) ;
459 derivs[i+5]=J(2,i) ;
460 }
461 assert (_trkTraj == &(getParentRep()->traj()));
462 sigma1=sqrt(W(1,1));
463 sigma2=sqrt(W(2,2));
464 deltaChi1=dm[0]; //V(1,2)=V(2,1)
465 deltaChi2=dm[1];
466
468 // FIXME: I wish I could tell poca to NOT iterate
469 // and ONLY compute the distance & derivatives...
470 // TrkDifPoca poca(*_trkTraj,fltLen(),*hitTraj(), hitLen(),_tolerance);
471 /*
472 if (poca.status().failure()) {
473 return TrkErrCode(TrkErrCode::fail);
474 }
475 if (derivs.num_row() != 0) {
476 poca.fetchDerivs(derivs);
477 } else {
478 derivs = poca.derivs();
479 }
480 double sigInv = 1. / hitRms();
481 deltaChi = _resid * sigInv; // NOTE: use _INTERNAL_ residual
482 derivs *= sigInv;
483 */
484 //return TrkErrCode(TrkErrCode::fail);//yzhang FIXME
485}
int failure() const
Definition TrkErrCode.h:61
TrkPoca * _poca
const TrkErrCode & status() const
Definition TrkPocaBase.h:62

Referenced by TrkHelixFitter::fit().

◆ getFitStuff() [4/4]

TrkErrCode CgemHitOnTrack::getFitStuff ( HepVector & Xderivs,
double & XdeltaChi,
HepVector & Vderivs,
double & VdeltaChi ) const

Definition at line 543 of file CgemHitOnTrack.cxx.

544{
545 //---get infomation from cluster
546 int layer = _dHit->getlayerid();
547 int sheet = _dHit->getsheetid();
548 double phi_cluster = _dHit->getrecphi();
549 double z_cluster = _dHit->getRecZ()/10;
550 double Q = _dHit->getenergydeposit();
551 //cout<<"layer:"<<layer<<endl;
552
553 //---get geometry parameters from CgemGeomSvc
554 CgemGeoReadoutPlane* readoutPlane = _cgemGeomSvc->getReadoutPlane(layer,sheet);
555 double r_X = readoutPlane->getRX()/10;
556 double r_V = readoutPlane->getRV()/10;
557 double r_M = readoutPlane->getMidRAtGap()/10;
558 double a_stero = readoutPlane->getStereoAngle();
559
560 //---calculate the intersection of cgem layer and helix track
561 double flt=0;
562 HepVector trkpar = getParentRep()->traj().localTrajectory(0.,flt)->parameters()->parameter(); //get para??????
563 //cout<<"barbar:"<<trkpar[0]<<" "<<trkpar[1]<<" "<<trkpar[2]<<" "<<trkpar[3]<<" "<<trkpar[4]<<endl;
564 HepPoint3D pivot(0,0,0);
565 trkpar[0] = -trkpar[0];// BarBar d0 -> BESIII dr
566 trkpar[1] = trkpar[1]-M_PI/2;// BarBar phi0 -> BESIII phi0
567 trkpar[2] = 333.567*trkpar[2];// BarBar omega -> BESIII kappa
568 trkpar[2] = -trkpar[2]; // modification for the reversed sign in TrackUtil/Helix
569 trkpar[3] = trkpar[3];
570 trkpar[4] = trkpar[4];
571 while(trkpar[1] < 0) trkpar[1] += 2*M_PI;
572 while(trkpar[1] >= 2*M_PI) trkpar[1] -= 2*M_PI;
573 //cout<<"besIII:"<<trkpar[0]<<" "<<trkpar[1]<<" "<<trkpar[2]<<" "<<trkpar[3]<<" "<<trkpar[4]<<endl;
574
575 Helix cgem_helix_0(pivot, trkpar);
576 double dPhi = cgem_helix_0.IntersectCylinder(r_M);
577 HepPoint3D pos = cgem_helix_0.x(dPhi);
578 double x_cross = pos.x();
579 double y_cross = pos.y();
580 double z_cross = pos.z();
581 double phi_cross = pos.phi(); //[-pi,pi)
582 while( phi_cross < 0) phi_cross += 2*M_PI;
583 while( phi_cross >= 2*M_PI) phi_cross -= 2*M_PI;
584 double r2 = pos.perp2();
585 //double dphi = phi_cluster - phi_cross;
586 double dphi = phi_cross - phi_cluster;
587 while(dphi < -M_PI) dphi += 2*M_PI;
588 while(dphi >= M_PI) dphi -= 2*M_PI;
589 //cout<<"radius:"<<cgem_helix_0.radius()<<endl;
590 //cout<<"distance:"<<cgem_helix_0.center().perp()<<endl;
591
592 //---get sigma of X and V strip from CgemCalibFunSvc
593 int iView(0), mode(1);//FIXME
594 double T(100);//FIXME
595 double Phi_tangent = cgem_helix_0.direction(dPhi).phi();
596 double Phi_position = phi_cross;//FIXME
597 double delta_phi=Phi_tangent - Phi_position;
598 while(delta_phi>M_PI) delta_phi-=CLHEP::twopi;
599 while(delta_phi<-M_PI) delta_phi+=CLHEP::twopi;
600 double sigma_X = _cgemCalibFunSvc->getSigma(layer,0,mode,delta_phi,Q,T)/10;// mm->cm
601 double sigma_V = _cgemCalibFunSvc->getSigma(layer,1,mode,delta_phi,Q,T)/10;// mm->cm
602
603 //---calculate partial derivative of X and V w.r.t x,y,z
604 HepMatrix J_dmdx(2,3,0), J_dxda(3,5,0), J(2,5,0);
605 J_dmdx(1,1)=-r_X*y_cross/r2;
606 J_dmdx(1,2)= r_X*x_cross/r2;
607 J_dmdx(1,3)= 0.0;
608 J_dmdx(2,1)=-r_V*cos(a_stero)*y_cross/r2;
609 J_dmdx(2,2)= r_V*cos(a_stero)*x_cross/r2;
610 J_dmdx(2,3)= sin(a_stero);
611
612 //---calculate partial derivative of x,y,z w.r.t helix parameters:dr, phi0, kappa, dz, tanl
613 double alpha = cgem_helix_0.alpha();
614 //cout<<"alpha:"<<alpha<<endl;
615 alpha = -alpha; // modification for the reversed sign in TrackUtil/Helix
616 double dr = cgem_helix_0.dr();
617 double phi0 = cgem_helix_0.phi0();
618 double kappa = cgem_helix_0.kappa();
619 kappa = -kappa; // modification for the reversed sign in TrackUtil/Helix
620 double dz = cgem_helix_0.dz();
621 double tanl = cgem_helix_0.tanl();
622
623 double cosPhi=cos(dPhi);
624 double sinPhi=sin(dPhi);
625
626 double dPhiDdr = -(kappa/alpha-cosPhi/(dr+alpha/kappa))/sinPhi;
627 //double dPhiDdr2= -kappa*kappa*(2.0*alpha*dr+kappa*(dr*dr+r2))/(2*alpha*(alpha+dr*kappa)*(alpha+dr*kappa)*sinPhi);
628 //cout<<"dPhiDdr = "<<dPhiDdr<<endl;
629 //cout<<"dPhiDdr2= "<<dPhiDdr2<<endl;
630 double dPhiDkappa = -kappa*(dr*dr-r2)*(2*alpha+dr*kappa)/(2*alpha*(alpha+dr*kappa)*(alpha+dr*kappa)*sinPhi);
631
632 double dxDdr = cos(phi0)+alpha/kappa*sin(phi0+dPhi)*dPhiDdr;
633 double dyDdr = sin(phi0)-alpha/kappa*cos(phi0+dPhi)*dPhiDdr;
634 double dxDphi0 = -dr*sin(phi0)+alpha/kappa*(-sin(phi0)+sin(phi0+dPhi));
635 double dyDphi0 = -dr*cos(phi0)+alpha/kappa*( cos(phi0)-cos(phi0+dPhi));
636 double dxDkappa = -alpha/(kappa*kappa)*(cos(phi0)-cos(phi0+dPhi))+alpha/kappa*sin(phi0+dPhi)*dPhiDkappa;
637 double dyDkappa = -alpha/(kappa*kappa)*(sin(phi0)-sin(phi0+dPhi))-alpha/kappa*cos(phi0+dPhi)*dPhiDkappa;
638 double dzDdr = -alpha/kappa*tanl*dPhiDdr;
639 double dzDkappa = alpha/(kappa*kappa)*tanl*dPhi-alpha/kappa*tanl*dPhiDkappa;
640 double dzDtanl = -alpha/kappa*dPhi;
641
642 //---return the partial residuals and derivatives of X and V w.r.t helix parameters:d0, phi0, omega, z0, tanl
643 J_dxda(1,1) = -1*dxDdr;//BESIII dr -> BarBar d0
644 J_dxda(1,2) = dxDphi0;
645 J_dxda(1,3) = -alpha*dxDkappa;// BESIII kappa -> BarBar omega
646 J_dxda(2,1) = -1*dyDdr;//BESIII dr -> BarBar d0
647 J_dxda(2,2) = dyDphi0;
648 J_dxda(2,3) = -alpha*dyDkappa;// BESIII kappa -> BarBar omega
649 J_dxda(3,1) = -1*dzDdr;//BESIII dr -> BarBar d0
650 J_dxda(3,3) = -alpha*dzDkappa;// BESIII kappa -> BarBar omega
651 J_dxda(3,4) = 1.0;
652 J_dxda(3,5) = dzDtanl;
653 J=J_dmdx*J_dxda;
654 int nPar = getParentRep()->traj().localTrajectory(0.,flt)->nPar();
655 for(int i=1;i<=nPar;i++){
656 Xderivs(i) = J(1,i)/sigma_X;
657 Vderivs(i) = J(2,i)/sigma_V;
658 }
659 XdeltaChi = dphi*r_X/sigma_X;//delta X
660 //VdeltaChi = ((z_cluster-z_cross)*sin(a_stero)+r_V*cos(a_stero)*dphi)/sigma_V;
661 VdeltaChi = ((z_cross-z_cluster)*sin(a_stero)+r_V*cos(a_stero)*dphi)/sigma_V;
662 //cout<<"X:"<<phi_cluster<<" "<<phi_cross<<" "<<sigma_V<<endl;
663 //cout<<"V:"<<z_cluster<<" "<<z_cross<<" "<<sigma_V<<endl;
664 if(nPar == 3){
665 Vderivs = HepVector(nPar,0);
666 VdeltaChi = 0;
667 }
669}
const double alpha

◆ hitTraj()

const Trajectory * CgemHitOnTrack::hitTraj ( ) const
virtual

Implements TrkHitOnTrk.

Definition at line 366 of file CgemHitOnTrack.cxx.

367{
368 //return _hitTraj;
369 std::cout<<__FILE__<<" "<<__LINE__<<" CgemHitOnTrack::hitTraj() not implemented, return NULL "<<std::endl;
370 return NULL;
371}

◆ isBeyondEndflange()

bool CgemHitOnTrack::isBeyondEndflange ( ) const
inlineprotected

Definition at line 136 of file CgemHitOnTrack.h.

137 { return (hitLen() < _startLen || hitLen() > _endLen); }
double hitLen() const
Definition TrkHitOnTrk.h:92

◆ layerNumber()

unsigned CgemHitOnTrack::layerNumber ( ) const
inlinevirtual

Implements TrkHitOnTrk.

Definition at line 100 of file CgemHitOnTrack.h.

100{ return _dHit->getlayerid();}

◆ print()

void CgemHitOnTrack::print ( std::ostream & ) const
virtual

Reimplemented from TrkHitOnTrk.

Definition at line 392 of file CgemHitOnTrack.cxx.

392 {
393 std::cout<<" CgemHOT id "<<_dHit->getclusterid()<<" layer "<<_dHit->getlayerid()<<" recphi "<< _dHit->getrecphi()<<" recv "<< _dHit->getrecv()<<" recz "<<_dHit->getRecZ() << std::endl;
394}
int getclusterid(void) const
double getrecv(void) const

◆ rawTime()

double CgemHitOnTrack::rawTime ( ) const

◆ setCgemCalibFunSvc()

void CgemHitOnTrack::setCgemCalibFunSvc ( const CgemCalibFunSvc * svc)
inline

Definition at line 115 of file CgemHitOnTrack.h.

115{_cgemCalibFunSvc = svc;}

Referenced by CgemMdcFitAlg::fit(), HoughTrack::fitCircle(), HoughTrack::fitHelix(), and HoughTrack::fitHelix().

◆ setCgemGeomSvc()

void CgemHitOnTrack::setCgemGeomSvc ( const CgemGeomSvc * svc)
inline

Definition at line 114 of file CgemHitOnTrack.h.

114{_cgemGeomSvc = svc;}

Referenced by CgemMdcFitAlg::fit(), HoughTrack::fitCircle(), HoughTrack::fitHelix(), and HoughTrack::fitHelix().

◆ setT0()

void CgemHitOnTrack::setT0 ( double t0)

Definition at line 133 of file CgemHitOnTrack.cxx.

134{
135 //_fitTime= _dHit->rawTime()-t0*1e-9;
136 _fitTime = t0*1e-9;//FIXME
137}

◆ status()

unsigned CgemHitOnTrack::status ( ) const
inline

Definition at line 94 of file CgemHitOnTrack.h.

94{ return -999;}//FIXME

◆ tdcIndex()

unsigned CgemHitOnTrack::tdcIndex ( ) const
inline

Definition at line 93 of file CgemHitOnTrack.h.

93{ return -999;}//FIXME

◆ timeAbsolute()

bool CgemHitOnTrack::timeAbsolute ( double & t,
double & tErr ) const
virtual

Implements TrkHitOnTrk.

Definition at line 304 of file CgemHitOnTrack.cxx.

305{
306 double tresid(-1.0);
307 if(timeResid(tresid,tErr)){
308 // add back the track time
309 t = tresid + getParentRep()->parentTrack()->trackT0();
310 return true;
311 } else
312 return false;
313}
virtual bool timeResid(double &t, double &tErr) const
double trackT0() const
TrkRecoTrk * parentTrack()
Definition TrkRep.h:82
int t()
Definition t.c:1

◆ timeResid()

bool CgemHitOnTrack::timeResid ( double & t,
double & tErr ) const
virtual

Implements TrkHitOnTrk.

Definition at line 293 of file CgemHitOnTrack.cxx.

294{
295 //double v = driftVelocity();
296 //if (v <= 0) return false;
297 //t = (fabs(drift())-fabs(dcaToWire()))/v;
298 t = -999;//FIXME
299 //tErr= hitRms()/v;
300 return true;
301}

Referenced by timeAbsolute().

◆ updateAmbiguity()

bool CgemHitOnTrack::updateAmbiguity ( double dca)
protected

◆ updateMeasurement()

TrkErrCode CgemHitOnTrack::updateMeasurement ( const TrkDifTraj * traj,
bool maintainAmbiguity )
protectedvirtual

Implements TrkHitOnTrk.

Definition at line 202 of file CgemHitOnTrack.cxx.

203{
204 //std::cout<<__FILE__<<" "<<__LINE__<<" WARNING CgemHitOnTrack::updateMeasurement not implemented "<<std::endl;
205 traj = (traj!=0?traj:&(getParentRep()->traj()));//track traj
206 //TrkErrCode status=updatePoca(traj,maintainAmb);
207 //if (status.failure()) {
208 // std::cout<<" ErrMsg(warning) " << "CgemHitOnTrack::updateMeasurement failed " << status << std::endl;
209 // return status;
210 //}
211 //assert (_poca!=0);
212 double dca=-999;//FIXME _poca->doca();
213 ////yzhang FIXME
214 bool forceIteration = true;//(maintainAmb&&ambig()!=0)?false:updateAmbiguity(dca);
215 //if( whatView()==0) {
216 BesAngle phiCluster = BesAngle(_dHit->getrecphi());//-pi 2 pi
217 double flt=0;
218 const HepVector par = getParentRep()->traj().localTrajectory(0.,flt)->parameters()->parameter();
219 //cout<<par<<endl;
220 double d0 = par[0];
221 double phi0 = par[1];
222 double omega = par[2];
223 double radius = fabs(omega)<0.00001 ? -9999: 1./fabs(omega);
224 double l = d0 + radius;
225 double r = _clusterr;
226 double xc = l * cos(phi0 - Constants::halfPi);
227 double yc = l * sin(phi0 - Constants::halfPi);
228 double phi_center = atan2(yc,xc);
229
230 double cosPhi = (radius * radius + l * l - r * r) / (2 * radius * l);
231 if(cosPhi < -1 || cosPhi > 1) return TrkErrCode(TrkErrCode::fail);
232 double dPhi = phi_center - acos(cosPhi) - (phi0-Constants::halfPi);
233 //std::cout<<__FILE__<<" "<<__LINE__<<" radius "<<radius<<" l "<<l<<" r "<<r<<" xc "<<xc<<" yc "<<yc <<" cosPhi "<<cosPhi<<" phi center "<<phi_center<<" phi0 - pi/2 "<<phi0-Constants::halfPi<<" "<<std::endl;
234 BesAngle phi(dPhi);
235 //if(dPhi < -M_PI) dPhi += 2 * M_PI;
236
237 double x = radius*sin(dPhi) - (radius + d0)*sin(phi0);
238 double y = -1.*radius*cos(dPhi) + (radius + d0)*sin(phi0);
239
240 //double phiTrack = atan2(y,x);
241 BesAngle phiTrack = BesAngle(atan2(y,x));
242
243 //std::cout<<__FILE__<<" "<<__LINE__<<" phiCluster "<<phiCluster<<" phiTrack "<<phiTrack<<" x "<<x<<" y "<<y<<std::endl;
244 dca = (phiCluster - phiTrack).rad();
245 //}
246 //return TrkErrCode(TrkErrCode::fail);//not used for fit
247 return TrkErrCode(TrkErrCode::succeed);//not used for fit
248 //TrkErrCode(TrkErrCode::succeed, 11, "Ambiguity flipped");
249}
static const double halfPi
Definition Constants.h:40
const float rad
Definition vector3.h:134

◆ whatView()

TrkEnums::TrkViewInfo CgemHitOnTrack::whatView ( ) const
virtual

Implements TrkHitOnTrk.

Definition at line 316 of file CgemHitOnTrack.cxx.

317{
318 //enum TrkViewInfo {noView=-1,xyView=0, zView, bothView };
320 if(_dHit->getflag()==0) view = TrkEnums::TrkViewInfo(0);
321 else if(_dHit->getflag()==1) view = TrkEnums::TrkViewInfo(1);
322 else if(_dHit->getflag()==2) view = TrkEnums::TrkViewInfo(2);
323
324 return view;
325}
int getflag(void) const

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