4static const double Small( 0.01 );
5static const double Infinite( 1.0e10 );
6static const double kRad = 57.2958;
8static const int fix_ = 1;
9static const int chi2lim_ = 100;
19 if(!HitExist) {FilterOK =
false;
return FilterOK;}
20 m_samestrip = m_gapid[0]==m_nearesthit->
Part()&& m_gapid[1]==m_nearesthit->
Seg()&&m_gapid[2]==m_nearesthit->
Gap()&&m_iStrip==m_nearesthit->
Strip();
23 Hep3Vector mom_unit = m_CurrentMomentum;
29 m_orient = nearestGap->
Orient();
32 if(m_orient==1) m_sigma = sx/sqrt(12.);
33 if(m_orient==0) m_sigma = sy/sqrt(12.);
36 HepSymMatrix IntrErr_loc(6,0);
37 IntrErr_loc.assign(rotation*m_CurrentInsctXPErr*rotation.T());
38 Hep3Vector modpos_loc;
39 Hep3Vector modmom_loc;
40 HepSymMatrix moderr_loc(6,0);
42 double chisq =
Fit(IntrPos_loc,mom_loc,IntrErr_loc);
43 modpos_loc.setX(m_bm[0]);modpos_loc.setY(m_bm[1]);modpos_loc.setZ(m_bm[2]);
44 modmom_loc.setX(m_bm[3]);modmom_loc.setY(m_bm[4]);modmom_loc.setZ(m_bm[5]);
46bool direction =
false;
47double dirchange = (modmom_loc.theta()-1.5707963)*(mom_loc.theta()-1.5707963);
48if(dirchange<0.) {direction =
true;
53HepSymMatrix moderr_glob(6,0);
54moderr_glob.assign(rotation.T()*moderr_loc*rotation);
56if(chisq>0.&&chisq<100.&&!direction)
61 m_err_mod = moderr_glob;
62 m_pos_mod = modpos_glob;
63 m_mom_mod = modmom_glob;
80 vector<MucRecHit*> hitvec;
81 vector<MucRecHit*> HitInGap =
GapHit();
82 int hitsize = HitInGap.size();
83 double dist_nearest = 9999.;
84 for (
int h = 0;h<hitsize;h++ )
91 HepSymMatrix IntrErr_loc(6,0);
92 IntrErr_loc.assign(rotation*m_CurrentInsctXPErr*rotation.T());
96 double window = -9999.;
99 window = n_sigm*sqrt(IntrErr_loc(1,1)+sx*sx/12.);
103 window = n_sigm*sqrt(IntrErr_loc(2,2)+sy*sy/12.);
109 if(fabs(distance)<window)
111 hitvec.push_back(myhit);
112 if(dist_nearest>fabs(distance))
116 dist_nearest=fabs(distance);
117 m_nearesthit = HitInGap[h];
128 cout <<
"RecMucTrack:GetHitDistance-E1 null hit pointer!" << endl;
132 int part = hit->
Part();
133 int gap = hit->
Gap();
135 cout <<
"RecMucTrack::GetHitDistance() bad gap number = " << gap << endl;
143 float distance = -9990;
144 if(orient == 1) distance = (posHitLocal.x()-posInsctLocal.x());
145 if(orient == 0) distance = (posHitLocal.y()-posInsctLocal.y());
154 Hep3Vector mom_unit= m_CurrentMomentum;
155 mom_unit.setMag(1.0);
157 m_CurrentInsct = _interc;
159 int iStrip = box->
GuessStrip(m_CurrentInsct_loc.x(),m_CurrentInsct_loc.y(),m_CurrentInsct_loc.z());
178 m_CurrentInsctXPErr = m_CurrentXPErr.similarity( m_jcb );
197 vector<MucRecHit*> gaphit;
199 MucDigiCol::iterator digiIter = m_MucDigiCol->begin();
200 for ( ; digiIter != m_MucDigiCol->end(); digiIter++ )
207 int m_part =(int)m_gapid[0];
208 int m_seg = (int)m_gapid[1];
209 int m_gap = (int)m_gapid[2];
212 if(m_part==part&&m_gap == layer)
221 gaphit.push_back(hit);
230m_hitgap.setX(m_nearesthit->
Part());
231m_hitgap.setY(m_nearesthit->
Seg());
232m_hitgap.setZ(m_nearesthit->
Gap());
239 HepMatrix m_xp_jcb(6,6,0);
240 double dx( ( m_CurrentInsct - m_CurrentPosition ).mag() );
242 double p2( m_CurrentMomentum.mag2() );
243 double p_abs( sqrt(
p2 ) );
246 if( p_abs > Small && m_CurrentMomentum.mag() > Small ){
252 double p2inv( p_inv * p_inv );
253 double p3inv( p2inv * p_inv );
254 double fdx( dx * p3inv );
256 double fdp( dp * p_inv );
257 double px( m_CurrentMomentum.x() );
258 double py( m_CurrentMomentum.y() );
259 double pz( m_CurrentMomentum.z() );
260 double px2( px * px );
261 double py2( py * py );
262 double pz2( pz * pz );
263 double pxy( px * py );
264 double pyz( py * pz );
265 double pzx( pz * px );
266 m_xp_jcb( 1, 1 ) = 1.0;
267 m_xp_jcb( 1, 4 ) = fdx * ( py2 + pz2 );
268 m_xp_jcb( 1, 5 ) = - fdx * pxy;
269 m_xp_jcb( 1, 6 ) = - fdx * pzx;
270 m_xp_jcb( 2, 2 ) = 1.0;
271 m_xp_jcb( 2, 4 ) = - fdx * pxy;
272 m_xp_jcb( 2, 5 ) = fdx * ( pz2 + px2 );
273 m_xp_jcb( 2, 6 ) = - fdx * pyz;
275 m_xp_jcb( 3, 3 ) = 1.0;
276 m_xp_jcb( 3, 4 ) = - fdx * pzx;
277 m_xp_jcb( 3, 5 ) = - fdx * pyz;
278 m_xp_jcb( 3, 6 ) = fdx * ( px2 + py2 );
280 m_xp_jcb( 4, 4 ) = 1.0 - fdp;
281 m_xp_jcb( 5, 5 ) = 1.0 - fdp;
282 m_xp_jcb( 6, 6 ) = 1.0 - fdp;
293 float thetaX,phiX,thetaY,phiY,thetaZ,phiZ;
302 Hep3Vector colX, colY,colZ;
303 colX.setRThetaPhi(1.,thetaX,phiX);
304 colY.setRThetaPhi(1.,thetaY,phiY);
305 colZ.setRThetaPhi(1.,thetaZ,phiZ);
307 HepMatrix rotation(6,6,0);
308 rotation(1,1) = colX.x();
309 rotation(1,2) = colX.y();
310 rotation(1,3) = colX.z();
311 rotation(2,1) = colY.x();
312 rotation(2,2) = colY.y();
313 rotation(2,3) = colY.z();
314 rotation(3,1) = colZ.x();
315 rotation(3,2) = colZ.y();
316 rotation(3,3) = colZ.z();
318 rotation(4,4) = colX.x();
319 rotation(4,5) = colX.y();
320 rotation(4,6) = colX.z();
321 rotation(5,4) = colY.x();
322 rotation(5,5) = colY.y();
323 rotation(5,6) = colY.z();
324 rotation(6,4) = colZ.x();
325 rotation(6,5) = colZ.y();
326 rotation(6,6) = colZ.z();
333 static HepVector a(6,0);
343 HepMatrix V_meas(1,1,0);
344 V_meas(1,1)= m_sigma*m_sigma;
345 double mag2(m_bm[5]*m_bm[5]+m_bm[4]*m_bm[4]+m_bm[3]*m_bm[3]);
347 HepSymMatrix ebm(6,0);
356 if(m_orient == 1)
H(1,1) = 1;
357 if(m_orient == 0)
H(1,2) = 1;
358 HepMatrix ebm_HT(6,1,0);
359 ebm_HT = ebm *
H.T();
364 HepMatrix Aii(1,1,0);
365 Aii(1,1)=(
H * ebm_HT)(1,1);
366 R =
H * ebm_HT + V_meas;
369 double aii = Aii(1,1);
373 K = ebm_HT * R.inverse(ierr);
377 if(r==0.)pull = 9999;
383 HepVector diff_v_bm(6, 0);
384 diff_v_bm = K * dist;
388 if ((fabs(diff_v_bm[0]) > 2 * n_sigm * sqrt(V_meas(1,1)+fabs(m_Ebm(1,1)))&&m_orient==1) ||
389 (fabs(diff_v_bm[1]) > 2 * n_sigm * sqrt(V_meas(1,1)+fabs(m_Ebm(2,2)))&&m_orient==0) ){
391 cout<<
"KLMK:WARNING! Huge diff_v_bm found!Discard this fit!: "<<endl;
395 HepVector v_bm_mod = v_bm + diff_v_bm;
397 static const HepSymMatrix Id(6,1);
398 HepMatrix ebm_mod(6,6,0);
399 ebm_mod = (Id - K*
H) * ebm;
401 r_bm = (1 - (
H*K)(1,1))*dist;
404 Rk = (V_meas -
H * ebm_mod *
H.T())(1,1);
411 if (chi2>0 && chi2 < chi2lim_) {
412 HepSymMatrix ebm_replace;
413 ebm_replace.assign(ebm_mod);
414 HepVector v_bm_replace;
415 v_bm_replace = v_bm_mod;
421 double mag2mod(m_bm[5]*m_bm[5]+m_bm[4]*m_bm[4]+m_bm[3]*m_bm[3]);
422 v_bm_replace[3] = v_bm_replace[3]*sqrt(mag2)/sqrt(mag2mod);
423 v_bm_replace[4] = v_bm_replace[4]*sqrt(mag2)/sqrt(mag2mod);
424 v_bm_replace[5] = v_bm_replace[5]*sqrt(mag2)/sqrt(mag2mod);
const int kDeltaSeg[kNSegSearch]
double GetDistance(const MucRecHit *hit)
vector< MucRecHit * > GapHit()
double Fit(Hep3Vector &pos, Hep3Vector &mom, HepSymMatrix &err)
HepMatrix GetRoationMatrix(MucGeoGap *box)
void XPmod(Hep3Vector &pos, Hep3Vector &mom, HepSymMatrix &err)
vector< MucRecHit * > TrackHit()
Hep3Vector RotateToGlobal(const Hep3Vector pVect) const
Rotate a vector from gap coordinate to global coordinate.
Hep3Vector RotateToGap(const Hep3Vector gVect) const
Rotate a vector from global coordinate to gap coordinate.
HepPoint3D TransformToGlobal(const HepPoint3D pPoint) const
Transform a point from gap coordinate to global coordinate.
int GuessStrip(const float x, const float y, const float z) const
HepPoint3D ProjectToGap(const HepPoint3D gPoint, const Hep3Vector gVect) const
Given a line, find the intersection with the gap in the global.
void GetRotationMatrix(float &thetaX, float &phiX, float &thetaY, float &phiY, float &thetaZ, float &phiZ) const
Get the rotation angles (in degrees) of the gap in global coordinate.
HepPoint3D TransformToGap(const HepPoint3D gPoint) const
Transform a point from global coordinate to gap coordinate.
MucGeoGap * GetGap(const int part, const int seg, const int gap) const
Get a pointer to the gap identified by (part,seg,gap).
static MucGeoGeneral * Instance()
Get a pointer to the single instance of MucGeoGeneral.
void GetCenterSigma(float &sx, float &sy, float &sz)
Get uncertainty in the position of this strip (in the gap coordinate system).
static int barrel_ec(const Identifier &id)
Values of different levels.
static int layer(const Identifier &id)
static int segment(const Identifier &id)
static value_type getSegNum(int part)
static int strip(const Identifier &id)
static value_type getGapNum(int part)
MucGeoGap * GetGap() const
Get geometry data for the gap containing this hit.
Hep3Vector GetCenterPos() const
Get Center position of the strip (global coords).
MucGeoStrip * GetStrip() const
Get geometry data for the strip containing this hit.
int Part() const
Get Part.
int Strip() const
Get Strip.