CMS 3D CMS Logo

PixelRecoLineRZ.h
Go to the documentation of this file.
1 #ifndef PixelRecoLineRZ_H
2 #define PixelRecoLineRZ_H
3 
7 #include <cmath>
8 
11 
13 public:
15 
17 
19  : theTIP2(initTIP2(p1.x(), p1.y(), p2.x(), p2.y())),
21  theCotLine(initCot(p2.z() - theOrigin.z(), subTIP(p2.perp()) - theOrigin.r())) {}
22 
23  PixelRecoLineRZ(const LineOrigin& aOrigin, float aCotLine, float transverseIP = 0.f)
24  : theTIP2(transverseIP * transverseIP), theOrigin(subTIP(aOrigin.r()), aOrigin.z()), theCotLine(aCotLine) {}
25 
26  PixelRecoLineRZ(const LineOrigin& aOrigin, const PixelRecoPointRZ& aPoint, float transverseIP = 0.f)
28  theOrigin(subTIP(aOrigin.r()), aOrigin.z()),
29  theCotLine(initCot(aPoint.z() - theOrigin.z(), subTIP(aPoint.r()) - theOrigin.r())) {}
30 
31  float cotLine() const { return theCotLine; }
32  float transverseIP() const { return std::sqrt(theTIP2); }
33  float transverseIP2() const { return theTIP2; }
34  LineOrigin origin() const { return LineOrigin(addTIP(theOrigin.r()), theOrigin.z()); }
35 
36  float zAtR(float r) const { return theOrigin.z() + (subTIP(r) - theOrigin.r()) * theCotLine; }
37  float rAtZ(float z) const {
38  return (std::abs(theCotLine) > 1.e-4f) ? addTIP(theOrigin.r() + (z - theOrigin.z()) / theCotLine) : 99999.f;
39  }
40 
41 private:
42  static float initCot(float dz, float dr) { return (std::abs(dr) > 1.e-4f) ? dz / dr : 99999.f; }
43  static float initTIP2(float x1, float y1, float x2, float y2) {
44  double l = y1 * (x2 - x1) - x1 * (y2 - y1);
45  return l * l / ((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
46  }
47 
48  inline float addTIP(float val) const { return theTIP2 ? std::sqrt(val * val + theTIP2) : val; }
49  inline float subTIP(float val) const {
50  if (!theTIP2)
51  return val;
52  float val2 = val * val;
53  return val2 > theTIP2 ? std::sqrt(val2 - theTIP2) : 0.;
54  }
55 
56 private:
57  float theTIP2;
59  float theCotLine;
60 };
61 
62 // simpler version (no tip)
63 class SimpleLineRZ {
64 public:
66 
68 
69  SimpleLineRZ(const Point& aOrigin, float aCotLine) : theOrigin(aOrigin), theCotLine(aCotLine) {}
70 
71  SimpleLineRZ(const Point& aOrigin, const Point& aPoint)
72  : theOrigin(aOrigin), theCotLine((aPoint.z() - theOrigin.z()) / (aPoint.r() - theOrigin.r())) {}
73 
74  float cotLine() const { return theCotLine; }
75  Point const& origin() const { return theOrigin; }
76 
77  float zAtR(float r) const { return theOrigin.z() + (r - theOrigin.r()) * theCotLine; }
78  float rAtZ(float z) const { return theOrigin.r() + (z - theOrigin.z()) / theCotLine; }
79 
80 private:
82  float theCotLine = 0;
83 };
84 
85 #endif
float transverseIP() const
float subTIP(float val) const
float cotLine() const
static float initCot(float dz, float dr)
float addTIP(float val) const
LineOrigin origin() const
SimpleLineRZ(const Point &aOrigin, const Point &aPoint)
static float initTIP2(float x1, float y1, float x2, float y2)
float zAtR(float r) const
float transverseIP2() const
T sqrt(T t)
Definition: SSEVec.h:23
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double f[11][100]
PixelRecoLineRZ(const LineOrigin &aOrigin, const PixelRecoPointRZ &aPoint, float transverseIP=0.f)
LineOrigin theOrigin
float r() const
T perp() const
Magnitude of transverse component.
SimpleLineRZ(const Point &aOrigin, float aCotLine)
float rAtZ(float z) const
float rAtZ(float z) const
float cotLine() const
PixelRecoPointRZ LineOrigin
PixelRecoLineRZ(const LineOrigin &aOrigin, float aCotLine, float transverseIP=0.f)
PixelRecoLineRZ(const GlobalPoint &p1, const GlobalPoint &p2)
float z() const
float zAtR(float r) const
PixelRecoPointRZ Point
Point const & origin() const