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:
bergamaschi
2012-05-25 15:23:32 +00:00
parent d30ad5faac
commit c14b98d938
7 changed files with 166 additions and 57 deletions

View File

@ -55,33 +55,26 @@ 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 ich;
int chmin,chmax;
#ifdef VERBOSE
std::cout << "Setting bad channel correction to " << fname << std::endl;
#endif
string str;
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;
while (infile.good() and interrupt==0) {
getline(infile,str);
nbad=0;
while (infile.good() and interrupt==0) {
getline(infile,str);
#ifdef VERBOSE
std::cout << str << std::endl;
std::cout << str << std::endl;
#endif
istringstream ssstr;
ssstr.str(str);
istringstream ssstr;
ssstr.str(str);
if (ssstr.bad() || ssstr.fail() || infile.eof()) {
interrupt=1;
break;
@ -117,16 +110,26 @@ int postProcessing::setBadChannelCorrection(string fname, int &nbad, int *badlis
} else
interrupt=1;
}
}
}
infile.close();
if (nbad>0 && nbad<MAX_BADCHANS) {
return nbad;
} else
return 0;
for (int ich=0; ich<nbad; ich++) {
badlist[ich]=badlist[ich]+moff;
}
return nbad;
}
void postProcessing::processFrame(int *myData, int delflag) {
string fname;
@ -401,12 +404,12 @@ int postProcessing::fillBadChannelMask() {
#ifdef VERBOSE
cout << "deleting bad channel mask beacuse number of bad channels is 0" << endl;
#endif
delete [] badChannelMask;
badChannelMask=NULL;
delete [] badChannelMask;
badChannelMask=NULL;
}
}
} else {
#ifdef VERBOSE
cout << "bad channel correction is disabled " << nbad << endl;
@ -419,11 +422,12 @@ int postProcessing::fillBadChannelMask() {
badChannelMask=NULL;
}
}
#ifdef VERBOSE
cout << "number of bad channels is " << nbad << endl;
cout << "number of bad channels is " << nbad << endl;
#endif
return nbad;
}