#ifndef ETA_INTERPOLATION_ADAPTIVEBINS_H #define ETA_INTERPOLATION_ADAPTIVEBINS_H #include #include "tiffIO.h" //#include "etaInterpolationBase.h" #include "etaInterpolationPosXY.h" class etaInterpolationAdaptiveBins : public etaInterpolationPosXY { // protected: private: virtual void iterate(float *newhhx, float *newhhy) { double bsize=1./nSubPixels; double hy[nSubPixels][nbeta]; //profile y double hx[nSubPixels][nbeta]; //profile x double hix[nSubPixels][nbeta]; //integral of projection x double hiy[nSubPixels][nbeta]; //integral of projection y int ipy, ipx; double tot_eta_x[nSubPixels]; double tot_eta_y[nSubPixels]; //for (int ipy=0; ipy=nSubPixels) ipy=nSubPixels-1; hx[ipy][ibx]+=heta[ibx+iby*nbeta]; ipx=hhx[ibx+iby*nbeta]*nSubPixels; if (ipx<0) ipx=0; if (ipx>=nSubPixels) ipx=nSubPixels-1; hy[ipx][iby]+=heta[ibx+iby*nbeta]; } } for (ipy=0; ipy=((ipy)*bsize) && hhy[ibx+iby*nbeta]<=((ipy+1)*bsize)) { ipy=hhy[ibx+iby*nbeta]*nSubPixels; if (ipy<0) ipy=0; if (ipy>=nSubPixels) ipy=nSubPixels-1; if (ipy>=0 && ipy0) newhhx[ibx+iby*nbeta]=hix[ipy][ibx]/(tot_eta_x[ipy]); else cout << "Bad tot_etax " << ipy << " " << tot_eta_x[ipy] << endl; else cout << "** Bad value ipy " << ibx << " " << iby << " "<< ipy << " " << hhy[ibx+iby*nbeta]*nSubPixels << endl; // if (newhhx[ibx+iby*nbeta]>=1 || newhhx[ibx+iby*nbeta]<0 ) cout << "***"<< ibx << " " << iby << newhhx[ibx+iby*nbeta] << endl; // if (ipy==3 && ibx==10) cout << newhhx[ibx+iby*nbeta] << " " << hix[ibx] << " " << ibx+iby*nbeta << endl; // } ipy=hhx[ibx+iby*nbeta]*nSubPixels; //if (hhx[ibx+iby*nbeta]>=((ipy)*bsize) && hhx[ibx+iby*nbeta]<=((ipy+1)*bsize)) { if (ipy<0) ipy=0; if (ipy>=nSubPixels) ipy=nSubPixels-1; if (ipy>=0 && ipy0) newhhy[ibx+iby*nbeta]=hiy[ipy][iby]/(tot_eta_y[ipy]); else cout << "Bad tot_etay " << ipy << " " << tot_eta_y[ipy] << endl; else cout << "** Bad value ipx " << ibx << " " << iby << " "<< ipy << " " << hhx[ibx+iby*nbeta]*nSubPixels << endl; // if (newhhy[ibx+iby*nbeta]>=1 || newhhy[ibx+iby*nbeta]<0 ) cout << "***"<< ibx << " " << iby << newhhy[ibx+iby*nbeta] << endl; // if (ipy==3 && iby==10) cout << newhhy[ibx+iby*nbeta] << " " << hiy[iby] << " " << ibx+iby*nbeta << endl; // } } } // } } public: etaInterpolationAdaptiveBins(int nx=400, int ny=400, int ns=25, int nb=-1, double emin=1, double emax=0) : etaInterpolationPosXY(nx,ny,ns, nb, emin,emax){ // flat=new double[nSubPixels*nSubPixels]; flat_x=new double[nSubPixels]; flat_y=new double[nSubPixels]; // flat=new double[nSubPixels*nSubPixels]; }; etaInterpolationAdaptiveBins(etaInterpolationAdaptiveBins *orig): etaInterpolationPosXY(orig){hintcorr=new int[nPixelsX*nPixelsY*nSubPixels];}; virtual etaInterpolationAdaptiveBins* Clone()=0; /* return new etaInterpolationAdaptiveBins(this); */ /* }; */ virtual void prepareInterpolation(int &ok) { prepareInterpolation(ok, 1000); } virtual void prepareInterpolation(int &ok, int nint) { ok=1; ///*Eta Distribution Rebinning*/// double bsize=1./nSubPixels; //precision // cout<<"nPixelsX = "< rms) { /* #ifdef SAVE_ALL */ /* if (iint%10==0) */ /* debugSaveAll(iint); */ /* #endif */ // cout << "Iteration " << iint << endl; iterate(newhhx,newhhy); new_diff=calcDiff(avg, newhhx, newhhy); // cout << " chi2= " << new_diff << " (rms= " << sqrt(tot_eta) << ")"<