Interpolation has problems. To be checked

This commit is contained in:
2019-12-17 17:09:50 +01:00
parent 27f2321d64
commit f7695113b8
9 changed files with 923 additions and 843 deletions

View File

@ -1,406 +0,0 @@
#ifndef ETA2_INTERPOLATION_BASE_H
#define ETA2_INTERPOLATION_BASE_H
#ifdef MYROOT1
#include <TObject.h>
#include <TTree.h>
#include <TH2D.h>
#include <TH2F.h>
#endif
#include "etaInterpolationBase.h"
class eta2InterpolationBase : public virtual etaInterpolationBase {
public:
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; */
/* etamax=2; */
/* // cout << ":" <<endl; */
/* } */
/* etastep=(etamax-etamin)/nbeta; */
};
eta2InterpolationBase(eta2InterpolationBase *orig): etaInterpolationBase(orig){ };
//////////////////////////////////////////////////////////////////////////////
//////////// /*It return position hit for the event in input */ //////////////
virtual void getInterpolatedPosition(int x, int y, int *data, double &int_x, double &int_y)
{
double sDum[2][2];
double tot, totquad;
double etax=0,etay=0;
int corner;
corner=calcQuad(data, tot, totquad, sDum);
if (nSubPixelsX>2 || nSubPixelsY>2)
calcEta(totquad, sDum, etax, etay);
getInterpolatedPosition(x,y,etax,etay,corner,int_x,int_y);
return;
};
virtual void getInterpolatedPosition(int x, int y, double *data, double &int_x, double &int_y)
{
double sDum[2][2];
double tot, totquad;
double etax=0,etay=0;
int corner;
corner=calcQuad(data, tot, totquad, sDum);
if (nSubPixelsX>2 || nSubPixelsY>2 )
calcEta(totquad, sDum, etax, etay);
getInterpolatedPosition(x,y,etax,etay,corner,int_x,int_y);
return;
};
virtual void getInterpolatedPosition(int x, int y, double totquad,int quad,double *cl,double &int_x, double &int_y) {
double cc[2][2];
int xoff=0, yoff=0;
switch (quad) {
case BOTTOM_LEFT:
xoff=0;
yoff=0;
break;
case BOTTOM_RIGHT:
xoff=1;
yoff=0;
break;
case TOP_LEFT:
xoff=0;
yoff=1;
break;
case TOP_RIGHT:
xoff=1;
yoff=1;
break;
default:
;
}
double etax=0, etay=0;
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];
cc[1][1]=cl[xoff+1+3*(yoff+1)];
calcEta(totquad,cc,etax,etay);
}
return getInterpolatedPosition(x,y,etax, etay,quad,int_x,int_y);
}
virtual void getInterpolatedPosition(int x, int y, double totquad,int quad,int *cl,double &int_x, double &int_y) {
double cc[2][2];
int xoff=0, yoff=0;
switch (quad) {
case BOTTOM_LEFT:
xoff=0;
yoff=0;
break;
case BOTTOM_RIGHT:
xoff=1;
yoff=0;
break;
case TOP_LEFT:
xoff=0;
yoff=1;
break;
case TOP_RIGHT:
xoff=1;
yoff=1;
break;
default:
;
}
double etax=0, etay=0;
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];
cc[1][1]=cl[xoff+1+3*(xoff+1)];
calcEta(totquad,cc,etax,etay);
}
return getInterpolatedPosition(x,y,etax, etay,quad,int_x,int_y);
}
virtual void getInterpolatedPosition(int x, int y, double etax, double etay, int corner, double &int_x, double &int_y)
{
double xpos_eta=0,ypos_eta=0;
double dX,dY;
int ex,ey;
switch (corner)
{
case TOP_LEFT:
dX=-1.;
dY=0;
break;
case TOP_RIGHT:
;
dX=0;
dY=0;
break;
case BOTTOM_LEFT:
dX=-1.;
dY=-1.;
break;
case BOTTOM_RIGHT:
dX=0;
dY=-1.;
break;
default:
cout << "bad quadrant" << endl;
dX=0.;
dY=0.;
}
if (nSubPixelsX>2 || nSubPixelsY>2 ) {
ex=(etax-etamin)/etastepX;
ey=(etay-etamin)/etastepY;
if (ex<0) {
cout << "x*"<< ex << endl;
ex=0;
}
if (ex>=nbetaX) {
cout << "x?"<< ex << endl;
ex=nbetaX-1;
}
if (ey<0) {
cout << "y*"<< ey << " " << nbetaY << endl;
ey=0;
}
if (ey>=nbetaY) {
cout << "y?"<< ey << " " << nbetaY << endl;
ey=nbetaY-1;
}
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;
ypos_eta=0.5*dY+0.25;
}
int_x=((double)x) + xpos_eta+0.5;
int_y=((double)y) + ypos_eta+0.5;
}
virtual int addToFlatField(double totquad,int quad,int *cl,double &etax, double &etay) {
double cc[2][2];
int xoff=0, yoff=0;
switch (quad) {
case BOTTOM_LEFT:
xoff=0;
yoff=0;
break;
case BOTTOM_RIGHT:
xoff=1;
yoff=0;
break;
case TOP_LEFT:
xoff=0;
yoff=1;
break;
case TOP_RIGHT:
xoff=1;
yoff=1;
break;
default:
;
}
cc[0][0]=cl[xoff+3*yoff];
cc[1][0]=cl[xoff+3*(yoff+1)];
cc[0][1]=cl[xoff+1+3*yoff];
cc[1][1]=cl[xoff+1+3*(yoff+1)];
//calcMyEta(totquad,quad,cl,etax, etay);
calcEta(totquad, cc,etax, etay);
// cout <<"******"<< etax << " " << etay << endl;
return addToFlatField(etax,etay);
}
virtual int addToFlatField(double totquad,int quad,double *cl,double &etax, double &etay) {
double cc[2][2];
int xoff=0, yoff=0;
switch (quad) {
case BOTTOM_LEFT:
xoff=0;
yoff=0;
break;
case BOTTOM_RIGHT:
xoff=1;
yoff=0;
break;
case TOP_LEFT:
xoff=0;
yoff=1;
break;
case TOP_RIGHT:
xoff=1;
yoff=1;
break;
default:
;
}
cc[0][0]=cl[xoff+3*yoff];
cc[1][0]=cl[(yoff+1)*3+xoff];
cc[0][1]=cl[yoff*3+xoff+1];
cc[1][1]=cl[(yoff+1)*3+xoff+1];
/* cout << cl[0] << " " << cl[1] << " " << cl[2] << endl; */
/* cout << cl[3] << " " << cl[4] << " " << cl[5] << endl; */
/* cout << cl[6] << " " << cl[7] << " " << cl[8] << endl; */
/* cout <<"******"<<totquad << " " << quad << endl; */
/* cout << cc[0][0]<< " " << cc[0][1] << endl; */
/* cout << cc[1][0]<< " " << cc[1][1] << endl; */
//calcMyEta(totquad,quad,cl,etax, etay);
calcEta(totquad, cc,etax, etay);
// cout <<"******"<< etax << " " << etay << endl;
return addToFlatField(etax,etay);
}
//////////////////////////////////////////////////////////////////////////////////////
virtual int addToFlatField(double *cluster, double &etax, double &etay){
double sDum[2][2];
double tot, totquad;
// int corner;
//corner=
calcQuad(cluster, tot, totquad, sDum);
//double xpos_eta,ypos_eta;
//double dX,dY;
calcEta(totquad, sDum, etax, etay);
return addToFlatField(etax,etay);
};
virtual int addToFlatField(int *cluster, double &etax, double &etay){
double sDum[2][2];
double tot, totquad;
//int corner;
//corner=
calcQuad(cluster, tot, totquad, sDum);
// double xpos_eta,ypos_eta;
//double dX,dY;
calcEta(totquad, sDum, etax, etay);
return addToFlatField(etax,etay);
};
virtual int addToFlatField(double etax, double etay){
#ifdef MYROOT1
heta->Fill(etax,etay);
#endif
#ifndef MYROOT1
int ex,ey;
ex=(etax-etamin)/etastepX;
ey=(etay-etamin)/etastepY;
if (ey<nbetaY && ex<nbetaX && ex>=0 && ey>=0)
heta[ey*nbetaX+ex]++;
#endif
return 0;
};
virtual int *getInterpolatedImage(){
int ipx, ipy;
// cout << "ff" << endl;
calcDiff(1, hhx, hhy); //get flat
double avg=0;
for (ipx=0; ipx<nSubPixelsX; ipx++)
for (ipy=0; ipy<nSubPixelsY; ipy++)
avg+=flat[ipx+ipy*nSubPixelsX];
avg/=nSubPixelsY*nSubPixelsX;
for (int ibx=0 ; ibx<nSubPixelsX*nPixelsX; ibx++) {
ipx=ibx%nSubPixelsX-nSubPixelsX/2;
if (ipx<0) ipx=nSubPixelsX+ipx;
for (int iby=0 ; iby<nSubPixelsY*nPixelsY; iby++) {
ipy=iby%nSubPixelsY-nSubPixelsY/2;
if (ipy<0) ipy=nSubPixelsY+ipy;
// cout << ipx << " " << ipy << " " << ibx << " " << iby << endl;
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*nSubPixelsX*nPixelsX]=hint[ibx+iby*nSubPixelsX*nPixelsX];
}
}
return hintcorr;
};
/* protected: */
/* #ifdef MYROOT1 */
/* TH2D *heta; */
/* TH2D *hhx; */
/* TH2D *hhy; */
/* #endif */
/* #ifndef MYROOT1 */
/* int *heta; */
/* float *hhx; */
/* float *hhy; */
/* #endif */
/* int nbeta; */
/* double etamin, etamax, etastep; */
};
#endif

