mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-12 12:57:13 +02:00
WIP
This commit is contained in:
@ -1,71 +1,60 @@
|
||||
|
||||
#include <unistd.h>
|
||||
#include <cstring>
|
||||
#ifndef DETECTOR_DATA_H
|
||||
#define DETECTOR_DATA_H
|
||||
#pragma once
|
||||
/**
|
||||
@short data structure to hold the detector data after postprocessing (e.g. to plot, store in a root tree etc.)
|
||||
@short data structure to hold the detector data after postprocessing
|
||||
*/
|
||||
class detectorData {
|
||||
public:
|
||||
/** @short The constructor
|
||||
\param f_ind file index
|
||||
\param fname file name to which the data are saved
|
||||
\param np number of points in x coordinate defaults to the number of detector channels (1D detector) or dimension in x (2D detector)
|
||||
\param ny dimension in y (2D detector)
|
||||
\param cval pointer to data in char* format
|
||||
\param dbytes number of bytes of image pointed to by cval pointer
|
||||
\param dr dynamic range or bits per pixel
|
||||
\param file_ind file index
|
||||
/**
|
||||
* Constructor
|
||||
* @param progress progress index
|
||||
* @param fname file name prefix
|
||||
* @param nx number of detector channels (1D detector) or dimension in x (2D detector)
|
||||
* @param ny dimension in y (2D detector)
|
||||
* @param d pointer to data in char* format
|
||||
* @param dbytes number of bytes of image pointed to by cval pointer
|
||||
* @param dr dynamic range or bits per pixel
|
||||
* @param fIndex file index
|
||||
*/
|
||||
detectorData(double f_ind=-1,
|
||||
const char *fname="", int np=-1, int ny=1, char *cval=NULL, int dbytes=0, int dr=0,
|
||||
long long int file_ind=-1) :
|
||||
progressIndex(f_ind),
|
||||
npoints(np), npy(ny), cvalues(cval), databytes(dbytes),
|
||||
dynamicRange(dr), dgainvalues(NULL), fileIndex(file_ind) {
|
||||
strcpy(fileName,fname);
|
||||
};
|
||||
|
||||
|
||||
int64_t getChannel(int i) {
|
||||
int off=dynamicRange/8;
|
||||
if (off==1) {
|
||||
char val=*(cvalues+i);
|
||||
return val;
|
||||
}
|
||||
if (off==2) {
|
||||
int16_t val=*((int16_t*)(cvalues+i*off));
|
||||
return val;
|
||||
}
|
||||
if (off==4) {
|
||||
int32_t val=*((int32_t*)(cvalues+i*off));
|
||||
return val;
|
||||
}
|
||||
if (off==8) {
|
||||
int64_t val=*((int64_t*)(cvalues+i*off));
|
||||
return val;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
detectorData(double progress, std::string fname, int x, int y, char *d, int dbytes, int dr, uint64_t fIndex) :
|
||||
progressIndex(progress), fileName(fname), nx(x), ny(y), data(d), databytes(dbytes), dynamicRange(dr), gain(nullptr), fileIndex(fIndex) {};
|
||||
|
||||
/**
|
||||
@short The destructor
|
||||
deletes also the arrays pointing to data/errors/angles if not NULL
|
||||
cvalues are deleted by caller
|
||||
* Destructor
|
||||
* Also deletes gain
|
||||
* data has to be deleted by caller
|
||||
*/
|
||||
~detectorData() {if(dgainvalues) delete [] dgainvalues;};
|
||||
~detectorData() {if(gain) delete [] gain;};
|
||||
|
||||
int64_t getChannel(int i) {
|
||||
int off=dynamicRange/8;
|
||||
if (off==1) {
|
||||
char val=*(data+i);
|
||||
return val;
|
||||
}
|
||||
if (off==2) {
|
||||
int16_t val=*((int16_t*)(data+i*off));
|
||||
return val;
|
||||
}
|
||||
if (off==4) {
|
||||
int32_t val=*((int32_t*)(data+i*off));
|
||||
return val;
|
||||
}
|
||||
if (off==8) {
|
||||
int64_t val=*((int64_t*)(data+i*off));
|
||||
return val;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
//private:
|
||||
double progressIndex;/**< @short file index */
|
||||
char fileName[1000];/**< @short file name */
|
||||
int npoints;/**< @short number of points */
|
||||
int npy;/**< @short dimensions in y coordinate*/
|
||||
char* cvalues; /**< @short pointer to the data as char arary */
|
||||
int databytes; /**< @short number of bytes of data. Used with cvalues */
|
||||
int dynamicRange; /**< @short dynamic range */
|
||||
double* dgainvalues; /**< @short pointer to gain data as double array for Jungfrau only in show gain mode */
|
||||
long long int fileIndex; /**< @short file index */
|
||||
double progressIndex;
|
||||
std::string fileName;
|
||||
uint64_t fileIndex;
|
||||
int nx;
|
||||
int ny;
|
||||
char* data;
|
||||
double* gain;
|
||||
int databytes;
|
||||
int dynamicRange;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user