mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-21 19:30:03 +02:00
debugged
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@164 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
parent
2463c9841c
commit
002444fd57
@ -38,124 +38,5 @@ class mythenDetector : public slsDetector{
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
reads configuration file fname calling executeLine
|
|
||||||
\param fname file to be read
|
|
||||||
*/
|
|
||||||
int readConfigurationFile(string const fname);
|
|
||||||
/**
|
|
||||||
writes configuration file calling executeLine
|
|
||||||
\param fname file to write to
|
|
||||||
*/
|
|
||||||
int writeConfigurationFile(string const fname);
|
|
||||||
/**
|
|
||||||
dumps all the possible detector parameters calling executeLine
|
|
||||||
\param fname file to write to
|
|
||||||
\param level 0 dumps only main parameters and filenames for flat field correction etc.; 2 dumps really the complete configuration including flat field files, badchannels files, trimbits, angular conversion etc.
|
|
||||||
*/
|
|
||||||
int dumpDetectorSetup(string const fname, int level=0);
|
|
||||||
/**
|
|
||||||
retrieves all possible detector parameters from file calling executeLine
|
|
||||||
\param fname file to be read
|
|
||||||
*/
|
|
||||||
int retrieveDetectorSetup(string const fname, int level=0);
|
|
||||||
|
|
||||||
/**
|
|
||||||
reads a trim/settings file
|
|
||||||
\param fname name of the file to be read
|
|
||||||
\param myMod pointer to the module structure which has to be set. <BR> If it is NULL a new module structure will be created
|
|
||||||
\returns the pointer to myMod or NULL if reading the file failed
|
|
||||||
*/
|
|
||||||
|
|
||||||
sls_detector_module* readSettingsFile(string fname, sls_detector_module* myMod=NULL);
|
|
||||||
|
|
||||||
/**
|
|
||||||
writes a trim/settings file
|
|
||||||
\param fname name of the file to be written
|
|
||||||
\param mod module structure which has to be written to file
|
|
||||||
\returns OK or FAIL if the file could not be written
|
|
||||||
|
|
||||||
\sa ::sls_detector_module
|
|
||||||
*/
|
|
||||||
int writeSettingsFile(string fname, sls_detector_module mod);
|
|
||||||
|
|
||||||
/**
|
|
||||||
writes a trim/settings file for module number imod - the values will be read from the current detector structure
|
|
||||||
\param fname name of the file to be written
|
|
||||||
\param imod module number
|
|
||||||
\returns OK or FAIL if the file could not be written
|
|
||||||
\sa ::sls_detector_module sharedSlsDetector
|
|
||||||
*/
|
|
||||||
int writeSettingsFile(string fname, int imod);
|
|
||||||
|
|
||||||
/**
|
|
||||||
writes a data file
|
|
||||||
\param name of the file to be written
|
|
||||||
\param data array of data values
|
|
||||||
\param err array of arrors on the data. If NULL no errors will be written
|
|
||||||
|
|
||||||
\param ang array of angular values. If NULL data will be in the form chan-val(-err) otherwise ang-val(-err)
|
|
||||||
\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
|
|
||||||
|
|
||||||
|
|
||||||
*/
|
|
||||||
int writeDataFile(string fname, float *data, float *err=NULL, float *ang=NULL, char dataformat='f', int nch=-1);
|
|
||||||
|
|
||||||
/**
|
|
||||||
writes a data file
|
|
||||||
\param name of the file to be written
|
|
||||||
\param data array of data values
|
|
||||||
\returns OK or FAIL if it could not write the file or data=NULL
|
|
||||||
*/
|
|
||||||
int writeDataFile(string fname, int *data);
|
|
||||||
|
|
||||||
/**
|
|
||||||
reads a data file
|
|
||||||
\param name of the file to be read
|
|
||||||
\param data array of data values to be filled
|
|
||||||
\param err array of arrors on the data. If NULL no errors are expected on the file
|
|
||||||
|
|
||||||
\param ang array of angular values. If NULL data are expected in the form chan-val(-err) otherwise ang-val(-err)
|
|
||||||
\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 <=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
|
|
||||||
|
|
||||||
|
|
||||||
*/
|
|
||||||
int readDataFile(string fname, float *data, float *err=NULL, float *ang=NULL, char dataformat='f', int nch=0);
|
|
||||||
|
|
||||||
/**
|
|
||||||
reads a data file
|
|
||||||
\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
|
|
||||||
*/
|
|
||||||
int readDataFile(string fname, int *data);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
reads a calibration file
|
|
||||||
\param fname file to be read
|
|
||||||
\param gain reference to the gain variable
|
|
||||||
\offset reference to the offset variable
|
|
||||||
\sa sharedSlsDetector
|
|
||||||
*/
|
|
||||||
int readCalibrationFile(string fname, float &gain, float &offset);
|
|
||||||
/**
|
|
||||||
writes a clibration file
|
|
||||||
\param fname file to be written
|
|
||||||
\param gain
|
|
||||||
\param offset
|
|
||||||
\sa sharedSlsDetector
|
|
||||||
*/
|
|
||||||
int writeCalibrationFile(string fname, float gain, float offset);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
@ -1685,6 +1685,277 @@ void slsDetectorUtils::acquire(int delflag){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void slsDetectorUtils::processFrame(int *myData, int delflag) {
|
||||||
|
|
||||||
|
string fname;
|
||||||
|
float *fdata;
|
||||||
|
|
||||||
|
progressIndex++;
|
||||||
|
//#ifdef VERBOSE
|
||||||
|
cout << fixed << setprecision(2) << setw (6) << getCurrentProgress() << " \%";
|
||||||
|
#ifdef VERBOSE
|
||||||
|
cout << endl;
|
||||||
|
#else
|
||||||
|
cout << "\r" << flush;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//process data
|
||||||
|
/** decode data */
|
||||||
|
fdata=decodeData(myData);
|
||||||
|
|
||||||
|
fname=createFileName();
|
||||||
|
|
||||||
|
|
||||||
|
//uses static function?!?!?!?
|
||||||
|
// writeDataFile (fname+string(".raw"), getTotalNumberOfChannels(),fdata, NULL, NULL, 'i');
|
||||||
|
writeDataFile (fname+string(".raw"),fdata, NULL, NULL, 'i');
|
||||||
|
|
||||||
|
doProcessing(fdata,delflag);
|
||||||
|
|
||||||
|
delete [] myData;
|
||||||
|
myData=NULL;
|
||||||
|
#ifdef VERBOSE
|
||||||
|
// cout << "Pop data queue " << *fileIndex << endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
pthread_mutex_lock(&mp);
|
||||||
|
dataQueue.pop(); //remove the data from the queue
|
||||||
|
queuesize=dataQueue.size();
|
||||||
|
pthread_mutex_unlock(&mp);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void slsDetectorUtils::doProcessing(float *fdata, int delflag) {
|
||||||
|
|
||||||
|
|
||||||
|
float *rcdata=NULL, *rcerr=NULL;
|
||||||
|
float *ffcdata=NULL, *ffcerr=NULL;
|
||||||
|
float *ang=NULL;
|
||||||
|
float bs=0.004;
|
||||||
|
// int imod;
|
||||||
|
int nb;
|
||||||
|
int np;
|
||||||
|
string ext;
|
||||||
|
string fname;
|
||||||
|
detectorData *thisData;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (*correctionMask!=0) {
|
||||||
|
ext=".dat";
|
||||||
|
} else {
|
||||||
|
ext=".raw";
|
||||||
|
}
|
||||||
|
|
||||||
|
fname=createFileName();
|
||||||
|
|
||||||
|
/** write raw data file */
|
||||||
|
if (*correctionMask==0 && delflag==1) {
|
||||||
|
delete [] fdata;
|
||||||
|
} else {
|
||||||
|
|
||||||
|
/** rate correction */
|
||||||
|
if (*correctionMask&(1<<RATE_CORRECTION)) {
|
||||||
|
rcdata=new float[getTotalNumberOfChannels()];
|
||||||
|
rcerr=new float[getTotalNumberOfChannels()];
|
||||||
|
rateCorrect(fdata,NULL,rcdata,rcerr);
|
||||||
|
delete [] fdata;
|
||||||
|
fdata=NULL;
|
||||||
|
} else {
|
||||||
|
rcdata=fdata;
|
||||||
|
fdata=NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/** flat field correction */
|
||||||
|
if (*correctionMask&(1<<FLAT_FIELD_CORRECTION)) {
|
||||||
|
|
||||||
|
ffcdata=new float[getTotalNumberOfChannels()];
|
||||||
|
ffcerr=new float[getTotalNumberOfChannels()];
|
||||||
|
flatFieldCorrect(rcdata,rcerr,ffcdata,ffcerr);
|
||||||
|
delete [] rcdata;
|
||||||
|
rcdata=NULL;
|
||||||
|
if (rcerr)
|
||||||
|
delete [] rcerr;
|
||||||
|
rcerr=NULL;
|
||||||
|
} else {
|
||||||
|
ffcdata=rcdata;
|
||||||
|
ffcerr=rcerr;
|
||||||
|
rcdata=NULL;
|
||||||
|
rcerr=NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// writes angualr converted files
|
||||||
|
|
||||||
|
if (*correctionMask!=0) {
|
||||||
|
if (*correctionMask&(1<< ANGULAR_CONVERSION))
|
||||||
|
ang=convertAngles(currentPosition);
|
||||||
|
writeDataFile (fname+string(".dat"), ffcdata, ffcerr,ang);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (*correctionMask&(1<< ANGULAR_CONVERSION) && (*numberOfPositions)>0) {
|
||||||
|
#ifdef VERBOSE
|
||||||
|
cout << "**************Current position index is " << currentPositionIndex << endl;
|
||||||
|
#endif
|
||||||
|
// if (*numberOfPositions>0) {
|
||||||
|
if (currentPositionIndex<=1) {
|
||||||
|
if (*binSize>0)
|
||||||
|
bs=*binSize;
|
||||||
|
else
|
||||||
|
*binSize=bs;
|
||||||
|
|
||||||
|
|
||||||
|
nb=(int)(360./bs)+1;
|
||||||
|
|
||||||
|
#ifdef VERBOSE
|
||||||
|
cout << "creating merging arrays "<< nb << endl;
|
||||||
|
#endif
|
||||||
|
mergingBins=new float[nb];
|
||||||
|
mergingCounts=new float[nb];
|
||||||
|
mergingErrors=new float[nb];
|
||||||
|
mergingMultiplicity=new int[nb];
|
||||||
|
#ifdef VERBOSE
|
||||||
|
cout << "reset merging " << endl;
|
||||||
|
#endif
|
||||||
|
resetMerging(mergingBins, mergingCounts,mergingErrors, mergingMultiplicity, bs);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef VERBOSE
|
||||||
|
cout << "add to merging "<< currentPositionIndex << endl;
|
||||||
|
#endif
|
||||||
|
addToMerging(ang, ffcdata, ffcerr, mergingBins, mergingCounts,mergingErrors, mergingMultiplicity, getTotalNumberOfChannels(), bs, *angDirection, *correctionMask, badChannelMask );
|
||||||
|
|
||||||
|
#ifdef VERBOSE
|
||||||
|
cout << currentPositionIndex << " " << (*numberOfPositions) << endl;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
pthread_mutex_lock(&mp);
|
||||||
|
if ((currentPositionIndex>=(*numberOfPositions) && posfinished==1 && queuesize==1)) {
|
||||||
|
|
||||||
|
#ifdef VERBOSE
|
||||||
|
cout << "finalize merging " << currentPositionIndex<< endl;
|
||||||
|
#endif
|
||||||
|
np=finalizeMerging(mergingBins, mergingCounts,mergingErrors, mergingMultiplicity, bs);
|
||||||
|
/** file writing */
|
||||||
|
|
||||||
|
currentPositionIndex++;
|
||||||
|
pthread_mutex_unlock(&mp);
|
||||||
|
|
||||||
|
|
||||||
|
fname=createFileName();
|
||||||
|
|
||||||
|
#ifdef VERBOSE
|
||||||
|
cout << "writing merged data file" << endl;
|
||||||
|
#endif
|
||||||
|
writeDataFile (fname+string(".dat"),np,mergingCounts, mergingErrors, mergingBins,'f');
|
||||||
|
#ifdef VERBOSE
|
||||||
|
cout << " done" << endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (delflag) {
|
||||||
|
|
||||||
|
if (mergingBins) {
|
||||||
|
delete [] mergingBins;
|
||||||
|
mergingBins=NULL;
|
||||||
|
}
|
||||||
|
if (mergingCounts) {
|
||||||
|
delete [] mergingCounts;
|
||||||
|
mergingCounts=NULL;
|
||||||
|
}
|
||||||
|
if (mergingErrors) {
|
||||||
|
delete [] mergingErrors;
|
||||||
|
mergingErrors=NULL;
|
||||||
|
}
|
||||||
|
if (mergingMultiplicity){
|
||||||
|
delete [] mergingMultiplicity;
|
||||||
|
mergingMultiplicity=NULL;
|
||||||
|
}
|
||||||
|
#ifdef VERBOSE
|
||||||
|
cout << "deleting merged data done " << endl;
|
||||||
|
#endif
|
||||||
|
} else {
|
||||||
|
thisData=new detectorData(mergingCounts,mergingErrors,mergingBins,getCurrentProgress(),(fname+string(ext)).c_str(),np);
|
||||||
|
|
||||||
|
pthread_mutex_lock(&mg);
|
||||||
|
finalDataQueue.push(thisData);
|
||||||
|
pthread_mutex_unlock(&mg);
|
||||||
|
}
|
||||||
|
pthread_mutex_lock(&mp);
|
||||||
|
}
|
||||||
|
pthread_mutex_unlock(&mp);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (ffcdata)
|
||||||
|
delete [] ffcdata;
|
||||||
|
ffcdata=NULL;
|
||||||
|
|
||||||
|
if (ffcerr)
|
||||||
|
delete [] ffcerr;
|
||||||
|
ffcerr=NULL;
|
||||||
|
if (ang)
|
||||||
|
delete [] ang;
|
||||||
|
ang=NULL;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
if (delflag) {
|
||||||
|
if (ffcdata)
|
||||||
|
delete [] ffcdata;
|
||||||
|
if (ffcerr)
|
||||||
|
delete [] ffcerr;
|
||||||
|
if ( ang)
|
||||||
|
delete [] ang;
|
||||||
|
} else {
|
||||||
|
thisData=new detectorData(ffcdata,ffcerr,NULL,getCurrentProgress(),(fname+string(ext)).c_str(),getTotalNumberOfChannels());
|
||||||
|
pthread_mutex_lock(&mg);
|
||||||
|
finalDataQueue.push(thisData);
|
||||||
|
pthread_mutex_unlock(&mg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
(*fileIndex)++;
|
||||||
|
#ifdef VERBOSE
|
||||||
|
cout << "Incrementing file index " << *fileIndex << endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void* slsDetectorUtils::processData(int delflag) {
|
void* slsDetectorUtils::processData(int delflag) {
|
||||||
|
|
||||||
|
|
||||||
@ -1700,26 +1971,21 @@ void* slsDetectorUtils::processData(int delflag) {
|
|||||||
//cout << "thread mutex unlock line 6505" << endl;
|
//cout << "thread mutex unlock line 6505" << endl;
|
||||||
|
|
||||||
int *myData;
|
int *myData;
|
||||||
float *fdata=NULL;
|
// float *fdata=NULL;
|
||||||
float *rcdata=NULL, *rcerr=NULL;
|
// float *rcdata=NULL, *rcerr=NULL;
|
||||||
float *ffcdata=NULL, *ffcerr=NULL;
|
// float *ffcdata=NULL, *ffcerr=NULL;
|
||||||
float *ang=NULL;
|
// float *ang=NULL;
|
||||||
float bs=0.004;
|
// float bs=0.004;
|
||||||
// int imod;
|
// // int imod;
|
||||||
int nb;
|
// int nb;
|
||||||
int np;
|
// int np;
|
||||||
detectorData *thisData;
|
// detectorData *thisData;
|
||||||
int dum=1;
|
int dum=1;
|
||||||
string ext;
|
// string ext;
|
||||||
string fname;
|
// string fname;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (*correctionMask!=0) {
|
|
||||||
ext=".dat";
|
|
||||||
} else {
|
|
||||||
ext=".raw";
|
|
||||||
}
|
|
||||||
while(dum | *threadedProcessing) { // ????????????????????????
|
while(dum | *threadedProcessing) { // ????????????????????????
|
||||||
|
|
||||||
|
|
||||||
@ -1742,276 +2008,276 @@ void* slsDetectorUtils::processData(int delflag) {
|
|||||||
|
|
||||||
if (myData) {
|
if (myData) {
|
||||||
|
|
||||||
|
processFrame(myData,delflag);
|
||||||
|
|
||||||
progressIndex++;
|
// progressIndex++;
|
||||||
//#ifdef VERBOSE
|
// //#ifdef VERBOSE
|
||||||
cout << fixed << setprecision(2) << setw (6) << getCurrentProgress() << " \%";
|
// cout << fixed << setprecision(2) << setw (6) << getCurrentProgress() << " \%";
|
||||||
#ifdef VERBOSE
|
// #ifdef VERBOSE
|
||||||
cout << endl;
|
// cout << endl;
|
||||||
#else
|
// #else
|
||||||
cout << "\r" << flush;
|
// cout << "\r" << flush;
|
||||||
#endif
|
// #endif
|
||||||
|
|
||||||
//process data
|
// //process data
|
||||||
/** decode data */
|
// /** decode data */
|
||||||
fdata=decodeData(myData);
|
// fdata=decodeData(myData);
|
||||||
|
|
||||||
fname=createFileName();
|
// fname=createFileName();
|
||||||
|
|
||||||
|
|
||||||
//uses static function?!?!?!?
|
// //uses static function?!?!?!?
|
||||||
// writeDataFile (fname+string(".raw"), getTotalNumberOfChannels(),fdata, NULL, NULL, 'i');
|
// // writeDataFile (fname+string(".raw"), getTotalNumberOfChannels(),fdata, NULL, NULL, 'i');
|
||||||
writeDataFile (fname+string(".raw"),fdata, NULL, NULL, 'i');
|
// writeDataFile (fname+string(".raw"),fdata, NULL, NULL, 'i');
|
||||||
|
|
||||||
|
|
||||||
/** write raw data file */
|
// /** write raw data file */
|
||||||
if (*correctionMask==0 && delflag==1) {
|
// if (*correctionMask==0 && delflag==1) {
|
||||||
delete [] fdata;
|
// delete [] fdata;
|
||||||
} else {
|
// } else {
|
||||||
|
|
||||||
/** rate correction */
|
// /** rate correction */
|
||||||
if (*correctionMask&(1<<RATE_CORRECTION)) {
|
// if (*correctionMask&(1<<RATE_CORRECTION)) {
|
||||||
rcdata=new float[getTotalNumberOfChannels()];
|
// rcdata=new float[getTotalNumberOfChannels()];
|
||||||
rcerr=new float[getTotalNumberOfChannels()];
|
// rcerr=new float[getTotalNumberOfChannels()];
|
||||||
rateCorrect(fdata,NULL,rcdata,rcerr);
|
// rateCorrect(fdata,NULL,rcdata,rcerr);
|
||||||
delete [] fdata;
|
// delete [] fdata;
|
||||||
fdata=NULL;
|
// fdata=NULL;
|
||||||
} else {
|
// } else {
|
||||||
rcdata=fdata;
|
// rcdata=fdata;
|
||||||
fdata=NULL;
|
// fdata=NULL;
|
||||||
}
|
// }
|
||||||
|
|
||||||
/** flat field correction */
|
// /** flat field correction */
|
||||||
if (*correctionMask&(1<<FLAT_FIELD_CORRECTION)) {
|
// if (*correctionMask&(1<<FLAT_FIELD_CORRECTION)) {
|
||||||
|
|
||||||
ffcdata=new float[getTotalNumberOfChannels()];
|
// ffcdata=new float[getTotalNumberOfChannels()];
|
||||||
ffcerr=new float[getTotalNumberOfChannels()];
|
// ffcerr=new float[getTotalNumberOfChannels()];
|
||||||
#ifdef VERBOSE
|
// #ifdef VERBOSE
|
||||||
// cout << "array size " << getTotalNumberOfChannels() << endl;
|
// // cout << "array size " << getTotalNumberOfChannels() << endl;
|
||||||
#endif
|
// #endif
|
||||||
flatFieldCorrect(rcdata,rcerr,ffcdata,ffcerr);
|
// flatFieldCorrect(rcdata,rcerr,ffcdata,ffcerr);
|
||||||
#ifdef VERBOSE
|
// #ifdef VERBOSE
|
||||||
// cout << "FF corr done " << endl;
|
// // cout << "FF corr done " << endl;
|
||||||
#endif
|
// #endif
|
||||||
delete [] rcdata;
|
// delete [] rcdata;
|
||||||
rcdata=NULL;
|
// rcdata=NULL;
|
||||||
if (rcerr) delete [] rcerr;
|
// if (rcerr) delete [] rcerr;
|
||||||
rcerr=NULL;
|
// rcerr=NULL;
|
||||||
} else {
|
// } else {
|
||||||
ffcdata=rcdata;
|
// ffcdata=rcdata;
|
||||||
ffcerr=rcerr;
|
// ffcerr=rcerr;
|
||||||
rcdata=NULL;
|
// rcdata=NULL;
|
||||||
rcerr=NULL;
|
// rcerr=NULL;
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (*correctionMask&(1<< ANGULAR_CONVERSION)) {
|
// if (*correctionMask&(1<< ANGULAR_CONVERSION)) {
|
||||||
#ifdef VERBOSE
|
// #ifdef VERBOSE
|
||||||
// cout << "**************Current position index is " << currentPositionIndex << endl;
|
// // cout << "**************Current position index is " << currentPositionIndex << endl;
|
||||||
#endif
|
// #endif
|
||||||
|
|
||||||
if (*numberOfPositions>0 || delflag==0) {
|
// if (*numberOfPositions>0 || delflag==0) {
|
||||||
|
|
||||||
if (currentPositionIndex<=1) {
|
// if (currentPositionIndex<=1) {
|
||||||
if (*binSize>0)
|
// if (*binSize>0)
|
||||||
bs=*binSize;
|
// bs=*binSize;
|
||||||
else
|
// else
|
||||||
*binSize=bs;
|
// *binSize=bs;
|
||||||
|
|
||||||
|
|
||||||
nb=(int)(360./bs)+1;
|
// nb=(int)(360./bs)+1;
|
||||||
|
|
||||||
#ifdef VERBOSE
|
// #ifdef VERBOSE
|
||||||
// cout << "creating merging arrays "<< nb << endl;
|
// // cout << "creating merging arrays "<< nb << endl;
|
||||||
#endif
|
// #endif
|
||||||
mergingBins=new float[nb];
|
// mergingBins=new float[nb];
|
||||||
mergingCounts=new float[nb];
|
// mergingCounts=new float[nb];
|
||||||
mergingErrors=new float[nb];
|
// mergingErrors=new float[nb];
|
||||||
mergingMultiplicity=new int[nb];
|
// mergingMultiplicity=new int[nb];
|
||||||
|
|
||||||
#ifdef VERBOSE
|
// #ifdef VERBOSE
|
||||||
cout << mergingBins<< " "<< mergingCounts<< " "<< mergingErrors<< " "<< mergingMultiplicity<< " " << endl;
|
// cout << mergingBins<< " "<< mergingCounts<< " "<< mergingErrors<< " "<< mergingMultiplicity<< " " << endl;
|
||||||
#endif
|
// #endif
|
||||||
|
|
||||||
#ifdef VERBOSE
|
// #ifdef VERBOSE
|
||||||
// cout << "reset merging " << endl;
|
// // cout << "reset merging " << endl;
|
||||||
#endif
|
// #endif
|
||||||
resetMerging(mergingBins, mergingCounts,mergingErrors, mergingMultiplicity, bs);
|
// resetMerging(mergingBins, mergingCounts,mergingErrors, mergingMultiplicity, bs);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
/* it would be better to create an ang0 with 0 encoder position and add to merging/write to file simply specifying that offset so that when it cycles writing the data or adding to merging it also calculates the angular position */
|
// /* it would be better to create an ang0 with 0 encoder position and add to merging/write to file simply specifying that offset so that when it cycles writing the data or adding to merging it also calculates the angular position */
|
||||||
|
|
||||||
#ifdef VERBOSE
|
// #ifdef VERBOSE
|
||||||
// cout << "convert angles" << endl;
|
// // cout << "convert angles" << endl;
|
||||||
#endif
|
// #endif
|
||||||
ang=convertAngles(currentPosition);
|
// ang=convertAngles(currentPosition);
|
||||||
|
|
||||||
// if (*correctionMask!=0) {
|
// // if (*correctionMask!=0) {
|
||||||
// if (*numberOfPositions>1) {
|
// // if (*numberOfPositions>1) {
|
||||||
//uses static function?!?!?!?
|
// //uses static function?!?!?!?
|
||||||
//writeDataFile (fname+string(".dat"), getTotalNumberOfChannels(), ffcdata, ffcerr,ang);
|
// //writeDataFile (fname+string(".dat"), getTotalNumberOfChannels(), ffcdata, ffcerr,ang);
|
||||||
#ifdef VERBOSE
|
// #ifdef VERBOSE
|
||||||
// cout << "Write angular converted file for position " << currentPositionIndex << endl;
|
// // cout << "Write angular converted file for position " << currentPositionIndex << endl;
|
||||||
#endif
|
// #endif
|
||||||
|
|
||||||
writeDataFile (fname+string(".dat"), ffcdata, ffcerr,ang);
|
// writeDataFile (fname+string(".dat"), ffcdata, ffcerr,ang);
|
||||||
// }
|
// // }
|
||||||
// }
|
// // }
|
||||||
#ifdef VERBOSE
|
// #ifdef VERBOSE
|
||||||
// cout << "add to merging "<< currentPositionIndex << endl;
|
// // cout << "add to merging "<< currentPositionIndex << endl;
|
||||||
#endif
|
// #endif
|
||||||
if (*numberOfPositions>0 || delflag==0) {
|
// if (*numberOfPositions>0 || delflag==0) {
|
||||||
addToMerging(ang, ffcdata, ffcerr, mergingBins, mergingCounts,mergingErrors, mergingMultiplicity, getTotalNumberOfChannels(), bs, *angDirection, *correctionMask, badChannelMask );
|
// addToMerging(ang, ffcdata, ffcerr, mergingBins, mergingCounts,mergingErrors, mergingMultiplicity, getTotalNumberOfChannels(), bs, *angDirection, *correctionMask, badChannelMask );
|
||||||
|
|
||||||
#ifdef VERBOSE
|
// #ifdef VERBOSE
|
||||||
cout << currentPositionIndex << " " << (*numberOfPositions) << endl;
|
// cout << currentPositionIndex << " " << (*numberOfPositions) << endl;
|
||||||
|
|
||||||
#endif
|
// #endif
|
||||||
|
|
||||||
|
|
||||||
pthread_mutex_lock(&mp);
|
// pthread_mutex_lock(&mp);
|
||||||
if ((currentPositionIndex>=(*numberOfPositions) && posfinished==1 && queuesize==1)) {
|
// if ((currentPositionIndex>=(*numberOfPositions) && posfinished==1 && queuesize==1)) {
|
||||||
|
|
||||||
|
|
||||||
// if ((currentPositionIndex>=(*numberOfPositions)) || (currentPositionIndex==0)) {
|
// // if ((currentPositionIndex>=(*numberOfPositions)) || (currentPositionIndex==0)) {
|
||||||
#ifdef VERBOSE
|
// #ifdef VERBOSE
|
||||||
// cout << "finalize merging " << currentPositionIndex<< endl;
|
// // cout << "finalize merging " << currentPositionIndex<< endl;
|
||||||
#endif
|
// #endif
|
||||||
np=finalizeMerging(mergingBins, mergingCounts,mergingErrors, mergingMultiplicity, bs);
|
// np=finalizeMerging(mergingBins, mergingCounts,mergingErrors, mergingMultiplicity, bs);
|
||||||
/** file writing */
|
// /** file writing */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
currentPositionIndex++;
|
// currentPositionIndex++;
|
||||||
pthread_mutex_unlock(&mp);
|
// pthread_mutex_unlock(&mp);
|
||||||
|
|
||||||
|
|
||||||
fname=createFileName();
|
// fname=createFileName();
|
||||||
|
|
||||||
|
|
||||||
#ifdef VERBOSE
|
// #ifdef VERBOSE
|
||||||
// cout << "writing merged data file" << endl;
|
// // cout << "writing merged data file" << endl;
|
||||||
#endif
|
// #endif
|
||||||
writeDataFile (fname+string(".dat"),np,mergingCounts, mergingErrors, mergingBins,'f');
|
// writeDataFile (fname+string(".dat"),np,mergingCounts, mergingErrors, mergingBins,'f');
|
||||||
#ifdef VERBOSE
|
// #ifdef VERBOSE
|
||||||
// cout << " done" << endl;
|
// // cout << " done" << endl;
|
||||||
#endif
|
// #endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (delflag) {
|
// if (delflag) {
|
||||||
#ifdef VERBOSE
|
// #ifdef VERBOSE
|
||||||
// cout << mergingBins<< " " << mergingCounts<< " " << mergingErrors << " " << mergingMultiplicity << " " << endl;
|
// // cout << mergingBins<< " " << mergingCounts<< " " << mergingErrors << " " << mergingMultiplicity << " " << endl;
|
||||||
#endif
|
// #endif
|
||||||
|
|
||||||
if (mergingBins) {
|
// if (mergingBins) {
|
||||||
#ifdef VERBOSE
|
// #ifdef VERBOSE
|
||||||
// cout << "deleting merged bins "<< mergingBins << " size " << sizeof(mergingBins) << endl;
|
// // cout << "deleting merged bins "<< mergingBins << " size " << sizeof(mergingBins) << endl;
|
||||||
#endif
|
// #endif
|
||||||
delete [] mergingBins;
|
// delete [] mergingBins;
|
||||||
mergingBins=NULL;
|
// mergingBins=NULL;
|
||||||
}
|
// }
|
||||||
if (mergingCounts) {
|
// if (mergingCounts) {
|
||||||
#ifdef VERBOSE
|
// #ifdef VERBOSE
|
||||||
// cout << "deleting merged counts "<< mergingCounts << endl;
|
// // cout << "deleting merged counts "<< mergingCounts << endl;
|
||||||
#endif
|
// #endif
|
||||||
delete [] mergingCounts;
|
// delete [] mergingCounts;
|
||||||
mergingCounts=NULL;
|
// mergingCounts=NULL;
|
||||||
}
|
// }
|
||||||
if (mergingErrors) {
|
// if (mergingErrors) {
|
||||||
#ifdef VERBOSE
|
// #ifdef VERBOSE
|
||||||
// cout << "deleting merged errors "<< mergingErrors << endl;
|
// // cout << "deleting merged errors "<< mergingErrors << endl;
|
||||||
#endif
|
// #endif
|
||||||
delete [] mergingErrors;
|
// delete [] mergingErrors;
|
||||||
mergingErrors=NULL;
|
// mergingErrors=NULL;
|
||||||
}
|
// }
|
||||||
if (mergingMultiplicity){
|
// if (mergingMultiplicity){
|
||||||
#ifdef VERBOSE
|
// #ifdef VERBOSE
|
||||||
// cout << "deleting merged multiplicity "<<mergingMultiplicity << endl;
|
// // cout << "deleting merged multiplicity "<<mergingMultiplicity << endl;
|
||||||
#endif
|
// #endif
|
||||||
delete [] mergingMultiplicity;
|
// delete [] mergingMultiplicity;
|
||||||
mergingMultiplicity=NULL;
|
// mergingMultiplicity=NULL;
|
||||||
}
|
// }
|
||||||
#ifdef VERBOSE
|
// #ifdef VERBOSE
|
||||||
// cout << "deleting merged data done " << endl;
|
// // cout << "deleting merged data done " << endl;
|
||||||
|
|
||||||
// cout << mergingBins<< " " << mergingCounts<< " " << mergingErrors << " " << mergingMultiplicity << " " << endl;
|
// // cout << mergingBins<< " " << mergingCounts<< " " << mergingErrors << " " << mergingMultiplicity << " " << endl;
|
||||||
|
|
||||||
#endif
|
// #endif
|
||||||
}
|
// }
|
||||||
} else {
|
// } else {
|
||||||
thisData=new detectorData(mergingCounts,mergingErrors,mergingBins,getCurrentProgress(),(fname+string(ext)).c_str(),np);
|
// thisData=new detectorData(mergingCounts,mergingErrors,mergingBins,getCurrentProgress(),(fname+string(ext)).c_str(),np);
|
||||||
|
|
||||||
pthread_mutex_lock(&mg);
|
// pthread_mutex_lock(&mg);
|
||||||
finalDataQueue.push(thisData);
|
// finalDataQueue.push(thisData);
|
||||||
pthread_mutex_unlock(&mg);
|
// pthread_mutex_unlock(&mg);
|
||||||
}
|
// }
|
||||||
pthread_mutex_lock(&mp);
|
// pthread_mutex_lock(&mp);
|
||||||
}
|
// }
|
||||||
pthread_mutex_unlock(&mp);
|
// pthread_mutex_unlock(&mp);
|
||||||
|
|
||||||
|
|
||||||
#ifdef VERBOSE
|
// #ifdef VERBOSE
|
||||||
// cout << "delete data" << ffcdata << endl;
|
// // cout << "delete data" << ffcdata << endl;
|
||||||
#endif
|
// #endif
|
||||||
|
|
||||||
if (ffcdata)
|
// if (ffcdata)
|
||||||
delete [] ffcdata;
|
// delete [] ffcdata;
|
||||||
ffcdata=NULL;
|
// ffcdata=NULL;
|
||||||
|
|
||||||
#ifdef VERBOSE
|
// #ifdef VERBOSE
|
||||||
// cout << "delete err " << ffcerr << endl;
|
// // cout << "delete err " << ffcerr << endl;
|
||||||
#endif
|
// #endif
|
||||||
if (ffcerr)
|
// if (ffcerr)
|
||||||
delete [] ffcerr;
|
// delete [] ffcerr;
|
||||||
ffcerr=NULL;
|
// ffcerr=NULL;
|
||||||
#ifdef VERBOSE
|
// #ifdef VERBOSE
|
||||||
// cout << "delete ang " << ang << endl;
|
// // cout << "delete ang " << ang << endl;
|
||||||
#endif
|
// #endif
|
||||||
if (ang)
|
// if (ang)
|
||||||
delete [] ang;
|
// delete [] ang;
|
||||||
ang=NULL;
|
// ang=NULL;
|
||||||
|
|
||||||
|
|
||||||
} else {
|
// } else {
|
||||||
if (*correctionMask!=0) {
|
// if (*correctionMask!=0) {
|
||||||
writeDataFile (fname+string(".dat"), ffcdata, ffcerr);
|
// writeDataFile (fname+string(".dat"), ffcdata, ffcerr);
|
||||||
}
|
// }
|
||||||
if (delflag) {
|
// if (delflag) {
|
||||||
if (ffcdata)
|
// if (ffcdata)
|
||||||
delete [] ffcdata;
|
// delete [] ffcdata;
|
||||||
if (ffcerr)
|
// if (ffcerr)
|
||||||
delete [] ffcerr;
|
// delete [] ffcerr;
|
||||||
if ( ang)
|
// if ( ang)
|
||||||
delete [] ang;
|
// delete [] ang;
|
||||||
} else {
|
// } else {
|
||||||
thisData=new detectorData(ffcdata,ffcerr,NULL,getCurrentProgress(),(fname+string(ext)).c_str(),getTotalNumberOfChannels());
|
// thisData=new detectorData(ffcdata,ffcerr,NULL,getCurrentProgress(),(fname+string(ext)).c_str(),getTotalNumberOfChannels());
|
||||||
pthread_mutex_lock(&mg);
|
// pthread_mutex_lock(&mg);
|
||||||
finalDataQueue.push(thisData);
|
// finalDataQueue.push(thisData);
|
||||||
pthread_mutex_unlock(&mg);
|
// pthread_mutex_unlock(&mg);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
(*fileIndex)++;
|
// (*fileIndex)++;
|
||||||
#ifdef VERBOSE
|
// #ifdef VERBOSE
|
||||||
// cout << "Incrementing file index " << *fileIndex << endl;
|
// // cout << "Incrementing file index " << *fileIndex << endl;
|
||||||
#endif
|
// #endif
|
||||||
|
|
||||||
#ifdef VERBOSE
|
// #ifdef VERBOSE
|
||||||
// cout << "delete data " << myData << endl;
|
// // cout << "delete data " << myData << endl;
|
||||||
#endif
|
// #endif
|
||||||
|
|
||||||
delete [] myData;
|
// delete [] myData;
|
||||||
myData=NULL;
|
// myData=NULL;
|
||||||
#ifdef VERBOSE
|
// #ifdef VERBOSE
|
||||||
// cout << "Pop data queue " << *fileIndex << endl;
|
// // cout << "Pop data queue " << *fileIndex << endl;
|
||||||
#endif
|
// #endif
|
||||||
|
|
||||||
pthread_mutex_lock(&mp);
|
// pthread_mutex_lock(&mp);
|
||||||
dataQueue.pop(); //remove the data from the queue
|
// dataQueue.pop(); //remove the data from the queue
|
||||||
queuesize=dataQueue.size();
|
// queuesize=dataQueue.size();
|
||||||
pthread_mutex_unlock(&mp);
|
// pthread_mutex_unlock(&mp);
|
||||||
usleep(1000);
|
usleep(1000);
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&mp);
|
pthread_mutex_unlock(&mp);
|
||||||
|
@ -380,7 +380,7 @@ class slsDetectorUtils : public slsDetectorBase {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
virtual int writeAngularConversion(const char *fname)=0;
|
virtual int writeAngularConversion(string fname)=0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
set bad channels correction
|
set bad channels correction
|
||||||
@ -820,6 +820,20 @@ s
|
|||||||
*/
|
*/
|
||||||
void *processData(int delflag);
|
void *processData(int delflag);
|
||||||
|
|
||||||
|
/** processes the data
|
||||||
|
\param delflag 0 leaves the data in the final data queue
|
||||||
|
\returns nothing
|
||||||
|
|
||||||
|
*/
|
||||||
|
void processFrame(int* myData, int delflag);
|
||||||
|
|
||||||
|
/** processes the data
|
||||||
|
\param delflag 0 leaves the data in the final data queue
|
||||||
|
\returns nothing
|
||||||
|
|
||||||
|
*/
|
||||||
|
void doProcessing(float* myData, int delflag);
|
||||||
|
|
||||||
virtual float* convertAngles(float pos)=0;
|
virtual float* convertAngles(float pos)=0;
|
||||||
virtual int setThresholdEnergy(int, int im=-1, detectorSettings isettings=GET_SETTINGS)=0;
|
virtual int setThresholdEnergy(int, int im=-1, detectorSettings isettings=GET_SETTINGS)=0;
|
||||||
virtual float setDAC(float, dacIndex, int im=-1)=0;
|
virtual float setDAC(float, dacIndex, int im=-1)=0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user