StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StHelix.hh
1 
9 /***************************************************************************
10  *
11  * $Id: StHelix.hh,v 1.14 2015/04/22 18:02:01 ullrich Exp $
12  *
13  * Author: Thomas Ullrich, Sep 1997
14  ***************************************************************************
15  *
16  * Description: Parametrization of a helix
17  *
18  ***************************************************************************
19  *
20  * $Log: StHelix.hh,v $
21  * Revision 1.14 2015/04/22 18:02:01 ullrich
22  * Added two default argument to dca of two helices for HFT.
23  *
24  * Revision 1.13 2010/10/18 21:55:11 fisyak
25  * Warn off for gcc4.5.1 64bits
26  *
27  * Revision 1.12 2006/06/29 15:53:22 ullrich
28  * Added direction vector at given pathlength (written by Yuri).
29  *
30  * Revision 1.11 2005/10/13 22:23:27 genevb
31  * NoSolution is public
32  *
33  * Revision 1.10 2005/07/06 18:49:56 fisyak
34  * Replace StHelixD, StLorentzVectorD,StLorentzVectorF,StMatrixD,StMatrixF,StPhysicalHelixD,StThreeVectorD,StThreeVectorF by templated version
35  *
36  * Revision 1.9 2004/12/02 02:51:16 ullrich
37  * Added option to pathLenghth() and distance() to search for
38  * DCA only within one period. Default stays as it was.
39  *
40  * Revision 1.8 2003/10/30 20:06:46 perev
41  * Check of quality added
42  *
43  * Revision 1.7 2002/06/21 17:49:25 genevb
44  * Some minor speed improvements
45  *
46  * Revision 1.6 2002/04/24 02:41:55 ullrich
47  * Restored old format.
48  *
49  **************************************************************************/
50 
51 #ifndef ST_HELIX_HH
52 #define ST_HELIX_HH
53 
54 #include <math.h>
55 #include <utility>
56 #include <algorithm>
57 #include "StThreeVector.hh"
58 #include "SystemOfUnits.h"
59 #if !defined(ST_NO_NAMESPACES)
60 using std::pair;
61 using std::swap;
62 using std::max;
63 #endif
64 
65 class StHelix {
66 public:
68  StHelix(double c, double dip, double phase,
69  const StThreeVector<double>& o, int h=-1);
70 
71  virtual ~StHelix();
72  // StHelix(const StHelix&); // use default
73  // StHelix& operator=(const StHelix&); // use default
74 
75  double dipAngle() const;
76  double curvature() const;
77  double phase() const;
78  double xcenter() const;
79  double ycenter() const;
80  int h() const;
81 
82  const StThreeVector<double>& origin() const;
83 
84  void setParameters(double c, double dip, double phase, const StThreeVector<double>& o, int h);
85 
87  double x(double s) const;
88  double y(double s) const;
89  double z(double s) const;
90 
91  StThreeVector<double> at(double s) const;
92 
94  double cx(double s) const;
95  double cy(double s) const;
96  double cz(double s = 0) const;
97 
98  StThreeVector<double> cat(double s) const;
99 
101  double period() const;
102 
104  pair<double, double> pathLength(double r) const;
105 
107  pair<double, double> pathLength(double r, double x, double y);
108 
110  double pathLength(const StThreeVector<double>& p, bool scanPeriods = true) const;
111 
113  double pathLength(const StThreeVector<double>& r,
114  const StThreeVector<double>& n) const;
115 
117  double pathLength(double x, double y) const;
118 
120  pair<double, double> pathLengths(const StHelix&,
121  double minStepSize = 10*micrometer,
122  double minRange = 10*centimeter) const;
123 
125  double distance(const StThreeVector<double>& p, bool scanPeriods = true) const;
126 
128  bool valid(double world = 1.e+5) const {return !bad(world);}
129  int bad(double world = 1.e+5) const;
130 
132  virtual void moveOrigin(double s);
133 
134  static const double NoSolution;
135 
136 protected:
137  StHelix();
138 
139  void setCurvature(double);
140  void setPhase(double);
141  void setDipAngle(double);
142 
144  double fudgePathLength(const StThreeVector<double>&) const;
145 
146 protected:
147  bool mSingularity; // true for straight line case (B=0)
148  StThreeVector<double> mOrigin;
149  double mDipAngle;
150  double mCurvature;
151  double mPhase;
152  int mH; // -sign(q*B);
153 
154  double mCosDipAngle;
155  double mSinDipAngle;
156  double mCosPhase;
157  double mSinPhase;
158 
159 #ifdef __ROOT__
160  ClassDef(StHelix,1)
161 #endif
162 };
163 
164 //
165 // Non-member functions
166 //
167 int operator== (const StHelix&, const StHelix&);
168 int operator!= (const StHelix&, const StHelix&);
169 ostream& operator<<(ostream&, const StHelix&);
170 
171 //
172 // Inline functions
173 //
174 inline int StHelix::h() const {return mH;}
175 
176 inline double StHelix::dipAngle() const {return mDipAngle;}
177 
178 inline double StHelix::curvature() const {return mCurvature;}
179 
180 inline double StHelix::phase() const {return mPhase;}
181 
182 inline double StHelix::x(double s) const
183 {
184  if (mSingularity)
185  return mOrigin.x() - s*mCosDipAngle*mSinPhase;
186  else
187  return mOrigin.x() + (cos(mPhase + s*mH*mCurvature*mCosDipAngle)-mCosPhase)/mCurvature;
188 }
189 
190 inline double StHelix::y(double s) const
191 {
192  if (mSingularity)
193  return mOrigin.y() + s*mCosDipAngle*mCosPhase;
194  else
195  return mOrigin.y() + (sin(mPhase + s*mH*mCurvature*mCosDipAngle)-mSinPhase)/mCurvature;
196 }
197 
198 inline double StHelix::z(double s) const
199 {
200  return mOrigin.z() + s*mSinDipAngle;
201 }
202 
203 inline double StHelix::cx(double s) const
204 {
205  if (mSingularity)
206  return -mCosDipAngle*mSinPhase;
207  else
208  return -sin(mPhase + s*mH*mCurvature*mCosDipAngle)*mH*mCosDipAngle;
209 }
210 
211 inline double StHelix::cy(double s) const
212 {
213  if (mSingularity)
214  return mCosDipAngle*mCosPhase;
215  else
216  return cos(mPhase + s*mH*mCurvature*mCosDipAngle)*mH*mCosDipAngle;
217 }
218 
219 inline double StHelix::cz(double /* s */) const
220 {
221  return mSinDipAngle;
222 }
223 
224 inline const StThreeVector<double>& StHelix::origin() const {return mOrigin;}
225 
226 inline StThreeVector<double> StHelix::at(double s) const
227 {
228  return StThreeVector<double>(x(s), y(s), z(s));
229 }
230 
231 inline StThreeVector<double> StHelix::cat(double s) const
232 {
233  return StThreeVector<double>(cx(s), cy(s), cz(s));
234 }
235 
236 inline double StHelix::pathLength(double X, double Y) const
237 {
238  return fudgePathLength(StThreeVector<double>(X, Y, 0));
239 }
240 inline int StHelix::bad(double WorldSize) const
241 {
242 
243  int ierr;
244  if (!::finite(mDipAngle )) return 11;
245  if (!::finite(mCurvature )) return 12;
246 
247  ierr = mOrigin.bad(WorldSize);
248  if (ierr) return 3+ierr*100;
249 
250  if (::fabs(mDipAngle) >1.58) return 21;
251  double qwe = ::fabs(::fabs(mDipAngle)-M_PI/2);
252  if (qwe < 1./WorldSize ) return 31;
253 
254  if (::fabs(mCurvature) > WorldSize) return 22;
255  if (mCurvature < 0 ) return 32;
256 
257  if (abs(mH) != 1 ) return 24;
258 
259  return 0;
260 }
261 
262 #endif
void setParameters(double c, double dip, double phase, const StThreeVector< double > &o, int h)
starting point
Definition: StHelix.cc:139
bool valid(double world=1.e+5) const
checks for valid parametrization
Definition: StHelix.hh:128
int h() const
y-center of circle in xy-plane
Definition: StHelix.hh:174
pair< double, double > pathLengths(const StHelix &, double minStepSize=10 *micrometer, double minRange=10 *centimeter) const
path lengths at dca between two helices
Definition: StHelix.cc:511
double x(double s) const
coordinates of helix at point s
Definition: StHelix.hh:182
double distance(const StThreeVector< double > &p, bool scanPeriods=true) const
minimal distance between point and helix
Definition: StHelix.cc:240
double cx(double s) const
pointing vector of helix at point s
Definition: StHelix.hh:203
double fudgePathLength(const StThreeVector< double > &) const
value of S where distance in x-y plane is minimal
Definition: StHelix.cc:223
pair< double, double > pathLength(double r) const
path length at given r (cylindrical r)
Definition: StHelix.cc:351
double ycenter() const
x-center of circle in xy-plane
Definition: StHelix.cc:215
const StThreeVector< double > & origin() const
-sign(q*B);
Definition: StHelix.hh:224
void setPhase(double)
performs also various checks
Definition: StHelix.cc:191
virtual void moveOrigin(double s)
move the origin along the helix to s which becomes then s=0
Definition: StHelix.cc:621
double period() const
returns period length of helix
Definition: StHelix.cc:339
double xcenter() const
aziumth in xy-plane measured from ring center
Definition: StHelix.cc:207
double phase() const
1/R in xy-plane
Definition: StHelix.hh:180