added Jungrfau02 - does not really work

git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorCalibration@32 113b152e-814d-439b-b186-022a431db7b5
This commit is contained in:
jungmann_j 2014-02-05 10:35:29 +00:00
parent dd26dccde4
commit 71c66775cc
3 changed files with 230 additions and 1 deletions

View File

@ -0,0 +1,90 @@
#ifndef CHIPTESTDATA_H
#define CHIPTESTDATA_H
#include "slsDetectorData.h"
class chiptestBoardData : public slsDetectorData<uint16_t> {
public:
/**
chiptestBoard data structure. Works for data acquired using the chiptestBoard.
Inherits and implements slsDetectorData.
Constructor (no error checking if datasize and offsets are compatible!)
\param npx number of pixels in the x direction
\param npy number of pixels in the y direction (1 for strips)
\param nadc number of adcs
\param offset offset at the beginning of the pattern
\param dMap array of size nx*ny storing the pointers to the data in the dataset (as offset)
\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)
\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.
*/
chiptestBoardData(int npx, int npy, int nadc, int offset, int **dMap=NULL, uint16_t **dMask=NULL, int **dROI=NULL): \
slsDetectorData<uint16_t>(npx, npy, nadc*(npx*npy)+offset, dMap, dMask, dROI), nAdc(nadc), offSize(offset), iframe(0) {};
/**
Returns the frame number for the given dataset. Virtual func: works for slsDetectorReceiver data (also for each packet), but can be overloaded.
\param buff pointer to the dataset
\returns frame number
*/
virtual int getFrameNumber(char *buff){(void)buff; return iframe;};
/**
Loops over a memory slot until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). Can be overloaded for different kind of detectors!
\param data pointer to the memory to be analyzed
\param ndata size of frame returned
\param dsize size of the memory slot to be analyzed
\returns always return the pointer to data (no frame loss!)
*/
virtual char *findNextFrame(char *data, int &ndata, int dsize) {ndata=dsize;setDataSize(dsize); return data;};
/**
Loops over a file stream until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). Can be overloaded for different kind of detectors!
\param filebin input file stream (binary)
\returns pointer to the first packet of the last good frame, NULL if no frame is found or last frame is incomplete
*/
virtual char *readNextFrame(ifstream &filebin) {
int afifo_length=0; //int afifo_length;
uint16_t *afifo_cont;//2343 values for
if (filebin.is_open()) {
if (filebin.read((char*)&afifo_length,sizeof(uint32_t))) {
setDataSize(afifo_length*nAdc);
afifo_cont=new uint16_t[afifo_length];
if (filebin.read((char*)afifo_cont,afifo_length*sizeof(uint16_t)*nAdc)) {
iframe++;
return (char*)afifo_cont;
} else {
delete [] afifo_cont;
return NULL;
}
} else {
return NULL;
}
}
return NULL;
};
private:
const int nAdc; /**<number of ADC read out */
const int offSize; /**< offset at the beginning of the frame (depends on the pattern) */
int iframe; /**< frame number (calculated in software! not in the data)*/
};
#endif

View File

@ -0,0 +1,135 @@
#ifndef JUNGFRAU02DATA_H
#define JUNGFRAU02DATA_H
#include "chiptestBoardData.h"
class jungfrau02Data : public chiptestBoardData {
public:
/**
Implements the chiptestBoardData structure for the jungfrau02 prototype
(48x48 pixels, ADC2 for analog output, eventually 2 more for digital bits , offset configurable etc.)
\param c crosstalk parameter for the output buffer
*/
jungfrau02Data(int nadc, int offset, double c=0): chiptestBoardData(48, 48, nadc, offset),
xtalk(c) {
uint16_t **dMask;
int **dMap;
dMask=new uint16_t*[48];
dMap=new int*[48];
for (int i = 0; i < 48; i++) {
dMap[i] = new int[48];
dMask[i] = new uint16_t[48];
}
for (int iy=0; iy<48; iy++) {
for (int ix=0; ix<48; ix++) {
dMap[iy][ix]=offset+(iy*48+ix)*nAdc;
// cout << ix << " " << iy << " " << dMap[ix][iy] << endl;
}
}
for (int ix=0; ix<48; ix++) {
for (int iy=0; iy<48; iy++)
dMask[iy][ix]=0x0;
}
setDataMap(dMap);
setDataMask(dMask);
};
/**
Returns the value of the selected channel for the given dataset. Since the ADC is only 14bit wide, if the gain bits are read out they are returned in bit 14-15
\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
\returns data for the selected channel, with inversion if required
*/
virtual uint16_t getChannel(char *data, int ix, int iy=0) {
uint16_t m=0, d=0;
if (ix>=0 && ix<nx && iy>=0 && iy<ny && dataMap[iy][ix]>=0 && dataMap[iy][ix]<dataSize) {
m=dataMask[iy][ix];
d=*((uint16_t*)(data+dataMap[iy][ix]));
if (nAdc==3) {
if (*(uint16_t*)(data+dataMap[iy][ix]+1)>8000)
d|=(1<<14); // set gain bit 0
if (*(uint16_t*)(data+dataMap[iy][ix]+2)>8000)
d|=(1<<15); // set gain bit 1
}
}
return d^m;
};
/**
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 || ix==0)
return (double)(getChannel(data, ix, iy)&0x3ff);
else
return (double)(getChannel(data, ix, iy)&0x3ff)-xtalk* (double)(getChannel(data, ix, iy)&0x3ff);
};
/** 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 */
};
#endif

View File

@ -229,11 +229,15 @@ class slsDetectorData {
*/
virtual char *readNextFrame(ifstream &filebin)=0;
/** Returns the size of the data frame */
int getDataSize() {return dataSize;};
/** changes the size of the data frame */
int setDataSize(int d) {};//dataSize=d; return dataSize;};
protected:
const int nx; /**< Number of pixels in the x direction */
const int ny; /**< Number of pixels in the y direction */
const int dataSize; /**<size of the data constituting one frame */
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) */