still messing up

This commit is contained in:
bergamaschi 2015-03-31 14:50:45 +02:00
commit db4e6ea678
2 changed files with 177 additions and 53 deletions

View File

@ -0,0 +1,170 @@
#ifndef EIGERMODULEDATA_H
#define EIGERMODULEDATA_H
#include "slsReceiverData.h"
class eigerHalfModuleData : public slsReceiverData<uint32_t> {
public:
/**
Implements the slsReceiverData structure for the eiger prototype read out by a half module i.e. using the slsReceiver
(256*256 pixels, 512 packets for 16 bit mode, 256 for 8, 128 for 4, 1024 for 32, 1040 etc.)
\param d dynamic range
\param c crosstalk parameter for the output buffer
*/
eigerHalfModuleData(int dr, int np, int bsize, int dsize, double c=0): slsReceiverData<uint32_t>(xpixels, ypixels, np, bsize),
xtalk(c), dynamicRange(dr), bufferSize(bsize), dataSize(dsize){
int **dMap;
uint32_t **dMask;
dMap=new int*[ypixels];
dMask=new uint32_t*[ypixels];
for (int i = 0; i < ypixels; i++) {
dMap[i] = new int[xpixels];
dMask[i] = new uint32_t[xpixels];
}
//Map
int totalNumberOfBytes = 1040 * dynamicRange * 16 *2; //for both 1g and 10g
int iPacket1 = 8;
int iPacket2 = (totalNumberOfBytes/2) + 8;
int iData1 = 0, iData2 = 0;
int iPort;
for (int ir=0; ir<ypixels; ir++) {
for (int ic=0; ic<xpixels; ic++) {
iPort = ic / (xpixels/2);
if(!iPort){
dMap[ir][ic] = iPacket1;
iPacket1 += (dynamicRange / 8);
iData1 +=(dynamicRange / 8);
if(iData1 >= dataSize){
iPacket1 += 16;
iData1 = 0;
}
}else{
dMap[ir][ic] = iPacket2;
iPacket2 += (dynamicRange / 8);
iData2 +=(dynamicRange / 8);
if(iData2 >= dataSize){
iPacket2 += 16;
iData2 = 0;
}
}
}
}
//Mask
for(int ir=0; ir<ypixels; ++ir)
for(int ic=0; ic<xpixels; ++ic)
dMask[ir][ic] = 0x0;
setDataMap(dMap);
setDataMask(dMask);
};
/** Returns the frame number for the given dataset.
\param buff pointer to the dataset
\returns frame number
*/
int getFrameNumber(char *buff){
return htonl(*(unsigned int*)((eiger_image_header *)((char*)(buff)))->fnum);
};
/** gets the packets number (last packet is labelled with 0 and is replaced with 40)
\param buff pointer to the memory
\returns packet number
*/
int getPacketNumber(char *buff){
return htonl(*(unsigned int*)((eiger_packet_header *)((char*)(buff)))->num2);
};
/**
returns the pixel value as double correcting for the output buffer crosstalk
\param data pointer to the memory
\param ix coordinate in the x direction
\param iy coordinate in the y direction
\returns channel value as double
*/
double getValue(char *data, int ix, int iy=0) {
// cout << "##" << (void*)data << " " << ix << " " <<iy << endl;
if (xtalk==0)
return slsDetectorData<uint32_t>::getValue(data, ix, iy);
else
return slsDetectorData<uint32_t>::getValue(data, ix, iy)-xtalk*slsDetectorData<uint32_t>::getValue(data, ix-1, iy);
};
/** sets the output buffer crosstalk correction parameter
\param c output buffer crosstalk correction parameter to be set
\returns current value for the output buffer crosstalk correction parameter
*/
double setXTalk(double c) {xtalk=c; return xtalk;}
/** gets the output buffer crosstalk parameter
\returns current value for the output buffer crosstalk correction parameter
*/
double getXTalk() {return xtalk;}
private:
double xtalk; /**<output buffer crosstalk correction parameter */
const static int xpixels = 1024;
const static int ypixels = 256;
const int bufferSize;
const int dataSize;
const int dynamicRange;
/** structure of an eiger image header*/
typedef struct
{
unsigned char header_before[20];
unsigned char fnum[4];
unsigned char header_after[24];
} eiger_image_header;
/** structure of an eiger image header*/
typedef struct
{
unsigned char num1[4];
unsigned char num2[4];
} eiger_packet_header;
};
#endif

