mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-28 09:10:01 +02:00
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
This commit is contained in:
parent
d30ad5faac
commit
c14b98d938
@ -1969,13 +1969,19 @@ int multiSlsDetector::setBadChannelCorrection(string fname){
|
|||||||
|
|
||||||
int badlist[MAX_BADCHANS];// badlistdet[MAX_BADCHANS];
|
int badlist[MAX_BADCHANS];// badlistdet[MAX_BADCHANS];
|
||||||
int nbad=0;//, nbaddet=0, choff=0, idet=0;
|
int nbad=0;//, nbaddet=0, choff=0, idet=0;
|
||||||
|
int ret=0;
|
||||||
|
|
||||||
|
|
||||||
if (fname=="default")
|
if (fname=="default")
|
||||||
fname=string(thisMultiDetector->badChanFile);
|
fname=string(thisMultiDetector->badChanFile);
|
||||||
|
|
||||||
int ret=setBadChannelCorrection(fname, nbad, badlist);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ret=setBadChannelCorrection(fname, nbad, badlist);
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
cout << "file contained " << ret << " badcahns" << endl;
|
cout << "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);
|
||||||
|
@ -4239,23 +4239,44 @@ int slsDetector::rateCorrect(float* datain, float *errin, float* dataout, float
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int slsDetector::setBadChannelCorrection(string fname){
|
int slsDetector::setBadChannelCorrection(string fname){
|
||||||
|
|
||||||
|
|
||||||
|
int nbadmod,ret=0;
|
||||||
|
int badchanlist[MAX_BADCHANS];
|
||||||
|
int off;
|
||||||
|
|
||||||
|
string fn=fname;
|
||||||
|
|
||||||
if (fname=="default")
|
if (fname=="default")
|
||||||
fname=string(thisDetector->badChanFile);
|
fname=string(badChanFile);
|
||||||
int ret=setBadChannelCorrection(fname, thisDetector->nBadChans, thisDetector->badChansList);
|
|
||||||
|
if (nBadChans && badChansList)
|
||||||
|
ret=setBadChannelCorrection(fname, *nBadChans, badChansList);
|
||||||
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
thisDetector->correctionMask|=(1<<DISCARD_BAD_CHANNELS);
|
*correctionMask|=(1<<DISCARD_BAD_CHANNELS);
|
||||||
strcpy(thisDetector->badChanFile,fname.c_str());
|
strcpy(badChanFile,fname.c_str());
|
||||||
} else
|
} else
|
||||||
thisDetector->correctionMask&=~(1<<DISCARD_BAD_CHANNELS);
|
*correctionMask&=~(1<<DISCARD_BAD_CHANNELS);
|
||||||
|
|
||||||
fillBadChannelMask();
|
fillBadChannelMask();
|
||||||
return thisDetector->correctionMask&(1<<DISCARD_BAD_CHANNELS);
|
return (*correctionMask)&(1<<DISCARD_BAD_CHANNELS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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;
|
||||||
@ -4263,9 +4284,12 @@ int slsDetector::setBadChannelCorrection(int nch, int *chs, int ff) {
|
|||||||
if (ff==0) {
|
if (ff==0) {
|
||||||
if (nch<MAX_BADCHANS && nch>0) {
|
if (nch<MAX_BADCHANS && nch>0) {
|
||||||
thisDetector->correctionMask|=(1<<DISCARD_BAD_CHANNELS);
|
thisDetector->correctionMask|=(1<<DISCARD_BAD_CHANNELS);
|
||||||
thisDetector->nBadChans=nch;
|
thisDetector->nBadChans=0;
|
||||||
for (int ich=0 ;ich<nch; ich++) {
|
for (int ich=0 ;ich<nch; ich++) {
|
||||||
|
if (chs[ich]<getMaxNumberOfChannels()) {
|
||||||
thisDetector->badChansList[ich]=chs[ich];
|
thisDetector->badChansList[ich]=chs[ich];
|
||||||
|
thisDetector->nBadChans++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
thisDetector->correctionMask&=~(1<<DISCARD_BAD_CHANNELS);
|
thisDetector->correctionMask&=~(1<<DISCARD_BAD_CHANNELS);
|
||||||
@ -5316,7 +5340,7 @@ int slsDetector::writeSettingsFile(string fname, int imod){
|
|||||||
int slsDetector::loadSettingsFile(string fname, int imod) {
|
int slsDetector::loadSettingsFile(string fname, int imod) {
|
||||||
|
|
||||||
sls_detector_module *myMod=NULL;
|
sls_detector_module *myMod=NULL;
|
||||||
string fn;
|
string fn=fname;
|
||||||
fn=fname;
|
fn=fname;
|
||||||
int mmin=0, mmax=setNumberOfModules();
|
int mmin=0, mmax=setNumberOfModules();
|
||||||
if (imod>=0) {
|
if (imod>=0) {
|
||||||
@ -5324,7 +5348,7 @@ int slsDetector::loadSettingsFile(string fname, int imod) {
|
|||||||
mmax=imod+1;
|
mmax=imod+1;
|
||||||
}
|
}
|
||||||
for (int im=mmin; im<mmax; im++) {
|
for (int im=mmin; im<mmax; im++) {
|
||||||
if (fname.find(".sn")==string::npos) {
|
if (fname.find(".sn")==string::npos && fname.find(".trim")) {
|
||||||
ostringstream ostfn;
|
ostringstream ostfn;
|
||||||
ostfn << fname << ".sn" << setfill('0') << setw(3) << hex << getId(MODULE_SERIAL_NUMBER, im);
|
ostfn << fname << ".sn" << setfill('0') << setw(3) << hex << getId(MODULE_SERIAL_NUMBER, im);
|
||||||
fn=ostfn.str();
|
fn=ostfn.str();
|
||||||
|
@ -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; im<modma; im++) {
|
||||||
|
|
||||||
|
|
||||||
|
if (singlefile) {
|
||||||
|
|
||||||
|
ostringstream ostfn;
|
||||||
|
ostfn << fname << ".sn" << setfill('0') << setw(3) << hex << getId(MODULE_SERIAL_NUMBER, im);
|
||||||
|
fn=ostfn.str();
|
||||||
|
|
||||||
|
} else
|
||||||
|
fn=fname;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
infile.open(fn.c_str(), ios_base::in);
|
||||||
|
if (infile.is_open()==0) {
|
||||||
|
std::cout << "could not open file " << fname <<std::endl;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
nbad=setBadChannelCorrection(infile, nbad, badlist, offset);
|
||||||
|
infile.close();
|
||||||
|
|
||||||
|
for (int ich=0; ich<nbad; ich++) {
|
||||||
|
if (nbadtot<MAX_BADCHANS) {
|
||||||
|
badchanlist[nbadtot]=badlist[ich];
|
||||||
|
nbadtot++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
offset+=getChansPerMod(im);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
if (nbadtot>0 && nbadtot<MAX_BADCHANS) {
|
||||||
|
return nbadtot;
|
||||||
|
} else
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
float slsDetectorUtils::getCurrentProgress() {
|
float slsDetectorUtils::getCurrentProgress() {
|
||||||
|
@ -69,6 +69,7 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
|
|||||||
// int getPositions(float *pos=NULL){return angularConversion::getPositions(pos);};
|
// int getPositions(float *pos=NULL){return angularConversion::getPositions(pos);};
|
||||||
|
|
||||||
using slsDetectorBase::setFlatFieldCorrection;
|
using slsDetectorBase::setFlatFieldCorrection;
|
||||||
|
using postProcessing::setBadChannelCorrection;
|
||||||
|
|
||||||
// string getFilePath(){return fileIO::getFilePath();};
|
// string getFilePath(){return fileIO::getFilePath();};
|
||||||
// string setFilePath(string s){return fileIO::setFilePath(s);};
|
// string setFilePath(string s){return fileIO::setFilePath(s);};
|
||||||
@ -269,6 +270,7 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int setBadChannelCorrection(string fname, int &nbadtot, int *badchanlist, int off=0);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -55,25 +55,18 @@ int postProcessing::flatFieldCorrect(float datain, float errin, float &dataout,
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
int postProcessing::setBadChannelCorrection(string fname, int &nbad, int *badlist){
|
|
||||||
ifstream infile;
|
|
||||||
string str;
|
|
||||||
|
int postProcessing::setBadChannelCorrection(ifstream &infile, int &nbad, int *badlist, int moff){
|
||||||
|
|
||||||
int interrupt=0;
|
int interrupt=0;
|
||||||
int ich;
|
int ich;
|
||||||
int chmin,chmax;
|
int chmin,chmax;
|
||||||
#ifdef VERBOSE
|
string str;
|
||||||
std::cout << "Setting bad channel correction to " << fname << std::endl;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (fname=="" || fname=="none") {
|
|
||||||
nbad=0;
|
|
||||||
return 0;
|
|
||||||
} else {
|
|
||||||
infile.open(fname.c_str(), ios_base::in);
|
|
||||||
if (infile.is_open()==0) {
|
|
||||||
std::cout << "could not open file " << fname <<std::endl;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
nbad=0;
|
nbad=0;
|
||||||
while (infile.good() and interrupt==0) {
|
while (infile.good() and interrupt==0) {
|
||||||
getline(infile,str);
|
getline(infile,str);
|
||||||
@ -118,15 +111,25 @@ int postProcessing::setBadChannelCorrection(string fname, int &nbad, int *badlis
|
|||||||
interrupt=1;
|
interrupt=1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int ich=0; ich<nbad; ich++) {
|
||||||
|
badlist[ich]=badlist[ich]+moff;
|
||||||
}
|
}
|
||||||
infile.close();
|
|
||||||
if (nbad>0 && nbad<MAX_BADCHANS) {
|
|
||||||
return nbad;
|
return nbad;
|
||||||
} else
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void postProcessing::processFrame(int *myData, int delflag) {
|
void postProcessing::processFrame(int *myData, int delflag) {
|
||||||
|
|
||||||
string fname;
|
string fname;
|
||||||
@ -424,6 +427,7 @@ int postProcessing::fillBadChannelMask() {
|
|||||||
cout << "number of bad channels is " << nbad << endl;
|
cout << "number of bad channels is " << nbad << endl;
|
||||||
#endif
|
#endif
|
||||||
return nbad;
|
return nbad;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -75,9 +75,7 @@ class postProcessing : public angularConversion, public fileIO
|
|||||||
*/
|
*/
|
||||||
virtual int setBadChannelCorrection(string fname="")=0;
|
virtual int setBadChannelCorrection(string fname="")=0;
|
||||||
|
|
||||||
|
static int setBadChannelCorrection(ifstream &infile, int &nbad, int *badlist, int moff=0);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
set bad channels correction
|
set bad channels correction
|
||||||
\param fname file with bad channel list ("" disable)
|
\param fname file with bad channel list ("" disable)
|
||||||
@ -85,7 +83,7 @@ class postProcessing : public angularConversion, public fileIO
|
|||||||
\param badlist array of badchannels
|
\param badlist array of badchannels
|
||||||
\returns 0 if bad channel disabled, >0 otherwise
|
\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;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user