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
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
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
0029 RectangularPixelPhase2Topology(int nrows,
0030 int ncols,
0031 float pitchx,
0032 float pitchy,
0033 int ROWS_PER_ROC,
0034 int COLS_PER_ROC,
0035 int BIG_PIX_PER_ROC_X,
0036 int BIG_PIX_PER_ROC_Y,
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),
0046 m_COLS_PER_ROC(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
0055
0056
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);
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
0073
0074 LocalPoint localPosition(const MeasurementPoint& mp) const override;
0075
0076
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
0083
0084 std::pair<float, float> pixel(const LocalPoint& p) const override;
0085
0086
0087
0088 LocalError localError(const MeasurementPoint&, const MeasurementError&) const override;
0089
0090 MeasurementError measurementError(const LocalPoint&, const LocalError&) const override;
0091
0092
0093
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
0102
0103 float localX(const float mpX) const override;
0104 float localY(const float mpY) const override;
0105
0106
0107
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
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
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
0179 std::pair<float, float> pitch() const override { return std::pair<float, float>(float(m_pitchx), float(m_pitchy)); }
0180
0181 int nrows() const override { return (m_nrows); }
0182
0183 int ncolumns() const override { return (m_ncols); }
0184
0185 int rocsY() const override { return m_ROCS_Y; }
0186
0187 int rocsX() const override { return m_ROCS_X; }
0188
0189 int rowsperroc() const override { return m_ROWS_PER_ROC; }
0190
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
0217 auto firstBigPixel = nPxTot / 2 - nPxBigPerROC;
0218 auto lastBigPixel = nPxTot / 2 - 1 + nPxBigPerROC;
0219
0220
0221
0222
0223
0224 bool noBigPixel = (nPxBigPerROC == 0) || (iMin > lastBigPixel) || (iMax < firstBigPixel);
0225
0226 return !noBigPixel;
0227 }
0228 };
0229
0230 #endif