CMS 3D CMS Logo

RectangularMTDTopology.cc
Go to the documentation of this file.
2 
3 //--------------------------------------------------------------------
4 // PixelTopology interface.
5 // Transform LocalPoint in cm to measurement in pitch units.
6 std::pair<float, float> RectangularMTDTopology::pixel(const LocalPoint& p) const {
7  // check limits
8  float py = p.y();
9  float px = p.x();
10 
11  // In Y
12  float newybin = (py - m_yoffset) / m_pitchy;
13  // In X
14  float newxbin = (px - m_xoffset) / m_pitchx;
15 
16  return std::pair<float, float>(newxbin, newybin);
17 }
18 
19 //provide pixel indices based on local module position (with protection for border positions)
20 std::pair<int, int> RectangularMTDTopology::pixelIndex(const LocalPoint& p) const {
21  const auto& thepixel = pixel(p);
22  bool fail(false);
23 
24  static constexpr float tol = 5e-5f; // 0.5 micron tolerance
25 
26  int row = static_cast<int>(thepixel.first);
27  if (row >= m_nrows) {
28  fail = (p.x() - m_pitchx * m_nrows > tol);
29  if (!fail) {
30  row--;
31  }
32  }
33  int col = static_cast<int>(thepixel.second);
34  if (col >= m_ncols) {
35  fail = (p.y() - m_pitchy * m_ncols > tol);
36  if (!fail) {
37  col--;
38  }
39  }
40  if (fail) {
41  throw cms::Exception("RectangularMTDTopology")
42  << "Incorrect pixel id! r/c " << std::fixed << std::setw(2) << row << " / " << std::fixed << std::setw(2) << col
43  << " with max " << std::fixed << std::setw(2) << m_nrows << " / " << std::fixed << std::setw(2) << m_ncols
44  << " for LocalPoint " << std::fixed << std::setw(8) << std::setprecision(4) << p.x() << " , " << std::fixed
45  << std::setw(8) << std::setprecision(4) << p.y() << " pixel " << std::fixed << std::setw(8)
46  << std::setprecision(4) << thepixel.first << " , " << std::fixed << std::setw(8) << std::setprecision(4)
47  << thepixel.second << " deltas " << p.x() - m_pitchx * m_nrows << " , " << p.y() - m_pitchy * m_ncols;
48  }
49 
50  return std::pair<int, int>(row, col);
51 }
52 
53 //The following lines check whether the point is actually out of the active pixel area.
55  bool isInside = true;
56  const auto& thepixel = pixel(p);
57  const int ixbin = static_cast<int>(thepixel.first);
58  const int iybin = static_cast<int>(thepixel.second);
59  const float fractionX = thepixel.first - ixbin;
60  const float fractionY = thepixel.second - iybin;
61  if ((fractionX > 1.0 - m_GAPxInterpadFrac || fractionX < m_GAPxInterpadFrac) ||
62  (ixbin == 0 && fractionX < m_GAPxBorderFrac) || (ixbin == m_nrows - 1 && fractionX > 1.0 - m_GAPxBorderFrac)) {
63  isInside = false;
64  }
65  if ((fractionY > 1.0 - m_GAPyInterpadFrac || fractionY < m_GAPyInterpadFrac) ||
66  (iybin == 0 && fractionY < m_GAPyBorderFrac) || (iybin == m_ncols - 1 && fractionY > 1.0 - m_GAPyBorderFrac)) {
67  isInside = false;
68  }
69  return isInside;
70 }
71 
72 //----------------------------------------------------------------------
73 // Topology interface, go from Measurement to Local corrdinates
74 // pixel coordinates (mp) -> cm (LocalPoint)
76  float mpy = mp.y(); // measurements
77  float mpx = mp.x();
78 
79  float lpY = localY(mpy);
80  float lpX = localX(mpx);
81 
82  // Return it as a LocalPoint
83  return LocalPoint(lpX, lpY);
84 }
85 
86 //--------------------------------------------------------------------
87 //
88 // measuremet to local transformation for X coordinate
89 float RectangularMTDTopology::localX(const float mpx) const {
90  // The final position in local coordinates
91  float lpX = (mpx + 0.5f) * m_pitchx + m_xoffset;
92 
93  return lpX;
94 }
95 
96 float RectangularMTDTopology::localY(const float mpy) const {
97  // The final position in local coordinates
98  float lpY = (mpy + 0.5f) * m_pitchy + m_yoffset;
99 
100  return lpY;
101 }
102 
104 // Get hit errors in LocalPoint coordinates (cm)
106  return LocalError(me.uu() * float(m_pitchx * m_pitchx), 0, me.vv() * float(m_pitchy * m_pitchy));
107 }
108 
110 // Get errors in pixel pitch units.
112  return MeasurementError(le.xx() / float(m_pitchx * m_pitchx), 0, le.yy() / float(m_pitchy * m_pitchy));
113 }
bool isInPixel(const LocalPoint &p) const
Point3DBase< Scalar, LocalTag > LocalPoint
Definition: Definitions.h:30
LocalError localError(const MeasurementPoint &, const MeasurementError &) const override
T x() const
Definition: PV2DBase.h:43
T y() const
Definition: PV2DBase.h:44
float yy() const
Definition: LocalError.h:24
std::pair< float, float > pixel(const LocalPoint &p) const override
float localX(const float mpX) const override
double f[11][100]
float localY(const float mpY) const override
col
Definition: cuy.py:1009
std::pair< int, int > pixelIndex(const LocalPoint &p) const
LocalPoint localPosition(const MeasurementPoint &mp) const override
MeasurementError measurementError(const LocalPoint &, const LocalError &) const override
float xx() const
Definition: LocalError.h:22