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

View File

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

View File

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

View File

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

View File

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

View File

@ -135,7 +135,7 @@ class postProcessing : public angularConversion, public fileIO, public badChanne
get flat field corrections file name get flat field corrections file name
\returns flat field correction 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");};