more debugging at the beamline

git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@538 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
x04sa 2013-04-30 11:25:29 +00:00
parent 711cb836c0
commit 88f3fe3b26
7 changed files with 84 additions and 48 deletions

View File

@ -2170,6 +2170,7 @@ int multiSlsDetector::setFlatFieldCorrection(string fname){
}
fillModuleMask(mMask);
// cout << "multi chpm0 " << chpm[0] << endl;
fillBadChannelMask();
if ((postProcessingFuncs::calculateFlatField(&nm, chpm, mMask, badChannelMask, data, ffcoefficients, fferrors))>=0) {
strcpy(thisMultiDetector->flatFieldFile,fname.c_str());
@ -2486,6 +2487,7 @@ int multiSlsDetector::setBadChannelCorrection(string fname){
int nbad=0;//, nbaddet=0, choff=0, idet=0;
int ret=0;
cout << thisMultiDetector->badChanFile << endl;
if (fname=="default")
fname=string(thisMultiDetector->badChanFile);
@ -2496,7 +2498,7 @@ int multiSlsDetector::setBadChannelCorrection(string fname){
ret=setBadChannelCorrection(fname, nbad, badlist);
//#ifdef VERBOSE
cout << "file contained " << ret << " badchans" << endl;
cout << "multi: file contained " << ret << " badchans" << endl;
//#endif
if (ret==0) {
thisMultiDetector->correctionMask&=~(1<<DISCARD_BAD_CHANNELS);
@ -2513,10 +2515,15 @@ int multiSlsDetector::setBadChannelCorrection(string fname){
int multiSlsDetector::setBadChannelCorrection(int nbad, int *badlist, int ff) {
//#define VERBOSE
int badlistdet[MAX_BADCHANS];
int nbaddet=0, choff=0, idet=0;
if (nbad<1)
badlistdet[0]=0;
else
badlistdet[0]=badlist[0];
if (nbad>0) {
thisMultiDetector->correctionMask|=(1<<DISCARD_BAD_CHANNELS);
@ -2524,10 +2531,10 @@ int multiSlsDetector::setBadChannelCorrection(int nbad, int *badlist, int ff) {
for (int ich=0; ich<nbad; ich++) {
if (detectors[idet]) {
if ((badlist[ich]-choff)>=detectors[idet]->getMaxNumberOfChannels()) {
#ifdef VERBOSE
//#ifdef VERBOSE
cout << "setting " << nbaddet << " badchans to detector " << idet << endl;
#endif
detectors[idet]->setBadChannelCorrection(nbaddet,badlist,0);
//#endif
detectors[idet]->setBadChannelCorrection(nbaddet,badlistdet,0);
if(detectors[idet]->getErrorMask())
setErrorMask(getErrorMask()|(1<<idet));
choff+=detectors[idet]->getMaxNumberOfChannels();
@ -2549,7 +2556,7 @@ int multiSlsDetector::setBadChannelCorrection(int nbad, int *badlist, int ff) {
#ifdef VERBOSE
cout << "setting " << nbaddet << " badchans to detector " << idet << endl;
#endif
detectors[idet]->setBadChannelCorrection(nbaddet,badlist,0);
detectors[idet]->setBadChannelCorrection(nbaddet,badlistdet,0);
if(detectors[idet]->getErrorMask())
setErrorMask(getErrorMask()|(1<<idet));
choff+=detectors[idet]->getMaxNumberOfChannels();
@ -2559,11 +2566,11 @@ int multiSlsDetector::setBadChannelCorrection(int nbad, int *badlist, int ff) {
}
nbaddet=0;
for (int i=idet; i<thisMultiDetector->numberOfDetectors; i++) {
#ifdef VERBOSE
#ifdef VERBOSE
cout << "setting " << 0 << " badchans to detector " << i << endl;
#endif
#endif
if (detectors[i]) {
detectors[i]->setBadChannelCorrection(nbaddet,badlist,0);
detectors[i]->setBadChannelCorrection(nbaddet,badlistdet,0);
if(detectors[i]->getErrorMask())
setErrorMask(getErrorMask()|(1<<i));
}
@ -2576,7 +2583,7 @@ int multiSlsDetector::setBadChannelCorrection(int nbad, int *badlist, int ff) {
#ifdef VERBOSE
cout << "setting " << 0 << " badchans to detector " << idet << endl;
#endif
detectors[idet]->setBadChannelCorrection(nbaddet,badlist,0);
detectors[idet]->setBadChannelCorrection(nbaddet,badlistdet,0);
if(detectors[idet]->getErrorMask())
setErrorMask(getErrorMask()|(1<<idet));
}
@ -2810,24 +2817,33 @@ double multiSlsDetector::setAngularConversionParameter(angleConversionParameter
int multiSlsDetector::getBadChannelCorrection(int *bad) {
//int ichan;
int *bd, nd, ntot=0, choff=0;;
if (((thisMultiDetector->correctionMask)&(1<< DISCARD_BAD_CHANNELS))==0)
return 0;
else
cout << "bad chans corr enabled "<< thisMultiDetector->correctionMask << endl;
for (int idet=0; idet<thisMultiDetector->numberOfDetectors; idet++) {
if (detectors[idet]) {
nd=detectors[idet]->getBadChannelCorrection();
bd = new int[nd];
nd=detectors[idet]->getBadChannelCorrection(bd);
if(detectors[idet]->getErrorMask())
setErrorMask(getErrorMask()|(1<<idet));
cout << "det " << idet << " nbad " << nd << endl;
if (nd>0) {
bd = new int[nd];
nd=detectors[idet]->getBadChannelCorrection(bd);
if(detectors[idet]->getErrorMask())
setErrorMask(getErrorMask()|(1<<idet));
for (int id=0; id<nd; id++) {
if (bd[id]<detectors[idet]->getTotalNumberOfChannels()) {
if (bad) bad[ntot]=choff+bd[id];
ntot++;
for (int id=0; id<nd; id++) {
if (bd[id]<detectors[idet]->getTotalNumberOfChannels()) {
if (bad) bad[ntot]=choff+bd[id];
ntot++;
}
}
}
choff+=detectors[idet]->getTotalNumberOfChannels();
delete [] bd;
choff+=detectors[idet]->getTotalNumberOfChannels();
delete [] bd;
} else
ntot+=nd;
}
}
return ntot;

View File

@ -4546,7 +4546,7 @@ int slsDetector::setBadChannelCorrection(string fname){
int slsDetector::setBadChannelCorrection(int nch, int *chs, int ff) {
#ifdef VERBOSE
#ifdef VERBOSE
cout << "setting " << nch << " bad chans " << endl;
#endif
if (ff==0) {
@ -4554,9 +4554,10 @@ int slsDetector::setBadChannelCorrection(int nch, int *chs, int ff) {
thisDetector->correctionMask|=(1<<DISCARD_BAD_CHANNELS);
thisDetector->nBadChans=0;
for (int ich=0 ;ich<nch; ich++) {
if (chs[ich]<getMaxNumberOfChannels()) {
if (chs[ich]>=0 && chs[ich]<getMaxNumberOfChannels()) {
thisDetector->badChansList[ich]=chs[ich];
thisDetector->nBadChans++;
// cout << "det : " << thisDetector->nBadChans << " " << thisDetector->badChansList[ich] << endl;
}
}
} else
@ -4572,7 +4573,7 @@ int slsDetector::setBadChannelCorrection(int nch, int *chs, int ff) {
#ifdef VERBOSE
cout << "badchans flag is "<< (thisDetector->correctionMask&(1<< DISCARD_BAD_CHANNELS)) << endl;
#endif
fillBadChannelMask();
// fillBadChannelMask();
if (thisDetector->correctionMask&(1<< DISCARD_BAD_CHANNELS)) {
return thisDetector->nBadChans+thisDetector->nBadFF;
} else

View File

@ -1512,7 +1512,7 @@ string slsDetectorCommand::cmdFlatField(int narg, char *args[], int action){
sval=string(args[1]);
else
sval="none";
double corr[24*1280], ecorr[24*1280];
double corr[ myDet->getMaxNumberOfChannels()], ecorr[myDet->getMaxNumberOfChannels()];
if (myDet->getFlatFieldCorrection(corr,ecorr)) {
if (sval!="none") {
myDet->writeDataFile(sval,corr,ecorr,NULL,'i');
@ -1612,7 +1612,7 @@ string slsDetectorCommand::cmdBadChannels(int narg, char *args[], int action){
sval=string(args[1]);
else
sval="none";
int bch[24*1280], nbch;
int bch[myDet->getMaxNumberOfChannels()], nbch;
if ((nbch=myDet->getBadChannelCorrection(bch))) {
if (sval!="none") {
ofstream outfile;
@ -2105,16 +2105,18 @@ string slsDetectorCommand::cmdScans(int narg, char *args[], int action) {
}
}
ns=myDet->getScanSteps(is);
values=new double[ns];
ns=myDet->getScanSteps(is, values);
int p=myDet->getScanPrecision(is);
char format[1000];
sprintf(format, "%%s %%0.%df",p);
sprintf(answer,"%d ",ns);
for (int i=0; i<ns; i++) {
sprintf(answer,format,answer,values[i]);
if (ns>0) {
values=new double[ns];
ns=myDet->getScanSteps(is, values);
int p=myDet->getScanPrecision(is);
char format[1000];
sprintf(format, "%%s %%0.%df",p);
for (int i=0; i<ns; i++) {
sprintf(answer,format,answer,values[i]);
}
delete [] values;
}
delete [] values;
return string(answer);
}
if (cmd.find("range")!=string::npos) {

View File

@ -519,7 +519,7 @@ int slsDetectorUtils::setBadChannelCorrection(string fname, int &nbadtot, int *b
//int ich;
//int chmin,chmax;
#ifdef VERBOSE
std::cout << "Setting bad channel correction to " << fname << std::endl;
std::cout << "utils: Setting bad channel correction to " << fname << std::endl;
#endif
// int modmi=0;
int modma=1;

View File

@ -36,7 +36,6 @@ class badChannelCorrections{
ssstr >> chmax; \
for (ich=chmin; ich<=chmax; ich++) { \
badlist[nbad]=ich; \
cout << badlist[nbad] << " " << moff << endl; \
nbad++; \
} \
} else { \
@ -50,7 +49,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; cout << badlist[ich] << " " << moff << endl; }; \
for (int ich=0; ich<nbad; ich++) { badlist[ich]=badlist[ich]+moff; }; \
return retval; \
};

View File

@ -24,7 +24,7 @@ static void* startProcessDataNoDelete(void *n){\
postProcessing::postProcessing(): expTime(NULL), ang(NULL), val(NULL), err(NULL), numberOfChannels(0){
postProcessing::postProcessing(): expTime(NULL), ang(NULL), val(NULL), err(NULL), numberOfChannels(0), badChannelMask(NULL){
pthread_mutex_t mp1 = PTHREAD_MUTEX_INITIALIZER;
mp=mp1;
pthread_mutex_init(&mp, NULL);
@ -273,21 +273,34 @@ void postProcessing::doProcessing(double *lfdata, int delflag, string fname) {
int postProcessing::fillBadChannelMask() {
int nbad=0;
cout << "pp fill bad channel mask " << endl;
int nbad=0, nb;
//#define VERBOSE
if (*correctionMask&(1<< DISCARD_BAD_CHANNELS)) {
nbad=getBadChannelCorrection();
#ifdef VERBOSE
cout << "number of bad channels is " << nbad << endl;
#endif
nb=nbad;
if (nbad>0) {
int *badChansList=new int[nbad];
#ifdef VERBOSE
cout << "get badch array " << nbad << endl;
#endif
getBadChannelCorrection(badChansList);
#ifdef VERBOSE
cout << "done " << nbad << endl;
#endif
if (badChannelMask)
delete [] badChannelMask;
//#ifdef VERBOSE
cout << " nchans " << getTotalNumberOfChannels() << endl;
//#endif
badChannelMask=new int[getTotalNumberOfChannels()];
#ifdef VERBOSE
@ -298,12 +311,13 @@ int postProcessing::fillBadChannelMask() {
#ifdef VERBOSE
cout << " badChanMask has be reset" << badChannelMask << endl;
#endif
for (int ichan=0; ichan<nbad; ichan++) {
for (int ichan=0; ichan<nb; ichan++) {
if (badChansList[ichan]<getTotalNumberOfChannels() && badChansList[ichan]>=0 ) {
if (badChannelMask[badChansList[ichan]]==0)
nbad++;
badChannelMask[badChansList[ichan]]=1;
if (badChannelMask[badChansList[ichan]]==0) {
badChannelMask[badChansList[ichan]]=1;
// cout << "bad: " << ichan << " " << badChansList[ichan] << endl;
} else
nbad--;
}
}
delete [] badChansList;
@ -655,6 +669,10 @@ void postProcessing::initDataset(int r) {
#ifdef VERBOSE
cout << "init dataset" << endl;
#endif
// cout << "pp bad channel mask " << badChannelMask << endl;
fillBadChannelMask();
// cout << "pp bad channel mask " << badChannelMask << endl;
ppFun->initDataset(&nmod,chPM,mM,badChannelMask, ffcoeff, fferr, &tdead, &angdir, angRad, angOff, angCenter, &to, &bs, &sx, &sy);
#ifdef VERBOSE

View File

@ -135,7 +135,7 @@ class postProcessing : public angularConversion, public fileIO, public badChanne
get flat field corrections file name
\returns flat field correction file name
*/
string getFlatFieldCorrectionFile(){ if ((*correctionMask)&(1<<FLAT_FIELD_CORRECTION)) return string(flatFieldFile); else return string("none");};
string getFlatFieldCorrectionFile(){ if ((*correctionMask)&(1<<FLAT_FIELD_CORRECTION)) return string(flatFieldFile); else return string("none");};