3 * \author Thomas Ullrich, Sep 26 1997
5 * Parametrization of a helix. Can also cope with straight tracks, i.e.
6 * with zero curvature. This represents only the mathematical model of
7 * a helix. See the SCL user guide for more.
9 /***************************************************************************
13 * Author: Thomas Ullrich, Sep 1997
14 ***************************************************************************
16 * Description: Parametrization of a helix
18 ***************************************************************************
21 * Revision 1.1.1.1 2007/04/25 15:38:41 panos
22 * Importing the HBT code dir
24 * Revision 1.1.1.1 2007/03/07 10:14:49 mchojnacki
25 * First version on CVS
27 * Revision 1.11 2005/10/13 22:23:27 genevb
28 * NoSolution is public
30 * Revision 1.10 2005/07/06 18:49:56 fisyak
31 * Replace AliFmHelixD, AliFmLorentzVectorD,AliFmLorentzVectorF,AliFmMatrixD,AliFmMatrixF,AliFmPhysicalHelixD,AliFmThreeVectorD,AliFmThreeVectorF by templated version
33 * Revision 1.9 2004/12/02 02:51:16 ullrich
34 * Added option to pathLenghth() and distance() to search for
35 * DCA only within one period. Default stays as it was.
37 * Revision 1.8 2003/10/30 20:06:46 perev
38 * Check of quality added
40 * Revision 1.7 2002/06/21 17:49:25 genevb
41 * Some minor speed improvements
43 * Revision 1.6 2002/04/24 02:41:55 ullrich
44 * Restored old format.
46 **************************************************************************/
54 #include "AliFmThreeVector.h"
55 #if !defined(ST_NO_NAMESPACES)
67 /// curvature, dip angle, phase, origin, h
68 AliFmHelix(double c, double dip, double phase,
69 const AliFmThreeVector<double>& o, int h=-1);
71 virtual ~AliFmHelix();
72 // AliFmHelix(const AliFmHelix&); // use default
73 // AliFmHelix& operator=(const AliFmHelix&); // use default
75 double dipAngle() const;
76 double curvature() const; /// 1/R in xy-plane
77 double phase() const; /// aziumth in xy-plane measured from ring center
78 double xcenter() const; /// x-center of circle in xy-plane
79 double ycenter() const; /// y-center of circle in xy-plane
80 int h() const; /// -sign(q*B);
82 const AliFmThreeVector<double>& origin() const; /// starting point
84 void setParameters(double c, double dip, double phase, const AliFmThreeVector<double>& o, int h);
86 double x(double s) const;
87 double y(double s) const;
88 double z(double s) const;
90 AliFmThreeVector<double> at(double s) const;
92 /// returns period length of helix
93 double period() const;
95 /// path length at given r (cylindrical r)
96 pair<double, double> pathLength(double r) const;
98 /// path length at given r (cylindrical r, cylinder axis at x,y)
99 pair<double, double> pathLength(double r, double x, double y, bool scanPeriods = true);
101 /// path length at distance of closest approach to a given point
102 double pathLength(const AliFmThreeVector<double>& p, bool scanPeriods = true) const;
104 /// path length at intersection with plane
105 double pathLength(const AliFmThreeVector<double>& r,
106 const AliFmThreeVector<double>& n) const;
108 /// path length at distance of closest approach in the xy-plane to a given point
109 double pathLength(double x, double y) const;
111 /// path lengths at dca between two helices
112 pair<double, double> pathLengths(const AliFmHelix&, bool scanPeriods = true) const;
114 /// minimal distance between point and helix
115 double distance(const AliFmThreeVector<double>& p, bool scanPeriods = true) const;
117 /// checks for valid parametrization
118 bool valid(double world = 1.e+5) const {return !bad(world);}
119 int bad(double world = 1.e+5) const;
121 /// move the origin along the helix to s which becomes then s=0
122 virtual void moveOrigin(double s);
124 static const double NoSolution;
129 void setCurvature(double); /// performs also various checks
130 void setPhase(double);
131 void setDipAngle(double);
133 /// value of S where distance in x-y plane is minimal
134 double fudgePathLength(const AliFmThreeVector<double>&) const;
137 bool mSingularity; // true for straight line case (B=0)
138 AliFmThreeVector<double> mOrigin;
142 int mH; // -sign(q*B);
149 ClassDef(AliFmHelix,1)
154 // Non-member functions
156 int operator== (const AliFmHelix&, const AliFmHelix&);
157 int operator!= (const AliFmHelix&, const AliFmHelix&);
158 ostream& operator<<(ostream&, const AliFmHelix&);
163 inline int AliFmHelix::h() const {return mH;}
165 inline double AliFmHelix::dipAngle() const {return mDipAngle;}
167 inline double AliFmHelix::curvature() const {return mCurvature;}
169 inline double AliFmHelix::phase() const {return mPhase;}
171 inline double AliFmHelix::x(double s) const
174 return mOrigin.x() - s*mCosDipAngle*mSinPhase;
176 return mOrigin.x() + (cos(mPhase + s*mH*mCurvature*mCosDipAngle)-mCosPhase)/mCurvature;
179 inline double AliFmHelix::y(double s) const
182 return mOrigin.y() + s*mCosDipAngle*mCosPhase;
184 return mOrigin.y() + (sin(mPhase + s*mH*mCurvature*mCosDipAngle)-mSinPhase)/mCurvature;
187 inline double AliFmHelix::z(double s) const
189 return mOrigin.z() + s*mSinDipAngle;
192 inline const AliFmThreeVector<double>& AliFmHelix::origin() const {return mOrigin;}
194 inline AliFmThreeVector<double> AliFmHelix::at(double s) const
196 return AliFmThreeVector<double>(x(s), y(s), z(s));
199 inline double AliFmHelix::pathLength(double x, double y) const
201 return fudgePathLength(AliFmThreeVector<double>(x, y, 0));
203 inline int AliFmHelix::bad(double WorldSize) const
207 if (!::finite(mDipAngle )) return 11;
208 if (!::finite(mCurvature )) return 12;
210 ierr = mOrigin.bad(WorldSize);
211 if (ierr) return 3+ierr*100;
213 if (::fabs(mDipAngle) >1.58) return 21;
214 double qwe = ::fabs(::fabs(mDipAngle)-M_PI/2);
215 if (qwe < 1./WorldSize ) return 31;
217 if (::fabs(mCurvature) > WorldSize) return 22;
218 if (mCurvature < 0 ) return 32;
220 if (abs(mH) != 1 ) return 24;