CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
HelixExtrapolatorToLine2Order Class Referencefinal

#include <HelixExtrapolatorToLine2Order.h>

Inheritance diagram for HelixExtrapolatorToLine2Order:
HelixLineExtrapolation

Public Member Functions

virtual DirectionType direction (double s) const
 Direction at pathlength s from the starting point. More...
 
DirectionTypeDouble directionInDouble (double s) const
 Direction at pathlength s from the starting point in double precision. More...
 
 HelixExtrapolatorToLine2Order (const PositionType &point, const DirectionType &direction, const float curvature, const PropagationDirection propDir=alongMomentum)
 Constructor using point, direction and (transverse!) curvature. More...
 
 HelixExtrapolatorToLine2Order (const double &x0, const double &y0, const double &z0, const double &cosPhi0, const double &sinPhi0, const double &cosTheta, const double &sinTheta, const double &rho, const PropagationDirection propDir=alongMomentum)
 Fast constructor (for use by IterativeHelixExtrapolatorToLine). More...
 
virtual std::pair< bool, double > pathLength (const GlobalPoint &point) const
 
virtual std::pair< bool, double > pathLength (const Line &line) const
 
virtual PositionType position (double s) const
 Position at pathlength s from the starting point. More...
 
PositionTypeDouble positionInDouble (double s) const
 Position at pathlength s from the starting point in double precision. More...
 
virtual ~HelixExtrapolatorToLine2Order ()
 

Private Member Functions

virtual std::pair< bool, double > pathLengthFromCoefficients (const double ceq[4]) const
 common part for propagation to point and line More...
 
int solve2ndOrder (const double ceq[], double sol[]) const
 Solutions of 2nd order equation. More...
 
int solve3rdOrder (const double ceq[], double sol[]) const
 Solutions of 3rd order equation. More...
 

Private Attributes

DirectionTypeDouble theDirection
 
const PositionTypeDouble thePosition
 
const PropagationDirection thePropDir
 
const double theRho
 
double theSinTheta
 

Additional Inherited Members

- Public Types inherited from HelixLineExtrapolation
typedef Basic3DVector< float > DirectionType
 
typedef Basic3DVector< double > DirectionTypeDouble
 
typedef Basic3DVector< float > PositionType
 
typedef Basic3DVector< double > PositionTypeDouble
 

Detailed Description

Calculates intersections of a helix with planes of any orientation using a parabolic approximation.

Definition at line 11 of file HelixExtrapolatorToLine2Order.h.

Constructor & Destructor Documentation

HelixExtrapolatorToLine2Order::HelixExtrapolatorToLine2Order ( const PositionType point,
const DirectionType direction,
const float  curvature,
const PropagationDirection  propDir = alongMomentum 
)

Constructor using point, direction and (transverse!) curvature.

Definition at line 7 of file HelixExtrapolatorToLine2Order.cc.

References AlCaHLTBitMon_ParallelJobs::p, EnergyCorrector::pt, mathSSE::sqrt(), theDirection, theSinTheta, Basic3DVector< T >::x(), Basic3DVector< T >::y(), and Basic3DVector< T >::z().

10  :
13  thePropDir(propDir)
14 {
15  //
16  // Components of direction vector (with correct normalisation)
17  //
18  double px = direction.x();
19  double py = direction.y();
20  double pz = direction.z();
21  double pt = px*px+py*py;
22  double p = sqrt(pt+pz*pz);
23  pt = sqrt(pt);
24  theDirection = DirectionTypeDouble(px/pt,py/pt,pz/pt);
25  theSinTheta = pt/p;
26 }
virtual DirectionType direction(double s) const
Direction at pathlength s from the starting point.
T y() const
Cartesian y coordinate.
T x() const
Cartesian x coordinate.
Basic3DVector< double > DirectionTypeDouble
T curvature(T InversePt, const edm::EventSetup &iSetup)
T z() const
Cartesian z coordinate.
T sqrt(T t)
Definition: SSEVec.h:18
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5
HelixExtrapolatorToLine2Order::HelixExtrapolatorToLine2Order ( const double &  x0,
const double &  y0,
const double &  z0,
const double &  cosPhi0,
const double &  sinPhi0,
const double &  cosTheta,
const double &  sinTheta,
const double &  rho,
const PropagationDirection  propDir = alongMomentum 
)
inline

Fast constructor (for use by IterativeHelixExtrapolatorToLine).

Definition at line 20 of file HelixExtrapolatorToLine2Order.h.

24  :
25  thePosition(x0,y0,z0),
26  theDirection(cosPhi0,sinPhi0,cosTheta/sinTheta),
27  theSinTheta(sinTheta),
28  theRho(rho),
29  thePropDir(propDir) {}
virtual HelixExtrapolatorToLine2Order::~HelixExtrapolatorToLine2Order ( )
inlinevirtual

