added slsDetectorData class to readout (analog) detectors

git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorCalibration@2 113b152e-814d-439b-b186-022a431db7b5
This commit is contained in:
bergamaschi 2013-09-24 08:13:42 +00:00
parent 7ca31b2a62
commit 6a1ffaeda0
2 changed files with 91 additions and 6 deletions

View File

@ -1,6 +0,0 @@
# DO NOT DELETE
./energyCalibration_cpp.so: energyCalibration.h
./energyCalibration_cpp.so: /afs/psi.ch/project/sls_det_software/root_v5.32.01_sl5_32bit/include/cintdictversion.h /afs/psi.ch/project/sls_det_software/root_v5.32.01_sl5_32bit/include/RVersion.h
energyCalibration_cpp__ROOTBUILDVERSION= 5.32/01

View File

@ -0,0 +1,91 @@
#ifndef SLSDETECTORDATA_H
#define SLSDETECTORDATA_H
class 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
\param ds size of the dataset
\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)
*/
slsDetectorData(int npx, int npy=1, int ds=-1, int **dMap=NULL, int **dMask=NULL) {
nx=npx;
ny=npy;
if (ds<=0)
dataSize=nx*ny;
else
dataSize=ds;
dataMap=new int[nx][ny];
dataMask=new int[nx][ny];
if (dMap==NULL) {
for (int iy=0; iy<ny; iy++)
for (int ix=0; ix<nx; ix++)
dataMap[ix][iy]=iy*nx+ix;
} else {
for (int iy=0; iy<ny; iy++)
for (int ix=0; ix<nx; ix++)
dataMap[ix][iy]=dMap[ix][iy];
}
if (dMap!=NULL) {
for (int iy=0; iy<ny; iy++)
for (int ix=0; ix<nx; ix++)
dataMask[ix][iy]=dMask[ix][iy];
}
};
/**
Returns the value of the selected channel for the given dataset (no error checking if number of pixels are compatible!)
\param data pointer to the dataset (including headers etc)
\param ix pixel numb er in the x direction
\param iy pixel number in the y direction
\returns data for the selected channel, with inversion if required
*/
int getChannel(int *data, int ix, int iy=1) {
return *(data+dataMap[ix][iy])^dataMask[ix][iy];
};
/**
Returns the value of the selected channel for the given dataset (no error checking if number of pixels are compatible!)
\param data pointer to the dataset (including headers etc)
\param ix pixel numb er in the x direction
\param iy pixel number in the y direction
\returns data for the selected channel, with inversion if required
*/
int getChannel(u_int16_t *data, int ix, int iy=1) {
return *(data+dataMap[ix][iy])^((u_int16_t)dataMask[ix][iy]);
};
private:
int nx; /**< Number of pixels in the x direction */
int ny; /**< Number of pixels in the y direction */
int dataSize; /**< Size of a dataset */
int **dataMap; /**< Array of size nx*ny storing the pointers to the data in the dataset (as offset)*/
int **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 */
};
#endif