Compare commits

..

29 Commits

Author SHA1 Message Date
70048a9220 added photon counter no thread 2021-03-12 08:41:48 +01:00
f11cc4a7f3 Merge branch 'moench' of https://github.com/slsdetectorgroup/slsDetectorPackage into moench 2020-07-16 12:30:30 +02:00
f99c431722 changing zmq process to allow for partial readout and fixing interpolation 2020-07-16 12:27:40 +02:00
bce4a615fa some fixes from 4.2.0 that might be important formoench 2020-06-19 13:30:56 +02:00
8747ca04f3 zmq back in 2020-06-19 13:28:54 +02:00
2afa620a97 pedestal and data structures moved from 2D to 1D array; fixed bug with the file pointer in the zmq process 2020-06-16 13:52:36 +02:00
1d9341f031 Merge branch 'moench' of https://github.com/slsdetectorgroup/slsDetectorPackage into moench 2020-06-03 10:43:53 +02:00
ab3877d9dd function to write pedestal rms and some fixes 2020-06-03 10:43:16 +02:00
2a31e921ac memory leak when running single task 2020-04-20 13:42:33 +02:00
eac02479c5 rxr bug fix: master file not created, rxr does not return 2020-04-20 11:40:21 +02:00
8096d4078c Merge branch 'moench' of https://github.com/slsdetectorgroup/slsDetectorPackage into moench 2020-04-17 17:24:01 +02:00
5710dda12a fixed mistake in moench03 data stucture when calculating xmap, ymap 2020-04-17 17:23:24 +02:00
a510010b27 rxr bug fix: master file not created, rxr does not return 2020-04-16 16:08:34 +02:00
c55d19dbfe some corrections to cluster writing 2020-04-14 17:48:04 +02:00
163eb2710f Some fixes to the offline processing - could also affect hte zmq process 2020-04-06 09:42:38 +02:00
95351d0924 fixed bug by pedestal cloning 2020-03-24 12:05:10 +01:00
ded757b40c Merge branch 'moench' of https://github.com/slsdetectorgroup/slsDetectorPackage into moench 2020-03-19 11:29:05 +01:00
8b6eb0985f one of client warnings fixed 2020-03-19 11:28:16 +01:00
14b572cdd9 Merge branch 'moench' of https://github.com/slsdetectorgroup/slsDetectorPackage into moench 2020-03-19 11:16:10 +01:00
770ca7bb96 zmq fix sprintf serveraddress 2020-03-19 11:15:49 +01:00
d551bac3f7 fixed warnings to avoid crashing 2020-03-19 11:13:56 +01:00
d43d74a92d fixed warning for fname in zmqheader 2020-03-19 10:18:37 +01:00
e61d1a1651 zmqsocket bug fix: memcpy source and destination overlap 2020-02-25 10:28:23 +01:00
63f5b52a6e jctbDetectorServer compilation flags match only for moench 2020-02-19 12:26:35 +01:00
53ba22dbc4 fixed for current rectangular sensor geometry 2020-02-18 11:37:10 +01:00
124e2a7714 now rectangular interpolation possible 2020-02-18 11:36:31 +01:00
fcd4821b8d fixed compilation problem with rectangular pixels for zmq process 2020-02-18 11:23:54 +01:00
940c8f05cd interpolation without quads 2020-01-24 15:32:48 +01:00
e4ab4547db Interpolation in both directions for rect pixels works, saving of the rectangular image is done by rebinning 2020-01-15 17:27:46 +01:00
47 changed files with 2314 additions and 1587 deletions

5
cmk.sh
View File

@ -60,6 +60,7 @@ while getopts ":bchd:j:trge" opt ; do
b)
echo "Building of CMake files Required"
REBUILD=1
CLEAN=1
;;
c)
echo "Clean Required"
@ -69,6 +70,7 @@ while getopts ":bchd:j:trge" opt ; do
echo "Building of CMake files with HDF5 option Required"
HDF5=1
REBUILD=1
CLEAN=1
;;
d)
echo "New HDF5 directory: $OPTARG"
@ -82,16 +84,19 @@ while getopts ":bchd:j:trge" opt ; do
echo "Compiling Options: Text Client"
TEXTCLIENT=1
REBUILD=1
CLEAN=1
;;
r)
echo "Compiling Options: Receiver"
RECEIVER=1
REBUILD=1
CLEAN=1
;;
g)
echo "Compiling Options: GUI"
GUI=1
REBUILD=1
CLEAN=1
;;
e)
echo "Compiling Options: Debug"

View File

@ -1,4 +1,4 @@
hostname bchip020+
hostname bchip071+
patword 0000 0000000000000000
patword 0001 0000000000000000
@ -417,18 +417,23 @@ patwaittime2 0
####mcp2011
0:rx_tcpport 1954
0:rx_udpip 10.1.1.102
0:detectorip 10.1.1.19
0:rx_udpport 32411
####gui listening to
zmqip 129.129.202.106
zmqport 50001
####data streaming out of
rx_zmqip 10.1.2.103
rx_zmqport 50003
0:rx_hostname mpc2011
#zmqip 129.129.202.86
#0:rx_udpip 10.1.2.117
#0:detectorip 10.1.2.19
#rx_zmqip 10.1.2.117
#0:rx_hostname mpc2608
zmqip 129.129.202.98
0:rx_udpip 10.1.1.102
0:detectorip 10.1.1.19
rx_zmqip 10.1.1.102
0:rx_hostname mpc2011
####pcmoench01
#0:rx_tcpport 1977
@ -478,16 +483,17 @@ adcphase 90
adcpipeline 15
adcreg 14 40
powerchip 1
vhighvoltage 90
vhighvoltage 200
period 0.005
r_discardpolicy discardpartial
frames 100
period 0.1
outdir /scratch/
outdir /mnt/moench_data/scratch/
enablefwrite 0

View File