Definition at line 32 of file HelixExtrapolatorToLine2Order.h.

32 {}

Member Function Documentation

HelixLineExtrapolation::DirectionType HelixExtrapolatorToLine2Order::direction ( double  s) const
virtual

Direction at pathlength s from the starting point.

Implements HelixLineExtrapolation.

Definition at line 226 of file HelixExtrapolatorToLine2Order.cc.

References directionInDouble().

226  {
227  // use double precision result
228 // DirectionTypeDouble dir = directionInDouble(s);
229 // return DirectionType(dir.x(),dir.y(),dir.z());
231 }
Basic3DVector< float > DirectionType
DirectionTypeDouble directionInDouble(double s) const
Direction at pathlength s from the starting point in double precision.
HelixExtrapolatorToLine2Order::DirectionTypeDouble HelixExtrapolatorToLine2Order::directionInDouble ( double  s) const

Direction at pathlength s from the starting point in double precision.

Definition at line 236 of file HelixExtrapolatorToLine2Order.cc.

References theDirection, theRho, theSinTheta, Basic3DVector< T >::x(), Basic3DVector< T >::y(), and Basic3DVector< T >::z().

Referenced by direction(), and IterativeHelixExtrapolatorToLine::directionInDouble().

236  {
237  // based on delta phi
238  double dph = s*theRho*theSinTheta;
239  return DirectionTypeDouble(theDirection.x()-(theDirection.y()+0.5*theDirection.x()*dph)*dph,
240  theDirection.y()+(theDirection.x()-0.5*theDirection.y()*dph)*dph,
241  theDirection.z());
242 }
T y() const
Cartesian y coordinate.
T x() const
Cartesian x coordinate.
Basic3DVector< double > DirectionTypeDouble
T z() const
Cartesian z coordinate.
std::pair< bool, double > HelixExtrapolatorToLine2Order::pathLength ( const GlobalPoint point) const
virtual

Propagation status (true if valid) and (signed) path length along the helix from the starting point to the closest approach to the point. The starting point is given in the constructor.

Implements HelixLineExtrapolation.

Definition at line 32 of file HelixExtrapolatorToLine2Order.cc.

References Basic3DVector< T >::dot(), Basic3DVector< T >::mag2(), pathLengthFromCoefficients(), position(), theDirection, thePosition, theRho, Basic3DVector< T >::x(), and Basic3DVector< T >::y().

Referenced by IterativeHelixExtrapolatorToLine::genericPathLength().

32  {
33  //
36  0.5*theRho*theDirection.x(),
37  0.);
39  //
40  // coefficients of 3rd order equation
41  //
42  double ceq[4];
43  ceq[3] = 2*helix2.mag2();
44  // ceq[2] = 3*theDirection.dot(helix2) = 0 since they are orthogonal
45  ceq[2] = 0.;
46  ceq[1] = theDirection.mag2()+2*deltaPos.dot(helix2);
47  ceq[0] = deltaPos.dot(theDirection);
48  //
49  return pathLengthFromCoefficients(ceq);
50 }
T y() const
Cartesian y coordinate.
T x() const
Cartesian x coordinate.
Basic3DVector< double > PositionTypeDouble
Basic3DVector< double > DirectionTypeDouble
virtual PositionType position(double s) const
Position at pathlength s from the starting point.
virtual std::pair< bool, double > pathLengthFromCoefficients(const double ceq[4]) const
common part for propagation to point and line
T mag2() const
The vector magnitude squared. Equivalent to vec.dot(vec)
std::pair< bool, double > HelixExtrapolatorToLine2Order::pathLength ( const Line line) const
virtual

Propagation status (true if valid) and (signed) path length along the helix from the starting point to the closest approach to the line. The starting point is given in the constructor.

Implements HelixLineExtrapolation.

Definition at line 56 of file HelixExtrapolatorToLine2Order.cc.

References Line::direction(), Basic3DVector< T >::dot(), pathLengthFromCoefficients(), Line::position(), theDirection, thePosition, theRho, Basic3DVector< T >::x(), and Basic3DVector< T >::y().

