CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
HelixArbitraryPlaneCrossing Class Referencefinal

#include <HelixArbitraryPlaneCrossing.h>

Inheritance diagram for HelixArbitraryPlaneCrossing:
HelixPlaneCrossing

Public Types

typedef Basic3DVector< double > DirectionTypeDouble
 
typedef Basic3DVector< double > PositionTypeDouble
 
- Public Types inherited from HelixPlaneCrossing
typedef Basic3DVector< float > DirectionType
 
typedef Basic3DVector< float > PositionType
 the helix is passed to the constructor and does not appear in the interface More...
 

Public Member Functions

DirectionType direction (double s) const override
 
DirectionTypeDouble directionInDouble (double s) const
 
 HelixArbitraryPlaneCrossing (const PositionType &point, const DirectionType &direction, const float curvature, const PropagationDirection propDir=alongMomentum)
 
std::pair< bool, double > pathLength (const Plane &plane) override
 
PositionType position (double s) const override
 
PositionTypeDouble positionInDouble (double s) const
 
 ~HelixArbitraryPlaneCrossing () override
 
- Public Member Functions inherited from HelixPlaneCrossing
virtual ~HelixPlaneCrossing ()=default
 

Private Member Functions

bool notAtSurface (const Plane &, const PositionTypeDouble &, const float) const
 

Private Attributes

double theCachedCDPhi
 
double theCachedDPhi
 
double theCachedS
 
double theCachedSDPhi
 
double theCosPhi0
 
double theCosTheta
 
const PropagationDirection thePropDir
 
HelixArbitraryPlaneCrossing2Order theQuadraticCrossingFromStart
 
const double theRho
 
double theSinPhi0
 
double theSinTheta
 
const double theX0
 
const double theY0
 
const double theZ0
 

Static Private Attributes

static const float theMaxDistToPlane = 1.e-4f
 
static const float theNumericalPrecision = 5.e-7f
 

Detailed Description

Calculates intersections of a helix with planes of any orientation.

Definition at line 10 of file HelixArbitraryPlaneCrossing.h.

Member Typedef Documentation

◆ DirectionTypeDouble

Definition at line 38 of file HelixArbitraryPlaneCrossing.h.

◆ PositionTypeDouble

Definition at line 37 of file HelixArbitraryPlaneCrossing.h.

Constructor & Destructor Documentation

◆ HelixArbitraryPlaneCrossing()

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

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

Definition at line 32 of file HelixArbitraryPlaneCrossing.cc.

References direction(), SiStripOfflineCRack_cfg::p2, HLT_2024v11_cff::pt2, multPhiCorr_741_25nsDY_cfi::px, multPhiCorr_741_25nsDY_cfi::py, mathSSE::sqrt(), theCosPhi0, theCosTheta, theSinPhi0, theSinTheta, Basic3DVector< T >::x(), Basic3DVector< T >::y(), and Basic3DVector< T >::z().

37  theX0(point.x()),
38  theY0(point.y()),
39  theZ0(point.z()),
41  thePropDir(propDir),
42  theCachedS(0),
43  theCachedDPhi(0.),
44  theCachedSDPhi(0.),
45  theCachedCDPhi(1.) {
46  //
47  // Components of direction vector (with correct normalisation)
48  //
49  double px = direction.x();
50  double py = direction.y();
51  double pz = direction.z();
52  double pt2 = px * px + py * py;
53  double p2 = pt2 + pz * pz;
54  double pI = 1. / sqrt(p2);
55  double ptI = 1. / sqrt(pt2);
56  theCosPhi0 = px * ptI;
57  theSinPhi0 = py * ptI;
58  theCosTheta = pz * pI;
59  theSinTheta = pt2 * ptI * pI;
60 }
HelixArbitraryPlaneCrossing2Order theQuadraticCrossingFromStart
T x() const
Cartesian x coordinate.
const PropagationDirection thePropDir
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
*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

◆ ~HelixArbitraryPlaneCrossing()

HelixArbitraryPlaneCrossing::~HelixArbitraryPlaneCrossing ( )
inlineoverride

Definition at line 19 of file HelixArbitraryPlaneCrossing.h.

19 {}

Member Function Documentation

◆ direction()

HelixPlaneCrossing::DirectionType HelixArbitraryPlaneCrossing::direction ( double  s) const
overridevirtual

Direction at pathlength s from the starting point.

Implements HelixPlaneCrossing.

Definition at line 193 of file HelixArbitraryPlaneCrossing.cc.

