CMS 3D CMS Logo

RectangularMTDTopology.h
Go to the documentation of this file.
1 #ifndef Geometry_MTDGeometryBuilder_RectangularMTDTopology_H
2 #define Geometry_MTDGeometryBuilder_RectangularMTDTopology_H
3 
7 // Modified for the large pixels. Should work for barrel and forward.
8 // Danek Kotlinski & Michele Pioppi, 3/06.
9 // The bigger pixels are on the ROC boundries.
10 // For columns (Y direction, longer direction):
11 // the normal pixel are 150um long, big pixels are 300um long,
12 // the pixel index goes from 0 to 416 (or less for smaller modules)
13 // the big pixel are in 0, 52,104,156,208,260,312,363
14 // 51,103,155,207,259,311,363,415 .
15 // For rows (X direction, shorter direction):
16 // the normal pixel are 100um wide, big pixels are 200um wide,
17 // the pixel index goes from 0 to 159 (or less for smaller modules)
18 // the big pixel are in 79,80.
19 // The ROC has rows=80, cols=52.
20 // There are a lot of hardwired constants, sorry but this is a very
21 // specific class. For any other sensor design it has to be rewritten.
22 
23 // G. Giurgiu 11/27/06 ---------------------------------------------
24 // Check whether the pixel is at the edge of the module by adding the
25 // following functions (ixbin and iybin are the pixel row and column
26 // inside the module):
27 // bool isItEdgePixelInX (int ixbin)
28 // bool isItEdgePixelInY (int iybin)
29 // bool isItEdgePixel (int ixbin, int iybin)
30 // ------------------------------------------------------------------
31 // Add the individual measurement to local trasformations classes 01/07 d.k.
32 // ------------------------------------------------------------------
33 // Add big pixel flags for cluster range 15/3/07 V.Chiochia
34 
38 
39 
41 {
42 public:
43 
44  // Constructor, initilize
45  RectangularMTDTopology( int nrows, int ncols, float pitchx, float pitchy,
46  bool upgradeGeometry,
47  int ROWS_PER_ROC, // Num of Rows per ROC
48  int COLS_PER_ROC, // Num of Cols per ROC
49  int BIG_PIX_PER_ROC_X, // in x direction, rows. BIG_PIX_PER_ROC_X = 0 for SLHC
50  int BIG_PIX_PER_ROC_Y, // in y direction, cols. BIG_PIX_PER_ROC_Y = 0 for SLHC
51  int ROCS_X, int ROCS_Y )
52  : m_pitchx( pitchx ),
53  m_pitchy( pitchy ),
54  m_nrows( nrows ),
55  m_ncols( ncols ),
56  m_ROWS_PER_ROC( ROWS_PER_ROC ), // Num of Rows per ROC
57  m_COLS_PER_ROC( COLS_PER_ROC ), // Num of Cols per ROC
58  m_ROCS_X( ROCS_X ), // 2 for SLHC
59  m_ROCS_Y( ROCS_Y ), // 8 for SLHC
60  m_upgradeGeometry( upgradeGeometry ) {
61 
62  setOffset(BIG_PIX_PER_ROC_X, BIG_PIX_PER_ROC_Y, ROWS_PER_ROC, COLS_PER_ROC);
63 
64  }
65 
66 
67  // Edge of the active sensor with respect to the center
68  void setOffset(const int& BIG_PIX_PER_ROC_X, const int& BIG_PIX_PER_ROC_Y,
69  const int& ROWS_PER_ROC, const int& COLS_PER_ROC);
70 
71 
72  // Topology interface, go from Masurement to Local module corrdinates
73  // pixel coordinates (mp) -> cm (LocalPoint)
74  LocalPoint localPosition( const MeasurementPoint& mp ) const override;
75 
76  // Transform LocalPoint to Measurement. Call pixel().
78  const override {
79  std::pair<float,float> p = pixel( lp );
80  return MeasurementPoint( p.first, p.second );
81  }
82 
83  // PixelTopology interface.
84  // Transform LocalPoint in cm to measurement in pitch units.
85  std::pair<float,float> pixel( const LocalPoint& p ) const override;
86 
87  // Errors
88  // Error in local (cm) from the masurement errors
90  const MeasurementError& ) const override;
91  // Errors in pitch units from localpoint error (in cm)
93  const LocalError& ) const override;
94 
95  //-------------------------------------------------------------
96  // Transform LocalPoint to channel. Call pixel()
97  //
98  int channel( const LocalPoint& lp ) const override {
99  std::pair<float,float> p = pixel( lp );
100  return MTDChannelIdentifier::pixelToChannel( int( p.first ),
101  int( p.second ));
102  }
103 
104  //----
105  // Transforms between module-local coordinates and pixel-local coordinates
106  // don't need a transform for errors, same units
108  std::pair<float,float> p = pixel( mlp );
109  return LocalPoint( mlp.x() - (m_xoffset + (int(p.first)+0.5f)*m_pitchx),
110  mlp.y() - (m_yoffset + (int(p.second)+0.5f)*m_pitchy),
111  mlp.z());
112  }
113  LocalPoint pixelToModuleLocalPoint(const LocalPoint& plp, int row, int col) const {
114  return LocalPoint( plp.x() + (m_xoffset + (row+0.5f)*m_pitchx),
115  plp.y() + (m_yoffset + (col+0.5f)*m_pitchy),
116  plp.z());
117  }
119  std::pair<int,int> p = MTDChannelIdentifier::channelToPixel(channel);
120  return pixelToModuleLocalPoint(plp,p.first,p.second);
121  }
122 
123  //-------------------------------------------------------------
124  // Transform measurement to local coordinates individually in each dimension
125  //
126  float localX( const float mpX ) const override;
127  float localY( const float mpY ) const override;
128 
129  //-------------------------------------------------------------
130  // Return the BIG pixel information for a given pixel
131  //
132  bool isItBigPixelInX( const int ixbin ) const override {
133  return (( m_upgradeGeometry )?(false):(( ixbin == 79 ) | ( ixbin == 80 )));
134  }
135 
136  bool isItBigPixelInY( const int iybin ) const override {
137  if UNLIKELY( m_upgradeGeometry ) return false;
138  else {
139  int iybin0 = iybin%52;
140  return(( iybin0 == 0 ) | ( iybin0 == 51 ));
141  // constexpr int bigYIndeces[]{0,51,52,103,104,155,156,207,208,259,260,311,312,363,364,415,416,511};
142  // return *std::lower_bound(std::begin(bigYIndeces),std::end(bigYIndeces),iybin) == iybin;
143  }
144  }
145 
146  //-------------------------------------------------------------
147  // Return BIG pixel flag in a given pixel range
148  //
149  bool containsBigPixelInX(int ixmin, int ixmax ) const override {
150  return m_upgradeGeometry ? false :( (ixmin<=80) & (ixmax>=79) );
151  }
152  bool containsBigPixelInY(int iymin, int iymax ) const override {
153  return m_upgradeGeometry ? false :
154  ( isItBigPixelInY( iymin ) || isItBigPixelInY( iymax ) || (iymin/52) != (iymax/52) )
155  ;
156  }
157 
158 
159  //-------------------------------------------------------------
160  // Check whether the pixel is at the edge of the module
161  //
162  bool isItEdgePixelInX (int ixbin) const override {
163  return ( (ixbin == 0) | (ixbin == (m_nrows-1)) );
164  }
165  bool isItEdgePixelInY (int iybin) const override {
166  return ( (iybin == 0) | (iybin == (m_ncols-1)) );
167  }
168  bool isItEdgePixel (int ixbin, int iybin) const override {
169  return ( isItEdgePixelInX( ixbin ) | isItEdgePixelInY( iybin ) );
170  }
171 
172  //------------------------------------------------------------------
173  // Return pitch
174  std::pair<float,float> pitch() const override {
175  return std::pair<float,float>( float(m_pitchx), float(m_pitchy));
176  }
177  // Return number of rows
178  int nrows() const override {
179  return ( m_nrows );
180  }
181  // Return number of cols
182  int ncolumns() const override {
183  return ( m_ncols );
184  }
185  // mlw Return number of ROCS Y
186  int rocsY() const override {
187  return m_ROCS_Y;
188  }
189  // mlw Return number of ROCS X
190  int rocsX() const override {
191  return m_ROCS_X;
192  }
193  // mlw Return number of rows per roc
194  int rowsperroc() const override {
195  return m_ROWS_PER_ROC;
196  }
197  // mlw Return number of cols per roc
198  int colsperroc() const override {
199  return m_COLS_PER_ROC;
200  }
201  float xoffset() const {
202  return m_xoffset;
203  }
204  float yoffset() const {
205  return m_yoffset;
206  }
207 
208 
209 private:
210 
211  float m_pitchx;
212  float m_pitchy;
213  float m_xoffset;
214  float m_yoffset;
215  int m_nrows;
216  int m_ncols;
219  int m_ROCS_X;
220  int m_ROCS_Y;
222 };
223 
224 #endif
225 
226 
bool isItEdgePixelInX(int ixbin) const override
Point3DBase< Scalar, LocalTag > LocalPoint
Definition: Definitions.h:32
bool isItBigPixelInX(const int ixbin) const override
float localX(const float mpX) const override
LocalError localError(const MeasurementPoint &, const MeasurementError &) const override
int colsperroc() const override
T y() const
Definition: PV3DBase.h:63
int ncolumns() const override
bool containsBigPixelInY(int iymin, int iymax) const override
bool isItBigPixelInY(const int iybin) const override
int nrows() const override
static std::pair< int, int > channelToPixel(int ch)
int channel(const LocalPoint &lp) const override
Measurement2DPoint MeasurementPoint
Measurement points are two-dimensional by default.
static int pixelToChannel(int row, int col)
LocalPoint localPosition(const MeasurementPoint &mp) const override
LocalPoint pixelToModuleLocalPoint(const LocalPoint &plp, int channel) const
T z() const
Definition: PV3DBase.h:64
int rocsX() const override
std::pair< float, float > pixel(const LocalPoint &p) const override
int rocsY() const override
LocalPoint pixelToModuleLocalPoint(const LocalPoint &plp, int row, int col) const
bool isItEdgePixel(int ixbin, int iybin) const override
MeasurementPoint measurementPosition(const LocalPoint &lp) const override
bool containsBigPixelInX(int ixmin, int ixmax) const override
col
Definition: cuy.py:1010
LocalPoint moduleToPixelLocalPoint(const LocalPoint &mlp) const
std::pair< float, float > pitch() const override
void setOffset(const int &BIG_PIX_PER_ROC_X, const int &BIG_PIX_PER_ROC_Y, const int &ROWS_PER_ROC, const int &COLS_PER_ROC)
float localY(const float mpY) const override
bool isItEdgePixelInY(int iybin) const override
MeasurementError measurementError(const LocalPoint &, const LocalError &) const override
#define UNLIKELY(x)
Definition: Likely.h:21
T x() const
Definition: PV3DBase.h:62
RectangularMTDTopology(int nrows, int ncols, float pitchx, float pitchy, bool upgradeGeometry, int ROWS_PER_ROC, int COLS_PER_ROC, int BIG_PIX_PER_ROC_X, int BIG_PIX_PER_ROC_Y, int ROCS_X, int ROCS_Y)
int rowsperroc() const override