mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-28 17:10:03 +02:00
Added f90Interface used at SLS X04SA
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@269 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
parent
fe73d4cb92
commit
924f583be9
@ -1,21 +1,29 @@
|
|||||||
INCLUDES= -IcommonFiles -IslsDetector -IMySocketTCP -IusersFunctions -ImultiSlsDetector -IslsDetectorUtils -IslsDetectorCommand -IslsDetectorAnalysis
|
INCLUDES= -IcommonFiles -IslsDetector -IMySocketTCP -IusersFunctions -ImultiSlsDetector -IslsDetectorUtils -IslsDetectorCommand -IslsDetectorAnalysis -If90Interface
|
||||||
|
|
||||||
EPICSFLAGS=-D EPICS -I/usr/local/epics/base/include/ -I /usr/local/epics/base/include/os/Linux/ -L /usr/local/epics/base/lib/SL5-x86/ -Wl,-R/usr/local/epics/base/lib/SL5-x86 -lca -lCom
|
EPICSFLAGS=-D EPICS -I/usr/local/epics/base/include/ -I /usr/local/epics/base/include/os/Linux/ -L /usr/local/epics/base/lib/SL5-x86/ -Wl,-R/usr/local/epics/base/lib/SL5-x86 -lca -lCom
|
||||||
|
|
||||||
CFLAGS= -DC_ONLY
|
CFLAGS= -DC_ONLY
|
||||||
FLAGS= $(EPICSFLAGS)
|
FLAGS= $(EPICSFLAGS)
|
||||||
|
|
||||||
|
CC=gcc
|
||||||
CC=g++
|
CXX=g++
|
||||||
|
|
||||||
|
|
||||||
SRC_CLNT= slsDetectorAnalysis/fileIO.cpp MySocketTCP/MySocketTCP.cpp usersFunctions/usersFunctions.cpp slsDetector/slsDetectorUtils.cpp slsDetector/slsDetectorCommand.cpp slsDetectorAnalysis/angularConversion.cpp slsDetectorAnalysis/energyConversion.cpp slsDetector/slsDetectorActions.cpp slsDetectorAnalysis/postProcessing.cpp slsDetector/slsDetector.cpp multiSlsDetector/multiSlsDetector.cpp
|
SRC_CLNT= slsDetectorAnalysis/fileIO.cpp MySocketTCP/MySocketTCP.cpp usersFunctions/usersFunctions.cpp slsDetector/slsDetectorUtils.cpp slsDetector/slsDetectorCommand.cpp slsDetectorAnalysis/angularConversion.cpp slsDetectorAnalysis/energyConversion.cpp slsDetector/slsDetectorActions.cpp slsDetectorAnalysis/postProcessing.cpp slsDetector/slsDetector.cpp multiSlsDetector/multiSlsDetector.cpp f90Interface/externPostProcessing.cpp
|
||||||
|
|
||||||
OBJS = $(SRC_CLNT:.cpp=.o)
|
OBJS = $(SRC_CLNT:.cpp=.o)
|
||||||
|
|
||||||
HEADERS = $(SRC_CLNT:.cpp=.h) commonFiles/sls_detector_defs.h slsDetectorAnalysis/detectorData.h slsDetector/slsDetectorBase.h slsDetector/slsDetectorUsers.h multiSlsDetector/multiSlsDetectorCommand.h
|
HEADERS = $(SRC_CLNT:.cpp=.h) commonFiles/sls_detector_defs.h slsDetectorAnalysis/detectorData.h slsDetector/slsDetectorBase.h slsDetector/slsDetectorUsers.h multiSlsDetector/multiSlsDetectorCommand.h
|
||||||
|
|
||||||
|
|
||||||
|
LGF=/usr/lib/gcc/i386-redhat-linux/4.1.2
|
||||||
|
GCC=/usr/bin//gcc
|
||||||
|
FF=/opt/intel/intel-10.1/fc-10.1/bin/ifort
|
||||||
|
|
||||||
|
SRC_F = f90Interface/sls_detector_analysis_f.f90
|
||||||
|
|
||||||
|
OBJS_F = f90Interface/sls_detector_analysis_f.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
|
||||||
|
|
||||||
@ -43,12 +51,15 @@ picassoServer: $(SRC_MYTHEN_SVC)
|
|||||||
$(CXX) -Wall -o $@ -c $< $(INCLUDES) $(FLAGS) $(EPICSFLAGS)
|
$(CXX) -Wall -o $@ -c $< $(INCLUDES) $(FLAGS) $(EPICSFLAGS)
|
||||||
|
|
||||||
|
|
||||||
package: $(OBJS)
|
$(OBJS_F) : $(SRC_F)
|
||||||
$(CXX) -shared -Wl,-soname,libSlsDetector.so -o libSlsDetector.so $(OBJS) -lc $(INCLUDES) $(FLAGS) $(EPICSFLAGS)
|
$(FF) -c $(SRC_F)
|
||||||
ar rcs libSlsDetector.a $(OBJS)
|
|
||||||
|
package: $(OBJS) $(OBJS_F)
|
||||||
|
$(CXX) -shared -Wl,-soname,libSlsDetector.so -o libSlsDetector.so $(OBJS) $(OBJS_F) -lc $(INCLUDES) $(FLAGS) $(EPICSFLAGS)
|
||||||
|
ar rcs libSlsDetector.a $(OBJS) $(OBJS_F)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf libSlsDetector.a libSlsDetector.so core docs/* $(OBJS)
|
rm -rf libSlsDetector.a libSlsDetector.so core docs/* $(OBJS) $(OBJS_F)
|
||||||
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
|
@ -80,7 +80,7 @@ LATEX_HIDE_INDICES = YES
|
|||||||
|
|
||||||
PREDEFINED = __cplusplus
|
PREDEFINED = __cplusplus
|
||||||
|
|
||||||
INPUT = slsDetector/slsDetectorUsers.h slsDetector/slsDetectorBase.h commonFiles/sls_detector_defs.h slsDetector/slsDetector.h MySocketTCP/MySocketTCP.h usersFunctions/usersFunctions.h multiSlsDetector/multiSlsDetector.h commonFiles/sls_detector_defs.h slsDetector/slsDetectorUtils.h slsDetector/slsDetectorBase.h slsDetector/slsDetectorCommand.h slsDetector/slsDetectorActions.h multiSlsDetector/multiSlsDetector.h slsDetectorAnalysis/detectorData.h slsDetectorAnalysis/energyConversion.h slsDetectorAnalysis/postProcessing.h slsDetectorAnalysis/angularConversion.h slsDetectorAnalysis/fileIO.h multiSlsDetector/multiSlsDetectorClient.h multiSlsDetector/multiSlsDetectorCommand.h
|
INPUT = slsDetector/slsDetectorUsers.h slsDetector/slsDetectorBase.h commonFiles/sls_detector_defs.h slsDetector/slsDetector.h MySocketTCP/MySocketTCP.h usersFunctions/usersFunctions.h multiSlsDetector/multiSlsDetector.h commonFiles/sls_detector_defs.h slsDetector/slsDetectorUtils.h slsDetector/slsDetectorBase.h slsDetector/slsDetectorCommand.h slsDetector/slsDetectorActions.h multiSlsDetector/multiSlsDetector.h slsDetectorAnalysis/detectorData.h slsDetectorAnalysis/energyConversion.h slsDetectorAnalysis/postProcessing.h slsDetectorAnalysis/angularConversion.h slsDetectorAnalysis/fileIO.h multiSlsDetector/multiSlsDetectorClient.h multiSlsDetector/multiSlsDetectorCommand.h slsDetectorAnalysis/angularConversionStatic.h slsDetectorAnalysis/angleConversionConstant.h slsDetectorAnalysis/enCalLogClass.h slsDetectorAnalysis/angCalLogClass.h slsDetectorAnalysis/badChannelCorrections.h slsDetectorAnalysis/fileIOStatic.h
|
||||||
|
|
||||||
OUTPUT_DIRECTORY = docs
|
OUTPUT_DIRECTORY = docs
|
||||||
|
|
||||||
|
48
slsDetectorSoftware/f90Interface/externPostProcessing.cpp
Normal file
48
slsDetectorSoftware/f90Interface/externPostProcessing.cpp
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
#include "externPostProcessing.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <fstream>
|
||||||
|
#include <iomanip>
|
||||||
|
#include <cstring>
|
||||||
|
#include <string>
|
||||||
|
#include <sstream>
|
||||||
|
#include <queue>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int externPostProcessing::InitDataset(int *nModules,int *chPerMod,int moduleMask[],int badChans[], double ffcoeff[], double fferr[], double* tDead, double angRadius[], double angOffset[], double angCentre[], double* totalOffset, double* binSize, double *sampleX, double *sampleY)
|
||||||
|
{
|
||||||
|
|
||||||
|
init_dataset(nModules,chPerMod,moduleMask,badChans,ffcoeff,fferr,tDead,angRadius,angOffset,angCentre,totalOffset,binSize,sampleX,sampleY);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
int externPostProcessing::finalizeDataset(double ang[], double val[], double err[])
|
||||||
|
{
|
||||||
|
cout<<"Finalize Dataset"<<endl;
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
int addFrame(double data[], double *pos, double *IO, double expTime, const char *filename, int *var=0)
|
||||||
|
{
|
||||||
|
cout<<"Do Processing"<<endl;
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
int calculateFlatField(int* nModules, int badChannelMask[], double ffData[], double ffCoeff[], double ffErr[])
|
||||||
|
{
|
||||||
|
cout<<"Outputs Flat Field Coefficient and errors from the input data"<<endl;
|
||||||
|
return 0;
|
||||||
|
};
|
65
slsDetectorSoftware/f90Interface/externPostProcessing.h
Normal file
65
slsDetectorSoftware/f90Interface/externPostProcessing.h
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
#ifndef EXTERNPOSTPROCESSING_H
|
||||||
|
#define EXTERNPOSTPROCESSING_H
|
||||||
|
|
||||||
|
|
||||||
|
#include "detectorData.h"
|
||||||
|
#include "sls_detector_defs.h"
|
||||||
|
#include "slsDetectorBase_Standalone.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <fstream>
|
||||||
|
#include <iomanip>
|
||||||
|
#include <cstring>
|
||||||
|
#include <string>
|
||||||
|
#include <sstream>
|
||||||
|
#include <queue>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
|
||||||
|
void init_dataset(int *nMod, int *chPerMod, int* modMask, int *badChanMask, double *ffCoeff, double *ffErr, double *tDead, double *angRadius, double *angOffset, double *angCenter, double *totalOff, double *binSize, double * sampleX, double* sampleY);
|
||||||
|
void finalize_dataset(double *outang, double *outval, double *outerr, int *np);
|
||||||
|
void add_frame(double *data, double *pos, double *i0, char *fn, double *var);
|
||||||
|
void calculate_flat_field(int *nMod, int *chPerMod, int *modMask,int *badChanMask, double *data, double *ffc, double *fferr);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class externPostProcessing : public virtual slsDetectorBase1
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
externPostProcessing(){};
|
||||||
|
virtual ~externPostProcessing(){};
|
||||||
|
|
||||||
|
|
||||||
|
static int InitDataset(int *nModules,int *chPerMod,int moduleMask[],int badChans[], double ffcoeff[], double fferr[], double* tDead, double angRadius[], double angOffset[], double angCentre[], double* totalOffset, double* binSize, double *sampleX, double *sampleY);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int finalizeDataset(double ang[], double val[], double err[]);
|
||||||
|
|
||||||
|
int addFrame(double data[], double *pos, double *IO, double expTime, const char *filename, int *var=0);
|
||||||
|
|
||||||
|
int calculateFlatField(int* nModules, int badChannelMask[], double ffData[], double ffCoeff[], double ffErr[]);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
171
slsDetectorSoftware/f90Interface/sls_detector_analysis_f.f90
Normal file
171
slsDetectorSoftware/f90Interface/sls_detector_analysis_f.f90
Normal file
@ -0,0 +1,171 @@
|
|||||||
|
module ax
|
||||||
|
USE,INTRINSIC :: ISO_C_BINDING
|
||||||
|
IMPLICIT NONE
|
||||||
|
integer(C_LONG) :: numberofmodules,totalnumberofchannels
|
||||||
|
real(C_DOUBLE) :: numberofbins
|
||||||
|
real(C_DOUBLE) :: bincenter(360000), binvalue(360000), binerror(360000)
|
||||||
|
|
||||||
|
contains
|
||||||
|
|
||||||
|
|
||||||
|
subroutine initdataset(nmodules, chpmod, modulemask,badchanmask,ffcoeff,fferr,tdead,angradius,angoffset,angcenter, totaloffset, binsize, samplex, sampley) bind(c, name='init_dataset')
|
||||||
|
IMPLICIT NONE
|
||||||
|
integer(C_LONG), intent(IN) :: nmodules, chpmod
|
||||||
|
integer(C_LONG), intent(IN) :: modulemask(nmodules), badchanmask(nmodules*chpmod)
|
||||||
|
real(C_DOUBLE), intent(IN) :: ffcoeff(nmodules*chpmod), fferr(nmodules*chpmod)
|
||||||
|
real(C_DOUBLE), intent(IN) :: tdead, totaloffset,binsize, samplex, sampley
|
||||||
|
real(C_DOUBLE), intent(IN) :: angradius(nmodules), angoffset(nmodules), angcenter(nmodules)
|
||||||
|
integer(C_LONG) :: i
|
||||||
|
|
||||||
|
print*,'init dataset'
|
||||||
|
|
||||||
|
numberofmodules=nmodules
|
||||||
|
|
||||||
|
print*,'Number of modules:'
|
||||||
|
print*,numberofmodules
|
||||||
|
print*,'Channels per module:'
|
||||||
|
print*,chpmod
|
||||||
|
|
||||||
|
totalnumberofchannels=nmodules*chpmod
|
||||||
|
|
||||||
|
print*,'Total number of channels:'
|
||||||
|
print*,totalnumberofchannels
|
||||||
|
|
||||||
|
|
||||||
|
print*,'Modulemask:'
|
||||||
|
do i=1,nmodules
|
||||||
|
print*,i,modulemask(i)
|
||||||
|
enddo
|
||||||
|
|
||||||
|
print*,'Badchannelmask:'
|
||||||
|
do i=1,nmodules*chpmod
|
||||||
|
print*,i,badchanmask(i)
|
||||||
|
enddo
|
||||||
|
|
||||||
|
print*,'Flat field coefficients:'
|
||||||
|
do i=1,nmodules*chpmod
|
||||||
|
print*,i,ffcoeff(i),'+-',fferr(i)
|
||||||
|
enddo
|
||||||
|
|
||||||
|
print*,'Tdead:'
|
||||||
|
print*,tdead
|
||||||
|
|
||||||
|
|
||||||
|
print*,'Angular conversion coefficients:'
|
||||||
|
do i=1,nmodules
|
||||||
|
print*,i,angradius(i),angoffset(i),angcenter(i)
|
||||||
|
enddo
|
||||||
|
|
||||||
|
|
||||||
|
print*,'Total offset:'
|
||||||
|
print*,totaloffset
|
||||||
|
|
||||||
|
print*,'Bin size:'
|
||||||
|
print*,binsize
|
||||||
|
|
||||||
|
numberofbins=360./binsize
|
||||||
|
|
||||||
|
|
||||||
|
print*,'Sample displacement:'
|
||||||
|
print*,samplex, sampley
|
||||||
|
|
||||||
|
end subroutine initdataset
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
subroutine resetdataset() bind(c, name='resetDataset')
|
||||||
|
IMPLICIT NONE
|
||||||
|
|
||||||
|
print*,'reset dataset'
|
||||||
|
|
||||||
|
|
||||||
|
end subroutine resetdataset
|
||||||
|
|
||||||
|
|
||||||
|
subroutine finalizedataset(outang, outval, outerr, outnpoints) bind(c, name='finalize_dataset')
|
||||||
|
IMPLICIT NONE
|
||||||
|
integer(C_LONG), intent(OUT) :: outnpoints
|
||||||
|
real(C_DOUBLE), intent(OUT) :: outang(*), outval(*), outerr(*)
|
||||||
|
integer(C_LONG) :: i
|
||||||
|
|
||||||
|
print*,'finalize dataset'
|
||||||
|
|
||||||
|
outnpoints=numberofbins
|
||||||
|
|
||||||
|
print*,'returning points:'
|
||||||
|
do i=1,numberofbins
|
||||||
|
|
||||||
|
outang(i)=i;
|
||||||
|
outval(i)=i*100;
|
||||||
|
outerr(i)=i*0.1
|
||||||
|
|
||||||
|
print*,i,outang(i),outval(i),outerr(i)
|
||||||
|
enddo
|
||||||
|
|
||||||
|
end subroutine finalizedataset
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
subroutine addframe(data, pos, i0, fname, var) bind(c, name='add_frame')
|
||||||
|
IMPLICIT NONE
|
||||||
|
real(C_DOUBLE), intent(IN) :: data(totalnumberofchannels)
|
||||||
|
real(C_DOUBLE), intent(IN) :: pos, i0, var
|
||||||
|
character(kind=c_char), dimension(*), intent(IN) :: fname
|
||||||
|
integer :: l
|
||||||
|
integer :: i
|
||||||
|
|
||||||
|
l=0
|
||||||
|
do
|
||||||
|
if (fname(l+1) == C_NULL_CHAR) exit
|
||||||
|
l = l + 1
|
||||||
|
end do
|
||||||
|
|
||||||
|
|
||||||
|
print*,'add frame'
|
||||||
|
|
||||||
|
print*,'Filename: '
|
||||||
|
print*,fname(1:l)
|
||||||
|
|
||||||
|
print*,'Position: '
|
||||||
|
print*,pos
|
||||||
|
|
||||||
|
print*,'I0: '
|
||||||
|
print*,i0
|
||||||
|
|
||||||
|
print*,'Var: '
|
||||||
|
print*,var
|
||||||
|
|
||||||
|
print*,'Data: '
|
||||||
|
print*,data
|
||||||
|
|
||||||
|
|
||||||
|
end subroutine addframe
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
subroutine calculateflatfield(nmodules, chpmod, modulemask, badchanmask,data, ffcoeff,fferr) bind(c, name='calculate_flat_field')
|
||||||
|
|
||||||
|
IMPLICIT NONE
|
||||||
|
integer(C_LONG), intent(IN) :: nmodules, chpmod
|
||||||
|
integer(C_LONG), intent(IN) :: modulemask(nmodules), badchanmask(nmodules*chpmod)
|
||||||
|
real(C_DOUBLE), intent(IN) :: data(nmodules*chpmod)
|
||||||
|
real(C_DOUBLE), intent(OUT) :: ffcoeff(*),fferr(*)
|
||||||
|
integer(C_LONG) :: i
|
||||||
|
|
||||||
|
real(C_DOUBLE) :: ave;
|
||||||
|
|
||||||
|
print*,'calculate flat field'
|
||||||
|
|
||||||
|
do i=1,nmodules*chpmod
|
||||||
|
ffcoeff(i)=data(i)*10.
|
||||||
|
fferr(i)=i
|
||||||
|
print*,i,data(i), ffcoeff(i),fferr(i)
|
||||||
|
enddo
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
end subroutine calculateflatfield
|
||||||
|
|
||||||
|
|
||||||
|
end module ax
|
@ -35,7 +35,7 @@ class containing the methods to set/unset the angular conversion and merge the d
|
|||||||
The angular conversion itself is defined by the angle() function defined in usersFunctions.cpp
|
The angular conversion itself is defined by the angle() function defined in usersFunctions.cpp
|
||||||
|
|
||||||
*/
|
*/
|
||||||
class angularConversion : public virtual slsDetectorBase, public virtual angularConversionStatic
|
class angularConversion : public virtual slsDetectorBase, public angularConversionStatic
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -4,7 +4,9 @@
|
|||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
#include "angleConversionConstant.h"
|
||||||
|
|
||||||
|
#include "sls_detector_defs.h"
|
||||||
#include "angleFunction.h"
|
#include "angleFunction.h"
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
@ -180,7 +182,7 @@ int angularConversionStatic::resetMerging(double *mp, double *mv, double *me, in
|
|||||||
me[ibin]=0;
|
me[ibin]=0;
|
||||||
mm[ibin]=0;
|
mm[ibin]=0;
|
||||||
}
|
}
|
||||||
return OK;
|
return slsDetectorDefs::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -214,25 +216,25 @@ int angularConversionStatic::addToMerging(double *p1, double *v1, double *e1, d
|
|||||||
if (p1==NULL)
|
if (p1==NULL)
|
||||||
return 0;
|
return 0;
|
||||||
if (v1==NULL)
|
if (v1==NULL)
|
||||||
return FAIL;
|
return slsDetectorDefs::FAIL;
|
||||||
|
|
||||||
if (mp==NULL) //can be changed if we want to use a fixed bin algorithm!
|
if (mp==NULL) //can be changed if we want to use a fixed bin algorithm!
|
||||||
return FAIL;
|
return slsDetectorDefs::FAIL;
|
||||||
|
|
||||||
if (mv==NULL)
|
if (mv==NULL)
|
||||||
return FAIL;
|
return slsDetectorDefs::FAIL;
|
||||||
if (me==NULL)
|
if (me==NULL)
|
||||||
return FAIL;
|
return slsDetectorDefs::FAIL;
|
||||||
if (mm==NULL)
|
if (mm==NULL)
|
||||||
return FAIL;
|
return slsDetectorDefs::FAIL;
|
||||||
if (nchans==0)
|
if (nchans==0)
|
||||||
return FAIL;
|
return slsDetectorDefs::FAIL;
|
||||||
|
|
||||||
if (binsize<=0)
|
if (binsize<=0)
|
||||||
return FAIL;
|
return slsDetectorDefs::FAIL;
|
||||||
|
|
||||||
if (nbins<=0)
|
if (nbins<=0)
|
||||||
return FAIL;
|
return slsDetectorDefs::FAIL;
|
||||||
|
|
||||||
for (int ip=0; ip<nchans; ip++) {
|
for (int ip=0; ip<nchans; ip++) {
|
||||||
if (badChanMask) {
|
if (badChanMask) {
|
||||||
@ -259,10 +261,10 @@ int angularConversionStatic::addToMerging(double *p1, double *v1, double *e1, d
|
|||||||
cout << "add " << ibin << " "<< mm[ibin] << " " << mp[ibin]<< mv[ibin] << me[ibin] << endl;
|
cout << "add " << ibin << " "<< mm[ibin] << " " << mp[ibin]<< mv[ibin] << me[ibin] << endl;
|
||||||
#endif
|
#endif
|
||||||
} else
|
} else
|
||||||
return FAIL;
|
return slsDetectorDefs::FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return OK;
|
return slsDetectorDefs::OK;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,55 +1,37 @@
|
|||||||
#include "angularConversion.h"
|
#include "angularConversionStatic.h"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#ifndef MYROOT
|
|
||||||
#include "usersFunctions.h"
|
|
||||||
|
|
||||||
#endif
|
|
||||||
#include "angleFunction.h"
|
#include "angleFunction.h"
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
angularConversion::angularConversion(): currentPosition(0),
|
angularConversionStatic::angularConversionStatic()
|
||||||
currentPositionIndex(0)
|
|
||||||
{
|
{
|
||||||
//angleFunctionPointer=0;
|
//angleFunctionPointer=0;
|
||||||
registerAngleFunctionCallback(&defaultAngleFunction);
|
registerAngleFunctionCallback(&defaultAngleFunction);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
angularConversion::~angularConversion(){
|
angularConversionStatic::~angularConversionStatic(){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// int angularConversion::setAngularConversionPointer(angleConversionConstant *p, int *nm, int nch, int idet) {
|
|
||||||
// if (p) {
|
|
||||||
// angOff[idet]=p;
|
|
||||||
// nMods[idet]=nm;
|
|
||||||
// nCh[idet]=nch;
|
|
||||||
// } else {
|
|
||||||
// angOff[idet]=NULL;
|
|
||||||
// nMods[idet]=NULL;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// return OK;
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
|
double* angularConversionStatic::convertAngles(double pos, int nch, int *chansPerMod, angleConversionConstant **angOff, int *mF, double fo, double go, int angdir) {
|
||||||
|
|
||||||
double* angularConversion::convertAngles(double pos, int nch) {
|
|
||||||
int imod=0;
|
int imod=0;
|
||||||
double *ang=new double[nch];
|
double *ang=new double[nch];
|
||||||
double enc=pos;
|
double enc=pos;
|
||||||
angleConversionConstant *p=NULL;
|
angleConversionConstant *p=NULL;
|
||||||
|
|
||||||
int ch0=0;
|
int ch0=0;
|
||||||
int chlast=getChansPerMod(0);
|
int chlast=chansPerMod[0];
|
||||||
int nchmod=getChansPerMod(0);
|
int nchmod=chansPerMod[0];
|
||||||
p=getAngularConversionPointer(imod);
|
p=angOff[imod];
|
||||||
if (getMoveFlag(imod)==0)
|
if (mF[imod]==0)
|
||||||
enc=0;
|
enc=0;
|
||||||
else
|
else
|
||||||
enc=pos;
|
enc=pos;
|
||||||
@ -60,14 +42,14 @@ double* angularConversion::convertAngles(double pos, int nch) {
|
|||||||
#endif
|
#endif
|
||||||
if (ip>=chlast) {
|
if (ip>=chlast) {
|
||||||
imod++;
|
imod++;
|
||||||
p=getAngularConversionPointer(imod);
|
p=angOff[imod];
|
||||||
if (getMoveFlag(imod)==0)
|
if (mF[imod]==0)
|
||||||
enc=0;
|
enc=0;
|
||||||
else
|
else
|
||||||
enc=pos;
|
enc=pos;
|
||||||
|
|
||||||
ch0=chlast;
|
ch0=chlast;
|
||||||
nchmod=getChansPerMod(imod);
|
nchmod=chansPerMod[imod];
|
||||||
if (nchmod>0)
|
if (nchmod>0)
|
||||||
chlast+=nchmod;
|
chlast+=nchmod;
|
||||||
}
|
}
|
||||||
@ -75,12 +57,12 @@ double* angularConversion::convertAngles(double pos, int nch) {
|
|||||||
if (p)
|
if (p)
|
||||||
ang[ip]=angle(ip-ch0, \
|
ang[ip]=angle(ip-ch0, \
|
||||||
enc, \
|
enc, \
|
||||||
(*fineOffset)+(*globalOffset), \
|
fo+go, \
|
||||||
p->r_conversion, \
|
p->r_conversion, \
|
||||||
p->center, \
|
p->center, \
|
||||||
p->offset, \
|
p->offset, \
|
||||||
p->tilt, \
|
p->tilt, \
|
||||||
*angDirection );
|
angdir );
|
||||||
}
|
}
|
||||||
return ang;
|
return ang;
|
||||||
}
|
}
|
||||||
@ -88,7 +70,7 @@ double* angularConversion::convertAngles(double pos, int nch) {
|
|||||||
|
|
||||||
|
|
||||||
//static!
|
//static!
|
||||||
int angularConversion::readAngularConversion(string fname, int nmod, angleConversionConstant *angOff) {
|
int angularConversionStatic::readAngularConversion(string fname, int nmod, angleConversionConstant *angOff) {
|
||||||
|
|
||||||
ifstream infile;
|
ifstream infile;
|
||||||
string ss;
|
string ss;
|
||||||
@ -109,7 +91,7 @@ int angularConversion::readAngularConversion(string fname, int nmod, angleConver
|
|||||||
|
|
||||||
|
|
||||||
//static
|
//static
|
||||||
int angularConversion::readAngularConversion( ifstream& infile, int nmod, angleConversionConstant *angOff) {
|
int angularConversionStatic::readAngularConversion( ifstream& infile, int nmod, angleConversionConstant *angOff) {
|
||||||
string str;
|
string str;
|
||||||
int mod;
|
int mod;
|
||||||
double center, ecenter;
|
double center, ecenter;
|
||||||
@ -155,7 +137,7 @@ int angularConversion::readAngularConversion( ifstream& infile, int nmod, angleC
|
|||||||
}
|
}
|
||||||
|
|
||||||
//static
|
//static
|
||||||
int angularConversion:: writeAngularConversion(string fname, int nmod, angleConversionConstant *angOff) {
|
int angularConversionStatic:: writeAngularConversion(string fname, int nmod, angleConversionConstant *angOff) {
|
||||||
|
|
||||||
ofstream outfile;
|
ofstream outfile;
|
||||||
outfile.open (fname.c_str(),ios_base::out);
|
outfile.open (fname.c_str(),ios_base::out);
|
||||||
@ -174,7 +156,7 @@ int angularConversion:: writeAngularConversion(string fname, int nmod, angleConv
|
|||||||
|
|
||||||
|
|
||||||
//static
|
//static
|
||||||
int angularConversion:: writeAngularConversion(ofstream& outfile, int nmod, angleConversionConstant *angOff) {
|
int angularConversionStatic:: writeAngularConversion(ofstream& outfile, int nmod, angleConversionConstant *angOff) {
|
||||||
|
|
||||||
for (int imod=0; imod<nmod; imod++) {
|
for (int imod=0; imod<nmod; imod++) {
|
||||||
outfile << " module " << imod << " center "<< angOff[imod].center<<" +- "<< angOff[imod].ecenter<<" conversion "<< angOff[imod].r_conversion << " +- "<< angOff[imod].er_conversion << " offset "<< angOff[imod].offset << " +- "<< angOff[imod].eoffset << std::endl;
|
outfile << " module " << imod << " center "<< angOff[imod].center<<" +- "<< angOff[imod].ecenter<<" conversion "<< angOff[imod].r_conversion << " +- "<< angOff[imod].er_conversion << " offset "<< angOff[imod].offset << " +- "<< angOff[imod].eoffset << std::endl;
|
||||||
@ -184,7 +166,7 @@ int angularConversion:: writeAngularConversion(ofstream& outfile, int nmod, angl
|
|||||||
|
|
||||||
|
|
||||||
//static
|
//static
|
||||||
int angularConversion::resetMerging(double *mp, double *mv, double *me, int *mm, int nb) {
|
int angularConversionStatic::resetMerging(double *mp, double *mv, double *me, int *mm, int nb) {
|
||||||
|
|
||||||
|
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
@ -203,7 +185,7 @@ int angularConversion::resetMerging(double *mp, double *mv, double *me, int *mm,
|
|||||||
|
|
||||||
|
|
||||||
//static
|
//static
|
||||||
int angularConversion::finalizeMerging(double *mp, double *mv, double *me, int *mm,int nb) {
|
int angularConversionStatic::finalizeMerging(double *mp, double *mv, double *me, int *mm,int nb) {
|
||||||
int np=0;
|
int np=0;
|
||||||
for (int ibin=0; ibin<nb; ibin++) {
|
for (int ibin=0; ibin<nb; ibin++) {
|
||||||
if (mm[ibin]>0) {
|
if (mm[ibin]>0) {
|
||||||
@ -223,7 +205,7 @@ int angularConversion::finalizeMerging(double *mp, double *mv, double *me, int *
|
|||||||
}
|
}
|
||||||
|
|
||||||
//static
|
//static
|
||||||
int angularConversion::addToMerging(double *p1, double *v1, double *e1, double *mp, double *mv,double *me, int *mm, int nchans, double binsize,int nbins, int *badChanMask ) {
|
int angularConversionStatic::addToMerging(double *p1, double *v1, double *e1, double *mp, double *mv,double *me, int *mm, int nchans, double binsize,int nbins, int *badChanMask ) {
|
||||||
|
|
||||||
|
|
||||||
double binmi=-180.;
|
double binmi=-180.;
|
||||||
@ -284,243 +266,3 @@ int angularConversion::addToMerging(double *p1, double *v1, double *e1, double
|
|||||||
return OK;
|
return OK;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int angularConversion::deleteMerging() {
|
|
||||||
|
|
||||||
if (mergingBins)
|
|
||||||
delete [] mergingBins;
|
|
||||||
|
|
||||||
if (mergingCounts)
|
|
||||||
delete [] mergingCounts;
|
|
||||||
|
|
||||||
if (mergingErrors)
|
|
||||||
delete [] mergingErrors;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int angularConversion::resetMerging() {
|
|
||||||
getAngularConversionParameter(BIN_SIZE);
|
|
||||||
|
|
||||||
mergingBins=new double[nBins];
|
|
||||||
|
|
||||||
|
|
||||||
mergingCounts=new double[nBins];
|
|
||||||
|
|
||||||
|
|
||||||
mergingErrors=new double[nBins];
|
|
||||||
|
|
||||||
|
|
||||||
mergingMultiplicity=new int[nBins];
|
|
||||||
|
|
||||||
return resetMerging(mergingBins, mergingCounts, mergingErrors, mergingMultiplicity);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
int angularConversion::resetMerging(double *mp, double *mv, double *me, int *mm) {
|
|
||||||
getAngularConversionParameter(BIN_SIZE);
|
|
||||||
if (nBins)
|
|
||||||
return resetMerging(mp, mv, me, mm,nBins);
|
|
||||||
else
|
|
||||||
return FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int angularConversion::finalizeMerging() {
|
|
||||||
int np=finalizeMerging(mergingBins, mergingCounts, mergingErrors, mergingMultiplicity);
|
|
||||||
|
|
||||||
if (mergingMultiplicity)
|
|
||||||
delete [] mergingMultiplicity;
|
|
||||||
|
|
||||||
return np;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int angularConversion::finalizeMerging(double *mp, double *mv, double *me, int *mm) {
|
|
||||||
if (nBins)
|
|
||||||
return finalizeMerging(mp, mv, me, mm, nBins);
|
|
||||||
else
|
|
||||||
return FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
int angularConversion::addToMerging(double *p1, double *v1, double *e1, int *badChanMask ) {
|
|
||||||
|
|
||||||
return addToMerging(p1,v1,e1,mergingBins,mergingCounts, mergingErrors, mergingMultiplicity, badChanMask);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int angularConversion::addToMerging(double *p1, double *v1, double *e1, double *mp, double *mv,double *me, int *mm, int *badChanMask ) {
|
|
||||||
|
|
||||||
int del=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 );
|
|
||||||
|
|
||||||
|
|
||||||
if (del) {
|
|
||||||
delete [] p1;
|
|
||||||
p1=NULL;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
sets the value of s angular conversion parameter
|
|
||||||
\param c can be ANGULAR_DIRECTION, GLOBAL_OFFSET, FINE_OFFSET, BIN_SIZE
|
|
||||||
\param v the value to be set
|
|
||||||
\returns the actual value
|
|
||||||
*/
|
|
||||||
|
|
||||||
double angularConversion::setAngularConversionParameter(angleConversionParameter c, double v){
|
|
||||||
|
|
||||||
|
|
||||||
switch (c) {
|
|
||||||
case ANGULAR_DIRECTION:
|
|
||||||
if (v<0)
|
|
||||||
*angDirection=-1;
|
|
||||||
else
|
|
||||||
*angDirection=1;
|
|
||||||
return *angDirection;
|
|
||||||
case GLOBAL_OFFSET:
|
|
||||||
*globalOffset=v;
|
|
||||||
return *globalOffset;
|
|
||||||
case FINE_OFFSET:
|
|
||||||
*fineOffset=v;
|
|
||||||
return *fineOffset;
|
|
||||||
case BIN_SIZE:
|
|
||||||
if (v>0) {
|
|
||||||
*binSize=v;
|
|
||||||
nBins=360./(*binSize);
|
|
||||||
}
|
|
||||||
return *binSize;
|
|
||||||
case MOVE_FLAG:
|
|
||||||
if (moveFlag) {
|
|
||||||
if (v>0)
|
|
||||||
*moveFlag=1;
|
|
||||||
else if (v==0)
|
|
||||||
*moveFlag=0;
|
|
||||||
return *moveFlag;
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
returns the value of an angular conversion parameter
|
|
||||||
\param c can be ANGULAR_DIRECTION, GLOBAL_OFFSET, FINE_OFFSET, BIN_SIZE
|
|
||||||
\returns the actual value
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
double angularConversion::getAngularConversionParameter(angleConversionParameter c) {
|
|
||||||
|
|
||||||
switch (c) {
|
|
||||||
case ANGULAR_DIRECTION:
|
|
||||||
return *angDirection;
|
|
||||||
case GLOBAL_OFFSET:
|
|
||||||
return *globalOffset;
|
|
||||||
case FINE_OFFSET:
|
|
||||||
return *fineOffset;
|
|
||||||
case BIN_SIZE:
|
|
||||||
if (*binSize>0)
|
|
||||||
nBins=360./(*binSize);
|
|
||||||
else
|
|
||||||
nBins=0;
|
|
||||||
return *binSize;
|
|
||||||
case MOVE_FLAG:
|
|
||||||
if (moveFlag)
|
|
||||||
return *moveFlag;
|
|
||||||
else
|
|
||||||
return -1;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int angularConversion::setAngularConversionFile(string fname) {
|
|
||||||
if (fname=="") {
|
|
||||||
setAngularCorrectionMask(0);
|
|
||||||
#ifdef VERBOSE
|
|
||||||
std::cout << "Unsetting angular conversion" << std::endl;
|
|
||||||
#endif
|
|
||||||
} else {
|
|
||||||
if (fname=="default") {
|
|
||||||
fname=string(angConvFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef VERBOSE
|
|
||||||
std::cout << "Setting angular conversion to " << fname << std:: endl;
|
|
||||||
#endif
|
|
||||||
if (readAngularConversionFile(fname)>=0) {
|
|
||||||
setAngularCorrectionMask(1);
|
|
||||||
strcpy(angConvFile,fname.c_str());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return setAngularCorrectionMask();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
set positions for the acquisition
|
|
||||||
\param nPos number of positions
|
|
||||||
\param pos array with the encoder positions
|
|
||||||
\returns number of positions
|
|
||||||
*/
|
|
||||||
int angularConversion::setPositions(int nPos, double *pos){
|
|
||||||
if (nPos>=0)
|
|
||||||
*numberOfPositions=nPos;
|
|
||||||
for (int ip=0; ip<nPos; ip++)
|
|
||||||
detPositions[ip]=pos[ip];
|
|
||||||
|
|
||||||
return *numberOfPositions;
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
get positions for the acquisition
|
|
||||||
\param pos array which will contain the encoder positions
|
|
||||||
\returns number of positions
|
|
||||||
*/
|
|
||||||
int angularConversion::getPositions(double *pos){
|
|
||||||
if (pos) {
|
|
||||||
for (int ip=0; ip<(*numberOfPositions); ip++)
|
|
||||||
pos[ip]=detPositions[ip];
|
|
||||||
}
|
|
||||||
|
|
||||||
return *numberOfPositions;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,17 +7,17 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#include "sls_detector_defs.h"
|
|
||||||
|
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
#include "angleConversionConstant.h"
|
//#include "angleConversionConstant.h"
|
||||||
|
|
||||||
|
|
||||||
//double angle(int ichan, double encoder, double totalOffset, double conv_r, double center, double offset, double tilt, int direction)
|
//double angle(int ichan, double encoder, double totalOffset, double conv_r, double center, double offset, double tilt, int direction)
|
||||||
|
|
||||||
|
class angleConversionConstant;
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
@ -35,7 +35,8 @@ class containing the methods to set/unset the angular conversion and merge the d
|
|||||||
The angular conversion itself is defined by the angle() function defined in usersFunctions.cpp
|
The angular conversion itself is defined by the angle() function defined in usersFunctions.cpp
|
||||||
|
|
||||||
*/
|
*/
|
||||||
class angularConversionStatic : public virtual slsDetectorDefs
|
class angularConversionStatic
|
||||||
|
// : public virtual slsDetectorDefs
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
#include "angleConversionConstant.h"
|
#include "angleConversionConstant.h"
|
||||||
|
|
||||||
|
|
||||||
//double angle(int ichan, double encoder, double totalOffset, double conv_r, double center, double offset, double tilt, int direction)
|
//double angle(int ichan, double encoder, double totalOffset, double conv_r, double center, double offset, double tilt, int direction)
|
||||||
|
|
||||||
|
|
||||||
@ -147,12 +148,12 @@ class angularConversionStatic : public virtual slsDetectorDefs
|
|||||||
int registerAngleFunctionCallback(double (*fun)(double, double, double, double, double, double, double, int)) {angle = fun; return 0;};
|
int registerAngleFunctionCallback(double (*fun)(double, double, double, double, double, double, double, int)) {angle = fun; return 0;};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
|
|
||||||
double (*angle)(double, double, double, double, double, double, double, int);
|
double (*angle)(double, double, double, double, double, double, double, int);
|
||||||
|
|
||||||
|
|
||||||
|
// private:
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user