References DeadROC_duringRun::dir, directionInDouble(), and alignCSCRings::s.

Referenced by PixelForwardLayer::computeCrossings(), PixelForwardLayerPhase1::computeCrossings(), and HelixArbitraryPlaneCrossing().

193  {
194  // use result in double precision
196  return DirectionType(dir.x(), dir.y(), dir.z());
197 }
Basic3DVector< float > DirectionType
Basic3DVector< double > DirectionTypeDouble
DirectionTypeDouble directionInDouble(double s) const

◆ directionInDouble()

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

Direction at pathlength s from the starting point.

Definition at line 201 of file HelixArbitraryPlaneCrossing.cc.

References funct::abs(), HelixArbitraryPlaneCrossing2Order::directionInDouble(), MillePedeFileConverter_cfg::e, mkfit::mini_propagators::fast_sincos(), alignCSCRings::s, theCachedCDPhi, theCachedDPhi, theCachedS, theCachedSDPhi, theCosPhi0, theCosTheta, theQuadraticCrossingFromStart, theRho, theSinPhi0, theSinTheta, and UNLIKELY.

Referenced by direction(), and pathLength().

201  {
202  //
203  // Calculate delta phi (if not already available)
204  //
205  if UNLIKELY (s != theCachedS) { // very very unlikely!
206  theCachedS = s;
209  }
210 
211  if (std::abs(theCachedDPhi) > 1.e-4) {
212  // full helix formula
216  } else {
217  // 2nd order
219  }
220 }
HelixArbitraryPlaneCrossing2Order theQuadraticCrossingFromStart
DirectionTypeDouble directionInDouble(double s) const
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
Basic3DVector< double > DirectionTypeDouble
#define UNLIKELY(x)
Definition: Likely.h:21
void fast_sincos(const MPF &a, MPF &s, MPF &c)

◆ notAtSurface()

bool HelixArbitraryPlaneCrossing::notAtSurface ( const Plane plane,
const PositionTypeDouble point,
const float  maxDist 
) const
inlineprivate

Iteration control: check for significant distance to plane.

Definition at line 223 of file HelixArbitraryPlaneCrossing.cc.

References funct::abs(), PVValHelper::dz, Plane::localZ(), TtFullHadJetPartonMatch_cfi::maxDist, and point.

Referenced by pathLength().

225  {
226  float dz = plane.localZ(Surface::GlobalPoint(point.x(), point.y(), point.z()));
227  return std::abs(dz) > maxDist;
228 }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
float localZ(const GlobalPoint &gp) const
Definition: Plane.h:45
*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()

std::pair< bool, double > HelixArbitraryPlaneCrossing::pathLength ( const Plane plane)
overridevirtual

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

Implements HelixPlaneCrossing.

Definition at line 64 of file HelixArbitraryPlaneCrossing.cc.

References funct::abs(), alongMomentum, anyDirection, ALPAKA_ACCELERATOR_NAMESPACE::brokenline::constexpr(), directionInDouble(), PVValHelper::dz, align_cfg::iteration, Plane::localZ(), LogDebug, Basic3DVector< T >::mag(), maxiter, HLT_2024v11_cff::maxIterations, notAtSurface(), oppositeToMomentum, HelixArbitraryPlaneCrossing2Order::pathLength(), GloballyPositioned< T >::position(), positionInDouble(), theCosTheta, theMaxDistToPlane, theNumericalPrecision, thePropDir, theQuadraticCrossingFromStart, theRho, theSinTheta, theX0, theY0, theZ0, and UNLIKELY.

Referenced by PixelForwardLayer::computeCrossings(), and PixelForwardLayerPhase1::computeCrossings().

