faster acquisition for multidetector and angualr data merging independent of angular direction

git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@156 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
x04sa 2012-03-22 13:25:19 +00:00
parent bc8b0860b4
commit e3ca421c3c
8 changed files with 117 additions and 65 deletions

View File

@ -38,15 +38,13 @@ picassoServer: $(SRC_MYTHEN_SVC)
package: $(OBJS)
echo $(OBJS)
$(CXX) -shared -Wl,-soname,libSlsDetector.so.1 -o libSlsDetector.so.1.0.1 objs/slsDetector.o objs/slsDetectorUtils.o objs/slsDetectorCommand.o objs/multiSlsDetector.o objs/usersFunctions.o objs/MySocketTCP.o -lc $(INCLUDES) $(FLAGS) $(EPICSFLAGS)
ln -sf libSlsDetector.so libSlsDetector.so.1
ln -sf libSlsDetector.so libSlsDetector.so.1.0.1
$(CXX) -shared -Wl,-soname,libSlsDetector.so -o libSlsDetector.so $(OBJS) -lc $(INCLUDES) $(FLAGS) $(EPICSFLAGS)
ar rcs libSlsDetector.a $(OBJS)
clean:
rm -rf libSlsDetector.so.1 libSlsDetector.so.1.0.1 libSlsDetector.so core docs/* $(OBJS)
#objs/*
rm -rf libSlsDetector.a libSlsDetector.so core docs/* $(OBJS)
#-------------------------------------------------------------------------------
lib: package

View File

@ -12,7 +12,8 @@ OBJS = $(SRC_CLNT:.cpp=.o)
SRC_MYTHEN_SVC = mythenDetectorServer/server.c mythenDetectorServer/server_funcs.c mythenDetectorServer/communication_funcs.c mythenDetectorServer/firmware_funcs.c mythenDetectorServer/mcb_funcs.c mythenDetectorServer/trimming_funcs.c
all: package doc
all: package $(SRC_CLNT)
doc: $(SRC_H) $(SRC_CLNT)
doxygen doxy.config
@ -34,17 +35,11 @@ picassoServer: $(SRC_MYTHEN_SVC)
package: $(OBJS)
$(CXX) -shared -Wl,-soname,libSlsDetector.so -o libSlsDetector.so $(OBJS) -lc $(INCLUDES) $(FLAGS) $(EPICSFLAGS)
# $(CXX) -shared -Wl,-soname,libSlsDetector.so.1 -o libSlsDetector.so.1.0.1 objs/slsDetector.o $(OBJS) -lc $(INCLUDES) $(FLAGS) $(EPICSFLAGS)
# ln -sf libSlsDetector.so libSlsDetector.so.1
# ln -sf libSlsDetector.so libSlsDetector.so.1.0.1
ar rcs libSlsDetector.a $(OBJS)
clean:
rm -rf libSlsDetector.so.1 libSlsDetector.so.1.0.1 libSlsDetector.so core objs/* docs/*
rm -rf libSlsDetector.so libSlsDetector.a core $(OBJS) docs/*
#-------------------------------------------------------------------------------
lib: package

View File

@ -973,18 +973,18 @@ int* multiSlsDetector::getDataFromDetector() {
for (int id=0; id<thisMultiDetector->numberOfDetectors; id++) {
if (detectors[id]) {
retdet=detectors[id]->getDataFromDetector();
retdet=detectors[id]->getDataFromDetector(p);
n=detectors[id]->getDataBytes();
if (retdet) {
nodata=0;
#ifdef VERBOSE
cout << "Detector " << id << " returned " << n << " bytes " << endl;
#endif
memcpy(p,retdet,n);
#ifdef VERBOSE
cout << "Copied to pointer "<< p << endl;
#endif
delete [] retdet;
// memcpy(p,retdet,n);
//#ifdef VERBOSE
//cout << "Copied to pointer "<< p << endl;
//#endif
// delete [] retdet;
} else {
nodatadet=id;
#ifdef VERBOSE
@ -1004,7 +1004,6 @@ int* multiSlsDetector::getDataFromDetector() {
#endif
detectors[id]->stopAcquisition();
while ((retdet=detectors[id]->getDataFromDetector())) {
#ifdef VERBOSE
cout << "Detector "<< id << " still sent data " << endl;
#endif
@ -2032,7 +2031,15 @@ float* multiSlsDetector::convertAngles(float pos) {
for (int idet=0; idet<thisMultiDetector->numberOfDetectors; idet++) {
if (detectors[idet]) {
#ifdef EPICS
// cout << "convert angle det " << idet << endl;
if (idet<2)
#endif
p=detectors[idet]->convertAngles(pos);
#ifdef EPICS
else //////////// GOOD ONLY AT THE BEAMLINE!!!!!!!!!!!!!
p=detectors[idet]->convertAngles(0);
#endif
for (int ich=0; ich<detectors[idet]->getTotalNumberOfChannels(); ich++) {
ang[choff+ich]=p[ich];
}

View File

@ -3009,10 +3009,17 @@ int* slsDetector::readFrame(){
int* slsDetector::getDataFromDetector(){
int* slsDetector::getDataFromDetector(int *retval){
int nel=thisDetector->dataBytes/sizeof(int);
int n;
int* retval=new int[nel];
// int* retval=new int[nel];
if (retval==NULL)
retval=new int[nel];
int ret=FAIL;
char mess[100]="Nothing";
@ -3035,8 +3042,10 @@ int* slsDetector::getDataFromDetector(){
std::cout<< "Detector successfully returned: " << mess << " " << n << std::endl;
#endif
}
if (retval==NULL) {
delete [] retval;
retval=NULL;
}
return NULL;
} else {
n=controlSocket->ReceiveDataOnly(retval,thisDetector->dataBytes);
@ -3047,8 +3056,10 @@ int* slsDetector::getDataFromDetector(){
std::cout<< "wrong data size received: received " << n << " but expected " << thisDetector->dataBytes << std::endl;
thisDetector->stoppedFlag=1;
ret=FAIL;
if (retval==NULL) {
delete [] retval;
retval=NULL;
}
return NULL;
}
}
@ -4565,7 +4576,16 @@ float* slsDetector::convertAngles(float pos) {
float *ang=new float[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);
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
);
// cout << imod << " " << thisDetector->angOff[imod].offset << " " << ang[ip] << endl;
}
return ang;
}

View File

@ -276,6 +276,7 @@ typedef struct sharedSlsDetector {
using slsDetectorUtils::readAngularConversion;
using slsDetectorUtils::writeAngularConversion;
// using slsDetectorBase::getDataFromDetector;
@ -1313,7 +1314,10 @@ typedef struct sharedSlsDetector {
\returns pointer to the data (or NULL if failed)
*/
int* getDataFromDetector();
int* getDataFromDetector(int *retval=NULL);
//int*
/** returns if the detector is Master, slave or nothing
\param flag can be GET_MASTER, NO_MASTER, IS_MASTER, IS_SLAVE

View File

@ -537,9 +537,14 @@ int slsDetectorUtils::readAngularConversion( ifstream& infile, int nmod, angleCo
angOff[nm].eoffset=eoff;
} else
break;
//cout << nm<<" " << angOff[nm].offset << endl;
nm++;
if (nm>=nmod)
break;
}
return nm;
}
@ -620,7 +625,7 @@ int slsDetectorUtils::addToMerging(float *p1, float *v1, float *e1, float *mp,
float binmi=-180., binma;
int ibin=0;
// int imod;
float ang=0;
float ang=0, angold;
binmi=-180.;
@ -629,7 +634,7 @@ int slsDetectorUtils::addToMerging(float *p1, float *v1, float *e1, float *mp,
cout << "pointer to badchan mask is " << badChanMask << endl;
#endif
if (angDir>0) {
// if (angDir>0) {
for (int ip=0; ip<nchans; ip++) {
if ((cm)&(1<< DISCARD_BAD_CHANNELS)) {
if (badChanMask[ip]) {
@ -640,38 +645,25 @@ int slsDetectorUtils::addToMerging(float *p1, float *v1, float *e1, float *mp,
}
}
ang=p1[ip];
if (ip==0)
angold=p1[ip];
if (angold<=ang) {
while (binma<ang) {
ibin++;
binmi+=binsize;
binma+=binsize;
}
if (ibin<(360./binsize)) {
mp[ibin]+=ang;
mv[ibin]+=v1[ip];
if (e1)
me[ibin]+=(e1[ip]*e1[ip]);
else
me[ibin]+=v1[ip];
mm[ibin]++;
} else
return FAIL;
}
} else {
for (int ip=nchans-1; ip>=0; ip--) {
if ((cm)&(1<< DISCARD_BAD_CHANNELS)) {
if (badChanMask[ip])
continue;
while (binmi>ang) {
ibin--;
binmi-=binsize;
binma-=binsize;
}
while (binma<ang) {
ibin++;
binmi+=binsize;
binma+=binsize;
}
if (ibin<(360./binsize)) {
if (ibin<(360./binsize) && ibin>=0) {
angold=ang;
mp[ibin]+=ang;
mv[ibin]+=v1[ip];
if (e1)
@ -682,7 +674,32 @@ int slsDetectorUtils::addToMerging(float *p1, float *v1, float *e1, float *mp,
} else
return FAIL;
}
}
// } else {
// for (int ip=nchans-1; ip>=0; ip--) {
// if ((cm)&(1<< DISCARD_BAD_CHANNELS)) {
// if (badChanMask[ip])
// continue;
// }
// while (binma<ang) {
// ibin++;
// binmi+=binsize;
// binma+=binsize;
// }
// if (ibin<(360./binsize)) {
// mp[ibin]+=ang;
// mv[ibin]+=v1[ip];
// if (e1)
// me[ibin]+=(e1[ip]*e1[ip]);
// else
// me[ibin]+=v1[ip];
// mm[ibin]++;
// } else
// return FAIL;
// }
// }
return OK;
}

View File

@ -124,8 +124,14 @@ float angle(int ichan, float encoder, float totalOffset, float conv_r, float cen
(void) tilt; /* to avoid warning: unused parameter */
float ang;
ang=180./PI*(center*conv_r+atan((float)(ichan-center)*conv_r))+encoder+totalOffset+offset;
cout <<"***" << offset << " " << ang << endl;
return direction*ang;
}

View File

@ -126,6 +126,11 @@ float angle(int ichan, float encoder, float totalOffset, float conv_r, float cen
ang=180./PI*(center*conv_r+atan((float)(ichan-center)*conv_r))+encoder+totalOffset+offset;
// printf("*** %f %f\n",offset,ang);
return direction*ang;
}