From ed84d21da037cefbf2f4c2ae568e56d4669b4bb6 Mon Sep 17 00:00:00 2001 From: bergamaschi Date: Fri, 1 Jun 2012 13:57:31 +0000 Subject: [PATCH] solved bug in angular conversion git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@186 951219d9-93cf-4727-9268-0efd64621fa3 --- .../slsDetectorAnalysis/angularConversion.cpp | 53 +++++++++++++------ .../slsDetectorAnalysis/angularConversion.h | 2 +- .../slsDetectorAnalysis/postProcessing.cpp | 7 +-- 3 files changed, 39 insertions(+), 23 deletions(-) diff --git a/slsDetectorSoftware/slsDetectorAnalysis/angularConversion.cpp b/slsDetectorSoftware/slsDetectorAnalysis/angularConversion.cpp index f1185f54c..00041981a 100644 --- a/slsDetectorSoftware/slsDetectorAnalysis/angularConversion.cpp +++ b/slsDetectorSoftware/slsDetectorAnalysis/angularConversion.cpp @@ -204,13 +204,17 @@ int angularConversion::finalizeMerging(float *mp, float *mv, float *me, int *mm, int np=0; for (int ibin=0; ibin0) { + +#ifdef VERBOSE + cout << "finalize " << ibin << " "<< mm[ibin] << " " << mp[ibin]<< mv[ibin] << me[ibin] << endl; +#endif mp[np]=mp[ibin]/mm[ibin]; mv[np]=mv[ibin]/mm[ibin]; - me[np]=me[ibin]/mm[ibin]; - me[np]=sqrt(me[ibin]); - mm[np]=mm[ibin]; - np++; - } + me[np]=me[ibin]/mm[ibin]; + me[np]=sqrt(me[ibin]); + mm[np]=mm[ibin]; + np++; + } } return np; } @@ -218,6 +222,7 @@ int angularConversion::finalizeMerging(float *mp, float *mv, float *me, int *mm, //static int angularConversion::addToMerging(float *p1, float *v1, float *e1, float *mp, float *mv,float *me, int *mm, int nchans, float binsize,int nbins, int *badChanMask ) { + float binmi=-180.; int ibin=0; @@ -238,23 +243,24 @@ int angularConversion::addToMerging(float *p1, float *v1, float *e1, float *mp, if (nchans==0) return FAIL; - if (binsize==0) + if (binsize<=0) return FAIL; - if (nbins==0) + + if (nbins<=0) return FAIL; - for (int ip=0; ip=0) { mp[ibin]+=p1[ip]; mv[ibin]+=v1[ip]; @@ -263,6 +269,10 @@ int angularConversion::addToMerging(float *p1, float *v1, float *e1, float *mp, else me[ibin]+=v1[ip]; mm[ibin]++; + +#ifdef VERBOSE + cout << "add " << ibin << " "<< mm[ibin] << " " << mp[ibin]<< mv[ibin] << me[ibin] << endl; +#endif } else return FAIL; } @@ -287,6 +297,7 @@ int angularConversion::deleteMerging() { int angularConversion::resetMerging() { + getAngularConversionParameter(BIN_SIZE); mergingBins=new float[nBins]; @@ -304,6 +315,7 @@ int angularConversion::resetMerging() { } int angularConversion::resetMerging(float *mp, float *mv, float *me, int *mm) { + getAngularConversionParameter(BIN_SIZE); if (nBins) return resetMerging(mp, mv, me, mm,nBins); else @@ -327,7 +339,6 @@ int angularConversion::finalizeMerging() { int angularConversion::finalizeMerging(float *mp, float *mv, float *me, int *mm) { - if (nBins) return finalizeMerging(mp, mv, me, mm, nBins); else @@ -335,7 +346,7 @@ int angularConversion::finalizeMerging(float *mp, float *mv, float *me, int *mm) } int angularConversion::addToMerging(float *p1, float *v1, float *e1, int *badChanMask ) { - + return addToMerging(p1,v1,e1,mergingBins,mergingCounts, mergingErrors, mergingMultiplicity, badChanMask); @@ -344,20 +355,24 @@ int angularConversion::addToMerging(float *p1, float *v1, float *e1, int *badCh int angularConversion::addToMerging(float *p1, float *v1, float *e1, float *mp, float *mv,float *me, int *mm, int *badChanMask ) { - int del=0; - - if (*binSize==0) - return FAIL; - if (nBins==0) + if (getAngularConversionParameter(BIN_SIZE)==0){ + cout << "no bin size " << endl; return FAIL; + } + + if (nBins==0) { + cout << "no bins " << endl; + return FAIL; + } if (p1==NULL) { del=1; p1=convertAngles(); } + int ret=addToMerging(p1, v1, e1, mp, mv,me, mm,getTotalNumberOfChannels(), *binSize,nBins, badChanMask ); @@ -429,7 +444,11 @@ float angularConversion::getAngularConversionParameter(angleConversionParameter return *globalOffset; case FINE_OFFSET: return *fineOffset; - case BIN_SIZE: + case BIN_SIZE: + if (*binSize>0) + nBins=360./(*binSize); + else + nBins=0; return *binSize; case MOVE_FLAG: if (moveFlag) diff --git a/slsDetectorSoftware/slsDetectorAnalysis/angularConversion.h b/slsDetectorSoftware/slsDetectorAnalysis/angularConversion.h index a0b0627cf..afb05a840 100644 --- a/slsDetectorSoftware/slsDetectorAnalysis/angularConversion.h +++ b/slsDetectorSoftware/slsDetectorAnalysis/angularConversion.h @@ -227,7 +227,7 @@ class angularConversion : public virtual slsDetectorBase { \param bs bin size to be set \returns actual bin size */ - float setBinSize(float bs){return setAngularConversionParameter(BIN_SIZE,bs);}; + float setBinSize(float bs){if (bs>0) nBins=360/bs; return setAngularConversionParameter(BIN_SIZE,bs);}; /** get detector bin size diff --git a/slsDetectorSoftware/slsDetectorAnalysis/postProcessing.cpp b/slsDetectorSoftware/slsDetectorAnalysis/postProcessing.cpp index 2b82d5c22..7847e575e 100644 --- a/slsDetectorSoftware/slsDetectorAnalysis/postProcessing.cpp +++ b/slsDetectorSoftware/slsDetectorAnalysis/postProcessing.cpp @@ -181,7 +181,6 @@ void postProcessing::doProcessing(float *lfdata, int delflag, string fname) { // ; // } else { - float *rcdata=NULL, *rcerr=NULL; @@ -235,7 +234,7 @@ void postProcessing::doProcessing(float *lfdata, int delflag, string fname) { ang=convertAngles(); writeDataFile (fname+ext, ffcdata, ffcerr,ang); } - + if (*correctionMask&(1<< ANGULAR_CONVERSION) && getNumberOfPositions()>0) { #ifdef VERBOSE cout << "**************Current position index is " << getCurrentPositionIndex() << endl; @@ -252,10 +251,8 @@ void postProcessing::doProcessing(float *lfdata, int delflag, string fname) { #ifdef VERBOSE cout << "add to merging "<< getCurrentPositionIndex() << endl; #endif - - if (*correctionMask&(1<< ANGULAR_CONVERSION)) + addToMerging(ang, ffcdata, ffcerr, badChannelMask ); - #ifdef VERBOSE cout << getCurrentPositionIndex() << " " << getNumberOfPositions() << endl;