56  {
57  //
58  // Auxiliary vectors. Assumes that line.direction().mag()=1 !
59  //
60  PositionTypeDouble linePosition(line.position());
61  DirectionTypeDouble lineDirection(line.direction());
63  0.5*theRho*theDirection.x(),
64  0.);
65  DirectionTypeDouble deltaPos(thePosition-linePosition);
66  DirectionTypeDouble helix1p(theDirection-lineDirection*theDirection.dot(lineDirection));
67  DirectionTypeDouble helix2p(helix2-lineDirection*helix2.dot(lineDirection));
68  //
69  // coefficients of 3rd order equation
70  //
71  double ceq[4];
72  ceq[3] = 2*helix2.dot(helix2p);
73  // ceq[2] = 3*helix1.dot(helix1p);
74  // since theDirection.dot(helix2)==0 equivalent to
75  ceq[2] = 3*theDirection.dot(lineDirection)*helix2.dot(lineDirection);
76  ceq[1] = theDirection.dot(helix1p)+2*deltaPos.dot(helix2p);
77  ceq[0] = deltaPos.dot(helix1p);
78  //
79  return pathLengthFromCoefficients(ceq);
80 }
DirectionType direction() const
Definition: Line.h:27
T y() const
Cartesian y coordinate.
T x() const
Cartesian x coordinate.
Basic3DVector< double > PositionTypeDouble
Basic3DVector< double > DirectionTypeDouble
PositionType position() const
Definition: Line.h:26
virtual std::pair< bool, double > pathLengthFromCoefficients(const double ceq[4]) const
common part for propagation to point and line
T dot(const Basic3DVector &rh) const
Scalar product, or &quot;dot&quot; product, with a vector of same type.
std::pair< bool, double > HelixExtrapolatorToLine2Order::pathLengthFromCoefficients ( const double  ceq[4]) const
privatevirtual

common part for propagation to point and line

Definition at line 86 of file HelixExtrapolatorToLine2Order.cc.

References alongMomentum, anyDirection, i, oppositeToMomentum, StEvtSolProducer_cfi::solutions, solve3rdOrder(), thePropDir, and theSinTheta.

Referenced by pathLength().

87 {
88  //
89  // Solution of 3rd order equation
90  //
91  double solutions[3];
92  unsigned int nRaw = solve3rdOrder(ceq,solutions);
93  //
94  // check compatibility with propagation direction
95  //
96  unsigned int nDir(0);
97  for ( unsigned int i=0; i<nRaw; i++ ) {
98  if ( thePropDir==anyDirection ||
99  (solutions[i]>=0&&thePropDir==alongMomentum) ||
100  (solutions[i]<=0&&thePropDir==oppositeToMomentum) )
101  solutions[nDir++] = solutions[i];
102  }
103  if ( nDir==0 ) return std::make_pair(false,0.);
104  //
105  // check 2nd derivative
106  //
107  unsigned int nMin(0);
108  for ( unsigned int i=0; i<nDir; i++ ) {
109  double st = solutions[i];
110  double deri2 = (3*ceq[3]*st+2*ceq[2])*st+ceq[1];
111  if ( deri2>0. ) solutions[nMin++] = st;
112  }
113  if ( nMin==0 ) return std::make_pair(false,0.);
114  //
115  // choose smallest path length
116  //
117  double dSt = solutions[0];
118  for ( unsigned int i=1; i<nMin; i++ ) {
119  if ( fabs(solutions[i])<fabs(dSt) ) dSt = solutions[i];
120  }
121 
122  return std::make_pair(true,dSt/theSinTheta);
123 }
int i
Definition: DBlmapReader.cc:9
int solve3rdOrder(const double ceq[], double sol[]) const
Solutions of 3rd order equation.
HelixLineExtrapolation::PositionType HelixExtrapolatorToLine2Order::position ( double  s) const
virtual

Position at pathlength s from the starting point.

Implements HelixLineExtrapolation.

Definition at line 205 of file HelixExtrapolatorToLine2Order.cc.

References positionInDouble().

Referenced by pathLength().

205  {
206  // use double precision result
207 // PositionTypeDouble pos = positionInDouble(s);
208 // return PositionType(pos.x(),pos.y(),pos.z());
210 }
PositionTypeDouble positionInDouble(double s) const
Position at pathlength s from the starting point in double precision.
Basic3DVector< float > PositionType
HelixExtrapolatorToLine2Order::PositionTypeDouble HelixExtrapolatorToLine2Order::positionInDouble ( double  s) const

Position at pathlength s from the starting point in double precision.

Definition at line 215 of file HelixExtrapolatorToLine2Order.cc.

References theDirection, thePosition, theRho, theSinTheta, Basic3DVector< T >::x(), Basic3DVector< T >::y(), and Basic3DVector< T >::z().

Referenced by position(), and IterativeHelixExtrapolatorToLine::positionInDouble().

215  {
216  // based on path length in the transverse plane
217  double st = s*theSinTheta;
219  thePosition.y()+(theDirection.y()+st*0.5*theRho*theDirection.x())*st,
220  thePosition.z()+st*theDirection.z());
221 }
T y() const
Cartesian y coordinate.
T x() const
Cartesian x coordinate.
Basic3DVector< double > PositionTypeDouble
T z() const
Cartesian z coordinate.
int HelixExtrapolatorToLine2Order::solve2ndOrder ( const double  ceq[],
double  sol[] 
) const
private

