test
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 // Function for testing ThirdHitPredictionFromInvParabola
27 namespace test {
28  namespace PixelTriplets_InvPrbl_prec {
29  int test();
30  }
31  namespace PixelTriplets_InvPrbl_t {
32  int test();
33  }
34 }
35 
36 
38  // For tests
41 
42 public:
43  using Scalar=double;
48 
51  Scalar tolerance): theTolerance(tolerance)
52  {
53  init(x1,y1,x2,y2,ip,std::abs(curv));
54  }
55 
57  Scalar ip, Scalar curv, Scalar tolerance);
58 
59 // inline Range operator()(Scalar radius, int charge) const { return rangeRPhiSlow(radius,charge,1); }
60  inline Range operator()(Scalar radius, int charge) const { return rangeRPhi(radius,charge); }
61 
62  inline Range operator()(Scalar radius) const { return rangeRPhi(radius); }
63 
64 
65  Range rangeRPhi(Scalar radius, int charge) const; // __attribute__ ((optimize(3, "fast-math")));
66 
68 
69 
70  // Range rangeRPhiSlow(Scalar radius, int charge, int nIter=5) const;
71 
72  void init( const GlobalPoint & P1, const GlobalPoint & P2, Scalar ip, Scalar curv) {
73  init( P1.x(), P1.y(), P2.x(),P2.y(),ip,curv);
74  }
75  void init(Scalar x1,Scalar y1, Scalar x2,Scalar y2, Scalar ip, Scalar curv);
76 
77 private:
78 
79 
80 
81  inline Scalar coeffA(Scalar impactParameter) const;
82  inline Scalar coeffB(Scalar impactParameter) const;
83  inline Scalar predV(Scalar u, Scalar ip) const;
84  inline Scalar ipFromCurvature(Scalar curvature, bool pos) const;
85 
86  Point2D transform(Point2D const & p) const {
87  return theRotation.rotate(p)/p.mag2();
88  }
89 
90  Point2D transformBack(Point2D const & p) const {
91  return theRotation.rotateBack(p)/p.mag2();
92  }
93 
94 private:
95 
98 
99  // formula is symmetric for (ip,pos) -> (-ip,neg)
100  inline void findPointAtCurve(Scalar radius, Scalar ip, Scalar &u, Scalar &v) const;
101 
104  bool emptyP, emptyM;
105 
106 };
107 
108 
109 
111  coeffA(Scalar impactParameter) const
112 {
113  auto c = -pv*overDu;
114  return c - u1u2*impactParameter;
115 }
116 
118  coeffB(Scalar impactParameter) const
119 {
120  auto c = dv*overDu;
121  return c - su*impactParameter;
122 }
123 
126 {
127  Scalar overU1u2 = 1./u1u2;
128  Scalar inInf = -pv*overDu*overU1u2;
129  return (pos? inInf : -inInf) -curvature*overU1u2*0.5;
130 }
131 
132 
134 predV( Scalar u, Scalar ip) const
135 {
136  auto c = -( coeffA(ip) - coeffB(ip*u) - ip*u*u);
137  return c;
138 }
139 
140 
142  Scalar & u, Scalar & v) const
143 {
144  //
145  // assume u=(1-alpha^2/2)/r v=alpha/r
146  // solve qudratic equation neglecting aplha^4 term
147  //
148  Scalar A = coeffA(ip);
149  Scalar B = coeffB(ip);
150 
151  // Scalar overR = 1./r;
152  Scalar ipOverR = ip/r; // *overR;
153 
154  Scalar a = 0.5*B+ipOverR;
155  Scalar c = -B+A*r-ipOverR;
156 
157  Scalar delta = 1-4*a*c;
158  // Scalar sqrtdelta = (delta > 0) ? std::sqrt(delta) : 0.;
159  Scalar sqrtdelta = std::sqrt(delta);
160  // Scalar alpha = (-1+sqrtdelta)/(2*a);
161  Scalar alpha = (-2*c)/(1+sqrtdelta);
162 
163  v = alpha; // *overR
164  Scalar d2 = 1. - v*v; // overR*overR - v*v
165  // u = (d2 > 0) ? std::sqrt(d2) : 0.;
166  u = std::sqrt(d2);
167 
168  // u,v not rotated! not multiplied by 1/r
169 }
170 
171 
172 #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
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:18
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