mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-20 02:40:03 +02:00
almost compiling on 64bit...
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@297 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
parent
0c89b0986f
commit
6fb6f72bc3
@ -1,4 +1,4 @@
|
||||
CFLAGS= -DC_ONLY
|
||||
CFLAGS= -DC_ONLY -fPIC
|
||||
#FLAGS+= #-DVERBOSE -DVERYVERBOSE
|
||||
|
||||
DFLAGS= -DDACS_INT
|
||||
@ -40,11 +40,11 @@ picassoServer: $(SRC_MYTHEN_SVC)
|
||||
|
||||
|
||||
%.o : %.cpp %.h
|
||||
$(CXX) -Wall -o $@ -c $< $(INCLUDES) $(DFLAGS) $(FLAGS) $(EPICSFLAGS)
|
||||
$(CXX) -Wall -o $@ -c $< $(INCLUDES) $(DFLAGS) $(FLAGS) -fPIC $(EPICSFLAGS)
|
||||
|
||||
|
||||
package: $(OBJS)
|
||||
$(CXX) -shared -Wl,-soname,libSlsDetector.so -o libSlsDetector.so $(OBJS) -lc $(INCLUDES) $(DFLAGS) $(FLAGS) $(EPICSFLAGS)
|
||||
$(CXX) -shared -Wl,-soname,libSlsDetector.so -o libSlsDetector.so $(OBJS) -lc $(INCLUDES) $(DFLAGS) $(FLAGS) $(EPICSFLAGS)
|
||||
ar rcs libSlsDetector.a $(OBJS)
|
||||
|
||||
clean:
|
||||
|
@ -22,9 +22,9 @@ using namespace std;
|
||||
|
||||
extern "C" {
|
||||
|
||||
void init_dataset(int *nMod, int *chPerMod, int* modMask, int *badChanMask, double *ffCoeff, double *ffErr, double *tDead, double *angRadius, double *angOffset, double *angCenter, double *totalOff, double *binSize, double * sampleX, double* sampleY);
|
||||
void init_dataset(int *nMod, int *chPerMod, int* modMask, int *badChanMask, double *ffCoeff, double *ffErr, double *tDead, int *dir, double *angRadius, double *angOffset, double *angCenter, double *totalOff, double *binSize, double * sampleX, double* sampleY);
|
||||
void finalize_dataset(double *outang, double *outval, double *outerr, int *np);
|
||||
void add_frame(double *data, double *pos, double *i0, char *fn, double *var);
|
||||
void add_frame(double *data, double *pos, double *i0, double *exptime, char *fn, double *var);
|
||||
void calculate_flat_field(int *nMod, int *chPerMod, int *modMask,int *badChanMask, double *data, double *ffc, double *fferr);
|
||||
}
|
||||
|
||||
@ -39,13 +39,13 @@ class externPostProcessing
|
||||
virtual ~externPostProcessing(){};
|
||||
|
||||
|
||||
static int InitDataset(int *nModules,int *chPerMod,int moduleMask[],int badChans[], double ffcoeff[], double fferr[], double* tDead, double angRadius[], double angOffset[], double angCentre[], double* totalOffset, double* binSize, double *sampleX, double *sampleY);
|
||||
static int InitDataset(int *nModules,int *chPerMod,int moduleMask[],int badChans[], double ffcoeff[], double fferr[], double* tDead, int *dir, double angRadius[], double angOffset[], double angCentre[], double* totalOffset, double* binSize, double *sampleX, double *sampleY);
|
||||
|
||||
|
||||
|
||||
static int finalizeDataset(double ang[], double val[], double err[], int *np);
|
||||
|
||||
static int addFrame(double data[], double *pos, double *IO, double expTime, const char *filename, int *var=0);
|
||||
static int addFrame(double data[], double *pos, double *IO, double *expTime, const char *filename, int *var=0);
|
||||
|
||||
static int calculateFlatField(int* nModules, int *chPerMod, int moduleMask[], int badChannelMask[], double ffData[], double ffCoeff[], double ffErr[]);
|
||||
|
||||
|
@ -2194,7 +2194,7 @@ dacs_t multiSlsDetector::getADC(dacIndex idac, int imod) {
|
||||
return ret1;
|
||||
}
|
||||
|
||||
int multiSlsDetector::setChannel(long long reg, int ichan, int ichip, int imod) {
|
||||
int multiSlsDetector::setChannel(int64_t reg, int ichan, int ichip, int imod) {
|
||||
int ret, ret1=-100;
|
||||
int id=-1, im=-1;
|
||||
int dmi=0, dma=thisMultiDetector->numberOfDetectors;
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include "slsDetectorActions.h"
|
||||
#include <iostream>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
using namespace std;
|
||||
|
||||
|
||||
|
@ -198,7 +198,7 @@ class slsDetectorActions : public virtual slsDetectorBase
|
||||
|
||||
|
||||
virtual int setThresholdEnergy(int, int im=-1, detectorSettings isettings=GET_SETTINGS)=0;
|
||||
virtual int setChannel(long long, int ich=-1, int ichip=-1, int imod=-1)=0;
|
||||
virtual int setChannel(int64_t, int ich=-1, int ichip=-1, int imod=-1)=0;
|
||||
|
||||
|
||||
int setStartIndex(int i=-1){if (i>=0) {startIndex=i; lastIndex=startIndex; nowIndex=startIndex;};return startIndex;};
|
||||
|
@ -194,11 +194,37 @@ string slsDetectorUsers::getDetectorType(){
|
||||
}
|
||||
|
||||
|
||||
|
||||
void slsDetectorUsers::initDataset(int refresh){
|
||||
myDetector->initDataset(refresh);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void slsDetectorUsers::addFrame(double *data, double pos, double i0, double t, string fname, double var){
|
||||
myDetector->addFrame(data,pos,i0,t,fname,var);
|
||||
}
|
||||
|
||||
|
||||
void slsDetectorUsers::finalizeDataset(double *a, double *v, double *e, int &np){
|
||||
myDetector->finalizeDataset(a, v, e, np);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void slsDetectorUsers::registerDataCallback(int( *userCallback)(detectorData*, void*), void *pArg){
|
||||
myDetector->registerDataCallback(userCallback,pArg);
|
||||
}
|
||||
|
||||
void slsDetectorUsers::registerRawDataCallback(int( *userCallback)(double*, void*), void *pArg){
|
||||
void slsDetectorUsers::registerRawDataCallback(int( *userCallback)(double*, int, void*), void *pArg){
|
||||
myDetector->registerRawDataCallback(userCallback,pArg);
|
||||
}
|
||||
|
||||
|
@ -358,12 +358,46 @@ class slsDetectorUsers
|
||||
void registerDataCallback(int( *userCallback)(detectorData*, void*), void *pArg);
|
||||
|
||||
/**
|
||||
@short register calbback for accessing raw data
|
||||
\param userCallback function for postprocessing and saving the data
|
||||
@short register callback for accessing raw data - if the rawDataCallback is registered, no filewriting/postprocessing will be carried on automatically by the software - the raw data are deleted by the software
|
||||
\param userCallback function for postprocessing and saving the data - p is the pointer to the data, n is the number of channels
|
||||
*/
|
||||
|
||||
void registerRawDataCallback(int( *userCallback)(double*, void*), void *pArg);
|
||||
void registerRawDataCallback(int( *userCallback)(double* p, int n, void*), void *pArg);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
@short function to initalize a set of measurements (reset binning if angular conversion, reset summing otherwise) - can be overcome by the user's functions thanks to the virtual property
|
||||
\param refresh if 1, all parameters like ffcoefficients, badchannels, ratecorrections etc. are reset (should be called at least onece with this option), if 0 simply reset merging/ summation
|
||||
*/
|
||||
|
||||
virtual void initDataset(int refresh);
|
||||
|
||||
|
||||
/**
|
||||
@short adds frame to merging/summation - can be overcome by the user's functions thanks to the virtual property
|
||||
\param data pointer to the raw data
|
||||
\param pos encoder position
|
||||
\param i0 beam monitor readout for intensity normalization (if 0 not performed)
|
||||
\param t exposure time in seconds, required only if rate corrections
|
||||
\param fname file name (unused since filewriting would be performed by the user)
|
||||
\param var optional parameter - unused.
|
||||
*/
|
||||
|
||||
virtual void addFrame(double *data, double pos, double i0, double t, string fname, double var);
|
||||
|
||||
/**
|
||||
@short finalizes the data set returning the array of angles, values and errors to be used as final data - can be overcome by the user's functions thanks to the virtual property
|
||||
\param a pointer to the array of angles - can be null if no angular coversion is required
|
||||
\param v pointer to the array of values
|
||||
\param e pointer to the array of errors
|
||||
\param np reference returning the number of points
|
||||
*/
|
||||
|
||||
virtual void finalizeDataset(double *a, double *v, double *e, int &np);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
@short register calbback for accessing detector final data
|
||||
\param func function to be called at the end of the acquisition. gets detector status and progress index as arguments
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <math.h>
|
||||
#include <cstring>
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
@ -69,31 +69,18 @@ double* angularConversionStatic::convertAngles(double pos, int nch, int *chansPe
|
||||
return ang;
|
||||
}
|
||||
|
||||
double angularConversionStatic::convertAngle(double pos, int ich, int *chansPerMod, angleConversionConstant **angOff, int *mF, double fo, double go, int angdir) {
|
||||
|
||||
int imod=0;
|
||||
double ang;
|
||||
|
||||
|
||||
|
||||
|
||||
double angularConversionStatic::convertAngle(double pos, int ich, angleConversionConstant *p, int mF, double fo, double go, int angdir) {
|
||||
|
||||
|
||||
double enc=0, trans=0;
|
||||
angleConversionConstant *p=NULL;
|
||||
|
||||
int ch0=0;
|
||||
int chlast=chansPerMod[0]-1;
|
||||
int nchmod=chansPerMod[0];
|
||||
double ang;
|
||||
|
||||
|
||||
|
||||
while (ich>chlast) {
|
||||
imod++;
|
||||
ch0=chlast+1;
|
||||
nchmod=chansPerMod[imod];
|
||||
chlast=ch0+nchmod-1;
|
||||
}
|
||||
|
||||
p=angOff[imod];
|
||||
|
||||
|
||||
|
||||
switch (mF[imod]) {
|
||||
switch (mF) {
|
||||
case 0:
|
||||
enc=0;
|
||||
trans=0;
|
||||
@ -118,11 +105,9 @@ double angularConversionStatic::convertAngle(double pos, int ich, int *chansPerM
|
||||
enc=0;
|
||||
trans=0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (p)
|
||||
ang=angle(ich-ch0, \
|
||||
ang=angle(ich, \
|
||||
enc, \
|
||||
fo+go, \
|
||||
p->r_conversion, \
|
||||
@ -133,6 +118,47 @@ double angularConversionStatic::convertAngle(double pos, int ich, int *chansPerM
|
||||
|
||||
return ang;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
double angularConversionStatic::convertAngle(double pos, int ich, int *chansPerMod, angleConversionConstant **angOff, int *mF, double fo, double go, int angdir) {
|
||||
|
||||
int imod=0;
|
||||
double ang;
|
||||
double enc=0, trans=0;
|
||||
angleConversionConstant *p=NULL;
|
||||
|
||||
int ch0=0;
|
||||
int chlast=chansPerMod[0]-1;
|
||||
int nchmod=chansPerMod[0];
|
||||
|
||||
|
||||
|
||||
while (ich>chlast) {
|
||||
imod++;
|
||||
ch0=chlast+1;
|
||||
nchmod=chansPerMod[imod];
|
||||
chlast=ch0+nchmod-1;
|
||||
}
|
||||
|
||||
p=angOff[imod];
|
||||
|
||||
|
||||
ang=convertAngle(pos, ich-ch0, p, mF[imod], fo, go, angdir);
|
||||
|
||||
return ang;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -162,12 +188,13 @@ int angularConversionStatic::readAngularConversion(string fname, int nmod, angle
|
||||
int angularConversionStatic::readAngularConversion( ifstream& infile, int nmod, angleConversionConstant *angOff) {
|
||||
string str;
|
||||
int mod;
|
||||
double center, ecenter;
|
||||
double center, ecenter, pitch, epitch;
|
||||
double r_conv, er_conv;
|
||||
double off, eoff;
|
||||
string ss;
|
||||
int interrupt=0;
|
||||
int nm=0;
|
||||
int newangconv=0;
|
||||
//" module %i center %E +- %E conversion %E +- %E offset %f +- %f \n"
|
||||
while (infile.good() and interrupt==0) {
|
||||
getline(infile,str);
|
||||
@ -178,18 +205,31 @@ int angularConversionStatic::readAngularConversion( ifstream& infile, int nmod,
|
||||
istringstream ssstr(str);
|
||||
ssstr >> ss >> mod;
|
||||
ssstr >> ss >> center;
|
||||
if (ss==string("center"))
|
||||
newangconv=1;
|
||||
ssstr >> ss >> ecenter;
|
||||
if (newangconv) {
|
||||
ssstr >> ss >> pitch;
|
||||
ssstr >> ss >> epitch;
|
||||
}
|
||||
ssstr >> ss >> r_conv;
|
||||
ssstr >> ss >> er_conv;
|
||||
ssstr >> ss >> off;
|
||||
ssstr >> ss >> eoff;
|
||||
if (nm<nmod && nm>=0 ) {
|
||||
angOff[nm].center=center;
|
||||
angOff[nm].r_conversion=r_conv;
|
||||
angOff[nm].offset=off;
|
||||
angOff[nm].ecenter=ecenter;
|
||||
angOff[nm].er_conversion=er_conv;
|
||||
angOff[nm].eoffset=eoff;
|
||||
if (newangconv==0) {
|
||||
angOff[nm].center=center;
|
||||
angOff[nm].r_conversion=r_conv;
|
||||
angOff[nm].offset=off;
|
||||
angOff[nm].ecenter=ecenter;
|
||||
angOff[nm].er_conversion=er_conv;
|
||||
angOff[nm].eoffset=eoff;
|
||||
} else {
|
||||
|
||||
angOff[nm].tilt=pitch;
|
||||
angOff[nm].etilt=epitch;
|
||||
|
||||
}
|
||||
} else
|
||||
break;
|
||||
//cout << nm<<" " << angOff[nm].offset << endl;
|
||||
|
@ -258,9 +258,9 @@ int angularConversionStatic::finalizeMerging(double *mp, double *mv, double *me,
|
||||
for (int ibin=0; ibin<nb; ibin++) {
|
||||
if (mm[ibin]>0) {
|
||||
|
||||
#ifdef VERBOSE
|
||||
cout << "finalize " << ibin << " "<< mm[ibin] << " " << mp[ibin]<< mv[ibin] << me[ibin] << endl;
|
||||
#endif
|
||||
// #ifdef VERBOSE
|
||||
// cout << "finalize " << ibin << " "<< mm[ibin] << " " << mp[ibin]<< mv[ibin] << me[ibin] << endl;
|
||||
// #endif
|
||||
mp[np]=mp[ibin]/mm[ibin];
|
||||
mv[np]=mv[ibin]/mm[ibin];
|
||||
me[np]=me[ibin]/mm[ibin];
|
||||
@ -323,9 +323,9 @@ int angularConversionStatic::addToMerging(double *p1, double *v1, double *e1, d
|
||||
me[ibin]+=v1[ip];
|
||||
mm[ibin]++;
|
||||
|
||||
#ifdef VERBOSE
|
||||
cout << "add " << ibin << " "<< mm[ibin] << " " << mp[ibin]<< mv[ibin] << me[ibin] << endl;
|
||||
#endif
|
||||
// #ifdef VERBOSE
|
||||
// cout << "add " << ibin << " "<< mm[ibin] << " " << mp[ibin]<< mv[ibin] << me[ibin] << endl;
|
||||
// #endif
|
||||
} else
|
||||
return slsDetectorDefs::FAIL;
|
||||
}
|
||||
@ -371,9 +371,9 @@ int angularConversionStatic::addPointToMerging(double p1, double v1, double e1,
|
||||
me[ibin]+=v1;
|
||||
mm[ibin]++;
|
||||
|
||||
#ifdef VERBOSE
|
||||
cout << "add " << ibin << " "<< mm[ibin] << " " << mp[ibin]<< mv[ibin] << me[ibin] << endl;
|
||||
#endif
|
||||
// #ifdef VERBOSE
|
||||
// cout << "add " << ibin << " "<< mm[ibin] << " " << mp[ibin]<< mv[ibin] << me[ibin] << endl;
|
||||
// #endif
|
||||
} else
|
||||
return slsDetectorDefs::FAIL;
|
||||
|
||||
|
@ -161,6 +161,9 @@ class angularConversionStatic
|
||||
double convertAngle(double pos, int ich, int *chansPerMod, angleConversionConstant **angOff, int *mF, double fo, double go, int angdir);
|
||||
|
||||
|
||||
double convertAngle(double pos, int ich, angleConversionConstant *angOff, int mF, double fo, double go, int angdir);
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -116,7 +116,26 @@ class angularConversionStatic
|
||||
\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 );
|
||||
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=NULL);
|
||||
|
||||
|
||||
/**
|
||||
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 addPointToMerging(double p1, double v1, double e1, double *mp, double *mv,double *me, int *mm, double binsize, int nb);
|
||||
|
||||
|
||||
/**
|
||||
@ -139,6 +158,8 @@ class angularConversionStatic
|
||||
|
||||
double* convertAngles(double pos, int nch, int *chansPerMod, angleConversionConstant **angOff, int *mF, double fo, double go, int angdir);
|
||||
|
||||
double convertAngle(double pos, int ich, int *chansPerMod, angleConversionConstant **angOff, int *mF, double fo, double go, int angdir);
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
@ -3,26 +3,30 @@
|
||||
#include "angleConversionConstant.h"
|
||||
#ifdef VERBOSE
|
||||
#include "usersFunctions.h"
|
||||
#elif EXTPP
|
||||
#include "usersFunctions.h"
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
postProcessing::postProcessing(): expTime(NULL), ang(NULL), val(NULL), err(NULL){
|
||||
postProcessing::postProcessing(): expTime(NULL), ang(NULL), val(NULL), err(NULL), numberOfChannels(0){
|
||||
pthread_mutex_t mp1 = PTHREAD_MUTEX_INITIALIZER;
|
||||
mp=mp1;
|
||||
pthread_mutex_init(&mp, NULL);
|
||||
mg=mp1;
|
||||
pthread_mutex_init(&mg, NULL);
|
||||
// mg=mp1;
|
||||
// pthread_mutex_init(&mg, NULL);
|
||||
//cout << "reg callback "<< endl;
|
||||
dataReady = 0;
|
||||
pCallbackArg = 0;
|
||||
#ifdef VERBOSE
|
||||
registerDataCallback(&defaultDataReadyFunc, NULL);
|
||||
#endif
|
||||
//cout << "done "<< endl;
|
||||
rawDataReady = 0;
|
||||
pRawDataArg = 0;
|
||||
|
||||
#ifdef VERBOSE
|
||||
registerDataCallback(&defaultDataReadyFunc, NULL);
|
||||
#endif
|
||||
#ifdef EXTPP
|
||||
registerRawDataCallback(&defaultRawDataReadyFunc, NULL);
|
||||
#endif
|
||||
ppFun=new postProcessingFuncs();
|
||||
}
|
||||
|
||||
@ -30,7 +34,9 @@ postProcessing::postProcessing(): expTime(NULL), ang(NULL), val(NULL), err(NULL)
|
||||
|
||||
|
||||
|
||||
postProcessing::~postProcessing(){delete ppFun;};
|
||||
postProcessing::~postProcessing(){
|
||||
delete ppFun;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -62,50 +68,60 @@ void postProcessing::processFrame(int *myData, int delflag) {
|
||||
cout << "decode"<< endl;
|
||||
#endif
|
||||
|
||||
if (rawDataReady) {
|
||||
//#ifdef VERBOSE
|
||||
cout << "raw data ready..." << endl;
|
||||
//#endif
|
||||
rawDataReady(fdata,numberOfChannels, pRawDataArg);
|
||||
//#ifdef VERBOSE
|
||||
cout << "done" << endl;
|
||||
cout << "NO FILE WRITING AND/OR DATA PROCESSING DONE BY SLS DETECTOR SOFTWARE!!!" << endl;
|
||||
//#endif
|
||||
|
||||
} else {
|
||||
|
||||
|
||||
pthread_mutex_lock(&mp);
|
||||
fname=createFileName();
|
||||
pthread_mutex_unlock(&mp);
|
||||
pthread_mutex_lock(&mp);
|
||||
fname=createFileName();
|
||||
pthread_mutex_unlock(&mp);
|
||||
#ifdef VERBOSE
|
||||
cout << "fname is " << fname << endl;
|
||||
cout << "fname is " << fname << endl;
|
||||
#endif
|
||||
|
||||
//Checking for write flag
|
||||
if((*correctionMask)&(1<<WRITE_FILE)) {
|
||||
|
||||
//Checking for write flag
|
||||
if((*correctionMask)&(1<<WRITE_FILE)) {
|
||||
|
||||
#ifdef VERBOSE
|
||||
cout << "writing raw data " << endl;
|
||||
|
||||
cout << "writing raw data " << endl;
|
||||
|
||||
#endif
|
||||
//uses static function?!?!?!?
|
||||
writeDataFile (fname+string(".raw"),fdata, NULL, NULL, 'i');
|
||||
|
||||
writeDataFile (fname+string(".raw"),fdata, NULL, NULL, 'i');
|
||||
|
||||
#ifdef VERBOSE
|
||||
cout << "done " << endl;
|
||||
|
||||
#endif
|
||||
}
|
||||
if (rawDataReady) {
|
||||
#ifdef VERBOSE
|
||||
cout << "raw data ready..." << endl;
|
||||
#endif
|
||||
rawDataReady(fdata,pRawDataArg);
|
||||
#ifdef VERBOSE
|
||||
cout << "done" << endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
if ((*correctionMask) & ~(1<<WRITE_FILE)) {
|
||||
doProcessing(fdata,delflag, fname);
|
||||
} else
|
||||
if (dataReady) {
|
||||
thisData=new detectorData(fdata,NULL,NULL,getCurrentProgress(),(fname+string(".raw")).c_str(),getTotalNumberOfChannels());
|
||||
dataReady(thisData, pCallbackArg);
|
||||
delete thisData;
|
||||
fdata=NULL;
|
||||
}
|
||||
cout << "done " << endl;
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
}
|
||||
if ((*correctionMask) & ~(1<<WRITE_FILE)) {
|
||||
doProcessing(fdata,delflag, fname);
|
||||
} else
|
||||
if (dataReady) {
|
||||
thisData=new detectorData(fdata,NULL,NULL,getCurrentProgress(),(fname+string(".raw")).c_str(),getTotalNumberOfChannels());
|
||||
dataReady(thisData, pCallbackArg);
|
||||
delete thisData;
|
||||
fdata=NULL;
|
||||
}
|
||||
#ifdef VERBOSE
|
||||
cout << "findex incremented " << endl;
|
||||
#endif
|
||||
if(*correctionMask&(1<<WRITE_FILE))
|
||||
IncrementFileIndex();
|
||||
}
|
||||
|
||||
delete [] myData;
|
||||
if (fdata)
|
||||
delete [] fdata;
|
||||
@ -116,20 +132,15 @@ void postProcessing::processFrame(int *myData, int delflag) {
|
||||
cout << "Pop data queue " << *fileIndex << endl;
|
||||
#endif
|
||||
|
||||
if(*correctionMask&(1<<WRITE_FILE))
|
||||
IncrementFileIndex();
|
||||
|
||||
#ifdef VERBOSE
|
||||
cout << "findex incremented " << endl;
|
||||
#endif
|
||||
popDataQueue(); //remove the data from the queue
|
||||
|
||||
#ifdef VERBOSE
|
||||
cout << "Pop data queue " << *fileIndex << endl;
|
||||
cout << "Data queue popped" << endl;
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef VERBOSE
|
||||
cout << "processing returning " << *fileIndex << endl;
|
||||
cout << "process frame returning " << endl;
|
||||
#endif
|
||||
|
||||
|
||||
@ -144,13 +155,7 @@ void postProcessing::doProcessing(double *lfdata, int delflag, string fname) {
|
||||
cout << "do processing - data size is " << arraySize << endl;
|
||||
#endif
|
||||
|
||||
if (*correctionMask&(1<< ANGULAR_CONVERSION))
|
||||
ang=new double[arraySize];
|
||||
else
|
||||
ang=NULL;
|
||||
|
||||
val=new double[arraySize];
|
||||
err=new double[arraySize];
|
||||
int np;
|
||||
|
||||
#ifdef VERBOSE
|
||||
@ -177,36 +182,44 @@ void postProcessing::doProcessing(double *lfdata, int delflag, string fname) {
|
||||
if (GetCurrentPositionIndex()<=1) {
|
||||
#ifdef VERBOSE
|
||||
cout << "init dataset" << endl;
|
||||
#endif
|
||||
ppFun->initDataset();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
if (*correctionMask&(1<< ANGULAR_CONVERSION))
|
||||
ang=new double[arraySize];
|
||||
else
|
||||
ang=NULL;
|
||||
|
||||
val=new double[arraySize];
|
||||
err=new double[arraySize];
|
||||
initDataset(0);
|
||||
}
|
||||
|
||||
#ifdef VERBOSE
|
||||
cout << "add frame" << endl;
|
||||
#endif
|
||||
|
||||
ppFun->addFrame(lfdata, ¤tPosition, ¤tI0, &t, (fname).c_str(), NULL);
|
||||
addFrame(lfdata,currentPosition, currentI0, t, fname, 0);
|
||||
|
||||
if ((GetCurrentPositionIndex()>=npos && positionFinished() && dataQueueSize()) || npos==0) {
|
||||
|
||||
if ((GetCurrentPositionIndex()>=npos && positionFinished() && dataQueueSize()) || npos==0) {
|
||||
|
||||
#ifdef VERBOSE
|
||||
cout << "finalize dataset" << endl;
|
||||
cout << "finalize dataset" << endl;
|
||||
#endif
|
||||
|
||||
ppFun->finalizeDataset(ang, val, err, &np);
|
||||
|
||||
finalizeDataset(ang, val, err, np);
|
||||
IncrementPositionIndex();
|
||||
|
||||
pthread_mutex_lock(&mp);
|
||||
fname=createFileName();
|
||||
pthread_mutex_unlock(&mp);
|
||||
|
||||
|
||||
|
||||
if((*correctionMask)&(1<<WRITE_FILE)) {
|
||||
//cout << "write to file " << fname+ext << " " << np << " " << ang<< " " << val << " " << err << endl;
|
||||
writeDataFile (fname+ext,np,val, err,ang,'f');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if (dataReady) {
|
||||
thisData=new detectorData(val,err,ang,getCurrentProgress(),(fname+ext).c_str(),np);
|
||||
dataReady(thisData, pCallbackArg);
|
||||
@ -215,6 +228,7 @@ void postProcessing::doProcessing(double *lfdata, int delflag, string fname) {
|
||||
val=NULL;
|
||||
err=NULL;
|
||||
}
|
||||
|
||||
if (ang)
|
||||
delete [] ang;
|
||||
if (val)
|
||||
@ -222,7 +236,11 @@ void postProcessing::doProcessing(double *lfdata, int delflag, string fname) {
|
||||
if (err)
|
||||
delete [] err;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -414,16 +432,16 @@ int* postProcessing::popDataQueue() {
|
||||
return retval;
|
||||
}
|
||||
|
||||
detectorData* postProcessing::popFinalDataQueue() {
|
||||
detectorData *retval=NULL;
|
||||
pthread_mutex_unlock(&mg);
|
||||
if( !finalDataQueue.empty() ) {
|
||||
retval=finalDataQueue.front();
|
||||
finalDataQueue.pop();
|
||||
}
|
||||
pthread_mutex_unlock(&mg);
|
||||
return retval;
|
||||
}
|
||||
// detectorData* postProcessing::popFinalDataQueue() {
|
||||
// detectorData *retval=NULL;
|
||||
// pthread_mutex_unlock(&mg);
|
||||
// if( !finalDataQueue.empty() ) {
|
||||
// retval=finalDataQueue.front();
|
||||
// finalDataQueue.pop();
|
||||
// }
|
||||
// pthread_mutex_unlock(&mg);
|
||||
// return retval;
|
||||
// }
|
||||
|
||||
void postProcessing::resetDataQueue() {
|
||||
int *retval=NULL;
|
||||
@ -437,30 +455,24 @@ void postProcessing::resetDataQueue() {
|
||||
|
||||
}
|
||||
|
||||
void postProcessing::resetFinalDataQueue() {
|
||||
detectorData *retval=NULL;
|
||||
pthread_mutex_lock(&mg);
|
||||
while( !finalDataQueue.empty() ) {
|
||||
retval=finalDataQueue.front();
|
||||
finalDataQueue.pop();
|
||||
delete retval;
|
||||
}
|
||||
pthread_mutex_unlock(&mg);
|
||||
}
|
||||
// void postProcessing::resetFinalDataQueue() {
|
||||
// detectorData *retval=NULL;
|
||||
// pthread_mutex_lock(&mg);
|
||||
// while( !finalDataQueue.empty() ) {
|
||||
// retval=finalDataQueue.front();
|
||||
// finalDataQueue.pop();
|
||||
// delete retval;
|
||||
// }
|
||||
// pthread_mutex_unlock(&mg);
|
||||
// }
|
||||
void postProcessing::initDataset(int r) {
|
||||
|
||||
|
||||
void postProcessing::startThread(int delflag) {
|
||||
|
||||
/////////////////////////////////// Initialize dataset
|
||||
|
||||
//resetDataQueue();
|
||||
|
||||
setTotalProgress();
|
||||
|
||||
int nmod=getNMods();
|
||||
int *chPM=new int[nmod];
|
||||
int *mM=new int[nmod];
|
||||
int totch=0;
|
||||
if (r) {
|
||||
|
||||
int nmod=getNMods();
|
||||
int *chPM=new int[nmod];
|
||||
int *mM=new int[nmod];
|
||||
int totch=0;
|
||||
#ifdef VERBOSE
|
||||
cout << "init dataset stuff" << endl;
|
||||
#endif
|
||||
@ -484,14 +496,14 @@ void postProcessing::startThread(int delflag) {
|
||||
cout << "total channels is " << totch << endl;
|
||||
#endif
|
||||
double *ffcoeff=NULL, *fferr=NULL;
|
||||
|
||||
|
||||
if (*correctionMask&(1<<FLAT_FIELD_CORRECTION)) {
|
||||
#ifdef VERBOSE
|
||||
cout << "get ff " << endl;
|
||||
cout << "get ff " << endl;
|
||||
#endif
|
||||
ffcoeff=new double[totch];
|
||||
fferr=new double[totch];
|
||||
|
||||
|
||||
getFlatFieldCorrection(ffcoeff,fferr);
|
||||
}
|
||||
|
||||
@ -554,16 +566,69 @@ void postProcessing::startThread(int delflag) {
|
||||
arraySize=totch;
|
||||
}
|
||||
|
||||
numberOfChannels=totch;
|
||||
|
||||
queuesize=dataQueueSize();
|
||||
|
||||
resetFinalDataQueue();
|
||||
// resetFinalDataQueue();
|
||||
resetDataQueue();
|
||||
|
||||
|
||||
} else {
|
||||
ppFun->initDataset();
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void postProcessing::addFrame(double *data, double pos, double i0, double t, string fname, double var) {
|
||||
ppFun->addFrame(data, &pos, &i0, &t, fname.c_str(), &var);
|
||||
|
||||
}
|
||||
|
||||
void postProcessing::finalizeDataset(double *a, double *v, double *e, int &np) {
|
||||
|
||||
ppFun->finalizeDataset(a, v, e, &np);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void postProcessing::startThread(int delflag) {
|
||||
|
||||
/////////////////////////////////// Initialize dataset
|
||||
|
||||
//resetDataQueue();
|
||||
|
||||
setTotalProgress();
|
||||
|
||||
initDataset(1);
|
||||
|
||||
/////////////////////////////////// Start thread ////////////////////////////////////////////////////////
|
||||
#ifdef VERBOSE
|
||||
cout << "start thread stuff" << endl;
|
||||
#endif
|
||||
|
||||
pthread_attr_t tattr;
|
||||
int ret;
|
||||
sched_param param, mparam;
|
||||
|
@ -184,12 +184,12 @@ s
|
||||
|
||||
int dataQueueSize();
|
||||
|
||||
/**
|
||||
pops the data from thepostprocessed data queue
|
||||
\returns pointer to the popped data or NULL if the queue is empty.
|
||||
\sa finalDataQueue
|
||||
*/
|
||||
detectorData* popFinalDataQueue();
|
||||
/* /\** */
|
||||
/* pops the data from thepostprocessed data queue */
|
||||
/* \returns pointer to the popped data or NULL if the queue is empty. */
|
||||
/* \sa finalDataQueue */
|
||||
/* *\/ */
|
||||
/* detectorData* popFinalDataQueue(); */
|
||||
|
||||
|
||||
int checkJoinThread();
|
||||
@ -202,11 +202,11 @@ s
|
||||
*/
|
||||
void resetDataQueue();
|
||||
|
||||
/**
|
||||
resets the postprocessed data queue
|
||||
\sa finalDataQueue
|
||||
*/
|
||||
void resetFinalDataQueue();
|
||||
/* /\** */
|
||||
/* resets the postprocessed data queue */
|
||||
/* \sa finalDataQueue */
|
||||
/* *\/ */
|
||||
/* void resetFinalDataQueue(); */
|
||||
|
||||
|
||||
|
||||
@ -238,7 +238,7 @@ s
|
||||
void registerDataCallback(int( *userCallback)(detectorData*, void*), void *pArg) {dataReady = userCallback; pCallbackArg = pArg;};
|
||||
|
||||
|
||||
void registerRawDataCallback(int( *userCallback)(double*, void*), void *pArg) {rawDataReady = userCallback; pRawDataArg = pArg;};
|
||||
void registerRawDataCallback(int( *userCallback)(double*, int, void*), void *pArg) {rawDataReady = userCallback; pRawDataArg = pArg;};
|
||||
|
||||
|
||||
|
||||
@ -251,6 +251,15 @@ s
|
||||
int setCurrentPosition(double v) { pthread_mutex_lock(&mp); currentPosition=v; pthread_mutex_unlock(&mp); return currentPosition;};
|
||||
|
||||
|
||||
|
||||
|
||||
void initDataset(int refresh);
|
||||
void addFrame(double *data, double pos, double i0, double t, string fname, double var);
|
||||
void finalizeDataset(double *a, double *v, double *e, int &np);
|
||||
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
int *threadedProcessing;
|
||||
@ -322,7 +331,7 @@ s
|
||||
int (*dataReady)(detectorData*,void*);
|
||||
void *pCallbackArg;
|
||||
|
||||
int (*rawDataReady)(double*,void*);
|
||||
int (*rawDataReady)(double*,int,void*);
|
||||
void *pRawDataArg;
|
||||
|
||||
|
||||
@ -334,6 +343,7 @@ s
|
||||
double *val;
|
||||
double *err;
|
||||
|
||||
int numberOfChannels;
|
||||
|
||||
|
||||
|
||||
|
@ -70,18 +70,30 @@ int postProcessingFuncs::finalizeDataset(double *ang, double *val, double *err,
|
||||
|
||||
}
|
||||
|
||||
int postProcessingFuncs::addFrame(double *data, double *pos, double *I0, double *expTime, const char *filename, int *var) {
|
||||
int postProcessingFuncs::addFrame(double *data, double *pos, double *I0, double *expTime, const char *filename, double *var) {
|
||||
|
||||
|
||||
double p1, vin, ein, vout, eout;
|
||||
double e=0.;
|
||||
double i0=*I0;
|
||||
int imod=0, ch0=0;
|
||||
|
||||
int chlast=chansPerMod[0]-1;
|
||||
int nchmod=chansPerMod[0];
|
||||
|
||||
if (i0>0)
|
||||
totalI0+=i0;
|
||||
|
||||
for (int ich=0; ich<totalChans; ich++) {
|
||||
|
||||
|
||||
if (ich>chlast) {
|
||||
imod++;
|
||||
ch0=chlast+1;
|
||||
nchmod=chansPerMod[imod];
|
||||
chlast=ch0+nchmod-1;
|
||||
}
|
||||
|
||||
vin=data[ich];
|
||||
ein=0;
|
||||
vout=data[ich];
|
||||
@ -138,12 +150,14 @@ int postProcessingFuncs::addFrame(double *data, double *pos, double *I0, double
|
||||
//check module mask?!?!?!?
|
||||
|
||||
|
||||
p1=convertAngle(*pos,ich,chansPerMod,angConv,moduleMask,totalOffset,0,angDir);
|
||||
p1=convertAngle(*pos,ich-ch0,angConv[imod],moduleMask[imod],totalOffset,0,angDir);
|
||||
|
||||
#ifdef VERBOSE
|
||||
cout << "ppFuncs merge" << endl;
|
||||
#endif
|
||||
addPointToMerging(p1,vout,eout,mp,mv,me,mm, binSize, nBins);
|
||||
|
||||
|
||||
} else {
|
||||
#ifdef VERBOSE
|
||||
cout << "ppFuncs merge" << endl;
|
||||
|
@ -38,7 +38,7 @@ class postProcessingFuncs : public virtual angularConversionStatic
|
||||
|
||||
int finalizeDataset(double ang[], double val[], double err[], int *np);
|
||||
|
||||
int addFrame(double data[], double *pos, double *IO, double *expTime, const char *filename, int *var=0);
|
||||
int addFrame(double data[], double *pos, double *IO, double *expTime, const char *filename, double *var=0);
|
||||
|
||||
static int calculateFlatField(int* nModules, int *chPerMod, int moduleMask[], int badChannelMask[], double ffData[], double ffCoeff[], double ffErr[]);
|
||||
|
||||
|
@ -321,5 +321,19 @@ int defaultDataReadyFunc(detectorData* d, void* p) {
|
||||
}
|
||||
|
||||
|
||||
int defaultRawDataReadyFunc(double* d, int np, void* p) {
|
||||
//#ifdef VERBOSE
|
||||
printf("UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU Raw Data received \n");
|
||||
if (d==NULL)
|
||||
printf("no data received\n");
|
||||
else
|
||||
printf("received %d channels\n",np);
|
||||
|
||||
printf("UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU Finished \n");
|
||||
//#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -38,7 +38,7 @@ extern "C" {
|
||||
double defaultGetI0(int t,void *d);
|
||||
|
||||
int defaultDataReadyFunc(detectorData* d, void* p);
|
||||
|
||||
int defaultRawDataReadyFunc(double* d, int np, void* p);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
Loading…
x
Reference in New Issue
Block a user