Solutions of 2nd order equation.

Definition at line 172 of file HelixExtrapolatorToLine2Order.cc.

References alignCSCRings::e, and mathSSE::sqrt().

Referenced by solve3rdOrder().

174 {
175  //
176  double deq1 = coeff[1]*coeff[1];
177  double deq2 = coeff[2]*coeff[0];
178  if ( fabs(deq1)<FLT_MIN || fabs(deq2/deq1)>1.e-6 ) {
179  //
180  // Standard solution for quadratic equations
181  //
182  double deq = deq1+2*deq2;
183  if ( deq<0. ) return 0;
184  double ceq = -0.5*(coeff[1]+(coeff[1]>0?1:-1)*sqrt(deq));
185  solutions[0] = -2*ceq/coeff[2];
186  solutions[1] = coeff[0]/ceq;
187  return 2;
188  }
189  else {
190  //
191  // Solution by expansion of sqrt(1+deq)
192  //
193  double ceq = coeff[1]/coeff[2];
194  double deq = deq2/deq1;
195  deq *= (1-deq/2);
196  solutions[0] = -ceq*deq;
197  solutions[1] = ceq*(2+deq);
198  return 2;
199  }
200 }
T sqrt(T t)
Definition: SSEVec.h:18
int HelixExtrapolatorToLine2Order::solve3rdOrder ( const double  ceq[],
double  sol[] 
) const
private

Solutions of 3rd order equation.

Definition at line 126 of file HelixExtrapolatorToLine2Order.cc.

References a, b, funct::cos(), i, M_PI, phi, funct::pow(), lumiQueryAPI::q, alignCSCRings::r, mps_fire::result, solve2ndOrder(), and mathSSE::sqrt().

Referenced by pathLengthFromCoefficients().

128 {
129  //
130  // Real 3rd order equation? Follow numerical recipes ..
131  //
132  if ( fabs(ceq[3])>FLT_MIN ) {
133  int result(0);
134  double q = (ceq[2]*ceq[2]-3*ceq[3]*ceq[1]) / (ceq[3]*ceq[3]) / 9.;
135  double r = (2*ceq[2]*ceq[2]*ceq[2]-9*ceq[3]*ceq[2]*ceq[1]+27*ceq[3]*ceq[3]*ceq[0])
136  / (ceq[3]*ceq[3]*ceq[3]) / 54.;
137  double q3 = q*q*q;
138  if ( r*r<q3 ) {
139  double phi = acos(r/sqrt(q3))/3.;
140  double rootq = sqrt(q);
141  for ( int i=0; i<3; i++ ) {
142  solutions[i] = -2*rootq*cos(phi) - ceq[2]/ceq[3]/3.;
143  phi += 2./3.*M_PI;
144  }
145  result = 3;
146  }
147  else {
148  double a = pow(fabs(r)+sqrt(r*r-q3),1./3.);
149  if ( r>0. ) a *= -1;
150  double b = fabs(a)>FLT_MIN ? q/a : 0.;
151  solutions[0] = a + b - ceq[2]/ceq[3]/3.;
152  result = 1;
153  }
154  return result;
155  }
156  //
157  // Second order equation
158  //
159  else if ( fabs(ceq[2])>FLT_MIN ) {
160  return solve2ndOrder(ceq,solutions);
161  }
162  else {
163  //
164  // Special case: linear equation
165  //
166  solutions[0] = -ceq[0]/ceq[1];
167  return 1;
168  }
169 }
int i
Definition: DBlmapReader.cc:9
tuple result
Definition: mps_fire.py:95
T sqrt(T t)
Definition: SSEVec.h:18
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
int solve2ndOrder(const double ceq[], double sol[]) const
Solutions of 2nd order equation.
#define M_PI
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40

Member Data Documentation

DirectionTypeDouble HelixExtrapolatorToLine2Order::theDirection
private
const PositionTypeDouble HelixExtrapolatorToLine2Order::thePosition
private

Definition at line 67 of file HelixExtrapolatorToLine2Order.h.

Referenced by pathLength(), and positionInDouble().

const PropagationDirection HelixExtrapolatorToLine2Order::thePropDir
private

Definition at line 71 of file HelixExtrapolatorToLine2Order.h.

Referenced by pathLengthFromCoefficients().

const double HelixExtrapolatorToLine2Order::theRho
private

Definition at line 70 of file HelixExtrapolatorToLine2Order.h.

Referenced by directionInDouble(), pathLength(), and positionInDouble().

double HelixExtrapolatorToLine2Order::theSinTheta
private