CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ThirdHitPredictionFromInvParabola.h
Go to the documentation of this file.
1 #ifndef ThirdHitPredictionFromInvParabola_H
2 #define ThirdHitPredictionFromInvParabola_H
3 
15 
18 #include <array>
19 
21 
22 
23 class TrackingRegion;
24 class OrderedHitPair;
25 
26 
28 
29 public:
30  using Scalar=double;
35 
38  Scalar tolerance): theTolerance(tolerance)
39  {
40  init(x1,y1,x2,y2,ip,std::abs(curv));
41  }
42 
44  Scalar ip, Scalar curv, Scalar tolerance);
45 
46 // inline Range operator()(Scalar radius, int charge) const { return rangeRPhiSlow(radius,charge,1); }
47  inline Range operator()(Scalar radius, int charge) const { return rangeRPhi(radius,charge); }
48 
49  inline Range operator()(Scalar radius) const { return rangeRPhi(radius); }
50 
51 
52  Range rangeRPhi(Scalar radius, int charge) const; // __attribute__ ((optimize(3, "fast-math")));
53 
55 
56 
57  // Range rangeRPhiSlow(Scalar radius, int charge, int nIter=5) const;
58 
59  void init( const GlobalPoint & P1, const GlobalPoint & P2, Scalar ip, Scalar curv) {
60  init( P1.x(), P1.y(), P2.x(),P2.y(),ip,curv);
61  }
62  void init(Scalar x1,Scalar y1, Scalar x2,Scalar y2, Scalar ip, Scalar curv);
63 
64 private:
65 
66 
67 
68  inline Scalar coeffA(Scalar impactParameter) const;
69  inline Scalar coeffB(Scalar impactParameter) const;
70  inline Scalar predV(Scalar u, Scalar ip) const;
71  inline Scalar ipFromCurvature(Scalar curvature, bool pos) const;
72 
73  Point2D transform(Point2D const & p) const {
74  return theRotation.rotate(p)/p.mag2();
75  }
76 
77  Point2D transformBack(Point2D const & p) const {
78  return theRotation.rotateBack(p)/p.mag2();
79  }
80 
81 private:
82 
85 
86  // formula is symmetric for (ip,pos) -> (-ip,neg)
87  inline void findPointAtCurve(Scalar radius, Scalar ip, Scalar &u, Scalar &v) const;
88 
91  bool emptyP, emptyM;
92 
93 };
94 
95 
96 
98  coeffA(Scalar impactParameter) const
99 {
100  auto c = -pv*overDu;
101  return c - u1u2*impactParameter;
102 }
103 
105  coeffB(Scalar impactParameter) const
106 {
107  auto c = dv*overDu;
108  return c - su*impactParameter;
109 }
110 
113 {
114  Scalar overU1u2 = 1./u1u2;
115  Scalar inInf = -pv*overDu*overU1u2;
116  return (pos? inInf : -inInf) -curvature*overU1u2*0.5;
117 }
118 
119 
121 predV( Scalar u, Scalar ip) const
122 {
123  auto c = -( coeffA(ip) - coeffB(ip*u) - ip*u*u);
124  return c;
125 }
126 
127 
129  Scalar & u, Scalar & v) const
130 {
131  //
132  // assume u=(1-alpha^2/2)/r v=alpha/r
133  // solve qudratic equation neglecting aplha^4 term
134  //
135  Scalar A = coeffA(ip);
136  Scalar B = coeffB(ip);
137 
138  // Scalar overR = 1./r;
139  Scalar ipOverR = ip/r; // *overR;
140 
141  Scalar a = 0.5*B+ipOverR;
142  Scalar c = -B+A*r-ipOverR;
143 
144  Scalar delta = 1-4*a*c;
145  // Scalar sqrtdelta = (delta > 0) ? std::sqrt(delta) : 0.;
146  Scalar sqrtdelta = std::sqrt(delta);
147  // Scalar alpha = (-1+sqrtdelta)/(2*a);
148  Scalar alpha = (-2*c)/(1+sqrtdelta);
149 
150  v = alpha; // *overR
151  Scalar d2 = 1. - v*v; // overR*overR - v*v
152  // u = (d2 > 0) ? std::sqrt(d2) : 0.;
153  u = std::sqrt(d2);
154 
155  // u,v not rotated! not multiplied by 1/r
156 }
157 
158 
159 #endif
Scalar coeffA(Scalar impactParameter) const
dbl * delta
Definition: mlp_gen.cc:36
float alpha
Definition: AMPTWrapper.h:95
T y() const
Definition: PV3DBase.h:63
double charge(const std::vector< uint8_t > &Ampls)
void init(const GlobalPoint &P1, const GlobalPoint &P2, Scalar ip, Scalar curv)
T curvature(T InversePt, const edm::EventSetup &iSetup)
Range rangeRPhi(Scalar radius, int charge) const
T sqrt(T t)
Definition: SSEVec.h:48
ThirdHitPredictionFromInvParabola(Scalar x1, Scalar y1, Scalar x2, Scalar y2, Scalar ip, Scalar curv, Scalar tolerance)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
Scalar coeffB(Scalar impactParameter) const
Scalar ipFromCurvature(Scalar curvature, bool pos) const
void findPointAtCurve(Scalar radius, Scalar ip, Scalar &u, Scalar &v) const
Range operator()(Scalar radius, int charge) const
T mag2() const
The vector magnitude squared. Equivalent to vec.dot(vec)
double a
Definition: hdecay.h:121
BasicVector rotateBack(const BasicVector &v) const
T x() const
Definition: PV3DBase.h:62
Point2D transformBack(Point2D const &p) const
BasicVector rotate(const BasicVector &v) const