CMS 3D CMS Logo

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

DirectionType direction (double s) const override
 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...
 
std::pair< bool, double > pathLength (const GlobalPoint &point) const override
 
std::pair< bool, double > pathLength (const Line &line) const override
 
PositionType position (double s) const override
 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...
 
 ~HelixExtrapolatorToLine2Order () override
 
- Public Member Functions inherited from HelixLineExtrapolation
virtual ~HelixLineExtrapolation ()=default
 

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() [1/2]

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 direction(), AlCaHLTBitMon_ParallelJobs::p, DiDispStaMuonMonitor_cfi::pt, multPhiCorr_741_25nsDY_cfi::px, multPhiCorr_741_25nsDY_cfi::py, mathSSE::sqrt(), theDirection, theSinTheta, Basic3DVector< T >::x(), Basic3DVector< T >::y(), and Basic3DVector< T >::z().

12  //
13  // Components of direction vector (with correct normalisation)
14  //
15  double px = direction.x();
16  double py = direction.y();
17  double pz = direction.z();
18  double pt = px * px + py * py;
19  double p = sqrt(pt + pz * pz);
20  pt = sqrt(pt);
22  theSinTheta = pt / p;
23 }
T x() const
Cartesian x coordinate.
Basic3DVector< double > DirectionTypeDouble
T y() const
Cartesian y coordinate.
T curvature(T InversePt, const MagneticField &field)
T sqrt(T t)
Definition: SSEVec.h:19
T z() const
Cartesian z coordinate.
DirectionType direction(double s) const override
Direction at pathlength s from the starting point.
*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() [2/2]

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.

◆ ~HelixExtrapolatorToLine2Order()

HelixExtrapolatorToLine2Order::~HelixExtrapolatorToLine2Order ( )
inlineoverride

Definition at line 36 of file HelixExtrapolatorToLine2Order.h.

36 {}

Member Function Documentation

◆ direction()

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

Direction at pathlength s from the starting point.

Implements HelixLineExtrapolation.

Definition at line 208 of file HelixExtrapolatorToLine2Order.cc.

References directionInDouble(), and alignCSCRings::s.

Referenced by HelixExtrapolatorToLine2Order().

208  {
209  // use double precision result
210  // DirectionTypeDouble dir = directionInDouble(s);
211  // return DirectionType(dir.x(),dir.y(),dir.z());
213 }
DirectionTypeDouble directionInDouble(double s) const
Direction at pathlength s from the starting point in double precision.
Basic3DVector< float > DirectionType

◆ directionInDouble()

HelixExtrapolatorToLine2Order::DirectionTypeDouble HelixExtrapolatorToLine2Order::directionInDouble ( double  s) const

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

Definition at line 217 of file HelixExtrapolatorToLine2Order.cc.

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

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

217  {
218  // based on delta phi
219  double dph = s * theRho * theSinTheta;
220  return DirectionTypeDouble(theDirection.x() - (theDirection.y() + 0.5 * theDirection.x() * dph) * dph,
221  theDirection.y() + (theDirection.x() - 0.5 * theDirection.y() * dph) * dph,
222  theDirection.z());
223 }
T x() const
Cartesian x coordinate.
Basic3DVector< double > DirectionTypeDouble
T y() const
Cartesian y coordinate.
T z() const
Cartesian z coordinate.

◆ pathLength() [1/2]

std::pair< bool, double > HelixExtrapolatorToLine2Order::pathLength ( const GlobalPoint point) const
overridevirtual

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 28 of file HelixExtrapolatorToLine2Order.cc.

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

Referenced by IterativeHelixExtrapolatorToLine::genericPathLength().

28  {
29  //
31  DirectionTypeDouble helix2(-0.5 * theRho * theDirection.y(), 0.5 * theRho * theDirection.x(), 0.);
33  //
34  // coefficients of 3rd order equation
35  //
36  double ceq[4];
37  ceq[3] = 2 * helix2.mag2();
38  // ceq[2] = 3*theDirection.dot(helix2) = 0 since they are orthogonal
39  ceq[2] = 0.;
40  ceq[1] = theDirection.mag2() + 2 * deltaPos.dot(helix2);
41  ceq[0] = deltaPos.dot(theDirection);
42  //
43  return pathLengthFromCoefficients(ceq);
44 }
T x() const
Cartesian x coordinate.
Basic3DVector< double > PositionTypeDouble
virtual std::pair< bool, double > pathLengthFromCoefficients(const double ceq[4]) const
common part for propagation to point and line
PositionType position(double s) const override
Position at pathlength s from the starting point.
Basic3DVector< double > DirectionTypeDouble
T y() const
Cartesian y coordinate.
T mag2() const
The vector magnitude squared. Equivalent to vec.dot(vec)
*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

◆ pathLength() [2/2]

