CMS 3D CMS Logo

ThirdHitPredictionFromInvParabola.h
Go to the documentation of this file.
1 #ifndef RecoTracker_PixelSeeding_plugins_ThirdHitPredictionFromInvParabola_h
2 #define RecoTracker_PixelSeeding_plugins_ThirdHitPredictionFromInvParabola_h
3 
13 
16 #include <array>
17 
19 
20 class TrackingRegion;
21 class OrderedHitPair;
22 
23 // Function for testing ThirdHitPredictionFromInvParabola
24 namespace test {
25  namespace PixelTriplets_InvPrbl_prec {
26  int test();
27  }
28  namespace PixelTriplets_InvPrbl_t {
29  int test();
30  }
31 } // namespace test
32 
34  // For tests
37 
38 public:
39  using Scalar = double;
44 
48  init(x1, y1, x2, y2, ip, std::abs(curv));
49  }
50 
52  const GlobalPoint &P1, const GlobalPoint &P2, Scalar ip, Scalar curv, Scalar tolerance);
53 
54  // inline Range operator()(Scalar radius, int charge) const { return rangeRPhiSlow(radius,charge,1); }
55  inline Range operator()(Scalar radius, int charge) const { return rangeRPhi(radius, charge); }
56 
57  inline Range operator()(Scalar radius) const { return rangeRPhi(radius); }
58 
59  Range rangeRPhi(Scalar radius, int charge) const; // __attribute__ ((optimize(3, "fast-math")));
60 
62 
63  // Range rangeRPhiSlow(Scalar radius, int charge, int nIter=5) const;
64 
65  void init(const GlobalPoint &P1, const GlobalPoint &P2, Scalar ip, Scalar curv) {
66  init(P1.x(), P1.y(), P2.x(), P2.y(), ip, curv);
67  }
68  void init(Scalar x1, Scalar y1, Scalar x2, Scalar y2, Scalar ip, Scalar curv);
69 
70 private:
71  inline Scalar coeffA(Scalar impactParameter) const;
72  inline Scalar coeffB(Scalar impactParameter) const;
73  inline Scalar predV(Scalar u, Scalar ip) const;
74  inline Scalar ipFromCurvature(Scalar curvature, bool pos) const;
75 
76  Point2D transform(Point2D const &p) const { return theRotation.rotate(p) / p.mag2(); }
77 
78  Point2D transformBack(Point2D const &p) const { return theRotation.rotateBack(p) / p.mag2(); }
79 
80 private:
83 
84  // formula is symmetric for (ip,pos) -> (-ip,neg)
85  inline void findPointAtCurve(Scalar radius, Scalar ip, Scalar &u, Scalar &v) const;
86 
89  bool emptyP, emptyM;
90 };
91 
93  auto c = -pv * overDu;
94  return c - u1u2 * impactParameter;
95 }
96 
98  auto c = dv * overDu;
99  return c - su * impactParameter;
100 }
101 
103  bool pos) const {
104  Scalar overU1u2 = 1. / u1u2;
105  Scalar inInf = -pv * overDu * overU1u2;
106  return (pos ? inInf : -inInf) - curvature * overU1u2 * 0.5;
107 }
108 
110  auto c = -(coeffA(ip) - coeffB(ip * u) - ip * u * u);
111  return c;
112 }
113 
115  //
116  // assume u=(1-alpha^2/2)/r v=alpha/r
117  // solve qudratic equation neglecting aplha^4 term
118  //
119  Scalar A = coeffA(ip);
120  Scalar B = coeffB(ip);
121 
122  // Scalar overR = 1./r;
123  Scalar ipOverR = ip / r; // *overR;
124 
125  Scalar a = 0.5 * B + ipOverR;
126  Scalar c = -B + A * r - ipOverR;
127 
128  Scalar delta = 1 - 4 * a * c;
129  // Scalar sqrtdelta = (delta > 0) ? std::sqrt(delta) : 0.;
130  Scalar sqrtdelta = std::sqrt(delta);
131  // Scalar alpha = (-1+sqrtdelta)/(2*a);
132  Scalar alpha = (-2 * c) / (1 + sqrtdelta);
133 
134  v = alpha; // *overR
135  Scalar d2 = 1. - v * v; // overR*overR - v*v
136  // u = (d2 > 0) ? std::sqrt(d2) : 0.;
137  u = std::sqrt(d2);
138 
139  // u,v not rotated! not multiplied by 1/r
140 }
141 
142 #endif
Scalar ipFromCurvature(Scalar curvature, bool pos) const
BasicVector rotateBack(const BasicVector &v) const
Definition: APVGainStruct.h:7
const double tolerance
Scalar coeffB(Scalar impactParameter) const
T curvature(T InversePt, const MagneticField &field)
void init(const GlobalPoint &P1, const GlobalPoint &P2, Scalar ip, Scalar curv)
Range rangeRPhi(Scalar radius, int charge) const
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
Scalar coeffA(Scalar impactParameter) const
T sqrt(T t)
Definition: SSEVec.h:19
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
Range operator()(Scalar radius, int charge) const
double a
Definition: hdecay.h:121
BasicVector rotate(const BasicVector &v) const
Definition: APVGainStruct.h:7
void findPointAtCurve(Scalar radius, Scalar ip, Scalar &u, Scalar &v) const