From c14b98d9386263a2dca4cdd95d8b2551c23b1584 Mon Sep 17 00:00:00 2001 From: bergamaschi Date: Fri, 25 May 2012 15:23:32 +0000 Subject: [PATCH] impplemented the possibility of setting the bad channels on a module basis git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@183 951219d9-93cf-4727-9268-0efd64621fa3 --- .../multiSlsDetector/multiSlsDetector.cpp | 18 +++-- .../slsDetector/slsDetector.cpp | 46 +++++++++--- slsDetectorSoftware/slsDetector/slsDetector.h | 2 +- .../slsDetector/slsDetectorUtils.cpp | 75 +++++++++++++++++++ .../slsDetector/slsDetectorUtils.h | 4 +- .../slsDetectorAnalysis/postProcessing.cpp | 70 +++++++++-------- .../slsDetectorAnalysis/postProcessing.h | 8 +- 7 files changed, 166 insertions(+), 57 deletions(-) diff --git a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp index 69265f3c6..d5e8fc8be 100644 --- a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp +++ b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp @@ -1969,13 +1969,19 @@ int multiSlsDetector::setBadChannelCorrection(string fname){ int badlist[MAX_BADCHANS];// badlistdet[MAX_BADCHANS]; int nbad=0;//, nbaddet=0, choff=0, idet=0; + int ret=0; + if (fname=="default") fname=string(thisMultiDetector->badChanFile); + + + - int ret=setBadChannelCorrection(fname, nbad, badlist); + + ret=setBadChannelCorrection(fname, nbad, badlist); #ifdef VERBOSE - cout << "file contained " << ret << " badcahns" << endl; + cout << "file contained " << ret << " badchans" << endl; #endif if (ret==0) { thisMultiDetector->correctionMask&=~(1<0) { - + if (detectors[idet]) { #ifdef VERBOSE cout << "setting " << nbaddet << " badchans to detector " << idet << endl; @@ -2035,7 +2041,7 @@ int multiSlsDetector::setBadChannelCorrection(int nbad, int *badlist, int ff) { nbaddet=0; for (int i=idet; inumberOfDetectors; i++) { #ifdef VERBOSE - cout << "setting " << 0 << " badchans to detector " << i << endl; + cout << "setting " << 0 << " badchans to detector " << i << endl; #endif if (detectors[i]) { detectors[i]->setBadChannelCorrection(nbaddet,badlist,0); @@ -2047,9 +2053,9 @@ int multiSlsDetector::setBadChannelCorrection(int nbad, int *badlist, int ff) { for (int i=0; inumberOfDetectors; i++) { if (detectors[idet]) { #ifdef VERBOSE - cout << "setting " << 0 << " badchans to detector " << idet << endl; + cout << "setting " << 0 << " badchans to detector " << idet << endl; #endif - detectors[idet]->setBadChannelCorrection(nbaddet,badlist,0); + detectors[idet]->setBadChannelCorrection(nbaddet,badlist,0); } } thisMultiDetector->correctionMask&=~(1<badChanFile); - int ret=setBadChannelCorrection(fname, thisDetector->nBadChans, thisDetector->badChansList); + fname=string(badChanFile); + + if (nBadChans && badChansList) + ret=setBadChannelCorrection(fname, *nBadChans, badChansList); if (ret) { - thisDetector->correctionMask|=(1<badChanFile,fname.c_str()); + *correctionMask|=(1<correctionMask&=~(1<correctionMask&(1<0) { thisDetector->correctionMask|=(1<nBadChans=nch; + thisDetector->nBadChans=0; for (int ich=0 ;ichbadChansList[ich]=chs[ich]; + if (chs[ich]badChansList[ich]=chs[ich]; + thisDetector->nBadChans++; + } } } else thisDetector->correctionMask&=~(1<=0) { @@ -5324,7 +5348,7 @@ int slsDetector::loadSettingsFile(string fname, int imod) { mmax=imod+1; } for (int im=mmin; im0 otherwise */ int setBadChannelCorrection(string fname=""); - + /** set bad channels correction \param nch number of bad channels diff --git a/slsDetectorSoftware/slsDetector/slsDetectorUtils.cpp b/slsDetectorSoftware/slsDetector/slsDetectorUtils.cpp index 2b08b7b3d..a726ef6ac 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorUtils.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetectorUtils.cpp @@ -313,6 +313,81 @@ int slsDetectorUtils::setTotalProgress() { +int slsDetectorUtils::setBadChannelCorrection(string fname, int &nbadtot, int *badchanlist, int off){ + + int nbad; + int badlist[MAX_BADCHANS]; + + ifstream infile; + string str; + int interrupt=0; + int ich; + int chmin,chmax; +#ifdef VERBOSE + std::cout << "Setting bad channel correction to " << fname << std::endl; +#endif + int modmi=0, modma=1; + int singlefile=0; + + string fn; + int offset=off; + + + nbadtot=0; + + if (fname=="" || fname=="none") { + ; + } else { + + if (fname.find(".sn")==string::npos && fname.find(".chans")==string::npos) { + modma=setNumberOfModules(); + singlefile=1; + } + + for (int im=0; im0 && nbadtot0 && nbad0 otherwise */ virtual int setBadChannelCorrection(string fname="")=0; - - - - + + static int setBadChannelCorrection(ifstream &infile, int &nbad, int *badlist, int moff=0); /** set bad channels correction \param fname file with bad channel list ("" disable) @@ -85,7 +83,7 @@ class postProcessing : public angularConversion, public fileIO \param badlist array of badchannels \returns 0 if bad channel disabled, >0 otherwise */ - static int setBadChannelCorrection(string fname, int &nbad, int *badlist); + virtual int setBadChannelCorrection(string fname, int &nbad, int *badlist, int off=0)=0; /**