std::pair< bool, double > HelixExtrapolatorToLine2Order::pathLength ( const Line line) const
overridevirtual

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 49 of file HelixExtrapolatorToLine2Order.cc.

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

49  {
50  //
51  // Auxiliary vectors. Assumes that line.direction().mag()=1 !
52  //
53  PositionTypeDouble linePosition(line.position());
54  DirectionTypeDouble lineDirection(line.direction());
55  DirectionTypeDouble helix2(-0.5 * theRho * theDirection.y(), 0.5 * theRho * theDirection.x(), 0.);
56  DirectionTypeDouble deltaPos(thePosition - linePosition);
57  DirectionTypeDouble helix1p(theDirection - lineDirection * theDirection.dot(lineDirection));
58  DirectionTypeDouble helix2p(helix2 - lineDirection * helix2.dot(lineDirection));
59  //
60  // coefficients of 3rd order equation
61  //
62  double ceq[4];
63  ceq[3] = 2 * helix2.dot(helix2p);
64  // ceq[2] = 3*helix1.dot(helix1p);
65  // since theDirection.dot(helix2)==0 equivalent to
66  ceq[2] = 3 * theDirection.dot(lineDirection) * helix2.dot(lineDirection);
67  ceq[1] = theDirection.dot(helix1p) + 2 * deltaPos.dot(helix2p);
68  ceq[0] = deltaPos.dot(helix1p);
69  //
70  return pathLengthFromCoefficients(ceq);
71 }
T x() const
Cartesian x coordinate.
Basic3DVector< double > PositionTypeDouble
virtual std::pair< bool, double > pathLengthFromCoefficients(const double ceq[4]) const
common part for propagation to point and line
Basic3DVector< double > DirectionTypeDouble
T y() const
Cartesian y coordinate.
T dot(const Basic3DVector &rh) const
Scalar product, or "dot" product, with a vector of same type.

◆ pathLengthFromCoefficients()

std::pair< bool, double > HelixExtrapolatorToLine2Order::pathLengthFromCoefficients ( const double  ceq[4]) const
privatevirtual

common part for propagation to point and line

Definition at line 76 of file HelixExtrapolatorToLine2Order.cc.

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

Referenced by pathLength().