View File

@ -1,271 +0,0 @@
#ifndef ETA3_INTERPOLATION_BASE_H
#define ETA3_INTERPOLATION_BASE_H
#ifdef MYROOT1
#include <TObject.h>
#include <TTree.h>
#include <TH2D.h>
#include <TH2F.h>
#endif
#include "etaInterpolationBase.h"
class eta3InterpolationBase : public virtual etaInterpolationBase {
public:
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; */
/* } */
// cout << nbeta << " " << etamin << " " << etamax << endl;
};
eta3InterpolationBase(eta3InterpolationBase *orig): etaInterpolationBase(orig){ };
/* virtual eta3InterpolationBase* Clone()=0; */
// virtual void prepareInterpolation(int &ok){};
//////////////////////////////////////////////////////////////////////////////
//////////// /*It return position hit for the event in input */ //////////////
virtual void getInterpolatedPosition(int x, int y, int *data, double &int_x, double &int_y)
{
double tot;
double etax,etay;
int corner=calcEta3(data,etax,etay, tot);
getInterpolatedPosition(x,y,etax,etay,corner,int_x,int_y);
return;
};
virtual void getInterpolatedPosition(int x, int y, double *data, double &int_x, double &int_y)
{
//double sDum[2][2];
double tot;
double etax,etay;
int corner=calcEta3(data,etax,etay, tot);
getInterpolatedPosition(x,y,etax,etay,corner,int_x,int_y);
return;
};
virtual void getInterpolatedPosition(int x, int y, double totquad,int quad,double *cl,double &int_x, double &int_y) {
double etax, etay;
if (nSubPixelsX>2 || nSubPixelsY>2 ) {
calcEta3(cl,etax,etay, totquad);
}
return getInterpolatedPosition(x,y,etax, etay,quad,int_x,int_y);
}
virtual void getInterpolatedPosition(int x, int y, double totquad,int quad,int *cl,double &int_x, double &int_y) {
double etax, etay;
if (nSubPixelsX>2 || nSubPixelsY>2 ) {
calcEta3(cl,etax,etay, totquad);
}
return getInterpolatedPosition(x,y,etax, etay,quad,int_x,int_y);
}
virtual void getInterpolatedPosition(int x, int y, double etax, double etay, int corner, double &int_x, double &int_y)
{
double xpos_eta=0,ypos_eta=0;
int ex,ey;
if (nSubPixelsX>2 || nSubPixelsY>2 ) {
#ifdef MYROOT1
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)/etastepX;
ey=(etay-etamin)/etastepY;
if (ex<0) {
/* cout << etax << " " << etamin << " "; */
/* cout << "3x*"<< ex << endl; */
ex=0;
}
if (ex>=nbetaX) {
/* cout << etax << " " << etamin << " "; */
/* cout << "3x?"<< ex << endl; */
ex=nbetaX-1;
}
if (ey<0) {
/* cout << etay << " " << etamin << " "; */
/* cout << "3y*"<< ey << endl; */
ey=0;
}
if (ey>=nbetaY) {
/* cout << etay << " " << etamin << " "; */
/* cout << "3y?"<< ey << endl; */
ey=nbetaY-1;
}
xpos_eta=(((double)hhx[(ey*nbetaX+ex)]));///((double)nSubPixels);
ypos_eta=(((double)hhy[(ey*nbetaX+ex)]));///((double)nSubPixels);
#endif
} else {
switch (corner) {
case BOTTOM_LEFT:
xpos_eta=-0.25;
ypos_eta=-0.25;
break;
case BOTTOM_RIGHT:
xpos_eta=0.25;
ypos_eta=-0.25;
break;
case TOP_LEFT:
xpos_eta=-0.25;
ypos_eta=0.25;
break;
case TOP_RIGHT:
xpos_eta=0.25;
ypos_eta=0.25;
break;
default:
xpos_eta=0;
ypos_eta=0;
}
}
int_x=((double)x) + xpos_eta;
int_y=((double)y) + ypos_eta;
// int_x=5. + xpos_eta;
// int_y=5. + ypos_eta;
}
/* ///////////////////////////////////////////////////////////////////////////////////////////////// */
/* virtual void getPositionETA3(int x, int y, double *data, double &int_x, double &int_y) */
/* { */
/* double sDum[2][2]; */
/* double tot, totquad; */
/* double eta3x,eta3y; */
/* double ex,ey; */
/* calcQuad(data, tot, totquad, sDum); */
/* calcEta3(data,eta3x, eta3y,tot); */
/* double xpos_eta,ypos_eta; */
/* #ifdef MYROOT1 */
/* xpos_eta=((hhx->GetBinContent(hhx->GetXaxis()->FindBin(eta3x),hhy->GetYaxis()->FindBin(eta3y))))/((double)nSubPixels); */
/* ypos_eta=((hhy->GetBinContent(hhx->GetXaxis()->FindBin(eta3x),hhy->GetYaxis()->FindBin(eta3y))))/((double)nSubPixels); */
/* #endif */
/* #ifndef MYROOT1 */
/* ex=(eta3x-etamin)/etastep; */
/* ey=(eta3y-etamin)/etastep; */
/* if (ex<0) ex=0; */
/* if (ex>=nbeta) ex=nbeta-1; */
/* if (ey<0) ey=0; */
/* if (ey>=nbeta) ey=nbeta-1; */
/* xpos_eta=(((double)hhx[(int)(ey*nbeta+ex)]))/((double)nSubPixels); */
/* ypos_eta=(((double)hhy[(int)(ey*nbeta+ex)]))/((double)nSubPixels); */
/* #endif */
/* int_x=((double)x) + xpos_eta; */
/* int_y=((double)y) + ypos_eta; */
/* return; */
/* }; */
virtual int addToFlatField(double totquad,int quad,int *cl,double &etax, double &etay) {
calcEta3(cl, etax, etay, totquad);
return addToFlatField(etax,etay);
}
virtual int addToFlatField(double totquad,int quad,double *cl,double &etax, double &etay) {
calcEta3(cl, etax, etay, totquad);
return addToFlatField(etax,etay);
}
//////////////////////////////////////////////////////////////////////////////////////
virtual int addToFlatField(double *cluster, double &etax, double &etay){
double totquad;
calcEta3(cluster, etax, etay, totquad);
return addToFlatField(etax,etay);
};
virtual int addToFlatField(int *cluster, double &etax, double &etay){
double totquad;
calcEta3(cluster, etax, etay, totquad);
return addToFlatField(etax,etay);
};
virtual int addToFlatField(double etax, double etay){
#ifdef MYROOT1
heta->Fill(etax,etay);
#endif
#ifndef MYROOT1
int ex,ey;
ex=(etax-etamin)/etastepX;
ey=(etay-etamin)/etastepY;
if (ey<nbetaY && ex<nbetaX && ex>=0 && ey>=0)
heta[ey*nbetaX+ex]++;
#endif
return 0;
};
/* protected: */
/* #ifdef MYROOT1 */
/* TH2D *heta; */
/* TH2D *hhx; */
/* TH2D *hhy; */
/* #endif */
/* #ifndef MYROOT1 */
/* int *heta; */
/* float *hhx; */
/* float *hhy; */
/* #endif */
/* int nbeta; */
/* double etamin, etamax, etastep; */
};
#endif