@ -31,7 +31,7 @@ class MovingStat
*/
void Set(double val, double rms=0, int m=-1)
{
if (m>0) m_n = m; else m_n = n;
if (m>=0) m_n = m; else m_n = n;
m_newM=val*m_n;
// cout << "set " << val << " " << m << " " << m_n << " " << m_newM << endl;
SetRMS(rms);

View File

@ -67,11 +67,11 @@ template <class dataType> class analogDetector {
if (det)
det->getDetectorSize(nx,ny);
stat=new pedestalSubtraction*[ny];
stat=new pedestalSubtraction[ny*nx];
for (int i=0; i<ny; i++) {
stat[i]=new pedestalSubtraction[nx];
// stat[i]=new pedestalSubtraction[nx];
for (int ix=0; ix<nx; ix++) {
stat[i][ix].SetNPedestals(nped);
stat[i*nx+ix].SetNPedestals(nped);
}
}
image=new int[nx*ny];
@ -95,7 +95,7 @@ template <class dataType> class analogDetector {
/**
destructor. Deletes the pdestalSubtraction array and the image
*/
virtual ~analogDetector() {for (int i=0; i<ny; i++) delete [] stat[i]; delete [] stat; delete [] image;
virtual ~analogDetector() {for (int i=0; i<ny; i++) delete [] stat; delete [] image;
#ifdef ROOTSPECTRUM
delete hs;
#ifdef ROOTCLUST
@ -131,16 +131,13 @@ template <class dataType> class analogDetector {
myFile=orig->myFile;
stat=new pedestalSubtraction*[ny];
for (int i=0; i<ny; i++) {
stat[i]=new pedestalSubtraction[nx];
}
stat=new pedestalSubtraction[ny*nx];
int nped=orig->SetNPedestals();
//cout << nped << " " << orig->getPedestal(ix,iy) << orig->getPedestalRMS(ix,iy) << endl;
for (int iy=0; iy<ny; iy++) {
for (int ix=0; ix<nx; ix++) {
stat[iy][ix].SetNPedestals(nped);
stat[iy*nx+ix].SetNPedestals(nped);
setPedestal(ix,iy,orig->getPedestal(ix,iy),orig->getPedestalRMS(ix,iy),orig->GetNPedestals(ix,iy));
}
}
@ -199,7 +196,7 @@ template <class dataType> class analogDetector {
\param nns reference to number of subpixels for interpolating detector, will always be 1 in this case
\returns number of pixels of the detector image
*/
virtual int getImageSize(int &nnx, int &nny, int &nns){nnx=nx; nny=ny; nns=1; return nx*ny;};
virtual int getImageSize(int &nnx, int &nny, int &nnsx, int &nnsy){nnx=nx; nny=ny; nnsx=1; nnsy=1; return nx*ny;};
/**
Returns data size of the detector image matrix
\param nnx reference to pixel size in x
@ -226,8 +223,11 @@ template <class dataType> class analogDetector {
\returns pointer to current gain map is file reading succeeded, NULL is file reading didn't work.
*/
double *readGainMap(const char * imgname) {
uint32 nnx, nny;
float *gm=ReadFromTiff( imgname, nny, nnx);
uint32 unnx, unny;
int nnx, nny;
float *gm=ReadFromTiff( imgname, unny, unnx);
nnx=unnx;
nny=unny;
if (gm) {
if (gmap) delete [] gmap;
gmap=new double[nnx*nny];
@ -269,7 +269,7 @@ template <class dataType> class analogDetector {
iframe=-1;
for (int iy=0; iy<ny; iy++)
for (int ix=0; ix<nx; ix++) {
stat[iy][ix].Clear();
stat[iy*nx+ix].Clear();
image[iy*nx+ix]=0;
}
if (cmSub) cmSub->Clear();
@ -339,7 +339,7 @@ template <class dataType> class analogDetector {
val+=getGhost(ix,iy);
// cout << val ;
// cout << endl;
stat[iy][ix].addToPedestal(val);
stat[iy*nx+ix].addToPedestal(val);
/* if (cmSub && cm>0) { */
/* if (det) if (det->isGood(ix, iy)==0) return; */
/* cmSub->addToCommonMode(val, ix, iy); */
@ -402,9 +402,9 @@ template <class dataType> class analogDetector {
virtual double getPedestal (int ix, int iy, int cm=0){
if (ix>=0 && ix<nx && iy>=0 && iy<ny) {
if (cmSub && cm>0) {
return stat[iy][ix].getPedestal()+getCommonMode(ix,iy);
return stat[iy*nx+ix].getPedestal()+getCommonMode(ix,iy);
} else return stat[iy][ix].getPedestal();
} else return stat[iy*nx+ix].getPedestal();
} else return -1;
};
@ -423,14 +423,14 @@ template <class dataType> class analogDetector {
if (g==0) g=-1.;
}
return stat[iy][ix].getPedestalRMS()/g;//divide by gain?
return stat[iy*nx+ix].getPedestalRMS()/g;//divide by gain?
}
return -1;
};
virtual int getNumpedestals(int ix, int iy){
if (ix>=0 && ix<nx && iy>=0 && iy<ny)
return stat[iy][ix].getNumpedestals();
return stat[iy*nx+ix].getNumpedestals();
return -1;
};
/**
@ -441,11 +441,12 @@ template <class dataType> class analogDetector {
\returns pedestal value
*/
virtual double* getPedestal(double *ped){
if (ped==NULL)
if (ped==NULL) {
ped=new double[nx*ny];
}
for (int iy=0; iy<ny; iy++) {
for (int ix=0; ix<nx; ix++) {
ped[iy*nx+ix]=stat[iy][ix].getPedestal();
ped[iy*nx+ix]=stat[iy*nx+ix].getPedestal();
//cout << ped[iy*nx+ix] << " " ;
}
}
@ -459,11 +460,12 @@ template <class dataType> class analogDetector {
\returns pedestal rms
*/
virtual double* getPedestalRMS(double *ped=NULL){
if (ped==NULL)
if (ped==NULL) {
ped=new double[nx*ny];
for (int iy=0; iy<ny; iy++) {
for (int ix=0; ix<nx; ix++) {
ped[iy*nx+ix]=stat[iy][ix].getPedestalRMS();
}
for (int iy=0; iy<ny; iy++) {
for (int ix=0; ix<nx; ix++) {
ped[iy*nx+ix]=stat[iy*nx+ix].getPedestalRMS();
}
}
return ped;
@ -489,7 +491,7 @@ template <class dataType> class analogDetector {
\param rms rms to be set if any, defaults to 0
\param m number of pedestal samples to be set or the moving stat structure is any, defaults to 0
*/
virtual void setPedestal(int ix, int iy, double val, double rms=0, int m=-1){if (ix>=0 && ix<nx && iy>=0 && iy<ny) stat[iy][ix].setPedestal(val,rms, m);};
virtual void setPedestal(int ix, int iy, double val, double rms=0, int m=-1){if (ix>=0 && ix<nx && iy>=0 && iy<ny) stat[iy*nx+ix].setPedestal(val,rms, m);};
/**
sets pedestal
@ -504,8 +506,8 @@ template <class dataType> class analogDetector {
for (int iy=ymin; iy<ymax; iy++) {
for (int ix=xmin; ix<xmax; ix++) {
if (rms) rr=rms[iy*nx+ix];
stat[iy][ix].setPedestal(ped[iy*nx+ix],rr, m);
// cout << ix << " " << iy << " " << ped[iy*nx+ix] << " " << stat[iy][ix].getPedestal() << endl;
stat[iy*nx+ix].setPedestal(ped[iy*nx+ix],rr, m);
// cout << ix << " " << iy << " " << ped[iy*nx+ix] << " " << stat[iy*nx+ix].getPedestal() << endl;
};
};
@ -521,7 +523,7 @@ template <class dataType> class analogDetector {
\param iy pixel y coordinate
\param rms value to set
*/
virtual void setPedestalRMS(int ix, int iy, double rms=0){if (ix>=0 && ix<nx && iy>=0 && iy<ny) stat[iy][ix].setPedestalRMS(rms);};
virtual void setPedestalRMS(int ix, int iy, double rms=0){if (ix>=0 && ix<nx && iy>=0 && iy<ny) stat[iy*nx+ix].setPedestalRMS(rms);};
@ -533,7 +535,7 @@ template <class dataType> class analogDetector {
virtual void setPedestalRMS(double *rms){
for (int iy=ymin; iy<ymax; iy++) {
for (int ix=xmin; ix<xmax; ix++) {
stat[iy][ix].setPedestalRMS(rms[iy*nx+ix]);
stat[iy*nx+ix].setPedestalRMS(rms[iy*nx+ix]);
};
};
@ -623,9 +625,9 @@ template <class dataType> class analogDetector {
for (int iy=0; iy<ny; iy++) {
for (int ix=0; ix<nx; ix++) {
/* if (cmSub) */
/* gm[iy*nx+ix]=stat[iy][ix].getPedestal()-cmSub->getCommonMode(); */
/* gm[iy*nx+ix]=stat[iy*nx+ix].getPedestal()-cmSub->getCommonMode(); */
/* else */
gm[iy*nx+ix]=stat[iy][ix].getPedestal();
gm[iy*nx+ix]=stat[iy*nx+ix].getPedestal();
#ifdef ROOTSPECTRUM
hmap->SetBinContent(ix+1, iy+1,gm[iy*nx+ix]);
#endif
@ -669,7 +671,7 @@ template <class dataType> class analogDetector {
if (gm) {
for (int iy=0; iy<nny; iy++) {
for (int ix=0; ix<nnx; ix++) {
stat[iy][ix].setPedestal(gm[iy*nx+ix],-1,-1);
stat[iy*nx+ix].setPedestal(gm[iy*nx+ix],-1,-1);
}
}
delete [] gm;
@ -720,7 +722,7 @@ template <class dataType> class analogDetector {
gm=new float[nx*ny];
for (int iy=0; iy<ny; iy++) {
for (int ix=0; ix<nx; ix++) {
gm[iy*nx+ix]=stat[iy][ix].getPedestalRMS();
gm[iy*nx+ix]=stat[iy*nx+ix].getPedestalRMS();
}
}
ret=WriteToTiff(gm, imgname, ny, nx);
@ -742,7 +744,7 @@ template <class dataType> class analogDetector {
if (gm) {
for (int iy=0; iy<nny; iy++) {
for (int ix=0; ix<nnx; ix++) {
stat[iy][ix].setPedestalRMS(gm[iy*nx+ix]);
stat[iy*nx+ix].setPedestalRMS(gm[iy*nx+ix]);
}
}
delete [] gm;
@ -1018,7 +1020,7 @@ template <class dataType> class analogDetector {
nph=v/thr;
/* if (ix ==10 && iy<20) */
/* cout << det->getValue(data,ix,iy) << " " << stat[iy][ix].getPedestal() << " " << getCommonMode(ix,iy) << " " << getPedestal(ix,iy,0)<< " " << getPedestal(ix,iy,1) << endl; */
/* cout << det->getValue(data,ix,iy) << " " << stat[iy*nx+ix].getPedestal() << " " << getCommonMode(ix,iy) << " " << getPedestal(ix,iy,0)<< " " << getPedestal(ix,iy,1) << endl; */
// cout << subtractPedestal(data,ix,iy,0) << " " << subtractPedestal(data,ix,iy,1) << " " << nph << endl;
if (nph>0) {
//cout << " " << nph << endl;
@ -1095,8 +1097,8 @@ template <class dataType> class analogDetector {
if (i>0)
for (iy=0; iy<ny; iy++)
for (ix=0; ix<nx; ix++)
stat[iy][ix].SetNPedestals(i);
return stat[0][0].SetNPedestals();
stat[iy*nx+ix].SetNPedestals(i);
return stat[0].SetNPedestals();
};
/** gets number of samples for moving average pedestal calculation
@ -1104,7 +1106,7 @@ template <class dataType> class analogDetector {
*/
int GetNPedestals(int ix, int iy) {
if (ix>=0 && ix<nx && iy>=0 && iy<ny)
return stat[iy][ix].GetNPedestals();
return stat[iy*nx+ix].GetNPedestals();
else
return -1;
};
@ -1232,7 +1234,7 @@ FILE *getFilePointer(){return myFile;};
slsDetectorData<dataType> *det; /**< slsDetectorData to be used */
int nx; /**< Size of the detector in x direction */
int ny; /**< Size of the detector in y direction */
pedestalSubtraction **stat; /**< pedestalSubtraction class */
pedestalSubtraction *stat; /**< pedestalSubtraction class */
commonModeSubtraction *cmSub;/**< commonModeSubtraction class */
int dataSign; /**< sign of the data i.e. 1 if photon is positive, -1 if negative */
int iframe; /**< frame number (not from file but incremented within the dataset every time newFrame is called */

View File

@ -77,9 +77,9 @@ class moench03T1ReceiverDataNew : public slsDetectorData<uint16_t> {
int row, col;
int isample;
// int isample;
int iadc;
int ix, iy;
// int ix, iy;
int npackets=40;
int i;
@ -99,46 +99,46 @@ class moench03T1ReceiverDataNew : public slsDetectorData<uint16_t> {
} else {
row=200+i/sc_width;
}
dataMap[row][col]=sizeof(sls_detector_header)+(nadc*i+iadc)*2;//+16*(ip+1);
dataMap[row*nx+col]=sizeof(sls_detector_header)+(nadc*i+iadc)*2;//+16*(ip+1);
#ifdef HIGHZ
dataMask[row][col]=0x3fff;
dataMask[row*nx+col]=0x3fff;
#endif
if (dataMap[row][col]<0 || dataMap[row][col]>=nSamples*2*32)
cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl;
if (dataMap[row*nx+col]<0 || dataMap[row*nx+col]>=nSamples*2*32)
cout << "Error: pointer " << dataMap[row*nx+col] << " out of range "<< endl;
}
}
}
}
int ipacket;
int ibyte;
int ii=0;
for (ibyte=0; ibyte<sizeof(sls_detector_header)/2; ibyte++){
xmap[ibyte]=-1;
ymap[ibyte]=-1;
}
int off=sizeof(sls_detector_header)/2;
for (ipacket=0; ipacket<npackets; ipacket++) {
for (ibyte=0; ibyte< 8192/2; ibyte++) {
i=ipacket*8208/2+ibyte;
isample=ii/nadc;
if (isample<nSamples) {
iadc=ii%nadc;
adc4 = (int)iadc/4;
ix=isample%sc_width;
iy=isample/sc_width;
if (adc4%2==0) {
xmap[i+off]=adc_nr[iadc]+ix;
ymap[i+off]=ny/2-1-iy;
} else {
xmap[i+off]=adc_nr[iadc]+ix;
ymap[i+off]=ny/2+iy;
}
}
ii++;
// }
}
}
// int ipacket;
// int ibyte;
// int ii=0;
// for (ibyte=0; ibyte<sizeof(sls_detector_header)/2; ibyte++){
// xmap[ibyte]=-1;
// ymap[ibyte]=-1;
// }
// int off=sizeof(sls_detector_header)/2;
// for (ipacket=0; ipacket<npackets; ipacket++) {
// for (ibyte=0; ibyte< 8192/2; ibyte++) {
// i=ipacket*8208/2+ibyte;
// isample=ii/nadc;
// if (isample<nSamples) {
// iadc=ii%nadc;
// adc4 = (int)iadc/4;
// ix=isample%sc_width;
// iy=isample/sc_width;
// if (adc4%2==0) {
// xmap[i+off]=adc_nr[iadc]+ix;
// ymap[i+off]=ny/2-1-iy;
// } else {
// xmap[i+off]=adc_nr[iadc]+ix;
// ymap[i+off]=ny/2+iy;
// }
// }
// ii++;
// // }
// }
// }
iframe=0;
// cout << "data struct created" << endl;
@ -240,15 +240,15 @@ class moench03T1ReceiverDataNew : public slsDetectorData<uint16_t> {
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np, char *data) {
char *retval=0;
int nd;
int fnum = -1;
np=0;
int pn;
//char *retval=0;
// int nd;
//int fnum = -1;
// np=0;
// int pn;
// cout << dataSize << endl;
if (ff>=0)
fnum=ff;
// if (ff>=0)
// fnum=ff;
if (filebin.is_open()) {
if (filebin.read(data, dataSize) ){

View File

@ -60,12 +60,12 @@ class moench03T1ZmqDataNew : public slsDetectorData<uint16_t> {
} else {
row=200+i/sc_width;
}
dataMap[row][col]=(nadc*i+iadc)*2+offset;//+16*(ip+1);
dataMap[row*nx+col]=(nadc*i+iadc)*2+offset;//+16*(ip+1);
#ifdef HIGHZ
dataMask[row][col]=0x3fff;
dataMask[row*nx+col]=0x3fff;
#endif
if (dataMap[row][col]<0 || dataMap[row][col]>=dataSize)
cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl;
if (dataMap[row*nx+col]<0 || dataMap[row*nx+col]>=dataSize)
cout << "Error: pointer " << dataMap[row*nx+col] << " out of range "<< endl;
}
}
}
@ -74,8 +74,8 @@ class moench03T1ZmqDataNew : public slsDetectorData<uint16_t> {
int ii=0;
for (i=0; i< dataSize; i++) {
if (i<offset) {
for (i=0; i< dataSize/2; i++) {
if (i<offset/2) {
//header! */
xmap[i]=-1;
ymap[i]=-1;

View File

@ -46,7 +46,7 @@ class moench03T1ZmqDataNew : public slsDetectorData<uint16_t> {
int row, col;
int isample;
// int isample;
int iadc;
int ix, iy;
@ -102,7 +102,7 @@ class moench03T1ZmqDataNew : public slsDetectorData<uint16_t> {
iy=row*2;
}
#endif
dataMap[iy][ix]=pix;
dataMap[iy*nx+ix]=pix;
}
}
}

View File

@ -15,9 +15,9 @@ class slsDetectorData {
const int nx; /**< Number of pixels in the x direction */
const int ny; /**< Number of pixels in the y direction */
int dataSize; /**<size of the data constituting one frame */
int **dataMap; /**< Array of size nx*ny storing the pointers to the data in the dataset (as offset)*/
dataType **dataMask; /**< Array of size nx*ny storing the polarity of the data in the dataset (should be 0 if no inversion is required, 0xffffffff is inversion is required) */
int **dataROIMask; /**< Array of size nx*ny 1 if channel is good (or in the ROI), 0 if bad channel (or out of ROI) */
int *dataMap; /**< Array of size nx*ny storing the pointers to the data in the dataset (as offset)*/
dataType *dataMask; /**< Array of size nx*ny storing the polarity of the data in the dataset (should be 0 if no inversion is required, 0xffffffff is inversion is required) */
int *dataROIMask; /**< Array of size nx*ny 1 if channel is good (or in the ROI), 0 if bad channel (or out of ROI) */
int *xmap;
int *ymap;
@ -37,35 +37,25 @@ class slsDetectorData {
\param dROI Array of size nx*ny. The elements are 1s if the channel is good or in the ROI, 0 is bad or out of the ROI. NULL (default) means all 1s.
*/
slsDetectorData(int npx, int npy, int dsize, int **dMap=NULL, dataType **dMask=NULL, int **dROI=NULL): nx(npx), ny(npy), dataSize(dsize) {
slsDetectorData(int npx, int npy, int dsize, int *dMap=NULL, dataType *dMask=NULL, int *dROI=NULL): nx(npx), ny(npy), dataSize(dsize) {
xmap=new int[dsize/sizeof(dataType)];
ymap=new int[dsize/sizeof(dataType)];
int el=dsize/sizeof(dataType);
xmap=new int[el];
ymap=new int[el];
// if (dataMask==NULL) {
dataMask=new dataType*[ny];
for(int i = 0; i < ny; i++) {
dataMask[i] = new dataType[nx];
}
dataMask=new dataType[ny*nx];
// }
// if (dataMap==NULL) {
dataMap=new int*[ny];
for(int i = 0; i < ny; i++) {
dataMap[i] = new int[nx];
}
dataMap=new int[ny*nx];
// }
// if (dataROIMask==NULL) {
dataROIMask=new int*[ny];
for(int i = 0; i < ny; i++) {
dataROIMask[i] = new int[nx];
for (int j=0; j<nx; j++)
dataROIMask[i][j]=1;
}
dataROIMask=new int [ny*nx];
// }
for (int ip=0; ip<dsize/sizeof(dataType); ip++){
for (int ip=0; ip<el; ip++){
xmap[ip]=-1;
ymap[ip]=-1;
}
@ -77,11 +67,6 @@ class slsDetectorData {
};
virtual ~slsDetectorData() {
for(int i = 0; i < ny; i++) {
delete [] dataMap[i];
delete [] dataMask[i];
delete [] dataROIMask[i];
}
delete [] dataMap;
delete [] dataMask;
delete [] dataROIMask;
@ -94,14 +79,14 @@ class slsDetectorData {
defines the data map (as offset) - no error checking if datasize and offsets are compatible!
\param dMap array of size nx*ny storing the pointers to the data in the dataset (as offset). If NULL (default),the data are arranged as if read out row by row (dataMap[iy][ix]=(iy*nx+ix)*sizeof(dataType);)
*/
void setDataMap(int **dMap=NULL) {
void setDataMap(int *dMap=NULL) {
int ip=0;
int ix, iy;
if (dMap==NULL) {
for (iy=0; iy<ny; iy++) {
for (ix=0; ix<nx; ix++) {
dataMap[iy][ix]=(iy*nx+ix)*sizeof(dataType);
dataMap[iy*nx+ix]=(iy*nx+ix)*sizeof(dataType);
}
}
} else {
@ -109,7 +94,7 @@ class slsDetectorData {
for (iy=0; iy<ny; iy++){
// cout << iy << endl;
for (ix=0; ix<nx; ix++) {
dataMap[iy][ix]=dMap[iy][ix];
dataMap[iy*nx+ix]=dMap[iy*nx+ix];
// cout << ix << " " << iy << endl;
/*ip=dataMap[ix][iy]/sizeof(dataType);
xmap[ip]=ix;
@ -119,7 +104,7 @@ class slsDetectorData {
}
for (iy=0; iy<ny; iy++){
for (ix=0; ix<nx; ix++) {
ip=dataMap[iy][ix]/sizeof(dataType);
ip=dataMap[iy*nx+ix]/sizeof(dataType);
xmap[ip]=ix;
ymap[ip]=iy;
}
@ -135,17 +120,17 @@ class slsDetectorData {
\param dMask Array of size nx*ny storing the polarity of the data in the dataset (should be 0 if no inversion is required, 0xffffffff is inversion is required)
*/
void setDataMask(dataType **dMask=NULL){
void setDataMask(dataType *dMask=NULL){
if (dMask!=NULL) {
for (int iy=0; iy<ny; iy++)
for (int ix=0; ix<nx; ix++)
dataMask[iy][ix]=dMask[iy][ix];
dataMask[iy*nx+ix]=dMask[iy*nx+ix];
} else {
for (int iy=0; iy<ny; iy++)
for (int ix=0; ix<nx; ix++)
dataMask[iy][ix]=0;
dataMask[iy*nx+ix]=0;
}
};
/**
@ -153,18 +138,18 @@ class slsDetectorData {
\param dROI Array of size nx*ny. The lements are 1s if the channel is good or in the ROI, 0 is bad or out of the ROI. NULL (default) means all 1s.
*/
void setDataROIMask(int **dROI=NULL){
void setDataROIMask(int *dROI=NULL){
if (dROI!=NULL) {
for (int iy=0; iy<ny; iy++)
for (int ix=0; ix<nx; ix++)
dataROIMask[iy][ix]=dROI[iy][ix];
dataROIMask[iy*nx+ix]=dROI[iy*nx+ix];
} else {
for (int iy=0; iy<ny; iy++)
for (int ix=0; ix<nx; ix++)
dataROIMask[iy][ix]=1;
dataROIMask[iy*nx+ix]=1;
}
@ -178,14 +163,14 @@ class slsDetectorData {
\param i 1 if pixel is good (or in the roi), 0 if bad
\returns 1 if pixel is good, 0 if it's bad, -1 if pixel is out of range
*/
int setGood(int ix, int iy, int i=1) { if (ix>=0 && ix<nx && iy>=0 && iy<ny) dataROIMask[iy][ix]=i; return isGood(ix,iy);};
int setGood(int ix, int iy, int i=1) { if (ix>=0 && ix<nx && iy>=0 && iy<ny) dataROIMask[iy*nx+ix]=i; return isGood(ix,iy);};
/**
Define bad channel or roi mask for a single channel
\param ix channel x coordinate
\param iy channel y coordinate (1 for strips)
\returns 1 if pixel is good, 0 if it's bad, -1 if pixel is out of range
*/
int isGood(int ix, int iy) { if (ix>=0 && ix<nx && iy>=0 && iy<ny) return dataROIMask[iy][ix]; else return -1;};
int isGood(int ix, int iy) { if (ix>=0 && ix<nx && iy>=0 && iy<ny) return dataROIMask[iy*nx+ix]; else return -1;};
/**
Returns detector size in x,y
@ -204,38 +189,33 @@ class slsDetectorData {
virtual void getPixel(int ip, int &x, int &y) {x=xmap[ip]; y=ymap[ip];};
virtual dataType **getData(char *ptr, int dsize=-1) {
dataType **data;
virtual dataType *getData(char *ptr, int dsize=-1) {
int el=dsize/sizeof(dataType);
dataType *data;
int ix,iy;
data=new dataType*[ny];
for(int i = 0; i < ny; i++) {
data[i]=new dataType[nx];
}
data=new dataType[ny*nx];
if (dsize<=0 || dsize>dataSize) dsize=dataSize;
for (int ip=0; ip<(dsize/sizeof(dataType)); ip++) {
for (int ip=0; ip<(el); ip++) {
getPixel(ip,ix,iy);
if (ix>=0 && ix<nx && iy>=0 && iy<ny) {
data[iy][ix]=getChannel(ptr,ix,iy);
data[iy*nx+ix]=getChannel(ptr,ix,iy);
}
}
return data;
};
virtual double **getImage(char *ptr, int dsize=-1) {
virtual double *getImage(char *ptr, int dsize=-1) {
double **data;
double *data;
int ix,iy;
data=new double*[ny];
for(int i = 0; i < ny; i++) {
data[i]=new double[nx];
}
data=new double[ny*nx];
int el=dsize/sizeof(dataType);
if (dsize<=0 || dsize>dataSize) dsize=dataSize;
for (int ip=0; ip<(dsize/sizeof(dataType)); ip++) {
for (int ip=0; ip<el; ip++) {
getPixel(ip,ix,iy);
if (ix>=0 && ix<nx && iy>=0 && iy<ny) {
data[iy][ix]=getValue(ptr,ix,iy);
data[iy*nx+ix]=getValue(ptr,ix,iy);
}
}
return data;
@ -251,12 +231,13 @@ class slsDetectorData {
*/
virtual dataType getChannel(char *data, int ix, int iy=0) {
dataType m=0, d=0;
if (ix>=0 && ix<nx && iy>=0 && iy<ny && dataMap[iy][ix]>=0 && dataMap[iy][ix]<dataSize) {
dataType m=0, d=0, *p;
if (ix>=0 && ix<nx && iy>=0 && iy<ny && dataMap[iy*nx+ix]>=0 && dataMap[iy*nx+ix]<dataSize) {
// cout << ix << " " << iy << " " ;
//cout << dataMap[ix][iy] << " " << (void*)data << " " << dataSize<< endl;
m=dataMask[iy][ix];
d=*((dataType*)(data+dataMap[iy][ix]));
m=dataMask[iy*nx+ix];
p=(dataType*)(data+dataMap[iy*nx+ix]);
d=*p;
}
return d^m;
};

View File

@ -13,7 +13,7 @@ template <class dataType> class ghostSummation {
/** constructor
\param xt crosstalk
*/
ghostSummation(slsDetectorData<dataType> *d, double xt) : xtalk(xt),det(d) {
ghostSummation(slsDetectorData<dataType> *d, double xt) : xtalk(xt),det(d), nx(1), ny(1) {
if (det)
det->getDetectorSize(nx,ny);
ghost=new double[nx*ny];
@ -22,6 +22,9 @@ template <class dataType> class ghostSummation {
ghostSummation(ghostSummation *orig) {
xtalk=orig->xtalk;
det=orig->det;
nx=1;
ny=1;
det->getDetectorSize(nx,ny);
ghost=new double[nx*ny];
}

View File

@ -50,7 +50,12 @@ class interpolatingDetector : public singlePhotonDetector {
singlePhotonDetector(d, 3,nsigma,sign, cm, nped, nd, nnx, nny, gm, gs) , interp(inte), id(0) {
//cout << "**"<< xmin << " " << xmax << " " << ymin << " " << ymax << endl;
fi=new pthread_mutex_t ;
if (pthread_mutex_init(fi, NULL) != 0)
{
printf("\n mutex init failed\n");
}
};
@ -107,11 +112,11 @@ class interpolatingDetector : public singlePhotonDetector {
singlePhotonDetector::clearImage();
};
int getImageSize(int &nnx, int &nny, int &ns) {
int getImageSize(int &nnx, int &nny, int &nsx, int &nsy) {
if (interp)
return interp->getImageSize(nnx, nny, ns);
return interp->getImageSize(nnx, nny, nsx, nsy);
else
return analogDetector<uint16_t>::getImageSize(nnx, nny, ns);
return analogDetector<uint16_t>::getImageSize(nnx, nny, nsx, nsy);
};
@ -251,6 +256,7 @@ int addFrame(char *data, int *ph=NULL, int ff=0) {
}
virtual int getNSubPixels(){ if (interp) return interp->getNSubPixels(); else return 1;}
virtual int setNSubPixels(int ns) {
if (interp) {
pthread_mutex_lock(fi);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -94,7 +94,10 @@ class slsInterpolation
//create interpolated image
//returns interpolated image
virtual int *getInterpolatedImage(){
//cout << "?" <<endl;
// cout << "return interpolated image " << endl;
/* for (int i=0; i<nSubPixels* nSubPixels* nPixelsX*nPixelsY; i++) { */
/* cout << i << " " << hint[i] << endl; */
/* } */
return hint;
};
@ -102,21 +105,17 @@ class slsInterpolation
void *writeInterpolatedImage(const char * imgname) {
float *gm=NULL;
//cout << "!" <<endl;
float *gm=NULL;
int *dummy=getInterpolatedImage();
cout << "got interpolated image " << endl;
gm=new float[ nSubPixelsX* nSubPixelsY* nPixelsX*nPixelsY];
cout << "created dummy " << endl;
if (gm) {
for (int ix=0; ix<nPixelsX*nSubPixelsX; ix++) {
for (int iy=0; iy<nPixelsY*nSubPixelsY; iy++) {
gm[iy*nPixelsX*nSubPixelsX+ix]=dummy[iy*nPixelsX*nSubPixelsX+ix];
// cout << "++" << ix << " " << iy << " " << iy*nPixelsX*nSubPixelsX+ix << endl;
}
}
WriteToTiff(gm, imgname,nSubPixelsX* nPixelsX ,nSubPixelsY* nPixelsY);
// cout << "wrote to tiff " << endl;
WriteToTiff(gm, imgname,nSubPixelsY* nPixelsX ,nSubPixelsY* nPixelsY);
delete [] gm;
} else cout << "Could not allocate float image " << endl;
return NULL;
@ -173,7 +172,7 @@ class slsInterpolation
virtual int *setFlatField(int *h, int nb=-1, double emin=-1, double emax=-1){return NULL;};
virtual void *writeFlatField(const char * imgname){return NULL;};
virtual void *readFlatField(const char * imgname, int nb=-1, double emin=1, double emax=0){return NULL;};
virtual int *getFlatField(int &nb, double &emin, double &emax){nb=0; emin=0; emax=0; return getFlatField();};
virtual int *getFlatField(int &nb, int &nby, double &emin, double &emax){nb=0; nby=0; emin=0; emax=0; return getFlatField();};
virtual void resetFlatField()=0;
@ -189,7 +188,6 @@ class slsInterpolation
static int calcQuad(double *cl, double &sum, double &totquad, double sDum[2][2]){
//cout << "2";
int corner = UNDEFINED_QUADRANT;
/* double *cluster[3]; */
@ -198,11 +196,12 @@ class slsInterpolation
/* cluster[2]=cl+6; */
sum=0;
int xoff=0, yoff=0;
#ifndef WRITE_QUAD
double sumBL=0;
double sumTL=0;
double sumBR=0;
double sumTR=0;
int xoff=0, yoff=0;
for (int ix=0; ix<3; ix++) {
for (int iy=0; iy<3; iy++) {
sum+=cl[ix+3*iy];
@ -222,34 +221,95 @@ class slsInterpolation
if(sumTL >= totquad){
/* sDum[0][0] = cluster[1][0]; sDum[1][0] = cluster[2][0]; */
/* sDum[0][1] = cluster[1][1]; sDum[1][1] = cluster[2][1]; */
/* #ifdef WRITE_QUAD */
/* /\* sDum[0][0] = cluster[1][0]; sDum[1][0] = cluster[2][0]; *\/ */
/* /\* sDum[0][1] = cluster[1][1]; sDum[1][1] = cluster[2][1]; *\/ */
/* if (sumTL ==sum) { */
/* #endif */
corner = TOP_LEFT;
totquad=sumTL;
xoff=0;
yoff=1;
/* #ifdef WRITE_QUAD */
/* } */
/* #endif */
}
if(sumBR >= totquad){
/* sDum[0][0] = cluster[0][1]; sDum[1][0] = cluster[1][1]; */
/* sDum[0][1] = cluster[0][2]; sDum[1][1] = cluster[1][2]; */
/* #ifdef WRITE_QUAD */
/* /\* sDum[0][0] = cluster[1][0]; sDum[1][0] = cluster[2][0]; *\/ */
/* /\* sDum[0][1] = cluster[1][1]; sDum[1][1] = cluster[2][1]; *\/ */
/* if (sumBR ==sum) { */
/* #endif */
corner = BOTTOM_RIGHT;
xoff=1;
yoff=0;
corner = BOTTOM_RIGHT;
totquad=sumBR;
/* #ifdef WRITE_QUAD */
/* } */
/* #endif */
}
if(sumTR >= totquad){
/* #ifdef WRITE_QUAD */
/* /\* sDum[0][0] = cluster[1][0]; sDum[1][0] = cluster[2][0]; *\/ */
/* /\* sDum[0][1] = cluster[1][1]; sDum[1][1] = cluster[2][1]; *\/ */
/* if (sumTR ==sum) { */
/* #endif */
xoff=1;
yoff=1;
/* sDum[0][0] = cluster[1][1]; sDum[1][0] = cluster[2][1]; */
/* sDum[0][1] = cluster[1][2]; sDum[1][1] = cluster[2][2]; */
corner = TOP_RIGHT;
totquad=sumTR;
/* #ifdef WRITE_QUAD */
/* } */
/* #endif */
}
#endif
#ifdef WRITE_QUAD
double sumB=0;
double sumT=0;
double sumR=0;
double sumL=0;
for (int ix=0; ix<3; ix++) {
for (int iy=0; iy<3; iy++) {
sum+=cl[ix+3*iy];
if (ix<1 ) sumL+=cl[ix+iy*3];
if (ix>1) sumR+=cl[ix+iy*3];
if (iy<1) sumB=cl[ix+iy*3];
if (iy>1) sumT+=cl[ix+iy*3];
}
}
totquad=sum;
if ( sumT==0 && sumR==0) {
corner = BOTTOM_LEFT;
xoff=0;
yoff=0;
} else if ( sumB==0 && sumR==0 ) {
corner = TOP_LEFT;
xoff=0;
yoff=1;
} else if ( sumT==0 && sumL==0) {
corner = BOTTOM_RIGHT;
xoff=1;
yoff=0;
} else if ( sumB==0 && sumL==0) {
xoff=1;
yoff=1;
corner = TOP_RIGHT;
} else
printf("** bad 2x2 cluster!\n");
#endif
for (int ix=0; ix<2; ix++) {
for (int iy=0; iy<2; iy++) {
@ -370,7 +430,6 @@ class slsInterpolation
static int calcEta3(double *cl, double &etax, double &etay, double &sum) {
// cout << "3";
double l=0,r=0,t=0,b=0, val;
sum=0;
// int quad;
@ -378,10 +437,10 @@ class slsInterpolation
for (int iy=0; iy<3; iy++) {
val=cl[ix+3*iy];
sum+=val;
if (ix==0) l+=val;
if (ix==2) r+=val;
if (iy==0) b+=val;
if (iy==2) t+=val;
if (iy==0) l+=val;
if (iy==2) r+=val;
if (ix==0) b+=val;
if (ix==2) t+=val;
}
}
if (sum>0) {

View File

@ -1,12 +1,14 @@
#module add CBFlib/0.9.5
INCDIR=-I. -I../ -I../interpolations -I../interpolations/etaVEL -I../dataStructures -I../../slsSupportLib/include/ -I../../slsReceiverSoftware/include/
LDFLAG= ../tiffIO.cpp -L/usr/lib64/ -lpthread -lm -lstdc++ -pthread -lrt -ltiff -O3 -std=c++11
INCDIR=-I. -I../ -I../interpolations -I../interpolations/etaVEL -I../dataStructures -I../../slsReceiverSoftware/include/
LDFLAG= ../tiffIO.cpp -L/usr/lib64/ -lpthread -lm -lstdc++ -pthread -lrt -ltiff -std=c++11 -Wall -O3
#-g3
#-fsanitize=thread -fno-omit-frame-pointer
#-fsanitize=address,undefined,
MAIN=moench03ClusterFinder.cpp
all: moenchClusterFinder moenchMakeEta moenchInterpolation moenchNoInterpolation moenchPhotonCounter moenchAnalog
all: moenchClusterFinder moenchMakeEta moenchMakeEta3 moenchInterpolation moenchInterpolation3 moenchNoInterpolation moenchPhotonCounter moenchAnalog moenchPhotonCounterNoThread moenchAnalogNoThread
@ -23,9 +25,15 @@ moenchClusterFinderHighZ: moench03ClusterFinder.cpp $(INCS) clean
moenchMakeEta: moench03Interpolation.cpp $(INCS) clean
g++ -o moenchMakeEta moench03Interpolation.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DFF
moenchMakeEta3: moench03Interpolation.cpp $(INCS) clean
g++ -o moenchMakeEta3 moench03Interpolation.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DFF -DETA3
moenchInterpolation: moench03Interpolation.cpp $(INCS) clean
g++ -o moenchInterpolation moench03Interpolation.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF)
moenchInterpolation3: moench03Interpolation.cpp $(INCS) clean
g++ -o moenchInterpolation3 moench03Interpolation.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DETA3
moenchNoInterpolation: moench03NoInterpolation.cpp $(INCS) clean
g++ -o moenchNoInterpolation moench03NoInterpolation.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF)
@ -41,7 +49,13 @@ moenchPhotonCounterHighZ: moenchPhotonCounter.cpp $(INCS) clean
moenchAnalogHighZ: moenchPhotonCounter.cpp $(INCS) clean
g++ -o moenchAnalogHighZ moenchPhotonCounter.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWRECEIVER -DANALOG -DHIGHZ
moenchAnalogNoThread : moenchPhotonCounterNoThread.cpp $(INCS) clean
g++ -o moenchAnalogNoThread moenchPhotonCounterNoThread.cpp $(LDFLAG) $(INCDIR) -DNEWRECEIVER -DANALOG
moenchPhotonCounterNoThread : moenchPhotonCounterNoThread.cpp $(INCS) clean
g++ -o moenchPhotonCounterNoThread moenchPhotonCounterNoThread.cpp $(LDFLAG) $(INCDIR) $ -DNEWRECEIVER
clean:
rm -f moenchClusterFinder moenchMakeEta moenchInterpolation moenchNoInterpolation moenchPhotonCounter moenchAnalog
rm -f moenchClusterFinder moenchMakeEta moenchInterpolation moenchNoInterpolation moenchPhotonCounter moenchAnalog moenchPhotonCounterNoThread moenchAnalogNoThread

View File

@ -12,12 +12,12 @@ MAIN=moench03ClusterFinder.cpp
#-lhdf5
#DESTDIR?=../bin
all: moenchClusterFinderRect moenchMakeEtaRect moenchInterpolationRect moenchNoInterpolationRect moenchPhotonCounterRect moenchAnalogRect
all: moenchClusterFinderRect moenchMakeEtaRect moenchInterpolationRect moenchNoInterpolationRect moenchPhotonCounterRect moenchAnalogRect moenchMakeEtaRect1 moenchInterpolationRect1
moenchClusterFinderRect: moench03ClusterFinder.cpp $(INCS) clean
g++ -o moenchClusterFinderRect moench03ClusterFinder.cpp $(LDFLAG) $(INCDIR) -DSAVE_ALL -DNEWRECEIVER -DRECT
g++ -o moenchClusterFinderRect moench03ClusterFinder.cpp $(LDFLAG) $(INCDIR) -DSAVE_ALL -DNEWRECEIVER -DRECT
moenchMakeEtaRect: moench03Interpolation.cpp $(INCS) clean
g++ -o moenchMakeEtaRect moench03Interpolation.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DFF -DRECT
@ -34,6 +34,12 @@ moenchPhotonCounterRect: moenchPhotonCounter.cpp $(INCS) clean
moenchAnalogRect: moenchPhotonCounter.cpp $(INCS) clean
g++ -o moenchAnalogRect moenchPhotonCounter.cpp $(LDFLAG) $(INCDIR) -DNEWRECEIVER -DANALOG -DRECT
moenchMakeEtaRect1: moench03Interpolation.cpp $(INCS) clean
g++ -o moenchMakeEtaRect1 moench03Interpolation.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DFF -DRECT -DRECT1
moenchInterpolationRect1: moench03Interpolation.cpp $(INCS) clean
g++ -o moenchInterpolationRect1 moench03Interpolation.cpp $(LDFLAG) $(INCDIR) -DRECT -DRECT1
clean:
rm -f moenchClusterFinderRect moenchMakeEtaRect moenchInterpolationRect moenchNoInterpolationRect moenchPhotonCounterRect moenchAnalogRect

View File

@ -1,40 +0,0 @@
#CBFLIBDIR= /afs/psi.ch/project/sls_det_software/CBFlib-0.9.5/
#ZMQLIB=../slsReceiverSoftware/include
#LIBRARYCBF=$(CBFLIBDIR)/lib/*.o
INCDIR=-I. -I../ -I../interpolations -I../interpolations/etaVEL -I../dataStructures -I../../slsReceiverSoftware/include
#-I$(CBFLIBDIR)/include/
#LIBHDF5=
LDFLAG= ../tiffIO.cpp -L/usr/lib64/ -lpthread -lm -lstdc++ -L. -pthread -lrt -ltiff
#-L$(ZMQLIB) -lzmq -L$(CBFLIBDIR)/lib/
#-L../../bin
MAIN=moench03ClusterFinder.cpp
#-lhdf5
#DESTDIR?=../bin
all: moenchClusterFinder moenchMakeEta moenchInterpolation moenchNoInterpolation moenchPhotonCounter moenchAnalog
moenchClusterFinder : moench03ClusterFinder.cpp $(INCS) clean
g++ -o moenchClusterFinder moench03ClusterFinder.cpp $(LDFLAG) $(INCDIR) -DSAVE_ALL -DNEWRECEIVER -DWRITE_QUAD
moenchMakeEta : moench03Interpolation.cpp $(INCS) clean
g++ -o moenchMakeEta moench03Interpolation.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DFF -DWRITE_QUAD
moenchInterpolation : moench03Interpolation.cpp $(INCS) clean
g++ -o moenchInterpolation moench03Interpolation.cpp $(LDFLAG) $(INCDIR) -DWRITE_QUAD
moenchNoInterpolation : moench03NoInterpolation.cpp $(INCS) clean
g++ -o moenchNoInterpolation moench03NoInterpolation.cpp $(LDFLAG) $(INCDIR) -DWRITE_QUAD
moenchPhotonCounter : moenchPhotonCounter.cpp $(INCS) clean
g++ -o moenchPhotonCounter moenchPhotonCounter.cpp $(LDFLAG) $(INCDIR) $ -DNEWRECEIVER -DWRITE_QUAD
moenchAnalog : moenchPhotonCounter.cpp $(INCS) clean
g++ -o moenchAnalog moenchPhotonCounter.cpp $(LDFLAG) $(INCDIR) -DNEWRECEIVER -DANALOG -DWRITE_QUAD
clean:
rm -f moenchClusterFinder moenchMakeEta moenchInterpolation moenchNoInterpolation moenchPhotonCounter moenchAnalog

View File

@ -1,6 +1,7 @@
//#include "ansi.h"
#include <iostream>
// bin/moenchClusterFinder moench03_25022020 moench_fluo_outputs flat_27keV_d0_f000000%d00000_1 0 10
//#include "moench03T1ZmqData.h"
#ifdef NEWRECEIVER
@ -33,7 +34,9 @@
#include "multiThreadedAnalogDetector.h"
#include "singlePhotonDetector.h"
//#include "interpolatingDetector.h"
#include <string>
#include <sstream>
#include <stdio.h>
#include <map>
#include <fstream>
@ -50,20 +53,20 @@ int main(int argc, char *argv[]) {
cout << "Usage is " << argv[0] << "indir outdir fname runmin runmax " << endl;
return 1;
}
int p=10000;
//int p=10000;
int fifosize=1000;
int nthreads=1;
int nsubpix=25;
int etabins=nsubpix*10;
double etamin=-1, etamax=2;
int nthreads=16;
//int nsubpix=25;
//int etabins=nsubpix*10;
//double etamin=-1, etamax=2;
int csize=3;
int nx=400, ny=400;
int save=1;
int nsigma=1;
//int save=1;
int nsigma=5;
int nped=1000;
int ndark=100;
int ok;
int iprog=0;
//int ndark=100;
//int ok;
//int iprog=0;
@ -108,9 +111,9 @@ int main(int argc, char *argv[]) {
// cout << "filter "<< endl;
int size = 327680;////atoi(argv[3]);
//int size = 327680;////atoi(argv[3]);
int* image;
//int* image;
//int* image =new int[327680/sizeof(int)];
filter->newDataSet();
@ -120,21 +123,21 @@ int main(int argc, char *argv[]) {
cout << " data size is " << dsize;
char data[dsize];
//char data[dsize];
ifstream filebin;
char *indir=argv[1];
char *outdir=argv[2];
char *fformat=argv[3];
string indir=string(argv[1]);
string outdir=string(argv[2]);
string fformat=string(argv[3]);
int runmin=atoi(argv[4]);
int runmax=atoi(argv[5]);
char fname[10000];
char outfname[10000];
char imgfname[10000];
char pedfname[10000];
string fname;
string outfname;
string imgfname;
//char pedfname[10000];
// strcpy(pedfname,argv[6]);
char fn[10000];
char fn[10000];
std::time_t end_time;
@ -148,12 +151,6 @@ int main(int argc, char *argv[]) {
cout << std::ctime(&end_time) << endl;
char* buff;
multiThreadedAnalogDetector *mt=new multiThreadedAnalogDetector(filter,nthreads,fifosize);
@ -170,17 +167,26 @@ int main(int argc, char *argv[]) {
for (int irun=runmin; irun<runmax; irun++) {
sprintf(fn,fformat,irun);
sprintf(fname,"%s/%s.raw",indir,fn);
sprintf(outfname,"%s/%s.clust",outdir,fn);
sprintf(imgfname,"%s/%s.tiff",outdir,fn);
sprintf(fn,fformat.c_str(),irun);
fname=indir+"/"+string(fn)+".raw";
//sprintf(fname,"%s/%s.raw",indir,fn);
#ifndef WRITE_QUAD
outfname=outdir+string(fn)+".clust";
//sprintf(outfname,"%s/%s.clust",outdir,fn);
#endif
#ifdef WRITE_QUAD
outfname=outdir+string(fn)+".clust2";
// sprintf(outfname,"%s/%s.clust2",outdir,fn);
#endif
imgfname=outdir+string(fn)+".tiff";
//sprintf(imgfname,"%s/%s.tiff",outdir,fn);
std::time(&end_time);
cout << std::ctime(&end_time) << endl;
cout << fname << " " << outfname << " " << imgfname << endl;
filebin.open((const char *)(fname), ios::in | ios::binary);
filebin.open(fname.c_str(), ios::in | ios::binary);
// //open file
if (filebin.is_open()){
of=fopen(outfname,"w");
of=fopen(outfname.c_str(),"w");
if (of) {
mt->setFilePointer(of);
// cout << "file pointer set " << endl;
@ -212,7 +218,7 @@ int main(int argc, char *argv[]) {
}
ff=-1;
}
cout << "--" << endl;
cout << "--" << endl;
filebin.close();
// //close file
// //join threads
@ -220,7 +226,7 @@ int main(int argc, char *argv[]) {
if (of)
fclose(of);
mt->writeImage(imgfname);
mt->writeImage(imgfname.c_str());
mt->clearImage();
std::time(&end_time);

View File

@ -5,7 +5,7 @@
//#include "moench03T1ZmqData.h"
//#define DOUBLE_SPH
//#define MANYFILES
//#define WRITE_QUAD
#ifdef DOUBLE_SPH
#include "single_photon_hit_double.h"
#endif
@ -14,12 +14,7 @@
#include "single_photon_hit.h"
#endif
#ifdef RECT
#include "etaInterpolationGlobal.h"
#endif
#ifndef RECT
#include "etaInterpolationPosXY.h"
#endif
#include "noInterpolation.h"
//#include "etaInterpolationCleverAdaptiveBins.h"
//#include "etaInterpolationRandomBins.h"
@ -41,7 +36,6 @@ using namespace std;
int main(int argc, char *argv[]) {
#ifndef FF
cout << "INTERPOLATING" << endl;
if (argc<9) {
cout << "Wrong usage! Should be: "<< argv[0] << " infile etafile outfile runmin runmax ns cmin cmax" << endl;
return 1;
@ -49,7 +43,6 @@ int main(int argc, char *argv[]) {
#endif
#ifdef FF
cout << "CALC ETA" << endl;
if (argc<7) {
cout << "Wrong usage! Should be: "<< argv[0] << " infile etafile runmin runmax cmin cmax" << endl;
return 1;
@ -57,9 +50,9 @@ int main(int argc, char *argv[]) {
#endif
int iarg=4;
char infname[10000];
char fname[10000];
char outfname[10000];
#ifndef FF
char fname[10000];
iarg=4;
#endif
@ -81,26 +74,42 @@ int main(int argc, char *argv[]) {
cout << "Energy min: " << cmin << endl;
cout << "Energy max: " << cmax << endl;
//int etabins=500;
int etabins=999;//nsubpix*2*100;
#ifndef NOINTERPOLATION
int etabins=1000;//nsubpix*2*100;
int etabinsY=etabins;//nsubpix*2*100;
double etamin=0, etamax=1;
double etamin=-1, etamax=2;
//double etamin=-0.1, etamax=1.1;
double eta3min=-1, eta3max=1;
double etax=0, etay=0;
#ifndef FF
double int_x, int_y;
// double d_x, d_y, res=5, xx, yy;
int ok;
#endif
#ifdef ETA3
etamin=-2;
etamax=2;
#endif
#endif
//#ifndef FF
int quad;
//#endif
double sum, totquad;
double sDum[2][2];
double etax, etay, int_x, int_y;
double eta3x, eta3y, int3_x, int3_y, noint_x, noint_y;
int ok;
#ifdef NOINTERPOLATION
#ifndef FF
double noint_x, noint_y;
#endif
#endif
int f0=-1;
int ix, iy, isx, isy;
int nframes=0, lastframe=-1;
double d_x, d_y, res=5, xx, yy;
int nph=0, badph=0, totph=0;
FILE *f=NULL;
char fff[10000];
//badph=0,
int nph=0, totph=0;
FILE *f=NULL;
#ifdef DOUBLE_SPH
single_photon_hit_double cl(3,3);
@ -111,24 +120,23 @@ int main(int argc, char *argv[]) {
#endif
int nSubPixels=nsubpix;
int nSubPixelsY=nsubpix;
#ifdef RECT
nSubPixels=5; //might make more sense using 2?
// etabins=5;
#ifdef RECT1
// nSubPixels=2; //might make more sense using 2?
// etabins=100;
float *rectimg=new float[NC*NR*nSubPixelsY];;
#endif
// #endif
#ifndef NOINTERPOLATION
etaInterpolationBase *interp;
#ifndef RECT
interp=new eta2InterpolationPosXY(NC, NR, nSubPixels, nSubPixelsY, etabins, etabinsY, etamin, etamax);
//eta2InterpolationCleverAdaptiveBins *interp=new eta2InterpolationCleverAdaptiveBins(NC, NR, nsubpix, etabins, etamin, etamax);
#ifndef ETA3
eta2InterpolationPosXY *interp=new eta2InterpolationPosXY(NC, NR, nSubPixels, nSubPixelsY, etabins, etabinsY, etamin, etamax);
#endif
#ifdef RECT
interp=new eta2InterpolationGlobal(NC, NR, nSubPixels, nSubPixelsY, etabins, etabinsY, eta3min, eta3max);
// eta3InterpolationPosXY *interpOdd=new eta3InterpolationPosXY(NC, NR, nSubPixels, nSubPixelsY, etabins, etabinsY, eta3min, eta3max);
//eta2InterpolationCleverAdaptiveBins *interp=new eta2InterpolationCleverAdaptiveBins(NC, NR, nsubpix, etabins, etamin, etamax);
#ifdef ETA3
eta3InterpolationPosXY *interp=new eta3InterpolationPosXY(NC, NR, nSubPixels, nSubPixelsY, etabins, etabinsY, etamin, etamax);
#endif
//eta2InterpolationCleverAdaptiveBins *interp=new eta2InterpolationCleverAdaptiveBins(NC, NR, nsubpix, etabins, etamin, etamax);
#endif
#ifdef NOINTERPOLATION
noInterpolation *interp=new noInterpolation(NC, NR, nsubpix, nSubPixelsY);
@ -137,24 +145,12 @@ int main(int argc, char *argv[]) {
#ifndef FF
int *img;
#ifndef NOINTERPOLATION
cout << "read ff " << argv[2] << endl;
sprintf(fname,"%s",argv[2]);
//#ifndef RECT
interp->readFlatField(fname, etamin, etamax);
interp->prepareInterpolation(ok);//, MAX_ITERATIONS);
interp->debugSaveAll(0);
//#endif
// #ifdef RECT
// sprintf(fff,"%s.even",fname);
// interpEven->readFlatField(fff, etamin, etamax);
// interpEven->prepareInterpolation(ok);, MAX_ITERATIONS);
// interpEven->debugSaveAll(1);
// sprintf(fff,"%s.odd",fname);
// interpOdd->readFlatField(fff, etamin, etamax);
// interpOdd->prepareInterpolation(ok);, MAX_ITERATIONS);
// interpOdd->debugSaveAll(2);
// #endif
#endif
// return 0;
#endif
@ -162,7 +158,6 @@ int main(int argc, char *argv[]) {
cout << "Will write eta file " << argv[2] << endl;
#endif
int *img;
float *totimg=new float[NC*NR*nSubPixels*nSubPixelsY];
for (ix=0; ix<NC; ix++) {
for (iy=0; iy<NR; iy++) {
@ -177,9 +172,6 @@ int main(int argc, char *argv[]) {
#ifdef FF
sprintf(outfname,argv[2]);
#endif
int tl=0, tr=0, bl=0, br=0;
int irun;
for (irun=runmin; irun<runmax; irun++) {
@ -201,80 +193,76 @@ int main(int argc, char *argv[]) {
if (nframes==0) f0=lastframe;
nframes++;
}
#ifdef RECT
// quad=interp->calcEta3(cl.get_cluster(), etax, etay, sum);
//#ifndef FF
#ifndef ETA3
quad=interp->calcEta(cl.get_cluster(), etax, etay, sum, totquad, sDum);
// if (cl.y%2==0)
// if (etay>0)
// interp=interpEven;
// else
// interp=interpOdd;
// else
// if (etay>0)
// interp=interpOdd;
// else
// interp=interpEven;
#endif
#ifdef ETA3
quad=interp->calcEta3(cl.get_cluster(), etax, etay, sum);
totquad=sum;
#endif
//#endif
// #ifdef FF
// #ifndef ETA3
// interp->calcEta(cl.get_cluster(), etax, etay, sum, totquad, sDum);
// #endif
// #endif
#endif
#ifndef RECT
quad=interp->calcEta(cl.get_cluster(), etax, etay, sum, totquad, sDum);
#endif
switch(quad) {
case TOP_LEFT:
tl++;
break;
case TOP_RIGHT:
tr++;
break;
case BOTTOM_LEFT:
bl++;
break;
case BOTTOM_RIGHT:
br++;
break;
}
// if (sum>cmin && totquad/sum>0.8 && totquad/sum<1.2 && sum<cmax ) {
if (sum>cmin && sum<cmax ) {
if (sum>cmin && totquad/sum>0.8 && totquad/sum<1.2 && sum<cmax ) {
nph++;
#ifndef FF
// if (sum>200 && sum<580) {
// interp->getInterpolatedPosition(cl.x,cl.y, totquad,quad,cl.get_cluster(),int_x, int_y);
// #ifdef SOLEIL
// if (cl.x>210 && cl.x<240 && cl.y>210 && cl.y<240) {
// #endif
if (cl.x<0 || cl.y<0 || cl.x>NC || cl.y>NR) {
if (cl.x<-1 || cl.y<-1 || cl.x>NC+1 || cl.y>NR+1) {
cout <<"**************"<< endl;
cout << cl.x << " " << cl.y << " " << sum << endl;
cl.print();
cout <<"**************"<< endl;
}
} else {
#ifndef FF
// interp->getInterpolatedPosition(cl.x,cl.y, cl.get_cluster(),int_x, int_y);
interp->getInterpolatedPosition(cl.x,cl.y, etax, etay, quad,int_x, int_y);
interp->addToImage(int_x, int_y);
// cout <<"**************"<< endl;
// cout << cl.x << " " << cl.y << " " << sum << endl;
// cl.print();
// cout << int_x << " " << int_y << endl;
// cout <<"**************"<< endl;
// if (etax!=0 && etay!=0 && etax!=1 && etay!=1)
if (int_x<-1 || int_y<-1 || int_x>NC+1 || int_y>NR+1) {
cout <<"**************"<< endl;
cout << cl.x << " " << cl.y << " " << sum << endl;
cl.print();
cout << int_x << " " << int_y << endl;
cout <<"**************"<< endl;
} else
interp->addToImage(int_x, int_y);
#endif
#ifdef FF
// interp->addToFlatField(cl.get_cluster(), etax, etay);
// #ifdef UCL
// if (cl.x>50)
// #endif
// if (etax!=0 && etay!=0 && etax!=1 && etay!=1)
interp->addToFlatField(etax, etay);
// if (etax==0 || etay==0) cout << cl.x << " " << cl.y << endl;
#endif
}
// #ifdef SOLEIL
// }
// #endif
if (nph%1000000==0) cout << nph << endl;
if (nph%10000000==0) {
#ifndef FF
cout << "writing interpolated iamge" << endl;
//#ifndef RECT
interp->writeInterpolatedImage(outfname);
//#endif
// #ifdef RECT
// sprintf(fff,"%s.even",outfname);
// interpEven->writeInterpolatedImage(fff);
// sprintf(fff,"%s.odd",outfname);
// interpOdd->writeInterpolatedImage(fff);
// #endif
cout << "done" << endl;
interp->writeInterpolatedImage(outfname);
#endif
#ifdef FF
cout << "writing eta" << endl;
//#ifndef RECT
interp->writeFlatField(outfname);
//#endif
// #ifdef RECT
// sprintf(fff,"%s.even",outfname);
// interpEven->writeFlatField(fff);
// sprintf(fff,"%s.odd",outfname);
// interpOdd->writeFlatField(fff);
// #endif
cout << "done" << endl;
interp->writeFlatField(outfname);
#endif
}
@ -285,84 +273,71 @@ int main(int argc, char *argv[]) {
fclose(f);
#ifdef FF
//#ifndef RECT
interp->writeFlatField(outfname);
// #endif
// #ifdef RECT
// sprintf(fff,"%s.even",outfname);
// interpEven->writeFlatField(outfname);
// sprintf(fff,"%s.odd",outfname);
// interpOdd->writeFlatField(outfname);
// #endif
#endif
#ifndef FF
//#ifndef RECT
#ifndef RECT1
interp->writeInterpolatedImage(outfname);
// #endif
// #ifdef RECT
// sprintf(fff,"%s.even",outfname);
// interpEven->writeInterpolatedImage(fff);
// sprintf(fff,"%s.odd",outfname);
// interpOdd->writeInterpolatedImage(fff);
// #endif
//#ifdef RECT
//interp=interpEven;
//#endif
#endif
img=interp->getInterpolatedImage();
for (ix=0; ix<NC; ix++) {
for (iy=0; iy<NR; iy++) {
for (isx=0; isx<nSubPixels; isx++) {
for (iy=0; iy<NR; iy++) {
for (isx=0; isx<nSubPixels; isx++) {
for (isy=0; isy<nSubPixelsY; isy++) {
totimg[ix*nSubPixels+isx+(iy*nSubPixelsY+isy)*(NC*nSubPixels)]+=img[ix*nSubPixels+isx+(iy*nSubPixelsY+isy)*(NC*nSubPixels)];
// cout << "--" << ix << " " << iy <<" " << ix*nSubPixels+isx+(iy*nSubPixelsY+isy)*(NC*nSubPixels) << endl;
#ifdef RECT1
if (isx==0)
rectimg[ix+(iy*nSubPixelsY+isy)*(NC)]=img[ix*nSubPixels+isx+(iy*nSubPixelsY+isy)*(NC*nSubPixels)];
else
rectimg[ix+(iy*nSubPixelsY+isy)*(NC)]+=img[ix*nSubPixels+isx+(iy*nSubPixelsY+isy)*(NC*nSubPixels)];
#endif
}
}
}
}
cout << "Read " << nframes << " frames (first frame: " << f0 << " last frame: " << lastframe << " delta:" << lastframe-f0 << ") nph="<< nph <<endl;
cout << "Top-Left=" << tl << " " << " Top-Right=" << tr << " Bottom-Left="<< bl << " Bottom-Right=" << br << endl;
interp->clearInterpolatedImage();
// #ifdef RECT
// interp=interpOdd;
// img=interp->getInterpolatedImage();
// for (ix=0; ix<NC; ix++) {
// for (iy=0; iy<NR; iy++) {
// for (isx=0; isx<nSubPixels; isx++) {
// for (isy=0; isy<nSubPixelsY; isy++) {
// totimg[ix*nSubPixels+isx+(iy*nSubPixelsY+isy)*(NC*nSubPixels)]+=img[ix*nSubPixels+isx+(iy*nSubPixelsY+isy)*(NC*nSubPixels)];
// // cout << "--" << ix << " " << iy <<" " << ix*nSubPixels+isx+(iy*nSubPixelsY+isy)*(NC*nSubPixels) << endl;
// }
// }
// }
// }
// interp->clearInterpolatedImage();
// #endif
#ifdef RECT1
WriteToTiff(rectimg, outfname,NC,NR*nSubPixelsY);
#endif
interp->clearInterpolatedImage();
#endif
cout << "Read " << nframes << " frames (first frame: " << f0 << " last frame: " << lastframe << " delta:" << lastframe-f0 << ") nph="<< nph <<endl;
} else
cout << "could not open file " << infname << endl;
}
#ifndef FF
sprintf(outfname,argv[3],11111);
#ifndef RECT1
WriteToTiff(totimg, outfname,NC*nSubPixels,NR*nSubPixelsY);
#endif
#ifdef RECT1
img=interp->getInterpolatedImage();
for (ix=0; ix<NC; ix++) {
for (iy=0; iy<NR; iy++) {
for (isx=0; isx<nSubPixels; isx++) {
for (isy=0; isy<nSubPixelsY; isy++) {
if (isx==0)
rectimg[ix+(iy*nSubPixelsY+isy)*(NC)]=totimg[ix*nSubPixels+isx+(iy*nSubPixelsY+isy)*(NC*nSubPixels)];
else
rectimg[ix+(iy*nSubPixelsY+isy)*(NC)]+=totimg[ix*nSubPixels+isx+(iy*nSubPixelsY+isy)*(NC*nSubPixels)];
}
}
}
}
WriteToTiff(rectimg, outfname,NC,NR*nSubPixelsY);
#endif
#endif
#ifdef FF
//#ifndef RECT
interp->writeFlatField(outfname);
//#endif
// #ifdef RECT
// sprintf(fff,"%s.even",outfname);
// interpEven->writeFlatField(fff);
// sprintf(fff,"%s.odd",outfname);
// interpOdd->writeFlatField(fff);
// #endif
#endif
cout << "Filled " << nph << " (/"<< totph <<") " << endl;

View File

@ -18,7 +18,7 @@ int main(int argc, char *argv[]) {
*/
if (argc<7) {
cout << "Wrong usage! Should be: "<< argv[0] << " infile " << " etafile outfile runmin runmax ns" << endl;
cout << "Wrong usage! Should be: "<< argv[0] << " infile " << " outfile runmin runmax ns" << endl;
return 1;
}
@ -28,13 +28,14 @@ int main(int argc, char *argv[]) {
int runmax=atoi(argv[5]);
int nsubpix=atoi(argv[6]);
int etabins=1000;//nsubpix*2*100;
double etamin=-1, etamax=2;
// int etabins=1000;//nsubpix*2*100;
// double etamin=-1, etamax=2;
int quad;
double sum, totquad;
double sDum[2][2];
double etax, etay, int_x, int_y;
int ok;
//double etax, etay,
double int_x, int_y;
//int ok;
int ix, iy, isx, isy;

View File

@ -43,7 +43,7 @@
#include <map>
#include <fstream>
#include <sys/stat.h>
#include <dirent.h>
#include <ctime>
using namespace std;
@ -58,19 +58,19 @@ int main(int argc, char *argv[]) {
return 1;
}
int p=10000;
//int p=10000;
int fifosize=1000;
int nthreads=10;
int nsubpix=25;
int etabins=nsubpix*10;
double etamin=-1, etamax=2;
//int nsubpix=25;
//int etabins=nsubpix*10;
//double etamin=-1, etamax=2;
int csize=3;
int save=1;
//int save=1;
int nsigma=5;
int nped=10000;
int ndark=100;
int ok;
int iprog=0;
//int ndark=100;
//int ok;
//int iprog=0;
int cf=0;
@ -101,13 +101,13 @@ int main(int argc, char *argv[]) {
moench03CommonMode *cm=NULL;
moench03GhostSummation *gs;
double *gainmap=NULL;
float *gm;
//float *gm;
int size = 327680;////atoi(argv[3]);
//int size = 327680;////atoi(argv[3]);
int* image;
//int* image;
//int* image =new int[327680/sizeof(int)];
int ff, np;
@ -171,7 +171,7 @@ int main(int argc, char *argv[]) {
char fname[10000];
char imgfname[10000];
char cfname[10000];
char fn[10000];
//char fn[10000];
std::time_t end_time;
@ -185,9 +185,9 @@ int main(int argc, char *argv[]) {
cout << "pedestal file is " << pedfile << endl;
if (thr>0)
cout << "threshold is " << thr << endl;
uint32 nnx, nny;
double *gmap;
uint32 unnx, unny;
int nnx, nny;
//double *gmap;
// if (gainfname) {
// gm=ReadFromTiff(gainfname, nny, nnx);
@ -221,10 +221,10 @@ int main(int argc, char *argv[]) {
} else
thr=0.15*thr;
filter->newDataSet();
int dsize=decoder->getDataSize();
//int dsize=decoder->getDataSize();
char data[dsize];
//char data[dsize];
@ -270,12 +270,14 @@ int main(int argc, char *argv[]) {
mt->StartThreads();
mt->popFree(buff);
DIR *dir;
struct dirent *ent;
// cout << "mt " << endl;
int ifr=0;
double ped[nx*ny], *ped1;
double ped[nx*ny];//, *ped1;
if (pedfile) {
@ -302,7 +304,7 @@ int main(int argc, char *argv[]) {
mt->nextThread();
mt->popFree(buff);
ifr++;
if (ifr%100==0)
if (ifr%10000==0)
cout << ifr << " " << ff << " " << np << endl;
} else
cout << ifr << " " << ff << " " << np << endl;
@ -314,7 +316,9 @@ int main(int argc, char *argv[]) {
} else
cout << "Could not open pedestal file "<< fname << " for reading " << endl;
} else {
float *pp=ReadFromTiff(pedfile, nny, nnx);
float *pp=ReadFromTiff(pedfile, unny, unnx);
nny=unny;
nnx=unnx;
if (pp && nnx==nx && nny==ny) {
for (int i=0; i<nx*ny; i++) {
ped[i]=pp[i];
@ -341,28 +345,23 @@ int main(int argc, char *argv[]) {
ifr=0;
int ifile=0;
char ext[100];
mt->setFrameMode(eFrame);
for (int irun=runmin; irun<=runmax; irun++) {
cout << "DATA " ;
// sprintf(fn,fformat,irun);
sprintf(ffname,"%s/%s.raw",indir,fformat);
sprintf(fname,ffname,irun);
sprintf(ffname,"%s/%s.tiff",outdir,fformat);
sprintf(imgfname,ffname,irun);
sprintf(ffname,"%s/%s.clust",outdir,fformat);
sprintf(cfname,ffname,irun);
cout << fname << " " ;
sprintf(ext,"_%d.raw",irun);
sprintf(imgfname,"%s/%s_%d.tiff",outdir,fformat,irun);
// sprintf(imgfname,ffname,irun);
sprintf(cfname,"%s/%s_%d.clust",outdir,fformat, irun);
//sprintf(cfname,ffname,irun);
cout << cfname << " " ;
cout << imgfname << endl;
std::time(&end_time);
cout << std::ctime(&end_time) << endl;
// cout << fname << " " << outfname << " " << imgfname << endl;
filebin.open((const char *)(fname), ios::in | ios::binary);
// //open file
ifile=0;
if (filebin.is_open()){
if (thr<=0 && cf!=0) { //cluster finder
if (thr<=0 && cf!=0) { //cluster finder
if (of==NULL) {
of=fopen(cfname,"w");
if (of) {
@ -375,77 +374,105 @@ int main(int argc, char *argv[]) {
}
}
}
// //while read frame
ff=-1;
ifr=0;
while (decoder->readNextFrame(filebin, ff, np,buff)) {
if (np==40) {
// cout << "*"<<ifr++<<"*"<<ff<< endl;
// cout << ff << " " << np << endl;
// //push
mt->pushData(buff);
// // //pop
mt->nextThread();
// // // cout << " " << (void*)buff;
mt->popFree(buff);
if ((dir = opendir (indir)) != NULL) {
/* print all the files and directories within directory */
while ((ent = readdir (dir)) != NULL) {
// printf ("----------- %s\n", ent->d_name);
// printf ("************** %s", ent->d_name);
// cout << string(ent->d_name).find(fformat) << endl;
if (string(ent->d_name).find(string(fformat)+"_d0_f0")==0) {
// printf ("+++++++++++++++ %s\n", ent->d_name);
if (string(ent->d_name).find(ext)!= string::npos) {
//printf ("**************8 %s\n", ent->d_name);
sprintf(fname,"%s/%s",indir,ent->d_name);
//sprintf(fname,ffname,irun);
cout << fname << endl;
ifr++;
if (ifr%100==0) cout << ifr << " " << ff << endl;
if (nframes>0) {
if (ifr%nframes==0) {
//The name has an additional "_fXXXXX" at the end, where "XXXXX" is the initial frame number of the image (0,1000,2000...)
sprintf(ffname,"%s/%s_f%05d.tiff",outdir,fformat,ifile);
sprintf(imgfname,ffname,irun);
//cout << "Writing tiff to " << imgfname << " " << thr1 << endl;
mt->writeImage(imgfname, thr1);
mt->clearImage();
ifile++;
std::time(&end_time);
cout << std::ctime(&end_time) << endl;
// cout << fname << " " << outfname << " " << imgfname << endl;
filebin.open((const char *)(fname), ios::in | ios::binary);
// //open file
ifile=0;
if (filebin.is_open()){
// //while read frame
ff=-1;
ifr=0;
while (decoder->readNextFrame(filebin, ff, np,buff)) {
if (np==40) {
mt->pushData(buff);
mt->nextThread();
mt->popFree(buff);
ifr++;
if (ifr%10000==0) cout << ifr << " " << ff << endl;
if (nframes>0) {
while (mt->isBusy()) {;}
if (ifr%nframes==0) {
//The name has an additional "_fXXXXX" at the end, where "XXXXX" is the initial frame number of the image (0,1000,2000...)
sprintf(ffname,"%s/%s_f%05d.tiff",outdir,fformat,ifile);
sprintf(imgfname,ffname,irun);
//cout << "Writing tiff to " << imgfname << " " << thr1 << endl;
mt->writeImage(imgfname, thr1);
mt->clearImage();
ifile++;
}
}
}
ff=-1;
}
}
} else
cout << ifr << " " << ff << " " << np << endl;
ff=-1;
filebin.close();
} else
cout << "Could not open "<< fname << " for reading " << endl;
}
}
cout << "--" << endl;
filebin.close();
// //close file
// //join threads
while (mt->isBusy()) {;}
if (nframes>=0) {
if (nframes>0) {
sprintf(ffname,"%s/%s_f%05d.tiff",outdir,fformat,ifile);
sprintf(imgfname,ffname,irun);
} else {
sprintf(ffname,"%s/%s.tiff",outdir,fformat);
sprintf(imgfname,ffname,irun);
}
cout << "Writing tiff to " << imgfname << " " << thr1 <<endl;
mt->writeImage(imgfname, thr1);
mt->clearImage();
if (of) {
fclose(of);
of=NULL;
mt->setFilePointer(NULL);
}
}
std::time(&end_time);
cout << std::ctime(&end_time) << endl;
} else
cout << "Could not open "<< fname << " for reading " << endl;
}
while (mt->isBusy()) {;}
if (nframes>=0) {
if (nframes>0) {
sprintf(ffname,"%s/%s_f%05d.tiff",outdir,fformat,ifile);
sprintf(imgfname,ffname,irun);
} else {
sprintf(imgfname,"%s/%s_%d.tiff",outdir,fformat,irun);
//sprintf(imgfname,ffname,irun);
}
cout << "Writing tiff to " << imgfname << " " << ifr <<endl;
mt->writeImage(imgfname, thr1);
mt->clearImage();
if (of) {
fclose(of);
of=NULL;
mt->setFilePointer(NULL);
}
}
std::time(&end_time);
cout << std::ctime(&end_time) << endl;
closedir (dir);
} else {
/* could not open directory */
cout << "could not open directory " << indir << endl;
}
}
if (nframes<0){
sprintf(ffname,"%s/%s.tiff",outdir,fformat);
strcpy(imgfname,ffname);
cout << "Writing tiff to " << imgfname << " " << thr1 <<endl;
cout << "Writing tiff to " << imgfname << " " << ifr <<endl;
mt->writeImage(imgfname, thr1);
}
sprintf(imgfname,"%s/%s_ped.tiff",outdir,fformat);
mt->writePedestal(imgfname);
sprintf(imgfname,"%s/%s_noise.tiff",outdir,fformat);
mt->writePedestalRMS(imgfname);
return 0;
}

View File

@ -0,0 +1,527 @@
//#include "ansi.h"
#include <iostream>
//#define CORR
#define NOTHREAD
#define C_GHOST 0.0004
#define CM_ROWS 50
//#define VERSION_V1
//#include "moench03T1ZmqData.h"
#ifdef NEWRECEIVER
#ifndef RECT
#include "moench03T1ReceiverDataNew.h"
#endif
#ifdef RECT
#include "moench03T1ReceiverDataNewRect.h"
#endif
#endif
#ifdef CSAXS_FP
#include "moench03T1ReceiverData.h"
#endif
#ifdef OLDDATA
#include "moench03Ctb10GbT1Data.h"
#endif
// #include "interpolatingDetector.h"
//#include "etaInterpolationPosXY.h"
// #include "linearInterpolation.h"
// #include "noInterpolation.h"
#include "multiThreadedCountingDetector.h"
//#include "multiThreadedAnalogDetector.h"
#include "singlePhotonDetector.h"
#include "moench03GhostSummation.h"
#include "moench03CommonMode.h"
//#include "interpolatingDetector.h"
#include <stdio.h>
#include <map>
#include <fstream>
#include <sys/stat.h>
#include <dirent.h>
#include <ctime>
using namespace std;
int main(int argc, char *argv[]) {
if (argc<4) {
cout << "Usage is " << argv[0] << "indir outdir fname [runmin] [runmax] [pedfile] [threshold] [nframes] [xmin xmax ymin ymax] [gainmap]" << endl;
cout << "threshold <0 means analog; threshold=0 means cluster finder; threshold>0 means photon counting" << endl;
cout << "nframes <0 means sum everything; nframes=0 means one file per run; nframes>0 means one file every nframes" << endl;
return 1;
}
//int p=10000;
int fifosize=1000;
int nthreads=10;
//int nsubpix=25;
//int etabins=nsubpix*10;
//double etamin=-1, etamax=2;
int csize=3;
//int save=1;
int nsigma=5;
int nped=10000;
//int ndark=100;
//int ok;
//int iprog=0;
int cf=0;
#ifdef NEWRECEIVER
#ifdef RECT
cout << "Should be rectangular!" <<endl;
#endif
moench03T1ReceiverDataNew *decoder=new moench03T1ReceiverDataNew();
cout << "RECEIVER DATA WITH ONE HEADER!"<<endl;
#endif
#ifdef CSAXS_FP
moench03T1ReceiverData *decoder=new moench03T1ReceiverData();
cout << "RECEIVER DATA WITH ALL HEADERS!"<<endl;
#endif
#ifdef OLDDATA
moench03Ctb10GbT1Data *decoder=new moench03Ctb10GbT1Data();
cout << "OLD RECEIVER DATA!"<<endl;
#endif
int nx=400, ny=400;
decoder->getDetectorSize(nx,ny);
int ncol_cm=CM_ROWS;
double xt_ghost=C_GHOST;
moench03CommonMode *cm=NULL;
moench03GhostSummation *gs;
double *gainmap=NULL;
//float *gm;
//int size = 327680;////atoi(argv[3]);
//int* image;
//int* image =new int[327680/sizeof(int)];
int ff, np;
//cout << " data size is " << dsize;
ifstream filebin;
char *indir=argv[1];
char *outdir=argv[2];
char *fformat=argv[3];
int runmin=0;
// cout << "argc is " << argc << endl;
if (argc>=5) {
runmin=atoi(argv[4]);
}
int runmax=runmin;
if (argc>=6) {
runmax=atoi(argv[5]);
}
char *pedfile=NULL;
if (argc>=7) {
pedfile=argv[6];
}
double thr=0;
double thr1=1;
if (argc>=8) {
thr=atof(argv[7]);
}
int nframes=0;
if (argc>=9) {
nframes=atoi(argv[8]);
}
int xmin=0, xmax=nx, ymin=0, ymax=ny;
if (argc>=13) {
xmin=atoi(argv[9]);
xmax=atoi(argv[10]);
ymin=atoi(argv[11]);
ymax=atoi(argv[12]);
}
char *gainfname=NULL;
if (argc>13) {
gainfname=argv[13];
cout << "Gain map file name is: " << gainfname << endl;
}
char ffname[10000];
char fname[10000];
char imgfname[10000];
char cfname[10000];
//char fn[10000];
std::time_t end_time;
FILE *of=NULL;
cout << "input directory is " << indir << endl;
cout << "output directory is " << outdir << endl;
cout << "input file is " << fformat << endl;
cout << "runmin is " << runmin << endl;
cout << "runmax is " << runmax << endl;
if (pedfile)
cout << "pedestal file is " << pedfile << endl;
if (thr>0)
cout << "threshold is " << thr << endl;
uint32 unnx, unny;
int nnx, nny;
//double *gmap;
// if (gainfname) {
// gm=ReadFromTiff(gainfname, nny, nnx);
// if (gm && nnx==nx && nny==ny) {
// gmap=new double[nx*ny];
// for (int i=0; i<nx*ny; i++) {
// gmap[i]=gm[i];
// }
// delete gm;
// } else
// cout << "Could not open gain map " << gainfname << endl;
// }
#ifdef CORR
cout << "Applying common mode " << ncol_cm << endl;
cm=new moench03CommonMode(ncol_cm);
cout << "Applying ghost corrections " << xt_ghost << endl;
gs=new moench03GhostSummation(decoder, xt_ghost);
#endif
singlePhotonDetector *filter=new singlePhotonDetector(decoder,csize, nsigma, 1, cm, nped, 200, -1, -1, gainmap, gs);
if (gainfname) {
if (filter->readGainMap(gainfname))
cout << "using gain map " << gainfname << endl;
else
cout << "Could not open gain map " << gainfname << endl;
} else
thr=0.15*thr;
filter->newDataSet();
//int dsize=decoder->getDataSize();
//char data[dsize];
//#ifndef ANALOG
if (thr>0) {
cout << "threshold is " << thr << endl;
//#ifndef ANALOG
filter->setThreshold(thr);
//#endif
cf=0;
} else
cf=1;
//#endif
filter->setROI(xmin,xmax,ymin,ymax);
std::time(&end_time);
cout << std::ctime(&end_time) << endl;
char* buff;
// multiThreadedAnalogDetector *mt=new multiThreadedAnalogDetector(filter,nthreads,fifosize);
#ifndef NOTHREAD
multiThreadedCountingDetector *mt=new multiThreadedCountingDetector(filter,nthreads,fifosize);
#endif
#ifdef NOTHREAD
singlePhotonDetector *mt=filter;
#endif
#ifndef ANALOG
mt->setDetectorMode(ePhotonCounting);
cout << "Counting!" << endl;
if (thr>0) {
cf=0;
}
#endif
//{
#ifdef ANALOG
mt->setDetectorMode(eAnalog);
cout << "Analog!" << endl;
cf=0;
//thr1=thr;
#endif
// }
#ifndef NOTHREAD
mt->StartThreads();
mt->popFree(buff);
#endif
DIR *dir;
struct dirent *ent;
// cout << "mt " << endl;
int ifr=0;
double ped[nx*ny];//, *ped1;
if (pedfile) {
cout << "PEDESTAL " << endl;
sprintf(imgfname,"%s/pedestals.tiff",outdir);
if (string(pedfile).find(".tif")==std::string::npos){
sprintf(fname,"%s.raw",pedfile);
cout << fname << endl ;
std::time(&end_time);
cout << "aaa" << std::ctime(&end_time) << endl;
mt->setFrameMode(ePedestal);
// sprintf(fn,fformat,irun);
filebin.open((const char *)(fname), ios::in | ios::binary);
// //open file
if (filebin.is_open()){
ff=-1;
while (decoder->readNextFrame(filebin, ff, np,buff)) {
if (np==40) {
#ifdef NOTHREAD
mt->processData(buff);
#endif
#ifndef NOTHREAD
mt->pushData(buff);
mt->nextThread();
mt->popFree(buff);
#endif
ifr++;
if (ifr%10000==0)
cout << ifr << " " << ff << " " << np << endl;
} else
cout << ifr << " " << ff << " " << np << endl;
ff=-1;
}
filebin.close();
#ifndef NOTHREAD
while (mt->isBusy()) {;}
#endif
} else
cout << "Could not open pedestal file "<< fname << " for reading " << endl;
} else {
float *pp=ReadFromTiff(pedfile, unny, unnx);
nny=unny;
nnx=unnx;
if (pp && nnx==nx && nny==ny) {
for (int i=0; i<nx*ny; i++) {
ped[i]=pp[i];
}
delete [] pp;
mt->setPedestal(ped);
// ped1=mt->getPedestal();
// for (int i=0; i<nx*ny; i++) {
// cout << ped[i]<<"/"<<ped1[i] << " " ;
// }
cout << "Pedestal set from tiff file " << pedfile << endl;
} else {
cout << "Could not open pedestal tiff file "<< pedfile << " for reading " << endl;
}
}
#ifdef NOTHREAD
mt->writePedestals(imgfname);
#endif
#ifndef NOTHREAD
mt->writePedestal(imgfname);
#endif
std::time(&end_time);
cout << std::ctime(&end_time) << endl;
}
ifr=0;
int ifile=0;
char ext[100];
mt->setFrameMode(eFrame);
for (int irun=runmin; irun<=runmax; irun++) {
cout << "DATA " ;
// sprintf(fn,fformat,irun);
sprintf(ext,"_%d.raw",irun);
sprintf(imgfname,"%s/%s_%d.tiff",outdir,fformat,irun);
// sprintf(imgfname,ffname,irun);
sprintf(cfname,"%s/%s_%d.clust",outdir,fformat, irun);
//sprintf(cfname,ffname,irun);
cout << cfname << " " ;
cout << imgfname << endl;
if (thr<=0 && cf!=0) { //cluster finder
if (of==NULL) {
of=fopen(cfname,"w");
if (of) {
mt->setFilePointer(of);
cout << "file pointer set " << endl;
} else {
cout << "Could not open "<< cfname << " for writing " << endl;
mt->setFilePointer(NULL);
return 1;
}
}
}
if ((dir = opendir (indir)) != NULL) {
/* print all the files and directories within directory */
while ((ent = readdir (dir)) != NULL) {
// printf ("----------- %s\n", ent->d_name);
// printf ("************** %s", ent->d_name);
// cout << string(ent->d_name).find(fformat) << endl;
if (string(ent->d_name).find(string(fformat)+"_d0_f0")==0) {
// printf ("+++++++++++++++ %s\n", ent->d_name);
if (string(ent->d_name).find(ext)!= string::npos) {
//printf ("**************8 %s\n", ent->d_name);
sprintf(fname,"%s/%s",indir,ent->d_name);
//sprintf(fname,ffname,irun);
cout << fname << endl;
std::time(&end_time);
cout << std::ctime(&end_time) << endl;
// cout << fname << " " << outfname << " " << imgfname << endl;
filebin.open((const char *)(fname), ios::in | ios::binary);
// //open file
ifile=0;
if (filebin.is_open()){
// //while read frame
ff=-1;
ifr=0;
while (decoder->readNextFrame(filebin, ff, np,buff)) {
if (np==40) {
#ifdef NOTHREAD
mt->processData(buff);
#endif
#ifndef NOTHREAD
mt->pushData(buff);
mt->nextThread();
mt->popFree(buff);
#endif
ifr++;
if (ifr%10000==0) cout << ifr << " " << ff << endl;
if (nframes>0) {
#ifndef NOTHREAD
while (mt->isBusy()) {;}
#endif
if (ifr%nframes==0) {
//The name has an additional "_fXXXXX" at the end, where "XXXXX" is the initial frame number of the image (0,1000,2000...)
sprintf(ffname,"%s/%s_f%05d.tiff",outdir,fformat,ifile);
sprintf(imgfname,ffname,irun);
//cout << "Writing tiff to " << imgfname << " " << thr1 << endl;
#ifdef NOTHREAD
mt->writeImage(imgfname);
#endif
#ifndef NOTHREAD
mt->writeImage(imgfname, thr1);
#endif
mt->clearImage();
ifile++;
}
}
}
ff=-1;
}
filebin.close();
} else
cout << "Could not open "<< fname << " for reading " << endl;
}
}
}
#ifndef NOTHREAD
while (mt->isBusy()) {;}
#endif
if (nframes>=0) {
if (nframes>0) {
sprintf(ffname,"%s/%s_f%05d.tiff",outdir,fformat,ifile);
sprintf(imgfname,ffname,irun);
} else {
sprintf(imgfname,"%s/%s_%d.tiff",outdir,fformat,irun);
//sprintf(imgfname,ffname,irun);
}
cout << "Writing tiff to " << imgfname << " " << ifr <<endl;
#ifdef NOTHREAD
mt->writeImage(imgfname);
#endif
#ifndef NOTHREAD
mt->writeImage(imgfname, thr1);
#endif
mt->clearImage();
if (of) {
fclose(of);
of=NULL;
mt->setFilePointer(NULL);
}
}
std::time(&end_time);
cout << std::ctime(&end_time) << endl;
closedir (dir);
} else {
/* could not open directory */
cout << "could not open directory " << indir << endl;
}
}
if (nframes<0){
sprintf(ffname,"%s/%s.tiff",outdir,fformat);
strcpy(imgfname,ffname);
cout << "Writing tiff to " << imgfname << " " << ifr <<endl;
#ifdef NOTHREAD
mt->writeImage(imgfname);
#endif
#ifndef NOTHREAD
mt->writeImage(imgfname, thr1);
#endif
}
sprintf(imgfname,"%s/%s_ped.tiff",outdir,fformat);
#ifdef NOTHREAD
mt->writePedestals(imgfname);
#endif
#ifndef NOTHREAD
mt->writePedestal(imgfname);
#endif
sprintf(imgfname,"%s/%s_noise.tiff",outdir,fformat);
mt->writePedestalRMS(imgfname);
return 0;
}

View File

@ -1,4 +1,4 @@
#define WRITE_QUAD
//#define WRITE_QUAD
#define MOENCH_BRANCH
#define C_GHOST 0.0004
@ -54,10 +54,11 @@ int main(int argc, char *argv[]) {
*/
FILE *of=NULL;
int fifosize=5000;
int etabins=1000;//nsubpix*2*100;
int etabins=1000, etabinsy=1000;//nsubpix*2*100;
double etamin=-1, etamax=2;
int nSubPixels=2;
int nSubPixelsX=2;
// int emin, emax;
int nSubPixelsY=2;
// help
if (argc < 3 ) {
cprintf(RED, "Help: ./trial [receive socket ip] [receive starting port number] [send_socket ip] [send starting port number] [nthreads] [nsubpix] [gainmap] [etafile]\n");
@ -98,10 +99,14 @@ int main(int argc, char *argv[]) {
nthreads=atoi(argv[5]);
cout << "Number of threads is: " << nthreads << endl;
if (argc>6)
nSubPixels=atoi(argv[6]);
cout << "Number of subpixels is: " << nSubPixels << endl;
if (argc>6) {
nSubPixelsX=atoi(argv[6]);
nSubPixelsY=nSubPixelsX;
#ifdef RECT
nSubPixelsX=2;
#endif
}
cout << "Number of subpixels is: " << nSubPixelsX << " " << nSubPixelsY << endl;
char *gainfname=NULL;
if (argc>7) {
@ -134,8 +139,12 @@ int main(int argc, char *argv[]) {
int ncol_cm=CM_ROWS;
double xt_ghost=C_GHOST;
moench03CommonMode *cm=new moench03CommonMode(ncol_cm);
moench03GhostSummation *gs=new moench03GhostSummation(det, xt_ghost);
moench03CommonMode *cm=NULL;
moench03GhostSummation *gs=NULL;
#ifdef CORR
gs=new moench03GhostSummation(det, xt_ghost);
cm=new moench03CommonMode(ncol_cm);
#endif
double *gainmap=NULL;
float *gm;
double *gmap=NULL;
@ -170,7 +179,7 @@ int main(int argc, char *argv[]) {
// multiThreadedAnalogDetector *mt=new multiThreadedAnalogDetector(filter,nthreads,fifosize);
#endif
#ifdef INTERP
eta2InterpolationPosXY *interp=new eta2InterpolationPosXY(npx, npy, nSubPixels, etabins, etamin, etamax);
eta2InterpolationPosXY *interp=new eta2InterpolationPosXY(npx, npy, nSubPixelsX,nSubPixelsY, etabins, etabinsy, etamin, etamax);
if (etafname) interp->readFlatField(etafname);
@ -285,10 +294,10 @@ int main(int argc, char *argv[]) {
int iframe=0;
char ofname[10000];
char fname[10000];
string fname;
// int length;
int *detimage=NULL;
int nnx, nny,nns;
int nnx, nny,nnsx, nnsy;
//uint32_t imageSize = 0, nPixelsX = 0, nPixelsY = 0,
//uint32_t dynamicRange = 0;
// infinite loop
@ -326,7 +335,7 @@ int main(int argc, char *argv[]) {
frameMode fMode=eFrame;
double *ped;
filter->getImageSize(nnx, nny,nns);
filter->getImageSize(nnx, nny,nnsx, nnsy);
@ -355,8 +364,9 @@ int main(int argc, char *argv[]) {
while (mt->isBusy()) {;}//wait until all data are processed from the queues
usleep(1000);
if (of) {
mt->setFilePointer(NULL);
fclose(of);
of=NULL;
}
@ -369,7 +379,7 @@ int main(int argc, char *argv[]) {
} else {
send_something=0;
if (fMode==ePedestal) {
sprintf(ofname,"%s_%ld_ped.tiff",fname,fileindex);
sprintf(ofname,"%s_%ld_ped.tiff",fname.c_str(),fileindex);
mt->writePedestal(ofname);
cout << "Writing pedestal to " << ofname << endl;
send_something=1;
@ -377,7 +387,7 @@ int main(int argc, char *argv[]) {
#ifdef INTERP
else if (fMode==eFlat) {
mt->prepareInterpolation(ok);
sprintf(ofname,"%s_%ld_eta.tiff",fname,fileindex);
sprintf(ofname,"%s_%ld_eta.tiff",fname.c_str(),fileindex);
mt->writeFlatField(ofname);
cout << "Writing eta to " << ofname << endl;
send_something=1;
@ -386,7 +396,7 @@ int main(int argc, char *argv[]) {
else {
if (subframes>0 ) {
if (insubframe>0) {
sprintf(ofname,"%s_sf%ld_%ld.tiff",fname,nnsubframe,fileindex);
sprintf(ofname,"%s_sf%ld_%ld.tiff",fname.c_str(),nnsubframe,fileindex);
// mt->writeImage(ofname);
doutf= new float[nnx*nny];
if (subframes>0 && insubframe!=subframes && insubframe>0)
@ -411,7 +421,7 @@ int main(int argc, char *argv[]) {
send_something=1;
}
} else {
sprintf(ofname,"%s_%ld.tiff",fname,fileindex);
sprintf(ofname,"%s_%ld.tiff",fname.c_str(),fileindex);
mt->writeImage(ofname);
send_something=1;
}
@ -424,11 +434,13 @@ int main(int argc, char *argv[]) {
if (fMode==ePedestal) {
cprintf(MAGENTA,"Get pedestal!\n");
nns=1;
nnsx=1;
nnsy=1;
nnx=npx;
nny=npy;
//dout= new int16_t[nnx*nny*nns*nns];
dout= new int32_t[nnx*nny*nns*nns];
dout= new int32_t[nnx*nny*nnsx*nnsy];
// cout << "get pedestal " << endl;
ped=mt->getPedestal();
// cout << "got pedestal " << endl;
@ -442,11 +454,11 @@ int main(int argc, char *argv[]) {
}
#ifdef INTERP
else if (fMode==eFlat) {
int nb;
int nb, nby;
double emi=0, ema=1;
int *ff=mt->getFlatField(nb, emi, ema);
int *ff=mt->getFlatField(nb, nby, emi, ema);
nnx=nb;
nny=nb;
nny=nby;
dout= new int32_t[nb*nb];
for (int ix=0; ix<nb*nb; ix++) {
dout[ix]=ff[ix];
@ -454,9 +466,9 @@ int main(int argc, char *argv[]) {
}
#endif
else {
detimage=mt->getImage(nnx,nny,nns);
detimage=mt->getImage(nnx,nny,nnsx, nnsy);
cprintf(MAGENTA,"Get image!\n");
cout << nnx << " " << nny << " " << nns << endl;
cout << nnx << " " << nny << " " << nnsx << " " << nnsy << endl;
// nns=1;
// nnx=npx;
// nny=npy;
@ -489,16 +501,16 @@ int main(int argc, char *argv[]) {
if(send_something) {
#ifndef DEVELOPER
#ifndef MOENCH_BRANCH
zmqsocket2->SendHeaderData (0, false, SLS_DETECTOR_JSON_HEADER_VERSION, dr, fileindex, 0,0, nnx, nny, nnx*nny*dr/8,acqIndex, frameIndex, fname, acqIndex,0 , packetNumber,bunchId, timestamp, modId, xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, 0,0, additionalJsonHeader);
zmqsocket2->SendHeaderData (0, false, SLS_DETECTOR_JSON_HEADER_VERSION, dr, fileindex, 0,0, nnx, nny, nnx*nny*dr/8,acqIndex, frameIndex, fname.c_str(), acqIndex,0 , packetNumber,bunchId, timestamp, modId, xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, 0,0, additionalJsonHeader);
#endif
#endif
#ifdef DEVELOPER
zmqsocket2->SendHeaderData (0, false,SLS_DETECTOR_JSON_HEADER_VERSION , dr, fileindex, 0,0,nnx,nny,nnx*nny*dr/8,acqIndex, frameIndex, fname,acqIndex,0 , packetNumber,bunchId, timestamp, modId,xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, 0,0, 0,additionalJsonHeader);
zmqsocket2->SendHeaderData (0, false,SLS_DETECTOR_JSON_HEADER_VERSION , dr, fileindex, 0,0,nnx,nny,nnx*nny*dr/8,acqIndex, frameIndex, fname.c_str(),acqIndex,0 , packetNumber,bunchId, timestamp, modId,xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, 0,0, 0,additionalJsonHeader);
#endif
#ifdef MOENCH_BRANCH
zmqsocket2->SendHeaderData (0, false, SLS_DETECTOR_JSON_HEADER_VERSION, dr, fileindex, nnx, nny, nnx*nny*dr/8,acqIndex, frameIndex, fname, acqIndex, subFrameIndex, packetNumber,bunchId, timestamp, modId, xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, flippedData, additionalJsonHeader);
zmqsocket2->SendHeaderData (0, false, SLS_DETECTOR_JSON_HEADER_VERSION, dr, fileindex, nnx, nny, nnx*nny*dr/8,acqIndex, frameIndex, fname.c_str(), acqIndex, subFrameIndex, packetNumber,bunchId, timestamp, modId, xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, flippedData, additionalJsonHeader);
#endif
@ -525,8 +537,8 @@ int main(int argc, char *argv[]) {
// auto meas_duration = duration_cast<microseconds>( t2 - t0 ).count();
// auto real_duration = duration_cast<microseconds>( t2 - t1 ).count();
cout << "Measurement lasted " << difftime(end,begin) << endl;
cout << "Processing lasted " << difftime(finished,begin) << endl;
// cout << "Measurement lasted " << difftime(end,begin) << endl;
//cout << "Processing lasted " << difftime(finished,begin) << endl;
continue; //continue to not get out
@ -560,8 +572,8 @@ int main(int argc, char *argv[]) {
//dataSize=size;
strcpy(fname,filename.c_str());
//strcpy(fname,filename.c_str());
fname=filename;
// cprintf(BLUE, "Header Info:\n"
// "size: %u\n"
// "multisize: %u\n"
@ -799,7 +811,7 @@ int main(int argc, char *argv[]) {
// timestamp=doc["timestamp"].GetUint();
packetNumber=doc["packetNumber"].GetUint();
// cout << acqIndex << " " << frameIndex << " " << subFrameIndex << " "<< bunchId << " " << timestamp << " " << packetNumber << endl;
if (packetNumber>=40) {
if (packetNumber>0) {
//*((int*)buff)=frameIndex;
if (insubframe==0) f0=frameIndex;
memcpy(buff,&frameIndex,sizeof(int));
@ -811,7 +823,7 @@ int main(int argc, char *argv[]) {
insubframe++;
nsubframes=frameIndex+1-f0;
} else {
cprintf(RED, "Incomplete frame: received only %d packet\n", packetNumber);
cprintf(RED, "Empty frame %d\n", frameIndex);
//length =
zmqsocket->ReceiveData(0, dummybuff, size);
}
@ -821,7 +833,7 @@ int main(int argc, char *argv[]) {
if (subframes>0 && insubframe>=subframes && fMode==eFrame) {
while (mt->isBusy()) {;}//wait until all data are processed from the queues
detimage=mt->getImage(nnx,nny,nns);
detimage=mt->getImage(nnx,nny,nnsx, nnsy);
cprintf(MAGENTA,"Get image!\n");
dout= new int32_t[nnx*nny];
doutf= new float[nnx*nny];
@ -834,7 +846,7 @@ int main(int argc, char *argv[]) {
if (dout[ix]<0) dout[ix]=0;
doutf[ix]=dout[ix];
}
sprintf(ofname,"%s_sf%ld_%ld.tiff",fname,nnsubframe,fileindex);
sprintf(ofname,"%s_sf%ld_%ld.tiff",fname.c_str(),nnsubframe,fileindex);
cout << "Writing image to " << ofname << endl;
@ -846,16 +858,16 @@ int main(int argc, char *argv[]) {
#ifndef DEVELOPER
#ifndef MOENCH_BRANCH
zmqsocket2->SendHeaderData (0, false, SLS_DETECTOR_JSON_HEADER_VERSION, dr, fileindex, 0,0, nnx, nny, nnx*nny*dr/8,acqIndex, frameIndex, fname, acqIndex,0 , packetNumber,bunchId, timestamp, modId, xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, 0,0, additionalJsonHeader);
zmqsocket2->SendHeaderData (0, false, SLS_DETECTOR_JSON_HEADER_VERSION, dr, fileindex, 0,0, nnx, nny, nnx*nny*dr/8,acqIndex, frameIndex, fname.c_str(), acqIndex,0 , packetNumber,bunchId, timestamp, modId, xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, 0,0, additionalJsonHeader);
#endif
#endif
#ifdef DEVELOPER
zmqsocket2->SendHeaderData (0, false,SLS_DETECTOR_JSON_HEADER_VERSION , dr, fileindex, 0,0,nnx,nny,nnx*nny*dr/8,acqIndex, frameIndex, fname,acqIndex,0 , packetNumber,bunchId, timestamp, modId,xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, 0,0, 0,additionalJsonHeader);
zmqsocket2->SendHeaderData (0, false,SLS_DETECTOR_JSON_HEADER_VERSION , dr, fileindex, 0,0,nnx,nny,nnx*nny*dr/8,acqIndex, frameIndex, fname.c_str(),acqIndex,0 , packetNumber,bunchId, timestamp, modId,xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, 0,0, 0,additionalJsonHeader);
#endif
#ifdef MOENCH_BRANCH
zmqsocket2->SendHeaderData (0, false, SLS_DETECTOR_JSON_HEADER_VERSION, dr, fileindex, nnx, nny, nnx*nny*dr/8,acqIndex, frameIndex, fname, acqIndex, subFrameIndex, packetNumber,bunchId, timestamp, modId, xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, flippedData, additionalJsonHeader);
zmqsocket2->SendHeaderData (0, false, SLS_DETECTOR_JSON_HEADER_VERSION, dr, fileindex, nnx, nny, nnx*nny*dr/8,acqIndex, frameIndex, fname.c_str(), acqIndex, subFrameIndex, packetNumber,bunchId, timestamp, modId, xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, flippedData, additionalJsonHeader);
#endif

View File

@ -95,7 +95,7 @@ public:
virtual int *getImage() {
return det->getImage();
}
virtual int getImageSize(int &nnx, int &nny, int &ns) {return det->getImageSize(nnx, nny, ns);};
virtual int getImageSize(int &nnx, int &nny, int &nsx,int &nsy) {return det->getImageSize(nnx, nny, nsx, nsy);};
virtual int getDetectorSize(int &nnx, int &nny) {return det->getDetectorSize(nnx, nny);};
virtual ~threadedAnalogDetector() {StopThread(); delete fifoFree; delete fifoData;}
@ -208,11 +208,11 @@ FILE *getFilePointer(){return det->getFilePointer();};
return NULL;
}
virtual int *getFlatField(int &nb, double emi, double ema){
virtual int *getFlatField(int &nb, int &nby, double emi, double ema){
slsInterpolation *interp=(det)->getInterpolation();
int *ff=NULL;
if (interp) {
ff=interp->getFlatField(nb,emi,ema);
ff=interp->getFlatField(nb,nby,emi,ema);
}
return ff;
}
@ -320,33 +320,41 @@ public:
virtual void newDataSet(){for (int i=0; i<nThreads; i++) dets[i]->newDataSet();};
virtual int *getImage(int &nnx, int &nny, int &ns) {
virtual int *getImage(int &nnx, int &nny, int &ns, int &nsy) {
int *img;
cout << "get image "<< image << endl;
// int nnx, nny, ns;
// int nnx, nny, ns;
int nn=dets[0]->getImageSize(nnx, nny,ns);
int nn=dets[0]->getImageSize(nnx, nny,ns, nsy);
if (image) {
delete image;
cout << "del image "<< image << endl;
delete [] image;
image=NULL;
}
image=new int[nn];
cout << "new image" << image << endl;
//int nn=dets[0]->getImageSize(nnx, nny, ns);
//for (i=0; i<nn; i++) image[i]=0;
for (int ii=0; ii<nThreads; ii++) {
//cout << ii << " " << nn << " " << nnx << " " << nny << " " << ns << endl;
img=dets[ii]->getImage();
for (int i=0; i<nn; i++) {
if (ii==0)
if (image) {
for (int ii=0; ii<nThreads; ii++) {
cout << ii << " " << nn << " " << nnx << " " << nny << " " << nsy << endl;
img=dets[ii]->getImage();
for (int i=0; i<nn; i++) {
if (ii==0)
// if (img[i]>0)
image[i]=img[i];
// else
// image[i]=0;
else //if (img[i]>0)
image[i]+=img[i];
//if (img[i]) cout << "det " << ii << " pix " << i << " val " << img[i] << " " << image[i] << endl;
// else
// image[i]=0;
else //if (img[i]>0)
image[i]+=img[i];
/***
gdb runtime error
../multiThreadedAnalogDetector.h:349:14: runtime error: signed integer overflow: -1094794611 + -1094795013 cannot be rep
**/
//if (img[i]) cout << "det " << ii << " pix " << i << " val " << img[i] << " " << image[i] << endl;
}
}
}
return image;
@ -369,29 +377,32 @@ public:
/* dets[ii]->writeImage(tit); */
/* } */
/* #endif */
int nnx, nny, ns;
getImage(nnx, nny, ns);
cout << "write image" << endl;
int nnx, nny, ns, nsy;
getImage(nnx, nny, ns, nsy);
//int nnx, nny, ns;
int nn=dets[0]->getImageSize(nnx, nny, ns);
float *gm=new float[nn];
if (gm) {
for (int ix=0; ix<nn; ix++) {
if (t) {
if (image[ix]<0)
gm[ix]=0;
else
gm[ix]=(image[ix])/t;
} else
gm[ix]=image[ix];
int nn=dets[0]->getImageSize(nnx, nny, ns, nsy);
float *gm=new float[nn];
if (gm) {
for (int ix=0; ix<nn; ix++) {
if (t) {
if (image[ix]<0)
gm[ix]=0;
else
gm[ix]=(image[ix])/t;
} else
gm[ix]=image[ix];
//if (image[ix]>0 && ix/nnx<350) cout << ix/nnx << " " << ix%nnx << " " << image[ix]<< " " << gm[ix] << endl;
}
//cout << "image " << nnx << " " << nny << endl;
WriteToTiff(gm,imgname ,nnx, nny);
delete [] gm;
} else cout << "Could not allocate float image " << endl;
return NULL;
}
//if (image[ix]>0 && ix/nnx<350) cout << ix/nnx << " " << ix%nnx << " " << image[ix]<< " " << gm[ix] << endl;
}
cout << "image " << nnx << " " << nny << endl;
WriteToTiff(gm,imgname ,nnx, nny);
cout << imgname << endl;
delete [] gm;
cout << "del" << endl;
} else cout << "Could not allocate float image " << endl;
return NULL;
}
virtual void StartThreads() {
@ -468,6 +479,37 @@ public:
return ped;
};
virtual double *getPedestalRMS(){
int nx, ny;
dets[0]->getDetectorSize(nx,ny);
double *rms=new double[nx*ny];
double *p0=new double[nx*ny];
for (int i=0; i<nThreads; i++) {
//inte=(slsInterpolation*)dets[i]->getInterpolation(nb,emi,ema);
// cout << i << endl;
p0=dets[i]->getPedestalRMS(p0);
if (p0) {
if (i==0) {
for (int ib=0; ib<nx*ny; ib++) {
rms[ib]=p0[ib]/((double)nThreads);
// cout << p0[ib] << " ";
}
} else {
for (int ib=0; ib<nx*ny; ib++) {
rms[ib]+=p0[ib]/((double)nThreads);
// cout << p0[ib] << " ";
}
}
}
}
delete [] p0;
return rms;
};
virtual double *setPedestal(double *h=NULL){
//int nb=0;
@ -504,6 +546,26 @@ public:
};
virtual void *writePedestalRMS(const char * imgname){
int nx, ny;
dets[0]->getDetectorSize(nx,ny);
double *rms=getPedestalRMS();
float *gm=new float[nx*ny];
if (gm) {
for (int ix=0; ix<nx*ny; ix++) {
gm[ix]=rms[ix];
}
WriteToTiff(gm,imgname ,nx, ny);
delete [] gm;
delete [] rms;
} else cout << "Could not allocate float image " << endl;
return NULL;
};
virtual void *readPedestal(const char * imgname, int nb=-1, double emin=1, double emax=0){
@ -560,7 +622,7 @@ public:
int *ff;
double *ped;
pthread_mutex_t fmutex;
};
};
#endif

View File

@ -28,8 +28,8 @@ public:
return (dets[0])->getFlatField();
}
virtual int *getFlatField(int &nb, double emi, double ema){
return (dets[0])->getFlatField(nb,emi,ema);
virtual int *getFlatField(int &nb, int &nby, double emi, double ema){
return (dets[0])->getFlatField(nb,nby,emi,ema);
}
virtual int *setFlatField(int *h=NULL, int nb=-1, double emin=1, double emax=0){
@ -46,7 +46,7 @@ public:
};
virtual int setNSubPixels(int ns) { return (dets[0])->setNSubPixels(ns);};
/* virtual int setNSubPixels(int ns) { return (dets[0])->setNSubPixels(ns);}; */
virtual void resetFlatField() {(dets[0])->resetFlatField();};
@ -69,15 +69,15 @@ public:
virtual int *getImage(int &nnx, int &nny, int &ns) {
if (getInterpolation()==NULL) return multiThreadedAnalogDetector::getImage(nnx,nny,ns);
virtual int *getImage(int &nnx, int &nny, int &nsx, int &nsy) {
if (getInterpolation()==NULL) return multiThreadedAnalogDetector::getImage(nnx,nny,nsx, nsy);
//if one interpolates, the whole image is stored in detector 0;
int *img;
// int nnx, nny, ns;
// int nnx, nny, ns;
int nn=dets[0]->getImageSize(nnx, nny,ns);
int nn=dets[0]->getImageSize(nnx, nny,nsx, nsy);
if (image) {
delete image;
delete [] image;
image=NULL;
}
image=new int[nn];

View File

@ -4,7 +4,7 @@
#include "analogDetector.h"
#include "single_photon_hit.h"
#include <mutex>
//#define MYROOT1
@ -62,13 +62,10 @@ public analogDetector<uint16_t> {
fm=new pthread_mutex_t ;
fm=new mutex;
// fm=new pthread_mutex_t ;
eventMask=new eventType*[ny];
for (int i=0; i<ny; i++) {
eventMask[i]=new eventType[nx];
}
eventMask=new eventType[ny*nx];
if (ny==1)
clusterSizeY=1;
@ -84,7 +81,7 @@ public analogDetector<uint16_t> {
/**
destructor. Deletes the cluster structure, the pdestalSubtraction and the image array
*/
virtual ~singlePhotonDetector() {delete [] clusters; for (int i=0; i<ny; i++) delete [] eventMask[i]; delete [] eventMask; };
virtual ~singlePhotonDetector() {delete [] clusters; for (int i=0; i<ny; i++) delete [] eventMask; };
@ -99,10 +96,7 @@ public analogDetector<uint16_t> {
nDark=orig->nDark;
myFile=orig->myFile;
eventMask=new eventType*[ny];
for (int i=0; i<ny; i++) {
eventMask[i]=new eventType[nx];
}
eventMask=new eventType[ny*nx];
eMin=orig->eMin;
eMax=orig->eMax;
@ -117,6 +111,9 @@ public analogDetector<uint16_t> {
setClusterSize(clusterSize);
fm=orig->fm;
//setMutex(orig->fm);
quad=UNDEFINED_QUADRANT;
tot=0;
@ -182,7 +179,7 @@ public analogDetector<uint16_t> {
nph=image;
//nph=new int[nx*ny];
double rest[ny][nx];
double rest[ny*nx];
//int cy=(clusterSizeY+1)/2; //quad size
//int cs=(clusterSize+1)/2; //quad size
@ -218,19 +215,19 @@ public analogDetector<uint16_t> {
cout << "add to common mode?"<< endl;
addToCommonMode(data);
}
for (int iy=ymin; iy<ymax; iy++) {
for (int ix=xmin; ix<xmax; ix++) {
for (int iy=ymin; iy<ymax; iy++) {
for (int ix=xmin; ix<xmax; ix++) {
if (det->isGood(ix,iy)) {
val=subtractPedestal(data,ix,iy, cm);
nn=analogDetector<uint16_t>::getNPhotons(data,ix,iy);//val/thr;//
if (nn>0) {
nph[ix+nx*iy]+=nn;
rest[iy][ix]=(val-nn*thr);//?+0.5*thr
rest[iy*nx+ix]=(val-nn*thr);//?+0.5*thr
nphFrame+=nn;
nphTot+=nn;
} else
rest[iy][ix]=val;
rest[iy*nx+ix]=val;
}
}
@ -240,7 +237,7 @@ public analogDetector<uint16_t> {
for (int ix=xmin; ix<xmax; ix++) {
if (det->isGood(ix,iy)) {
eventMask[iy][ix]=PEDESTAL;
eventMask[iy*nx+ix]=PEDESTAL;
max=0;
tl=0;
tr=0;
@ -249,15 +246,15 @@ public analogDetector<uint16_t> {
tot=0;
quadTot=0;
if (rest[iy][ix]>0.25*thr) {
eventMask[iy][ix]=NEIGHBOUR;
if (rest[iy*nx+ix]>0.25*thr) {
eventMask[iy*nx+ix]=NEIGHBOUR;
for (int ir=-(clusterSizeY/2); ir<(clusterSizeY/2)+1; ir++) {
for (int ic=-(clusterSize/2); ic<(clusterSize/2)+1; ic++) {
if ((iy+ir)>=0 && (iy+ir)<ny && (ix+ic)>=0 && (ix+ic)<nx) {
//clusters->set_data(rest[iy+ir][ix+ic], ic, ir);
//clusters->set_data(rest[(iy+ir)*nx+ix+ic], ic, ir);
v=rest[iy+ir][ix+ic];//clusters->get_data(ic,ir);
v=rest[(iy+ir)*nx+ix+ic];//clusters->get_data(ic,ir);
tot+=v;
if (ir<=0 && ic<=0)
@ -276,8 +273,9 @@ public analogDetector<uint16_t> {
//}
}
}
}
if (rest[iy][ix]>=max) {
if (rest[iy*nx+ix]>=max) {
if (bl>=br && bl>=tl && bl>=tr) {
quad=BOTTOM_LEFT;
quadTot=bl;
@ -289,9 +287,9 @@ public analogDetector<uint16_t> {
quadTot=tl;
} else if (tr>=bl && tr>=tl && tr>=br) {
quad=TOP_RIGHT;
quadTot=tr;
quadTot=tr;
}
if (nSigma==0) {
tthr=thr;
tthr1=thr;
@ -312,9 +310,9 @@ public analogDetector<uint16_t> {
}
if (tot>tthr1 || quadTot>tthr2 || max>tthr) {
eventMask[iy][ix]=PHOTON;
eventMask[iy*nx+ix]=PHOTON;
nph[ix+nx*iy]++;
rest[iy][ix]-=thr;
rest[iy*nx+ix]-=thr;
nphFrame++;
nphTot++;
@ -322,9 +320,8 @@ public analogDetector<uint16_t> {
}
}
}
}
}
}
}
} else return getClusters(data, nph);
}
return NULL;
@ -346,11 +343,11 @@ int *getClusters(char *data, int *ph=NULL) {
int nph=0;
double val[ny][nx];
double val[ny*nx];
int cy=(clusterSizeY+1)/2;
int cs=(clusterSize+1)/2;
//int ir, ic;
int iframe=det->getFrameNumber(data);
double max=0, tl=0, tr=0, bl=0,br=0, *v;
int cm=0;
int good=1;
@ -366,12 +363,12 @@ int *getClusters(char *data, int *ph=NULL) {
if (cm)
if (cm) {
addToCommonMode(data);
}
for (int iy=ymin; iy<ymax; iy++) {
for (int ix=xmin; ix<xmax; ix++) {
for (int iy=ymin; iy<ymax; iy++) {
for (int ix=xmin; ix<xmax; ix++) {
if (det->isGood(ix,iy)) {
max=0;
tl=0;
@ -384,7 +381,7 @@ int *getClusters(char *data, int *ph=NULL) {
eventMask[iy][ix]=PEDESTAL;
eventMask[iy*nx+ix]=PEDESTAL;
(clusters+nph)->rms=getPedestalRMS(ix,iy);
@ -394,35 +391,40 @@ int *getClusters(char *data, int *ph=NULL) {
for (int ir=-(clusterSizeY/2); ir<(clusterSizeY/2)+1; ir++) {
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, cm);
}
v=&(val[iy+ir][ix+ic]);
tot+=*v;
if (ir<=0 && ic<=0)
bl+=*v;
if (ir<=0 && ic>=0)
br+=*v;
if (ir>=0 && ic<=0)
tl+=*v;
if (ir>=0 && ic>=0)
tr+=*v;
if (*v>max) {
max=*v;
}
if ((iy+ir)>=0 && (iy+ir)<ny && (ix+ic)>=0 && (ix+ic)<nx) {
if ((iy+ir)>=iy &&(ix+ic)>=ix)
val[(iy+ir)*nx+ix+ic]=subtractPedestal(data,ix+ic,iy+ir, cm);
(clusters+nph)->set_data(val[(iy+ir)*nx+ix+ic],ic,ir);
v=&(val[(iy+ir)*nx+ix+ic]);
tot+=*v;
if (ir<=0 && ic<=0)
bl+=*v;
if (ir<=0 && ic>=0)
br+=*v;
if (ir>=0 && ic<=0)
tl+=*v;
if (ir>=0 && ic>=0)
tr+=*v;
if (*v>max) {
max=*v;
}
if (ir==0 && ic==0) {
if (*v<-nSigma*(clusters+nph)->rms)
eventMask[iy][ix]=NEGATIVE_PEDESTAL;
else if (*v>nSigma*(clusters+nph)->rms)
eventMask[iy][ix]=PHOTON;
}
if (ir==0 && ic==0) {
if (*v<-nSigma*(clusters+nph)->rms)
eventMask[iy*nx+ix]=NEGATIVE_PEDESTAL;
else if (*v>nSigma*(clusters+nph)->rms)
eventMask[iy*nx+ix]=PHOTON;
}
} else
(clusters+nph)->set_data(0,ic,ir);
}
}
if (eventMask[iy][ix]==PHOTON && val[iy][ix]<max)
if (eventMask[iy*nx+ix]==PHOTON && val[iy*nx+ix]<max)
continue;
if (bl>=br && bl>=tl && bl>=tr) {
@ -430,7 +432,7 @@ int *getClusters(char *data, int *ph=NULL) {
(clusters+nph)->quadTot=bl;
} else if (br>=bl && br>=tl && br>=tr) {
(clusters+nph)->quad=BOTTOM_RIGHT;
(clusters+nph)->quadTot=br;
(clusters+nph)->quadTot=br;
} else if (tl>=br && tl>=bl && tl>=tr) {
(clusters+nph)->quad=TOP_LEFT;
(clusters+nph)->quadTot=tl;
@ -438,34 +440,36 @@ int *getClusters(char *data, int *ph=NULL) {
(clusters+nph)->quad=TOP_RIGHT;
(clusters+nph)->quadTot=tr;
}
if (max>nSigma*(clusters+nph)->rms || tot>sqrt(clusterSizeY*clusterSize)*nSigma*(clusters+nph)->rms || ((clusters+nph)->quadTot)>sqrt(cy*cs)*nSigma*(clusters+nph)->rms) {
if (val[iy][ix]>=max) {
eventMask[iy][ix]=PHOTON_MAX;
(clusters+nph)->tot=tot;
(clusters+nph)->x=ix;
(clusters+nph)->y=iy;
// (clusters+nph)->iframe=det->getFrameNumber(data);
// cout << det->getFrameNumber(data) << " " << (clusters+nph)->iframe << endl;
(clusters+nph)->ped=getPedestal(ix,iy,0);
for (int ir=-(clusterSizeY/2); ir<(clusterSizeY/2)+1; ir++) {
for (int ic=-(clusterSize/2); ic<(clusterSize/2)+1; ic++) {
(clusters+nph)->set_data(val[iy+ir][ix+ic],ic,ir);
if (val[iy*nx+ix]>=max) {
eventMask[iy*nx+ix]=PHOTON_MAX;
// (clusters+nph)->tot=tot;
(clusters+nph)->x=ix;
(clusters+nph)->y=iy;
(clusters+nph)->iframe=iframe;
// cout << det->getFrameNumber(data) << " " << (clusters+nph)->iframe << endl;
// (clusters+nph)->ped=getPedestal(ix,iy,0);
// for (int ir=-(clusterSizeY/2); ir<(clusterSizeY/2)+1; ir++) {
// for (int ic=-(clusterSize/2); ic<(clusterSize/2)+1; ic++) {
// if ((iy+ir)>=0 && (iy+ir)<ny && (ix+ic)>=0 && (ix+ic)<nx)
// (clusters+nph)->set_data(val[(iy+ir)*nx+ix+ic],ic,ir);
// else
// (clusters+nph)->set_data(0,ic,ir);
// }
// }
good=1;
if (eMin>0 && tot<eMin) good=0;
if (eMax>0 && tot>eMax) good=0;
if (good) {
nph++;
image[iy*nx+ix]++;
}
}
good=1;
if (eMin>0 && tot<eMin) good=0;
if (eMax>0 && tot>eMax) good=0;
if (good) {
nph++;
image[iy*nx+ix]++;
}
} else {
eventMask[iy][ix]=PHOTON;
eventMask[iy*nx+ix]=PHOTON;
}
} else if (eventMask[iy][ix]==PEDESTAL) {
} else if (eventMask[iy*nx+ix]==PEDESTAL) {
addToPedestal(data,ix,iy,cm);
}
}
@ -474,8 +478,9 @@ int *getClusters(char *data, int *ph=NULL) {
nphFrame=nph;
nphTot+=nph;
//cout << nphFrame << endl;
// cout <<"**********************************"<< det->getFrameNumber(data) << " " << nphFrame << endl;
writeClusters(det->getFrameNumber(data));
if (iframe%10000==0)
cout <<"**********************************"<< iframe << " " << nphFrame << endl;
writeClusters(iframe);
return image;
};
@ -517,7 +522,7 @@ int *getClusters(char *data, int *ph=NULL) {
\param ir y coordinate (center is (0,0))
\returns event mask enum for the given pixel
*/
eventType getEventMask(int ic, int ir=0){return eventMask[ir][ic];};
eventType getEventMask(int ic, int ir=0){return eventMask[ir*nx+ic];};
#ifdef MYROOT1
@ -566,7 +571,9 @@ int *getClusters(char *data, int *ph=NULL) {
/* if (fwrite((void*)&fn, 1, sizeof(int), f)) */
/* if (fwrite((void*)&nph, 1, sizeof(int), f)) */
/* #endif */
for (int i=0; i<nph; i++) (cl+i)->write(f);
if (f)
for (int i=0; i<nph; i++) (cl+i)->write(f);
};
void writeClusters(FILE *f, int fn=0){
writeClusters(f,clusters,nphFrame, fn);
@ -576,12 +583,15 @@ int *getClusters(char *data, int *ph=NULL) {
void writeClusters(int fn){
if (myFile) {
//cout << "++" << endl;
pthread_mutex_lock(fm);
// cout <<"**********************************"<< fn << " " << nphFrame << endl;
//pthread_mutex_lock(fm);
fm->lock();
// cout <<id << " **********************************"<< fn << " " << nphFrame << endl;
writeClusters(myFile,clusters,nphFrame, fn);
// for (int i=0; i<nphFrame; i++)
// (clusters+i)->write(myFile);
pthread_mutex_unlock(fm);
// cout << "--" << endl;
fm->unlock();
//pthread_mutex_unlock(fm);
//cout << "--" << endl;
}
};
@ -613,12 +623,13 @@ int *getClusters(char *data, int *ph=NULL) {
void setEnergyRange(double emi, double ema){eMin=emi; eMax=ema;};
void getEnergyRange(double &emi, double &ema){emi=eMin; ema=eMax;};
void setMutex(pthread_mutex_t *m){fm=m;};
// void setMutex(pthread_mutex_t *m){fm=m;};
void setMutex(mutex *m){fm=m;};
protected:
int nDark; /**< number of frames to be used at the beginning of the dataset to calculate pedestal without applying photon discrimination */
eventType **eventMask; /**< matrix of event type or each pixel */
eventType *eventMask; /**< matrix of event type or each pixel */
double nSigma; /**< number of sigma parameter for photon discrimination */
double eMin, eMax;
int clusterSize; /**< cluster size in the x direction */
@ -631,8 +642,8 @@ int *getClusters(char *data, int *ph=NULL) {
int nphTot;
int nphFrame;
pthread_mutex_t *fm;
// pthread_mutex_t *fm;
mutex *fm;
};

View File

@ -44,8 +44,8 @@ class single_photon_hit {
//#endif
#ifndef WRITE_QUAD
//printf("no quad ");
if (fwrite((void*)&x, 2, sizeof(int16_t), myFile))
return fwrite((void*)data, 1, dx*dy*sizeof(int), myFile);
if (fwrite((void*)&x, sizeof(int16_t), 2, myFile))
return fwrite((void*)data, sizeof(int),dx*dy, myFile);
#endif
#ifdef WRITE_QUAD
// printf("quad ");
@ -91,8 +91,8 @@ class single_photon_hit {
default:
;
}
if (fwrite((void*)&x, 2, sizeof(int16_t), myFile))
return fwrite((void*)qq, 1, 4*sizeof(int), myFile);
if (fwrite((void*)&x, sizeof(int16_t), 2, myFile))
return fwrite((void*)qq, sizeof(int), 4, myFile);
#endif
return 0;
};
@ -110,53 +110,53 @@ class single_photon_hit {
#ifndef WRITE_QUAD
// printf( "no quad \n");
if (fread((void*)&x, 2, sizeof(int16_t), myFile))
return fread((void*)data, 1, dx*dy*sizeof(int), myFile);
return fread((void*)data,sizeof(int), dx*dy, myFile);
#endif
#ifdef WRITE_QUAD
int qq[4];
// printf( "quad \n");
if (fread((void*)&x, 2, sizeof(int16_t), myFile))
if (fread((void*)qq, 1, 4*sizeof(int), myFile)) {
if (fread((void*)&x, sizeof(int16_t), 2, myFile))
if (fread((void*)qq, sizeof(int), 4, myFile)) {
quad=TOP_RIGHT;
/* int mm=qq[0]; */
/* for (int i=1; i<4; i++) { */
/* if (qq[i]>mm) { */
/* switch (i) { */
/* case 1: */
/* quad=TOP_LEFT; */
/* break; */
/* case 2: */
/* quad=BOTTOM_RIGHT; */
/* break; */
/* case 3: */
/* quad=BOTTOM_LEFT; */
/* break; */
/* default: */
/* ; */
/* } */
int mm=qq[0];
for (int i=1; i<4; i++) {
if (qq[i]>mm) {
switch (i) {
case 1:
quad=TOP_LEFT;
break;
case 2:
quad=BOTTOM_RIGHT;
break;
case 3:
quad=BOTTOM_LEFT;
break;
default:
;
}
mm=qq[i];
}
/* } */
/* } */
}
/* switch(quad) { */
/* case TOP_LEFT: */
/* data[0]=0; */
/* data[1]=0; */
/* data[2]=0; */
/* data[3]=qq[0]; */
/* data[4]=qq[1]; */
/* data[5]=0; */
/* data[6]=qq[2]; */
/* data[7]=qq[3]; */
/* data[8]=0; */
/* x=x+1; */
/* y=y; */
/* break; */
switch(quad) {
case TOP_LEFT:
data[0]=0;
data[1]=0;
data[2]=0;
data[3]=qq[0];
data[4]=qq[1];
data[5]=0;
data[6]=qq[2];
data[7]=qq[3];
data[8]=0;
x=x+1;
y=y;
break;
/* case TOP_RIGHT: */
case TOP_RIGHT:
data[0]=0;
data[1]=0;
data[2]=0;
@ -168,40 +168,40 @@ class single_photon_hit {
data[8]=qq[3];
x=x;
y=y;
/* break; */
break;
/* case BOTTOM_LEFT: */
/* data[0]=qq[0]; */
/* data[1]=qq[1]; */
/* data[2]=0; */
/* data[3]=qq[2]; */
/* data[4]=qq[3]; */
/* data[5]=0; */
/* data[6]=0; */
/* data[7]=0; */
/* data[8]=0; */
/* x=x+1; */
/* y=y+1; */
/* break; */
/* case BOTTOM_RIGHT: */
/* data[0]=0; */
/* data[1]=qq[0]; */
/* data[2]=qq[1]; */
/* data[3]=0; */
/* data[4]=qq[2]; */
/* data[5]=qq[3]; */
/* data[6]=0; */
/* data[7]=0; */
/* data[8]=0; */
/* x=x; */
/* y=y+1; */
/* break; */
case BOTTOM_LEFT:
data[0]=qq[0];
data[1]=qq[1];
data[2]=0;
data[3]=qq[2];
data[4]=qq[3];
data[5]=0;
data[6]=0;
data[7]=0;
data[8]=0;
x=x+1;
y=y+1;
break;
case BOTTOM_RIGHT:
data[0]=0;
data[1]=qq[0];
data[2]=qq[1];
data[3]=0;
data[4]=qq[2];
data[5]=qq[3];
data[6]=0;
data[7]=0;
data[8]=0;
x=x;
y=y+1;
break;
/* default: */
/* ; */
/* } */
default:
;
}
return 1;
}
#endif
@ -210,7 +210,10 @@ class single_photon_hit {
};
void print() {
#ifdef WRITE_QUAD
printf("Q");
#endif
// int ix, iy;
printf("*** %d %d %d\n",iframe, x, y);
for (int iy=0; iy<dy; iy++) {

View File

@ -6,7 +6,7 @@
CROSS = bfin-uclinux-
CC = $(CROSS)gcc
CFLAGS += -Wall -DMOENCHD -DMCB_FUNCS -DDACS_INT -DDEBUG -DV1 -DCTB
CFLAGS += -Wall -DMOENCHD -DMCB_FUNCS -DDACS_INT -DDEBUG -DV1 -DCTB -DOLDVERSION
PROGS= jctbDetectorServer

View File

@ -1,9 +1,9 @@
Path: slsDetectorsPackage/slsDetectorSoftware/jctbDetectorServer
URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
Repsitory UUID: 9e5ec6a57bf206fe9384260fc4040867a9bbd71c
Revision: 33
Branch: developer
Last Changed Author: Erik_Frojdh
Last Changed Rev: 4065
Last Changed Date: 2019-01-30 17:38:35.000000002 +0100 ./firmware_funcs.c
Repsitory UUID: 53ba22dbc40d17c8ca77647d4ca2edad230f9f8a
Revision: 34
Branch: moench
Last Changed Author: Anna_Bergamaschi
Last Changed Rev: 4088
Last Changed Date: 2020-02-19 12:03:18.000000002 +0100 ./Makefile

View File

@ -1,6 +1,6 @@
#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
#define GITREPUUID "9e5ec6a57bf206fe9384260fc4040867a9bbd71c"
#define GITAUTH "Erik_Frojdh"
#define GITREV 0x4065
#define GITDATE 0x20190130
#define GITBRANCH "developer"
#define GITREPUUID "53ba22dbc40d17c8ca77647d4ca2edad230f9f8a"
#define GITAUTH "Anna_Bergamaschi"
#define GITREV 0x4088
#define GITDATE 0x20200219
#define GITBRANCH "moench"

View File

@ -4952,6 +4952,9 @@ int multiSlsDetector::createReceivingDataSockets(const bool destroy) {
cout << "Destroyed Receiving Data Socket(s)" << endl;
return OK;
}
if (client_downstream) {
return OK;
}
cprintf(MAGENTA, "Going to create data sockets\n");

View File

@ -3242,13 +3242,13 @@ string slsDetector::getSettingsDir() {
return std::string(thisDetector->settingsDir);
}
string slsDetector::setSettingsDir(string s) {
sprintf(thisDetector->settingsDir, s.c_str()); return thisDetector->settingsDir;
sprintf(thisDetector->settingsDir, "%s", s.c_str()); return thisDetector->settingsDir;
}
string slsDetector::getCalDir() {
return thisDetector->calDir;
}
string slsDetector::setCalDir(string s) {
sprintf(thisDetector->calDir, s.c_str()); return thisDetector->calDir;
sprintf(thisDetector->calDir, "%s", s.c_str()); return thisDetector->calDir;
}
@ -4110,10 +4110,13 @@ int slsDetector::configureMAC() {
//converting IPaddress to hex
stringstream ss(arg[0]);
char cword[50]="";
bzero(cword, 50);
memset(cword, 0, sizeof(cword));
string s;
while (getline(ss, s, '.')) {
sprintf(cword,"%s%02x",cword,atoi(s.c_str()));
char temp[20]="";
memset(temp, 0, sizeof(temp));
sprintf(temp,"%02x",atoi(s.c_str()));
strcat(cword, temp);
}
bzero(arg[0], 50);
strcpy(arg[0],cword);
@ -4126,12 +4129,12 @@ int slsDetector::configureMAC() {
//converting MACaddress to hex
stringstream ss(arg[1]);
char cword[50]="";
bzero(cword, 50);
memset(cword, 0, sizeof(cword));
string s;
while (getline(ss, s, ':')) {
sprintf(cword,"%s%s",cword,s.c_str());
strcat(cword, s.c_str());
}
bzero(arg[1], 50);
memset(arg[1], 0, sizeof(arg[1]));
strcpy(arg[1],cword);
#ifdef VERBOSE
std::cout<<"receiver mac:"<<arg[1]<<"."<<std::endl;
@ -4145,12 +4148,12 @@ int slsDetector::configureMAC() {
{
stringstream ss(arg[3]);
char cword[50]="";
bzero(cword, 50);
memset(cword, 0, sizeof(cword));
string s;
while (getline(ss, s, ':')) {
sprintf(cword,"%s%s",cword,s.c_str());
strcat(cword, s.c_str());
}
bzero(arg[3], 50);
memset(arg[3], 0, sizeof(arg[3]));
strcpy(arg[3],cword);
#ifdef VERBOSE
std::cout<<"detecotor mac:"<<arg[3]<<"."<<std::endl;
@ -4161,12 +4164,15 @@ int slsDetector::configureMAC() {
//converting IPaddress to hex
stringstream ss(arg[4]);
char cword[50]="";
bzero(cword, 50);
memset(cword, 0, sizeof(cword));
string s;
while (getline(ss, s, '.')) {
sprintf(cword,"%s%02x",cword,atoi(s.c_str()));
char temp[20]="";
memset(temp, 0, sizeof(temp));
sprintf(temp,"%02x",atoi(s.c_str()));
strcat(cword, temp);
}
bzero(arg[4], 50);
memset(arg[4], 0, sizeof(arg[4]));
strcpy(arg[4],cword);
#ifdef VERBOSE
std::cout<<"detector ip:"<<arg[4]<<"."<<std::endl;
@ -4426,7 +4432,7 @@ int64_t slsDetector::getTimeLeft(timerIndex index, int imod) {
int fnum=F_GET_TIME_LEFT;
int64_t retval;
int64_t retval = FAIL;
char mess[MAX_STR_LENGTH]="";
int ret=OK;
@ -6051,8 +6057,10 @@ int slsDetector::setUDPConnection() {
std::cout << "could not configure mac" << endl;
}
}
}else
}else{
ret=FAIL;
setErrorMask((getErrorMask())|(COULD_NOT_CONFIGURE_MAC));
}
#ifdef VERBOSE
printReceiverConfiguration();
#endif

View File

@ -846,6 +846,7 @@ virtual int enableDataStreamingFromReceiver(int enable=-1)=0;
case RUNNING: return std::string("running");\
case TRANSMITTING: return std::string("data"); \
case RUN_FINISHED: return std::string("finished"); \
case STOPPED: return std::string("stopped"); \
default: return std::string("idle"); \
}};

View File

@ -64,9 +64,12 @@ int slsDetectorUtils::acquire(int delflag){
if(!receiver){
setDetectorIndex(-1);
}
pthread_mutex_lock(&mg);
int nc=setTimer(CYCLES_NUMBER,-1);
int nf=setTimer(FRAME_NUMBER,-1);
pthread_mutex_unlock(&mg);
if (nc==0) nc=1;
if (nf==0) nf=1;
int multiframe = nc*nf;

View File

@ -93,7 +93,7 @@ class fileIO : public fileIOStatic, public virtual slsDetectorBase {
*/
virtual std::string setFilePath(std::string s) {
pthread_mutex_lock(&mf);
sprintf(filePath, s.c_str());
sprintf(filePath, "%s", s.c_str());
pthread_mutex_unlock(&mf);
return std::string(filePath);
};

View File

@ -151,6 +151,7 @@ void* ThreadPool::execute_thread(){
int ThreadPool::add_task(Task* task){
if(m_pool_size == 1){
(*task)();
delete task;
return 0;
}
m_task_mutex.lock();

View File

@ -106,4 +106,4 @@ install(TARGETS slsReceiverShared slsReceiverStatic slsReceiver
install(FILES ${ZMQ_STATIC_ARCHIVE}
DESTINATION lib)
DESTINATION lib)

View File

@ -62,6 +62,7 @@ else
$(CXX) -o $@ -c $< $(INCLUDES) $(DFLAGS) -fPIC $(EPICSFLAGS) $(LDFLAGRXR) -pthread $(FLAGS) $(LIBZMQ) -lrt
endif
versioning:
$(call colorecho,`./updateGitVersion.sh`)

View File

@ -206,7 +206,7 @@ class DataStreamer : private virtual slsReceiverDefs, public ThreadObject {
uint64_t firstMeasurementIndex;
/* File name to stream */
char fileNametoStream[MAX_STR_LENGTH];
std::string fileNametoStream;
/** Complete buffer used for roi, eg. shortGotthard */
char* completeBuffer;

View File

@ -56,8 +56,10 @@ public:
(ConvertInternetAddresstoIpString(result, ip, MAX_STR_LENGTH)))
throw std::exception();
std::string sip(ip);
// construct address
sprintf (sockfd.serverAddress, "tcp://%s:%d", ip, portno);
sprintf (sockfd.serverAddress, "tcp://%s:%d", sip.c_str(), portno);
#ifdef VERBOSE
cprintf(BLUE,"address:%s\n",sockfd.serverAddress);
#endif
@ -245,7 +247,7 @@ public:
*/
int SendHeaderData ( int index, bool dummy, uint32_t jsonversion, uint32_t dynamicrange = 0, uint64_t fileIndex = 0,
uint32_t npixelsx = 0, uint32_t npixelsy = 0, uint32_t imageSize = 0,
uint64_t acqIndex = 0, uint64_t fIndex = 0, char* fname = NULL,
uint64_t acqIndex = 0, uint64_t fIndex = 0, std::string fname = "",
uint64_t frameNumber = 0, uint32_t expLength = 0, uint32_t packetNumber = 0,
uint64_t bunchId = 0, uint64_t timestamp = 0,
uint16_t modId = 0, uint16_t row = 0, uint16_t column = 0, uint16_t reserved = 0,
@ -286,9 +288,9 @@ public:
"\"flippedDataX\":%u"
;//"}\n";
int length = sprintf(buf, jsonHeaderFormat,
sprintf(buf, jsonHeaderFormat,
jsonversion, dynamicrange, fileIndex, npixelsx, npixelsy, imageSize,
acqIndex, fIndex, (fname == NULL)? "":fname, dummy?0:1,
acqIndex, fIndex, fname.c_str(), dummy?0:1,
frameNumber, expLength, packetNumber, bunchId, timestamp,
modId, row, column, reserved, debug, roundRNumber,
@ -298,10 +300,12 @@ public:
((flippedData == 0 ) ? 0 :flippedData[0])
);
if (additionalJsonHeader && strlen(additionalJsonHeader)) {
length = sprintf(buf, "%s, %s}\n", buf, additionalJsonHeader);
} else {
length = sprintf(buf, "%s}\n", buf);
strcat(buf, ", ");
strcat(buf, additionalJsonHeader);
}
strcat(buf,"}\n");
int length = strlen(buf);
#ifdef VERBOSE
//if(!index)

View File

@ -21,7 +21,7 @@
#define FILE_BUFFER_SIZE (16*1024*1024) //16mb
//fifo
#define FIFO_HEADER_NUMBYTES 4
#define FIFO_HEADER_NUMBYTES 8
//hdf5

View File

@ -146,7 +146,7 @@ void DataProcessor::ResetParametersforNewMeasurement(){
delete [] tempBuffer;
tempBuffer = 0;
}
if (*gapPixelsEnable >= 0) {
if (*gapPixelsEnable) {
tempBuffer = new char[generalData->imageSize];
memset(tempBuffer, 0, generalData->imageSize);
}

View File

@ -40,7 +40,6 @@ DataStreamer::DataStreamer(int ind, Fifo*& f, uint32_t* dr, std::vector<ROI>* r,
FILE_LOG(logDEBUG) << "DataStreamer " << ind << " created";
memset(fileNametoStream, 0, MAX_STR_LENGTH);
}
@ -83,7 +82,7 @@ void DataStreamer::ResetParametersforNewMeasurement(char* fname){
runningFlag = false;
firstMeasurementIndex = 0;
measurementStartedFlag = false;
strcpy(fileNametoStream, fname);
fileNametoStream.assign(fname);
if (completeBuffer) {
delete [] completeBuffer;
completeBuffer = 0;

View File

@ -64,9 +64,11 @@ Listener::Listener(int ind, detectorType dtype, Fifo*& f, runStatus* s,
Listener::~Listener() {
if (udpSocket) delete udpSocket;
sem_post(&semaphore_socket);
sem_destroy(&semaphore_socket);
if (udpSocket) {
delete udpSocket;
sem_post(&semaphore_socket);
sem_destroy(&semaphore_socket);
}
if (carryOverPacket) delete [] carryOverPacket;
if (listeningPacket) delete [] listeningPacket;
ThreadObject::DestroyThread();
@ -228,7 +230,9 @@ void Listener::ShutDownUDPSocket() {
FILE_LOG(logINFO) << "Shut down of UDP port " << *udpPortNumber;
fflush(stdout);
//delete socket at stoplistening
sem_wait(&semaphore_socket);
if (runningFlag) {
sem_wait(&semaphore_socket);
}
delete udpSocket;
udpSocket = 0;
sem_destroy(&semaphore_socket);

View File

@ -16,12 +16,13 @@
#include <sys/wait.h> //wait
#include <unistd.h> //usleep
#include <syscall.h>
#include <semaphore.h>
sem_t semaphore;
bool keeprunning;
void sigInterruptHandler(int p){
keeprunning = false;
sem_post(&semaphore);
}
/*
@ -65,7 +66,7 @@ void GetData(char* metadata, char* datapointer, uint32_t datasize, void* p){
int main(int argc, char *argv[]) {
keeprunning = true;
sem_init(&semaphore,1,0);
cprintf(BLUE,"Created [ Tid: %ld ]\n", (long)syscall(SYS_gettid));
// Catch signal SIGINT to close files and call destructors properly
@ -148,8 +149,8 @@ int main(int argc, char *argv[]) {
FILE_LOG(logINFO) << "Ready ... ";
cprintf(RESET, "\n[ Press \'Ctrl+c\' to exit ]\n");
while(keeprunning)
pause();
sem_wait(&semaphore);
sem_destroy(&semaphore);
delete receiver;
cprintf(BLUE,"Exiting [ Tid: %ld ]\n", (long)syscall(SYS_gettid));