CMS 3D CMS Logo

RectangularPixelTopology.cc
Go to the documentation of this file.
2 
6 // Modified for the large pixles.
7 // Danek Kotlinski & Michele Pioppi, 3/06.
8 // See documentation in the include file.
9 
10 //--------------------------------------------------------------------
11 // PixelTopology interface.
12 // Transform LocalPoint in cm to measurement in pitch units.
13 std::pair<float, float> RectangularPixelTopology::pixel(const LocalPoint& p) const {
14  // check limits
15  float py = p.y();
16  float px = p.x();
17 
18 #ifdef EDM_ML_DEBUG
19 #define EPSCM 0
20 #define EPS 0
21  // This will catch points which are outside the active sensor area.
22  // In the digitizer during the early induce_signal phase non valid
23  // location are passed here. They are cleaned later.
24 
25  std::ostringstream debugstr;
26  debugstr << "py = " << py << ", m_yoffset = " << m_yoffset << "px = " << px << ", m_xoffset = " << m_xoffset << "\n";
27 
28  if (py < m_yoffset) // m_yoffset is negative
29  {
30  debugstr << " wrong lp y " << py << " " << m_yoffset << "\n";
31  py = m_yoffset + EPSCM; // make sure it is in, add an EPS in cm
32  }
33  if (py > -m_yoffset) {
34  debugstr << " wrong lp y " << py << " " << -m_yoffset << "\n";
35  py = -m_yoffset - EPSCM;
36  }
37  if (px < m_xoffset) // m_xoffset is negative
38  {
39  debugstr << " wrong lp x " << px << " " << m_xoffset << "\n";
40  px = m_xoffset + EPSCM;
41  }
42  if (px > -m_xoffset) {
43  debugstr << " wrong lp x " << px << " " << -m_xoffset << "\n";
44  px = -m_xoffset - EPSCM;
45  }
46 
47  if (!debugstr.str().empty())
48  LogDebug("RectangularPixelTopology") << debugstr.str();
49 #endif // EDM_ML_DEBUG
50 
51  float newybin = (py - m_yoffset) / m_pitchy;
52  int iybin = int(newybin);
53  float fractionY = newybin - iybin;
54 
55  // Normalize it all to 1 ROC
56  int iybin0 = 0;
57  int numROC = 0;
58  float mpY = 0.;
59 
60  if (m_upgradeGeometry) {
61  iybin0 = (iybin % m_COLS_PER_ROC); // 0-51
62  numROC = iybin / m_COLS_PER_ROC; // 0-7
63  mpY = float(numROC * m_COLS_PER_ROC + iybin0) + fractionY;
64 
65 #ifdef EDM_ML_DEBUG
66 
67  if (iybin0 > m_COLS_PER_ROC) {
68  LogDebug("RectangularPixelTopology") << " very bad, newbiny " << iybin0 << "\n"
69  << py << " " << m_yoffset << " " << m_pitchy << " " << newybin << " "
70  << iybin << " " << fractionY << " " << iybin0 << " " << numROC;
71  }
72 #endif // EDM_ML_DEBUG
73 
74  } else {
75  iybin0 = (iybin % 54); // 0-53
76  numROC = iybin / 54; // 0-7
77 
78  if (iybin0 == 53) { // inside big pixel
79  iybin0 = 51;
80  fractionY = (fractionY + 1.) / 2.;
81  } else if (iybin0 == 52) { // inside big pixel
82  iybin0 = 51;
83  fractionY = fractionY / 2.;
84  } else if (iybin0 > 1) { // inside normal pixel
85  iybin0 = iybin0 - 1;
86  } else if (iybin0 == 1) { // inside big pixel
87  iybin0 = 0;
88  fractionY = (fractionY + 1.) / 2.;
89  } else if (iybin0 == 0) { // inside big pixel
90  iybin0 = 0;
91  fractionY = fractionY / 2.;
92  }
93 
94  mpY = float(numROC * 52. + iybin0) + fractionY;
95  }
96 
97 #ifdef EDM_ML_DEBUG
98 
99  if (mpY < 0. || mpY >= 416.) {
100  LogDebug("RectangularPixelTopology") << " bad pix y " << mpY << "\n"
101  << py << " " << m_yoffset << " " << m_pitchy << " " << newybin << " " << iybin
102  << " " << fractionY << " " << iybin0 << " " << numROC;
103  }
104 #endif // EDM_ML_DEBUG
105 
106  // In X
107  float newxbin = (px - m_xoffset) / m_pitchx;
108  int ixbin = int(newxbin);
109  float fractionX = newxbin - ixbin;
110 
111 #ifdef EDM_ML_DEBUG
112 
113  if (ixbin > 161 || ixbin < 0) // ixbin < 0 outside range
114  {
115  LogDebug("RectangularPixelTopology") << " very bad, newbinx " << ixbin << "\n"
116  << px << " " << m_xoffset << " " << m_pitchx << " " << newxbin << " " << ixbin
117  << " " << fractionX;
118  }
119 #endif // EDM_ML_DEBUG
120 
121  if (!m_upgradeGeometry) {
122  if (ixbin > 82) { // inside normal pixel, ROC 1
123  ixbin = ixbin - 2;
124  } else if (ixbin == 82) { // inside bin pixel
125  ixbin = 80;
126  fractionX = (fractionX + 1.) / 2.;
127  } else if (ixbin == 81) { // inside big pixel
128  ixbin = 80;
129  fractionX = fractionX / 2.;
130  } else if (ixbin == 80) { // inside bin pixel, ROC 0
131  ixbin = 79;
132  fractionX = (fractionX + 1.) / 2.;
133  } else if (ixbin == 79) { // inside big pixel
134  ixbin = 79;
135  fractionX = fractionX / 2.;
136  }
137  }
138 
139  float mpX = float(ixbin) + fractionX;
140 
141 #ifdef EDM_ML_DEBUG
142 
143  if (mpX < 0. || mpX >= 160.) {
144  LogDebug("RectangularPixelTopology") << " bad pix x " << mpX << "\n"
145  << px << " " << m_xoffset << " " << m_pitchx << " " << newxbin << " " << ixbin
146  << " " << fractionX;
147  }
148 #endif // EDM_ML_DEBUG
149 
150  return std::pair<float, float>(mpX, mpY);
151 }
152 
153 //----------------------------------------------------------------------
154 // Topology interface, go from Masurement to Local corrdinates
155 // pixel coordinates (mp) -> cm (LocalPoint)
157  float mpy = mp.y(); // measurements
158  float mpx = mp.x();
159 
160 #ifdef EDM_ML_DEBUG
161 #define EPS 0
162  // check limits
163  std::ostringstream debugstr;
164 
165  if (mpy < 0.) {
166  debugstr << " wrong mp y, fix " << mpy << " " << 0 << "\n";
167  mpy = 0.;
168  }
169  if (mpy >= m_ncols) {
170  debugstr << " wrong mp y, fix " << mpy << " " << m_ncols << "\n";
171  mpy = float(m_ncols) - EPS; // EPS is a small number
172  }
173  if (mpx < 0.) {
174  debugstr << " wrong mp x, fix " << mpx << " " << 0 << "\n";
175  mpx = 0.;
176  }
177  if (mpx >= m_nrows) {
178  debugstr << " wrong mp x, fix " << mpx << " " << m_nrows << "\n";
179  mpx = float(m_nrows) - EPS; // EPS is a small number
180  }
181  if (!debugstr.str().empty())
182  LogDebug("RectangularPixelTopology") << debugstr.str();
183 #endif // EDM_ML_DEBUG
184 
185  float lpY = localY(mpy);
186  float lpX = localX(mpx);
187 
188  // Return it as a LocalPoint
189  return LocalPoint(lpX, lpY);
190 }
191 
192 //--------------------------------------------------------------------
193 //
194 // measuremet to local transformation for X coordinate
195 // X coordinate is in the ROC row number direction
196 float RectangularPixelTopology::localX(const float mpx) const {
197  int binoffx = int(mpx); // truncate to int
198  float fractionX = mpx - float(binoffx); // find the fraction
199  float local_pitchx = m_pitchx; // defaultpitch
200 
202 #ifdef EDM_ML_DEBUG
203  if (binoffx > m_ROWS_PER_ROC * m_ROCS_X) // too large
204  {
205  LogDebug("RectangularPixelTopology")
206  << " very bad, binx " << binoffx << "\n"
207  << mpx << " " << binoffx << " " << fractionX << " " << local_pitchx << " " << m_xoffset << "\n";
208  }
209 #endif
210  } else {
211  if (binoffx > 80) { // ROC 1 - handles x on edge cluster
212  binoffx = binoffx + 2;
213  } else if (binoffx == 80) { // ROC 1
214  binoffx = binoffx + 1;
215  local_pitchx *= 2;
216  } else if (binoffx == 79) { // ROC 0
217  binoffx = binoffx + 0;
218  local_pitchx *= 2;
219  }
220  // else if (binoffx>=0) { // ROC 0
221  // binoffx=binoffx+0;
222  // }
223 
224 #ifdef EDM_ML_DEBUG
225  if (binoffx < 0) // too small
226  LogDebug("RectangularPixelTopology")
227  << " very bad, binx " << binoffx << "\n"
228  << mpx << " " << binoffx << " " << fractionX << " " << local_pitchx << " " << m_xoffset;
229 #endif
230  }
231 
232  // The final position in local coordinates
233  float lpX = float(binoffx * m_pitchx) + fractionX * local_pitchx + m_xoffset;
234 
235 #ifdef EDM_ML_DEBUG
236 
237  if (lpX < m_xoffset || lpX > (-m_xoffset)) {
238  LogDebug("RectangularPixelTopology") << " bad lp x " << lpX << "\n"
239  << mpx << " " << binoffx << " " << fractionX << " " << local_pitchx << " "
240  << m_xoffset;
241  }
242 #endif // EDM_ML_DEBUG
243 
244  return lpX;
245 }
246 
247 // measuremet to local transformation for Y coordinate
248 // Y is in the ROC column number direction
249 float RectangularPixelTopology::localY(const float mpy) const {
250  int binoffy = int(mpy); // truncate to int
251  float fractionY = mpy - float(binoffy); // find the fraction
252  float local_pitchy = m_pitchy; // defaultpitch
253 
255 #ifdef EDM_ML_DEBUG
256  if (binoffy > m_ROCS_Y * m_COLS_PER_ROC) // too large
257  {
258  LogDebug("RectangularPixelTopology")
259  << " very bad, biny " << binoffy << "\n"
260  << mpy << " " << binoffy << " " << fractionY << " " << local_pitchy << " " << m_yoffset;
261  }
262 #endif
263  } else { // 415 is last big pixel, 416 and above do not exists!
264  constexpr int bigYIndeces[]{0, 51, 52, 103, 104, 155, 156, 207, 208, 259, 260, 311, 312, 363, 364, 415, 416, 511};
265  auto const j = std::lower_bound(std::begin(bigYIndeces), std::end(bigYIndeces), binoffy);
266  if (*j == binoffy)
267  local_pitchy *= 2;
268  binoffy += (j - bigYIndeces);
269  }
270 
271  // The final position in local coordinates
272  float lpY = float(binoffy * m_pitchy) + fractionY * local_pitchy + m_yoffset;
273 
274 #ifdef EDM_ML_DEBUG
275 
276  if (lpY < m_yoffset || lpY > (-m_yoffset)) {
277  LogDebug("RectangularPixelTopology") << " bad lp y " << lpY << "\n"
278  << mpy << " " << binoffy << " " << fractionY << " " << local_pitchy << " "
279  << m_yoffset;
280  }
281 #endif // EDM_ML_DEBUG
282 
283  return lpY;
284 }
285 
287 // Get hit errors in LocalPoint coordinates (cm)
289  float pitchy = m_pitchy;
290  int binoffy = int(mp.y());
291  if (isItBigPixelInY(binoffy))
292  pitchy = 2. * m_pitchy;
293 
294  float pitchx = m_pitchx;
295  int binoffx = int(mp.x());
296  if (isItBigPixelInX(binoffx))
297  pitchx = 2. * m_pitchx;
298 
299  return LocalError(me.uu() * float(pitchx * pitchx), 0, me.vv() * float(pitchy * pitchy));
300 }
301 
303 // Get errors in pixel pitch units.
305  float pitchy = m_pitchy;
306  float pitchx = m_pitchx;
307 
308  if LIKELY (!m_upgradeGeometry) {
309  int iybin = int((lp.y() - m_yoffset) / m_pitchy); //get bin for equal picth
310  int iybin0 = iybin % 54; //This is just to avoid many ifs by using the periodicy
311  //quasi bins 0,1,52,53 fall into larger pixels
312  if ((iybin0 <= 1) | (iybin0 >= 52))
313  pitchy = 2.f * m_pitchy;
314 
315  int ixbin = int((lp.x() - m_xoffset) / m_pitchx); //get bin for equal pitch
316  //quasi bins 79,80,81,82 fall into the 2 larger pixels
317  if ((ixbin >= 79) & (ixbin <= 82))
318  pitchx = 2.f * m_pitchx;
319  }
320 
321  return MeasurementError(le.xx() / float(pitchx * pitchx), 0, le.yy() / float(pitchy * pitchy));
322 }
RectangularPixelTopology::localPosition
LocalPoint localPosition(const MeasurementPoint &mp) const override
Definition: RectangularPixelTopology.cc:156
Point2DBase
Definition: Point2DBase.h:9
RectangularPixelTopology::m_nrows
int m_nrows
Definition: RectangularPixelTopology.h:172
RectangularPixelTopology::m_COLS_PER_ROC
int m_COLS_PER_ROC
Definition: RectangularPixelTopology.h:175
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
RectangularPixelTopology::measurementError
MeasurementError measurementError(const LocalPoint &, const LocalError &) const override
Definition: RectangularPixelTopology.cc:304
RectangularPixelTopology::m_yoffset
float m_yoffset
Definition: RectangularPixelTopology.h:171
RectangularPixelTopology.h
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
multPhiCorr_741_25nsDY_cfi.py
py
Definition: multPhiCorr_741_25nsDY_cfi.py:12
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
RectangularPixelTopology::m_ROCS_X
int m_ROCS_X
Definition: RectangularPixelTopology.h:176
hcal_dqm_sourceclient-live_cfg.debugstr
debugstr
Definition: hcal_dqm_sourceclient-live_cfg.py:18
RectangularPixelTopology::m_ROWS_PER_ROC
int m_ROWS_PER_ROC
Definition: RectangularPixelTopology.h:174
align::LocalPoint
Point3DBase< Scalar, LocalTag > LocalPoint
Definition: Definitions.h:30
RectangularPixelTopology::m_pitchx
float m_pitchx
Definition: RectangularPixelTopology.h:168
RectangularPixelTopology::isItBigPixelInY
bool isItBigPixelInY(const int iybin) const override
Definition: RectangularPixelTopology.h:118
UNLIKELY
#define UNLIKELY(x)
Definition: Likely.h:21
RectangularPixelTopology::isItBigPixelInX
bool isItBigPixelInX(const int ixbin) const override
Definition: RectangularPixelTopology.h:114
LocalError::xx
float xx() const
Definition: LocalError.h:22
MeasurementError
Definition: MeasurementError.h:8
mps_fire.end
end
Definition: mps_fire.py:242
EPS
#define EPS
Definition: GammaContinuedFraction.cc:6
Point3DBase< float, LocalTag >
pfDeepBoostedJetPreprocessParams_cfi.lower_bound
lower_bound
Definition: pfDeepBoostedJetPreprocessParams_cfi.py:15
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
LocalError
Definition: LocalError.h:12
PV2DBase::y
T y() const
Definition: PV2DBase.h:44
PV2DBase::x
T x() const
Definition: PV2DBase.h:43
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
RectangularPixelTopology::m_ROCS_Y
int m_ROCS_Y
Definition: RectangularPixelTopology.h:177
createfilelist.int
int
Definition: createfilelist.py:10
RectangularPixelTopology::pixel
std::pair< float, float > pixel(const LocalPoint &p) const override
Definition: RectangularPixelTopology.cc:13
RectangularPixelTopology::m_ncols
int m_ncols
Definition: RectangularPixelTopology.h:173
RectangularPixelTopology::m_upgradeGeometry
bool m_upgradeGeometry
Definition: RectangularPixelTopology.h:178
RectangularPixelTopology::m_xoffset
float m_xoffset
Definition: RectangularPixelTopology.h:170
RectangularPixelTopology::localY
float localY(const float mpY) const override
Definition: RectangularPixelTopology.cc:249
multPhiCorr_741_25nsDY_cfi.px
px
Definition: multPhiCorr_741_25nsDY_cfi.py:10
RectangularPixelTopology::localX
float localX(const float mpX) const override
Definition: RectangularPixelTopology.cc:196
LIKELY
#define LIKELY(x)
Definition: Likely.h:20
RectangularPixelTopology::m_pitchy
float m_pitchy
Definition: RectangularPixelTopology.h:169
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
hlt_dqm_clientPB-live_cfg.me
me
Definition: hlt_dqm_clientPB-live_cfg.py:61
LocalError::yy
float yy() const
Definition: LocalError.h:24
RectangularPixelTopology::localError
LocalError localError(const MeasurementPoint &, const MeasurementError &) const override
Definition: RectangularPixelTopology.cc:288