View File

@ -12,6 +12,19 @@
#include "tiffIO.h"
class etaInterpolationBase : public slsInterpolation {
protected:
float *hhx;
float *hhy;
int *heta;
int nbetaX, nbetaY;
double etamin, etamax, etastepX, etastepY;
double rangeMin, rangeMax;
double *flat;
int *hintcorr;
public:
@ -190,19 +203,10 @@ float *gethhx()
// hhy->Scale((double)nSubPixels);
return hhy;
};
virtual int addToFlatField(double etax, double etay){
int ex,ey;
ex=(etax-etamin)/etastepX;
ey=(etay-etamin)/etastepY;
if (ey<nbetaY && ex<nbetaX && ex>=0 && ey>=0)
heta[ey*nbetaX+ex]++;
return 0;
};
// virtual void prepareInterpolation(int &ok)=0;
void debugSaveAll(int ind=0) {
int ibx, iby;
char tit[10000];
@ -223,15 +227,15 @@ float *gethhx()
for (int ii=0; ii<nbetaX*nbetaY; ii++) {
ibb=(hhx[ii]*nSubPixelsX);
etah[ii]=ibb;
//ibb=hhx[ii];//*nSubPixelsX);
etah[ii]=hhx[ii];
}
sprintf(tit,"/scratch/eta_hhx_%d.tiff",ind);
WriteToTiff(etah, tit, nbetaX, nbetaY);
for (int ii=0; ii<nbetaX*nbetaY; ii++) {
ibb=hhy[ii]*nSubPixelsY;
etah[ii]=ibb;
//ibb=hhy[ii];//*nSubPixelsY;
etah[ii]=hhy[ii];
}
sprintf(tit,"/scratch/eta_hhy_%d.tiff",ind);
WriteToTiff(etah, tit, nbetaX, nbetaY);
@ -291,6 +295,37 @@ float *gethhx()
}
virtual int *getInterpolatedImage(){
/* int ipx, ipy; */
/* // cout << "ff" << endl; */
/* calcDiff(1, hhx, hhy); //get flat */
/* double avg=0; */
/* for (ipx=0; ipx<nSubPixelsX; ipx++) */
/* for (ipy=0; ipy<nSubPixelsY; ipy++) */
/* avg+=flat[ipx+ipy*nSubPixelsX]; */
/* avg/=nSubPixelsY*nSubPixelsX; */
/* for (int ibx=0 ; ibx<nSubPixelsX*nPixelsX; ibx++) { */
/* ipx=ibx%nSubPixelsX-nSubPixelsX/2; */
/* if (ipx<0) ipx=nSubPixelsX+ipx; */
/* for (int iby=0 ; iby<nSubPixelsY*nPixelsY; iby++) { */
/* ipy=iby%nSubPixelsY-nSubPixelsY/2; */
/* if (ipy<0) ipy=nSubPixelsY+ipy; */
/* // cout << ipx << " " << ipy << " " << ibx << " " << iby << endl; */
/* 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*nSubPixelsX*nPixelsX]=hint[ibx+iby*nSubPixelsX*nPixelsX]; */
/* } */
/* } */
return hint;
/* return hintcorr; */
};
protected:
@ -363,19 +398,575 @@ float *gethhx()
return sqrt(diff);
}
float *hhx;
float *hhy;
int *heta;
int nbetaX, nbetaY;
double etamin, etamax, etastepX, etastepY;
double rangeMin, rangeMax;
double *flat;
int *hintcorr;
};
class eta2InterpolationBase : public virtual etaInterpolationBase {
public:
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) {
};
eta2InterpolationBase(eta2InterpolationBase *orig): etaInterpolationBase(orig){ };
//////////////////////////////////////////////////////////////////////////////
//////////// /*It return position hit for the event in input */ //////////////
virtual void getInterpolatedPosition(int x, int y, int *data, double &int_x, double &int_y)
{
double sDum[2][2];
double tot, totquad;
double etax=0,etay=0;
int corner;
corner=calcQuad(data, tot, totquad, sDum);
if (nSubPixelsX>2 || nSubPixelsY>2)
calcEta(totquad, sDum, etax, etay);
getInterpolatedPosition(x,y,etax,etay,corner,int_x,int_y);
return;
};
virtual void getInterpolatedPosition(int x, int y, double *data, double &int_x, double &int_y)
{
double sDum[2][2];
double tot, totquad;
double etax=0,etay=0;
int corner;
corner=calcQuad(data, tot, totquad, sDum);
if (nSubPixelsX>2 || nSubPixelsY>2 )
calcEta(totquad, sDum, etax, etay);
getInterpolatedPosition(x,y,etax,etay,corner,int_x,int_y);
return;
};
virtual void getInterpolatedPosition(int x, int y, double totquad,int quad,double *cl,double &int_x, double &int_y) {
double cc[2][2];
int xoff=0, yoff=0;
switch (quad) {
case BOTTOM_LEFT:
xoff=0;
yoff=0;
break;
case BOTTOM_RIGHT:
xoff=1;
yoff=0;
break;
case TOP_LEFT:
xoff=0;
yoff=1;
break;
case TOP_RIGHT:
xoff=1;
yoff=1;
break;
default:
;
}
double etax=0, etay=0;
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];
cc[1][1]=cl[xoff+1+3*(yoff+1)];
calcEta(totquad,cc,etax,etay);
}
return getInterpolatedPosition(x,y,etax, etay,quad,int_x,int_y);
}
virtual void getInterpolatedPosition(int x, int y, double totquad,int quad,int *cl,double &int_x, double &int_y) {
double cc[2][2];
int xoff=0, yoff=0;
switch (quad) {
case BOTTOM_LEFT:
xoff=0;
yoff=0;
break;
case BOTTOM_RIGHT:
xoff=1;
yoff=0;
break;
case TOP_LEFT:
xoff=0;
yoff=1;
break;
case TOP_RIGHT:
xoff=1;
yoff=1;
break;
default:
;
}
double etax=0, etay=0;
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];
cc[1][1]=cl[xoff+1+3*(xoff+1)];
calcEta(totquad,cc,etax,etay);
}
return getInterpolatedPosition(x,y,etax, etay,quad,int_x,int_y);
}
virtual void getInterpolatedPosition(int x, int y, double etax, double etay, int corner, double &int_x, double &int_y)
{
double xpos_eta=0,ypos_eta=0;
double dX,dY;
int ex,ey;
switch (corner)
{
case TOP_LEFT:
dX=-1.;
dY=0;
break;
case TOP_RIGHT:
;
dX=0;
dY=0;
break;
case BOTTOM_LEFT:
dX=-1.;
dY=-1.;
break;
case BOTTOM_RIGHT:
dX=0;
dY=-1.;
break;
default:
cout << "bad quadrant" << endl;
dX=0.;
dY=0.;
}
if (nSubPixelsX>2 || nSubPixelsY>2 ) {
ex=(etax-etamin)/etastepX;
ey=(etay-etamin)/etastepY;
if (ex<0) {
cout << "x*"<< ex << endl;
ex=0;
}
if (ex>=nbetaX) {
cout << "x?"<< ex << endl;
ex=nbetaX-1;
}
if (ey<0) {
cout << "y*"<< ey << " " << nbetaY << endl;
ey=0;
}
if (ey>=nbetaY) {
cout << "y?"<< ey << " " << nbetaY << endl;
ey=nbetaY-1;
}
xpos_eta=(((double)hhx[(ey*nbetaX+ex)]));
ypos_eta=(((double)hhy[(ey*nbetaX+ex)]));
if (xpos_eta<0 || xpos_eta>1)
xpos_eta=-100;
else
xpos_eta+=dX ;///((double)nSubPixels);
if (ypos_eta<0 || ypos_eta>1)
ypos_eta=-100;
else
ypos_eta+=dY ;///((double)nSubPixels);
} else {
xpos_eta=0.5*dX+0.25;
ypos_eta=0.5*dY+0.25;
}
if (xpos_eta<-1)
int_x=-100;
else
int_x=((double)x) + xpos_eta+0.5;
if (ypos_eta<-1)
int_y=-100;
else
int_y=((double)y) + ypos_eta+0.5;
}
virtual int addToFlatField(double totquad,int quad,int *cl,double &etax, double &etay) {
double cc[2][2];
int xoff=0, yoff=0;
switch (quad) {
case BOTTOM_LEFT:
xoff=0;
yoff=0;
break;
case BOTTOM_RIGHT:
xoff=1;
yoff=0;
break;
case TOP_LEFT:
xoff=0;
yoff=1;
break;
case TOP_RIGHT:
xoff=1;
yoff=1;
break;
default:
;
}
cc[0][0]=cl[xoff+3*yoff];
cc[1][0]=cl[xoff+3*(yoff+1)];
cc[0][1]=cl[xoff+1+3*yoff];
cc[1][1]=cl[xoff+1+3*(yoff+1)];
//calcMyEta(totquad,quad,cl,etax, etay);
calcEta(totquad, cc,etax, etay);
// cout <<"******"<< etax << " " << etay << endl;
return addToFlatField(etax,etay);
}
virtual int addToFlatField(double totquad,int quad,double *cl,double &etax, double &etay) {
double cc[2][2];
int xoff=0, yoff=0;
switch (quad) {
case BOTTOM_LEFT:
xoff=0;
yoff=0;
break;
case BOTTOM_RIGHT:
xoff=1;
yoff=0;
break;
case TOP_LEFT:
xoff=0;
yoff=1;
break;
case TOP_RIGHT:
xoff=1;
yoff=1;
break;
default:
;
}
cc[0][0]=cl[xoff+3*yoff];
cc[1][0]=cl[(yoff+1)*3+xoff];
cc[0][1]=cl[yoff*3+xoff+1];
cc[1][1]=cl[(yoff+1)*3+xoff+1];
/* cout << cl[0] << " " << cl[1] << " " << cl[2] << endl; */
/* cout << cl[3] << " " << cl[4] << " " << cl[5] << endl; */
/* cout << cl[6] << " " << cl[7] << " " << cl[8] << endl; */
/* cout <<"******"<<totquad << " " << quad << endl; */
/* cout << cc[0][0]<< " " << cc[0][1] << endl; */
/* cout << cc[1][0]<< " " << cc[1][1] << endl; */
//calcMyEta(totquad,quad,cl,etax, etay);
calcEta(totquad, cc,etax, etay);
// cout <<"******"<< etax << " " << etay << endl;
return addToFlatField(etax,etay);
}
//////////////////////////////////////////////////////////////////////////////////////
virtual int addToFlatField(double *cluster, double &etax, double &etay){
double sDum[2][2];
double tot, totquad;
// int corner;
//corner=
calcQuad(cluster, tot, totquad, sDum);
//double xpos_eta,ypos_eta;
//double dX,dY;
calcEta(totquad, sDum, etax, etay);
return addToFlatField(etax,etay);
};
virtual int addToFlatField(int *cluster, double &etax, double &etay){
double sDum[2][2];
double tot, totquad;
//int corner;
//corner=
calcQuad(cluster, tot, totquad, sDum);
// double xpos_eta,ypos_eta;
//double dX,dY;
calcEta(totquad, sDum, etax, etay);
return addToFlatField(etax,etay);
};
virtual int addToFlatField(double etax, double etay){
#ifdef MYROOT1
heta->Fill(etax,etay);
#endif
#ifndef MYROOT1
int ex,ey;
ex=(etax-etamin)/etastepX;
ey=(etay-etamin)/etastepY;
if (ey<nbetaY && ex<nbetaX && ex>=0 && ey>=0)
heta[ey*nbetaX+ex]++;
#endif
return 0;
};
};
class eta3InterpolationBase : public virtual etaInterpolationBase {
public:
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;
};
eta3InterpolationBase(eta3InterpolationBase *orig): etaInterpolationBase(orig){ };
//////////////////////////////////////////////////////////////////////////////
//////////// /*It return position hit for the event in input */ //////////////
virtual void getInterpolatedPosition(int x, int y, int *data, double &int_x, double &int_y)
{
double tot;
double etax,etay;
int corner=calcEta3(data,etax,etay, tot);
getInterpolatedPosition(x,y,etax,etay,corner,int_x,int_y);
return;
};
virtual void getInterpolatedPosition(int x, int y, double *data, double &int_x, double &int_y)
{
//double sDum[2][2];
double tot;
double etax,etay;
int corner=calcEta3(data,etax,etay, tot);
getInterpolatedPosition(x,y,etax,etay,corner,int_x,int_y);
return;
};
virtual void getInterpolatedPosition(int x, int y, double totquad,int quad,double *cl,double &int_x, double &int_y) {
double etax, etay;
if (nSubPixelsX>2 || nSubPixelsY>2 ) {
calcEta3(cl,etax,etay, totquad);
}
return getInterpolatedPosition(x,y,etax, etay,quad,int_x,int_y);
}
virtual void getInterpolatedPosition(int x, int y, double totquad,int quad,int *cl,double &int_x, double &int_y) {
double etax, etay;
if (nSubPixelsX>2 || nSubPixelsY>2 ) {
calcEta3(cl,etax,etay, totquad);
}
return getInterpolatedPosition(x,y,etax, etay,quad,int_x,int_y);
}
virtual void getInterpolatedPosition(int x, int y, double etax, double etay, int corner, double &int_x, double &int_y)
{
//cout << "**";
double xpos_eta=0,ypos_eta=0;
int ex,ey;
if (nSubPixelsX>2 || nSubPixelsY>2 ) {
#ifdef MYROOT1
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)/etastepX;
ey=(etay-etamin)/etastepY;
if (ex<0) {
/* cout << etax << " " << etamin << " "; */
/* cout << "3x*"<< ex << endl; */
ex=0;
}
if (ex>=nbetaX) {
/* cout << etax << " " << etamin << " "; */
/* cout << "3x?"<< ex << endl; */
ex=nbetaX-1;
}
if (ey<0) {
/* cout << etay << " " << etamin << " "; */
/* cout << "3y*"<< ey << endl; */
ey=0;
}
if (ey>=nbetaY) {
/* cout << etay << " " << etamin << " "; */
/* cout << "3y?"<< ey << endl; */
ey=nbetaY-1;
}
xpos_eta=(((double)hhx[(ey*nbetaX+ex)]));///((double)nSubPixels);
ypos_eta=(((double)hhy[(ey*nbetaX+ex)]));///((double)nSubPixels);
#endif
} else {
switch (corner) {
case BOTTOM_LEFT:
xpos_eta=-0.25;
ypos_eta=-0.25;
break;
case BOTTOM_RIGHT:
xpos_eta=0.25;
ypos_eta=-0.25;
break;
case TOP_LEFT:
xpos_eta=-0.25;
ypos_eta=0.25;
break;
case TOP_RIGHT:
xpos_eta=0.25;
ypos_eta=0.25;
break;
default:
xpos_eta=0;
ypos_eta=0;
}
}
/* if (xpos_eta<0 || xpos_eta>1) */
/* int_x=-1; */
/* else */
int_x=((double)x) + xpos_eta;
/* if (ypos_eta<0 || ypos_eta>1) */
/* int_y=-1; */
/* else */
int_y=((double)y) + ypos_eta;
// int_x=5. + xpos_eta;
// int_y=5. + ypos_eta;
}
virtual int addToFlatField(double totquad,int quad,int *cl,double &etax, double &etay) {
calcEta3(cl, etax, etay, totquad);
return addToFlatField(etax,etay);
}
virtual int addToFlatField(double totquad,int quad,double *cl,double &etax, double &etay) {
calcEta3(cl, etax, etay, totquad);
return addToFlatField(etax,etay);
}
//////////////////////////////////////////////////////////////////////////////////////
virtual int addToFlatField(double *cluster, double &etax, double &etay){
double totquad;
calcEta3(cluster, etax, etay, totquad);
return addToFlatField(etax,etay);
};
virtual int addToFlatField(int *cluster, double &etax, double &etay){
double totquad;
calcEta3(cluster, etax, etay, totquad);
return addToFlatField(etax,etay);
};
virtual int addToFlatField(double etax, double etay){
#ifdef MYROOT1
heta->Fill(etax,etay);
#endif
#ifndef MYROOT1
int ex,ey;
ex=(etax-etamin)/etastepX;
ey=(etay-etamin)/etastepY;
if (ey<nbetaY && ex<nbetaX && ex>=0 && ey>=0)
heta[ey*nbetaX+ex]++;
#endif
return 0;
};
};
#endif

