CMS 3D CMS Logo

RectangularPixelPhase2Topology.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> RectangularPixelPhase2Topology::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("RectangularPixelPhase2Topology") << debugstr.str();
49 #endif // EDM_ML_DEBUG
50 
51  float newybin = py - m_yoffset; // m_pitchy;
52  int iybin = 0; //int(newybin);
53  float fractionY = 0; //newybin - iybin;
54  int iybin0 = 0;
55  float mpY = 0.;
56 
57  if ((newybin >= m_pitchy * (m_ncols / 2 - m_BIG_PIX_PER_ROC_Y)) &&
58  (newybin < (m_pitchy * (m_ncols / 2 - m_BIG_PIX_PER_ROC_Y) +
60  iybin = m_ncols / 2 - m_BIG_PIX_PER_ROC_Y;
61  iybin0 = iybin;
62  fractionY = (newybin - m_pitchy * (m_ncols / 2 - m_BIG_PIX_PER_ROC_Y)) / m_BIG_PIX_PITCH_Y;
63  } else if ((newybin >= (m_pitchy * (m_ncols / 2 - m_BIG_PIX_PER_ROC_Y) +
65  iybin = int((newybin - (m_pitchy * (m_ncols / 2 - m_BIG_PIX_PER_ROC_Y) +
67  m_pitchy) +
69  iybin0 = iybin - m_ncols / 2;
70  fractionY = (newybin - (m_pitchy * (m_ncols / 2 - m_BIG_PIX_PER_ROC_Y) +
72  (iybin0 - m_BIG_PIX_PER_ROC_Y) * m_pitchy)) /
73  m_pitchy;
74  } else {
75  iybin = int(newybin / m_pitchy);
76  iybin0 = iybin;
77  fractionY = newybin / m_pitchy - iybin;
78  }
79 
80  mpY = fractionY + iybin;
81 #ifdef EDM_ML_DEBUG
82 
83  if (iybin0 > m_COLS_PER_ROC) {
84  LogDebug("RectangularPixelPhase2Topology") << " very bad, newbiny " << iybin0 << "\n"
85  << py << " " << m_yoffset << " " << m_pitchy << " " << newybin << " "
86  << iybin << " " << fractionY << " " << iybin0 << " " << m_COLS_PER_ROC;
87  }
88 #endif // EDM_ML_DEBUG
89 
90 #ifdef EDM_ML_DEBUG
91 
92  if (mpY < 0. || mpY >= 2 * m_COLS_PER_ROC) {
93  LogDebug("RectangularPixelPhase2Topology")
94  << " bad pix y " << mpY << "\n"
95  << py << " " << m_yoffset << " " << m_pitchy << " " << newybin << " " << iybin << " " << fractionY << " "
96  << iybin0 << " " << 2 * m_COLS_PER_ROC;
97  }
98 #endif // EDM_ML_DEBUG
99 
100  // In X
101  float newxbin = (px - m_xoffset);
102  int ixbin = 0;
103  float fractionX = 0;
104  int ixbin0 = 0;
105  float mpX = 0.;
106 
107  if ((newxbin >= m_pitchx * (m_nrows / 2 - m_BIG_PIX_PER_ROC_X)) &&
108  (newxbin < (m_pitchx * (m_nrows / 2 - m_BIG_PIX_PER_ROC_X) +
110  ixbin = m_nrows / 2 - m_BIG_PIX_PER_ROC_X;
111  ixbin0 = ixbin;
112  fractionX = (newxbin - m_pitchx * (m_nrows / 2 - m_BIG_PIX_PER_ROC_X)) / m_BIG_PIX_PITCH_X;
113  } else if ((newxbin >= (m_pitchx * (m_nrows / 2 - m_BIG_PIX_PER_ROC_X) +
115  ixbin = int((newxbin - (m_pitchx * (m_nrows / 2 - m_BIG_PIX_PER_ROC_X) +
117  m_pitchx) +
119  ixbin0 = ixbin - m_nrows / 2;
120  fractionX = (newxbin - (m_pitchx * (m_nrows / 2 - m_BIG_PIX_PER_ROC_X) +
122  (ixbin0 - m_BIG_PIX_PER_ROC_X) * m_pitchx)) /
123  m_pitchx;
124  } else {
125  ixbin = int(newxbin / m_pitchx);
126  ixbin0 = ixbin;
127  fractionX = newxbin / m_pitchx - ixbin;
128  }
129 
130  mpX = fractionX + ixbin;
131 
132 #ifdef EDM_ML_DEBUG
133 
134  if (ixbin0 > m_ROWS_PER_ROC || ixbin0 < 0) // ixbin < 0 outside range
135  {
136  LogDebug("RectangularPixelPhase2Topology")
137  << " very bad, newbinx " << ixbin << "\n"
138  << px << " " << m_xoffset << " " << m_pitchx << " " << newxbin << " " << ixbin << " " << fractionX;
139  }
140 #endif // EDM_ML_DEBUG
141 
142 #ifdef EDM_ML_DEBUG
143 
144  if (mpX < 0. || mpX >= 2 * m_ROWS_PER_ROC) {
145  LogDebug("RectangularPixelPhase2Topology")
146  << " bad pix x " << mpX << "\n"
147  << px << " " << m_xoffset << " " << m_pitchx << " " << newxbin << " " << ixbin << " " << fractionX;
148  }
149 #endif // EDM_ML_DEBUG
150 
151  return std::pair<float, float>(mpX, mpY);
152 }
153 
154 //----------------------------------------------------------------------
155 // Topology interface, go from Masurement to Local corrdinates
156 // pixel coordinates (mp) -> cm (LocalPoint)
158  float mpy = mp.y(); // measurements
159  float mpx = mp.x();
160 
161 #ifdef EDM_ML_DEBUG
162 #define EPS 0
163  // check limits
164  std::ostringstream debugstr;
165 
166  if (mpy < 0.) {
167  debugstr << " wrong mp y, fix " << mpy << " " << 0 << "\n";
168  mpy = 0.;
169  }
170  if (mpy >= m_ncols) {
171  debugstr << " wrong mp y, fix " << mpy << " " << m_ncols << "\n";
172  mpy = float(m_ncols) - EPS; // EPS is a small number
173  }
174  if (mpx < 0.) {
175  debugstr << " wrong mp x, fix " << mpx << " " << 0 << "\n";
176  mpx = 0.;
177  }
178  if (mpx >= m_nrows) {
179  debugstr << " wrong mp x, fix " << mpx << " " << m_nrows << "\n";
180  mpx = float(m_nrows) - EPS; // EPS is a small number
181  }
182  if (!debugstr.str().empty())
183  LogDebug("RectangularPixelPhase2Topology") << debugstr.str();
184 #endif // EDM_ML_DEBUG
185 
186  float lpY = localY(mpy);
187  float lpX = localX(mpx);
188 
189  // Return it as a LocalPoint
190  return LocalPoint(lpX, lpY);
191 }
192 
193 //--------------------------------------------------------------------
194 //
195 // measurement to local transformation for X coordinate
196 // X coordinate is in the ROC row number direction
197 float RectangularPixelPhase2Topology::localX(const float mpx) const {
198  int binoffx = int(mpx); // truncate to int
199  float fractionX = mpx - float(binoffx); // find the fraction
200  float local_pitchx = m_pitchx; // defaultpitch
201  int ispix_secondhalf_x = 0;
202 
203  if (binoffx >= (m_nrows / 2 - 2 + 2 * m_nrows / m_ROWS_PER_ROC)) { // ROC 1 - handles x on edge cluster
204  binoffx = binoffx - 2 * m_nrows / m_ROWS_PER_ROC;
205  ispix_secondhalf_x = 1;
206  } else if (((m_nrows / 2 - 2) <= binoffx) && (binoffx < (m_nrows / 2 - 2 + 2 * m_nrows / m_ROWS_PER_ROC))) { // ROC 1
207  binoffx = m_nrows / 2 - 2;
208  fractionX = mpx - float(m_nrows / 2 - 2);
209  local_pitchx = m_BIG_PIX_PITCH_X;
210  }
211 
212 #ifdef EDM_ML_DEBUG
213  if (binoffx > m_ROWS_PER_ROC * m_ROCS_X) // too large
214  {
215  LogDebug("RectangularPixelPhase2Topology")
216  << " very bad, binx " << binoffx << "\n"
217  << mpx << " " << binoffx << " " << fractionX << " " << local_pitchx << " " << m_xoffset << "\n";
218  }
219 #endif
220 
221  // The final position in local coordinates
222  float lpX = float(binoffx * m_pitchx) + fractionX * local_pitchx +
223  ispix_secondhalf_x * 2 * m_BIG_PIX_PITCH_X * m_nrows / m_ROWS_PER_ROC + m_xoffset;
224 
225 #ifdef EDM_ML_DEBUG
226 
227  if (lpX < m_xoffset || lpX > (-m_xoffset)) {
228  LogDebug("RectangularPixelPhase2Topology")
229  << " bad lp x " << lpX << "\n"
230  << mpx << " " << binoffx << " " << fractionX << " " << local_pitchx << " " << m_xoffset;
231  }
232 #endif // EDM_ML_DEBUG
233 
234  return lpX;
235 }
236 
237 // measurement to local transformation for Y coordinate
238 // Y is in the ROC column number direction
239 float RectangularPixelPhase2Topology::localY(const float mpy) const {
240  int binoffy = int(mpy); // truncate to int
241  float fractionY = mpy - float(binoffy); // find the fraction
242  float local_pitchy = m_pitchy; // defaultpitch
243  int ispix_secondhalf_y = 0;
244 
245  if (binoffy >= (m_ncols / 2 - 1 + m_ncols / m_COLS_PER_ROC)) { // ROC 1 - handles x on edge cluster
246  binoffy = binoffy - m_ncols / m_COLS_PER_ROC;
247  ispix_secondhalf_y = 1;
248  } else if (((m_ncols / 2 - 1) <= binoffy) && (binoffy < (m_ncols / 2 - 1 + m_ncols / m_COLS_PER_ROC))) { // ROC 1
249  binoffy = m_ncols / 2 - 1;
250  fractionY = mpy - float(m_ncols / 2 - 1);
251  local_pitchy = m_BIG_PIX_PITCH_Y;
252  }
253 
254 #ifdef EDM_ML_DEBUG
255  if (binoffy > m_ROCS_Y * m_COLS_PER_ROC) // too large
256  {
257  LogDebug("RectangularPixelPhase2Topology")
258  << " very bad, biny " << binoffy << "\n"
259  << mpy << " " << binoffy << " " << fractionY << " " << local_pitchy << " " << m_yoffset;
260  }
261 #endif
262 
263  // The final position in local coordinates // using an int to switch first or second half of the module.
264  float lpY = float(binoffy * m_pitchy) + fractionY * local_pitchy +
265  ispix_secondhalf_y * m_BIG_PIX_PITCH_Y * m_ncols / m_COLS_PER_ROC + m_yoffset;
266 
267 #ifdef EDM_ML_DEBUG
268 
269  if (lpY < m_yoffset || lpY > (-m_yoffset)) {
270  LogDebug("RectangularPixelPhase2Topology")
271  << " bad lp y " << lpY << "\n"
272  << mpy << " " << binoffy << " " << fractionY << " " << local_pitchy << " " << m_yoffset;
273  }
274 #endif // EDM_ML_DEBUG
275 
276  return lpY;
277 }
278 
280 // Get hit errors in LocalPoint coordinates (cm)
282  float pitchy = m_pitchy;
283  int binoffy = int(mp.y());
284  if (isItBigPixelInY(binoffy))
285  pitchy = 2. * m_pitchy;
286 
287  float pitchx = m_pitchx;
288  int binoffx = int(mp.x());
289  if (isItBigPixelInX(binoffx))
290  pitchx = 2. * m_pitchx;
291 
292  return LocalError(me.uu() * float(pitchx * pitchx), 0, me.vv() * float(pitchy * pitchy));
293 }
294 
296 // Get errors in pixel pitch units.
298  float pitchy = m_pitchy;
299  float pitchx = m_pitchx;
300 
301  return MeasurementError(le.xx() / float(pitchx * pitchx), 0, le.yy() / float(pitchy * pitchy));
302 }
Point3DBase< Scalar, LocalTag > LocalPoint
Definition: Definitions.h:30
float localX(const float mpX) const override
#define EPS
bool isItBigPixelInY(const int iybin) const override
T x() const
Definition: PV2DBase.h:43
MeasurementError measurementError(const LocalPoint &, const LocalError &) const override
T y() const
Definition: PV2DBase.h:44
float yy() const
Definition: LocalError.h:24
std::pair< float, float > pixel(const LocalPoint &p) const override
LocalPoint localPosition(const MeasurementPoint &mp) const override
bool isItBigPixelInX(const int ixbin) const override
float localY(const float mpY) const override
LocalError localError(const MeasurementPoint &, const MeasurementError &) const override
float xx() const
Definition: LocalError.h:22
#define LogDebug(id)