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
|
||||
|
@ -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) {
|
||||
|
||||
|
||||
@ -1700,26 +1971,21 @@ void* slsDetectorUtils::processData(int delflag) {
|
||||
//cout << "thread mutex unlock line 6505" << endl;
|
||||
|
||||
int *myData;
|
||||
float *fdata=NULL;
|
||||
float *rcdata=NULL, *rcerr=NULL;
|
||||
float *ffcdata=NULL, *ffcerr=NULL;
|
||||
float *ang=NULL;
|
||||
float bs=0.004;
|
||||
// int imod;
|
||||
int nb;
|
||||
int np;
|
||||
detectorData *thisData;
|
||||
// float *fdata=NULL;
|
||||
// float *rcdata=NULL, *rcerr=NULL;
|
||||
// float *ffcdata=NULL, *ffcerr=NULL;
|
||||
// float *ang=NULL;
|
||||
// float bs=0.004;
|
||||
// // int imod;
|
||||
// int nb;
|
||||
// int np;
|
||||
// detectorData *thisData;
|
||||
int dum=1;
|
||||
string ext;
|
||||
string fname;
|
||||
// string ext;
|
||||
// string fname;
|
||||
|
||||
|
||||
|
||||
if (*correctionMask!=0) {
|
||||
ext=".dat";
|
||||
} else {
|
||||
ext=".raw";
|
||||
}
|
||||
while(dum | *threadedProcessing) { // ????????????????????????
|
||||
|
||||
|
||||
@ -1742,276 +2008,276 @@ void* slsDetectorUtils::processData(int delflag) {
|
||||
|
||||
if (myData) {
|
||||
|
||||
processFrame(myData,delflag);
|
||||
|
||||
// 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();
|
||||
|
||||
|
||||
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');
|
||||
|
||||
|
||||
//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) {
|
||||
// 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()];
|
||||
// #ifdef VERBOSE
|
||||
// // cout << "array size " << getTotalNumberOfChannels() << endl;
|
||||
// #endif
|
||||
// flatFieldCorrect(rcdata,rcerr,ffcdata,ffcerr);
|
||||
// #ifdef VERBOSE
|
||||
// // cout << "FF corr done " << endl;
|
||||
// #endif
|
||||
// delete [] rcdata;
|
||||
// rcdata=NULL;
|
||||
// if (rcerr) delete [] rcerr;
|
||||
// rcerr=NULL;
|
||||
// } else {
|
||||
// ffcdata=rcdata;
|
||||
// ffcerr=rcerr;
|
||||
// rcdata=NULL;
|
||||
// rcerr=NULL;
|
||||
// }
|
||||
|
||||
// if (*correctionMask&(1<< ANGULAR_CONVERSION)) {
|
||||
// #ifdef VERBOSE
|
||||
// // cout << "**************Current position index is " << currentPositionIndex << endl;
|
||||
// #endif
|
||||
|
||||
// if (*numberOfPositions>0 || delflag==0) {
|
||||
|
||||
// if (currentPositionIndex<=1) {
|
||||
// if (*binSize>0)
|
||||
// bs=*binSize;
|
||||
// else
|
||||
// *binSize=bs;
|
||||
|
||||
|
||||
/** write raw data file */
|
||||
if (*correctionMask==0 && delflag==1) {
|
||||
delete [] fdata;
|
||||
} else {
|
||||
// nb=(int)(360./bs)+1;
|
||||
|
||||
/** 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;
|
||||
}
|
||||
// #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];
|
||||
|
||||
/** flat field correction */
|
||||
if (*correctionMask&(1<<FLAT_FIELD_CORRECTION)) {
|
||||
// #ifdef VERBOSE
|
||||
// cout << mergingBins<< " "<< mergingCounts<< " "<< mergingErrors<< " "<< mergingMultiplicity<< " " << endl;
|
||||
// #endif
|
||||
|
||||
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;
|
||||
rcdata=NULL;
|
||||
if (rcerr) delete [] rcerr;
|
||||
rcerr=NULL;
|
||||
} else {
|
||||
ffcdata=rcdata;
|
||||
ffcerr=rcerr;
|
||||
rcdata=NULL;
|
||||
rcerr=NULL;
|
||||
}
|
||||
// #ifdef VERBOSE
|
||||
// // cout << "reset merging " << endl;
|
||||
// #endif
|
||||
// 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 */
|
||||
|
||||
if (*correctionMask&(1<< ANGULAR_CONVERSION)) {
|
||||
#ifdef VERBOSE
|
||||
// cout << "**************Current position index is " << currentPositionIndex << endl;
|
||||
#endif
|
||||
// #ifdef VERBOSE
|
||||
// // cout << "convert angles" << endl;
|
||||
// #endif
|
||||
// ang=convertAngles(currentPosition);
|
||||
|
||||
if (*numberOfPositions>0 || delflag==0) {
|
||||
// // if (*correctionMask!=0) {
|
||||
// // if (*numberOfPositions>1) {
|
||||
// //uses static function?!?!?!?
|
||||
// //writeDataFile (fname+string(".dat"), getTotalNumberOfChannels(), ffcdata, ffcerr,ang);
|
||||
// #ifdef VERBOSE
|
||||
// // cout << "Write angular converted file for position " << currentPositionIndex << endl;
|
||||
// #endif
|
||||
|
||||
if (currentPositionIndex<=1) {
|
||||
if (*binSize>0)
|
||||
bs=*binSize;
|
||||
else
|
||||
*binSize=bs;
|
||||
// writeDataFile (fname+string(".dat"), ffcdata, ffcerr,ang);
|
||||
// // }
|
||||
// // }
|
||||
// #ifdef VERBOSE
|
||||
// // cout << "add to merging "<< currentPositionIndex << endl;
|
||||
// #endif
|
||||
// if (*numberOfPositions>0 || delflag==0) {
|
||||
// addToMerging(ang, ffcdata, ffcerr, mergingBins, mergingCounts,mergingErrors, mergingMultiplicity, getTotalNumberOfChannels(), bs, *angDirection, *correctionMask, badChannelMask );
|
||||
|
||||
// #ifdef VERBOSE
|
||||
// cout << currentPositionIndex << " " << (*numberOfPositions) << endl;
|
||||
|
||||
// #endif
|
||||
|
||||
|
||||
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 << mergingBins<< " "<< mergingCounts<< " "<< mergingErrors<< " "<< mergingMultiplicity<< " " << endl;
|
||||
#endif
|
||||
|
||||
#ifdef VERBOSE
|
||||
// cout << "reset merging " << endl;
|
||||
#endif
|
||||
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 */
|
||||
|
||||
#ifdef VERBOSE
|
||||
// cout << "convert angles" << endl;
|
||||
#endif
|
||||
ang=convertAngles(currentPosition);
|
||||
|
||||
// if (*correctionMask!=0) {
|
||||
// if (*numberOfPositions>1) {
|
||||
//uses static function?!?!?!?
|
||||
//writeDataFile (fname+string(".dat"), getTotalNumberOfChannels(), ffcdata, ffcerr,ang);
|
||||
#ifdef VERBOSE
|
||||
// cout << "Write angular converted file for position " << currentPositionIndex << endl;
|
||||
#endif
|
||||
|
||||
writeDataFile (fname+string(".dat"), ffcdata, ffcerr,ang);
|
||||
// }
|
||||
// }
|
||||
#ifdef VERBOSE
|
||||
// cout << "add to merging "<< currentPositionIndex << endl;
|
||||
#endif
|
||||
if (*numberOfPositions>0 || delflag==0) {
|
||||
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)) {
|
||||
|
||||
|
||||
pthread_mutex_lock(&mp);
|
||||
if ((currentPositionIndex>=(*numberOfPositions) && posfinished==1 && queuesize==1)) {
|
||||
|
||||
|
||||
// if ((currentPositionIndex>=(*numberOfPositions)) || (currentPositionIndex==0)) {
|
||||
#ifdef VERBOSE
|
||||
// cout << "finalize merging " << currentPositionIndex<< endl;
|
||||
#endif
|
||||
np=finalizeMerging(mergingBins, mergingCounts,mergingErrors, mergingMultiplicity, bs);
|
||||
/** file writing */
|
||||
// // if ((currentPositionIndex>=(*numberOfPositions)) || (currentPositionIndex==0)) {
|
||||
// #ifdef VERBOSE
|
||||
// // cout << "finalize merging " << currentPositionIndex<< endl;
|
||||
// #endif
|
||||
// np=finalizeMerging(mergingBins, mergingCounts,mergingErrors, mergingMultiplicity, bs);
|
||||
// /** file writing */
|
||||
|
||||
|
||||
|
||||
|
||||
currentPositionIndex++;
|
||||
pthread_mutex_unlock(&mp);
|
||||
// currentPositionIndex++;
|
||||
// pthread_mutex_unlock(&mp);
|
||||
|
||||
|
||||
fname=createFileName();
|
||||
// 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
|
||||
// #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) {
|
||||
#ifdef VERBOSE
|
||||
// cout << mergingBins<< " " << mergingCounts<< " " << mergingErrors << " " << mergingMultiplicity << " " << endl;
|
||||
#endif
|
||||
// if (delflag) {
|
||||
// #ifdef VERBOSE
|
||||
// // cout << mergingBins<< " " << mergingCounts<< " " << mergingErrors << " " << mergingMultiplicity << " " << endl;
|
||||
// #endif
|
||||
|
||||
if (mergingBins) {
|
||||
#ifdef VERBOSE
|
||||
// cout << "deleting merged bins "<< mergingBins << " size " << sizeof(mergingBins) << endl;
|
||||
#endif
|
||||
delete [] mergingBins;
|
||||
mergingBins=NULL;
|
||||
}
|
||||
if (mergingCounts) {
|
||||
#ifdef VERBOSE
|
||||
// cout << "deleting merged counts "<< mergingCounts << endl;
|
||||
#endif
|
||||
delete [] mergingCounts;
|
||||
mergingCounts=NULL;
|
||||
}
|
||||
if (mergingErrors) {
|
||||
#ifdef VERBOSE
|
||||
// cout << "deleting merged errors "<< mergingErrors << endl;
|
||||
#endif
|
||||
delete [] mergingErrors;
|
||||
mergingErrors=NULL;
|
||||
}
|
||||
if (mergingMultiplicity){
|
||||
#ifdef VERBOSE
|
||||
// cout << "deleting merged multiplicity "<<mergingMultiplicity << endl;
|
||||
#endif
|
||||
delete [] mergingMultiplicity;
|
||||
mergingMultiplicity=NULL;
|
||||
}
|
||||
#ifdef VERBOSE
|
||||
// cout << "deleting merged data done " << endl;
|
||||
// if (mergingBins) {
|
||||
// #ifdef VERBOSE
|
||||
// // cout << "deleting merged bins "<< mergingBins << " size " << sizeof(mergingBins) << endl;
|
||||
// #endif
|
||||
// delete [] mergingBins;
|
||||
// mergingBins=NULL;
|
||||
// }
|
||||
// if (mergingCounts) {
|
||||
// #ifdef VERBOSE
|
||||
// // cout << "deleting merged counts "<< mergingCounts << endl;
|
||||
// #endif
|
||||
// delete [] mergingCounts;
|
||||
// mergingCounts=NULL;
|
||||
// }
|
||||
// if (mergingErrors) {
|
||||
// #ifdef VERBOSE
|
||||
// // cout << "deleting merged errors "<< mergingErrors << endl;
|
||||
// #endif
|
||||
// delete [] mergingErrors;
|
||||
// mergingErrors=NULL;
|
||||
// }
|
||||
// if (mergingMultiplicity){
|
||||
// #ifdef VERBOSE
|
||||
// // cout << "deleting merged multiplicity "<<mergingMultiplicity << endl;
|
||||
// #endif
|
||||
// delete [] mergingMultiplicity;
|
||||
// mergingMultiplicity=NULL;
|
||||
// }
|
||||
// #ifdef VERBOSE
|
||||
// // cout << "deleting merged data done " << endl;
|
||||
|
||||
// cout << mergingBins<< " " << mergingCounts<< " " << mergingErrors << " " << mergingMultiplicity << " " << endl;
|
||||
// // cout << mergingBins<< " " << mergingCounts<< " " << mergingErrors << " " << mergingMultiplicity << " " << endl;
|
||||
|
||||
#endif
|
||||
}
|
||||
} else {
|
||||
thisData=new detectorData(mergingCounts,mergingErrors,mergingBins,getCurrentProgress(),(fname+string(ext)).c_str(),np);
|
||||
// #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);
|
||||
// pthread_mutex_lock(&mg);
|
||||
// finalDataQueue.push(thisData);
|
||||
// pthread_mutex_unlock(&mg);
|
||||
// }
|
||||
// pthread_mutex_lock(&mp);
|
||||
// }
|
||||
// pthread_mutex_unlock(&mp);
|
||||
|
||||
|
||||
#ifdef VERBOSE
|
||||
// cout << "delete data" << ffcdata << endl;
|
||||
#endif
|
||||
// #ifdef VERBOSE
|
||||
// // cout << "delete data" << ffcdata << endl;
|
||||
// #endif
|
||||
|
||||
if (ffcdata)
|
||||
delete [] ffcdata;
|
||||
ffcdata=NULL;
|
||||
// if (ffcdata)
|
||||
// delete [] ffcdata;
|
||||
// ffcdata=NULL;
|
||||
|
||||
#ifdef VERBOSE
|
||||
// cout << "delete err " << ffcerr << endl;
|
||||
#endif
|
||||
if (ffcerr)
|
||||
delete [] ffcerr;
|
||||
ffcerr=NULL;
|
||||
#ifdef VERBOSE
|
||||
// cout << "delete ang " << ang << endl;
|
||||
#endif
|
||||
if (ang)
|
||||
delete [] ang;
|
||||
ang=NULL;
|
||||
// #ifdef VERBOSE
|
||||
// // cout << "delete err " << ffcerr << endl;
|
||||
// #endif
|
||||
// if (ffcerr)
|
||||
// delete [] ffcerr;
|
||||
// ffcerr=NULL;
|
||||
// #ifdef VERBOSE
|
||||
// // cout << "delete ang " << ang << endl;
|
||||
// #endif
|
||||
// if (ang)
|
||||
// delete [] ang;
|
||||
// ang=NULL;
|
||||
|
||||
|
||||
} else {
|
||||
if (*correctionMask!=0) {
|
||||
writeDataFile (fname+string(".dat"), ffcdata, ffcerr);
|
||||
}
|
||||
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
|
||||
// } else {
|
||||
// if (*correctionMask!=0) {
|
||||
// writeDataFile (fname+string(".dat"), ffcdata, ffcerr);
|
||||
// }
|
||||
// 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
|
||||
|
||||
#ifdef VERBOSE
|
||||
// cout << "delete data " << myData << endl;
|
||||
#endif
|
||||
// #ifdef VERBOSE
|
||||
// // cout << "delete data " << myData << endl;
|
||||
// #endif
|
||||
|
||||
delete [] myData;
|
||||
myData=NULL;
|
||||
#ifdef VERBOSE
|
||||
// cout << "Pop data queue " << *fileIndex << endl;
|
||||
#endif
|
||||
// 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);
|
||||
// pthread_mutex_lock(&mp);
|
||||
// dataQueue.pop(); //remove the data from the queue
|
||||
// queuesize=dataQueue.size();
|
||||
// pthread_mutex_unlock(&mp);
|
||||
usleep(1000);
|
||||
}
|
||||
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
|
||||
@ -820,6 +820,20 @@ s
|
||||
*/
|
||||
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 int setThresholdEnergy(int, int im=-1, detectorSettings isettings=GET_SETTINGS)=0;
|
||||
virtual float setDAC(float, dacIndex, int im=-1)=0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user