View File

@ -4,11 +4,11 @@
#include "etaInterpolationBase.h"
class etaInterpolationGlobal : public etaInterpolationBase{
class etaInterpolationGlobal : public virtual etaInterpolationBase {
public:
globalEtaInterpolation(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){};
etaInterpolationGlobal(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){};
virtual void prepareInterpolation(int &ok)
{
@ -24,62 +24,106 @@ class etaInterpolationGlobal : public etaInterpolationBase{
///*Eta Distribution Rebinning*///
double bsize=1./nSubPixels; //precision
// double bsizeX=1./nSubPixelsX; //precision
// cout<<"nPixelsX = "<<nPixelsX<<" nPixelsY = "<<nPixelsY<<" nSubPixels = "<<nSubPixels<<endl;
double tot_eta=0;
for (int ip=0; ip<nbeta*nbeta; ip++)
for (int ip=0; ip<nbetaX*nbetaY; ip++)
tot_eta+=heta[ip];
cout << "total eta entries is :"<< tot_eta << endl;
if (tot_eta<=0) {ok=0; return;};
double hx[nbeta]; //projection x
double hy[nbeta]; //projection y
double hx[nbetaX]; //projection x
double hy[nbetaY]; //projection y
for (int ibx=0; ibx<nbeta; ibx++) {
for (int iby=0; iby<nbeta; iby++) {
hx[ibx]=hx[ibx]+heta[ibx+iby*nbeta];
hy[iby]=hx[iby]+heta[ibx+iby*nbeta];
for (int ibx=0; ibx<nbetaX; ibx++) { hx[ibx]=0;}
for (int iby=0; iby<nbetaY; iby++) { hy[iby]=0;}
for (int ibx=0; ibx<nbetaX; ibx++) {
for (int iby=0; iby<nbetaY; iby++) {
hx[ibx]=hx[ibx]+heta[ibx+iby*nbetaX];
hy[iby]=hy[iby]+heta[ibx+iby*nbetaX];
}
}
double hix[nbeta]; //integral of projection x
double hiy[nbeta]; //integral of projection y
double hix[nbetaX]; //integral of projection x
double hiy[nbetaY]; //integral of projection y
hix[0]=hx[0];
hiy[0]=hy[0];
for (int ib=1; ib<nbeta; ib++) {
for (int ib=1; ib<nbetaX; ib++) {
hix[ib]=hix[ib-1]+hx[ib];
hiy[ib]=hiy[ib-1]+hx[ib];
}
for (int ib=1; ib<nbetaY; ib++) {
hiy[ib]=hiy[ib-1]+hy[ib];
}
double tot_x=hix[nbetaX-1]+1;
double tot_y=hiy[nbetaY-1]+1;
int ib=0;
for (int ibx=0; ibx<nbeta; ibx++) {
if (hix[ibx]>(ib+1)*tot_eta*bsize) ib++;
for (int iby=0; iby<nbeta; iby++) {
#ifdef MYROOT1
hhx->SetBinContent(ibx+1,iby+1,ib);
#endif
#ifndef MYROOT1
hhx[ibx+iby*nbeta]=ib;
#endif
}
}
ib=0;
for (int iby=0; iby<nbeta; iby++) {
if (hiy[iby]>(ib+1)*tot_eta*bsize) ib++;
for (int ibx=0; ibx<nbeta; ibx++) {
#ifdef MYROOT1
hhy->SetBinContent(ibx+1,iby+1,ib);
#endif
#ifndef MYROOT1
hhy[ibx+iby*nbeta]=ib;
#endif
for (int ibx=0; ibx<nbetaX; ibx++) {
// if (hix[ibx]>(ib+1)*tot_eta*bsize) ib++;
for (int iby=0; iby<nbetaY; iby++) {
if (tot_x>0)
hhx[ibx+iby*nbetaX]=hix[ibx]/tot_x;
else
hhx[ibx+iby*nbetaX]=-1;
if (tot_y>0)
hhy[ibx+iby*nbetaX]=hiy[iby]/tot_y;
else
hhy[ibx+iby*nbetaX]=-1;
}
}
/* ib=0; */
/* for (int iby=0; iby<nbeta; iby++) { */
/* if (hiy[iby]>(ib+1)*tot_eta*bsize) ib++; */
/* for (int ibx=0; ibx<nbeta; ibx++) { */
/* #ifdef MYROOT1 */
/* hhy->SetBinContent(ibx+1,iby+1,ib); */
/* #endif */
/* #ifndef MYROOT1 */
/* hhy[ibx+iby*nbeta]=ib; */
/* #endif */
/* } */
/* } */
return ;
};
etaInterpolationGlobal(etaInterpolationGlobal *orig): etaInterpolationBase(orig) {};
};
//etaInterpolationBase(nx,ny, ns, nsy, nb, nby, emin, emax),
class eta2InterpolationGlobal : public virtual eta2InterpolationBase, public virtual etaInterpolationGlobal {
public:
eta2InterpolationGlobal(int nx=400, int ny=400, int ns=25, int nsy=25, int nb=-1, int nby=-1, double emin=1, double emax=0) : eta2InterpolationBase(nx,ny, ns, nsy, nb, nby, emin, emax), etaInterpolationGlobal(nx,ny, ns, nsy, nb, nby, emin, emax){
cout << "e2pxy " << nbetaX << " " << nbetaY << etamin << " " << etamax << " " << nSubPixelsX<< " " << nSubPixelsY << endl;
};
eta2InterpolationGlobal(eta2InterpolationGlobal *orig): etaInterpolationBase(orig), etaInterpolationGlobal(orig) {};
virtual eta2InterpolationGlobal* Clone() { return new eta2InterpolationGlobal(this);};
};
//etaInterpolationBase(nx,ny, ns, nsy, nb, nby, emin, emax),
class eta3InterpolationGlobal : public virtual eta3InterpolationBase, public virtual etaInterpolationGlobal {
public:
eta3InterpolationGlobal(int nx=400, int ny=400, int ns=25, int nsy=25, int nb=-1, int nby=-1, double emin=1, double emax=0) : eta3InterpolationBase(nx,ny, ns, nsy, nb, nby, emin, emax), etaInterpolationGlobal(nx,ny, ns, nsy, nb, nby, emin, emax){
cout << "e3pxy " << nbetaX << " " << nbetaY << etamin << " " << etamax << " " << nSubPixelsX<< " " << nSubPixelsY << endl;
};
eta3InterpolationGlobal(eta3InterpolationGlobal *orig): etaInterpolationBase(orig), etaInterpolationGlobal(orig) {};
virtual eta3InterpolationGlobal* Clone() {return new eta3InterpolationGlobal(this);};
};
#endif

View File

@ -4,8 +4,6 @@
//#include "tiffIO.h"
#include "etaInterpolationBase.h"
#include "eta2InterpolationBase.h"
#include "eta3InterpolationBase.h"
class etaInterpolationPosXY : public virtual etaInterpolationBase{
public:
@ -44,9 +42,8 @@ class etaInterpolationPosXY : public virtual etaInterpolationBase{
double hiy[nbetaY]; //integral of projection y
// int ii=0;
double etax, etay;
for (int ib=0; ib<nbetaX; ib++) {
for (int ib=0; ib<nbetaX; ib++) {
//tot_eta_y=0;
for (int iby=0; iby<nbetaY; iby++) {
@ -54,10 +51,10 @@ class etaInterpolationPosXY : public virtual etaInterpolationBase{
//cout << etax << endl;
// tot_eta_x+=hx[iby];
if (etay>=0 && etay<=1)
// if (etay>=0 && etay<=1)
hy[iby]=heta[ib+iby*nbetaX];
else
hy[iby]=0;
// else
// hy[iby]=0;
// tot_eta_y+=hy[iby];
}
@ -71,7 +68,7 @@ class etaInterpolationPosXY : public virtual etaInterpolationBase{
tot_eta_y=hiy[nbetaY-1]+1;
for (int iby=0; iby<nbetaY; iby++) {
if (tot_eta_y<=0) {
if (tot_eta_y<=1) {
hhy[ib+iby*nbetaX]=-1;
//ii=(ibx*nSubPixels)/nbeta;
} else {
@ -80,7 +77,7 @@ class etaInterpolationPosXY : public virtual etaInterpolationBase{
}
}
}
cout << "hhy filled " << endl;
for (int ib=0; ib<nbetaY; ib++) {
@ -88,11 +85,11 @@ class etaInterpolationPosXY : public virtual etaInterpolationBase{
for (int ibx=0; ibx<nbetaX; ibx++) {
etax=etamin+ibx*etastepX;
//cout << etax << endl;
if (etax>=0 && etax<=1)
// if (etax>=0 && etax<=1)
hx[ibx]=heta[ibx+ib*nbetaX];
else {
hx[ibx]=0;
}
// else {
// hx[ibx]=0;
// }
}
hix[0]=hx[0];
@ -104,7 +101,7 @@ class etaInterpolationPosXY : public virtual etaInterpolationBase{
tot_eta_x=hix[nbetaX-1]+1;
for (int ibx=0; ibx<nbetaX; ibx++) {
if (tot_eta_x<=0) {
if (tot_eta_x<=1) {
hhx[ibx+ib*nbetaX]=-1;
}
else {
@ -122,40 +119,49 @@ class etaInterpolationPosXY : public virtual etaInterpolationBase{
hhx[ibx+ib*nbetaX]=hix[ibx]/tot_eta_x;
}
}
}
}
int ibx, iby, ib;
/* cout << "hhx filled " << endl; */
/* int ibx, iby, ib; */
iby=0;
while (hhx[iby*nbetaY+nbetaY/2]<0) iby++;
for (ib=0; ib<iby;ib++) {
for (ibx=0; ibx<nbetaX;ibx++)
hhx[ibx+nbetaX*ib]=hhx[ibx+nbetaX*iby];
}
iby=nbetaY-1;
/* iby=0; */
/* while (hhx[iby*nbetaY+nbetaY/2]<0 && iby<nbetaY/2) iby++; */
/* for (ib=0; ib<iby;ib++) { */
/* for (ibx=0; ibx<nbetaX;ibx++) */
/* hhx[ibx+nbetaX*ib]=hhx[ibx+nbetaX*iby]; */
/* } */
while (hhx[iby*nbetaY+nbetaY/2]<0) iby--;
for (ib=iby+1; ib<nbetaY;ib++) {
for (ibx=0; ibx<nbetaX;ibx++)
hhx[ibx+nbetaX*ib]=hhx[ibx+nbetaX*iby];
}
iby=0;
while (hhy[nbetaX/2*nbetaX+iby]<0) iby++;
for (ib=0; ib<iby;ib++) {
for (ibx=0; ibx<nbetaY;ibx++)
hhy[ib+nbetaX*ibx]=hhy[iby+nbetaX*ibx];
}
iby=nbetaX-1;
while (hhy[nbetaX/2*nbetaX+iby]<0) iby--;
for (ib=iby+1; ib<nbetaX;ib++) {
for (ibx=0; ibx<nbetaY;ibx++)
hhy[ib+nbetaX*ibx]=hhy[iby+nbetaX*ibx];
}
/* cout << "hhx low optimized" << endl; */
/* iby=nbetaY-1; */
/* while (hhx[iby*nbetaY+nbetaY/2]<0 && iby>0) iby--; */
/* for (ib=iby+1; ib<nbetaY;ib++) { */
/* for (ibx=0; ibx<nbetaX;ibx++){ */
/* cout << iby << " " << ib << " " << ibx << " " << ibx+nbetaX*ib << " " << ibx+nbetaX*iby << " " << nbetaX*nbetaY << endl; */
/* hhx[ibx+nbetaX*ib]=hhx[ibx+nbetaX*iby]; */
/* } */
/* } */
/* cout << "hhx high optimized" << endl; */
/* iby=0; */
/* while (hhy[nbetaX/2*nbetaX+iby]<0 && iby<nbetaX) iby++; */
/* for (ib=0; ib<iby;ib++) { */
/* for (ibx=0; ibx<nbetaY;ibx++) */
/* hhy[ib+nbetaX*ibx]=hhy[iby+nbetaX*ibx]; */
/* } */
/* cout << "hhy low optimized" << endl; */
/* iby=nbetaX-1; */
/* while (hhy[nbetaX/2*nbetaX+iby]<0 && iby>) iby--; */
/* for (ib=iby+1; ib<nbetaX;ib++) { */
/* for (ibx=0; ibx<nbetaY;ibx++) */
/* hhy[ib+nbetaX*ibx]=hhy[iby+nbetaX*ibx]; */
/* } */
/* cout << "hhy high optimized" << endl; */
@ -180,7 +186,7 @@ class etaInterpolationPosXY : public virtual etaInterpolationBase{
class eta2InterpolationPosXY : public virtual eta2InterpolationBase, public virtual etaInterpolationPosXY {
public:
eta2InterpolationPosXY(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),eta2InterpolationBase(nx,ny, ns, nsy, nb, nby, emin, emax),etaInterpolationPosXY(nx,ny, ns, nsy, nb, nby, emin, emax){
// cout << "e2pxy " << nb << " " << emin << " " << emax << endl;
cout << "e2pxy " << nbetaX << " " << nbetaY << etamin << " " << etamax << " " << nSubPixelsX<< " " << nSubPixelsY << endl;
};
eta2InterpolationPosXY(eta2InterpolationPosXY *orig): etaInterpolationBase(orig), etaInterpolationPosXY(orig) {};
@ -189,12 +195,12 @@ class eta2InterpolationPosXY : public virtual eta2InterpolationBase, public virt
};
//
class eta3InterpolationPosXY : public virtual eta3InterpolationBase, public virtual etaInterpolationPosXY {
public:
eta3InterpolationPosXY(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),eta3InterpolationBase(nx,ny, ns, nsy, nb, nby, emin, emax), etaInterpolationPosXY(nx,ny, ns, nsy, nb, nby, emin, emax){
// cout << "e3pxy " << nbeta << " " << etamin << " " << etamax << " " << nSubPixels<< endl;
eta3InterpolationPosXY(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), eta3InterpolationBase(nx,ny, ns, nsy, nb, nby, emin, emax), etaInterpolationPosXY(nx,ny, ns, nsy, nb, nby, emin, emax){
cout << "e3pxy " << nbetaX << " " << nbetaY << etamin << " " << etamax << " " << nSubPixelsX<< " " << nSubPixelsY << endl;
};
eta3InterpolationPosXY(eta3InterpolationPosXY *orig): etaInterpolationBase(orig), etaInterpolationPosXY(orig) {};

View File

@ -94,10 +94,7 @@ class slsInterpolation
//create interpolated image
//returns interpolated image
virtual int *getInterpolatedImage(){
// cout << "return interpolated image " << endl;
/* for (int i=0; i<nSubPixels* nSubPixels* nPixelsX*nPixelsY; i++) { */
/* cout << i << " " << hint[i] << endl; */
/* } */
//cout << "?" <<endl;
return hint;
};
@ -105,17 +102,21 @@ class slsInterpolation
void *writeInterpolatedImage(const char * imgname) {
//cout << "!" <<endl;
float *gm=NULL;
//cout << "!" <<endl;
int *dummy=getInterpolatedImage();
cout << "got interpolated image " << endl;
gm=new float[ nSubPixelsX* nSubPixelsY* nPixelsX*nPixelsY];
cout << "created dummy " << endl;
if (gm) {
for (int ix=0; ix<nPixelsX*nSubPixelsX; ix++) {
for (int iy=0; iy<nPixelsY*nSubPixelsY; iy++) {
gm[iy*nPixelsX*nSubPixelsX+ix]=dummy[iy*nPixelsX*nSubPixelsX+ix];
// cout << "++" << ix << " " << iy << " " << iy*nPixelsX*nSubPixelsX+ix << endl;
}
}
WriteToTiff(gm, imgname,nSubPixelsY* nPixelsX ,nSubPixelsY* nPixelsY);
WriteToTiff(gm, imgname,nSubPixelsX* nPixelsX ,nSubPixelsY* nPixelsY);
// cout << "wrote to tiff " << endl;
delete [] gm;
} else cout << "Could not allocate float image " << endl;
return NULL;
@ -188,6 +189,7 @@ class slsInterpolation
static int calcQuad(double *cl, double &sum, double &totquad, double sDum[2][2]){
//cout << "2";
int corner = UNDEFINED_QUADRANT;
/* double *cluster[3]; */
@ -368,6 +370,7 @@ class slsInterpolation
static int calcEta3(double *cl, double &etax, double &etay, double &sum) {
// cout << "3";
double l=0,r=0,t=0,b=0, val;
sum=0;
// int quad;
@ -375,10 +378,10 @@ class slsInterpolation
for (int iy=0; iy<3; iy++) {
val=cl[ix+3*iy];
sum+=val;
if (iy==0) l+=val;
if (iy==2) r+=val;
if (ix==0) b+=val;
if (ix==2) t+=val;
if (ix==0) l+=val;
if (ix==2) r+=val;
if (iy==0) b+=val;
if (iy==2) t+=val;
}
}
if (sum>0) {