64  {
65  //
66  // Constants used for control of convergence
67  //
68  constexpr int maxIterations = 20;
69  //
70  // maximum distance to plane (taking into account numerical precision)
71  //
72  float maxNumDz = theNumericalPrecision * plane.position().mag();
73  float safeMaxDist = (theMaxDistToPlane > maxNumDz ? theMaxDistToPlane : maxNumDz);
74  //
75  // Prepare internal value of the propagation direction and position / direction vectors for iteration
76  //
77 
78  float dz = plane.localZ(Surface::GlobalPoint(theX0, theY0, theZ0));
79  if (std::abs(dz) < safeMaxDist)
80  return std::make_pair(true, 0.);
81 
82  bool notFail;
83  double dSTotal;
84  // Use existing 2nd order object at first pass
85  std::tie(notFail, dSTotal) = theQuadraticCrossingFromStart.pathLength(plane);
86  if UNLIKELY (!notFail)
87  return std::make_pair(notFail, dSTotal);
88  auto xnew = positionInDouble(dSTotal);
89 
90  auto propDir = thePropDir;
91  auto newDir = dSTotal >= 0 ? alongMomentum : oppositeToMomentum;
92  if (propDir == anyDirection) {
93  propDir = newDir;
94  } else {
95  if UNLIKELY (newDir != propDir)
96  return std::pair<bool, double>(false, 0);
97  }
98 
99  //
100  // Prepare iterations: count and total pathlength
101  //
102  auto iteration = maxIterations;
103  while (notAtSurface(plane, xnew, safeMaxDist)) {
104  //
105  // return empty solution vector if no convergence after maxIterations iterations
106  //
107  if UNLIKELY (--iteration == 0) {
108  LogDebug("HelixArbitraryPlaneCrossing") << "pathLength : no convergence";
109  return std::pair<bool, double>(false, 0);
110  }
111 
112  //
113  // create temporary object for subsequent passes.
114  auto pnew = directionInDouble(dSTotal);
115  HelixArbitraryPlaneCrossing2Order quadraticCrossing(
116  xnew.x(), xnew.y(), xnew.z(), pnew.x(), pnew.y(), theCosTheta, theSinTheta, theRho, anyDirection);
117 
118  auto deltaS2 = quadraticCrossing.pathLength(plane);
119 
120  if UNLIKELY (!deltaS2.first)
121  return deltaS2;
122  //
123  // Calculate and sort total pathlength (max. 2 solutions)
124  //
125  dSTotal += deltaS2.second;
126  auto newDir = dSTotal >= 0 ? alongMomentum : oppositeToMomentum;
127  if (propDir == anyDirection) {
128  propDir = newDir;
129  } else {
130  if UNLIKELY (newDir != propDir)
131  return std::pair<bool, double>(false, 0);
132  }
133  //
134  // Step forward by dSTotal.
135  //
136  xnew = positionInDouble(dSTotal);
137  }
138  //
139  // Return result
140  //
142 
143  return std::make_pair(true, dSTotal);
144 }
HelixArbitraryPlaneCrossing2Order theQuadraticCrossingFromStart
return((rh ^ lh) &mask)
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
const PropagationDirection thePropDir
PositionTypeDouble positionInDouble(double s) const
bool notAtSurface(const Plane &, const PositionTypeDouble &, const float) const
U second(std::pair< T, U > const &p)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
static const MaxIter maxiter
float localZ(const GlobalPoint &gp) const
Definition: Plane.h:45
const PositionType & position() const
std::pair< bool, double > pathLength(const Plane &) override
DirectionTypeDouble directionInDouble(double s) const
#define UNLIKELY(x)
Definition: Likely.h:21
if(threadIdxLocalY==0 &&threadIdxLocalX==0)
#define LogDebug(id)

◆ position()

HelixPlaneCrossing::PositionType HelixArbitraryPlaneCrossing::position ( double  s) const
overridevirtual

Position at pathlength s from the starting point.

Implements HelixPlaneCrossing.

Definition at line 148 of file HelixArbitraryPlaneCrossing.cc.

References positionInDouble(), and alignCSCRings::s.

Referenced by PixelForwardLayer::computeCrossings(), and PixelForwardLayerPhase1::computeCrossings().

148  {
149  // use result in double precision
151  return PositionType(pos.x(), pos.y(), pos.z());
152 }
Basic3DVector< double > PositionTypeDouble
PositionTypeDouble positionInDouble(double s) const
Basic3DVector< float > PositionType
the helix is passed to the constructor and does not appear in the interface

◆ positionInDouble()

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

Position at pathlength s from the starting point.

Definition at line 156 of file HelixArbitraryPlaneCrossing.cc.

References funct::abs(), MillePedeFileConverter_cfg::e, mkfit::mini_propagators::fast_sincos(), EcalTangentSkim_cfg::o, HelixArbitraryPlaneCrossing2Order::positionInDouble(), alignCSCRings::s, theCachedCDPhi, theCachedDPhi, theCachedS, theCachedSDPhi, theCosPhi0, theCosTheta, theQuadraticCrossingFromStart, theRho, theSinPhi0, theSinTheta, theX0, theY0, theZ0, and UNLIKELY.

Referenced by pathLength(), and position().

