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

@ -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
}
delete [] retval;
retval=NULL;
if (retval==NULL) {
delete [] retval;
}
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;
delete [] retval;
retval=NULL;
if (retval==NULL) {
delete [] retval;
}
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];
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 (binma<ang) {
ibin++;
binmi+=binsize;
binma+=binsize;
if (angold<=ang) {
while (binma<ang) {
ibin++;
binmi+=binsize;
binma+=binsize;
}
} else {
while (binmi>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;
}