7#include "CLHEP/Geometry/Point3D.h"
8#include "CLHEP/Matrix/SymMatrix.h"
9#include "CLHEP/Vector/ThreeVector.h"
10#include "MdcGeom/BesAngle.h"
11#include "MdcGeom/Constants.h"
12#include "MdcRecoUtil/DifNumber.h"
13#include "MdcRecoUtil/DifPoint.h"
14#include "MdcRecoUtil/DifVector.h"
15#include "TrkBase/HelixTraj.h"
16#include "TrkBase/TrkExchangePar.h"
17#include "TrkBase/TrkVisitor.h"
25# define M_2PI 2 * M_PI
30 :
TrkSimpTraj( pvec, pcov, lowlim, hilim, refpoint ) {
35 std::cout <<
"ErrMsg(fatal) "
36 <<
"HelixTraj: incorrect constructor vector/matrix dimension" << std::endl;
45 :
TrkSimpTraj( inpar.params(), inpar.covariance(), lowlim, hilim, refpoint ) {
74double HelixTraj::z(
const double&
f )
const {
79 double cDip = cosDip();
80 double sDip =
tanDip() * cDip;
82 double ang = phi00 + cDip *
f *
omega();
83 double cang =
cos( ang );
84 double sang =
sin( ang );
85 double sphi0 =
sin( phi00 );
86 double cphi0 =
cos( phi00 );
98 double cDip = cosDip();
103 double ang = angle( fltLen );
104 double cDip = cosDip();
105 double delX = -
omega() * cDip * cDip *
sin( ang );
106 double delY =
omega() * cDip * cDip *
cos( ang );
107 return Hep3Vector( delX, delY, 0.0 );
121 Hep3Vector& delDir )
const {
123 double cDip = cosDip();
124 double sDip =
tanDip() * cDip;
126 double ang = phi00 + cDip * fltLen *
omega();
127 double cang =
cos( ang );
128 double sang =
sin( ang );
129 double sphi0 =
sin( phi00 );
130 double cphi0 =
cos( phi00 );
139 dir.setX( cang * cDip );
140 dir.setY( sang * cDip );
143 double delX = -
omega() * cDip * cDip * sang;
144 double delY =
omega() * cDip * cDip * cang;
152 double cDip = cosDip();
153 double sDip =
tanDip() * cDip;
155 double ang = phi00 + cDip * fltLen *
omega();
156 double cang =
cos( ang );
157 double sang =
sin( ang );
158 double sphi0 =
sin( phi00 );
159 double cphi0 =
cos( phi00 );
168 dir.setX( cang * cDip );
169 dir.setY( sang * cDip );
338 HepMatrix ddflct(
NHLXPRM, 1 );
342 double omeg =
omega();
344 double arcl = arc( fltlen );
345 double dx =
cos( arcl );
346 double dy =
sin( arcl );
347 double cosd = cosDip();
348 double darc = omeg *
d0();
357 ddflct(
tanDipIndex + 1, 1 ) = 1.0 / ( cosd * cosd );
358 ddflct(
d0Index + 1, 1 ) = ( 1 - dx ) * tand / omeg;
359 ddflct(
phi0Index + 1, 1 ) = -dy * tand / ( 1 + darc );
362 -translen( fltlen ) - ( tand * tand ) * dy / ( omeg * ( 1 + darc ) );
367 ddflct(
d0Index + 1, 1 ) = -dy / ( cosd * omeg );
368 ddflct(
phi0Index + 1, 1 ) = dx / ( cosd * ( 1 + darc ) );
369 ddflct(
z0Index + 1, 1 ) = -tand * ( 1 - dx / ( 1 + darc ) ) / ( cosd * omeg );
385 HepMatrix ddflct(
NHLXPRM, 1 );
389 double omeg =
omega();
391 double arcl = arc( fltlen );
392 double dx =
cos( arcl );
393 double dy =
sin( arcl );
394 double cosd = cosDip();
395 double sind = sinDip();
396 double darc_1 = 1.0 + omeg *
d0();
405 ddflct(
d0Index + 1, 1 ) = -sind * dy;
406 ddflct(
phi0Index + 1, 1 ) = sind * dx * omeg / darc_1;
407 ddflct(
z0Index + 1, 1 ) = sind * tand * dx / darc_1 + cosd;
413 ddflct(
phi0Index + 1, 1 ) = dy * omeg / darc_1;
414 ddflct(
z0Index + 1, 1 ) = tand * dy / darc_1;
431 HepMatrix dmomfrac(
NHLXPRM, 1 );
435 double omeg =
omega();
437 double tranl = translen( fltlen );
438 double arcl = tranl * omeg;
439 double dx =
cos( arcl );
440 double dy =
sin( arcl );
441 double darc = omeg *
d0();
449 dmomfrac(
d0Index + 1, 1 ) = -( 1 - dx ) / omeg;
451 dmomfrac(
phi0Index + 1, 1 ) = dy / ( 1 + darc );
453 dmomfrac(
z0Index + 1, 1 ) = -tand * ( tranl - dy / ( ( 1 + darc ) * omeg ) );
462 double cosd = cosDip();
464 return ( cosd * cosd ) * fabs(
omega() );
472 const HepVector& oldvec,
const HepSymMatrix& oldcov,
473 HepVector& newvec, HepSymMatrix& newcov,
double fltlen ) {
475 HepVector parvec( oldvec );
479 double delx = newpoint.x() - oldpoint.x();
480 double dely = newpoint.y() - oldpoint.y();
481 double delz = newpoint.z() - oldpoint.z();
488 double perp = delx * sin0 - dely * cos0;
489 double para = delx * cos0 + dely * sin0;
491 double oldphi = parvec[
phi0Index] + fltlen * parvec[
omegaIndex] / sqrt( 1. + tand * tand );
493 double newdelta2 = delta * delta + delx * delx + dely * dely + 2.0 * delta * perp;
495 double newdelta = delta > 0 ? sqrt( newdelta2 ) : -sqrt( newdelta2 );
496 double invdelta = 1.0 / newdelta;
497 double invdelta2 = 1.0 / newdelta2;
501 double newphi = atan2( sin0 + delx / delta, cos0 - dely / delta );
502 while ( fabs( newphi - oldphi ) >
M_PI )
503 if ( newphi > oldphi ) newphi -=
M_2PI;
504 else newphi +=
M_2PI;
506 double delphi = newphi - parvec[
phi0Index];
508 newvec[
z0Index] += tand *
rad * (delphi)-delz;
518 covrot(
d0Index + 1,
omegaIndex + 1 ) = rad2 * ( 1.0 - invdelta * ( delta + perp ) );
535 newcov = oldcov.similarity( covrot );
548 for (
unsigned iparam = 0; iparam <
NHLXPRM; iparam++ )
556 flags[iparam] =
true;
560 flags[iparam] =
false;
563 flags[iparam] =
false;
576double HelixTraj::angle(
const double&
f )
const {
return BesAngle(
phi0() + arc(
f ) ); }
579 os <<
"HelixTraj with range " <<
lowRange() <<
" to " <<
hiRange() <<
" and parameters "
581 <<
"d0= " <<
d0() <<
" phi0= " <<
phi0() <<
" omega= " <<
omega() <<
" z0 = " <<
z0()
582 <<
" tanDip= " <<
tanDip() << endl;
HepGeom::Point3D< double > HepPoint3D
TFile f("ana_bhabha660a_dqa_mcPat_zy_old.root")
double sin(const BesAngle a)
double cos(const BesAngle a)
HepGeom::Point3D< double > HepPoint3D
void setIndepPar(const DifIndepPar *par)
DifNumber & mod(double lo, double hi)
void cosAndSin(DifNumber &c, DifNumber &s) const
double curvature(double fltLen) const
HelixTraj(const HepVector &, const HepSymMatrix &, double lowlim=-99999., double hilim=99999., const HepPoint3D &refpoint=_theOrigin)
HepMatrix derivDeflect(double fltlen, deflectDirection) const
HelixTraj * clone() const
virtual void getDFInfo2(double fltLen, DifPoint &pos, DifVector &dir) const
HepMatrix derivPFract(double fltlen) const
virtual void print(std::ostream &os) const
virtual HepPoint3D position(double fltLen) const
void invertParams(TrkParams *params, std::vector< bool > &flags) const
virtual Hep3Vector delDirect(double) const
HelixTraj & operator=(const HelixTraj &)
virtual void printAll(std::ostream &os) const
virtual double distTo2ndError(double s, double tol, int pathDir) const
HepMatrix derivDisplace(double fltlen, deflectDirection idir) const
virtual void getDFInfo(double fltLen, DifPoint &, DifVector &dir, DifVector &delDir) const
virtual void getInfo(double fltLen, HepPoint3D &pos, Hep3Vector &dir) const
virtual double distTo1stError(double s, double tol, int pathDir) const
virtual void visitAccept(TrkVisitor *vis) const
virtual Hep3Vector direction(double fltLen) const
virtual void print(std::ostream &os) const
Trajectory & operator=(const Trajectory &)
TrkSimpTraj(const HepVector ¶ms, const HepSymMatrix &cov, const double startRange=-99999., const double endRange=99999., const HepPoint3D &refpoint=_theOrigin)
const HepPoint3D & referencePoint() const
virtual void trkVisitHelixTraj(const HelixTraj *)=0