View File

@ -19,8 +19,6 @@ class slsDetectorData {
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;
public:
@ -41,8 +39,6 @@ class slsDetectorData {
slsDetectorData(int npx, int npy, int dsize, int **dMap=NULL, dataType **dMask=NULL, int **dROI=NULL): nx(npx), ny(npy), dataSize(dsize) {
cout << "data size is " << dataSize << endl;
cout << "detector size is " << nx << " " << ny << endl;
dataMask=new dataType*[ny];
for(int i = 0; i < ny; i++) {
@ -60,16 +56,6 @@ class slsDetectorData {
dataROIMask[i][j]=1;
}
cout << "map size is " << dataSize/sizeof(dataType) << endl;
xmap=new int[dataSize/sizeof(dataType)];
ymap=new int[dataSize/sizeof(dataType)];
for (int i=0 ; i<dataSize/sizeof(dataType); i++) {
xmap[i]=-1;
ymap[i]=-1;
}
setDataMap(dMap);
setDataMask(dMask);
setDataROIMask(dROI);
@ -77,29 +63,18 @@ class slsDetectorData {
};
virtual ~slsDetectorData() {
// cout <<"delete xmap, ymap" << endl;
delete[] xmap;
delete[] ymap;
// cout <<"delete first d" << endl;
for(int i = 0; i < ny; i++) {
// cout <<"delete data mask "<< i << endl;
delete[] dataMask[i];
// cout <<"delete data roi "<< i << endl;
delete[] dataROIMask[i];
// cout <<"delete data map "<< i << endl;
delete[] dataMap[i];
delete [] dataMap[i];
delete [] dataMask[i];
delete [] dataROIMask[i];
}
// cout <<"delete second d" << endl;
delete[] dataMap;
delete[] dataMask;
delete[] dataROIMask;
delete [] dataMap;
delete [] dataMask;
delete [] dataROIMask;
}
virtual void getPixel(int ip, int &x, int &y) {x=ip; y=0;};
virtual void getPixel(int ip, int &x, int &y) {if (ip>=0 && ip<dataSize) {x=xmap[ip]; y=ymap[ip];} else {x=-1; y=-1;};};
/**
@ -112,26 +87,6 @@ class slsDetectorData {
void setDataMap(int **dMap=NULL) {
<<<<<<< HEAD
if (dMap==NULL) {
for (int iy=0; iy<ny; iy++)
for (int ix=0; ix<nx; ix++) {
dataMap[iy][ix]=(iy*nx+ix)*sizeof(dataType);
}
} else {
cout << "set dmap "<< dataMap << " " << dMap << endl;
for (int iy=0; iy<ny; iy++)
for (int ix=0; ix<nx; ix++) {
dataMap[iy][ix]=dMap[iy][ix];
cout << ix << " " << iy << endl;
if (dMap[iy][ix]<dataSize) {
xmap[dMap[iy][ix]/sizeof(dataType)]=ix;
ymap[dMap[iy][ix]/sizeof(dataType)]=iy;
}
}
}
=======
if (dMap==NULL) {
for (int iy=0; iy<ny; iy++)
for (int ix=0; ix<nx; ix++)
@ -147,7 +102,6 @@ class slsDetectorData {
}
}
// cout << "nx:" <<nx << " ny:" << ny << endl;
>>>>>>> 7ef3348d521f1a704f974b05dd763cd65253dd98
};