mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-20 02:40:03 +02:00
Common mode added, working for gotthard double modules
This commit is contained in:
parent
ab06c33107
commit
b029f1fa26
@ -271,34 +271,37 @@ template <class dataType> class analogDetector {
|
||||
else return 0;
|
||||
}
|
||||
|
||||
virtual void addToCommonMode(double val, int ix, int iy=0){
|
||||
/* virtual void addToCommonMode(double val, int ix, int iy=0){ */
|
||||
|
||||
if (ix>=0 && ix<nx && iy>=0 && iy<ny) {
|
||||
if (cmSub) {
|
||||
if (det) if (det->isGood(ix, iy)==0) return;
|
||||
if (getNumpedestals(ix,iy)>0)
|
||||
cmSub->addToCommonMode(val-getPedestal(ix,iy), ix, iy);
|
||||
};
|
||||
/* if (ix>=0 && ix<nx && iy>=0 && iy<ny) { */
|
||||
/* if (cmSub) { */
|
||||
/* if (det) if (det->isGood(ix, iy)==0) return; */
|
||||
/* if (getNumpedestals(ix,iy)>0) { */
|
||||
/* cmSub->addToCommonMode(val-getPedestal(ix,iy), ix, iy); */
|
||||
/* } */
|
||||
/* }; */
|
||||
|
||||
}
|
||||
}
|
||||
/* } */
|
||||
/* } */
|
||||
|
||||
virtual void addToCommonMode(char *data){
|
||||
if (cmSub) {
|
||||
for (int ix=xmin; ix<xmax; ix++) {
|
||||
for (int iy=ymin; iy<ymax; iy++) {
|
||||
if (getNumpedestals(ix,iy)>0)
|
||||
// if (getNumpedestals(ix,iy)>0)
|
||||
addToCommonMode(data, ix, iy);
|
||||
}
|
||||
}
|
||||
cout << "cm " << getCommonMode(0,0) << " " << getCommonMode(1,0) << endl;
|
||||
//cout << "cm " << getCommonMode(0,0) << " " << getCommonMode(1,0) << endl;
|
||||
}
|
||||
}
|
||||
virtual void addToCommonMode(char *data, int ix, int iy=0){
|
||||
if (cmSub) {
|
||||
if (det) if (det->isGood(ix, iy)==0) return;
|
||||
if (getNumpedestals(ix,iy)>0)
|
||||
if (getNumpedestals(ix,iy)>0){
|
||||
cmSub->addToCommonMode(subtractPedestal(data,ix,iy,0), ix, iy);
|
||||
// cout << ix << " " <<subtractPedestal(data,ix,iy,0) << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
@ -668,9 +671,9 @@ template <class dataType> class analogDetector {
|
||||
val=dataSign*det->getValue(data, ix, iy);
|
||||
else
|
||||
val=((double*)data)[iy*nx+ix];
|
||||
if (cm && cmSub)
|
||||
val-=getCommonMode(ix,iy);
|
||||
addToPedestal(val,ix,iy);
|
||||
/* if (cm && cmSub) */
|
||||
/* val-=getCommonMode(ix,iy); */
|
||||
addToPedestal(val,ix,iy, cm);
|
||||
}
|
||||
return ;
|
||||
|
||||
@ -722,7 +725,6 @@ template <class dataType> class analogDetector {
|
||||
}
|
||||
|
||||
if (det) {
|
||||
// cout << det->getValue(data, ix, iy) << " " << getPedestal(ix,iy) << " " << (dataSign*det->getValue(data, ix, iy)-getPedestal(ix,iy))/g << endl;
|
||||
return (dataSign*det->getValue(data, ix, iy)-getPedestal(ix,iy, cm))/g;
|
||||
}
|
||||
else
|
||||
|
@ -34,6 +34,9 @@ public:
|
||||
|
||||
|
||||
|
||||
#ifdef BCHIP074_BCHIP075
|
||||
cout << "This is a bchip074-bchip075 system " << endl;
|
||||
#endif
|
||||
|
||||
|
||||
uint16_t **dMask;
|
||||
@ -59,6 +62,11 @@ public:
|
||||
dMap[0][ix] = 1280*2+2*offset+ipix*2;//dataSize-2-ix;//+2*offset;
|
||||
// dMap[0][ix] = 2*ipix+offset*(imod+1)+1280*2*imod;
|
||||
dMask[0][ix] = 0x0;
|
||||
#ifdef BCHIP074_BCHIP075
|
||||
int ibad=ix/2+1280*imod;
|
||||
if ((ibad>=128*4 && ibad<128*5) || (ibad>=9*128 && ibad<10*128) || (ibad>=(1280+128*4) && ibad<ibad>=(1280+128*6)))
|
||||
dataROIMask[0][ix]=0;
|
||||
#endif
|
||||
}
|
||||
|
||||
setDataMap(dMap);
|
||||
|
@ -0,0 +1,30 @@
|
||||
#ifndef GOTTHARDDOUBLECOMMONMODESUBTRACTION_H
|
||||
#define GOTTHARDDOUBLECOMMONMODESUBTRACTION_H
|
||||
|
||||
|
||||
#include "commonModeSubtractionNew.h"
|
||||
|
||||
class gotthardDoubleModuleCommonModeSubtraction : public commonModeSubtraction {
|
||||
|
||||
/** @short class to calculate the common mode of the pedestals based on an approximated moving average*/
|
||||
|
||||
public:
|
||||
|
||||
/** constructor
|
||||
\param nn number of samples for the moving average to calculate the average common mode
|
||||
\param iroi number of regions on which one can calculate the common mode separately. Defaults to 1 i.e. whole detector
|
||||
|
||||
*/
|
||||
gotthardDoubleModuleCommonModeSubtraction(int ns=3) : commonModeSubtraction(2, ns) {};
|
||||
|
||||
/**
|
||||
gets the common mode ROI for pixel ix, iy
|
||||
*/
|
||||
virtual int getROI(int ix, int iy){return ix%2;};
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
@ -14,6 +14,8 @@
|
||||
#include <fstream>
|
||||
#include <cstring>
|
||||
|
||||
//#define BCHIP074_BCHIP075
|
||||
|
||||
#include "gotthardModuleDataNew.h"
|
||||
#include "gotthardDoubleModuleDataNew.h"
|
||||
#include "gotthardDoubleModuleCommonModeSubtractionNew.h"
|
||||
@ -34,7 +36,6 @@
|
||||
|
||||
|
||||
|
||||
|
||||
#define SLS_DETECTOR_JSON_HEADER_VERSION 0x2
|
||||
int main(int argc, char *argv[]){
|
||||
//void *gotthardProcessFrame() {
|
||||
@ -57,20 +58,22 @@ int main(int argc, char *argv[]){
|
||||
offset=48;
|
||||
#endif
|
||||
|
||||
commonModeSubtraction *cm=NULL;
|
||||
//commonModeSubtraction *cm=NULL;
|
||||
|
||||
cm=new gotthardDoubleModuleCommonModeSubtraction();
|
||||
gotthardDoubleModuleCommonModeSubtraction *cm=new gotthardDoubleModuleCommonModeSubtraction();
|
||||
gotthardModuleDataNew *decoder=new gotthardModuleDataNew();
|
||||
gotthardDoubleModuleDataNew *det=new gotthardDoubleModuleDataNew(offset);
|
||||
// singlePhotonDetector *filter=new singlePhotonDetector(det,3, 5, 1, 0, 1000, 100);
|
||||
analogDetector<uint16_t> *filter=new analogDetector<uint16_t>(det, 1, cm, 1000);
|
||||
singlePhotonDetector *filter=new singlePhotonDetector(det,3, 5, 1, cm, 1000, 100);
|
||||
// analogDetector<uint16_t> *filter=new analogDetector<uint16_t>(det, 1, cm, 1000);
|
||||
// analogDetector<uint16_t> *filter_nocm=new analogDetector<uint16_t>(det, 1, NULL, 1000);
|
||||
filter->setROI(0,2560,0,1);
|
||||
char *buff;//[2*(48+1280*2)];
|
||||
char *buff0;
|
||||
char *buff1;
|
||||
multiThreadedAnalogDetector *mt=new multiThreadedAnalogDetector(filter,nthreads,fifosize);
|
||||
mt->setFrameMode(eFrame);
|
||||
// mt->setFrameMode(eFrame);
|
||||
mt->setFrameMode(ePedestal);
|
||||
// mt->setFrameMode(ePedestal);
|
||||
mt->StartThreads();
|
||||
mt->popFree(buff);
|
||||
buff0=buff;
|
||||
@ -222,6 +225,7 @@ int main(int argc, char *argv[]){
|
||||
|
||||
|
||||
char ofname[10000];
|
||||
char fn0[10000], fn1[10000];
|
||||
FILE *fout=NULL;
|
||||
for (int i=0; i<nnx; i++)
|
||||
dout[i]=0;
|
||||
@ -274,37 +278,130 @@ int main(int argc, char *argv[]){
|
||||
// cout << "Receive header " << nf << endl;
|
||||
if (!zmqsocket0->ReceiveHeader(0, acqIndex0, frameIndex0, subframeIndex0, filename0, fileindex0)) {
|
||||
|
||||
cout << "************************************************************************** packet0!*****************************"<< endl;
|
||||
// cout << "************************************************************************** packet0!*****************************"<< endl;
|
||||
|
||||
end_of_acquisition++;
|
||||
}
|
||||
if (!zmqsocket1->ReceiveHeader(0, acqIndex1, frameIndex1, subframeIndex1, filename1, fileindex1)) {
|
||||
cout << "************************************************************************** packet1!*****************************"<< endl;
|
||||
//cout << "************************************************************************** packet1!*****************************"<< endl;
|
||||
|
||||
end_of_acquisition++;
|
||||
}
|
||||
|
||||
// if ((!zmqsocket0->ReceiveHeader(0, acqIndex0, frameIndex0, subframeIndex0, filename0, fileindex0)) && (!zmqsocket1->ReceiveHeader(0, acqIndex1, frameIndex1, subframeIndex1, filename1, fileindex1))){
|
||||
if (end_of_acquisition==0) {
|
||||
if (acqIndex0!=acqIndex1)
|
||||
cout << "different acquisition indexes " << acqIndex0 << " and " << acqIndex1 << endl;
|
||||
if (frameIndex0!=frameIndex1)
|
||||
cout << "different frame indexes " << frameIndex0 << " and " << frameIndex1 << endl;
|
||||
|
||||
|
||||
while (frameIndex0<frameIndex1) {
|
||||
cout << "aligning det 0 " << endl;
|
||||
length = zmqsocket0->ReceiveData(0, buff0, size/2);
|
||||
if (!zmqsocket0->ReceiveHeader(0, acqIndex0, frameIndex0, subframeIndex0, filename0, fileindex0)) {
|
||||
end_of_acquisition++;
|
||||
}
|
||||
}
|
||||
|
||||
while (frameIndex1<frameIndex0) {
|
||||
cout << "aligning det 1 " << endl;
|
||||
length = zmqsocket1->ReceiveData(0, buff1, size/2);
|
||||
if (!zmqsocket1->ReceiveHeader(0, acqIndex1, frameIndex1, subframeIndex1, filename1, fileindex1)) {
|
||||
end_of_acquisition++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (end_of_acquisition) {
|
||||
cout << "************************************************************************** END OF FRAME" << end_of_acquisition << " !*****************************"<< endl;
|
||||
// return 0;
|
||||
|
||||
// while (mt->isBusy()) {;}
|
||||
// image=filter->getImage();
|
||||
// if (image) {
|
||||
sprintf(ofname,"%s_%d.ph",fn0,irun);
|
||||
while (mt->isBusy()) {;}
|
||||
image=filter->getImage();
|
||||
if (image) {
|
||||
// fout=fopen(ofname,"w");
|
||||
// cout << nf << "*****************" << endl;
|
||||
// for (int i=0; i<2560; i++) {
|
||||
cout << nf << "*****************" << endl;
|
||||
for (int i=0; i<2560/2; i++) {
|
||||
// fprintf(fout,"%d %d\n",i,image[i]);
|
||||
// dout[i]=image[i];
|
||||
// if (image[i]<0)
|
||||
// dout[i]=0;
|
||||
// }
|
||||
dout[i]=image[i/2];
|
||||
dout[i+1280]=image[i/2+1];
|
||||
|
||||
if (dout[i]<0)
|
||||
dout[i]=0;
|
||||
}
|
||||
// fclose(fout);
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
if (send) {
|
||||
|
||||
zmqsocket2->SendHeaderData(0, false, SLS_DETECTOR_JSON_HEADER_VERSION,0,0,0,0,0, 0,0,fn0, 0, 0,0,0,0,0,0,0,0,0,0,0,1);
|
||||
zmqsocket3->SendHeaderData(0, false, SLS_DETECTOR_JSON_HEADER_VERSION,0,0,0,0,0, 0,0,fn1, 0, 0,0,0,0,0,0,0,0,0,0,0,1);
|
||||
|
||||
zmqsocket2->SendData((char*)dout,size/2);
|
||||
zmqsocket3->SendData(((char*)dout)+size/2,size/2);
|
||||
// // cprintf(GREEN, "Sent Data\n");
|
||||
|
||||
|
||||
zmqsocket2->SendHeaderData(0, true, SLS_DETECTOR_JSON_HEADER_VERSION);
|
||||
zmqsocket3->SendHeaderData(0, true, SLS_DETECTOR_JSON_HEADER_VERSION);
|
||||
}
|
||||
|
||||
|
||||
//mt->setFrameMode(eFrame);
|
||||
filter->clearImage();
|
||||
// std::time(&end_time);
|
||||
// cout << std::ctime(&end_time) << " " << nf << endl;
|
||||
|
||||
|
||||
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
strcpy(fn0,filename0.c_str());
|
||||
strcpy(fn1,filename1.c_str());
|
||||
|
||||
// cout << "Receive data " << nf << endl;
|
||||
length = zmqsocket0->ReceiveData(0, buff0, size/2);
|
||||
length += zmqsocket1->ReceiveData(0, buff1, size/2);
|
||||
|
||||
irun=fileindex0;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// // if (nf>100)
|
||||
// // mt->setFrameMode(eFrame);
|
||||
// //filter->clearImage();
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
mt->pushData(buff);
|
||||
mt->nextThread();
|
||||
cout << "==" << nf << endl;
|
||||
|
||||
// while (mt->isBusy()) {;}
|
||||
// image=filter->getImage();
|
||||
// if (image) {
|
||||
// for (int i=0; i<2560; i++) {
|
||||
// // if (i<512)
|
||||
|
||||
// // fprintf(fout,"%d %d\n",i,image[i]);
|
||||
// dout[i]=filter->subtractPedestal(buff,i,0,1);//image[i];//filter->getPedestal(i,0);//
|
||||
// if (dout[i]<0)
|
||||
// dout[i]=0;
|
||||
// // cout << i << " " << image[i] << " " << dout[i] << endl;
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
// if (send) {
|
||||
// strcpy(fname0,filename0.c_str());
|
||||
// strcpy(fname1,filename1.c_str());
|
||||
// // zmqsocket2->SendHeaderData(0, false, SLS_DETECTOR_JSON_HEADER_VERSION,16,fileindex,400,400,400*400, acqIndex,frameIndex,fname, acqIndex, 0,0,0,0,0,0,0,0,0,0,0,1);
|
||||
@ -316,86 +413,12 @@ int main(int argc, char *argv[]){
|
||||
// // cprintf(GREEN, "Sent Data\n");
|
||||
|
||||
|
||||
// zmqsocket2->SendHeaderData(0, true, SLS_DETECTOR_JSON_HEADER_VERSION);
|
||||
// zmqsocket3->SendHeaderData(0, true, SLS_DETECTOR_JSON_HEADER_VERSION);
|
||||
// // zmqsocket2->SendHeaderData(0, true, SLS_DETECTOR_JSON_HEADER_VERSION);
|
||||
// // zmqsocket3->SendHeaderData(0, true, SLS_DETECTOR_JSON_HEADER_VERSION);
|
||||
|
||||
// cprintf(RED, "Received %d frames\n", nf);
|
||||
// // cprintf(RED, "Received %d frames\n", nf);
|
||||
|
||||
zmqsocket2->SendHeaderData(0, true, SLS_DETECTOR_JSON_HEADER_VERSION);
|
||||
zmqsocket3->SendHeaderData(0, true, SLS_DETECTOR_JSON_HEADER_VERSION);
|
||||
}
|
||||
|
||||
|
||||
mt->setFrameMode(eFrame);
|
||||
filter->clearImage();
|
||||
// std::time(&end_time);
|
||||
// cout << std::ctime(&end_time) << " " << nf << endl;
|
||||
|
||||
|
||||
|
||||
|
||||
continue;
|
||||
}
|
||||
if (acqIndex0!=acqIndex1)
|
||||
cout << "different acquisition indexes " << acqIndex0 << " and " << acqIndex1 << endl;
|
||||
if (frameIndex0!=frameIndex1)
|
||||
cout << "different frame indexes " << frameIndex0 << " and " << frameIndex1 << endl;
|
||||
|
||||
|
||||
// cout << "Receive data " << nf << endl;
|
||||
length = zmqsocket0->ReceiveData(0, buff0, size/2);
|
||||
length += zmqsocket1->ReceiveData(0, buff1, size/2);
|
||||
|
||||
irun=fileindex0;
|
||||
sprintf(ofname,"%s_%d.ph",filename0.c_str(),fileindex0);
|
||||
|
||||
|
||||
while (mt->isBusy()) {;}
|
||||
image=filter->getImage();
|
||||
if (image) {
|
||||
for (int i=0; i<2560; i++) {
|
||||
// fprintf(fout,"%d %d\n",i,image[i]);
|
||||
dout[i]=det->getChannel(buff,i,0);//image[i]+1000;//filter->getPedestal(i,0);//
|
||||
// if (image[i]<0)
|
||||
// dout[i]=0;
|
||||
// cout << i << " " << image[i] << " " << dout[i] << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (send) {
|
||||
strcpy(fname0,filename0.c_str());
|
||||
strcpy(fname1,filename1.c_str());
|
||||
// zmqsocket2->SendHeaderData(0, false, SLS_DETECTOR_JSON_HEADER_VERSION,16,fileindex,400,400,400*400, acqIndex,frameIndex,fname, acqIndex, 0,0,0,0,0,0,0,0,0,0,0,1);
|
||||
zmqsocket2->SendHeaderData(0, false, SLS_DETECTOR_JSON_HEADER_VERSION,0,0,0,0,0, 0,0,fname0, 0, 0,0,0,0,0,0,0,0,0,0,0,1);
|
||||
zmqsocket3->SendHeaderData(0, false, SLS_DETECTOR_JSON_HEADER_VERSION,0,0,0,0,0, 0,0,fname1, 0, 0,0,0,0,0,0,0,0,0,0,0,1);
|
||||
|
||||
zmqsocket2->SendData((char*)dout,size/2);
|
||||
zmqsocket3->SendData(((char*)dout)+size/2,size/2);
|
||||
// cprintf(GREEN, "Sent Data\n");
|
||||
|
||||
|
||||
// zmqsocket2->SendHeaderData(0, true, SLS_DETECTOR_JSON_HEADER_VERSION);
|
||||
// zmqsocket3->SendHeaderData(0, true, SLS_DETECTOR_JSON_HEADER_VERSION);
|
||||
|
||||
// cprintf(RED, "Received %d frames\n", nf);
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (nf>100)
|
||||
mt->setFrameMode(eFrame);
|
||||
filter->clearImage();
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
mt->pushData(buff);
|
||||
mt->nextThread();
|
||||
// }
|
||||
|
||||
|
||||
mt->popFree(buff);
|
||||
@ -412,6 +435,8 @@ int main(int argc, char *argv[]){
|
||||
#ifndef ZMQ
|
||||
|
||||
|
||||
|
||||
|
||||
while (mt->isBusy()) {;}
|
||||
image=filter->getImage();
|
||||
if (image) {
|
||||
@ -420,7 +445,7 @@ int main(int argc, char *argv[]){
|
||||
for (int i=0; i<512; i++) {
|
||||
fprintf(fout,"%d %d\n",i,image[i]);
|
||||
}
|
||||
fclose(fout);;
|
||||
fclose(fout);
|
||||
}
|
||||
filter->clearImage();
|
||||
|
||||
|
436
slsDetectorCalibration/interpolations/eta2InterpolationBase.h
Normal file
436
slsDetectorCalibration/interpolations/eta2InterpolationBase.h
Normal file
@ -0,0 +1,436 @@
|
||||
#ifndef ETA2_INTERPOLATION_BASE_H
|
||||
#define ETA2_INTERPOLATION_BASE_H
|
||||
|
||||
#ifdef MYROOT1
|
||||
#include <TObject.h>
|
||||
#include <TTree.h>
|
||||
#include <TH2D.h>
|
||||
#include <TH2F.h>
|
||||
#endif
|
||||
|
||||
#include "etaInterpolationBase.h"
|
||||
|
||||
class eta2InterpolationBase : public virtual etaInterpolationBase {
|
||||
|
||||
public:
|
||||
eta2InterpolationBase(int nx=400, int ny=400, int ns=25, int nb=-1, double emin=1, double emax=0) : etaInterpolationBase(nx,ny, ns, nb, emin, emax) {
|
||||
// cout << "e2ib " << nb << " " << emin << " " << emax << endl;
|
||||
|
||||
if (nbeta<=0) {
|
||||
nbeta=nSubPixels*10;
|
||||
}
|
||||
if (etamin>=etamax) {
|
||||
etamin=-1;
|
||||
etamax=2;
|
||||
cout << ":" <<endl;
|
||||
}
|
||||
etastep=(etamax-etamin)/nbeta;
|
||||
#ifdef MYROOT1
|
||||
delete heta;
|
||||
delete hhx;
|
||||
delete hhy;
|
||||
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
|
||||
delete [] heta;
|
||||
delete [] hhx;
|
||||
delete [] hhy;
|
||||
heta=new int[nbeta*nbeta];
|
||||
hhx=new float[nbeta*nbeta];
|
||||
hhy=new float[nbeta*nbeta];
|
||||
|
||||
#endif
|
||||
|
||||
// cout << nbeta << " " << etamin << " " << etamax << endl;
|
||||
};
|
||||
|
||||
eta2InterpolationBase(eta2InterpolationBase *orig): etaInterpolationBase(orig){ };
|
||||
|
||||
virtual eta2InterpolationBase* Clone()=0;/* {
|
||||
|
||||
return new eta2InterpolationBase(this);
|
||||
|
||||
};
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//////////// /*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,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;
|
||||
};
|
||||
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
virtual void getInterpolatedPosition(int x, int y, double totquad,int quad,double *cl,double &int_x, double &int_y) {
|
||||
|
||||
double cc[2][2];
|
||||
double *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);
|
||||
}
|
||||
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 *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);
|
||||
}
|
||||
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 (nSubPixels>2) {
|
||||
|
||||
#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) {
|
||||
cout << "x*"<< ex << endl;
|
||||
ex=0;
|
||||
}
|
||||
if (ex>=nbeta) {
|
||||
cout << "x?"<< ex << endl;
|
||||
ex=nbeta-1;
|
||||
|
||||
}
|
||||
if (ey<0) {
|
||||
cout << "y*"<< ey << endl;
|
||||
ey=0;
|
||||
}
|
||||
if (ey>=nbeta) {
|
||||
cout << "y?"<< ey << endl;
|
||||
ey=nbeta-1;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
xpos_eta=(((double)hhx[(ey*nbeta+ex)]))+dX ;///((double)nSubPixels);
|
||||
ypos_eta=(((double)hhy[(ey*nbeta+ex)]))+dY ;///((double)nSubPixels);
|
||||
//else
|
||||
//return 0;
|
||||
|
||||
#endif
|
||||
} 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 *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:
|
||||
;
|
||||
}
|
||||
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];
|
||||
|
||||
/* 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 totquad,int quad,double *cl,double &etax, double &etay) {
|
||||
double cc[2][2];
|
||||
double *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:
|
||||
;
|
||||
}
|
||||
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];
|
||||
|
||||
/* cout << cl[0] << " " << cl[1] << " " << cl[2] << endl; */
|
||||
/* cout << cl[3] << " " << cl[4] << " " << cl[5] << endl; */
|
||||
/* cout << cl[6] << " " << cl[7] << " " << cl[8] << endl; */
|
||||
/* cout <<"******"<<totquad << " " << quad << endl; */
|
||||
/* cout << cc[0][0]<< " " << cc[0][1] << endl; */
|
||||
/* cout << cc[1][0]<< " " << cc[1][1] << endl; */
|
||||
//calcMyEta(totquad,quad,cl,etax, etay);
|
||||
calcEta(totquad, cc,etax, etay);
|
||||
|
||||
// cout <<"******"<< etax << " " << etay << endl;
|
||||
|
||||
|
||||
return addToFlatField(etax,etay);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
virtual int addToFlatField(double *cluster, double &etax, double &etay){
|
||||
double sDum[2][2];
|
||||
double tot, totquad;
|
||||
int corner;
|
||||
corner=calcQuad(cluster, tot, totquad, sDum);
|
||||
|
||||
double xpos_eta,ypos_eta;
|
||||
double dX,dY;
|
||||
|
||||
|
||||
calcEta(totquad, sDum, etax, etay);
|
||||
|
||||
return addToFlatField(etax,etay);
|
||||
|
||||
};
|
||||
|
||||
virtual int addToFlatField(int *cluster, double &etax, double &etay){
|
||||
double sDum[2][2];
|
||||
double tot, totquad;
|
||||
int corner;
|
||||
corner=calcQuad(cluster, tot, totquad, sDum);
|
||||
|
||||
double xpos_eta,ypos_eta;
|
||||
double dX,dY;
|
||||
|
||||
|
||||
calcEta(totquad, sDum, etax, etay);
|
||||
|
||||
return addToFlatField(etax,etay);
|
||||
|
||||
};
|
||||
|
||||
|
||||
virtual int addToFlatField(double etax, double etay){
|
||||
#ifdef MYROOT1
|
||||
heta->Fill(etax,etay);
|
||||
#endif
|
||||
#ifndef MYROOT1
|
||||
int ex,ey;
|
||||
ex=(etax-etamin)/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; */
|
||||
/* float *hhx; */
|
||||
/* float *hhy; */
|
||||
/* #endif */
|
||||
/* int nbeta; */
|
||||
/* double etamin, etamax, etastep; */
|
||||
|
||||
};
|
||||
|
||||
#endif
|
294
slsDetectorCalibration/interpolations/eta3InterpolationBase.h
Normal file
294
slsDetectorCalibration/interpolations/eta3InterpolationBase.h
Normal file
@ -0,0 +1,294 @@
|
||||
#ifndef ETA3_INTERPOLATION_BASE_H
|
||||
#define ETA3_INTERPOLATION_BASE_H
|
||||
|
||||
#ifdef MYROOT1
|
||||
#include <TObject.h>
|
||||
#include <TTree.h>
|
||||
#include <TH2D.h>
|
||||
#include <TH2F.h>
|
||||
#endif
|
||||
|
||||
#include "etaInterpolationBase.h"
|
||||
|
||||
class eta3InterpolationBase : public virtual etaInterpolationBase {
|
||||
|
||||
public:
|
||||
eta3InterpolationBase(int nx=400, int ny=400, int ns=25, int nb=-1, double emin=1, double emax=0) : etaInterpolationBase(nx, ny, ns, nb, emin, emax) {
|
||||
// cout << "e3ib " << nb << " " << emin << " " << emax << endl;
|
||||
if (nbeta<=0) {
|
||||
nbeta=nSubPixels*10;
|
||||
}
|
||||
if (etamin>=etamax) {
|
||||
etamin=-1;
|
||||
etamax=1;
|
||||
}
|
||||
|
||||
etastep=(etamax-etamin)/nbeta;
|
||||
#ifdef MYROOT1
|
||||
delete heta;
|
||||
delete hhx;
|
||||
delete hhy;
|
||||
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
|
||||
delete [] heta;
|
||||
delete [] hhx;
|
||||
delete [] hhy;
|
||||
|
||||
heta=new int[nbeta*nbeta];
|
||||
hhx=new float[nbeta*nbeta];
|
||||
hhy=new float[nbeta*nbeta];
|
||||
|
||||
#endif
|
||||
// cout << nbeta << " " << etamin << " " << etamax << endl;
|
||||
};
|
||||
|
||||
eta3InterpolationBase(eta3InterpolationBase *orig): etaInterpolationBase(orig){ };
|
||||
|
||||
virtual eta3InterpolationBase* Clone()=0;
|
||||
|
||||
|
||||
|
||||
|
||||
// virtual void prepareInterpolation(int &ok){};
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//////////// /*It return position hit for the event in input */ //////////////
|
||||
virtual void getInterpolatedPosition(int x, int y, int *data, double &int_x, double &int_y)
|
||||
{
|
||||
double tot, totquad;
|
||||
double etax,etay;
|
||||
|
||||
int corner=calcEta3(data,etax,etay, totquad);
|
||||
|
||||
getInterpolatedPosition(x,y,etax,etay,corner,int_x,int_y);
|
||||
|
||||
return;
|
||||
};
|
||||
|
||||
|
||||
virtual void getInterpolatedPosition(int x, int y, double *data, double &int_x, double &int_y)
|
||||
{
|
||||
double sDum[2][2];
|
||||
double tot, totquad;
|
||||
double etax,etay;
|
||||
|
||||
int corner=calcEta3(data,etax,etay, totquad);
|
||||
|
||||
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 (nSubPixels>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 (nSubPixels>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 (nSubPixels>2) {
|
||||
|
||||
#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) {
|
||||
/* cout << etax << " " << etamin << " "; */
|
||||
/* cout << "3x*"<< ex << endl; */
|
||||
ex=0;
|
||||
}
|
||||
if (ex>=nbeta) {
|
||||
/* cout << etax << " " << etamin << " "; */
|
||||
/* cout << "3x?"<< ex << endl; */
|
||||
ex=nbeta-1;
|
||||
}
|
||||
if (ey<0) {
|
||||
/* cout << etay << " " << etamin << " "; */
|
||||
/* cout << "3y*"<< ey << endl; */
|
||||
ey=0;
|
||||
}
|
||||
if (ey>=nbeta) {
|
||||
/* cout << etay << " " << etamin << " "; */
|
||||
/* cout << "3y?"<< ey << endl; */
|
||||
ey=nbeta-1;
|
||||
|
||||
}
|
||||
xpos_eta=(((double)hhx[(ey*nbeta+ex)]));///((double)nSubPixels);
|
||||
ypos_eta=(((double)hhy[(ey*nbeta+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)/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; */
|
||||
/* float *hhx; */
|
||||
/* float *hhy; */
|
||||
/* #endif */
|
||||
/* int nbeta; */
|
||||
/* double etamin, etamax, etastep; */
|
||||
|
||||
};
|
||||
|
||||
#endif
|
@ -0,0 +1,417 @@
|
||||
#ifndef ETA_INTERPOLATION_RANDOMBINS_H
|
||||
#define ETA_INTERPOLATION_RANDOMBINS_H
|
||||
|
||||
|
||||
#include "tiffIO.h"
|
||||
//#include "etaInterpolationBase.h"
|
||||
#include "etaInterpolationPosXY.h"
|
||||
#include <cstdlib>
|
||||
#include <algorithm>
|
||||
//#include <math>
|
||||
#include <cmath> // std::abs
|
||||
|
||||
#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 ";
|
||||
|
||||
|
||||
|
||||
diff+=(p_tot-avg)*(p_tot-avg);
|
||||
|
||||
}
|
||||
// cout << "\n";
|
||||
}
|
||||
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;
|
||||
|
||||
int p0;
|
||||
int vx[(nSubPixels+1)*(nSubPixels+1)], vy[(nSubPixels+1)*(nSubPixels+1)];
|
||||
|
||||
int arrx[nSubPixels+1], arry[nSubPixels+1];
|
||||
|
||||
int bad=1;
|
||||
|
||||
|
||||
int isby, isbx;
|
||||
int ii=0;
|
||||
|
||||
|
||||
// using default comparison (operator <):
|
||||
// std::sort (myvector.begin(), myvector.begin()+4); //(12 32 45 71)26 80 53 33
|
||||
|
||||
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) {
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
sort(arrx,arrx+(nSubPixels+1)/2+1);
|
||||
sort(arry,arry+(nSubPixels+1)/2+1);
|
||||
|
||||
// cout << "*****"<< endl;
|
||||
// cout << endl;
|
||||
|
||||
for (int isbx=0; isbx<(nSubPixels+1)/2+1; isbx++) {
|
||||
vx[isby*(nSubPixels+1)+isbx]=arrx[isbx];
|
||||
vy[isbx*(nSubPixels+1)+isby]=arry[isbx];
|
||||
|
||||
|
||||
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];
|
||||
|
||||
|
||||
vx[(nSubPixels-isby)*(nSubPixels+1)+(isbx)]=arrx[isbx];
|
||||
vy[(nSubPixels-isbx)*(nSubPixels+1)+(isby)]=nbeta-arry[isbx];
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/* 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 (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);
|
||||
|
||||
if (bad==0)
|
||||
ii++;
|
||||
|
||||
bad=1;
|
||||
// break;
|
||||
}
|
||||
|
||||
}
|
||||
//if (bad) break;
|
||||
}
|
||||
// cout << "sort" << endl;
|
||||
|
||||
}
|
||||
|
||||
|
||||
cout << ii << " sub iteractions " << avg*(nSubPixels*nSubPixels)/(nbeta*nbeta) << endl;
|
||||
|
||||
double m,q;
|
||||
int in_quad;
|
||||
int p[4];
|
||||
int p1x,p2x, p1y, p2y;
|
||||
// cout << nbeta << endl;
|
||||
double angle;
|
||||
double dtheta,theta1,theta2;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
for (int ibx=0; ibx<nbeta; ibx++) {
|
||||
|
||||
for (int iby=0; iby<nbeta; iby++) {
|
||||
|
||||
in_quad=0;
|
||||
|
||||
/* 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 (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; */
|
||||
|
||||
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;
|
||||
|
||||
while (dtheta > PI)
|
||||
dtheta -= TWOPI;
|
||||
while (dtheta < -PI)
|
||||
dtheta += TWOPI;
|
||||
|
||||
angle += dtheta;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
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){};
|
||||
|
||||
etaInterpolationRandomBins(etaInterpolationRandomBins *orig): etaInterpolationPosXY(orig){};
|
||||
|
||||
virtual etaInterpolationRandomBins* Clone() {
|
||||
|
||||
return new etaInterpolationRandomBins(this);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
virtual void prepareInterpolation(int &ok)
|
||||
{
|
||||
ok=1;
|
||||
cout << "Adaptive bins" << 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;
|
||||
#ifdef SAVE_ALL
|
||||
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;
|
||||
|
||||
|
||||
|
||||
/* #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;
|
||||
|
||||
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
|
@ -429,7 +429,8 @@ int *getClusters(char *data, int *ph=NULL) {
|
||||
int ir, ic;
|
||||
|
||||
double max=0, tl=0, tr=0, bl=0,br=0, *v, vv;
|
||||
|
||||
int cm=0;
|
||||
if (cmSub) cm=1;
|
||||
if (ph==NULL)
|
||||
ph=image;
|
||||
|
||||
@ -438,6 +439,13 @@ int *getClusters(char *data, int *ph=NULL) {
|
||||
return 0;
|
||||
}
|
||||
newFrame();
|
||||
|
||||
|
||||
|
||||
if (cm)
|
||||
addToCommonMode(data);
|
||||
|
||||
|
||||
for (int ix=xmin; ix<xmax; ix++) {
|
||||
for (int iy=ymin; iy<ymax; iy++) {
|
||||
|
||||
@ -463,7 +471,7 @@ int *getClusters(char *data, int *ph=NULL) {
|
||||
for (int ic=-(clusterSize/2); ic<(clusterSize/2)+1; ic++) {
|
||||
|
||||
if ((iy+ir)>=iy && (iy+ir)<ny && (ix+ic)>=ix && (ix+ic)<nx) {
|
||||
val[iy+ir][ix+ic]=subtractPedestal(data,ix+ic,iy+ir);
|
||||
val[iy+ir][ix+ic]=subtractPedestal(data,ix+ic,iy+ir, cm);
|
||||
}
|
||||
|
||||
v=&(val[iy+ir][ix+ic]);
|
||||
@ -516,6 +524,7 @@ int *getClusters(char *data, int *ph=NULL) {
|
||||
(clusters+nph)->set_data(val[iy+ir][ix+ic],ic,ir);
|
||||
}
|
||||
}
|
||||
// cout << (clusters+nph)->iframe << " " << ix << " " << nph << " " << tot << " " << (clusters+nph)->quadTot << endl;
|
||||
nph++;
|
||||
image[iy*nx+ix]++;
|
||||
|
||||
@ -523,7 +532,7 @@ int *getClusters(char *data, int *ph=NULL) {
|
||||
eventMask[iy][ix]=PHOTON;
|
||||
}
|
||||
} else if (eventMask[iy][ix]==PEDESTAL) {
|
||||
addToPedestal(data,ix,iy);
|
||||
addToPedestal(data,ix,iy,cm);
|
||||
}
|
||||
|
||||
|
||||
|
98
slsDetectorCalibration/single_photon_hit_double.h
Normal file
98
slsDetectorCalibration/single_photon_hit_double.h
Normal file
@ -0,0 +1,98 @@
|
||||
#ifndef SINGLE_PHOTON_HIT_H
|
||||
#define SINGLE_PHOTON_HIT_H
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
|
||||
typedef double double32_t;
|
||||
typedef float float32_t;
|
||||
typedef int int32_t;
|
||||
|
||||
#ifndef DEF_QUAD
|
||||
#define DEF_QUAD
|
||||
enum quadrant {
|
||||
TOP_LEFT=0,
|
||||
TOP_RIGHT=1,
|
||||
BOTTOM_LEFT=2,
|
||||
BOTTOM_RIGHT=3,
|
||||
UNDEFINED_QUADRANT=-1
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
class single_photon_hit_double {
|
||||
|
||||
/** @short Structure for a single photon hit */
|
||||
|
||||
public:
|
||||
/** constructor, instantiates the data array -- all class elements are public!
|
||||
\param nx cluster size in x direction
|
||||
\param ny cluster size in y direction (defaults to 1 for 1D detectors)
|
||||
*/
|
||||
single_photon_hit_double(int nx=3, int ny=3): dx(nx), dy(ny) {
|
||||
data=new double[dx*dy];
|
||||
};
|
||||
|
||||
~single_photon_hit_double(){delete [] data;}; /**< destructor, deletes the data array */
|
||||
|
||||
/** binary write to file of all elements of the structure, except size of the cluster
|
||||
\param myFile file descriptor
|
||||
*/
|
||||
size_t write(FILE *myFile) {
|
||||
//fwrite((void*)this, 1, 3*sizeof(int)+4*sizeof(double)+sizeof(quad), myFile);
|
||||
if (fwrite((void*)this, 1, sizeof(int)+2*sizeof(int), myFile))
|
||||
return fwrite((void*)data, 1, dx*dy*sizeof(double), myFile);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
binary read from file of all elements of the structure, except size of the cluster. The structure is then filled with those args
|
||||
\param myFile file descriptor
|
||||
*/
|
||||
size_t read(FILE *myFile) {
|
||||
//fread((void*)this, 1, 3*sizeof(int)+4*sizeof(double)+sizeof(quad), myFile);
|
||||
|
||||
if (fread((void*)this, 1, sizeof(int)+2*sizeof(int), myFile))
|
||||
return fread((void*)data, 1, dx*dy*sizeof(double), myFile);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
assign the value to the element of the cluster matrix, with relative coordinates where the center of the cluster is (0,0)
|
||||
\param v value to be set
|
||||
\param ix coordinate x within the cluster (center is (0,0))
|
||||
\param iy coordinate y within the cluster (center is (0,0))
|
||||
*/
|
||||
void set_data(double v, int ix, int iy=0){data[(iy+dy/2)*dx+ix+dx/2]=v;};
|
||||
|
||||
void set_cluster_size(int nx, int ny) {
|
||||
|
||||
if (nx>0) dx=nx; if (ny>0) dy=ny; delete [] data; data=new double[dx*dy];
|
||||
};
|
||||
void get_cluster_size(int &nx, int &ny) {nx=dx; ny=dy;};
|
||||
void get_pixel(int &x1, int &y1) {x1=x; y1=y;};
|
||||
|
||||
/**
|
||||
gets the value to the element of the cluster matrix, with relative coordinates where the center of the cluster is (0,0)
|
||||
\param ix coordinate x within the cluster (center is (0,0))
|
||||
\param iy coordinate y within the cluster (center is (0,0))
|
||||
\returns value of the cluster element
|
||||
*/
|
||||
double get_data(int ix, int iy=0){return data[(iy+dy/2)*dx+ix+dx/2];};
|
||||
double *get_cluster() {return data;};
|
||||
|
||||
int iframe; /**< frame number */
|
||||
int x; /**< x-coordinate of the center of hit */
|
||||
int y; /**< x-coordinate of the center of hit */
|
||||
double rms; /**< noise of central pixel l -- at some point it can be removed*/
|
||||
double ped; /**< pedestal of the central pixel -- at some point it can be removed*/
|
||||
double tot; /**< sum of the 3x3 cluster */
|
||||
quadrant quad; /**< quadrant where the photon is located */
|
||||
double quadTot; /**< sum of the maximum 2x2cluster */
|
||||
int dx; /**< size of data cluster in x */
|
||||
int dy; /**< size of data cluster in y */
|
||||
double *data; /**< pointer to data */
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
93
slsDetectorCalibration/single_photon_hit_old.h
Normal file
93
slsDetectorCalibration/single_photon_hit_old.h
Normal file
@ -0,0 +1,93 @@
|
||||
#ifndef SINGLE_PHOTON_HIT_H
|
||||
#define SINGLE_PHOTON_HIT_H
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
|
||||
typedef double double32_t;
|
||||
typedef float float32_t;
|
||||
typedef int int32_t;
|
||||
|
||||
#ifndef DEF_QUAD
|
||||
#define DEF_QUAD
|
||||
enum quadrant {
|
||||
TOP_LEFT=0,
|
||||
TOP_RIGHT=1,
|
||||
BOTTOM_LEFT=2,
|
||||
BOTTOM_RIGHT=3,
|
||||
UNDEFINED_QUADRANT=-1
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
class single_photon_hit {
|
||||
|
||||
/** @short Structure for a single photon hit */
|
||||
|
||||
public:
|
||||
/** constructor, instantiates the data array -- all class elements are public!
|
||||
\param nx cluster size in x direction
|
||||
\param ny cluster size in y direction (defaults to 1 for 1D detectors)
|
||||
*/
|
||||
single_photon_hit(int nx=3, int ny=3): dx(nx), dy(ny) {data=new int[dx*dy];};
|
||||
|
||||
~single_photon_hit(){delete [] data;}; /**< destructor, deletes the data array */
|
||||
|
||||
/** binary write to file of all elements of the structure, except size of the cluster
|
||||
\param myFile file descriptor
|
||||
*/
|
||||
size_t write(FILE *myFile) {
|
||||
//fwrite((void*)this, 1, 3*sizeof(int)+4*sizeof(double)+sizeof(quad), myFile);
|
||||
if (fwrite((void*)this, 1, sizeof(int)+2*sizeof(int16_t), myFile))
|
||||
return fwrite((void*)data, 1, dx*dy*sizeof(int), myFile);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
binary read from file of all elements of the structure, except size of the cluster. The structure is then filled with those args
|
||||
\param myFile file descriptor
|
||||
*/
|
||||
size_t read(FILE *myFile) {
|
||||
//fread((void*)this, 1, 3*sizeof(int)+4*sizeof(double)+sizeof(quad), myFile);
|
||||
|
||||
if (fread((void*)this, 1, sizeof(int)+2*sizeof(int16_t), myFile))
|
||||
return fread((void*)data, 1, dx*dy*sizeof(int), myFile);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
assign the value to the element of the cluster matrix, with relative coordinates where the center of the cluster is (0,0)
|
||||
\param v value to be set
|
||||
\param ix coordinate x within the cluster (center is (0,0))
|
||||
\param iy coordinate y within the cluster (center is (0,0))
|
||||
*/
|
||||
void set_data(double v, int ix, int iy=0){data[(iy+dy/2)*dx+ix+dx/2]=v;};
|
||||
|
||||
void set_cluster_size(int nx, int ny) {if (nx>0) dx=nx; if (ny>0) dy=ny; delete [] data; data=new int[dx*dy];};
|
||||
void get_cluster_size(int &nx, int &ny) {nx=dx; ny=dy;};
|
||||
void get_pixel(int &x1, int &y1) {x1=x; y1=y;};
|
||||
|
||||
/**
|
||||
gets the value to the element of the cluster matrix, with relative coordinates where the center of the cluster is (0,0)
|
||||
\param ix coordinate x within the cluster (center is (0,0))
|
||||
\param iy coordinate y within the cluster (center is (0,0))
|
||||
\returns value of the cluster element
|
||||
*/
|
||||
double get_data(int ix, int iy=0){return data[(iy+dy/2)*dx+ix+dx/2];};
|
||||
int *get_cluster() {return data;};
|
||||
|
||||
int iframe; /**< frame number */
|
||||
int16_t x; /**< x-coordinate of the center of hit */
|
||||
int16_t y; /**< x-coordinate of the center of hit */
|
||||
double rms; /**< noise of central pixel l -- at some point it can be removed*/
|
||||
double ped; /**< pedestal of the central pixel -- at some point it can be removed*/
|
||||
double tot; /**< sum of the 3x3 cluster */
|
||||
quadrant quad; /**< quadrant where the photon is located */
|
||||
double quadTot; /**< sum of the maximum 2x2cluster */
|
||||
int dx; /**< size of data cluster in x */
|
||||
int dy; /**< size of data cluster in y */
|
||||
int *data; /**< pointer to data */
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
@ -1,9 +1,9 @@
|
||||
Path: slsDetectorsPackage/slsDetectorGui
|
||||
URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
|
||||
Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
|
||||
Repsitory UUID: b58c3e8951625ed9124669404f6b68aca340a1b8
|
||||
Revision: 491
|
||||
Repsitory UUID: ab06c33107ecfeb4741d49407903ff80286cf75b
|
||||
Revision: 492
|
||||
Branch: developer
|
||||
Last Changed Author: Dhanya_Thattil
|
||||
Last Changed Rev: 3727
|
||||
Last Changed Date: 2018-03-14 15:24:03.000000002 +0100 ./src/qTabMeasurement.cpp
|
||||
Last Changed Author: Anna_Bergamaschi
|
||||
Last Changed Rev: 3731
|
||||
Last Changed Date: 2018-03-15 12:27:06.000000002 +0100 ./src/qTabMeasurement.cpp
|
||||
|
@ -1,6 +1,6 @@
|
||||
#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
|
||||
#define GITREPUUID "b58c3e8951625ed9124669404f6b68aca340a1b8"
|
||||
#define GITAUTH "Dhanya_Thattil"
|
||||
#define GITREV 0x3727
|
||||
#define GITDATE 0x20180314
|
||||
#define GITREPUUID "ab06c33107ecfeb4741d49407903ff80286cf75b"
|
||||
#define GITAUTH "Anna_Bergamaschi"
|
||||
#define GITREV 0x3731
|
||||
#define GITDATE 0x20180315
|
||||
#define GITBRANCH "developer"
|
||||
|
@ -1,9 +1,9 @@
|
||||
Path: slsDetectorsPackage/slsDetectorSoftware
|
||||
URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
|
||||
Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
|
||||
Repsitory UUID: b58c3e8951625ed9124669404f6b68aca340a1b8
|
||||
Revision: 1842
|
||||
Repsitory UUID: ab06c33107ecfeb4741d49407903ff80286cf75b
|
||||
Revision: 1846
|
||||
Branch: developer
|
||||
Last Changed Author: Dhanya_Thattil
|
||||
Last Changed Rev: 3727
|
||||
Last Changed Date: 2018-03-14 16:10:22.000000002 +0100 ./multiSlsDetector/multiSlsDetector.cpp
|
||||
Last Changed Author: Anna_Bergamaschi
|
||||
Last Changed Rev: 3731
|
||||
Last Changed Date: 2018-03-15 12:30:34.000000002 +0100 ./threadFiles/ThreadPool.o
|
||||
|
@ -1,6 +1,6 @@
|
||||
#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
|
||||
#define GITREPUUID "b58c3e8951625ed9124669404f6b68aca340a1b8"
|
||||
#define GITAUTH "Dhanya_Thattil"
|
||||
#define GITREV 0x3727
|
||||
#define GITDATE 0x20180314
|
||||
#define GITREPUUID "ab06c33107ecfeb4741d49407903ff80286cf75b"
|
||||
#define GITAUTH "Anna_Bergamaschi"
|
||||
#define GITREV 0x3731
|
||||
#define GITDATE 0x20180315
|
||||
#define GITBRANCH "developer"
|
||||
|
@ -1,9 +1,9 @@
|
||||
Path: slsDetectorsPackage/slsReceiverSoftware
|
||||
URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
|
||||
Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
|
||||
Repsitory UUID: b58c3e8951625ed9124669404f6b68aca340a1b8
|
||||
Revision: 764
|
||||
Repsitory UUID: ab06c33107ecfeb4741d49407903ff80286cf75b
|
||||
Revision: 765
|
||||
Branch: developer
|
||||
Last Changed Author: Dhanya_Thattil
|
||||
Last Changed Rev: 3727
|
||||
Last Changed Date: 2018-03-13 10:29:32.000000002 +0100 ./src/slsReceiverTCPIPInterface.cpp
|
||||
Last Changed Author: Anna_Bergamaschi
|
||||
Last Changed Rev: 3731
|
||||
Last Changed Date: 2018-03-15 12:27:06.000000002 +0100 ./src/slsReceiverTCPIPInterface.cpp
|
||||
|
@ -1,6 +1,6 @@
|
||||
#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
|
||||
#define GITREPUUID "b58c3e8951625ed9124669404f6b68aca340a1b8"
|
||||
#define GITAUTH "Dhanya_Thattil"
|
||||
#define GITREV 0x3727
|
||||
#define GITDATE 0x20180313
|
||||
#define GITREPUUID "ab06c33107ecfeb4741d49407903ff80286cf75b"
|
||||
#define GITAUTH "Anna_Bergamaschi"
|
||||
#define GITREV 0x3731
|
||||
#define GITDATE 0x20180315
|
||||
#define GITBRANCH "developer"
|
||||
|
Loading…
x
Reference in New Issue
Block a user