mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-09 11:30:43 +02:00
post processing debugging at the beamline
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@537 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
parent
3c3ab6fc9d
commit
711cb836c0
@ -2164,11 +2164,12 @@ int multiSlsDetector::setFlatFieldCorrection(string fname){
|
|||||||
int chpm[nm];
|
int chpm[nm];
|
||||||
int mMask[nm];
|
int mMask[nm];
|
||||||
for (int i=0; i<nm; i++) {
|
for (int i=0; i<nm; i++) {
|
||||||
chpm[im]=getChansPerMod(im);
|
chpm[i]=getChansPerMod(i);
|
||||||
mMask[im]=im;
|
mMask[i]=i;
|
||||||
|
// cout << "multi chpm " << im << " " << chpm[im] << endl;
|
||||||
}
|
}
|
||||||
fillModuleMask(mMask);
|
fillModuleMask(mMask);
|
||||||
|
// cout << "multi chpm0 " << chpm[0] << endl;
|
||||||
if ((postProcessingFuncs::calculateFlatField(&nm, chpm, mMask, badChannelMask, data, ffcoefficients, fferrors))>=0) {
|
if ((postProcessingFuncs::calculateFlatField(&nm, chpm, mMask, badChannelMask, data, ffcoefficients, fferrors))>=0) {
|
||||||
strcpy(thisMultiDetector->flatFieldFile,fname.c_str());
|
strcpy(thisMultiDetector->flatFieldFile,fname.c_str());
|
||||||
|
|
||||||
@ -2494,9 +2495,9 @@ int multiSlsDetector::setBadChannelCorrection(string fname){
|
|||||||
|
|
||||||
|
|
||||||
ret=setBadChannelCorrection(fname, nbad, badlist);
|
ret=setBadChannelCorrection(fname, nbad, badlist);
|
||||||
#ifdef VERBOSE
|
//#ifdef VERBOSE
|
||||||
cout << "file contained " << ret << " badchans" << endl;
|
cout << "file contained " << ret << " badchans" << endl;
|
||||||
#endif
|
//#endif
|
||||||
if (ret==0) {
|
if (ret==0) {
|
||||||
thisMultiDetector->correctionMask&=~(1<<DISCARD_BAD_CHANNELS);
|
thisMultiDetector->correctionMask&=~(1<<DISCARD_BAD_CHANNELS);
|
||||||
nbad=0;
|
nbad=0;
|
||||||
|
@ -4334,6 +4334,8 @@ int slsDetector::setFlatFieldCorrection(double *corr, double *ecorr) {
|
|||||||
fferrors[ichan]=ecorr[ichan];
|
fferrors[ichan]=ecorr[ichan];
|
||||||
else
|
else
|
||||||
fferrors[ichan]=1;
|
fferrors[ichan]=1;
|
||||||
|
|
||||||
|
cout << ichan << " " << ffcoefficients[ichan] << endl;
|
||||||
}
|
}
|
||||||
thisDetector->correctionMask|=(1<<FLAT_FIELD_CORRECTION);
|
thisDetector->correctionMask|=(1<<FLAT_FIELD_CORRECTION);
|
||||||
} else
|
} else
|
||||||
@ -4362,9 +4364,11 @@ int slsDetector::getFlatFieldCorrection(double *corr, double *ecorr) {
|
|||||||
#endif
|
#endif
|
||||||
if (corr) {
|
if (corr) {
|
||||||
for (int ichan=0; ichan<thisDetector->nMod[X]*thisDetector->nMod[Y]*thisDetector->nChans*thisDetector->nChips; ichan++) {
|
for (int ichan=0; ichan<thisDetector->nMod[X]*thisDetector->nMod[Y]*thisDetector->nChans*thisDetector->nChips; ichan++) {
|
||||||
corr[ichan]=(ffcoefficients[ichan]*ffcoefficients[ichan])/(fferrors[ichan]*fferrors[ichan]);
|
// corr[ichan]=(ffcoefficients[ichan]*ffcoefficients[ichan])/(fferrors[ichan]*fferrors[ichan]);
|
||||||
|
corr[ichan]=ffcoefficients[ichan];
|
||||||
if (ecorr) {
|
if (ecorr) {
|
||||||
ecorr[ichan]=ffcoefficients[ichan]/fferrors[ichan];
|
//ecorr[ichan]=ffcoefficients[ichan]/fferrors[ichan];
|
||||||
|
ecorr[ichan]=fferrors[ichan];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -261,9 +261,12 @@ void slsDetectorUtils::acquire(int delflag){
|
|||||||
}
|
}
|
||||||
pthread_mutex_unlock(&mg);
|
pthread_mutex_unlock(&mg);
|
||||||
}
|
}
|
||||||
|
#ifdef VERBOSE
|
||||||
|
cout << "Acquiring " << endl;
|
||||||
|
#endif
|
||||||
startAndReadAll();
|
startAndReadAll();
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
|
cout << "finished " << endl;
|
||||||
cout << "returned! " << endl;
|
cout << "returned! " << endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -39,9 +39,9 @@ double* angularConversionStatic::convertAngles(double pos, int nch, int *chansPe
|
|||||||
enc=pos;
|
enc=pos;
|
||||||
|
|
||||||
for (int ip=0; ip<nch; ip++) {
|
for (int ip=0; ip<nch; ip++) {
|
||||||
//#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
cout << "ip " << ip << " ch0 " << ch0 << " chlast " << chlast << " imod " << imod << endl;
|
cout << "ip " << ip << " ch0 " << ch0 << " chlast " << chlast << " imod " << imod << endl;
|
||||||
//#endif
|
#endif
|
||||||
if (ip>chlast) {
|
if (ip>chlast) {
|
||||||
imod++;
|
imod++;
|
||||||
p=angOff[imod];
|
p=angOff[imod];
|
||||||
@ -50,10 +50,12 @@ double* angularConversionStatic::convertAngles(double pos, int nch, int *chansPe
|
|||||||
else
|
else
|
||||||
enc=pos;
|
enc=pos;
|
||||||
|
|
||||||
|
#ifdef VERBOSE
|
||||||
if (p)
|
if (p)
|
||||||
cout << enc << endl << fo+go << endl << p->r_conversion << endl << p->center << endl << p->offset << endl << p->tilt << angdir << endl;
|
cout << enc << endl << fo+go << endl << p->r_conversion << endl << p->center << endl << p->offset << endl << p->tilt << angdir << endl;
|
||||||
else
|
else
|
||||||
cout << "no ang conv " << endl;
|
cout << "no ang conv " << endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
ch0=chlast+1;
|
ch0=chlast+1;
|
||||||
nchmod=chansPerMod[imod];
|
nchmod=chansPerMod[imod];
|
||||||
@ -70,7 +72,9 @@ double* angularConversionStatic::convertAngles(double pos, int nch, int *chansPe
|
|||||||
p->offset, \
|
p->offset, \
|
||||||
p->tilt, \
|
p->tilt, \
|
||||||
angdir );
|
angdir );
|
||||||
|
#ifdef VERBOSE
|
||||||
cout << "ip " << ip << " ch0 " << ch0 << " chlast " << chlast << " imod " << imod << endl;
|
cout << "ip " << ip << " ch0 " << ch0 << " chlast " << chlast << " imod " << imod << endl;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
return ang;
|
return ang;
|
||||||
}
|
}
|
||||||
@ -208,10 +212,10 @@ int angularConversionStatic::readAngularConversion( ifstream& infile, int nmod,
|
|||||||
//" module %i center %E +- %E conversion %E +- %E offset %f +- %f \n"
|
//" module %i center %E +- %E conversion %E +- %E offset %f +- %f \n"
|
||||||
while (infile.good() and interrupt==0) {
|
while (infile.good() and interrupt==0) {
|
||||||
getline(infile,str);
|
getline(infile,str);
|
||||||
//#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
cout << "** mod " << nm << " " ;
|
cout << "** mod " << nm << " " ;
|
||||||
std::cout<< str << std::endl;
|
std::cout<< str << std::endl;
|
||||||
//#endif
|
#endif
|
||||||
istringstream ssstr(str);
|
istringstream ssstr(str);
|
||||||
ssstr >> ss >> mod;
|
ssstr >> ss >> mod;
|
||||||
ssstr >> ss >> center;
|
ssstr >> ss >> center;
|
||||||
@ -228,7 +232,9 @@ int angularConversionStatic::readAngularConversion( ifstream& infile, int nmod,
|
|||||||
ssstr >> ss >> er_conv;
|
ssstr >> ss >> er_conv;
|
||||||
ssstr >> ss >> off;
|
ssstr >> ss >> off;
|
||||||
ssstr >> ss >> eoff;
|
ssstr >> ss >> eoff;
|
||||||
|
#ifdef VERBOSE
|
||||||
cout << nm << " " << nmod << endl;
|
cout << nm << " " << nmod << endl;
|
||||||
|
#endif
|
||||||
if (nm<nmod && nm>=0 ) {
|
if (nm<nmod && nm>=0 ) {
|
||||||
angOff[nm].center=center;
|
angOff[nm].center=center;
|
||||||
angOff[nm].r_conversion=r_conv;
|
angOff[nm].r_conversion=r_conv;
|
||||||
@ -250,7 +256,9 @@ int angularConversionStatic::readAngularConversion( ifstream& infile, int nmod,
|
|||||||
|
|
||||||
} else
|
} else
|
||||||
break;
|
break;
|
||||||
|
#ifdef VERBOSE
|
||||||
cout << nm<<" " << angOff[nm].offset << endl;
|
cout << nm<<" " << angOff[nm].offset << endl;
|
||||||
|
#endif
|
||||||
nm++;
|
nm++;
|
||||||
if (nm>=nmod)
|
if (nm>=nmod)
|
||||||
break;
|
break;
|
||||||
|
@ -36,6 +36,7 @@ class badChannelCorrections{
|
|||||||
ssstr >> chmax; \
|
ssstr >> chmax; \
|
||||||
for (ich=chmin; ich<=chmax; ich++) { \
|
for (ich=chmin; ich<=chmax; ich++) { \
|
||||||
badlist[nbad]=ich; \
|
badlist[nbad]=ich; \
|
||||||
|
cout << badlist[nbad] << " " << moff << endl; \
|
||||||
nbad++; \
|
nbad++; \
|
||||||
} \
|
} \
|
||||||
} else { \
|
} else { \
|
||||||
@ -49,7 +50,7 @@ class badChannelCorrections{
|
|||||||
|
|
||||||
static int setBadChannelCorrection(ifstream &infile, int &nbad, int *badlist, int moff){ \
|
static int setBadChannelCorrection(ifstream &infile, int &nbad, int *badlist, int moff){ \
|
||||||
int retval=readBadChannelCorrectionFile(infile,nbad,badlist); \
|
int retval=readBadChannelCorrectionFile(infile,nbad,badlist); \
|
||||||
for (int ich=0; ich<nbad; ich++) badlist[ich]=badlist[ich]+moff; \
|
for (int ich=0; ich<nbad; ich++) { badlist[ich]=badlist[ich]+moff; cout << badlist[ich] << " " << moff << endl; }; \
|
||||||
return retval; \
|
return retval; \
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -90,14 +90,14 @@ void postProcessing::processFrame(int *myData, int delflag) {
|
|||||||
// fdata=NULL;
|
// fdata=NULL;
|
||||||
|
|
||||||
if (rawDataReady) {
|
if (rawDataReady) {
|
||||||
//#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
cout << "raw data ready..." << endl;
|
cout << "raw data ready..." << endl;
|
||||||
//#endif
|
#endif
|
||||||
rawDataReady(fdata,numberOfChannels, pRawDataArg);
|
rawDataReady(fdata,numberOfChannels, pRawDataArg);
|
||||||
//#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
cout << "done" << endl;
|
cout << "done" << endl;
|
||||||
cout << "NO FILE WRITING AND/OR DATA PROCESSING DONE BY SLS DETECTOR SOFTWARE!!!" << endl;
|
cout << "NO FILE WRITING AND/OR DATA PROCESSING DONE BY SLS DETECTOR SOFTWARE!!!" << endl;
|
||||||
//#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
|
||||||
@ -577,13 +577,19 @@ void postProcessing::initDataset(int r) {
|
|||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
cout << "chanspermod" << endl;
|
cout << "chanspermod" << endl;
|
||||||
#endif
|
#endif
|
||||||
// mM[im]=getMoveFlag(im);
|
mM[im]=getMoveFlag(im);
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
cout << "moveflag" << endl;
|
cout << "moveflag" << im << " " << mM[im] << endl;
|
||||||
#endif
|
#endif
|
||||||
totch+=chPM[im];
|
totch+=chPM[im];
|
||||||
}
|
}
|
||||||
fillModuleMask(mM);
|
|
||||||
|
|
||||||
|
// uncomment if to be used with antonio's funcs!!!
|
||||||
|
//fillModuleMask(mM);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
cout << "total channels is " << totch << endl;
|
cout << "total channels is " << totch << endl;
|
||||||
#endif
|
#endif
|
||||||
@ -634,9 +640,9 @@ void postProcessing::initDataset(int r) {
|
|||||||
angOff[im]=p->offset;
|
angOff[im]=p->offset;
|
||||||
angCenter[im]=p->center;
|
angCenter[im]=p->center;
|
||||||
|
|
||||||
|
#ifdef VERBOSE
|
||||||
cout << im << " " << angCenter[im] << " " << angRad[im] << " " << angOff[im] << endl;
|
cout << im << " " << angCenter[im] << " " << angRad[im] << " " << angOff[im] << endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include "postProcessingFuncs.h"
|
#include "postProcessingFuncs.h"
|
||||||
#include "angleConversionConstant.h"
|
#include "angleConversionConstant.h"
|
||||||
|
|
||||||
#define VERBOSE
|
//#define VERBOSE
|
||||||
|
|
||||||
postProcessingFuncs::postProcessingFuncs(int *nModules,int *chPerMod,int modMask[],int badCh[], double ffcoeff[], double fferr[], double* t, int *dir, double angRadius[], double angOffset[], double angCentre[], double* to, double* bs, double *sX, double *sY):
|
postProcessingFuncs::postProcessingFuncs(int *nModules,int *chPerMod,int modMask[],int badCh[], double ffcoeff[], double fferr[], double* t, int *dir, double angRadius[], double angOffset[], double angCentre[], double* to, double* bs, double *sX, double *sY):
|
||||||
nMods(0), chansPerMod(NULL), moduleMask(NULL), badChannelMask(NULL), ffCoeff(NULL), ffErr(NULL), tDead(0), angDir(1), angConv(NULL), totalOffset(0), binSize(0), sampleX(0), sampleY(0), totalChans(0), nBins(0), mp(NULL), mv(NULL), me(NULL), mm(NULL)
|
nMods(0), chansPerMod(NULL), moduleMask(NULL), badChannelMask(NULL), ffCoeff(NULL), ffErr(NULL), tDead(0), angDir(1), angConv(NULL), totalOffset(0), binSize(0), sampleX(0), sampleY(0), totalChans(0), nBins(0), mp(NULL), mv(NULL), me(NULL), mm(NULL)
|
||||||
@ -89,6 +89,7 @@ int postProcessingFuncs::addFrame(double *data, double *pos, double *I0, double
|
|||||||
|
|
||||||
|
|
||||||
if (ich>chlast) {
|
if (ich>chlast) {
|
||||||
|
// cout << *pos << " " << moduleMask[imod] << endl;
|
||||||
imod++;
|
imod++;
|
||||||
ch0=chlast+1;
|
ch0=chlast+1;
|
||||||
nchmod=chansPerMod[imod];
|
nchmod=chansPerMod[imod];
|
||||||
@ -281,7 +282,9 @@ int postProcessingFuncs::initDataset(int *nModules,int *chPerMod,int modMask[],i
|
|||||||
angConv=new angleConversionConstant*[nMods];
|
angConv=new angleConversionConstant*[nMods];
|
||||||
nBins=(int)(360./binSize)+1;
|
nBins=(int)(360./binSize)+1;
|
||||||
}
|
}
|
||||||
|
#ifdef VERBOSE
|
||||||
cout << "nBins " << nBins << endl;
|
cout << "nBins " << nBins << endl;
|
||||||
|
#endif
|
||||||
for (int im=0; im<nMods; im++) {
|
for (int im=0; im<nMods; im++) {
|
||||||
//#ifdef VERBOSE
|
//#ifdef VERBOSE
|
||||||
// cout << "MODULE "<< im << endl;
|
// cout << "MODULE "<< im << endl;
|
||||||
@ -325,6 +328,9 @@ int postProcessingFuncs::initDataset(int *nModules,int *chPerMod,int modMask[],i
|
|||||||
ffCoeff[ich]=ffcoeff[ich];
|
ffCoeff[ich]=ffcoeff[ich];
|
||||||
if (ffErr)
|
if (ffErr)
|
||||||
ffErr[ich]=fferr[ich];
|
ffErr[ich]=fferr[ich];
|
||||||
|
|
||||||
|
// cout << " init ff " << ich << " " << ffCoeff[ich] << ffcoeff[ich] << endl;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -375,9 +381,9 @@ postProcessingFuncs::~postProcessingFuncs(){
|
|||||||
|
|
||||||
int postProcessingFuncs::flatFieldCorrect(double datain, double errin, double &dataout, double &errout, double ffcoefficient, double fferr){
|
int postProcessingFuncs::flatFieldCorrect(double datain, double errin, double &dataout, double &errout, double ffcoefficient, double fferr){
|
||||||
double e;
|
double e;
|
||||||
|
|
||||||
dataout=datain*ffcoefficient;
|
dataout=datain*ffcoefficient;
|
||||||
|
|
||||||
|
// cout << datain << " " << ffcoefficient << " " << dataout << endl;
|
||||||
if (errin==0 && datain>=0)
|
if (errin==0 && datain>=0)
|
||||||
e=sqrt(datain);
|
e=sqrt(datain);
|
||||||
else
|
else
|
||||||
@ -417,6 +423,8 @@ int postProcessingFuncs::calculateFlatField(int* nModules, int *chPerMod, int *m
|
|||||||
int nmed=0, im=0;
|
int nmed=0, im=0;
|
||||||
double *xmed;
|
double *xmed;
|
||||||
|
|
||||||
|
// cout << "Claculate flat field " << endl;
|
||||||
|
|
||||||
if (chPerMod==NULL)
|
if (chPerMod==NULL)
|
||||||
return -1;
|
return -1;
|
||||||
// if (moduleMask==NULL)
|
// if (moduleMask==NULL)
|
||||||
@ -428,15 +436,18 @@ int postProcessingFuncs::calculateFlatField(int* nModules, int *chPerMod, int *m
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
|
||||||
|
// cout << *nModules << " pp chpm0 " << chPerMod[0] << endl;
|
||||||
int totch=0;
|
int totch=0;
|
||||||
for (int im=0; im<*nModules; im++) {
|
int nm= *nModules;
|
||||||
|
for (int im=0; im<nm; im++) {
|
||||||
totch+=chPerMod[im];
|
totch+=chPerMod[im];
|
||||||
|
// cout << im << " " << totch << endl;
|
||||||
}
|
}
|
||||||
|
// cout << "tot ch " << totch << endl;
|
||||||
xmed=new double[totch];
|
xmed=new double[totch];
|
||||||
|
|
||||||
for (int ich=0; ich<totch; ich++) {
|
for (int ich=0; ich<totch; ich++) {
|
||||||
|
// cout << ich << " " << totch << endl;
|
||||||
if (badChannelMask)
|
if (badChannelMask)
|
||||||
if (badChannelMask[ich])
|
if (badChannelMask[ich])
|
||||||
continue;
|
continue;
|
||||||
@ -460,12 +471,12 @@ int postProcessingFuncs::calculateFlatField(int* nModules, int *chPerMod, int *m
|
|||||||
|
|
||||||
|
|
||||||
if (nmed>1 && xmed[nmed/2]>0) {
|
if (nmed>1 && xmed[nmed/2]>0) {
|
||||||
#ifdef VERBOSE
|
//#ifdef VERBOSE
|
||||||
std::cout<< "Flat field median is " << xmed[nmed/2] << " calculated using "<< nmed << " points" << std::endl;
|
// std::cout<< "Flat field median is " << xmed[nmed/2] << " calculated using "<< nmed << " points" << std::endl;
|
||||||
#endif
|
//#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// cout << "checking bad channel mask " << endl;
|
||||||
for (int ich=0; ich<totch; ich++) {
|
for (int ich=0; ich<totch; ich++) {
|
||||||
if (badChannelMask)
|
if (badChannelMask)
|
||||||
if (badChannelMask[ich]) {
|
if (badChannelMask[ich]) {
|
||||||
@ -482,10 +493,11 @@ int postProcessingFuncs::calculateFlatField(int* nModules, int *chPerMod, int *m
|
|||||||
ffCoeff[ich]=0.;
|
ffCoeff[ich]=0.;
|
||||||
ffErr[ich]=1.;
|
ffErr[ich]=1.;
|
||||||
}
|
}
|
||||||
|
cout << ich << " " << ffData[ich] << " " << ffCoeff[ich] << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
cout << "done " << endl;
|
||||||
|
|
||||||
delete [] xmed;
|
delete [] xmed;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user