mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-23 18:17:59 +02:00
postprocessing based on external functions - can work with f90 interface
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@285 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
#include "slsDetector.h"
|
||||
#include "usersFunctions.h"
|
||||
#include "slsDetectorCommand.h"
|
||||
#include "postProcessingFuncs.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/shm.h>
|
||||
#include <sys/socket.h>
|
||||
@ -662,9 +663,10 @@ int slsDetector::initializeDetectorSize(detectorType type) {
|
||||
fileName=thisDetector->fileName;
|
||||
fileIndex=&thisDetector->fileIndex;
|
||||
moveFlag=&thisDetector->moveFlag;
|
||||
|
||||
sampleDisplacement=NULL;
|
||||
settingsFile=thisDetector->settingsFile;
|
||||
|
||||
|
||||
// setAngularConversionPointer(thisDetector->angOff,&thisDetector->nMods, thisDetector->nChans*thisDetector->nChips);
|
||||
|
||||
#ifdef VERBOSE
|
||||
@ -900,10 +902,16 @@ int slsDetector::receiveModule(sls_detector_module* myMod) {
|
||||
|
||||
|
||||
int slsDetector::setOnline(int off) {
|
||||
int old=thisDetector->onlineFlag;
|
||||
if (off!=GET_ONLINE_FLAG) {
|
||||
thisDetector->onlineFlag=off;
|
||||
if (thisDetector->onlineFlag==ONLINE_FLAG)
|
||||
if (thisDetector->onlineFlag==ONLINE_FLAG) {
|
||||
setTCPSocket();
|
||||
if (thisDetector->onlineFlag==ONLINE_FLAG && old==OFFLINE_FLAG) {
|
||||
cout << "Detector connecting for the first time - updating!" << endl;
|
||||
updateDetector();
|
||||
}
|
||||
}
|
||||
}
|
||||
return thisDetector->onlineFlag;
|
||||
}
|
||||
@ -911,7 +919,7 @@ int slsDetector::setOnline(int off) {
|
||||
|
||||
|
||||
string slsDetector::checkOnline() {
|
||||
string retval = "";
|
||||
string retval = string("");
|
||||
if(!controlSocket){
|
||||
//this already sets the online/offline flag
|
||||
setTCPSocket();
|
||||
@ -927,7 +935,7 @@ string slsDetector::checkOnline() {
|
||||
thisDetector->onlineFlag=OFFLINE_FLAG;
|
||||
delete controlSocket;
|
||||
controlSocket=NULL;
|
||||
retval = thisDetector->hostname;
|
||||
retval = string(thisDetector->hostname);
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "offline!" << std::endl;
|
||||
#endif
|
||||
@ -2854,7 +2862,17 @@ int slsDetector::updateDetectorNoWait() {
|
||||
n = controlSocket->ReceiveDataOnly(&nm,sizeof(nm));
|
||||
thisDetector->nMod[X]=nm;
|
||||
n = controlSocket->ReceiveDataOnly( &nm,sizeof(nm));
|
||||
thisDetector->nMod[Y]=nm;
|
||||
/// Should be overcome at a certain point!
|
||||
|
||||
if (thisDetector->myDetectorType==MYTHEN) {
|
||||
thisDetector->nModMax[X]=nm;
|
||||
thisDetector->nModMax[Y]=1;
|
||||
thisDetector->nModsMax=thisDetector->nModMax[Y]*thisDetector->nModMax[X];
|
||||
thisDetector->nMod[Y]=1;
|
||||
} else {
|
||||
thisDetector->nMod[Y]=nm;
|
||||
}
|
||||
|
||||
thisDetector->nMods=thisDetector->nMod[Y]*thisDetector->nMod[X];
|
||||
if (thisDetector->nModsMax<thisDetector->nMods)
|
||||
thisDetector->nModsMax=thisDetector->nMods;
|
||||
@ -3342,8 +3360,13 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t){
|
||||
thisDetector->timerValue[index]=retval;
|
||||
}
|
||||
controlSocket->Disconnect();
|
||||
if (ret==FORCE_UPDATE)
|
||||
if (ret==FORCE_UPDATE) {
|
||||
updateDetector();
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "Updated!" << std::endl;
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -4035,7 +4058,7 @@ int slsDetector::setFlatFieldCorrection(string fname)
|
||||
|
||||
char ffffname[MAX_STR_LENGTH*2];
|
||||
if (fname=="default") {
|
||||
fname=string("thisDetector->flatFieldFile");
|
||||
fname=string(thisDetector->flatFieldFile);
|
||||
}
|
||||
|
||||
if (fname=="") {
|
||||
@ -4043,77 +4066,50 @@ int slsDetector::setFlatFieldCorrection(string fname)
|
||||
std::cout<< "disabling flat field correction" << std::endl;
|
||||
#endif
|
||||
thisDetector->correctionMask&=~(1<<FLAT_FIELD_CORRECTION);
|
||||
//strcpy(thisDetector->flatFieldFile,"none");
|
||||
|
||||
|
||||
|
||||
} else {
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "Setting flat field correction from file " << fname << std::endl;
|
||||
#endif
|
||||
sprintf(ffffname,"%s/%s",thisDetector->flatFieldDir,fname.c_str());
|
||||
nch=readDataFile(string(ffffname),data);
|
||||
if (nch>0) {
|
||||
strcpy(thisDetector->flatFieldFile,fname.c_str());
|
||||
for (int ichan=0; ichan<nch; ichan++) {
|
||||
if (data[ichan]>0) {
|
||||
/* add to median */
|
||||
im=0;
|
||||
while ((im<nmed) && (xmed[im]<data[ichan]))
|
||||
im++;
|
||||
for (int i=nmed; i>im; i--)
|
||||
xmed[i]=xmed[i-1];
|
||||
xmed[im]=data[ichan];
|
||||
nmed++;
|
||||
} else {
|
||||
//add the channel to the ff bad channel list
|
||||
if (thisDetector->nBadFF<MAX_BADCHANS) {
|
||||
thisDetector->badFFList[thisDetector->nBadFF]=ichan;
|
||||
(thisDetector->nBadFF)++;
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "Channel " << ichan << " added to the bad channel list" << std::endl;
|
||||
#endif
|
||||
} else
|
||||
std::cout<< "Too many bad channels " << std::endl;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (nmed>1 && xmed[nmed/2]>0) {
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "Flat field median is " << xmed[nmed/2] << " calculated using "<< nmed << " points" << std::endl;
|
||||
std::cout<< "Setting flat field correction from file " << fname << std::endl;
|
||||
#endif
|
||||
|
||||
|
||||
sprintf(ffffname,"%s/%s",thisDetector->flatFieldDir,fname.c_str());
|
||||
nch=readDataFile(string(ffffname),data);
|
||||
if (nch>0) {
|
||||
|
||||
//???? bad ff chans?
|
||||
int nm=getNMods();
|
||||
int chpm[nm];
|
||||
int mMask[nm];
|
||||
for (int i=0; i<nm; i++) {
|
||||
chpm[im]=getChansPerMod(im);
|
||||
mMask[im]=im;
|
||||
}
|
||||
|
||||
if ((postProcessingFuncs::calculateFlatField(&nm, chpm, mMask, badChannelMask, data, ffcoefficients, fferrors))) {
|
||||
strcpy(thisDetector->flatFieldFile,fname.c_str());
|
||||
|
||||
|
||||
thisDetector->correctionMask|=(1<<FLAT_FIELD_CORRECTION);
|
||||
for (int ichan=0; ichan<nch; ichan++) {
|
||||
if (data[ichan]>0) {
|
||||
ffcoefficients[ichan]=xmed[nmed/2]/data[ichan];
|
||||
fferrors[ichan]=ffcoefficients[ichan]*sqrt(data[ichan])/data[ichan];
|
||||
} else {
|
||||
ffcoefficients[ichan]=0.;
|
||||
fferrors[ichan]=1.;
|
||||
}
|
||||
}
|
||||
for (int ichan=nch; ichan<thisDetector->nMod[X]*thisDetector->nMod[Y]*thisDetector->nChans*thisDetector->nChips; ichan++) {
|
||||
ffcoefficients[ichan]=1.;
|
||||
fferrors[ichan]=0.;
|
||||
}
|
||||
thisDetector->correctionMask|=(1<<FLAT_FIELD_CORRECTION);
|
||||
|
||||
setFlatFieldCorrection(ffcoefficients, fferrors);
|
||||
|
||||
}
|
||||
} else {
|
||||
std::cout<< "Flat field from file " << fname << " is not valid " << nch << std::endl;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
fillBadChannelMask();
|
||||
return thisDetector->correctionMask&(1<<FLAT_FIELD_CORRECTION);
|
||||
|
||||
} else {
|
||||
std::cout<< "Flat field data from file " << fname << " are not valid (" << nmed << "///" << xmed[nmed/2] << std::endl;
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
std::cout<< "Flat field from file " << fname << " is not valid " << nch << std::endl;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return thisDetector->correctionMask&(1<<FLAT_FIELD_CORRECTION);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int slsDetector::setFlatFieldCorrection(double *corr, double *ecorr) {
|
||||
if (corr!=NULL) {
|
||||
for (int ichan=0; ichan<thisDetector->nMod[X]*thisDetector->nChans*thisDetector->nChips; ichan++) {
|
||||
@ -4129,7 +4125,11 @@ int slsDetector::setFlatFieldCorrection(double *corr, double *ecorr) {
|
||||
thisDetector->correctionMask|=(1<<FLAT_FIELD_CORRECTION);
|
||||
} else
|
||||
thisDetector->correctionMask&=~(1<<FLAT_FIELD_CORRECTION);
|
||||
|
||||
#ifdef VERBOSE
|
||||
cout << "set ff corrections " << ((thisDetector->correctionMask)&(1<<FLAT_FIELD_CORRECTION)) << endl;
|
||||
#endif
|
||||
|
||||
|
||||
return thisDetector->correctionMask&(1<<FLAT_FIELD_CORRECTION);
|
||||
}
|
||||
|
||||
@ -4184,7 +4184,7 @@ int slsDetector::flatFieldCorrect(double* datain, double *errin, double* dataout
|
||||
} else {
|
||||
e=errin[ichan];
|
||||
}
|
||||
flatFieldCorrect(datain[ichan],e,dataout[ichan],eo,ffcoefficients[ichan],fferrors[ichan]);
|
||||
postProcessingFuncs::flatFieldCorrect(datain[ichan],e,dataout[ichan],eo,ffcoefficients[ichan],fferrors[ichan]);
|
||||
if (errout)
|
||||
errout[ichan]=eo;
|
||||
// #ifdef VERBOSE
|
||||
@ -4257,8 +4257,6 @@ double slsDetector::getRateCorrectionTau(){
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int slsDetector::getRateCorrection(){
|
||||
|
||||
if (thisDetector->correctionMask&(1<<RATE_CORRECTION)) {
|
||||
@ -4286,7 +4284,7 @@ int slsDetector::rateCorrect(double* datain, double *errin, double* dataout, dou
|
||||
} else
|
||||
e=errin[ichan];
|
||||
|
||||
rateCorrect(datain[ichan], e, dataout[ichan], errout[ichan], tau, t);
|
||||
postProcessingFuncs::rateCorrect(datain[ichan], e, dataout[ichan], errout[ichan], tau, t);
|
||||
}
|
||||
}
|
||||
|
||||
@ -4638,38 +4636,6 @@ int slsDetector::getAngularConversion(int &direction, angleConversionConstant *
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// double* slsDetector::convertAngles(double pos) {
|
||||
// int imod;
|
||||
// double *ang=new double[thisDetector->nChans*thisDetector->nChips*thisDetector->nMods];
|
||||
// for (int ip=0; ip<thisDetector->nChans*thisDetector->nChips*thisDetector->nMods; ip++) {
|
||||
// imod=ip/(thisDetector->nChans*thisDetector->nChips);
|
||||
// ang[ip]=angle(ip%(thisDetector->nChans*thisDetector->nChips),\
|
||||
// pos, \
|
||||
// thisDetector->fineOffset+thisDetector->globalOffset, \
|
||||
// thisDetector->angOff[imod].r_conversion, \
|
||||
// thisDetector->angOff[imod].center, \
|
||||
// thisDetector->angOff[imod].offset, \
|
||||
// thisDetector->angOff[imod].tilt, \
|
||||
// thisDetector->angDirection
|
||||
// );
|
||||
// }
|
||||
// return ang;
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int slsDetector:: writeAngularConversion(string fname) {
|
||||
|
||||
return writeAngularConversion(fname, thisDetector->nMods, thisDetector->angOff);
|
||||
@ -4843,12 +4809,7 @@ int slsDetector::readConfigurationFile(string const fname){
|
||||
string ans;
|
||||
string str;
|
||||
ifstream infile;
|
||||
// int iargval;
|
||||
// int interrupt=0;
|
||||
char *args[1000];
|
||||
// for (int ia=0; ia<100; ia++) {
|
||||
// args[ia]=new char[1000];
|
||||
// }
|
||||
|
||||
string sargname, sargval;
|
||||
int iline=0;
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include "angleConversionConstant.h"
|
||||
#include "MySocketTCP.h"
|
||||
|
||||
|
||||
#include "angleConversionConstant.h";
|
||||
|
||||
|
||||
/**
|
||||
@ -244,6 +244,7 @@ typedef struct sharedSlsDetector {
|
||||
/** online flag - is set if the receiver is connected, unset if socket connection is not possible */
|
||||
int receiverOnlineFlag;
|
||||
|
||||
|
||||
} sharedSlsDetector;
|
||||
|
||||
|
||||
|
@ -123,6 +123,15 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
|
||||
descrToFuncMap[i].m_pFuncName="moveflag" ;//
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdAngConv;
|
||||
i++;
|
||||
|
||||
descrToFuncMap[i].m_pFuncName="samplex" ;//
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdAngConv;
|
||||
i++;
|
||||
|
||||
|
||||
descrToFuncMap[i].m_pFuncName="sampley" ;//
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdAngConv;
|
||||
i++;
|
||||
|
||||
|
||||
|
||||
@ -1682,7 +1691,14 @@ string slsDetectorCommand::cmdAngConv(int narg, char *args[], int action){
|
||||
|
||||
} else if (string(args[0])==string("moveflag")) {
|
||||
c=MOVE_FLAG;
|
||||
} else
|
||||
} else if (string(args[0])==string("samplex")) {
|
||||
c=SAMPLE_X;
|
||||
} else if (string(args[0])==string("sampley")) {
|
||||
c=SAMPLE_Y;
|
||||
}
|
||||
|
||||
|
||||
else
|
||||
return string("could not decode angular conversion parameter ")+cmd;
|
||||
|
||||
|
||||
@ -1712,6 +1728,10 @@ string slsDetectorCommand::helpAngConv(int narg, char *args[], int action){
|
||||
t=4;
|
||||
} else if (string(args[0])==string("binsize")) {
|
||||
t=8;
|
||||
} else if (string(args[0])==string("samplex")) {
|
||||
t=16;
|
||||
} else if (string(args[0])==string("sampley")) {
|
||||
t=32;
|
||||
}
|
||||
if (t&1) {
|
||||
if (action==GET_ACTION || action==HELP_ACTION)
|
||||
@ -1739,11 +1759,19 @@ string slsDetectorCommand::helpAngConv(int narg, char *args[], int action){
|
||||
if (action==PUT_ACTION || action==HELP_ACTION)
|
||||
os << string("binsize f\t sets the bin size used for the angular conversion \n");
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (t&16) {
|
||||
if (action==GET_ACTION || action==HELP_ACTION)
|
||||
os << string("samplex \t gets the sample displacement in th direction parallel to the beam \n");
|
||||
if (action==PUT_ACTION || action==HELP_ACTION)
|
||||
os << string("samplex f\t sets the sample displacement in th direction parallel to the beam \n");
|
||||
}
|
||||
if (t&32) {
|
||||
if (action==GET_ACTION || action==HELP_ACTION)
|
||||
os << string("sampley \t gets the sample displacement in the direction orthogonal to the beam \n");
|
||||
if (action==PUT_ACTION || action==HELP_ACTION)
|
||||
os << string("sampley f\t sets the sample displacement in the direction orthogonal to the beam \n");
|
||||
}
|
||||
|
||||
return os.str();
|
||||
}
|
||||
|
@ -10,8 +10,7 @@
|
||||
#include <sys/shm.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
slsDetectorUtils::slsDetectorUtils() {
|
||||
slsDetectorUtils::slsDetectorUtils() {
|
||||
|
||||
|
||||
#ifdef VERBOSE
|
||||
@ -34,13 +33,13 @@ slsDetectorUtils::slsDetectorUtils() {
|
||||
cout << "done " << endl;
|
||||
#endif
|
||||
|
||||
expTime=timerValue+ACQUISITION_TIME;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void slsDetectorUtils::acquire(int delflag){
|
||||
|
||||
// setTotalProgress();
|
||||
@ -80,13 +79,36 @@ void slsDetectorUtils::acquire(int delflag){
|
||||
|
||||
|
||||
|
||||
pthread_mutex_lock(&mp);
|
||||
resetFinalDataQueue();
|
||||
resetDataQueue();
|
||||
jointhread=0;
|
||||
queuesize=0;
|
||||
posfinished=0;
|
||||
pthread_mutex_unlock(&mp);
|
||||
|
||||
setJoinThread(0);
|
||||
positionFinished(0);
|
||||
|
||||
|
||||
|
||||
|
||||
int nm=timerValue[MEASUREMENTS_NUMBER];
|
||||
if (nm<1)
|
||||
nm=1;
|
||||
|
||||
int np=getNumberOfPositions();
|
||||
if (np<1)
|
||||
np=1;
|
||||
|
||||
|
||||
int ns0=1;
|
||||
if (*actionMask & (1 << MAX_ACTIONS)) {
|
||||
ns0=getScanSteps(0);
|
||||
if (ns0<1)
|
||||
ns0=1;
|
||||
}
|
||||
|
||||
int ns1=1;
|
||||
if (*actionMask & (1 << (MAX_ACTIONS+1))) {
|
||||
ns1=getScanSteps(1);
|
||||
if (ns1<1)
|
||||
ns1=1;
|
||||
}
|
||||
|
||||
|
||||
if (*threadedProcessing) {
|
||||
startThread(delflag);
|
||||
@ -96,48 +118,21 @@ void slsDetectorUtils::acquire(int delflag){
|
||||
#endif
|
||||
|
||||
|
||||
int nm=1;
|
||||
|
||||
if (timerValue[MEASUREMENTS_NUMBER]>0)
|
||||
nm=timerValue[MEASUREMENTS_NUMBER];
|
||||
|
||||
for(int im=0;im<nm;im++) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef VERBOSE
|
||||
cout << " starting measurement "<< im << " of " << nm << endl;
|
||||
#endif
|
||||
|
||||
//cout << "data thread started " << endl;
|
||||
int np=1;
|
||||
if (*numberOfPositions>0)
|
||||
np=*numberOfPositions;
|
||||
|
||||
int ns0=1;
|
||||
if (*actionMask & (1 << MAX_ACTIONS)) {
|
||||
ns0=nScanSteps[0];
|
||||
}
|
||||
|
||||
if (ns0<1)
|
||||
ns0=1;
|
||||
|
||||
int ns1=1;
|
||||
if (*actionMask & (1 << (MAX_ACTIONS+1))) {
|
||||
ns1=nScanSteps[1];
|
||||
}
|
||||
|
||||
if (ns1<1)
|
||||
ns1=1;
|
||||
|
||||
|
||||
//loop measurements
|
||||
|
||||
pthread_mutex_lock(&mp);
|
||||
setStartIndex(*fileIndex);
|
||||
pthread_mutex_unlock(&mp);
|
||||
|
||||
//cout << "action at start" << endl;
|
||||
if (*stoppedFlag==0) {
|
||||
@ -166,14 +161,14 @@ void slsDetectorUtils::acquire(int delflag){
|
||||
} else
|
||||
break;
|
||||
|
||||
currentPositionIndex=0;
|
||||
ResetPositionIndex();
|
||||
|
||||
for (int ip=0; ip<np; ip++) {
|
||||
// cout << "positions " << endl;
|
||||
if (*stoppedFlag==0) {
|
||||
if (*numberOfPositions>0) {
|
||||
if (getNumberOfPositions()>0) {
|
||||
moveDetector(detPositions[ip]);
|
||||
currentPositionIndex=ip+1;
|
||||
IncrementPositionIndex();
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "moving to position" << std::endl;
|
||||
#endif
|
||||
@ -200,23 +195,15 @@ void slsDetectorUtils::acquire(int delflag){
|
||||
|
||||
executeAction(headerBefore);
|
||||
|
||||
if (*correctionMask&(1<< ANGULAR_CONVERSION)) {
|
||||
pthread_mutex_lock(&mp);
|
||||
currentPosition=getDetectorPosition();
|
||||
posfinished=0;
|
||||
pthread_mutex_unlock(&mp);
|
||||
if (*correctionMask&(1<< ANGULAR_CONVERSION) || aclog || eclog) {
|
||||
positionFinished(0);
|
||||
setCurrentPosition(getDetectorPosition());
|
||||
}
|
||||
|
||||
if (aclog) {
|
||||
if ((*correctionMask&(1<< ANGULAR_CONVERSION))==0) {
|
||||
pthread_mutex_lock(&mp);
|
||||
currentPosition=getDetectorPosition();
|
||||
posfinished=0;
|
||||
pthread_mutex_unlock(&mp);
|
||||
}
|
||||
|
||||
aclog->addStep(currentPosition, getCurrentFileName());
|
||||
}
|
||||
|
||||
if (aclog)
|
||||
aclog->addStep(getCurrentPosition(), getCurrentFileName());
|
||||
|
||||
|
||||
if (eclog)
|
||||
eclog->addStep(setDAC(-1,THRESHOLD), getCurrentFileName());
|
||||
@ -229,16 +216,23 @@ void slsDetectorUtils::acquire(int delflag){
|
||||
}
|
||||
|
||||
startAndReadAll();
|
||||
#ifdef VERBOSE
|
||||
cout << "returned! " << endl;
|
||||
#endif
|
||||
|
||||
if (*correctionMask&(1<< I0_NORMALIZATION)) {
|
||||
if (get_i0)
|
||||
currentI0=get_i0(1,IOarg); // this is the correct i0!!!!!
|
||||
}
|
||||
#ifdef VERBOSE
|
||||
cout << "pos finished? " << endl;
|
||||
#endif
|
||||
|
||||
positionFinished(1);
|
||||
|
||||
pthread_mutex_lock(&mp);
|
||||
posfinished=1;
|
||||
pthread_mutex_unlock(&mp);
|
||||
|
||||
#ifdef VERBOSE
|
||||
cout << "done! " << endl;
|
||||
#endif
|
||||
|
||||
|
||||
if (*threadedProcessing==0){
|
||||
@ -254,15 +248,11 @@ void slsDetectorUtils::acquire(int delflag){
|
||||
|
||||
// wait until data processing thread has finished the data
|
||||
|
||||
pthread_mutex_lock(&mp);
|
||||
while (queuesize){
|
||||
pthread_mutex_unlock(&mp);
|
||||
while (dataQueueSize()){
|
||||
usleep(100000);
|
||||
pthread_mutex_lock(&mp);
|
||||
|
||||
}
|
||||
pthread_mutex_unlock(&mp);
|
||||
|
||||
pthread_mutex_lock(&mp);
|
||||
|
||||
if (*stoppedFlag==0) {
|
||||
executeAction(headerAfter);
|
||||
setLastIndex(*fileIndex);
|
||||
@ -270,7 +260,7 @@ void slsDetectorUtils::acquire(int delflag){
|
||||
setLastIndex(*fileIndex);
|
||||
break;
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&mp);
|
||||
|
||||
|
||||
if (*stoppedFlag) {
|
||||
@ -279,7 +269,9 @@ void slsDetectorUtils::acquire(int delflag){
|
||||
#endif
|
||||
break;
|
||||
} else if (ip<(np-1)) {
|
||||
pthread_mutex_lock(&mp);
|
||||
*fileIndex=setStartIndex();
|
||||
pthread_mutex_unlock(&mp);
|
||||
}
|
||||
} // loop on position finished
|
||||
|
||||
@ -296,7 +288,9 @@ void slsDetectorUtils::acquire(int delflag){
|
||||
#endif
|
||||
break;
|
||||
} else if (is1<(ns1-1)) {
|
||||
pthread_mutex_lock(&mp);
|
||||
*fileIndex=setStartIndex();
|
||||
pthread_mutex_unlock(&mp);
|
||||
}
|
||||
}
|
||||
|
||||
@ -309,12 +303,16 @@ void slsDetectorUtils::acquire(int delflag){
|
||||
#endif
|
||||
break;
|
||||
} else if (is0<(ns0-1)) {
|
||||
*fileIndex=setStartIndex();
|
||||
pthread_mutex_lock(&mp);
|
||||
*fileIndex=setStartIndex();
|
||||
pthread_mutex_unlock(&mp);
|
||||
}
|
||||
|
||||
} //end scan0 loop is0
|
||||
|
||||
*fileIndex=setLastIndex();
|
||||
pthread_mutex_lock(&mp);
|
||||
*fileIndex=setLastIndex();
|
||||
pthread_mutex_unlock(&mp);
|
||||
if (*stoppedFlag==0) {
|
||||
executeAction(stopScript);
|
||||
} else
|
||||
@ -335,9 +333,7 @@ void slsDetectorUtils::acquire(int delflag){
|
||||
|
||||
// waiting for the data processing thread to finish!
|
||||
if (*threadedProcessing) {
|
||||
pthread_mutex_lock(&mp);
|
||||
jointhread=1;
|
||||
pthread_mutex_unlock(&mp);
|
||||
setJoinThread(1);
|
||||
pthread_join(dataProcessingThread, &status);
|
||||
}
|
||||
|
||||
@ -349,17 +345,15 @@ void slsDetectorUtils::acquire(int delflag){
|
||||
|
||||
if (aclog)
|
||||
delete aclog;
|
||||
|
||||
|
||||
if (eclog)
|
||||
delete eclog;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (acquisition_finished)
|
||||
acquisition_finished(getCurrentProgress(),getDetectorStatus(),acqFinished_p);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -491,17 +485,21 @@ int slsDetectorUtils::setBadChannelCorrection(string fname, int &nbadtot, int *b
|
||||
|
||||
|
||||
double slsDetectorUtils::getCurrentProgress() {
|
||||
pthread_mutex_lock(&mp);
|
||||
#ifdef VERBOSE
|
||||
cout << progressIndex << " / " << totalProgress << endl;
|
||||
#endif
|
||||
return 100.*((double)progressIndex)/((double)totalProgress);
|
||||
pthread_mutex_unlock(&mp);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void slsDetectorUtils::incrementProgress() {
|
||||
pthread_mutex_lock(&mp);
|
||||
progressIndex++;
|
||||
cout << fixed << setprecision(2) << setw (6) << getCurrentProgress() << " \%";
|
||||
cout << fixed << setprecision(2) << setw (6) << 100.*((double)progressIndex)/((double)totalProgress) << " \%";
|
||||
pthread_mutex_unlock(&mp);
|
||||
#ifdef VERBOSE
|
||||
cout << endl;
|
||||
#else
|
||||
@ -838,115 +836,3 @@ int slsDetectorUtils::dumpDetectorSetup(string const fname, int level){
|
||||
}
|
||||
|
||||
|
||||
// int slsDetectorUtils::setFlatFieldCorrectionFile(string fname){
|
||||
// int tch=getTotalNumberOfChannels();
|
||||
|
||||
|
||||
|
||||
// double data[tch], xmed[tch];
|
||||
// double ffcoefficients[tch], fferrors[tch];
|
||||
// int nmed=0;
|
||||
// int idet=0, ichdet=-1;
|
||||
// char ffffname[MAX_STR_LENGTH*2];
|
||||
// int nbad=0, nch;
|
||||
// int badlist[MAX_BADCHANS];
|
||||
// int im=0;
|
||||
|
||||
// if (fname=="default") {
|
||||
// fname=string(flatFieldFile);
|
||||
// }
|
||||
// if (fname=="") {
|
||||
// #ifdef VERBOSE
|
||||
// std::cout<< "disabling flat field correction" << std::endl;
|
||||
// #endif
|
||||
// (*correctionMask)&=~(1<<FLAT_FIELD_CORRECTION);
|
||||
// // strcpy(thisMultiDetector->flatFieldFile,"none");
|
||||
|
||||
// setFlatFieldCorrection(NULL, NULL);
|
||||
// } else {
|
||||
|
||||
// #ifdef VERBOSE
|
||||
// std::cout<< "Setting flat field correction from file " << fname << std::endl;
|
||||
// #endif
|
||||
// sprintf(ffffname,"%s/%s",flatFieldDir,fname.c_str());
|
||||
// nch=readDataFile(string(ffffname),data);
|
||||
|
||||
// if (nch>tch)
|
||||
// nch=tch;
|
||||
|
||||
// if (nch>0) {
|
||||
// strcpy(flatFieldFile,fname.c_str());
|
||||
|
||||
|
||||
// nbad=0;
|
||||
// for (int ichan=0; ichan<nch; ichan++) {
|
||||
|
||||
// if (data[ichan]>0) {
|
||||
// /* add to median */
|
||||
// im=0;
|
||||
// while ((im<nmed) && (xmed[im]<data[ichan]))
|
||||
// im++;
|
||||
// for (int i=nmed; i>im; i--)
|
||||
// xmed[i]=xmed[i-1];
|
||||
// xmed[im]=data[ichan];
|
||||
// nmed++;
|
||||
// } else {
|
||||
// if (nbad<MAX_BADCHANS) {
|
||||
// badlist[nbad]=ichan;
|
||||
// nbad++;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
// if (nmed>1 && xmed[nmed/2]>0) {
|
||||
// #ifdef VERBOSE
|
||||
// std::cout<< "Flat field median is " << xmed[nmed/2] << " calculated using "<< nmed << " points" << std::endl;
|
||||
// #endif
|
||||
|
||||
// thisMultiDetector->correctionMask|=(1<<FLAT_FIELD_CORRECTION);
|
||||
|
||||
// // add to ff coefficients and errors of single detectors
|
||||
|
||||
|
||||
|
||||
|
||||
// for (int ichan=0; ichan<nch; ichan++) {
|
||||
|
||||
// setFlatFieldCorrection(ffcoefficients, fferrors);
|
||||
|
||||
// if (data[ichan]>0) {
|
||||
// ffcoefficients[ichan]=xmed[nmed/2]/data[ichan];
|
||||
// fferrors[ichan]=ffcoefficients[ichan]*sqrt(data[ichan])/data[ichan];
|
||||
// } else {
|
||||
// ffcoefficients[ichan]=0.;
|
||||
// fferrors[ichan]=1.;
|
||||
// }
|
||||
|
||||
// }
|
||||
|
||||
// setFlatFieldCorrection(ffcoefficients, fferrors);
|
||||
|
||||
|
||||
// } else {
|
||||
// std::cout<< "Flat field data from file " << fname << " are not valid (" << nmed << "///" << xmed[nmed/2] << std::endl;
|
||||
// thisMultiDetector->correctionMask&=~(1<<FLAT_FIELD_CORRECTION);
|
||||
// for (int i=0; i<thisMultiDetector->numberOfDetectors; i++) {
|
||||
// if (detectors[i])
|
||||
// detectors[i]->setFlatFieldCorrection(NULL, NULL);
|
||||
// }
|
||||
// return -1;
|
||||
// }
|
||||
// } else {
|
||||
// std::cout<< "Flat field from file " << fname << " is not valid " << nch << std::endl;
|
||||
// thisMultiDetector->correctionMask&=~(1<<FLAT_FIELD_CORRECTION);
|
||||
// for (int i=0; i<thisMultiDetector->numberOfDetectors; i++) {
|
||||
// if (detectors[i])
|
||||
// detectors[i]->setFlatFieldCorrection(NULL, NULL);
|
||||
// }
|
||||
// return -1;
|
||||
// }
|
||||
// }
|
||||
// return thisMultiDetector->correctionMask&(1<<FLAT_FIELD_CORRECTION);
|
||||
// }
|
||||
|
||||
|
@ -50,11 +50,9 @@ using namespace std;
|
||||
(used in the PSi command line interface)
|
||||
*/
|
||||
|
||||
//class postProcessing;
|
||||
|
||||
class slsDetectorUtils : public slsDetectorActions, public postProcessing {
|
||||
|
||||
//public postProcessing
|
||||
|
||||
public:
|
||||
|
||||
@ -599,7 +597,7 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
|
||||
detectorSettings *currentSettings;
|
||||
int *currentThresholdEV;
|
||||
|
||||
|
||||
|
||||
int totalProgress;
|
||||
|
||||
int progressIndex;
|
||||
|
Reference in New Issue
Block a user