CMS 3D CMS Logo

HelixArbitraryPlaneCrossing2Order.cc
Go to the documentation of this file.
2 
5 
6 #include <cmath>
7 #include <cfloat>
10 
12  const DirectionType& direction,
13  const float curvature,
14  const PropagationDirection propDir)
15  : theX0(point.x()), theY0(point.y()), theZ0(point.z()), theRho(curvature), thePropDir(propDir) {
16  //
17  // Components of direction vector (with correct normalisation)
18  //
19  double px = direction.x();
20  double py = direction.y();
21  double pz = direction.z();
22  double pt2 = px * px + py * py;
23  double p2 = pt2 + pz * pz;
24  double pI = 1. / sqrt(p2);
25  double ptI = 1. / sqrt(pt2);
26  theCosPhi0 = px * ptI;
27  theSinPhi0 = py * ptI;
28  theCosTheta = pz * pI;
29  theSinThetaI = p2 * pI * ptI; // (1/(pt/p)) = p/pt = p*ptI and p = p2/p = p2*pI
30 }
31 
32 //
33 // Propagation status and path length to intersection
34 //
35 std::pair<bool, double> HelixArbitraryPlaneCrossing2Order::pathLength(const Plane& plane) {
36  //
37  // get local z-vector in global co-ordinates and
38  // distance to starting point
39  //
40  GlobalVector normalToPlane = plane.normalVector();
41  double nPx = normalToPlane.x();
42  double nPy = normalToPlane.y();
43  double nPz = normalToPlane.z();
44  double cP = plane.localZ(GlobalPoint(theX0, theY0, theZ0));
45  //
46  // coefficients of 2nd order equation to obtain intersection point
47  // in approximation (without curvature-related factors).
48  //
49  double ceq1 = theRho * (nPx * theSinPhi0 - nPy * theCosPhi0);
50  double ceq2 = nPx * theCosPhi0 + nPy * theSinPhi0 + nPz * theCosTheta * theSinThetaI;
51  double ceq3 = cP;
52  //
53  // Check for degeneration to linear equation (zero
54  // curvature, forward plane or direction perp. to plane)
55  //
56  double dS1, dS2;
57  if
58  LIKELY(std::abs(ceq1) > FLT_MIN) {
59  double deq1 = ceq2 * ceq2;
60  double deq2 = ceq1 * ceq3;
61  if (std::abs(deq1) < FLT_MIN || std::abs(deq2 / deq1) > 1.e-6) {
62  //
63  // Standard solution for quadratic equations
64  //
65  double deq = deq1 + 2 * deq2;
66  if
67  UNLIKELY(deq < 0.) return std::pair<bool, double>(false, 0);
68  double ceq = ceq2 + std::copysign(std::sqrt(deq), ceq2);
69  dS1 = (ceq / ceq1) * theSinThetaI;
70  dS2 = -2. * (ceq3 / ceq) * theSinThetaI;
71  } else {
72  //
73  // Solution by expansion of sqrt(1+deq)
74  //
75  double ceq = (ceq2 / ceq1) * theSinThetaI;
76  double deq = deq2 / deq1;
77  deq *= (1 - 0.5 * deq);
78  dS1 = -ceq * deq;
79  dS2 = ceq * (2 + deq);
80  }
81  }
82  else {
83  //
84  // Special case: linear equation
85  //
86  dS1 = dS2 = -(ceq3 / ceq2) * theSinThetaI;
87  }
88  //
89  // Choose and return solution
90  //
91  return solutionByDirection(dS1, dS2);
92 }
93 
94 //
95 // Position after a step of path length s (2nd order)
96 //
98  // use double precision result
100  return PositionType(pos.x(), pos.y(), pos.z());
101 }
102 //
103 // Position after a step of path length s (2nd order) (in double precision)
104 //
106  double s) const {
107  // based on path length in the transverse plane
108  double st = s / theSinThetaI;
109  return PositionTypeDouble(theX0 + (theCosPhi0 - (st * 0.5 * theRho) * theSinPhi0) * st,
110  theY0 + (theSinPhi0 + (st * 0.5 * theRho) * theCosPhi0) * st,
111  theZ0 + st * theCosTheta * theSinThetaI);
112 }
113 //
114 // Direction after a step of path length 2 (2nd order) (in double precision)
115 //
117  // use double precision result
119  return DirectionType(dir.x(), dir.y(), dir.z());
120 }
121 //
122 // Direction after a step of path length 2 (2nd order)
123 //
125  double s) const {
126  // based on delta phi
127  double dph = s * theRho / theSinThetaI;
128  return DirectionTypeDouble(theCosPhi0 - (theSinPhi0 + 0.5 * dph * theCosPhi0) * dph,
129  theSinPhi0 + (theCosPhi0 - 0.5 * dph * theSinPhi0) * dph,
131 }
132 //
133 // Choice of solution according to propagation direction
134 //
135 std::pair<bool, double> HelixArbitraryPlaneCrossing2Order::solutionByDirection(const double dS1,
136  const double dS2) const {
137  bool valid = false;
138  double path = 0;
139  if (thePropDir == anyDirection) {
140  valid = true;
141  path = smallestPathLength(dS1, dS2);
142  } else {
143  // use same logic for both directions (invert if necessary)
144  double propSign = thePropDir == alongMomentum ? 1 : -1;
145  double s1(propSign * dS1);
146  double s2(propSign * dS2);
147  // sort
148  if (s1 > s2)
149  std::swap(s1, s2);
150  // choose solution (if any with positive sign)
151  if ((s1 < 0) & (s2 >= 0)) {
152  // First solution in backward direction: choose second one.
153  valid = true;
154  path = propSign * s2;
155  } else if (s1 >= 0) {
156  // First solution in forward direction: choose it (s2 is further away!).
157  valid = true;
158  path = propSign * s1;
159  }
160  }
161  if (edm::isNotFinite(path))
162  valid = false;
163  return std::pair<bool, double>(valid, path);
164 }
Vector3DBase
Definition: Vector3DBase.h:8
Likely.h
anyDirection
Definition: PropagationDirection.h:4
HLT_2018_cff.pt2
pt2
Definition: HLT_2018_cff.py:8552
detailsBasic3DVector::z
float float float z
Definition: extBasic3DVector.h:14
HelixArbitraryPlaneCrossing2Order::smallestPathLength
double smallestPathLength(const double firstPathLength, const double secondPathLength) const
Definition: HelixArbitraryPlaneCrossing2Order.h:71
edm::isNotFinite
constexpr bool isNotFinite(T x)
Definition: isFinite.h:9
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
multPhiCorr_741_25nsDY_cfi.py
py
Definition: multPhiCorr_741_25nsDY_cfi.py:12
HelixPlaneCrossing::DirectionType
Basic3DVector< float > DirectionType
Definition: HelixPlaneCrossing.h:23
pos
Definition: PixelAliasList.h:18
HelixArbitraryPlaneCrossing2Order::theSinThetaI
double theSinThetaI
Definition: HelixArbitraryPlaneCrossing2Order.h:83
indexGen.s2
s2
Definition: indexGen.py:107
HelixArbitraryPlaneCrossing2Order::PositionTypeDouble
Basic3DVector< double > PositionTypeDouble
Definition: HelixArbitraryPlaneCrossing2Order.h:58
HelixArbitraryPlaneCrossing2Order::theY0
const double theY0
Definition: HelixArbitraryPlaneCrossing2Order.h:81
PixelRecoUtilities::curvature
T curvature(T InversePt, const edm::EventSetup &iSetup)
Definition: PixelRecoUtilities.h:42
HelixArbitraryPlaneCrossing2Order::solutionByDirection
std::pair< bool, double > solutionByDirection(const double dS1, const double dS2) const
Definition: HelixArbitraryPlaneCrossing2Order.cc:135
validateGeometry_cfg.valid
valid
Definition: validateGeometry_cfg.py:21
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
Plane.h
UNLIKELY
#define UNLIKELY(x)
Definition: Likely.h:21
HelixArbitraryPlaneCrossing2Order::thePropDir
const PropagationDirection thePropDir
Definition: HelixArbitraryPlaneCrossing2Order.h:85
alignCSCRings.s
s
Definition: alignCSCRings.py:92
HelixArbitraryPlaneCrossing2Order::theZ0
const double theZ0
Definition: HelixArbitraryPlaneCrossing2Order.h:81
HelixArbitraryPlaneCrossing2Order::directionInDouble
DirectionTypeDouble directionInDouble(double s) const
Definition: HelixArbitraryPlaneCrossing2Order.cc:124
Basic3DVector::y
T y() const
Cartesian y coordinate.
Definition: extBasic3DVector.h:97
std::swap
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
Definition: DataFrameContainer.h:209
HelixArbitraryPlaneCrossing2Order::theRho
const double theRho
Definition: HelixArbitraryPlaneCrossing2Order.h:84
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
vertices_cff.x
x
Definition: vertices_cff.py:29
HelixArbitraryPlaneCrossing2Order::position
PositionType position(double s) const override
Definition: HelixArbitraryPlaneCrossing2Order.cc:97
p2
double p2[4]
Definition: TauolaWrapper.h:90
GlobalPoint
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
HelixArbitraryPlaneCrossing2Order::theCosPhi0
double theCosPhi0
Definition: HelixArbitraryPlaneCrossing2Order.h:82
HelixArbitraryPlaneCrossing2Order::theX0
const double theX0
Definition: HelixArbitraryPlaneCrossing2Order.h:81
HelixArbitraryPlaneCrossing2Order::DirectionTypeDouble
Basic3DVector< double > DirectionTypeDouble
Definition: HelixArbitraryPlaneCrossing2Order.h:59
Plane::localZ
float localZ(const GlobalPoint &gp) const
Definition: Plane.h:45
HelixArbitraryPlaneCrossing2Order::pathLength
std::pair< bool, double > pathLength(const Plane &) override
Definition: HelixArbitraryPlaneCrossing2Order.cc:35
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
HelixArbitraryPlaneCrossing2Order::theSinPhi0
double theSinPhi0
Definition: HelixArbitraryPlaneCrossing2Order.h:82
HelixArbitraryPlaneCrossing2Order::positionInDouble
PositionTypeDouble positionInDouble(double s) const
Definition: HelixArbitraryPlaneCrossing2Order.cc:105
HelixArbitraryPlaneCrossing2Order.h
multPhiCorr_741_25nsDY_cfi.px
px
Definition: multPhiCorr_741_25nsDY_cfi.py:10
HelixArbitraryPlaneCrossing2Order::theCosTheta
double theCosTheta
Definition: HelixArbitraryPlaneCrossing2Order.h:83
isFinite.h
LIKELY
#define LIKELY(x)
Definition: Likely.h:20
PropagationDirection
PropagationDirection
Definition: PropagationDirection.h:4
Plane
Definition: Plane.h:16
detailsBasic3DVector::y
float float y
Definition: extBasic3DVector.h:14
HelixArbitraryPlaneCrossing2Order::HelixArbitraryPlaneCrossing2Order
HelixArbitraryPlaneCrossing2Order(const PositionType &point, const DirectionType &direction, const float curvature, const PropagationDirection propDir=alongMomentum)
Definition: HelixArbitraryPlaneCrossing2Order.cc:11
Basic3DVector::x
T x() const
Cartesian x coordinate.
Definition: extBasic3DVector.h:94
HelixArbitraryPlaneCrossing2Order::direction
DirectionType direction(double s) const override
Definition: HelixArbitraryPlaneCrossing2Order.cc:116
castor_dqm_sourceclient_file_cfg.path
path
Definition: castor_dqm_sourceclient_file_cfg.py:37
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
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
Basic3DVector::z
T z() const
Cartesian z coordinate.
Definition: extBasic3DVector.h:100
GlobalPoint.h
alongMomentum
Definition: PropagationDirection.h:4
Basic3DVector< float >
DeadROC_duringRun.dir
dir
Definition: DeadROC_duringRun.py:23
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
HelixPlaneCrossing::PositionType
Basic3DVector< float > PositionType
the helix is passed to the constructor and does not appear in the interface
Definition: HelixPlaneCrossing.h:22
Plane::normalVector
GlobalVector normalVector() const
Definition: Plane.h:41