#ifndef ETA_INTERPOLATION_ADAPTIVEBINS_H #define ETA_INTERPOLATION_ADAPTIVEBINS_H #include "tiffIO.h" //#include "etaInterpolationBase.h" #include "etaInterpolationPosXY.h" class etaInterpolationAdaptiveBins : public etaInterpolationPosXY { private: double calcDiff(double avg, float *hx, float *hy) { double p_tot=0; double diff=0; double bsize=1./nSubPixels; for (int ipx=0; ipx=((ipx)*bsize) && hx[ibx+iby*nbeta]<((ipx+1)*bsize) && hy[ibx+iby*nbeta]>=((ipy)*bsize) && hy[ibx+iby*nbeta]<((ipy+1)*bsize)) { p_tot+=heta[ibx+iby*nbeta]; } } } cout << p_tot << " \t "; diff+=(p_tot-avg)*(p_tot-avg); } cout << "\n"; } return diff; } void iterate(float *newhhx, float *newhhy) { double bsize=1./nSubPixels; double hy[nbeta]; //profile y double hx[nbeta]; //profile x double hix[nbeta]; //integral of projection x double hiy[nbeta]; //integral of projection y double tot_eta_x=0; double tot_eta_y=0; for (int ipy=0; ipy=((ipy)*bsize) && hhy[ibx+iby*nbeta]<=((ipy+1)*bsize)) { hx[ibx]+=heta[ibx+iby*nbeta]; tot_eta_x+=heta[ibx+iby*nbeta]; } if (hhx[ibx+iby*nbeta]>=((ipy)*bsize) && hhx[ibx+iby*nbeta]<=((ipy+1)*bsize)) { hy[iby]+=heta[ibx+iby*nbeta]; tot_eta_y+=heta[ibx+iby*nbeta]; } } } hix[0]=hx[0]; hiy[0]=hy[0]; for (int ib=1; ib=((ipy)*bsize) && hhy[ibx+iby*nbeta]<=((ipy+1)*bsize)) { newhhx[ibx+iby*nbeta]=hix[ibx]/((double)tot_eta_x); if (newhhx[ibx+iby*nbeta]>1) cout << "***"<< ibx << " " << iby << newhhx[ibx+iby*nbeta] << endl; // if (ipy==3 && ibx==10) cout << newhhx[ibx+iby*nbeta] << " " << hix[ibx] << " " << ibx+iby*nbeta << endl; } if (hhx[ibx+iby*nbeta]>=((ipy)*bsize) && hhx[ibx+iby*nbeta]<=((ipy+1)*bsize)) { newhhy[ibx+iby*nbeta]=hiy[iby]/((double)tot_eta_y); if (newhhy[ibx+iby*nbeta]>1) 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){}; etaInterpolationAdaptiveBins(etaInterpolationAdaptiveBins *orig): etaInterpolationPosXY(orig){}; virtual etaInterpolationAdaptiveBins* Clone() { return new etaInterpolationAdaptiveBins(this); }; virtual void prepareInterpolation(int &ok) { ok=1; cout << "Adaptive bins" << endl; ///*Eta Distribution Rebinning*/// double bsize=1./nSubPixels; //precision // cout<<"nPixelsX = "<1 || etah[ii]<0 ) cout << "***"<< ii << etah[ii] << endl; */ /* } */ /* sprintf(tit,"/scratch/neweta_hhy_%d.tiff",iint); */ /* WriteToTiff(etah, tit, etabins, etabins); */ /* #endif */ if (new_diff