mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-19 08:17:13 +02:00
After some speed optimization...
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@171 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
@ -15,7 +15,7 @@
|
||||
using namespace std;
|
||||
|
||||
/**
|
||||
angular conversion constant for a module
|
||||
@short Angular conversion constants needed for a detector module
|
||||
*/
|
||||
typedef struct {
|
||||
float center; /**< center of the module (channel at which the radius is perpendicular to the module surface) */
|
||||
@ -30,14 +30,20 @@ typedef struct {
|
||||
|
||||
|
||||
/**
|
||||
class containing the methods to set/unset the angular conversion and merge the data
|
||||
The angular conversion itself is stored in the slsDetector/multiSlsDetector class!
|
||||
|
||||
@short methods to set/unset the angular conversion and merge the data
|
||||
class containing the methods to set/unset the angular conversion and merge the data
|
||||
|
||||
|
||||
The angular conversion itself is defined by the angle() function defined in usersFunctions.cpp
|
||||
|
||||
*/
|
||||
class angularConversion : public slsDetectorDefs {
|
||||
|
||||
public:
|
||||
/** default constructor */
|
||||
angularConversion();
|
||||
/** virtual destructor */
|
||||
virtual ~angularConversion();
|
||||
|
||||
|
||||
@ -51,45 +57,68 @@ class angularConversion : public slsDetectorDefs {
|
||||
|
||||
reads an angular conversion file
|
||||
\param fname file to be read
|
||||
\param nmod number of modules (maximum) to be read
|
||||
\param angOff pointer to array of angleConversionConstants
|
||||
\returns OK or FAIL
|
||||
*/
|
||||
static int readAngularConversion(string fname, int nmod, angleConversionConstant *angOff);
|
||||
|
||||
/**
|
||||
|
||||
MOVE TO ANGULAR CALIBRATION?!?!??!?
|
||||
reads an angular conversion file
|
||||
\param fname file to be read
|
||||
\param ifstream input file stream to be read
|
||||
\param nmod number of modules (maximum) to be read
|
||||
\param angOff pointer to array of angleConversionConstants
|
||||
\returns OK or FAIL
|
||||
|
||||
*/
|
||||
static int readAngularConversion(ifstream& ifs, int nmod, angleConversionConstant *angOff);
|
||||
/**
|
||||
MOVE TO ANGULAR CALIBRATION?!?!??!?
|
||||
writes an angular conversion file
|
||||
\param fname file to be written
|
||||
\sa angleConversionConstant mythenDetector::writeAngularConversion
|
||||
\param nmod number of modules to be written
|
||||
\param angOff pointer to array of angleConversionConstants
|
||||
\returns OK or FAIL
|
||||
*/
|
||||
static int writeAngularConversion(string fname, int nmod, angleConversionConstant *angOff);
|
||||
|
||||
/**
|
||||
MOVE TO ANGULAR CALIBRATION?!?!??!?
|
||||
writes an angular conversion file
|
||||
\param fname file to be written
|
||||
\sa angleConversionConstant mythenDetector::writeAngularConversion
|
||||
\param ofstream output file stream
|
||||
\param nmod number of modules to be written
|
||||
\param angOff pointer to array of angleConversionConstants
|
||||
\returns OK or FAIL
|
||||
*/
|
||||
static int writeAngularConversion(ofstream& ofs, int nmod, angleConversionConstant *angOff);
|
||||
|
||||
/**
|
||||
pure virtual function
|
||||
\param file name to be written (nmod and array of angular conversion constants default to the ones ot the slsDetector
|
||||
*/
|
||||
virtual int writeAngularConversion(string fname)=0;
|
||||
|
||||
/**
|
||||
MOVE TO ANGULAR CALIBRATION?!?!??!?
|
||||
sets the arrays of the merged data to 0. NB The array should be created with size >= 360./getBinSize();
|
||||
\param mp already merged postions
|
||||
\param mv already merged data
|
||||
\param me already merged errors (squared sum)
|
||||
\param mm multiplicity of merged arrays
|
||||
\returns OK or FAIL
|
||||
\sa mythenDetector::resetMerging
|
||||
*/
|
||||
sets the arrays of the merged data to 0. NB The array should be created with size nbins >= 360./getBinSize();
|
||||
\param mp already merged postions
|
||||
\param mv already merged data
|
||||
\param me already merged errors (squared sum)
|
||||
\param mm multiplicity of merged arrays
|
||||
\param nbins number of bins
|
||||
\returns OK or FAIL
|
||||
*/
|
||||
static int resetMerging(float *mp, float *mv,float *me, int *mm, int nbins);
|
||||
/**
|
||||
sets the arrays of the merged data to 0. NB The array should be created with size >= 360./getBinSize();
|
||||
\param mp already merged postions
|
||||
\param mv already merged data
|
||||
\param me already merged errors (squared sum)
|
||||
\param mm multiplicity of merged arrays
|
||||
\returns OK or FAIL
|
||||
*/
|
||||
int resetMerging(float *mp, float *mv,float *me, int *mm);
|
||||
|
||||
/**
|
||||
creates the arrays for merging the data and sets them to 0.
|
||||
*/
|
||||
int resetMerging();
|
||||
|
||||
/**
|
||||
@ -110,92 +139,152 @@ class angularConversion : public slsDetectorDefs {
|
||||
|
||||
static int addToMerging(float *p1, float *v1, float *e1, float *mp, float *mv,float *me, int *mm, int nchans, float binsize,int nb, int *badChanMask );
|
||||
|
||||
/**
|
||||
merge dataset
|
||||
\param p1 angular positions of dataset
|
||||
\param v1 data
|
||||
\param e1 errors
|
||||
\param mp already merged postions
|
||||
\param mv already merged data
|
||||
\param me already merged errors (squared sum)
|
||||
\param mm multiplicity of merged arrays
|
||||
\param badChanMask badchannelmask (if NULL does not correct for bad channels)
|
||||
\returns OK or FAIL
|
||||
*/
|
||||
|
||||
int addToMerging(float *p1, float *v1, float *e1, float *mp, float *mv,float *me, int *mm, int *badChanMask);
|
||||
/**
|
||||
merge dataset
|
||||
\param p1 angular positions of dataset
|
||||
\param v1 data
|
||||
\param e1 errors
|
||||
\param badChanMask badchannelmask (if NULL does not correct for bad channels)
|
||||
\returns OK or FAIL
|
||||
*/
|
||||
|
||||
int addToMerging(float *p1, float *v1, float *e1,int *badChanMask);
|
||||
|
||||
/**
|
||||
MOVE TO ANGULAR CALIBRATION?!?!??!?
|
||||
calculates the "final" positions, data value and errors for the emrged data
|
||||
calculates the "final" positions, data value and errors for the merged data
|
||||
\param mp already merged postions
|
||||
\param mv already merged data
|
||||
\param me already merged errors (squared sum)
|
||||
\param mm multiplicity of merged arrays
|
||||
\param nb number of bins
|
||||
\returns FAIL or the number of non empty bins (i.e. points belonging to the pattern)
|
||||
*/
|
||||
|
||||
static int finalizeMerging(float *mp, float *mv,float *me, int *mm, int nb);
|
||||
/**
|
||||
calculates the "final" positions, data value and errors for the merged data
|
||||
\param mp already merged postions
|
||||
\param mv already merged data
|
||||
\param me already merged errors (squared sum)
|
||||
\param mm multiplicity of merged arrays
|
||||
\returns FAIL or the number of non empty bins (i.e. points belonging to the pattern)
|
||||
\sa mythenDetector::finalizeMerging
|
||||
*/
|
||||
|
||||
static int finalizeMerging(float *mp, float *mv,float *me, int *mm, int nb);
|
||||
int finalizeMerging(float *mp, float *mv,float *me, int *mm);
|
||||
|
||||
/**
|
||||
calculates the "final" positions, data value and errors for the merged data
|
||||
\returns FAIL or the number of non empty bins (i.e. points belonging to the pattern)
|
||||
*/
|
||||
|
||||
int finalizeMerging(float *mp, float *mv,float *me, int *mm);
|
||||
int finalizeMerging();
|
||||
|
||||
|
||||
/**
|
||||
pure virtual function
|
||||
set detector global offset
|
||||
\sa mythenDetector::setGlobalOffset
|
||||
\param f global offset to be set
|
||||
\returns actual global offset
|
||||
*/
|
||||
float setGlobalOffset(float f){return setAngularConversionParameter(GLOBAL_OFFSET,f);};
|
||||
|
||||
|
||||
/**
|
||||
pure virtual function
|
||||
set detector fine offset
|
||||
\sa mythenDetector::setFineOffset
|
||||
\param f global fine to be set
|
||||
\returns actual fine offset
|
||||
*/
|
||||
float setFineOffset(float f){return setAngularConversionParameter(FINE_OFFSET,f);};
|
||||
|
||||
/**
|
||||
pure virtual function
|
||||
get detector fine offset
|
||||
\sa mythenDetector::getFineOffset
|
||||
\returns actual fine offset
|
||||
*/
|
||||
float getFineOffset(){return getAngularConversionParameter(FINE_OFFSET);};
|
||||
|
||||
/**
|
||||
pure virtual function
|
||||
get detector global offset
|
||||
\sa mythenDetector::getGlobalOffset
|
||||
\returns actual global offset
|
||||
*/
|
||||
float getGlobalOffset(){return getAngularConversionParameter(GLOBAL_OFFSET);};
|
||||
|
||||
/**
|
||||
|
||||
set detector bin size used for merging (approx angular resolution)
|
||||
\param bs bin size in degrees
|
||||
\returns current bin size
|
||||
\sa mythenDetector::setBinSize
|
||||
*/
|
||||
set detector bin size
|
||||
\param bs bin size to be set
|
||||
\returns actual bin size
|
||||
*/
|
||||
float setBinSize(float bs){return setAngularConversionParameter(BIN_SIZE,bs);};
|
||||
|
||||
/**
|
||||
return detector bin size used for merging (approx angular resolution)
|
||||
\sa mythenDetector::getBinSize
|
||||
get detector bin size
|
||||
\returns detector bin size used for merging (approx angular resolution)
|
||||
*/
|
||||
float getBinSize() {return getAngularConversionParameter(BIN_SIZE);};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
get angular direction
|
||||
\returns actual angular direction (1 is channel number increasing with angle, -1 decreasing)
|
||||
*/
|
||||
int getAngularDirection(){return (int)getAngularConversionParameter(ANGULAR_DIRECTION);};
|
||||
|
||||
|
||||
/**
|
||||
|
||||
set angular direction
|
||||
\param d angular direction to be set (1 is channel number increasing with angle, -1 decreasing)
|
||||
\returns actual angular direction (1 is channel number increasing with angle, -1 decreasing)
|
||||
*/
|
||||
int setAngularDirection(int d){return (int)setAngularConversionParameter(ANGULAR_DIRECTION, (float)d);};
|
||||
|
||||
|
||||
/**
|
||||
\returns number of angular bins in the merging (360./binsize)
|
||||
*/
|
||||
int getNumberOfAngularBins(){return nBins;};
|
||||
|
||||
/**
|
||||
get angular conversion
|
||||
\param direction reference to diffractometer direction
|
||||
get angular conversion
|
||||
\param direction reference to diffractometer direction
|
||||
\param angconv array that will be filled with the angular conversion constants
|
||||
\returns 0 if angular conversion disabled, >0 otherwise
|
||||
*/
|
||||
virtual int getAngularConversion(int &direction, angleConversionConstant *angconv=NULL)=0;
|
||||
|
||||
float setAngularConversionParameter(angleConversionParameter c, float v);
|
||||
|
||||
/**
|
||||
set angular conversion parameter
|
||||
\param c parameter type (globaloffset, fineoffset, binsize, angular direction, move flag)
|
||||
\param v value to be set
|
||||
\returns actual value
|
||||
*/
|
||||
float setAngularConversionParameter(angleConversionParameter c, float v);
|
||||
/**
|
||||
get angular conversion parameter
|
||||
\param c parameter type (globaloffset, fineoffset, binsize, angular direction, move flag)
|
||||
\returns actual value
|
||||
*/
|
||||
float getAngularConversionParameter(angleConversionParameter c);
|
||||
|
||||
|
||||
/**
|
||||
pure virtual function
|
||||
\returns total number of channels of the (multi)detector
|
||||
*/
|
||||
virtual int getTotalNumberOfChannels()=0;
|
||||
|
||||
|
||||
@ -214,10 +303,23 @@ class angularConversion : public slsDetectorDefs {
|
||||
*/
|
||||
virtual int getPositions(float *pos=NULL);
|
||||
|
||||
/**
|
||||
deletes the array of merged data
|
||||
\returns OK
|
||||
*/
|
||||
int deleteMerging();
|
||||
|
||||
/**
|
||||
\returns pointer to the array o merged positions
|
||||
*/
|
||||
float *getMergedPositions(){return mergingBins;};
|
||||
/**
|
||||
\returns pointer to the array of merged counts
|
||||
*/
|
||||
float *getMergedCounts(){return mergingCounts;};
|
||||
/**
|
||||
\returns pointer to the array of merged errors
|
||||
*/
|
||||
float *getMergedErrors(){return mergingErrors;};
|
||||
|
||||
|
||||
@ -237,42 +339,86 @@ class angularConversion : public slsDetectorDefs {
|
||||
string getAngularConversionFile(){if (setAngularCorrectionMask()) return string(angConvFile); else return string("none");};
|
||||
|
||||
|
||||
/**
|
||||
reads teh angular conversion file for the (multi)detector and writes it to shared memory
|
||||
*/
|
||||
virtual int readAngularConversionFile(string fname="")=0;
|
||||
|
||||
|
||||
// int setAngularConversionPointer(angleConversionConstant *p, int *nm, int nch, int idet=0);
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
\returns number of modules of the (multi)detector
|
||||
*/
|
||||
virtual int getNMods()=0;
|
||||
|
||||
/**
|
||||
returns number of channels in the module
|
||||
\param imod module number
|
||||
\returns number of channels in the module
|
||||
*/
|
||||
virtual int getChansPerMod(int imod=0)=0;
|
||||
|
||||
/**
|
||||
get the angular conversion contant of one modules
|
||||
\param imod module number
|
||||
\returns pointer to the angular conversion constant
|
||||
*/
|
||||
virtual angleConversionConstant *getAngularConversionPointer(int imod=0)=0;
|
||||
|
||||
/**
|
||||
converts channel number to angle
|
||||
\param pos encoder position
|
||||
\returns array of angles corresponding to the channels
|
||||
*/
|
||||
float* convertAngles(float pos);
|
||||
|
||||
/**
|
||||
converts channel number to angle for the current encoder position
|
||||
\returns array of angles corresponding to the channels
|
||||
*/
|
||||
float *convertAngles(){return convertAngles(currentPosition);};
|
||||
|
||||
/**
|
||||
\param imod module number
|
||||
\returns move flag of the module (1 encoder is added to the angle, 0 not)
|
||||
*/
|
||||
virtual int getMoveFlag(int imod)=0;
|
||||
|
||||
/**
|
||||
returns current position index
|
||||
*/
|
||||
int getCurrentPositionIndex() {return currentPositionIndex;};
|
||||
|
||||
/**
|
||||
returns number of positions
|
||||
*/
|
||||
int getNumberOfPositions() {return *numberOfPositions;};
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
/** pointer to number of positions for the acquisition*/
|
||||
int *numberOfPositions;
|
||||
|
||||
/** pointer to the detector positions for the acquisition*/
|
||||
float *detPositions;
|
||||
|
||||
/** pointer to angular conversion file name*/
|
||||
char *angConvFile;
|
||||
|
||||
/** pointer to angular bin size*/
|
||||
float *binSize;
|
||||
|
||||
/** pointer to beamlien fine offset*/
|
||||
float *fineOffset;
|
||||
/** pointer to beamlien global offset*/
|
||||
float *globalOffset;
|
||||
/** pointer to beamlien angular direction*/
|
||||
int *angDirection;
|
||||
/** pointer to detector move flag (1 moves with encoder, 0 not)*/
|
||||
int *moveFlag;
|
||||
|
||||
|
||||
/** number of bins for angular conversion (360./binsize)*/
|
||||
int nBins;
|
||||
|
||||
|
||||
@ -287,6 +433,12 @@ class angularConversion : public slsDetectorDefs {
|
||||
*/
|
||||
int currentPositionIndex;
|
||||
|
||||
|
||||
/**
|
||||
enables/disable the angular conversion
|
||||
\param i 1 sets, 0 unsets,, -1 gets
|
||||
\returns actual angular conversion flag
|
||||
*/
|
||||
virtual int setAngularCorrectionMask(int i=-1)=0;
|
||||
|
||||
|
||||
@ -303,12 +455,6 @@ class angularConversion : public slsDetectorDefs {
|
||||
/** merging multiplicity */
|
||||
int *mergingMultiplicity;
|
||||
|
||||
/** pointer to the angular conversion constants for the (multi)detector class*/
|
||||
|
||||
/* angleConversionConstant *angOff[MAXDET]; */
|
||||
/* int *nMods[MAXDET]; */
|
||||
/* int nCh[MAXDET]; */
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
@ -3,7 +3,9 @@
|
||||
#include <cstring>
|
||||
|
||||
/**
|
||||
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
|
||||
|
||||
(e.g. to plot, store in a root tree etc.)
|
||||
*/
|
||||
class detectorData {
|
||||
public:
|
||||
|
@ -5,19 +5,23 @@
|
||||
#include <string>
|
||||
|
||||
using namespace std;
|
||||
|
||||
/**
|
||||
@short class handling the energy calibration and trim files IO
|
||||
*/
|
||||
|
||||
|
||||
class energyConversion: public slsDetectorDefs {
|
||||
|
||||
public:
|
||||
/** default constrauctor */
|
||||
energyConversion(){};
|
||||
/** default destructor */
|
||||
virtual ~energyConversion(){};
|
||||
|
||||
|
||||
/**
|
||||
|
||||
reads a calibration file MOVE TO ENERGY CALIBRATION?!?!??!?
|
||||
reads a calibration file
|
||||
\param fname file to be read
|
||||
\param gain reference to the gain variable
|
||||
\offset reference to the offset variable
|
||||
@ -26,7 +30,7 @@ class energyConversion: public slsDetectorDefs {
|
||||
|
||||
/**
|
||||
|
||||
writes a calibration file MOVE TO ENERGY CALIBRATION?!?!??!?
|
||||
writes a calibration file
|
||||
\param fname file to be written
|
||||
\param gain
|
||||
\param offset
|
||||
@ -37,9 +41,9 @@ class energyConversion: public slsDetectorDefs {
|
||||
/**
|
||||
reads a trim/settings file
|
||||
\param fname name of the file to be read
|
||||
\param myDetectorType detector type (needed for number of channels, chips, dacs etc.)
|
||||
\param myMod pointer to the module structure which has to be set. <BR> If it is NULL a new module structure will be created
|
||||
\returns the pointer to myMod or NULL if reading the file failed
|
||||
\sa mythenDetector::readSettingsFile
|
||||
*/
|
||||
|
||||
sls_detector_module* readSettingsFile(string fname, detectorType myDetectorType, sls_detector_module* myMod=NULL);
|
||||
@ -47,6 +51,7 @@ class energyConversion: public slsDetectorDefs {
|
||||
/**
|
||||
writes a trim/settings file
|
||||
\param fname name of the file to be written
|
||||
\param myDetectorType detector type (needed for number of channels, chips, dacs etc.)
|
||||
\param mod module structure which has to be written to file
|
||||
\returns OK or FAIL if the file could not be written
|
||||
|
||||
@ -54,12 +59,20 @@ class energyConversion: public slsDetectorDefs {
|
||||
*/
|
||||
int writeSettingsFile(string fname, detectorType myDetectorType, sls_detector_module mod);
|
||||
|
||||
|
||||
/** allocates the momery for a detector module structure
|
||||
\param myDetectorType detector type (needed for number of channels, chips, dacs etc.)
|
||||
\returns pointer to detector module
|
||||
*/
|
||||
virtual sls_detector_module* createModule(detectorType myDetectorType)=0;
|
||||
|
||||
/**
|
||||
frees the memory of a detector module structure
|
||||
\param myMod pointer to memeory to be freed
|
||||
*/
|
||||
virtual void deleteModule(sls_detector_module *myMod)=0;
|
||||
|
||||
protected:
|
||||
/** pointer to settings file name */
|
||||
char *settingsFile;
|
||||
|
||||
|
||||
|
@ -12,44 +12,54 @@
|
||||
#include <math.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
/**
|
||||
@short class handling the data file I/O flags
|
||||
*/
|
||||
class fileIO : public slsDetectorDefs {
|
||||
|
||||
|
||||
|
||||
public:
|
||||
/** default constructor */
|
||||
fileIO(){};
|
||||
/** virtual destructor */
|
||||
virtual ~fileIO(){};
|
||||
|
||||
|
||||
/**
|
||||
sets the default output files path
|
||||
\param s file path
|
||||
\return actual file path
|
||||
*/
|
||||
string setFilePath(string s) {sprintf(filePath, s.c_str()); return string(filePath);};
|
||||
|
||||
/**
|
||||
sets the default output files root name
|
||||
\param s file name to be set
|
||||
\returns actual file name
|
||||
*/
|
||||
string setFileName(string s) {sprintf(fileName, s.c_str()); return string(fileName);};
|
||||
|
||||
/**
|
||||
sets the default output file index
|
||||
\param i start file index to be set
|
||||
\returns actual file index
|
||||
*/
|
||||
int setFileIndex(int i) {*fileIndex=i; return *fileIndex;};
|
||||
|
||||
/**
|
||||
returns the default output files path
|
||||
\sa sharedSlsDetector
|
||||
\returns the output files path
|
||||
|
||||
*/
|
||||
string getFilePath() {return string(filePath);};
|
||||
|
||||
/**
|
||||
returns the default output files root name
|
||||
\returns the output files root name
|
||||
*/
|
||||
string getFileName() {return string(fileName);};
|
||||
|
||||
/**
|
||||
returns the default output file index
|
||||
\returns the output file index
|
||||
*/
|
||||
int getFileIndex() {return *fileIndex;};
|
||||
|
||||
@ -62,10 +72,10 @@ class fileIO : public slsDetectorDefs {
|
||||
|
||||
always appends to file path and file name the run index.
|
||||
|
||||
in case also appends the position index
|
||||
in case also appends the position index and the two level of scan varaibles with the specified precision
|
||||
|
||||
Filenames will be of the form: filepath/filename(_px)_i
|
||||
where x is the position index and i is the run index
|
||||
Filenames will be of the form: filepath/filename(_Sy_sw_px)_i
|
||||
where y is the scan0 variable, W is the scan 1 variable, x is the position index and i is the run index
|
||||
\param filepath outdir
|
||||
\param filename file root name
|
||||
\param aMask action mask (scans, positions)
|
||||
@ -80,13 +90,16 @@ class fileIO : public slsDetectorDefs {
|
||||
*/
|
||||
static string createFileName(char *filepath, char *filename, int aMask, float sv0, int prec0, float sv1, int prec1, int pindex, int npos, int findex);
|
||||
|
||||
|
||||
/** generates file name without extension */
|
||||
virtual string createFileName();
|
||||
|
||||
|
||||
/** static function that returns the file index from the file name
|
||||
/** static function that returns the file index from the file name
|
||||
\param fname file name
|
||||
\returns file index*/
|
||||
static int getFileIndexFromFileName(string fname);
|
||||
\returns file index
|
||||
*/
|
||||
static int getFileIndexFromFileName(string fname);
|
||||
|
||||
/** static function that returns the variables from the file name
|
||||
\param fname file name
|
||||
@ -96,187 +109,307 @@ class fileIO : public slsDetectorDefs {
|
||||
\param sv1 reference to scan variable 1
|
||||
\returns file index
|
||||
*/
|
||||
static int getVariablesFromFileName(string fname, int &index, int &p_index, float &sv0, float &sv1);
|
||||
static int getVariablesFromFileName(string fname, int &index, int &p_index, float &sv0, float &sv1);
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
|
||||
writes a data file
|
||||
\param name of the file to be written
|
||||
\param data array of data values
|
||||
\param err array of arrors on the data. If NULL no errors will be written
|
||||
|
||||
\param ang array of angular values. If NULL data will be in the form chan-val(-err) otherwise ang-val(-err)
|
||||
\param dataformat format of the data: can be 'i' integer or 'f' float (default)
|
||||
\param nch number of channels to be written to file. if -1 defaults to the number of installed channels of the detector
|
||||
\returns OK or FAIL if it could not write the file or data=NULL
|
||||
|
||||
writes a data file
|
||||
\param fname of the file to be written
|
||||
\param data array of data values
|
||||
\param err array of arrors on the data. If NULL no errors will be written
|
||||
|
||||
\param ang array of angular values. If NULL data will be in the form chan-val(-err) otherwise ang-val(-err)
|
||||
\param dataformat format of the data: can be 'i' integer or 'f' float (default)
|
||||
\param nch number of channels to be written to file. if -1 defaults to the number of installed channels of the detector
|
||||
\returns OK or FAIL if it could not write the file or data=NULL
|
||||
|
||||
*/
|
||||
virtual int writeDataFile(string fname, float *data, float *err=NULL, float *ang=NULL, char dataformat='f', int nch=-1);
|
||||
int writeDataFile(ofstream &outfile, float *data, float *err=NULL, float *ang=NULL, char dataformat='f', int nch=-1, int offset=0);
|
||||
|
||||
|
||||
/**
|
||||
|
||||
writes a data file
|
||||
\param name of the file to be written
|
||||
\param data array of data values
|
||||
\returns OK or FAIL if it could not write the file or data=NULL
|
||||
\sa mythenDetector::writeDataFile
|
||||
|
||||
writes a data file
|
||||
\paramoutfile output file stream
|
||||
\param data array of data values
|
||||
\param err array of arrors on the data. If NULL no errors will be written
|
||||
|
||||
\param ang array of angular values. If NULL data will be in the form chan-val(-err) otherwise ang-val(-err)
|
||||
\param dataformat format of the data: can be 'i' integer or 'f' float (default)
|
||||
\param nch number of channels to be written to file. if -1 defaults to the number of installed channels of the detector
|
||||
\param offset start channel number
|
||||
\returns OK or FAIL if it could not write the file or data=NULL
|
||||
|
||||
*/
|
||||
int writeDataFile(ofstream &outfile, float *data, float *err=NULL, float *ang=NULL, char dataformat='f', int nch=-1, int offset=0);
|
||||
|
||||
|
||||
/**
|
||||
writes a data file
|
||||
\param fname of the file to be written
|
||||
\param data array of data values
|
||||
\returns OK or FAIL if it could not write the file or data=NULL
|
||||
*/
|
||||
virtual int writeDataFile(string fname, int *data);
|
||||
|
||||
/**
|
||||
writes a data file
|
||||
\param outfile output file stream
|
||||
\param data array of data values
|
||||
\param offset start channel number
|
||||
\returns OK or FAIL if it could not write the file or data=NULL
|
||||
*/
|
||||
int writeDataFile(ofstream &outfile, int *data, int offset=0);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
writes a data file
|
||||
\param name of the file to be written
|
||||
writes a data file of short ints
|
||||
\param fname of the file to be written
|
||||
\param data array of data values
|
||||
\returns OK or FAIL if it could not write the file or data=NULL
|
||||
\sa mythenDetector::writeDataFile
|
||||
*/
|
||||
virtual int writeDataFile(string fname, short int *data);
|
||||
virtual int writeDataFile(string fname, short int *data);
|
||||
|
||||
/**
|
||||
writes a data file of short ints
|
||||
\param outfile output file stream
|
||||
\param data array of data values
|
||||
\param offset start channel number
|
||||
\returns OK or FAIL if it could not write the file or data=NULL
|
||||
*/
|
||||
int writeDataFile(ofstream &outfile, short int *data, int offset=0);
|
||||
|
||||
|
||||
/**
|
||||
|
||||
reads a data file
|
||||
\param name of the file to be read
|
||||
\param fname of the file to be read
|
||||
\param data array of data values to be filled
|
||||
\param err array of arrors on the data. If NULL no errors are expected on the file
|
||||
|
||||
\param ang array of angular values. If NULL data are expected in the form chan-val(-err) otherwise ang-val(-err)
|
||||
\param dataformat format of the data: can be 'i' integer or 'f' float (default)
|
||||
\param nch number of channels to be written to file. if <=0 defaults to the number of installed channels of the detector
|
||||
\returns OK or FAIL if it could not read the file or data=NULL
|
||||
|
||||
*/
|
||||
virtual int readDataFile(string fname, float *data, float *err=NULL, float *ang=NULL, char dataformat='f');
|
||||
|
||||
/**
|
||||
reads a data file
|
||||
\param ifstream input file stream
|
||||
\param data array of data values to be filled
|
||||
\param err array of arrors on the data. If NULL no errors are expected on the file
|
||||
|
||||
\param ang array of angular values. If NULL data are expected in the form chan-val(-err) otherwise ang-val(-err)
|
||||
\param offset start channel number to be expected
|
||||
\returns OK or FAIL if it could not read the file or data=NULL
|
||||
*/
|
||||
int readDataFile(ifstream& infile, float *data, float *err=NULL, float *ang=NULL, char dataformat='f', int offset=0);
|
||||
|
||||
/**
|
||||
|
||||
reads a data file
|
||||
\param name of the file to be read
|
||||
reads a raw data file
|
||||
\param fname of the file to be read
|
||||
\param data array of data values
|
||||
\returns OK or FAIL if it could not read the file or data=NULL
|
||||
*/
|
||||
virtual int readDataFile(string fname, int *data);
|
||||
virtual int readDataFile(string fname, int *data); /**
|
||||
reads a raw data file
|
||||
\param infile input file stream
|
||||
\param data array of data values
|
||||
\param offset first channel number to be expected
|
||||
\returns OK or FAIL if it could not read the file or data=NULL
|
||||
*/
|
||||
int readDataFile(ifstream &infile, int *data, int offset=0);
|
||||
|
||||
/**
|
||||
|
||||
reads a data file
|
||||
\param name of the file to be read
|
||||
reads a short int raw data file
|
||||
\param fname of the file to be read
|
||||
\param data array of data values
|
||||
\returns OK or FAIL if it could not read the file or data=NULL
|
||||
*/
|
||||
virtual int readDataFile(string fname, short int *data);
|
||||
virtual int readDataFile(string fname, short int *data);
|
||||
/**
|
||||
reads a short int raw data file
|
||||
\param infile input file stream
|
||||
\param data array of data values
|
||||
\param offset first channel number to be expected
|
||||
\returns OK or FAIL if it could not read the file or data=NULL
|
||||
*/
|
||||
int readDataFile(ifstream &infile, short int *data, int offset=0);
|
||||
|
||||
/**
|
||||
|
||||
writes a data file
|
||||
\param name of the file to be written
|
||||
\param fname of the file to be written
|
||||
\param nch number of channels to be written
|
||||
\param data array of data values
|
||||
\param err array of arrors on the data. If NULL no errors will be written
|
||||
|
||||
\param err array of arrors on the data. If NULL no errors will be written
|
||||
\param ang array of angular values. If NULL data will be in the form chan-val(-err) otherwise ang-val(-err)
|
||||
\param dataformat format of the data: can be 'i' integer or 'f' float (default)
|
||||
\param nch number of channels to be written to file. if -1 defaults to the number of installed channels of the detector
|
||||
\returns OK or FAIL if it could not write the file or data=NULL
|
||||
\sa mythenDetector::writeDataFile
|
||||
|
||||
*/
|
||||
|
||||
static int writeDataFile(string fname, int nch, float *data, float *err=NULL, float *ang=NULL, char dataformat='f');
|
||||
static int writeDataFile(string fname, int nch, float *data, float *err=NULL, float *ang=NULL, char dataformat='f');
|
||||
/**
|
||||
writes a data file
|
||||
\param outfile output file stream
|
||||
\param nch number of channels to be written
|
||||
\param data array of data values
|
||||
\param err array of arrors on the data. If NULL no errors will be written
|
||||
\param ang array of angular values. If NULL data will be in the form chan-val(-err) otherwise ang-val(-err)
|
||||
\param dataformat format of the data: can be 'i' integer or 'f' float (default)
|
||||
\param offset start channel number
|
||||
\returns OK or FAIL if it could not write the file or data=NULL
|
||||
*/
|
||||
static int writeDataFile(ofstream &outfile, int nch, float *data, float *err=NULL, float *ang=NULL, char dataformat='f', int offset=0);
|
||||
|
||||
/**
|
||||
|
||||
writes a data file
|
||||
\param name of the file to be written
|
||||
writes a raw data file
|
||||
\param fname of the file to be written
|
||||
\param nch number of channels
|
||||
\param data array of data values
|
||||
\returns OK or FAIL if it could not write the file or data=NULL
|
||||
\sa mythenDetector::writeDataFile
|
||||
*/
|
||||
static int writeDataFile(string fname,int nch, int *data);
|
||||
static int writeDataFile(string fname,int nch, int *data);
|
||||
|
||||
/**
|
||||
writes a raw data file
|
||||
\param outfile output file stream
|
||||
\param nch number of channels
|
||||
\param data array of data values
|
||||
\param offset start channel number
|
||||
\returns OK or FAIL if it could not write the file or data=NULL
|
||||
*/
|
||||
static int writeDataFile(ofstream &outfile,int nch, int *data, int offset=0);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
writes a data file
|
||||
\param name of the file to be written
|
||||
writes a short int raw data file
|
||||
\param fname of the file to be written
|
||||
\param nch number of channels
|
||||
\param data array of data values
|
||||
\returns OK or FAIL if it could not write the file or data=NULL
|
||||
\sa mythenDetector::writeDataFile
|
||||
*/
|
||||
static int writeDataFile(string fname,int nch, short int *data);
|
||||
static int writeDataFile(string fname,int nch, short int *data);
|
||||
|
||||
/**
|
||||
writes a short int raw data file
|
||||
\param outfile output file stream
|
||||
\param nch number of channels
|
||||
\param data array of data values
|
||||
\param offset start channel number
|
||||
\returns OK or FAIL if it could not write the file or data=NULL
|
||||
*/
|
||||
static int writeDataFile(ofstream &outfile,int nch, short int *data, int offset=0);
|
||||
/**
|
||||
|
||||
|
||||
|
||||
/**
|
||||
reads a data file
|
||||
\param name of the file to be read
|
||||
\param nch number of channels
|
||||
\param fname of the file to be read
|
||||
\param data array of data values to be filled
|
||||
\param err array of arrors on the data. If NULL no errors are expected on the file
|
||||
|
||||
\param ang array of angular values. If NULL data are expected in the form chan-val(-err) otherwise ang-val(-err)
|
||||
\param dataformat format of the data: can be 'i' integer or 'f' float (default)
|
||||
\param nch number of channels to be written to file. if <=0 defaults to the number of installed channels of the detector
|
||||
\returns number of channels read or -1 if it could not read the file or data=NULL
|
||||
|
||||
\sa mythenDetector::readDataFile
|
||||
*/
|
||||
static int readDataFile(int nch, string fname, float *data, float *err=NULL, float *ang=NULL, char dataformat='f');
|
||||
static int readDataFile(int nch, string fname, float *data, float *err=NULL, float *ang=NULL, char dataformat='f');
|
||||
/**
|
||||
reads a data file
|
||||
\param nch number of channels
|
||||
\param infile input file stream
|
||||
\param data array of data values to be filled
|
||||
\param err array of arrors on the data. If NULL no errors are expected on the file
|
||||
\param ang array of angular values. If NULL data are expected in the form chan-val(-err) otherwise ang-val(-err)
|
||||
\param dataformat format of the data: can be 'i' integer or 'f' float (default)
|
||||
\param offset start channel number
|
||||
\returns number of channels read or -1 if it could not read the file or data=NULL
|
||||
|
||||
*/
|
||||
static int readDataFile(int nch, ifstream &infile, float *data, float *err=NULL, float *ang=NULL, char dataformat='f', int offset=0);
|
||||
|
||||
/**
|
||||
|
||||
reads a data file
|
||||
\param name of the file to be read
|
||||
reads a raw data file
|
||||
\param fname of the file to be read
|
||||
\param data array of data values
|
||||
\param nch number of channels
|
||||
\returns OK or FAIL if it could not read the file or data=NULL
|
||||
*/
|
||||
static int readDataFile(string fname, int *data, int nch);
|
||||
|
||||
/**
|
||||
reads a raw data file
|
||||
\param infile input file stream
|
||||
\param data array of data values
|
||||
\param nch number of channels
|
||||
\param offset start channel value
|
||||
\returns OK or FAIL if it could not read the file or data=NULL
|
||||
*/
|
||||
static int readDataFile(ifstream &infile, int *data, int nch, int offset);
|
||||
|
||||
/**
|
||||
|
||||
reads a data file
|
||||
reads a short int rawdata file
|
||||
\param name of the file to be read
|
||||
\param data array of data values
|
||||
\param nch number of channels
|
||||
\returns OK or FAIL if it could not read the file or data=NULL
|
||||
\sa mythenDetector::readDataFile
|
||||
*/
|
||||
static int readDataFile(string fname, short int *data, int nch);
|
||||
static int readDataFile(string fname, short int *data, int nch);
|
||||
/**
|
||||
reads a short int raw data file
|
||||
\param infile input file stream
|
||||
\param data array of data values
|
||||
\param nch number of channels
|
||||
\param offset start channel value
|
||||
\returns OK or FAIL if it could not read the file or data=NULL
|
||||
*/
|
||||
static int readDataFile(ifstream &infile, short int *data, int nch, int offset);
|
||||
|
||||
|
||||
/**
|
||||
\returns action mask
|
||||
*/
|
||||
virtual int getActionMask()=0;// {return 0;};
|
||||
/**
|
||||
\param index scan level index
|
||||
\returns current scan variable
|
||||
*/
|
||||
virtual float getCurrentScanVariable(int index)=0;// {return 0;};
|
||||
/**
|
||||
\param index scan level index
|
||||
\returns current scan variable precision (for file name)
|
||||
*/
|
||||
virtual int getScanPrecision(int index)=0;// {return 0;};
|
||||
/**
|
||||
\returns current position index
|
||||
*/
|
||||
virtual int getCurrentPositionIndex()=0;// {return 0;};
|
||||
/**
|
||||
\returns number of positions
|
||||
*/
|
||||
virtual int getNumberOfPositions()=0;// {return 0;};
|
||||
|
||||
virtual int getActionMask() {return 0;};
|
||||
|
||||
virtual float getCurrentScanVariable(int index) {return 0;};
|
||||
virtual int getScanPrecision(int index) {return 0;};
|
||||
|
||||
virtual int getCurrentPositionIndex() {return 0;};
|
||||
virtual int getNumberOfPositions() {return 0;};
|
||||
|
||||
/**
|
||||
\returns total number of channels
|
||||
*/
|
||||
virtual int getTotalNumberOfChannels()=0;
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
|
||||
|
||||
char *filePath;
|
||||
char *fileName;
|
||||
int *fileIndex;
|
||||
|
||||
/** output directory */
|
||||
char *filePath;
|
||||
/** file root name */
|
||||
char *fileName;
|
||||
/** file index */
|
||||
int *fileIndex;
|
||||
|
||||
|
||||
};
|
||||
|
@ -127,34 +127,34 @@ int postProcessing::setBadChannelCorrection(string fname, int &nbad, int *badlis
|
||||
void postProcessing::processFrame(int *myData, int delflag) {
|
||||
|
||||
string fname;
|
||||
float *fdata;
|
||||
// float *fdata=NULL;
|
||||
|
||||
|
||||
incrementProgress();
|
||||
|
||||
/** decode data */
|
||||
fdata=decodeData(myData);
|
||||
|
||||
fname=createFileName();
|
||||
|
||||
incrementProgress();
|
||||
|
||||
/** decode data */
|
||||
|
||||
fdata=decodeData(myData, fdata);
|
||||
|
||||
fname=createFileName();
|
||||
|
||||
|
||||
//uses static function?!?!?!?
|
||||
// writeDataFile (fname+string(".raw"), getTotalNumberOfChannels(),fdata, NULL, NULL, 'i');
|
||||
writeDataFile (fname+string(".raw"),fdata, NULL, NULL, 'i');
|
||||
|
||||
doProcessing(fdata,delflag);
|
||||
doProcessing(fdata,delflag);
|
||||
|
||||
delete [] myData;
|
||||
myData=NULL;
|
||||
delete [] myData;
|
||||
myData=NULL;
|
||||
#ifdef VERBOSE
|
||||
// cout << "Pop data queue " << *fileIndex << endl;
|
||||
#endif
|
||||
|
||||
|
||||
pthread_mutex_lock(&mp);
|
||||
dataQueue.pop(); //remove the data from the queue
|
||||
queuesize=dataQueue.size();
|
||||
pthread_mutex_unlock(&mp);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -174,20 +174,15 @@ void postProcessing::doProcessing(float *fdata, int delflag) {
|
||||
detectorData *thisData;
|
||||
|
||||
|
||||
|
||||
if (*correctionMask!=0) {
|
||||
ext=".dat";
|
||||
} else {
|
||||
ext=".raw";
|
||||
}
|
||||
|
||||
fname=createFileName();
|
||||
|
||||
/** write raw data file */
|
||||
if (*correctionMask==0 && delflag==1) {
|
||||
delete [] fdata;
|
||||
// delete [] fdata;
|
||||
;
|
||||
} else {
|
||||
|
||||
ext=".dat";
|
||||
fname=createFileName();
|
||||
|
||||
/** rate correction */
|
||||
if (*correctionMask&(1<<RATE_CORRECTION)) {
|
||||
rcdata=new float[getTotalNumberOfChannels()];
|
||||
@ -333,6 +328,7 @@ void postProcessing::doProcessing(float *fdata, int delflag) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
incrementFileIndex();
|
||||
|
||||
|
||||
@ -422,6 +418,8 @@ void* postProcessing::processData(int delflag) {
|
||||
std::cout<< " processing data - threaded mode " << *threadedProcessing << endl;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
setTotalProgress();
|
||||
pthread_mutex_lock(&mp);
|
||||
queuesize=dataQueue.size();
|
||||
@ -430,46 +428,44 @@ void* postProcessing::processData(int delflag) {
|
||||
int *myData;
|
||||
int dum=1;
|
||||
|
||||
fdata=NULL;
|
||||
|
||||
|
||||
while(dum | *threadedProcessing) { // ????????????????????????
|
||||
|
||||
|
||||
/* IF THERE ARE DATA PROCESS THEM*/
|
||||
pthread_mutex_lock(&mp);
|
||||
while((queuesize=dataQueue.size())>0) {
|
||||
|
||||
/** Pop data queue */
|
||||
myData=dataQueue.front(); // get the data from the queue
|
||||
pthread_mutex_unlock(&mp);
|
||||
|
||||
|
||||
|
||||
if (myData) {
|
||||
|
||||
processFrame(myData,delflag);
|
||||
|
||||
usleep(1000);
|
||||
//usleep(1000);
|
||||
}
|
||||
pthread_mutex_unlock(&mp);
|
||||
usleep(1000);
|
||||
pthread_mutex_lock(&mp);
|
||||
|
||||
}
|
||||
|
||||
|
||||
pthread_mutex_unlock(&mp);
|
||||
|
||||
/* IF THERE ARE NO DATA look if acquisition is finished */
|
||||
pthread_mutex_lock(&mp);
|
||||
if (jointhread) {
|
||||
if (dataQueue.size()==0) {
|
||||
pthread_mutex_unlock(&mp);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
pthread_mutex_unlock(&mp);
|
||||
} else {
|
||||
pthread_mutex_unlock(&mp);
|
||||
}
|
||||
dum=0;
|
||||
}
|
||||
|
||||
if (fdata)
|
||||
delete [] fdata;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,12 @@ using namespace std;
|
||||
|
||||
#define defaultTDead {170,90,750} /**< should be changed in order to have it separate for the different detector types */
|
||||
|
||||
|
||||
/**
|
||||
@short methods for data postprocessing
|
||||
|
||||
(including thread for writing data files and plotting in parallel with the acquisition)
|
||||
*/
|
||||
class postProcessing : public angularConversion, public fileIO {
|
||||
|
||||
|
||||
@ -232,7 +238,7 @@ s
|
||||
virtual int setTotalProgress()=0;
|
||||
|
||||
|
||||
virtual float* decodeData(int *datain)=0;
|
||||
virtual float* decodeData(int *datain, float *fdata=NULL)=0;
|
||||
virtual int getTotalNumberOfChannels()=0;
|
||||
|
||||
|
||||
@ -353,7 +359,7 @@ s
|
||||
*/
|
||||
float currentI0;
|
||||
|
||||
|
||||
float *fdata;
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user