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 LIKELY (std::abs(ceq1) > FLT_MIN) {
58  double deq1 = ceq2 * ceq2;
59  double deq2 = ceq1 * ceq3;
60  if (std::abs(deq1) < FLT_MIN || std::abs(deq2 / deq1) > 1.e-6) {
61  //
62  // Standard solution for quadratic equations
63  //
64  double deq = deq1 + 2 * deq2;
65  if UNLIKELY (deq < 0.)
66  return std::pair<bool, double>(false, 0);
67  double ceq = ceq2 + std::copysign(std::sqrt(deq), ceq2);
68  dS1 = (ceq / ceq1) * theSinThetaI;
69  dS2 = -2. * (ceq3 / ceq) * theSinThetaI;
70  } else {
71  //
72  // Solution by expansion of sqrt(1+deq)
73  //
74  double ceq = (ceq2 / ceq1) * theSinThetaI;
75  double deq = deq2 / deq1;
76  deq *= (1 - 0.5 * deq);
77  dS1 = -ceq * deq;
78  dS2 = ceq * (2 + deq);
79  }
80  } else {
81  //
82  // Special case: linear equation
83  //
84  dS1 = dS2 = -(ceq3 / ceq2) * theSinThetaI;
85  }
86  //
87  // Choose and return solution
88  //
89  return solutionByDirection(dS1, dS2);
90 }
91 
92 //
93 // Position after a step of path length s (2nd order)
94 //
96  // use double precision result
98  return PositionType(pos.x(), pos.y(), pos.z());
99 }
100 //
101 // Position after a step of path length s (2nd order) (in double precision)
102 //
104  double s) const {
105  // based on path length in the transverse plane
106  double st = s / theSinThetaI;
107  return PositionTypeDouble(theX0 + (theCosPhi0 - (st * 0.5 * theRho) * theSinPhi0) * st,
108  theY0 + (theSinPhi0 + (st * 0.5 * theRho) * theCosPhi0) * st,
109  theZ0 + st * theCosTheta * theSinThetaI);
110 }
111 //
112 // Direction after a step of path length 2 (2nd order) (in double precision)
113 //
115  // use double precision result
117  return DirectionType(dir.x(), dir.y(), dir.z());
118 }
119 //
120 // Direction after a step of path length 2 (2nd order)
121 //
123  double s) const {
124  // based on delta phi
125  double dph = s * theRho / theSinThetaI;
126  return DirectionTypeDouble(theCosPhi0 - (theSinPhi0 + 0.5 * dph * theCosPhi0) * dph,
127  theSinPhi0 + (theCosPhi0 - 0.5 * dph * theSinPhi0) * dph,
129 }
130 //
131 // Choice of solution according to propagation direction
132 //
133 std::pair<bool, double> HelixArbitraryPlaneCrossing2Order::solutionByDirection(const double dS1,
134  const double dS2) const {
135  bool valid = false;
136  double path = 0;
137  if (thePropDir == anyDirection) {
138  valid = true;
139  path = smallestPathLength(dS1, dS2);
140  } else {
141  // use same logic for both directions (invert if necessary)
142  double propSign = thePropDir == alongMomentum ? 1 : -1;
143  double s1(propSign * dS1);
144  double s2(propSign * dS2);
145  // sort
146  if (s1 > s2)
147  std::swap(s1, s2);
148  // choose solution (if any with positive sign)
149  if ((s1 < 0) & (s2 >= 0)) {
150  // First solution in backward direction: choose second one.
151  valid = true;
152  path = propSign * s2;
153  } else if (s1 >= 0) {
154  // First solution in forward direction: choose it (s2 is further away!).
155  valid = true;
156  path = propSign * s1;
157  }
158  }
159  if (edm::isNotFinite(path))
160  valid = false;
161  return std::pair<bool, double>(valid, path);
162 }
Vector3DBase
Definition: Vector3DBase.h:8
Likely.h
anyDirection
Definition: PropagationDirection.h:4
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
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:133
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:122
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
HelixArbitraryPlaneCrossing2Order::position
PositionType position(double s) const override
Definition: HelixArbitraryPlaneCrossing2Order.cc:95
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:103
HelixArbitraryPlaneCrossing2Order.h
HLT_FULL_cff.pt2
pt2
Definition: HLT_FULL_cff.py:9895
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
genVertex_cff.x
x
Definition: genVertex_cff.py:13
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:114
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
RunInfoPI::valid
Definition: RunInfoPayloadInspectoHelper.h:16
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