Merge branch 'master' of gitorious.psi.ch:sls_det_software/sls_detector_calibration

Conflicts:
	slsDetectorData.h
This commit is contained in:
cartier_s
2015-05-28 14:29:45 +02:00
8 changed files with 601 additions and 80 deletions

View File

@@ -18,7 +18,8 @@ class slsDetectorData {
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;
public:
@@ -39,6 +40,8 @@ class slsDetectorData {
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[nx*ny];
ymap=new int[nx*ny];
dataMask=new dataType*[ny];
for(int i = 0; i < ny; i++) {
@@ -55,7 +58,9 @@ class slsDetectorData {
for (int j=0; j<nx; j++)
dataROIMask[i][j]=1;
}
setDataMap(dMap);
setDataMask(dMask);
setDataROIMask(dROI);
@@ -71,9 +76,11 @@ class slsDetectorData {
delete [] dataMap;
delete [] dataMask;
delete [] dataROIMask;
delete [] xmap;
delete [] ymap;
}
virtual void getPixel(int ip, int &x, int &y) {x=ip; y=0;};
virtual void getPixel(int ip, int &x, int &y) {x=xmap[ip]; y=ymap[ip];};
@@ -85,6 +92,7 @@ class slsDetectorData {
void setDataMap(int **dMap=NULL) {
<<<<<<< HEAD
if (dMap==NULL) {
@@ -100,6 +108,28 @@ class slsDetectorData {
}
}
=======
int ip;
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++){
// cout << iy << endl;
for (int ix=0; ix<nx; ix++) {
dataMap[iy][ix]=dMap[iy][ix];
// cout << ix << " " << iy << endl;
/*ip=dataMap[ix][iy]/sizeof(dataType);
xmap[ip]=ix;
ymap[ip]=iy;Annaa*/
}
}
}
// cout << "nx:" <<nx << " ny:" << ny << endl;
>>>>>>> 844c207d55aa5279626c496c677446de61103a30
};
@@ -197,8 +227,62 @@ class slsDetectorData {
return d^m;
};
/**
Returns the value of the selected channel for the given dataset. Virtual function, can be overloaded.
\param data pointer to the dataset (including headers etc)
\param ix pixel number in the x direction
\param iy pixel number in the y direction
\param dr dynamic range
\returns data for the selected channel, with inversion if required
*/
virtual dataType getChannel(char *data, int ix, int iy, int dr) {
dataType m=0;
uint64_t t;
int numBytes,divFactor,newix,pixelval;
//cout <<"ix:"<<ix<<" nx:"<<nx<<" iy:"<<ny<<" ny:"<<ny<<" datamap[iy][ix]:"<< dataMap[iy][ix] <<"datasize:"<< dataSize <<endl;
if (ix>=0 && ix<nx && iy>=0 && iy<ny && dataMap[iy][ix]>=0 && dataMap[iy][ix]<dataSize) {
m=dataMask[iy][ix];
numBytes = (nx * iy + ix);
divFactor=2;
if(dr == 4) divFactor = 16;
else if (dr == 8) divFactor = 8;
else if (dr == 16) divFactor = 4;
pixelval = numBytes % divFactor;
newix = ix - pixelval;
//cout <<"pixelval:"<<pixelval<<" newix:"<<newix<<endl;
//cout <<"64:"<< hex<<((uint64_t)(*((uint64_t*)(((char*)data)+(dataMap[iy][newix])))))<<endl;
t = (be64toh((uint64_t)(*((uint64_t*)(((char*)data)+(dataMap[iy][newix]))))));
//cout<<"t:"<<t<<endl;
}else
cprintf(RED,"outside limits\n");
if(dr == 4)
//uint8_t value = t >> (pixelval*4); cout <<"value:"<< value << endl;
return ((t >> (pixelval*4)) & 0xf)^m;
else if(dr == 8)
//uint8_t value = t >> (pixelval*8); cout <<"value:"<< value << endl;
return ((t >> (pixelval*8)) & 0xff)^m;
else if(dr == 16){
//uint16_t value = t >> (pixelval*16); cout <<"value:"<< value << endl;
return ((t >> (pixelval*16)) & 0xffff)^m;
}else{
//uint32_t value = t >> (pixelval*32); cout <<"value:"<< value << endl;
return ((t >> (pixelval*32)) & 0xffffffff)^m;
}
};
/**
Returns the value of the selected channel for the given dataset as double.
\param data pointer to the dataset (including headers etc)
\param ix pixel number in the x direction
@@ -208,6 +292,20 @@ class slsDetectorData {
*/
virtual double getValue(char *data, int ix, int iy=0) {return (double)getChannel(data, ix, iy);};
/**
Returns the value of the selected channel for the given dataset as double.
\param data pointer to the dataset (including headers etc)
\param ix pixel number in the x direction
\param iy pixel number in the y direction
\param dr dynamic range
\returns data for the selected channel, with inversion if required as double
*/
virtual double getValue(char *data, int ix, int iy, int dr) {
return ((double)getChannel(data, ix, iy, dr));
};
/**
Returns the frame number for the given dataset. Purely virtual func.