mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-23 06:50:02 +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 mMask[nm];
|
||||
for (int i=0; i<nm; i++) {
|
||||
chpm[im]=getChansPerMod(im);
|
||||
mMask[im]=im;
|
||||
chpm[i]=getChansPerMod(i);
|
||||
mMask[i]=i;
|
||||
// cout << "multi chpm " << im << " " << chpm[im] << endl;
|
||||
}
|
||||
fillModuleMask(mMask);
|
||||
|
||||
// cout << "multi chpm0 " << chpm[0] << endl;
|
||||
if ((postProcessingFuncs::calculateFlatField(&nm, chpm, mMask, badChannelMask, data, ffcoefficients, fferrors))>=0) {
|
||||
strcpy(thisMultiDetector->flatFieldFile,fname.c_str());
|
||||
|
||||
@ -2494,9 +2495,9 @@ int multiSlsDetector::setBadChannelCorrection(string fname){
|
||||
|
||||
|
||||
ret=setBadChannelCorrection(fname, nbad, badlist);
|
||||
#ifdef VERBOSE
|
||||
//#ifdef VERBOSE
|
||||
cout << "file contained " << ret << " badchans" << endl;
|
||||
#endif
|
||||
//#endif
|
||||
if (ret==0) {
|
||||
thisMultiDetector->correctionMask&=~(1<<DISCARD_BAD_CHANNELS);
|
||||
nbad=0;
|
||||
|
@ -4334,6 +4334,8 @@ int slsDetector::setFlatFieldCorrection(double *corr, double *ecorr) {
|
||||
fferrors[ichan]=ecorr[ichan];
|
||||
else
|
||||
fferrors[ichan]=1;
|
||||
|
||||
cout << ichan << " " << ffcoefficients[ichan] << endl;
|
||||
}
|
||||
thisDetector->correctionMask|=(1<<FLAT_FIELD_CORRECTION);
|
||||
} else
|
||||
@ -4362,9 +4364,11 @@ int slsDetector::getFlatFieldCorrection(double *corr, double *ecorr) {
|
||||
#endif
|
||||
if (corr) {
|
||||
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) {
|
||||
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);
|
||||
}
|
||||
|
||||
#ifdef VERBOSE
|
||||
cout << "Acquiring " << endl;
|
||||
#endif
|
||||
startAndReadAll();
|
||||
#ifdef VERBOSE
|
||||
cout << "finished " << endl;
|
||||
cout << "returned! " << endl;
|
||||
#endif
|
||||
|
||||
|
@ -39,9 +39,9 @@ double* angularConversionStatic::convertAngles(double pos, int nch, int *chansPe
|
||||
enc=pos;
|
||||
|
||||
for (int ip=0; ip<nch; ip++) {
|
||||
//#ifdef VERBOSE
|
||||
#ifdef VERBOSE
|
||||
cout << "ip " << ip << " ch0 " << ch0 << " chlast " << chlast << " imod " << imod << endl;
|
||||
//#endif
|
||||
#endif
|
||||
if (ip>chlast) {
|
||||
imod++;
|
||||
p=angOff[imod];
|
||||
@ -50,10 +50,12 @@ double* angularConversionStatic::convertAngles(double pos, int nch, int *chansPe
|
||||
else
|
||||
enc=pos;
|
||||
|
||||
if (p)
|
||||
#ifdef VERBOSE
|
||||
if (p)
|
||||
cout << enc << endl << fo+go << endl << p->r_conversion << endl << p->center << endl << p->offset << endl << p->tilt << angdir << endl;
|
||||
else
|
||||
cout << "no ang conv " << endl;
|
||||
#endif
|
||||
|
||||
ch0=chlast+1;
|
||||
nchmod=chansPerMod[imod];
|
||||
@ -70,7 +72,9 @@ double* angularConversionStatic::convertAngles(double pos, int nch, int *chansPe
|
||||
p->offset, \
|
||||
p->tilt, \
|
||||
angdir );
|
||||
#ifdef VERBOSE
|
||||
cout << "ip " << ip << " ch0 " << ch0 << " chlast " << chlast << " imod " << imod << endl;
|
||||
#endif
|
||||
}
|
||||
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"
|
||||
while (infile.good() and interrupt==0) {
|
||||
getline(infile,str);
|
||||
//#ifdef VERBOSE
|
||||
#ifdef VERBOSE
|
||||
cout << "** mod " << nm << " " ;
|
||||
std::cout<< str << std::endl;
|
||||
//#endif
|
||||
#endif
|
||||
istringstream ssstr(str);
|
||||
ssstr >> ss >> mod;
|
||||
ssstr >> ss >> center;
|
||||
@ -228,7 +232,9 @@ int angularConversionStatic::readAngularConversion( ifstream& infile, int nmod,
|
||||
ssstr >> ss >> er_conv;
|
||||
ssstr >> ss >> off;
|
||||
ssstr >> ss >> eoff;
|
||||
#ifdef VERBOSE
|
||||
cout << nm << " " << nmod << endl;
|
||||
#endif
|
||||
if (nm<nmod && nm>=0 ) {
|
||||
angOff[nm].center=center;
|
||||
angOff[nm].r_conversion=r_conv;
|
||||
@ -250,7 +256,9 @@ int angularConversionStatic::readAngularConversion( ifstream& infile, int nmod,
|
||||
|
||||
} else
|
||||
break;
|
||||
#ifdef VERBOSE
|
||||
cout << nm<<" " << angOff[nm].offset << endl;
|
||||
#endif
|
||||
nm++;
|
||||
if (nm>=nmod)
|
||||
break;
|
||||
|
@ -36,6 +36,7 @@ class badChannelCorrections{
|
||||
ssstr >> chmax; \
|
||||
for (ich=chmin; ich<=chmax; ich++) { \
|
||||
badlist[nbad]=ich; \
|
||||
cout << badlist[nbad] << " " << moff << endl; \
|
||||
nbad++; \
|
||||
} \
|
||||
} else { \
|
||||
@ -49,7 +50,7 @@ class badChannelCorrections{
|
||||
|
||||
static int setBadChannelCorrection(ifstream &infile, int &nbad, int *badlist, int moff){ \
|
||||
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; \
|
||||
};
|
||||
|
||||
|
@ -90,14 +90,14 @@ void postProcessing::processFrame(int *myData, int delflag) {
|
||||
// fdata=NULL;
|
||||
|
||||
if (rawDataReady) {
|
||||
//#ifdef VERBOSE
|
||||
#ifdef VERBOSE
|
||||
cout << "raw data ready..." << endl;
|
||||
//#endif
|
||||
#endif
|
||||
rawDataReady(fdata,numberOfChannels, pRawDataArg);
|
||||
//#ifdef VERBOSE
|
||||
#ifdef VERBOSE
|
||||
cout << "done" << endl;
|
||||
cout << "NO FILE WRITING AND/OR DATA PROCESSING DONE BY SLS DETECTOR SOFTWARE!!!" << endl;
|
||||
//#endif
|
||||
#endif
|
||||
} else {
|
||||
|
||||
|
||||
@ -577,13 +577,19 @@ void postProcessing::initDataset(int r) {
|
||||
#ifdef VERBOSE
|
||||
cout << "chanspermod" << endl;
|
||||
#endif
|
||||
// mM[im]=getMoveFlag(im);
|
||||
mM[im]=getMoveFlag(im);
|
||||
#ifdef VERBOSE
|
||||
cout << "moveflag" << endl;
|
||||
cout << "moveflag" << im << " " << mM[im] << endl;
|
||||
#endif
|
||||
totch+=chPM[im];
|
||||
}
|
||||
fillModuleMask(mM);
|
||||
|
||||
|
||||
// uncomment if to be used with antonio's funcs!!!
|
||||
//fillModuleMask(mM);
|
||||
|
||||
|
||||
|
||||
#ifdef VERBOSE
|
||||
cout << "total channels is " << totch << endl;
|
||||
#endif
|
||||
@ -634,9 +640,9 @@ void postProcessing::initDataset(int r) {
|
||||
angOff[im]=p->offset;
|
||||
angCenter[im]=p->center;
|
||||
|
||||
|
||||
#ifdef VERBOSE
|
||||
cout << im << " " << angCenter[im] << " " << angRad[im] << " " << angOff[im] << endl;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "postProcessingFuncs.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):
|
||||
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) {
|
||||
// cout << *pos << " " << moduleMask[imod] << endl;
|
||||
imod++;
|
||||
ch0=chlast+1;
|
||||
nchmod=chansPerMod[imod];
|
||||
@ -281,7 +282,9 @@ int postProcessingFuncs::initDataset(int *nModules,int *chPerMod,int modMask[],i
|
||||
angConv=new angleConversionConstant*[nMods];
|
||||
nBins=(int)(360./binSize)+1;
|
||||
}
|
||||
#ifdef VERBOSE
|
||||
cout << "nBins " << nBins << endl;
|
||||
#endif
|
||||
for (int im=0; im<nMods; im++) {
|
||||
//#ifdef VERBOSE
|
||||
// cout << "MODULE "<< im << endl;
|
||||
@ -325,6 +328,9 @@ int postProcessingFuncs::initDataset(int *nModules,int *chPerMod,int modMask[],i
|
||||
ffCoeff[ich]=ffcoeff[ich];
|
||||
if (ffErr)
|
||||
ffErr[ich]=fferr[ich];
|
||||
|
||||
// cout << " init ff " << ich << " " << ffCoeff[ich] << ffcoeff[ich] << endl;
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -375,9 +381,9 @@ postProcessingFuncs::~postProcessingFuncs(){
|
||||
|
||||
int postProcessingFuncs::flatFieldCorrect(double datain, double errin, double &dataout, double &errout, double ffcoefficient, double fferr){
|
||||
double e;
|
||||
|
||||
dataout=datain*ffcoefficient;
|
||||
|
||||
// cout << datain << " " << ffcoefficient << " " << dataout << endl;
|
||||
if (errin==0 && datain>=0)
|
||||
e=sqrt(datain);
|
||||
else
|
||||
@ -417,6 +423,8 @@ int postProcessingFuncs::calculateFlatField(int* nModules, int *chPerMod, int *m
|
||||
int nmed=0, im=0;
|
||||
double *xmed;
|
||||
|
||||
// cout << "Claculate flat field " << endl;
|
||||
|
||||
if (chPerMod==NULL)
|
||||
return -1;
|
||||
// if (moduleMask==NULL)
|
||||
@ -428,15 +436,18 @@ int postProcessingFuncs::calculateFlatField(int* nModules, int *chPerMod, int *m
|
||||
return -1;
|
||||
|
||||
|
||||
// cout << *nModules << " pp chpm0 " << chPerMod[0] << endl;
|
||||
int totch=0;
|
||||
for (int im=0; im<*nModules; im++) {
|
||||
int nm= *nModules;
|
||||
for (int im=0; im<nm; im++) {
|
||||
totch+=chPerMod[im];
|
||||
// cout << im << " " << totch << endl;
|
||||
}
|
||||
|
||||
// cout << "tot ch " << totch << endl;
|
||||
xmed=new double[totch];
|
||||
|
||||
for (int ich=0; ich<totch; ich++) {
|
||||
|
||||
// cout << ich << " " << totch << endl;
|
||||
if (badChannelMask)
|
||||
if (badChannelMask[ich])
|
||||
continue;
|
||||
@ -455,17 +466,17 @@ int postProcessingFuncs::calculateFlatField(int* nModules, int *chPerMod, int *m
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (nmed>1 && xmed[nmed/2]>0) {
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "Flat field median is " << xmed[nmed/2] << " calculated using "<< nmed << " points" << std::endl;
|
||||
#endif
|
||||
//#ifdef VERBOSE
|
||||
// std::cout<< "Flat field median is " << xmed[nmed/2] << " calculated using "<< nmed << " points" << std::endl;
|
||||
//#endif
|
||||
|
||||
|
||||
|
||||
// cout << "checking bad channel mask " << endl;
|
||||
for (int ich=0; ich<totch; ich++) {
|
||||
if (badChannelMask)
|
||||
if (badChannelMask[ich]) {
|
||||
@ -482,10 +493,11 @@ int postProcessingFuncs::calculateFlatField(int* nModules, int *chPerMod, int *m
|
||||
ffCoeff[ich]=0.;
|
||||
ffErr[ich]=1.;
|
||||
}
|
||||
|
||||
cout << ich << " " << ffData[ich] << " " << ffCoeff[ich] << endl;
|
||||
}
|
||||
|
||||
}
|
||||
cout << "done " << endl;
|
||||
|
||||
delete [] xmed;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user