156  {
157  //
158  // Calculate delta phi (if not already available)
159  //
160  if UNLIKELY (s != theCachedS) {
161  theCachedS = s;
164  }
165  //
166  // Calculate with appropriate formulation of full helix formula or with
167  // 2nd order approximation.
168  //
169  // if ( fabs(theCachedDPhi)>1.e-1 ) {
170  if (std::abs(theCachedDPhi) > 1.e-4) {
171  // "standard" helix formula
172  double o = 1. / theRho;
176  }
177  // else if ( fabs(theCachedDPhi)>theNumericalPrecision ) {
178  // // full helix formula, but avoiding (1-cos(deltaPhi)) for small angles
179  // return PositionTypeDouble(theX0+(-theSinPhi0*theCachedSDPhi*theCachedSDPhi/(1.+theCachedCDPhi)+
180  // theCosPhi0*theCachedSDPhi)/theRho,
181  // theY0+(theCosPhi0*theCachedSDPhi*theCachedSDPhi/(1.+theCachedCDPhi)+
182  // theSinPhi0*theCachedSDPhi)/theRho,
183  // theZ0+theCachedS*theCosTheta);
184  // }
185  else {
186  // Use 2nd order.
188  }
189 }
HelixArbitraryPlaneCrossing2Order theQuadraticCrossingFromStart
PositionTypeDouble positionInDouble(double s) const
Basic3DVector< double > PositionTypeDouble
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
#define UNLIKELY(x)
Definition: Likely.h:21
void fast_sincos(const MPF &a, MPF &s, MPF &c)

Member Data Documentation

◆ theCachedCDPhi

double HelixArbitraryPlaneCrossing::theCachedCDPhi
mutableprivate

Definition at line 66 of file HelixArbitraryPlaneCrossing.h.

Referenced by directionInDouble(), and positionInDouble().

◆ theCachedDPhi

double HelixArbitraryPlaneCrossing::theCachedDPhi
mutableprivate

Definition at line 64 of file HelixArbitraryPlaneCrossing.h.

Referenced by directionInDouble(), and positionInDouble().

◆ theCachedS

double HelixArbitraryPlaneCrossing::theCachedS
mutableprivate

Definition at line 63 of file HelixArbitraryPlaneCrossing.h.

Referenced by directionInDouble(), and positionInDouble().

◆ theCachedSDPhi

double HelixArbitraryPlaneCrossing::theCachedSDPhi
mutableprivate

Definition at line 65 of file HelixArbitraryPlaneCrossing.h.

Referenced by directionInDouble(), and positionInDouble().

◆ theCosPhi0

double HelixArbitraryPlaneCrossing::theCosPhi0
private

◆ theCosTheta

double HelixArbitraryPlaneCrossing::theCosTheta
private

◆ theMaxDistToPlane

const float HelixArbitraryPlaneCrossing::theMaxDistToPlane = 1.e-4f
staticprivate

Definition at line 69 of file HelixArbitraryPlaneCrossing.h.

Referenced by pathLength().

◆ theNumericalPrecision

const float HelixArbitraryPlaneCrossing::theNumericalPrecision = 5.e-7f
staticprivate

Definition at line 68 of file HelixArbitraryPlaneCrossing.h.

Referenced by pathLength().

◆ thePropDir

const PropagationDirection HelixArbitraryPlaneCrossing::thePropDir
private

Definition at line 61 of file HelixArbitraryPlaneCrossing.h.

Referenced by pathLength().

◆ theQuadraticCrossingFromStart

HelixArbitraryPlaneCrossing2Order HelixArbitraryPlaneCrossing::theQuadraticCrossingFromStart
private

Definition at line 54 of file HelixArbitraryPlaneCrossing.h.

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

◆ theRho

const double HelixArbitraryPlaneCrossing::theRho
private

Definition at line 59 of file HelixArbitraryPlaneCrossing.h.

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

◆ theSinPhi0

double HelixArbitraryPlaneCrossing::theSinPhi0
private

◆ theSinTheta

double HelixArbitraryPlaneCrossing::theSinTheta
private

◆ theX0

const double HelixArbitraryPlaneCrossing::theX0
private

Definition at line 56 of file HelixArbitraryPlaneCrossing.h.

Referenced by pathLength(), and positionInDouble().

◆ theY0

const double HelixArbitraryPlaneCrossing::theY0
private

Definition at line 56 of file HelixArbitraryPlaneCrossing.h.

Referenced by pathLength(), and positionInDouble().

◆ theZ0

const double HelixArbitraryPlaneCrossing::theZ0
private

Definition at line 56 of file HelixArbitraryPlaneCrossing.h.

Referenced by pathLength(), and positionInDouble().