diff --git a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp index 9754c7ef1..d0db08852 100644 --- a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp +++ b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp @@ -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<0) { thisMultiDetector->correctionMask|=(1<=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<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<getMaxNumberOfChannels(); @@ -2559,11 +2566,11 @@ int multiSlsDetector::setBadChannelCorrection(int nbad, int *badlist, int ff) { } nbaddet=0; for (int i=idet; inumberOfDetectors; 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<setBadChannelCorrection(nbaddet,badlist,0); + detectors[idet]->setBadChannelCorrection(nbaddet,badlistdet,0); if(detectors[idet]->getErrorMask()) setErrorMask(getErrorMask()|(1<correctionMask)&(1<< DISCARD_BAD_CHANNELS))==0) + return 0; + else + cout << "bad chans corr enabled "<< thisMultiDetector->correctionMask << endl; + for (int idet=0; idetnumberOfDetectors; idet++) { if (detectors[idet]) { nd=detectors[idet]->getBadChannelCorrection(); - bd = new int[nd]; - nd=detectors[idet]->getBadChannelCorrection(bd); - if(detectors[idet]->getErrorMask()) - setErrorMask(getErrorMask()|(1<0) { + bd = new int[nd]; + nd=detectors[idet]->getBadChannelCorrection(bd); + if(detectors[idet]->getErrorMask()) + setErrorMask(getErrorMask()|(1<getTotalNumberOfChannels()) { - if (bad) bad[ntot]=choff+bd[id]; - ntot++; + for (int id=0; idgetTotalNumberOfChannels()) { + 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; diff --git a/slsDetectorSoftware/slsDetector/slsDetector.cpp b/slsDetectorSoftware/slsDetector/slsDetector.cpp index 6e94c298f..e8e769cfd 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetector.cpp @@ -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<nBadChans=0; for (int ich=0 ;ich=0 && chs[ich]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 diff --git a/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp b/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp index 57615755b..d97eafa41 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp @@ -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; i0) { + 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> 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; ich0) { 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=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 diff --git a/slsDetectorSoftware/slsDetectorAnalysis/postProcessing.h b/slsDetectorSoftware/slsDetectorAnalysis/postProcessing.h index 37b93b55b..d58b74962 100644 --- a/slsDetectorSoftware/slsDetectorAnalysis/postProcessing.h +++ b/slsDetectorSoftware/slsDetectorAnalysis/postProcessing.h @@ -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<