mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-26 16:20:03 +02:00
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:
parent
bc8b0860b4
commit
e3ca421c3c
@ -38,15 +38,13 @@ picassoServer: $(SRC_MYTHEN_SVC)
|
|||||||
|
|
||||||
|
|
||||||
package: $(OBJS)
|
package: $(OBJS)
|
||||||
echo $(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/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
|
|
||||||
ar rcs libSlsDetector.a $(OBJS)
|
ar rcs libSlsDetector.a $(OBJS)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf libSlsDetector.so.1 libSlsDetector.so.1.0.1 libSlsDetector.so core docs/* $(OBJS)
|
rm -rf libSlsDetector.a libSlsDetector.so core docs/* $(OBJS)
|
||||||
#objs/*
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
lib: package
|
lib: package
|
||||||
|
|
||||||
|
@ -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
|
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)
|
doc: $(SRC_H) $(SRC_CLNT)
|
||||||
doxygen doxy.config
|
doxygen doxy.config
|
||||||
@ -34,17 +35,11 @@ picassoServer: $(SRC_MYTHEN_SVC)
|
|||||||
|
|
||||||
package: $(OBJS)
|
package: $(OBJS)
|
||||||
$(CXX) -shared -Wl,-soname,libSlsDetector.so -o libSlsDetector.so $(OBJS) -lc $(INCLUDES) $(FLAGS) $(EPICSFLAGS)
|
$(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)
|
ar rcs libSlsDetector.a $(OBJS)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
clean:
|
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
|
lib: package
|
||||||
|
@ -973,18 +973,18 @@ int* multiSlsDetector::getDataFromDetector() {
|
|||||||
|
|
||||||
for (int id=0; id<thisMultiDetector->numberOfDetectors; id++) {
|
for (int id=0; id<thisMultiDetector->numberOfDetectors; id++) {
|
||||||
if (detectors[id]) {
|
if (detectors[id]) {
|
||||||
retdet=detectors[id]->getDataFromDetector();
|
retdet=detectors[id]->getDataFromDetector(p);
|
||||||
n=detectors[id]->getDataBytes();
|
n=detectors[id]->getDataBytes();
|
||||||
if (retdet) {
|
if (retdet) {
|
||||||
nodata=0;
|
nodata=0;
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
cout << "Detector " << id << " returned " << n << " bytes " << endl;
|
cout << "Detector " << id << " returned " << n << " bytes " << endl;
|
||||||
#endif
|
#endif
|
||||||
memcpy(p,retdet,n);
|
// memcpy(p,retdet,n);
|
||||||
#ifdef VERBOSE
|
//#ifdef VERBOSE
|
||||||
cout << "Copied to pointer "<< p << endl;
|
//cout << "Copied to pointer "<< p << endl;
|
||||||
#endif
|
//#endif
|
||||||
delete [] retdet;
|
// delete [] retdet;
|
||||||
} else {
|
} else {
|
||||||
nodatadet=id;
|
nodatadet=id;
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
@ -1004,7 +1004,6 @@ int* multiSlsDetector::getDataFromDetector() {
|
|||||||
#endif
|
#endif
|
||||||
detectors[id]->stopAcquisition();
|
detectors[id]->stopAcquisition();
|
||||||
while ((retdet=detectors[id]->getDataFromDetector())) {
|
while ((retdet=detectors[id]->getDataFromDetector())) {
|
||||||
|
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
cout << "Detector "<< id << " still sent data " << endl;
|
cout << "Detector "<< id << " still sent data " << endl;
|
||||||
#endif
|
#endif
|
||||||
@ -2032,7 +2031,15 @@ float* multiSlsDetector::convertAngles(float pos) {
|
|||||||
for (int idet=0; idet<thisMultiDetector->numberOfDetectors; idet++) {
|
for (int idet=0; idet<thisMultiDetector->numberOfDetectors; idet++) {
|
||||||
|
|
||||||
if (detectors[idet]) {
|
if (detectors[idet]) {
|
||||||
|
#ifdef EPICS
|
||||||
|
// cout << "convert angle det " << idet << endl;
|
||||||
|
if (idet<2)
|
||||||
|
#endif
|
||||||
p=detectors[idet]->convertAngles(pos);
|
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++) {
|
for (int ich=0; ich<detectors[idet]->getTotalNumberOfChannels(); ich++) {
|
||||||
ang[choff+ich]=p[ich];
|
ang[choff+ich]=p[ich];
|
||||||
}
|
}
|
||||||
|
@ -3009,10 +3009,17 @@ int* slsDetector::readFrame(){
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
int* slsDetector::getDataFromDetector(){
|
int* slsDetector::getDataFromDetector(int *retval){
|
||||||
int nel=thisDetector->dataBytes/sizeof(int);
|
int nel=thisDetector->dataBytes/sizeof(int);
|
||||||
int n;
|
int n;
|
||||||
int* retval=new int[nel];
|
|
||||||
|
|
||||||
|
|
||||||
|
// int* retval=new int[nel];
|
||||||
|
|
||||||
|
if (retval==NULL)
|
||||||
|
retval=new int[nel];
|
||||||
|
|
||||||
int ret=FAIL;
|
int ret=FAIL;
|
||||||
char mess[100]="Nothing";
|
char mess[100]="Nothing";
|
||||||
|
|
||||||
@ -3035,8 +3042,10 @@ int* slsDetector::getDataFromDetector(){
|
|||||||
std::cout<< "Detector successfully returned: " << mess << " " << n << std::endl;
|
std::cout<< "Detector successfully returned: " << mess << " " << n << std::endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
if (retval==NULL) {
|
||||||
delete [] retval;
|
delete [] retval;
|
||||||
retval=NULL;
|
}
|
||||||
|
return NULL;
|
||||||
} else {
|
} else {
|
||||||
n=controlSocket->ReceiveDataOnly(retval,thisDetector->dataBytes);
|
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;
|
std::cout<< "wrong data size received: received " << n << " but expected " << thisDetector->dataBytes << std::endl;
|
||||||
thisDetector->stoppedFlag=1;
|
thisDetector->stoppedFlag=1;
|
||||||
ret=FAIL;
|
ret=FAIL;
|
||||||
|
if (retval==NULL) {
|
||||||
delete [] retval;
|
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];
|
float *ang=new float[thisDetector->nChans*thisDetector->nChips*thisDetector->nMods];
|
||||||
for (int ip=0; ip<thisDetector->nChans*thisDetector->nChips*thisDetector->nMods; ip++) {
|
for (int ip=0; ip<thisDetector->nChans*thisDetector->nChips*thisDetector->nMods; ip++) {
|
||||||
imod=ip/(thisDetector->nChans*thisDetector->nChips);
|
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;
|
return ang;
|
||||||
}
|
}
|
||||||
|
@ -276,6 +276,7 @@ typedef struct sharedSlsDetector {
|
|||||||
|
|
||||||
using slsDetectorUtils::readAngularConversion;
|
using slsDetectorUtils::readAngularConversion;
|
||||||
using slsDetectorUtils::writeAngularConversion;
|
using slsDetectorUtils::writeAngularConversion;
|
||||||
|
// using slsDetectorBase::getDataFromDetector;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -1313,7 +1314,10 @@ typedef struct sharedSlsDetector {
|
|||||||
\returns pointer to the data (or NULL if failed)
|
\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
|
/** returns if the detector is Master, slave or nothing
|
||||||
\param flag can be GET_MASTER, NO_MASTER, IS_MASTER, IS_SLAVE
|
\param flag can be GET_MASTER, NO_MASTER, IS_MASTER, IS_SLAVE
|
||||||
|
@ -537,9 +537,14 @@ int slsDetectorUtils::readAngularConversion( ifstream& infile, int nmod, angleCo
|
|||||||
angOff[nm].eoffset=eoff;
|
angOff[nm].eoffset=eoff;
|
||||||
} else
|
} else
|
||||||
break;
|
break;
|
||||||
|
//cout << nm<<" " << angOff[nm].offset << endl;
|
||||||
nm++;
|
nm++;
|
||||||
if (nm>=nmod)
|
if (nm>=nmod)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
return nm;
|
return nm;
|
||||||
}
|
}
|
||||||
@ -620,7 +625,7 @@ int slsDetectorUtils::addToMerging(float *p1, float *v1, float *e1, float *mp,
|
|||||||
float binmi=-180., binma;
|
float binmi=-180., binma;
|
||||||
int ibin=0;
|
int ibin=0;
|
||||||
// int imod;
|
// int imod;
|
||||||
float ang=0;
|
float ang=0, angold;
|
||||||
|
|
||||||
|
|
||||||
binmi=-180.;
|
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;
|
cout << "pointer to badchan mask is " << badChanMask << endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (angDir>0) {
|
// if (angDir>0) {
|
||||||
for (int ip=0; ip<nchans; ip++) {
|
for (int ip=0; ip<nchans; ip++) {
|
||||||
if ((cm)&(1<< DISCARD_BAD_CHANNELS)) {
|
if ((cm)&(1<< DISCARD_BAD_CHANNELS)) {
|
||||||
if (badChanMask[ip]) {
|
if (badChanMask[ip]) {
|
||||||
@ -640,38 +645,25 @@ int slsDetectorUtils::addToMerging(float *p1, float *v1, float *e1, float *mp,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
ang=p1[ip];
|
ang=p1[ip];
|
||||||
|
if (ip==0)
|
||||||
|
angold=p1[ip];
|
||||||
|
|
||||||
|
|
||||||
|
if (angold<=ang) {
|
||||||
while (binma<ang) {
|
while (binma<ang) {
|
||||||
ibin++;
|
ibin++;
|
||||||
binmi+=binsize;
|
binmi+=binsize;
|
||||||
binma+=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 {
|
} else {
|
||||||
for (int ip=nchans-1; ip>=0; ip--) {
|
while (binmi>ang) {
|
||||||
if ((cm)&(1<< DISCARD_BAD_CHANNELS)) {
|
ibin--;
|
||||||
if (badChanMask[ip])
|
binmi-=binsize;
|
||||||
continue;
|
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;
|
mp[ibin]+=ang;
|
||||||
mv[ibin]+=v1[ip];
|
mv[ibin]+=v1[ip];
|
||||||
if (e1)
|
if (e1)
|
||||||
@ -682,7 +674,32 @@ int slsDetectorUtils::addToMerging(float *p1, float *v1, float *e1, float *mp,
|
|||||||
} else
|
} else
|
||||||
return FAIL;
|
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;
|
return OK;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -124,8 +124,14 @@ float angle(int ichan, float encoder, float totalOffset, float conv_r, float cen
|
|||||||
(void) tilt; /* to avoid warning: unused parameter */
|
(void) tilt; /* to avoid warning: unused parameter */
|
||||||
float ang;
|
float ang;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ang=180./PI*(center*conv_r+atan((float)(ichan-center)*conv_r))+encoder+totalOffset+offset;
|
ang=180./PI*(center*conv_r+atan((float)(ichan-center)*conv_r))+encoder+totalOffset+offset;
|
||||||
|
|
||||||
|
|
||||||
|
cout <<"***" << offset << " " << ang << endl;
|
||||||
|
|
||||||
|
|
||||||
return direction*ang;
|
return direction*ang;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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;
|
ang=180./PI*(center*conv_r+atan((float)(ichan-center)*conv_r))+encoder+totalOffset+offset;
|
||||||
|
|
||||||
|
|
||||||
|
// printf("*** %f %f\n",offset,ang);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return direction*ang;
|
return direction*ang;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user