Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-01-21 00:19:33

0001 #ifndef Geometry_TrackerGeometryBuilder_RectangularPixelTopology_H
0002 #define Geometry_TrackerGeometryBuilder_RectangularPixelTopology_H
0003 
0004 /**
0005    * Topology for rectangular pixel detector with BIG pixels.
0006    */
0007 // Modified for the large pixels. Should work for barrel and forward.
0008 // Danek Kotlinski & Michele Pioppi, 3/06.
0009 // The bigger pixels are on the ROC boundries.
0010 // For columns (Y direction, longer direction):
0011 //  the normal pixel are 150um long, big pixels are 300um long,
0012 //  the pixel index goes from 0 to 416 (or less for smaller modules)
0013 //  the big pixel are in 0, 52,104,156,208,260,312,363
0014 //                      51,103,155,207,259,311,363,415 .
0015 // For rows (X direction, shorter direction):
0016 //  the normal pixel are 100um wide, big pixels are 200um wide,
0017 //  the pixel index goes from 0 to 159 (or less for smaller modules)
0018 //  the big pixel are in 79,80.
0019 // The ROC has rows=80, cols=52.
0020 // There are a lot of hardwired constants, sorry but this is a very
0021 // specific class. For any other sensor design it has to be rewritten.
0022 
0023 // G. Giurgiu 11/27/06 ---------------------------------------------
0024 // Check whether the pixel is at the edge of the module by adding the
0025 // following functions (ixbin and iybin are the pixel row and column
0026 // inside the module):
0027 // bool isItEdgePixelInX (int ixbin)
0028 // bool isItEdgePixelInY (int iybin)
0029 // bool isItEdgePixel (int ixbin, int iybin)
0030 // ------------------------------------------------------------------
0031 // Add the individual measurement to local trasformations classes 01/07 d.k.
0032 // ------------------------------------------------------------------
0033 // Add big pixel flags for cluster range 15/3/07 V.Chiochia
0034 
0035 #include "Geometry/CommonTopologies/interface/PixelTopology.h"
0036 #include "DataFormats/SiPixelDetId/interface/PixelChannelIdentifier.h"
0037 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0038 
0039 class RectangularPixelTopology final : public PixelTopology {
0040 public:
0041   // Constructor, initilize
0042   RectangularPixelTopology(int nrows,
0043                            int ncols,
0044                            float pitchx,
0045                            float pitchy,
0046                            bool upgradeGeometry,
0047                            int ROWS_PER_ROC,       // Num of Rows per ROC
0048                            int COLS_PER_ROC,       // Num of Cols per ROC
0049                            int BIG_PIX_PER_ROC_X,  // in x direction, rows. BIG_PIX_PER_ROC_X = 0 for SLHC
0050                            int BIG_PIX_PER_ROC_Y,  // in y direction, cols. BIG_PIX_PER_ROC_Y = 0 for SLHC
0051                            int ROCS_X,
0052                            int ROCS_Y)
0053       : m_pitchx(pitchx),
0054         m_pitchy(pitchy),
0055         m_nrows(nrows),
0056         m_ncols(ncols),
0057         m_ROWS_PER_ROC(ROWS_PER_ROC),  // Num of Rows per ROC
0058         m_COLS_PER_ROC(COLS_PER_ROC),  // Num of Cols per ROC
0059         m_ROCS_X(ROCS_X),              // 2 for SLHC
0060         m_ROCS_Y(ROCS_Y),              // 8 for SLHC
0061         m_upgradeGeometry(upgradeGeometry) {
0062     // Calculate the edge of the active sensor with respect to the center,
0063     // that is simply the half-size.
0064     // Take into account large pixels
0065     m_xoffset = -(m_nrows + BIG_PIX_PER_ROC_X * m_nrows / ROWS_PER_ROC) / 2. * m_pitchx;
0066     m_yoffset = -(m_ncols + BIG_PIX_PER_ROC_Y * m_ncols / COLS_PER_ROC) / 2. * m_pitchy;
0067 
0068     LogDebug("RectangularPixelTopology") << "nrows " << m_nrows << ", ncols " << m_ncols << ", pitchx " << m_pitchx
0069                                          << ", pitchy " << m_pitchy << ", xoffset " << m_xoffset << ", yoffset "
0070                                          << m_yoffset << ", BIG_PIX_PER_ROC_X " << BIG_PIX_PER_ROC_X
0071                                          << ", BIG_PIX_PER_ROC_Y " << BIG_PIX_PER_ROC_Y << ", ROWS_PER_ROC "
0072                                          << ROWS_PER_ROC << ", COLS_PER_ROC " << COLS_PER_ROC << ", ROCS_X " << ROCS_X
0073                                          << ", ROCS_Y " << ROCS_Y << "\nNROWS " << m_ROWS_PER_ROC * m_ROCS_X
0074                                          << ", NCOL " << m_COLS_PER_ROC * m_ROCS_Y;
0075   }
0076 
0077   // Topology interface, go from Masurement to Local corrdinates
0078   // pixel coordinates (mp) -> cm (LocalPoint)
0079   LocalPoint localPosition(const MeasurementPoint& mp) const override;
0080 
0081   // Transform LocalPoint to Measurement. Call pixel().
0082   MeasurementPoint measurementPosition(const LocalPoint& lp) const override {
0083     std::pair<float, float> p = pixel(lp);
0084     return MeasurementPoint(p.first, p.second);
0085   }
0086 
0087   // PixelTopology interface.
0088   // Transform LocalPoint in cm to measurement in pitch units.
0089   std::pair<float, float> pixel(const LocalPoint& p) const override;
0090 
0091   // Errors
0092   // Error in local (cm) from the masurement errors
0093   LocalError localError(const MeasurementPoint&, const MeasurementError&) const override;
0094   // Errors in pitch units from localpoint error (in cm)
0095   MeasurementError measurementError(const LocalPoint&, const LocalError&) const override;
0096 
0097   //-------------------------------------------------------------
0098   // Transform LocalPoint to channel. Call pixel()
0099   //
0100   int channel(const LocalPoint& lp) const override {
0101     std::pair<float, float> p = pixel(lp);
0102     return PixelChannelIdentifier::pixelToChannel(int(p.first), int(p.second));
0103   }
0104 
0105   //-------------------------------------------------------------
0106   // Transform measurement to local coordinates individually in each dimension
0107   //
0108   float localX(const float mpX) const override;
0109   float localY(const float mpY) const override;
0110 
0111   //-------------------------------------------------------------
0112   // Return the BIG pixel information for a given pixel
0113   //
0114   bool isItBigPixelInX(const int ixbin) const override {
0115     return ((m_upgradeGeometry) ? (false) : ((ixbin == 79) | (ixbin == 80)));
0116   }
0117 
0118   bool isItBigPixelInY(const int iybin) const override {
0119     if UNLIKELY (m_upgradeGeometry)
0120       return false;
0121     else {
0122       int iybin0 = iybin % 52;
0123       return ((iybin0 == 0) | (iybin0 == 51));
0124       // constexpr int bigYIndeces[]{0,51,52,103,104,155,156,207,208,259,260,311,312,363,364,415,416,511};
0125       // return *std::lower_bound(std::begin(bigYIndeces),std::end(bigYIndeces),iybin) == iybin;
0126     }
0127   }
0128 
0129   //-------------------------------------------------------------
0130   // Return BIG pixel flag in a given pixel range
0131   //
0132   bool containsBigPixelInX(int ixmin, int ixmax) const override {
0133     return m_upgradeGeometry ? false : ((ixmin <= 80) & (ixmax >= 79));
0134   }
0135   bool containsBigPixelInY(int iymin, int iymax) const override {
0136     return m_upgradeGeometry ? false
0137                              : (isItBigPixelInY(iymin) || isItBigPixelInY(iymax) || (iymin / 52) != (iymax / 52));
0138   }
0139 
0140   //-------------------------------------------------------------
0141   // Check whether the pixel is at the edge of the module
0142   //
0143   bool isItEdgePixelInX(int ixbin) const override { return ((ixbin == 0) | (ixbin == (m_nrows - 1))); }
0144   bool isItEdgePixelInY(int iybin) const override { return ((iybin == 0) | (iybin == (m_ncols - 1))); }
0145   bool isItEdgePixel(int ixbin, int iybin) const override {
0146     return (isItEdgePixelInX(ixbin) || isItEdgePixelInY(iybin));
0147   }
0148 
0149   //------------------------------------------------------------------
0150   // Return pitch
0151   std::pair<float, float> pitch() const override { return std::pair<float, float>(float(m_pitchx), float(m_pitchy)); }
0152   // Return number of rows
0153   int nrows() const override { return (m_nrows); }
0154   // Return number of cols
0155   int ncolumns() const override { return (m_ncols); }
0156   // mlw Return number of ROCS Y
0157   int rocsY() const override { return m_ROCS_Y; }
0158   // mlw Return number of ROCS X
0159   int rocsX() const override { return m_ROCS_X; }
0160   // mlw Return number of rows per roc
0161   int rowsperroc() const override { return m_ROWS_PER_ROC; }
0162   // mlw Return number of cols per roc
0163   int colsperroc() const override { return m_COLS_PER_ROC; }
0164   float xoffset() const { return m_xoffset; }
0165   float yoffset() const { return m_yoffset; }
0166 
0167 private:
0168   float m_pitchx;
0169   float m_pitchy;
0170   float m_xoffset;
0171   float m_yoffset;
0172   int m_nrows;
0173   int m_ncols;
0174   int m_ROWS_PER_ROC;
0175   int m_COLS_PER_ROC;
0176   int m_ROCS_X;
0177   int m_ROCS_Y;
0178   bool m_upgradeGeometry;
0179 };
0180 
0181 #endif