AngularConversion splitted in a static file and in one file dependent on slsDetectorBase

git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@240 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
bergamaschi
2012-09-05 10:12:49 +00:00
parent ca75754b83
commit 6b34cb8e71
14 changed files with 1636 additions and 380 deletions

View File

@ -2,12 +2,19 @@
#ifndef ANGULARCONVERSION_H
#define ANGULARCONVERSION_H
#ifdef __CINT
#define MYROOT
#endif
#ifndef MYROOT
#include "slsDetectorBase.h"
#else
#include "sls_detector_defs.h"
#endif
#include <string>
#include <fstream>
#include "angularConversionStatic.h"
//double angle(int ichan, double encoder, double totalOffset, double conv_r, double center, double offset, double tilt, int direction)
@ -17,16 +24,6 @@ using namespace std;
/**
@short Angular conversion constants needed for a detector module
*/
typedef struct {
double center; /**< center of the module (channel at which the radius is perpendicular to the module surface) */
double ecenter; /**< error in the center determination */
double r_conversion; /**< detector pixel size (or strip pitch) divided by the diffractometer radius */
double er_conversion; /**< error in the r_conversion determination */
double offset; /**< the module offset i.e. the position of channel 0 with respect to the diffractometer 0 */
double eoffset; /**< error in the offset determination */
double tilt; /**< ossible tilt in the orthogonal direction (unused)*/
double etilt; /**< error in the tilt determination */
} angleConversionConstant;
/**
@ -38,7 +35,9 @@ class containing the methods to set/unset the angular conversion and merge the d
The angular conversion itself is defined by the angle() function defined in usersFunctions.cpp
*/
class angularConversion : public virtual slsDetectorBase {
class angularConversion : public virtual slsDetectorBase, public virtual angularConversionStatic
{
public:
/** default constructor */
@ -53,59 +52,11 @@ class angularConversion : public virtual slsDetectorBase {
/**
reads an angular conversion file
\param fname file to be read
\param nmod number of modules (maximum) to be read
\param angOff pointer to array of angleConversionConstants
\returns OK or FAIL
*/
static int readAngularConversion(string fname, int nmod, angleConversionConstant *angOff);
/**
reads an angular conversion file
\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);
/**
writes an angular conversion file
\param fname file to be written
\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);
/**
writes an angular conversion file
\param ofstream output file stream
\param nmod number of modules to be written
\param angOff pointer to array of angleConversionConstants
\returns OK or FAIL
*/
static int writeAngularConversion(ofstream& ofs, int nmod, angleConversionConstant *angOff);
/**
pure virtual function
\param file name to be written (nmod and array of angular conversion constants default to the ones ot the slsDetector
*/
virtual int writeAngularConversion(string fname)=0;
/**
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(double *mp, double *mv,double *me, int *mm, int nbins);
/**
sets the arrays of the merged data to 0. NB The array should be created with size >= 360./getBinSize();
\param mp already merged postions
@ -121,23 +72,6 @@ class angularConversion : public virtual slsDetectorBase {
*/
int resetMerging();
/**
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 nchans number of channels
\param binsize size of angular bin
\param nb number of angular bins
\param badChanMask badchannelmask (if NULL does not correct for bad channels)
\returns OK or FAIL
*/
static int addToMerging(double *p1, double *v1, double *e1, double *mp, double *mv,double *me, int *mm, int nchans, double binsize,int nb, int *badChanMask );
/**
merge dataset
@ -164,17 +98,6 @@ class angularConversion : public virtual slsDetectorBase {
int addToMerging(double *p1, double *v1, double *e1,int *badChanMask);
/**
calculates the "final" positions, data value and errors for the merged data
\param mp already merged postions
\param mv already merged data
\param me already merged errors (squared sum)
\param mm multiplicity of merged arrays
\param nb number of bins
\returns FAIL or the number of non empty bins (i.e. points belonging to the pattern)
*/
static int finalizeMerging(double *mp, double *mv,double *me, int *mm, int nb);
/**
calculates the "final" positions, data value and errors for the merged data
\param mp already merged postions
@ -368,6 +291,9 @@ class angularConversion : public virtual slsDetectorBase {
\returns array of angles corresponding to the channels
*/
double* convertAngles(double pos);
/**
converts channel number to angle for the current encoder position
\returns array of angles corresponding to the channels
@ -377,6 +303,7 @@ class angularConversion : public virtual slsDetectorBase {
/**
\param imod module number
\returns move flag of the module (1 encoder is added to the angle, 0 not)
Shold be module dependent!
*/
virtual int getMoveFlag(int imod)=0;
@ -385,8 +312,11 @@ class angularConversion : public virtual slsDetectorBase {
*/
int getNumberOfPositions() {return *numberOfPositions;};
protected:
/** pointer to number of positions for the acquisition*/
int *numberOfPositions;
@ -439,11 +369,21 @@ class angularConversion : public virtual slsDetectorBase {
void registerAngleFunctionCallback(double( *fun)(double, double, double, double, double, double, double, int)) {angle = fun;};
private:
// int nChans;
// int nMods;
// int chansPerMod;
// int moveFlag;
/** merging bins */
double *mergingBins;
@ -456,8 +396,6 @@ class angularConversion : public virtual slsDetectorBase {
/** merging multiplicity */
int *mergingMultiplicity;
double (*angle)(double, double, double, double, double, double, double, int);
};
#endif