diff --git a/slsDetectorCalibration/interpolations/slsInterpolation.h b/slsDetectorCalibration/interpolations/slsInterpolation.h index 6b0d2393b..958f8ce0a 100644 --- a/slsDetectorCalibration/interpolations/slsInterpolation.h +++ b/slsDetectorCalibration/interpolations/slsInterpolation.h @@ -196,11 +196,12 @@ class slsInterpolation /* cluster[2]=cl+6; */ sum=0; + int xoff=0, yoff=0; +#ifndef WRITE_QUAD double sumBL=0; double sumTL=0; double sumBR=0; double sumTR=0; - int xoff=0, yoff=0; for (int ix=0; ix<3; ix++) { for (int iy=0; iy<3; iy++) { sum+=cl[ix+3*iy]; @@ -220,34 +221,95 @@ class slsInterpolation if(sumTL >= totquad){ - /* sDum[0][0] = cluster[1][0]; sDum[1][0] = cluster[2][0]; */ - /* sDum[0][1] = cluster[1][1]; sDum[1][1] = cluster[2][1]; */ - +/* #ifdef WRITE_QUAD */ +/* /\* sDum[0][0] = cluster[1][0]; sDum[1][0] = cluster[2][0]; *\/ */ +/* /\* sDum[0][1] = cluster[1][1]; sDum[1][1] = cluster[2][1]; *\/ */ +/* if (sumTL ==sum) { */ +/* #endif */ corner = TOP_LEFT; totquad=sumTL; xoff=0; yoff=1; +/* #ifdef WRITE_QUAD */ +/* } */ +/* #endif */ } if(sumBR >= totquad){ /* sDum[0][0] = cluster[0][1]; sDum[1][0] = cluster[1][1]; */ /* sDum[0][1] = cluster[0][2]; sDum[1][1] = cluster[1][2]; */ +/* #ifdef WRITE_QUAD */ +/* /\* sDum[0][0] = cluster[1][0]; sDum[1][0] = cluster[2][0]; *\/ */ +/* /\* sDum[0][1] = cluster[1][1]; sDum[1][1] = cluster[2][1]; *\/ */ +/* if (sumBR ==sum) { */ +/* #endif */ + corner = BOTTOM_RIGHT; xoff=1; yoff=0; - corner = BOTTOM_RIGHT; totquad=sumBR; +/* #ifdef WRITE_QUAD */ +/* } */ +/* #endif */ } if(sumTR >= totquad){ +/* #ifdef WRITE_QUAD */ +/* /\* sDum[0][0] = cluster[1][0]; sDum[1][0] = cluster[2][0]; *\/ */ +/* /\* sDum[0][1] = cluster[1][1]; sDum[1][1] = cluster[2][1]; *\/ */ +/* if (sumTR ==sum) { */ +/* #endif */ xoff=1; yoff=1; /* sDum[0][0] = cluster[1][1]; sDum[1][0] = cluster[2][1]; */ /* sDum[0][1] = cluster[1][2]; sDum[1][1] = cluster[2][2]; */ corner = TOP_RIGHT; totquad=sumTR; +/* #ifdef WRITE_QUAD */ +/* } */ +/* #endif */ } + +#endif +#ifdef WRITE_QUAD + + double sumB=0; + double sumT=0; + double sumR=0; + double sumL=0; + + for (int ix=0; ix<3; ix++) { + for (int iy=0; iy<3; iy++) { + sum+=cl[ix+3*iy]; + if (ix<1 ) sumL+=cl[ix+iy*3]; + if (ix>1) sumR+=cl[ix+iy*3]; + if (iy<1) sumB=cl[ix+iy*3]; + if (iy>1) sumT+=cl[ix+iy*3]; + } + } + totquad=sum; + if ( sumT==0 && sumR==0) { + corner = BOTTOM_LEFT; + xoff=0; + yoff=0; + } else if ( sumB==0 && sumR==0 ) { + corner = TOP_LEFT; + xoff=0; + yoff=1; + } else if ( sumT==0 && sumL==0) { + corner = BOTTOM_RIGHT; + xoff=1; + yoff=0; + } else if ( sumB==0 && sumL==0) { + xoff=1; + yoff=1; + corner = TOP_RIGHT; + } else + printf("** bad 2x2 cluster!\n"); + +#endif + for (int ix=0; ix<2; ix++) { for (int iy=0; iy<2; iy++) { diff --git a/slsDetectorCalibration/moenchExecutables/Makefile.cluster_finder_rect_rh7 b/slsDetectorCalibration/moenchExecutables/Makefile.cluster_finder_rect_rh7 index 7eb1d2c9f..730b092b7 100644 --- a/slsDetectorCalibration/moenchExecutables/Makefile.cluster_finder_rect_rh7 +++ b/slsDetectorCalibration/moenchExecutables/Makefile.cluster_finder_rect_rh7 @@ -12,12 +12,12 @@ MAIN=moench03ClusterFinder.cpp #-lhdf5 #DESTDIR?=../bin -all: moenchClusterFinderRect moenchMakeEtaRect moenchInterpolationRect moenchNoInterpolationRect moenchPhotonCounterRect moenchAnalogRect +all: moenchClusterFinderRect moenchMakeEtaRect moenchInterpolationRect moenchNoInterpolationRect moenchPhotonCounterRect moenchAnalogRect moenchMakeEtaRect1 moenchInterpolationRect1 moenchClusterFinderRect: moench03ClusterFinder.cpp $(INCS) clean - g++ -o moenchClusterFinderRect moench03ClusterFinder.cpp $(LDFLAG) $(INCDIR) -DSAVE_ALL -DNEWRECEIVER -DRECT + g++ -o moenchClusterFinderRect moench03ClusterFinder.cpp $(LDFLAG) $(INCDIR) -DSAVE_ALL -DNEWRECEIVER -DRECT moenchMakeEtaRect: moench03Interpolation.cpp $(INCS) clean g++ -o moenchMakeEtaRect moench03Interpolation.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DFF -DRECT @@ -34,6 +34,12 @@ moenchPhotonCounterRect: moenchPhotonCounter.cpp $(INCS) clean moenchAnalogRect: moenchPhotonCounter.cpp $(INCS) clean g++ -o moenchAnalogRect moenchPhotonCounter.cpp $(LDFLAG) $(INCDIR) -DNEWRECEIVER -DANALOG -DRECT +moenchMakeEtaRect1: moench03Interpolation.cpp $(INCS) clean + g++ -o moenchMakeEtaRect1 moench03Interpolation.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DFF -DRECT -DRECT1 + +moenchInterpolationRect1: moench03Interpolation.cpp $(INCS) clean + g++ -o moenchInterpolationRect1 moench03Interpolation.cpp $(LDFLAG) $(INCDIR) -DRECT -DRECT1 + clean: rm -f moenchClusterFinderRect moenchMakeEtaRect moenchInterpolationRect moenchNoInterpolationRect moenchPhotonCounterRect moenchAnalogRect diff --git a/slsDetectorCalibration/moenchExecutables/moench03Interpolation.cpp b/slsDetectorCalibration/moenchExecutables/moench03Interpolation.cpp index ca6bf5d4e..76ce75739 100644 --- a/slsDetectorCalibration/moenchExecutables/moench03Interpolation.cpp +++ b/slsDetectorCalibration/moenchExecutables/moench03Interpolation.cpp @@ -5,7 +5,7 @@ //#include "moench03T1ZmqData.h" //#define DOUBLE_SPH //#define MANYFILES - +#define WRITE_QUAD #ifdef DOUBLE_SPH #include "single_photon_hit_double.h" #endif @@ -101,10 +101,14 @@ int main(int argc, char *argv[]) { #endif int nSubPixels=nsubpix; int nSubPixelsY=nsubpix; -#ifdef RECT - nSubPixels=1; //might make more sense using 2? - etabins=2; +#ifdef RECT1 +// nSubPixels=2; //might make more sense using 2? +// etabins=100; + + + float *rectimg=new float[NC*NR*nSubPixelsY];; #endif +// #endif #ifndef NOINTERPOLATION eta2InterpolationPosXY *interp=new eta2InterpolationPosXY(NC, NR, nSubPixels, nSubPixelsY, etabins, etabinsY, etamin, etamax); //eta2InterpolationCleverAdaptiveBins *interp=new eta2InterpolationCleverAdaptiveBins(NC, NR, nsubpix, etabins, etamin, etamax); @@ -172,6 +176,8 @@ int main(int argc, char *argv[]) { // #ifdef SOLEIL // if (cl.x>210 && cl.x<240 && cl.y>210 && cl.y<240) { // #endif + if (cl.x<0 || cl.y<0 || cl.x>NC || cl.y>NR) { + } else { #ifndef FF // interp->getInterpolatedPosition(cl.x,cl.y, cl.get_cluster(),int_x, int_y); interp->getInterpolatedPosition(cl.x,cl.y, etax, etay, quad,int_x, int_y); @@ -181,14 +187,14 @@ int main(int argc, char *argv[]) { // cout << int_x << " " << int_y << endl; // cout <<"**************"<< endl; // if (etax!=0 && etay!=0 && etax!=1 && etay!=1) - interp->addToImage(int_x, int_y); - if (int_x<0 || int_y<0 || int_x>NC || int_y>NR) { - cout <<"**************"<< endl; - cout << cl.x << " " << cl.y << " " << sum << endl; - cl.print(); - cout << int_x << " " << int_y << endl; - cout <<"**************"<< endl; - } + if (int_x<-1 || int_y<-1 || int_x>NC+1 || int_y>NR+1) { + cout <<"**************"<< endl; + cout << cl.x << " " << cl.y << " " << sum << endl; + cl.print(); + cout << int_x << " " << int_y << endl; + cout <<"**************"<< endl; + } else + interp->addToImage(int_x, int_y); #endif #ifdef FF // interp->addToFlatField(cl.get_cluster(), etax, etay); @@ -200,6 +206,7 @@ int main(int argc, char *argv[]) { // if (etax==0 || etay==0) cout << cl.x << " " << cl.y << endl; #endif + } // #ifdef SOLEIL // } // #endif @@ -225,18 +232,31 @@ int main(int argc, char *argv[]) { #endif #ifndef FF +#ifndef RECT1 interp->writeInterpolatedImage(outfname); - +#endif img=interp->getInterpolatedImage(); for (ix=0; ix