StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StPicoHelix.h
1 
12 #ifndef StPicoHelix_h
13 #define StPicoHelix_h
14 
15 // C++ headers
16 #include <cmath>
17 #include <utility>
18 #include <algorithm>
19 
20 // ROOT headers
21 #include "TVector3.h"
22 
23 // PicoDst headers
24 #ifdef _VANILLA_ROOT_
25 #include "SystemOfUnits.h"
26 #else
27 #include "StarClassLibrary/SystemOfUnits.h"
28 #endif
29 
30 // Declare C++ namespaces
31 #if !defined(ST_NO_NAMESPACES)
32 using std::pair;
33 using std::swap;
34 using std::max;
35 #endif
36 
37 //_________________
38 class StPicoHelix {
39 
40  public:
42  StPicoHelix();
43 
46  StPicoHelix(Double_t c, Double_t dip, Double_t phase,
47  const TVector3& o, Int_t h=-1);
48 
50  StPicoHelix(const StPicoHelix&);
51 
52  // Assignment operator (will use the one, provided by compiler)
53  //StPicoHelix& operator=(const StPicoHelix&);
54 
56  virtual ~StPicoHelix();
57 
59  Double_t dipAngle() const;
61  Double_t curvature() const;
63  Double_t phase() const;
65  Double_t xcenter() const;
67  Double_t ycenter() const;
69  Int_t h() const;
70 
72  const TVector3& origin() const;
73 
75  void setParameters(Double_t c, Double_t dip, Double_t phase, const TVector3& o, Int_t h);
76 
78  Double_t x(Double_t s) const;
79  Double_t y(Double_t s) const;
80  Double_t z(Double_t s) const;
81  TVector3 at(Double_t s) const;
82 
84  Double_t cx(Double_t s) const;
85  Double_t cy(Double_t s) const;
86  Double_t cz(Double_t s = 0) const;
87  TVector3 cat(Double_t s) const;
88 
90  Double_t period() const;
91 
93  pair<Double_t, Double_t> pathLength(Double_t r) const;
94 
96  pair<Double_t, Double_t> pathLength(Double_t r, Double_t x, Double_t y);
97 
99  Double_t pathLength(const TVector3& p, Bool_t scanPeriods = true) const;
100 
102  Double_t pathLength(const TVector3& r,
103  const TVector3& n) const;
104 
106  Double_t pathLength(Double_t x, Double_t y) const;
107 
109  pair<Double_t, Double_t> pathLengths(const StPicoHelix&,
110  Double_t minStepSize = 10*micrometer,
111  Double_t minRange = 10*centimeter) const;
112 
114  Double_t distance(const TVector3& p, Bool_t scanPeriods = true) const;
115 
117  Bool_t valid(Double_t world = 1.e+5) const { return !bad(world); }
118  Int_t bad(Double_t world = 1.e+5) const;
119 
121  virtual void moveOrigin(Double_t s);
122 
123  static const Double_t NoSolution;
124 
125  protected:
126 
128  void setCurvature(Double_t);
129  void setPhase(Double_t);
132  void setDipAngle(Double_t);
134  Double_t fudgePathLength(const TVector3&) const;
135 
136  protected:
138  Bool_t mSingularity;
140  TVector3 mOrigin;
142  Double_t mDipAngle;
144  Double_t mCurvature;
146  Double_t mPhase;
148  Int_t mH;
149 
151  Double_t mCosDipAngle;
153  Double_t mSinDipAngle;
155  Double_t mCosPhase;
157  Double_t mSinPhase;
158 
159  ClassDef(StPicoHelix,1)
160 };
161 
162 //
163 // Non-member functions
164 //
165 Int_t operator== (const StPicoHelix&, const StPicoHelix&);
166 Int_t operator!= (const StPicoHelix&, const StPicoHelix&);
167 std::ostream& operator<<(std::ostream&, const StPicoHelix&);
168 
169 //
170 // Inline functions
171 //
172 inline Int_t StPicoHelix::h() const {return mH;}
173 
174 inline Double_t StPicoHelix::dipAngle() const {return mDipAngle;}
175 
176 inline Double_t StPicoHelix::curvature() const {return mCurvature;}
177 
178 inline Double_t StPicoHelix::phase() const {return mPhase;}
179 
180 inline Double_t StPicoHelix::x(Double_t s) const {
181  if (mSingularity)
182  return mOrigin.x() - s*mCosDipAngle*mSinPhase;
183  else
184  return mOrigin.x() + (cos(mPhase + s*mH*mCurvature*mCosDipAngle)-mCosPhase)/mCurvature;
185 }
186 
187 inline Double_t StPicoHelix::y(Double_t s) const {
188  if (mSingularity)
189  return mOrigin.y() + s*mCosDipAngle*mCosPhase;
190  else
191  return mOrigin.y() + (sin(mPhase + s*mH*mCurvature*mCosDipAngle)-mSinPhase)/mCurvature;
192 }
193 
194 inline Double_t StPicoHelix::z(Double_t s) const {
195  return mOrigin.z() + s*mSinDipAngle;
196 }
197 
198 inline Double_t StPicoHelix::cx(Double_t s) const {
199  if (mSingularity)
200  return -mCosDipAngle*mSinPhase;
201  else
202  return -sin(mPhase + s*mH*mCurvature*mCosDipAngle)*mH*mCosDipAngle;
203 }
204 
205 inline Double_t StPicoHelix::cy(Double_t s) const {
206  if (mSingularity)
207  return mCosDipAngle*mCosPhase;
208  else
210 }
211 
212 inline Double_t StPicoHelix::cz(Double_t /* s */) const { return mSinDipAngle; }
213 inline const TVector3& StPicoHelix::origin() const { return mOrigin; }
214 inline TVector3 StPicoHelix::at(Double_t s) const { return TVector3(x(s), y(s), z(s)); }
215 inline TVector3 StPicoHelix::cat(Double_t s) const { return TVector3(cx(s), cy(s), cz(s)); }
216 inline Double_t StPicoHelix::pathLength(Double_t X, Double_t Y) const { return fudgePathLength(TVector3(X, Y, 0)); }
217 
218 inline Int_t StPicoHelix::bad(Double_t WorldSize) const {
219 
220  Int_t ierr = 0;
221  if ( !std::isfinite(mDipAngle) ) {
222  return 11;
223  }
224  if ( !std::isfinite(mCurvature) ) {
225  return 12;
226  }
227 
228  //ierr = mOrigin.bad(WorldSize);
229 
230  // The line above is commented and the StThreeVector::bad(double)
231  // is rewritten here
232  for(Int_t iIter=0; iIter<3; iIter++) {
233 
234  Double_t tmpVal;
235  // Value StThreeVector.mX1[iter] ???
236  switch(iIter) {
237  case 0: tmpVal = mOrigin.X(); break;
238  case 1: tmpVal = mOrigin.Y(); break;
239  case 2: tmpVal = mOrigin.Z(); break;
240  default: tmpVal = NAN;
241  };
242 
243  if ( !std::isfinite( tmpVal ) ) {
244  ierr = 10 + iIter;
245  }
246  if ( ::fabs( tmpVal ) > WorldSize ) {
247  ierr = 20 + iIter;
248  }
249  } //for(Int_t iIter=0; iIter<3; iIter+)
250 
251  if (ierr) {
252  return (3+ierr*100);
253  }
254  if ( ::fabs(mDipAngle) > 1.58 ) {
255  return 21;
256  }
257 
258  Double_t qwe = ::fabs( ::fabs(mDipAngle) - M_PI/2 );
259  if ( qwe < 1./WorldSize ) {
260  return 31;
261  }
262 
263  if ( ::fabs(mCurvature) > WorldSize ) {
264  return 22;
265  }
266  if ( mCurvature < 0 ) {
267  return 32;
268  }
269  if (abs(mH) != 1 ) {
270  return 24;
271  }
272 
273  return 0;
274 }
275 
276 #endif
Double_t xcenter() const
Return x-center of circle in xy-plane.
pair< Double_t, Double_t > pathLengths(const StPicoHelix &, Double_t minStepSize=10 *micrometer, Double_t minRange=10 *centimeter) const
path lengths at dca between two helices
Double_t x(Double_t s) const
coordinates of helix at point s
Definition: StPicoHelix.h:180
Double_t curvature() const
Return curvature: 1/R in xy-plane.
Definition: StPicoHelix.h:176
Double_t mCurvature
Curvature = 1/R.
Definition: StPicoHelix.h:144
Bool_t valid(Double_t world=1.e+5) const
checks for valid parametrization
Definition: StPicoHelix.h:117
Double_t mSinDipAngle
Sin of dip angle.
Definition: StPicoHelix.h:153
virtual ~StPicoHelix()
Destructor.
Definition: StPicoHelix.cxx:60
Double_t fudgePathLength(const TVector3 &) const
Value of S where distance in x-y plane is minimal.
Double_t dipAngle() const
Return dip angle.
Definition: StPicoHelix.h:174
Int_t h() const
Return -sign(q*B);.
Definition: StPicoHelix.h:172
Double_t mCosPhase
Cos of phase.
Definition: StPicoHelix.h:155
TVector3 mOrigin
starting point of a helix
Definition: StPicoHelix.h:140
pair< Double_t, Double_t > pathLength(Double_t r) const
path length at given r (cylindrical r)
const TVector3 & origin() const
Return origin of the helix = starting point.
Definition: StPicoHelix.h:213
Double_t period() const
returns period length of helix
Int_t mH
-sign(q*B);
Definition: StPicoHelix.h:148
virtual void moveOrigin(Double_t s)
Move the origin along the helix to s which becomes then s=0.
void setPhase(Double_t)
Set phase of the helix.
void setParameters(Double_t c, Double_t dip, Double_t phase, const TVector3 &o, Int_t h)
Set helix parameters.
Definition: StPicoHelix.cxx:63
void setDipAngle(Double_t)
Set dip angle of the helix.
Double_t distance(const TVector3 &p, Bool_t scanPeriods=true) const
minimal distance between point and helix
Double_t mDipAngle
Dip angle.
Definition: StPicoHelix.h:142
Helix parametrization that uses ROOT TVector3.
Definition: StPicoHelix.h:38
Double_t phase() const
Return phase: aziumth in xy-plane measured from ring center.
Definition: StPicoHelix.h:178
Bool_t mSingularity
true for straight line case (B=0)
Definition: StPicoHelix.h:138
Double_t mCosDipAngle
Cos of dip angle.
Definition: StPicoHelix.h:151
Double_t ycenter() const
Return y-center of circle in xy-plane.
Double_t mPhase
Phase.
Definition: StPicoHelix.h:146
void setCurvature(Double_t)
Set curvature of the helix.
Definition: StPicoHelix.cxx:96
StPicoHelix()
Default constructor.
Definition: StPicoHelix.cxx:32
Double_t cx(Double_t s) const
pointing vector of helix at point s
Definition: StPicoHelix.h:198