76  {
77  //
78  // Solution of 3rd order equation
79  //
80  double solutions[3];
81  unsigned int nRaw = solve3rdOrder(ceq, solutions);
82  //
83  // check compatibility with propagation direction
84  //
85  unsigned int nDir(0);
86  for (unsigned int i = 0; i < nRaw; i++) {
87  if (thePropDir == anyDirection || (solutions[i] >= 0 && thePropDir == alongMomentum) ||
89  solutions[nDir++] = solutions[i];
90  }
91  if (nDir == 0)
92  return std::make_pair(false, 0.);
93  //
94  // check 2nd derivative
95  //
96  unsigned int nMin(0);
97  for (unsigned int i = 0; i < nDir; i++) {
98  double st = solutions[i];
99  double deri2 = (3 * ceq[3] * st + 2 * ceq[2]) * st + ceq[1];
100  if (deri2 > 0.)
101  solutions[nMin++] = st;
102  }
103  if (nMin == 0)
104  return std::make_pair(false, 0.);
105  //
106  // choose smallest path length
107  //
108  double dSt = solutions[0];
109  for (unsigned int i = 1; i < nMin; i++) {
110  if (fabs(solutions[i]) < fabs(dSt))
111  dSt = solutions[i];
112  }
113 
114  return std::make_pair(true, dSt / theSinTheta);
115 }
int solve3rdOrder(const double ceq[], double sol[]) const
Solutions of 3rd order equation.

◆ position()

HelixLineExtrapolation::PositionType HelixExtrapolatorToLine2Order::position ( double  s) const
overridevirtual

Position at pathlength s from the starting point.

Implements HelixLineExtrapolation.

Definition at line 189 of file HelixExtrapolatorToLine2Order.cc.

References positionInDouble(), and alignCSCRings::s.

Referenced by pathLength().

189  {
190  // use double precision result
191  // PositionTypeDouble pos = positionInDouble(s);
192  // return PositionType(pos.x(),pos.y(),pos.z());
194 }
Basic3DVector< float > PositionType
PositionTypeDouble positionInDouble(double s) const
Position at pathlength s from the starting point in double precision.

◆ positionInDouble()

HelixExtrapolatorToLine2Order::PositionTypeDouble HelixExtrapolatorToLine2Order::positionInDouble ( double  s) const

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

Definition at line 198 of file HelixExtrapolatorToLine2Order.cc.

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

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

198  {
199  // based on path length in the transverse plane
200  double st = s * theSinTheta;
201  return PositionTypeDouble(thePosition.x() + (theDirection.x() - st * 0.5 * theRho * theDirection.y()) * st,
202  thePosition.y() + (theDirection.y() + st * 0.5 * theRho * theDirection.x()) * st,
203  thePosition.z() + st * theDirection.z());
204 }
T x() const
Cartesian x coordinate.
Basic3DVector< double > PositionTypeDouble
T y() const
Cartesian y coordinate.
T z() const
Cartesian z coordinate.

◆ solve2ndOrder()

int HelixExtrapolatorToLine2Order::solve2ndOrder ( const double  ceq[],
double  sol[] 
) const
private

Solutions of 2nd order equation.

Definition at line 159 of file HelixExtrapolatorToLine2Order.cc.

References MillePedeFileConverter_cfg::e, StEvtSolProducer_cfi::solutions, and mathSSE::sqrt().

Referenced by solve3rdOrder().

159  {
160  //
161  double deq1 = coeff[1] * coeff[1];
162  double deq2 = coeff[2] * coeff[0];
163  if (fabs(deq1) < FLT_MIN || fabs(deq2 / deq1) > 1.e-6) {
164  //
165  // Standard solution for quadratic equations
166  //
167  double deq = deq1 + 2 * deq2;
168  if (deq < 0.)
169  return 0;
170  double ceq = -0.5 * (coeff[1] + (coeff[1] > 0 ? 1 : -1) * sqrt(deq));
171  solutions[0] = -2 * ceq / coeff[2];
172  solutions[1] = coeff[0] / ceq;
173  return 2;
174  } else {
175  //
176  // Solution by expansion of sqrt(1+deq)
177  //
178  double ceq = coeff[1] / coeff[2];
179  double deq = deq2 / deq1;
180  deq *= (1 - deq / 2);
181  solutions[0] = -ceq * deq;
182  solutions[1] = ceq * (2 + deq);
183  return 2;
184  }
185 }
T sqrt(T t)
Definition: SSEVec.h:19

◆ solve3rdOrder()

int HelixExtrapolatorToLine2Order::solve3rdOrder ( const double  ceq[],
double  sol[] 
) const
private

Solutions of 3rd order equation.

Definition at line 117 of file HelixExtrapolatorToLine2Order.cc.

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

Referenced by pathLengthFromCoefficients().

117  {
118  //
119  // Real 3rd order equation? Follow numerical recipes ..
120  //
121  if (fabs(ceq[3]) > FLT_MIN) {
122  int result(0);
123  double q = (ceq[2] * ceq[2] - 3 * ceq[3] * ceq[1]) / (ceq[3] * ceq[3]) / 9.;
124  double r = (2 * ceq[2] * ceq[2] * ceq[2] - 9 * ceq[3] * ceq[2] * ceq[1] + 27 * ceq[3] * ceq[3] * ceq[0]) /
125  (ceq[3] * ceq[3] * ceq[3]) / 54.;
126  double q3 = q * q * q;
127  if (r * r < q3) {
128  double phi = acos(r / sqrt(q3)) / 3.;
129  double rootq = sqrt(q);
130  for (int i = 0; i < 3; i++) {
131  solutions[i] = -2 * rootq * cos(phi) - ceq[2] / ceq[3] / 3.;
132  phi += 2. / 3. * M_PI;
133  }
134  result = 3;
135  } else {
136  double a = pow(fabs(r) + sqrt(r * r - q3), 1. / 3.);
137  if (r > 0.)
138  a *= -1;
139  double b = fabs(a) > FLT_MIN ? q / a : 0.;
140  solutions[0] = a + b - ceq[2] / ceq[3] / 3.;
141  result = 1;
142  }
143  return result;
144  }
145  //
146  // Second order equation
147  //
148  else if (fabs(ceq[2]) > FLT_MIN) {
149  return solve2ndOrder(ceq, solutions);
150  } else {
151  //
152  // Special case: linear equation
153  //
154  solutions[0] = -ceq[0] / ceq[1];
155  return 1;
156  }
157 }
int solve2ndOrder(const double ceq[], double sol[]) const
Solutions of 2nd order equation.
T sqrt(T t)
Definition: SSEVec.h:19
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
#define M_PI
double b
Definition: hdecay.h:118
double a
Definition: hdecay.h:119
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29

Member Data Documentation

◆ theDirection

DirectionTypeDouble HelixExtrapolatorToLine2Order::theDirection
private

◆ thePosition

const PositionTypeDouble HelixExtrapolatorToLine2Order::thePosition
private

Definition at line 71 of file HelixExtrapolatorToLine2Order.h.

Referenced by pathLength(), and positionInDouble().

◆ thePropDir

const PropagationDirection HelixExtrapolatorToLine2Order::thePropDir
private

Definition at line 75 of file HelixExtrapolatorToLine2Order.h.

Referenced by pathLengthFromCoefficients().

◆ theRho

const double HelixExtrapolatorToLine2Order::theRho
private

Definition at line 74 of file HelixExtrapolatorToLine2Order.h.

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

◆ theSinTheta

double HelixExtrapolatorToLine2Order::theSinTheta
private