mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-23 01:58:00 +02:00
Raw data file write/read now uses absolute channel values in multidetector systems. Flat field and bad channel corrections and angular conversion debugged
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@135 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
@ -670,15 +670,15 @@ int slsDetector::initializeDetectorSize(detectorType type) {
|
||||
#ifdef VERBOSE
|
||||
cout << "done" << endl;
|
||||
#endif
|
||||
#ifdef VERBOSE
|
||||
cout << "filling bad channel mask" << endl;
|
||||
#endif
|
||||
/** fill the BadChannelMask \sa fillBadChannelMask */
|
||||
fillBadChannelMask();
|
||||
// #ifdef VERBOSE
|
||||
// cout << "filling bad channel mask" << endl;
|
||||
// #endif
|
||||
// /** fill the BadChannelMask \sa fillBadChannelMask */
|
||||
// fillBadChannelMask();
|
||||
|
||||
#ifdef VERBOSE
|
||||
cout << "done" << endl;
|
||||
#endif
|
||||
// #ifdef VERBOSE
|
||||
// cout << "done" << endl;
|
||||
// #endif
|
||||
|
||||
/** modifies the last PID accessing the detector */
|
||||
thisDetector->lastPID=getpid();
|
||||
@ -1041,6 +1041,7 @@ int slsDetector::setTCPSocket(string const name, int const control_port, int con
|
||||
int slsDetector::connectControl() {
|
||||
if (controlSocket)
|
||||
return controlSocket->Connect();
|
||||
return FAIL;
|
||||
}
|
||||
/** disconnect from the control port */
|
||||
int slsDetector::disconnectControl() {
|
||||
@ -1055,6 +1056,7 @@ int slsDetector::disconnectControl() {
|
||||
int slsDetector::connectData() {
|
||||
if (dataSocket)
|
||||
return dataSocket->Connect();
|
||||
return FAIL;
|
||||
};
|
||||
/** disconnect from the data port */
|
||||
int slsDetector::disconnectData(){
|
||||
@ -1068,6 +1070,7 @@ int slsDetector::disconnectControl() {
|
||||
int slsDetector::connectStop() {
|
||||
if (stopSocket)
|
||||
return stopSocket->Connect();
|
||||
return FAIL;
|
||||
};
|
||||
/** disconnect from the stop port */
|
||||
int slsDetector::disconnectStop(){
|
||||
@ -4021,7 +4024,10 @@ int slsDetector::setFlatFieldCorrection(string fname){
|
||||
|
||||
int slsDetector::setFlatFieldCorrection(float *corr, float *ecorr) {
|
||||
if (corr!=NULL) {
|
||||
for (int ichan=0; ichan<thisDetector->nMod[X]*thisDetector->nMod[Y]*thisDetector->nChans*thisDetector->nChips; ichan++) {
|
||||
for (int ichan=0; ichan<thisDetector->nMod[X]*thisDetector->nChans*thisDetector->nChips; ichan++) {
|
||||
// #ifdef VERBOSE
|
||||
// std::cout<< ichan << " "<< corr[ichan] << std::endl;
|
||||
// #endif
|
||||
ffcoefficients[ichan]=corr[ichan];
|
||||
if (ecorr!=NULL)
|
||||
fferrors[ichan]=ecorr[ichan];
|
||||
@ -4079,16 +4085,19 @@ int slsDetector::flatFieldCorrect(float* datain, float *errin, float* dataout, f
|
||||
std::cout<< "Flat field correcting data" << std::endl;
|
||||
#endif
|
||||
float e, eo;
|
||||
if (thisDetector->correctionMask&(1<<FLAT_FIELD_CORRECTION)) {
|
||||
for (int ichan=0; ichan<thisDetector->nMod[X]*thisDetector->nMod[Y]*thisDetector->nChans*thisDetector->nChips; ichan++) {
|
||||
if (errin==NULL)
|
||||
if (thisDetector->correctionMask & (1<<FLAT_FIELD_CORRECTION)) {
|
||||
for (int ichan=0; ichan<thisDetector->nMod[X]*thisDetector->nChans*thisDetector->nChips; ichan++) {
|
||||
if (errin==NULL) {
|
||||
e=0;
|
||||
else
|
||||
} else {
|
||||
e=errin[ichan];
|
||||
|
||||
}
|
||||
flatFieldCorrect(datain[ichan],e,dataout[ichan],eo,ffcoefficients[ichan],fferrors[ichan]);
|
||||
if (errout)
|
||||
errout[ichan]=eo;
|
||||
// #ifdef VERBOSE
|
||||
// cout << ichan << " " <<datain[ichan]<< " " << ffcoefficients[ichan]<< " " << dataout[ichan] << endl;
|
||||
// #endif
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
@ -4209,22 +4218,29 @@ int slsDetector::setBadChannelCorrection(string fname){
|
||||
|
||||
|
||||
int slsDetector::setBadChannelCorrection(int nch, int *chs, int ff) {
|
||||
|
||||
#ifdef VERBOSE
|
||||
cout << "setting " << nch << " bad chans " << endl;
|
||||
#endif
|
||||
if (ff==0) {
|
||||
if (nch<MAX_BADCHANS) {
|
||||
if (nch<MAX_BADCHANS && nch>0) {
|
||||
thisDetector->correctionMask|=(1<<DISCARD_BAD_CHANNELS);
|
||||
thisDetector->nBadChans=nch;
|
||||
for (int ich=0 ;ich<nch; ich++) {
|
||||
thisDetector->badChansList[ich]=chs[ich];
|
||||
}
|
||||
}
|
||||
} else
|
||||
thisDetector->correctionMask&=~(1<<DISCARD_BAD_CHANNELS);
|
||||
} else {
|
||||
if (nch<MAX_BADCHANS) {
|
||||
if (nch<MAX_BADCHANS && nch>0) {
|
||||
thisDetector->nBadFF=nch;
|
||||
for (int ich=0 ;ich<nch; ich++) {
|
||||
thisDetector->badFFList[ich]=chs[ich];
|
||||
}
|
||||
}
|
||||
}
|
||||
#ifdef VERBOSE
|
||||
cout << "badchans flag is "<< (thisDetector->correctionMask&(1<< DISCARD_BAD_CHANNELS)) << endl;
|
||||
#endif
|
||||
fillBadChannelMask();
|
||||
if (thisDetector->correctionMask&(1<< DISCARD_BAD_CHANNELS)) {
|
||||
return thisDetector->nBadChans+thisDetector->nBadFF;
|
||||
|
@ -601,9 +601,14 @@ typedef struct sharedSlsDetector {
|
||||
/** Returns the number of modules (without connecting to the detector) */
|
||||
int getNMods(){return thisDetector->nMods;}; //
|
||||
|
||||
/** Returns the number of modules (without connecting to the detector) */
|
||||
int getMaxMods(){return thisDetector->nModsMax;}; //
|
||||
|
||||
|
||||
int getTotalNumberOfChannels(){return thisDetector->nChans*thisDetector->nChips*thisDetector->nMods;};
|
||||
|
||||
int getMaxNumberOfChannels(){return thisDetector->nChans*thisDetector->nChips*thisDetector->nModsMax;};
|
||||
|
||||
|
||||
/* Communication to server */
|
||||
|
||||
|
@ -87,6 +87,13 @@ int slsDetectorUtils::getPointers(int * const l_stoppedFlag, \
|
||||
fileName=l_fileName;
|
||||
fileIndex=l_fileIndex;
|
||||
|
||||
#ifdef VERBOSE
|
||||
cout << "pointer to badChannelMask is "<< badChannelMask << endl;
|
||||
#endif
|
||||
fillBadChannelMask();
|
||||
#ifdef VERBOSE
|
||||
cout << "pointer to badChannelMask is "<< badChannelMask << endl;
|
||||
#endif
|
||||
return OK;
|
||||
|
||||
|
||||
@ -337,7 +344,7 @@ int slsDetectorUtils::setBadChannelCorrection(string fname, int &nbad, int *badl
|
||||
std::cout << "Setting bad channel correction to " << fname << std::endl;
|
||||
#endif
|
||||
|
||||
if (fname=="") {
|
||||
if (fname=="" || fname=="none") {
|
||||
nbad=0;
|
||||
return 0;
|
||||
} else {
|
||||
@ -395,7 +402,7 @@ int slsDetectorUtils::setBadChannelCorrection(string fname, int &nbad, int *badl
|
||||
}
|
||||
infile.close();
|
||||
if (nbad>0 && nbad<MAX_BADCHANS) {
|
||||
return 1;
|
||||
return nbad;
|
||||
} else
|
||||
return 0;
|
||||
}
|
||||
@ -512,6 +519,7 @@ int slsDetectorUtils::readAngularConversion( ifstream& infile, int nmod, angleCo
|
||||
while (infile.good() and interrupt==0) {
|
||||
getline(infile,str);
|
||||
#ifdef VERBOSE
|
||||
cout << "** mod " << nm << " " ;
|
||||
std::cout<< str << std::endl;
|
||||
#endif
|
||||
istringstream ssstr(str);
|
||||
@ -522,15 +530,18 @@ int slsDetectorUtils::readAngularConversion( ifstream& infile, int nmod, angleCo
|
||||
ssstr >> ss >> er_conv;
|
||||
ssstr >> ss >> off;
|
||||
ssstr >> ss >> eoff;
|
||||
if (mod<nmod && mod>=0) {
|
||||
angOff[mod].center=center;
|
||||
angOff[mod].r_conversion=r_conv;
|
||||
angOff[mod].offset=off;
|
||||
angOff[mod].ecenter=ecenter;
|
||||
angOff[mod].er_conversion=er_conv;
|
||||
angOff[mod].eoffset=eoff;
|
||||
nm++;
|
||||
}
|
||||
if (nm<nmod && nm>=0 ) {
|
||||
angOff[nm].center=center;
|
||||
angOff[nm].r_conversion=r_conv;
|
||||
angOff[nm].offset=off;
|
||||
angOff[nm].ecenter=ecenter;
|
||||
angOff[nm].er_conversion=er_conv;
|
||||
angOff[nm].eoffset=eoff;
|
||||
} else
|
||||
break;
|
||||
nm++;
|
||||
if (nm>=nmod)
|
||||
break;
|
||||
}
|
||||
return nm;
|
||||
}
|
||||
@ -616,12 +627,17 @@ int slsDetectorUtils::addToMerging(float *p1, float *v1, float *e1, float *mp,
|
||||
|
||||
binmi=-180.;
|
||||
binma=binmi+binsize;
|
||||
|
||||
#ifdef VERBOSE
|
||||
cout << "pointer to badchan mask is " << badChanMask << endl;
|
||||
#endif
|
||||
|
||||
if (angDir>0) {
|
||||
for (int ip=0; ip<nchans; ip++) {
|
||||
if ((cm)&(1<< DISCARD_BAD_CHANNELS)) {
|
||||
if (badChanMask[ip]) {
|
||||
#ifdef VERBOSE
|
||||
cout << "channel " << ip << " is bad " << endl;
|
||||
#endif
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@ -752,7 +768,8 @@ int slsDetectorUtils::writeDataFile(string fname, int nch, float *data, float *e
|
||||
outfile.open (fname.c_str(),ios_base::out);
|
||||
if (outfile.is_open())
|
||||
{
|
||||
writeDataFile(outfile, nch, data, err, ang, dataformat);
|
||||
writeDataFile(outfile, nch, data, err, ang, dataformat, 0);
|
||||
outfile.close();
|
||||
return OK;
|
||||
} else {
|
||||
std::cout<< "Could not open file " << fname << "for writing"<< std::endl;
|
||||
@ -761,7 +778,7 @@ int slsDetectorUtils::writeDataFile(string fname, int nch, float *data, float *e
|
||||
};
|
||||
|
||||
|
||||
int slsDetectorUtils::writeDataFile(ofstream &outfile, int nch, float *data, float *err, float *ang, char dataformat){
|
||||
int slsDetectorUtils::writeDataFile(ofstream &outfile, int nch, float *data, float *err, float *ang, char dataformat, int offset){
|
||||
|
||||
|
||||
int idata;
|
||||
@ -773,7 +790,7 @@ int slsDetectorUtils::writeDataFile(ofstream &outfile, int nch, float *data, flo
|
||||
|
||||
for (int ichan=0; ichan<nch; ichan++) {
|
||||
if (ang==NULL) {
|
||||
outfile << ichan << " ";
|
||||
outfile << ichan+offset << " ";
|
||||
} else {
|
||||
outfile << ang[ichan] << " ";
|
||||
}
|
||||
@ -795,7 +812,7 @@ int slsDetectorUtils::writeDataFile(ofstream &outfile, int nch, float *data, flo
|
||||
// }
|
||||
}
|
||||
|
||||
outfile.close();
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
@ -819,7 +836,7 @@ int slsDetectorUtils::writeDataFile(string fname, int nch, int *data){
|
||||
outfile.open (fname.c_str(),ios_base::out);
|
||||
if (outfile.is_open())
|
||||
{
|
||||
writeDataFile(outfile, nch, data);
|
||||
writeDataFile(outfile, nch, data, 0);
|
||||
outfile.close();
|
||||
return OK;
|
||||
} else {
|
||||
@ -831,13 +848,14 @@ int slsDetectorUtils::writeDataFile(string fname, int nch, int *data){
|
||||
|
||||
|
||||
/*writes raw data file */
|
||||
int slsDetectorUtils::writeDataFile(ofstream &outfile, int nch, int *data){
|
||||
int slsDetectorUtils::writeDataFile(ofstream &outfile, int nch, int *data, int offset){
|
||||
if (data==NULL)
|
||||
return FAIL;
|
||||
|
||||
for (int ichan=0; ichan<nch; ichan++)
|
||||
outfile << ichan << " " << *(data+ichan) << std::endl;
|
||||
outfile << ichan+offset << " " << *(data+ichan) << std::endl;
|
||||
|
||||
return OK;
|
||||
};
|
||||
|
||||
|
||||
@ -870,7 +888,7 @@ int slsDetectorUtils::readDataFile(int nch, string fname, float *data, float *er
|
||||
#endif
|
||||
infile.open(fname.c_str(), ios_base::in);
|
||||
if (infile.is_open()) {
|
||||
readDataFile(nch, infile, data, err, ang, dataformat);
|
||||
iline=readDataFile(nch, infile, data, err, ang, dataformat, 0);
|
||||
infile.close();
|
||||
} else {
|
||||
std::cout<< "Could not read file " << fname << std::endl;
|
||||
@ -880,7 +898,7 @@ int slsDetectorUtils::readDataFile(int nch, string fname, float *data, float *er
|
||||
};
|
||||
|
||||
|
||||
int slsDetectorUtils::readDataFile(int nch, ifstream &infile, float *data, float *err, float *ang, char dataformat){
|
||||
int slsDetectorUtils::readDataFile(int nch, ifstream &infile, float *data, float *err, float *ang, char dataformat, int offset){
|
||||
|
||||
|
||||
int ichan, iline=0;
|
||||
@ -902,13 +920,16 @@ int slsDetectorUtils::readDataFile(int nch, ifstream &infile, float *data, float
|
||||
istringstream ssstr(str);
|
||||
if (ang==NULL) {
|
||||
ssstr >> ichan >> fdata;
|
||||
ich=ichan;
|
||||
//ich=ichan;
|
||||
if (ssstr.fail() || ssstr.bad()) {
|
||||
interrupt=1;
|
||||
break;
|
||||
}
|
||||
if (ich!=iline)
|
||||
std::cout<< "Channel number " << ichan << " does not match with line number " << iline << " " << dataformat << std::endl;
|
||||
// if (ich!=iline)
|
||||
// std::cout<< "Channel number " << ichan << " does not match with line number " << iline << " " << dataformat << std::endl;
|
||||
ich=iline;
|
||||
if (ichan<offset)
|
||||
continue;
|
||||
} else {
|
||||
ssstr >> fang >> fdata;
|
||||
ich=iline;
|
||||
@ -924,18 +945,22 @@ int slsDetectorUtils::readDataFile(int nch, ifstream &infile, float *data, float
|
||||
break;
|
||||
}
|
||||
if (ich<maxchans) {
|
||||
if (ang) {
|
||||
if (ang) {
|
||||
ang[ich]=fang;
|
||||
}
|
||||
data[ich]=fdata;
|
||||
if (err)
|
||||
err[ich]=ferr;
|
||||
iline++;
|
||||
} else {
|
||||
std::cout<< " too many lines in file: "<< iline << " instead of " << maxchans << std::endl;
|
||||
interrupt=1;
|
||||
break;
|
||||
}
|
||||
} // else {
|
||||
// std::cout<< " too many lines in file: "<< iline << " instead of " << maxchans << std::endl;
|
||||
// interrupt=1;
|
||||
// break;
|
||||
// }
|
||||
if (iline>=nch) {
|
||||
interrupt=1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return iline;
|
||||
};
|
||||
@ -954,7 +979,7 @@ int slsDetectorUtils::readDataFile(string fname, int *data, int nch){
|
||||
#endif
|
||||
infile.open(fname.c_str(), ios_base::in);
|
||||
if (infile.is_open()) {
|
||||
readDataFile(infile, data, nch);
|
||||
iline=readDataFile(infile, data, nch, 0);
|
||||
infile.close();
|
||||
} else {
|
||||
std::cout<< "Could not read file " << fname << std::endl;
|
||||
@ -963,7 +988,7 @@ int slsDetectorUtils::readDataFile(string fname, int *data, int nch){
|
||||
return iline;
|
||||
};
|
||||
|
||||
int slsDetectorUtils::readDataFile(ifstream &infile, int *data, int nch){
|
||||
int slsDetectorUtils::readDataFile(ifstream &infile, int *data, int nch, int offset){
|
||||
|
||||
int ichan, idata, iline=0;
|
||||
int interrupt=0;
|
||||
@ -981,19 +1006,21 @@ int slsDetectorUtils::readDataFile(ifstream &infile, int *data, int nch){
|
||||
interrupt=1;
|
||||
break;
|
||||
}
|
||||
if (ichan!=iline) {
|
||||
std::cout<< " Expected channel "<< iline <<" but read channel "<< ichan << std::endl;
|
||||
interrupt=1;
|
||||
break;
|
||||
} else {
|
||||
if (iline<nch) {
|
||||
// if (ichan!=iline) {
|
||||
// std::cout<< " Expected channel "<< iline <<" but read channel "<< ichan << std::endl;
|
||||
// interrupt=1;
|
||||
// break;
|
||||
// } else {
|
||||
if (iline<nch) {
|
||||
if (ichan>=offset) {
|
||||
data[iline]=idata;
|
||||
iline++;
|
||||
} else {
|
||||
}
|
||||
} else {
|
||||
interrupt=1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// }
|
||||
}
|
||||
return iline;
|
||||
};
|
||||
@ -1011,7 +1038,7 @@ int slsDetectorUtils::readDataFile(string fname, short int *data, int nch){
|
||||
#endif
|
||||
infile.open(fname.c_str(), ios_base::in);
|
||||
if (infile.is_open()) {
|
||||
readDataFile(infile, data, nch);
|
||||
iline=readDataFile(infile, data, nch, 0);
|
||||
infile.close();
|
||||
} else {
|
||||
std::cout<< "Could not read file " << fname << std::endl;
|
||||
@ -1020,14 +1047,12 @@ int slsDetectorUtils::readDataFile(string fname, short int *data, int nch){
|
||||
return iline;
|
||||
};
|
||||
|
||||
int slsDetectorUtils::readDataFile(ifstream &infile, short int *data, int nch){
|
||||
int slsDetectorUtils::readDataFile(ifstream &infile, short int *data, int nch, int offset){
|
||||
|
||||
int ichan, iline=0;
|
||||
short int idata;
|
||||
int interrupt=0;
|
||||
string str;
|
||||
|
||||
|
||||
while (infile.good() and interrupt==0) {
|
||||
getline(infile,str);
|
||||
#ifdef VERBOSE
|
||||
@ -1039,22 +1064,27 @@ int slsDetectorUtils::readDataFile(ifstream &infile, short int *data, int nch){
|
||||
interrupt=1;
|
||||
break;
|
||||
}
|
||||
if (ichan!=iline) {
|
||||
std::cout<< " Expected channel "<< iline <<" but read channel "<< ichan << std::endl;
|
||||
interrupt=1;
|
||||
break;
|
||||
} else {
|
||||
if (iline<nch) {
|
||||
// if (ichan!=iline) {
|
||||
// std::cout<< " Expected channel "<< iline <<" but read channel "<< ichan << std::endl;
|
||||
// interrupt=1;
|
||||
// break;
|
||||
// } else {
|
||||
if (iline<nch) {
|
||||
if (ichan>=offset) {
|
||||
data[iline]=idata;
|
||||
iline++;
|
||||
} else {
|
||||
interrupt=1;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
interrupt=1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// }
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "read " << iline <<" channels " << std::endl;
|
||||
#endif
|
||||
}
|
||||
return iline;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -1067,11 +1097,11 @@ int slsDetectorUtils::writeDataFile(string fname, float *data, float *err, float
|
||||
return writeDataFile(fname, nch, data, err, ang, dataformat);
|
||||
|
||||
}
|
||||
int slsDetectorUtils::writeDataFile(ofstream &outfile, float *data, float *err, float *ang, char dataformat, int nch){
|
||||
int slsDetectorUtils::writeDataFile(ofstream &outfile, float *data, float *err, float *ang, char dataformat, int nch, int offset){
|
||||
if (nch==-1)
|
||||
nch=getTotalNumberOfChannels();
|
||||
|
||||
return writeDataFile(outfile, nch, data, err, ang, dataformat);
|
||||
return writeDataFile(outfile, nch, data, err, ang, dataformat, offset);
|
||||
|
||||
}
|
||||
|
||||
@ -1083,9 +1113,9 @@ int slsDetectorUtils::writeDataFile(string fname, int *data){
|
||||
return writeDataFile(fname, getTotalNumberOfChannels(), data);
|
||||
}
|
||||
|
||||
int slsDetectorUtils::writeDataFile(ofstream &outfile, int *data){
|
||||
int slsDetectorUtils::writeDataFile(ofstream &outfile, int *data, int offset){
|
||||
|
||||
return writeDataFile(outfile, getTotalNumberOfChannels(), data);
|
||||
return writeDataFile(outfile, getTotalNumberOfChannels(), data, offset);
|
||||
}
|
||||
|
||||
|
||||
@ -1095,8 +1125,8 @@ int slsDetectorUtils::readDataFile(string fname, float *data, float *err, float
|
||||
|
||||
}
|
||||
|
||||
int slsDetectorUtils::readDataFile(ifstream &infile, float *data, float *err, float *ang, char dataformat) {
|
||||
return readDataFile(getTotalNumberOfChannels(), infile, data, err, ang, dataformat);
|
||||
int slsDetectorUtils::readDataFile(ifstream &infile, float *data, float *err, float *ang, char dataformat, int offset) {
|
||||
return readDataFile(getTotalNumberOfChannels(), infile, data, err, ang, dataformat, offset);
|
||||
|
||||
}
|
||||
|
||||
@ -1108,9 +1138,9 @@ int slsDetectorUtils::readDataFile(string fname, int *data){
|
||||
};
|
||||
|
||||
|
||||
int slsDetectorUtils::readDataFile(ifstream &infile, int *data){
|
||||
int slsDetectorUtils::readDataFile(ifstream &infile, int *data, int offset){
|
||||
|
||||
return readDataFile(infile, data, getTotalNumberOfChannels());
|
||||
return readDataFile(infile, data, getTotalNumberOfChannels(), offset);
|
||||
};
|
||||
|
||||
|
||||
@ -1123,9 +1153,9 @@ int slsDetectorUtils::readDataFile(string fname, short int *data){
|
||||
};
|
||||
|
||||
|
||||
int slsDetectorUtils::readDataFile(ifstream &infile, short int *data){
|
||||
int slsDetectorUtils::readDataFile(ifstream &infile, short int *data, int offset){
|
||||
|
||||
return readDataFile(infile, data, getTotalNumberOfChannels());
|
||||
return readDataFile(infile, data, getTotalNumberOfChannels(),offset);
|
||||
};
|
||||
|
||||
|
||||
@ -1627,12 +1657,16 @@ void* slsDetectorUtils::processData(int delflag) {
|
||||
|
||||
fname=createFileName();
|
||||
|
||||
|
||||
//uses static function?!?!?!?
|
||||
// writeDataFile (fname+string(".raw"), getTotalNumberOfChannels(),fdata, NULL, NULL, 'i');
|
||||
writeDataFile (fname+string(".raw"),fdata, NULL, NULL, 'i');
|
||||
|
||||
|
||||
/** write raw data file */
|
||||
if (*correctionMask==0 && delflag==1) {
|
||||
writeDataFile (fname+string(".raw"), getTotalNumberOfChannels(),fdata, NULL, NULL, 'i');
|
||||
delete [] fdata;
|
||||
} else {
|
||||
writeDataFile (fname+string(".raw"), getTotalNumberOfChannels(),fdata, NULL, NULL, 'i');
|
||||
|
||||
/** rate correction */
|
||||
if (*correctionMask&(1<<RATE_CORRECTION)) {
|
||||
@ -1650,9 +1684,15 @@ void* slsDetectorUtils::processData(int delflag) {
|
||||
|
||||
ffcdata=new float[getTotalNumberOfChannels()];
|
||||
ffcerr=new float[getTotalNumberOfChannels()];
|
||||
#ifdef VERBOSE
|
||||
cout << "array size " << getTotalNumberOfChannels() << endl;
|
||||
#endif
|
||||
flatFieldCorrect(rcdata,rcerr,ffcdata,ffcerr);
|
||||
#ifdef VERBOSE
|
||||
cout << "FF corr done " << endl;
|
||||
#endif
|
||||
delete [] rcdata;
|
||||
delete [] rcerr;
|
||||
if (rcerr) delete [] rcerr;
|
||||
} else {
|
||||
ffcdata=rcdata;
|
||||
ffcerr=rcerr;
|
||||
@ -1683,8 +1723,11 @@ void* slsDetectorUtils::processData(int delflag) {
|
||||
ang=convertAngles(currentPosition);
|
||||
|
||||
if (*correctionMask!=0) {
|
||||
if (*numberOfPositions>1)
|
||||
writeDataFile (fname+string(".dat"), getTotalNumberOfChannels(), ffcdata, ffcerr,ang);
|
||||
if (*numberOfPositions>1) {
|
||||
//uses static function?!?!?!?
|
||||
//writeDataFile (fname+string(".dat"), getTotalNumberOfChannels(), ffcdata, ffcerr,ang);
|
||||
writeDataFile (fname+string(".dat"), ffcdata, ffcerr,ang);
|
||||
}
|
||||
}
|
||||
addToMerging(ang, ffcdata, ffcerr, mergingBins, mergingCounts,mergingErrors, mergingMultiplicity, getTotalNumberOfChannels(), bs, *angDirection, *correctionMask, badChannelMask );
|
||||
|
||||
@ -1694,6 +1737,7 @@ void* slsDetectorUtils::processData(int delflag) {
|
||||
currentPositionIndex++;
|
||||
fname=createFileName();
|
||||
if (*correctionMask!=0) {
|
||||
//uses static function?!?!?!?
|
||||
writeDataFile (fname+string(".dat"),np,mergingCounts, mergingErrors, mergingBins,'f');
|
||||
}
|
||||
if (delflag) {
|
||||
@ -1715,7 +1759,9 @@ void* slsDetectorUtils::processData(int delflag) {
|
||||
delete [] ang;
|
||||
} else {
|
||||
if (*correctionMask!=0) {
|
||||
writeDataFile (fname+string(".dat"), getTotalNumberOfChannels(), ffcdata, ffcerr);
|
||||
//uses static function?!?!?!?
|
||||
//writeDataFile (fname+string(".dat"), getTotalNumberOfChannels(), ffcdata, ffcerr);
|
||||
writeDataFile (fname+string(".dat"), ffcdata, ffcerr);
|
||||
}
|
||||
if (delflag) {
|
||||
if (ffcdata)
|
||||
@ -1841,10 +1887,14 @@ void slsDetectorUtils::startThread(int delflag) {
|
||||
int slsDetectorUtils::fillBadChannelMask() {
|
||||
|
||||
int nbad=0;
|
||||
|
||||
|
||||
|
||||
|
||||
if (*correctionMask&(1<< DISCARD_BAD_CHANNELS)) {
|
||||
nbad=getBadChannelCorrection();
|
||||
|
||||
#ifdef VERBOSE
|
||||
cout << "number of bad channels is " << nbad << endl;
|
||||
#endif
|
||||
if (nbad>0) {
|
||||
|
||||
int *badChansList=new int[nbad];
|
||||
@ -1853,9 +1903,16 @@ int slsDetectorUtils::fillBadChannelMask() {
|
||||
if (badChannelMask)
|
||||
delete [] badChannelMask;
|
||||
badChannelMask=new int[getTotalNumberOfChannels()];
|
||||
|
||||
#ifdef VERBOSE
|
||||
cout << " pointer to bad channel mask is " << badChannelMask << endl;
|
||||
#endif
|
||||
for (int ichan=0; ichan<getTotalNumberOfChannels(); ichan++)
|
||||
badChannelMask[ichan]=0;
|
||||
for (int ichan=0; ichan<*nBadChans; ichan++) {
|
||||
#ifdef VERBOSE
|
||||
cout << " badChanMask has be reset" << badChannelMask << endl;
|
||||
#endif
|
||||
for (int ichan=0; ichan<nbad; ichan++) {
|
||||
if (badChansList[ichan]<getTotalNumberOfChannels() && badChansList[ichan]>=0 ) {
|
||||
if (badChannelMask[badChansList[ichan]]==0)
|
||||
nbad++;
|
||||
@ -1867,18 +1924,31 @@ int slsDetectorUtils::fillBadChannelMask() {
|
||||
|
||||
} else {
|
||||
if (badChannelMask) {
|
||||
#ifdef VERBOSE
|
||||
cout << "deleting bad channel mask beacuse number of bad channels is 0" << endl;
|
||||
#endif
|
||||
|
||||
delete [] badChannelMask;
|
||||
badChannelMask=NULL;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
#ifdef VERBOSE
|
||||
cout << "bad channel correction is disabled " << nbad << endl;
|
||||
#endif
|
||||
if (badChannelMask) {
|
||||
#ifdef VERBOSE
|
||||
cout << "deleting bad channel mask beacuse no bad channel correction is selected" << endl;
|
||||
#endif
|
||||
delete [] badChannelMask;
|
||||
badChannelMask=NULL;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef VERBOSE
|
||||
cout << "number of bad channels is " << nbad << endl;
|
||||
#endif
|
||||
return nbad;
|
||||
}
|
||||
|
||||
|
@ -159,11 +159,10 @@ class slsDetectorUtils : public slsDetectorBase {
|
||||
\param dataformat format of the data: can be 'i' integer or 'f' float (default)
|
||||
\param nch number of channels to be written to file. if -1 defaults to the number of installed channels of the detector
|
||||
\returns OK or FAIL if it could not write the file or data=NULL
|
||||
\sa mythenDetector::writeDataFile
|
||||
|
||||
*/
|
||||
int writeDataFile(string fname, float *data, float *err=NULL, float *ang=NULL, char dataformat='f', int nch=-1);
|
||||
int writeDataFile(ofstream &outfile, float *data, float *err=NULL, float *ang=NULL, char dataformat='f', int nch=-1);
|
||||
virtual int writeDataFile(string fname, float *data, float *err=NULL, float *ang=NULL, char dataformat='f', int nch=-1);
|
||||
int writeDataFile(ofstream &outfile, float *data, float *err=NULL, float *ang=NULL, char dataformat='f', int nch=-1, int offset=0);
|
||||
|
||||
|
||||
/**
|
||||
@ -174,8 +173,8 @@ class slsDetectorUtils : public slsDetectorBase {
|
||||
\returns OK or FAIL if it could not write the file or data=NULL
|
||||
\sa mythenDetector::writeDataFile
|
||||
*/
|
||||
int writeDataFile(string fname, int *data);
|
||||
int writeDataFile(ofstream &outfile, int *data);
|
||||
virtual int writeDataFile(string fname, int *data);
|
||||
int writeDataFile(ofstream &outfile, int *data, int offset=0);
|
||||
|
||||
/**
|
||||
|
||||
@ -189,10 +188,9 @@ class slsDetectorUtils : public slsDetectorBase {
|
||||
\param nch number of channels to be written to file. if <=0 defaults to the number of installed channels of the detector
|
||||
\returns OK or FAIL if it could not read the file or data=NULL
|
||||
|
||||
\sa mythenDetector::readDataFile
|
||||
*/
|
||||
int readDataFile(string fname, float *data, float *err=NULL, float *ang=NULL, char dataformat='f');
|
||||
int readDataFile(ifstream& infile, float *data, float *err=NULL, float *ang=NULL, char dataformat='f');
|
||||
virtual int readDataFile(string fname, float *data, float *err=NULL, float *ang=NULL, char dataformat='f');
|
||||
int readDataFile(ifstream& infile, float *data, float *err=NULL, float *ang=NULL, char dataformat='f', int offset=0);
|
||||
|
||||
/**
|
||||
|
||||
@ -200,10 +198,9 @@ class slsDetectorUtils : public slsDetectorBase {
|
||||
\param name of the file to be read
|
||||
\param data array of data values
|
||||
\returns OK or FAIL if it could not read the file or data=NULL
|
||||
\sa mythenDetector::readDataFile
|
||||
*/
|
||||
int readDataFile(string fname, int *data);
|
||||
int readDataFile(ifstream &infile, int *data);
|
||||
virtual int readDataFile(string fname, int *data);
|
||||
int readDataFile(ifstream &infile, int *data, int offset=0);
|
||||
|
||||
/**
|
||||
|
||||
@ -211,10 +208,9 @@ class slsDetectorUtils : public slsDetectorBase {
|
||||
\param name of the file to be read
|
||||
\param data array of data values
|
||||
\returns OK or FAIL if it could not read the file or data=NULL
|
||||
\sa mythenDetector::readDataFile
|
||||
*/
|
||||
int readDataFile(string fname, short int *data);
|
||||
int readDataFile(ifstream &infile, short int *data);
|
||||
virtual int readDataFile(string fname, short int *data);
|
||||
int readDataFile(ifstream &infile, short int *data, int offset=0);
|
||||
|
||||
/**
|
||||
|
||||
@ -232,7 +228,7 @@ class slsDetectorUtils : public slsDetectorBase {
|
||||
*/
|
||||
|
||||
static int writeDataFile(string fname, int nch, float *data, float *err=NULL, float *ang=NULL, char dataformat='f');
|
||||
static int writeDataFile(ofstream &outfile, int nch, float *data, float *err=NULL, float *ang=NULL, char dataformat='f');
|
||||
static int writeDataFile(ofstream &outfile, int nch, float *data, float *err=NULL, float *ang=NULL, char dataformat='f', int offset=0);
|
||||
/**
|
||||
|
||||
writes a data file
|
||||
@ -242,7 +238,7 @@ class slsDetectorUtils : public slsDetectorBase {
|
||||
\sa mythenDetector::writeDataFile
|
||||
*/
|
||||
static int writeDataFile(string fname,int nch, int *data);
|
||||
static int writeDataFile(ofstream &outfile,int nch, int *data);
|
||||
static int writeDataFile(ofstream &outfile,int nch, int *data, int offset=0);
|
||||
|
||||
/**
|
||||
|
||||
@ -259,7 +255,7 @@ class slsDetectorUtils : public slsDetectorBase {
|
||||
\sa mythenDetector::readDataFile
|
||||
*/
|
||||
static int readDataFile(int nch, string fname, float *data, float *err=NULL, float *ang=NULL, char dataformat='f');
|
||||
static int readDataFile(int nch, ifstream &infile, float *data, float *err=NULL, float *ang=NULL, char dataformat='f');
|
||||
static int readDataFile(int nch, ifstream &infile, float *data, float *err=NULL, float *ang=NULL, char dataformat='f', int offset=0);
|
||||
|
||||
/**
|
||||
|
||||
@ -270,7 +266,7 @@ class slsDetectorUtils : public slsDetectorBase {
|
||||
\sa mythenDetector::readDataFile
|
||||
*/
|
||||
static int readDataFile(string fname, int *data, int nch);
|
||||
static int readDataFile(ifstream &infile, int *data, int nch);
|
||||
static int readDataFile(ifstream &infile, int *data, int nch, int offset=0);
|
||||
|
||||
/**
|
||||
|
||||
@ -281,7 +277,7 @@ class slsDetectorUtils : public slsDetectorBase {
|
||||
\sa mythenDetector::readDataFile
|
||||
*/
|
||||
static int readDataFile(string fname, short int *data, int nch);
|
||||
static int readDataFile(ifstream &infile, short int *data, int nch);
|
||||
static int readDataFile(ifstream &infile, short int *data, int nch, int offset=0);
|
||||
|
||||
/**
|
||||
|
||||
@ -735,6 +731,7 @@ s
|
||||
virtual int flatFieldCorrect(float*, float*, float*, float*)=0;
|
||||
|
||||
virtual int getTotalNumberOfChannels()=0;
|
||||
virtual int getMaxNumberOfChannels()=0;
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user