13 std::pair<float,float> RectangularPixelTopology::pixel(
27 cout<<
" wrong lp y "<<py<<
" "<<m_yoffset<<endl;
28 py = m_yoffset + EPSCM;
31 cout<<
" wrong lp y "<<py<<
" "<<-m_yoffset<<endl;
32 py = -m_yoffset - EPSCM;
35 cout<<
" wrong lp x "<<px<<
" "<<m_xoffset<<endl;
36 px = m_xoffset + EPSCM;
39 cout<<
" wrong lp x "<<px<<
" "<<-m_xoffset<<endl;
40 px = -m_xoffset - EPSCM;
44 float newybin=(py - m_yoffset)/m_pitchy;
45 int iybin = int(newybin);
46 float fractionY = newybin - iybin;
50 int iybin0 = (iybin%54);
51 int numROC = iybin/54;
55 cout<<
" very bad, newbiny "<<iybin0<<endl;
56 cout<<py<<
" "<<m_yoffset<<
" "<<m_pitchy<<
" "
57 <<newybin<<
" "<<iybin<<
" "<<fractionY<<
" "<<iybin0<<
" "
60 }
else if (iybin0==53) {
62 fractionY = (fractionY+1.)/2.;
63 }
else if (iybin0==52) {
65 fractionY = fractionY/2.;
66 }
else if (iybin0>1) {
68 }
else if (iybin0==1) {
70 fractionY = (fractionY+1.)/2.;
71 }
else if (iybin0==0) {
73 fractionY = fractionY/2.;
76 cout<<
" very bad, newbiny "<<newybin<<endl;
77 cout<<py<<
" "<<m_yoffset<<
" "<<m_pitchy<<
" "
78 <<newybin<<
" "<<iybin<<
" "<<fractionY<<
" "
79 <<iybin0<<
" "<<numROC<<endl;
82 float mpY = float(numROC*52. + iybin0) + fractionY;
83 if(
TP_DEBUG && (mpY<0. || mpY>=416.)) {
84 cout<<
" bad pix y "<<mpY<<endl;
85 cout<<py<<
" "<<m_yoffset<<
" "<<m_pitchy<<
" "
86 <<newybin<<
" "<<iybin<<
" "<<fractionY<<
" "
87 <<iybin0<<
" "<<numROC<<endl;
91 float newxbin=(px - m_xoffset) / m_pitchx;
92 int ixbin = int(newxbin);
93 float fractionX = newxbin - ixbin;
102 cout<<
" very bad, newbinx "<<ixbin<<endl;
103 cout<<px<<
" "<<m_xoffset<<
" "<<m_pitchx<<
" "
104 <<newxbin<<
" "<<ixbin<<
" "<<fractionX<<endl;
106 }
else if (ixbin>82) {
108 }
else if (ixbin==82) {
110 fractionX = (fractionX+1.)/2.;
111 }
else if (ixbin==81) {
113 fractionX = fractionX/2.;
114 }
else if (ixbin==80) {
116 fractionX = (fractionX+1.)/2.;
117 }
else if (ixbin==79) {
119 fractionX = fractionX/2.;
120 }
else if (ixbin<0) {
122 cout<<
" very bad, newbinx "<<ixbin<<endl;
123 cout<<px<<
" "<<m_xoffset<<
" "<<m_pitchx<<
" "
124 <<newxbin<<
" "<<ixbin<<
" "<<fractionX<<endl;
128 float mpX = float(ixbin) + fractionX;
130 if(
TP_DEBUG && (mpX<0. || mpX>=160.) ) {
131 cout<<
" bad pix x "<<mpX<<
" "<<endl;
132 cout<<px<<
" "<<m_xoffset<<
" "<<m_pitchx<<
" "
133 <<newxbin<<
" "<<ixbin<<
" "<<fractionX<<endl;
136 return std::pair<float,float>(mpX,mpY);
141 LocalPoint RectangularPixelTopology::localPosition(
152 cout<<
" wrong mp y, fix "<<mpy<<
" "
157 cout<<
" wrong mp y, fix "<<mpy<<
" "
159 mpy = float(m_ncols) -
EPS;
162 cout<<
" wrong mp x, fix "<<mpx<<
" "
167 cout<<
" wrong mp x, fix "<<mpx<<
" "
169 mpx = float(m_nrows) -
EPS;
175 float lpY = localY(mpy);
279 float lpX = localX(mpx);
330 float RectangularPixelTopology::localX(
const float mpx)
const {
334 int binoffx=int(mpx);
335 float fractionX = mpx - binoffx;
336 float local_pitchx = m_pitchx;
341 }
else if (binoffx==80) {
343 local_pitchx = 2 * m_pitchx;
345 }
else if (binoffx==79) {
347 local_pitchx = 2 * m_pitchx;
348 }
else if (binoffx>=0) {
353 cout<<
" very bad, binx "<<binoffx<<endl;
354 cout<<mpx<<
" "<<binoffx<<
" "
355 <<fractionX<<
" "<<local_pitchx<<
" "<<m_xoffset<<endl;
360 float lpX = float(binoffx*m_pitchx) + fractionX*local_pitchx +
363 if(
TP_DEBUG && (lpX<m_xoffset || lpX>(-m_xoffset)) ) {
364 cout<<
" bad lp x "<<lpX<<endl;
365 cout<<mpx<<
" "<<binoffx<<
" "
366 <<fractionX<<
" "<<local_pitchx<<
" "<<m_xoffset<<endl;
374 float RectangularPixelTopology::localY(
const float mpy)
const {
377 int binoffy = int(mpy);
378 float fractionY = mpy - binoffy;
379 float local_pitchy = m_pitchy;
384 }
else if (binoffy==416) {
386 local_pitchy = 2 * m_pitchy;
388 }
else if (binoffy==415) {
390 local_pitchy = 2 * m_pitchy;
391 }
else if (binoffy>364) {
393 }
else if (binoffy==364) {
395 local_pitchy = 2 * m_pitchy;
397 }
else if (binoffy==363) {
399 local_pitchy = 2 * m_pitchy;
400 }
else if (binoffy>312) {
402 }
else if (binoffy==312) {
404 local_pitchy = 2 * m_pitchy;
406 }
else if (binoffy==311) {
408 local_pitchy = 2 * m_pitchy;
409 }
else if (binoffy>260) {
411 }
else if (binoffy==260) {
413 local_pitchy = 2 * m_pitchy;
415 }
else if (binoffy==259) {
417 local_pitchy = 2 * m_pitchy;
418 }
else if (binoffy>208) {
420 }
else if (binoffy==208) {
422 local_pitchy = 2 * m_pitchy;
424 }
else if (binoffy==207) {
426 local_pitchy = 2 * m_pitchy;
427 }
else if (binoffy>156) {
429 }
else if (binoffy==156) {
431 local_pitchy = 2 * m_pitchy;
433 }
else if (binoffy==155) {
435 local_pitchy = 2 * m_pitchy;
436 }
else if (binoffy>104) {
438 }
else if (binoffy==104) {
440 local_pitchy = 2 * m_pitchy;
442 }
else if (binoffy==103) {
444 local_pitchy = 2 * m_pitchy;
445 }
else if (binoffy>52) {
447 }
else if (binoffy==52) {
449 local_pitchy = 2 * m_pitchy;
451 }
else if (binoffy==51) {
453 local_pitchy = 2 * m_pitchy;
454 }
else if (binoffy>0) {
456 }
else if (binoffy==0) {
458 local_pitchy = 2 * m_pitchy;
461 cout<<
" very bad, biny "<<binoffy<<endl;
462 cout<<mpy<<
" "<<binoffy<<
" "
463 <<fractionY<<
" "<<local_pitchy<<
" "<<m_yoffset<<endl;
468 float lpY = float(binoffy*m_pitchy) + fractionY*local_pitchy +
470 if(
TP_DEBUG && (lpY<m_yoffset || lpY>(-m_yoffset)) ) {
471 cout<<
" bad lp y "<<lpY<<endl;
472 cout<<mpy<<
" "<<binoffy<<
" "
473 <<fractionY<<
" "<<local_pitchy<<
" "<<m_yoffset<<endl;
480 LocalError RectangularPixelTopology::localError(
483 float pitchy=m_pitchy;
484 int binoffy=int(mp.
y());
485 if( isItBigPixelInY(binoffy) )pitchy = 2.*m_pitchy;
487 float pitchx=m_pitchx;
488 int binoffx=int(mp.
x());
489 if( isItBigPixelInX(binoffx) )pitchx = 2.*m_pitchx;
492 me.
vv()*float(pitchy*pitchy));
500 float pitchy=m_pitchy;
501 int iybin = int( (lp.
y() - m_yoffset)/m_pitchy );
502 int iybin0 = iybin%54;
504 if(iybin0==0 || iybin0==1 || iybin0==52 || iybin0==53 )
505 pitchy = 2. * m_pitchy;
507 float pitchx=m_pitchx;
508 int ixbin = int( (lp.
x() - m_xoffset)/m_pitchx );
510 if(ixbin>=79 && ixbin<=82) pitchx = 2. * m_pitchx;
513 le.
yy()/float(pitchy*pitchy));
516 bool RectangularPixelTopology::containsBigPixelInX(
const int& ixmin,
const int& ixmax)
const {
518 for(
int i=ixmin;
i!=ixmax+1;
i++) {
519 if(isItBigPixelInX(
i) && big==
false) big=
true;
524 bool RectangularPixelTopology::containsBigPixelInY(
const int& iymin,
const int& iymax)
const {
526 for(
int i=iymin;
i!=iymax+1;
i++) {
527 if(isItBigPixelInY(
i) && big==
false) big=
true;