mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-22 03:40:04 +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:
parent
3ddafe3baf
commit
ab4e569b6c
@ -33,6 +33,8 @@ and to the server programs running on the detector
|
|||||||
#define GET_FLAG -1
|
#define GET_FLAG -1
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
||||||
|
/** @short class containing all the structures, constants and enum definitions */
|
||||||
class slsDetectorDefs {
|
class slsDetectorDefs {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -47,7 +49,8 @@ class slsDetectorDefs {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
structure for a detector channel
|
@short structure for a detector channel
|
||||||
|
|
||||||
should not be used by unexperienced users
|
should not be used by unexperienced users
|
||||||
|
|
||||||
\see ::channelRegisterBit
|
\see ::channelRegisterBit
|
||||||
@ -60,7 +63,8 @@ class slsDetectorDefs {
|
|||||||
} sls_detector_channel;
|
} sls_detector_channel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
structure for a detector chip
|
@short structure for a detector chip
|
||||||
|
|
||||||
should not be used by unexperienced users
|
should not be used by unexperienced users
|
||||||
\see ::chipRegisterBit ::channelRegisterBit
|
\see ::chipRegisterBit ::channelRegisterBit
|
||||||
*/
|
*/
|
||||||
@ -75,7 +79,8 @@ class slsDetectorDefs {
|
|||||||
} sls_detector_chip;
|
} sls_detector_chip;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
structure for a detector module
|
@short structure for a detector module
|
||||||
|
|
||||||
should not be used by unexperienced users
|
should not be used by unexperienced users
|
||||||
|
|
||||||
\see :: moduleRegisterBit ::chipRegisterBit :channelRegisterBit
|
\see :: moduleRegisterBit ::chipRegisterBit :channelRegisterBit
|
||||||
@ -108,7 +113,7 @@ typedef struct {
|
|||||||
} sls_detector_module;
|
} sls_detector_module;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
structure for a region of interest
|
@short structure for a region of interest
|
||||||
|
|
||||||
xmin,xmax,ymin,ymax define the limits of the region
|
xmin,xmax,ymin,ymax define the limits of the region
|
||||||
*/
|
*/
|
||||||
@ -119,14 +124,13 @@ typedef struct {
|
|||||||
int ymax; /**< is the roi ymax (in channel number)*/
|
int ymax; /**< is the roi ymax (in channel number)*/
|
||||||
} ROI ;
|
} ROI ;
|
||||||
|
|
||||||
/**
|
/* /\* */
|
||||||
structure for a generic integer array
|
/* @short structure for a generic integer array */
|
||||||
|
/* *\/ */
|
||||||
*/
|
/* typedef struct { */
|
||||||
typedef struct {
|
/* int len; /\**< is the number of elements of the array *\/ */
|
||||||
int len; /**< is the number of elements of the array */
|
/* int *iptr; /\**< is the pointer to the array *\/ */
|
||||||
int *iptr; /**< is the pointer to the array */
|
/* } iarray ; */
|
||||||
} iarray ;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -80,9 +80,7 @@ LATEX_HIDE_INDICES = YES
|
|||||||
|
|
||||||
PREDEFINED = __cplusplus
|
PREDEFINED = __cplusplus
|
||||||
|
|
||||||
INPUT = slsDetector/slsDetectorBase.h commonFiles/sls_detector_defs.h
|
INPUT = slsDetector/slsDetectorBase.h commonFiles/sls_detector_defs.h slsDetector/slsDetector.h MySocketTCP/MySocketTCP.h usersFunctions/usersFunctions.h multiSlsDetector/multiSlsDetector.h commonFiles/sls_detector_defs.h slsDetector/slsDetectorUtils.h slsDetector/slsDetectorBase.h slsDetector/slsDetectorCommand.h slsDetector/slsDetectorActions.h multiSlsDetector/multiSlsDetector.h slsDetectorAnalysis/detectorData.h slsDetectorAnalysis/energyConversion.h slsDetectorAnalysis/postProcessing.h slsDetectorAnalysis/angularConversion.h slsDetectorAnalysis/fileIO.h
|
||||||
|
|
||||||
#INPUT = slsDetector/slsDetector.h MySocketTCP/MySocketTCP.h usersFunctions/usersFunctions.h multiSlsDetector/multiSlsDetector.h commonFiles/sls_detector_defs.h slsDetector/slsDetectorUtils.h slsDetector/slsDetectorBase.h slsDetector/slsDetectorCommand.h multiSlsDetector/multiSlsDetector.h
|
|
||||||
|
|
||||||
OUTPUT_DIRECTORY = docs
|
OUTPUT_DIRECTORY = docs
|
||||||
|
|
||||||
|
@ -1402,22 +1402,30 @@ int multiSlsDetector::setROI(int nroi, int *xmin, int *xmax, int *ymin, int *yma
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
float* multiSlsDetector::decodeData(int *datain) {
|
float* multiSlsDetector::decodeData(int *datain, float *fdata) {
|
||||||
float *dataout=new float[thisMultiDetector->numberOfChannels];
|
float *dataout;
|
||||||
int ich=0;
|
if (fdata)
|
||||||
float *detp;
|
dataout=fdata;
|
||||||
|
else
|
||||||
|
dataout=new float[thisMultiDetector->numberOfChannels];
|
||||||
|
|
||||||
|
// int ich=0;
|
||||||
|
|
||||||
|
float *detp=dataout;
|
||||||
int *datap=datain;
|
int *datap=datain;
|
||||||
|
|
||||||
|
|
||||||
for (int i=0; i<thisMultiDetector->numberOfDetectors; i++) {
|
for (int i=0; i<thisMultiDetector->numberOfDetectors; i++) {
|
||||||
if (detectors[i]) {
|
if (detectors[i]) {
|
||||||
detp=detectors[i]->decodeData(datap);
|
detectors[i]->decodeData(datap, detp);
|
||||||
datap+=detectors[i]->getDataBytes()/sizeof(int);
|
datap+=detectors[i]->getDataBytes()/sizeof(int);
|
||||||
for (int j=0; j<detectors[i]->getTotalNumberOfChannels(); j++) {
|
detp+=detectors[i]->getTotalNumberOfChannels();
|
||||||
dataout[ich]=detp[j];
|
|
||||||
ich++;
|
// for (int j=0; j<detectors[i]->getTotalNumberOfChannels(); j++) {
|
||||||
}
|
// dataout[ich]=detp[j];
|
||||||
delete [] detp;
|
// ich++;
|
||||||
|
// }
|
||||||
|
//delete [] detp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3339,7 +3347,7 @@ int multiSlsDetector::writeDataFile(string fname, float *data, float *err, float
|
|||||||
ofstream outfile;
|
ofstream outfile;
|
||||||
int choff=0, off=0; //idata,
|
int choff=0, off=0; //idata,
|
||||||
float *pe=err, *pa=ang;
|
float *pe=err, *pa=ang;
|
||||||
int nch_left=nch, n;
|
int nch_left=nch, n, nd;
|
||||||
|
|
||||||
if (nch_left<=0)
|
if (nch_left<=0)
|
||||||
nch_left=getTotalNumberOfChannels();
|
nch_left=getTotalNumberOfChannels();
|
||||||
@ -3348,26 +3356,33 @@ int multiSlsDetector::writeDataFile(string fname, float *data, float *err, float
|
|||||||
if (data==NULL)
|
if (data==NULL)
|
||||||
return FAIL;
|
return FAIL;
|
||||||
|
|
||||||
// args|=0x10; // one line per channel!
|
|
||||||
|
|
||||||
outfile.open (fname.c_str(),ios_base::out);
|
outfile.open (fname.c_str(),ios_base::out);
|
||||||
if (outfile.is_open())
|
if (outfile.is_open())
|
||||||
{
|
{
|
||||||
|
|
||||||
for (int i=0; i<thisMultiDetector->numberOfDetectors; i++) {
|
for (int i=0; i<thisMultiDetector->numberOfDetectors; i++) {
|
||||||
|
|
||||||
if (detectors[i]) {
|
if (detectors[i]) {
|
||||||
n=detectors[i]->getTotalNumberOfChannels();
|
n=detectors[i]->getTotalNumberOfChannels();
|
||||||
if (nch_left<n)
|
if (nch_left<nd)
|
||||||
n=nch_left;
|
n=nch_left;
|
||||||
|
|
||||||
detectors[i]->writeDataFile(outfile,n, data+off, pe, pa, dataformat, choff);
|
detectors[i]->writeDataFile(outfile,n, data+off, pe, pa, dataformat, choff);
|
||||||
|
|
||||||
nch_left-=n;
|
nch_left-=n;
|
||||||
|
|
||||||
choff+=detectors[i]->getMaxNumberOfChannels();
|
choff+=detectors[i]->getMaxNumberOfChannels();
|
||||||
|
|
||||||
off+=n;
|
off+=n;
|
||||||
|
|
||||||
if (pe)
|
if (pe)
|
||||||
pe=pe+off;
|
pe=pe+off;
|
||||||
|
|
||||||
if (pa)
|
if (pa)
|
||||||
pa=pa+off;
|
pa=pa+off;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
outfile.close();
|
outfile.close();
|
||||||
|
@ -721,7 +721,7 @@ class multiSlsDetector : public slsDetectorUtils {
|
|||||||
\param datain data from the detector
|
\param datain data from the detector
|
||||||
\returns pointer to a float array with a data per channel
|
\returns pointer to a float array with a data per channel
|
||||||
*/
|
*/
|
||||||
float* decodeData(int *datain);
|
float* decodeData(int *datain, float *fdata=NULL);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -3199,14 +3199,16 @@ int* slsDetector::startAndReadAll(){
|
|||||||
|
|
||||||
|
|
||||||
int* retval;
|
int* retval;
|
||||||
|
#ifdef VERBOSE
|
||||||
int i=0;
|
int i=0;
|
||||||
|
#endif
|
||||||
startAndReadAllNoWait();
|
startAndReadAllNoWait();
|
||||||
//#ifdef VERBOSE
|
//#ifdef VERBOSE
|
||||||
// std::cout<< "started" << std::endl;
|
// std::cout<< "started" << std::endl;
|
||||||
//#endif
|
//#endif
|
||||||
while ((retval=getDataFromDetector())){
|
while ((retval=getDataFromDetector())){
|
||||||
i++;
|
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
|
i++;
|
||||||
std::cout<< i << std::endl;
|
std::cout<< i << std::endl;
|
||||||
//#else
|
//#else
|
||||||
//std::cout<< "-" << flush;
|
//std::cout<< "-" << flush;
|
||||||
@ -3907,8 +3909,14 @@ int slsDetector::executeTrimming(trimMode mode, int par1, int par2, int imod){
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
float* slsDetector::decodeData(int *datain) {
|
float* slsDetector::decodeData(int *datain, float *fdata) {
|
||||||
float *dataout=new float[thisDetector->nChans*thisDetector->nChips*thisDetector->nMods];
|
|
||||||
|
float *dataout;
|
||||||
|
if (fdata)
|
||||||
|
dataout=fdata;
|
||||||
|
else
|
||||||
|
dataout=new float[thisDetector->nChans*thisDetector->nChips*thisDetector->nMods];
|
||||||
|
|
||||||
const int bytesize=8;
|
const int bytesize=8;
|
||||||
|
|
||||||
int ival=0;
|
int ival=0;
|
||||||
@ -3916,7 +3924,9 @@ float* slsDetector::decodeData(int *datain) {
|
|||||||
char iptr;
|
char iptr;
|
||||||
|
|
||||||
int nbits=thisDetector->dynamicRange;
|
int nbits=thisDetector->dynamicRange;
|
||||||
|
int nch=thisDetector->nChans*thisDetector->nChips*thisDetector->nMods;
|
||||||
int ipos=0, ichan=0, ibyte;
|
int ipos=0, ichan=0, ibyte;
|
||||||
|
|
||||||
if (thisDetector->timerValue[PROBES_NUMBER]==0) {
|
if (thisDetector->timerValue[PROBES_NUMBER]==0) {
|
||||||
switch (nbits) {
|
switch (nbits) {
|
||||||
case 1:
|
case 1:
|
||||||
@ -3948,7 +3958,7 @@ float* slsDetector::decodeData(int *datain) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 16:
|
case 16:
|
||||||
for (ichan=0; ichan<thisDetector->nChans*thisDetector->nChips*thisDetector->nMods; ichan++) {
|
for (ichan=0; ichan<nch; ichan++) {
|
||||||
// dataout[ichan]=0;
|
// dataout[ichan]=0;
|
||||||
ival=0;
|
ival=0;
|
||||||
for (ibyte=0; ibyte<2; ibyte++) {
|
for (ibyte=0; ibyte<2; ibyte++) {
|
||||||
@ -3959,40 +3969,18 @@ float* slsDetector::decodeData(int *datain) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
for (ichan=0; ichan<thisDetector->nChans*thisDetector->nChips*thisDetector->nMods; ichan++) {
|
for (ichan=0; ichan<nch; ichan++) {
|
||||||
ival=datain[ichan]&0xffffff;
|
ival=datain[ichan]&0xffffff;
|
||||||
dataout[ichan]=ival;
|
dataout[ichan]=ival;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (ichan=0; ichan<thisDetector->nChans*thisDetector->nChips*thisDetector->nMods; ichan++) {
|
for (ichan=0; ichan<nch; ichan++) {
|
||||||
dataout[ichan]=datain[ichan];
|
dataout[ichan]=datain[ichan];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
if (nbits==32) {
|
|
||||||
for (ichan=0; ichan<thisDetector->nChans*thisDetector->nChips*thisDetector->nMods; ichan++)
|
|
||||||
dataout[ichan]=(datain[ichan]&0xffffff);
|
|
||||||
} else {
|
|
||||||
for (int ibyte=0; ibyte<thisDetector->dataBytes; ibyte++) {
|
|
||||||
for (int ibit=0; ibit<bytesize; ibit++) {
|
|
||||||
ival|=(ptr[ibyte]&(one<<ibit)>>ibit)<<ipos++;
|
|
||||||
if (ipos==thisDetector->dynamicRange) {
|
|
||||||
ipos=0;
|
|
||||||
dataout[ichan]=ival;
|
|
||||||
ichan++;
|
|
||||||
ival=0;
|
|
||||||
if (ichan>thisDetector->nChans*thisDetector->nChips*thisDetector->nMods){
|
|
||||||
std::cout<< "error: decoding too many channels!" << ichan;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
std::cout<< "decoded "<< ichan << " channels" << std::endl;
|
std::cout<< "decoded "<< ichan << " channels" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
@ -10,40 +10,11 @@
|
|||||||
#include "MySocketTCP.h"
|
#include "MySocketTCP.h"
|
||||||
|
|
||||||
|
|
||||||
//using namespace std;
|
|
||||||
/**
|
|
||||||
\mainpage Common C++ library for SLS detectors data acquisition
|
|
||||||
*
|
|
||||||
* \section intro_sec Introduction
|
|
||||||
|
|
||||||
* \subsection mot_sec Motivation
|
|
||||||
Although the SLS detectors group delvelops several types of detectors (1/2D, counting/integrating etc.) it is common interest of the group to use a common platfor for data acquisition
|
|
||||||
\subsection arch_sec System Architecture
|
|
||||||
The architecture of the acquisitions system is intended as follows:
|
|
||||||
\li A socket server running on the detector (or more than one in some special cases)
|
|
||||||
\li C++ classes common to all detectors for client-server communication. These can be supplied to users as libraries and embedded also in acquisition systems which are not developed by the SLS \sa MySocketTCP slsDetector
|
|
||||||
\li the possibility of using a Qt-based graphical user interface (with eventually root analisys capabilities)
|
|
||||||
\li the possibility of runnin alla commands from command line. In order to ensure a fast operation of this so called "text client" the detector parameters should not be re-initialized everytime. For this reason a shared memory block is allocated where the main detector flags and parameters are stored \sa slsDetector::sharedSlsDetector
|
|
||||||
\section howto_sec How to use it
|
|
||||||
The best way to operate the slsDetectors is to use the software (text client or GUI) developed by the sls detectors group.
|
|
||||||
In case you need to embed the detector control in a previously existing software, compile these classes using <BR>
|
|
||||||
make package
|
|
||||||
<br>
|
|
||||||
and link the shared library created to your software bin/libSlsDetector.so.1.0.1
|
|
||||||
Then in your software you should use the class related to the detector you want to control (mythenDetector or eigerDetector).
|
|
||||||
|
|
||||||
@author Anna Bergamaschi
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*
|
* @short the slsDetector class takes care of the communication with the detector and all kind actions related with a single detector controller
|
||||||
@libdoc The slsDetector class is expected to become the interface class for all SLS Detectors acquisition (and analysis) software.
|
|
||||||
*
|
|
||||||
* @short This is the base class for all SLS detector functionalities
|
|
||||||
* @author Anna Bergamaschi
|
* @author Anna Bergamaschi
|
||||||
* @version 0.1alpha
|
* @version 0.1alpha
|
||||||
*/
|
*/
|
||||||
@ -54,6 +25,10 @@ Then in your software you should use the class related to the detector you want
|
|||||||
#define NCHANSMAX 65536
|
#define NCHANSMAX 65536
|
||||||
#define NDACSMAX 16
|
#define NDACSMAX 16
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
@short complete detector functionalities for a single module detector
|
||||||
|
*/
|
||||||
class slsDetector : public slsDetectorUtils, public energyConversion {
|
class slsDetector : public slsDetectorUtils, public energyConversion {
|
||||||
|
|
||||||
|
|
||||||
@ -69,7 +44,9 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@short Structure allocated in shared memory to store detector settings and be accessed in parallel by several applications (take care of possible conflicts!)
|
@short Structure allocated in shared memory to store detector settings.
|
||||||
|
|
||||||
|
Structure allocated in shared memory to store detector settings and be accessed in parallel by several applications on the same machine (take care of possible conflicts, particularly if things are run on different machines!)
|
||||||
|
|
||||||
*/
|
*/
|
||||||
typedef struct sharedSlsDetector {
|
typedef struct sharedSlsDetector {
|
||||||
@ -1162,7 +1139,7 @@ typedef struct sharedSlsDetector {
|
|||||||
\param datain data from the detector
|
\param datain data from the detector
|
||||||
\returns pointer to a float array with a data per channel
|
\returns pointer to a float array with a data per channel
|
||||||
*/
|
*/
|
||||||
float* decodeData(int *datain);
|
float* decodeData(int *datain, float *fdata=NULL);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -15,14 +15,17 @@ using namespace std;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
||||||
class implementing the script and scan utilities of the detectors
|
@short class implementing the script and scan utilities of the detectors
|
||||||
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class slsDetectorActions : public slsDetectorDefs {
|
class slsDetectorActions : public slsDetectorDefs {
|
||||||
public :
|
public :
|
||||||
|
/** default constructor */
|
||||||
slsDetectorActions(){};
|
slsDetectorActions(){};
|
||||||
|
|
||||||
|
/** virtual destructor */
|
||||||
virtual ~slsDetectorActions(){};
|
virtual ~slsDetectorActions(){};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -35,20 +38,23 @@ class slsDetectorActions : public slsDetectorDefs {
|
|||||||
int setAction(int iaction, string fname="", string par="");
|
int setAction(int iaction, string fname="", string par="");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
set action
|
set action script
|
||||||
\param iaction can be enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript, MAX_ACTIONS}
|
\param iaction can be enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript, MAX_ACTIONS}
|
||||||
\param fname for script ("" disable)
|
\param fname for script ("" disable)
|
||||||
\returns 0 if action disabled, >0 otherwise
|
\returns 0 if action disabled, >0 otherwise
|
||||||
*/
|
*/
|
||||||
int setActionScript(int iaction, string fname="");
|
int setActionScript(int iaction, string fname="");
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
set action
|
set action
|
||||||
\param iaction can be enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript, MAX_ACTIONS}
|
\param iaction can be enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript, MAX_ACTIONS}
|
||||||
\param par for script ("" disable)
|
\param par for script
|
||||||
\returns 0 if action disabled, >0 otherwise
|
\returns 0 if action disabled, >0 otherwise
|
||||||
*/
|
*/
|
||||||
int setActionParameter(int iaction, string par="");
|
int setActionParameter(int iaction, string par="");
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
returns action script
|
returns action script
|
||||||
\param iaction can be enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript}
|
\param iaction can be enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript}
|
||||||
@ -74,19 +80,49 @@ class slsDetectorActions : public slsDetectorDefs {
|
|||||||
/**
|
/**
|
||||||
set scan
|
set scan
|
||||||
\param index of the scan (0,1)
|
\param index of the scan (0,1)
|
||||||
\param fname for script ("" disables, "none" disables and overwrites current)
|
\param script fname for script ("" disables, "none" disables and overwrites current, "threshold" threshold scan, "trimbits", trimbits scan)
|
||||||
\param nvalues number of steps (0 disables, -1 leaves current value)
|
\param nvalues number of steps (0 disables, -1 leaves current value)
|
||||||
\param values pointer to steps (if NULL leaves current values)
|
\param values pointer to steps (if NULL leaves current values)
|
||||||
\param par parameter for the scan script ("" leaves unchanged)
|
\param par parameter for the scan script ("" leaves unchanged)
|
||||||
|
\param precision to write the scan varaible in the scan name (-1 unchanged)
|
||||||
\returns 0 is scan disabled, >0 otherwise
|
\returns 0 is scan disabled, >0 otherwise
|
||||||
*/
|
*/
|
||||||
int setScan(int index, string script="", int nvalues=-1, float *values=NULL, string par="", int precision=-1);
|
int setScan(int index, string script="", int nvalues=-1, float *values=NULL, string par="", int precision=-1);
|
||||||
|
|
||||||
|
/** set scan script
|
||||||
|
\param index of the scan (0,1)
|
||||||
|
\param script fname for script ("" disables, "none" disables and overwrites current, "threshold" threshold scan, "trimbits", trimbits scan)
|
||||||
|
\returns 0 is scan disabled, >0 otherwise
|
||||||
|
*/
|
||||||
int setScanScript(int index, string script="");
|
int setScanScript(int index, string script="");
|
||||||
|
/** set scan script parameter
|
||||||
|
\param index of the scan (0,1)
|
||||||
|
\param script parameter for scan
|
||||||
|
\returns 0 is scan disabled, >0 otherwise
|
||||||
|
*/
|
||||||
int setScanParameter(int index, string par="");
|
int setScanParameter(int index, string par="");
|
||||||
|
/** set scan script parameter
|
||||||
|
\param index of the scan (0,1)
|
||||||
|
\param precision scan varaible precision to be printed in file name
|
||||||
|
\returns 0 is scan disabled, >0 otherwise
|
||||||
|
*/
|
||||||
int setScanPrecision(int index, int precision=-1);
|
int setScanPrecision(int index, int precision=-1);
|
||||||
|
|
||||||
|
|
||||||
|
/** set scan steps
|
||||||
|
\param index of the scan (0,1)
|
||||||
|
\param nvalues number of steps
|
||||||
|
\param values pointer to array of values
|
||||||
|
\returns 0 is scan disabled, >0 otherwise
|
||||||
|
*/
|
||||||
int setScanSteps(int index, int nvalues=-1, float *values=NULL);
|
int setScanSteps(int index, int nvalues=-1, float *values=NULL);
|
||||||
float getScanStep(int index, int istep){if (index<MAX_SCAN_LEVELS && istep<MAX_SCAN_STEPS) return scanSteps[index][istep]; else return -1;};
|
|
||||||
|
/** get scan step
|
||||||
|
\param index of the scan (0,1)
|
||||||
|
\param istep step number
|
||||||
|
\returns value of the scan variable
|
||||||
|
*/
|
||||||
|
float getScanStep(int index, int istep){if (index<MAX_SCAN_LEVELS && index>=0 && istep>=0 && istep<MAX_SCAN_STEPS) return scanSteps[index][istep]; else return -1;};
|
||||||
/**
|
/**
|
||||||
returns scan script
|
returns scan script
|
||||||
\param iscan can be (0,1)
|
\param iscan can be (0,1)
|
||||||
@ -112,7 +148,7 @@ class slsDetectorActions : public slsDetectorDefs {
|
|||||||
returns scan steps
|
returns scan steps
|
||||||
\param iscan can be (0,1)
|
\param iscan can be (0,1)
|
||||||
\param v is the pointer to the scan steps
|
\param v is the pointer to the scan steps
|
||||||
\returns scan steps
|
\returns number of scan steps
|
||||||
*/
|
*/
|
||||||
int getScanSteps(int iscan, float *v=NULL);
|
int getScanSteps(int iscan, float *v=NULL);
|
||||||
|
|
||||||
@ -125,25 +161,47 @@ class slsDetectorActions : public slsDetectorDefs {
|
|||||||
int getScanPrecision(int iscan);
|
int getScanPrecision(int iscan);
|
||||||
|
|
||||||
|
|
||||||
|
/** calculates the total number of steps for the acquisition
|
||||||
|
\returns total number of steps for the acquisitions
|
||||||
|
*/
|
||||||
virtual int setTotalProgress()=0;
|
virtual int setTotalProgress()=0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
\returns the action mask
|
||||||
|
*/
|
||||||
int getActionMask() {if (actionMask) return *actionMask; return 0;};
|
int getActionMask() {if (actionMask) return *actionMask; return 0;};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\param index scan level index
|
||||||
|
\returns value of the current scan variable
|
||||||
|
*/
|
||||||
float getCurrentScanVariable(int index) {return currentScanVariable[index];};
|
float getCurrentScanVariable(int index) {return currentScanVariable[index];};
|
||||||
// int getScanPrecision(int index) {return scanPrecision[index];};
|
// int getScanPrecision(int index) {return scanPrecision[index];};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
/** action mask */
|
||||||
int *actionMask;
|
int *actionMask;
|
||||||
|
/** array of action scripts */
|
||||||
mystring *actionScript;
|
mystring *actionScript;
|
||||||
|
/** array of actionparameters */
|
||||||
mystring *actionParameter;
|
mystring *actionParameter;
|
||||||
|
|
||||||
|
/** pointer to number of steps [2] */
|
||||||
int *nScanSteps;
|
int *nScanSteps;
|
||||||
|
/** pointer to arrays of step values [2] */
|
||||||
mysteps *scanSteps;
|
mysteps *scanSteps;
|
||||||
|
/** pointer to array of scan mode [2] */
|
||||||
int *scanMode;
|
int *scanMode;
|
||||||
|
|
||||||
|
/** POINTER TO ARRAY OF SCAN PRECISION [2] */
|
||||||
int *scanPrecision;
|
int *scanPrecision;
|
||||||
|
|
||||||
|
/** pointer to array of scan scripts [2] */
|
||||||
mystring *scanScript;
|
mystring *scanScript;
|
||||||
|
|
||||||
|
/** pointer to array of scan parameters [2] */
|
||||||
mystring *scanParameter;
|
mystring *scanParameter;
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,6 +1,50 @@
|
|||||||
|
|
||||||
#ifndef SLS_DETECTOR_BASE_H
|
#ifndef SLS_DETECTOR_BASE_H
|
||||||
#define SLS_DETECTOR_BASE_H
|
#define SLS_DETECTOR_BASE_H
|
||||||
|
/**
|
||||||
|
\mainpage Common C++ library for SLS detectors data acquisition
|
||||||
|
*
|
||||||
|
* \section intro_sec Introduction
|
||||||
|
|
||||||
|
* \subsection mot_sec Motivation
|
||||||
|
Although the SLS detectors group delvelops several types of detectors (1/2D, counting/integrating etc.) it is common interest of the group to use a common platfor for data acquisition
|
||||||
|
\subsection arch_sec System Architecture
|
||||||
|
The architecture of the acquisitions system is intended as follows:
|
||||||
|
\li A socket server running on the detector (or more than one in some special cases)
|
||||||
|
\li C++ classes common to all detectors for client-server communication. These can be supplied to users as libraries and embedded also in acquisition systems which are not developed by the SLS
|
||||||
|
\li the possibility of using a Qt-based graphical user interface (with eventually root analisys capabilities)
|
||||||
|
\li the possibility of running all commands from command line. In order to ensure a fast operation of this so called "text client" the detector parameters should not be re-initialized everytime. For this reason a shared memory block is allocated where the main detector flags and parameters are stored
|
||||||
|
\li a Root library for data postprocessing and detector calibration (energy, angle).
|
||||||
|
|
||||||
|
\section howto_sec How to use it
|
||||||
|
|
||||||
|
The detectors can be simply operated by using the provided GUi or command line executable. <br>
|
||||||
|
In case you need to embed the detector control e.g in the beamline control software, compile these classes using
|
||||||
|
<BR>
|
||||||
|
make package
|
||||||
|
<br>
|
||||||
|
and link the shared library created to your software slsDetectorSoftware/bin/libSlsDetector.so
|
||||||
|
<br>
|
||||||
|
The software can also be installed (with super-user rights)<br>
|
||||||
|
make install
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
Most methods of interest for the user are implemented in the ::slsDetectorBase interface class, but the classes to be implemented in the main program are either ::slsDetector (for single controller detectors) or ::multiSlsDetector (for multiple controllers, but can work also for single controllers).
|
||||||
|
|
||||||
|
@author Anna Bergamaschi
|
||||||
|
@version 0.1alpha
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @author Anna Bergamaschi
|
||||||
|
* @version 0.1alpha
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "sls_detector_defs.h"
|
#include "sls_detector_defs.h"
|
||||||
@ -11,8 +55,13 @@
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
/**
|
/**
|
||||||
|
|
||||||
|
@libdoc The slsDetectorBase class is a minimal purely virtual interface class which should be instantiated by the users in their acquisition software (EPICS, spec etc.). More advanced configuration functions are not implemented and can be written in a configuration file tha can be read/written.
|
||||||
|
|
||||||
|
|
||||||
This class contains the functions accessible by the users to control the slsDetectors (both multiSlsDetector and slsDetector)
|
This class contains the functions accessible by the users to control the slsDetectors (both multiSlsDetector and slsDetector)
|
||||||
|
|
||||||
|
* @short This is the base class for detector functionalities of interest for the users.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@ -42,10 +91,10 @@ class slsDetectorBase : public slsDetectorDefs
|
|||||||
reads the IC (if required) <br>
|
reads the IC (if required) <br>
|
||||||
reads the encoder (iof required for angualr conversion) <br>
|
reads the encoder (iof required for angualr conversion) <br>
|
||||||
processes the data (flat field, rate, angular conversion and merging ::processData())
|
processes the data (flat field, rate, angular conversion and merging ::processData())
|
||||||
\param delflag 0 leaves the data in the final data queue
|
\param delflag 0 leaves the data in the final data queue (default is 1)
|
||||||
\returns nothing
|
\returns nothing
|
||||||
*/
|
*/
|
||||||
virtual void acquire(int delflag)=0;
|
virtual void acquire(int delflag=1)=0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
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
|
||||||
|
@ -653,7 +653,7 @@ string slsDetectorCommand::executeLine(int narg, char *args[], int action) {
|
|||||||
|
|
||||||
|
|
||||||
string slsDetectorCommand::cmdUnknown(int narg, char *args[], int action) {
|
string slsDetectorCommand::cmdUnknown(int narg, char *args[], int action) {
|
||||||
return string("Unknown command ")+string(args[0])+string("\n");//+helpLine(narg, args, action);
|
return string("Unknown command ")+string(args[0])+string("\n")+helpLine(0, args, action);
|
||||||
|
|
||||||
}
|
}
|
||||||
string slsDetectorCommand::cmdUnderDevelopment(int narg, char *args[], int action) {
|
string slsDetectorCommand::cmdUnderDevelopment(int narg, char *args[], int action) {
|
||||||
@ -681,62 +681,11 @@ string slsDetectorCommand::helpLine(int narg, char *args[], int action) {
|
|||||||
os << endl;
|
os << endl;
|
||||||
return os.str();
|
return os.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
return executeLine(narg,args,HELP_ACTION);
|
return executeLine(narg,args,HELP_ACTION);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// os << helpAcquire(narg,args,action) << endl;
|
|
||||||
|
|
||||||
// os << helpData(narg,args,action) << endl;
|
|
||||||
// os << helpFrame(narg,args,action) << endl;
|
|
||||||
// os << helpStatus(narg,args,action) << endl;
|
|
||||||
// os << helpFree(narg,args,action) << endl;
|
|
||||||
// os << helpAdd(narg,args,action) << endl;
|
|
||||||
// os << helpRemove(narg,args,action) << endl;
|
|
||||||
// os << helpHostname(narg,args,action) << endl;
|
|
||||||
// os << helpId(narg,args,action) << endl;
|
|
||||||
// os << helpMaster(narg,args,action) << endl;
|
|
||||||
// os << helpSync(narg,args,action) << endl;
|
|
||||||
// os << helpExitServer(narg,args,action) << endl;
|
|
||||||
// os << helpSettingsDir(narg,args,action) << endl;
|
|
||||||
// os << helpCalDir(narg,args,action) << endl;
|
|
||||||
// os << helpOutDir(narg,args,action) << endl;
|
|
||||||
// os << helpFileName(narg,args,action) << endl;
|
|
||||||
// os << helpFileIndex(narg,args,action) << endl;
|
|
||||||
// os << helpFlatField(narg,args,action) << endl;
|
|
||||||
// os << helpRateCorr(narg,args,action) << endl;
|
|
||||||
// os << helpBadChannels(narg,args,action) << endl;
|
|
||||||
// os << helpAngConv(narg,args,action) << endl;
|
|
||||||
// os << helpThreaded(narg,args,action) << endl;
|
|
||||||
// os << helpPositions(narg,args,action) << endl;
|
|
||||||
// os << helpScripts(narg,args,action) << endl;
|
|
||||||
// os << helpScans(narg,args,action) << endl;
|
|
||||||
// os << helpNetworkParameter(narg,args,action) << endl;
|
|
||||||
// os << helpPort(narg,args,action) << endl;
|
|
||||||
// os << helpLock(narg,args,action) << endl;
|
|
||||||
// os << helpLastClient(narg,args,action) << endl;
|
|
||||||
// os << helpOnline(narg,args,action) << endl;
|
|
||||||
// os << helpConfigureMac(narg,args,action) << endl;
|
|
||||||
// os << helpDetectorSize(narg,args,action) << endl;
|
|
||||||
// os << helpSettings(narg,args,action) << endl;
|
|
||||||
// os << helpSN(narg,args,action) << endl;
|
|
||||||
// os << helpDigiTest(narg,args,action) << endl;
|
|
||||||
// os << helpRegister(narg,args,action) << endl;
|
|
||||||
// os << helpDAC(narg,args,action) << endl;
|
|
||||||
// os << helpTimer(narg,args,action) << endl;
|
|
||||||
// os << helpTiming(narg,args,action) << endl;
|
|
||||||
// os << helpTimeLeft(narg,args,action) << endl;
|
|
||||||
// os << helpSpeed(narg,args,action) << endl;
|
|
||||||
// os << helpAdvanced(narg,args,action) << endl;
|
|
||||||
// os << helpConfiguration(narg,args,action) << endl;
|
|
||||||
// os << helpImage(narg,args,action) << endl;
|
|
||||||
// os << helpADC(narg,args,action) << endl;
|
|
||||||
|
|
||||||
// return os.str();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1010,6 +959,7 @@ string slsDetectorCommand::helpHostname(int narg, char *args[], int action){
|
|||||||
return os.str();
|
return os.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
string slsDetectorCommand::cmdId(int narg, char *args[], int action){
|
string slsDetectorCommand::cmdId(int narg, char *args[], int action){
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
cout << string("Executing command ")+string(args[0])+string(" ( ")+cmd+string(" )\n");
|
cout << string("Executing command ")+string(args[0])+string(" ( ")+cmd+string(" )\n");
|
||||||
@ -1130,7 +1080,14 @@ string slsDetectorCommand::cmdHelp(int narg, char *args[], int action){
|
|||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
cout << string("Executing command ")+string(args[0])+string(" ( ")+cmd+string(" )\n");
|
cout << string("Executing command ")+string(args[0])+string(" ( ")+cmd+string(" )\n");
|
||||||
#endif
|
#endif
|
||||||
return helpLine(narg, args, action);
|
|
||||||
|
cout << narg << endl;
|
||||||
|
|
||||||
|
if (narg>=1)
|
||||||
|
return helpLine(narg-1, args+1, action);
|
||||||
|
else
|
||||||
|
return helpLine(0, args, action);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -8,10 +8,9 @@
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
|
||||||
/* /\** This class handles the command line I/Os, help etc. */
|
/** @short This class handles the command line I/Os, help etc. of the text clients */
|
||||||
/* It is inherited by both slsDetector and multiSlsDetector */
|
|
||||||
|
|
||||||
/* *\/ */
|
|
||||||
class slsDetectorCommand : public slsDetectorDefs {
|
class slsDetectorCommand : public slsDetectorDefs {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -477,6 +477,8 @@ float slsDetectorUtils::getCurrentProgress() {
|
|||||||
return 100.*((float)progressIndex)/((float)totalProgress);
|
return 100.*((float)progressIndex)/((float)totalProgress);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void slsDetectorUtils::incrementProgress() {
|
void slsDetectorUtils::incrementProgress() {
|
||||||
progressIndex++;
|
progressIndex++;
|
||||||
cout << fixed << setprecision(2) << setw (6) << getCurrentProgress() << " \%";
|
cout << fixed << setprecision(2) << setw (6) << getCurrentProgress() << " \%";
|
||||||
|
@ -52,7 +52,11 @@ using namespace std;
|
|||||||
#define DEFAULT_HOSTNAME "localhost"
|
#define DEFAULT_HOSTNAME "localhost"
|
||||||
#define DEFAULT_SHM_KEY 5678
|
#define DEFAULT_SHM_KEY 5678
|
||||||
|
|
||||||
|
/**
|
||||||
|
@short class containing all the possible detector functionalities
|
||||||
|
|
||||||
|
(used in the PSi command line interface)
|
||||||
|
*/
|
||||||
class slsDetectorUtils : public slsDetectorActions, public postProcessing, public slsDetectorBase {
|
class slsDetectorUtils : public slsDetectorActions, public postProcessing, public slsDetectorBase {
|
||||||
|
|
||||||
|
|
||||||
@ -87,6 +91,11 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing, publi
|
|||||||
|
|
||||||
int getScanPrecision(int i){return slsDetectorActions::getScanPrecision(i);};
|
int getScanPrecision(int i){return slsDetectorActions::getScanPrecision(i);};
|
||||||
|
|
||||||
|
int getActionMask() {return slsDetectorActions::getActionMask();};
|
||||||
|
float getCurrentScanVariable(int i) {return slsDetectorActions::getCurrentScanVariable(i);};
|
||||||
|
int getCurrentPositionIndex(){return angularConversion::getCurrentPositionIndex();};
|
||||||
|
int getNumberOfPositions(){return angularConversion::getNumberOfPositions();};
|
||||||
|
|
||||||
|
|
||||||
string getFlatFieldCorrectionDir(){return postProcessing::getFlatFieldCorrectionDir();};
|
string getFlatFieldCorrectionDir(){return postProcessing::getFlatFieldCorrectionDir();};
|
||||||
string setFlatFieldCorrectionDir(string s){return postProcessing::setFlatFieldCorrectionDir(s);};
|
string setFlatFieldCorrectionDir(string s){return postProcessing::setFlatFieldCorrectionDir(s);};
|
||||||
@ -374,7 +383,7 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing, publi
|
|||||||
\returns nothing
|
\returns nothing
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void acquire(int delflag);
|
void acquire(int delflag=1);
|
||||||
|
|
||||||
|
|
||||||
// float* convertAngles(){return convertAngles(currentPosition);};
|
// float* convertAngles(){return convertAngles(currentPosition);};
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
angular conversion constant for a module
|
@short Angular conversion constants needed for a detector module
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
float center; /**< center of the module (channel at which the radius is perpendicular to the module surface) */
|
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 {
|
class angularConversion : public slsDetectorDefs {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
/** default constructor */
|
||||||
angularConversion();
|
angularConversion();
|
||||||
|
/** virtual destructor */
|
||||||
virtual ~angularConversion();
|
virtual ~angularConversion();
|
||||||
|
|
||||||
|
|
||||||
@ -51,45 +57,68 @@ class angularConversion : public slsDetectorDefs {
|
|||||||
|
|
||||||
reads an angular conversion file
|
reads an angular conversion file
|
||||||
\param fname file to be read
|
\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);
|
static int readAngularConversion(string fname, int nmod, angleConversionConstant *angOff);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
||||||
MOVE TO ANGULAR CALIBRATION?!?!??!?
|
|
||||||
reads an angular conversion file
|
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);
|
static int readAngularConversion(ifstream& ifs, int nmod, angleConversionConstant *angOff);
|
||||||
/**
|
/**
|
||||||
MOVE TO ANGULAR CALIBRATION?!?!??!?
|
|
||||||
writes an angular conversion file
|
writes an angular conversion file
|
||||||
\param fname file to be written
|
\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);
|
static int writeAngularConversion(string fname, int nmod, angleConversionConstant *angOff);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
MOVE TO ANGULAR CALIBRATION?!?!??!?
|
|
||||||
writes an angular conversion file
|
writes an angular conversion file
|
||||||
\param fname file to be written
|
\param ofstream output file stream
|
||||||
\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(ofstream& ofs, int nmod, angleConversionConstant *angOff);
|
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;
|
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 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();
|
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 mp already merged postions
|
||||||
\param mv already merged data
|
\param mv already merged data
|
||||||
\param me already merged errors (squared sum)
|
\param me already merged errors (squared sum)
|
||||||
\param mm multiplicity of merged arrays
|
\param mm multiplicity of merged arrays
|
||||||
\returns OK or FAIL
|
\returns OK or FAIL
|
||||||
\sa mythenDetector::resetMerging
|
|
||||||
*/
|
*/
|
||||||
static int resetMerging(float *mp, float *mv,float *me, int *mm, int nbins);
|
|
||||||
int resetMerging(float *mp, float *mv,float *me, int *mm);
|
int resetMerging(float *mp, float *mv,float *me, int *mm);
|
||||||
|
|
||||||
|
/**
|
||||||
|
creates the arrays for merging the data and sets them to 0.
|
||||||
|
*/
|
||||||
int resetMerging();
|
int resetMerging();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -110,77 +139,123 @@ 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 );
|
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);
|
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);
|
int addToMerging(float *p1, float *v1, float *e1,int *badChanMask);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
MOVE TO ANGULAR CALIBRATION?!?!??!?
|
calculates the "final" positions, data value and errors for the merged data
|
||||||
calculates the "final" positions, data value and errors for the emrged 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 mp already merged postions
|
||||||
\param mv already merged data
|
\param mv already merged data
|
||||||
\param me already merged errors (squared sum)
|
\param me already merged errors (squared sum)
|
||||||
\param mm multiplicity of merged arrays
|
\param mm multiplicity of merged arrays
|
||||||
\returns FAIL or the number of non empty bins (i.e. points belonging to the pattern)
|
\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);
|
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();
|
int finalizeMerging();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
pure virtual function
|
|
||||||
set detector global offset
|
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);};
|
float setGlobalOffset(float f){return setAngularConversionParameter(GLOBAL_OFFSET,f);};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
pure virtual function
|
|
||||||
set detector fine offset
|
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);};
|
float setFineOffset(float f){return setAngularConversionParameter(FINE_OFFSET,f);};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
pure virtual function
|
|
||||||
get detector fine offset
|
get detector fine offset
|
||||||
\sa mythenDetector::getFineOffset
|
\returns actual fine offset
|
||||||
*/
|
*/
|
||||||
float getFineOffset(){return getAngularConversionParameter(FINE_OFFSET);};
|
float getFineOffset(){return getAngularConversionParameter(FINE_OFFSET);};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
pure virtual function
|
|
||||||
get detector global offset
|
get detector global offset
|
||||||
\sa mythenDetector::getGlobalOffset
|
\returns actual global offset
|
||||||
*/
|
*/
|
||||||
float getGlobalOffset(){return getAngularConversionParameter(GLOBAL_OFFSET);};
|
float getGlobalOffset(){return getAngularConversionParameter(GLOBAL_OFFSET);};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
||||||
set detector bin size used for merging (approx angular resolution)
|
set detector bin size
|
||||||
\param bs bin size in degrees
|
\param bs bin size to be set
|
||||||
\returns current bin size
|
\returns actual bin size
|
||||||
\sa mythenDetector::setBinSize
|
*/
|
||||||
*/
|
|
||||||
float setBinSize(float bs){return setAngularConversionParameter(BIN_SIZE,bs);};
|
float setBinSize(float bs){return setAngularConversionParameter(BIN_SIZE,bs);};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
return detector bin size used for merging (approx angular resolution)
|
get detector bin size
|
||||||
\sa mythenDetector::getBinSize
|
\returns detector bin size used for merging (approx angular resolution)
|
||||||
*/
|
*/
|
||||||
float getBinSize() {return getAngularConversionParameter(BIN_SIZE);};
|
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);};
|
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);};
|
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;};
|
int getNumberOfAngularBins(){return nBins;};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -191,11 +266,25 @@ class angularConversion : public slsDetectorDefs {
|
|||||||
*/
|
*/
|
||||||
virtual int getAngularConversion(int &direction, angleConversionConstant *angconv=NULL)=0;
|
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);
|
float getAngularConversionParameter(angleConversionParameter c);
|
||||||
|
|
||||||
|
/**
|
||||||
|
pure virtual function
|
||||||
|
\returns total number of channels of the (multi)detector
|
||||||
|
*/
|
||||||
virtual int getTotalNumberOfChannels()=0;
|
virtual int getTotalNumberOfChannels()=0;
|
||||||
|
|
||||||
|
|
||||||
@ -214,10 +303,23 @@ class angularConversion : public slsDetectorDefs {
|
|||||||
*/
|
*/
|
||||||
virtual int getPositions(float *pos=NULL);
|
virtual int getPositions(float *pos=NULL);
|
||||||
|
|
||||||
|
/**
|
||||||
|
deletes the array of merged data
|
||||||
|
\returns OK
|
||||||
|
*/
|
||||||
int deleteMerging();
|
int deleteMerging();
|
||||||
|
|
||||||
|
/**
|
||||||
|
\returns pointer to the array o merged positions
|
||||||
|
*/
|
||||||
float *getMergedPositions(){return mergingBins;};
|
float *getMergedPositions(){return mergingBins;};
|
||||||
|
/**
|
||||||
|
\returns pointer to the array of merged counts
|
||||||
|
*/
|
||||||
float *getMergedCounts(){return mergingCounts;};
|
float *getMergedCounts(){return mergingCounts;};
|
||||||
|
/**
|
||||||
|
\returns pointer to the array of merged errors
|
||||||
|
*/
|
||||||
float *getMergedErrors(){return mergingErrors;};
|
float *getMergedErrors(){return mergingErrors;};
|
||||||
|
|
||||||
|
|
||||||
@ -237,42 +339,86 @@ class angularConversion : public slsDetectorDefs {
|
|||||||
string getAngularConversionFile(){if (setAngularCorrectionMask()) return string(angConvFile); else return string("none");};
|
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;
|
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;
|
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;
|
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;
|
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);
|
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);};
|
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;
|
virtual int getMoveFlag(int imod)=0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
returns current position index
|
||||||
|
*/
|
||||||
int getCurrentPositionIndex() {return currentPositionIndex;};
|
int getCurrentPositionIndex() {return currentPositionIndex;};
|
||||||
|
|
||||||
|
/**
|
||||||
|
returns number of positions
|
||||||
|
*/
|
||||||
int getNumberOfPositions() {return *numberOfPositions;};
|
int getNumberOfPositions() {return *numberOfPositions;};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
/** pointer to number of positions for the acquisition*/
|
||||||
int *numberOfPositions;
|
int *numberOfPositions;
|
||||||
|
|
||||||
|
/** pointer to the detector positions for the acquisition*/
|
||||||
float *detPositions;
|
float *detPositions;
|
||||||
|
|
||||||
|
/** pointer to angular conversion file name*/
|
||||||
char *angConvFile;
|
char *angConvFile;
|
||||||
|
|
||||||
|
/** pointer to angular bin size*/
|
||||||
float *binSize;
|
float *binSize;
|
||||||
|
|
||||||
|
/** pointer to beamlien fine offset*/
|
||||||
float *fineOffset;
|
float *fineOffset;
|
||||||
|
/** pointer to beamlien global offset*/
|
||||||
float *globalOffset;
|
float *globalOffset;
|
||||||
|
/** pointer to beamlien angular direction*/
|
||||||
int *angDirection;
|
int *angDirection;
|
||||||
|
/** pointer to detector move flag (1 moves with encoder, 0 not)*/
|
||||||
int *moveFlag;
|
int *moveFlag;
|
||||||
|
|
||||||
|
/** number of bins for angular conversion (360./binsize)*/
|
||||||
int nBins;
|
int nBins;
|
||||||
|
|
||||||
|
|
||||||
@ -287,6 +433,12 @@ class angularConversion : public slsDetectorDefs {
|
|||||||
*/
|
*/
|
||||||
int currentPositionIndex;
|
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;
|
virtual int setAngularCorrectionMask(int i=-1)=0;
|
||||||
|
|
||||||
|
|
||||||
@ -303,12 +455,6 @@ class angularConversion : public slsDetectorDefs {
|
|||||||
/** merging multiplicity */
|
/** merging multiplicity */
|
||||||
int *mergingMultiplicity;
|
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>
|
#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 {
|
class detectorData {
|
||||||
public:
|
public:
|
||||||
|
@ -5,19 +5,23 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
/**
|
||||||
|
@short class handling the energy calibration and trim files IO
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
class energyConversion: public slsDetectorDefs {
|
class energyConversion: public slsDetectorDefs {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
/** default constrauctor */
|
||||||
energyConversion(){};
|
energyConversion(){};
|
||||||
|
/** default destructor */
|
||||||
virtual ~energyConversion(){};
|
virtual ~energyConversion(){};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
||||||
reads a calibration file MOVE TO ENERGY CALIBRATION?!?!??!?
|
reads a calibration file
|
||||||
\param fname file to be read
|
\param fname file to be read
|
||||||
\param gain reference to the gain variable
|
\param gain reference to the gain variable
|
||||||
\offset reference to the offset 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 fname file to be written
|
||||||
\param gain
|
\param gain
|
||||||
\param offset
|
\param offset
|
||||||
@ -37,9 +41,9 @@ class energyConversion: public slsDetectorDefs {
|
|||||||
/**
|
/**
|
||||||
reads a trim/settings file
|
reads a trim/settings file
|
||||||
\param fname name of the file to be read
|
\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
|
\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
|
\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);
|
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
|
writes a trim/settings file
|
||||||
\param fname name of the file to be written
|
\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
|
\param mod module structure which has to be written to file
|
||||||
\returns OK or FAIL if the file could not be written
|
\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);
|
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;
|
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;
|
virtual void deleteModule(sls_detector_module *myMod)=0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
/** pointer to settings file name */
|
||||||
char *settingsFile;
|
char *settingsFile;
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,44 +12,54 @@
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
/**
|
||||||
|
@short class handling the data file I/O flags
|
||||||
|
*/
|
||||||
class fileIO : public slsDetectorDefs {
|
class fileIO : public slsDetectorDefs {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
/** default constructor */
|
||||||
fileIO(){};
|
fileIO(){};
|
||||||
|
/** virtual destructor */
|
||||||
virtual ~fileIO(){};
|
virtual ~fileIO(){};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
sets the default output files path
|
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);};
|
string setFilePath(string s) {sprintf(filePath, s.c_str()); return string(filePath);};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
sets the default output files root name
|
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);};
|
string setFileName(string s) {sprintf(fileName, s.c_str()); return string(fileName);};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
sets the default output file index
|
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;};
|
int setFileIndex(int i) {*fileIndex=i; return *fileIndex;};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
returns the default output files path
|
\returns the output files path
|
||||||
\sa sharedSlsDetector
|
|
||||||
*/
|
*/
|
||||||
string getFilePath() {return string(filePath);};
|
string getFilePath() {return string(filePath);};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
returns the default output files root name
|
\returns the output files root name
|
||||||
*/
|
*/
|
||||||
string getFileName() {return string(fileName);};
|
string getFileName() {return string(fileName);};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
returns the default output file index
|
\returns the output file index
|
||||||
*/
|
*/
|
||||||
int getFileIndex() {return *fileIndex;};
|
int getFileIndex() {return *fileIndex;};
|
||||||
|
|
||||||
@ -62,10 +72,10 @@ class fileIO : public slsDetectorDefs {
|
|||||||
|
|
||||||
always appends to file path and file name the run index.
|
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
|
Filenames will be of the form: filepath/filename(_Sy_sw_px)_i
|
||||||
where x is the position index and i is the run index
|
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 filepath outdir
|
||||||
\param filename file root name
|
\param filename file root name
|
||||||
\param aMask action mask (scans, positions)
|
\param aMask action mask (scans, positions)
|
||||||
@ -80,12 +90,15 @@ 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);
|
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();
|
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
|
\param fname file name
|
||||||
\returns file index*/
|
\returns file index
|
||||||
|
*/
|
||||||
static int getFileIndexFromFileName(string fname);
|
static int getFileIndexFromFileName(string fname);
|
||||||
|
|
||||||
/** static function that returns the variables from the file name
|
/** static function that returns the variables from the file name
|
||||||
@ -104,7 +117,7 @@ class fileIO : public slsDetectorDefs {
|
|||||||
/**
|
/**
|
||||||
|
|
||||||
writes a data file
|
writes a data file
|
||||||
\param name of the file to be written
|
\param fname of the file to be written
|
||||||
\param data array of data values
|
\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
|
||||||
|
|
||||||
@ -115,167 +128,287 @@ class fileIO : public slsDetectorDefs {
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
virtual int writeDataFile(string fname, float *data, float *err=NULL, float *ang=NULL, char dataformat='f', int nch=-1);
|
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
|
writes a data file
|
||||||
\param name of the file to be written
|
\paramoutfile output file stream
|
||||||
\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, int *data);
|
|
||||||
int writeDataFile(ofstream &outfile, int *data, 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
|
|
||||||
*/
|
|
||||||
virtual int writeDataFile(string fname, short int *data);
|
|
||||||
int writeDataFile(ofstream &outfile, short int *data, int offset=0);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
|
|
||||||
reads a data file
|
|
||||||
\param name 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');
|
|
||||||
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
|
|
||||||
\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);
|
|
||||||
int readDataFile(ifstream &infile, int *data, int offset=0);
|
|
||||||
|
|
||||||
/**
|
|
||||||
|
|
||||||
reads a data file
|
|
||||||
\param name 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);
|
|
||||||
int readDataFile(ifstream &infile, short int *data, int offset=0);
|
|
||||||
|
|
||||||
/**
|
|
||||||
|
|
||||||
writes a data file
|
|
||||||
\param name of the file to be written
|
|
||||||
\param data array of data values
|
\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 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 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 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
|
\returns OK or FAIL if it could not write the file or data=NULL
|
||||||
\sa mythenDetector::writeDataFile
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
int writeDataFile(ofstream &outfile, float *data, float *err=NULL, float *ang=NULL, char dataformat='f', int nch=-1, int offset=0);
|
||||||
|
|
||||||
static int writeDataFile(string fname, int nch, float *data, float *err=NULL, float *ang=NULL, char dataformat='f');
|
|
||||||
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
|
writes a data file
|
||||||
\param name of the file to be written
|
\param fname of the file to be written
|
||||||
\param data array of data values
|
\param data array of data values
|
||||||
\returns OK or FAIL if it could not write the file or data=NULL
|
\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);
|
virtual int writeDataFile(string fname, int *data);
|
||||||
static int writeDataFile(ofstream &outfile,int nch, int *data, int offset=0);
|
|
||||||
|
/**
|
||||||
|
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 of short ints
|
||||||
writes a data file
|
\param fname of the file to be written
|
||||||
\param name of the file to be written
|
|
||||||
\param data array of data values
|
\param data array of data values
|
||||||
\returns OK or FAIL if it could not write the file or data=NULL
|
\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);
|
virtual int writeDataFile(string fname, short int *data);
|
||||||
static int writeDataFile(ofstream &outfile,int nch, short int *data, int offset=0);
|
|
||||||
/**
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
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
|
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 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 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 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 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 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); /**
|
||||||
|
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 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);
|
||||||
|
/**
|
||||||
|
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 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 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)
|
||||||
|
\returns OK or FAIL if it could not write the file or data=NULL
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
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 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
|
||||||
|
*/
|
||||||
|
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 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
|
||||||
|
*/
|
||||||
|
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 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)
|
||||||
\returns number of channels read or -1 if it could not read the file or data=NULL
|
\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);
|
static int readDataFile(int nch, ifstream &infile, float *data, float *err=NULL, float *ang=NULL, char dataformat='f', int offset=0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
reads a raw data file
|
||||||
reads a data file
|
\param fname of the file to be read
|
||||||
\param name of the file to be read
|
|
||||||
\param data array of data values
|
\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
|
\returns OK or FAIL if it could not read the file or data=NULL
|
||||||
*/
|
*/
|
||||||
static int readDataFile(string fname, int *data, int nch);
|
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);
|
static int readDataFile(ifstream &infile, int *data, int nch, int offset);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
reads a short int rawdata file
|
||||||
reads a data file
|
|
||||||
\param name of the file to be read
|
\param name of the file to be read
|
||||||
\param data array of data values
|
\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
|
\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);
|
static int readDataFile(ifstream &infile, short int *data, int nch, int offset);
|
||||||
|
|
||||||
|
|
||||||
virtual int getActionMask() {return 0;};
|
/**
|
||||||
|
\returns action mask
|
||||||
virtual float getCurrentScanVariable(int index) {return 0;};
|
*/
|
||||||
virtual int getScanPrecision(int index) {return 0;};
|
virtual int getActionMask()=0;// {return 0;};
|
||||||
|
/**
|
||||||
virtual int getCurrentPositionIndex() {return 0;};
|
\param index scan level index
|
||||||
virtual int getNumberOfPositions() {return 0;};
|
\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;};
|
||||||
|
|
||||||
|
/**
|
||||||
|
\returns total number of channels
|
||||||
|
*/
|
||||||
virtual int getTotalNumberOfChannels()=0;
|
virtual int getTotalNumberOfChannels()=0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/** output directory */
|
||||||
char *filePath;
|
char *filePath;
|
||||||
|
/** file root name */
|
||||||
char *fileName;
|
char *fileName;
|
||||||
|
/** file index */
|
||||||
int *fileIndex;
|
int *fileIndex;
|
||||||
|
|
||||||
|
|
||||||
|
@ -127,19 +127,19 @@ int postProcessing::setBadChannelCorrection(string fname, int &nbad, int *badlis
|
|||||||
void postProcessing::processFrame(int *myData, int delflag) {
|
void postProcessing::processFrame(int *myData, int delflag) {
|
||||||
|
|
||||||
string fname;
|
string fname;
|
||||||
float *fdata;
|
// float *fdata=NULL;
|
||||||
|
|
||||||
|
|
||||||
incrementProgress();
|
incrementProgress();
|
||||||
|
|
||||||
/** decode data */
|
/** decode data */
|
||||||
fdata=decodeData(myData);
|
|
||||||
|
fdata=decodeData(myData, fdata);
|
||||||
|
|
||||||
fname=createFileName();
|
fname=createFileName();
|
||||||
|
|
||||||
|
|
||||||
//uses static function?!?!?!?
|
//uses static function?!?!?!?
|
||||||
// writeDataFile (fname+string(".raw"), getTotalNumberOfChannels(),fdata, NULL, NULL, 'i');
|
|
||||||
writeDataFile (fname+string(".raw"),fdata, NULL, NULL, 'i');
|
writeDataFile (fname+string(".raw"),fdata, NULL, NULL, 'i');
|
||||||
|
|
||||||
doProcessing(fdata,delflag);
|
doProcessing(fdata,delflag);
|
||||||
@ -174,20 +174,15 @@ void postProcessing::doProcessing(float *fdata, int delflag) {
|
|||||||
detectorData *thisData;
|
detectorData *thisData;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (*correctionMask!=0) {
|
|
||||||
ext=".dat";
|
|
||||||
} else {
|
|
||||||
ext=".raw";
|
|
||||||
}
|
|
||||||
|
|
||||||
fname=createFileName();
|
|
||||||
|
|
||||||
/** write raw data file */
|
/** write raw data file */
|
||||||
if (*correctionMask==0 && delflag==1) {
|
if (*correctionMask==0 && delflag==1) {
|
||||||
delete [] fdata;
|
// delete [] fdata;
|
||||||
|
;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
ext=".dat";
|
||||||
|
fname=createFileName();
|
||||||
|
|
||||||
/** rate correction */
|
/** rate correction */
|
||||||
if (*correctionMask&(1<<RATE_CORRECTION)) {
|
if (*correctionMask&(1<<RATE_CORRECTION)) {
|
||||||
rcdata=new float[getTotalNumberOfChannels()];
|
rcdata=new float[getTotalNumberOfChannels()];
|
||||||
@ -333,6 +328,7 @@ void postProcessing::doProcessing(float *fdata, int delflag) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
incrementFileIndex();
|
incrementFileIndex();
|
||||||
|
|
||||||
|
|
||||||
@ -422,6 +418,8 @@ void* postProcessing::processData(int delflag) {
|
|||||||
std::cout<< " processing data - threaded mode " << *threadedProcessing << endl;
|
std::cout<< " processing data - threaded mode " << *threadedProcessing << endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
setTotalProgress();
|
setTotalProgress();
|
||||||
pthread_mutex_lock(&mp);
|
pthread_mutex_lock(&mp);
|
||||||
queuesize=dataQueue.size();
|
queuesize=dataQueue.size();
|
||||||
@ -430,46 +428,44 @@ void* postProcessing::processData(int delflag) {
|
|||||||
int *myData;
|
int *myData;
|
||||||
int dum=1;
|
int dum=1;
|
||||||
|
|
||||||
|
fdata=NULL;
|
||||||
|
|
||||||
|
|
||||||
while(dum | *threadedProcessing) { // ????????????????????????
|
while(dum | *threadedProcessing) { // ????????????????????????
|
||||||
|
|
||||||
|
|
||||||
|
/* IF THERE ARE DATA PROCESS THEM*/
|
||||||
pthread_mutex_lock(&mp);
|
pthread_mutex_lock(&mp);
|
||||||
while((queuesize=dataQueue.size())>0) {
|
while((queuesize=dataQueue.size())>0) {
|
||||||
|
|
||||||
/** Pop data queue */
|
/** Pop data queue */
|
||||||
myData=dataQueue.front(); // get the data from the queue
|
myData=dataQueue.front(); // get the data from the queue
|
||||||
pthread_mutex_unlock(&mp);
|
pthread_mutex_unlock(&mp);
|
||||||
|
|
||||||
|
|
||||||
if (myData) {
|
if (myData) {
|
||||||
|
|
||||||
processFrame(myData,delflag);
|
processFrame(myData,delflag);
|
||||||
|
//usleep(1000);
|
||||||
|
}
|
||||||
|
pthread_mutex_lock(&mp);
|
||||||
|
|
||||||
usleep(1000);
|
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&mp);
|
pthread_mutex_unlock(&mp);
|
||||||
usleep(1000);
|
|
||||||
|
|
||||||
}
|
/* IF THERE ARE NO DATA look if acquisition is finished */
|
||||||
|
|
||||||
|
|
||||||
pthread_mutex_unlock(&mp);
|
|
||||||
pthread_mutex_lock(&mp);
|
pthread_mutex_lock(&mp);
|
||||||
if (jointhread) {
|
if (jointhread) {
|
||||||
if (dataQueue.size()==0) {
|
if (dataQueue.size()==0) {
|
||||||
pthread_mutex_unlock(&mp);
|
pthread_mutex_unlock(&mp);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pthread_mutex_unlock(&mp);
|
pthread_mutex_unlock(&mp);
|
||||||
} else {
|
} else {
|
||||||
pthread_mutex_unlock(&mp);
|
pthread_mutex_unlock(&mp);
|
||||||
}
|
}
|
||||||
dum=0;
|
dum=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (fdata)
|
||||||
|
delete [] fdata;
|
||||||
return 0;
|
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 */
|
#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 {
|
class postProcessing : public angularConversion, public fileIO {
|
||||||
|
|
||||||
|
|
||||||
@ -232,7 +238,7 @@ s
|
|||||||
virtual int setTotalProgress()=0;
|
virtual int setTotalProgress()=0;
|
||||||
|
|
||||||
|
|
||||||
virtual float* decodeData(int *datain)=0;
|
virtual float* decodeData(int *datain, float *fdata=NULL)=0;
|
||||||
virtual int getTotalNumberOfChannels()=0;
|
virtual int getTotalNumberOfChannels()=0;
|
||||||
|
|
||||||
|
|
||||||
@ -353,7 +359,7 @@ s
|
|||||||
*/
|
*/
|
||||||
float currentI0;
|
float currentI0;
|
||||||
|
|
||||||
|
float *fdata;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user