Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-04-21 02:53:12

0001 #include "Geometry/MTDGeometryBuilder/interface/RectangularMTDTopology.h"
0002 
0003 //--------------------------------------------------------------------
0004 // PixelTopology interface.
0005 // Transform LocalPoint in cm to measurement in pitch units.
0006 std::pair<float, float> RectangularMTDTopology::pixel(const LocalPoint& p) const {
0007   // check limits
0008   float py = p.y();
0009   float px = p.x();
0010 
0011   // In Y
0012   float newybin = (py - m_yoffset) / m_pitchy;
0013   // In X
0014   float newxbin = (px - m_xoffset) / m_pitchx;
0015 
0016   return std::pair<float, float>(newxbin, newybin);
0017 }
0018 
0019 //The following lines check whether the point is actually out of the active pixel area.
0020 bool RectangularMTDTopology::isInPixel(const LocalPoint& p) const {
0021   bool isInside = true;
0022   const auto& thepixel = pixel(p);
0023   const int ixbin = static_cast<int>(thepixel.first);
0024   const int iybin = static_cast<int>(thepixel.second);
0025   const float fractionX = thepixel.first - ixbin;
0026   const float fractionY = thepixel.second - iybin;
0027   if ((fractionX > 1.0 - m_GAPxInterpadFrac || fractionX < m_GAPxInterpadFrac) ||
0028       (ixbin == 0 && fractionX < m_GAPxBorderFrac) || (ixbin == m_nrows - 1 && fractionX > 1.0 - m_GAPxBorderFrac)) {
0029     isInside = false;
0030   }
0031   if ((fractionY > 1.0 - m_GAPyInterpadFrac || fractionY < m_GAPyInterpadFrac) ||
0032       (iybin == 0 && fractionY < m_GAPyBorderFrac) || (iybin == m_ncols - 1 && fractionY > 1.0 - m_GAPyBorderFrac)) {
0033     isInside = false;
0034   }
0035   return isInside;
0036 }
0037 
0038 //----------------------------------------------------------------------
0039 // Topology interface, go from Measurement to Local corrdinates
0040 // pixel coordinates (mp) -> cm (LocalPoint)
0041 LocalPoint RectangularMTDTopology::localPosition(const MeasurementPoint& mp) const {
0042   float mpy = mp.y();  // measurements
0043   float mpx = mp.x();
0044 
0045   float lpY = localY(mpy);
0046   float lpX = localX(mpx);
0047 
0048   // Return it as a LocalPoint
0049   return LocalPoint(lpX, lpY);
0050 }
0051 
0052 //--------------------------------------------------------------------
0053 //
0054 // measuremet to local transformation for X coordinate
0055 float RectangularMTDTopology::localX(const float mpx) const {
0056   // The final position in local coordinates
0057   float lpX = mpx * m_pitchx + m_xoffset;
0058 
0059   return lpX;
0060 }
0061 
0062 float RectangularMTDTopology::localY(const float mpy) const {
0063   // The final position in local coordinates
0064   float lpY = mpy * m_pitchy + m_yoffset;
0065 
0066   return lpY;
0067 }
0068 
0069 ///////////////////////////////////////////////////////////////////
0070 // Get hit errors in LocalPoint coordinates (cm)
0071 LocalError RectangularMTDTopology::localError(const MeasurementPoint& mp, const MeasurementError& me) const {
0072   return LocalError(me.uu() * float(m_pitchx * m_pitchx), 0, me.vv() * float(m_pitchy * m_pitchy));
0073 }
0074 
0075 /////////////////////////////////////////////////////////////////////
0076 // Get errors in pixel pitch units.
0077 MeasurementError RectangularMTDTopology::measurementError(const LocalPoint& lp, const LocalError& le) const {
0078   return MeasurementError(le.xx() / float(m_pitchx * m_pitchx), 0, le.yy() / float(m_pitchy * m_pitchy));
0079 }