mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-22 03:40:04 +02:00
slsDetectorUsers inherited by all classes i.e. API ready for EPICS driver
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@187 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
parent
ed84d21da0
commit
fe86145881
@ -1608,13 +1608,15 @@ int multiSlsDetector::setFlatFieldCorrection(string fname){
|
|||||||
int badlist[MAX_BADCHANS];
|
int badlist[MAX_BADCHANS];
|
||||||
int im=0;
|
int im=0;
|
||||||
|
|
||||||
|
if (fname=="default") {
|
||||||
|
fname=string(thisMultiDetector->flatFieldFile);
|
||||||
|
}
|
||||||
if (fname=="") {
|
if (fname=="") {
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
std::cout<< "disabling flat field correction" << std::endl;
|
std::cout<< "disabling flat field correction" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
thisMultiDetector->correctionMask&=~(1<<FLAT_FIELD_CORRECTION);
|
thisMultiDetector->correctionMask&=~(1<<FLAT_FIELD_CORRECTION);
|
||||||
strcpy(thisMultiDetector->flatFieldFile,"none");
|
// strcpy(thisMultiDetector->flatFieldFile,"none");
|
||||||
for (int i=0; i<thisMultiDetector->numberOfDetectors; i++) {
|
for (int i=0; i<thisMultiDetector->numberOfDetectors; i++) {
|
||||||
if (detectors[i])
|
if (detectors[i])
|
||||||
detectors[i]->setFlatFieldCorrection(NULL, NULL);
|
detectors[i]->setFlatFieldCorrection(NULL, NULL);
|
||||||
|
@ -265,7 +265,9 @@ class multiSlsDetector : public slsDetectorUtils {
|
|||||||
|
|
||||||
|
|
||||||
string getHostname(int pos=-1);
|
string getHostname(int pos=-1);
|
||||||
|
using slsDetectorBase::getDetectorType;
|
||||||
|
|
||||||
|
string getDetectorType(){return sgetDetectorsType();};
|
||||||
|
|
||||||
detectorType getDetectorsType(int pos=-1);
|
detectorType getDetectorsType(int pos=-1);
|
||||||
detectorType setDetectorsType(detectorType type=GET_DETECTOR_TYPE, int pos=-1){addSlsDetector(type, pos); return getDetectorsType(pos);};
|
detectorType setDetectorsType(detectorType type=GET_DETECTOR_TYPE, int pos=-1){addSlsDetector(type, pos); return getDetectorsType(pos);};
|
||||||
|
@ -3985,13 +3985,16 @@ int slsDetector::setFlatFieldCorrection(string fname){
|
|||||||
thisDetector->nBadFF=0;
|
thisDetector->nBadFF=0;
|
||||||
|
|
||||||
char ffffname[MAX_STR_LENGTH*2];
|
char ffffname[MAX_STR_LENGTH*2];
|
||||||
|
if (fname=="default") {
|
||||||
|
fname=string("thisDetector->flatFieldFile");
|
||||||
|
}
|
||||||
|
|
||||||
if (fname=="") {
|
if (fname=="") {
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
std::cout<< "disabling flat field correction" << std::endl;
|
std::cout<< "disabling flat field correction" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
thisDetector->correctionMask&=~(1<<FLAT_FIELD_CORRECTION);
|
thisDetector->correctionMask&=~(1<<FLAT_FIELD_CORRECTION);
|
||||||
strcpy(thisDetector->flatFieldFile,"none");
|
//strcpy(thisDetector->flatFieldFile,"none");
|
||||||
} else {
|
} else {
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
std::cout<< "Setting flat field correction from file " << fname << std::endl;
|
std::cout<< "Setting flat field correction from file " << fname << std::endl;
|
||||||
|
@ -258,7 +258,7 @@ typedef struct sharedSlsDetector {
|
|||||||
using slsDetectorUtils::getAngularConversion;
|
using slsDetectorUtils::getAngularConversion;
|
||||||
|
|
||||||
|
|
||||||
|
string getDetectorType(){return sgetDetectorsType();};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ Most methods of interest for the user are implemented in the ::slsDetectorBase i
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
//#include "slsDetectorUsers.h"
|
#include "slsDetectorUsers.h"
|
||||||
#include "sls_detector_defs.h"
|
#include "sls_detector_defs.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -64,8 +64,7 @@ using namespace std;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
//public virtual slsDetectorUsers,
|
//public virtual slsDetectorUsers,
|
||||||
class slsDetectorBase : public virtual slsDetectorDefs
|
class slsDetectorBase : public virtual slsDetectorDefs, public slsDetectorUsers {
|
||||||
{
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -76,7 +75,7 @@ class slsDetectorBase : public virtual slsDetectorDefs
|
|||||||
/** virtual destructor */
|
/** virtual destructor */
|
||||||
virtual ~slsDetectorBase(){};
|
virtual ~slsDetectorBase(){};
|
||||||
|
|
||||||
|
string getDetectorDeveloper(){return string("PSI");};
|
||||||
// protected:
|
// protected:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -275,7 +274,7 @@ class slsDetectorBase : public virtual slsDetectorDefs
|
|||||||
|
|
||||||
virtual int setFlatFieldCorrection(string fname="")=0;
|
virtual int setFlatFieldCorrection(string fname="")=0;
|
||||||
|
|
||||||
|
int setFlatFieldCorrectionFile(string fname=""){return setFlatFieldCorrection(fname);};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
set/get dynamic range
|
set/get dynamic range
|
||||||
@ -283,7 +282,7 @@ class slsDetectorBase : public virtual slsDetectorDefs
|
|||||||
\returns current dynamic range
|
\returns current dynamic range
|
||||||
*/
|
*/
|
||||||
virtual int setDynamicRange(int i=-1)=0;
|
virtual int setDynamicRange(int i=-1)=0;
|
||||||
|
int setBitDepth(int i=-1){return setDynamicRange(i);};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
set/get the size of the detector
|
set/get the size of the detector
|
||||||
@ -293,6 +292,12 @@ class slsDetectorBase : public virtual slsDetectorDefs
|
|||||||
*/
|
*/
|
||||||
virtual int setNumberOfModules(int i=-1, dimension d=X)=0;
|
virtual int setNumberOfModules(int i=-1, dimension d=X)=0;
|
||||||
|
|
||||||
|
int setDetectorSize(int x0=-1, int y0=-1, int nx=-1, int ny=-1){return setNumberOfModules(nx,X);};
|
||||||
|
|
||||||
|
int getDetectorSize(int &x0, int &y0, int &nx, int &ny){x0=0; nx=setNumberOfModules(-1,X); return nx;};
|
||||||
|
|
||||||
|
virtual int getMaxNumberOfModules(dimension d=X)=0; //
|
||||||
|
int getMaximumDetectorSize(int &nx, int &ny){nx=getMaxNumberOfModules(X); ny=1; return nx;};
|
||||||
|
|
||||||
|
|
||||||
/** Locks/Unlocks the connection to the server
|
/** Locks/Unlocks the connection to the server
|
||||||
@ -314,6 +319,7 @@ class slsDetectorBase : public virtual slsDetectorDefs
|
|||||||
*/
|
*/
|
||||||
virtual void acquire(int delflag=1)=0;
|
virtual void acquire(int delflag=1)=0;
|
||||||
|
|
||||||
|
int startMeasurement(){acquire(0); return OK;};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
asks and receives a data frame from the detector, writes it to disk and processes the data
|
asks and receives a data frame from the detector, writes it to disk and processes the data
|
||||||
@ -332,7 +338,7 @@ class slsDetectorBase : public virtual slsDetectorDefs
|
|||||||
\returns OK/FAIL
|
\returns OK/FAIL
|
||||||
*/
|
*/
|
||||||
virtual int stopAcquisition()=0;
|
virtual int stopAcquisition()=0;
|
||||||
|
int stopMeasurement(){return stopAcquisition();};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -342,6 +348,12 @@ class slsDetectorBase : public virtual slsDetectorDefs
|
|||||||
\returns timer set value in ns or number of...(e.g. frames, gates, probes)
|
\returns timer set value in ns or number of...(e.g. frames, gates, probes)
|
||||||
*/
|
*/
|
||||||
virtual int64_t setTimer(timerIndex index, int64_t t=-1)=0;
|
virtual int64_t setTimer(timerIndex index, int64_t t=-1)=0;
|
||||||
|
int64_t setExposureTime(int64_t t=-1){return setTimer(ACQUISITION_TIME,t);};
|
||||||
|
int64_t setExposurePeriod(int64_t t=-1){return setTimer(FRAME_PERIOD,t);};
|
||||||
|
int64_t setDelayAfterTrigger(int64_t t=-1){return setTimer(DELAY_AFTER_TRIGGER,t);};
|
||||||
|
int64_t setNumberOfGates(int64_t t=-1){return setTimer(GATES_NUMBER,t);};
|
||||||
|
int64_t setNumberOfFrames(int64_t t=-1){return setTimer(FRAME_NUMBER,t);};
|
||||||
|
int64_t setNumberOfCycles(int64_t t=-1){return setTimer(CYCLES_NUMBER,t);};
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
/**
|
/**
|
||||||
@ -349,7 +361,7 @@ class slsDetectorBase : public virtual slsDetectorDefs
|
|||||||
\returns status mask
|
\returns status mask
|
||||||
*/
|
*/
|
||||||
virtual runStatus getRunStatus()=0;
|
virtual runStatus getRunStatus()=0;
|
||||||
|
int getDetectorStatus() {return (int)getRunStatus();};
|
||||||
|
|
||||||
|
|
||||||
/** @short sets the onlineFlag
|
/** @short sets the onlineFlag
|
||||||
@ -363,15 +375,15 @@ class slsDetectorBase : public virtual slsDetectorDefs
|
|||||||
\returns current settings
|
\returns current settings
|
||||||
*/
|
*/
|
||||||
virtual detectorSettings setSettings(detectorSettings isettings, int imod=-1)=0;
|
virtual detectorSettings setSettings(detectorSettings isettings, int imod=-1)=0;
|
||||||
|
int setSettings(int isettings){return (int)setSettings((detectorSettings)isettings,-1);};
|
||||||
virtual detectorSettings getSettings(int imod=-1)=0;
|
virtual detectorSettings getSettings(int imod=-1)=0;
|
||||||
/**
|
/**
|
||||||
get threshold energy
|
get threshold energy
|
||||||
\param imod module number (-1 all)
|
\param imod module number (-1 all)
|
||||||
\returns current threshold value for imod in ev (-1 failed)
|
\returns current threshold value for imod in ev (-1 failed)
|
||||||
*/
|
*/
|
||||||
virtual int getThresholdEnergy(int imod=-1)=0;
|
virtual int getThresholdEnergy(int imod)=0;
|
||||||
|
int getThresholdEnergy(){return getThresholdEnergy(-1);};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
set/get the external communication mode
|
set/get the external communication mode
|
||||||
@ -381,6 +393,16 @@ class slsDetectorBase : public virtual slsDetectorDefs
|
|||||||
\returns current external communication mode
|
\returns current external communication mode
|
||||||
*/
|
*/
|
||||||
virtual externalCommunicationMode setExternalCommunicationMode(externalCommunicationMode pol=GET_EXTERNAL_COMMUNICATION_MODE)=0;
|
virtual externalCommunicationMode setExternalCommunicationMode(externalCommunicationMode pol=GET_EXTERNAL_COMMUNICATION_MODE)=0;
|
||||||
|
int setTimingMode(int i=-1){return (int)setExternalCommunicationMode((externalCommunicationMode)i);};
|
||||||
|
|
||||||
|
|
||||||
|
virtual int setThresholdEnergy(int e_eV, int imod, detectorSettings isettings=GET_SETTINGS)=0;
|
||||||
|
int setThresholdEnergy(int e_eV){return setThresholdEnergy(e_eV,-1);};
|
||||||
|
|
||||||
|
|
||||||
|
int getBeamEnergy(){return 2*getThresholdEnergy();};
|
||||||
|
int setBeamEnergy(int e){return 2*setThresholdEnergy(e/2);};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -389,8 +411,10 @@ class slsDetectorBase : public virtual slsDetectorDefs
|
|||||||
\returns OK or FAIL
|
\returns OK or FAIL
|
||||||
*/
|
*/
|
||||||
virtual int readConfigurationFile(string const fname)=0;
|
virtual int readConfigurationFile(string const fname)=0;
|
||||||
virtual int dumpDetectorSetup(string const fname, int level=0)=0;
|
virtual int dumpDetectorSetup(string const fname, int level)=0;
|
||||||
virtual int retrieveDetectorSetup(string const fname, int level=0)=0;
|
int dumpDetectorSetup(string const fname){return dumpDetectorSetup(fname,0);};
|
||||||
|
virtual int retrieveDetectorSetup(string const fname, int level)=0;
|
||||||
|
int retrieveDetectorSetup(string const fname){return retrieveDetectorSetup(fname,0);};
|
||||||
/**
|
/**
|
||||||
@short
|
@short
|
||||||
\returns the default output file index
|
\returns the default output file index
|
||||||
|
@ -735,3 +735,116 @@ int slsDetectorUtils::dumpDetectorSetup(string const fname, int level){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// int slsDetectorUtils::setFlatFieldCorrectionFile(string fname){
|
||||||
|
// int tch=getTotalNumberOfChannels();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// float data[tch], xmed[tch];
|
||||||
|
// float ffcoefficients[tch], fferrors[tch];
|
||||||
|
// int nmed=0;
|
||||||
|
// int idet=0, ichdet=-1;
|
||||||
|
// char ffffname[MAX_STR_LENGTH*2];
|
||||||
|
// int nbad=0, nch;
|
||||||
|
// int badlist[MAX_BADCHANS];
|
||||||
|
// int im=0;
|
||||||
|
|
||||||
|
// if (fname=="default") {
|
||||||
|
// fname=string(flatFieldFile);
|
||||||
|
// }
|
||||||
|
// if (fname=="") {
|
||||||
|
// #ifdef VERBOSE
|
||||||
|
// std::cout<< "disabling flat field correction" << std::endl;
|
||||||
|
// #endif
|
||||||
|
// (*correctionMask)&=~(1<<FLAT_FIELD_CORRECTION);
|
||||||
|
// // strcpy(thisMultiDetector->flatFieldFile,"none");
|
||||||
|
|
||||||
|
// setFlatFieldCorrection(NULL, NULL);
|
||||||
|
// } else {
|
||||||
|
|
||||||
|
// #ifdef VERBOSE
|
||||||
|
// std::cout<< "Setting flat field correction from file " << fname << std::endl;
|
||||||
|
// #endif
|
||||||
|
// sprintf(ffffname,"%s/%s",flatFieldDir,fname.c_str());
|
||||||
|
// nch=readDataFile(string(ffffname),data);
|
||||||
|
|
||||||
|
// if (nch>tch)
|
||||||
|
// nch=tch;
|
||||||
|
|
||||||
|
// if (nch>0) {
|
||||||
|
// strcpy(flatFieldFile,fname.c_str());
|
||||||
|
|
||||||
|
|
||||||
|
// nbad=0;
|
||||||
|
// for (int ichan=0; ichan<nch; ichan++) {
|
||||||
|
|
||||||
|
// if (data[ichan]>0) {
|
||||||
|
// /* add to median */
|
||||||
|
// im=0;
|
||||||
|
// while ((im<nmed) && (xmed[im]<data[ichan]))
|
||||||
|
// im++;
|
||||||
|
// for (int i=nmed; i>im; i--)
|
||||||
|
// xmed[i]=xmed[i-1];
|
||||||
|
// xmed[im]=data[ichan];
|
||||||
|
// nmed++;
|
||||||
|
// } else {
|
||||||
|
// if (nbad<MAX_BADCHANS) {
|
||||||
|
// badlist[nbad]=ichan;
|
||||||
|
// nbad++;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
// if (nmed>1 && xmed[nmed/2]>0) {
|
||||||
|
// #ifdef VERBOSE
|
||||||
|
// std::cout<< "Flat field median is " << xmed[nmed/2] << " calculated using "<< nmed << " points" << std::endl;
|
||||||
|
// #endif
|
||||||
|
|
||||||
|
// thisMultiDetector->correctionMask|=(1<<FLAT_FIELD_CORRECTION);
|
||||||
|
|
||||||
|
// // add to ff coefficients and errors of single detectors
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// for (int ichan=0; ichan<nch; ichan++) {
|
||||||
|
|
||||||
|
// setFlatFieldCorrection(ffcoefficients, fferrors);
|
||||||
|
|
||||||
|
// if (data[ichan]>0) {
|
||||||
|
// ffcoefficients[ichan]=xmed[nmed/2]/data[ichan];
|
||||||
|
// fferrors[ichan]=ffcoefficients[ichan]*sqrt(data[ichan])/data[ichan];
|
||||||
|
// } else {
|
||||||
|
// ffcoefficients[ichan]=0.;
|
||||||
|
// fferrors[ichan]=1.;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
|
// setFlatFieldCorrection(ffcoefficients, fferrors);
|
||||||
|
|
||||||
|
|
||||||
|
// } else {
|
||||||
|
// std::cout<< "Flat field data from file " << fname << " are not valid (" << nmed << "///" << xmed[nmed/2] << std::endl;
|
||||||
|
// thisMultiDetector->correctionMask&=~(1<<FLAT_FIELD_CORRECTION);
|
||||||
|
// for (int i=0; i<thisMultiDetector->numberOfDetectors; i++) {
|
||||||
|
// if (detectors[i])
|
||||||
|
// detectors[i]->setFlatFieldCorrection(NULL, NULL);
|
||||||
|
// }
|
||||||
|
// return -1;
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
// std::cout<< "Flat field from file " << fname << " is not valid " << nch << std::endl;
|
||||||
|
// thisMultiDetector->correctionMask&=~(1<<FLAT_FIELD_CORRECTION);
|
||||||
|
// for (int i=0; i<thisMultiDetector->numberOfDetectors; i++) {
|
||||||
|
// if (detectors[i])
|
||||||
|
// detectors[i]->setFlatFieldCorrection(NULL, NULL);
|
||||||
|
// }
|
||||||
|
// return -1;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return thisMultiDetector->correctionMask&(1<<FLAT_FIELD_CORRECTION);
|
||||||
|
// }
|
||||||
|
|
||||||
|
@ -71,6 +71,9 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
|
|||||||
using slsDetectorBase::setFlatFieldCorrection;
|
using slsDetectorBase::setFlatFieldCorrection;
|
||||||
using postProcessing::setBadChannelCorrection;
|
using postProcessing::setBadChannelCorrection;
|
||||||
|
|
||||||
|
int enableFlatFieldCorrection(int i=-1) {if (i>0) setFlatFieldCorrectionFile("default"); else if (i==0) setFlatFieldCorrectionFile(""); return getFlatFieldCorrection();}
|
||||||
|
int enablePixelMaskCorrection(int i=-1) {if (i>0) setBadChannelCorrection("default"); else if (i==0) setBadChannelCorrection(""); return getBadChannelCorrection();}
|
||||||
|
int enableCountRateCorrection(int i=-1){if (i>0) setRateCorrection(-1); else if (i==0) setRateCorrection(0); return getRateCorrection();}
|
||||||
// string getFilePath(){return fileIO::getFilePath();};
|
// string getFilePath(){return fileIO::getFilePath();};
|
||||||
// string setFilePath(string s){return fileIO::setFilePath(s);};
|
// string setFilePath(string s){return fileIO::setFilePath(s);};
|
||||||
|
|
||||||
|
@ -15,6 +15,10 @@ postProcessing::postProcessing(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int postProcessing::flatFieldCorrect(float datain, float errin, float &dataout, float &errout, float ffcoefficient, float fferr){
|
int postProcessing::flatFieldCorrect(float datain, float errin, float &dataout, float &errout, float ffcoefficient, float fferr){
|
||||||
float e;
|
float e;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user