Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-05-29 23:12:52

0001 #ifndef Geometry_TrackerGeometryBuilder_RectangularPixelPhase2Topology_H
0002 #define Geometry_TrackerGeometryBuilder_RectangularPixelPhase2Topology_H
0003 
0004 /**
0005    * Topology for rectangular pixel detector with BIG pixels.
0006    */
0007 // Re-written for phase-2 pixels.
0008 // E. Migliore INFN/Universita Torino 2023/11
0009 // The bigger pixels are on the ROC boundries.
0010 // G. Giurgiu 11/27/06 ---------------------------------------------
0011 // Check whether the pixel is at the edge of the module by adding the
0012 // following functions (ixbin and iybin are the pixel row and column
0013 // inside the module):
0014 // bool isItEdgePixelInX (int ixbin)
0015 // bool isItEdgePixelInY (int iybin)
0016 // bool isItEdgePixel (int ixbin, int iybin)
0017 // ------------------------------------------------------------------
0018 // Add the individual measurement to local trasformations classes 01/07 d.k.
0019 // ------------------------------------------------------------------
0020 // Add big pixel flags for cluster range 15/3/07 V.Chiochia
0021 
0022 #include "Geometry/CommonTopologies/interface/PixelTopology.h"
0023 #include "DataFormats/SiPixelDetId/interface/PixelChannelIdentifier.h"
0024 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0025 
0026 class RectangularPixelPhase2Topology final : public PixelTopology {
0027 public:
0028   // Constructor, initilize
0029   RectangularPixelPhase2Topology(int nrows,
0030                                  int ncols,
0031                                  float pitchx,
0032                                  float pitchy,
0033                                  int ROWS_PER_ROC,       // Num of Rows per ROC
0034                                  int COLS_PER_ROC,       // Num of Cols per ROC
0035                                  int BIG_PIX_PER_ROC_X,  // in x direction, rows
0036                                  int BIG_PIX_PER_ROC_Y,  // in y direction, cols
0037                                  float BIG_PIX_PITCH_X,
0038                                  float BIG_PIX_PITCH_Y,
0039                                  int ROCS_X,
0040                                  int ROCS_Y)
0041       : m_pitchx(pitchx),
0042         m_pitchy(pitchy),
0043         m_nrows(nrows),
0044         m_ncols(ncols),
0045         m_ROWS_PER_ROC(ROWS_PER_ROC),            // Num of Rows per ROC
0046         m_COLS_PER_ROC(COLS_PER_ROC),            // Num of Cols per ROC
0047         m_BIG_PIX_PER_ROC_X(BIG_PIX_PER_ROC_X),  //
0048         m_BIG_PIX_PER_ROC_Y(BIG_PIX_PER_ROC_Y),  //
0049         m_BIG_PIX_PITCH_X(BIG_PIX_PITCH_X),
0050         m_BIG_PIX_PITCH_Y(BIG_PIX_PITCH_Y),
0051         m_ROCS_X(ROCS_X),  //
0052         m_ROCS_Y(ROCS_Y)   //
0053   {
0054     // Calculate the edge of the active sensor with respect to the center,
0055     // that is simply the half-size.
0056     // Take into account large pixels
0057     m_xoffset = -(
0058         (m_nrows / 2 - m_BIG_PIX_PER_ROC_X) * m_pitchx +
0059         m_BIG_PIX_PER_ROC_X *
0060             m_BIG_PIX_PITCH_X);  // assuming the big pixel pitch is well computed it gets always in the middle regardless the number of big pixel.  Quad is 670*0.025 + 2*0.0875; double is 336* 0.025; 3D is 336*0.025; old geom is 672*faxe x pitch
0061     m_yoffset = -((m_ncols / 2 - m_BIG_PIX_PER_ROC_Y) * m_pitchy + m_BIG_PIX_PER_ROC_Y * m_BIG_PIX_PITCH_Y);
0062 
0063     LogDebug("RectangularPixelPhase2Topology")
0064         << "nrows " << m_nrows << ", ncols " << m_ncols << ", pitchx " << m_pitchx << ", pitchy " << m_pitchy
0065         << ", xoffset " << m_xoffset << ", yoffset " << m_yoffset << ", BIG_PIX_PER_ROC_X " << BIG_PIX_PER_ROC_X
0066         << ", BIG_PIX_PER_ROC_Y " << BIG_PIX_PER_ROC_Y << ", BIG_PIX_PITCH_X " << BIG_PIX_PITCH_X
0067         << ", BIG_PIX_PITCH_Y " << BIG_PIX_PITCH_Y << ", ROWS_PER_ROC " << ROWS_PER_ROC << ", COLS_PER_ROC "
0068         << COLS_PER_ROC << ", ROCS_X " << ROCS_X << ", ROCS_Y " << ROCS_Y << "\nNROWS " << m_ROWS_PER_ROC * m_ROCS_X
0069         << ", NCOL " << m_COLS_PER_ROC * m_ROCS_Y;
0070   }
0071 
0072   // Topology interface, go from Masurement to Local corrdinates
0073   // pixel coordinates (mp) -> cm (LocalPoint)
0074   LocalPoint localPosition(const MeasurementPoint& mp) const override;
0075 
0076   // Transform LocalPoint to Measurement. Call pixel().
0077   MeasurementPoint measurementPosition(const LocalPoint& lp) const override {
0078     std::pair<float, float> p = pixel(lp);
0079     return MeasurementPoint(p.first, p.second);
0080   }
0081 
0082   // PixelTopology interface.
0083   // Transform LocalPoint in cm to measurement in pitch units.
0084   std::pair<float, float> pixel(const LocalPoint& p) const override;
0085 
0086   // Errors
0087   // Error in local (cm) from the masurement errors
0088   LocalError localError(const MeasurementPoint&, const MeasurementError&) const override;
0089   // Errors in pitch units from localpoint error (in cm)
0090   MeasurementError measurementError(const LocalPoint&, const LocalError&) const override;
0091 
0092   //-------------------------------------------------------------
0093   // Transform LocalPoint to channel. Call pixel()
0094   //
0095   int channel(const LocalPoint& lp) const override {
0096     std::pair<float, float> p = pixel(lp);
0097     return PixelChannelIdentifier::pixelToChannel(int(p.first), int(p.second));
0098   }
0099 
0100   //-------------------------------------------------------------
0101   // Transform measurement to local coordinates individually in each dimension
0102   //
0103   float localX(const float mpX) const override;
0104   float localY(const float mpY) const override;
0105 
0106   //-------------------------------------------------------------
0107   // Return the BIG pixel information for a given pixel (assuming they are always at the edge between two CROCs)
0108   //
0109   bool isItBigPixelInX(const int ixbin) const override {
0110     bool no_big_pixel = (m_BIG_PIX_PER_ROC_X == 0);
0111     if (!no_big_pixel)
0112       no_big_pixel = std::abs((ixbin - m_nrows / 2) + 0.5) > m_BIG_PIX_PER_ROC_X;
0113 
0114     return !no_big_pixel;
0115   }
0116 
0117   bool isItBigPixelInY(const int iybin) const override {
0118     bool no_big_pixel = (m_BIG_PIX_PER_ROC_Y == 0);
0119     if (!no_big_pixel)
0120       no_big_pixel = std::abs((iybin - m_ncols / 2) + 0.5) > m_BIG_PIX_PER_ROC_Y;
0121 
0122     return !no_big_pixel;
0123   }
0124 
0125   float pixelFractionInX(const int ixbin) const override {
0126     bool no_big_pixel = (m_BIG_PIX_PER_ROC_X == 0);
0127 
0128     if (no_big_pixel) {
0129       return 1.0f;
0130     } else {
0131       if (((m_nrows / 2 - m_BIG_PIX_PER_ROC_X) <= ixbin) &&
0132           (ixbin < (m_nrows / 2 - m_BIG_PIX_PER_ROC_X + m_BIG_PIX_PER_ROC_X * m_nrows / m_ROWS_PER_ROC))) {
0133         return float(m_BIG_PIX_PITCH_X / m_pitchx);
0134       } else {
0135         return 1.0f;
0136       }
0137     }
0138   }
0139 
0140   float pixelFractionInY(const int iybin) const override {
0141     bool no_big_pixel = (m_BIG_PIX_PER_ROC_Y == 0);
0142     if (no_big_pixel) {
0143       return 1.0f;
0144     } else {
0145       if (((m_ncols / 2 - m_BIG_PIX_PER_ROC_Y) <= iybin) &&
0146           (iybin < (m_ncols / 2 - m_BIG_PIX_PER_ROC_Y + m_BIG_PIX_PER_ROC_Y * m_ncols / m_COLS_PER_ROC))) {
0147         return float(m_BIG_PIX_PITCH_Y / m_pitchy);
0148       } else {
0149         return 1.0f;
0150       }
0151     }
0152   }
0153 
0154   //-------------------------------------------------------------
0155   // Return BIG pixel flag in a given pixel range (assuming they are always at the edge between two CROCs)
0156   //
0157   bool containsBigPixelInX(int ixmin, int ixmax) const override {
0158     return containsBigPixel(ixmin, ixmax, m_nrows, m_BIG_PIX_PER_ROC_X);
0159   }
0160 
0161   bool containsBigPixelInY(int iymin, int iymax) const override {
0162     return containsBigPixel(iymin, iymax, m_ncols, m_BIG_PIX_PER_ROC_Y);
0163   }
0164 
0165   bool bigpixelsX() const override { return false; }
0166   bool bigpixelsY() const override { return false; }
0167 
0168   //-------------------------------------------------------------
0169   // Check whether the pixel is at the edge of the module
0170   //
0171   bool isItEdgePixelInX(int ixbin) const override { return ((ixbin == 0) | (ixbin == (m_nrows - 1))); }
0172   bool isItEdgePixelInY(int iybin) const override { return ((iybin == 0) | (iybin == (m_ncols - 1))); }
0173   bool isItEdgePixel(int ixbin, int iybin) const override {
0174     return (isItEdgePixelInX(ixbin) || isItEdgePixelInY(iybin));
0175   }
0176 
0177   //------------------------------------------------------------------
0178   // Return pitch
0179   std::pair<float, float> pitch() const override { return std::pair<float, float>(float(m_pitchx), float(m_pitchy)); }
0180   // Return number of rows
0181   int nrows() const override { return (m_nrows); }
0182   // Return number of cols
0183   int ncolumns() const override { return (m_ncols); }
0184   // mlw Return number of ROCS Y
0185   int rocsY() const override { return m_ROCS_Y; }
0186   // mlw Return number of ROCS X
0187   int rocsX() const override { return m_ROCS_X; }
0188   // mlw Return number of rows per roc
0189   int rowsperroc() const override { return m_ROWS_PER_ROC; }
0190   // mlw Return number of cols per roc
0191   int colsperroc() const override { return m_COLS_PER_ROC; }
0192   int bigpixperrocX() const { return m_BIG_PIX_PER_ROC_X; }
0193   int bigpixperrocY() const { return m_BIG_PIX_PER_ROC_Y; }
0194   float xoffset() const { return m_xoffset; }
0195   float yoffset() const { return m_yoffset; }
0196   float pitchbigpixelX() const { return m_BIG_PIX_PITCH_X; }
0197   float pitchbigpixelY() const { return m_BIG_PIX_PITCH_Y; }
0198 
0199 private:
0200   float m_pitchx;
0201   float m_pitchy;
0202   float m_xoffset;
0203   float m_yoffset;
0204   int m_nrows;
0205   int m_ncols;
0206   int m_ROWS_PER_ROC;
0207   int m_COLS_PER_ROC;
0208   int m_BIG_PIX_PER_ROC_X;
0209   int m_BIG_PIX_PER_ROC_Y;
0210   float m_BIG_PIX_PITCH_X;
0211   float m_BIG_PIX_PITCH_Y;
0212   int m_ROCS_X;
0213   int m_ROCS_Y;
0214 
0215   bool containsBigPixel(int iMin, int iMax, int nPxTot, int nPxBigPerROC) const {
0216     // nPxTot/2 should lie in the upper half of the dimension
0217     auto firstBigPixel = nPxTot / 2 - nPxBigPerROC;
0218     auto lastBigPixel = nPxTot / 2 - 1 + nPxBigPerROC;
0219 
0220     // the interval contains no big pixel when either of the following is met:
0221     // - there are no big pixels
0222     // - the whole interval lies to the right of the big pixel chunk
0223     // - the whole interval lies to the left of the big pixel chunk
0224     bool noBigPixel = (nPxBigPerROC == 0) || (iMin > lastBigPixel) || (iMax < firstBigPixel);
0225 
0226     return !noBigPixel;
0227   }
0228 };
0229 
0230 #endif