mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-23 01:58:00 +02:00
formatted slsDetectorCalibration
This commit is contained in:
@ -4,405 +4,378 @@
|
||||
#define ETA2_INTERPOLATION_BASE_H
|
||||
|
||||
#ifdef MYROOT1
|
||||
#include <TObject.h>
|
||||
#include <TTree.h>
|
||||
#include <TH2D.h>
|
||||
#include <TH2F.h>
|
||||
#include <TObject.h>
|
||||
#include <TTree.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);
|
||||
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){
|
||||
|
||||
return;
|
||||
};
|
||||
|
||||
/* if (etamin>=etamax) { */
|
||||
/* etamin=-1; */
|
||||
/* etamax=2; */
|
||||
/* // cout << ":" <<endl; */
|
||||
/* } */
|
||||
/* etastep=(etamax-etamin)/nbeta; */
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
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);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
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);
|
||||
|
||||
return;
|
||||
};
|
||||
|
||||
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 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) {
|
||||
|
||||
virtual int addToFlatField(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:;
|
||||
}
|
||||
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);
|
||||
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]++;
|
||||
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;
|
||||
};
|
||||
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;
|
||||
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];
|
||||
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;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
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; */
|
||||
/* 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
|
||||
|
@ -4,270 +4,260 @@
|
||||
#define ETA3_INTERPOLATION_BASE_H
|
||||
|
||||
#ifdef MYROOT1
|
||||
#include <TObject.h>
|
||||
#include <TTree.h>
|
||||
#include <TH2D.h>
|
||||
#include <TH2F.h>
|
||||
#include <TObject.h>
|
||||
#include <TTree.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){ };
|
||||
class eta3InterpolationBase : public virtual etaInterpolationBase {
|
||||
|
||||
/* virtual eta3InterpolationBase* Clone()=0; */
|
||||
|
||||
|
||||
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; */
|
||||
/* } */
|
||||
|
||||
|
||||
// virtual void prepareInterpolation(int &ok){};
|
||||
|
||||
// cout << nbeta << " " << etamin << " " << etamax << endl;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//////////// /*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);
|
||||
eta3InterpolationBase(eta3InterpolationBase *orig)
|
||||
: etaInterpolationBase(orig){};
|
||||
|
||||
return;
|
||||
};
|
||||
|
||||
/* virtual eta3InterpolationBase* Clone()=0; */
|
||||
|
||||
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);
|
||||
// virtual void prepareInterpolation(int &ok){};
|
||||
|
||||
return;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//////////// /*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;
|
||||
|
||||
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);
|
||||
int corner = calcEta3(data, etax, etay, tot);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
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);
|
||||
getInterpolatedPosition(x, y, etax, etay, corner, int_x, int_y);
|
||||
|
||||
return;
|
||||
};
|
||||
|
||||
virtual int addToFlatField(int *cluster, double &etax, double &etay){
|
||||
|
||||
double totquad;
|
||||
|
||||
calcEta3(cluster, etax, etay, totquad);
|
||||
return addToFlatField(etax,etay);
|
||||
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) {
|
||||
|
||||
virtual int addToFlatField(double etax, double etay){
|
||||
#ifdef MYROOT1
|
||||
heta->Fill(etax,etay);
|
||||
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
|
||||
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; */
|
||||
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
|
||||
|
@ -3,285 +3,316 @@
|
||||
#ifndef ETA_INTERPOLATION_ADAPTIVEBINS_H
|
||||
#define ETA_INTERPOLATION_ADAPTIVEBINS_H
|
||||
|
||||
#include <cmath>
|
||||
#include "tiffIO.h"
|
||||
#include <cmath>
|
||||
//#include "etaInterpolationBase.h"
|
||||
#include "etaInterpolationPosXY.h"
|
||||
|
||||
|
||||
|
||||
class etaInterpolationAdaptiveBins : public etaInterpolationPosXY {
|
||||
|
||||
// protected:
|
||||
// protected:
|
||||
|
||||
private:
|
||||
virtual void iterate(float *newhhx, float *newhhy) {
|
||||
|
||||
private:
|
||||
double bsize = 1. / nSubPixels;
|
||||
|
||||
virtual void iterate(float *newhhx, float *newhhy) {
|
||||
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++) {
|
||||
|
||||
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++) {
|
||||
|
||||
for (ipy=0; ipy<nSubPixels; ipy++) {
|
||||
for (int ibx=0; ibx<nbeta; ibx++) {
|
||||
hx[ipy][ibx]=0;
|
||||
hy[ipy][ibx]=0;
|
||||
}
|
||||
}
|
||||
for (ipy = 0; ipy < nSubPixels; ipy++) {
|
||||
for (int ibx = 0; ibx < nbeta; ibx++) {
|
||||
hx[ipy][ibx] = 0;
|
||||
hy[ipy][ibx] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// cout << ipy << " " << ((ipy)*bsize) << " " << ((ipy+1)*bsize) << endl;
|
||||
for (int ibx=0; ibx<nbeta; ibx++) {
|
||||
for (int iby=0; iby<nbeta; iby++) {
|
||||
ipy=hhy[ibx+iby*nbeta]*nSubPixels;
|
||||
if (ipy<0) ipy=0;
|
||||
if (ipy>=nSubPixels) ipy=nSubPixels-1;
|
||||
hx[ipy][ibx]+=heta[ibx+iby*nbeta];
|
||||
// cout << ipy << " " << ((ipy)*bsize) << " " << ((ipy+1)*bsize) <<
|
||||
// endl;
|
||||
for (int ibx = 0; ibx < nbeta; ibx++) {
|
||||
for (int iby = 0; iby < nbeta; iby++) {
|
||||
ipy = hhy[ibx + iby * nbeta] * nSubPixels;
|
||||
if (ipy < 0)
|
||||
ipy = 0;
|
||||
if (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];
|
||||
}
|
||||
}
|
||||
|
||||
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<nSubPixels; ipy++) {
|
||||
hix[ipy][0]=hx[ipy][0];
|
||||
hiy[ipy][0]=hy[ipy][0];
|
||||
for (int ib=1; ib<nbeta; ib++) {
|
||||
hix[ipy][ib]=hix[ipy][ib-1]+hx[ipy][ib];
|
||||
hiy[ipy][ib]=hiy[ipy][ib-1]+hy[ipy][ib];
|
||||
}
|
||||
tot_eta_x[ipy]=hix[ipy][nbeta-1]+1;
|
||||
tot_eta_y[ipy]=hiy[ipy][nbeta-1]+1;
|
||||
// cout << ipy << " " << tot_eta_x[ipy] << " " << tot_eta_y[ipy] << endl;
|
||||
|
||||
}
|
||||
// for (int ipy=0; ipy<nSubPixels; ipy++) {
|
||||
|
||||
for (int ibx=0; ibx<nbeta; ibx++) {
|
||||
for (int iby=0; iby<nbeta; iby++) {
|
||||
|
||||
// if ( hhy[ibx+iby*nbeta]>=((ipy)*bsize) && hhy[ibx+iby*nbeta]<=((ipy+1)*bsize)) {
|
||||
ipy=hhy[ibx+iby*nbeta]*nSubPixels;
|
||||
for (ipy = 0; ipy < nSubPixels; ipy++) {
|
||||
hix[ipy][0] = hx[ipy][0];
|
||||
hiy[ipy][0] = hy[ipy][0];
|
||||
for (int ib = 1; ib < nbeta; ib++) {
|
||||
hix[ipy][ib] = hix[ipy][ib - 1] + hx[ipy][ib];
|
||||
hiy[ipy][ib] = hiy[ipy][ib - 1] + hy[ipy][ib];
|
||||
}
|
||||
tot_eta_x[ipy] = hix[ipy][nbeta - 1] + 1;
|
||||
tot_eta_y[ipy] = hiy[ipy][nbeta - 1] + 1;
|
||||
// cout << ipy << " " << tot_eta_x[ipy] << " " << tot_eta_y[ipy] <<
|
||||
// endl;
|
||||
}
|
||||
// for (int ipy=0; ipy<nSubPixels; ipy++) {
|
||||
|
||||
if (ipy<0) ipy=0;
|
||||
if (ipy>=nSubPixels) ipy=nSubPixels-1;
|
||||
for (int ibx = 0; ibx < nbeta; ibx++) {
|
||||
for (int iby = 0; iby < nbeta; iby++) {
|
||||
|
||||
if (ipy>=0 && ipy<nSubPixels)
|
||||
if (tot_eta_x[ipy]>0)
|
||||
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 ( hhy[ibx+iby*nbeta]>=((ipy)*bsize) &&
|
||||
// hhy[ibx+iby*nbeta]<=((ipy+1)*bsize)) {
|
||||
ipy = hhy[ibx + iby * nbeta] * nSubPixels;
|
||||
|
||||
if (ipy>=0 && ipy<nSubPixels)
|
||||
if (tot_eta_y[ipy]>0)
|
||||
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;
|
||||
// }
|
||||
}
|
||||
}
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (ipy < 0)
|
||||
ipy = 0;
|
||||
if (ipy >= nSubPixels)
|
||||
ipy = nSubPixels - 1;
|
||||
|
||||
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];
|
||||
};
|
||||
if (ipy >= 0 && ipy < nSubPixels)
|
||||
if (tot_eta_x[ipy] > 0)
|
||||
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;
|
||||
|
||||
etaInterpolationAdaptiveBins(etaInterpolationAdaptiveBins *orig): etaInterpolationPosXY(orig){hintcorr=new int[nPixelsX*nPixelsY*nSubPixels];};
|
||||
if (ipy >= 0 && ipy < nSubPixels)
|
||||
if (tot_eta_y[ipy] > 0)
|
||||
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;
|
||||
// }
|
||||
}
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
||||
virtual etaInterpolationAdaptiveBins* Clone()=0;
|
||||
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];
|
||||
};
|
||||
|
||||
/* return new etaInterpolationAdaptiveBins(this); */
|
||||
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) {
|
||||
prepareInterpolation(ok, 1000);
|
||||
}
|
||||
|
||||
virtual void prepareInterpolation(int &ok, int nint)
|
||||
{
|
||||
ok=1;
|
||||
virtual void prepareInterpolation(int &ok, int nint) {
|
||||
ok = 1;
|
||||
|
||||
///*Eta Distribution Rebinning*///
|
||||
double bsize=1./nSubPixels; //precision
|
||||
// cout<<"nPixelsX = "<<nPixelsX<<" nPixelsY = "<<nPixelsY<<" nSubPixels = "<<nSubPixels<<endl;
|
||||
double tot_eta=0;
|
||||
double tot_eta_x=0;
|
||||
double tot_eta_y=0;
|
||||
for (int ip=0; ip<nbeta*nbeta; ip++)
|
||||
tot_eta+=heta[ip];
|
||||
if (tot_eta<=0) {ok=0; return;};
|
||||
///*Eta Distribution Rebinning*///
|
||||
double bsize = 1. / nSubPixels; // precision
|
||||
// cout<<"nPixelsX = "<<nPixelsX<<" nPixelsY = "<<nPixelsY<<" nSubPixels
|
||||
// = "<<nSubPixels<<endl;
|
||||
double tot_eta = 0;
|
||||
double tot_eta_x = 0;
|
||||
double tot_eta_y = 0;
|
||||
for (int ip = 0; ip < nbeta * nbeta; ip++)
|
||||
tot_eta += heta[ip];
|
||||
if (tot_eta <= 0) {
|
||||
ok = 0;
|
||||
return;
|
||||
};
|
||||
|
||||
double hx[nbeta]; // profile x
|
||||
double hy[nbeta]; // profile y
|
||||
double hix[nbeta]; // integral of projection x
|
||||
double hiy[nbeta]; // integral of projection y
|
||||
int ii = 0;
|
||||
|
||||
double hx[nbeta]; //profile x
|
||||
double hy[nbeta]; //profile y
|
||||
double hix[nbeta]; //integral of projection x
|
||||
double hiy[nbeta]; //integral of projection y
|
||||
int ii=0;
|
||||
/** initialize distribution to linear interpolation */
|
||||
// for (int ibx=0; ibx<nbeta; ibx++) {
|
||||
// for (int ib=0; ib<nbeta; ib++) {
|
||||
// hhx[ibx+ib*nbeta]=((float)ibx)/((float)nbeta);
|
||||
// hhy[ibx+ib*nbeta]=((float)ib)/((float)nbeta);
|
||||
// }
|
||||
// }
|
||||
|
||||
etaInterpolationPosXY::prepareInterpolation(ok);
|
||||
|
||||
/** initialize distribution to linear interpolation */
|
||||
// for (int ibx=0; ibx<nbeta; ibx++) {
|
||||
// for (int ib=0; ib<nbeta; ib++) {
|
||||
// hhx[ibx+ib*nbeta]=((float)ibx)/((float)nbeta);
|
||||
// hhy[ibx+ib*nbeta]=((float)ib)/((float)nbeta);
|
||||
// }
|
||||
// }
|
||||
|
||||
etaInterpolationPosXY::prepareInterpolation(ok);
|
||||
double thr = 1. / ((double)nSubPixels);
|
||||
double avg = tot_eta / ((double)(nSubPixels * nSubPixels));
|
||||
double rms = sqrt(tot_eta);
|
||||
cout << "total eta entries is :" << tot_eta << " avg: " << avg
|
||||
<< " rms: " << sqrt(tot_eta) << endl;
|
||||
double old_diff = calcDiff(avg, hhx, hhy), new_diff = old_diff + 1,
|
||||
best_diff = old_diff;
|
||||
// cout << " chi2= " << old_diff << " (rms= " << sqrt(tot_eta) << ")" <<
|
||||
// endl;
|
||||
cout << endl;
|
||||
cout << endl;
|
||||
debugSaveAll(0);
|
||||
int iint = 0;
|
||||
float *newhhx = new float[nbeta * nbeta]; // profile x
|
||||
float *newhhy = new float[nbeta * nbeta]; // profile y
|
||||
float *besthhx = hhx; // profile x
|
||||
float *besthhy = hhy; // profile y
|
||||
|
||||
cout << "Iteration " << iint << " Chi2: " << old_diff
|
||||
<< endl; //" Best: "<< best_diff << " RMS: "<< rms<< endl;
|
||||
while (iint < nint && best_diff > rms) {
|
||||
|
||||
double thr=1./((double)nSubPixels);
|
||||
double avg=tot_eta/((double)(nSubPixels*nSubPixels));
|
||||
double rms=sqrt(tot_eta);
|
||||
cout << "total eta entries is :"<< tot_eta << " avg: "<< avg << " rms: " << sqrt(tot_eta) << endl;
|
||||
double old_diff=calcDiff(avg, hhx, hhy), new_diff=old_diff+1, best_diff=old_diff;
|
||||
// cout << " chi2= " << old_diff << " (rms= " << sqrt(tot_eta) << ")" << endl;
|
||||
cout << endl;
|
||||
cout << endl;
|
||||
debugSaveAll(0);
|
||||
int iint=0;
|
||||
float *newhhx=new float[nbeta*nbeta]; //profile x
|
||||
float *newhhy=new float[nbeta*nbeta]; //profile y
|
||||
float *besthhx=hhx; //profile x
|
||||
float *besthhy=hhy; //profile y
|
||||
/* #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) <<
|
||||
// ")"<<endl;
|
||||
|
||||
cout << "Iteration "<< iint << " Chi2: " << old_diff << endl; //" Best: "<< best_diff << " RMS: "<< rms<< endl;
|
||||
while (iint<nint && best_diff > rms) {
|
||||
if (new_diff < best_diff) {
|
||||
best_diff = new_diff;
|
||||
besthhx = newhhx;
|
||||
besthhy = newhhy;
|
||||
}
|
||||
|
||||
/* #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) << ")"<<endl;
|
||||
if (hhx != besthhx)
|
||||
delete[] hhx;
|
||||
if (hhy != besthhy)
|
||||
delete[] hhy;
|
||||
|
||||
if (new_diff<best_diff) {
|
||||
best_diff=new_diff;
|
||||
besthhx=newhhx;
|
||||
besthhy=newhhy;
|
||||
}
|
||||
|
||||
if (hhx!=besthhx)
|
||||
delete [] hhx;
|
||||
if (hhy!=besthhy)
|
||||
delete [] hhy;
|
||||
|
||||
hhx=newhhx;
|
||||
hhy=newhhy;
|
||||
hhx = newhhx;
|
||||
hhy = newhhy;
|
||||
|
||||
|
||||
#ifdef SAVE_ALL
|
||||
if (new_diff<=best_diff) {
|
||||
debugSaveAll(iint);
|
||||
}
|
||||
if (new_diff <= best_diff) {
|
||||
debugSaveAll(iint);
|
||||
}
|
||||
#endif
|
||||
|
||||
newhhx = new float[nbeta * nbeta]; // profile x
|
||||
newhhy = new float[nbeta * nbeta]; // profile y
|
||||
|
||||
newhhx=new float[nbeta*nbeta]; //profile x
|
||||
newhhy=new float[nbeta*nbeta]; //profile y
|
||||
/* if (new_diff<old_diff){ */
|
||||
/* cout << "best difference at iteration "<< iint << " (" <<
|
||||
* new_diff << " < " << old_diff << ")"<< "Best: "<< best_diff << "
|
||||
* RMS: "<< sqrt(tot_eta) << endl; */
|
||||
/* ; */
|
||||
/* } else { */
|
||||
// break;
|
||||
// }
|
||||
|
||||
|
||||
/* if (new_diff<old_diff){ */
|
||||
/* cout << "best difference at iteration "<< iint << " (" << new_diff << " < " << old_diff << ")"<< "Best: "<< best_diff << " RMS: "<< sqrt(tot_eta) << endl; */
|
||||
/* ; */
|
||||
/* } else { */
|
||||
// break;
|
||||
// }
|
||||
|
||||
old_diff=new_diff;
|
||||
old_diff = new_diff;
|
||||
|
||||
iint++;
|
||||
cout << "Iteration "<< iint << " Chi2: " << new_diff << endl; //" Best: "<< best_diff << " RMS: "<< rms<< endl;
|
||||
}
|
||||
delete [] newhhx;
|
||||
delete [] newhhy;
|
||||
|
||||
if (hhx!=besthhx)
|
||||
delete [] hhx;
|
||||
if (hhy!=besthhy)
|
||||
delete [] hhy;
|
||||
|
||||
hhx=besthhx;
|
||||
hhy=besthhy;
|
||||
iint++;
|
||||
cout << "Iteration " << iint << " Chi2: " << new_diff
|
||||
<< endl; //" Best: "<< best_diff << " RMS: "<< rms<< endl;
|
||||
}
|
||||
delete[] newhhx;
|
||||
delete[] newhhy;
|
||||
|
||||
|
||||
cout << "Iteration "<< iint << " Chi2: " << best_diff << endl; //" Best: "<< best_diff << " RMS: "<< rms<< endl;
|
||||
if (hhx != besthhx)
|
||||
delete[] hhx;
|
||||
if (hhy != besthhy)
|
||||
delete[] hhy;
|
||||
|
||||
hhx = besthhx;
|
||||
hhy = besthhy;
|
||||
|
||||
cout << "Iteration " << iint << " Chi2: " << best_diff
|
||||
<< endl; //" Best: "<< best_diff << " RMS: "<< rms<< endl;
|
||||
#ifdef SAVE_ALL
|
||||
debugSaveAll(iint);
|
||||
debugSaveAll(iint);
|
||||
#endif
|
||||
|
||||
return ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
class eta2InterpolationAdaptiveBins : public virtual eta2InterpolationBase, public virtual etaInterpolationAdaptiveBins {
|
||||
public:
|
||||
eta2InterpolationAdaptiveBins(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(nx,ny,ns, nb, emin,emax),etaInterpolationAdaptiveBins(nx,ny,ns, nb, emin,emax){
|
||||
cout << "NSUBPIX is " << ns << " " << nSubPixels << endl;
|
||||
// cout << "e2pxy " << nb << " " << emin << " " << emax << endl;
|
||||
};
|
||||
|
||||
eta2InterpolationAdaptiveBins(eta2InterpolationAdaptiveBins *orig): etaInterpolationBase(orig), etaInterpolationAdaptiveBins(orig) {};
|
||||
|
||||
virtual eta2InterpolationAdaptiveBins* Clone() { return new eta2InterpolationAdaptiveBins(this);};
|
||||
|
||||
|
||||
class eta2InterpolationAdaptiveBins
|
||||
: public virtual eta2InterpolationBase,
|
||||
public virtual etaInterpolationAdaptiveBins {
|
||||
public:
|
||||
eta2InterpolationAdaptiveBins(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(nx, ny, ns, nb, emin, emax),
|
||||
etaInterpolationAdaptiveBins(nx, ny, ns, nb, emin, emax) {
|
||||
cout << "NSUBPIX is " << ns << " " << nSubPixels << endl;
|
||||
// cout << "e2pxy " << nb << " " << emin << " " << emax << endl;
|
||||
};
|
||||
|
||||
eta2InterpolationAdaptiveBins(eta2InterpolationAdaptiveBins *orig)
|
||||
: etaInterpolationBase(orig), etaInterpolationAdaptiveBins(orig){};
|
||||
|
||||
virtual eta2InterpolationAdaptiveBins *Clone() {
|
||||
return new eta2InterpolationAdaptiveBins(this);
|
||||
};
|
||||
};
|
||||
|
||||
class eta3InterpolationAdaptiveBins
|
||||
: public virtual eta3InterpolationBase,
|
||||
public virtual etaInterpolationAdaptiveBins {
|
||||
public:
|
||||
eta3InterpolationAdaptiveBins(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(nx, ny, ns, nb, emin, emax),
|
||||
etaInterpolationAdaptiveBins(nx, ny, ns, nb, emin, emax) {
|
||||
cout << "e3pxy " << nbeta << " " << etamin << " " << etamax << " "
|
||||
<< nSubPixels << endl;
|
||||
};
|
||||
|
||||
eta3InterpolationAdaptiveBins(eta3InterpolationAdaptiveBins *orig)
|
||||
: etaInterpolationBase(orig), etaInterpolationAdaptiveBins(orig){};
|
||||
|
||||
class eta3InterpolationAdaptiveBins : public virtual eta3InterpolationBase, public virtual etaInterpolationAdaptiveBins {
|
||||
public:
|
||||
eta3InterpolationAdaptiveBins(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(nx,ny,ns, nb, emin,emax), etaInterpolationAdaptiveBins(nx,ny,ns, nb, emin,emax){
|
||||
cout << "e3pxy " << nbeta << " " << etamin << " " << etamax << " " << nSubPixels<< endl;
|
||||
};
|
||||
|
||||
eta3InterpolationAdaptiveBins(eta3InterpolationAdaptiveBins *orig): etaInterpolationBase(orig), etaInterpolationAdaptiveBins(orig) {};
|
||||
|
||||
virtual eta3InterpolationAdaptiveBins* Clone() { return new eta3InterpolationAdaptiveBins(this);};
|
||||
virtual eta3InterpolationAdaptiveBins *Clone() {
|
||||
return new eta3InterpolationAdaptiveBins(this);
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -4,388 +4,379 @@
|
||||
#define ETA_INTERPOLATION_BASE_H
|
||||
|
||||
#ifdef MYROOT1
|
||||
#include <TObject.h>
|
||||
#include <TTree.h>
|
||||
#include <TH2D.h>
|
||||
#include <TH2F.h>
|
||||
#include <TObject.h>
|
||||
#include <TTree.h>
|
||||
#endif
|
||||
#include <cmath>
|
||||
#include "slsInterpolation.h"
|
||||
#include "tiffIO.h"
|
||||
#include <cmath>
|
||||
|
||||
class etaInterpolationBase : public slsInterpolation {
|
||||
|
||||
public:
|
||||
|
||||
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 (nbetaX<=0) {
|
||||
//cout << "aaa:" <<endl;
|
||||
nbetaX=nSubPixelsX*10;
|
||||
}
|
||||
if (nbetaY<=0) {
|
||||
//cout << "aaa:" <<endl;
|
||||
nbetaY=nSubPixelsY*10;
|
||||
}
|
||||
if (etamin>=etamax) {
|
||||
etamin=-1;
|
||||
etamax=2;
|
||||
}
|
||||
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[nSubPixelsX*nSubPixelsY];
|
||||
hintcorr=new int [nSubPixelsX*nSubPixelsY*nPixelsX*nPixelsY];
|
||||
|
||||
};
|
||||
|
||||
etaInterpolationBase(etaInterpolationBase *orig): slsInterpolation(orig){
|
||||
nbetaX=orig->nbetaX;
|
||||
nbetaY=orig->nbetaY;
|
||||
etamin=orig->etamin;
|
||||
etamax=orig->etamax;
|
||||
rangeMin=orig->rangeMin;
|
||||
rangeMax=orig->rangeMax;
|
||||
|
||||
|
||||
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];
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
virtual void resetFlatField() {
|
||||
for (int ibx=0; ibx<nbetaX*nbetaY; ibx++) {
|
||||
heta[ibx]=0;
|
||||
hhx[ibx]=0;
|
||||
hhy[ibx]=0;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
int *setEta(int *h, int nb=-1, int nby=-1, double emin=1, double emax=0)
|
||||
{
|
||||
if (h) {
|
||||
if (heta) delete [] heta;
|
||||
heta=h;
|
||||
nbetaX=nb;
|
||||
nbetaY=nby;
|
||||
if (nbetaX<=0) nbetaX=nSubPixelsX*10;
|
||||
if (nbetaY<=0) nbetaY=nSubPixelsY*10;
|
||||
|
||||
etamin=emin;
|
||||
etamax=emax;
|
||||
if (etamin>=etamax) {
|
||||
etamin=-1;
|
||||
etamax=2;
|
||||
}
|
||||
rangeMin=etamin;
|
||||
rangeMax=etamax;
|
||||
etastepX=(etamax-etamin)/nbetaX;
|
||||
etastepY=(etamax-etamin)/nbetaY;
|
||||
}
|
||||
return heta;
|
||||
};
|
||||
|
||||
int *setFlatField(int *h, int nb=-1, int nby=-1, double emin=1, double emax=0)
|
||||
{
|
||||
return setEta(h, nb, nby, emin, emax);
|
||||
};
|
||||
|
||||
|
||||
|
||||
int *getFlatField(){return setEta(NULL);};
|
||||
|
||||
int *getFlatField(int &nb, int &nby, double &emin, double &emax){
|
||||
nb=nbetaX;
|
||||
nby=nbetaY;
|
||||
emin=etamin;
|
||||
emax=etamax;
|
||||
return getFlatField();
|
||||
};
|
||||
|
||||
|
||||
void *writeFlatField(const char * imgname) {
|
||||
float *gm=NULL;
|
||||
gm=new float[nbetaX*nbetaY];
|
||||
for (int ix=0; ix<nbetaX; ix++) {
|
||||
for (int iy=0; iy<nbetaY; iy++) {
|
||||
gm[iy*nbetaX+ix]=heta[iy*nbetaX+ix];
|
||||
}
|
||||
}
|
||||
WriteToTiff(gm, imgname, nbetaX, nbetaY);
|
||||
delete [] gm;
|
||||
return NULL;
|
||||
};
|
||||
|
||||
int readFlatField(const char * imgname, double emin=1, double emax=0) {
|
||||
if (emax>=1) etamax=emax;
|
||||
if (emin<=0) etamin=emin;
|
||||
|
||||
if (etamin>=etamax) {
|
||||
etamin=-1;
|
||||
etamax=2;
|
||||
}
|
||||
|
||||
etastepX=(etamax-etamin)/nbetaX;
|
||||
etastepY=(etamax-etamin)/nbetaY;
|
||||
uint32_t nnx;
|
||||
uint32_t nny;
|
||||
float *gm=ReadFromTiff(imgname, nnx, nny);
|
||||
/* if (nnx!=nny) { */
|
||||
/* cout << "different number of bins in x " << nnx << " and y " << nny<< " !"<< endl; */
|
||||
/* cout << "Aborting read"<< endl; */
|
||||
/* return 0; */
|
||||
/* } */
|
||||
nbetaX=nnx;
|
||||
nbetaY=nny;
|
||||
if (gm) {
|
||||
if (heta) {
|
||||
delete [] heta;
|
||||
delete [] hhx;
|
||||
delete [] hhy;
|
||||
}
|
||||
|
||||
heta=new int[nbetaX*nbetaY];
|
||||
hhx=new float[nbetaX*nbetaY];
|
||||
hhy=new float[nbetaX*nbetaY];
|
||||
|
||||
for (int ix=0; ix<nbetaX; ix++) {
|
||||
for (int iy=0; iy<nbetaY; iy++) {
|
||||
heta[iy*nbetaX+ix]=gm[iy*nbetaX+ix];
|
||||
}
|
||||
}
|
||||
delete [] gm;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
float *gethhx()
|
||||
{
|
||||
// hhx->Scale((double)nSubPixels);
|
||||
return hhx;
|
||||
};
|
||||
|
||||
float *gethhy()
|
||||
{
|
||||
// hhy->Scale((double)nSubPixels);
|
||||
return hhy;
|
||||
public:
|
||||
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 (nbetaX <= 0) {
|
||||
// cout << "aaa:" <<endl;
|
||||
nbetaX = nSubPixelsX * 10;
|
||||
}
|
||||
if (nbetaY <= 0) {
|
||||
// cout << "aaa:" <<endl;
|
||||
nbetaY = nSubPixelsY * 10;
|
||||
}
|
||||
if (etamin >= etamax) {
|
||||
etamin = -1;
|
||||
etamax = 2;
|
||||
}
|
||||
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[nSubPixelsX * nSubPixelsY];
|
||||
hintcorr = new int[nSubPixelsX * nSubPixelsY * nPixelsX * nPixelsY];
|
||||
};
|
||||
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;
|
||||
|
||||
etaInterpolationBase(etaInterpolationBase *orig) : slsInterpolation(orig) {
|
||||
nbetaX = orig->nbetaX;
|
||||
nbetaY = orig->nbetaY;
|
||||
etamin = orig->etamin;
|
||||
etamax = orig->etamax;
|
||||
rangeMin = orig->rangeMin;
|
||||
rangeMax = orig->rangeMax;
|
||||
|
||||
void debugSaveAll(int ind=0) {
|
||||
int ibx, iby;
|
||||
char tit[10000];
|
||||
|
||||
float tot_eta=0;
|
||||
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];
|
||||
};
|
||||
|
||||
float *etah=new float[nbetaX*nbetaY];
|
||||
// int etabins=nbeta;
|
||||
int ibb=0;
|
||||
virtual void resetFlatField() {
|
||||
for (int ibx = 0; ibx < nbetaX * nbetaY; ibx++) {
|
||||
heta[ibx] = 0;
|
||||
hhx[ibx] = 0;
|
||||
hhy[ibx] = 0;
|
||||
}
|
||||
};
|
||||
|
||||
for (int ii=0; ii<nbetaX*nbetaY; ii++) {
|
||||
|
||||
etah[ii]=heta[ii];
|
||||
tot_eta+=heta[ii];
|
||||
}
|
||||
sprintf(tit,"/scratch/eta_%d.tiff",ind);
|
||||
WriteToTiff(etah, tit, nbetaX, nbetaY);
|
||||
int *setEta(int *h, int nb = -1, int nby = -1, double emin = 1,
|
||||
double emax = 0) {
|
||||
if (h) {
|
||||
if (heta)
|
||||
delete[] heta;
|
||||
heta = h;
|
||||
nbetaX = nb;
|
||||
nbetaY = nby;
|
||||
if (nbetaX <= 0)
|
||||
nbetaX = nSubPixelsX * 10;
|
||||
if (nbetaY <= 0)
|
||||
nbetaY = nSubPixelsY * 10;
|
||||
|
||||
etamin = emin;
|
||||
etamax = emax;
|
||||
if (etamin >= etamax) {
|
||||
etamin = -1;
|
||||
etamax = 2;
|
||||
}
|
||||
rangeMin = etamin;
|
||||
rangeMax = etamax;
|
||||
etastepX = (etamax - etamin) / nbetaX;
|
||||
etastepY = (etamax - etamin) / nbetaY;
|
||||
}
|
||||
return heta;
|
||||
};
|
||||
|
||||
for (int ii=0; ii<nbetaX*nbetaY; ii++) {
|
||||
ibb=(hhx[ii]*nSubPixelsX);
|
||||
etah[ii]=ibb;
|
||||
}
|
||||
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;
|
||||
}
|
||||
sprintf(tit,"/scratch/eta_hhy_%d.tiff",ind);
|
||||
WriteToTiff(etah, tit, nbetaX, nbetaY);
|
||||
|
||||
|
||||
float *ftest=new float[nSubPixelsX*nSubPixelsY];
|
||||
int *setFlatField(int *h, int nb = -1, int nby = -1, double emin = 1,
|
||||
double emax = 0) {
|
||||
return setEta(h, nb, nby, emin, emax);
|
||||
};
|
||||
|
||||
for (int ib=0; ib<nSubPixelsX*nSubPixelsY; ib++) ftest[ib]=0;
|
||||
|
||||
int *getFlatField() { return setEta(NULL); };
|
||||
|
||||
//int ibx=0, iby=0;
|
||||
|
||||
for (int ii=0; ii<nbetaX*nbetaY; ii++) {
|
||||
|
||||
ibx=nSubPixelsX*hhx[ii];
|
||||
iby=nSubPixelsY*hhy[ii];
|
||||
if (ibx<0) ibx=0;
|
||||
if (iby<0) iby=0;
|
||||
if (ibx>=nSubPixelsX) ibx=nSubPixelsX-1;
|
||||
if (iby>=nSubPixelsY) iby=nSubPixelsY-1;
|
||||
|
||||
int *getFlatField(int &nb, int &nby, double &emin, double &emax) {
|
||||
nb = nbetaX;
|
||||
nby = nbetaY;
|
||||
emin = etamin;
|
||||
emax = etamax;
|
||||
return getFlatField();
|
||||
};
|
||||
|
||||
if (ibx>=0 && ibx<nSubPixelsX && iby>=0 && iby<nSubPixelsY) {
|
||||
//
|
||||
// if (ibx>0 && iby>0) cout << ibx << " " << iby << " " << ii << endl;
|
||||
ftest[ibx+iby*nSubPixelsX]+=heta[ii];
|
||||
} else
|
||||
cout << "Bad interpolation "<< ii << " " << ibx << " " << iby<< endl;
|
||||
|
||||
}
|
||||
void *writeFlatField(const char *imgname) {
|
||||
float *gm = NULL;
|
||||
gm = new float[nbetaX * nbetaY];
|
||||
for (int ix = 0; ix < nbetaX; ix++) {
|
||||
for (int iy = 0; iy < nbetaY; iy++) {
|
||||
gm[iy * nbetaX + ix] = heta[iy * nbetaX + ix];
|
||||
}
|
||||
}
|
||||
WriteToTiff(gm, imgname, nbetaX, nbetaY);
|
||||
delete[] gm;
|
||||
return NULL;
|
||||
};
|
||||
|
||||
sprintf(tit,"/scratch/ftest_%d.tiff",ind);
|
||||
WriteToTiff(ftest, tit, nSubPixelsX, nSubPixelsY);
|
||||
int readFlatField(const char *imgname, double emin = 1, double emax = 0) {
|
||||
if (emax >= 1)
|
||||
etamax = emax;
|
||||
if (emin <= 0)
|
||||
etamin = emin;
|
||||
|
||||
//int ibx=0, iby=0;
|
||||
tot_eta/=nSubPixelsX*nSubPixelsY;
|
||||
int nbad=0;
|
||||
for (int ii=0; ii<nbetaX*nbetaY; ii++) {
|
||||
ibx=nSubPixelsX*hhx[ii];
|
||||
iby=nSubPixelsY*hhy[ii];
|
||||
if (ftest[ibx+iby*nSubPixelsX]<tot_eta*0.5f) {
|
||||
etah[ii]=1;
|
||||
nbad++;
|
||||
} else if(ftest[ibx+iby*nSubPixelsX]>tot_eta*2.f){
|
||||
etah[ii]=2;
|
||||
nbad++;
|
||||
} else
|
||||
etah[ii]=0;
|
||||
}
|
||||
sprintf(tit,"/scratch/eta_bad_%d.tiff",ind);
|
||||
WriteToTiff(etah, tit, nbetaX, nbetaY);
|
||||
// cout << "Index: " << ind << "\t Bad bins: "<< nbad << endl;
|
||||
//int ibx=0, iby=0;
|
||||
if (etamin >= etamax) {
|
||||
etamin = -1;
|
||||
etamax = 2;
|
||||
}
|
||||
|
||||
delete [] ftest;
|
||||
delete [] etah;
|
||||
etastepX = (etamax - etamin) / nbetaX;
|
||||
etastepY = (etamax - etamin) / nbetaY;
|
||||
uint32_t nnx;
|
||||
uint32_t nny;
|
||||
float *gm = ReadFromTiff(imgname, nnx, nny);
|
||||
/* if (nnx!=nny) { */
|
||||
/* cout << "different number of bins in x " << nnx << " and y " <<
|
||||
* nny<< " !"<< endl; */
|
||||
/* cout << "Aborting read"<< endl; */
|
||||
/* return 0; */
|
||||
/* } */
|
||||
nbetaX = nnx;
|
||||
nbetaY = nny;
|
||||
if (gm) {
|
||||
if (heta) {
|
||||
delete[] heta;
|
||||
delete[] hhx;
|
||||
delete[] hhy;
|
||||
}
|
||||
|
||||
}
|
||||
heta = new int[nbetaX * nbetaY];
|
||||
hhx = new float[nbetaX * nbetaY];
|
||||
hhy = new float[nbetaX * nbetaY];
|
||||
|
||||
for (int ix = 0; ix < nbetaX; ix++) {
|
||||
for (int iy = 0; iy < nbetaY; iy++) {
|
||||
heta[iy * nbetaX + ix] = gm[iy * nbetaX + ix];
|
||||
}
|
||||
}
|
||||
delete[] gm;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
|
||||
protected:
|
||||
|
||||
float *gethhx() {
|
||||
// hhx->Scale((double)nSubPixels);
|
||||
return hhx;
|
||||
};
|
||||
|
||||
double calcDiff(double avg, float *hx, float *hy) {
|
||||
//double p_tot=0;
|
||||
double diff=0, d;
|
||||
//double bsize=1./nSubPixels;
|
||||
int nbad=0;
|
||||
double *p_tot_x=new double[nSubPixelsX];
|
||||
double *p_tot_y=new double[nSubPixelsY];
|
||||
double *p_tot= new double[nSubPixelsX*nSubPixelsY];
|
||||
float *gethhy() {
|
||||
// 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;
|
||||
|
||||
double maxdiff=0, mindiff=avg*nSubPixelsX*nSubPixelsY;
|
||||
|
||||
int ipx, ipy;
|
||||
for (ipy=0; ipy<nSubPixelsY; ipy++) {
|
||||
for (ipx=0; ipx<nSubPixelsX; ipx++) {
|
||||
p_tot[ipx+ipy*nSubPixelsX]=0;
|
||||
}
|
||||
p_tot_y[ipy]=0;
|
||||
p_tot_x[ipy]=0;
|
||||
void debugSaveAll(int ind = 0) {
|
||||
int ibx, iby;
|
||||
char tit[10000];
|
||||
|
||||
float tot_eta = 0;
|
||||
|
||||
float *etah = new float[nbetaX * nbetaY];
|
||||
// int etabins=nbeta;
|
||||
int ibb = 0;
|
||||
|
||||
for (int ii = 0; ii < nbetaX * nbetaY; ii++) {
|
||||
|
||||
etah[ii] = heta[ii];
|
||||
tot_eta += heta[ii];
|
||||
}
|
||||
sprintf(tit, "/scratch/eta_%d.tiff", ind);
|
||||
WriteToTiff(etah, tit, nbetaX, nbetaY);
|
||||
|
||||
for (int ii = 0; ii < nbetaX * nbetaY; ii++) {
|
||||
ibb = (hhx[ii] * nSubPixelsX);
|
||||
etah[ii] = ibb;
|
||||
}
|
||||
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;
|
||||
}
|
||||
sprintf(tit, "/scratch/eta_hhy_%d.tiff", ind);
|
||||
WriteToTiff(etah, tit, nbetaX, nbetaY);
|
||||
|
||||
float *ftest = new float[nSubPixelsX * nSubPixelsY];
|
||||
|
||||
for (int ib = 0; ib < nSubPixelsX * nSubPixelsY; ib++)
|
||||
ftest[ib] = 0;
|
||||
|
||||
// int ibx=0, iby=0;
|
||||
|
||||
for (int ii = 0; ii < nbetaX * nbetaY; ii++) {
|
||||
|
||||
ibx = nSubPixelsX * hhx[ii];
|
||||
iby = nSubPixelsY * hhy[ii];
|
||||
if (ibx < 0)
|
||||
ibx = 0;
|
||||
if (iby < 0)
|
||||
iby = 0;
|
||||
if (ibx >= nSubPixelsX)
|
||||
ibx = nSubPixelsX - 1;
|
||||
if (iby >= nSubPixelsY)
|
||||
iby = nSubPixelsY - 1;
|
||||
|
||||
if (ibx >= 0 && ibx < nSubPixelsX && iby >= 0 &&
|
||||
iby < nSubPixelsY) {
|
||||
//
|
||||
// if (ibx>0 && iby>0) cout << ibx << " " << iby << " " << ii <<
|
||||
// endl;
|
||||
ftest[ibx + iby * nSubPixelsX] += heta[ii];
|
||||
} else
|
||||
cout << "Bad interpolation " << ii << " " << ibx << " " << iby
|
||||
<< endl;
|
||||
}
|
||||
|
||||
sprintf(tit, "/scratch/ftest_%d.tiff", ind);
|
||||
WriteToTiff(ftest, tit, nSubPixelsX, nSubPixelsY);
|
||||
|
||||
// int ibx=0, iby=0;
|
||||
tot_eta /= nSubPixelsX * nSubPixelsY;
|
||||
int nbad = 0;
|
||||
for (int ii = 0; ii < nbetaX * nbetaY; ii++) {
|
||||
ibx = nSubPixelsX * hhx[ii];
|
||||
iby = nSubPixelsY * hhy[ii];
|
||||
if (ftest[ibx + iby * nSubPixelsX] < tot_eta * 0.5f) {
|
||||
etah[ii] = 1;
|
||||
nbad++;
|
||||
} else if (ftest[ibx + iby * nSubPixelsX] > tot_eta * 2.f) {
|
||||
etah[ii] = 2;
|
||||
nbad++;
|
||||
} else
|
||||
etah[ii] = 0;
|
||||
}
|
||||
sprintf(tit, "/scratch/eta_bad_%d.tiff", ind);
|
||||
WriteToTiff(etah, tit, nbetaX, nbetaY);
|
||||
// cout << "Index: " << ind << "\t Bad bins: "<< nbad << endl;
|
||||
// int ibx=0, iby=0;
|
||||
|
||||
delete[] ftest;
|
||||
delete[] etah;
|
||||
}
|
||||
|
||||
for (int ibx=0; ibx<nbetaX; ibx++) {
|
||||
for (int iby=0; iby<nbetaY; iby++) {
|
||||
ipx=hx[ibx+iby*nbetaX]*nSubPixelsX;
|
||||
if (ipx<0) ipx=0;
|
||||
if (ipx>=nSubPixelsX) ipx=nSubPixelsX-1;
|
||||
|
||||
ipy=hy[ibx+iby*nbetaX]*nSubPixelsY;
|
||||
if (ipy<0) ipy=0;
|
||||
if (ipy>=nSubPixelsY) ipy=nSubPixelsY-1;
|
||||
|
||||
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];
|
||||
}
|
||||
|
||||
protected:
|
||||
double calcDiff(double avg, float *hx, float *hy) {
|
||||
// double p_tot=0;
|
||||
double diff = 0, d;
|
||||
// double bsize=1./nSubPixels;
|
||||
int nbad = 0;
|
||||
double *p_tot_x = new double[nSubPixelsX];
|
||||
double *p_tot_y = new double[nSubPixelsY];
|
||||
double *p_tot = new double[nSubPixelsX * nSubPixelsY];
|
||||
|
||||
double maxdiff = 0, mindiff = avg * nSubPixelsX * nSubPixelsY;
|
||||
|
||||
int ipx, ipy;
|
||||
for (ipy = 0; ipy < nSubPixelsY; ipy++) {
|
||||
for (ipx = 0; ipx < nSubPixelsX; ipx++) {
|
||||
p_tot[ipx + ipy * nSubPixelsX] = 0;
|
||||
}
|
||||
p_tot_y[ipy] = 0;
|
||||
p_tot_x[ipy] = 0;
|
||||
}
|
||||
|
||||
for (int ibx = 0; ibx < nbetaX; ibx++) {
|
||||
for (int iby = 0; iby < nbetaY; iby++) {
|
||||
ipx = hx[ibx + iby * nbetaX] * nSubPixelsX;
|
||||
if (ipx < 0)
|
||||
ipx = 0;
|
||||
if (ipx >= nSubPixelsX)
|
||||
ipx = nSubPixelsX - 1;
|
||||
|
||||
ipy = hy[ibx + iby * nbetaX] * nSubPixelsY;
|
||||
if (ipy < 0)
|
||||
ipy = 0;
|
||||
if (ipy >= nSubPixelsY)
|
||||
ipy = nSubPixelsY - 1;
|
||||
|
||||
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; ipy < nSubPixelsY; ipy++) {
|
||||
cout.width(5);
|
||||
// flat_y[ipy]=p_tot_y[ipy];//avg/nSubPixels;
|
||||
for (ipx = 0; ipx < nSubPixelsX; ipx++) {
|
||||
|
||||
// flat_x[ipx]=p_tot_x[ipx];///avg/nSubPixels;
|
||||
flat[ipx + nSubPixelsX * ipy] =
|
||||
p_tot[ipx + nSubPixelsX * ipy]; /// avg;
|
||||
d = p_tot[ipx + nSubPixelsX * ipy] - avg;
|
||||
if (d < 0)
|
||||
d *= -1.;
|
||||
if (d > 5 * sqrt(avg))
|
||||
nbad++;
|
||||
diff += d * d;
|
||||
if (d < mindiff)
|
||||
mindiff = d;
|
||||
if (d > maxdiff)
|
||||
maxdiff = d;
|
||||
// cout << setprecision(4) << p_tot[ipx+nSubPixels*ipy] <<
|
||||
//" ";
|
||||
}
|
||||
|
||||
/* cout << "** " << setprecision(4) << flat_y[ipy]; */
|
||||
// cout << "\n";
|
||||
}
|
||||
/* cout << "**" << endl; cout.width(5); */
|
||||
/* for (ipx=0; ipx<nSubPixels; ipx++) { */
|
||||
/* cout << setprecision(4) << flat_x[ipx] << " "; */
|
||||
/* } */
|
||||
// cout << "**" << endl; cout.width(5);
|
||||
// cout << "Min diff: " << mindiff/sqrt(avg) << " Max diff: " <<
|
||||
// maxdiff/sqrt(avg) << " Nbad: " << nbad << endl;
|
||||
|
||||
// cout << "Bad pixels: " <<
|
||||
// 100.*(float)nbad/((float)(nSubPixels*nSubPixels)) << " %" << endl;
|
||||
delete[] p_tot_x;
|
||||
delete[] p_tot_y;
|
||||
delete[] p_tot;
|
||||
|
||||
return sqrt(diff);
|
||||
}
|
||||
|
||||
|
||||
// cout << endl << endl;
|
||||
for (ipy=0; ipy<nSubPixelsY; ipy++) {
|
||||
cout.width(5);
|
||||
//flat_y[ipy]=p_tot_y[ipy];//avg/nSubPixels;
|
||||
for (ipx=0; ipx<nSubPixelsX; ipx++) {
|
||||
|
||||
// flat_x[ipx]=p_tot_x[ipx];///avg/nSubPixels;
|
||||
flat[ipx+nSubPixelsX*ipy]=p_tot[ipx+nSubPixelsX*ipy];///avg;
|
||||
d=p_tot[ipx+nSubPixelsX*ipy]-avg;
|
||||
if (d<0) d*=-1.;
|
||||
if (d>5*sqrt(avg) )
|
||||
nbad++;
|
||||
diff+=d*d;
|
||||
if (d<mindiff) mindiff=d;
|
||||
if (d>maxdiff) maxdiff=d;
|
||||
// cout << setprecision(4) << p_tot[ipx+nSubPixels*ipy] << " ";
|
||||
}
|
||||
|
||||
/* cout << "** " << setprecision(4) << flat_y[ipy]; */
|
||||
//cout << "\n";
|
||||
}
|
||||
/* cout << "**" << endl; cout.width(5); */
|
||||
/* for (ipx=0; ipx<nSubPixels; ipx++) { */
|
||||
/* cout << setprecision(4) << flat_x[ipx] << " "; */
|
||||
/* } */
|
||||
//cout << "**" << endl; cout.width(5);
|
||||
//cout << "Min diff: " << mindiff/sqrt(avg) << " Max diff: " << maxdiff/sqrt(avg) << " Nbad: " << nbad << endl;
|
||||
|
||||
|
||||
|
||||
// cout << "Bad pixels: " << 100.*(float)nbad/((float)(nSubPixels*nSubPixels)) << " %" << endl;
|
||||
delete [] p_tot_x;
|
||||
delete [] p_tot_y;
|
||||
delete [] p_tot;
|
||||
|
||||
return sqrt(diff);
|
||||
}
|
||||
|
||||
float *hhx;
|
||||
float *hhy;
|
||||
int *heta;
|
||||
int nbetaX, nbetaY;
|
||||
double etamin, etamax, etastepX, etastepY;
|
||||
double rangeMin, rangeMax;
|
||||
|
||||
|
||||
|
||||
double *flat;
|
||||
int *hintcorr;
|
||||
|
||||
float *hhx;
|
||||
float *hhy;
|
||||
int *heta;
|
||||
int nbetaX, nbetaY;
|
||||
double etamin, etamax, etastepX, etastepY;
|
||||
double rangeMin, rangeMax;
|
||||
|
||||
double *flat;
|
||||
int *hintcorr;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -3,263 +3,323 @@
|
||||
#ifndef ETA_INTERPOLATION_CLEVER_ADAPTIVEBINS_H
|
||||
#define ETA_INTERPOLATION_CLEVER_ADAPTIVEBINS_H
|
||||
|
||||
#include <cmath>
|
||||
#include "tiffIO.h"
|
||||
#include <cmath>
|
||||
//#include "etaInterpolationBase.h"
|
||||
#include "etaInterpolationAdaptiveBins.h"
|
||||
|
||||
|
||||
//#define HSIZE 1
|
||||
|
||||
|
||||
class etaInterpolationCleverAdaptiveBins : public etaInterpolationAdaptiveBins {
|
||||
|
||||
private:
|
||||
private:
|
||||
// double *gradientX, *gradientY, *gradientXY;
|
||||
|
||||
virtual void iterate(float *newhhx, float *newhhy) {
|
||||
|
||||
// double *gradientX, *gradientY, *gradientXY;
|
||||
double bsize = 1. / nSubPixels;
|
||||
|
||||
/* double hy[nSubPixels*HSIZE][nbeta]; //profile y */
|
||||
/* double hx[nSubPixels*HSIZE][nbeta]; //profile x */
|
||||
// double hix[nSubPixels*HSIZE][nbeta]; //integral of projection x
|
||||
// double hiy[nSubPixels*HSIZE][nbeta]; //integral of projection y
|
||||
int ipy, ipx, ippx, ippy;
|
||||
// double tot_eta_x[nSubPixels*HSIZE];
|
||||
// double tot_eta_y[nSubPixels*HSIZE];
|
||||
|
||||
virtual void iterate(float *newhhx, float *newhhy) {
|
||||
double mean = 0;
|
||||
double maxflat = 0, minflat = 0, maxgradX = 0, mingradX = 0,
|
||||
maxgradY = 0, mingradY = 0, maxgr = 0, mingr = 0;
|
||||
|
||||
double bsize=1./nSubPixels;
|
||||
|
||||
/* double hy[nSubPixels*HSIZE][nbeta]; //profile y */
|
||||
/* double hx[nSubPixels*HSIZE][nbeta]; //profile x */
|
||||
// double hix[nSubPixels*HSIZE][nbeta]; //integral of projection x
|
||||
// double hiy[nSubPixels*HSIZE][nbeta]; //integral of projection y
|
||||
int ipy, ipx, ippx, ippy;
|
||||
// double tot_eta_x[nSubPixels*HSIZE];
|
||||
//double tot_eta_y[nSubPixels*HSIZE];
|
||||
int ix_maxflat, iy_maxflat, ix_minflat, iy_minflat, ix_maxgrX,
|
||||
iy_maxgrX, ix_mingrX, iy_mingrX, ix_maxgrY, iy_maxgrY, ix_mingrY,
|
||||
iy_mingrY, ix_mingr, iy_mingr, ix_maxgr, iy_maxgr;
|
||||
int maskMin[nSubPixels * nSubPixels], maskMax[nSubPixels * nSubPixels];
|
||||
|
||||
double mean=0;
|
||||
double maxflat=0, minflat=0, maxgradX=0, mingradX=0, maxgradY=0, mingradY=0, maxgr=0, mingr=0;
|
||||
// for (int ipy=0; ipy<nSubPixels; ipy++) {
|
||||
|
||||
int ix_maxflat, iy_maxflat, ix_minflat, iy_minflat, ix_maxgrX, iy_maxgrX, ix_mingrX, iy_mingrX,ix_maxgrY, iy_maxgrY, ix_mingrY, iy_mingrY, ix_mingr, iy_mingr, ix_maxgr, iy_maxgr;
|
||||
int maskMin[nSubPixels*nSubPixels], maskMax[nSubPixels*nSubPixels];
|
||||
for (ipy = 0; ipy < nSubPixels; ipy++) {
|
||||
for (ipx = 0; ipx < nSubPixels; ipx++) {
|
||||
// cout << ipx << " " << ipy << endl;
|
||||
mean += flat[ipx + nSubPixels * ipy] /
|
||||
((double)(nSubPixels * nSubPixels));
|
||||
}
|
||||
}
|
||||
|
||||
// cout << "Mean is " << mean << endl;
|
||||
|
||||
//for (int ipy=0; ipy<nSubPixels; ipy++) {
|
||||
|
||||
for (ipy=0; ipy<nSubPixels; ipy++) {
|
||||
for (ipx=0; ipx<nSubPixels; ipx++) {
|
||||
// cout << ipx << " " << ipy << endl;
|
||||
mean+=flat[ipx+nSubPixels*ipy]/((double)(nSubPixels*nSubPixels));
|
||||
}
|
||||
/*** Find local minima and maxima within the staistical uncertainty **/
|
||||
for (ipy = 0; ipy < nSubPixels; ipy++) {
|
||||
for (ipx = 0; ipx < nSubPixels; ipx++) {
|
||||
if (flat[ipx + nSubPixels * ipy] < mean - 3. * sqrt(mean))
|
||||
maskMin[ipx + nSubPixels * ipy] = 1;
|
||||
else
|
||||
maskMin[ipx + nSubPixels * ipy] = 0;
|
||||
if (flat[ipx + nSubPixels * ipy] > mean + 3. * sqrt(mean))
|
||||
maskMax[ipx + nSubPixels * ipy] = 1;
|
||||
else
|
||||
maskMax[ipx + nSubPixels * ipy] = 0;
|
||||
if (ipx > 0 && ipy > 0) {
|
||||
if (flat[ipx + nSubPixels * ipy] <
|
||||
flat[ipx - 1 + nSubPixels * (ipy - 1)])
|
||||
maskMax[ipx + nSubPixels * ipy] = 0;
|
||||
if (flat[ipx + nSubPixels * ipy] >
|
||||
flat[ipx - 1 + nSubPixels * (ipy - 1)])
|
||||
maskMin[ipx + nSubPixels * ipy] = 0;
|
||||
}
|
||||
if (ipx > 0 && ipy < nSubPixels - 1) {
|
||||
if (flat[ipx + nSubPixels * ipy] <
|
||||
flat[ipx - 1 + nSubPixels * (ipy + 1)])
|
||||
maskMax[ipx + nSubPixels * ipy] = 0;
|
||||
if (flat[ipx + nSubPixels * ipy] >
|
||||
flat[ipx - 1 + nSubPixels * (ipy + 1)])
|
||||
maskMin[ipx + nSubPixels * ipy] = 0;
|
||||
}
|
||||
if (ipy > 0 && ipx < nSubPixels - 1) {
|
||||
if (flat[ipx + nSubPixels * ipy] <
|
||||
flat[ipx + 1 + nSubPixels * (ipy - 1)])
|
||||
maskMax[ipx + nSubPixels * ipy] = 0;
|
||||
if (flat[ipx + nSubPixels * ipy] >
|
||||
flat[ipx + 1 + nSubPixels * (ipy - 1)])
|
||||
maskMin[ipx + nSubPixels * ipy] = 0;
|
||||
}
|
||||
if (ipy < nSubPixels - 1 && ipx < nSubPixels - 1) {
|
||||
if (flat[ipx + nSubPixels * ipy] <
|
||||
flat[ipx + 1 + nSubPixels * (ipy + 1)])
|
||||
maskMax[ipx + nSubPixels * ipy] = 0;
|
||||
if (flat[ipx + nSubPixels * ipy] >
|
||||
flat[ipx + 1 + nSubPixels * (ipy + 1)])
|
||||
maskMin[ipx + nSubPixels * ipy] = 0;
|
||||
}
|
||||
if (ipy < nSubPixels - 1) {
|
||||
if (flat[ipx + nSubPixels * ipy] <
|
||||
flat[ipx + nSubPixels * (ipy + 1)])
|
||||
maskMax[ipx + nSubPixels * ipy] = 0;
|
||||
if (flat[ipx + nSubPixels * ipy] >
|
||||
flat[ipx + nSubPixels * (ipy + 1)])
|
||||
maskMin[ipx + nSubPixels * ipy] = 0;
|
||||
}
|
||||
if (ipx < nSubPixels - 1) {
|
||||
if (flat[ipx + nSubPixels * ipy] <
|
||||
flat[ipx + 1 + nSubPixels * (ipy)])
|
||||
maskMax[ipx + nSubPixels * ipy] = 0;
|
||||
if (flat[ipx + nSubPixels * ipy] >
|
||||
flat[ipx + 1 + nSubPixels * (ipy)])
|
||||
maskMin[ipx + nSubPixels * ipy] = 0;
|
||||
}
|
||||
|
||||
if (ipy > 0) {
|
||||
if (flat[ipx + nSubPixels * ipy] <
|
||||
flat[ipx + nSubPixels * (ipy - 1)])
|
||||
maskMax[ipx + nSubPixels * ipy] = 0;
|
||||
if (flat[ipx + nSubPixels * ipy] >
|
||||
flat[ipx + nSubPixels * (ipy - 1)])
|
||||
maskMin[ipx + nSubPixels * ipy] = 0;
|
||||
}
|
||||
|
||||
if (ipx > 0) {
|
||||
if (flat[ipx + nSubPixels * ipy] <
|
||||
flat[ipx - 1 + nSubPixels * (ipy)])
|
||||
maskMax[ipx + nSubPixels * ipy] = 0;
|
||||
if (flat[ipx + nSubPixels * ipy] >
|
||||
flat[ipx - 1 + nSubPixels * (ipy)])
|
||||
maskMin[ipx + nSubPixels * ipy] = 0;
|
||||
}
|
||||
|
||||
// if (maskMin[ipx+nSubPixels*ipy]) cout << ipx << " " <<
|
||||
//ipy << " is a local minimum " << flat[ipx+nSubPixels*ipy] <<
|
||||
//endl; if (maskMax[ipx+nSubPixels*ipy]) cout << ipx << " " <<
|
||||
//ipy << " is a local maximum "<< flat[ipx+nSubPixels*ipy] <<
|
||||
//endl;
|
||||
}
|
||||
}
|
||||
int is_a_border = 0;
|
||||
|
||||
// initialize the new partition to the previous one
|
||||
// int ibx_p, iby_p, ibx_n, iby_n;
|
||||
int ibbx, ibby;
|
||||
|
||||
memcpy(newhhx, hhx, nbeta * nbeta * sizeof(float));
|
||||
memcpy(newhhy, hhy, nbeta * nbeta * sizeof(float));
|
||||
|
||||
for (int ibx = 0; ibx < nbeta; ibx++) {
|
||||
for (int iby = 0; iby < nbeta; iby++) {
|
||||
|
||||
ippy = hhy[ibx + iby * nbeta] * nSubPixels;
|
||||
ippx = hhx[ibx + iby * nbeta] * nSubPixels;
|
||||
|
||||
is_a_border = 0;
|
||||
|
||||
if (maskMin[ippx + nSubPixels * ippy] ||
|
||||
maskMax[ippx + nSubPixels * ippy]) {
|
||||
|
||||
for (int ix = -1; ix < 2; ix++) {
|
||||
ibbx = ibx + ix;
|
||||
if (ibbx < 0)
|
||||
ibbx = 0;
|
||||
if (ibbx > nbeta - 1)
|
||||
ibbx = nbeta - 1;
|
||||
for (int iy = -1; iy < 2; iy++) {
|
||||
ibby = iby + iy;
|
||||
if (ibby < 0)
|
||||
ibby = 0;
|
||||
if (ibby > nbeta - 1)
|
||||
ibby = nbeta - 1;
|
||||
|
||||
ipy = hhy[ibbx + ibby * nbeta] * nSubPixels;
|
||||
ipx = hhx[ibbx + ibby * nbeta] * nSubPixels;
|
||||
|
||||
if (ipx != ippx || ipy != ippy) {
|
||||
is_a_border = 1;
|
||||
if (maskMin[ippx + nSubPixels * ippy]) {
|
||||
// increase the region
|
||||
newhhx[ibbx + ibby * nbeta] =
|
||||
((double)ippx + 0.5) /
|
||||
((double)nSubPixels);
|
||||
newhhy[ibbx + ibby * nbeta] =
|
||||
((double)ippy + 0.5) /
|
||||
((double)nSubPixels);
|
||||
}
|
||||
if (maskMax[ippx + nSubPixels * ippy]) {
|
||||
// reduce the region
|
||||
newhhx[ibx + iby * nbeta] =
|
||||
((double)ipx + 0.5) /
|
||||
((double)nSubPixels);
|
||||
newhhy[ibx + iby * nbeta] =
|
||||
((double)ipy + 0.5) /
|
||||
((double)nSubPixels);
|
||||
}
|
||||
|
||||
// cout << ippx << " " << ippy << " " <<
|
||||
//ibx << " " << iby << " * " << ipx << " " <<
|
||||
//ipy << " " << ibbx << " " << ibby << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check that the resulting histograms are monotonic and they don't have
|
||||
// holes!
|
||||
|
||||
for (int ibx = 0; ibx < nbeta - 1; ibx++) {
|
||||
for (int iby = 0; iby < nbeta - 1; iby++) {
|
||||
|
||||
ippy = newhhy[ibx + iby * nbeta] * nSubPixels;
|
||||
ippx = newhhx[ibx + iby * nbeta] * nSubPixels;
|
||||
|
||||
ipy = newhhy[ibx + (iby + 1) * nbeta] * nSubPixels;
|
||||
ipx = newhhx[ibx + 1 + iby * nbeta] * nSubPixels;
|
||||
|
||||
if (ippx > ipx)
|
||||
newhhx[ibx + 1 + iby * nbeta] = newhhx[ibx + iby * nbeta];
|
||||
else if (ipx > ippx + 1)
|
||||
newhhx[ibx + 1 + iby * nbeta] =
|
||||
((double)(ippx + 1 + 0.5)) / ((double)nSubPixels);
|
||||
|
||||
if (ippy > ipy)
|
||||
newhhy[ibx + (iby + 1) * nbeta] = newhhy[ibx + iby * nbeta];
|
||||
else if (ipy > ippy + 1)
|
||||
newhhy[ibx + (iby + 1) * nbeta] =
|
||||
((double)(ippy + 1 + 0.5)) / ((double)nSubPixels);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// cout << "Mean is " << mean << endl;
|
||||
public:
|
||||
etaInterpolationCleverAdaptiveBins(int nx = 400, int ny = 400, int ns = 25,
|
||||
int nb = -1, double emin = 1,
|
||||
double emax = 0)
|
||||
: etaInterpolationAdaptiveBins(nx, ny, ns, nb, emin, emax){
|
||||
|
||||
/*** Find local minima and maxima within the staistical uncertainty **/
|
||||
for (ipy=0; ipy<nSubPixels; ipy++) {
|
||||
for (ipx=0; ipx<nSubPixels; ipx++) {
|
||||
if (flat[ipx+nSubPixels*ipy]<mean-3.*sqrt(mean))maskMin[ipx+nSubPixels*ipy]=1; else maskMin[ipx+nSubPixels*ipy]=0;
|
||||
if (flat[ipx+nSubPixels*ipy]>mean+3.*sqrt(mean)) maskMax[ipx+nSubPixels*ipy]=1; else maskMax[ipx+nSubPixels*ipy]=0;
|
||||
if (ipx>0 && ipy>0) {
|
||||
if (flat[ipx+nSubPixels*ipy]<flat[ipx-1+nSubPixels*(ipy-1)]) maskMax[ipx+nSubPixels*ipy]=0;
|
||||
if (flat[ipx+nSubPixels*ipy]>flat[ipx-1+nSubPixels*(ipy-1)]) maskMin[ipx+nSubPixels*ipy]=0;
|
||||
}
|
||||
if (ipx>0 && ipy<nSubPixels-1) {
|
||||
if (flat[ipx+nSubPixels*ipy]<flat[ipx-1+nSubPixels*(ipy+1)]) maskMax[ipx+nSubPixels*ipy]=0;
|
||||
if (flat[ipx+nSubPixels*ipy]>flat[ipx-1+nSubPixels*(ipy+1)]) maskMin[ipx+nSubPixels*ipy]=0;
|
||||
}
|
||||
if (ipy>0 && ipx<nSubPixels-1) {
|
||||
if (flat[ipx+nSubPixels*ipy]<flat[ipx+1+nSubPixels*(ipy-1)]) maskMax[ipx+nSubPixels*ipy]=0;
|
||||
if (flat[ipx+nSubPixels*ipy]>flat[ipx+1+nSubPixels*(ipy-1)]) maskMin[ipx+nSubPixels*ipy]=0;
|
||||
}
|
||||
if (ipy<nSubPixels-1 && ipx<nSubPixels-1) {
|
||||
if (flat[ipx+nSubPixels*ipy]<flat[ipx+1+nSubPixels*(ipy+1)]) maskMax[ipx+nSubPixels*ipy]=0;
|
||||
if (flat[ipx+nSubPixels*ipy]>flat[ipx+1+nSubPixels*(ipy+1)]) maskMin[ipx+nSubPixels*ipy]=0;
|
||||
}
|
||||
if (ipy<nSubPixels-1 ) {
|
||||
if (flat[ipx+nSubPixels*ipy]<flat[ipx+nSubPixels*(ipy+1)]) maskMax[ipx+nSubPixels*ipy]=0;
|
||||
if (flat[ipx+nSubPixels*ipy]>flat[ipx+nSubPixels*(ipy+1)]) maskMin[ipx+nSubPixels*ipy]=0;
|
||||
}
|
||||
if (ipx<nSubPixels-1) {
|
||||
if (flat[ipx+nSubPixels*ipy]<flat[ipx+1+nSubPixels*(ipy)]) maskMax[ipx+nSubPixels*ipy]=0;
|
||||
if (flat[ipx+nSubPixels*ipy]>flat[ipx+1+nSubPixels*(ipy)]) maskMin[ipx+nSubPixels*ipy]=0;
|
||||
}
|
||||
|
||||
if (ipy>0 ) {
|
||||
if (flat[ipx+nSubPixels*ipy]<flat[ipx+nSubPixels*(ipy-1)]) maskMax[ipx+nSubPixels*ipy]=0;
|
||||
if (flat[ipx+nSubPixels*ipy]>flat[ipx+nSubPixels*(ipy-1)]) maskMin[ipx+nSubPixels*ipy]=0;
|
||||
}
|
||||
};
|
||||
|
||||
if (ipx>0 ) {
|
||||
if (flat[ipx+nSubPixels*ipy]<flat[ipx-1+nSubPixels*(ipy)]) maskMax[ipx+nSubPixels*ipy]=0;
|
||||
if (flat[ipx+nSubPixels*ipy]>flat[ipx-1+nSubPixels*(ipy)]) maskMin[ipx+nSubPixels*ipy]=0;
|
||||
}
|
||||
etaInterpolationCleverAdaptiveBins(etaInterpolationCleverAdaptiveBins *orig)
|
||||
: etaInterpolationAdaptiveBins(orig){};
|
||||
|
||||
// if (maskMin[ipx+nSubPixels*ipy]) cout << ipx << " " << ipy << " is a local minimum " << flat[ipx+nSubPixels*ipy] << endl;
|
||||
// if (maskMax[ipx+nSubPixels*ipy]) cout << ipx << " " << ipy << " is a local maximum "<< flat[ipx+nSubPixels*ipy] << endl;
|
||||
|
||||
}
|
||||
}
|
||||
int is_a_border=0;
|
||||
|
||||
//initialize the new partition to the previous one
|
||||
// int ibx_p, iby_p, ibx_n, iby_n;
|
||||
int ibbx, ibby;
|
||||
|
||||
|
||||
memcpy(newhhx,hhx,nbeta*nbeta*sizeof(float));
|
||||
memcpy(newhhy,hhy,nbeta*nbeta*sizeof(float));
|
||||
|
||||
for (int ibx=0; ibx<nbeta; ibx++) {
|
||||
for (int iby=0; iby<nbeta; iby++) {
|
||||
|
||||
ippy=hhy[ibx+iby*nbeta]*nSubPixels;
|
||||
ippx=hhx[ibx+iby*nbeta]*nSubPixels;
|
||||
|
||||
|
||||
is_a_border=0;
|
||||
|
||||
if (maskMin[ippx+nSubPixels*ippy] || maskMax[ippx+nSubPixels*ippy]) {
|
||||
|
||||
|
||||
for (int ix=-1; ix<2; ix++) {
|
||||
ibbx=ibx+ix;
|
||||
if (ibbx<0) ibbx=0;
|
||||
if (ibbx>nbeta-1) ibbx=nbeta-1;
|
||||
for (int iy=-1; iy<2; iy++) {
|
||||
ibby=iby+iy;
|
||||
if (ibby<0) ibby=0;
|
||||
if (ibby>nbeta-1) ibby=nbeta-1;
|
||||
|
||||
|
||||
ipy=hhy[ibbx+ibby*nbeta]*nSubPixels;
|
||||
ipx=hhx[ibbx+ibby*nbeta]*nSubPixels;
|
||||
|
||||
|
||||
if (ipx!=ippx || ipy!=ippy) {
|
||||
is_a_border=1;
|
||||
if (maskMin[ippx+nSubPixels*ippy]) {
|
||||
//increase the region
|
||||
newhhx[ibbx+ibby*nbeta]=((double)ippx+0.5)/((double)nSubPixels);
|
||||
newhhy[ibbx+ibby*nbeta]=((double)ippy+0.5)/((double)nSubPixels);
|
||||
}
|
||||
if (maskMax[ippx+nSubPixels*ippy]) {
|
||||
//reduce the region
|
||||
newhhx[ibx+iby*nbeta]=((double)ipx+0.5)/((double)nSubPixels);
|
||||
newhhy[ibx+iby*nbeta]=((double)ipy+0.5)/((double)nSubPixels);
|
||||
}
|
||||
|
||||
// cout << ippx << " " << ippy << " " << ibx << " " << iby << " * " << ipx << " " << ipy << " " << ibbx << " " << ibby << endl;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//Check that the resulting histograms are monotonic and they don't have holes!
|
||||
|
||||
for (int ibx=0; ibx<nbeta-1; ibx++) {
|
||||
for (int iby=0; iby<nbeta-1; iby++) {
|
||||
|
||||
ippy=newhhy[ibx+iby*nbeta]*nSubPixels;
|
||||
ippx=newhhx[ibx+iby*nbeta]*nSubPixels;
|
||||
|
||||
ipy=newhhy[ibx+(iby+1)*nbeta]*nSubPixels;
|
||||
ipx=newhhx[ibx+1+iby*nbeta]*nSubPixels;
|
||||
|
||||
if ( ippx>ipx)
|
||||
newhhx[ibx+1+iby*nbeta]=newhhx[ibx+iby*nbeta];
|
||||
else if (ipx >ippx+1)
|
||||
newhhx[ibx+1+iby*nbeta]=((double)(ippx+1+0.5))/((double)nSubPixels);
|
||||
|
||||
if ( ippy>ipy)
|
||||
newhhy[ibx+(iby+1)*nbeta]=newhhy[ibx+iby*nbeta];
|
||||
else if (ipy >ippy+1)
|
||||
newhhy[ibx+(iby+1)*nbeta]=((double)(ippy+1+0.5))/((double)nSubPixels);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public:
|
||||
etaInterpolationCleverAdaptiveBins(int nx=400, int ny=400, int ns=25, int nb=-1, double emin=1, double emax=0) : etaInterpolationAdaptiveBins(nx,ny,ns, nb, emin,emax){
|
||||
|
||||
|
||||
};
|
||||
|
||||
etaInterpolationCleverAdaptiveBins(etaInterpolationCleverAdaptiveBins *orig): etaInterpolationAdaptiveBins(orig){};
|
||||
|
||||
virtual etaInterpolationCleverAdaptiveBins* Clone()=0;
|
||||
|
||||
/* return new etaInterpolationCleverAdaptiveBins(this); */
|
||||
|
||||
/* }; */
|
||||
virtual etaInterpolationCleverAdaptiveBins *Clone() = 0;
|
||||
|
||||
/* return new etaInterpolationCleverAdaptiveBins(this); */
|
||||
|
||||
/* }; */
|
||||
};
|
||||
|
||||
class eta2InterpolationCleverAdaptiveBins : public virtual eta2InterpolationBase, public virtual etaInterpolationCleverAdaptiveBins {
|
||||
public:
|
||||
eta2InterpolationCleverAdaptiveBins(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(nx,ny,ns, nb, emin,emax),etaInterpolationCleverAdaptiveBins(nx,ny,ns, nb, emin,emax){
|
||||
};
|
||||
|
||||
eta2InterpolationCleverAdaptiveBins(eta2InterpolationCleverAdaptiveBins *orig): etaInterpolationBase(orig), etaInterpolationCleverAdaptiveBins(orig) {};
|
||||
class eta2InterpolationCleverAdaptiveBins
|
||||
: public virtual eta2InterpolationBase,
|
||||
public virtual etaInterpolationCleverAdaptiveBins {
|
||||
public:
|
||||
eta2InterpolationCleverAdaptiveBins(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(nx, ny, ns, nb, emin, emax),
|
||||
etaInterpolationCleverAdaptiveBins(nx, ny, ns, nb, emin, emax){};
|
||||
|
||||
virtual eta2InterpolationCleverAdaptiveBins* Clone() { return new eta2InterpolationCleverAdaptiveBins(this);};
|
||||
eta2InterpolationCleverAdaptiveBins(
|
||||
eta2InterpolationCleverAdaptiveBins *orig)
|
||||
: etaInterpolationBase(orig),
|
||||
etaInterpolationCleverAdaptiveBins(orig){};
|
||||
|
||||
// virtual int *getInterpolatedImage(){return eta2InterpolationBase::getInterpolatedImage();};
|
||||
virtual eta2InterpolationCleverAdaptiveBins *Clone() {
|
||||
return new eta2InterpolationCleverAdaptiveBins(this);
|
||||
};
|
||||
|
||||
/* virtual int *getInterpolatedImage(){ */
|
||||
/* int ipx, ipy; */
|
||||
/* cout << "ff" << endl; */
|
||||
/* calcDiff(1, hhx, hhy); //get flat */
|
||||
/* double avg=0; */
|
||||
/* for (ipx=0; ipx<nSubPixels; ipx++) */
|
||||
/* for (ipy=0; ipy<nSubPixels; ipy++) */
|
||||
/* avg+=flat[ipx+ipy*nSubPixels]; */
|
||||
/* avg/=nSubPixels*nSubPixels; */
|
||||
|
||||
/* for (int ibx=0 ; ibx<nSubPixels*nPixelsX; ibx++) { */
|
||||
/* ipx=ibx%nSubPixels-nSubPixels; */
|
||||
/* if (ipx<0) ipx=nSubPixels+ipx; */
|
||||
/* for (int iby=0 ; iby<nSubPixels*nPixelsY; iby++) { */
|
||||
/* ipy=iby%nSubPixels-nSubPixels; */
|
||||
/* if (ipy<0) ipy=nSubPixels+ipy; */
|
||||
|
||||
/* if (flat[ipx+ipy*nSubPixels]>0) */
|
||||
/* hintcorr[ibx+iby*nSubPixels*nPixelsX]=hint[ibx+iby*nSubPixels*nPixelsX]*(avg/flat[ipx+ipy*nSubPixels]); */
|
||||
/* else */
|
||||
/* hintcorr[ibx+iby*nSubPixels*nPixelsX]=hint[ibx+iby*nSubPixels*nPixelsX]; */
|
||||
// virtual int *getInterpolatedImage(){return
|
||||
// eta2InterpolationBase::getInterpolatedImage();};
|
||||
|
||||
/* virtual int *getInterpolatedImage(){ */
|
||||
/* int ipx, ipy; */
|
||||
/* cout << "ff" << endl; */
|
||||
/* calcDiff(1, hhx, hhy); //get flat */
|
||||
/* double avg=0; */
|
||||
/* for (ipx=0; ipx<nSubPixels; ipx++) */
|
||||
/* for (ipy=0; ipy<nSubPixels; ipy++) */
|
||||
/* avg+=flat[ipx+ipy*nSubPixels]; */
|
||||
/* avg/=nSubPixels*nSubPixels; */
|
||||
|
||||
/* } */
|
||||
/* } */
|
||||
/* for (int ibx=0 ; ibx<nSubPixels*nPixelsX; ibx++) { */
|
||||
/* ipx=ibx%nSubPixels-nSubPixels; */
|
||||
/* if (ipx<0) ipx=nSubPixels+ipx; */
|
||||
/* for (int iby=0 ; iby<nSubPixels*nPixelsY; iby++) { */
|
||||
/* ipy=iby%nSubPixels-nSubPixels; */
|
||||
/* if (ipy<0) ipy=nSubPixels+ipy; */
|
||||
|
||||
/* if (flat[ipx+ipy*nSubPixels]>0) */
|
||||
/* hintcorr[ibx+iby*nSubPixels*nPixelsX]=hint[ibx+iby*nSubPixels*nPixelsX]*(avg/flat[ipx+ipy*nSubPixels]);
|
||||
*/
|
||||
/* else */
|
||||
/* hintcorr[ibx+iby*nSubPixels*nPixelsX]=hint[ibx+iby*nSubPixels*nPixelsX];
|
||||
*/
|
||||
|
||||
/* } */
|
||||
/* } */
|
||||
|
||||
/* return hintcorr; */
|
||||
/* }; */
|
||||
|
||||
|
||||
/* return hintcorr; */
|
||||
/* }; */
|
||||
};
|
||||
|
||||
class eta3InterpolationCleverAdaptiveBins
|
||||
: public virtual eta3InterpolationBase,
|
||||
public virtual etaInterpolationCleverAdaptiveBins {
|
||||
public:
|
||||
eta3InterpolationCleverAdaptiveBins(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(nx, ny, ns, nb, emin, emax),
|
||||
etaInterpolationCleverAdaptiveBins(nx, ny, ns, nb, emin, emax){
|
||||
|
||||
};
|
||||
|
||||
class eta3InterpolationCleverAdaptiveBins : public virtual eta3InterpolationBase, public virtual etaInterpolationCleverAdaptiveBins {
|
||||
public:
|
||||
eta3InterpolationCleverAdaptiveBins(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(nx,ny,ns, nb, emin,emax), etaInterpolationCleverAdaptiveBins(nx,ny,ns, nb, emin,emax){
|
||||
|
||||
};
|
||||
eta3InterpolationCleverAdaptiveBins(
|
||||
eta3InterpolationCleverAdaptiveBins *orig)
|
||||
: etaInterpolationBase(orig),
|
||||
etaInterpolationCleverAdaptiveBins(orig){};
|
||||
|
||||
eta3InterpolationCleverAdaptiveBins(eta3InterpolationCleverAdaptiveBins *orig): etaInterpolationBase(orig), etaInterpolationCleverAdaptiveBins(orig) {};
|
||||
|
||||
virtual eta3InterpolationCleverAdaptiveBins* Clone() { return new eta3InterpolationCleverAdaptiveBins(this);};
|
||||
virtual eta3InterpolationCleverAdaptiveBins *Clone() {
|
||||
return new eta3InterpolationCleverAdaptiveBins(this);
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -3,85 +3,94 @@
|
||||
#ifndef ETA_INTERPOLATION_GLOBAL_H
|
||||
#define ETA_INTERPOLATION_GLOBAL_H
|
||||
|
||||
|
||||
#include "etaInterpolationBase.h"
|
||||
|
||||
class etaInterpolationGlobal : public 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){};
|
||||
|
||||
class etaInterpolationGlobal : public 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){};
|
||||
|
||||
virtual void prepareInterpolation(int &ok) {
|
||||
ok = 1;
|
||||
#ifdef MYROOT1
|
||||
if (hhx)
|
||||
delete hhx;
|
||||
if (hhy)
|
||||
delete hhy;
|
||||
|
||||
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());
|
||||
|
||||
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*///
|
||||
double bsize = 1. / nSubPixels; // precision
|
||||
// cout<<"nPixelsX = "<<nPixelsX<<" nPixelsY = "<<nPixelsY<<" nSubPixels
|
||||
// = "<<nSubPixels<<endl;
|
||||
double tot_eta = 0;
|
||||
for (int ip = 0; ip < nbeta * nbeta; ip++)
|
||||
tot_eta += heta[ip];
|
||||
cout << "total eta entries is :" << tot_eta << endl;
|
||||
if (tot_eta <= 0) {
|
||||
ok = 0;
|
||||
return;
|
||||
};
|
||||
|
||||
///*Eta Distribution Rebinning*///
|
||||
double bsize=1./nSubPixels; //precision
|
||||
// cout<<"nPixelsX = "<<nPixelsX<<" nPixelsY = "<<nPixelsY<<" nSubPixels = "<<nSubPixels<<endl;
|
||||
double tot_eta=0;
|
||||
for (int ip=0; ip<nbeta*nbeta; 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
|
||||
|
||||
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];
|
||||
}
|
||||
}
|
||||
double hix[nbeta]; // integral of projection x
|
||||
double hiy[nbeta]; // integral of projection y
|
||||
hix[0] = hx[0];
|
||||
hiy[0] = hy[0];
|
||||
|
||||
double hx[nbeta]; //projection x
|
||||
double hy[nbeta]; //projection y
|
||||
for (int ib = 1; ib < nbeta; ib++) {
|
||||
hix[ib] = hix[ib - 1] + hx[ib];
|
||||
hiy[ib] = hiy[ib - 1] + hx[ib];
|
||||
}
|
||||
|
||||
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];
|
||||
}
|
||||
}
|
||||
double hix[nbeta]; //integral of projection x
|
||||
double hiy[nbeta]; //integral of projection y
|
||||
hix[0]=hx[0];
|
||||
hiy[0]=hy[0];
|
||||
|
||||
for (int ib=1; ib<nbeta; ib++) {
|
||||
hix[ib]=hix[ib-1]+hx[ib];
|
||||
hiy[ib]=hiy[ib-1]+hx[ib];
|
||||
}
|
||||
|
||||
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);
|
||||
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;
|
||||
#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);
|
||||
}
|
||||
}
|
||||
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;
|
||||
#ifndef MYROOT1
|
||||
hhy[ibx + iby * nbeta] = ib;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
return ;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -3,210 +3,211 @@
|
||||
#ifndef ETA_INTERPOLATION_POSXY_H
|
||||
#define ETA_INTERPOLATION_POSXY_H
|
||||
|
||||
|
||||
//#include "tiffIO.h"
|
||||
#include "etaInterpolationBase.h"
|
||||
#include "eta2InterpolationBase.h"
|
||||
#include "eta3InterpolationBase.h"
|
||||
#include "etaInterpolationBase.h"
|
||||
|
||||
class etaInterpolationPosXY : public virtual etaInterpolationBase{
|
||||
public:
|
||||
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;
|
||||
};
|
||||
class etaInterpolationPosXY : public virtual etaInterpolationBase {
|
||||
public:
|
||||
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;
|
||||
};
|
||||
|
||||
etaInterpolationPosXY(etaInterpolationPosXY *orig): etaInterpolationBase(orig) {};
|
||||
etaInterpolationPosXY(etaInterpolationPosXY *orig)
|
||||
: etaInterpolationBase(orig){};
|
||||
|
||||
virtual etaInterpolationPosXY* Clone()=0; /* { */
|
||||
virtual etaInterpolationPosXY *Clone() = 0; /* { */
|
||||
|
||||
/* return new etaInterpolationPosXY(this); */
|
||||
|
||||
/* }; */
|
||||
|
||||
virtual void prepareInterpolation(int &ok)
|
||||
{
|
||||
ok=1;
|
||||
virtual void prepareInterpolation(int &ok) {
|
||||
ok = 1;
|
||||
|
||||
///*Eta Distribution Rebinning*///
|
||||
// double bsize=1./nSubPixels; //precision
|
||||
// cout<<"nPixelsX = "<<nPixelsX<<" nPixelsY = "<<nPixelsY<<" nSubPixels
|
||||
// = "<<nSubPixels<<endl;
|
||||
double tot_eta = 0;
|
||||
double tot_eta_x = 0;
|
||||
double tot_eta_y = 0;
|
||||
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;
|
||||
};
|
||||
|
||||
///*Eta Distribution Rebinning*///
|
||||
// double bsize=1./nSubPixels; //precision
|
||||
// cout<<"nPixelsX = "<<nPixelsX<<" nPixelsY = "<<nPixelsY<<" nSubPixels = "<<nSubPixels<<endl;
|
||||
double tot_eta=0;
|
||||
double tot_eta_x=0;
|
||||
double tot_eta_y=0;
|
||||
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 = new double[nbetaX]; // profile x
|
||||
double *hy = new double[nbetaY]; // profile y
|
||||
double *hix = new double[nbetaX]; // integral of projection x
|
||||
double *hiy = new double[nbetaY]; // integral of projection y
|
||||
// int ii=0;
|
||||
double etax, etay;
|
||||
for (int ib = 0; ib < nbetaX; ib++) {
|
||||
|
||||
// tot_eta_y=0;
|
||||
|
||||
double *hx=new double[nbetaX]; //profile x
|
||||
double *hy=new double[nbetaY]; //profile y
|
||||
double *hix=new double[nbetaX]; //integral of projection x
|
||||
double *hiy=new double[nbetaY]; //integral of projection y
|
||||
// int ii=0;
|
||||
double etax, etay;
|
||||
for (int ib=0; ib<nbetaX; ib++) {
|
||||
for (int iby = 0; iby < nbetaY; iby++) {
|
||||
etay = etamin + iby * etastepY;
|
||||
// cout << etax << endl;
|
||||
|
||||
|
||||
//tot_eta_y=0;
|
||||
// tot_eta_x+=hx[iby];
|
||||
if (etay >= 0 && etay <= 1)
|
||||
hy[iby] = heta[ib + iby * nbetaX];
|
||||
else
|
||||
hy[iby] = 0;
|
||||
// tot_eta_y+=hy[iby];
|
||||
}
|
||||
|
||||
for (int iby=0; iby<nbetaY; iby++) {
|
||||
etay=etamin+iby*etastepY;
|
||||
//cout << etax << endl;
|
||||
|
||||
// tot_eta_x+=hx[iby];
|
||||
if (etay>=0 && etay<=1)
|
||||
hy[iby]=heta[ib+iby*nbetaX];
|
||||
else
|
||||
hy[iby]=0;
|
||||
// tot_eta_y+=hy[iby];
|
||||
}
|
||||
hiy[0] = hy[0];
|
||||
|
||||
|
||||
hiy[0]=hy[0];
|
||||
for (int iby = 1; iby < nbetaY; iby++) {
|
||||
hiy[iby] = hiy[iby - 1] + hy[iby];
|
||||
}
|
||||
|
||||
for (int iby=1; iby<nbetaY; iby++) {
|
||||
hiy[iby]=hiy[iby-1]+hy[iby];
|
||||
}
|
||||
tot_eta_y = hiy[nbetaY - 1] + 1;
|
||||
|
||||
tot_eta_y=hiy[nbetaY-1]+1;
|
||||
|
||||
for (int iby=0; iby<nbetaY; iby++) {
|
||||
if (tot_eta_y<=0) {
|
||||
hhy[ib+iby*nbetaX]=-1;
|
||||
//ii=(ibx*nSubPixels)/nbeta;
|
||||
} else {
|
||||
//if (hiy[ibx]>tot_eta_y*(ii+1)/nSubPixels) ii++;
|
||||
hhy[ib+iby*nbetaX]=hiy[iby]/tot_eta_y;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int iby = 0; iby < nbetaY; iby++) {
|
||||
if (tot_eta_y <= 0) {
|
||||
hhy[ib + iby * nbetaX] = -1;
|
||||
// ii=(ibx*nSubPixels)/nbeta;
|
||||
} else {
|
||||
// if (hiy[ibx]>tot_eta_y*(ii+1)/nSubPixels) ii++;
|
||||
hhy[ib + iby * nbetaX] = hiy[iby] / tot_eta_y;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int ib = 0; ib < nbetaY; ib++) {
|
||||
|
||||
for (int ibx = 0; ibx < nbetaX; ibx++) {
|
||||
etax = etamin + ibx * etastepX;
|
||||
// cout << etax << endl;
|
||||
if (etax >= 0 && etax <= 1)
|
||||
hx[ibx] = heta[ibx + ib * nbetaX];
|
||||
else {
|
||||
hx[ibx] = 0;
|
||||
}
|
||||
}
|
||||
hix[0] = hx[0];
|
||||
|
||||
for (int ib=0; ib<nbetaY; ib++) {
|
||||
for (int ibx = 1; ibx < nbetaX; ibx++) {
|
||||
hix[ibx] = hix[ibx - 1] + hx[ibx];
|
||||
}
|
||||
|
||||
for (int ibx=0; ibx<nbetaX; ibx++) {
|
||||
etax=etamin+ibx*etastepX;
|
||||
//cout << etax << endl;
|
||||
if (etax>=0 && etax<=1)
|
||||
hx[ibx]=heta[ibx+ib*nbetaX];
|
||||
else {
|
||||
hx[ibx]=0;
|
||||
}
|
||||
}
|
||||
hix[0]=hx[0];
|
||||
|
||||
for (int ibx=1; ibx<nbetaX; ibx++) {
|
||||
hix[ibx]=hix[ibx-1]+hx[ibx];
|
||||
}
|
||||
tot_eta_x = hix[nbetaX - 1] + 1;
|
||||
|
||||
|
||||
tot_eta_x=hix[nbetaX-1]+1;
|
||||
|
||||
for (int ibx=0; ibx<nbetaX; ibx++) {
|
||||
if (tot_eta_x<=0) {
|
||||
hhx[ibx+ib*nbetaX]=-1;
|
||||
}
|
||||
else {
|
||||
hhx[ibx+ib*nbetaX]=hix[ibx]/tot_eta_x;
|
||||
}
|
||||
}
|
||||
|
||||
for (int ibx = 0; ibx < nbetaX; ibx++) {
|
||||
if (tot_eta_x <= 0) {
|
||||
hhx[ibx + ib * nbetaX] = -1;
|
||||
} else {
|
||||
hhx[ibx + ib * nbetaX] = hix[ibx] / tot_eta_x;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (int ibx=0; ibx<nbetaX; ibx++) {
|
||||
if (tot_eta_x<=0) {
|
||||
hhx[ibx+ib*nbetaX]=-1;
|
||||
} else {
|
||||
//if (hix[ibx]>tot_eta_x*(ii+1)/nSubPixels) ii++;
|
||||
hhx[ibx+ib*nbetaX]=hix[ibx]/tot_eta_x;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
for (int ibx = 0; ibx < nbetaX; ibx++) {
|
||||
if (tot_eta_x <= 0) {
|
||||
hhx[ibx + ib * nbetaX] = -1;
|
||||
} else {
|
||||
// if (hix[ibx]>tot_eta_x*(ii+1)/nSubPixels) ii++;
|
||||
hhx[ibx + ib * nbetaX] = hix[ibx] / tot_eta_x;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
|
||||
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];
|
||||
}
|
||||
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;
|
||||
|
||||
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];
|
||||
}
|
||||
|
||||
#ifdef SAVE_ALL
|
||||
debugSaveAll();
|
||||
#endif
|
||||
delete [] hx;
|
||||
delete [] hy;
|
||||
delete [] hix;
|
||||
delete [] hiy;
|
||||
|
||||
return ;
|
||||
}
|
||||
debugSaveAll();
|
||||
#endif
|
||||
delete[] hx;
|
||||
delete[] hy;
|
||||
delete[] hix;
|
||||
delete[] hiy;
|
||||
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
eta2InterpolationPosXY(eta2InterpolationPosXY *orig)
|
||||
: etaInterpolationBase(orig), etaInterpolationPosXY(orig){};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
eta2InterpolationPosXY(eta2InterpolationPosXY *orig): etaInterpolationBase(orig), etaInterpolationPosXY(orig) {};
|
||||
|
||||
virtual eta2InterpolationPosXY* Clone() { return new eta2InterpolationPosXY(this);};
|
||||
|
||||
virtual eta2InterpolationPosXY *Clone() {
|
||||
return new eta2InterpolationPosXY(this);
|
||||
};
|
||||
};
|
||||
|
||||
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(eta3InterpolationPosXY *orig)
|
||||
: etaInterpolationBase(orig), etaInterpolationPosXY(orig){};
|
||||
|
||||
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(eta3InterpolationPosXY *orig): etaInterpolationBase(orig), etaInterpolationPosXY(orig) {};
|
||||
|
||||
virtual eta3InterpolationPosXY* Clone() { return new eta3InterpolationPosXY(this);};
|
||||
virtual eta3InterpolationPosXY *Clone() {
|
||||
return new eta3InterpolationPosXY(this);
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -3,417 +3,397 @@
|
||||
#ifndef ETA_INTERPOLATION_RANDOMBINS_H
|
||||
#define ETA_INTERPOLATION_RANDOMBINS_H
|
||||
|
||||
|
||||
#include "tiffIO.h"
|
||||
//#include "etaInterpolationBase.h"
|
||||
#include "etaInterpolationPosXY.h"
|
||||
#include <cstdlib>
|
||||
#include <algorithm>
|
||||
#include <cstdlib>
|
||||
//#include <math>
|
||||
#include <cmath> // std::abs
|
||||
#include <cmath> // std::abs
|
||||
|
||||
#define PI 3.14159265
|
||||
#define TWOPI 2.*PI
|
||||
#define PI 3.14159265
|
||||
#define TWOPI 2. * PI
|
||||
|
||||
using namespace std;
|
||||
|
||||
class etaInterpolationRandomBins : 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<nSubPixels; ipx++) {
|
||||
for (int ipy=0; ipy<nSubPixels; ipy++) {
|
||||
p_tot=0;
|
||||
for (int ibx=0; ibx<nbeta; ibx++) {
|
||||
for (int iby=0; iby<nbeta; iby++) {
|
||||
if ( hx[ibx+iby*nbeta]>=((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 ";
|
||||
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 < nSubPixels; ipx++) {
|
||||
for (int ipy = 0; ipy < nSubPixels; ipy++) {
|
||||
p_tot = 0;
|
||||
for (int ibx = 0; ibx < nbeta; ibx++) {
|
||||
for (int iby = 0; iby < nbeta; iby++) {
|
||||
if (hx[ibx + iby * nbeta] >= ((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";
|
||||
diff += (p_tot - avg) * (p_tot - avg);
|
||||
}
|
||||
// cout << "\n";
|
||||
}
|
||||
return diff;
|
||||
}
|
||||
return diff;
|
||||
}
|
||||
|
||||
double iterate(float *newhhx, float *newhhy, double avg) {
|
||||
|
||||
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;
|
||||
double iterate(float *newhhx, float *newhhy, double avg) {
|
||||
|
||||
int p0;
|
||||
int vx[(nSubPixels+1)*(nSubPixels+1)], vy[(nSubPixels+1)*(nSubPixels+1)];
|
||||
double bsize = 1. / nSubPixels;
|
||||
|
||||
int arrx[nSubPixels+1], arry[nSubPixels+1];
|
||||
double hy[nbeta]; // profile y
|
||||
double hx[nbeta]; // profile x
|
||||
double hix[nbeta]; // integral of projection x
|
||||
double hiy[nbeta]; // integral of projection y
|
||||
|
||||
int bad=1;
|
||||
double tot_eta_x = 0;
|
||||
double tot_eta_y = 0;
|
||||
|
||||
int p0;
|
||||
int vx[(nSubPixels + 1) * (nSubPixels + 1)],
|
||||
vy[(nSubPixels + 1) * (nSubPixels + 1)];
|
||||
|
||||
int isby, isbx;
|
||||
int ii=0;
|
||||
|
||||
int arrx[nSubPixels + 1], arry[nSubPixels + 1];
|
||||
|
||||
// using default comparison (operator <):
|
||||
// std::sort (myvector.begin(), myvector.begin()+4); //(12 32 45 71)26 80 53 33
|
||||
int bad = 1;
|
||||
|
||||
for (isby=0; isby<(nSubPixels+1)/2+1; isby++) {
|
||||
|
||||
for (isbx=0; isbx<(nSubPixels+1)/2+1; isbx++) {
|
||||
p0=isby*(nSubPixels+1)+isbx;
|
||||
// for (int iv=0; iv<(nSubPixels+1)*(nSubPixels+1); iv++) {
|
||||
if (isbx==0) {
|
||||
vy[p0]=isby*nbeta/nSubPixels;
|
||||
vx[p0]=0;
|
||||
} else if ( isby==0 ) {
|
||||
vy[p0]=0;
|
||||
vx[p0]=isbx*nbeta/nSubPixels;
|
||||
}
|
||||
else {
|
||||
vy[p0]=rand()%(nbeta/2);
|
||||
vx[p0]=rand()%(nbeta/2);
|
||||
if (nSubPixels%2==0 && isbx==nSubPixels/2)
|
||||
vx[p0]=nbeta/2;
|
||||
if (nSubPixels%2==0 && isby==nSubPixels/2 )
|
||||
vy[p0]=nbeta/2;
|
||||
}
|
||||
// cout << "(" << vx[p0] << " , " << vy[p0] << " ) \t" ;
|
||||
// }
|
||||
}
|
||||
//cout << endl;
|
||||
}
|
||||
// cout << "rand" << endl;
|
||||
|
||||
|
||||
while (bad) {
|
||||
int isby, isbx;
|
||||
int ii = 0;
|
||||
|
||||
for (isby=0; isby<(nSubPixels+1)/2+1; isby++) {
|
||||
|
||||
|
||||
for (isbx=0; isbx<(nSubPixels+1)/2+1; isbx++) {
|
||||
arrx[isbx]=vx[isby*(nSubPixels+1)+isbx];
|
||||
arry[isbx]=vy[isbx*(nSubPixels+1)+isby];
|
||||
//cout << isbx << " " << arrx[isbx] << " " << isby << " " << arry[isbx] << endl;
|
||||
}
|
||||
// using default comparison (operator <):
|
||||
// std::sort (myvector.begin(), myvector.begin()+4); //(12 32
|
||||
// 45 71)26 80 53 33
|
||||
|
||||
sort(arrx,arrx+(nSubPixels+1)/2+1);
|
||||
sort(arry,arry+(nSubPixels+1)/2+1);
|
||||
|
||||
// cout << "*****"<< endl;
|
||||
// cout << endl;
|
||||
for (isby = 0; isby < (nSubPixels + 1) / 2 + 1; isby++) {
|
||||
|
||||
for (int isbx=0; isbx<(nSubPixels+1)/2+1; isbx++) {
|
||||
vx[isby*(nSubPixels+1)+isbx]=arrx[isbx];
|
||||
vy[isbx*(nSubPixels+1)+isby]=arry[isbx];
|
||||
|
||||
for (isbx = 0; isbx < (nSubPixels + 1) / 2 + 1; isbx++) {
|
||||
p0 = isby * (nSubPixels + 1) + isbx;
|
||||
// for (int iv=0; iv<(nSubPixels+1)*(nSubPixels+1); iv++) {
|
||||
if (isbx == 0) {
|
||||
vy[p0] = isby * nbeta / nSubPixels;
|
||||
vx[p0] = 0;
|
||||
} else if (isby == 0) {
|
||||
vy[p0] = 0;
|
||||
vx[p0] = isbx * nbeta / nSubPixels;
|
||||
} else {
|
||||
vy[p0] = rand() % (nbeta / 2);
|
||||
vx[p0] = rand() % (nbeta / 2);
|
||||
if (nSubPixels % 2 == 0 && isbx == nSubPixels / 2)
|
||||
vx[p0] = nbeta / 2;
|
||||
if (nSubPixels % 2 == 0 && isby == nSubPixels / 2)
|
||||
vy[p0] = nbeta / 2;
|
||||
}
|
||||
// cout << "(" << vx[p0] << " , " << vy[p0] << " ) \t" ;
|
||||
// }
|
||||
}
|
||||
// cout << endl;
|
||||
}
|
||||
// cout << "rand" << endl;
|
||||
|
||||
vx[(nSubPixels-isby)*(nSubPixels+1)+(nSubPixels-isbx)]=nbeta-arrx[isbx];
|
||||
vy[(nSubPixels-isbx)*(nSubPixels+1)+(nSubPixels-isby)]=nbeta-arry[isbx];
|
||||
while (bad) {
|
||||
|
||||
vx[isby*(nSubPixels+1)+(nSubPixels-isbx)]=nbeta-arrx[isbx];
|
||||
vy[isbx*(nSubPixels+1)+(nSubPixels-isby)]=arry[isbx];
|
||||
|
||||
for (isby = 0; isby < (nSubPixels + 1) / 2 + 1; isby++) {
|
||||
|
||||
vx[(nSubPixels-isby)*(nSubPixels+1)+(isbx)]=arrx[isbx];
|
||||
vy[(nSubPixels-isbx)*(nSubPixels+1)+(isby)]=nbeta-arry[isbx];
|
||||
for (isbx = 0; isbx < (nSubPixels + 1) / 2 + 1; isbx++) {
|
||||
arrx[isbx] = vx[isby * (nSubPixels + 1) + isbx];
|
||||
arry[isbx] = vy[isbx * (nSubPixels + 1) + isby];
|
||||
// cout << isbx << " " << arrx[isbx] << " " << isby << " "
|
||||
// << arry[isbx] << endl;
|
||||
}
|
||||
|
||||
sort(arrx, arrx + (nSubPixels + 1) / 2 + 1);
|
||||
sort(arry, arry + (nSubPixels + 1) / 2 + 1);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/* for (isby=0; isby<nSubPixels+1; isby++) { */
|
||||
|
||||
/* for (isbx=0; isbx<nSubPixels+1; isbx++) { */
|
||||
// cout << "*****"<< endl;
|
||||
// cout << endl;
|
||||
|
||||
/* cout << "("<< vx[isby*(nSubPixels+1)+isbx] << " " << vy[isby*(nSubPixels+1)+isbx] << ")\t";//<< endl; */
|
||||
/* } */
|
||||
/* cout << endl; */
|
||||
/* } */
|
||||
|
||||
bad=0;
|
||||
for (isby=1; isby<(nSubPixels+1)/2+1; isby++) {
|
||||
|
||||
for (isbx=1; isbx<(nSubPixels+1)/2+1; isbx++) {
|
||||
|
||||
if (heta[vx[isby*(nSubPixels+1)+isbx]+vy[isby*(nSubPixels+1)+isbx]*nbeta]<avg*(nSubPixels*nSubPixels)/(nbeta*nbeta)) {
|
||||
// cout << ii << " " << isbx << " " << isby << " " << vx[isby*(nSubPixels+1)+isbx] << " " << vy[isby*(nSubPixels+1)+isbx] << " " << heta[vx[isby*(nSubPixels+1)+isbx]+vy[isby*(nSubPixels+1)+isbx]*nbeta] << endl;
|
||||
if (nSubPixels%2==0 && isbx==nSubPixels/2)
|
||||
;
|
||||
else
|
||||
vx[isby*(nSubPixels+1)+isbx]=rand()%(nbeta/2);
|
||||
|
||||
if (nSubPixels%2==0 && isbx==nSubPixels/2)
|
||||
;
|
||||
else
|
||||
vy[isby*(nSubPixels+1)+isbx]=rand()%(nbeta/2);
|
||||
for (int isbx = 0; isbx < (nSubPixels + 1) / 2 + 1; isbx++) {
|
||||
vx[isby * (nSubPixels + 1) + isbx] = arrx[isbx];
|
||||
vy[isbx * (nSubPixels + 1) + isby] = arry[isbx];
|
||||
|
||||
if (bad==0)
|
||||
ii++;
|
||||
|
||||
bad=1;
|
||||
// break;
|
||||
}
|
||||
|
||||
}
|
||||
//if (bad) break;
|
||||
}
|
||||
// cout << "sort" << endl;
|
||||
|
||||
}
|
||||
vx[(nSubPixels - isby) * (nSubPixels + 1) +
|
||||
(nSubPixels - isbx)] = nbeta - arrx[isbx];
|
||||
vy[(nSubPixels - isbx) * (nSubPixels + 1) +
|
||||
(nSubPixels - isby)] = nbeta - arry[isbx];
|
||||
|
||||
vx[isby * (nSubPixels + 1) + (nSubPixels - isbx)] =
|
||||
nbeta - arrx[isbx];
|
||||
vy[isbx * (nSubPixels + 1) + (nSubPixels - isby)] =
|
||||
arry[isbx];
|
||||
|
||||
cout << ii << " sub iteractions " << avg*(nSubPixels*nSubPixels)/(nbeta*nbeta) << endl;
|
||||
vx[(nSubPixels - isby) * (nSubPixels + 1) + (isbx)] =
|
||||
arrx[isbx];
|
||||
vy[(nSubPixels - isbx) * (nSubPixels + 1) + (isby)] =
|
||||
nbeta - arry[isbx];
|
||||
}
|
||||
}
|
||||
|
||||
double m,q;
|
||||
int in_quad;
|
||||
int p[4];
|
||||
int p1x,p2x, p1y, p2y;
|
||||
// cout << nbeta << endl;
|
||||
double angle;
|
||||
double dtheta,theta1,theta2;
|
||||
/* for (isby=0; isby<nSubPixels+1; isby++) { */
|
||||
|
||||
/* for (isbx=0; isbx<nSubPixels+1; isbx++) { */
|
||||
|
||||
/* cout << "("<< vx[isby*(nSubPixels+1)+isbx] << " " <<
|
||||
* vy[isby*(nSubPixels+1)+isbx] << ")\t";//<< endl; */
|
||||
/* } */
|
||||
/* cout << endl; */
|
||||
/* } */
|
||||
|
||||
bad = 0;
|
||||
for (isby = 1; isby < (nSubPixels + 1) / 2 + 1; isby++) {
|
||||
|
||||
|
||||
for (int ibx=0; ibx<nbeta; ibx++) {
|
||||
|
||||
for (int iby=0; iby<nbeta; iby++) {
|
||||
for (isbx = 1; isbx < (nSubPixels + 1) / 2 + 1; isbx++) {
|
||||
|
||||
in_quad=0;
|
||||
if (heta[vx[isby * (nSubPixels + 1) + isbx] +
|
||||
vy[isby * (nSubPixels + 1) + isbx] * nbeta] <
|
||||
avg * (nSubPixels * nSubPixels) / (nbeta * nbeta)) {
|
||||
// cout << ii << " " << isbx << " " << isby << " "
|
||||
//<< vx[isby*(nSubPixels+1)+isbx] << " " <<
|
||||
//vy[isby*(nSubPixels+1)+isbx] << " " <<
|
||||
//heta[vx[isby*(nSubPixels+1)+isbx]+vy[isby*(nSubPixels+1)+isbx]*nbeta]
|
||||
//<< endl;
|
||||
if (nSubPixels % 2 == 0 && isbx == nSubPixels / 2)
|
||||
;
|
||||
else
|
||||
vx[isby * (nSubPixels + 1) + isbx] =
|
||||
rand() % (nbeta / 2);
|
||||
|
||||
/* if (ibx==0) */
|
||||
/* isbx=0; */
|
||||
/* else */
|
||||
/* isbx= (newhhx[ibx-1+iby*nbeta])/bsize-1; */
|
||||
/* if (isbx<0) isbx=0; */
|
||||
/* if (isbx>nSubPixels-1) isbx=nSubPixels-1; */
|
||||
if (nSubPixels % 2 == 0 && isbx == nSubPixels / 2)
|
||||
;
|
||||
else
|
||||
vy[isby * (nSubPixels + 1) + isbx] =
|
||||
rand() % (nbeta / 2);
|
||||
|
||||
/* if (iby==0) */
|
||||
/* isby=0; */
|
||||
/* else */
|
||||
/* isby= (newhhx[ibx+(iby-1)*nbeta])/bsize-1; */
|
||||
|
||||
/* if (isby<0) isbx=0; */
|
||||
/* if (isby>nSubPixels-1) isby=nSubPixels-1; */
|
||||
/* // cout << isbx << " " << isby << endl; */
|
||||
if (bad == 0)
|
||||
ii++;
|
||||
|
||||
for (isby=0; isby<nSubPixels; isby++) {
|
||||
|
||||
for (isbx=0; isbx<nSubPixels; isbx++) {
|
||||
bad = 1;
|
||||
// break;
|
||||
}
|
||||
}
|
||||
// if (bad) break;
|
||||
}
|
||||
// cout << "sort" << endl;
|
||||
}
|
||||
|
||||
// cout << ibx << " " << iby << " " << isbx << " " << isby << endl;
|
||||
p[0]=isby*(nSubPixels+1)+isbx;
|
||||
p[1]=isby*(nSubPixels+1)+isbx+1;
|
||||
p[2]=(isby+1)*(nSubPixels+1)+isbx+1;
|
||||
p[3]=(isby+1)*(nSubPixels+1)+isbx;
|
||||
|
||||
cout << ii << " sub iteractions "
|
||||
<< avg * (nSubPixels * nSubPixels) / (nbeta * nbeta) << endl;
|
||||
|
||||
angle=0;
|
||||
for (int i=0;i<4;i++) {
|
||||
p1x = vx[p[i]] - ibx;
|
||||
p1y = vy[p[i]] - iby;
|
||||
p2x = vx[p[(i+1)%4]] - ibx;
|
||||
p2y = vy[p[(i+1)%4]] - iby;
|
||||
theta1 = atan2(p1y,p1x);
|
||||
theta2 = atan2(p2y,p2x);
|
||||
dtheta = theta2 - theta1;
|
||||
double m, q;
|
||||
int in_quad;
|
||||
int p[4];
|
||||
int p1x, p2x, p1y, p2y;
|
||||
// cout << nbeta << endl;
|
||||
double angle;
|
||||
double dtheta, theta1, theta2;
|
||||
|
||||
while (dtheta > PI)
|
||||
dtheta -= TWOPI;
|
||||
while (dtheta < -PI)
|
||||
dtheta += TWOPI;
|
||||
for (int ibx = 0; ibx < nbeta; ibx++) {
|
||||
|
||||
angle += dtheta;
|
||||
}
|
||||
for (int iby = 0; iby < nbeta; iby++) {
|
||||
|
||||
if (abs((double)angle) < PI)
|
||||
in_quad=0;
|
||||
else
|
||||
in_quad=1;
|
||||
|
||||
if (in_quad) {
|
||||
newhhx[ibx+iby*nbeta]=bsize*((double)isbx);
|
||||
newhhy[ibx+iby*nbeta]=bsize*((double)isby);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
if (in_quad) break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// cout << "hist" << endl;
|
||||
return calcDiff(avg, newhhx, newhhy);
|
||||
}
|
||||
|
||||
in_quad = 0;
|
||||
|
||||
public:
|
||||
etaInterpolationRandomBins(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){};
|
||||
/* if (ibx==0) */
|
||||
/* isbx=0; */
|
||||
/* else */
|
||||
/* isbx= (newhhx[ibx-1+iby*nbeta])/bsize-1; */
|
||||
/* if (isbx<0) isbx=0; */
|
||||
/* if (isbx>nSubPixels-1) isbx=nSubPixels-1; */
|
||||
|
||||
etaInterpolationRandomBins(etaInterpolationRandomBins *orig): etaInterpolationPosXY(orig){};
|
||||
/* if (iby==0) */
|
||||
/* isby=0; */
|
||||
/* else */
|
||||
/* isby= (newhhx[ibx+(iby-1)*nbeta])/bsize-1; */
|
||||
|
||||
virtual etaInterpolationRandomBins* Clone() {
|
||||
/* if (isby<0) isbx=0; */
|
||||
/* if (isby>nSubPixels-1) isby=nSubPixels-1; */
|
||||
/* // cout << isbx << " " << isby << endl; */
|
||||
|
||||
return new etaInterpolationRandomBins(this);
|
||||
for (isby = 0; isby < nSubPixels; isby++) {
|
||||
|
||||
};
|
||||
for (isbx = 0; isbx < nSubPixels; isbx++) {
|
||||
|
||||
// cout << ibx << " " << iby << " " << isbx << " " <<
|
||||
// isby << endl;
|
||||
p[0] = isby * (nSubPixels + 1) + isbx;
|
||||
p[1] = isby * (nSubPixels + 1) + isbx + 1;
|
||||
p[2] = (isby + 1) * (nSubPixels + 1) + isbx + 1;
|
||||
p[3] = (isby + 1) * (nSubPixels + 1) + isbx;
|
||||
|
||||
angle = 0;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
p1x = vx[p[i]] - ibx;
|
||||
p1y = vy[p[i]] - iby;
|
||||
p2x = vx[p[(i + 1) % 4]] - ibx;
|
||||
p2y = vy[p[(i + 1) % 4]] - iby;
|
||||
theta1 = atan2(p1y, p1x);
|
||||
theta2 = atan2(p2y, p2x);
|
||||
dtheta = theta2 - theta1;
|
||||
|
||||
virtual void prepareInterpolation(int &ok)
|
||||
{
|
||||
ok=1;
|
||||
cout << "Adaptive bins" << endl;
|
||||
while (dtheta > PI)
|
||||
dtheta -= TWOPI;
|
||||
while (dtheta < -PI)
|
||||
dtheta += TWOPI;
|
||||
|
||||
///*Eta Distribution Rebinning*///
|
||||
double bsize=1./nSubPixels; //precision
|
||||
// cout<<"nPixelsX = "<<nPixelsX<<" nPixelsY = "<<nPixelsY<<" nSubPixels = "<<nSubPixels<<endl;
|
||||
double tot_eta=0;
|
||||
for (int ip=0; ip<nbeta*nbeta; ip++)
|
||||
tot_eta+=heta[ip];
|
||||
if (tot_eta<=0) {ok=0; return;};
|
||||
angle += dtheta;
|
||||
}
|
||||
|
||||
if (abs((double)angle) < PI)
|
||||
in_quad = 0;
|
||||
else
|
||||
in_quad = 1;
|
||||
|
||||
int ii=0;
|
||||
if (in_quad) {
|
||||
newhhx[ibx + iby * nbeta] = bsize * ((double)isbx);
|
||||
newhhy[ibx + iby * nbeta] = bsize * ((double)isby);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (in_quad)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// cout << "hist" << endl;
|
||||
return calcDiff(avg, newhhx, newhhy);
|
||||
}
|
||||
|
||||
|
||||
int nint=1000;
|
||||
public:
|
||||
etaInterpolationRandomBins(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){};
|
||||
|
||||
double thr=1./((double)nSubPixels);
|
||||
double avg=tot_eta/((double)(nSubPixels*nSubPixels));
|
||||
cout << "total eta entries is :"<< tot_eta << " avg: "<< avg << endl;
|
||||
cout << "Start " << endl;
|
||||
double old_diff=-1, new_diff=-1;
|
||||
// cout << " diff= " << new_diff << endl;
|
||||
|
||||
etaInterpolationRandomBins(etaInterpolationRandomBins *orig)
|
||||
: etaInterpolationPosXY(orig){};
|
||||
|
||||
virtual etaInterpolationRandomBins *Clone() {
|
||||
|
||||
return new etaInterpolationRandomBins(this);
|
||||
};
|
||||
|
||||
virtual void prepareInterpolation(int &ok) {
|
||||
ok = 1;
|
||||
cout << "Adaptive bins" << endl;
|
||||
|
||||
|
||||
etaInterpolationPosXY::prepareInterpolation(ok);
|
||||
|
||||
old_diff=calcDiff(avg, hhx, hhy);
|
||||
cout << " diff= " << old_diff << endl;
|
||||
///*Eta Distribution Rebinning*///
|
||||
double bsize = 1. / nSubPixels; // precision
|
||||
// cout<<"nPixelsX = "<<nPixelsX<<" nPixelsY = "<<nPixelsY<<" nSubPixels
|
||||
// = "<<nSubPixels<<endl;
|
||||
double tot_eta = 0;
|
||||
for (int ip = 0; ip < nbeta * nbeta; ip++)
|
||||
tot_eta += heta[ip];
|
||||
if (tot_eta <= 0) {
|
||||
ok = 0;
|
||||
return;
|
||||
};
|
||||
|
||||
int ii = 0;
|
||||
|
||||
int nint = 1000;
|
||||
|
||||
double thr = 1. / ((double)nSubPixels);
|
||||
double avg = tot_eta / ((double)(nSubPixels * nSubPixels));
|
||||
cout << "total eta entries is :" << tot_eta << " avg: " << avg << endl;
|
||||
cout << "Start " << endl;
|
||||
double old_diff = -1, new_diff = -1;
|
||||
// cout << " diff= " << new_diff << endl;
|
||||
|
||||
etaInterpolationPosXY::prepareInterpolation(ok);
|
||||
|
||||
old_diff = calcDiff(avg, hhx, hhy);
|
||||
cout << " diff= " << old_diff << endl;
|
||||
|
||||
|
||||
|
||||
|
||||
int iint=0;
|
||||
float *newhhx=new float[nbeta*nbeta]; //profile x
|
||||
float *newhhy=new float[nbeta*nbeta]; //profile y
|
||||
int igood=0, ibad=0;
|
||||
int iint = 0;
|
||||
float *newhhx = new float[nbeta * nbeta]; // profile x
|
||||
float *newhhy = new float[nbeta * nbeta]; // profile y
|
||||
int igood = 0, ibad = 0;
|
||||
#ifdef SAVE_ALL
|
||||
int etabins=nbeta;
|
||||
float *etah=new float[nbeta*nbeta];
|
||||
char tit[1000];
|
||||
int etabins = nbeta;
|
||||
float *etah = new float[nbeta * nbeta];
|
||||
char tit[1000];
|
||||
#endif
|
||||
|
||||
while (iint<nint) {
|
||||
|
||||
cout << "Iteration " << iint << endl;
|
||||
new_diff=iterate(newhhx,newhhy, avg);
|
||||
//new_diff=calcDiff(avg, newhhx, newhhy);
|
||||
cout << " diff= " << new_diff << " ( " << old_diff<< " ) " << endl;
|
||||
while (iint < nint) {
|
||||
|
||||
cout << "Iteration " << iint << endl;
|
||||
new_diff = iterate(newhhx, newhhy, avg);
|
||||
// new_diff=calcDiff(avg, newhhx, newhhy);
|
||||
cout << " diff= " << new_diff << " ( " << old_diff << " ) " << endl;
|
||||
|
||||
/* #ifdef SAVE_ALL */
|
||||
/* for (int ii=0; ii<etabins*etabins; ii++) { */
|
||||
/* etah[ii]=newhhx[ii]; */
|
||||
/* if (etah[ii]>1 || etah[ii]<0 ) cout << "***"<< ii <<
|
||||
* etah[ii] << endl; */
|
||||
/* } */
|
||||
/* sprintf(tit,"/scratch/randeta_hhx_%d.tiff",iint); */
|
||||
/* WriteToTiff(etah, tit, etabins, etabins); */
|
||||
|
||||
/* #ifdef SAVE_ALL */
|
||||
/* for (int ii=0; ii<etabins*etabins; ii++) { */
|
||||
/* etah[ii]=newhhx[ii]; */
|
||||
/* if (etah[ii]>1 || etah[ii]<0 ) cout << "***"<< ii << etah[ii] << endl; */
|
||||
/* } */
|
||||
/* sprintf(tit,"/scratch/randeta_hhx_%d.tiff",iint); */
|
||||
/* WriteToTiff(etah, tit, etabins, etabins); */
|
||||
|
||||
/* for (int ii=0; ii<etabins*etabins; ii++) { */
|
||||
/* etah[ii]=newhhy[ii]; */
|
||||
/* if (etah[ii]>1 || etah[ii]<0 ) cout << "***"<< ii << etah[ii] << endl; */
|
||||
/* } */
|
||||
/* sprintf(tit,"/scratch/randeta_hhy_%d.tiff",iint); */
|
||||
/* WriteToTiff(etah, tit, etabins, etabins); */
|
||||
/* #endif */
|
||||
|
||||
if (new_diff<old_diff) {
|
||||
|
||||
cout << "******************** GOOD! ***********************"<< endl;
|
||||
delete [] hhx;
|
||||
delete [] hhy;
|
||||
igood++;
|
||||
hhx=newhhx;
|
||||
hhy=newhhy;
|
||||
newhhx=new float[nbeta*nbeta]; //profile x */
|
||||
newhhy=new float[nbeta*nbeta]; //profile y */
|
||||
old_diff=new_diff;
|
||||
} else
|
||||
ibad++;
|
||||
|
||||
iint++;
|
||||
}
|
||||
delete [] newhhx;
|
||||
delete [] newhhy;
|
||||
/* for (int ii=0; ii<etabins*etabins; ii++) { */
|
||||
/* etah[ii]=newhhy[ii]; */
|
||||
/* if (etah[ii]>1 || etah[ii]<0 ) cout << "***"<< ii <<
|
||||
* etah[ii] << endl; */
|
||||
/* } */
|
||||
/* sprintf(tit,"/scratch/randeta_hhy_%d.tiff",iint); */
|
||||
/* WriteToTiff(etah, tit, etabins, etabins); */
|
||||
/* #endif */
|
||||
|
||||
cout << "performed " << iint << " iterations of which " << igood << " positive " << endl;
|
||||
if (new_diff < old_diff) {
|
||||
|
||||
cout << "******************** GOOD! ***********************"
|
||||
<< endl;
|
||||
delete[] hhx;
|
||||
delete[] hhy;
|
||||
igood++;
|
||||
hhx = newhhx;
|
||||
hhy = newhhy;
|
||||
newhhx = new float[nbeta * nbeta]; // profile x */
|
||||
newhhy = new float[nbeta * nbeta]; // profile y */
|
||||
old_diff = new_diff;
|
||||
} else
|
||||
ibad++;
|
||||
|
||||
/* #ifdef SAVE_ALL */
|
||||
|
||||
iint++;
|
||||
}
|
||||
delete[] newhhx;
|
||||
delete[] newhhy;
|
||||
|
||||
/* for (int ii=0; ii<etabins*etabins; ii++) { */
|
||||
/* etah[ii]=hhx[ii]; */
|
||||
/* } */
|
||||
/* sprintf(tit,"/scratch/eta_hhx_%d.tiff",id); */
|
||||
/* WriteToTiff(etah, tit, etabins, etabins); */
|
||||
|
||||
/* for (int ii=0; ii<etabins*etabins; ii++) { */
|
||||
/* etah[ii]=hhy[ii]; */
|
||||
/* } */
|
||||
/* sprintf(tit,"/scratch/eta_hhy_%d.tiff",id); */
|
||||
/* WriteToTiff(etah, tit, etabins, etabins); */
|
||||
|
||||
/* for (int ii=0; ii<etabins*etabins; ii++) { */
|
||||
/* etah[ii]=heta[ii]; */
|
||||
/* } */
|
||||
/* sprintf(tit,"/scratch/eta_%d.tiff",id); */
|
||||
/* WriteToTiff(etah, tit, etabins, etabins); */
|
||||
/* delete [] etah; */
|
||||
/* #endif */
|
||||
return ;
|
||||
}
|
||||
cout << "performed " << iint << " iterations of which " << igood
|
||||
<< " positive " << endl;
|
||||
|
||||
/* #ifdef SAVE_ALL */
|
||||
|
||||
/* for (int ii=0; ii<etabins*etabins; ii++) { */
|
||||
/* etah[ii]=hhx[ii]; */
|
||||
/* } */
|
||||
/* sprintf(tit,"/scratch/eta_hhx_%d.tiff",id); */
|
||||
/* WriteToTiff(etah, tit, etabins, etabins); */
|
||||
|
||||
/* for (int ii=0; ii<etabins*etabins; ii++) { */
|
||||
/* etah[ii]=hhy[ii]; */
|
||||
/* } */
|
||||
/* sprintf(tit,"/scratch/eta_hhy_%d.tiff",id); */
|
||||
/* WriteToTiff(etah, tit, etabins, etabins); */
|
||||
|
||||
/* for (int ii=0; ii<etabins*etabins; ii++) { */
|
||||
/* etah[ii]=heta[ii]; */
|
||||
/* } */
|
||||
/* sprintf(tit,"/scratch/eta_%d.tiff",id); */
|
||||
/* WriteToTiff(etah, tit, etabins, etabins); */
|
||||
/* delete [] etah; */
|
||||
/* #endif */
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,26 +1,25 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
#include <iostream>
|
||||
#include <TGraph.h>
|
||||
#include <TAxis.h>
|
||||
#include <TMultiGraph.h>
|
||||
#include <TBuffer.h>
|
||||
#include <TGraph.h>
|
||||
#include <TH2D.h>
|
||||
#include <TMath.h>
|
||||
#include <TMultiGraph.h>
|
||||
#include <TObject.h>
|
||||
#include <TBuffer.h>
|
||||
#include <iostream>
|
||||
|
||||
#include <TMatrixD.h>
|
||||
|
||||
#include <TDecompSVD.h>
|
||||
//#include <TDecompQRH.h>
|
||||
|
||||
|
||||
#include <TH1.h>
|
||||
#include <TMath.h>
|
||||
#include <vector>
|
||||
|
||||
#include <ostream>
|
||||
#include <istream>
|
||||
#include <ostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
@ -28,139 +27,133 @@ using namespace std;
|
||||
#define ETAVPS
|
||||
|
||||
typedef struct {
|
||||
int itN;
|
||||
double *xPos;
|
||||
double *yPos;
|
||||
double *binCont;
|
||||
int itN;
|
||||
double *xPos;
|
||||
double *yPos;
|
||||
double *binCont;
|
||||
} itLog;
|
||||
|
||||
class EtaVEL : public TObject {
|
||||
|
||||
public:
|
||||
EtaVEL(int numberOfPixels = 25, double minn = 0., double maxx = 1.,
|
||||
int nnx = 160, int nny = 160)
|
||||
: nPixels(numberOfPixels), min(minn), max(maxx), converged(0), nx(nnx),
|
||||
ny(nny), chi_sq(0) {
|
||||
// acc = 0.02;
|
||||
ds = 0.005;
|
||||
|
||||
class EtaVEL : public TObject{
|
||||
init();
|
||||
}
|
||||
void init() {
|
||||
double pOffset = (max - min) / (double)nPixels;
|
||||
xPPos = new double[(nPixels + 1) * (nPixels + 1) + 1];
|
||||
yPPos = new double[(nPixels + 1) * (nPixels + 1) + 1];
|
||||
binCont = new double[nPixels * nPixels + 1];
|
||||
totCont = 0.;
|
||||
edgeL = new double[2 * nPixels * (nPixels + 1) + 1];
|
||||
|
||||
public:
|
||||
EtaVEL(int numberOfPixels = 25, double minn=0., double maxx=1., int nnx=160, int nny=160) : nPixels(numberOfPixels), min(minn), max(maxx), converged(0), nx(nnx), ny(nny), chi_sq(0){
|
||||
//acc = 0.02;
|
||||
ds = 0.005;
|
||||
|
||||
init();
|
||||
}
|
||||
void init(){
|
||||
double pOffset = (max-min)/(double)nPixels;
|
||||
xPPos = new double[(nPixels+1)*(nPixels+1)+1];
|
||||
yPPos = new double[(nPixels+1)*(nPixels+1)+1];
|
||||
binCont = new double[nPixels*nPixels+1];
|
||||
totCont = 0.;
|
||||
edgeL = new double[2*nPixels*(nPixels+1)+1];
|
||||
for (int ii = 0; ii < 2 * nPixels * (nPixels + 1) + 1; ii++) {
|
||||
edgeL[ii] = 1.0;
|
||||
// cout << "ii " << ii << endl;
|
||||
}
|
||||
|
||||
for(int ii = 0; ii < 2*nPixels*(nPixels+1)+1; ii++){
|
||||
edgeL[ii] = 1.0;
|
||||
//cout << "ii " << ii << endl;
|
||||
for (int x = 0; x < nPixels + 1; x++) {
|
||||
for (int y = 0; y < nPixels + 1; y++) {
|
||||
xPPos[getCorner(x, y)] = min + (double)x * pOffset;
|
||||
yPPos[getCorner(x, y)] = min + (double)y * pOffset;
|
||||
|
||||
if (x < nPixels && y < nPixels)
|
||||
binCont[getBin(x, y)] = 0;
|
||||
}
|
||||
}
|
||||
// edgeL[1] = 3.0;
|
||||
updatePixelCorner();
|
||||
it = 0;
|
||||
|
||||
log = new itLog[nIterations];
|
||||
}
|
||||
|
||||
for(int x = 0; x < nPixels+1; x++){
|
||||
for(int y = 0; y < nPixels+1; y++){
|
||||
xPPos[getCorner(x,y)] = min + (double)x * pOffset;
|
||||
yPPos[getCorner(x,y)] = min + (double)y * pOffset;
|
||||
|
||||
if(x < nPixels && y < nPixels) binCont[getBin(x,y)] = 0;
|
||||
}
|
||||
void fill(double x, double y, double amount = 1.) {
|
||||
totCont += amount;
|
||||
int bin = findBin(x, y);
|
||||
if (bin < 0) {
|
||||
// cout << "can not find bin x: " << x << " y: " << y << endl;
|
||||
totCont -= amount;
|
||||
}
|
||||
binCont[bin] += amount;
|
||||
}
|
||||
// edgeL[1] = 3.0;
|
||||
updatePixelCorner();
|
||||
it = 0;
|
||||
|
||||
log = new itLog[nIterations];
|
||||
}
|
||||
|
||||
void fill(double x, double y, double amount = 1.){
|
||||
totCont+=amount;
|
||||
int bin = findBin(x,y);
|
||||
if(bin < 0) {
|
||||
//cout << "can not find bin x: " << x << " y: " << y << endl;
|
||||
totCont-=amount;
|
||||
int getBin(int x, int y) {
|
||||
if (x < 0 || x >= nPixels || y < 0 || y >= nPixels) {
|
||||
// cout << "getBin: out of bounds : x " << x << " y " << y << endl;
|
||||
return 0;
|
||||
}
|
||||
return y * nPixels + x + 1;
|
||||
}
|
||||
binCont[bin]+=amount;
|
||||
|
||||
}
|
||||
|
||||
int getBin(int x, int y){
|
||||
if(x < 0 || x >= nPixels || y < 0 || y >= nPixels){
|
||||
//cout << "getBin: out of bounds : x " << x << " y " << y << endl;
|
||||
return 0;
|
||||
int getXBin(int bin) { return (bin - 1) % nPixels; }
|
||||
|
||||
int getYBin(int bin) { return (bin - 1) / nPixels; }
|
||||
|
||||
int getCorner(int x, int y) { return y * (nPixels + 1) + x + 1; }
|
||||
|
||||
int getEdgeX(int x, int row) {
|
||||
int ret = row * nPixels + x + 1;
|
||||
// cout << "| edge X x " << x << " row " << row << ": "<< ret << " | ";
|
||||
return ret;
|
||||
}
|
||||
return y*nPixels+x+1;
|
||||
}
|
||||
|
||||
int getXBin(int bin){
|
||||
return (bin-1)%nPixels;
|
||||
}
|
||||
|
||||
int getYBin(int bin){
|
||||
return (bin-1)/nPixels;
|
||||
}
|
||||
int getEdgeY(int col, int y) {
|
||||
int ret = nPixels * (nPixels + 1) + col * nPixels + y + 1;
|
||||
// cout << "| edge Y col " << col << " y " << y << ": "<< ret << " | ";
|
||||
return ret;
|
||||
}
|
||||
|
||||
int getCorner(int x, int y){
|
||||
return y*(nPixels+1)+x+1;
|
||||
}
|
||||
int getIt() { return it; };
|
||||
|
||||
int getEdgeX(int x,int row){
|
||||
int ret = row*nPixels+x+1;
|
||||
//cout << "| edge X x " << x << " row " << row << ": "<< ret << " | ";
|
||||
return ret;
|
||||
}
|
||||
int getNPixels() { return nPixels; }
|
||||
double *getXPPos() { return xPPos; }
|
||||
double *getYPPos() { return yPPos; }
|
||||
|
||||
int getEdgeY(int col, int y){
|
||||
int ret = nPixels*(nPixels+1)+col*nPixels+y+1;
|
||||
//cout << "| edge Y col " << col << " y " << y << ": "<< ret << " | ";
|
||||
return ret;
|
||||
}
|
||||
|
||||
void updatePixelCorner();
|
||||
double *getPixelCorners(int x, int y);
|
||||
int findBin(double xx, double yy);
|
||||
void createLogEntry();
|
||||
|
||||
int getIt(){ return it; };
|
||||
void updatePixelPos();
|
||||
double *getSizeMap();
|
||||
double *getChangeMap();
|
||||
TH2D *getContent(int it = -1, int changeType = 0);
|
||||
TMultiGraph *plotPixelBorder(int plotCenters = 0);
|
||||
TMultiGraph *plotLog(int stepSize = 1, int maxIt = -1);
|
||||
void printGrid();
|
||||
TH1D *getCounts();
|
||||
|
||||
int getNPixels(){ return nPixels; }
|
||||
double *getXPPos(){ return xPPos; }
|
||||
double *getYPPos(){ return yPPos; }
|
||||
void serialize(ostream &o);
|
||||
void deserialize(istream &is);
|
||||
|
||||
void updatePixelCorner();
|
||||
double *getPixelCorners(int x, int y);
|
||||
int findBin(double xx, double yy);
|
||||
void createLogEntry();
|
||||
|
||||
void updatePixelPos();
|
||||
double *getSizeMap();
|
||||
double *getChangeMap();
|
||||
TH2D *getContent(int it=-1, int changeType = 0);
|
||||
TMultiGraph *plotPixelBorder(int plotCenters=0);
|
||||
TMultiGraph *plotLog(int stepSize=1, int maxIt=-1);
|
||||
void printGrid();
|
||||
TH1D *getCounts();
|
||||
int converged;
|
||||
double getChiSq() { return chi_sq; };
|
||||
|
||||
void serialize(ostream &o);
|
||||
void deserialize(istream &is);
|
||||
private:
|
||||
itLog *log;
|
||||
int it;
|
||||
const static int nIterations = 10000;
|
||||
int nx, ny;
|
||||
int nPixels;
|
||||
double *xPPos;
|
||||
double *yPPos;
|
||||
double *binCont;
|
||||
double totCont;
|
||||
double *edgeL;
|
||||
// double acc;
|
||||
double ds;
|
||||
double min, max;
|
||||
double chi_sq;
|
||||
|
||||
int converged ;
|
||||
double getChiSq(){return chi_sq;};
|
||||
|
||||
private:
|
||||
itLog *log;
|
||||
int it;
|
||||
const static int nIterations =10000;
|
||||
int nx, ny;
|
||||
int nPixels;
|
||||
double *xPPos;
|
||||
double *yPPos;
|
||||
double *binCont;
|
||||
double totCont;
|
||||
double *edgeL;
|
||||
// double acc;
|
||||
double ds;
|
||||
double min,max;
|
||||
double chi_sq;
|
||||
|
||||
ClassDefNV(EtaVEL,1);
|
||||
#pragma link C++ class EtaVEL-;
|
||||
ClassDefNV(EtaVEL, 1);
|
||||
#pragma link C++ class EtaVEL - ;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -1,136 +1,144 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
#include "interpolation_EtaVEL.h"
|
||||
#include "TH2F.h"
|
||||
#include "TCanvas.h"
|
||||
#include "TH2F.h"
|
||||
#include "TROOT.h"
|
||||
#include "interpolation_EtaVEL.h"
|
||||
//#include "EtaVEL.h"
|
||||
#include "EtaVEL.cpp"
|
||||
/*
|
||||
Zum erstellen der correction map ist createGainAndEtaFile(...) in EVELAlg.C der entry point.
|
||||
Zum erstellen des HR images ist createImage(...) der entry point.
|
||||
Zum erstellen der correction map ist createGainAndEtaFile(...) in EVELAlg.C der
|
||||
entry point. Zum erstellen des HR images ist createImage(...) der entry point.
|
||||
*/
|
||||
interpolation_EtaVEL::interpolation_EtaVEL(int nx, int ny, int ns, double etamin, double etamax, int p) : slsInterpolation(nx, ny, ns), newEta(NULL), heta(NULL), plot(p) {
|
||||
newEta = new EtaVEL(nSubPixels,etamin,etamax,nPixelsX, nPixelsY);
|
||||
heta= new TH2F("heta","heta",50*nSubPixels, etamin,etamax,50*nSubPixels, etamin,etamax);
|
||||
heta->SetStats(kFALSE);
|
||||
interpolation_EtaVEL::interpolation_EtaVEL(int nx, int ny, int ns,
|
||||
double etamin, double etamax, int p)
|
||||
: slsInterpolation(nx, ny, ns), newEta(NULL), heta(NULL), plot(p) {
|
||||
newEta = new EtaVEL(nSubPixels, etamin, etamax, nPixelsX, nPixelsY);
|
||||
heta = new TH2F("heta", "heta", 50 * nSubPixels, etamin, etamax,
|
||||
50 * nSubPixels, etamin, etamax);
|
||||
heta->SetStats(kFALSE);
|
||||
}
|
||||
|
||||
interpolation_EtaVEL::~interpolation_EtaVEL() {
|
||||
delete newEta;
|
||||
delete heta;
|
||||
delete newEta;
|
||||
delete heta;
|
||||
}
|
||||
|
||||
|
||||
void interpolation_EtaVEL::prepareInterpolation(int &ok, int maxit) {
|
||||
int nit=0;
|
||||
while ((newEta->converged != 1) && nit++<maxit) {
|
||||
cout << " -------------- new step "<< nit << endl;
|
||||
iterate();
|
||||
}
|
||||
if (plot) {
|
||||
Draw();
|
||||
gPad->Modified();
|
||||
gPad->Update();
|
||||
}
|
||||
if (newEta->converged==1) ok=1; else ok=0;
|
||||
int nit = 0;
|
||||
while ((newEta->converged != 1) && nit++ < maxit) {
|
||||
cout << " -------------- new step " << nit << endl;
|
||||
iterate();
|
||||
}
|
||||
if (plot) {
|
||||
Draw();
|
||||
gPad->Modified();
|
||||
gPad->Update();
|
||||
}
|
||||
if (newEta->converged == 1)
|
||||
ok = 1;
|
||||
else
|
||||
ok = 0;
|
||||
}
|
||||
|
||||
int interpolation_EtaVEL::addToFlatField(Double_t *cluster, Double_t &etax, Double_t &etay) {
|
||||
Double_t sum, totquad, sDum[2][2];
|
||||
int corner =calcEta(cluster, etax, etay, sum, totquad, sDum);
|
||||
//check if it's OK...should redo it every time?
|
||||
//or should we fill a finer histogram and afterwards re-fill the newEta?
|
||||
addToFlatField(etax, etay);
|
||||
return corner;
|
||||
int interpolation_EtaVEL::addToFlatField(Double_t *cluster, Double_t &etax,
|
||||
Double_t &etay) {
|
||||
Double_t sum, totquad, sDum[2][2];
|
||||
int corner = calcEta(cluster, etax, etay, sum, totquad, sDum);
|
||||
// check if it's OK...should redo it every time?
|
||||
// or should we fill a finer histogram and afterwards re-fill the newEta?
|
||||
addToFlatField(etax, etay);
|
||||
return corner;
|
||||
}
|
||||
|
||||
int interpolation_EtaVEL::addToFlatField(Double_t etax, Double_t etay) {
|
||||
// newEta->fill(etaX,etaY);
|
||||
heta->Fill(etax,etay);
|
||||
return 0;
|
||||
// newEta->fill(etaX,etaY);
|
||||
heta->Fill(etax, etay);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void interpolation_EtaVEL::iterate() {
|
||||
cout << " -------------- newEta refilled"<< endl;
|
||||
for (int ibx=0; ibx<heta->GetNbinsX(); ibx++) {
|
||||
for (int iby=0; iby<heta->GetNbinsY(); iby++) {
|
||||
newEta->fill(heta->GetXaxis()->GetBinCenter(ibx+1),heta->GetYaxis()->GetBinCenter(iby+1),heta->GetBinContent(ibx+1,iby+1));
|
||||
}
|
||||
}
|
||||
newEta->updatePixelPos();
|
||||
cout << " -------------- pixelPosition updated"<< endl;
|
||||
cout << " -------------- newEta refilled" << endl;
|
||||
for (int ibx = 0; ibx < heta->GetNbinsX(); ibx++) {
|
||||
for (int iby = 0; iby < heta->GetNbinsY(); iby++) {
|
||||
newEta->fill(heta->GetXaxis()->GetBinCenter(ibx + 1),
|
||||
heta->GetYaxis()->GetBinCenter(iby + 1),
|
||||
heta->GetBinContent(ibx + 1, iby + 1));
|
||||
}
|
||||
}
|
||||
newEta->updatePixelPos();
|
||||
cout << " -------------- pixelPosition updated" << endl;
|
||||
}
|
||||
|
||||
void interpolation_EtaVEL::DrawH() {
|
||||
heta->Draw("col");
|
||||
(newEta->plotPixelBorder())->Draw();
|
||||
heta->Draw("col");
|
||||
(newEta->plotPixelBorder())->Draw();
|
||||
}
|
||||
|
||||
void interpolation_EtaVEL::getInterpolatedPosition(Int_t x, Int_t y,
|
||||
Double_t *cluster,
|
||||
Double_t &int_x,
|
||||
Double_t &int_y) {
|
||||
|
||||
void interpolation_EtaVEL::getInterpolatedPosition(Int_t x, Int_t y, Double_t *cluster, Double_t &int_x, Double_t &int_y) {
|
||||
Double_t etax, etay, sum, totquad, sDum[2][2];
|
||||
|
||||
Double_t etax, etay, sum, totquad, sDum[2][2];
|
||||
int corner = calcEta(cluster, etax, etay, sum, totquad, sDum);
|
||||
|
||||
int corner =calcEta(cluster, etax, etay, sum, totquad, sDum);
|
||||
|
||||
int bin = newEta->findBin(etax,etay);
|
||||
if (bin<=0) {
|
||||
int_x=-1;
|
||||
int_y=-1;
|
||||
return;
|
||||
}
|
||||
double subX = ((double)(newEta->getXBin(bin))+.5)/((double)newEta->getNPixels());
|
||||
double subY = ((double)(newEta->getYBin(bin))+.5)/((double)newEta->getNPixels());
|
||||
|
||||
double dX, dY;
|
||||
switch (corner) {
|
||||
case TOP_LEFT:
|
||||
dX=-1.;
|
||||
dY=+1.;
|
||||
break;
|
||||
case TOP_RIGHT:
|
||||
dX=+1.;
|
||||
dY=+1.;
|
||||
break;
|
||||
case BOTTOM_LEFT:
|
||||
dX=-1.;
|
||||
dY=-1.;
|
||||
break;
|
||||
case BOTTOM_RIGHT:
|
||||
dX=+1.;
|
||||
dY=-1.;
|
||||
break;
|
||||
default:
|
||||
dX=0;
|
||||
dY=0;
|
||||
}
|
||||
|
||||
int_x=((double)x)+ subX+0.5*dX;
|
||||
int_y=((double)y)+ subY+0.5*dY;
|
||||
|
||||
// cout << corner << " " << subX<< " " << subY << " " << dX << " " << dY << " " << int_x << " " << int_y << endl;
|
||||
int bin = newEta->findBin(etax, etay);
|
||||
if (bin <= 0) {
|
||||
int_x = -1;
|
||||
int_y = -1;
|
||||
return;
|
||||
}
|
||||
double subX =
|
||||
((double)(newEta->getXBin(bin)) + .5) / ((double)newEta->getNPixels());
|
||||
double subY =
|
||||
((double)(newEta->getYBin(bin)) + .5) / ((double)newEta->getNPixels());
|
||||
|
||||
double dX, dY;
|
||||
switch (corner) {
|
||||
case TOP_LEFT:
|
||||
dX = -1.;
|
||||
dY = +1.;
|
||||
break;
|
||||
case TOP_RIGHT:
|
||||
dX = +1.;
|
||||
dY = +1.;
|
||||
break;
|
||||
case BOTTOM_LEFT:
|
||||
dX = -1.;
|
||||
dY = -1.;
|
||||
break;
|
||||
case BOTTOM_RIGHT:
|
||||
dX = +1.;
|
||||
dY = -1.;
|
||||
break;
|
||||
default:
|
||||
dX = 0;
|
||||
dY = 0;
|
||||
}
|
||||
|
||||
int_x = ((double)x) + subX + 0.5 * dX;
|
||||
int_y = ((double)y) + subY + 0.5 * dY;
|
||||
|
||||
// cout << corner << " " << subX<< " " << subY << " " << dX << " " << dY <<
|
||||
// " " << int_x << " " << int_y << endl;
|
||||
};
|
||||
|
||||
|
||||
// void interpolation_EtaVEL::Streamer(TBuffer &b){newEta->Streamer(b);};
|
||||
void interpolation_EtaVEL::getInterpolatedBin(Double_t *cluster, Int_t &int_x, Int_t &int_y) {
|
||||
void interpolation_EtaVEL::getInterpolatedBin(Double_t *cluster, Int_t &int_x,
|
||||
Int_t &int_y) {
|
||||
|
||||
Double_t etax, etay, sum, totquad, sDum[2][2];
|
||||
|
||||
int corner =calcEta(cluster, etax, etay, sum, totquad, sDum);
|
||||
|
||||
int bin = newEta->findBin(etax,etay);
|
||||
if (bin<0) {
|
||||
int_x=-1;
|
||||
int_y=-1;
|
||||
return;
|
||||
}
|
||||
int_x=newEta->getXBin(bin);
|
||||
int_y=newEta->getYBin(bin);
|
||||
|
||||
Double_t etax, etay, sum, totquad, sDum[2][2];
|
||||
|
||||
int corner = calcEta(cluster, etax, etay, sum, totquad, sDum);
|
||||
|
||||
int bin = newEta->findBin(etax, etay);
|
||||
if (bin < 0) {
|
||||
int_x = -1;
|
||||
int_y = -1;
|
||||
return;
|
||||
}
|
||||
int_x = newEta->getXBin(bin);
|
||||
int_y = newEta->getYBin(bin);
|
||||
};
|
||||
|
||||
|
@ -3,55 +3,61 @@
|
||||
#ifndef INTERPOLATION_ETAVEL_H
|
||||
#define INTERPOLATION_ETAVEL_H
|
||||
|
||||
#include <slsInterpolation.h>
|
||||
#include "EtaVEL.h"
|
||||
#include <slsInterpolation.h>
|
||||
//#include "TH2F.h"
|
||||
//#include "EtaVEL.cpp"
|
||||
//class EtaVEL;
|
||||
// class EtaVEL;
|
||||
|
||||
class etaVELInterpolation: public etaInterpolationBase {
|
||||
class etaVELInterpolation : public etaInterpolationBase {
|
||||
|
||||
public:
|
||||
interpolation_EtaVEL(int nx=40, int ny=160, int ns=25, double etamin=-0.02, double etamax=1.02, int p=0);
|
||||
~interpolation_EtaVEL();
|
||||
|
||||
|
||||
//create eta distribution, eta rebinnining etc.
|
||||
//returns flat field image
|
||||
void prepareInterpolation(int &ok){prepareInterpolation(ok,10000);};
|
||||
void prepareInterpolation(int &ok, int maxit);
|
||||
public:
|
||||
interpolation_EtaVEL(int nx = 40, int ny = 160, int ns = 25,
|
||||
double etamin = -0.02, double etamax = 1.02,
|
||||
int p = 0);
|
||||
~interpolation_EtaVEL();
|
||||
|
||||
//create interpolated image
|
||||
//returns interpolated image
|
||||
|
||||
//return position inside the pixel for the given photon
|
||||
void getInterpolatedPosition(Int_t x, Int_t y, Double_t *data, Double_t &int_x, Double_t &int_y);
|
||||
void getInterpolatedBin(Double_t *cluster, Int_t &int_x, Int_t &int_y);
|
||||
|
||||
// create eta distribution, eta rebinnining etc.
|
||||
// returns flat field image
|
||||
void prepareInterpolation(int &ok) { prepareInterpolation(ok, 10000); };
|
||||
void prepareInterpolation(int &ok, int maxit);
|
||||
|
||||
// create interpolated image
|
||||
// returns interpolated image
|
||||
|
||||
int addToFlatField(Double_t *cluster, Double_t &etax, Double_t &etay);
|
||||
int addToFlatField(Double_t etax, Double_t etay);
|
||||
int setPlot(int p=-1) {if (p>=0) plot=p; return plot;};
|
||||
// int WriteH(){newEta->Write("newEta"); heta->Write("heta");};
|
||||
EtaVEL *setEta(EtaVEL *ev){if (ev) {delete newEta; newEta=ev;} return newEta;};
|
||||
// return position inside the pixel for the given photon
|
||||
void getInterpolatedPosition(Int_t x, Int_t y, Double_t *data,
|
||||
Double_t &int_x, Double_t &int_y);
|
||||
void getInterpolatedBin(Double_t *cluster, Int_t &int_x, Int_t &int_y);
|
||||
|
||||
int addToFlatField(Double_t *cluster, Double_t &etax, Double_t &etay);
|
||||
int addToFlatField(Double_t etax, Double_t etay);
|
||||
int setPlot(int p = -1) {
|
||||
if (p >= 0)
|
||||
plot = p;
|
||||
return plot;
|
||||
};
|
||||
// int WriteH(){newEta->Write("newEta"); heta->Write("heta");};
|
||||
EtaVEL *setEta(EtaVEL *ev) {
|
||||
if (ev) {
|
||||
delete newEta;
|
||||
newEta = ev;
|
||||
}
|
||||
return newEta;
|
||||
};
|
||||
|
||||
// TH2F *setEta(TH2F *ev){if (ev) {delete heta; heta=ev;} return heta;};
|
||||
void iterate();
|
||||
// void DrawH();
|
||||
double getChiSq() { return newEta->getChiSq(); };
|
||||
|
||||
// TH2F *setEta(TH2F *ev){if (ev) {delete heta; heta=ev;} return heta;};
|
||||
void iterate();
|
||||
// void DrawH();
|
||||
double getChiSq(){return newEta->getChiSq();};
|
||||
|
||||
protected:
|
||||
EtaVEL *newEta;
|
||||
// TH2F *heta;
|
||||
int plot;
|
||||
|
||||
|
||||
protected:
|
||||
EtaVEL *newEta;
|
||||
// TH2F *heta;
|
||||
int plot;
|
||||
|
||||
// ClassDefNV(interpolation_EtaVEL,1);
|
||||
// #pragma link C++ class interpolation_EtaVEL-;
|
||||
// ClassDefNV(interpolation_EtaVEL,1);
|
||||
// #pragma link C++ class interpolation_EtaVEL-;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -9,228 +9,215 @@
|
||||
|
||||
#include "slsInterpolation.h"
|
||||
|
||||
class linearInterpolation : public slsInterpolation{
|
||||
class linearInterpolation : public slsInterpolation {
|
||||
|
||||
public:
|
||||
linearInterpolation(int nx=400, int ny=400, int ns=25) : slsInterpolation(nx,ny,ns) {};
|
||||
linearInterpolation(linearInterpolation *orig) : slsInterpolation(orig) {};
|
||||
public:
|
||||
linearInterpolation(int nx = 400, int ny = 400, int ns = 25)
|
||||
: slsInterpolation(nx, ny, ns){};
|
||||
linearInterpolation(linearInterpolation *orig) : slsInterpolation(orig){};
|
||||
|
||||
virtual void prepareInterpolation(int &ok){ok=1;};
|
||||
virtual void prepareInterpolation(int &ok) { ok = 1; };
|
||||
|
||||
virtual linearInterpolation* Clone() {
|
||||
virtual linearInterpolation *Clone() {
|
||||
|
||||
return new linearInterpolation(this);
|
||||
return new linearInterpolation(this);
|
||||
};
|
||||
|
||||
};
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//////////// /*It return position hit for the event in input */
|
||||
/////////////////
|
||||
virtual void getInterpolatedPosition(int x, int y, double *data,
|
||||
double &int_x, double &int_y) {
|
||||
double sDum[2][2];
|
||||
double tot, totquad;
|
||||
double etax, etay;
|
||||
|
||||
int corner;
|
||||
corner = calcQuad(data, tot, totquad, sDum);
|
||||
if (nSubPixels > 2) {
|
||||
calcEta(totquad, sDum, etax, etay);
|
||||
}
|
||||
getInterpolatedPosition(x, y, etax, etay, corner, int_x, int_y);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//////////// /*It return position hit for the event in input */ //////////////
|
||||
virtual void getInterpolatedPosition(int x, int y, double *data, double &int_x, double &int_y)
|
||||
{
|
||||
double sDum[2][2];
|
||||
double tot, totquad;
|
||||
double etax,etay;
|
||||
|
||||
int corner;
|
||||
corner=calcQuad(data, tot, totquad, sDum);
|
||||
if (nSubPixels>2) {
|
||||
calcEta(totquad, sDum, etax, etay);
|
||||
}
|
||||
getInterpolatedPosition(x, y, etax,etay, corner, int_x, int_y);
|
||||
|
||||
return;
|
||||
};
|
||||
return;
|
||||
};
|
||||
|
||||
virtual void getInterpolatedPosition(int x, int y, int *data, double &int_x, double &int_y)
|
||||
{
|
||||
double sDum[2][2];
|
||||
double tot, totquad;
|
||||
double etax,etay;
|
||||
|
||||
int corner;
|
||||
corner=calcQuad(data, tot, totquad, sDum);
|
||||
if (nSubPixels>2)
|
||||
calcEta(totquad, sDum, etax, etay);
|
||||
getInterpolatedPosition(x,y,etax,etay,corner,int_x,int_y);
|
||||
virtual void getInterpolatedPosition(int x, int y, int *data, double &int_x,
|
||||
double &int_y) {
|
||||
double sDum[2][2];
|
||||
double tot, totquad;
|
||||
double etax, etay;
|
||||
|
||||
return;
|
||||
};
|
||||
|
||||
virtual void getInterpolatedPosition(int x, int y, double totquad,int quad,double *cl,double &int_x, double &int_y) {
|
||||
|
||||
double eta_x, eta_y;
|
||||
if (nSubPixels>2) {
|
||||
double cc[2][2];
|
||||
double *cluster[3];
|
||||
cluster[0]=cl;
|
||||
cluster[1]=cl+3;
|
||||
cluster[2]=cl+6;
|
||||
int xoff, yoff;
|
||||
|
||||
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]=cluster[yoff][xoff];
|
||||
cc[1][0]=cluster[yoff+1][xoff];
|
||||
cc[0][1]=cluster[yoff][xoff+1];
|
||||
cc[1][1]=cluster[yoff+1][xoff+1];
|
||||
calcEta(totquad,cc,eta_x,eta_y);
|
||||
int corner;
|
||||
corner = calcQuad(data, tot, totquad, sDum);
|
||||
if (nSubPixels > 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 eta_x, eta_y;
|
||||
if (nSubPixels > 2) {
|
||||
double cc[2][2];
|
||||
double *cluster[3];
|
||||
cluster[0] = cl;
|
||||
cluster[1] = cl + 3;
|
||||
cluster[2] = cl + 6;
|
||||
int xoff, yoff;
|
||||
|
||||
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] = cluster[yoff][xoff];
|
||||
cc[1][0] = cluster[yoff + 1][xoff];
|
||||
cc[0][1] = cluster[yoff][xoff + 1];
|
||||
cc[1][1] = cluster[yoff + 1][xoff + 1];
|
||||
calcEta(totquad, cc, eta_x, eta_y);
|
||||
}
|
||||
// cout << x << " " << y << " " << eta_x << " " << eta_y << " " << int_x
|
||||
// << " " << int_y << endl;
|
||||
return getInterpolatedPosition(x, y, eta_x, eta_y, quad, int_x, int_y);
|
||||
}
|
||||
// cout << x << " " << y << " " << eta_x << " " << eta_y << " " << int_x << " " << int_y << endl;
|
||||
return getInterpolatedPosition(x,y,eta_x, eta_y,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 *cluster[3];
|
||||
int xoff, yoff;
|
||||
cluster[0] = cl;
|
||||
cluster[1] = cl + 3;
|
||||
cluster[2] = cl + 6;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
virtual void getInterpolatedPosition(int x, int y, double totquad,int quad,int *cl,double &int_x, double &int_y) {
|
||||
|
||||
double cc[2][2];
|
||||
int *cluster[3];
|
||||
int xoff, yoff;
|
||||
cluster[0]=cl;
|
||||
cluster[1]=cl+3;
|
||||
cluster[2]=cl+6;
|
||||
|
||||
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, etay;
|
||||
if (nSubPixels>2) {
|
||||
cc[0][0]=cluster[yoff][xoff];
|
||||
cc[1][0]=cluster[yoff+1][xoff];
|
||||
cc[0][1]=cluster[yoff][xoff+1];
|
||||
cc[1][1]=cluster[yoff+1][xoff+1];
|
||||
calcEta(totquad,cc,etax,etay);
|
||||
}
|
||||
// cout << x << " " << y << " " << etax << " " << etay << " " << int_x << " " << int_y << endl;
|
||||
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,ypos_eta;
|
||||
double dX,dY;
|
||||
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 (nSubPixels>2) {
|
||||
xpos_eta=(etax)+dX;
|
||||
ypos_eta=(etay)+dY;
|
||||
} else {
|
||||
xpos_eta=0.5*dX+0.25;
|
||||
ypos_eta=0.5*dY+0.25;
|
||||
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, etay;
|
||||
if (nSubPixels > 2) {
|
||||
cc[0][0] = cluster[yoff][xoff];
|
||||
cc[1][0] = cluster[yoff + 1][xoff];
|
||||
cc[0][1] = cluster[yoff][xoff + 1];
|
||||
cc[1][1] = cluster[yoff + 1][xoff + 1];
|
||||
calcEta(totquad, cc, etax, etay);
|
||||
}
|
||||
// cout << x << " " << y << " " << etax << " " << etay << " " << int_x
|
||||
// << " " << int_y << endl;
|
||||
return getInterpolatedPosition(x, y, etax, etay, quad, int_x, int_y);
|
||||
}
|
||||
int_x=((double)x) + xpos_eta;
|
||||
int_y=((double)y) + ypos_eta;
|
||||
// cout <<"**"<< x << " " << y << " " << xpos_eta << " " << ypos_eta << " " << corner << endl;
|
||||
return;
|
||||
};
|
||||
|
||||
virtual void getInterpolatedPosition(int x, int y, double etax, double etay,
|
||||
int corner, double &int_x,
|
||||
double &int_y) {
|
||||
|
||||
double xpos_eta, ypos_eta;
|
||||
double dX, dY;
|
||||
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 (nSubPixels > 2) {
|
||||
xpos_eta = (etax) + dX;
|
||||
ypos_eta = (etay) + dY;
|
||||
} else {
|
||||
xpos_eta = 0.5 * dX + 0.25;
|
||||
ypos_eta = 0.5 * dY + 0.25;
|
||||
}
|
||||
int_x = ((double)x) + xpos_eta;
|
||||
int_y = ((double)y) + ypos_eta;
|
||||
// cout <<"**"<< x << " " << y << " " << xpos_eta << " " << ypos_eta <<
|
||||
// " " << corner << endl;
|
||||
return;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
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;
|
||||
|
||||
calcQuad(data, tot, totquad, sDum);
|
||||
calcEta3(data, eta3x, eta3y, tot);
|
||||
|
||||
double xpos_eta, 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;
|
||||
|
||||
calcQuad(data, tot, totquad, sDum);
|
||||
calcEta3(data,eta3x, eta3y,tot);
|
||||
|
||||
double xpos_eta,ypos_eta;
|
||||
|
||||
xpos_eta=eta3x;
|
||||
ypos_eta=eta3y;
|
||||
|
||||
int_x=((double)x) + xpos_eta;
|
||||
int_y=((double)y) + ypos_eta;
|
||||
|
||||
return;
|
||||
};
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
virtual int addToFlatField(double *cluster, double &etax, double &etay){};
|
||||
virtual int addToFlatField(int *cluster, double &etax, double &etay){};
|
||||
virtual int addToFlatField(double etax, double etay){};
|
||||
virtual int addToFlatField(double totquad,int quad,double *cl,double &etax, double &etay) {};
|
||||
virtual int addToFlatField(double totquad,int quad,int *cl,double &etax, double &etay) {};
|
||||
xpos_eta = eta3x;
|
||||
ypos_eta = eta3y;
|
||||
|
||||
protected:
|
||||
;
|
||||
int_x = ((double)x) + xpos_eta;
|
||||
int_y = ((double)y) + ypos_eta;
|
||||
|
||||
return;
|
||||
};
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
virtual int addToFlatField(double *cluster, double &etax, double &etay){};
|
||||
virtual int addToFlatField(int *cluster, double &etax, double &etay){};
|
||||
virtual int addToFlatField(double etax, double etay){};
|
||||
virtual int addToFlatField(double totquad, int quad, double *cl,
|
||||
double &etax, double &etay){};
|
||||
virtual int addToFlatField(double totquad, int quad, int *cl, double &etax,
|
||||
double &etay){};
|
||||
|
||||
protected:
|
||||
;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -11,96 +11,100 @@
|
||||
/* #include <TRandom.h> */
|
||||
/* #endif */
|
||||
|
||||
#include <cstdlib>
|
||||
#include "slsInterpolation.h"
|
||||
#include <cstdlib>
|
||||
|
||||
class noInterpolation : public slsInterpolation {
|
||||
public:
|
||||
noInterpolation(int nx = 400, int ny = 400, int ns = 25)
|
||||
: slsInterpolation(nx, ny, ns){}; // {eventGenerator=new TRandom();};
|
||||
noInterpolation(noInterpolation *orig) : slsInterpolation(orig){};
|
||||
virtual void prepareInterpolation(int &ok) { ok = 1; };
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//////////// /*It return position hit for the event in input */
|
||||
/////////////////
|
||||
|
||||
class noInterpolation : public slsInterpolation{
|
||||
public:
|
||||
noInterpolation(int nx=400, int ny=400, int ns=25) : slsInterpolation(nx,ny,ns) {};// {eventGenerator=new TRandom();};
|
||||
noInterpolation(noInterpolation *orig) : slsInterpolation(orig){};
|
||||
virtual void prepareInterpolation(int &ok){ok=1;};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//////////// /*It return position hit for the event in input */ //////////////
|
||||
virtual noInterpolation *Clone() { return new noInterpolation(this); };
|
||||
|
||||
virtual noInterpolation* Clone() {
|
||||
virtual void getInterpolatedPosition(int x, int y, double *data,
|
||||
double &int_x, double &int_y) {
|
||||
// Random coordinate in the Pixel reference
|
||||
int_x = x + ((double)rand()) / ((double)RAND_MAX) -
|
||||
0.5; // eventGenerator->Uniform(-0.5,0.5);
|
||||
int_y = y + ((double)rand()) / ((double)RAND_MAX) -
|
||||
0.5; // eventGenerator->Uniform(-0.5,0.5);
|
||||
|
||||
return new noInterpolation(this);
|
||||
return;
|
||||
};
|
||||
|
||||
};
|
||||
virtual void getInterpolatedPosition(int x, int y, int *data, double &int_x,
|
||||
double &int_y) {
|
||||
return getInterpolatedPosition(x, y, (double *)NULL, int_x, int_y);
|
||||
}
|
||||
|
||||
virtual void getInterpolatedPosition(int x, int y, double etax, double etay,
|
||||
int corner, double &int_x,
|
||||
double &int_y) {
|
||||
getInterpolatedPosition(x, y, (double *)NULL, int_x, int_y);
|
||||
};
|
||||
|
||||
virtual void getInterpolatedPosition(int x, int y, double *data, double &int_x, double &int_y)
|
||||
{
|
||||
//Random coordinate in the Pixel reference
|
||||
int_x = x + ((double)rand())/((double)RAND_MAX) -0.5;//eventGenerator->Uniform(-0.5,0.5);
|
||||
int_y = y + ((double)rand())/((double)RAND_MAX) -0.5;//eventGenerator->Uniform(-0.5,0.5);
|
||||
|
||||
return ;
|
||||
};
|
||||
virtual void getInterpolatedPosition(int x, int y, double totquad, int quad,
|
||||
double *cl, double &etax,
|
||||
double &etay) {
|
||||
getInterpolatedPosition(x, y, (double *)NULL, etax, etay);
|
||||
};
|
||||
|
||||
virtual void getInterpolatedPosition(int x, int y, int *data, double &int_x, double &int_y)
|
||||
{
|
||||
return getInterpolatedPosition(x, y, (double*)NULL, int_x, int_y);
|
||||
}
|
||||
|
||||
virtual void getInterpolatedPosition(int x, int y, double totquad, int quad,
|
||||
int *cl, double &etax, double &etay) {
|
||||
getInterpolatedPosition(x, y, (double *)NULL, etax, etay);
|
||||
};
|
||||
|
||||
virtual void getInterpolatedPosition(int x, int y, double etax, double etay, int corner, double &int_x, double &int_y)
|
||||
{
|
||||
getInterpolatedPosition(x, y, (double*)NULL, int_x, int_y);
|
||||
};
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
virtual void getPositionETA3(int x, int y, double *data, double &int_x,
|
||||
double &int_y) {
|
||||
// Random coordinate in the Pixel reference
|
||||
int_x = x + ((double)rand()) / ((double)RAND_MAX) -
|
||||
0.5; // eventGenerator->Uniform(-0.5,0.5);
|
||||
int_y = y + ((double)rand()) / ((double)RAND_MAX) -
|
||||
0.5; // eventGenerator->Uniform(-0.5,0.5);
|
||||
|
||||
return;
|
||||
};
|
||||
|
||||
virtual void getPositionETA3(int x, int y, int *data, double &int_x,
|
||||
double &int_y) {
|
||||
return getPositionETA3(x, y, (double *)NULL, int_x, int_y);
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
virtual int addToFlatField(double *cluster, double &etax, double &etay) {
|
||||
return 0;
|
||||
};
|
||||
|
||||
virtual void getInterpolatedPosition(int x, int y, double totquad,int quad,double *cl,double &etax, double &etay){
|
||||
getInterpolatedPosition(x, y, (double*)NULL, etax, etay);
|
||||
};
|
||||
virtual int addToFlatField(int *cluster, double &etax, double &etay) {
|
||||
return 0;
|
||||
};
|
||||
|
||||
virtual int addToFlatField(double etax, double etay) { return 0; };
|
||||
|
||||
virtual void getInterpolatedPosition(int x, int y, double totquad,int quad,int *cl,double &etax, double &etay){
|
||||
getInterpolatedPosition(x, y, (double*)NULL, etax, etay);
|
||||
};
|
||||
virtual int addToFlatField(double totquad, int quad, double *cl,
|
||||
double &etax, double &etay) {
|
||||
return 0;
|
||||
};
|
||||
|
||||
virtual int addToFlatField(double totquad, int quad, int *cl, double &etax,
|
||||
double &etay) {
|
||||
return 0;
|
||||
};
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
virtual void getPositionETA3(int x, int y, double *data, double &int_x, double &int_y)
|
||||
{
|
||||
//Random coordinate in the Pixel reference
|
||||
int_x = x + ((double)rand())/((double)RAND_MAX) -0.5;//eventGenerator->Uniform(-0.5,0.5);
|
||||
int_y = y + ((double)rand())/((double)RAND_MAX) -0.5;//eventGenerator->Uniform(-0.5,0.5);
|
||||
|
||||
return ;
|
||||
};
|
||||
virtual void resetFlatField(){};
|
||||
|
||||
virtual void getPositionETA3(int x, int y, int *data, double &int_x, double &int_y)
|
||||
{
|
||||
return getPositionETA3(x, y, (double*)NULL, int_x, int_y);
|
||||
};
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
virtual int addToFlatField(double *cluster, double &etax, double &etay){return 0;};
|
||||
|
||||
virtual int addToFlatField(int *cluster, double &etax, double &etay){return 0;};
|
||||
|
||||
virtual int addToFlatField(double etax, double etay){return 0;};
|
||||
|
||||
virtual int addToFlatField(double totquad,int quad,double *cl,double &etax, double &etay){return 0;};
|
||||
|
||||
|
||||
virtual int addToFlatField(double totquad,int quad,int *cl,double &etax, double &etay){return 0;};
|
||||
|
||||
virtual void resetFlatField(){};
|
||||
protected:
|
||||
;
|
||||
// TRandom *eventGenerator;
|
||||
// ClassDefNV(slsInterpolation,1);
|
||||
// #pragma link C++ class slsInterpolation-;
|
||||
protected:
|
||||
;
|
||||
// TRandom *eventGenerator;
|
||||
// ClassDefNV(slsInterpolation,1);
|
||||
// #pragma link C++ class slsInterpolation-;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user