mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2026-01-17 19:46:30 +01:00
improved library structure for analog detectors and interpolation t.b.t.
This commit is contained in:
272
slsDetectorCalibration/etaVEL/etaInterpolationBase.h
Normal file
272
slsDetectorCalibration/etaVEL/etaInterpolationBase.h
Normal file
@@ -0,0 +1,272 @@
|
||||
#ifndef ETA_INTERPOLATION_BASE_H
|
||||
#define ETA_INTERPOLATION_BASE_H
|
||||
|
||||
#ifdef MYROOT1
|
||||
#include <TObject.h>
|
||||
#include <TTree.h>
|
||||
#include <TH2D.h>
|
||||
#include <TH2F.h>
|
||||
#endif
|
||||
|
||||
#include "slsInterpolation.h"
|
||||
|
||||
class etaInterpolationBase : public slsInterpolation {
|
||||
|
||||
public:
|
||||
etaInterpolationBase(int nx=400, int ny=400, int ns=25, int nb=-1, double emin=1, double emax=0) : slsInterpolation(nx,ny,ns), hhx(NULL), hhy(NULL), heta(NULL),nbeta(nb),etamin(emin), etamax(emax) {
|
||||
if (nb<=0)
|
||||
nbeta=nSubPixels*10;
|
||||
if (etamin>=etamax) {
|
||||
etamin=-0.1;
|
||||
etamax=1.1;
|
||||
}
|
||||
etastep=(etamax-etamin)/nbeta;
|
||||
#ifdef MYROOT1
|
||||
heta=new TH2D("heta","heta",nbeta,etamin,etamax,nbeta,etamin,etamax);
|
||||
hhx=new TH2D("hhx","hhx",nbeta,etamin,etamax,nbeta,etamin,etamax);
|
||||
hhy=new TH2D("hhy","hhy",nbeta,etamin,etamax,nbeta,etamin,etamax);
|
||||
#endif
|
||||
#ifndef MYROOT1
|
||||
heta=new int[nbeta*nbeta];
|
||||
hhx=new int[nbeta*nbeta];
|
||||
hhy=new int[nbeta*nbeta];
|
||||
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
#ifdef MYROOT1
|
||||
TH2D *setEta(TH2D *h, int nb=-1, double emin=1, double emax=0)
|
||||
{
|
||||
if (h) { heta=h;
|
||||
nbeta=heta->GetNbinsX();
|
||||
etamin=heta->GetXaxis()->GetXmin();
|
||||
etamax=heta->GetXaxis()->GetXmax();
|
||||
etastep=(etamax-etamin)/nbeta;
|
||||
}
|
||||
return heta;
|
||||
};
|
||||
TH2D *getFlatField(){return setEta(NULL);};
|
||||
#endif
|
||||
|
||||
#ifndef MYROOT1
|
||||
int *setEta(int *h, int nb=-1, double emin=1, double emax=0)
|
||||
{
|
||||
if (h) {heta=h;
|
||||
nbeta=nb;
|
||||
if (nb<=0) nbeta=nSubPixels*10;
|
||||
etamin=emin;
|
||||
etamax=emax;
|
||||
if (etamin>=etamax) {
|
||||
etamin=-0.1;
|
||||
etamax=1.1;
|
||||
}
|
||||
etastep=(etamax-etamin)/nbeta;
|
||||
}
|
||||
return heta;
|
||||
};
|
||||
int *getFlatField(){return setEta(NULL);};
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
virtual void prepareInterpolation(int &ok)=0;
|
||||
|
||||
/* ////////////////////////////////////////////////////////////////////////////// */
|
||||
|
||||
#ifdef MYROOT1
|
||||
TH2D *gethhx()
|
||||
{
|
||||
hhx->Scale((double)nSubPixels);
|
||||
return hhx;
|
||||
};
|
||||
|
||||
TH2D *gethhy()
|
||||
{
|
||||
hhy->Scale((double)nSubPixels);
|
||||
return hhy;
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifndef MYROOT1
|
||||
int *gethhx()
|
||||
{
|
||||
// hhx->Scale((double)nSubPixels);
|
||||
return hhx;
|
||||
};
|
||||
|
||||
int *gethhy()
|
||||
{
|
||||
// hhy->Scale((double)nSubPixels);
|
||||
return hhy;
|
||||
};
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//////////// /*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);
|
||||
|
||||
calcEta(totquad, sDum, etax, etay);
|
||||
getInterpolatedPosition(x,y,etax,etay,corner,int_x,int_y);
|
||||
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;
|
||||
double ex,ey;
|
||||
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.;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifdef MYROOT1
|
||||
xpos_eta=(hhx->GetBinContent(hhx->GetXaxis()->FindBin(etax),hhy->GetYaxis()->FindBin(etay)))/((double)nSubPixels);
|
||||
ypos_eta=(hhy->GetBinContent(hhx->GetXaxis()->FindBin(etax),hhy->GetYaxis()->FindBin(etay)))/((double)nSubPixels);
|
||||
#endif
|
||||
#ifndef MYROOT1
|
||||
ex=(etax-etamin)/etastep;
|
||||
ey=(etay-etamin)/etastep;
|
||||
if (ex<0) ex=0;
|
||||
if (ex>=nSubPixels) ex=nSubPixels-1;
|
||||
if (ey<0) ey=0;
|
||||
if (ey>=nSubPixels) ey=nSubPixels-1;
|
||||
|
||||
|
||||
xpos_eta=(((double)hhx[(int)(ey*nbeta+ex)]))/((double)nSubPixels);
|
||||
ypos_eta=(((double)hhy[(int)(ey*nbeta+ex)]))/((double)nSubPixels);
|
||||
//else
|
||||
//return 0;
|
||||
|
||||
#endif
|
||||
|
||||
int_x=((double)x) + 0.5*dX + xpos_eta;
|
||||
int_y=((double)y) + 0.5*dY + ypos_eta;
|
||||
//return 1;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
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>=nSubPixels) ex=nSubPixels-1;
|
||||
if (ey<0) ey=0;
|
||||
if (ey>=nSubPixels) ey=nSubPixels-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 *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){
|
||||
|
||||
int ex,ey;
|
||||
|
||||
#ifdef MYROOT1
|
||||
heta->Fill(etax,etay);
|
||||
#endif
|
||||
#ifndef MYROOT1
|
||||
ex=(etax-etamin)/etastep;
|
||||
ey=(etay-etamin)/etastep;
|
||||
if (ey<nbeta && ex<nbeta && ex>=0 && ey>=0)
|
||||
heta[ey*nbeta+ex]++;
|
||||
#endif
|
||||
return 0;
|
||||
};
|
||||
|
||||
protected:
|
||||
|
||||
#ifdef MYROOT1
|
||||
TH2D *heta;
|
||||
TH2D *hhx;
|
||||
TH2D *hhy;
|
||||
#endif
|
||||
#ifndef MYROOT1
|
||||
int *heta;
|
||||
int *hhx;
|
||||
int *hhy;
|
||||
#endif
|
||||
int nbeta;
|
||||
double etamin, etamax, etastep;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
85
slsDetectorCalibration/etaVEL/etaInterpolationGlobal.h
Normal file
85
slsDetectorCalibration/etaVEL/etaInterpolationGlobal.h
Normal file
@@ -0,0 +1,85 @@
|
||||
#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){};
|
||||
|
||||
|
||||
|
||||
virtual void prepareInterpolation(int &ok)
|
||||
{
|
||||
ok=1;
|
||||
#ifdef MYROOT1
|
||||
if (hhx) delete hhx;
|
||||
if (hhy) delete hhy;
|
||||
|
||||
hhx=new TH2D("hhx","hhx",heta->GetNbinsX(),heta->GetXaxis()->GetXmin(),heta->GetXaxis()->GetXmax(), heta->GetNbinsY(),heta->GetYaxis()->GetXmin(),heta->GetYaxis()->GetXmax());
|
||||
hhy=new TH2D("hhy","hhy",heta->GetNbinsX(),heta->GetXaxis()->GetXmin(),heta->GetXaxis()->GetXmax(), heta->GetNbinsY(),heta->GetYaxis()->GetXmin(),heta->GetYaxis()->GetXmax());
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
///*Eta Distribution Rebinning*///
|
||||
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];
|
||||
|
||||
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);
|
||||
#endif
|
||||
#ifndef MYROOT1
|
||||
hhx[ibx+iby*nbeta]=ib;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
ib=0;
|
||||
for (int iby=0; iby<nbeta; iby++) {
|
||||
if (hiy[iby]>(ib+1)*tot_eta*bsize) ib++;
|
||||
for (int ibx=0; ibx<nbeta; ibx++) {
|
||||
#ifdef MYROOT1
|
||||
hhy->SetBinContent(ibx+1,iby+1,ib);
|
||||
#endif
|
||||
#ifndef MYROOT1
|
||||
hhy[ibx+iby*nbeta]=ib;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
return ;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
99
slsDetectorCalibration/etaVEL/etaInterpolationPosXY.h
Normal file
99
slsDetectorCalibration/etaVEL/etaInterpolationPosXY.h
Normal file
@@ -0,0 +1,99 @@
|
||||
#ifndef ETA_INTERPOLATION_POSXY_H
|
||||
#define ETA_INTERPOLATION_POSXY_H
|
||||
|
||||
|
||||
#include "etaInterpolationBase.h"
|
||||
|
||||
class etaInterpolationPosXY : public etaInterpolationBase{
|
||||
public:
|
||||
etaInterpolationPosXY(int nx=400, int ny=400, int ns=25, int nb=-1, double emin=1, double emax=0) : etaInterpolationBase(nx,ny,ns, nb, emin,emax){};
|
||||
|
||||
|
||||
|
||||
virtual void prepareInterpolation(int &ok)
|
||||
{
|
||||
ok=1;
|
||||
#ifdef MYROOT1
|
||||
if (hhx) delete hhx;
|
||||
if (hhy) delete hhy;
|
||||
|
||||
hhx=new TH2D("hhx","hhx",heta->GetNbinsX(),heta->GetXaxis()->GetXmin(),heta->GetXaxis()->GetXmax(), heta->GetNbinsY(),heta->GetYaxis()->GetXmin(),heta->GetYaxis()->GetXmax());
|
||||
hhy=new TH2D("hhy","hhy",heta->GetNbinsX(),heta->GetXaxis()->GetXmin(),heta->GetXaxis()->GetXmax(), heta->GetNbinsY(),heta->GetYaxis()->GetXmin(),heta->GetYaxis()->GetXmax());
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
///*Eta Distribution Rebinning*///
|
||||
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];
|
||||
cout << "total eta entries is :"<< tot_eta << endl;
|
||||
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;
|
||||
|
||||
for (int ib=0; ib<nbeta; ib++) {
|
||||
|
||||
tot_eta_x=0;
|
||||
tot_eta_y=0;
|
||||
|
||||
for (int iby=0; iby<nbeta; iby++) {
|
||||
hx[iby]=heta[iby+ib*nbeta];
|
||||
tot_eta_x+=hx[iby];
|
||||
hy[iby]=heta[ib+iby*nbeta];
|
||||
tot_eta_y+=hy[iby];
|
||||
}
|
||||
|
||||
hix[0]=hx[0];
|
||||
hiy[0]=hy[0];
|
||||
|
||||
for (int iby=1; iby<nbeta; iby++) {
|
||||
hix[iby]=hix[iby-1]+hx[iby];
|
||||
hiy[iby]=hiy[iby-1]+hx[iby];
|
||||
}
|
||||
|
||||
ii=0;
|
||||
|
||||
for (int ibx=0; ibx<nbeta; ibx++) {
|
||||
if (hix[ibx]>(ii+1)*tot_eta_x*bsize) ii++;
|
||||
#ifdef MYROOT1
|
||||
hhx->SetBinContent(ibx+1,ib+1,ii);
|
||||
#endif
|
||||
#ifndef MYROOT1
|
||||
hhx[ibx+ib*nbeta]=ii;
|
||||
#endif
|
||||
}
|
||||
|
||||
ii=0;
|
||||
|
||||
for (int ibx=0; ibx<nbeta; ibx++) {
|
||||
if (hiy[ibx]>(ii+1)*tot_eta_y*bsize) ii++;
|
||||
#ifdef MYROOT1
|
||||
hhy->SetBinContent(ib+1,ibx+1,ii);
|
||||
#endif
|
||||
#ifndef MYROOT1
|
||||
hhy[ib+ibx*nbeta]=ii;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
return ;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
111
slsDetectorCalibration/etaVEL/linearInterpolation.h
Normal file
111
slsDetectorCalibration/etaVEL/linearInterpolation.h
Normal file
@@ -0,0 +1,111 @@
|
||||
#ifndef LINEAR_INTERPOLATION_H
|
||||
#define LINEAR_INTERPOLATION_H
|
||||
|
||||
//#include <TObject.h>
|
||||
//#include <TTree.h>
|
||||
//#include <TH2F.h>
|
||||
|
||||
#include "slsInterpolation.h"
|
||||
|
||||
class linearInterpolation : public slsInterpolation{
|
||||
|
||||
public:
|
||||
linearInterpolation(int nx=400, int ny=400, int ns=25) : slsInterpolation(nx,ny,ns) {};
|
||||
|
||||
virtual void prepareInterpolation(int &ok){ok=1;};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//////////// /*It return position hit for the event in input */ //////////////
|
||||
virtual void getInterpolatedPosition(Int_t x, Int_t 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);
|
||||
|
||||
calcEta(totquad, sDum, etax, etay);
|
||||
getInterpolatedPosition(x, y, etax,etay, corner, int_x, int_y);
|
||||
|
||||
return;
|
||||
};
|
||||
|
||||
|
||||
virtual void getInterpolatedPosition(Int_t x, Int_t 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=+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.;
|
||||
}
|
||||
|
||||
|
||||
xpos_eta=(etax);
|
||||
ypos_eta=(etay);
|
||||
|
||||
int_x=((double)x) + 0.5*dX + xpos_eta;
|
||||
int_y=((double)y) + 0.5*dY + ypos_eta;
|
||||
|
||||
return;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
virtual void getPositionETA3(Int_t x, Int_t 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(double etax, double etay){};
|
||||
|
||||
|
||||
protected:
|
||||
;
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
58
slsDetectorCalibration/etaVEL/noInterpolation.h
Normal file
58
slsDetectorCalibration/etaVEL/noInterpolation.h
Normal file
@@ -0,0 +1,58 @@
|
||||
#ifndef NO_INTERPOLATION_H
|
||||
#define NO_INTERPOLATION_H
|
||||
|
||||
/* #ifdef MYROOT1 */
|
||||
/* #include <TObject.h> */
|
||||
/* #include <TTree.h> */
|
||||
/* #include <TH2F.h> */
|
||||
/* #include <TROOT.h> */
|
||||
/* #include <TRandom.h> */
|
||||
/* #endif */
|
||||
|
||||
#include <cstdlib>
|
||||
#include "slsInterpolation.h"
|
||||
|
||||
|
||||
|
||||
class noInterpolation : public slsInterpolation{
|
||||
public:
|
||||
noInterpolation(int nx=400, int ny=400, int ns=25) : slsInterpolation(nx,ny,ns) {};// {eventGenerator=new TRandom();};
|
||||
virtual void prepareInterpolation(int &ok){ok=1;};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//////////// /*It return position hit for the event in input */ //////////////
|
||||
|
||||
virtual void getInterpolatedPosition(Int_t x, Int_t 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_t x, Int_t y, double etax, double etay, int corner, double &int_x, double &int_y)
|
||||
{
|
||||
return getInterpolatedPosition(x, y, NULL, int_x, int_y);
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
virtual void getPositionETA3(Int_t x, Int_t 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 int addToFlatField(double *cluster, double &etax, double &etay){return 0;};
|
||||
virtual int addToFlatField(double etax, double etay){return 0;};
|
||||
|
||||
protected:
|
||||
;
|
||||
// TRandom *eventGenerator;
|
||||
// ClassDefNV(slsInterpolation,1);
|
||||
// #pragma link C++ class slsInterpolation-;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,9 +1,11 @@
|
||||
#ifndef SLS_INTERPOLATION_H
|
||||
#define SLS_INTERPOLATION_H
|
||||
|
||||
#ifdef MYROOT1
|
||||
#include <TObject.h>
|
||||
#include <TTree.h>
|
||||
#include <TH2F.h>
|
||||
#endif
|
||||
|
||||
#ifndef DEF_QUAD
|
||||
#define DEF_QUAD
|
||||
@@ -16,35 +18,76 @@
|
||||
};
|
||||
#endif
|
||||
|
||||
class slsInterpolation : public TObject{
|
||||
//#ifdef MYROOT1
|
||||
//: public TObject
|
||||
//#endif
|
||||
class slsInterpolation
|
||||
{
|
||||
|
||||
public:
|
||||
slsInterpolation(int nx=40, int ny=160, int ns=25) :nPixelsX(nx), nPixelsY(ny), nSubPixels(ns) {hint=new TH2F("hint","hint",ns*nx, 0, nx, ns*ny, 0, ny);};
|
||||
|
||||
slsInterpolation(int nx=400, int ny=400, int ns=25) :nPixelsX(nx), nPixelsY(ny), nSubPixels(ns) {
|
||||
|
||||
#ifdef MYROOT1
|
||||
hint=new TH2F("hint","hint",ns*nx, 0, nx, ns*ny, 0, ny);
|
||||
#endif
|
||||
|
||||
#ifndef MYROOT1
|
||||
hint=new int[ns*nx*ns*ny];
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
int getNSubPixels() {return nSubPixels;};
|
||||
|
||||
|
||||
//create eta distribution, eta rebinnining etc.
|
||||
//returns flat field image
|
||||
virtual void prepareInterpolation(int &ok)=0;
|
||||
|
||||
//create interpolated image
|
||||
//returns interpolated image
|
||||
#ifdef MYROOT1
|
||||
virtual TH2F *getInterpolatedImage(){return hint;};
|
||||
#endif
|
||||
|
||||
#ifndef MYROOT1
|
||||
virtual int *getInterpolatedImage(){return hint;};
|
||||
#endif
|
||||
//return position inside the pixel for the given photon
|
||||
virtual void getInterpolatedPosition(Int_t x, Int_t y, Double_t *data, Double_t &int_x, Double_t &int_y)=0;
|
||||
virtual void getInterpolatedPosition(int x, int y, double *data, double &int_x, double &int_y)=0;
|
||||
//return position inside the pixel for the given photon
|
||||
virtual void getInterpolatedPosition(int x, int y, double etax, double etay, int quad, double &int_x, double &int_y)=0;
|
||||
|
||||
TH2F *addToImage(Double_t int_x, Double_t int_y){hint->Fill(int_x, int_y); return hint;};
|
||||
#ifdef MYROOT1
|
||||
TH2F *addToImage(double int_x, double int_y){hint->Fill(int_x, int_y); return hint;};
|
||||
#endif
|
||||
|
||||
#ifndef MYROOT1
|
||||
virtual int *addToImage(double int_x, double int_y){ int iy=nSubPixels*int_y; int ix=nSubPixels*int_x;
|
||||
if (ix>=0 && ix<(nPixelsX*nSubPixels) && iy<(nSubPixels*nPixelsY) && iy>=0 )(*(hint+ix+iy*nPixelsX))+=1;
|
||||
return hint;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
virtual int addToFlatField(Double_t *cluster, Double_t &etax, Double_t &etay)=0;
|
||||
virtual int addToFlatField(Double_t etax, Double_t etay)=0;
|
||||
virtual int addToFlatField(double *cluster, double &etax, double &etay)=0;
|
||||
virtual int addToFlatField(double etax, double etay)=0;
|
||||
|
||||
#ifdef MYROOT1
|
||||
virtual TH2D *getFlatField(){return NULL;};
|
||||
#endif
|
||||
|
||||
#ifndef MYROOT1
|
||||
virtual int *getFlatField(){return NULL;};
|
||||
#endif
|
||||
|
||||
//virtual void Streamer(TBuffer &b);
|
||||
|
||||
|
||||
static int calcQuad(Double_t *cl, Double_t &sum, Double_t &totquad, Double_t sDum[2][2]){
|
||||
static int calcQuad(double *cl, double &sum, double &totquad, double sDum[2][2]){
|
||||
|
||||
int corner = UNDEFINED_QUADRANT;
|
||||
Double_t *cluster[3];
|
||||
double *cluster[3];
|
||||
cluster[0]=cl;
|
||||
cluster[1]=cl+3;
|
||||
cluster[2]=cl+6;
|
||||
@@ -95,8 +138,8 @@ class slsInterpolation : public TObject{
|
||||
|
||||
}
|
||||
|
||||
static int calcEta(Double_t totquad, Double_t sDum[2][2], Double_t &etax, Double_t &etay){
|
||||
Double_t t,r;
|
||||
static int calcEta(double totquad, double sDum[2][2], double &etax, double &etay){
|
||||
double t,r;
|
||||
|
||||
if (totquad>0) {
|
||||
t = sDum[1][0] + sDum[1][1];
|
||||
@@ -109,7 +152,7 @@ class slsInterpolation : public TObject{
|
||||
}
|
||||
|
||||
|
||||
static int calcEta(Double_t *cl, Double_t &etax, Double_t &etay, Double_t &sum, Double_t &totquad, Double_t sDum[2][2]) {
|
||||
static int calcEta(double *cl, double &etax, double &etay, double &sum, double &totquad, double sDum[2][2]) {
|
||||
int corner = calcQuad(cl,sum,totquad,sDum);
|
||||
calcEta(totquad, sDum, etax, etay);
|
||||
|
||||
@@ -117,8 +160,8 @@ class slsInterpolation : public TObject{
|
||||
}
|
||||
|
||||
|
||||
static int calcEtaL(Double_t totquad, int corner, Double_t sDum[2][2], Double_t &etax, Double_t &etay){
|
||||
Double_t t,r, toth, totv;
|
||||
static int calcEtaL(double totquad, int corner, double sDum[2][2], double &etax, double &etay){
|
||||
double t,r, toth, totv;
|
||||
if (totquad>0) {
|
||||
switch(corner) {
|
||||
case TOP_LEFT:
|
||||
@@ -156,7 +199,7 @@ class slsInterpolation : public TObject{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int calcEtaL(Double_t *cl, Double_t &etax, Double_t &etay, Double_t &sum, Double_t &totquad, Double_t sDum[2][2]) {
|
||||
static int calcEtaL(double *cl, double &etax, double &etay, double &sum, double &totquad, double sDum[2][2]) {
|
||||
int corner = calcQuad(cl,sum,totquad,sDum);
|
||||
calcEtaL(totquad, corner, sDum, etax, etay);
|
||||
|
||||
@@ -165,7 +208,7 @@ class slsInterpolation : public TObject{
|
||||
|
||||
|
||||
|
||||
static int calcEtaC3(Double_t *cl, Double_t &etax, Double_t &etay, Double_t &sum, Double_t &totquad, Double_t sDum[2][2]){
|
||||
static int calcEtaC3(double *cl, double &etax, double &etay, double &sum, double &totquad, double sDum[2][2]){
|
||||
|
||||
int corner = calcQuad(cl,sum,totquad,sDum);
|
||||
calcEta(sum, sDum, etax, etay);
|
||||
@@ -175,8 +218,8 @@ class slsInterpolation : public TObject{
|
||||
|
||||
|
||||
|
||||
static int calcEta3(Double_t *cl, Double_t &etax, Double_t &etay, Double_t &sum) {
|
||||
Double_t l,r,t,b;
|
||||
static int calcEta3(double *cl, double &etax, double &etay, double &sum) {
|
||||
double l,r,t,b;
|
||||
sum=cl[0]+cl[1]+cl[2]+cl[3]+cl[4]+cl[5]+cl[6]+cl[7]+cl[8];
|
||||
if (sum>0) {
|
||||
l=cl[0]+cl[3]+cl[6];
|
||||
@@ -192,8 +235,8 @@ class slsInterpolation : public TObject{
|
||||
|
||||
|
||||
|
||||
static int calcEta3X(Double_t *cl, Double_t &etax, Double_t &etay, Double_t &sum) {
|
||||
Double_t l,r,t,b;
|
||||
static int calcEta3X(double *cl, double &etax, double &etay, double &sum) {
|
||||
double l,r,t,b;
|
||||
sum=cl[0]+cl[1]+cl[2]+cl[3]+cl[4]+cl[5]+cl[6]+cl[7]+cl[8];
|
||||
if (sum>0) {
|
||||
l=cl[3];
|
||||
@@ -213,12 +256,14 @@ class slsInterpolation : public TObject{
|
||||
|
||||
protected:
|
||||
int nPixelsX, nPixelsY;
|
||||
int nSubPixels;
|
||||
int nSubPixels;
|
||||
#ifdef MYROOT1
|
||||
TH2F *hint;
|
||||
#endif
|
||||
#ifndef MYROOT1
|
||||
int *hint;
|
||||
#endif
|
||||
|
||||
|
||||
// ClassDefNV(slsInterpolation,1);
|
||||
// #pragma link C++ class slsInterpolation-;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user