13 std::pair<float,float>
14 RectangularPixelTopology::pixel(
const LocalPoint&
p )
const
26 std::ostringstream debugstr;
27 debugstr <<
"py = " << py <<
", m_yoffset = " << m_yoffset
28 <<
"px = " << px <<
", m_xoffset = " << m_xoffset <<
"\n";
32 debugstr <<
" wrong lp y " << py <<
" " << m_yoffset <<
"\n";
33 py = m_yoffset + EPSCM;
37 debugstr <<
" wrong lp y " << py <<
" " << -m_yoffset <<
"\n";
38 py = -m_yoffset - EPSCM;
42 debugstr <<
" wrong lp x " << px <<
" " << m_xoffset <<
"\n";
43 px = m_xoffset + EPSCM;
47 debugstr <<
" wrong lp x " << px <<
" " << -m_xoffset <<
"\n";
48 px = -m_xoffset - EPSCM;
51 if( !debugstr.str().empty())
52 LogDebug(
"RectangularPixelTopology" ) << debugstr.str();
54 #endif // EDM_ML_DEBUG
56 float newybin = ( py - m_yoffset ) / m_pitchy;
57 int iybin = int( newybin );
58 float fractionY = newybin - iybin;
65 if( m_upgradeGeometry )
67 iybin0 = (iybin%m_COLS_PER_ROC);
68 numROC = iybin/m_COLS_PER_ROC;
69 mpY = float(numROC*m_COLS_PER_ROC + iybin0) + fractionY;
73 if( iybin0 > m_COLS_PER_ROC )
75 LogDebug(
"RectangularPixelTopology") <<
" very bad, newbiny " << iybin0 <<
"\n"
76 << py <<
" " << m_yoffset <<
" " << m_pitchy <<
" "
77 << newybin <<
" " << iybin <<
" " << fractionY <<
" " << iybin0 <<
" "
80 #endif // EDM_ML_DEBUG
90 fractionY = (fractionY+1.)/2.;
91 }
else if (iybin0==52) {
93 fractionY = fractionY/2.;
94 }
else if (iybin0>1) {
96 }
else if (iybin0==1) {
98 fractionY = (fractionY+1.)/2.;
99 }
else if (iybin0==0) {
101 fractionY = fractionY/2.;
104 mpY = float(numROC*52. + iybin0) + fractionY;
109 if( mpY < 0. || mpY >= 416. )
111 LogDebug(
"RectangularPixelTopology") <<
" bad pix y " << mpY <<
"\n"
112 << py <<
" " << m_yoffset <<
" " << m_pitchy <<
" "
113 << newybin <<
" " << iybin <<
" " << fractionY <<
" "
114 << iybin0 <<
" " << numROC;
116 #endif // EDM_ML_DEBUG
119 float newxbin = ( px - m_xoffset ) / m_pitchx;
120 int ixbin = int( newxbin );
121 float fractionX = newxbin - ixbin;
125 if( ixbin > 161 || ixbin < 0 )
127 LogDebug(
"RectangularPixelTopology") <<
" very bad, newbinx " << ixbin <<
"\n"
128 << px <<
" " << m_xoffset <<
" " << m_pitchx <<
" "
129 << newxbin <<
" " << ixbin <<
" " << fractionX;
131 #endif // EDM_ML_DEBUG
133 if( ! m_upgradeGeometry )
137 }
else if (ixbin==82) {
139 fractionX = (fractionX+1.)/2.;
140 }
else if (ixbin==81) {
142 fractionX = fractionX/2.;
143 }
else if (ixbin==80) {
145 fractionX = (fractionX+1.)/2.;
146 }
else if (ixbin==79) {
148 fractionX = fractionX/2.;
152 float mpX = float( ixbin ) + fractionX;
156 if( mpX < 0. || mpX >= 160. )
158 LogDebug(
"RectangularPixelTopology") <<
" bad pix x " << mpX <<
"\n"
159 << px <<
" " << m_xoffset <<
" " << m_pitchx <<
" "
160 << newxbin <<
" " << ixbin <<
" " << fractionX;
162 #endif // EDM_ML_DEBUG
164 return std::pair<float, float>( mpX, mpY );
178 std::ostringstream debugstr;
182 debugstr <<
" wrong mp y, fix " << mpy <<
" " << 0 <<
"\n";
187 debugstr <<
" wrong mp y, fix " << mpy <<
" " << m_ncols <<
"\n";
188 mpy = float(m_ncols) -
EPS;
192 debugstr <<
" wrong mp x, fix " << mpx <<
" " << 0 <<
"\n";
197 debugstr <<
" wrong mp x, fix " << mpx <<
" " << m_nrows <<
"\n";
198 mpx = float(m_nrows) -
EPS;
200 if(! debugstr.str().empty())
201 LogDebug(
"RectangularPixelTopology") << debugstr.str();
203 #endif // EDM_ML_DEBUG
205 float lpY = localY( mpy );
206 float lpX = localX( mpx );
217 RectangularPixelTopology::localX(
const float mpx )
const
219 int binoffx = int( mpx );
220 float fractionX = mpx - float(binoffx);
221 float local_pitchx = m_pitchx;
225 if( binoffx > m_ROWS_PER_ROC * `m_ROCS_X )
227 `
LogDebug(
"RectangularPixelTopology") <<
" very bad, binx " << binoffx <<
"\n"
228 << mpx <<
" " << binoffx <<
" "
229 << fractionX <<
" " << local_pitchx <<
" " << m_xoffset <<
"\n";
235 }
else if (binoffx==80) {
238 }
else if (binoffx==79) {
248 LogDebug(
"RectangularPixelTopology") <<
" very bad, binx " << binoffx <<
"\n"
249 << mpx <<
" " << binoffx <<
" "
250 << fractionX <<
" " << local_pitchx <<
" " << m_xoffset;
255 float lpX = float( binoffx * m_pitchx ) + fractionX * local_pitchx + m_xoffset;
259 if( lpX < m_xoffset || lpX > ( -m_xoffset ))
261 LogDebug(
"RectangularPixelTopology") <<
" bad lp x " << lpX <<
"\n"
262 << mpx <<
" " << binoffx <<
" "
263 << fractionX <<
" " << local_pitchx <<
" " << m_xoffset;
265 #endif // EDM_ML_DEBUG
273 RectangularPixelTopology::localY(
const float mpy )
const
275 int binoffy = int( mpy );
276 float fractionY = mpy - float(binoffy);
277 float local_pitchy = m_pitchy;
281 if( binoffy > m_ROCS_Y * m_COLS_PER_ROC )
283 LogDebug(
"RectangularPixelTopology" ) <<
" very bad, biny " << binoffy <<
"\n"
284 << mpy <<
" " << binoffy <<
" " << fractionY
285 <<
" " << local_pitchy <<
" " << m_yoffset;
289 constexpr int bigYIndeces[]{0,51,52,103,104,155,156,207,208,259,260,311,312,363,364,415,416,511};
291 if (*
j==binoffy) local_pitchy *= 2 ;
292 binoffy += (
j-bigYIndeces);
296 float lpY = float(binoffy*m_pitchy) + fractionY*local_pitchy + m_yoffset;
300 if( lpY < m_yoffset || lpY > ( -m_yoffset ))
302 LogDebug(
"RectangularPixelTopology" ) <<
" bad lp y " << lpY <<
"\n"
303 << mpy <<
" " << binoffy <<
" "
304 << fractionY <<
" " << local_pitchy <<
" " << m_yoffset;
306 #endif // EDM_ML_DEBUG
317 float pitchy=m_pitchy;
318 int binoffy=int(mp.
y());
319 if( isItBigPixelInY(binoffy) )pitchy = 2.*m_pitchy;
321 float pitchx=m_pitchx;
322 int binoffx=int(mp.
x());
323 if( isItBigPixelInX(binoffx) )pitchx = 2.*m_pitchx;
326 me.
vv()*float(pitchy*pitchy));
332 RectangularPixelTopology::measurementError(
const LocalPoint& lp,
335 float pitchy=m_pitchy;
336 float pitchx=m_pitchx;
338 if likely( !m_upgradeGeometry ) {
339 int iybin = int( (lp.
y() - m_yoffset)/m_pitchy );
340 int iybin0 = iybin%54;
342 if( (iybin0<=1) | (iybin0>=52) )
343 pitchy = 2.f * m_pitchy;
345 int ixbin = int( (lp.
x() - m_xoffset)/m_pitchx );
347 if( (ixbin>=79) & (ixbin<=82) ) pitchx = 2.f * m_pitchx;
351 le.
yy()/float(pitchy*pitchy));