diff --git a/slsDetectorCalibration/interpolations/eta2InterpolationBase.h b/slsDetectorCalibration/interpolations/eta2InterpolationBase.h index ed6f8dbad..afd4ada93 100644 --- a/slsDetectorCalibration/interpolations/eta2InterpolationBase.h +++ b/slsDetectorCalibration/interpolations/eta2InterpolationBase.h @@ -13,7 +13,7 @@ class eta2InterpolationBase : public virtual etaInterpolationBase { public: - eta2InterpolationBase(int nx=400, int ny=400, int ns=25, int nb=-1, double emin=1, double emax=0) : etaInterpolationBase(nx,ny, ns, nb, emin, emax) { + eta2InterpolationBase(int nx=400, int ny=400, int ns=25, int nsy=25, int nb=-1, int nby=-1, double emin=1, double emax=0) : etaInterpolationBase(nx,ny, ns, nsy, nb, nby, emin, emax) { /* if (etamin>=etamax) { */ /* etamin=-1; */ @@ -37,7 +37,7 @@ class eta2InterpolationBase : public virtual etaInterpolationBase { int corner; corner=calcQuad(data, tot, totquad, sDum); - if (nSubPixels>2) + if (nSubPixelsX>2 || nSubPixelsY>2) calcEta(totquad, sDum, etax, etay); getInterpolatedPosition(x,y,etax,etay,corner,int_x,int_y); @@ -53,7 +53,7 @@ class eta2InterpolationBase : public virtual etaInterpolationBase { int corner; corner=calcQuad(data, tot, totquad, sDum); - if (nSubPixels>2) + if (nSubPixelsX>2 || nSubPixelsY>2 ) calcEta(totquad, sDum, etax, etay); getInterpolatedPosition(x,y,etax,etay,corner,int_x,int_y); @@ -93,7 +93,7 @@ class eta2InterpolationBase : public virtual etaInterpolationBase { ; } double etax=0, etay=0; - if (nSubPixels>2) { + if (nSubPixelsX>2 || nSubPixelsY>2) { cc[0][0]=cl[xoff+3*yoff]; cc[1][0]=cl[xoff+3*(yoff+1)]; cc[0][1]=cl[xoff+1+3*yoff]; @@ -133,7 +133,7 @@ class eta2InterpolationBase : public virtual etaInterpolationBase { ; } double etax=0, etay=0; - if (nSubPixels>2) { + if (nSubPixelsX>2 || nSubPixelsY>2) { cc[0][0]=cl[xoff+3*yoff]; cc[1][0]=cl[xoff+3*(yoff+1)]; cc[0][1]=cl[xoff+1+3*yoff]; @@ -182,31 +182,31 @@ class eta2InterpolationBase : public virtual etaInterpolationBase { } - if (nSubPixels>2) { + if (nSubPixelsX>2 || nSubPixelsY>2 ) { - ex=(etax-etamin)/etastep; - ey=(etay-etamin)/etastep; + ex=(etax-etamin)/etastepX; + ey=(etay-etamin)/etastepY; if (ex<0) { cout << "x*"<< ex << endl; ex=0; } - if (ex>=nbeta) { + if (ex>=nbetaX) { cout << "x?"<< ex << endl; - ex=nbeta-1; + ex=nbetaX-1; } if (ey<0) { cout << "y*"<< ey << endl; ey=0; } - if (ey>=nbeta) { + if (ey>=nbetaY) { cout << "y?"<< ey << endl; - ey=nbeta-1; + ey=nbetaY-1; } - xpos_eta=(((double)hhx[(ey*nbeta+ex)]))+dX ;///((double)nSubPixels); - ypos_eta=(((double)hhy[(ey*nbeta+ex)]))+dY ;///((double)nSubPixels); + xpos_eta=(((double)hhx[(ey*nbetaX+ex)]))+dX ;///((double)nSubPixels); + ypos_eta=(((double)hhy[(ey*nbetaX+ex)]))+dY ;///((double)nSubPixels); } else { xpos_eta=0.5*dX+0.25; @@ -347,10 +347,10 @@ class eta2InterpolationBase : public virtual etaInterpolationBase { #endif #ifndef MYROOT1 int ex,ey; - ex=(etax-etamin)/etastep; - ey=(etay-etamin)/etastep; - if (ey=0 && ey>=0) - heta[ey*nbeta+ex]++; + ex=(etax-etamin)/etastepX; + ey=(etay-etamin)/etastepY; + if (ey=0 && ey>=0) + heta[ey*nbetaX+ex]++; #endif return 0; }; @@ -360,22 +360,22 @@ class eta2InterpolationBase : public virtual etaInterpolationBase { // cout << "ff" << endl; calcDiff(1, hhx, hhy); //get flat double avg=0; - for (ipx=0; ipx0) - hintcorr[ibx+iby*nSubPixels*nPixelsX]=hint[ibx+iby*nSubPixels*nPixelsX]*(avg/flat[ipx+ipy*nSubPixels]); + if (flat[ipx+ipy*nSubPixelsX]>0) + hintcorr[ibx+iby*nSubPixelsX*nPixelsX]=hint[ibx+iby*nSubPixelsX*nPixelsX]*(avg/flat[ipx+ipy*nSubPixelsX]); else - hintcorr[ibx+iby*nSubPixels*nPixelsX]=hint[ibx+iby*nSubPixels*nPixelsX]; + hintcorr[ibx+iby*nSubPixelsX*nPixelsX]=hint[ibx+iby*nSubPixelsX*nPixelsX]; } diff --git a/slsDetectorCalibration/interpolations/eta3InterpolationBase.h b/slsDetectorCalibration/interpolations/eta3InterpolationBase.h index 4fe2ceb4e..a00969bb2 100644 --- a/slsDetectorCalibration/interpolations/eta3InterpolationBase.h +++ b/slsDetectorCalibration/interpolations/eta3InterpolationBase.h @@ -13,35 +13,12 @@ class eta3InterpolationBase : public virtual etaInterpolationBase { public: - eta3InterpolationBase(int nx=400, int ny=400, int ns=25, int nb=-1, double emin=1, double emax=0) : etaInterpolationBase(nx, ny, ns, nb, emin, emax) { + eta3InterpolationBase(int nx=400, int ny=400, int ns=25, int nsy=25, int nb=-1, int nby=-1, double emin=1, double emax=0) : etaInterpolationBase(nx, ny, ns, nsy, nb, nby, emin, emax) { // cout << "e3ib " << nb << " " << emin << " " << emax << endl; /* if (nbeta<=0) { */ /* nbeta=nSubPixels*10; */ /* } */ - if (etamin>=etamax) { - etamin=-1; - etamax=1; - } - - etastep=(etamax-etamin)/nbeta; -#ifdef MYROOT1 - delete heta; - delete hhx; - delete hhy; - heta=new TH2D("heta","heta",nbeta,etamin,etamax,nbeta,etamin,etamax); - hhx=new TH2D("hhx","hhx",nbeta,etamin,etamax,nbeta,etamin,etamax); - hhy=new TH2D("hhy","hhy",nbeta,etamin,etamax,nbeta,etamin,etamax); -#endif -#ifndef MYROOT1 - /* delete [] heta; */ - /* delete [] hhx; */ - /* delete [] hhy; */ - - /* heta=new int[nbeta*nbeta]; */ - /* hhx=new float[nbeta*nbeta]; */ - /* hhy=new float[nbeta*nbeta]; */ - -#endif + // cout << nbeta << " " << etamin << " " << etamax << endl; }; @@ -88,7 +65,7 @@ class eta3InterpolationBase : public virtual etaInterpolationBase { double etax, etay; - if (nSubPixels>2) { + if (nSubPixelsX>2 || nSubPixelsY>2 ) { calcEta3(cl,etax,etay, totquad); } return getInterpolatedPosition(x,y,etax, etay,quad,int_x,int_y); @@ -101,7 +78,7 @@ class eta3InterpolationBase : public virtual etaInterpolationBase { double etax, etay; - if (nSubPixels>2) { + if (nSubPixelsX>2 || nSubPixelsY>2 ) { calcEta3(cl,etax,etay, totquad); } return getInterpolatedPosition(x,y,etax, etay,quad,int_x,int_y); @@ -117,38 +94,38 @@ class eta3InterpolationBase : public virtual etaInterpolationBase { double xpos_eta=0,ypos_eta=0; int ex,ey; - if (nSubPixels>2) { + if (nSubPixelsX>2 || nSubPixelsY>2 ) { #ifdef MYROOT1 - xpos_eta=(hhx->GetBinContent(hhx->GetXaxis()->FindBin(etax),hhy->GetYaxis()->FindBin(etay)))/((double)nSubPixels); - ypos_eta=(hhy->GetBinContent(hhx->GetXaxis()->FindBin(etax),hhy->GetYaxis()->FindBin(etay)))/((double)nSubPixels); + xpos_eta=(hhx->GetBinContent(hhx->GetXaxis()->FindBin(etax),hhy->GetYaxis()->FindBin(etay)))/((double)nSubPixelsX); + ypos_eta=(hhy->GetBinContent(hhx->GetXaxis()->FindBin(etax),hhy->GetYaxis()->FindBin(etay)))/((double)nSubPixelsY); #endif #ifndef MYROOT1 - ex=(etax-etamin)/etastep; - ey=(etay-etamin)/etastep; + ex=(etax-etamin)/etastepX; + ey=(etay-etamin)/etastepY; if (ex<0) { /* cout << etax << " " << etamin << " "; */ /* cout << "3x*"<< ex << endl; */ ex=0; } - if (ex>=nbeta) { + if (ex>=nbetaX) { /* cout << etax << " " << etamin << " "; */ /* cout << "3x?"<< ex << endl; */ - ex=nbeta-1; + ex=nbetaX-1; } if (ey<0) { /* cout << etay << " " << etamin << " "; */ /* cout << "3y*"<< ey << endl; */ ey=0; } - if (ey>=nbeta) { + if (ey>=nbetaY) { /* cout << etay << " " << etamin << " "; */ /* cout << "3y?"<< ey << endl; */ - ey=nbeta-1; + ey=nbetaY-1; } - xpos_eta=(((double)hhx[(ey*nbeta+ex)]));///((double)nSubPixels); - ypos_eta=(((double)hhy[(ey*nbeta+ex)]));///((double)nSubPixels); + xpos_eta=(((double)hhx[(ey*nbetaX+ex)]));///((double)nSubPixels); + ypos_eta=(((double)hhy[(ey*nbetaX+ex)]));///((double)nSubPixels); #endif @@ -265,10 +242,10 @@ class eta3InterpolationBase : public virtual etaInterpolationBase { #endif #ifndef MYROOT1 int ex,ey; - ex=(etax-etamin)/etastep; - ey=(etay-etamin)/etastep; - if (ey=0 && ey>=0) - heta[ey*nbeta+ex]++; + ex=(etax-etamin)/etastepX; + ey=(etay-etamin)/etastepY; + if (ey=0 && ey>=0) + heta[ey*nbetaX+ex]++; #endif return 0; }; diff --git a/slsDetectorCalibration/interpolations/etaInterpolationBase.h b/slsDetectorCalibration/interpolations/etaInterpolationBase.h index e4bda2c5d..e44396dc0 100644 --- a/slsDetectorCalibration/interpolations/etaInterpolationBase.h +++ b/slsDetectorCalibration/interpolations/etaInterpolationBase.h @@ -7,7 +7,7 @@ #include #include #endif - +#include #include "slsInterpolation.h" #include "tiffIO.h" @@ -15,44 +15,51 @@ class etaInterpolationBase : public slsInterpolation { public: - etaInterpolationBase(int nx=400, int ny=400, int ns=25, int nb=-1, double emin=1, double emax=0) : slsInterpolation(nx,ny,ns), hhx(NULL), hhy(NULL), heta(NULL), nbeta(nb), etamin(emin), etamax(emax) { + etaInterpolationBase(int nx=400, int ny=400, int ns=25, int nsy=25, int nb=-1, int nby=-1, double emin=1, double emax=0) : slsInterpolation(nx,ny,ns,nsy), hhx(NULL), hhy(NULL), heta(NULL), nbetaX(nb), nbetaY(nby), etamin(emin), etamax(emax) { // cout << "eb " << nb << " " << emin << " " << emax << endl; // cout << nb << " " << etamin << " " << etamax << endl; - if (nbeta<=0) { + if (nbetaX<=0) { //cout << "aaa:" <=etamax) { etamin=-1; etamax=2; } - etastep=(etamax-etamin)/nbeta; - heta=new int[nbeta*nbeta]; - hhx=new float[nbeta*nbeta]; - hhy=new float[nbeta*nbeta]; + etastepX=(etamax-etamin)/nbetaX; + etastepY=(etamax-etamin)/nbetaY; + heta=new int[nbetaX*nbetaY]; + hhx=new float[nbetaX*nbetaY]; + hhy=new float[nbetaX*nbetaY]; rangeMin=etamin; rangeMax=etamax; - flat= new double[nSubPixels*nSubPixels]; - hintcorr=new int [nSubPixels*nSubPixels*nPixelsX*nPixelsY]; + flat= new double[nSubPixelsX*nSubPixelsY]; + hintcorr=new int [nSubPixelsX*nSubPixelsY*nPixelsX*nPixelsY]; }; etaInterpolationBase(etaInterpolationBase *orig): slsInterpolation(orig){ - nbeta=orig->nbeta; + nbetaX=orig->nbetaX; + nbetaY=orig->nbetaY; etamin=orig->etamin; etamax=orig->etamax; rangeMin=orig->rangeMin; rangeMax=orig->rangeMax; - etastep=(etamax-etamin)/nbeta; - heta=new int[nbeta*nbeta]; - memcpy(heta,orig->heta,nbeta*nbeta*sizeof(int)); - hhx=new float[nbeta*nbeta]; - memcpy(hhx,orig->hhx,nbeta*nbeta*sizeof(float)); - hhy=new float[nbeta*nbeta]; - memcpy(hhy,orig->hhy,nbeta*nbeta*sizeof(float)); - hintcorr=new int [nSubPixels*nSubPixels*nPixelsX*nPixelsY]; + etastepX=(etamax-etamin)/nbetaX; + etastepY=(etamax-etamin)/nbetaY; + heta=new int[nbetaX*nbetaY]; + memcpy(heta,orig->heta,nbetaX*nbetaY*sizeof(int)); + hhx=new float[nbetaX*nbetaY]; + memcpy(hhx,orig->hhx,nbetaX*nbetaY*sizeof(float)); + hhy=new float[nbetaX*nbetaY]; + memcpy(hhy,orig->hhy,nbetaX*nbetaY*sizeof(float)); + hintcorr=new int [nSubPixelsX*nSubPixelsY*nPixelsX*nPixelsY]; }; @@ -61,7 +68,7 @@ class etaInterpolationBase : public slsInterpolation { virtual void resetFlatField() { - for (int ibx=0; ibx=etamax) { @@ -85,22 +95,24 @@ class etaInterpolationBase : public slsInterpolation { } rangeMin=etamin; rangeMax=etamax; - etastep=(etamax-etamin)/nbeta; + etastepX=(etamax-etamin)/nbetaX; + etastepY=(etamax-etamin)/nbetaY; } return heta; }; - int *setFlatField(int *h, int nb=-1, double emin=1, double emax=0) + int *setFlatField(int *h, int nb=-1, int nby=-1, double emin=1, double emax=0) { - return setEta(h, nb, emin, emax); + return setEta(h, nb, nby, emin, emax); }; int *getFlatField(){return setEta(NULL);}; - int *getFlatField(int &nb, double &emin, double &emax){ - nb=nbeta; + int *getFlatField(int &nb, int &nby, double &emin, double &emax){ + nb=nbetaX; + nby=nbetaY; emin=etamin; emax=etamax; return getFlatField(); @@ -109,13 +121,13 @@ class etaInterpolationBase : public slsInterpolation { void *writeFlatField(const char * imgname) { float *gm=NULL; - gm=new float[nbeta*nbeta]; - for (int ix=0; ix=0 && ey>=0) - heta[ey*nbeta+ex]++; + ex=(etax-etamin)/etastepX; + ey=(etay-etamin)/etastepY; + if (ey=0 && ey>=0) + heta[ey*nbetaX+ex]++; return 0; }; @@ -195,80 +209,80 @@ float *gethhx() float tot_eta=0; - float *etah=new float[nbeta*nbeta]; - int etabins=nbeta; + float *etah=new float[nbetaX*nbetaY]; + // int etabins=nbeta; int ibb=0; - for (int ii=0; ii=nSubPixels) ibx=nSubPixels-1; - if (iby>=nSubPixels) iby=nSubPixels-1; + if (ibx>=nSubPixelsX) ibx=nSubPixelsX-1; + if (iby>=nSubPixelsY) iby=nSubPixelsY-1; - if (ibx>=0 && ibx=0 && iby=0 && ibx=0 && iby0 && iby>0) cout << ibx << " " << iby << " " << ii << endl; - ftest[ibx+iby*nSubPixels]+=heta[ii]; + ftest[ibx+iby*nSubPixelsX]+=heta[ii]; } else cout << "Bad interpolation "<< ii << " " << ibx << " " << iby<< endl; - + } sprintf(tit,"/scratch/ftest_%d.tiff",ind); - WriteToTiff(ftest, tit, nSubPixels, nSubPixels); + WriteToTiff(ftest, tit, nSubPixelsX, nSubPixelsY); //int ibx=0, iby=0; - tot_eta/=nSubPixels*nSubPixels; + tot_eta/=nSubPixelsX*nSubPixelsY; int nbad=0; - for (int ii=0; iitot_eta*2.){ + } else if(ftest[ibx+iby*nSubPixelsX]>tot_eta*2.){ etah[ii]=2; nbad++; } else etah[ii]=0; } sprintf(tit,"/scratch/eta_bad_%d.tiff",ind); - WriteToTiff(etah, tit, etabins, etabins); + WriteToTiff(etah, tit, nbetaX, nbetaY); // cout << "Index: " << ind << "\t Bad bins: "<< nbad << endl; //int ibx=0, iby=0; @@ -286,46 +300,44 @@ float *gethhx() double diff=0, d; //double bsize=1./nSubPixels; int nbad=0; - double p_tot_x[nSubPixels], p_tot_y[nSubPixels], p_tot[nSubPixels*nSubPixels]; - double maxdiff=0, mindiff=avg*nSubPixels*nSubPixels; + double p_tot_x[nSubPixelsX], p_tot_y[nSubPixelsY], p_tot[nSubPixelsX*nSubPixelsY]; + double maxdiff=0, mindiff=avg*nSubPixelsX*nSubPixelsY; int ipx, ipy; - for (ipy=0; ipy=nSubPixels) ipx=nSubPixels-1; + if (ipx>=nSubPixelsX) ipx=nSubPixelsX-1; - ipy=hy[ibx+iby*nbeta]*nSubPixels; + ipy=hy[ibx+iby*nbetaX]*nSubPixelsY; if (ipy<0) ipy=0; - if (ipy>=nSubPixels) ipy=nSubPixels-1; + if (ipy>=nSubPixelsY) ipy=nSubPixelsY-1; - p_tot[ipx+ipy*nSubPixels]+=heta[ibx+iby*nbeta]; - p_tot_y[ipy]+=heta[ibx+iby*nbeta]; - p_tot_x[ipx]+=heta[ibx+iby*nbeta]; - - + p_tot[ipx+ipy*nSubPixelsX]+=heta[ibx+iby*nbetaX]; + p_tot_y[ipy]+=heta[ibx+iby*nbetaX]; + p_tot_x[ipx]+=heta[ibx+iby*nbetaX]; } } // cout << endl << endl; - for (ipy=0; ipy5*sqrt(avg) ) nbad++; @@ -354,8 +366,8 @@ float *gethhx() float *hhx; float *hhy; int *heta; - int nbeta; - double etamin, etamax, etastep; + int nbetaX, nbetaY; + double etamin, etamax, etastepX, etastepY; double rangeMin, rangeMax; diff --git a/slsDetectorCalibration/interpolations/etaInterpolationPosXY.h b/slsDetectorCalibration/interpolations/etaInterpolationPosXY.h index dfe6772f3..0d29c1658 100644 --- a/slsDetectorCalibration/interpolations/etaInterpolationPosXY.h +++ b/slsDetectorCalibration/interpolations/etaInterpolationPosXY.h @@ -9,7 +9,7 @@ class etaInterpolationPosXY : public virtual etaInterpolationBase{ public: - etaInterpolationPosXY(int nx=400, int ny=400, int ns=25, int nb=-1, double emin=1, double emax=0) : etaInterpolationBase(nx,ny,ns, nb, emin,emax){ + etaInterpolationPosXY(int nx=400, int ny=400, int ns=25, int nsy=25, int nb=-1, int nby=-1, double emin=1, double emax=0) : etaInterpolationBase(nx,ny, ns, nsy, nb, nby, emin, emax){ // cout << "epxy " << nb << " " << emin << " " << emax << endl; cout << nbeta << " " << etamin << " " << etamax << endl; }; @@ -24,14 +24,6 @@ class etaInterpolationPosXY : public virtual etaInterpolationBase{ virtual void prepareInterpolation(int &ok) { ok=1; -#ifdef MYROOT1 - if (hhx) delete hhx; - if (hhy) delete hhy; - - hhx=new TH2D("hhx","hhx",heta->GetNbinsX(),heta->GetXaxis()->GetXmin(),heta->GetXaxis()->GetXmax(), heta->GetNbinsY(),heta->GetYaxis()->GetXmin(),heta->GetYaxis()->GetXmax()); - hhy=new TH2D("hhy","hhy",heta->GetNbinsX(),heta->GetXaxis()->GetXmin(),heta->GetXaxis()->GetXmax(), heta->GetNbinsY(),heta->GetYaxis()->GetXmin(),heta->GetYaxis()->GetXmax()); - -#endif ///*Eta Distribution Rebinning*/// @@ -40,106 +32,128 @@ class etaInterpolationPosXY : public virtual etaInterpolationBase{ double tot_eta=0; double tot_eta_x=0; double tot_eta_y=0; - for (int ip=0; ip=0 && etax<=1) - hx[iby]=heta[iby+ib*nbeta]; - else { - hx[iby]=0; - } + // tot_eta_x+=hx[iby]; - if (etax>=0 && etax<=1) - hy[iby]=heta[ib+iby*nbeta]; + if (etay>=0 && etay<=1) + hy[iby]=heta[ib+iby*nbetaX]; else hy[iby]=0; // tot_eta_y+=hy[iby]; } - hix[0]=hx[0]; + hiy[0]=hy[0]; - for (int iby=1; iby(ii+1)*tot_eta_x*bsize) - { - //if (hix[ibx]>tot_eta_x*(ii+1)/nSubPixels) ii++; - hhx[ibx+ib*nbeta]=hix[ibx]/tot_eta_x; - } - } - /* if (ii!=(nSubPixels-1)) */ - /* cout << ib << " x " << tot_eta_x << " " << (ii+1)*tot_eta_x*bsize << " " << ii << " " << hix[nbeta-1]<< endl; */ - - //ii=0; - - for (int ibx=0; ibxtot_eta_y*(ii+1)/nSubPixels) ii++; - hhy[ib+ibx*nbeta]=hiy[ibx]/tot_eta_y; + hhy[ib+iby*nbetaX]=hiy[iby]/tot_eta_y; } } } + + for (int ib=0; ib=0 && etax<=1) + hx[ibx]=heta[ibx+ib*nbetaX]; + else { + hx[ibx]=0; + } + } + hix[0]=hx[0]; + + for (int ibx=1; ibxtot_eta_x*(ii+1)/nSubPixels) ii++; + hhx[ibx+ib*nbetaX]=hix[ibx]/tot_eta_x; + } + } + + } + + int ibx, iby, ib; iby=0; - while (hhx[iby*nbeta+nbeta/2]<0) iby++; + while (hhx[iby*nbetaY+nbetaY/2]<0) iby++; for (ib=0; ibnPixelsX; nPixelsY=orig->nPixelsY; - nSubPixels=orig->nSubPixels; + nSubPixelsX=orig->nSubPixelsX; + nSubPixelsY=orig->nSubPixelsY; - hint=new int[nSubPixels*nPixelsX*nSubPixels*nPixelsY]; - memcpy(hint, orig->hint,nSubPixels*nPixelsX*nSubPixels*nPixelsY*sizeof(int)); + hint=new int[nSubPixelsX*nPixelsX*nSubPixelsY*nPixelsY]; + memcpy(hint, orig->hint,nSubPixelsX*nPixelsX*nSubPixelsY*nPixelsY*sizeof(int)); }; @@ -51,23 +53,37 @@ class slsInterpolation return new slsInterpolation(this); }*/ - int getNSubPixels() {return nSubPixels;}; + int getNSubPixelsX() {return nSubPixelsX;}; + int getNSubPixelsY() {return nSubPixelsY;}; + int getNSubPixels() {if (nSubPixelsX==nSubPixelsY) return nSubPixelsX; else return 0;}; + void getNSubPixels(int &nsx, int &nsy) {nsx=nSubPixelsX; nsy=nsx=nSubPixelsY;} - - int setNSubPixels(int ns) { - if (ns>0 && ns!=nSubPixels) { + void setNSubPixels(int ns, int nsy=-1) { + delete [] hint; - nSubPixels=ns; - hint=new int[nSubPixels*nPixelsX*nSubPixels*nPixelsY]; - } - return nSubPixels; + nSubPixelsX=ns; + if (nsy>0) nSubPixelsY=nsy; + else nSubPixelsY=ns; + + hint=new int[nSubPixelsX*nPixelsX*nSubPixelsY*nPixelsY]; + + //return nSubPixels; } - int getImageSize(int &nnx, int &nny, int &ns) { - nnx=nSubPixels*nPixelsX; - nny=nSubPixels*nPixelsY; - ns=nSubPixels; - return nSubPixels*nSubPixels*nPixelsX*nPixelsY; + + + + int getImageSize(int &nnx, int &nny, int &nsx, int &nsy) { + nnx=nSubPixelsX*nPixelsX; + nny=nSubPixelsY*nPixelsY; + nsx=nSubPixelsX; + nsy=nSubPixelsY; + return nSubPixelsX*nSubPixelsY*nPixelsX*nPixelsY; + }; + + + int getImageSize() { + return nSubPixelsX*nSubPixelsY*nPixelsX*nPixelsY; }; @@ -92,14 +108,14 @@ class slsInterpolation //cout << "!" <=0 && ix<(nPixelsX*nSubPixels) && iy<(nSubPixels*nPixelsY) && iy>=0 ){ + int iy=((double)nSubPixelsY)*int_y; + int ix=((double)nSubPixelsX)*int_x; + if (ix>=0 && ix<(nPixelsX*nSubPixelsX) && iy<(nSubPixelsY*nPixelsY) && iy>=0 ){ // cout << int_x << " " << int_y << " " << " " << ix << " " << iy << " " << ix+iy*nPixelsX*nSubPixels << " " << hint[ix+iy*nPixelsX*nSubPixels]; - (*(hint+ix+iy*nPixelsX*nSubPixels))+=1; + (*(hint+ix+iy*nPixelsX*nSubPixelsX))+=1; // cout << " " << hint[ix+iy*nPixelsX*nSubPixels] << endl; }// else // cout << "bad! "<< int_x << " " << int_y << " " << " " << ix << " " << iy << " " << ix+iy*nPixelsX*nSubPixels << endl; @@ -495,7 +511,7 @@ class slsInterpolation protected: int nPixelsX, nPixelsY; - int nSubPixels; + int nSubPixelsX, nSubPixelsY; int id; int *hint; }; diff --git a/slsDetectorCalibration/moenchExecutables/moench03Interpolation.cpp b/slsDetectorCalibration/moenchExecutables/moench03Interpolation.cpp index eb4f5db1f..97acaa9c6 100644 --- a/slsDetectorCalibration/moenchExecutables/moench03Interpolation.cpp +++ b/slsDetectorCalibration/moenchExecutables/moench03Interpolation.cpp @@ -14,13 +14,21 @@ #include "single_photon_hit.h" #endif -//#include "etaInterpolationPosXY.h" +#include "etaInterpolationPosXY.h" #include "noInterpolation.h" -#include "etaInterpolationCleverAdaptiveBins.h" +//#include "etaInterpolationCleverAdaptiveBins.h" //#include "etaInterpolationRandomBins.h" using namespace std; +#ifndef RECT #define NC 400 #define NR 400 +#endif +#ifdef RECT +#define NC 200 +#define NR 800 +#endif + + #define MAX_ITERATIONS (nSubPixels*100) #define XTALK @@ -67,6 +75,7 @@ int main(int argc, char *argv[]) { cout << "Energy max: " << cmax << endl; //int etabins=500; int etabins=1000;//nsubpix*2*100; + int etabinsY=etabins;//nsubpix*2*100; double etamin=-1, etamax=2; //double etamin=-0.1, etamax=1.1; double eta3min=-2, eta3max=2; @@ -90,14 +99,18 @@ int main(int argc, char *argv[]) { #ifndef DOUBLE_SPH single_photon_hit cl(3,3); #endif - int nSubPixels=nsubpix; + int nSubPixelsY=nsubpix; +#ifdef RECT + nSubPixelsY=1; //might make more sense using 2? + etabinsY=2; +#endif #ifndef NOINTERPOLATION - eta2InterpolationPosXY *interp=new eta2InterpolationPosXY(NC, NR, nsubpix, etabins, etamin, etamax); + eta2InterpolationPosXY *interp=new eta2InterpolationPosXY(NC, NR, nSubPixels, nSubPixelsY, etabins, etabinsY, etamin, etamax); //eta2InterpolationCleverAdaptiveBins *interp=new eta2InterpolationCleverAdaptiveBins(NC, NR, nsubpix, etabins, etamin, etamax); #endif #ifdef NOINTERPOLATION - noInterpolation *interp=new noInterpolation(NC, NR, nsubpix); + noInterpolation *interp=new noInterpolation(NC, NR, nsubpix, nSubPixelsY); #endif @@ -116,12 +129,12 @@ int main(int argc, char *argv[]) { #endif int *img; - float *totimg=new float[NC*NR*nsubpix*nsubpix]; + float *totimg=new float[NC*NR*nSubPixels*nSubPixelsY]; for (ix=0; ixaddToImage(int_x, int_y); - if (int_x<0 || int_y<0 || int_x>400 || int_y>400) { + if (int_x<0 || int_y<0 || int_x>NC || int_y>NR) { cout <<"**************"<< endl; cout << cl.x << " " << cl.y << " " << sum << endl; cl.print(); @@ -220,9 +233,9 @@ int main(int argc, char *argv[]) { img=interp->getInterpolatedImage(); for (ix=0; ixgetFilePointer();}; } - virtual int setNSubPixels(int ns) { + virtual void setNSubPixels(int ns, int nsy=-1) { slsInterpolation *interp=(det)->getInterpolation(); - if (interp) return interp->setNSubPixels(ns); - else return 1;}; + if (interp) interp->setNSubPixels(ns, nsy); + //else return 1; + }; virtual slsInterpolation *setInterpolation(slsInterpolation *f){