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 
201  if
203 #ifdef EDM_ML_DEBUG
204  if (binoffx > m_ROWS_PER_ROC * m_ROCS_X) // too large
205  {
206  LogDebug("RectangularPixelTopology")
207  << " very bad, binx " << binoffx << "\n"
208  << mpx << " " << binoffx << " " << fractionX << " " << local_pitchx << " " << m_xoffset << "\n";
209  }
210 #endif
211  }
212  else {
213  if (binoffx > 80) { // ROC 1 - handles x on edge cluster
214  binoffx = binoffx + 2;
215  } else if (binoffx == 80) { // ROC 1
216  binoffx = binoffx + 1;
217  local_pitchx *= 2;
218  } else if (binoffx == 79) { // ROC 0
219  binoffx = binoffx + 0;
220  local_pitchx *= 2;
221  }
222  // else if (binoffx>=0) { // ROC 0
223  // binoffx=binoffx+0;
224  // }
225 
226 #ifdef EDM_ML_DEBUG
227  if (binoffx < 0) // too small
228  LogDebug("RectangularPixelTopology")
229  << " very bad, binx " << binoffx << "\n"
230  << mpx << " " << binoffx << " " << fractionX << " " << local_pitchx << " " << m_xoffset;
231 #endif
232  }
233 
234  // The final position in local coordinates
235  float lpX = float(binoffx * m_pitchx) + fractionX * local_pitchx + m_xoffset;
236 
237 #ifdef EDM_ML_DEBUG
238 
239  if (lpX < m_xoffset || lpX > (-m_xoffset)) {
240  LogDebug("RectangularPixelTopology") << " bad lp x " << lpX << "\n"
241  << mpx << " " << binoffx << " " << fractionX << " " << local_pitchx << " "
242  << m_xoffset;
243  }
244 #endif // EDM_ML_DEBUG
245 
246  return lpX;
247 }
248 
249 // measuremet to local transformation for Y coordinate
250 // Y is in the ROC column number direction
251 float RectangularPixelTopology::localY(const float mpy) const {
252  int binoffy = int(mpy); // truncate to int
253  float fractionY = mpy - float(binoffy); // find the fraction
254  float local_pitchy = m_pitchy; // defaultpitch
255 
256  if
258 #ifdef EDM_ML_DEBUG
259  if (binoffy > m_ROCS_Y * m_COLS_PER_ROC) // too large
260  {
261  LogDebug("RectangularPixelTopology")
262  << " very bad, biny " << binoffy << "\n"
263  << mpy << " " << binoffy << " " << fractionY << " " << local_pitchy << " " << m_yoffset;
264  }
265 #endif
266  }
267  else { // 415 is last big pixel, 416 and above do not exists!
268  constexpr int bigYIndeces[]{0, 51, 52, 103, 104, 155, 156, 207, 208, 259, 260, 311, 312, 363, 364, 415, 416, 511};
269  auto const j = std::lower_bound(std::begin(bigYIndeces), std::end(bigYIndeces), binoffy);
270  if (*j == binoffy)
271  local_pitchy *= 2;
272  binoffy += (j - bigYIndeces);
273  }
274 
275  // The final position in local coordinates
276  float lpY = float(binoffy * m_pitchy) + fractionY * local_pitchy + m_yoffset;
277 
278 #ifdef EDM_ML_DEBUG
279 
280  if (lpY < m_yoffset || lpY > (-m_yoffset)) {
281  LogDebug("RectangularPixelTopology") << " bad lp y " << lpY << "\n"
282  << mpy << " " << binoffy << " " << fractionY << " " << local_pitchy << " "
283  << m_yoffset;
284  }
285 #endif // EDM_ML_DEBUG
286 
287  return lpY;
288 }
289 
291 // Get hit errors in LocalPoint coordinates (cm)
293  float pitchy = m_pitchy;
294  int binoffy = int(mp.y());
295  if (isItBigPixelInY(binoffy))
296  pitchy = 2. * m_pitchy;
297 
298  float pitchx = m_pitchx;
299  int binoffx = int(mp.x());
300  if (isItBigPixelInX(binoffx))
301  pitchx = 2. * m_pitchx;
302 
303  return LocalError(me.uu() * float(pitchx * pitchx), 0, me.vv() * float(pitchy * pitchy));
304 }
305 
307 // Get errors in pixel pitch units.
309  float pitchy = m_pitchy;
310  float pitchx = m_pitchx;
311 
312  if
314  int iybin = int((lp.y() - m_yoffset) / m_pitchy); //get bin for equal picth
315  int iybin0 = iybin % 54; //This is just to avoid many ifs by using the periodicy
316  //quasi bins 0,1,52,53 fall into larger pixels
317  if ((iybin0 <= 1) | (iybin0 >= 52))
318  pitchy = 2.f * m_pitchy;
319 
320  int ixbin = int((lp.x() - m_xoffset) / m_pitchx); //get bin for equal pitch
321  //quasi bins 79,80,81,82 fall into the 2 larger pixels
322  if ((ixbin >= 79) & (ixbin <= 82))
323  pitchx = 2.f * m_pitchx;
324  }
325 
326  return MeasurementError(le.xx() / float(pitchx * pitchx), 0, le.yy() / float(pitchy * pitchy));
327 }
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:308
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
EPSCM
#define EPSCM
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
end
#define end
Definition: vmac.h:39
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
EPS
#define EPS
Definition: GammaContinuedFraction.cc:6
Point3DBase< float, LocalTag >
cuda_std::lower_bound
__host__ constexpr __device__ RandomIt lower_bound(RandomIt first, RandomIt last, const T &value, Compare comp={})
Definition: cudastdAlgorithm.h:27
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
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:251
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:56
LocalError::yy
float yy() const
Definition: LocalError.h:24
begin
#define begin
Definition: vmac.h:32
RectangularPixelTopology::localError
LocalError localError(const MeasurementPoint &, const MeasurementError &) const override
Definition: RectangularPixelTopology.cc:292