mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-07-09 17:38:01 +02:00
gainplot added, masking done separately before converting to double
This commit is contained in:
@ -279,6 +279,7 @@ multiSlsDetector::multiSlsDetector(int id) : slsDetectorUtils(), shmId(-1)
|
|||||||
threadpool = 0;
|
threadpool = 0;
|
||||||
if(createThreadPool() == FAIL)
|
if(createThreadPool() == FAIL)
|
||||||
exit(-1);
|
exit(-1);
|
||||||
|
gainDataEnable = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5436,7 +5437,7 @@ int multiSlsDetector::createReceivingDataSockets(const bool destroy){
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
int multiSlsDetector::getData(const int isocket, const bool masking, int* image, const int size,
|
int multiSlsDetector::getData(const int isocket, int* image, const int size,
|
||||||
uint64_t &acqIndex, uint64_t &frameIndex, uint32_t &subframeIndex, string &filename) {
|
uint64_t &acqIndex, uint64_t &frameIndex, uint32_t &subframeIndex, string &filename) {
|
||||||
|
|
||||||
//fail is on parse error or end of acquisition
|
//fail is on parse error or end of acquisition
|
||||||
@ -5446,14 +5447,6 @@ int multiSlsDetector::getData(const int isocket, const bool masking, int* image,
|
|||||||
//receiving incorrect size is replaced by 0xFF
|
//receiving incorrect size is replaced by 0xFF
|
||||||
zmqSocket[isocket]->ReceiveData(isocket, image, size);
|
zmqSocket[isocket]->ReceiveData(isocket, image, size);
|
||||||
|
|
||||||
//jungfrau masking adcval
|
|
||||||
if(masking){
|
|
||||||
unsigned int snel = size/sizeof(int);
|
|
||||||
for(unsigned int i=0;i<snel;++i){
|
|
||||||
image[i] = (image[i] & 0x3FFF3FFF);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5468,6 +5461,7 @@ void multiSlsDetector::readFrameFromReceiver(){
|
|||||||
int numSockets = thisMultiDetector->numberOfDetectors;
|
int numSockets = thisMultiDetector->numberOfDetectors;
|
||||||
int numSocketsPerSLSDetector = 1;
|
int numSocketsPerSLSDetector = 1;
|
||||||
bool jungfrau = false;
|
bool jungfrau = false;
|
||||||
|
double* gdata = NULL;
|
||||||
switch(getDetectorsType()){
|
switch(getDetectorsType()){
|
||||||
case EIGER:
|
case EIGER:
|
||||||
numSocketsPerSLSDetector = 2;
|
numSocketsPerSLSDetector = 2;
|
||||||
@ -5526,6 +5520,9 @@ void multiSlsDetector::readFrameFromReceiver(){
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int* multiframe=new int[nel]();
|
int* multiframe=new int[nel]();
|
||||||
|
int* multiframegain=NULL;
|
||||||
|
if (jungfrau)
|
||||||
|
multiframegain = new int[nel]();
|
||||||
int nch;
|
int nch;
|
||||||
|
|
||||||
bool runningList[numSockets];
|
bool runningList[numSockets];
|
||||||
@ -5552,7 +5549,7 @@ void multiSlsDetector::readFrameFromReceiver(){
|
|||||||
//if running
|
//if running
|
||||||
if (runningList[isocket]) {
|
if (runningList[isocket]) {
|
||||||
//get individual images
|
//get individual images
|
||||||
if(FAIL == getData(isocket, jungfrau, image, expectedslssize, currentAcquisitionIndex,currentFrameIndex,currentSubFrameIndex,currentFileName)){
|
if(FAIL == getData(isocket, image, expectedslssize, currentAcquisitionIndex,currentFrameIndex,currentSubFrameIndex,currentFileName)){
|
||||||
runningList[isocket] = false;
|
runningList[isocket] = false;
|
||||||
numRunning--;
|
numRunning--;
|
||||||
continue;
|
continue;
|
||||||
@ -5606,12 +5603,29 @@ void multiSlsDetector::readFrameFromReceiver(){
|
|||||||
|
|
||||||
//send data to callback
|
//send data to callback
|
||||||
if(running){
|
if(running){
|
||||||
|
if (jungfrau) {
|
||||||
|
// with gain data
|
||||||
|
if (gainDataEnable) {
|
||||||
|
memcpy(multiframegain, multiframe, nel * sizeof(int));
|
||||||
|
for(unsigned int i=0;i<nel;++i){
|
||||||
|
multiframegain[i] = ((multiframe[i] & 0xC0000000) >> 14) | ((multiframe[i] & 0x0000C000) >> 14) ;
|
||||||
|
multiframe[i] = (multiframe[i] & 0x3FFF3FFF);
|
||||||
|
}
|
||||||
|
gdata = decodeData(multiframegain,nch);
|
||||||
|
}
|
||||||
|
// without gain data
|
||||||
|
else {
|
||||||
|
for(unsigned int i=0;i<nel;++i)
|
||||||
|
multiframe[i] = (multiframe[i] & 0x3FFF3FFF);
|
||||||
|
}
|
||||||
|
}
|
||||||
fdata = decodeData(multiframe,nch);
|
fdata = decodeData(multiframe,nch);
|
||||||
if ((fdata) && (dataReady)){
|
if ((fdata) && (dataReady)){
|
||||||
thisData = new detectorData(fdata,NULL,NULL,getCurrentProgress(),currentFileName.c_str(),nx,ny);
|
thisData = new detectorData(fdata, NULL,NULL,getCurrentProgress(),currentFileName.c_str(),nx,ny, gdata);
|
||||||
dataReady(thisData, currentFrameIndex, currentSubFrameIndex, pCallbackArg);
|
dataReady(thisData, currentFrameIndex, currentSubFrameIndex, pCallbackArg);
|
||||||
delete thisData;
|
delete thisData;
|
||||||
fdata = NULL;
|
fdata = NULL;
|
||||||
|
gdata = NULL;
|
||||||
//cout<<"Send frame #"<< currentFrameIndex << " to gui"<<endl;
|
//cout<<"Send frame #"<< currentFrameIndex << " to gui"<<endl;
|
||||||
}
|
}
|
||||||
setCurrentProgress(currentAcquisitionIndex+1);
|
setCurrentProgress(currentAcquisitionIndex+1);
|
||||||
@ -5624,6 +5638,8 @@ void multiSlsDetector::readFrameFromReceiver(){
|
|||||||
//free resources
|
//free resources
|
||||||
delete [] image;
|
delete [] image;
|
||||||
delete[] multiframe;
|
delete[] multiframe;
|
||||||
|
if (jungfrau)
|
||||||
|
delete [] multiframegain;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -6256,3 +6272,8 @@ void multiSlsDetector::setExternalGuiFlag(bool b){
|
|||||||
bool multiSlsDetector::getExternalGuiFlag(){
|
bool multiSlsDetector::getExternalGuiFlag(){
|
||||||
return thisMultiDetector->externalgui;
|
return thisMultiDetector->externalgui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void multiSlsDetector::setGainDataEnableinDataCallback(bool e) {
|
||||||
|
gainDataEnable = e;
|
||||||
|
}
|
||||||
|
@ -1457,6 +1457,13 @@ class multiSlsDetector : public slsDetectorUtils {
|
|||||||
*/
|
*/
|
||||||
bool getExternalGuiFlag();
|
bool getExternalGuiFlag();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set Gain Data enable for gain plot
|
||||||
|
* in data call back
|
||||||
|
* @param e enable
|
||||||
|
*/
|
||||||
|
void setGainDataEnableinDataCallback(bool e);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -1464,7 +1471,6 @@ private:
|
|||||||
/**
|
/**
|
||||||
* Gets data from socket
|
* Gets data from socket
|
||||||
* @param isocket socket index
|
* @param isocket socket index
|
||||||
* @param masking if masking required (jungfrau)
|
|
||||||
* @param image image buffer
|
* @param image image buffer
|
||||||
* @param size size of image
|
* @param size size of image
|
||||||
* @param acqIndex address of acquisition index
|
* @param acqIndex address of acquisition index
|
||||||
@ -1472,7 +1478,7 @@ private:
|
|||||||
* @param subframeIndex address of subframe index
|
* @param subframeIndex address of subframe index
|
||||||
* @param filename address of file name
|
* @param filename address of file name
|
||||||
*/
|
*/
|
||||||
int getData(const int isocket, const bool masking, int* image, const int size, uint64_t &acqIndex, uint64_t &frameIndex, uint32_t &subframeIndex, string &filename);
|
int getData(const int isocket, int* image, const int size, uint64_t &acqIndex, uint64_t &frameIndex, uint32_t &subframeIndex, string &filename);
|
||||||
|
|
||||||
|
|
||||||
/** Ensures if sockets created successfully */
|
/** Ensures if sockets created successfully */
|
||||||
@ -1496,6 +1502,9 @@ private:
|
|||||||
private:
|
private:
|
||||||
ThreadPool* threadpool;
|
ThreadPool* threadpool;
|
||||||
|
|
||||||
|
/** Gain Data enabled in data call back */
|
||||||
|
bool gainDataEnable;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -16,15 +16,16 @@ class detectorData {
|
|||||||
\param fname file name to which the data are saved
|
\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)
|
\param np number of points in x coordinate defaults to the number of detector channels (1D detector)
|
||||||
\param ny dimension in y (1D detector)
|
\param ny dimension in y (1D detector)
|
||||||
|
\param gval pointer to gain data (for jungfrau)
|
||||||
*/
|
*/
|
||||||
detectorData(double *val=NULL, double *err=NULL, double *ang=NULL, double p_ind=-1, const char *fname="", int np=-1, int ny=1) : values(val), errors(err), angles(ang), progressIndex(p_ind), npoints(np), npy(ny){
|
detectorData(double *val=NULL, double *err=NULL, double *ang=NULL, double p_ind=-1, const char *fname="", int np=-1, int ny=1, double* gval=NULL) : values(val), errors(err), angles(ang), progressIndex(p_ind), npoints(np), npy(ny), gvalues(gval){
|
||||||
strcpy(fileName,fname);
|
strcpy(fileName,fname);
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
@short The destructor
|
@short The destructor
|
||||||
deletes also the arrays pointing to data/errors/angles if not NULL
|
deletes also the arrays pointing to data/errors/angles if not NULL
|
||||||
*/
|
*/
|
||||||
~detectorData() {if (values) delete [] values; if (errors) delete [] errors; if (angles) delete [] angles;};
|
~detectorData() {if (values) delete [] values; if (errors) delete [] errors; if (angles) delete [] angles; if (gvalues) delete [] gvalues;};
|
||||||
//private:
|
//private:
|
||||||
double *values; /**< @short pointer to the data */
|
double *values; /**< @short pointer to the data */
|
||||||
double *errors; /**< @short pointer to the errors */
|
double *errors; /**< @short pointer to the errors */
|
||||||
@ -33,6 +34,7 @@ class detectorData {
|
|||||||
char fileName[1000];/**< @short file name */
|
char fileName[1000];/**< @short file name */
|
||||||
int npoints;/**< @short number of points */
|
int npoints;/**< @short number of points */
|
||||||
int npy;/**< @short dimensions in y coordinate*/
|
int npy;/**< @short dimensions in y coordinate*/
|
||||||
|
double *gvalues; /**< @short pointer to the gain data */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user