diff --git a/slsDetectorSoftware/CMakeLists.txt b/slsDetectorSoftware/CMakeLists.txt index 67d0416aa..ec22dd886 100644 --- a/slsDetectorSoftware/CMakeLists.txt +++ b/slsDetectorSoftware/CMakeLists.txt @@ -4,19 +4,12 @@ set(SOURCES slsDetector/slsDetectorUsers.cpp slsDetector/slsDetectorUtils.cpp slsDetector/slsDetectorCommand.cpp - slsDetector/slsDetectorActions.cpp slsDetector/slsDetector.cpp - slsDetectorAnalysis/angularConversion.cpp - slsDetectorAnalysis/angularConversionStatic.cpp - slsDetectorAnalysis/energyConversion.cpp - slsDetectorAnalysis/fileIO.cpp slsDetectorAnalysis/postProcessing.cpp - slsDetectorAnalysis/postProcessingFuncs.cpp slsReceiverInterface/receiverInterface.cpp threadFiles/CondVar.cpp threadFiles/Mutex.cpp threadFiles/ThreadPool.cpp - usersFunctions/usersFunctions.cpp ) set(HEADERS @@ -32,7 +25,6 @@ slsDetectorCommand slsDetectorAnalysis slsReceiverInterface threadFiles -usersFunctions ../slsReceiverSoftware/include ../slsReceiverSoftware/MySocketTCP ) @@ -55,6 +47,17 @@ add_library(slsDetectorShared SHARED ${HEADERS} ) +add_library(zmq STATIC IMPORTED GLOBAL) + +set(ZMQ_STATIC_ARCHIVE ${CMAKE_CURRENT_SOURCE_DIR}/../slsReceiverSoftware/include/libzmq.a) +set_target_properties(zmq PROPERTIES + IMPORTED_LOCATION ${ZMQ_STATIC_ARCHIVE} +) + +target_link_libraries(slsDetectorShared + zmq +) + set(PUBLICHEADERS commonFiles/sls_detector_defs.h commonFiles/sls_detector_funcs.h @@ -63,18 +66,10 @@ set(PUBLICHEADERS sharedMemory/SharedMemory.h slsDetector/slsDetectorUtils.h slsDetector/slsDetector.h - slsDetector/slsDetectorActions.h slsDetector/slsDetectorBase.h slsDetector/slsDetectorUsers.h slsDetectorAnalysis/postProcessing.h slsDetectorAnalysis/detectorData.h - slsDetectorAnalysis/angularConversion.h - slsDetectorAnalysis/angularConversionStatic.h - slsDetectorAnalysis/angleConversionConstant.h - slsDetectorAnalysis/badChannelCorrections.h - slsDetectorAnalysis/energyConversion.h - slsDetectorAnalysis/fileIO.h - slsDetectorAnalysis/fileIOStatic.h multiSlsDetector/multiSlsDetector.h slsReceiverInterface/receiverInterface.h ../slsReceiverSoftware/include/sls_receiver_exceptions.h @@ -98,6 +93,10 @@ if(DOXYGEN_FOUND) ) endif() + +install(FILES ${ZMQ_STATIC_ARCHIVE} +DESTINATION lib) + install(TARGETS slsDetectorShared slsDetectorStatic LIBRARY DESTINATION lib PUBLIC_HEADER DESTINATION include diff --git a/slsDetectorSoftware/Makefile b/slsDetectorSoftware/Makefile index 1be7ccc6f..56c37040f 100644 --- a/slsDetectorSoftware/Makefile +++ b/slsDetectorSoftware/Makefile @@ -9,15 +9,15 @@ CFLAGS= -g -DC_ONLY -fPIC DFLAGS= -g -DDACS_INT -INCLUDES?= -IcommonFiles -IslsDetector -I../slsReceiverSoftware/MySocketTCP -IusersFunctions -ImultiSlsDetector -IslsDetectorUtils -IslsDetectorCommand -IslsDetectorAnalysis -IslsReceiverInterface -I../slsReceiverSoftware/include -IthreadFiles -IsharedMemory -I$(ASM) +INCLUDES?= -IcommonFiles -IslsDetector -I../slsReceiverSoftware/MySocketTCP -ImultiSlsDetector -IslsDetectorUtils -IslsDetectorCommand -IslsDetectorAnalysis -IslsReceiverInterface -I../slsReceiverSoftware/include -IthreadFiles -IsharedMemory -I$(ASM) #EPICSFLAGS=-D EPICS -I/usr/local/epics/base/include/ -I /usr/local/epics/base/include/os/Linux/ -L /usr/local/epics/base/lib/$(EPICS_HOST_ARCH) -Wl,-R/usr/local/epics/base/lib/$(EPICS_HOST_ARCH) -lca -lCom LIBZMQDIR = ../slsReceiverSoftware/include LIBZMQ = -L$(LIBZMQDIR) -Wl,-rpath=$(LIBZMQDIR) -lzmq -SRC_CLNT=slsDetectorAnalysis/fileIO.cpp usersFunctions/usersFunctions.cpp slsDetector/slsDetectorUtils.cpp slsDetector/slsDetectorCommand.cpp slsDetectorAnalysis/angularConversion.cpp slsDetectorAnalysis/angularConversionStatic.cpp slsDetectorAnalysis/energyConversion.cpp slsDetector/slsDetectorActions.cpp slsDetectorAnalysis/postProcessing.cpp slsDetector/slsDetector.cpp multiSlsDetector/multiSlsDetector.cpp slsDetectorAnalysis/postProcessingFuncs.cpp slsReceiverInterface/receiverInterface.cpp slsDetector/slsDetectorUsers.cpp threadFiles/CondVar.cpp threadFiles/Mutex.cpp threadFiles/ThreadPool.cpp sharedMemory/SharedMemory.cpp #../slsReceiverSoftware/MySocketTCP/MySocketTCP.cpp -DEPSINCLUDES = $(LIBZMQDIR)/sls_receiver_defs.h $(LIBZMQDIR)/sls_receiver_funcs.h $(LIBZMQDIR)/ansi.h commonFiles/sls_detector_defs.h commonFiles/sls_detector_funcs.h commonFiles/error_defs.h slsDetector/slsDetectorBase.h slsDetectorAnalysis/angCalLogClass.h slsDetectorAnalysis/angleConversionConstant.h slsDetectorAnalysis/badChannelCorrections.h slsDetectorAnalysis/detectorData.h slsDetectorAnalysis/enCalLogClass.h slsDetectorAnalysis/fileIOStatic.h slsDetectorAnalysis/movingStat.h slsDetectorAnalysis/runningStat.h slsDetectorAnalysis/single_photon_hit.h threadFiles/Global.h threadFiles/Task.h usersFunctions/angleFunction.h sharedMemory/SharedMemory.h $(LIBZMQDIR)/sls_receiver_exceptions.h commonFiles/versionAPI.h +SRC_CLNT= slsDetector/slsDetectorUtils.cpp slsDetector/slsDetectorCommand.cpp slsDetectorAnalysis/postProcessing.cpp slsDetector/slsDetector.cpp multiSlsDetector/multiSlsDetector.cpp slsReceiverInterface/receiverInterface.cpp slsDetector/slsDetectorUsers.cpp threadFiles/CondVar.cpp threadFiles/Mutex.cpp threadFiles/ThreadPool.cpp sharedMemory/SharedMemory.cpp #../slsReceiverSoftware/MySocketTCP/MySocketTCP.cpp +DEPSINCLUDES = $(LIBZMQDIR)/sls_receiver_defs.h $(LIBZMQDIR)/sls_receiver_funcs.h $(LIBZMQDIR)/ansi.h commonFiles/sls_detector_defs.h commonFiles/sls_detector_funcs.h commonFiles/error_defs.h slsDetector/slsDetectorBase.h slsDetectorAnalysis/detectorData.h threadFiles/Global.h threadFiles/Task.h sharedMemory/SharedMemory.h $(LIBZMQDIR)/sls_receiver_exceptions.h commonFiles/versionAPI.h diff --git a/slsDetectorSoftware/Makefile.Standalone b/slsDetectorSoftware/Makefile.Standalone deleted file mode 100644 index d9a7c0868..000000000 --- a/slsDetectorSoftware/Makefile.Standalone +++ /dev/null @@ -1,68 +0,0 @@ -CFLAGS= -DC_ONLY -#FLAGS= -DVERBOSE -DVERYVERBOSE -INCLUDES= -IcommonFiles -IslsDetector -IMySocketTCP -IusersFunctions -ImultiSlsDetector -IslsDetectorUtils -IslsDetectorCommand -IslsDetectorAnalysis - -#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 -CC=gcc -CXX=g++ - -SRC_CLNT= slsDetectorAnalysis/FileIO_Standalone.cpp MySocketTCP/MySocketTCP.cpp usersFunctions/usersFunctions.cpp slsDetector/slsDetectorUtils.cpp slsDetector/slsDetectorCommand.cpp slsDetectorAnalysis/AngularConversion_Standalone.cpp slsDetectorAnalysis/energyConversion.cpp slsDetector/slsDetectorActions.cpp slsDetectorAnalysis/postProcessingFileIO_Standalone.cpp slsDetector/slsDetector.cpp multiSlsDetector/multiSlsDetector.cpp - -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 - - - -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 $(SRC_CLNT) - echo "compiling all" - -doc: $(SRC_H) $(SRC_CLNT) - doxygen doxy.config - - - -mythenServer: $(SRC_MYTHEN_SVC) - $(CC) $(SRC_MYTHEN_SVC) $(CFLAGS) $(FLAGS) $(INCLUDES) -ImythenDetectorServer -DVIRTUAL -lm -D MCB_FUNCS -DC_ONLY -DVERBOSE - mv a.out mythenServer - - -picassoServer: $(SRC_MYTHEN_SVC) - $(CC) $(SRC_MYTHEN_SVC) $(CFLAGS) $(FLAGS) $(INCLUDES) -ImythenDetectorServer -D VIRTUAL -lm -DMCB_FUNCS -DPICASSOD -DC_ONLY - mv a.out picassoServer - - - - - -%.o : %.cpp %.h - $(CXX) -Wall -o $@ -c $< $(INCLUDES) $(FLAGS) $(EPICSFLAGS) - - -package: $(OBJS) - $(CXX) -shared -Wl,-soname,libSlsDetector.so -o libSlsDetector.so $(OBJS) -lc $(INCLUDES) $(FLAGS) $(EPICSFLAGS) - ar rcs libSlsDetector.a $(OBJS) - -clean: - rm -rf libSlsDetector.a libSlsDetector.so core docs/* $(OBJS) - - -#------------------------------------------------------------------------------- -lib: package - - -# added install target, HBl -install_lib: lib - $(shell test -d $(DESTDIR) || mkdir -p $(DESTDIR)) - cp -P libSlsDetector.so $(DESTDIR) - -install_inc: - $(shell test -d $(DESTDIR) || mkdir -p $(DESTDIR)) - cp -P $(HEADERS) $(DESTDIR) - - -install_doc: doc - $(shell test -d $(DESTDIR) || mkdir -p $(DESTDIR)) - cp -Pr docs/* $(DESTDIR) diff --git a/slsDetectorSoftware/Makefile.x04sa b/slsDetectorSoftware/Makefile.x04sa deleted file mode 100644 index 59755550f..000000000 --- a/slsDetectorSoftware/Makefile.x04sa +++ /dev/null @@ -1,87 +0,0 @@ -CFLAGS= -DC_ONLY -fPIC -#FLAGS+= #-DVERBOSE -DVERYVERBOSE - -DFLAGS= -DDACS_INT -DTHIS_PATH='"$(shell pwd)"' -DSLS_RECEIVER_FUNCTION_LIST - -#ASM=$(shell echo "/lib/modules/`uname -r`/build/include") - -INCLUDES?= -IcommonFiles -IslsDetector -IMySocketTCP -IusersFunctions -ImultiSlsDetector -IslsDetectorUtils -IslsDetectorCommand -IslsDetectorAnalysis -IslsReceiverInterface -IslsReceiver -I$(ASM) - -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 -CC=g++ - - -SRC_CLNT= slsDetectorAnalysis/fileIO.cpp MySocketTCP/MySocketTCP.cpp usersFunctions/usersFunctions.cpp slsDetector/slsDetectorUtils.cpp slsDetector/slsDetectorCommand.cpp slsDetectorAnalysis/angularConversion.cpp slsDetectorAnalysis/angularConversionStatic.cpp slsDetectorAnalysis/energyConversion.cpp slsDetector/slsDetectorActions.cpp slsDetectorAnalysis/postProcessing.cpp slsDetector/slsDetector.cpp multiSlsDetector/multiSlsDetector.cpp slsDetector/slsDetectorUsers.cpp slsDetectorAnalysis/postProcessingFuncs.cpp slsReceiverInterface/receiverInterface.cpp slsReceiver/slsReceiverFunctionList.cpp slsReceiver/slsReceiver_funcs.cpp slsReceiver/slsReceiverUsers.cpp - -OBJS = $(SRC_CLNT:.cpp=.o) - -HEADERS = $(SRC_CLNT:.cpp=.h) commonFiles/sls_detector_defs.h slsDetectorAnalysis/detectorData.h slsDetector/slsDetectorBase.h multiSlsDetector/multiSlsDetectorCommand.h slsDetectorAnalysis/enCalLogClass.h slsDetectorAnalysis/angCalLogClass.h slsDetectorAnalysis/angleConversionConstant.h usersFunctions/angleFunction.h slsReceiverInterface/receiverInterface.h slsDetector/svnInfoLib.h slsReceiver/circularFifo.h slsReceiver/slsReceiver_funcs.h slsReceiver/svnInfoReceiverTmp.h slsReceiver/receiver_defs.h slsReceiver/slsReceiverFunctionList.h slsReceiver/slsReceiverUsers.h slsReceiver/svnInfoReceiver.h - - - -DESTDIR ?= bin -DOCDIR ?= docs - - -all: package $(SRC_CLNT) - echo "compiling all" - -intdoc: $(SRC_H) $(SRC_CLNT) - doxygen doxy.config - -doc: $(DOCDIR)/pdf/slsDetectorUsersDocs.pdf - -$(DOCDIR)/pdf/slsDetectorUsersDocs.pdf: slsDetectorUsersDocs - cd slsDetectorUsersDocs/latex && make - $(shell test -d $(DOCDIR) || mkdir -p $(DOCDIR)) - $(shell test -d $(DOCDIR)/pdf || mkdir -p $(DOCDIR)/pdf) - cp slsDetectorUsersDocs/latex/refman.pdf $(DOCDIR)/pdf/slsDetectorUsersDocs.pdf - - -htmldoc: $(DOCDIR)/html/slsDetectorUsersDocs - -$(DOCDIR)/html/slsDetectorUsersDocs: slsDetectorUsersDocs - $(shell test -d $(DOCDIR) || mkdir -p $(DOCDIR)) - $(shell test -d $(DOCDIR)/html || mkdir -p $(DOCDIR)/html) - $(shell test -d $(DOCDIR)/html/slsDetectorUsersDocs && rm -r $(DOCDIR)/html/slsDetectorUsersDocs) - cp -r slsDetectorUsersDocs/html $(DOCDIR)/html/slsDetectorUsersDocs - -slsDetectorUsersDocs: slsDetectorUsers.doxy slsDetector/slsDetectorUsers.h slsDetector/slsDetectorUsers.cpp slsDetectorAnalysis/detectorData.h - doxygen slsDetectorUsers.doxy - - -mythenVirtualServer: $(SRC_MYTHEN_SVC) - cd mythenDetectorServer && make -f Makefile.virtual DESTDIR=$(DESTDIR) - -gotthardVirtualServer: $(SRC_MYTHEN_SVC) - cd gotthardDetectorServer && make -f Makefile.virtual DESTDIR=$(DESTDIR) - - - -%.o : %.cpp %.h Makefile - $(CXX) -Wall -o $@ -c $< $(INCLUDES) $(DFLAGS) $(FLAGS) -fPIC $(EPICSFLAGS) -L/usr/lib64/ - -package: $(OBJS) $(DESTDIR)/libSlsDetector.so $(DESTDIR)/libSlsDetector.a - -$(DESTDIR)/libSlsDetector.so: $(OBJS) - $(CXX) -shared -Wl,-soname,libSlsDetector.so -o libSlsDetector.so $(OBJS) -lc $(INCLUDES) $(DFLAGS) $(FLAGS) $(EPICSFLAGS) -L/usr/lib64/ - $(shell test -d $(DESTDIR) || mkdir -p $(DESTDIR)) - mv libSlsDetector.so $(DESTDIR) - -$(DESTDIR)/libSlsDetector.a: $(OBJS) - ar rcs libSlsDetector.a $(OBJS) - mv libSlsDetector.a $(DESTDIR) - -clean: - rm -rf libSlsDetector.a libSlsDetector.so core docs/* slsDetectorUsersDocs $(OBJS) - - -#------------------------------------------------------------------------------- - -install: package - -install_inc: - $(shell test -d $(DESTDIR) || mkdir -p $(DESTDIR)) - cp -P slsDetector/slsDetectorUsers.h slsDetectorAnalysis/detectorData.h $(DESTDIR) slsReceiver/slsReceiverUsers.h - - diff --git a/slsDetectorSoftware/commonFiles/error_defs.h b/slsDetectorSoftware/commonFiles/error_defs.h index dc733c2d7..7232e0a5b 100644 --- a/slsDetectorSoftware/commonFiles/error_defs.h +++ b/slsDetectorSoftware/commonFiles/error_defs.h @@ -38,20 +38,18 @@ #define FILE_PATH_DOES_NOT_EXIST 0x0200000000000000ULL #define COULDNOT_CREATE_UDP_SOCKET 0x0100000000000000ULL #define COULDNOT_CREATE_FILE 0x0080000000000000ULL -#define COULDNOT_ENABLE_COMPRESSION 0x0040000000000000ULL -#define RECEIVER_DET_HOSTNAME_NOT_SET 0x0020000000000000ULL -#define RECEIVER_DET_HOSTTYPE_NOT_SET 0x0010000000000000ULL -#define DETECTOR_TEN_GIGA 0x0008000000000000ULL -#define DETECTOR_ACTIVATE 0x0004000000000000ULL -#define COULD_NOT_CONFIGURE_MAC 0x0002000000000000ULL -#define COULDNOT_START_RECEIVER 0x0001000000000000ULL // default error like starting threads -#define COULDNOT_STOP_RECEIVER 0x0000800000000000ULL -#define RECEIVER_DET_POSID_NOT_SET 0x0000400000000000ULL -#define RECEIVER_MULTI_DET_SIZE_NOT_SET 0x0000200000000000ULL -#define PREPARE_ACQUISITION 0x0000100000000000ULL -#define CLEANUP_ACQUISITION 0x0000080000000000ULL -#define REGISER_WRITE_READ 0x0000040000000000ULL -#define VERSION_COMPATIBILITY 0x0000020000000000ULL +#define RECEIVER_DET_HOSTNAME_NOT_SET 0x0040000000000000ULL +#define RECEIVER_DET_HOSTTYPE_NOT_SET 0x0020000000000000ULL +#define DETECTOR_TEN_GIGA 0x0010000000000000ULL +#define DETECTOR_ACTIVATE 0x0008000000000000ULL +#define COULD_NOT_CONFIGURE_MAC 0x0004000000000000ULL +#define COULDNOT_START_RECEIVER 0x0002000000000000ULL // default error like starting threads +#define COULDNOT_STOP_RECEIVER 0x0001000000000000ULL +#define RECEIVER_DET_POSID_NOT_SET 0x0000800000000000ULL +#define RECEIVER_MULTI_DET_SIZE_NOT_SET 0x0000400000000000ULL +#define PREPARE_ACQUISITION 0x0000200000000000ULL +#define REGISER_WRITE_READ 0x0000100000000000ULL +#define VERSION_COMPATIBILITY 0x0000080000000000ULL // 0xFFFFFF0000000000ULL // 0x000000FFFFFFFFFFULL @@ -141,9 +139,6 @@ public: if(slsErrorMask&COULDNOT_CREATE_FILE) retval.append("Could not create file to start receiver.\nCheck permissions of output directory or the overwrite flag\n"); - if(slsErrorMask&COULDNOT_ENABLE_COMPRESSION) - retval.append("Could not enable/disable data compression in receiver.\nThread creation failed or recompile code with MYROOT1 flag.\n"); - if(slsErrorMask&RECEIVER_DET_HOSTNAME_NOT_SET) retval.append("Could not send the detector hostname to the receiver.\n"); @@ -165,9 +160,6 @@ public: if(slsErrorMask&PREPARE_ACQUISITION) retval.append("Could not prepare acquisition in detector\n"); - if(slsErrorMask&CLEANUP_ACQUISITION) - retval.append("Could not clean up after acquisition in detector\n"); - if(slsErrorMask®ISER_WRITE_READ) retval.append("Could not read/write register in detector\n"); diff --git a/slsDetectorSoftware/commonFiles/sls_detector_defs.h b/slsDetectorSoftware/commonFiles/sls_detector_defs.h index 0e3a388c0..430117bad 100755 --- a/slsDetectorSoftware/commonFiles/sls_detector_defs.h +++ b/slsDetectorSoftware/commonFiles/sls_detector_defs.h @@ -10,14 +10,6 @@ //#include #include "sls_receiver_defs.h" -/** default maximum string length */ -#define MAX_SCAN_STEPS 2000 -/** maxmimum number of modules per controller*/ -#define MAXMODS 24 -/** maxmimum number of detectors ina multidetector structure*/ -#define MAXDET 100 -/** header length for data :gotthard*/ -#define HEADERLENGTH 12 /** maximum rois */ #define MAX_ROIS 100 @@ -28,20 +20,10 @@ /** maximum unit size of program sent to detector */ #define MAX_FPGAPROGRAMSIZE (2 * 1024 *1024) - - -#define MAX_SCAN_LEVELS 2 - typedef char mystring[MAX_STR_LENGTH]; -typedef double mysteps[MAX_SCAN_STEPS]; - - -#ifndef DACS_FLOAT typedef int dacs_t; -#else -typedef float dacs_t; -#endif + #define DEFAULT_DET_MAC "00:aa:bb:cc:dd:ee" #define DEFAULT_DET_IP "129.129.202.46" @@ -57,8 +39,6 @@ and to the server programs running on the detector * @version 0.1alpha (any string) * @see slsDetector -$Revision: 824 $ - */ @@ -77,40 +57,6 @@ class slsDetectorDefs: public virtual slsReceiverDefs{ #endif - enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript, enCalLog, angCalLog, MAX_ACTIONS}; - - - -/** - @short structure for a detector channel - - should not be used by unexperienced users - - \see ::channelRegisterBit -*/ - typedef struct { - int chan; /**< is the channel number */ - int chip; /**< is the chip number */ - int module; /**< is the module number */ - int64_t reg; /**< is the is the channel register (e.g. trimbits, calibration enable, comparator enable...) */ - } sls_detector_channel; - - /** - @short structure for a detector chip - - should not be used by unexperienced users - \see ::chipRegisterBit ::channelRegisterBit -*/ - typedef struct { - int chip; /**< is the chip number */ - int module; /**< is the module number */ - int nchan; /**< is the number of channels in the chip */ - int reg; /** - -#include -#include -#include -#include -#include -#include -#include -#include - - -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[], int *np) -{ - finalize_dataset(ang, val, err, np); - return 0; -}; - - -int addFrame(double data[], double *pos, double *IO, double *expTime, const char *filename, int *var) -{ - add_frame(data, pos, i0, expTime, filename, var); - return 0; -}; - -int calculateFlatField(int* nModules, int *chPerMod, int modMask[], int badChanMask[], double data[], double ffCoeff[], double ffErr[]) -{ - calculate_flat_field(nModules, chPerMod, modMask, badChanMask, data, ffCoeff, ffErr); - return 0; -}; diff --git a/slsDetectorSoftware/f90Interface/externPostProcessing.h b/slsDetectorSoftware/f90Interface/externPostProcessing.h deleted file mode 100644 index 9225d66f9..000000000 --- a/slsDetectorSoftware/f90Interface/externPostProcessing.h +++ /dev/null @@ -1,58 +0,0 @@ -#ifndef EXTERNPOSTPROCESSING_H -#define EXTERNPOSTPROCESSING_H - - -#include "detectorData.h" - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - - - - - - -extern "C" { - - void init_dataset(int *nMod, int *chPerMod, int* modMask, int *badChanMask, double *ffCoeff, double *ffErr, double *tDead, int *dir, 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, double *exptime, 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: - externPostProcessing(){}; - virtual ~externPostProcessing(){}; - - - static int InitDataset(int *nModules,int *chPerMod,int moduleMask[],int badChans[], double ffcoeff[], double fferr[], double* tDead, int *dir, double angRadius[], double angOffset[], double angCentre[], double* totalOffset, double* binSize, double *sampleX, double *sampleY); - - - - static int finalizeDataset(double ang[], double val[], double err[], int *np); - - static int addFrame(double data[], double *pos, double *IO, double *expTime, const char *filename, int *var=0); - - static int calculateFlatField(int* nModules, int *chPerMod, int moduleMask[], int badChannelMask[], double ffData[], double ffCoeff[], double ffErr[]); - - - - - }; - - -#endif diff --git a/slsDetectorSoftware/f90Interface/sls_detector_analysis_f.f90 b/slsDetectorSoftware/f90Interface/sls_detector_analysis_f.f90 deleted file mode 100644 index 201371ef4..000000000 --- a/slsDetectorSoftware/f90Interface/sls_detector_analysis_f.f90 +++ /dev/null @@ -1,174 +0,0 @@ -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, exptime, fname, var) bind(c, name='add_frame') -IMPLICIT NONE -real(C_DOUBLE), intent(IN) :: data(totalnumberofchannels) -real(C_DOUBLE), intent(IN) :: pos, i0, exptime, 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*,'Exposure time: ' -print*,exptime - -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 diff --git a/slsDetectorSoftware/gitInfo.txt b/slsDetectorSoftware/gitInfo.txt index 7d297692c..1c744e668 100644 --- a/slsDetectorSoftware/gitInfo.txt +++ b/slsDetectorSoftware/gitInfo.txt @@ -1,9 +1,9 @@ Path: slsDetectorsPackage/slsDetectorSoftware URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git -Repsitory UUID: d2bce7e372c241cd235977b92be18555bca6a77d -Revision: 2040 -Branch: 4.0.0 +Repsitory UUID: def79807f6f40ed1797b8154240adbc0e35c95e0 +Revision: 2044 +Branch: refactor Last Changed Author: Dhanya_Thattil -Last Changed Rev: 4020 -Last Changed Date: 2018-09-27 18:22:10.000000002 +0200 ./sharedMemory/SharedMemory.o +Last Changed Rev: 4039 +Last Changed Date: 2018-10-02 15:03:24.000000002 +0200 ./CMakeLists.txt diff --git a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp index 8d0e67711..c8bda72c7 100644 --- a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp +++ b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp @@ -16,8 +16,6 @@ ID: $Id$ #include "ZmqSocket.h" #include "multiSlsDetectorClient.h" #include "multiSlsDetectorCommand.h" -#include "postProcessingFuncs.h" -#include "usersFunctions.h" #include #include @@ -107,7 +105,7 @@ std::string multiSlsDetector::callDetectorMember(std::string (slsDetector::*some for (unsigned int idet = 0; idet < detectors.size(); ++idet) { std::string thisValue = (detectors[idet]->*somefunc)(); - ; + if (detectors[idet]->getErrorMask()) setErrorMask(getErrorMask() | (1 << idet)); @@ -126,6 +124,17 @@ std::string multiSlsDetector::callDetectorMember(std::string (slsDetector::*some return firstValue; } +std::string multiSlsDetector::callDetectorMember(std::string (slsDetector::*somefunc)(std::string), + std::string s0) { + std::vector return_values(detectors.size(), ""); + for (unsigned int idet = 0; idet < detectors.size(); ++idet) { + return_values[idet] = (detectors[idet]->*somefunc)(s0); + if (detectors[idet]->getErrorMask()) + setErrorMask(getErrorMask() | (1 << idet)); + } + return concatenateIfDifferent(return_values); +} + template T multiSlsDetector::callDetectorMember(T (slsDetector::*somefunc)(V), V value) { //(Erik) to handle enums, probably a bad idea but follow previous code @@ -156,7 +165,7 @@ T multiSlsDetector::callDetectorMember(T (slsDetector::*somefunc)(P1, P2), template T multiSlsDetector::parallelCallDetectorMember(T (slsDetector::*somefunc)()) { if (!threadpool) { - cout << "Error in creating threadpool. Exiting" << endl; + std::cout << "Error in creating threadpool. Exiting" << std::endl; return -1; } else { std::vector return_values(detectors.size(), -1); @@ -175,10 +184,10 @@ template T multiSlsDetector::parallelCallDetectorMember(T (slsDetector::*somefunc)(P1), P1 value) { if (!threadpool) { - cout << "Error in creating threadpool. Exiting" << endl; - return -1; + std::cout << "Error in creating threadpool. Exiting" << std::endl; + return (T)-1; } else { - std::vector return_values(detectors.size(), -1); + std::vector return_values(detectors.size(), (T)-1); for (unsigned int idet = 0; idet < detectors.size(); ++idet) { Task* task = new Task(new func1_t(somefunc, detectors[idet], value, &return_values[idet])); @@ -194,7 +203,7 @@ template T multiSlsDetector::parallelCallDetectorMember(T (slsDetector::*somefunc)(P1, P2), P1 par1, P2 par2) { if (!threadpool) { - cout << "Error in creating threadpool. Exiting" << endl; + std::cout << "Error in creating threadpool. Exiting" << std::endl; return -1; } else { std::vector return_values(detectors.size(), -1); @@ -212,7 +221,7 @@ T multiSlsDetector::parallelCallDetectorMember(T (slsDetector::*somefunc)(P1, P2 int multiSlsDetector::parallelCallDetectorMember(int (slsDetector::*somefunc)(int, int, int), int v0, int v1, int v2) { if (!threadpool) { - cout << "Error in creating threadpool. Exiting" << endl; + std::cout << "Error in creating threadpool. Exiting" << std::endl; return -1; } else { std::vector return_values(detectors.size(), -1); @@ -227,6 +236,25 @@ int multiSlsDetector::parallelCallDetectorMember(int (slsDetector::*somefunc)(in } } +std::string multiSlsDetector::parallelCallDetectorMember(std::string (slsDetector::*somefunc)(std::string), + std::string s0) { + if (!threadpool) { + std::cout << "Error in creating threadpool. Exiting" << std::endl; + return ""; + } else { + std::vector return_values(detectors.size(), ""); + for (unsigned int idet = 0; idet < detectors.size(); ++idet) { + Task* task = new Task(new func1_t(somefunc, + detectors[idet], s0, &return_values[idet])); + threadpool->add_task(task); + } + threadpool->startExecuting(); + threadpool->wait_for_tasks_to_complete(); + + return concatenateIfDifferent(return_values); + } +} + template T multiSlsDetector::minusOneIfDifferent(const std::vector& return_values) { T ret = static_cast(-100); @@ -241,46 +269,26 @@ T multiSlsDetector::minusOneIfDifferent(const std::vector& return_values) { return ret; } +std::string multiSlsDetector::concatenateIfDifferent(const std::vector& return_values) { + std::string concatenatedValue, firstValue; + bool valueNotSame = false; -int multiSlsDetector::decodeNMod(int i, int& id, int& im) { -#ifdef VERBOSE - cout << " Module " << i << " belongs to detector " << id << endl; - ; - cout << getMaxMods(); -#endif - - if (i < 0 || i >= getMaxMods()) { - id = -1; - im = -1; -#ifdef VERBOSE - cout << " A---------" << id << " position " << im << endl; -#endif - - return -1; - } - int nm; for (unsigned int idet = 0; idet < detectors.size(); ++idet) { - nm = detectors[idet]->getNMods(); - if (nm > i) { - id = idet; - im = i; -#ifdef VERBOSE - cout << " B---------" << id << " position " << im << endl; -#endif - return im; + if (firstValue.empty()) { + concatenatedValue = return_values[idet]; + firstValue = return_values[idet]; } else { - i -= nm; + concatenatedValue += "+" + return_values[idet]; } + if (firstValue != return_values[idet]) + valueNotSame = true; } - id = -1; - im = -1; -#ifdef VERBOSE - cout << " C---------" << id << " position " << im << endl; -#endif - return -1; + if (valueNotSame) + return concatenatedValue; + else + return firstValue; } - int multiSlsDetector::decodeNChannel(int offsetX, int offsetY, int& channelX, int& channelY) { channelX = -1; channelY = -1; @@ -290,14 +298,14 @@ int multiSlsDetector::decodeNChannel(int offsetX, int offsetY, int& channelX, in int y = detectors[i]->getDetectorOffset(Y); //check x offset range if ((offsetX >= x) && - (offsetX < (x + detectors[i]->getMaxNumberOfChannelsInclGapPixels(X)))) { + (offsetX < (x + detectors[i]->getTotalNumberOfChannelsInclGapPixels(X)))) { if (offsetY == -1) { channelX = offsetX - x; return i; } else { //check y offset range if ((offsetY >= y) && - (offsetY < (y + detectors[i]->getMaxNumberOfChannelsInclGapPixels(Y)))) { + (offsetY < (y + detectors[i]->getTotalNumberOfChannelsInclGapPixels(Y)))) { channelX = offsetX - x; channelY = offsetY - y; return i; @@ -309,198 +317,6 @@ int multiSlsDetector::decodeNChannel(int offsetX, int offsetY, int& channelX, in } -double* multiSlsDetector::decodeData(int* datain, int& nn, double* fdata) { - double* dataout; - - if (fdata) - dataout = fdata; - else { - if (detectors[0]->getDetectorsType() == JUNGFRAUCTB) { - nn = thisMultiDetector->dataBytes / 2; - dataout = new double[nn]; - } else { - nn = thisMultiDetector->numberOfChannels; - dataout = new double[nn]; - } - } - - int n; - double* detp = dataout; - int* datap = datain; - - for (unsigned int i = 0; i < detectors.size(); ++i) { - detectors[i]->decodeData(datap, n, detp); - if (detectors[i]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << i)); -#ifdef VERBOSE - cout << "increment pointers " << endl; -#endif - datap += detectors[i]->getDataBytes() / sizeof(int); - detp += n; -#ifdef VERBOSE - cout << "done " << endl; -#endif - } - - return dataout; -} - - - -int multiSlsDetector::writeDataFile(std::string fname, double* data, double* err, - double* ang, char dataformat, int nch) { -#ifdef VERBOSE - cout << "using overloaded multiSlsDetector function to write formatted data file " - << getTotalNumberOfChannels() << endl; -#endif - - std::ofstream outfile; - int choff = 0, off = 0; //idata, - double *pe = err, *pa = ang; - int nch_left = nch, n; //, nd; - - if (nch_left <= 0) - nch_left = getTotalNumberOfChannels(); - - if (data == NULL) - return FAIL; - - outfile.open(fname.c_str(), std::ios_base::out); - if (outfile.is_open()) { - - for (unsigned int i = 0; i < detectors.size(); ++i) { - n = detectors[i]->getTotalNumberOfChannels(); - if (nch_left < n) - n = nch_left; -#ifdef VERBOSE - cout << " write " << i << " position " << off << " offset " << choff << endl; -#endif - fileIOStatic::writeDataFile(outfile, n, data + off, pe, pa, dataformat, choff); - if (detectors[i]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << i)); - - nch_left -= n; - - choff += detectors[i]->getMaxNumberOfChannels(); - - off += n; - - if (pe) - pe = err + off; - - if (pa) - pa = ang + off; - } - outfile.close(); - return OK; - } else { - std::cout << "Could not open file " << fname << "for writing" << std::endl; - return FAIL; - } -} - -int multiSlsDetector::writeDataFile(std::string fname, int* data) { - std::ofstream outfile; - int choff = 0, off = 0; -#ifdef VERBOSE - cout << "using overloaded multiSlsDetector function to write raw data file " << endl; -#endif - - if (data == NULL) - return FAIL; - - outfile.open(fname.c_str(), std::ios_base::out); - if (outfile.is_open()) { - for (unsigned int i = 0; i < detectors.size(); ++i) { -#ifdef VERBOSE - cout << " write " << i << " position " << off << " offset " << choff << endl; -#endif - detectors[i]->writeDataFile(outfile, - detectors[i]->getTotalNumberOfChannels(), data + off, choff); - if (detectors[i]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << i)); - choff += detectors[i]->getMaxNumberOfChannels(); - off += detectors[i]->getTotalNumberOfChannels(); - } - outfile.close(); - return OK; - } else { - std::cout << "Could not open file " << fname << "for writing" << std::endl; - return FAIL; - } -} - -int multiSlsDetector::readDataFile(std::string fname, double* data, double* err, - double* ang, char dataformat) { -#ifdef VERBOSE - cout << "using overloaded multiSlsDetector function to read formatted data file " << endl; -#endif - - std::ifstream infile; - int iline = 0; - std::string str; - int choff = 0, off = 0; - double *pe = err, *pa = ang; - -#ifdef VERBOSE - std::cout << "Opening file " << fname << std::endl; -#endif - infile.open(fname.c_str(), std::ios_base::in); - if (infile.is_open()) { - - for (unsigned int i = 0; i < detectors.size(); ++i) { - iline += detectors[i]->readDataFile(detectors[i]->getTotalNumberOfChannels(), - infile, data + off, pe, pa, dataformat, choff); - if (detectors[i]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << i)); - choff += detectors[i]->getMaxNumberOfChannels(); - off += detectors[i]->getTotalNumberOfChannels(); - if (pe) - pe = pe + off; - if (pa) - pa = pa + off; - } - - infile.close(); - } else { - std::cout << "Could not read file " << fname << std::endl; - return -1; - } - return iline; -} - -int multiSlsDetector::readDataFile(std::string fname, int* data) { -#ifdef VERBOSE - cout << "using overloaded multiSlsDetector function to read raw data file " << endl; -#endif - std::ifstream infile; - int iline = 0; - std::string str; - int choff = 0, off = 0; - -#ifdef VERBOSE - std::cout << "Opening file " << fname << std::endl; -#endif - infile.open(fname.c_str(), std::ios_base::in); - if (infile.is_open()) { - - for (unsigned int i = 0; i < detectors.size(); ++i) { - iline += detectors[i]->readDataFile(infile, data + off, - detectors[i]->getTotalNumberOfChannels(), choff); - if (detectors[i]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << i)); - choff += detectors[i]->getMaxNumberOfChannels(); - off += detectors[i]->getTotalNumberOfChannels(); - } - infile.close(); - } else { - std::cout << "Could not read file " << fname << std::endl; - return -1; - } - return iline; -} - - std::string multiSlsDetector::getErrorMessage(int& critical) { int64_t multiMask, slsMask = 0; std::string retval = ""; @@ -588,17 +404,20 @@ int multiSlsDetector::checkVersionCompatibility(portType t) { } int64_t multiSlsDetector::getId(idMode mode, int imod) { - int id, im; - int64_t ret; - if (decodeNMod(imod, id, im) >= 0) { - if (id < 0 || id >= (int)detectors.size()) - return -1; - ret = detectors[id]->getId(mode, im); - if (detectors[id]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << id)); - return ret; + + // single + { + if (imod >= 0) { + if (imod < 0 || imod >= (int)detectors.size()) + return -1; + int64_t ret = detectors[imod]->getId(mode, imod); + if (detectors[imod]->getErrorMask()) + setErrorMask(getErrorMask() | (1 << imod)); + return ret; + } } + // multi return callDetectorMember(&slsDetector::getId, mode, imod); } @@ -693,7 +512,7 @@ std::string multiSlsDetector::getUserDetails() { sstream << "\nPID: " << thisMultiDetector->lastPID //user << "\nUser: " << thisMultiDetector->lastUser - << "\nDate: " << thisMultiDetector->lastDate << endl; + << "\nDate: " << thisMultiDetector->lastDate << std::endl; std::string s = sstream.str(); return s; @@ -752,8 +571,6 @@ void multiSlsDetector::initializeDetectorStructure() { thisMultiDetector->numberOfDetector[Y] = 0; thisMultiDetector->onlineFlag = 1; thisMultiDetector->stoppedFlag = 0; - thisMultiDetector->masterPosition = -1; - thisMultiDetector->syncMode = GET_SYNCHRONIZATION_MODE; thisMultiDetector->dataBytes = 0; thisMultiDetector->dataBytesInclGapPixels = 0; thisMultiDetector->numberOfChannels = 0; @@ -761,11 +578,6 @@ void multiSlsDetector::initializeDetectorStructure() { thisMultiDetector->numberOfChannel[Y] = 0; thisMultiDetector->numberOfChannelInclGapPixels[X] = 0; thisMultiDetector->numberOfChannelInclGapPixels[Y] = 0; - thisMultiDetector->maxNumberOfChannels = 0; - thisMultiDetector->maxNumberOfChannel[X] = 0; - thisMultiDetector->maxNumberOfChannel[Y] = 0; - thisMultiDetector->maxNumberOfChannelInclGapPixels[X] = 0; - thisMultiDetector->maxNumberOfChannelInclGapPixels[Y] = 0; thisMultiDetector->maxNumberOfChannelsPerDetector[X] = 0; thisMultiDetector->maxNumberOfChannelsPerDetector[Y] = 0; for (int i = 0; i < MAX_TIMERS; ++i) { @@ -773,51 +585,9 @@ void multiSlsDetector::initializeDetectorStructure() { } thisMultiDetector->currentSettings = GET_SETTINGS; thisMultiDetector->currentThresholdEV = -1; - thisMultiDetector->progressIndex = 0; - thisMultiDetector->totalProgress = 1; - thisMultiDetector->fileIndex = 0; - strcpy(thisMultiDetector->fileName, "run"); - strcpy(thisMultiDetector->filePath, "/"); - thisMultiDetector->framesPerFile = 1; - thisMultiDetector->fileFormatType = ASCII; - thisMultiDetector->correctionMask = (1 << WRITE_FILE) | (1 << OVERWRITE_FILE); thisMultiDetector->threadedProcessing = 1; thisMultiDetector->tDead = 0; - strncpy(thisMultiDetector->flatFieldDir, getenv("HOME"), MAX_STR_LENGTH-1); - thisMultiDetector->flatFieldDir[MAX_STR_LENGTH-1] = 0; - strcpy(thisMultiDetector->flatFieldFile, "none"); - strcpy(thisMultiDetector->badChanFile, "none"); - strcpy(thisMultiDetector->angConvFile, "none"); - thisMultiDetector->angDirection = 1; - thisMultiDetector->fineOffset = 0; - thisMultiDetector->globalOffset = 0; - thisMultiDetector->binSize = 0.001; - for (int i = 0; i < 2; ++i) { - thisMultiDetector->sampleDisplacement[i] = 0.0; - } - thisMultiDetector->numberOfPositions = 0; - for (int i = 0; i < MAXPOS; ++i) { - thisMultiDetector->detPositions[i] = 0.0; - } - thisMultiDetector->actionMask = 0; - for (int i = 0; i < MAX_ACTIONS; ++i) { - strcpy(thisMultiDetector->actionScript[i], "none"); - strcpy(thisMultiDetector->actionParameter[i], "none"); - } - for (int i = 0; i < MAX_SCAN_LEVELS; ++i) { - thisMultiDetector->scanMode[i] = 0; - strcpy(thisMultiDetector->scanScript[i], "none"); - strcpy(thisMultiDetector-> scanParameter[i], "none"); - thisMultiDetector->nScanSteps[i] = 0; - { - double initValue = 0; - std::fill_n(thisMultiDetector->scanSteps[i], MAX_SCAN_STEPS, initValue); - } - thisMultiDetector->scanPrecision[i] = 0; - - } thisMultiDetector->acquiringFlag = false; - thisMultiDetector->externalgui = false; thisMultiDetector->receiverOnlineFlag = OFFLINE_FLAG; thisMultiDetector->receiver_upstream = false; } @@ -829,52 +599,11 @@ void multiSlsDetector::initializeMembers(bool verify) { currentSettings = &thisMultiDetector->currentSettings; currentThresholdEV = &thisMultiDetector->currentThresholdEV; - //fileIO.h - filePath = thisMultiDetector->filePath; - fileName = thisMultiDetector->fileName; - fileIndex = &thisMultiDetector->fileIndex; - framesPerFile = &thisMultiDetector->framesPerFile; - fileFormatType = &thisMultiDetector->fileFormatType; - //postprocessing threadedProcessing = &thisMultiDetector->threadedProcessing; - correctionMask = &thisMultiDetector->correctionMask; - flatFieldDir = thisMultiDetector->flatFieldDir; - flatFieldFile = thisMultiDetector->flatFieldFile; - expTime = &timerValue[ACQUISITION_TIME]; - badChannelMask = NULL; fdata = NULL; thisData = NULL; - //slsDetectorActions - actionMask = &thisMultiDetector->actionMask; - actionScript = thisMultiDetector->actionScript; - actionParameter = thisMultiDetector->actionParameter; - nScanSteps = thisMultiDetector->nScanSteps; - scanSteps = thisMultiDetector->scanSteps; - scanMode = thisMultiDetector->scanMode; - scanPrecision = thisMultiDetector->scanPrecision; - scanScript = thisMultiDetector->scanScript; - scanParameter = thisMultiDetector->scanParameter; - - //angularConversion.h - numberOfPositions = &thisMultiDetector->numberOfPositions; - detPositions = thisMultiDetector->detPositions; - angConvFile = thisMultiDetector->angConvFile; - binSize = &thisMultiDetector->binSize; - fineOffset = &thisMultiDetector->fineOffset; - globalOffset = &thisMultiDetector->globalOffset; - angDirection = &thisMultiDetector->angDirection; - moveFlag = NULL; - sampleDisplacement = thisMultiDetector->sampleDisplacement; - - //badChannelCorrections.h or postProcessing_Standalone.h - badChanFile = thisMultiDetector->badChanFile; - nBadChans = NULL; - badChansList = NULL; - nBadFF = NULL; - badFFList = NULL; - //multiSlsDetector for (std::vector::const_iterator it = zmqSocket.begin(); it != zmqSocket.end(); ++it) { delete(*it); @@ -980,12 +709,12 @@ void multiSlsDetector::addMultipleDetectors(const char* name) { void multiSlsDetector::addSlsDetector (std::string s) { #ifdef VERBOSE - cout << "Adding detector " << s << endl; + std::cout << "Adding detector " << s << std::endl; #endif for (std::vector::const_iterator it = detectors.begin(); it != detectors.end(); ++it) { if ((*it)->getHostname((it-detectors.begin())) == s) { - cout << "Detector " << s << "already part of the multiDetector!" << endl - << "Remove it before adding it back in a new position!" << endl; + std::cout << "Detector " << s << "already part of the multiDetector!" << std::endl + << "Remove it before adding it back in a new position!" << std::endl; return; } } @@ -996,7 +725,7 @@ void multiSlsDetector::addSlsDetector (std::string s) { // get type by connecting detectorType type = slsDetector::getDetectorType(s.c_str(), DEFAULT_PORTNO); if (type == GENERIC) { - cout << "Could not connect to Detector " << s << " to determine the type!" << endl; + std::cout << "Could not connect to Detector " << s << " to determine the type!" << std::endl; setErrorMask(getErrorMask() | MULTI_DETECTORS_NOT_ADDED); appendNotAddedList(s.c_str()); return; @@ -1014,7 +743,6 @@ void multiSlsDetector::addSlsDetector (std::string s) { thisMultiDetector->dataBytes += detectors[pos]->getDataBytes(); thisMultiDetector->dataBytesInclGapPixels += detectors[pos]->getDataBytesInclGapPixels(); thisMultiDetector->numberOfChannels += detectors[pos]->getTotalNumberOfChannels(); - thisMultiDetector->maxNumberOfChannels += detectors[pos]->getMaxNumberOfChannels(); } @@ -1048,16 +776,16 @@ void multiSlsDetector::createThreadPool() { threadpool = new ThreadPool(numthreads); switch (threadpool->initialize_threadpool()) { case 0: - std::cerr << "Failed to initialize thread pool!" << endl; + std::cerr << "Failed to initialize thread pool!" << std::endl; throw ThreadpoolException(); case 1: #ifdef VERBOSE - cout << "Not initializing threads, not multi detector" << endl; + std::cout << "Not initializing threads, not multi detector" << std::endl; #endif break; default: #ifdef VERBOSE - cout << "Initialized Threadpool " << threadpool << endl; + std::cout << "Initialized Threadpool " << threadpool << std::endl; #endif break; } @@ -1069,7 +797,7 @@ void multiSlsDetector::destroyThreadPool() { delete threadpool; threadpool = 0; #ifdef VERBOSE - cout << "Destroyed Threadpool " << threadpool << endl; + std::cout << "Destroyed Threadpool " << threadpool << std::endl; #endif } } @@ -1087,98 +815,6 @@ void multiSlsDetector::getNumberOfDetectors(int& nx, int& ny) { nx=thisMultiDetector->numberOfDetector[X];ny=thisMultiDetector->numberOfDetector[Y]; } -int multiSlsDetector::getNMods() { - int nm = 0; - for (std::vector::const_iterator it = detectors.begin(); it != detectors.end(); ++it) { - nm += (*it)->getNMods(); - } - return nm; -} - -int multiSlsDetector::getNMod(dimension d) { - int nm = 0; - for (std::vector::const_iterator it = detectors.begin(); it != detectors.end(); ++it) { - nm += (*it)->getNMod(d); - } - return nm; -} - -int multiSlsDetector::getMaxMods() { - int ret = 0; - for (std::vector::const_iterator it = detectors.begin(); it != detectors.end(); ++it) { - ret += (*it)->getMaxMods(); - } - return ret; -} - -int multiSlsDetector::getMaxMod(dimension d) { - int ret = 0, ret1; - for (std::vector::const_iterator it = detectors.begin(); it != detectors.end(); ++it) { - ret1 = (*it)->getNMaxMod(d); -#ifdef VERBOSE - cout << "detector " << (it-detectors.begin()) << " maxmods " << - ret1 << " in direction " << d << endl; -#endif - ret += ret1; - } -#ifdef VERBOSE - cout << "max mods in direction " << d << " is " << ret << endl; -#endif - - return ret; -} - -int multiSlsDetector::getMaxNumberOfModules(dimension d) { - int ret = 0; - for (std::vector::const_iterator it = detectors.begin(); it != detectors.end(); ++it) { - ret += (*it)->getMaxNumberOfModules(d); - } - return ret; -} - -int multiSlsDetector::setNumberOfModules(int p, dimension d) { - int ret = 0; - int nm = 0, mm = 0, nt = p; - - thisMultiDetector->dataBytes = 0; - thisMultiDetector->dataBytesInclGapPixels = 0; - thisMultiDetector->numberOfChannels = 0; - - for (unsigned int idet = 0; idet < detectors.size(); ++idet) { - if (p < 0) - nm = p; - else { - mm = detectors[idet]->getMaxNumberOfModules(); - if (nt > mm) { - nm = mm; - nt -= nm; - } else { - nm = nt; - nt -= nm; - } - } - ret += detectors[idet]->setNumberOfModules(nm); - if (detectors[idet]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << idet)); - thisMultiDetector->dataBytes += detectors[idet]->getDataBytes(); - thisMultiDetector->dataBytesInclGapPixels += detectors[idet]->getDataBytesInclGapPixels(); - thisMultiDetector->numberOfChannels += detectors[idet]->getTotalNumberOfChannels(); - } - - if (p != -1) - updateOffsets(); - return ret; -} - -int multiSlsDetector::getChansPerMod(int imod) { - int id = -1, im = -1; - decodeNMod(imod, id, im); - if (id >= 0 && id < (int)detectors.size()) { - return detectors[id]->getChansPerMod(im); - } - return -1; -} - int multiSlsDetector::getTotalNumberOfChannels() { thisMultiDetector->numberOfChannels = 0; for (std::vector::const_iterator it = detectors.begin(); it != detectors.end(); ++it) { @@ -1195,22 +831,6 @@ int multiSlsDetector::getTotalNumberOfChannelsInclGapPixels(dimension d) { return thisMultiDetector->numberOfChannelInclGapPixels[d]; } -int multiSlsDetector::getMaxNumberOfChannels() { - thisMultiDetector->maxNumberOfChannels = 0; - for (std::vector::const_iterator it = detectors.begin(); it != detectors.end(); ++it) { - thisMultiDetector->maxNumberOfChannels += (*it)->getMaxNumberOfChannels(); - } - return thisMultiDetector->maxNumberOfChannels; -} - -int multiSlsDetector::getMaxNumberOfChannels(dimension d) { - return thisMultiDetector->maxNumberOfChannel[d]; -} - -int multiSlsDetector::getMaxNumberOfChannelsInclGapPixels(dimension d) { - return thisMultiDetector->maxNumberOfChannelInclGapPixels[d]; -} - int multiSlsDetector::getMaxNumberOfChannelsPerDetector(dimension d) { return thisMultiDetector->maxNumberOfChannelsPerDetector[d]; } @@ -1236,10 +856,10 @@ void multiSlsDetector::setDetectorOffset(dimension d, int off, int pos) { void multiSlsDetector::updateOffsets() { //cannot paralllize due to slsdetector calling this via parentdet-> #ifdef VERBOSE - cout << endl - << "Updating Multi-Detector Offsets" << endl; + std::cout << std::endl + << "Updating Multi-Detector Offsets" << std::endl; #endif - int offsetX = 0, offsetY = 0, numX = 0, numY = 0, maxX = 0, maxY = 0; + int offsetX = 0, offsetY = 0, numX = 0, numY = 0; int maxChanX = thisMultiDetector->maxNumberOfChannelsPerDetector[X]; int maxChanY = thisMultiDetector->maxNumberOfChannelsPerDetector[Y]; int prevChanX = 0; @@ -1248,42 +868,39 @@ void multiSlsDetector::updateOffsets() { thisMultiDetector->numberOfChannel[X] = 0; thisMultiDetector->numberOfChannel[Y] = 0; - thisMultiDetector->maxNumberOfChannel[X] = 0; - thisMultiDetector->maxNumberOfChannel[Y] = 0; thisMultiDetector->numberOfDetector[X] = 0; thisMultiDetector->numberOfDetector[Y] = 0; // gap pixels - int offsetX_gp = 0, offsetY_gp = 0, numX_gp = 0, numY_gp = 0, maxX_gp = 0, maxY_gp = 0; + int offsetX_gp = 0, offsetY_gp = 0, numX_gp = 0, numY_gp = 0; int prevChanX_gp = 0, prevChanY_gp = 0; thisMultiDetector->numberOfChannelInclGapPixels[X] = 0; thisMultiDetector->numberOfChannelInclGapPixels[Y] = 0; - thisMultiDetector->maxNumberOfChannelInclGapPixels[X] = 0; - thisMultiDetector->maxNumberOfChannelInclGapPixels[Y] = 0; + for (unsigned int idet = 0; idet < detectors.size(); ++idet) { #ifdef VERBOSE - cout << "offsetX:" << offsetX << " prevChanX:" << prevChanX << " " - "offsetY:" << offsetY << " prevChanY:" << prevChanY << endl; - cout << "offsetX_gp:" << offsetX_gp << " " + std::cout << "offsetX:" << offsetX << " prevChanX:" << prevChanX << " " + "offsetY:" << offsetY << " prevChanY:" << prevChanY << std::endl; + std::cout << "offsetX_gp:" << offsetX_gp << " " "prevChanX_gp:" << prevChanX_gp << " " "offsetY_gp:" << offsetY_gp << " " - "prevChanY_gp:" << prevChanY_gp << endl; + "prevChanY_gp:" << prevChanY_gp << std::endl; #endif - //cout<<" totalchan:"<< detectors[idet]->getTotalNumberOfChannels(Y) - //<<" maxChanY:"<getTotalNumberOfChannels(Y) + //<<" maxChanY:"< 0) && ((offsetX + detectors[idet]->getTotalNumberOfChannels(X)) > maxChanX)) - cout << "\nDetector[" << idet << "] exceeds maximum channels " - "allowed for complete detector set in X dimension!" << endl; + std::cout << "\nDetector[" << idet << "] exceeds maximum channels " + "allowed for complete detector set in X dimension!" << std::endl; if ((maxChanY > 0) && ((offsetY + detectors[idet]->getTotalNumberOfChannels(Y)) > maxChanY)) - cout << "\nDetector[" << idet << "] exceeds maximum channels " - "allowed for complete detector set in Y dimension!" << endl; + std::cout << "\nDetector[" << idet << "] exceeds maximum channels " + "allowed for complete detector set in Y dimension!" << std::endl; prevChanX = detectors[idet]->getTotalNumberOfChannels(X); prevChanY = detectors[idet]->getTotalNumberOfChannels(Y); prevChanX_gp = detectors[idet]->getTotalNumberOfChannelsInclGapPixels(X); @@ -1292,14 +909,10 @@ void multiSlsDetector::updateOffsets() { numY += detectors[idet]->getTotalNumberOfChannels(Y); numX_gp += detectors[idet]->getTotalNumberOfChannelsInclGapPixels(X); numY_gp += detectors[idet]->getTotalNumberOfChannelsInclGapPixels(Y); - maxX += detectors[idet]->getMaxNumberOfChannels(X); - maxY += detectors[idet]->getMaxNumberOfChannels(Y); - maxX_gp += detectors[idet]->getMaxNumberOfChannelsInclGapPixels(X); - maxY_gp += detectors[idet]->getMaxNumberOfChannelsInclGapPixels(Y); ++thisMultiDetector->numberOfDetector[X]; ++thisMultiDetector->numberOfDetector[Y]; #ifdef VERBOSE - cout << "incrementing in both direction" << endl; + std::cout << "incrementing in both direction" << std::endl; #endif } @@ -1313,11 +926,9 @@ void multiSlsDetector::updateOffsets() { prevChanY_gp = detectors[idet]->getTotalNumberOfChannelsInclGapPixels(Y); numY += detectors[idet]->getTotalNumberOfChannels(Y); numY_gp += detectors[idet]->getTotalNumberOfChannelsInclGapPixels(Y); - maxY += detectors[idet]->getMaxNumberOfChannels(Y); - maxY_gp += detectors[idet]->getMaxNumberOfChannelsInclGapPixels(Y); ++thisMultiDetector->numberOfDetector[Y]; #ifdef VERBOSE - cout << "incrementing in y direction" << endl; + std::cout << "incrementing in y direction" << std::endl; #endif } @@ -1326,8 +937,8 @@ void multiSlsDetector::updateOffsets() { if ((maxChanX > 0) && ((offsetX + prevChanX + detectors[idet]->getTotalNumberOfChannels(X)) > maxChanX)) - cout << "\nDetector[" << idet << "] exceeds maximum channels " - "allowed for complete detector set in X dimension!" << endl; + std::cout << "\nDetector[" << idet << "] exceeds maximum channels " + "allowed for complete detector set in X dimension!" << std::endl; offsetY = 0; offsetY_gp = 0; prevChanY = detectors[idet]->getTotalNumberOfChannels(Y); @@ -1335,32 +946,28 @@ void multiSlsDetector::updateOffsets() { numY = 0; //assuming symmetry with this statement. //whats on 1st column should be on 2nd column numY_gp = 0; - maxY = 0; - maxY_gp = 0; offsetX += prevChanX; offsetX_gp += prevChanX_gp; prevChanX = detectors[idet]->getTotalNumberOfChannels(X); prevChanX_gp = detectors[idet]->getTotalNumberOfChannelsInclGapPixels(X); numX += detectors[idet]->getTotalNumberOfChannels(X); numX_gp += detectors[idet]->getTotalNumberOfChannelsInclGapPixels(X); - maxX += detectors[idet]->getMaxNumberOfChannels(X); - maxX_gp += detectors[idet]->getMaxNumberOfChannelsInclGapPixels(X); ++thisMultiDetector->numberOfDetector[X]; #ifdef VERBOSE - cout << "incrementing in x direction" << endl; + std::cout << "incrementing in x direction" << std::endl; #endif } double bytesperchannel = (double)detectors[idet]->getDataBytes() / - (double)(detectors[idet]->getMaxNumberOfChannels(X) - * detectors[idet]->getMaxNumberOfChannels(Y)); + (double)(detectors[idet]->getTotalNumberOfChannels(X) + * detectors[idet]->getTotalNumberOfChannels(Y)); detectors[idet]->setDetectorOffset(X, (bytesperchannel >= 1.0) ? offsetX_gp : offsetX); detectors[idet]->setDetectorOffset(Y, (bytesperchannel >= 1.0) ? offsetY_gp : offsetY); #ifdef VERBOSE - cout << "Detector[" << idet << "] has offsets (" << + std::cout << "Detector[" << idet << "] has offsets (" << detectors[idet]->getDetectorOffset(X) << ", " << - detectors[idet]->getDetectorOffset(Y) << ")" << endl; + detectors[idet]->getDetectorOffset(Y) << ")" << std::endl; #endif //offsetY has been reset sometimes and offsetX the first time, //but remember the highest values @@ -1372,24 +979,16 @@ void multiSlsDetector::updateOffsets() { thisMultiDetector->numberOfChannelInclGapPixels[X] = numX_gp; if (numY_gp > thisMultiDetector->numberOfChannelInclGapPixels[Y]) thisMultiDetector->numberOfChannelInclGapPixels[Y] = numY_gp; - if (maxX > thisMultiDetector->maxNumberOfChannel[X]) - thisMultiDetector->maxNumberOfChannel[X] = maxX; - if (maxY > thisMultiDetector->maxNumberOfChannel[Y]) - thisMultiDetector->maxNumberOfChannel[Y] = maxY; - if (maxX_gp > thisMultiDetector->maxNumberOfChannelInclGapPixels[X]) - thisMultiDetector->maxNumberOfChannelInclGapPixels[X] = maxX_gp; - if (maxY_gp > thisMultiDetector->maxNumberOfChannelInclGapPixels[Y]) - thisMultiDetector->maxNumberOfChannelInclGapPixels[Y] = maxY_gp; } #ifdef VERBOSE - cout << "Number of Channels in X direction:" << thisMultiDetector->numberOfChannel[X] << endl; - cout << "Number of Channels in Y direction:" << thisMultiDetector->numberOfChannel[Y] << endl - << endl; - cout << "Number of Channels in X direction with Gap Pixels:" << - thisMultiDetector->numberOfChannelInclGapPixels[X] << endl; - cout << "Number of Channels in Y direction with Gap Pixels:" << - thisMultiDetector->numberOfChannelInclGapPixels[Y] << endl - << endl; + std::cout << "Number of Channels in X direction:" << thisMultiDetector->numberOfChannel[X] << std::endl; + std::cout << "Number of Channels in Y direction:" << thisMultiDetector->numberOfChannel[Y] << std::endl + << std::endl; + std::cout << "Number of Channels in X direction with Gap Pixels:" << + thisMultiDetector->numberOfChannelInclGapPixels[X] << std::endl; + std::cout << "Number of Channels in Y direction with Gap Pixels:" << + thisMultiDetector->numberOfChannelInclGapPixels[Y] << std::endl + << std::endl; #endif } @@ -1412,8 +1011,8 @@ std::string multiSlsDetector::checkOnline() { } -int multiSlsDetector::setPort(portType t, int p) { - return callDetectorMember(&slsDetector::setPort, t, p); +int multiSlsDetector::setPort(portType t, int num) { + return callDetectorMember(&slsDetector::setPort, t, num); } int multiSlsDetector::lockServer(int p) { @@ -1489,10 +1088,10 @@ int multiSlsDetector::readConfigurationFile(std::string const fname) { ++iargval; } #ifdef VERBOSE - cout << endl; + std::cout << std::endl; for (int ia = 0; ia < iargval; ia++) - cout << args[ia] << " ??????? "; - cout << endl; + std::cout << args[ia] << " ??????? "; + std::cout << std::endl; #endif cmd = new multiSlsDetectorClient(iargval, args, PUT_ACTION, this); delete cmd; @@ -1510,9 +1109,6 @@ int multiSlsDetector::readConfigurationFile(std::string const fname) { std::cout << "Read configuration file of " << iline << " lines" << std::endl; #endif - setNumberOfModules(-1); - getMaxNumberOfModules(); - if (getErrorMask()) { int c; cprintf(RED, "\n----------------\n Error Messages\n----------------\n%s\n", @@ -1529,18 +1125,7 @@ int multiSlsDetector::writeConfigurationFile(std::string const fname) { std::string names[] = { "detsizechan", "hostname", - "master", - "sync", "outdir", - "ffdir", - "headerbefore", - "headerafter", - "headerbeforepar", - "headerafterpar", - "badchannels", - "angconv", - "globaloff", - "binsize", "threaded" }; @@ -1560,20 +1145,20 @@ int multiSlsDetector::writeConfigurationFile(std::string const fname) { slsDetectorCommand* cmd = new slsDetectorCommand(this); // complete size of detector - cout << iline << " " << names[iline] << endl; + std::cout << iline << " " << names[iline] << std::endl; strcpy(args[0], names[iline].c_str()); outfile << names[iline] << " " << cmd->executeLine(1, args, GET_ACTION) << std::endl; ++iline; // hostname of the detectors - cout << iline << " " << names[iline] << endl; + std::cout << iline << " " << names[iline] << std::endl; strcpy(args[0], names[iline].c_str()); outfile << names[iline] << " " << cmd->executeLine(1, args, GET_ACTION) << std::endl; ++iline; // single detector configuration for (unsigned int idet = 0; idet < detectors.size(); ++idet) { - outfile << endl; + outfile << std::endl; ret1 = detectors[idet]->writeConfigurationFile(outfile, idet); if (detectors[idet]->getErrorMask()) setErrorMask(getErrorMask() | (1 << idet)); @@ -1581,10 +1166,10 @@ int multiSlsDetector::writeConfigurationFile(std::string const fname) { ret = FAIL; } - outfile << endl; + outfile << std::endl; //other configurations while (iline < nvar) { - cout << iline << " " << names[iline] << endl; + std::cout << iline << " " << names[iline] << std::endl; strcpy(args[0], names[iline].c_str()); outfile << names[iline] << " " << cmd->executeLine(1, args, GET_ACTION) << std::endl; ++iline; @@ -1624,7 +1209,7 @@ slsDetectorDefs::detectorSettings multiSlsDetector::getSettings(int pos) { } if (!threadpool) { - cout << "Error in creating threadpool. Exiting" << endl; + std::cout << "Error in creating threadpool. Exiting" << std::endl; return GET_SETTINGS; } else { //return storage values @@ -1695,7 +1280,7 @@ int multiSlsDetector::setThresholdEnergy(int e_eV, int pos, detectorSettings ise } if (!threadpool) { - cout << "Error in creating threadpool. Exiting" << endl; + std::cout << "Error in creating threadpool. Exiting" << std::endl; return -1; } else { //return storage values @@ -1738,7 +1323,7 @@ slsDetectorDefs::detectorSettings multiSlsDetector::setSettings(detectorSettings } if (!threadpool) { - cout << "Error in creating threadpool. Exiting" << endl; + std::cout << "Error in creating threadpool. Exiting" << std::endl; return GET_SETTINGS; } else { //return storage values @@ -1844,20 +1429,19 @@ int multiSlsDetector::loadSettingsFile(std::string fname, int imod) { // single { - int id = -1, im = -1; - if (decodeNMod(imod, id, im) >= 0) { - if (id < 0 || id >= (int)detectors.size()) + if (imod >= 0) { + if (imod < 0 || imod >= (int)detectors.size()) return -1; - ret = detectors[id]->loadSettingsFile(fname, im); - if (detectors[id]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << id)); + ret = detectors[imod]->loadSettingsFile(fname, imod); + if (detectors[imod]->getErrorMask()) + setErrorMask(getErrorMask() | (1 << imod)); return ret; } } // multi if (!threadpool) { - cout << "Error in creating threadpool. Exiting" << endl; + std::cout << "Error in creating threadpool. Exiting" << std::endl; return -1; } @@ -1885,19 +1469,26 @@ int multiSlsDetector::loadSettingsFile(std::string fname, int imod) { } int multiSlsDetector::saveSettingsFile(std::string fname, int imod) { - int id = -1, im = -1, ret; - - if (decodeNMod(imod, id, im) >= 0) { - if (id < 0 || id >= (int)detectors.size()) - return -1; - ret = detectors[id]->saveSettingsFile(fname, im); - if (detectors[id]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << id)); - return ret; + int ret = OK; + // single + { + if (imod >= 0) { + if (imod < 0 || imod >= (int)detectors.size()) + return -1; + ret = detectors[imod]->saveSettingsFile(fname, imod); + if (detectors[imod]->getErrorMask()) + setErrorMask(getErrorMask() | (1 << imod)); + return ret; + } } + + // multi + int ret1 = OK; for (unsigned int idet = 0; idet < detectors.size(); ++idet) { - ret = detectors[idet]->saveSettingsFile(fname, imod); + ret1 = detectors[idet]->saveSettingsFile(fname, imod); + if (ret1 == FAIL) + ret = FAIL; if (detectors[idet]->getErrorMask()) setErrorMask(getErrorMask() | (1 << idet)); } @@ -1910,20 +1501,19 @@ int multiSlsDetector::loadCalibrationFile(std::string fname, int imod) { // single { - int id = -1, im = -1; - if (decodeNMod(imod, id, im) >= 0) { - if (id < 0 || id >= (int)detectors.size()) + if (imod >= 0) { + if (imod < 0 || imod >= (int)detectors.size()) return -1; - ret = detectors[id]->loadCalibrationFile(fname, im); - if (detectors[id]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << id)); + ret = detectors[imod]->loadCalibrationFile(fname, imod); + if (detectors[imod]->getErrorMask()) + setErrorMask(getErrorMask() | (1 << imod)); return ret; } } // multi if (!threadpool) { - cout << "Error in creating threadpool. Exiting" << endl; + std::cout << "Error in creating threadpool. Exiting" << std::endl; return -1; } @@ -1955,17 +1545,26 @@ int multiSlsDetector::loadCalibrationFile(std::string fname, int imod) { } int multiSlsDetector::saveCalibrationFile(std::string fname, int imod) { - int id = -1, im = -1, ret; - if (decodeNMod(imod, id, im) >= 0) { - if (id < 0 || id >= (int)detectors.size()) - return -1; - ret = detectors[id]->saveCalibrationFile(fname, im); - if (detectors[id]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << id)); - return ret; + int ret = OK; + + // single + { + if (imod >= 0) { + if (imod < 0 || imod >= (int)detectors.size()) + return -1; + ret = detectors[imod]->saveCalibrationFile(fname, imod); + if (detectors[imod]->getErrorMask()) + setErrorMask(getErrorMask() | (1 << imod)); + return ret; + } } + + // multi + int ret1 = OK; for (unsigned int idet = 0; idet < detectors.size(); ++idet) { - ret = detectors[idet]->saveCalibrationFile(fname, imod); + ret1 = detectors[idet]->saveCalibrationFile(fname, imod); + if (ret1 == FAIL) + ret = FAIL; if (detectors[idet]->getErrorMask()) setErrorMask(getErrorMask() | (1 << idet)); } @@ -1974,111 +1573,8 @@ int multiSlsDetector::saveCalibrationFile(std::string fname, int imod) { -int multiSlsDetector::setMaster(int i) { - int ret = -1, slave = 0; - masterFlags f; -#ifdef VERBOSE - cout << "settin master in position " << i << endl; -#endif - if (i >= 0 && i < (int)detectors.size()) { -#ifdef VERBOSE - cout << "detector position " << i << " "; -#endif - thisMultiDetector->masterPosition = i; - detectors[i]->setMaster(IS_MASTER); - if (detectors[i]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << i)); - - for (unsigned int idet = 0; idet < detectors.size(); ++idet) { - if (i != (int)idet) { -#ifdef VERBOSE - cout << "detector position " << idet << " "; -#endif - detectors[idet]->setMaster(IS_SLAVE); - if (detectors[idet]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << idet)); - } - } - - } else if (i == -2) { - for (unsigned int idet = 0; idet < detectors.size(); ++idet) { -#ifdef VERBOSE - cout << "detector position " << idet << " "; -#endif - detectors[idet]->setMaster(NO_MASTER); - if (detectors[idet]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << idet)); - } - } - - // check return value - - for (unsigned int idet = 0; idet < detectors.size(); ++idet) { -#ifdef VERBOSE - cout << "detector position " << idet << " "; -#endif - f = detectors[idet]->setMaster(GET_MASTER); - if (detectors[idet]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << idet)); - - switch (f) { - case NO_MASTER: - if (ret != -1) - ret = -2; - break; - case IS_MASTER: - if (ret == -1) - ret = idet; - else - ret = -2; - break; - case IS_SLAVE: - slave = 1; - break; - default: - ret = -2; - } - - } - if (slave > 0 && ret < 0) - ret = -2; - - if (ret < 0) - ret = -1; - - thisMultiDetector->masterPosition = ret; - - return thisMultiDetector->masterPosition; -} - - -slsDetectorDefs::synchronizationMode multiSlsDetector::setSynchronization(synchronizationMode sync) { - synchronizationMode ret = GET_SYNCHRONIZATION_MODE, ret1 = GET_SYNCHRONIZATION_MODE; - - for (unsigned int idet = 0; idet < detectors.size(); ++idet) { - ret1 = detectors[idet]->setSynchronization(sync); - if (detectors[idet]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << idet)); - if (idet == 0) - ret = ret1; - else if (ret != ret1) - ret = GET_SYNCHRONIZATION_MODE; - } - - thisMultiDetector->syncMode = ret; - - return thisMultiDetector->syncMode; -} - slsDetectorDefs::runStatus multiSlsDetector::getRunStatus() { runStatus s = IDLE, s1 = IDLE; - if (thisMultiDetector->masterPosition >= 0) { - s = detectors[thisMultiDetector->masterPosition]->getRunStatus(); - if (detectors[thisMultiDetector->masterPosition]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << thisMultiDetector->masterPosition)); - return s; - } - for (unsigned int i = 0; i < detectors.size(); ++i) { s1 = detectors[i]->getRunStatus(); if (detectors[i]->getErrorMask()) @@ -2094,95 +1590,35 @@ slsDetectorDefs::runStatus multiSlsDetector::getRunStatus() { int multiSlsDetector::prepareAcquisition() { - int i = 0; int ret = OK; int posmin = 0, posmax = detectors.size(); if (!threadpool) { - cout << "Error in creating threadpool. Exiting" << endl; + std::cout << "Error in creating threadpool. Exiting" << std::endl; return FAIL; } else { int* iret[posmax - posmin]; for (int idet = posmin; idet < posmax; ++idet) { - if (idet != thisMultiDetector->masterPosition) { - iret[idet] = new int(OK); - Task* task = new Task(new func0_t(&slsDetector::prepareAcquisition, - detectors[idet], iret[idet])); - threadpool->add_task(task); - } + iret[idet] = new int(OK); + Task* task = new Task(new func0_t(&slsDetector::prepareAcquisition, + detectors[idet], iret[idet])); + threadpool->add_task(task); } threadpool->startExecuting(); threadpool->wait_for_tasks_to_complete(); for (int idet = posmin; idet < posmax; ++idet) { - if (idet != thisMultiDetector->masterPosition) { - if (iret[idet] != NULL) { - if (*iret[idet] != OK) - ret = FAIL; - delete iret[idet]; - } else + if (iret[idet] != NULL) { + if (*iret[idet] != OK) ret = FAIL; - if (detectors[idet]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << idet)); - } + delete iret[idet]; + } else + ret = FAIL; + if (detectors[idet]->getErrorMask()) + setErrorMask(getErrorMask() | (1 << idet)); + } } - //master - int ret1 = OK; - i = thisMultiDetector->masterPosition; - if (thisMultiDetector->masterPosition >= 0) { - ret1 = detectors[i]->prepareAcquisition(); - if (detectors[i]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << i)); - if (ret1 != OK) - ret = FAIL; - } - - return ret; -} - -int multiSlsDetector::cleanupAcquisition() { - int i = 0; - int ret = OK, ret1 = OK; - int posmin = 0, posmax = detectors.size(); - - i = thisMultiDetector->masterPosition; - if (thisMultiDetector->masterPosition >= 0) { - ret1 = detectors[i]->cleanupAcquisition(); - if (detectors[i]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << i)); - if (ret1 != OK) - ret = FAIL; - } - - if (!threadpool) { - cout << "Error in creating threadpool. Exiting" << endl; - return FAIL; - } else { - int* iret[posmax - posmin]; - for (int idet = posmin; idet < posmax; ++idet) { - if (idet != thisMultiDetector->masterPosition) { - iret[idet] = new int(OK); - Task* task = new Task(new func0_t(&slsDetector::cleanupAcquisition, - detectors[idet], iret[idet])); - threadpool->add_task(task); - } - } - threadpool->startExecuting(); - threadpool->wait_for_tasks_to_complete(); - for (int idet = posmin; idet < posmax; ++idet) { - if (idet != thisMultiDetector->masterPosition) { - if (iret[idet] != NULL) { - if (*iret[idet] != OK) - ret = FAIL; - delete iret[idet]; - } else - ret = FAIL; - if (detectors[idet]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << idet)); - } - } - } return ret; } @@ -2193,94 +1629,68 @@ int multiSlsDetector::startAcquisition() { return FAIL; } - int i = 0; int ret = OK; int posmin = 0, posmax = detectors.size(); if (!threadpool) { - cout << "Error in creating threadpool. Exiting" << endl; + std::cout << "Error in creating threadpool. Exiting" << std::endl; return FAIL; } else { int* iret[posmax - posmin]; for (int idet = posmin; idet < posmax; ++idet) { - if (idet != thisMultiDetector->masterPosition) { - iret[idet] = new int(OK); - Task* task = new Task(new func0_t(&slsDetector::startAcquisition, - detectors[idet], iret[idet])); - threadpool->add_task(task); - } + iret[idet] = new int(OK); + Task* task = new Task(new func0_t(&slsDetector::startAcquisition, + detectors[idet], iret[idet])); + threadpool->add_task(task); } threadpool->startExecuting(); threadpool->wait_for_tasks_to_complete(); for (int idet = posmin; idet < posmax; ++idet) { - if (idet != thisMultiDetector->masterPosition) { - if (iret[idet] != NULL) { - if (*iret[idet] != OK) - ret = FAIL; - delete iret[idet]; - } else + if (iret[idet] != NULL) { + if (*iret[idet] != OK) ret = FAIL; - if (detectors[idet]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << idet)); - } + delete iret[idet]; + } else + ret = FAIL; + if (detectors[idet]->getErrorMask()) + setErrorMask(getErrorMask() | (1 << idet)); + } } - //master - int ret1 = OK; - i = thisMultiDetector->masterPosition; - if (thisMultiDetector->masterPosition >= 0) { - ret1 = detectors[i]->startAcquisition(); - if (detectors[i]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << i)); - if (ret1 != OK) - ret = FAIL; - } return ret; } int multiSlsDetector::stopAcquisition() { pthread_mutex_lock(&mg); // locks due to processing thread using threadpool when in use - int i = 0; - int ret = OK, ret1 = OK; + + int ret = OK; int posmin = 0, posmax = detectors.size(); - i = thisMultiDetector->masterPosition; - if (thisMultiDetector->masterPosition >= 0) { - ret1 = detectors[i]->stopAcquisition(); - if (detectors[i]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << i)); - if (ret1 != OK) - ret = FAIL; - } if (!threadpool) { - cout << "Error in creating threadpool. Exiting" << endl; + std::cout << "Error in creating threadpool. Exiting" << std::endl; return FAIL; } else { int* iret[posmax - posmin]; for (int idet = posmin; idet < posmax; ++idet) { - if (idet != thisMultiDetector->masterPosition) { - iret[idet] = new int(OK); - Task* task = new Task(new func0_t(&slsDetector::stopAcquisition, - detectors[idet], iret[idet])); - threadpool->add_task(task); - } + iret[idet] = new int(OK); + Task* task = new Task(new func0_t(&slsDetector::stopAcquisition, + detectors[idet], iret[idet])); + threadpool->add_task(task); } threadpool->startExecuting(); threadpool->wait_for_tasks_to_complete(); for (int idet = posmin; idet < posmax; ++idet) { - if (idet != thisMultiDetector->masterPosition) { - if (iret[idet] != NULL) { - if (*iret[idet] != OK) - ret = FAIL; - delete iret[idet]; - } else + if (iret[idet] != NULL) { + if (*iret[idet] != OK) ret = FAIL; - if (detectors[idet]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << idet)); - } + delete iret[idet]; + } else + ret = FAIL; + if (detectors[idet]->getErrorMask()) + setErrorMask(getErrorMask() | (1 << idet)); } } @@ -2292,66 +1702,58 @@ int multiSlsDetector::stopAcquisition() { int multiSlsDetector::sendSoftwareTrigger() { - int i = 0; int ret = OK; int posmin = 0, posmax = detectors.size(); if (!threadpool) { - cout << "Error in creating threadpool. Exiting" << endl; + std::cout << "Error in creating threadpool. Exiting" << std::endl; return FAIL; } else { int* iret[posmax - posmin]; for (int idet = posmin; idet < posmax; ++idet) { - if (idet != thisMultiDetector->masterPosition) { - iret[idet] = new int(OK); - Task* task = new Task(new func0_t(&slsDetector::sendSoftwareTrigger, - detectors[idet], iret[idet])); - threadpool->add_task(task); - } + iret[idet] = new int(OK); + Task* task = new Task(new func0_t(&slsDetector::sendSoftwareTrigger, + detectors[idet], iret[idet])); + threadpool->add_task(task); } threadpool->startExecuting(); threadpool->wait_for_tasks_to_complete(); for (int idet = posmin; idet < posmax; ++idet) { - if (idet != thisMultiDetector->masterPosition) { - if (iret[idet] != NULL) { - if (*iret[idet] != OK) - ret = FAIL; - delete iret[idet]; - } else + if (iret[idet] != NULL) { + if (*iret[idet] != OK) ret = FAIL; - if (detectors[idet]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << idet)); - } + delete iret[idet]; + } else + ret = FAIL; + if (detectors[idet]->getErrorMask()) + setErrorMask(getErrorMask() | (1 << idet)); } } - //master - int ret1 = OK; - i = thisMultiDetector->masterPosition; - if (thisMultiDetector->masterPosition >= 0) { - ret1 = detectors[i]->sendSoftwareTrigger(); - if (detectors[i]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << i)); - if (ret1 != OK) - ret = FAIL; - } return ret; } -int multiSlsDetector::startReadOut() { - unsigned int i = 0; - int ret = OK, ret1 = OK; - i = thisMultiDetector->masterPosition; - if (i >= 0) { - ret = detectors[i]->startReadOut(); - if (detectors[i]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << i)); - if (ret != OK) - ret1 = FAIL; +int multiSlsDetector::startAndReadAll() { + pthread_mutex_lock(&mg); // locks due to processing thread using threadpool when in use + if (getDetectorsType() == EIGER) { + if (prepareAcquisition() == FAIL) + return FAIL; } - for (i = 0; i < detectors.size(); ++i) { + + int ret = parallelCallDetectorMember(&slsDetector::startAndReadAll); + pthread_mutex_unlock(&mg); + return ret; +} + + + + +int multiSlsDetector::startReadOut() { + int ret = OK, ret1 = OK; + + for (unsigned int i = 0; i < detectors.size(); ++i) { ret = detectors[i]->startReadOut(); if (detectors[i]->getErrorMask()) setErrorMask(getErrorMask() | (1 << i)); @@ -2363,265 +1765,8 @@ int multiSlsDetector::startReadOut() { } -int* multiSlsDetector::startAndReadAll() { -#ifdef VERBOSE - cout << "Start and read all " << endl; -#endif - int* retval = NULL; - int i = 0; - if (thisMultiDetector->onlineFlag == ONLINE_FLAG) { - - if (getDetectorsType() == EIGER) { - if (prepareAcquisition() == FAIL) - return NULL; - } - startAndReadAllNoWait(); - - while ((retval = getDataFromDetector())) { - ++i; -#ifdef VERBOSE - std::cout << i << std::endl; -#endif - dataQueue.push(retval); - } - - for (unsigned int id = 0; id < detectors.size(); ++id) { - if (detectors[id]) { - detectors[id]->disconnectControl(); - } - } - } -#ifdef VERBOSE - std::cout << "Recieved " << i << " frames" << std::endl; -#endif - return dataQueueFront(); -} - - -int multiSlsDetector::startAndReadAllNoWait() { - pthread_mutex_lock(&mg); // locks due to processing thread using threadpool when in use - int i = 0; - int ret = OK; - int posmin = 0, posmax = detectors.size(); - - if (!threadpool) { - cout << "Error in creating threadpool. Exiting" << endl; - return FAIL; - } else { - int* iret[posmax - posmin]; - for (int idet = posmin; idet < posmax; ++idet) { - if (idet != thisMultiDetector->masterPosition){ - iret[idet] = new int(OK); - Task* task = new Task(new func0_t(&slsDetector::startAndReadAllNoWait, - detectors[idet], iret[idet])); - threadpool->add_task(task); - } - } - threadpool->startExecuting(); - threadpool->wait_for_tasks_to_complete(); - for (int idet = posmin; idet < posmax; ++idet) { - if (idet != thisMultiDetector->masterPosition) { - if (iret[idet] != NULL) { - if (*iret[idet] != OK) - ret = FAIL; - delete iret[idet]; - } else - ret = FAIL; - if (detectors[idet]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << idet)); - } - } - } - - //master - int ret1 = OK; - i = thisMultiDetector->masterPosition; - if (thisMultiDetector->masterPosition >= 0) { - ret1 = detectors[i]->startAndReadAllNoWait(); - if (detectors[i]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << i)); - if (ret1 != OK) - ret = FAIL; - } - pthread_mutex_unlock(&mg); - return ret; -} - - - -int* multiSlsDetector::getDataFromDetector() { - - int nel = thisMultiDetector->dataBytes / sizeof(int); - int n = 0; - int* retval = NULL; - int *retdet, *p = retval; - int nodatadet = -1; - int nodatadetectortype = false; - detectorType types = getDetectorsType(); - if (types == EIGER || types == JUNGFRAU || GOTTHARD || PROPIX) { - nodatadetectortype = true; - } - - if (!nodatadetectortype) - retval = new int[nel]; - p = retval; - - for (unsigned int id = 0; id < detectors.size(); ++id) { - retdet = detectors[id]->getDataFromDetector(p); - if (detectors[id]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << id)); - if (!nodatadetectortype) { - n = detectors[id]->getDataBytes(); - if (retdet) { - ; -#ifdef VERBOSE - cout << "Detector " << id << " returned " << n << " bytes " << endl; -#endif - } else { - nodatadet = id; -#ifdef VERBOSE - cout << "Detector " << id << " does not have data left " << endl; -#endif - } - p += n / sizeof(int); - } - } - - //eiger returns only null - if (nodatadetectortype) { - return NULL; - } - - if (nodatadet >= 0) { - for (unsigned int id = 0; id < detectors.size(); ++id) { - if ((int)id != nodatadet) { - if (detectors[id]) { - //#ifdef VERBOSE - cout << "Stopping detector " << id << endl; - //#endif - detectors[id]->stopAcquisition(); - if (detectors[id]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << id)); - - while ((retdet = detectors[id]->getDataFromDetector())) { - if (detectors[id]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << id)); -#ifdef VERBOSE - cout << "Detector " << id << " still sent data " << endl; -#endif - delete[] retdet; - } - if (detectors[id]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << id)); - } - } - } - delete[] retval; - return NULL; - } - - return retval; -} - - -int* multiSlsDetector::readFrame() { - int nel = thisMultiDetector->dataBytes / sizeof(int); - int n; - int* retval = new int[nel]; - int *retdet, *p = retval; - - for (unsigned int id = 0; id < detectors.size(); ++id) { - if (detectors[id]) { - retdet = detectors[id]->readFrame(); - if (detectors[id]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << id)); - if (retdet) { - n = detectors[id]->getDataBytes(); - if (detectors[id]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << id)); - memcpy(p, retdet, n); - delete[] retdet; - p += n / sizeof(int); - } else { -#ifdef VERBOSE - cout << "Detector " << id << " does not have data left " << endl; -#endif - delete[] retval; - return NULL; - } - } - } - dataQueue.push(retval); - return retval; -} - - -int* multiSlsDetector::readAll() { - int* retval = NULL; - int i = 0; -#ifdef VERBOSE - std::cout << "Reading all frames " << std::endl; -#endif - if (thisMultiDetector->onlineFlag == ONLINE_FLAG) { - - for (unsigned int id = 0; id < detectors.size(); ++id) { - detectors[id]->readAllNoWait(); - if (detectors[id]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << id)); - } - while ((retval = getDataFromDetector())) { - ++i; -#ifdef VERBOSE - std::cout << i << std::endl; -#endif - dataQueue.push(retval); - } - for (unsigned int id = 0; id < detectors.size(); ++id) { - detectors[id]->disconnectControl(); - } - } - -#ifdef VERBOSE - std::cout << "received " << i << " frames" << std::endl; -#endif - return dataQueueFront(); -} - - -int* multiSlsDetector::popDataQueue() { - int* retval = NULL; - if (!dataQueue.empty()) { - retval = dataQueue.front(); - dataQueue.pop(); - } - return retval; -} - -detectorData* multiSlsDetector::popFinalDataQueue() { - detectorData* retval = NULL; - if (!finalDataQueue.empty()) { - retval = finalDataQueue.front(); - finalDataQueue.pop(); - } - return retval; -} - -void multiSlsDetector::resetDataQueue() { - int* retval = NULL; - while (!dataQueue.empty()) { - retval = dataQueue.front(); - dataQueue.pop(); - delete[] retval; - } -} - -void multiSlsDetector::resetFinalDataQueue() { - detectorData* retval = NULL; - while (!finalDataQueue.empty()) { - retval = finalDataQueue.front(); - finalDataQueue.pop(); - delete retval; - } +int multiSlsDetector::readAll() { + return callDetectorMember(&slsDetector::readAll); } int multiSlsDetector::configureMAC() { @@ -2644,7 +1789,7 @@ int64_t multiSlsDetector::setTimer(timerIndex index, int64_t t, int imod) { // multi if(!threadpool){ - cout << "Error in creating threadpool. Exiting" << endl; + std::cout << "Error in creating threadpool. Exiting" << std::endl; return -1; }else{ //return storage values @@ -2681,26 +1826,20 @@ int64_t multiSlsDetector::setTimer(timerIndex index, int64_t t, int imod) { } int64_t multiSlsDetector::getTimeLeft(timerIndex index, int imod) { - int64_t ret = -100; - { // single - int id = -1, im = -1; - if (decodeNMod(imod, id, im) >= 0) { - if (id < 0 || id >= (int)detectors.size()) + // single + { + if (imod >= 0) { + if (imod < 0 || imod >= (int)detectors.size()) return -1; - ret = detectors[id]->getTimeLeft(index, im); - if (detectors[id]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << id)); + int64_t ret = detectors[imod]->getTimeLeft(index, imod); + if (detectors[imod]->getErrorMask()) + setErrorMask(getErrorMask() | (1 << imod)); return ret; } } - if (thisMultiDetector->masterPosition >= 0) - if (detectors[thisMultiDetector->masterPosition]) { - ret = detectors[thisMultiDetector->masterPosition]->getTimeLeft(index, imod); - if (detectors[thisMultiDetector->masterPosition]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << thisMultiDetector->masterPosition)); - return ret; - } + + // multi return callDetectorMember(&slsDetector::getTimeLeft, index, imod); } @@ -2727,7 +1866,7 @@ int multiSlsDetector::setDynamicRange(int p) { thisMultiDetector->numberOfChannels = 0; if (!threadpool) { - cout << "Error in creating threadpool. Exiting" << endl; + std::cout << "Error in creating threadpool. Exiting" << std::endl; return -1; } else { //return storage values @@ -2788,20 +1927,19 @@ dacs_t multiSlsDetector::setDAC(dacs_t val, dacIndex idac, int mV, int imod) { // single { - int id = -1, im = -1; - if (decodeNMod(imod, id, im) >= 0) { - if (id < 0 && id >= (int)detectors.size()) + if (imod >= 0) { + if (imod < 0 || imod >= (int)detectors.size()) return -1; - ret = detectors[id]->setDAC(val, idac, mV, im); - if (detectors[id]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << id)); + ret = detectors[imod]->setDAC(val, idac, mV, imod); + if (detectors[imod]->getErrorMask()) + setErrorMask(getErrorMask() | (1 << imod)); return ret; } } // multi if (!threadpool) { - cout << "Error in creating threadpool. Exiting" << endl; + std::cout << "Error in creating threadpool. Exiting" << std::endl; return -1; } @@ -2845,20 +1983,19 @@ dacs_t multiSlsDetector::getADC(dacIndex idac, int imod) { // single { - int id = -1, im = -1; - if (decodeNMod(imod, id, im) >= 0) { - if (id < 0 && id >= (int)detectors.size()) + if (imod >= 0) { + if (imod < 0 || imod >= (int)detectors.size()) return -1; - ret = detectors[id]->getADC(idac, im); - if (detectors[id]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << id)); + ret = detectors[imod]->getADC(idac, imod); + if (detectors[imod]->getErrorMask()) + setErrorMask(getErrorMask() | (1 << imod)); return ret; } } // multi if (!threadpool) { - cout << "Error in creating threadpool. Exiting" << endl; + std::cout << "Error in creating threadpool. Exiting" << std::endl; return -1; } @@ -2908,8 +2045,6 @@ slsDetectorDefs::externalCommunicationMode multiSlsDetector::setExternalCommunic if (ret != ret1) ret = GET_EXTERNAL_COMMUNICATION_MODE; } - setMaster(); - setSynchronization(); return ret; } @@ -2929,8 +2064,7 @@ slsDetectorDefs::externalSignalFlag multiSlsDetector::setExternalSignalFlags( if (ret != ret1) ret = GET_EXTERNAL_SIGNAL_FLAG; } - setMaster(); - setSynchronization(); + return ret; } @@ -2961,7 +2095,7 @@ uint32_t multiSlsDetector::writeRegister(uint32_t addr, uint32_t val) { else if (ret != ret1) { // not setting it to -1 as it is a possible value std::cout << "Error: Different Values for function writeRegister [" - << ret << "," << ret1 << "]" << endl; + << ret << "," << ret1 << "]" << std::endl; setErrorMask(getErrorMask() | MULTI_HAVE_DIFFERENT_VALUES); } } @@ -2981,7 +2115,7 @@ uint32_t multiSlsDetector::readRegister(uint32_t addr) { else if (ret != ret1) { // not setting it to -1 as it is a possible value std::cout << "Error: Different Values for function readRegister [" - << ret << "," << ret1 << "]" << endl; + << ret << "," << ret1 << "]" << std::endl; setErrorMask(getErrorMask() | MULTI_HAVE_DIFFERENT_VALUES); } } @@ -3003,7 +2137,7 @@ uint32_t multiSlsDetector::setBit(uint32_t addr, int n) { else if (ret != ret1) { // not setting it to -1 as it is a possible value std::cout << "Error: Different Values for function setBit [" - << ret << "," << ret1 << "]" << endl; + << ret << "," << ret1 << "]" << std::endl; setErrorMask(getErrorMask() | MULTI_HAVE_DIFFERENT_VALUES); } } @@ -3022,7 +2156,7 @@ uint32_t multiSlsDetector::clearBit(uint32_t addr, int n) { else if (ret != ret1) { // not setting it to -1 as it is a possible value std::cout << "Error: Different Values for function clearBit [" - << ret << "," << ret1 << "]" << endl; + << ret << "," << ret1 << "]" << std::endl; setErrorMask(getErrorMask() | MULTI_HAVE_DIFFERENT_VALUES); } } @@ -3035,7 +2169,7 @@ std::string multiSlsDetector::setNetworkParameter(networkParameter p, std::strin if (s.find('+') == std::string::npos) { if (!threadpool) { - cout << "Error in creating threadpool. Exiting" << endl; + std::cout << "Error in creating threadpool. Exiting" << std::endl; return getNetworkParameter(p); } else { std::string* sret[detectors.size()]; @@ -3104,66 +2238,29 @@ std::string multiSlsDetector::getNetworkParameter(networkParameter p) { } int multiSlsDetector::digitalTest(digitalTestMode mode, int imod) { - - int id, im, ret; - - if (decodeNMod(imod, id, im) >= 0) { - if (id < 0 || id >= (int)detectors.size()) - return -1; - ret = detectors[id]->digitalTest(mode, im); - if (detectors[id]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << id)); - return ret; - } - - return -1; -} - -int multiSlsDetector::executeTrimming(trimMode mode, int par1, int par2, int imod) { - int ret = 100; + int ret = OK; // single { - int id = -1, im = -1; - if (decodeNMod(imod, id, im) >= 0) { - if (id < 0 || id >= (int)detectors.size()) + if (imod >= 0) { + if (imod < 0 || imod >= (int)detectors.size()) return -1; - ret = detectors[id]->executeTrimming(mode, par1, par2, im); - if (detectors[id]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << id)); + ret = detectors[imod]->digitalTest(mode, imod); + if (detectors[imod]->getErrorMask()) + setErrorMask(getErrorMask() | (1 << imod)); return ret; } } // multi - if (!threadpool) { - cout << "Error in creating threadpool. Exiting" << endl; - return -1; - } - - int* iret[detectors.size()]; + int ret1 = OK; for (unsigned int idet = 0; idet < detectors.size(); ++idet) { - iret[idet] = new int(-1); - Task* task = new Task(new func4_t(&slsDetector::executeTrimming, - detectors[idet], mode, par1, par2, imod, iret[idet])); - threadpool->add_task(task); - } - threadpool->startExecuting(); - threadpool->wait_for_tasks_to_complete(); - for (unsigned int idet = 0; idet < detectors.size(); ++idet) { - if (iret[idet] != NULL) { - if (ret == -100) - ret = *iret[idet]; - else if (ret != *iret[idet]) - ret = -1; - delete iret[idet]; - } else - ret = -1; + ret1 = detectors[idet]->digitalTest(mode, imod); + if (ret1 == FAIL) + ret = FAIL; if (detectors[idet]->getErrorMask()) setErrorMask(getErrorMask() | (1 << idet)); } - return ret; } @@ -3278,10 +2375,10 @@ int multiSlsDetector::setROI(int n, ROI roiLimits[]) { //ensures min < max verifyMinMaxROI(n, roiLimits); #ifdef VERBOSE - cout << "Setting ROI for " << n << "rois:" << endl; + std::cout << "Setting ROI for " << n << "rois:" << std::endl; for (i = 0; i < n; ++i) - cout << i << ":" << roiLimits[i].xmin << "\t" << roiLimits[i].xmax - << "\t" << roiLimits[i].ymin << "\t" << roiLimits[i].ymax << endl; + std::cout << i << ":" << roiLimits[i].xmin << "\t" << roiLimits[i].xmax + << "\t" << roiLimits[i].ymin << "\t" << roiLimits[i].ymax << std::endl; #endif //for each roi for (i = 0; i < n; ++i) { @@ -3293,12 +2390,12 @@ int multiSlsDetector::setROI(int n, ROI roiLimits[]) { //check roi max values idet = decodeNChannel(xmax, ymax, channelX, channelY); #ifdef VERBOSE - cout << "Decoded Channel max vals: " << endl; - cout << "det:" << idet << "\t" << xmax << "\t" << ymax << "\t" - << channelX << "\t" << channelY << endl; + std::cout << "Decoded Channel max vals: " << std::endl; + std::cout << "det:" << idet << "\t" << xmax << "\t" << ymax << "\t" + << channelX << "\t" << channelY << std::endl; #endif if (idet == -1) { - cout << "invalid roi" << endl; + std::cout << "invalid roi" << std::endl; continue; } @@ -3311,18 +2408,18 @@ int multiSlsDetector::setROI(int n, ROI roiLimits[]) { //get offset for each detector idet = decodeNChannel(xmin, ymin, channelX, channelY); #ifdef VERBOSE - cout << "Decoded Channel min vals: " << endl; - cout << "det:" << idet << "\t" << xmin << "\t" << ymin - << "\t" << channelX << "\t" << channelY << endl; + std::cout << "Decoded Channel min vals: " << std::endl; + std::cout << "det:" << idet << "\t" << xmin << "\t" << ymin + << "\t" << channelX << "\t" << channelY << std::endl; #endif if (idet < 0 || idet >= (int)detectors.size()) { - cout << "invalid roi" << endl; + std::cout << "invalid roi" << std::endl; invalidroi = true; break; } //get last channel for each det in x and y dir - lastChannelX = (detectors[idet]->getMaxNumberOfChannelsInclGapPixels(X)) - 1; - lastChannelY = (detectors[idet]->getMaxNumberOfChannelsInclGapPixels(Y)) - 1; + lastChannelX = (detectors[idet]->getTotalNumberOfChannelsInclGapPixels(X)) - 1; + lastChannelY = (detectors[idet]->getTotalNumberOfChannelsInclGapPixels(Y)) - 1; offsetX = detectors[idet]->getDetectorOffset(X); offsetY = detectors[idet]->getDetectorOffset(Y); @@ -3334,8 +2431,8 @@ int multiSlsDetector::setROI(int n, ROI roiLimits[]) { lastChannelY = ymax - offsetY; #ifdef VERBOSE - cout << "lastChannelX:" << lastChannelX << "\t" - << "lastChannelY:" << lastChannelY << endl; + std::cout << "lastChannelX:" << lastChannelX << "\t" + << "lastChannelY:" << lastChannelY << std::endl; #endif //creating the list of roi for corresponding detector @@ -3351,7 +2448,7 @@ int multiSlsDetector::setROI(int n, ROI roiLimits[]) { ymin = ymax + 1; #ifdef VERBOSE - cout << "nroi[idet]:" << nroi[idet] << "\tymin:" << ymin << endl; + std::cout << "nroi[idet]:" << nroi[idet] << "\tymin:" << ymin << std::endl; #endif } @@ -3365,12 +2462,12 @@ int multiSlsDetector::setROI(int n, ROI roiLimits[]) { } #ifdef VERBOSE - cout << "Setting ROI :" << endl; + std::cout << "Setting ROI :" << std::endl; for (i = 0; i < detectors.size(); ++i) { - cout << "detector " << i << endl; + std::cout << "detector " << i << std::endl; for (int j = 0; j < nroi[i]; ++j) { - cout << allroi[i][j].xmin << "\t" << allroi[i][j].xmax << "\t" - << allroi[i][j].ymin << "\t" << allroi[i][j].ymax << endl; + std::cout << allroi[i][j].xmin << "\t" << allroi[i][j].xmax << "\t" + << allroi[i][j].ymin << "\t" << allroi[i][j].ymax << std::endl; } } #endif @@ -3378,7 +2475,7 @@ int multiSlsDetector::setROI(int n, ROI roiLimits[]) { //settings the rois for each detector for (unsigned i = 0; i < detectors.size(); ++i) { #ifdef VERBOSE - cout << "detector " << i << ":" << endl; + std::cout << "detector " << i << ":" << std::endl; #endif ret = detectors[i]->setROI(nroi[i], allroi[i]); if (detectors[i]->getErrorMask()) @@ -3414,12 +2511,12 @@ slsDetectorDefs::ROI* multiSlsDetector::getROI(int& n) { if (temp) { //#ifdef VERBOSE if (index) - cout << "detector " << i << ":" << endl; + std::cout << "detector " << i << ":" << std::endl; //#endif for (j = 0; j < index; ++j) { //#ifdef VERBOSE - cout << temp[j].xmin << "\t" << temp[j].xmax << "\t" - << temp[j].ymin << "\t" << temp[j].ymax << endl; + std::cout << temp[j].xmin << "\t" << temp[j].xmax << "\t" + << temp[j].ymin << "\t" << temp[j].ymax << std::endl; //#endif int x = detectors[i]->getDetectorOffset(X); int y = detectors[i]->getDetectorOffset(Y); @@ -3437,10 +2534,10 @@ slsDetectorDefs::ROI* multiSlsDetector::getROI(int& n) { return NULL; #ifdef VERBOSE - cout << "ROI :" << endl; + std::cout << "ROI :" << std::endl; for (int j = 0; j < n; ++j) { - cout << roiLimits[j].xmin << "\t" << roiLimits[j].xmax << "\t" - << roiLimits[j].ymin << "\t" << roiLimits[j].ymax << endl; + std::cout << roiLimits[j].xmin << "\t" << roiLimits[j].xmax << "\t" + << roiLimits[j].ymin << "\t" << roiLimits[j].ymax << std::endl; } #endif @@ -3477,11 +2574,11 @@ slsDetectorDefs::ROI* multiSlsDetector::getROI(int& n) { } #ifdef VERBOSE - cout << "Combined along x axis Getting ROI :" << endl; - cout << "detector " << i << endl; + std::cout << "Combined along x axis Getting ROI :" << std::endl; + std::cout << "detector " << i << std::endl; for (int j = 0; j < n; ++j) { - cout << roiLimits[j].xmin << "\t" << roiLimits[j].xmax << "\t" - << roiLimits[j].ymin << "\t" << roiLimits[j].ymax << endl; + std::cout << roiLimits[j].xmin << "\t" << roiLimits[j].xmax << "\t" + << roiLimits[j].ymin << "\t" << roiLimits[j].ymax << std::endl; } #endif @@ -3536,10 +2633,10 @@ slsDetectorDefs::ROI* multiSlsDetector::getROI(int& n) { } n = num; - cout << "\nxmin\txmax\tymin\tymax" << endl; + std::cout << "\nxmin\txmax\tymin\tymax" << std::endl; for (i = 0; i < n; ++i) - cout << retval[i].xmin << "\t" << retval[i].xmax << "\t" - << retval[i].ymin << "\t" << retval[i].ymax << endl; + std::cout << retval[i].xmin << "\t" << retval[i].xmax << "\t" + << retval[i].ymin << "\t" << retval[i].ymax << std::endl; return retval; } @@ -3556,7 +2653,7 @@ int multiSlsDetector::writeAdcRegister(int addr, int val) { else if (ret != ret1) { // not setting it to -1 as it is a possible value std::cout << "Error: Different Values for function " - "writeAdcRegister [" << ret << "," << ret1 << "]" << endl; + "writeAdcRegister [" << ret << "," << ret1 << "]" << std::endl; setErrorMask(getErrorMask() | MULTI_HAVE_DIFFERENT_VALUES); } } @@ -3585,20 +2682,19 @@ int multiSlsDetector::setAllTrimbits(int val, int imod) { // single { - int id = -1, im = -1; - if (decodeNMod(imod, id, im) >= 0) { - if (id < 0 || id >= (int)detectors.size()) + if (imod >= 0) { + if (imod < 0 || imod >= (int)detectors.size()) return -1; - ret = detectors[id]->setAllTrimbits(val, im); - if (detectors[id]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << id)); + ret = detectors[imod]->setAllTrimbits(val, imod); + if (detectors[imod]->getErrorMask()) + setErrorMask(getErrorMask() | (1 << imod)); return ret; } } // multi if (!threadpool) { - cout << "Error in creating threadpool. Exiting" << endl; + std::cout << "Error in creating threadpool. Exiting" << std::endl; return -1; } int* iret[detectors.size()]; @@ -3726,20 +2822,19 @@ int multiSlsDetector::setThresholdTemperature(int val, int imod) { // single { - int id = -1, im = -1; - if (decodeNMod(imod, id, im) >= 0) { - if (id < 0 || id >= (int)detectors.size()) + if (imod >= 0) { + if (imod < 0 || imod >= (int)detectors.size()) return -1; - ret = detectors[id]->setThresholdTemperature(val, im); - if (detectors[id]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << id)); + ret = detectors[imod]->setThresholdTemperature(val, imod); + if (detectors[imod]->getErrorMask()) + setErrorMask(getErrorMask() | (1 << imod)); return ret; } } // multi if (!threadpool) { - cout << "Error in creating threadpool. Exiting" << endl; + std::cout << "Error in creating threadpool. Exiting" << std::endl; return -1; } @@ -3775,20 +2870,19 @@ int multiSlsDetector::setTemperatureControl(int val, int imod) { // single { - int id = -1, im = -1; - if (decodeNMod(imod, id, im) >= 0) { - if (id < 0 || id >= (int)detectors.size()) + if (imod >= 0) { + if (imod < 0 || imod >= (int)detectors.size()) return -1; - ret = detectors[id]->setTemperatureControl(val, im); - if (detectors[id]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << id)); + ret = detectors[imod]->setTemperatureControl(val, imod); + if (detectors[imod]->getErrorMask()) + setErrorMask(getErrorMask() | (1 << imod)); return ret; } } // multi if (!threadpool) { - cout << "Error in creating threadpool. Exiting" << endl; + std::cout << "Error in creating threadpool. Exiting" << std::endl; return -1; } @@ -3824,20 +2918,19 @@ int multiSlsDetector::setTemperatureEvent(int val, int imod) { // single { - int id = -1, im = -1; - if (decodeNMod(imod, id, im) >= 0) { - if (id < 0 || id >= (int)detectors.size()) + if (imod >= 0) { + if (imod < 0 || imod >= (int)detectors.size()) return -1; - ret = detectors[id]->setTemperatureEvent(val, im); - if (detectors[id]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << id)); + ret = detectors[imod]->setTemperatureEvent(val, imod); + if (detectors[imod]->getErrorMask()) + setErrorMask(getErrorMask() | (1 << imod)); return ret; } } // multi if (!threadpool) { - cout << "Error in creating threadpool. Exiting" << endl; + std::cout << "Error in creating threadpool. Exiting" << std::endl; return -1; } @@ -3924,9 +3017,6 @@ int multiSlsDetector::setAutoComparatorDisableMode(int ival) { return ret1; } -double multiSlsDetector::getScanStep(int index, int istep) { - return thisMultiDetector->scanSteps[index][istep]; -} int multiSlsDetector::getChanRegs(double* retval, bool fromDetector) { //nChansDet and currentNumChans is because of varying channel size per detector @@ -3945,57 +3035,6 @@ int multiSlsDetector::getChanRegs(double* retval, bool fromDetector) { } - -int multiSlsDetector::setChannel(int64_t reg, int ichan, int ichip, int imod) { - int ret, ret1 = -100; - int id = -1, im = -1; - int dmi = 0, dma = detectors.size(); - - if (decodeNMod(imod, id, im) >= 0) { - if (id < 0 || id >= (int)detectors.size()) - return -1; - dmi = id; - dma = id + 1; - } - for (int idet = dmi; idet < dma; ++idet) { - ret = detectors[idet]->setChannel(reg, ichan, ichip, im); - if (detectors[idet]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << idet)); - if (ret1 == -100) - ret1 = ret; - else if (ret != ret1) - ret1 = -1; - } - return ret1; -} - -int multiSlsDetector::getMoveFlag(int imod) { - int id = -1, im = -1; - if (decodeNMod(imod, id, im) >= 0) { - if (id < 0 || id >= (int)detectors.size()) - return -1; - return detectors[id]->getMoveFlag(im); - } - - //default!!! - return 1; -} - -int multiSlsDetector::fillModuleMask(int* mM) { - int imod = 0, off = 0; - if (mM) { - for (unsigned int i = 0; i < detectors.size(); ++i) { - for (int im = 0; im < detectors[i]->getNMods(); ++im) { - mM[imod] = im + off; - ++imod; - } - off += detectors[i]->getMaxMods(); - } - } - return getNMods(); -} - - int multiSlsDetector::calibratePedestal(int frames) { return callDetectorMember(&slsDetector::calibratePedestal, frames); } @@ -4013,7 +3052,7 @@ int multiSlsDetector::setRateCorrection(double t) { // eiger return value is ok/fail if (getDetectorsType() == EIGER) { if (!threadpool) { - cout << "Error in creating threadpool. Exiting" << endl; + std::cout << "Error in creating threadpool. Exiting" << std::endl; return FAIL; } else { int* iret[posmax]; @@ -4040,36 +3079,9 @@ int multiSlsDetector::setRateCorrection(double t) { return ret; } - // mythen, others - if (t == 0) { - thisMultiDetector->correctionMask &= ~(1 << RATE_CORRECTION); - return thisMultiDetector->correctionMask & (1 << RATE_CORRECTION); - } else - thisMultiDetector->correctionMask |= (1 << RATE_CORRECTION); + printf("Unknown detector for rate correction\n"); + return -1; - ret = -100; - if (!threadpool) { - cout << "Error in creating threadpool. Exiting" << endl; - return -1; - } else { - int* iret[posmax]; - for (int idet = 0; idet < posmax; ++idet) { - iret[idet] = new int(-1); - Task* task = new Task(new func1_t - (&slsDetector::setRateCorrection, - detectors[idet], t, iret[idet])); - threadpool->add_task(task); - } - threadpool->startExecuting(); - threadpool->wait_for_tasks_to_complete(); - for (int idet = 0; idet < posmax; ++idet) { - if (iret[idet] != NULL) - delete iret[idet]; - if (detectors[idet]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << idet)); - } - } - return thisMultiDetector->correctionMask & (1 << RATE_CORRECTION); } int multiSlsDetector::getRateCorrection(double& t) { @@ -4078,18 +3090,8 @@ int multiSlsDetector::getRateCorrection(double& t) { return t; } - if (thisMultiDetector->correctionMask & (1 << RATE_CORRECTION)) { -#ifdef VERBOSE - std::cout << "Rate correction is enabled with dead time " << - thisMultiDetector->tDead << std::endl; -#endif - return 1; - } else - t = 0; -#ifdef VERBOSE - std::cout << "Rate correction is disabled " << std::endl; -#endif - return 0; + printf("Unknown detector for rate correction\n"); + return -1; } double multiSlsDetector::getRateCorrectionTau() { @@ -4098,7 +3100,7 @@ double multiSlsDetector::getRateCorrectionTau() { int posmax = detectors.size(); if (!threadpool) { - cout << "Error in creating threadpool. Exiting" << endl; + std::cout << "Error in creating threadpool. Exiting" << std::endl; return -1; } else { double* iret[posmax]; @@ -4132,391 +3134,17 @@ double multiSlsDetector::getRateCorrectionTau() { if (getDetectorsType() == EIGER) return ret; - //only mythen - if (thisMultiDetector->correctionMask & (1 << RATE_CORRECTION)) { -#ifdef VERBOSE - std::cout << "Rate correction is enabled with dead time " << - thisMultiDetector->tDead << std::endl; -#endif - } else { -#ifdef VERBOSE - std::cout << "Rate correction is disabled " << std::endl; -#endif - ret = 0; - } - return ret; + printf("Unknown detector for rate correction\n"); + return -1; } int multiSlsDetector::getRateCorrection() { if (getDetectorsType() == EIGER) { return getRateCorrectionTau(); } - if (thisMultiDetector->correctionMask & (1 << RATE_CORRECTION)) { - return 1; - } else - return 0; -}; -int multiSlsDetector::rateCorrect(double* datain, double* errin, double* dataout, double* errout) { - int ichdet = 0; - double* perr = errin; - for (unsigned int idet = 0; idet < detectors.size(); ++idet) { - if (errin) - perr += ichdet; - detectors[idet]->rateCorrect(datain + ichdet, perr, dataout + ichdet, - errout + ichdet); - if (detectors[idet]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << idet)); - ichdet += detectors[idet]->getTotalNumberOfChannels(); - } - return 0; -} - - -int multiSlsDetector::setFlatFieldCorrection(std::string fname) { - double* data = new double[thisMultiDetector->numberOfChannels]; - double* ffcoefficients = new double[thisMultiDetector->numberOfChannels]; - double* fferrors = new double[thisMultiDetector->numberOfChannels]; - char ffffname[MAX_STR_LENGTH * 2]; - int nch; - if (fname == "default") { - fname = std::string(thisMultiDetector->flatFieldFile); - } - - thisMultiDetector->correctionMask &= ~(1 << FLAT_FIELD_CORRECTION); - - if (fname == "") { -#ifdef VERBOSE - std::cout << "disabling flat field correction" << std::endl; -#endif - thisMultiDetector->correctionMask &= ~(1 << FLAT_FIELD_CORRECTION); - for (unsigned int i = 0; i < detectors.size(); ++i) { - detectors[i]->setFlatFieldCorrection(NULL, NULL); - if (detectors[i]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << i)); - } - } else { -#ifdef VERBOSE - std::cout << "Setting flat field correction from file " << fname << std::endl; -#endif - sprintf(ffffname, "%s/%s", thisMultiDetector->flatFieldDir, fname.c_str()); - nch = readDataFile(std::string(ffffname), data); - - if (nch > thisMultiDetector->numberOfChannels) - nch = thisMultiDetector->numberOfChannels; - - if (nch > 0) { - - int nm = getNMods(); - int chpm[nm]; - int mMask[nm]; - for (int i = 0; i < nm; ++i) { - chpm[i] = getChansPerMod(i); - mMask[i] = i; - } - fillModuleMask(mMask); - fillBadChannelMask(); - if ((postProcessingFuncs::calculateFlatField(&nm, chpm, mMask, - badChannelMask, data, ffcoefficients, fferrors)) >= 0) { - strcpy(thisMultiDetector->flatFieldFile, fname.c_str()); - - thisMultiDetector->correctionMask |= (1 << FLAT_FIELD_CORRECTION); - - setFlatFieldCorrection(ffcoefficients, fferrors); - - } else - std::cout << "Calculated flat field from file " << fname << - " is not valid " << nch << std::endl; - } else { - std::cout << "Flat field from file " << fname << " is not valid " - << nch << std::endl; - } - } - return thisMultiDetector->correctionMask & (1 << FLAT_FIELD_CORRECTION); -} - - -int multiSlsDetector::setFlatFieldCorrection(double* corr, double* ecorr) { - int ichdet = 0; - double *p, *ep; - for (unsigned int idet = 0; idet < detectors.size(); ++idet) { - if (corr != NULL) - p = corr + ichdet; - else - p = NULL; - if (ecorr != NULL) - ep = ecorr + ichdet; - else - ep = NULL; - detectors[idet]->setFlatFieldCorrection(p, ep); - if (detectors[idet]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << idet)); - ichdet += detectors[idet]->getTotalNumberOfChannels(); - } - return 0; -} - -int multiSlsDetector::getFlatFieldCorrection(double* corr, double* ecorr) { - int ichdet = 0; - double *p, *ep; - int ff = 1, dff; - for (unsigned int idet = 0; idet < detectors.size(); ++idet) { - if (corr != NULL) - p = corr + ichdet; - else - p = NULL; - if (ecorr != NULL) - ep = ecorr + ichdet; - else - ep = NULL; - dff = detectors[idet]->getFlatFieldCorrection(p, ep); - if (detectors[idet]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << idet)); - if (dff == 0) - ff = 0; - ichdet += detectors[idet]->getTotalNumberOfChannels(); - } - return ff; -} - -int multiSlsDetector::flatFieldCorrect(double* datain, double* errin, double* dataout, - double* errout) { - int ichdet = 0; - double* perr = errin; //*pdata, - for (unsigned int idet = 0; idet < detectors.size(); ++idet) { -#ifdef VERBOSE - cout << " detector " << idet << " offset " << ichdet << endl; -#endif - if (errin) - perr += ichdet; - detectors[idet]->flatFieldCorrect(datain + ichdet, perr, - dataout + ichdet, errout + ichdet); - if (detectors[idet]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << idet)); - ichdet += detectors[idet]->getTotalNumberOfChannels(); - } - return 0; -} - -int multiSlsDetector::setBadChannelCorrection(std::string fname) { - int badlist[MAX_BADCHANS]; - int nbad = 0; - int ret = 0; - - cout << thisMultiDetector->badChanFile << endl; - - if (fname == "default") - fname = std::string(thisMultiDetector->badChanFile); - - ret = setBadChannelCorrection(fname, nbad, badlist); - //#ifdef VERBOSE - cout << "multi: file contained " << ret << " badchans" << endl; - //#endif - if (ret == 0) { - thisMultiDetector->correctionMask &= ~(1 << DISCARD_BAD_CHANNELS); - nbad = 0; - } else { - thisMultiDetector->correctionMask |= (1 << DISCARD_BAD_CHANNELS); - strcpy(thisMultiDetector->badChanFile, fname.c_str()); - } - - return setBadChannelCorrection(nbad, badlist, 0); -} - -int multiSlsDetector::setBadChannelCorrection(int nbad, int* badlist, int ff) { - int badlistdet[MAX_BADCHANS]; - int nbaddet = 0, choff = 0, idet = 0; - if (nbad < 1) - badlistdet[0] = 0; - else - badlistdet[0] = badlist[0]; - - if (nbad > 0) { - thisMultiDetector->correctionMask |= (1 << DISCARD_BAD_CHANNELS); - - for (int ich = 0; ich < nbad; ++ich) { - if ((badlist[ich] - choff) >= detectors[idet]->getMaxNumberOfChannels()) { - //#ifdef VERBOSE - cout << "setting " << nbaddet << " badchans to detector " - << idet << endl; - //#endif - detectors[idet]->setBadChannelCorrection(nbaddet, badlistdet, 0); - if (detectors[idet]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << idet)); - choff += detectors[idet]->getMaxNumberOfChannels(); - nbaddet = 0; - ++idet; - if (detectors[idet] == NULL) - break; - } - badlistdet[nbaddet] = (badlist[ich] - choff); - ++nbaddet; -#ifdef VERBOSE - cout << nbaddet << " " << badlist[ich] << " " - << badlistdet[nbaddet - 1] << endl; -#endif - } - if (nbaddet > 0) { -#ifdef VERBOSE - cout << "setting " << nbaddet << " badchans to detector " - << idet << endl; -#endif - detectors[idet]->setBadChannelCorrection(nbaddet, badlistdet, 0); - if (detectors[idet]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << idet)); - choff += detectors[idet]->getMaxNumberOfChannels(); - nbaddet = 0; - ++idet; - } - nbaddet = 0; - for (unsigned int i = idet; i < detectors.size(); ++i) { -#ifdef VERBOSE - cout << "setting " << 0 << " badchans to detector " << i << endl; -#endif - detectors[i]->setBadChannelCorrection(nbaddet, badlistdet, 0); - if (detectors[i]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << i)); - } - - } else { - nbaddet = 0; - for (unsigned int i = 0; i < detectors.size(); ++i) { -#ifdef VERBOSE - cout << "setting " << 0 << " badchans to detector " << idet << endl; -#endif - detectors[idet]->setBadChannelCorrection(nbaddet, badlistdet, 0); - if (detectors[idet]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << idet)); - } - thisMultiDetector->correctionMask &= ~(1 << DISCARD_BAD_CHANNELS); - } -#ifdef VERBOSE - cout << (thisMultiDetector->correctionMask & (1 << DISCARD_BAD_CHANNELS)) << endl; -#endif - return thisMultiDetector->correctionMask & (1 << DISCARD_BAD_CHANNELS); -} - - -int multiSlsDetector::getBadChannelCorrection(int* bad) { - //int ichan; - int *bd, nd, ntot = 0, choff = 0; - ; - - if (((thisMultiDetector->correctionMask) & (1 << DISCARD_BAD_CHANNELS)) == 0) - return 0; - for (unsigned int idet = 0; idet < detectors.size(); ++idet) { - nd = detectors[idet]->getBadChannelCorrection(); - if (nd > 0) { - bd = new int[nd]; - nd = detectors[idet]->getBadChannelCorrection(bd); - if (detectors[idet]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << idet)); - - for (int id = 0; id < nd; ++id) { - if (bd[id] < detectors[idet]->getTotalNumberOfChannels()) { - if (bad) - bad[ntot] = choff + bd[id]; - ++ntot; - } - } - choff += detectors[idet]->getTotalNumberOfChannels(); - delete[] bd; - } else - ntot += nd; - } - return ntot; -} - - -int multiSlsDetector::readAngularConversionFile(std::string fname) { - - std::ifstream infile; - //int nm=0; - infile.open(fname.c_str(), std::ios_base::in); - if (infile.is_open()) { - - for (unsigned int idet = 0; idet < detectors.size(); ++idet) { -#ifdef VERBOSE - cout << " detector " << idet << endl; -#endif - detectors[idet]->readAngularConversion(infile); - if (detectors[idet]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << idet)); - } - infile.close(); - } else { - std::cout << "Could not open calibration file " << fname << std::endl; - return -1; - } - return 0; -} - -int multiSlsDetector::writeAngularConversion(std::string fname) { - - std::ofstream outfile; - // int nm=0; - outfile.open(fname.c_str(), std::ios_base::out); - if (outfile.is_open()) { - - for (unsigned int idet = 0; idet < detectors.size(); ++idet) { - detectors[idet]->writeAngularConversion(outfile); - if (detectors[idet]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << idet)); - } - outfile.close(); - } else { - std::cout << "Could not open calibration file " << fname << std::endl; - return -1; - } - return 0; -} - -int multiSlsDetector::getAngularConversion(int& direction, angleConversionConstant* angconv) { - - int dir = -100, dir1; - angleConversionConstant* a1 = angconv; - - for (unsigned int idet = 0; idet < detectors.size(); ++idet) { - detectors[idet]->getAngularConversion(dir1, a1); - if (detectors[idet]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << idet)); - if (dir == -100) - dir = dir1; - if (dir != dir1) - dir = 0; - if (angconv) { - a1 += detectors[idet]->getNMods(); - } - } - direction = dir; - - if (thisMultiDetector->correctionMask & (1 << ANGULAR_CONVERSION)) { - return 1; - } - return 0; -} - -double multiSlsDetector::setAngularConversionParameter(angleConversionParameter c, double v) { - double ret = slsDetectorUtils::setAngularConversionParameter(c, v); - for (unsigned int idet = 0; idet < detectors.size(); ++idet) { - detectors[idet]->setAngularConversionParameter(c, v); - if (detectors[idet]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << idet)); - } - return ret; -} - -angleConversionConstant* multiSlsDetector::getAngularConversionPointer(int imod) { - int id = -1, im = -1; -#ifdef VERBOSE - cout << "get angular conversion pointer " << endl; -#endif - if (decodeNMod(imod, id, im) >= 0) { - if (id < 0 || id >= (int)detectors.size()) - return NULL; - return detectors[id]->getAngularConversionPointer(im); - } - return NULL; + printf("Unknown detector for rate correction\n"); + return -1; } @@ -4580,80 +3208,30 @@ int multiSlsDetector::exitReceiver() { } std::string multiSlsDetector::getFilePath() { - return setFilePath(); + std::string s = ""; + return callDetectorMember(&slsDetector::setFilePath, s); } std::string multiSlsDetector::setFilePath(std::string s) { - - std::string ret = "errorerror", ret1; - for (unsigned int idet = 0; idet < detectors.size(); ++idet) { - ret1 = detectors[idet]->setFilePath(s); - if (detectors[idet]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << idet)); - if (ret == "errorerror") - ret = ret1; - else if (ret != ret1) - ret = ""; - } - fileIO::setFilePath(ret); - return fileIO::getFilePath(); + if (s.empty()) + return getFilePath(); + return parallelCallDetectorMember(&slsDetector::setFilePath, s); } std::string multiSlsDetector::getFileName() { - return setFileName(); + std::string s = ""; + return callDetectorMember(&slsDetector::setFileName, s); } std::string multiSlsDetector::setFileName(std::string s) { - - std::string ret = "error"; - int posmax = detectors.size(); - - if (!s.empty()) { - fileIO::setFileName(s); - if (thisMultiDetector->receiverOnlineFlag == ONLINE_FLAG) - s = createReceiverFilePrefix(); - } - - if (!threadpool) { - cout << "Error in creating threadpool. Exiting" << endl; - return std::string(""); - } else { - std::string* sret[detectors.size()]; - for (int idet = 0; idet < posmax; ++idet) { - sret[idet] = new std::string("error"); - Task* task = new Task(new func1_t(&slsDetector::setFileName, - detectors[idet], s, sret[idet])); - threadpool->add_task(task); - } - threadpool->startExecuting(); - threadpool->wait_for_tasks_to_complete(); - for (int idet = 0; idet < posmax; ++idet) { - if (sret[idet] != NULL) { - if (ret == "error") - ret = *sret[idet]; - else if (ret != *sret[idet]) - ret = ""; - delete sret[idet]; - } else - ret = ""; - //doing nothing with the return values - if (detectors[idet]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << idet)); - } - } - - if ((thisMultiDetector->receiverOnlineFlag == ONLINE_FLAG) && - ((ret != "error") || (ret != ""))) { -#ifdef VERBOSE - std::cout << "Complete file prefix from receiver: " << ret << std::endl; -#endif - fileIO::setFileName(getNameFromReceiverFilePrefix(ret)); - } - - return ret; + if (s.empty()) + return getFileName(); + return parallelCallDetectorMember(&slsDetector::setFileName, s); } int multiSlsDetector::setReceiverFramesPerFile(int f) { + if (f < 0) + callDetectorMember(&slsDetector::setReceiverFramesPerFile, -1); return parallelCallDetectorMember(&slsDetector::setReceiverFramesPerFile, f); } @@ -4666,15 +3244,19 @@ int multiSlsDetector::setReceiverPartialFramesPadding(int f) { } slsReceiverDefs::fileFormat multiSlsDetector::getFileFormat() { - return setFileFormat(); + return callDetectorMember(&slsDetector::setFileFormat, GET_FILE_FORMAT); } slsReceiverDefs::fileFormat multiSlsDetector::setFileFormat(fileFormat f) { - return callDetectorMember(&slsDetector::setFileFormat, f); + return parallelCallDetectorMember(&slsDetector::setFileFormat, f); } int multiSlsDetector::getFileIndex() { - return setFileIndex(); + return callDetectorMember(&slsDetector::setFileIndex, -1); +} + +int multiSlsDetector::incrementFileIndex() { + return parallelCallDetectorMember(&slsDetector::incrementFileIndex); } int multiSlsDetector::setFileIndex(int i) { @@ -4683,161 +3265,97 @@ int multiSlsDetector::setFileIndex(int i) { int multiSlsDetector::startReceiver() { - int i = 0; int ret = OK; int posmin = 0, posmax = detectors.size(); if (!threadpool) { - cout << "Error in creating threadpool. Exiting" << endl; + std::cout << "Error in creating threadpool. Exiting" << std::endl; return FAIL; } else { int* iret[posmax - posmin]; for (int idet = posmin; idet < posmax; ++idet) { - if (idet != thisMultiDetector->masterPosition){ - iret[idet] = new int(OK); - Task* task = new Task(new func0_t(&slsDetector::startReceiver, - detectors[idet], iret[idet])); - threadpool->add_task(task); - } + iret[idet] = new int(OK); + Task* task = new Task(new func0_t(&slsDetector::startReceiver, + detectors[idet], iret[idet])); + threadpool->add_task(task); } threadpool->startExecuting(); threadpool->wait_for_tasks_to_complete(); for (int idet = posmin; idet < posmax; ++idet) { - if (idet != thisMultiDetector->masterPosition) { - if (iret[idet] != NULL) { - if (*iret[idet] != OK) - ret = FAIL; - delete iret[idet]; - } else + if (iret[idet] != NULL) { + if (*iret[idet] != OK) ret = FAIL; - if (detectors[idet]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << idet)); - } + delete iret[idet]; + } else + ret = FAIL; + if (detectors[idet]->getErrorMask()) + setErrorMask(getErrorMask() | (1 << idet)); } } - //master - int ret1 = OK; - i = thisMultiDetector->masterPosition; - if (thisMultiDetector->masterPosition >= 0) { - ret1 = detectors[i]->startReceiver(); - if (detectors[i]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << i)); - if (ret1 != OK) - ret = FAIL; - } return ret; } int multiSlsDetector::stopReceiver() { - int i = 0; - int ret = OK, ret1 = OK; + int ret = OK; int posmin = 0, posmax = detectors.size(); - i = thisMultiDetector->masterPosition; - if (thisMultiDetector->masterPosition >= 0) { - ret1 = detectors[i]->stopReceiver(); - if (detectors[i]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << i)); - if (ret1 != OK) - ret = FAIL; - } - if (!threadpool) { - cout << "Error in creating threadpool. Exiting" << endl; + std::cout << "Error in creating threadpool. Exiting" << std::endl; return FAIL; } else { int* iret[posmax - posmin]; for (int idet = posmin; idet < posmax; ++idet) { - if (idet != thisMultiDetector->masterPosition) { - iret[idet] = new int(OK); - Task* task = new Task(new func0_t(&slsDetector::stopReceiver, - detectors[idet], iret[idet])); - threadpool->add_task(task); - } + iret[idet] = new int(OK); + Task* task = new Task(new func0_t(&slsDetector::stopReceiver, + detectors[idet], iret[idet])); + threadpool->add_task(task); } threadpool->startExecuting(); threadpool->wait_for_tasks_to_complete(); for (int idet = posmin; idet < posmax; ++idet) { - if (idet != thisMultiDetector->masterPosition) { - if (iret[idet] != NULL) { - if (*iret[idet] != OK) - ret = FAIL; - delete iret[idet]; - } else + if (iret[idet] != NULL) { + if (*iret[idet] != OK) ret = FAIL; - if (detectors[idet]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << idet)); - } + delete iret[idet]; + } else + ret = FAIL; + if (detectors[idet]->getErrorMask()) + setErrorMask(getErrorMask() | (1 << idet)); } } return ret; } -slsDetectorDefs::runStatus multiSlsDetector::startReceiverReadout() { - unsigned int i = 0; - runStatus s = IDLE, s1 = IDLE; - i = thisMultiDetector->masterPosition; - if (thisMultiDetector->masterPosition >= 0) { - s1 = detectors[i]->startReceiverReadout(); - if (detectors[i]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << i)); - } - for (i = 0; i < detectors.size(); ++i) { - s = detectors[i]->startReceiverReadout(); - if (detectors[i]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << i)); - if (s == ERROR) - s1 = ERROR; - if (s != IDLE) - s1 = s; - } - - return s1; -} - slsDetectorDefs::runStatus multiSlsDetector::getReceiverStatus() { - int i = 0; runStatus ret = IDLE; int posmin = 0, posmax = detectors.size(); - i = thisMultiDetector->masterPosition; - if (thisMultiDetector->masterPosition >= 0) { - ret = detectors[i]->getReceiverStatus(); - if (detectors[i]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << i)); - return ret; - } - if (!threadpool) { - cout << "Error in creating threadpool. Exiting" << endl; + std::cout << "Error in creating threadpool. Exiting" << std::endl; return ERROR; } else { runStatus* iret[posmax - posmin]; for (int idet = posmin; idet < posmax; ++idet) { - if (idet != thisMultiDetector->masterPosition) { - iret[idet] = new runStatus(ERROR); - Task* task = new Task(new func0_t(&slsDetector::getReceiverStatus, - detectors[idet], iret[idet])); - threadpool->add_task(task); - } + iret[idet] = new runStatus(ERROR); + Task* task = new Task(new func0_t(&slsDetector::getReceiverStatus, + detectors[idet], iret[idet])); + threadpool->add_task(task); } threadpool->startExecuting(); threadpool->wait_for_tasks_to_complete(); for (int idet = posmin; idet < posmax; ++idet) { - if (idet != thisMultiDetector->masterPosition){ - if (iret[idet] != NULL) { - if (*iret[idet] == (int)ERROR) - ret = ERROR; - if (*iret[idet] != IDLE) - ret = *iret[idet]; - delete iret[idet]; - } else + if (iret[idet] != NULL) { + if (*iret[idet] == (int)ERROR) ret = ERROR; - if (detectors[idet]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << idet)); - } + if (*iret[idet] != IDLE) + ret = *iret[idet]; + delete iret[idet]; + } else + ret = ERROR; + if (detectors[idet]->getErrorMask()) + setErrorMask(getErrorMask() | (1 << idet)); } } @@ -4846,20 +3364,12 @@ slsDetectorDefs::runStatus multiSlsDetector::getReceiverStatus() { int multiSlsDetector::getFramesCaughtByAnyReceiver() { int ret = 0; - int i = thisMultiDetector->masterPosition; - if (i >= 0) { - ret = detectors[i]->getFramesCaughtByReceiver(); - if (detectors[i]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << i)); - // return master receivers frames caught - return ret; - } // return the first one that works if (detectors.size()) { ret = detectors[0]->getFramesCaughtByReceiver(); if (detectors[0]->getErrorMask()) - setErrorMask(getErrorMask() | (1 << i)); + setErrorMask(getErrorMask() | (1 << 0)); return ret; } @@ -4872,7 +3382,7 @@ int multiSlsDetector::getFramesCaughtByReceiver() { int posmax = detectors.size(); if (!threadpool) { - cout << "Error in creating threadpool. Exiting" << endl; + std::cout << "Error in creating threadpool. Exiting" << std::endl; return -1; } else { int* iret[posmax]; @@ -4935,7 +3445,7 @@ int multiSlsDetector::createReceivingDataSockets(const bool destroy) { zmqSocket.clear(); client_downstream = false; - cout << "Destroyed Receiving Data Socket(s)" << endl; + std::cout << "Destroyed Receiving Data Socket(s)" << std::endl; return OK; } @@ -4953,8 +3463,8 @@ int multiSlsDetector::createReceivingDataSockets(const bool destroy) { sscanf(detectors[i / numSocketsPerDetector]->getClientStreamingPort().c_str(), "%d", &portnum); portnum += (i % numSocketsPerDetector); - //cout<<"ip to be set to :"<getClientStreamingIP().c_str()<getClientStreamingIP().c_str()<getClientStreamingIP().c_str(), @@ -4969,7 +3479,7 @@ int multiSlsDetector::createReceivingDataSockets(const bool destroy) { } client_downstream = true; - cout << "Receiving Data Socket(s) created" << endl; + std::cout << "Receiving Data Socket(s) created" << std::endl; return OK; } @@ -5082,7 +3592,7 @@ void multiSlsDetector::readFrameFromReceiver() { coordX = doc["column"].GetUint(); if (eiger) coordY = (nY - 1) - coordY; - //cout << "X:" << doc["row"].GetUint() <<" Y:"<numberOfChannelInclGapPixels[X]; nPixelsY = thisMultiDetector->numberOfChannelInclGapPixels[Y]; - thisData = new detectorData(NULL, NULL, NULL, getCurrentProgress(), + thisData = new detectorData(getCurrentProgress(), currentFileName.c_str(), nPixelsX, nPixelsY, multigappixels, n, dynamicRange, currentFileIndex); } // normal pixels else { - thisData = new detectorData(NULL, NULL, NULL, getCurrentProgress(), + thisData = new detectorData(getCurrentProgress(), currentFileName.c_str(), nPixelsX, nPixelsY, multiframe, multisize, dynamicRange, currentFileIndex); } @@ -5316,11 +3826,15 @@ int multiSlsDetector::processImageWithGapPixels(char* image, char*& gpImage) { int multiSlsDetector::enableWriteToFile(int enable) { - return callDetectorMember(&slsDetector::enableWriteToFile, enable); + if (enable < 0) + callDetectorMember(&slsDetector::enableWriteToFile, -1); + return parallelCallDetectorMember(&slsDetector::enableWriteToFile, enable); } int multiSlsDetector::overwriteFile(int enable) { - return callDetectorMember(&slsDetector::overwriteFile, enable); + if (enable < 0) + callDetectorMember(&slsDetector::overwriteFile, -1); + return parallelCallDetectorMember(&slsDetector::overwriteFile, enable); } @@ -5340,7 +3854,7 @@ int multiSlsDetector::enableDataStreamingToClient(int enable) { //create data threads else { if (createReceivingDataSockets() == FAIL) { - std::cout << "Could not create data threads in client." << std::endl; + std::cout << "Could not create data threads in client." << std::endl; //only for the first det as theres no general one setErrorMask(getErrorMask() | (1 << 0)); detectors[0]->setErrorMask((detectors[0]->getErrorMask()) | @@ -5359,9 +3873,6 @@ int multiSlsDetector::enableDataStreamingFromReceiver(int enable) { return thisMultiDetector->receiver_upstream; } -int multiSlsDetector::enableReceiverCompression(int i) { - return callDetectorMember(&slsDetector::enableReceiverCompression, i); -} int multiSlsDetector::enableTenGigabitEthernet(int i) { return callDetectorMember(&slsDetector::enableTenGigabitEthernet, i); diff --git a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h index dd6afede9..2356c3671 100644 --- a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h +++ b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h @@ -19,7 +19,7 @@ class ZmqSocket; #include -#define MULTI_SHMVERSION 0x180629 +#define MULTI_SHMVERSION 0x181002 #define SHORT_STRING_LENGTH 50 #define DATE_LENGTH 30 @@ -66,12 +66,6 @@ private: * is stopped manually. Is reset to 0 at the start of the acquisition */ int stoppedFlag; - /** position of the master detector */ - int masterPosition; - - /** type of synchronization between detectors */ - synchronizationMode syncMode; - /** size of the data that are transfered from all detectors */ int dataBytes; @@ -110,32 +104,6 @@ private: /** detector threshold (eV) */ int currentThresholdEV; - /** indicator for the acquisition progress - set to 0 at the beginning - * of the acquisition and incremented every time that the data are written - * to file */ - int progressIndex; - - /** total number of frames to be acquired */ - int totalProgress; - - /** current index of the output file */ - int fileIndex; - - /** name root of the output files */ - char fileName[MAX_STR_LENGTH]; - - /** path of the output files */ - char filePath[MAX_STR_LENGTH]; - - /** max frames per file */ - int framesPerFile; - - /** file format*/ - fileFormat fileFormatType; - - /** corrections to be applied to the data \see ::correctionFlags */ - int correctionMask; - /** threaded processing flag (i.e. if data are processed and written to * file in a separate thread) */ int threadedProcessing; @@ -143,60 +111,9 @@ private: /** dead time (in ns) for rate corrections */ double tDead; - /** directory where the flat field files are stored */ - char flatFieldDir[MAX_STR_LENGTH]; - - /** file used for flat field corrections */ - char flatFieldFile[MAX_STR_LENGTH]; - - /** file with the bad channels */ - char badChanFile[MAX_STR_LENGTH]; - - /** angular conversion file */ - char angConvFile[MAX_STR_LENGTH]; - - /** angular direction (1 if it corresponds to the encoder direction - * i.e. channel 0 is 0, maxchan is positive high angle, 0 otherwise */ - int angDirection; - - /** beamline fine offset (of the order of mdeg, might be adjusted for - * each measurements) */ - double fineOffset; - - /** beamline offset (might be a few degrees beacuse of encoder offset - - * normally it is kept fixed for a long period of time) */ - double globalOffset; - - /** bin size for data merging */ - double binSize; - - //X and Y displacement - double sampleDisplacement[2]; - - /** number of positions at which the detector should acquire */ - int numberOfPositions; - - /** list of encoder positions at which the detector should acquire */ - double detPositions[MAXPOS]; - - /** Scans and scripts */ - int actionMask; - - mystring actionScript[MAX_ACTIONS]; - mystring actionParameter[MAX_ACTIONS]; - int scanMode[MAX_SCAN_LEVELS]; - mystring scanScript[MAX_SCAN_LEVELS]; - mystring scanParameter[MAX_SCAN_LEVELS]; - int nScanSteps[MAX_SCAN_LEVELS]; - mysteps scanSteps[MAX_SCAN_LEVELS]; - int scanPrecision[MAX_SCAN_LEVELS]; - /** flag for acquiring */ bool acquiringFlag; - /** external gui */ - bool externalgui; - /** receiver online flag - is set if the receiver is connected, * unset if socket connection is not possible */ int receiverOnlineFlag; @@ -212,13 +129,6 @@ private: public: - using slsDetectorUtils::flatFieldCorrect; - using slsDetectorUtils::rateCorrect; - using slsDetectorUtils::setBadChannelCorrection; - using slsDetectorUtils::readAngularConversion; - using slsDetectorUtils::writeAngularConversion; - - /** * Constructor * @param id multi detector id @@ -272,6 +182,16 @@ public: */ std::string callDetectorMember(std::string(slsDetector::*somefunc)()); + /** + * Loop serially through all the detectors in calling a particular method + * with string argument and string return + * @param somefunc function pointer + * @param s0 argument for calling method + * @returns concatenated result if values are different, otherwise result in calling method + */ + std::string callDetectorMember(std::string (slsDetector::*somefunc)(std::string), + std::string s0); + /** * Loop serially through all the detectors in calling a particular method * with an extra argument @@ -303,7 +223,7 @@ public: T parallelCallDetectorMember(T (slsDetector::*somefunc)()); /** - * Loop serially through all the detectors in calling a particular method + * Parallel calls to all the detectors in calling a particular method * with an extra argument * @param somefunc function pointer * @param value argument for calling method @@ -313,7 +233,7 @@ public: T parallelCallDetectorMember(T (slsDetector::*somefunc)(P1), P1 value); /** - * Loop serially through all the detectors in calling a particular method + * Parallel calls to all the detectors in calling a particular method * with two extra arguments * @param somefunc function pointer * @param par1 argument for calling method @@ -324,7 +244,7 @@ public: T parallelCallDetectorMember(T (slsDetector::*somefunc)(P1, P2), P1 par1, P2 par2); /** - * Loop serially through all the detectors in calling a particular method + * Parallel calls to all the detectors in calling a particular method * with three int arguments * @param somefunc function pointer * @param v0 argument for calling method @@ -335,6 +255,15 @@ public: int parallelCallDetectorMember(int (slsDetector::*somefunc)(int, int, int), int v0, int v1, int v2); + /** + * Parallel calls to all the detectors in calling a particular method + * with string argument and string return + * @param somefunc function pointer + * @param s0 argument for calling method + * @returns concatenated result if values are different, otherwise result in calling method + */ + std::string parallelCallDetectorMember(std::string (slsDetector::*somefunc)(std::string), + std::string s0); /** * Loop serially through all results and * return a value if they are all same, else return -1 @@ -345,13 +274,12 @@ public: T minusOneIfDifferent(const std::vector&); /** - * Calculate the detector position index in multi vector and the module index - * using an index for all entire modules in list (Mythen) - * @param i position index of all modules in list - * @param idet position index in multi vector list - * @param imod module index in the sls detector + * Loop serially through all results and + * return a value if they are all same, else concatenate them + * @param return_values vector of results + * @returns concatenated result if values are different, otherwise result */ - int decodeNMod(int i, int &idet, int &imod); + std::string concatenateIfDifferent(const std::vector& return_values); /** * Decodes which detector and the corresponding channel numbers for it @@ -364,68 +292,6 @@ public: */ int decodeNChannel(int offsetX, int offsetY, int &channelX, int &channelY); - /** - * Decode data from the detector converting them to an array of doubles, - * one for each channel (Mythen only) - * @param datain data from the detector - * @param nn size of datain array - * @param fdata double array of decoded data - * @returns pointer to a double array with a data per channel - */ - double* decodeData(int *datain, int &nn, double *fdata=NULL); - - /** - * Writes a data file - * @param name of the file to be written - * @param data array of data values - * @param err array of errors on the data. If NULL no errors will be written - * @param ang array of angular values. If NULL data will be in the form - * chan-val(-err) otherwise ang-val(-err) - * @param dataformat format of the data: can be 'i' integer or 'f' double (default) - * @param nch number of channels to be written to file. if -1 defaults to - * the number of installed channels of the detector - * @returns OK or FAIL if it could not write the file or data=NULL - * \sa mythenDetector::writeDataFile - */ - int writeDataFile(std::string fname, double *data, double *err=NULL, - double *ang=NULL, char dataformat='f', int nch=-1); - - /** - * Writes a data file with an integer pointer to an array - * @param name of the file to be written - * @param data array of data values - * @returns OK or FAIL if it could not write the file or data=NULL - * \sa mythenDetector::writeDataFile - */ - int writeDataFile(std::string fname, int *data); - - /** - * Reads a data file - * @param name of the file to be read - * @param data array of data values to be filled - * @param err array of arrors on the data. If NULL no errors are expected - * on the file - * @param ang array of angular values. If NULL data are expected in the - * form chan-val(-err) otherwise ang-val(-err) - * @param dataformat format of the data: can be 'i' integer or 'f' double (default) - * @param nch number of channels to be written to file. if <=0 defaults - * to the number of installed channels of the detector - * @returns OK or FAIL if it could not read the file or data=NULL - *\sa mythenDetector::readDataFile - */ - int readDataFile(std::string fname, double *data, double *err=NULL, - double *ang=NULL, char dataformat='f'); - - - /** - * Reads a data file - * @param name of the file to be read - * @param data array of data values - * @returns OK or FAIL if it could not read the file or data=NULL - * \sa mythenDetector::readDataFile - */ - int readDataFile(std::string fname, int *data); - /** * Checks error mask and returns error message and its severity if it exists * @param critical is 1 if any of the messages is critical @@ -592,62 +458,6 @@ public: */ void getNumberOfDetectors(int& nx, int& ny); - /** - * Returns sum of all modules per sls detector from shared memory (Mythen) - * Other detectors, it is 1 - * @returns sum of all modules per sls detector - */ - int getNMods(); - - /** - * Returns sum of all modules per sls detector in dimension d from shared memory (Mythen) - * Other detectors, it is 1 - * @param d dimension d - * @returns sum of all modules per sls detector in dimension d - */ - int getNMod(dimension d); - - /** - * Returns sum of all maximum modules per sls detector from shared memory (Mythen) - * Other detectors, it is 1 - * @returns sum of all maximum modules per sls detector - */ - int getMaxMods(); - - /** - * Returns sum of all maximum modules per sls detector in dimension d from shared memory (Mythen) - * Other detectors, it is 1 - * @param d dimension d - * @returns sum of all maximum modules per sls detector in dimension d - */ - int getMaxMod(dimension d); - - /** - * Returns the sum of all maximum modules per sls detector in dimension d Mythen) - * from the detector directly. - * Other detectors, it is 1 - * @param d dimension d - * @returns sum of all maximum modules per sls detector in dimension d - */ - int getMaxNumberOfModules(dimension d=X); - - /** - * Sets/Gets the sum of all modules per sls detector in dimension d (Mythen) - * from the detector directly. - * Other detectors, it is 1 - * @param i the number of modules to set to - * @param d dimension d - * @returns sum of all modules per sls detector in dimension d - */ - int setNumberOfModules(int i=-1, dimension d=X); - - /** - * Using module id, returns the number of channels per that module - * from shared memory (Mythen) - * @param imod module number of entire multi detector list - * @returns number of channels per module imod - */ - int getChansPerMod(int imod=0); /** * Returns the total number of channels of all sls detectors from shared memory @@ -672,30 +482,6 @@ public: */ int getTotalNumberOfChannelsInclGapPixels(dimension d); - /** - * Returns the maximum number of channels of all sls detectors - * from shared memory (Mythen) - * @returns the maximum number of channels of all sls detectors - */ - int getMaxNumberOfChannels(); - - /** - * Returns the maximum number of channels of all sls detectors in dimension d - * from shared memory (Mythen) - * @param d dimension d - * @returns the maximum number of channels of all sls detectors in dimension d - */ - int getMaxNumberOfChannels(dimension d); - - /** - * Returns the total number of channels of all sls detectors in dimension d - * including gap pixels from shared memory(Mythen) - * @param d dimension d - * @returns the maximum number of channels of all sls detectors in dimension d - * including gap pixels - */ - int getMaxNumberOfChannelsInclGapPixels(dimension d); - /** * Returns the maximum number of channels of all sls detectors in each dimension d * from shared memory. multi detector shared memory variable to calculate @@ -757,10 +543,10 @@ public: /** * Set/Gets TCP Port of detector or receiver * @param t port type - * @param p port number (-1 gets) + * @param num port number (-1 gets) * @returns port number */ - int setPort(portType t, int p); + int setPort(portType t, int num=-1); /** * Lock server for this client IP @@ -897,22 +683,6 @@ public: */ int saveCalibrationFile(std::string fname, int imod=-1); - /** - * Sets/gets the detector in position i as master of the structure (Mythen) - * (e.g. it gates the other detectors and therefore must be started as last. - * Assumes that signal 0 is gate in, signal 1 is trigger in, signal 2 is gate out - * @param i position of master (-1 gets, -2 unset) - * @return master's position (-1 none) - */ - int setMaster(int i=-1); - - /** - * Sets/gets the synchronization mode of the various detector (Mythen) - * @param sync syncronization mode - * @returns current syncronization mode - */ - synchronizationMode setSynchronization(synchronizationMode sync=GET_SYNCHRONIZATION_MODE); - /** * Get Detector run status * @returns status @@ -920,19 +690,11 @@ public: runStatus getRunStatus(); /** - * Prepares detector for acquisition (Eiger and Gotthard) - * For Gotthard, it sets the detector data transmission mode (CPU or receiver) + * Prepares detector for acquisition (Eiger) * @returns OK if all detectors are ready for acquisition, FAIL otherwise */ int prepareAcquisition(); - /** - * Cleans up after acquisition (Gotthard only) - * For Gotthard, it sets the detector data transmission to default (via CPU) - * @returns OK or FAIL - */ - int cleanupAcquisition(); - /** * Start detector acquisition (Non blocking) * @returns OK or FAIL if even one does not start properly @@ -952,82 +714,22 @@ public: int sendSoftwareTrigger(); /** - * Start readout (without exposure or interrupting exposure) (Mythen) + * Start detector acquisition and read all data (Blocking until end of acquisition) + * @returns OK or FAIL + */ + int startAndReadAll(); + + /** + * Start readout (without exposure or interrupting exposure) (Eiger store in ram) * @returns OK or FAIL */ int startReadOut(); /** - * Start detector acquisition and read all data (Blocking until end of acquisition) - * (Mythen, puts all data into a data queue. Others, data at receiver via udp packets) - * @returns pointer to the front of the data queue (return significant only for Mythen) - * \sa startAndReadAllNoWait getDataFromDetector dataQueue - */ - int* startAndReadAll(); - - /** - * Start detector acquisition and call read out, but not reading (data for Mythen, - * and status for other detectors) from the socket. - * (startAndReadAll calls this and getDataFromDetector. Client is not blocking, - * but server is blocked until getDataFromDetector is called. so not recommended - * for users) + * Requests and receives all data from the detector (Eiger store in ram) * @returns OK or FAIL */ - int startAndReadAllNoWait(); - - /** - * Reads from the detector socket (data frame for Mythen and status for other - * detectors) - * @returns pointer to the data or NULL. If NULL disconnects the socket - * (return significant only for Mythen) - * Other detectors return NULL - * \sa getDataFromDetector - */ - int* getDataFromDetector(); - - /** - * Requests and receives a single data frame from the detector - * (Mythen: and puts it in the data queue) - * @returns pointer to the data or NULL. (return Mythen significant) - * Other detectors return NULL - * \sa getDataFromDetector - */ - int* readFrame(); - - /** - * Requests and receives all data from the detector - * (Mythen: and puts them in a data queue) - * @returns pointer to the front of the queue or NULL (return Mythen significant) - * Other detectors return NULL - * \sa getDataFromDetector dataQueue - */ - int* readAll(); - - /** - * Pops the data from the data queue (Mythen) - * @returns pointer to the popped data or NULL if the queue is empty. - * \sa dataQueue - */ - int* popDataQueue(); - - /** - * Pops the data from the postprocessed data queue (Mythen) - * @returns pointer to the popped data or NULL if the queue is empty. - * \sa finalDataQueue - */ - detectorData* popFinalDataQueue(); - - /** - * Resets the raw data queue (Mythen) - * \sa dataQueue - */ - void resetDataQueue(); - - /** - * Resets the post processed data queue (Mythen) - * \sa finalDataQueue - */ - void resetFinalDataQueue(); + int readAll(); /** * Configures in detector the destination for UDP packets (Not Mythen) @@ -1170,16 +872,6 @@ public: */ int digitalTest(digitalTestMode mode, int imod=0); - /** - * Execute trimming (Mythen) - * @param mode trimming mode type - * @param par1 parameter 1 - * @param par2 parameter 2 - * @param imod module index (-1 for all) - * @returns result of trimming - */ - int executeTrimming(trimMode mode, int par1, int par2, int imod=-1); - /** * Load dark or gain image to detector (Gotthard) * @param index image type @@ -1387,14 +1079,6 @@ public: */ int setAutoComparatorDisableMode(int ival= -1); - /** - * Get Scan steps (Mythen) - * @param index scan index - * @param istep step index - * @returns scan step value - */ - double getScanStep(int index, int istep); - /** * Returns the trimbits from the detector's shared memmory (Mythen, Eiger) * @param retval is the array with the trimbits @@ -1404,32 +1088,6 @@ public: */ int getChanRegs(double* retval,bool fromDetector); - /** - * Configure channel (Mythen) - * @param reg channel register - * @param ichan channel number (-1 all) - * @param ichip chip number (-1 all) - * @param imod module number (-1 all) - * \sa ::sls_detector_channel - * @returns current register value - */ - int setChannel(int64_t reg, int ichan=-1, int ichip=-1, int imod=-1); - - /** - * Get Move Flag (Mythen) - * @param imod module number (-1 all) - * @param istep step index - * @returns move flag - */ - int getMoveFlag(int imod); - - /** - * Fill Module mask for flat field corrections (Mythen) - * @param mM array - * @returns number of modules - */ - int fillModuleMask(int *mM); - /** * Calibrate Pedestal (ChipTestBoard) * Starts acquisition, calibrates pedestal and writes to fpga @@ -1466,115 +1124,6 @@ public: */ int getRateCorrection(); - /** - * Rate correct data (Mythen) - * @param datain data array - * @param errin error array on data (if NULL will default to sqrt(datain) - * @param dataout array of corrected data - * @param errout error on corrected data (if not NULL) - * @returns 0 - */ - int rateCorrect(double* datain, double *errin, double* dataout, double *errout); - - /** - * Set flat field corrections (Mythen) - * @param fname name of the flat field file (or "" if disable) - * @returns 0 if disable (or file could not be read), >0 otherwise - */ - int setFlatFieldCorrection(std::string fname=""); - - /** - * Set flat field corrections (Mythen) - * @param corr if !=NULL the flat field corrections will be filled with - * corr (NULL usets ff corrections) - * @param ecorr if !=NULL the flat field correction errors will be filled - * with ecorr (1 otherwise) - * @returns 0 if ff correction disabled, >0 otherwise - */ - int setFlatFieldCorrection(double *corr, double *ecorr=NULL); - - /** - * Get flat field corrections (Mythen) - * @param corr if !=NULL will be filled with the correction coefficients - * @param ecorr if !=NULL will be filled with the correction coefficients errors - * @returns 0 if ff correction disabled, >0 otherwise - */ - int getFlatFieldCorrection(double *corr=NULL, double *ecorr=NULL); - - /** - * Flat field correct data (Mythen) - * @param datain data array - * @param errin error array on data (if NULL will default to sqrt(datain) - * @param dataout array of corrected data - * @param errout error on corrected data (if not NULL) - * @returns 0 - */ - int flatFieldCorrect(double* datain, double *errin, double* dataout, double *errout); - - /** - * Set bad channels correction (Mythen) - * @param fname file with bad channel list ("" disable) - * @returns 0 if bad channel disabled, >0 otherwise - */ - int setBadChannelCorrection(std::string fname=""); - - /** - * Set bad channels correction (Mythen) - * @param nch number of bad channels - * @param chs array of channels - * @param ff 0 if normal bad channels, 1 if ff bad channels - * @returns 0 if bad channel disabled, >0 otherwise - */ - int setBadChannelCorrection(int nch, int *chs, int ff); - - /** - * Get bad channels correction (Mythen) - * @param bad pointer to array that if bad!=NULL will be filled with the - * bad channel list - * @returns 0 if bad channel disabled or no bad channels, >0 otherwise - */ - int getBadChannelCorrection(int *bad=NULL); - - /** - * Reads an angular conversion file (Mythen, Gotthard) - * \sa angleConversionConstant mythenDetector::readAngularConversion - * @param fname file to be read - * @returns 0 if angular conversion disabled, >0 otherwise - */ - int readAngularConversionFile(std::string fname); - - /** - * Writes an angular conversion file (Mythen, Gotthard) - * \sa angleConversionConstant mythenDetector::writeAngularConversion - * @param fname file to be written - * @returns 0 if angular conversion disabled, >0 otherwise - */ - int writeAngularConversion(std::string fname); - - /** - * Get angular conversion (Mythen, Gotthard) - * \sa angleConversionConstant mythenDetector::getAngularConversion - * @param direction reference to diffractometer - * @param angconv array that will be filled with the angular conversion constants - * @returns 0 if angular conversion disabled, >0 otherwise - */ - int getAngularConversion(int &direction, angleConversionConstant *angconv=NULL) ; - - /** - * Sets the value of angular conversion parameter (Mythen, Gotthard) - * @param c can be ANGULAR_DIRECTION, GLOBAL_OFFSET, FINE_OFFSET, BIN_SIZE - * @param v the value to be set - * @returns the actual value - */ - double setAngularConversionParameter(angleConversionParameter c, double v); - - /** - * Gets the value of angular conversion parameter (Mythen, Gotthard) - * @param imod module index (-1 for all) - * @returns the actual value - */ - angleConversionConstant *getAngularConversionPointer(int imod=0); - /** * Prints receiver configuration * @returns OK or FAIL @@ -1625,7 +1174,7 @@ public: * @param s file directory * @returns file dir */ - std::string setFilePath(std::string s=""); + std::string setFilePath(std::string s); /** * Returns file name prefix @@ -1638,7 +1187,7 @@ public: * @param s file name prefix * @returns file name prefix */ - std::string setFileName(std::string s=""); + std::string setFileName(std::string s); /** * Sets the max frames per file in receiver @@ -1672,7 +1221,7 @@ public: * @param f file format * @returns file format */ - fileFormat setFileFormat(fileFormat f=GET_FILE_FORMAT); + fileFormat setFileFormat(fileFormat f); /** * Returns file index @@ -1685,7 +1234,13 @@ public: * @param i file index * @returns file index */ - int setFileIndex(int i=-1); + int setFileIndex(int i); + + /** + * increments file index + * @returns the file index + */ + int incrementFileIndex(); /** * Receiver starts listening to packets @@ -1699,13 +1254,6 @@ public: */ int stopReceiver(); - /** - * Sets the receiver to start any readout remaining in the fifo and - * change status to transmitting (Mythen) - * The status changes to run_finished when fifo is empty - */ - runStatus startReceiverReadout(); - /** * Gets the status of the listening mode of receiver * @returns status @@ -1797,13 +1345,6 @@ public: */ int enableDataStreamingFromReceiver(int enable=-1); - /** - * Enable/disable or get data compression in receiver - * @param i is -1 to get, 0 to disable and 1 to enable - * @returns data compression in receiver - */ - int enableReceiverCompression(int i = -1); - /** * Enable/disable or 10Gbe * @param i is -1 to get, 0 to disable and 1 to enable diff --git a/slsDetectorSoftware/multiSlsDetector/multiSlsDetectorClient.h b/slsDetectorSoftware/multiSlsDetector/multiSlsDetectorClient.h index 3711ac583..095f6e178 100644 --- a/slsDetectorSoftware/multiSlsDetector/multiSlsDetectorClient.h +++ b/slsDetectorSoftware/multiSlsDetector/multiSlsDetectorClient.h @@ -11,7 +11,7 @@ int dummyCallback(detectorData* d, int p,void*) { - cout << "got data " << p << endl; + std::cout << "got data " << p << std::endl; return 0; }; @@ -27,16 +27,16 @@ public: char cmd[100] = ""; \ if (action==slsDetectorDefs::PUT_ACTION && argc<2) { \ - cout << "Wrong usage - should be: "<< argv[0] << \ - "[id-][pos:]channel arg" << endl; \ - cout << endl; \ + std::cout << "Wrong usage - should be: "<< argv[0] << \ + "[id-][pos:]channel arg" << std::endl; \ + std::cout << std::endl; \ return; \ if (del) delete myDetector; \ }; \ if (action==slsDetectorDefs::GET_ACTION && argc<1) { \ - cout << "Wrong usage - should be: "<< argv[0] << \ - "[id-][pos:]channel arg" << endl; \ - cout << endl; \ + std::cout << "Wrong usage - should be: "<< argv[0] << \ + "[id-][pos:]channel arg" << std::endl; \ + std::cout << std::endl; \ if (del) delete myDetector; \ return; \ }; \ @@ -51,7 +51,7 @@ public: //%s needn't be there (if not 1:), so 1 or 2 arguments scanned if (iv >= 1 && id >= 0) { \ argv[0] = cmd; \ - cout << id << "-" ; \ + std::cout << id << "-" ; \ } else { \ id = 0; \ } \ @@ -60,7 +60,7 @@ public: if (strchr(argv[0],':')) { \ iv=sscanf(argv[0],"%d:",&pos); \ if (iv == 1 && pos >= 0) { \ - cout << "pos " << pos << " is not allowed for readout!" << endl; \ + std::cout << "pos " << pos << " is not allowed for readout!" << std::endl; \ return; \ } \ } \ @@ -71,7 +71,7 @@ public: // scan success if (iv == 2 && id >= 0) { \ argv[0] = cmd; \ - cout << id << "-" ; \ + std::cout << id << "-" ; \ } else { \ id = 0; \ } \ @@ -80,7 +80,7 @@ public: // scan success if (iv == 2 && pos >= 0) { \ argv[0] = cmd; \ - cout << pos << ":" ; \ + std::cout << pos << ":" ; \ } \ if (iv != 2) { \ pos = -1; \ @@ -109,17 +109,17 @@ public: - //cout<<"id:"<executeLine(argc, argv, action, pos); \ } catch (const SlsDetectorPackageExceptions & e) { \ - /*cout << e.GetMessage() << endl; */ \ + /*std::cout << e.GetMessage() << std::endl; */ \ delete myCmd; \ if (del) delete myDetector; \ return; \ } catch (...) { \ - cout << " caught exception" << endl; \ + std::cout << " caught exception" << std::endl; \ delete myCmd; \ if (del) delete myDetector; \ return; \ } \ if (action!=slsDetectorDefs::READOUT_ACTION) { \ - cout << argv[0] << " " ; \ + std::cout << argv[0] << " " ; \ } \ - cout << answer<< endl; \ + std::cout << answer<< std::endl; \ delete myCmd; \ if (del) delete myDetector; \ }; diff --git a/slsDetectorSoftware/slsDetector/gitInfoLib.h b/slsDetectorSoftware/slsDetector/gitInfoLib.h index 96c53f374..fbb980f19 100644 --- a/slsDetectorSoftware/slsDetector/gitInfoLib.h +++ b/slsDetectorSoftware/slsDetector/gitInfoLib.h @@ -1,6 +1,6 @@ #define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git" -#define GITREPUUID "d2bce7e372c241cd235977b92be18555bca6a77d" +#define GITREPUUID "def79807f6f40ed1797b8154240adbc0e35c95e0" #define GITAUTH "Dhanya_Thattil" -#define GITREV 0x4020 -#define GITDATE 0x20180927 -#define GITBRANCH "4.0.0" +#define GITREV 0x4039 +#define GITDATE 0x20181002 +#define GITBRANCH "refactor" diff --git a/slsDetectorSoftware/slsDetector/slsDetector.cpp b/slsDetectorSoftware/slsDetector/slsDetector.cpp index 80f4ecc0a..4ee4e1fde 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetector.cpp @@ -5,9 +5,8 @@ #include "receiverInterface.h" #include "gitInfoLib.h" #include "versionAPI.h" -#include "usersFunctions.h" #include "slsDetectorCommand.h" -#include "postProcessingFuncs.h" + #include @@ -32,8 +31,6 @@ slsDetector::slsDetector(detectorType type, int multiId, int id, bool verify, mu controlSocket(0), stopSocket(0), dataSocket(0), - ffcoefficients(0), - fferrors(0), detectorModules(0), dacs(0), adcs(0), @@ -69,8 +66,6 @@ slsDetector::slsDetector(int multiId, int id, bool verify, multiSlsDetector* m) controlSocket(0), stopSocket(0), dataSocket(0), - ffcoefficients(0), - fferrors(0), detectorModules(0), dacs(0), adcs(0), @@ -115,88 +110,6 @@ bool slsDetector::isMultiSlsDetectorClass() { } -double* slsDetector::decodeData(int *datain, int &nn, double *fdata) { - - double *dataout = 0; - if (fdata) { - dataout=fdata; - nn=thisDetector->nChans*thisDetector->nChips*thisDetector->nMods; - if (thisDetector->myDetectorType == JUNGFRAUCTB) - nn=thisDetector->dataBytes/2; - } else { - if (thisDetector->myDetectorType == JUNGFRAUCTB) { - nn=thisDetector->dataBytes/2; - dataout=new double[nn]; - } else { - dataout=new double[thisDetector->nChans*thisDetector->nChips*thisDetector->nMods]; - nn=thisDetector->nChans*thisDetector->nChips*thisDetector->nMods; - } - } - - int ival = 0, ipos = 0, ichan=0, ibyte = 0; - char *ptr = (char*)datain; - char iptr = 0; - int nbits=thisDetector->dynamicRange; - int nch=thisDetector->nChans*thisDetector->nChips*thisDetector->nMods; - - if (thisDetector->timerValue[PROBES_NUMBER]==0) { - if (thisDetector->myDetectorType==JUNGFRAUCTB) { - for (ichan=0; ichandataBytes; ++ibyte) { - iptr=ptr[ibyte]; - for (ipos=0; ipos<8; ++ipos) { - ival=(iptr>>(ipos))&0x1; - dataout[ichan]=ival; - ++ichan; - } - } - break; - case 4: - for (ibyte=0; ibytedataBytes; ++ibyte) { - iptr=ptr[ibyte]; - for (ipos=0; ipos<2; ++ipos) { - ival=(iptr>>(ipos*4))&0xf; - dataout[ichan]=ival; - ++ichan; - } - } - break; - case 8: - for (ichan=0; ichandataBytes; ++ichan) { - ival=ptr[ichan]&0xff; - dataout[ichan]=ival; - } - break; - case 16: - for (ichan=0; ichanmyDetectorType == MYTHEN) mask=0xffffff; - for (ichan=0; ichanSendDataOnly(&fnum,sizeof(fnum)); controlSocket->SendDataOnly(&mode,sizeof(mode)); - if (mode==MODULE_SERIAL_NUMBER) - controlSocket->SendDataOnly(&imod,sizeof(imod)); controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); if (ret!=FAIL) controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); @@ -378,11 +285,7 @@ int64_t slsDetector::getId( idMode mode, int imod) { return ret; } else { #ifdef VERBOSE - if (mode==MODULE_SERIAL_NUMBER) - std::cout<< "Id of "<< imod <<" is " << hex <nTrimEn = 0; for(int i = 0; i < MAX_TRIMEN; ++i) thisDetector->trimEnergies[i] = 0; - thisDetector->progressIndex = 0; - thisDetector->totalProgress = 1; - strcpy(thisDetector->filePath, "/"); - thisDetector->correctionMask = 0; thisDetector->threadedProcessing = 1; thisDetector->tDead = 0; - strncpy(thisDetector->flatFieldDir, getenv("HOME"), MAX_STR_LENGTH-1); - thisDetector->flatFieldDir[MAX_STR_LENGTH-1] = 0; - strcpy(thisDetector->flatFieldFile, "none"); - thisDetector->nBadChans = 0; - strcpy(thisDetector->badChanFile, "none"); - thisDetector->nBadFF = 0; - for (int i = 0; i < MAX_BADCHANS; ++i) { - thisDetector->badChansList[i] = 0; - thisDetector->badFFList[i] = 0; - } - strcpy(thisDetector->angConvFile, "none"); - memset(thisDetector->angOff, 0, MAXMODS * sizeof(angleConversionConstant)); - thisDetector->angDirection = 1; - thisDetector->fineOffset = 0; - thisDetector->globalOffset = 0; - thisDetector->numberOfPositions = 0; - for (int i = 0; i < MAXPOS; ++i) { - thisDetector->detPositions[i] = 0; - } - thisDetector->binSize = 0.001; thisDetector->nROI = 0; memset(thisDetector->roiLimits, 0, MAX_ROIS * sizeof(ROI)); thisDetector->roFlags = NORMAL_READOUT; @@ -691,7 +492,6 @@ void slsDetector::initializeDetectorStructure(detectorType type) { thisDetector->timerValue[FRAME_PERIOD] = 0; thisDetector->timerValue[DELAY_AFTER_TRIGGER] = 0; thisDetector->timerValue[GATES_NUMBER] = 0; - thisDetector->timerValue[PROBES_NUMBER] = 0; thisDetector->timerValue[CYCLES_NUMBER] = 1; thisDetector->timerValue[ACTUAL_TIME] = 0; thisDetector->timerValue[MEASUREMENT_TIME] = 0; @@ -703,22 +503,6 @@ void slsDetector::initializeDetectorStructure(detectorType type) { thisDetector->timerValue[SUBFRAME_ACQUISITION_TIME] = 0; thisDetector->timerValue[STORAGE_CELL_NUMBER] = 0; thisDetector->timerValue[SUBFRAME_DEADTIME] = 0; - thisDetector->actionMask = 0; - for (int i = 0; i < MAX_ACTIONS; ++i) { - strcpy(thisDetector->actionScript[i], "none"); - strcpy(thisDetector->actionParameter[i], "none"); - } - for (int i = 0; i < MAX_SCAN_LEVELS; ++i) { - thisDetector->scanMode[i] = 0; - strcpy(thisDetector->scanScript[i], "none"); - strcpy(thisDetector->scanParameter[i], "none"); - thisDetector->nScanSteps[i] = 0; - { - double initValue = 0; - std::fill_n(thisDetector->scanSteps[i], MAX_SCAN_STEPS, initValue); - } - thisDetector->scanPrecision[i] = 0; - } strcpy(thisDetector->receiver_hostname, "none"); thisDetector->receiverTCPPort = DEFAULT_PORTNO+2; thisDetector->receiverUDPPort = DEFAULT_UDP_PORTNO; @@ -743,7 +527,6 @@ void slsDetector::initializeDetectorStructure(detectorType type) { memset(thisDetector->receiver_zmqip, 0, MAX_STR_LENGTH); thisDetector->gappixels = 0; memset(thisDetector->receiver_additionalJsonHeader, 0, MAX_STR_LENGTH); - thisDetector->receiver_framesPerFile = -1; thisDetector->detectorControlAPIVersion = 0; thisDetector->detectorStopAPIVersion = 0; thisDetector->receiverAPIVersion = 0; @@ -752,12 +535,32 @@ void slsDetector::initializeDetectorStructure(detectorType type) { thisDetector->activated = true; thisDetector->receiver_deactivatedPaddingEnable = true; thisDetector->receiver_silentMode = false; + strcpy(thisDetector->receiver_filePath, "/"); + strcpy(thisDetector->receiver_fileName, "run"); + thisDetector->receiver_fileIndex = 0; + thisDetector->receiver_fileFormatType = BINARY; + switch(thisDetector->myDetectorType) { + case GOTTHARD: + thisDetector->receiver_framesPerFile = MAX_FRAMES_PER_FILE; + break; + case EIGER: + thisDetector->receiver_framesPerFile = EIGER_MAX_FRAMES_PER_FILE; + break; + case JUNGFRAU: + thisDetector->receiver_framesPerFile = JFRAU_MAX_FRAMES_PER_FILE; + break; + case JUNGFRAUCTB: + thisDetector->receiver_framesPerFile = JFRAU_MAX_FRAMES_PER_FILE; + break; + default: + break; + } + thisDetector->receiver_fileWriteEnable = 1; + thisDetector->receiver_overWriteEnable = 0; // get the detector parameters based on type detParameterList detlist; setDetectorSpecificParameters(type, detlist); - thisDetector->nModMax[X] = detlist.nModMaxX; - thisDetector->nModMax[Y] = detlist.nModMaxY; thisDetector->nChan[X] = detlist.nChanX; thisDetector->nChan[Y] = detlist.nChanY; thisDetector->nChip[X] = detlist.nChipX; @@ -767,68 +570,45 @@ void slsDetector::initializeDetectorStructure(detectorType type) { thisDetector->nGain = detlist.nGain; thisDetector->nOffset = detlist.nOffset; thisDetector->dynamicRange = detlist.dynamicRange; - thisDetector->moveFlag = detlist.moveFlag; thisDetector->nGappixels[X] = detlist.nGappixelsX; thisDetector->nGappixels[Y] = detlist.nGappixelsY; // derived parameters - thisDetector->nModsMax = thisDetector->nModMax[X] * thisDetector->nModMax[Y]; thisDetector->nChans = thisDetector->nChan[X] * thisDetector->nChan[Y]; thisDetector->nChips = thisDetector->nChip[X] * thisDetector->nChip[Y]; - // number of modules is initally the maximum number of modules - thisDetector->nMod[X] = thisDetector->nModMax[X]; - thisDetector->nMod[Y] = thisDetector->nModMax[Y]; - thisDetector->nMods = thisDetector->nModsMax; // calculating databytes - thisDetector->dataBytes = thisDetector->nMods * thisDetector->nChips * - thisDetector->nChans * thisDetector->dynamicRange/8; + thisDetector->dataBytes = thisDetector->nChips * thisDetector->nChans * + thisDetector->dynamicRange/8; thisDetector->dataBytesInclGapPixels = - (thisDetector->nMod[X] * thisDetector->nChip[X] * thisDetector->nChan[X] + + (thisDetector->nChip[X] * thisDetector->nChan[X] + thisDetector->gappixels * thisDetector->nGappixels[X]) * - (thisDetector->nMod[Y] * thisDetector->nChip[Y] * thisDetector->nChan[Y] + + (thisDetector->nChip[Y] * thisDetector->nChan[Y] + thisDetector->gappixels * thisDetector->nGappixels[Y]) * thisDetector->dynamicRange/8; - // special for jctb and mythen in 24 bit/ with probes + // special for jctb if(thisDetector->myDetectorType==JUNGFRAUCTB){ getTotalNumberOfChannels(); } - else if(thisDetector->myDetectorType == MYTHEN){ - if (thisDetector->dynamicRange == 24 || thisDetector->timerValue[PROBES_NUMBER] > 0) { - thisDetector->dataBytes = thisDetector->nMods * thisDetector->nChips * - thisDetector->nChans * 4; - thisDetector->dataBytesInclGapPixels = - (thisDetector->nMod[X] * thisDetector->nChip[X] * thisDetector->nChan[X] + - thisDetector->gappixels * thisDetector->nGappixels[X]) * - (thisDetector->nMod[Y] * thisDetector->nChip[Y] * - thisDetector->nChan[Y] + - thisDetector->gappixels * thisDetector->nGappixels[Y]) * - 4; - } - } /** calculates the memory offsets for * flat field coefficients and errors, * module structures, dacs, adcs, chips and channels */ - thisDetector->ffoff = sizeof(sharedSlsDetector); - thisDetector->fferroff = thisDetector->ffoff + sizeof(double) * - thisDetector->nChans * thisDetector->nChips * thisDetector->nModsMax; - thisDetector->modoff = thisDetector->fferroff + sizeof(double) * - thisDetector->nChans * thisDetector->nChips * thisDetector->nModsMax; + thisDetector->modoff = sizeof(sharedSlsDetector); thisDetector->dacoff = thisDetector->modoff + - sizeof(sls_detector_module) * thisDetector->nModsMax; + sizeof(sls_detector_module); thisDetector->adcoff = thisDetector->dacoff + - sizeof(dacs_t) * thisDetector->nDacs * thisDetector->nModsMax; + sizeof(dacs_t) * thisDetector->nDacs; thisDetector->chipoff = thisDetector->adcoff + - sizeof(dacs_t) * thisDetector->nAdcs * thisDetector->nModsMax; + sizeof(dacs_t) * thisDetector->nAdcs; thisDetector->chanoff = thisDetector->chipoff + - sizeof(int) * thisDetector->nChips * thisDetector->nModsMax; + sizeof(int) * thisDetector->nChips; thisDetector->gainoff = thisDetector->chanoff + - sizeof(int) * thisDetector->nGain * thisDetector->nModsMax; + sizeof(int) * thisDetector->nGain; thisDetector->offsetoff = thisDetector->gainoff + - sizeof(int) * thisDetector->nOffset * thisDetector->nModsMax; + sizeof(int) * thisDetector->nOffset; } @@ -837,8 +617,6 @@ void slsDetector::initializeMembers() { // slsdetector // assign addresses char *goff = (char*)thisDetector; - ffcoefficients = (double*)(goff + thisDetector->ffoff); - fferrors = (double*)(goff + thisDetector->fferroff); detectorModules = (sls_detector_module*)(goff + thisDetector->modoff); dacs = (dacs_t*)(goff + thisDetector->dacoff); adcs = (dacs_t*)(goff + thisDetector->adcoff); @@ -859,79 +637,11 @@ void slsDetector::initializeMembers() { currentSettings = &thisDetector->currentSettings; currentThresholdEV = &thisDetector->currentThresholdEV; - // fileIO - filePath = thisDetector->filePath; - fileName=multiDet->fileName; - fileIndex=multiDet->fileIndex; - framesPerFile=multiDet->framesPerFile; - fileFormatType=multiDet->fileFormatType; - - if (thisDetector->myDetectorType != MYTHEN) - fileIO::setFileFormat(BINARY); - switch(thisDetector->myDetectorType) { - case GOTTHARD: - case PROPIX: - fileIO::setFramesPerFile(MAX_FRAMES_PER_FILE); - break; - case EIGER: - fileIO::setFramesPerFile(EIGER_MAX_FRAMES_PER_FILE); - break; - case MOENCH: - fileIO::setFramesPerFile(MOENCH_MAX_FRAMES_PER_FILE); - break; - case JUNGFRAU: - fileIO::setFramesPerFile(JFRAU_MAX_FRAMES_PER_FILE); - break; - case JUNGFRAUCTB: - fileIO::setFramesPerFile(JFRAU_MAX_FRAMES_PER_FILE); - break; - default: - break; - } - - //postProcessing threadedProcessing = &thisDetector->threadedProcessing; - correctionMask = &thisDetector->correctionMask; - flatFieldDir = thisDetector->flatFieldDir; - flatFieldFile = thisDetector->flatFieldFile; - expTime = &timerValue[ACQUISITION_TIME]; - badChannelMask = NULL; fdata = NULL; thisData = NULL; - - // slsDetectorActions - actionMask = &thisDetector->actionMask; - actionScript = thisDetector->actionScript; - actionParameter = thisDetector->actionParameter; - nScanSteps = thisDetector->nScanSteps; - scanSteps = thisDetector->scanSteps; - scanMode = thisDetector->scanMode; - scanPrecision = thisDetector->scanPrecision; - scanScript = thisDetector->scanScript; - scanParameter = thisDetector->scanParameter; - - // angularConversion - numberOfPositions = &thisDetector->numberOfPositions; - detPositions = thisDetector->detPositions; - angConvFile = thisDetector->angConvFile; - binSize = &thisDetector->binSize; - fineOffset = &thisDetector->fineOffset; - globalOffset = &thisDetector->globalOffset; - angDirection = &thisDetector->angDirection; - moveFlag = &thisDetector->moveFlag; - sampleDisplacement = NULL; - - // badChannelCorrections - badChanFile = thisDetector->badChanFile; - nBadChans = &thisDetector->nBadChans; - badChansList = thisDetector->badChansList; - nBadFF = &thisDetector->nBadFF; - badFFList = thisDetector->badFFList; - - //energyConversion - settingsFile = thisDetector->settingsFile; } @@ -939,57 +649,47 @@ void slsDetector::initializeMembers() { void slsDetector::initializeDetectorStructurePointers() { sls_detector_module* thisMod; - for (int imod = 0; imod < thisDetector->nModsMax; ++imod) { - // initializes the ffcoefficients values to 0 - for (int i = 0; i < thisDetector->nChans * thisDetector->nChips; ++i) { - *(ffcoefficients + i + thisDetector->nChans * thisDetector->nChips * imod) = 0; - } - // initializes the fferrors values to 0 - for (int i = 0; i < thisDetector->nChans * thisDetector->nChips; ++i) { - *(fferrors + i + thisDetector->nChans * thisDetector->nChips * imod) = 0; - } - // set thisMod to point to one of the detector structure modules - thisMod = detectorModules + imod; + // set thisMod to point to one of the detector structure modules + thisMod = detectorModules; - thisMod->module = imod; - thisMod->serialnumber = 0; - thisMod->nchan = thisDetector->nChans*thisDetector->nChips; - thisMod->nchip = thisDetector->nChips; - thisMod->ndac = thisDetector->nDacs; - thisMod->nadc = thisDetector->nAdcs; - thisMod->reg = 0; - // dacs, adcs, chipregs and chanregs for thisMod is not allocated in - // detectorModules in shared memory as they are already allocated separately - // in shared memory (below) - thisMod->gain = -1.; - thisMod->offset = -1.; + thisMod->serialnumber = 0; + thisMod->nchan = thisDetector->nChans*thisDetector->nChips; + thisMod->nchip = thisDetector->nChips; + thisMod->ndac = thisDetector->nDacs; + thisMod->nadc = thisDetector->nAdcs; + thisMod->reg = 0; + // dacs, adcs, chipregs and chanregs for thisMod is not allocated in + // detectorModules in shared memory as they are already allocated separately + // in shared memory (below) + thisMod->gain = -1.; + thisMod->offset = -1.; - // initializes the dacs values to 0 - for (int i = 0; i < thisDetector->nDacs; ++i) { - *(dacs + i + thisDetector->nDacs * imod) = 0; - } - // initializes the adc values to 0 - for (int i = 0; i < thisDetector->nAdcs; ++i) { - *(adcs + i + thisDetector->nAdcs * imod) = 0; - } - // initializes the chip registers to 0 - for (int i = 0; i < thisDetector->nChips; ++i) { - *(chipregs + i + thisDetector->nChips * imod) = -1; - } - // initializes the channel registers to 0 - for (int i = 0; i < thisDetector->nChans * thisDetector->nChips; ++i) { - *(chanregs + i + thisDetector->nChans * thisDetector->nChips * imod) = -1; - } - // initializes the gain values to 0 - for (int i = 0; i < thisDetector->nGain; ++i) { - *(gain + i + thisDetector->nGain * imod) = 0; - } - // initializes the offset values to 0 - for (int i = 0; i < thisDetector->nOffset; ++i) { - *(offset + i + thisDetector->nOffset * imod) = 0; - } + // initializes the dacs values to 0 + for (int i = 0; i < thisDetector->nDacs; ++i) { + *(dacs + i) = 0; } + // initializes the adc values to 0 + for (int i = 0; i < thisDetector->nAdcs; ++i) { + *(adcs + i) = 0; + } + // initializes the chip registers to 0 + for (int i = 0; i < thisDetector->nChips; ++i) { + *(chipregs + i) = -1; + } + // initializes the channel registers to 0 + for (int i = 0; i < thisDetector->nChans * thisDetector->nChips; ++i) { + *(chanregs + i) = -1; + } + // initializes the gain values to 0 + for (int i = 0; i < thisDetector->nGain; ++i) { + *(gain + i) = 0; + } + // initializes the offset values to 0 + for (int i = 0; i < thisDetector->nOffset; ++i) { + *(offset + i) = 0; + } + } @@ -1099,51 +799,15 @@ void slsDetector::disconnectStop() { -int slsDetector::sendChannel(sls_detector_channel *myChan) { - int ts=0; - ts+=controlSocket->SendDataOnly(&(myChan->chan),sizeof(myChan->chan)); - ts+=controlSocket->SendDataOnly(&(myChan->chip),sizeof(myChan->chip)); - ts+=controlSocket->SendDataOnly(&(myChan->module),sizeof(myChan->module)); - ts=controlSocket->SendDataOnly(&(myChan->reg),sizeof(myChan->reg)); - return ts; -} - -int slsDetector::sendChip(sls_detector_chip *myChip) { - int ts=0; - //send chip structure - ts+=controlSocket->SendDataOnly(&(myChip->chip),sizeof(myChip->chip)); - ts+=controlSocket->SendDataOnly(&(myChip->module),sizeof(myChip->module)); - ts+=controlSocket->SendDataOnly(&(myChip->nchan),sizeof(myChip->nchan)); - ts+=controlSocket->SendDataOnly(&(myChip->reg),sizeof(myChip->reg)); - ts+=controlSocket->SendDataOnly(myChip->chanregs,sizeof(myChip->chanregs)); -#ifdef VERY_VERBOSE - std::cout<< "chip structure sent" << std::endl; - std::cout<< "now sending " << myChip->nchan << " channles" << std::endl; -#endif - ts=controlSocket->SendDataOnly(myChip->chanregs,sizeof(int)*myChip->nchan ); -#ifdef VERBOSE - std::cout<< "chip's channels sent " <SendDataOnly(&(myMod->module),sizeof(myMod->module)); ts+=controlSocket->SendDataOnly(&(myMod->serialnumber),sizeof(myMod->serialnumber)); ts+=controlSocket->SendDataOnly(&(myMod->nchan),sizeof(myMod->nchan)); ts+=controlSocket->SendDataOnly(&(myMod->nchip),sizeof(myMod->nchip)); ts+=controlSocket->SendDataOnly(&(myMod->ndac),sizeof(myMod->ndac)); ts+=controlSocket->SendDataOnly(&(myMod->nadc),sizeof(myMod->nadc)); ts+=controlSocket->SendDataOnly(&(myMod->reg),sizeof(myMod->reg)); - // only for sending structures like in old mythen server - if (thisDetector->myDetectorType == MYTHEN) { - ts+=controlSocket->SendDataOnly(myMod->dacs,sizeof(myMod->ndac)); - ts+=controlSocket->SendDataOnly(myMod->adcs,sizeof(myMod->nadc)); - ts+=controlSocket->SendDataOnly(myMod->chipregs,sizeof(myMod->nchip)); - ts+=controlSocket->SendDataOnly(myMod->chanregs,sizeof(myMod->nchan)); - } ts+=controlSocket->SendDataOnly(&(myMod->gain),sizeof(myMod->gain)); ts+=controlSocket->SendDataOnly(&(myMod->offset), sizeof(myMod->offset)); @@ -1157,39 +821,6 @@ int slsDetector::sendModule(sls_detector_module *myMod) { return ts; } -int slsDetector::receiveChannel(sls_detector_channel *myChan) { - int ts=0; - ts+=controlSocket->ReceiveDataOnly(&(myChan->chan),sizeof(myChan->chan)); - ts+=controlSocket->ReceiveDataOnly(&(myChan->chip),sizeof(myChan->chip)); - ts+=controlSocket->ReceiveDataOnly(&(myChan->module),sizeof(myChan->module)); - ts=controlSocket->ReceiveDataOnly(&(myChan->reg),sizeof(myChan->reg)); - return ts; -} - -int slsDetector::receiveChip(sls_detector_chip* myChip) { - int *ptr=myChip->chanregs; - int nchanold=myChip->nchan; - int ts=0; - int nch; - - //receive chip structure - ts+=controlSocket->ReceiveDataOnly(&(myChip->chip),sizeof(myChip->chip)); - ts+=controlSocket->ReceiveDataOnly(&(myChip->module),sizeof(myChip->module)); - ts+=controlSocket->ReceiveDataOnly(&(myChip->nchan),sizeof(myChip->nchan)); - ts+=controlSocket->ReceiveDataOnly(&(myChip->reg),sizeof(myChip->reg)); - ts+=controlSocket->ReceiveDataOnly(myChip->chanregs,sizeof(myChip->chanregs)); - - myChip->chanregs=ptr; - if (nchanold<(myChip->nchan)) { - nch=nchanold; - printf("number of channels received is too large!\n"); - } else - nch=myChip->nchan; - - ts+=controlSocket->ReceiveDataOnly(myChip->chanregs,sizeof(int)*nch); - - return ts; -} int slsDetector::receiveModule(sls_detector_module* myMod) { @@ -1199,21 +830,12 @@ int slsDetector::receiveModule(sls_detector_module* myMod) { int *chanptr=myMod->chanregs; int ts=0; //send module structure - ts+=controlSocket->ReceiveDataOnly(&(myMod->module),sizeof(myMod->module)); ts+=controlSocket->ReceiveDataOnly(&(myMod->serialnumber),sizeof(myMod->serialnumber)); ts+=controlSocket->ReceiveDataOnly(&(myMod->nchan),sizeof(myMod->nchan)); ts+=controlSocket->ReceiveDataOnly(&(myMod->nchip),sizeof(myMod->nchip)); ts+=controlSocket->ReceiveDataOnly(&(myMod->ndac),sizeof(myMod->ndac)); ts+=controlSocket->ReceiveDataOnly(&(myMod->nadc),sizeof(myMod->nadc)); ts+=controlSocket->ReceiveDataOnly(&(myMod->reg),sizeof(myMod->reg)); - // only for sending structures like in old mythen server - if (thisDetector->myDetectorType == MYTHEN) { - ts+=controlSocket->ReceiveDataOnly(myMod->dacs,sizeof(myMod->ndac)); - ts+=controlSocket->ReceiveDataOnly(myMod->adcs,sizeof(myMod->nadc)); - ts+=controlSocket->ReceiveDataOnly(myMod->chipregs,sizeof(myMod->nchip)); - ts+=controlSocket->ReceiveDataOnly(myMod->chanregs,sizeof(myMod->nchan)); - } - ts+=controlSocket->ReceiveDataOnly(&(myMod->gain), sizeof(myMod->gain)); ts+=controlSocket->ReceiveDataOnly(&(myMod->offset), sizeof(myMod->offset)); @@ -1224,33 +846,33 @@ int slsDetector::receiveModule(sls_detector_module* myMod) { myMod->chanregs=chanptr; #ifdef VERBOSE - std::cout<< "received module " << myMod->module << " of size "<< ts + std::cout<< "received module of size "<< ts << " register " << myMod->reg << std::endl; #endif ts+=controlSocket->ReceiveDataOnly(myMod->dacs,sizeof(dacs_t)*(myMod->ndac)); #ifdef VERBOSE - std::cout<< "received dacs " << myMod->module << " of size "<< ts << std::endl; + std::cout<< "received dacs of size "<< ts << std::endl; #endif ts+=controlSocket->ReceiveDataOnly(myMod->adcs,sizeof(dacs_t)*(myMod->nadc)); #ifdef VERBOSE - std::cout<< "received adcs " << myMod->module << " of size "<< ts << std::endl; + std::cout<< "received adc of size "<< ts << std::endl; #endif if(thisDetector->myDetectorType != JUNGFRAU){ ts+=controlSocket->ReceiveDataOnly(myMod->chipregs,sizeof(int)*(myMod->nchip)); #ifdef VERBOSE - std::cout<< "received chips " << myMod->module << " of size "<< ts << std::endl; + std::cout<< "received chips of size "<< ts << std::endl; #endif ts+=controlSocket->ReceiveDataOnly(myMod->chanregs,sizeof(int)*(myMod->nchan)); #ifdef VERBOSE std::cout<< "nchans= " << thisDetector->nChans << " nchips= " << thisDetector->nChips; std::cout<< "mod - nchans= " << myMod->nchan << " nchips= " <nchip; - std::cout<< "received chans " << myMod->module << " of size "<< ts << std::endl; + std::cout<< "received chans of size "<< ts << std::endl; #endif } #ifdef VERBOSE - std::cout<< "received module " << myMod->module << " of size "<< ts << " register " + std::cout<< "received module of size "<< ts << " register " << myMod->reg << std::endl; #endif @@ -1436,210 +1058,6 @@ string slsDetector::getDetectorType() { } -int slsDetector::getNMods() { - return thisDetector->nMods; -} - -int slsDetector::getNMod(dimension d) { - return thisDetector->nMod[d]; -} - - -int slsDetector::getMaxMods() { - return thisDetector->nModsMax; -} - - -int slsDetector::getNMaxMod(dimension d) { - return thisDetector->nModMax[d]; -} - - - -int slsDetector::getMaxNumberOfModules(dimension d) { - - int retval; - int fnum=F_GET_MAX_NUMBER_OF_MODULES; - int ret=FAIL; - char mess[MAX_STR_LENGTH]=""; - - if (dY) { - std::cout<< "Get max number of modules in wrong dimension " << d << std::endl; - return ret; - } -#ifdef VERBOSE - std::cout<< std::endl; - std::cout<< "Getting max number of modules in dimension "<< d <onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK){ - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->SendDataOnly(&d,sizeof(d)); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret!=FAIL) - controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); - else { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; - } - disconnectControl(); - if (ret==FORCE_UPDATE) - updateDetector(); - } - } else { - ret=OK; - retval=thisDetector->nModMax[d]; - } -#ifdef VERBOSE - std::cout<< "Max number of modules in dimension "<< d <<" is " << retval << std::endl; -#endif - if (ret==FAIL) { - std::cout<< "Get max number of modules failed " << retval << std::endl; - return retval; - } else { - thisDetector->nModMax[d]=retval; - thisDetector->nModsMax=thisDetector->nModMax[X]*thisDetector->nModMax[Y]; - - - - } - return thisDetector->nModMax[d]; -} - - - -int slsDetector::setNumberOfModules(int n, dimension d) { - - int arg[2], retval=1; - int fnum=F_SET_NUMBER_OF_MODULES; - int ret=FAIL; - char mess[MAX_STR_LENGTH]="dummy"; - int connect; - - arg[0]=d; - arg[1]=n; - - - if (dY) { - std::cout<< "Set number of modules in wrong dimension " << d << std::endl; - return ret; - } - - -#ifdef VERBOSE - std::cout<< std::endl; - std::cout<< "Setting number of modules of dimension "<< d << " to " << n << std::endl; -#endif - if (thisDetector->onlineFlag==ONLINE_FLAG) { - connect = connectControl(); - if (connect == UNDEFINED) - cout << "no control socket?" << endl; - else if (connect == OK){ - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->SendDataOnly(&arg,sizeof(arg)); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret!=FAIL) { - controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); - } else { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; - } - disconnectControl(); - if (ret==FORCE_UPDATE) - updateDetector(); - } - } else { - cout << "offline" << endl; - ret=OK; - if (n==GET_FLAG) - ; - else { - if (n<=0 || n>thisDetector->nModMax[d]) { - ret=FAIL; - } else { - thisDetector->nMod[d]=n; - } - } - retval=thisDetector->nMod[d]; - } -#ifdef VERBOSE - std::cout<< "Number of modules in dimension "<< d <<" is " << retval << std::endl; -#endif - if (ret==FAIL) { - std::cout<< "Set number of modules failed " << std::endl; - } else { - thisDetector->nMod[d]=retval; - thisDetector->nMods=thisDetector->nMod[X]*thisDetector->nMod[Y]; - - - if (thisDetector->nModsMaxnMods) - thisDetector->nModsMax=thisDetector->nMods; - - if (thisDetector->nModMax[X]nMod[X]) - thisDetector->nModMax[X]=thisDetector->nMod[X]; - - if (thisDetector->nModMax[Y]nMod[Y]) - thisDetector->nModMax[Y]=thisDetector->nMod[Y]; - - int dr=thisDetector->dynamicRange; - if ((thisDetector->myDetectorType==MYTHEN) && (dr==24)) - dr=32; - - thisDetector->dataBytes=thisDetector->nMod[X]*thisDetector->nMod[Y]* - thisDetector->nChips*thisDetector->nChans*dr/8; - thisDetector->dataBytesInclGapPixels = - (thisDetector->nMod[X] * thisDetector->nChip[X] * - thisDetector->nChan[X] + thisDetector->gappixels * - thisDetector->nGappixels[X]) * - (thisDetector->nMod[Y] * thisDetector->nChip[Y] * - thisDetector->nChan[Y] + thisDetector->gappixels * - thisDetector->nGappixels[Y]) * - thisDetector->dynamicRange/8; - - if(thisDetector->myDetectorType==MYTHEN){ - if (thisDetector->timerValue[PROBES_NUMBER]!=0) { - thisDetector->dataBytes=thisDetector->nMod[X]* - thisDetector->nMod[Y]*thisDetector->nChips*thisDetector->nChans*4; - thisDetector->dataBytesInclGapPixels = - (thisDetector->nMod[X] * thisDetector->nChip[X] * thisDetector->nChan[X] + thisDetector->gappixels * thisDetector->nGappixels[X]) * - (thisDetector->nMod[Y] * thisDetector->nChip[Y] * thisDetector->nChan[Y] + thisDetector->gappixels * thisDetector->nGappixels[Y]) * - 4; - } - } - - if(thisDetector->myDetectorType==JUNGFRAUCTB){ - getTotalNumberOfChannels(); - } - - -#ifdef VERBOSE -std::cout<< "Data size is " << thisDetector->dataBytes << std::endl; -std::cout<< "nModX " << thisDetector->nMod[X] << " nModY " << thisDetector->nMod[Y] - << " nChips " << thisDetector->nChips << " nChans " << thisDetector->nChans - << " dr " << dr << std::endl; -#endif - } - - if(n != GET_FLAG){ - pthread_mutex_lock(&ms); - multiDet->updateOffsets(); - pthread_mutex_unlock(&ms); - } - - return thisDetector->nMod[d]; -} - - - -int slsDetector::getChansPerMod(int imod) { - return thisDetector->nChans*thisDetector->nChips; -} - -int slsDetector::getChansPerMod( dimension d,int imod) { - return thisDetector->nChan[d]*thisDetector->nChip[d]; -} - - int slsDetector::getTotalNumberOfChannels() { #ifdef VERBOSE cout << "total number of channels" << endl; @@ -1663,55 +1081,32 @@ int slsDetector::getTotalNumberOfChannels() { } thisDetector->nChans=thisDetector->nChan[X]; thisDetector->dataBytes=thisDetector->nChans*thisDetector->nChips* - thisDetector->nMods*2*thisDetector->timerValue[SAMPLES_JCTB]; + 2*thisDetector->timerValue[SAMPLES_JCTB]; thisDetector->dataBytesInclGapPixels = thisDetector->dataBytes; } else { #ifdef VERBOSE cout << "det type is "<< thisDetector->myDetectorType << endl; cout << "Total number of channels is "<< thisDetector->nChans*thisDetector->nChips* - thisDetector->nMods << " data bytes is " << thisDetector->dataBytes << endl; + << " data bytes is " << thisDetector->dataBytes << endl; // excluding gap pixels #endif ; } - return thisDetector->nChans*thisDetector->nChips*thisDetector->nMods; + return thisDetector->nChans*thisDetector->nChips; } int slsDetector::getTotalNumberOfChannels(dimension d) { getTotalNumberOfChannels(); - return thisDetector->nChan[d]*thisDetector->nChip[d]*thisDetector->nMod[d]; + return thisDetector->nChan[d]*thisDetector->nChip[d]; } int slsDetector::getTotalNumberOfChannelsInclGapPixels(dimension d) { getTotalNumberOfChannels(); return (thisDetector->nChan[d] * thisDetector->nChip[d] + thisDetector->gappixels - * thisDetector->nGappixels[d]) * thisDetector->nMod[d]; + * thisDetector->nGappixels[d]); } -int slsDetector::getMaxNumberOfChannels() { - if(thisDetector->myDetectorType==JUNGFRAUCTB) return 36*thisDetector->nChips* - thisDetector->nModsMax; - return thisDetector->nChans*thisDetector->nChips*thisDetector->nModsMax; -} - -int slsDetector::getMaxNumberOfChannels(dimension d) { - if(thisDetector->myDetectorType==JUNGFRAUCTB) { - if (d==X) return 36*thisDetector->nChip[d]*thisDetector->nModMax[d]; - else return 1*thisDetector->nChip[d]*thisDetector->nModMax[d]; - } - return thisDetector->nChan[d]*thisDetector->nChip[d]*thisDetector->nModMax[d]; -}; - -int slsDetector::getMaxNumberOfChannelsInclGapPixels(dimension d) { - if(thisDetector->myDetectorType==JUNGFRAUCTB) { - if (d==X) return 36*thisDetector->nChip[d]*thisDetector->nModMax[d]; - else return 1*thisDetector->nChip[d]*thisDetector->nModMax[d]; - } - return (thisDetector->nChan[d] * thisDetector->nChip[d] + thisDetector->gappixels * - thisDetector->nGappixels[d]) * thisDetector->nModMax[d]; -} - int slsDetector::getNChans() { return thisDetector->nChans; @@ -2281,30 +1676,6 @@ int slsDetector::updateDetectorNoWait() { #ifdef VERBOSE cout << "Updating detector last modified by " << lastClientIP << std::endl; #endif - n += controlSocket->ReceiveDataOnly(&nm,sizeof(nm)); - thisDetector->nMod[X]=nm; - n += controlSocket->ReceiveDataOnly( &nm,sizeof(nm)); - /// Should be overcome at a certain point! - - if (thisDetector->myDetectorType==MYTHEN) { - thisDetector->nModMax[X]=nm; - thisDetector->nModMax[Y]=1; - thisDetector->nModsMax=thisDetector->nModMax[Y]*thisDetector->nModMax[X]; - thisDetector->nMod[Y]=1; - } else { - thisDetector->nMod[Y]=nm; - } - - thisDetector->nMods=thisDetector->nMod[Y]*thisDetector->nMod[X]; - if (thisDetector->nModsMaxnMods) - thisDetector->nModsMax=thisDetector->nMods; - - if (thisDetector->nModMax[X]nMod[X]) - thisDetector->nModMax[X]=thisDetector->nMod[X]; - - if (thisDetector->nModMax[Y]nMod[Y]) - thisDetector->nModMax[Y]=thisDetector->nMod[Y]; - n += controlSocket->ReceiveDataOnly( &nm,sizeof(nm)); thisDetector->dynamicRange=nm; @@ -2314,8 +1685,7 @@ int slsDetector::updateDetectorNoWait() { n += controlSocket->ReceiveDataOnly( &t,sizeof(t)); thisDetector->currentSettings=t; - if((thisDetector->myDetectorType == EIGER) || - (thisDetector->myDetectorType == MYTHEN)){ + if(thisDetector->myDetectorType == EIGER){ n += controlSocket->ReceiveDataOnly( &thr,sizeof(thr)); thisDetector->currentThresholdEV=thr; } @@ -2348,11 +1718,6 @@ int slsDetector::updateDetectorNoWait() { thisDetector->timerValue[GATES_NUMBER]=retval; } - if (thisDetector->myDetectorType == MYTHEN){ - n += controlSocket->ReceiveDataOnly( &retval,sizeof(int64_t)); - thisDetector->timerValue[PROBES_NUMBER]=retval; - } - n += controlSocket->ReceiveDataOnly( &retval,sizeof(int64_t)); thisDetector->timerValue[CYCLES_NUMBER]=retval; @@ -2550,42 +1915,26 @@ int slsDetector::writeConfigurationFile(ofstream &outfile, int id) { names[nvar++] = "caldir"; names[nvar++] = "ffdir"; names[nvar++] = "outdir"; - names[nvar++] = "angdir"; - names[nvar++] = "moveflag"; names[nvar++] = "lock"; // receiver config - if (type != MYTHEN) { - names[nvar++] = "detectormac"; - names[nvar++] = "detectorip"; - names[nvar++] = "zmqport"; - names[nvar++] = "rx_zmqport"; - names[nvar++] = "zmqip"; - names[nvar++] = "rx_zmqip"; - names[nvar++] = "rx_tcpport"; - names[nvar++] = "rx_udpport"; - names[nvar++] = "rx_udpport2"; - names[nvar++] = "rx_udpip"; - names[nvar++] = "rx_hostname"; - names[nvar++] = "r_readfreq"; - } + names[nvar++] = "detectormac"; + names[nvar++] = "detectorip"; + names[nvar++] = "zmqport"; + names[nvar++] = "rx_zmqport"; + names[nvar++] = "zmqip"; + names[nvar++] = "rx_zmqip"; + names[nvar++] = "rx_tcpport"; + names[nvar++] = "rx_udpport"; + names[nvar++] = "rx_udpport2"; + names[nvar++] = "rx_udpip"; + names[nvar++] = "rx_hostname"; + names[nvar++] = "r_readfreq"; + // detector specific config switch (type) { - case MYTHEN: - names[nvar++] = "nmod"; - names[nvar++] = "waitstates"; - names[nvar++] = "setlength"; - names[nvar++] = "clkdivider"; - names[nvar++] = "extsig"; - break; case GOTTHARD: - case PROPIX: - names[nvar++] = "extsig"; - names[nvar++] = "vhighvoltage"; - break; - break; - case MOENCH: names[nvar++] = "extsig"; names[nvar++] = "vhighvoltage"; break; @@ -2662,8 +2011,7 @@ string slsDetector::getSettingsFile() { int slsDetector::writeSettingsFile(string fname, int imod, int iodelay, int tau) { - return writeSettingsFile(fname,thisDetector->myDetectorType, detectorModules[imod], - iodelay, tau); + return writeSettingsFile(fname, detectorModules[imod], iodelay, tau); } @@ -2706,167 +2054,14 @@ slsDetectorDefs::detectorSettings slsDetector::setSettings( detectorSettings ise // send only the settings, detector server will update dac values already in server case GOTTHARD: - case PROPIX: case JUNGFRAU: - case MOENCH: return sendSettingsOnly(isettings); - break; // others send whole module to detector default: - break; + printf("Unknown detector!\n"); + return GET_SETTINGS; } - - - - // MYTHEN ONLY (sends whole detector to module) - - sls_detector_module *myMod=createModule(); - int modmi=imod, modma=imod+1, im=imod; - string settingsfname, calfname; - string ssettings; - - //not included in module structure - int iodelay = -1; - int tau = -1; - int* gainval=0, *offsetval=0; - if(thisDetector->nGain) - gainval=new int[thisDetector->nGain]; - if(thisDetector->nOffset) - offsetval=new int[thisDetector->nOffset]; - - - switch (isettings) { - case STANDARD: - ssettings="/standard"; - thisDetector->currentSettings=STANDARD; - break; - case FAST: - ssettings="/fast"; - thisDetector->currentSettings=FAST; - break; - case HIGHGAIN: - ssettings="/highgain"; - thisDetector->currentSettings=HIGHGAIN; - break; - default: - break; - } - - - if (isettings != thisDetector->currentSettings) { - printf("Unknown settings %s for this detector!\n", - getDetectorSettings(isettings).c_str()); - setErrorMask((getErrorMask())|(SETTINGS_NOT_SET)); - }else{ - if (imod<0) { - modmi=0; - // modma=thisDetector->nModMax[X]*thisDetector->nModMax[Y]; - modma=thisDetector->nMod[X]*thisDetector->nMod[Y]; - } - - for (im=modmi; immodule=im; - - std::cout << std::endl << "Loading settings for module:" << im << std::endl; - - //create file names - ostfn << thisDetector->settingsDir << ssettings <<"/noise.sn" - << setfill('0') << setw(3) << hex << getId(MODULE_SERIAL_NUMBER, im) - << setbase(10); - oscfn << thisDetector->calDir << ssettings << "/calibration.sn" - << setfill('0') << setw(3) << hex << getId(MODULE_SERIAL_NUMBER, im) - << setbase(10); - - - //settings file**** - settingsfname=ostfn.str(); -#ifdef VERBOSE - cout << "the settings file name is "<settingsDir << ssettings - << ssettings << ".trim"; - settingsfname=ostfn_default.str(); -#ifdef VERBOSE - cout << settingsfname << endl; -#endif - if (NULL == readSettingsFile(settingsfname,detType, iodelay, tau, - myMod)) { - //if default doesnt work, return error - std::cout << "Could not open settings file" << endl; - setErrorMask((getErrorMask())|(SETTINGS_FILE_NOT_OPEN)); - return thisDetector->currentSettings; - } - } - - - - //calibration file**** - int ret=0; - calfname=oscfn.str(); -#ifdef VERBOSE - cout << "Specific file:"<< calfname << endl; -#endif - //extra gain and offset - if(thisDetector->nGain) - ret = readCalibrationFile(calfname,gainval, offsetval); - //normal gain and offset inside sls_detector_module - else - ret = readCalibrationFile(calfname,myMod->gain, myMod->offset); - - //if it didnt open, try default - if(ret != OK){ - ostringstream oscfn_default; - oscfn_default << thisDetector->calDir << ssettings << ssettings << ".cal"; - calfname=oscfn_default.str(); -#ifdef VERBOSE - cout << "Default file:" << calfname << endl; -#endif - //extra gain and offset - if(thisDetector->nGain) - ret = readCalibrationFile(calfname,gainval, offsetval); - //normal gain and offset inside sls_detector_module - else - ret = readCalibrationFile(calfname,myMod->gain, myMod->offset); - } - //if default doesnt work, return error - if(ret != OK){ - std::cout << "Could not open calibration file" << calfname << endl; - setErrorMask((getErrorMask())|(SETTINGS_FILE_NOT_OPEN)); - return thisDetector->currentSettings; - } - - - //if everything worked, set module**** - setModule(*myMod,iodelay,tau,-1,gainval,offsetval); - } - } - - - - deleteModule(myMod); - if(gainval) delete [] gainval; - if(offsetval) delete [] offsetval; - - if (thisDetector->correctionMask&(1<-1 && isett<3) { - thisDetector->tDead=t[isett]; - } - } - - - if (getSettings(imod) != isettings){ - std::cout << "Could not set settings" << endl; - setErrorMask((getErrorMask())|(SETTINGS_NOT_SET)); - } - - return thisDetector->currentSettings; } @@ -3055,8 +2250,7 @@ int slsDetector::setThresholdEnergyAndSettings(int e_eV, detectorSettings isetti #endif //read the files myMod=createModule(); - if (NULL == readSettingsFile(settingsfname,thisDetector->myDetectorType, - iodelay, tau, myMod, tb)) { + if (NULL == readSettingsFile(settingsfname, iodelay, tau, myMod, tb)) { if(myMod)deleteModule(myMod); return FAIL; } @@ -3096,15 +2290,13 @@ int slsDetector::setThresholdEnergyAndSettings(int e_eV, detectorSettings isetti int tau1 = -1; //not included in the module int iodelay2 = -1; //not included in the module int tau2 = -1; //not included in the module - if (NULL == readSettingsFile(settingsfname1,thisDetector->myDetectorType, - iodelay1, tau1, myMod1, tb)) { + if (NULL == readSettingsFile(settingsfname1,iodelay1, tau1, myMod1, tb)) { setErrorMask((getErrorMask())|(SETTINGS_FILE_NOT_OPEN)); deleteModule(myMod1); deleteModule(myMod2); return FAIL; } - if (NULL == readSettingsFile(settingsfname2,thisDetector->myDetectorType, - iodelay2, tau2, myMod2, tb)) { + if (NULL == readSettingsFile(settingsfname2, iodelay2, tau2, myMod2, tb)) { setErrorMask((getErrorMask())|(SETTINGS_FILE_NOT_OPEN)); deleteModule(myMod1); deleteModule(myMod2); @@ -3120,8 +2312,7 @@ int slsDetector::setThresholdEnergyAndSettings(int e_eV, detectorSettings isetti iodelay = iodelay1; //interpolate module - myMod = interpolateTrim(thisDetector->myDetectorType, myMod1, myMod2, - e_eV, trim1, trim2, tb); + myMod = interpolateTrim( myMod1, myMod2, e_eV, trim1, trim2, tb); if (myMod == NULL) { printf("Could not interpolate, different dac values in files\n"); setErrorMask((getErrorMask())|(SETTINGS_NOT_SET)); @@ -3138,7 +2329,6 @@ int slsDetector::setThresholdEnergyAndSettings(int e_eV, detectorSettings isetti } - myMod->module=0; myMod->reg=thisDetector->currentSettings; setModule(*myMod, iodelay, tau, e_eV, 0, 0, tb); deleteModule(myMod); @@ -3180,45 +2370,30 @@ int slsDetector::loadSettingsFile(string fname, int imod) { string fn=fname; fn=fname; - int mmin=0, mmax=setNumberOfModules(); - if (imod>=0) { - mmin=imod; - mmax=imod+1; - } - for (int im=mmin; immyDetectorType) { - case MYTHEN: - if (fname.find(".sn")==string::npos && fname.find(".trim")== - string::npos && fname.find(".settings")==string::npos) { - ostfn << ".sn" << setfill('0') << setw(3) << hex << - getId(MODULE_SERIAL_NUMBER, im); - } - break; - case EIGER: - if (fname.find(".sn")==string::npos && fname.find(".trim")== - string::npos && fname.find(".settings")==string::npos) { - ostfn << ".sn" << setfill('0') << setw(3) << dec << - getId(DETECTOR_SERIAL_NUMBER, im); - } - break; - default: - break; - } - fn=ostfn.str(); - myMod=readSettingsFile(fn, thisDetector->myDetectorType,iodelay, tau, myMod); - if (myMod) { - myMod->module=im; - //settings is saved in myMod.reg for all except mythen - if(thisDetector->myDetectorType!=MYTHEN) - myMod->reg=-1; - setModule(*myMod,iodelay,tau,-1,0,0); - deleteModule(myMod); - } else - return FAIL; + ostringstream ostfn; + ostfn << fname; + switch (thisDetector->myDetectorType) { + case EIGER: + if (fname.find(".sn")==string::npos && fname.find(".trim")== + string::npos && fname.find(".settings")==string::npos) { + ostfn << ".sn" << setfill('0') << setw(3) << dec << + getId(DETECTOR_SERIAL_NUMBER, 0); + } + break; + default: + break; } + fn=ostfn.str(); + myMod=readSettingsFile(fn, iodelay, tau, myMod); + + if (myMod) { + myMod->reg=-1; + setModule(*myMod,iodelay,tau,-1,0,0); + deleteModule(myMod); + } else + return FAIL; + return OK; } @@ -3230,39 +2405,29 @@ int slsDetector::saveSettingsFile(string fname, int imod) { int iodelay = -1; int tau = -1; - int mmin=0, mmax=setNumberOfModules(); - if (imod>=0) { - mmin=imod; - mmax=imod+1; + string fn=fname; + ostringstream ostfn; + ostfn << fname; + switch (thisDetector->myDetectorType) { + case EIGER: + ostfn << ".sn" << setfill('0') << setw(3) << dec << + getId(DETECTOR_SERIAL_NUMBER); + break; + default: + printf("Unknown detector!\n"); + return FAIL; } - for (int im=mmin; immyDetectorType) { - case MYTHEN: - ostfn << ".sn" << setfill('0') << setw(3) << hex << - getId(MODULE_SERIAL_NUMBER,im); - break; - case EIGER: - ostfn << ".sn" << setfill('0') << setw(3) << dec << - getId(DETECTOR_SERIAL_NUMBER); - break; - default: - break; - } - fn=ostfn.str(); - if ((myMod=getModule(im))) { + fn=ostfn.str(); + if ((myMod=getModule(0))) { - if(thisDetector->myDetectorType == EIGER){ - iodelay = (int)setDAC((dacs_t)-1,IO_DELAY,0,-1); - tau = (int64_t)getRateCorrectionTau(); - } - ret=writeSettingsFile(fn, thisDetector->myDetectorType, *myMod, - iodelay, tau); - deleteModule(myMod); + if(thisDetector->myDetectorType == EIGER){ + iodelay = (int)setDAC((dacs_t)-1,IO_DELAY,0,-1); + tau = (int64_t)getRateCorrectionTau(); } + ret=writeSettingsFile(fn, *myMod, iodelay, tau); + deleteModule(myMod); } + return ret; } @@ -3292,52 +2457,38 @@ int slsDetector::loadCalibrationFile(string fname, int imod) { } fn=fname; - - - int mmin=0, mmax=setNumberOfModules(); - if (imod>=0) { - mmin=imod; - mmax=imod+1; - } - for (int im=mmin; immyDetectorType) { - case MYTHEN: - if (fname.find(".sn")==string::npos && fname.find(".cal")==string::npos) { - ostfn << ".sn" << setfill('0') << setw(3) << hex << - getId(MODULE_SERIAL_NUMBER, im); - } - break; - case EIGER: - if (fname.find(".sn")==string::npos && fname.find(".cal")==string::npos) { - ostfn << "." << setfill('0') << setw(3) << dec << - getId(DETECTOR_SERIAL_NUMBER); - } - break; - default: - break; + ostringstream ostfn; + ostfn << fname ; + switch (thisDetector->myDetectorType) { + case EIGER: + if (fname.find(".sn")==string::npos && fname.find(".cal")==string::npos) { + ostfn << "." << setfill('0') << setw(3) << dec << + getId(DETECTOR_SERIAL_NUMBER); } - fn=ostfn.str(); - if((myMod=getModule(im))){ - //extra gain and offset - if(thisDetector->nGain){ - if(readCalibrationFile(fn, gainval, offsetval)==FAIL) - return FAIL; - } //normal gain and offset inside sls_detector_module - else{ - if(readCalibrationFile(fn,myMod->gain, myMod->offset)==FAIL) - return FAIL; - } - setModule(*myMod,-1,-1,-1,gainval,offsetval); - - deleteModule(myMod); - if(gainval) delete[]gainval; - if(offsetval) delete[] offsetval; - } else - return FAIL; + break; + default: + printf("Unknown detector!\n"); + return FAIL; } + fn=ostfn.str(); + if((myMod=getModule(0))){ + //extra gain and offset + if(thisDetector->nGain){ + if(readCalibrationFile(fn, gainval, offsetval)==FAIL) + return FAIL; + } //normal gain and offset inside sls_detector_module + else{ + if(readCalibrationFile(fn,myMod->gain, myMod->offset)==FAIL) + return FAIL; + } + setModule(*myMod,-1,-1,-1,gainval,offsetval); + + deleteModule(myMod); + if(gainval) delete[]gainval; + if(offsetval) delete[] offsetval; + } else + return FAIL; + return OK; } @@ -3348,173 +2499,37 @@ int slsDetector::saveCalibrationFile(string fname, int imod) { sls_detector_module *myMod=NULL; int ret=FAIL; - int mmin=0, mmax=setNumberOfModules(); - if (imod>=0) { - mmin=imod; - mmax=imod+1; + string fn=fname; + ostringstream ostfn; + ostfn << fname; + switch (thisDetector->myDetectorType) { + case EIGER: + ostfn << ".sn" << setfill('0') << setw(3) << dec << + getId(DETECTOR_SERIAL_NUMBER); + break; + default: + printf("Unknown detector!\n"); + return FAIL; + break; } - for (int im=mmin; immyDetectorType) { - case MYTHEN: - ostfn << ".sn" << setfill('0') << setw(3) << hex << - getId(MODULE_SERIAL_NUMBER,im); - break; - case EIGER: - ostfn << ".sn" << setfill('0') << setw(3) << dec << - getId(DETECTOR_SERIAL_NUMBER); - break; - default: - break; - } - fn=ostfn.str(); - if ((myMod=getModule(im))) { - //extra gain and offset - if(thisDetector->nGain) - ret=writeCalibrationFile(fn,gain, offset); - //normal gain and offset inside sls_detector_module - else - ret=writeCalibrationFile(fn,myMod->gain, myMod->offset); + fn=ostfn.str(); + if ((myMod=getModule(0))) { + //extra gain and offset + if(thisDetector->nGain) + ret=writeCalibrationFile(fn,gain, offset); + //normal gain and offset inside sls_detector_module + else + ret=writeCalibrationFile(fn,myMod->gain, myMod->offset); + + deleteModule(myMod); + }else + return FAIL; - deleteModule(myMod); - }else - return FAIL; - } return ret; } - -slsDetectorDefs::masterFlags slsDetector::setMaster(masterFlags flag) { - - - int fnum=F_SET_MASTER; - masterFlags retval=GET_MASTER; - char mess[MAX_STR_LENGTH]=""; - int ret=OK; - -#ifdef VERBOSE - std::cout<< "Setting master flags to "<< flag << std::endl; -#endif - - if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK){ - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->SendDataOnly(&flag,sizeof(flag)); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret==FAIL) { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; - } else { - controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); - } - disconnectControl(); - if (ret==FORCE_UPDATE) - updateDetector(); - } - } - -#ifdef VERBOSE - std::cout<< "Master flag set to "<< retval << std::endl; -#endif - return retval; -} - - - - -slsDetectorDefs::synchronizationMode slsDetector::setSynchronization(synchronizationMode flag) { - - - - int fnum=F_SET_SYNCHRONIZATION_MODE; - synchronizationMode retval=GET_SYNCHRONIZATION_MODE; - char mess[MAX_STR_LENGTH]=""; - int ret=OK; - -#ifdef VERBOSE - std::cout<< "Setting synchronization mode to "<< flag << std::endl; -#endif - - if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK){ - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->SendDataOnly(&flag,sizeof(flag)); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret==FAIL) { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; - } else { - controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); - } - disconnectControl(); - if (ret==FORCE_UPDATE) - updateDetector(); - } - } - -#ifdef VERBOSE - std::cout<< "Readout flag set to "<< retval << std::endl; -#endif - return retval; - -} - - -int slsDetector::setTotalProgress() { - - int nf=1, npos=1, nscan[MAX_SCAN_LEVELS]={1,1}, nc=1, nm=1, ns=1; - - if (thisDetector->timerValue[FRAME_NUMBER]) - nf=thisDetector->timerValue[FRAME_NUMBER]; - - if (thisDetector->timerValue[CYCLES_NUMBER]>0) - nc=thisDetector->timerValue[CYCLES_NUMBER]; - - if (thisDetector->timerValue[STORAGE_CELL_NUMBER]>0) - ns=thisDetector->timerValue[STORAGE_CELL_NUMBER]+1; - - if (thisDetector->numberOfPositions>0) - npos=thisDetector->numberOfPositions; - - if (timerValue[MEASUREMENTS_NUMBER]>0) - nm=timerValue[MEASUREMENTS_NUMBER]; - - - if ((thisDetector->nScanSteps[0]>0) && (thisDetector->actionMask & - (1 << MAX_ACTIONS))) - nscan[0]=thisDetector->nScanSteps[0]; - - if ((thisDetector->nScanSteps[1]>0) && (thisDetector->actionMask & - (1 << (MAX_ACTIONS+1)))) - nscan[1]=thisDetector->nScanSteps[1]; - - thisDetector->totalProgress=nf*nc*ns*npos*nm*nscan[0]*nscan[1]; - -#ifdef VERBOSE -cout << "nc " << nc << endl; -cout << "nm " << nm << endl; -cout << "nf " << nf << endl; -cout << "ns " << ns << endl; -cout << "npos " << npos << endl; -cout << "nscan[0] " << nscan[0] << endl; -cout << "nscan[1] " << nscan[1] << endl; - -cout << "Set total progress " << thisDetector->totalProgress << endl; -#endif -return thisDetector->totalProgress; -} - -double slsDetector::getCurrentProgress() { - - return 100.*((double)thisDetector->progressIndex)/((double)thisDetector->totalProgress); -} - - - slsDetectorDefs::runStatus slsDetector::getRunStatus() { int fnum=F_GET_RUN_STATUS; int ret=FAIL; @@ -3576,33 +2591,7 @@ int slsDetector::prepareAcquisition() { return ret; } -int slsDetector::cleanupAcquisition() { - int fnum = F_CLEANUP_ACQUISITION; - int ret=FAIL; - char mess[MAX_STR_LENGTH]=""; - if (thisDetector->onlineFlag==ONLINE_FLAG) { -#ifdef VERBOSE - std::cout << "Cleaning up Detector after Acquisition " << std::endl; -#endif - if (connectControl() == OK){ - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret==FAIL){ - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; - setErrorMask((getErrorMask())|(CLEANUP_ACQUISITION)); - } - disconnectControl(); - if (ret==FORCE_UPDATE) - updateDetector(); - } - }else - std::cout << "cannot connect to detector" << endl; - - return ret; - -} @@ -3703,8 +2692,41 @@ int slsDetector::sendSoftwareTrigger() { -int slsDetector::startReadOut() { +int slsDetector::startAndReadAll() { + int fnum= F_START_AND_READ_ALL; + int ret=FAIL; + char mess[MAX_STR_LENGTH]=""; + +#ifdef VERBOSE + std::cout<< "Starting and reading all frames "<< std::endl; +#endif + thisDetector->stoppedFlag=0; + if (thisDetector->onlineFlag==ONLINE_FLAG) { + if (connectControl() == OK){ + //std::cout<< "connected" << std::endl; + controlSocket->SendDataOnly(&fnum,sizeof(fnum)); + controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); + controlSocket->ReceiveDataOnly(mess,sizeof(mess)); + if (ret==FAIL) { + thisDetector->stoppedFlag=1; + std::cout<< "Detector returned: " << mess << std::endl; + } else { + ; + #ifdef VERBOSE + std::cout<< "Detector successfully returned: " << mess << " " << n + << std::endl; + #endif + } + disconnectControl(); + } + } + return ret; +} + + + +int slsDetector::startReadOut() { int fnum=F_START_READOUT; int ret=FAIL; char mess[MAX_STR_LENGTH]=""; @@ -3729,221 +2751,37 @@ int slsDetector::startReadOut() { } - -int* slsDetector::startAndReadAll() { - //cout << "Start and read all "<< endl; - - int* retval; - //#ifdef VERBOSE -#ifdef VERBOSE - int i=0; -#endif - //#endif - if(thisDetector->myDetectorType == EIGER) { - if (prepareAcquisition() == FAIL) - return NULL; - } - startAndReadAllNoWait(); - //#ifdef VERBOSE - // std::cout<< "started" << std::endl; - //#endif - while ((retval=getDataFromDetector())){ -#ifdef VERBOSE - ++i; - std::cout<< i << std::endl; - //#else - //std::cout<< "-" << flush; -#endif - dataQueue.push(retval); - - //std::cout<< "pushed" << std::endl; - } - disconnectControl(); - -#ifdef VERBOSE - std::cout<< "received "<< i<< " frames" << std::endl; - //#else - // std::cout << std::endl; -#endif - return dataQueue.front(); // check what we return! - /* while ((retval=getDataFromDetectorNoWait())) - ++i; - #ifdef VERBOSE - std::cout<< "Received " << i << " frames"<< std::endl; - #endif - return dataQueue.front(); // check what we return! - */ - -} - - - -int slsDetector::startAndReadAllNoWait() { - - int fnum= F_START_AND_READ_ALL; - -#ifdef VERBOSE - std::cout<< "Starting and reading all frames "<< std::endl; -#endif - thisDetector->stoppedFlag=0; - if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK){ - //std::cout<< "connected" << std::endl; - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - return OK; - } - } - return FAIL; -} - - - - -int* slsDetector::getDataFromDetector(int *retval) { - int ret=FAIL; - char mess[MAX_STR_LENGTH]="Nothing"; - int nel=thisDetector->dataBytes/sizeof(int); - int n; - int *r=retval; - - int nodatadetectortype = false; - detectorType types = getDetectorsType(); - if(types == EIGER || types == JUNGFRAU || GOTTHARD || PROPIX){ - nodatadetectortype = true; - } - - - if (!nodatadetectortype && retval==NULL) - retval=new int[nel]; - - -#ifdef VERBOSE - std::cout<< "getting data "<< thisDetector->dataBytes << " " << nel<< std::endl; -#endif - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); -#ifdef VERBOSE - cout << "ret=" << ret << endl; -#endif - - if (ret!=OK) { - n= controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - // if(thisDetector->receiverOnlineFlag == OFFLINE_FLAG) - if (ret==FAIL) { - thisDetector->stoppedFlag=1; - std::cout<< "Detector returned: " << mess << " " << n << std::endl; - } else { - ; -#ifdef VERBOSE - std::cout<< "Detector successfully returned: " << mess << " " << n - << std::endl; -#endif - } - if ((!nodatadetectortype) && (r==NULL)){ - delete [] retval; - } - return NULL; - } else if (!nodatadetectortype){ - - n=controlSocket->ReceiveDataOnly(retval,thisDetector->dataBytes); - -#ifdef VERBOSE - std::cout<< "Received "<< n << " data bytes" << std::endl; -#endif - if (n!=thisDetector->dataBytes) { - std::cout<< "wrong data size received from detector: received " << - n << " but expected " << thisDetector->dataBytes << std::endl; - thisDetector->stoppedFlag=1; - ret=FAIL; - if (r==NULL) { - delete [] retval; - } - return NULL; - } - // for (int ib=0; ibdataBytes/8; ++ib) - // cout << ((*(((u_int64_t*)retval)+ib))>>17&1) ; - - - } - // cout << "get data returning " << endl; - // cout << endl; - return retval; - -} - - - -int* slsDetector::readFrame() { - - int fnum=F_READ_FRAME; - int* retval=NULL; - -#ifdef VERBOSE - std::cout<< "slsDetector: Reading frame "<< std::endl; -#endif - if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK){ - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - retval=getDataFromDetector(); - if (retval) { - dataQueue.push(retval); - disconnectControl(); - } - } - } - return retval; -} - - - - -int* slsDetector::readAll() { +int slsDetector::readAll() { int fnum=F_READ_ALL; - int* retval; // check what we return! + int ret=FAIL; + char mess[MAX_STR_LENGTH]=""; #ifdef VERBOSE - int i=0; std::cout<< "Reading all frames "<< std::endl; #endif if (thisDetector->onlineFlag==ONLINE_FLAG) { if (connectControl() == OK){ controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - - while ((retval=getDataFromDetector())){ -#ifdef VERBOSE - ++i; - std::cout<< i << std::endl; -#endif - dataQueue.push(retval); + controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); + controlSocket->ReceiveDataOnly(mess,sizeof(mess)); + if (ret==FAIL) { + thisDetector->stoppedFlag=1; + std::cout<< "Detector returned: " << mess << std::endl; + } else { + ; + #ifdef VERBOSE + std::cout<< "Detector successfully returned: " << mess << " " << n + << std::endl; + #endif } disconnectControl(); } } -#ifdef VERBOSE - std::cout<< "received "<< i<< " frames" << std::endl; -#endif - return dataQueue.front(); // check what we return! - + return ret; } -int slsDetector::readAllNoWait() { - - int fnum= F_READ_ALL; - -#ifdef VERBOSE - std::cout<< "Reading all frames "<< std::endl; -#endif - - if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK){ - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - return OK; - } - } - return FAIL; -} - int slsDetector::configureMAC() { @@ -4197,15 +3035,8 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t, int imod) { //std::cout<< "offline " << std::endl; if (t>=0) thisDetector->timerValue[index]=t; - if((thisDetector->myDetectorType==GOTTHARD)|| - (thisDetector->myDetectorType==PROPIX)|| - (thisDetector->myDetectorType==JUNGFRAU)|| - (thisDetector->myDetectorType==MOENCH)) - thisDetector->timerValue[PROBES_NUMBER]=0; if(thisDetector->myDetectorType==JUNGFRAUCTB && index==SAMPLES_JCTB) { getTotalNumberOfChannels(); - // thisDetector->dataBytes=getTotalNumberOfChannels()* - //thisDetector->dynamicRange/8*thisDetector->timerValue[SAMPLES_JCTB]; } } @@ -4218,10 +3049,6 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t, int imod) { << "ns" << std::endl; #endif - if ((thisDetector->myDetectorType==MYTHEN)&&(index==PROBES_NUMBER)) { - setDynamicRange(); - //cout << "Changing probes: data size = " << thisDetector->dataBytes <myDetectorType==JUNGFRAUCTB) && (index==SAMPLES_JCTB)) { setDynamicRange(); cout << "Changing samples: data size = " << thisDetector->dataBytes <myDetectorType==MYTHEN)&&(index==PROBES_NUMBER)) { - setDynamicRange(); - //cout << "Changing probes: data size = " << thisDetector->dataBytes <myDetectorType == MYTHEN) &&(n==24)) - n=32; - - if (thisDetector->onlineFlag==ONLINE_FLAG) { if (connectControl() == OK){ @@ -4455,53 +3273,20 @@ int slsDetector::setDynamicRange(int n) { if (ret==FORCE_UPDATE) updateDetector(); } - } else if(thisDetector->myDetectorType==MYTHEN){ - if (n>0) - thisDetector->dynamicRange=n; - retval=thisDetector->dynamicRange; } //cout << "detector returned dynamic range " << retval << endl; if (ret!=FAIL && retval>0) { - /* checking the number of probes to chose the data size */ - - - - thisDetector->dataBytes=thisDetector->nMod[X]*thisDetector->nMod[Y]* - thisDetector->nChips*thisDetector->nChans*retval/8; + thisDetector->dataBytes=thisDetector->nChips*thisDetector->nChans*retval/8; thisDetector->dataBytesInclGapPixels = - (thisDetector->nMod[X] * thisDetector->nChip[X] * + (thisDetector->nChip[X] * thisDetector->nChan[X] + thisDetector->gappixels * thisDetector->nGappixels[X]) * - (thisDetector->nMod[Y] * thisDetector->nChip[Y] * + (thisDetector->nChip[Y] * thisDetector->nChan[Y] + thisDetector->gappixels * thisDetector->nGappixels[Y]) * retval/8; if (thisDetector->myDetectorType==JUNGFRAUCTB) { - // thisDetector->nChip[X]=retval/16; - // thisDetector->nChips=thisDetector->nChip[X]*thisDetector->nChip[Y]; - // cout << thisDetector->nMod[X]*thisDetector->nMod[Y] << " " - //<< thisDetector->nChans*thisDetector->nChips << " " << retval<< " "; getTotalNumberOfChannels(); - //thisDetector->dataBytes=getTotalNumberOfChannels()* - //retval/8*thisDetector->timerValue[SAMPLES_JCTB]; - //cout << "data bytes: "<< thisDetector->dataBytes << endl; - } - if(thisDetector->myDetectorType==MYTHEN){ - if (thisDetector->timerValue[PROBES_NUMBER]!=0) { - thisDetector->dataBytes=thisDetector->nMod[X]* - thisDetector->nMod[Y]*thisDetector->nChips*thisDetector->nChans*4; - thisDetector->dataBytesInclGapPixels = - (thisDetector->nMod[X] * thisDetector->nChip[X] * - thisDetector->nChan[X] + thisDetector->gappixels * - thisDetector->nGappixels[X]) * - (thisDetector->nMod[Y] * thisDetector->nChip[Y] * - thisDetector->nChan[Y] + thisDetector->gappixels * - thisDetector->nGappixels[Y]) * - 4; - } - - if (retval==32) - thisDetector->dynamicRange=24; } thisDetector->dynamicRange=retval; @@ -4564,8 +3349,7 @@ dacs_t slsDetector::setDAC(dacs_t val, dacIndex index, int mV, int imod) { int arg[3]; - if ( (index==HV_NEW) &&((thisDetector->myDetectorType == GOTTHARD) || - (thisDetector->myDetectorType == PROPIX))) + if ( (index==HV_NEW) &&(thisDetector->myDetectorType == GOTTHARD)) index=HV_POT; arg[0]=index; @@ -4589,13 +3373,8 @@ dacs_t slsDetector::setDAC(dacs_t val, dacIndex index, int mV, int imod) { if (index < thisDetector->nDacs){ if (dacs) { - if (imod>=0) { - *(dacs+index+imod*thisDetector->nDacs)=retval[0]; - } - else { - for (imod=0; imodnModsMax; ++imod) - *(dacs+index+imod*thisDetector->nDacs)=retval[0]; - } + *(dacs+index)=retval[0]; + } } } else { @@ -5214,17 +3993,15 @@ string slsDetector::setReceiver(string receiverIP) { thisDetector->myDetectorType) << endl; std::cout << "detector id:" << detId << endl; std::cout << "detector hostname:" << thisDetector->hostname << endl; - std::cout << "file path:" << fileIO::getFilePath() << endl; - std::cout << "file name:" << fileIO::getFileName() << endl; - std::cout << "file index:" << fileIO::getFileIndex() << endl; - std::cout << "file format:" << fileIO::getFileFormat() << endl; - std::cout << "r_framesperfile:" << thisDetector->receiver_framesPerFile << endl; + std::cout << "file path:" << thisDetector->receiver_filePath << endl; + std::cout << "file name:" << thisDetector->receiver_fileName << endl; + std::cout << "file index:" << thisDetector->receiver_fileIndex << endl; + std::cout << "file format:" << thisDetector->receiver_fileFormatType << endl; + std::cout << "framesperfile:" << thisDetector->receiver_framesPerFile << endl; std::cout << "r_discardpolicy:" << thisDetector->receiver_frameDiscardMode << endl; std::cout << "r_padding:" << thisDetector->receiver_framePadding << endl; - pthread_mutex_lock(&ms); - std::cout << "write enable:" << multiDet->enableWriteToFileMask() << endl; - std::cout << "overwrite enable:" << multiDet->enableOverwriteMask() << endl; - pthread_mutex_unlock(&ms); + std::cout << "write enable:" << thisDetector->receiver_fileWriteEnable << endl; + std::cout << "overwrite enable:" << thisDetector->receiver_overWriteEnable << endl; std::cout << "frame index needed:" << ((thisDetector->timerValue[FRAME_NUMBER] *thisDetector->timerValue[CYCLES_NUMBER])>1) << endl; std::cout << "frame period:" << thisDetector->timerValue[FRAME_PERIOD] << endl; @@ -5256,21 +4033,15 @@ string slsDetector::setReceiver(string receiverIP) { setUDPConnection(); //setReceiverUDPSocketBufferSize(atoi(getReceiverUDPSocketBufferSize().c_str())); - setFilePath(fileIO::getFilePath()); - setFileName(fileIO::getFileName()); - setFileIndex(fileIO::getFileIndex()); - setFileFormat(fileIO::getFileFormat()); + setFilePath(thisDetector->receiver_filePath); + setFileName(thisDetector->receiver_fileName); + setFileIndex(thisDetector->receiver_fileIndex); + setFileFormat(thisDetector->receiver_fileFormatType); setReceiverFramesPerFile(thisDetector->receiver_framesPerFile); setReceiverFramesDiscardPolicy(thisDetector->receiver_frameDiscardMode); setReceiverPartialFramesPadding(thisDetector->receiver_framePadding); - pthread_mutex_lock(&ms); - int imask = multiDet->enableWriteToFileMask(); - pthread_mutex_unlock(&ms); - enableWriteToFile(imask); - pthread_mutex_lock(&ms); - imask = multiDet->enableOverwriteMask(); - pthread_mutex_unlock(&ms); - overwriteFile(imask); + enableWriteToFile(thisDetector->receiver_fileWriteEnable); + overwriteFile(thisDetector->receiver_overWriteEnable); setTimer(FRAME_PERIOD,thisDetector->timerValue[FRAME_PERIOD]); setTimer(FRAME_NUMBER,thisDetector->timerValue[FRAME_NUMBER]); setTimer(ACQUISITION_TIME,thisDetector->timerValue[ACQUISITION_TIME]); @@ -5786,63 +4557,10 @@ int slsDetector::digitalTest( digitalTestMode mode, int imod) { } - -int slsDetector::executeTrimming(trimMode mode, int par1, int par2, int imod) { - - int fnum= F_EXECUTE_TRIMMING; - int retval=FAIL; - char mess[MAX_STR_LENGTH]=""; - int ret=OK; - int arg[3]; - arg[0]=imod; - arg[1]=par1; - arg[2]=par2; - - -#ifdef VERBOSE - std::cout<< "Trimming module " << imod << " with mode "<< mode << " parameters " - << par1 << " " << par2 << std::endl; -#endif - - if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK){ - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); -#ifdef VERBOSE - std::cout<< "sending mode bytes= "<< controlSocket->SendDataOnly( - &mode,sizeof(mode)) << std::endl; -#endif - controlSocket->SendDataOnly(&mode,sizeof(mode)); - controlSocket->SendDataOnly(arg,sizeof(arg)); - - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret==FAIL) { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; - } else { -#ifdef VERBOSE - std::cout<< "Detector trimmed "<< ret << std::endl; -#endif - /* - controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); - thisDetector->roFlags=retval; - */ - retval=ret; - } - disconnectControl(); - if (ret==FORCE_UPDATE) - updateDetector(); - } - } - return retval; - -} - - - int slsDetector::loadImageToDetector(imageType index,string const fname) { int ret=FAIL; - short int arg[thisDetector->nChans*thisDetector->nChips*thisDetector->nMods]; + short int arg[thisDetector->nChans*thisDetector->nChips]; #ifdef VERBOSE std::cout<< std::endl<< "Loading "; @@ -5862,6 +4580,7 @@ int slsDetector::loadImageToDetector(imageType index,string const fname) { } + int slsDetector::sendImageToDetector(imageType index,short int imageVals[]) { int ret=FAIL; @@ -5899,7 +4618,7 @@ int slsDetector::sendImageToDetector(imageType index,short int imageVals[]) { int slsDetector::writeCounterBlockFile(string const fname,int startACQ) { int ret=FAIL; - short int counterVals[thisDetector->nChans*thisDetector->nChips*thisDetector->nMods]; + short int counterVals[thisDetector->nChans*thisDetector->nChips]; #ifdef VERBOSE std::cout<< std::endl<< "Reading Counter to \""<=0) { - setChannel((val<<((int)TRIMBIT_OFF))|((int)COMPARATOR_ENABLE)); // trimbit scan - } - return val; - } else { - if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK){ - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->SendDataOnly(&val,sizeof(val)); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret==FAIL) { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; - setErrorMask((getErrorMask())|(ALLTIMBITS_NOT_SET)); - } else { - controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); - } - disconnectControl(); - if (ret==FORCE_UPDATE) - updateDetector(); + if (thisDetector->onlineFlag==ONLINE_FLAG) { + if (connectControl() == OK){ + controlSocket->SendDataOnly(&fnum,sizeof(fnum)); + controlSocket->SendDataOnly(&val,sizeof(val)); + controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); + if (ret==FAIL) { + controlSocket->ReceiveDataOnly(mess,sizeof(mess)); + std::cout<< "Detector returned error: " << mess << std::endl; + setErrorMask((getErrorMask())|(ALLTIMBITS_NOT_SET)); + } else { + controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); } + disconnectControl(); + if (ret==FORCE_UPDATE) + updateDetector(); } } @@ -6437,29 +5149,16 @@ int slsDetector::enableGapPixels(int val) { if (thisDetector->dynamicRange != 4) { thisDetector->dataBytesInclGapPixels = - (thisDetector->nMod[X] * thisDetector->nChip[X] * + (thisDetector->nChip[X] * thisDetector->nChan[X] + thisDetector->gappixels * thisDetector->nGappixels[X]) * - (thisDetector->nMod[Y] * thisDetector->nChip[Y] * + (thisDetector->nChip[Y] * thisDetector->nChan[Y] + thisDetector->gappixels * thisDetector->nGappixels[Y]) * thisDetector->dynamicRange/8; // set data bytes for other detector ( for future use) if(thisDetector->myDetectorType==JUNGFRAUCTB) getTotalNumberOfChannels(); - else if(thisDetector->myDetectorType==MYTHEN){ - if (thisDetector->dynamicRange==24 || - thisDetector->timerValue[PROBES_NUMBER]>0) { - thisDetector->dataBytesInclGapPixels = - (thisDetector->nMod[X] * thisDetector->nChip[X] * - thisDetector->nChan[X] + thisDetector->gappixels * - thisDetector->nGappixels[X]) * - (thisDetector->nMod[Y] * thisDetector->nChip[Y] * - thisDetector->nChan[Y] + thisDetector->gappixels * - thisDetector->nGappixels[Y]) * - 4; - } - } } } } @@ -7094,8 +5793,7 @@ int slsDetector::setAutoComparatorDisableMode(int ival) { int slsDetector::getChanRegs(double* retval,bool fromDetector) { int n=getTotalNumberOfChannels(); if(fromDetector){ - for(int im=0;imnChans*thisDetector->nChips]; - int chiregs[thisDetector->nChips]; - dacs_t das[thisDetector->nDacs], ads[thisDetector->nAdcs]; - int mmin=imod, mmax=imod+1; - int ret=FAIL; - - if (imod==-1) { - mmin=0; - mmax=thisDetector->nModsMax; - } - - - - for (int im=mmin; imnChans; - myModule.nchip=thisDetector->nChips; - myModule.ndac=thisDetector->nDacs; - myModule.nadc=thisDetector->nAdcs; - - myModule.reg=reg; - if (detectorModules) { - myModule.gain=(detectorModules+im)->gain; - myModule.offset=(detectorModules+im)->offset; - myModule.serialnumber=(detectorModules+im)->serialnumber; - } else { - myModule.gain=-1; - myModule.offset=-1; - myModule.serialnumber=-1; - } - - - for (int i=0; inAdcs; ++i) - ads[i]=-1; - - if (chanregs) - myModule.chanregs=chanregs+im*thisDetector->nChips*thisDetector->nChans; - else { - for (int i=0; inChans*thisDetector->nChips; ++i) - charegs[i]=-1; - myModule.chanregs=charegs; - } - if (chipregs) - myModule.chipregs=chanregs+im*thisDetector->nChips; - else { - for (int ichip=0; ichipnChips; ++ichip) - chiregs[ichip]=-1; - myModule.chipregs=chiregs; - } - if (dacs) - myModule.dacs=dacs+im*thisDetector->nDacs; - else { - for (int i=0; inDacs; ++i) - das[i]=-1; - myModule.dacs=das; - } - if (adcs) - myModule.adcs=adcs+im*thisDetector->nAdcs; - else { - for (int i=0; inAdcs; ++i) - ads[i]=-1; - myModule.adcs=ads; - } - ret=setModule(myModule,-1,-1,-1,0,0); - } - return ret; - - -} - int slsDetector::setModule(sls_detector_module module, int iodelay, int tau, int e_eV, int* gainval, int* offsetval, int tb) { @@ -7191,7 +5812,7 @@ int slsDetector::setModule(sls_detector_module module, int iodelay, int tau, int ret=FAIL; char mess[MAX_STR_LENGTH]=""; - int imod=module.module; + int imod=0; #ifdef VERBOSE @@ -7238,13 +5859,12 @@ int slsDetector::setModule(sls_detector_module module, int iodelay, int tau, if (ret!=FAIL) { if (detectorModules) { - if (imod>=0 && imodnMod[X]*thisDetector->nMod[Y]) { if(tb) { - (detectorModules+imod)->nchan=module.nchan; - (detectorModules+imod)->nchip=module.nchip; + (detectorModules)->nchan=module.nchan; + (detectorModules)->nchip=module.nchip; } - (detectorModules+imod)->ndac=module.ndac; - (detectorModules+imod)->nadc=module.nadc; + (detectorModules)->ndac=module.ndac; + (detectorModules)->nadc=module.nadc; if(tb) { thisDetector->nChips=module.nchip; thisDetector->nChans=module.nchan/module.nchip; @@ -7280,11 +5900,10 @@ int slsDetector::setModule(sls_detector_module module, int iodelay, int tau, dacs[i+imod*thisDetector->nDacs]=module.dacs[i]; } - (detectorModules+imod)->gain=module.gain; - (detectorModules+imod)->offset=module.offset; - (detectorModules+imod)->serialnumber=module.serialnumber; - (detectorModules+imod)->reg=module.reg; - } + (detectorModules)->gain=module.gain; + (detectorModules)->offset=module.offset; + (detectorModules)->serialnumber=module.serialnumber; + (detectorModules)->reg=module.reg; } if ((thisDetector->nGain) && (gainval) && (gain)) { @@ -7328,36 +5947,19 @@ slsDetectorDefs::sls_detector_module *slsDetector::getModule(int imod) { if(thisDetector->nOffset) offsetval=new int[thisDetector->nOffset]; - //char *ptr, *goff=(char*)thisDetector; - - // int chanreg[thisDetector->nChans*thisDetector->nChips]; - //int chipreg[thisDetector->nChips]; - //double dac[thisDetector->nDacs], adc[thisDetector->nAdcs]; int ret=FAIL; char mess[MAX_STR_LENGTH]=""; // int n; #ifdef VERBOSE - std::cout<< "getting module " << imod << std::endl; + std::cout<< "getting module " << std::endl; #endif - myMod->module=imod; - // myMod.nchan=thisDetector->nChans*thisDetector->nChips; - //myMod.chanregs=chanreg; - //myMod.nchip=thisDetector->nChips; - //myMod.chipregs=chipreg; - //myMod.ndac=thisDetector->nDacs; - //myMod.dacs=dac; - //myMod.ndac=thisDetector->nAdcs; - //myMod.dacs=adc; - if (thisDetector->onlineFlag==ONLINE_FLAG) { if (connectControl() == OK){ controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->SendDataOnly(&imod,sizeof(imod)); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); if (ret!=FAIL) { receiveModule(myMod); @@ -7380,11 +5982,10 @@ slsDetectorDefs::sls_detector_module *slsDetector::getModule(int imod) { if (ret!=FAIL) { if (detectorModules) { - if (imod>=0 && imodnMod[X]*thisDetector->nMod[Y]) { - (detectorModules+imod)->nchan=myMod->nchan; - (detectorModules+imod)->nchip=myMod->nchip; - (detectorModules+imod)->ndac=myMod->ndac; - (detectorModules+imod)->nadc=myMod->nadc; + (detectorModules)->nchan=myMod->nchan; + (detectorModules)->nchip=myMod->nchip; + (detectorModules)->ndac=myMod->ndac; + (detectorModules)->nadc=myMod->nadc; thisDetector->nChips=myMod->nchip; thisDetector->nChans=myMod->nchan/myMod->nchip; thisDetector->nDacs=myMod->ndac; @@ -7417,21 +6018,21 @@ slsDetectorDefs::sls_detector_module *slsDetector::getModule(int imod) { //cprintf(BLUE,"dac%d:%d\n",i, myMod->dacs[i]); } } - (detectorModules+imod)->gain=myMod->gain; - (detectorModules+imod)->offset=myMod->offset; - (detectorModules+imod)->serialnumber=myMod->serialnumber; - (detectorModules+imod)->reg=myMod->reg; - } + (detectorModules)->gain=myMod->gain; + (detectorModules)->offset=myMod->offset; + (detectorModules)->serialnumber=myMod->serialnumber; + (detectorModules)->reg=myMod->reg; + } if ((thisDetector->nGain) && (gainval) && (gain)) { for (int i=0; inGain; ++i) - gain[i+imod*thisDetector->nGain]=gainval[i]; + gain[i+thisDetector->nGain]=gainval[i]; } if ((thisDetector->nOffset) && (offsetval) && (offset)) { for (int i=0; inOffset; ++i) - offset[i+imod*thisDetector->nOffset]=offsetval[i]; + offset[i+thisDetector->nOffset]=offsetval[i]; } } else { @@ -7448,336 +6049,6 @@ slsDetectorDefs::sls_detector_module *slsDetector::getModule(int imod) { -int slsDetector::setChannel(int64_t reg, int ichan, int ichip, int imod) { - sls_detector_channel myChan; -#ifdef VERBOSE - std::cout<< "Setting channel "<< ichan << " " << ichip << " " << imod << - " to " << reg << std::endl; -#endif - //int mmin=imod, mmax=imod+1, chimin=ichip, chimax=ichip+1, chamin=ichan, - //chamax=ichan+1; - - int ret; - - /* if (imod==-1) { - mmin=0; - mmax=thisDetector->nModsMax; - } - - if (ichip==-1) { - chimin=0; - chimax=thisDetector->nChips; - } - - if (ichan==-1) { - chamin=0; - chamax=thisDetector->nChans; - }*/ - - // for (int im=mmin; imonlineFlag==ONLINE_FLAG) { - if (connectControl() == OK){ - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - sendChannel(&chan); - - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret!=FAIL) { - controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); - } else { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; - } - disconnectControl(); - if (ret==FORCE_UPDATE) - updateDetector(); - } - } - - - if (ret!=FAIL) { - if (chanregs) { - - int mmin=imod, mmax=imod+1, chimin=ichip, chimax=ichip+1, chamin=ichan, - chamax=ichan+1; - - if (imod==-1) { - mmin=0; - mmax=thisDetector->nModsMax; - } - - if (ichip==-1) { - chimin=0; - chimax=thisDetector->nChips; - } - - if (ichan==-1) { - chamin=0; - chamax=thisDetector->nChans; - } - - - - - - - for (int im=mmin; imnChans* - thisDetector->nChips+ichi*thisDetector->nChips+icha)=retval; - - } - } - } - - } - } -#ifdef VERBOSE - std::cout<< "Channel register returned "<< retval << std::endl; -#endif - return retval; - -} - - - - - -slsDetectorDefs::sls_detector_channel slsDetector::getChannel(int ichan, int ichip, - int imod) { - - - int fnum=F_GET_CHANNEL; - sls_detector_channel myChan; - int arg[3]; - int ret=FAIL; - char mess[MAX_STR_LENGTH]=""; - arg[0]=ichan; - arg[1]=ichip; - arg[2]=imod; - if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK){ - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->SendDataOnly(arg,sizeof(arg)); - - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret!=FAIL) { - receiveChannel(&myChan); - } else { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; - } - disconnectControl(); - if (ret==FORCE_UPDATE) - updateDetector(); - } - } - - - if (ret!=FAIL) { - if (chanregs) { - *(chanregs+imod*thisDetector->nChans*thisDetector->nChips+ichip* - thisDetector->nChips+ichan)=myChan.reg; - } - } - -#ifdef VERBOSE - std::cout<< "Returned channel "<< ichan << " " << ichip << " " << imod << " " - << myChan.reg << std::endl; -#endif - return myChan; -} - - - -int slsDetector::setChip(int reg, int ichip, int imod) { - sls_detector_chip myChip; - -#ifdef VERBOSE - std::cout<< "Setting chip "<< ichip << " " << imod << " to " << reg << std::endl; -#endif - - - int chregs[thisDetector->nChans]; - int mmin=imod, mmax=imod+1, chimin=ichip, chimax=ichip+1; - int ret=FAIL; - if (imod==-1) { - mmin=0; - mmax=thisDetector->nModsMax; - } - - if (ichip==-1) { - chimin=0; - chimax=thisDetector->nChips; - } - - myChip.nchan=thisDetector->nChans; - myChip.reg=reg; - for (int im=mmin; imnChans+im* - thisDetector->nChans*thisDetector->nChips); - else { - for (int i=0; inChans; ++i) - chregs[i]=-1; - myChip.chanregs=chregs; - } - ret=setChip(myChip); - } - } - return ret; -} - -int slsDetector::setChip(sls_detector_chip chip) { - - int fnum=F_SET_CHIP; - int retval; - int ret=FAIL; - char mess[MAX_STR_LENGTH]=""; - - int ichi=chip.chip; - int im=chip.module; - - - - - - if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK){ - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - sendChip(&chip); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret!=FAIL) { - controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); - } else { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; - } - disconnectControl(); - if (ret==FORCE_UPDATE) - updateDetector(); - } - } - - - if (ret!=FAIL) { - if (chipregs) - *(chipregs+ichi+im*thisDetector->nChips)=retval; - } - -#ifdef VERBOSE - std::cout<< "Chip register returned "<< retval << std::endl; -#endif - return retval; -} - - -slsDetectorDefs::sls_detector_chip slsDetector::getChip(int ichip, int imod) { - - int fnum=F_GET_CHIP; - sls_detector_chip myChip; - int chanreg[thisDetector->nChans]; - - int ret=FAIL; - char mess[MAX_STR_LENGTH]=""; - - - myChip.chip=ichip; - myChip.module=imod; - myChip.nchan=thisDetector->nChans; - myChip.chanregs=chanreg; - - int arg[2]; - arg[0]=ichip; - arg[1]=imod; - - - - - if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK){ - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->SendDataOnly(arg,sizeof(arg)); - - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret!=FAIL) { - receiveChip(&myChip); - } else { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; - } - disconnectControl(); - if (ret==FORCE_UPDATE) - updateDetector(); - } - } - - - if (ret!=FAIL) { - if (chipregs) - *(chipregs+ichip+imod*thisDetector->nChips)=myChip.reg; - if (chanregs) { - for (int ichan=0; ichannChans; ++ichan) - *(chanregs+imod*thisDetector->nChans*thisDetector->nChips+ichip* - thisDetector->nChans+ichan)=*((myChip.chanregs)+ichan); - } - } -#ifdef VERBOSE - std::cout<< "Returned chip "<< ichip << " " << imod << " " << myChip.reg << std::endl; -#endif - - return myChip; -} - - - -int slsDetector::getMoveFlag(int imod) { - if (moveFlag) - return *moveFlag; - else return 1; -} - - -int slsDetector::fillModuleMask(int *mM) { - if (mM) - for (int i=0; icorrectionMask&=~(1<correctionMask|=(1<0) - thisDetector->tDead=t; - else { - if (thisDetector->currentSettings<3 && thisDetector->currentSettings>-1) - thisDetector->tDead=tdead[thisDetector->currentSettings]; - else - thisDetector->tDead=0; - } -#ifdef VERBOSE - std::cout<< "Setting rate correction with dead time "<< thisDetector->tDead - << std::endl; -#endif - } - return thisDetector->correctionMask&(1<correctionMask&(1<tDead << std::endl; -#endif - t=thisDetector->tDead; - return 1; - } else - t=0; -#ifdef VERBOSE - std::cout<< "Rate correction is disabled " << std::endl; -#endif - return 0; + printf("unknown detector\n"); + return -1; }; double slsDetector::getRateCorrectionTau() { @@ -7924,20 +6159,8 @@ double slsDetector::getRateCorrectionTau() { return double(retval); } - - //mythen only - if (thisDetector->correctionMask&(1<tDead << std::endl; -#endif - return thisDetector->tDead; - //return 1; - } else -#ifdef VERBOSE - std::cout<< "Rate correction is disabled " << std::endl; -#endif - return 0; + printf("unknown detector\n"); + return -1; } @@ -7948,330 +6171,10 @@ int slsDetector::getRateCorrection() { return (int)t; } - if (thisDetector->correctionMask&(1<tDead; - double t=thisDetector->timerValue[ACQUISITION_TIME]; - // double data; - double e; - if (thisDetector->correctionMask&(1<nMod[X]*thisDetector->nMod[Y]* - thisDetector->nChans*thisDetector->nChips; ++ichan) { - - if (errin==NULL) { - e=sqrt(datain[ichan]); - } else - e=errin[ichan]; - - postProcessingFuncs::rateCorrect(datain[ichan], e, dataout[ichan], - errout[ichan], tau, t); - } - } - - return 0; -} - - - -int slsDetector::setFlatFieldCorrection(string fname) { - double data[thisDetector->nModMax[X]*thisDetector->nModMax[Y]* - thisDetector->nChans*thisDetector->nChips]; - int im=0; - int nch; - thisDetector->nBadFF=0; - - char ffffname[MAX_STR_LENGTH*2]; - if (fname=="default") { - fname=string(thisDetector->flatFieldFile); - } - - if (fname=="") { -#ifdef VERBOSE - std::cout<< "disabling flat field correction" << std::endl; -#endif - thisDetector->correctionMask&=~(1<flatFieldDir,fname.c_str()); - nch=readDataFile(string(ffffname),data); - if (nch>0) { - - //???? bad ff chans? - int nm=getNMods(); - int chpm[nm]; - int mMask[nm]; - for (int i=0; i=0) { - strcpy(thisDetector->flatFieldFile,fname.c_str()); - - - thisDetector->correctionMask|=(1<correctionMask&(1<nMod[Y]*thisDetector->nMod[X]* - thisDetector->nChans*thisDetector->nChips; ++ichan) { - // #ifdef VERBOSE - // std::cout<< ichan << " "<< corr[ichan] << std::endl; - // #endif - ffcoefficients[ichan]=corr[ichan]; - if (ecorr!=NULL) - fferrors[ichan]=ecorr[ichan]; - else - fferrors[ichan]=1; - - cout << ichan << " " << ffcoefficients[ichan] << endl; - } - thisDetector->correctionMask|=(1<correctionMask&=~(1<correctionMask)& - (1<correctionMask&(1<correctionMask&(1<nMod[X]*thisDetector->nMod[Y]* - thisDetector->nChans*thisDetector->nChips; ++ichan) { - corr[ichan]=ffcoefficients[ichan]; - if (ecorr) { - //ecorr[ichan]=ffcoefficients[ichan]/fferrors[ichan]; - ecorr[ichan]=fferrors[ichan]; - } - } - } - return 1; - } else { -#ifdef VERBOSE - std::cout<< "Flat field correction is disabled" << std::endl; -#endif - if (corr) - for (int ichan=0; ichannMod[X]*thisDetector->nMod[Y]* - thisDetector->nChans*thisDetector->nChips; ++ichan) { - corr[ichan]=1; - if (ecorr) - ecorr[ichan]=0; - } - return 0; - } - -} - - - -int slsDetector::flatFieldCorrect(double* datain, double *errin, double* dataout, - double *errout) { -#ifdef VERBOSE - std::cout<< "Flat field correcting data" << std::endl; -#endif - double e, eo; - if (thisDetector->correctionMask & (1<nMod[X]*thisDetector->nChans* - thisDetector->nChips; ++ichan) { - if (errin==NULL) { - e=0; - } else { - e=errin[ichan]; - } - postProcessingFuncs::flatFieldCorrect(datain[ichan],e,dataout[ichan], - eo,ffcoefficients[ichan],fferrors[ichan]); - if (errout) - errout[ichan]=eo; - } - } - return 0; - -} - - - - -int slsDetector::setBadChannelCorrection(string fname) { - - // int nbadmod; - int ret=0; - //int badchanlist[MAX_BADCHANS]; - //int off; - - string fn=fname; - - if (fname=="default") - fname=string(badChanFile); - - if (nBadChans && badChansList) - ret=setBadChannelCorrection(fname, *nBadChans, badChansList); - - if (ret) { - *correctionMask|=(1<0) { - thisDetector->correctionMask|=(1<nBadChans=0; - for (int ich=0 ;ich=0 && chs[ich]badChansList[ich]=chs[ich]; - ++thisDetector->nBadChans; - } - } - } else - thisDetector->correctionMask&=~(1<0) { - thisDetector->nBadFF=nch; - for (int ich=0 ;ichbadFFList[ich]=chs[ich]; - } - } - } -#ifdef VERBOSE - cout << "badchans flag is "<< (thisDetector->correctionMask& - (1<< DISCARD_BAD_CHANNELS)) << endl; -#endif - // fillBadChannelMask(); - if (thisDetector->correctionMask&(1<< DISCARD_BAD_CHANNELS)) { - return thisDetector->nBadChans+thisDetector->nBadFF; - } else - return 0; - -} - - -int slsDetector::getBadChannelCorrection(int *bad) { - int ichan; - if (thisDetector->correctionMask&(1<< DISCARD_BAD_CHANNELS)) { - if (bad) { - for (ichan=0; ichannBadChans; ++ichan) - bad[ichan]=thisDetector->badChansList[ichan]; - for (int ich=0; ichnBadFF; ++ich) - bad[ichan+ich]=thisDetector->badFFList[ich]; - } - return thisDetector->nBadChans+thisDetector->nBadFF; - } else - return 0; -} - - -int slsDetector::readAngularConversionFile(string fname) { - - return readAngularConversion(fname,thisDetector->nModsMax, thisDetector->angOff); - -} - -int slsDetector::readAngularConversion(ifstream& ifs) { - - return readAngularConversion(ifs,thisDetector->nModsMax, thisDetector->angOff); - -} - - -int slsDetector:: writeAngularConversion(string fname) { - - return writeAngularConversion(fname, thisDetector->nMods, thisDetector->angOff); - -} - - -int slsDetector:: writeAngularConversion(ofstream &ofs) { - - return writeAngularConversion(ofs, thisDetector->nMods, thisDetector->angOff); - -} - -int slsDetector::getAngularConversion(int &direction, angleConversionConstant *angconv) { - direction=thisDetector->angDirection; - if (angconv) { - for (int imod=0; imodnMods; ++imod) { - (angconv+imod)->center=thisDetector->angOff[imod].center; - (angconv+imod)->r_conversion=thisDetector->angOff[imod].r_conversion; - (angconv+imod)->offset=thisDetector->angOff[imod].offset; - (angconv+imod)->ecenter=thisDetector->angOff[imod].ecenter; - (angconv+imod)->er_conversion=thisDetector->angOff[imod].er_conversion; - (angconv+imod)->eoffset=thisDetector->angOff[imod].eoffset; - } - } - if (thisDetector->correctionMask&(1<< ANGULAR_CONVERSION)) { - return 1; - } else { - return 0; - } -} - - - -angleConversionConstant* slsDetector::getAngularConversionPointer(int imod) { - return &thisDetector->angOff[imod]; -} int slsDetector::printReceiverConfiguration() { @@ -8517,34 +6420,26 @@ int slsDetector::updateReceiverNoWait() { char path[MAX_STR_LENGTH]; char lastClientIP[INET_ADDRSTRLEN]; - n += dataSocket->ReceiveDataOnly(lastClientIP,sizeof(lastClientIP)); + n += dataSocket->ReceiveDataOnly(lastClientIP,sizeof(lastClientIP)); #ifdef VERBOSE cout << "Updating receiver last modified by " << lastClientIP << std::endl; #endif // filepath - n += dataSocket->ReceiveDataOnly(path,MAX_STR_LENGTH); - pthread_mutex_lock(&ms); - fileIO::setFilePath(path); - pthread_mutex_unlock(&ms); + n += dataSocket->ReceiveDataOnly(path,MAX_STR_LENGTH); + strcpy(thisDetector->receiver_filePath, path); // filename - n += dataSocket->ReceiveDataOnly(path,MAX_STR_LENGTH); - pthread_mutex_lock(&ms); - fileIO::setFileName(path); - pthread_mutex_unlock(&ms); + n += dataSocket->ReceiveDataOnly(path,MAX_STR_LENGTH); + strcpy(thisDetector->receiver_fileName, path); // index - n += dataSocket->ReceiveDataOnly(&ind,sizeof(ind)); - pthread_mutex_lock(&ms); - fileIO::setFileIndex(ind); - pthread_mutex_unlock(&ms); + n += dataSocket->ReceiveDataOnly(&ind,sizeof(ind)); + thisDetector->receiver_fileIndex = ind; //file format - n += dataSocket->ReceiveDataOnly(&ind,sizeof(ind)); - pthread_mutex_lock(&ms); - fileIO::setFileFormat(ind); - pthread_mutex_unlock(&ms); + n += dataSocket->ReceiveDataOnly(&ind,sizeof(ind)); + thisDetector->receiver_fileFormatType = (fileFormat)ind; // frames per file n += dataSocket->ReceiveDataOnly(&ind,sizeof(ind)); @@ -8559,35 +6454,31 @@ int slsDetector::updateReceiverNoWait() { thisDetector->receiver_framePadding = ind; // file write enable - n += dataSocket->ReceiveDataOnly(&ind,sizeof(ind)); - pthread_mutex_lock(&ms); - multiDet->enableWriteToFileMask(ind); - pthread_mutex_unlock(&ms); + n += dataSocket->ReceiveDataOnly(&ind,sizeof(ind)); + thisDetector->receiver_fileWriteEnable = ind; // file overwrite enable - n += dataSocket->ReceiveDataOnly(&ind,sizeof(ind)); - pthread_mutex_lock(&ms); - multiDet->enableOverwriteMask(ind); - pthread_mutex_unlock(&ms); + n += dataSocket->ReceiveDataOnly(&ind,sizeof(ind)); + thisDetector->receiver_overWriteEnable = ind; // gap pixels n += dataSocket->ReceiveDataOnly(&ind,sizeof(ind)); thisDetector->gappixels = ind; // receiver read frequency - n += dataSocket->ReceiveDataOnly(&ind,sizeof(ind)); + n += dataSocket->ReceiveDataOnly(&ind,sizeof(ind)); thisDetector->receiver_read_freq = ind; // receiver streaming port - n += dataSocket->ReceiveDataOnly(&ind,sizeof(ind)); + n += dataSocket->ReceiveDataOnly(&ind,sizeof(ind)); thisDetector->receiver_zmqport = ind; // streaming source ip - n += dataSocket->ReceiveDataOnly(path,MAX_STR_LENGTH); + n += dataSocket->ReceiveDataOnly(path,MAX_STR_LENGTH); strcpy(thisDetector->receiver_zmqip, path); // additional json header - n += dataSocket->ReceiveDataOnly(path,MAX_STR_LENGTH); + n += dataSocket->ReceiveDataOnly(path,MAX_STR_LENGTH); strcpy(thisDetector->receiver_additionalJsonHeader, path); // receiver streaming enable @@ -8714,83 +6605,64 @@ void slsDetector::setDetectorHostname() { string slsDetector::getFilePath() { - return setFilePath(); + return thisDetector->receiver_filePath; } - - string slsDetector::setFilePath(string s) { + + if (s.empty()) + return getFilePath(); + + int fnum = F_SET_RECEIVER_FILE_PATH; int ret = FAIL; char arg[MAX_STR_LENGTH]=""; char retval[MAX_STR_LENGTH] = ""; - struct stat st; - if(thisDetector->receiverOnlineFlag==OFFLINE_FLAG){ - if(!s.empty()){ - if(stat(s.c_str(),&st)){ - std::cout << "path does not exist" << endl; - setErrorMask((getErrorMask())|(FILE_PATH_DOES_NOT_EXIST)); - }else{ - pthread_mutex_lock(&ms); - fileIO::setFilePath(s); - pthread_mutex_unlock(&ms); - } - } - } - - else{ - strcpy(arg,s.c_str()); + strcpy(arg,s.c_str()); #ifdef VERBOSE - std::cout << "Sending file path to receiver " << arg << std::endl; + std::cout << "Sending file path to receiver " << arg << std::endl; #endif - if (connectData() == OK){ - ret=thisReceiver->sendString(fnum,retval,arg); - disconnectData(); - } - if(ret!=FAIL){ - pthread_mutex_lock(&ms); - fileIO::setFilePath(string(retval)); - pthread_mutex_unlock(&ms); - } - else if(!s.empty()){ + if (connectData() == OK){ + ret=thisReceiver->sendString(fnum,retval,arg); + disconnectData(); + } + if(ret!=FAIL){ + strcpy(thisDetector->receiver_filePath,retval); + } + else { + if(!s.empty()){ std::cout << "file path does not exist" << endl; setErrorMask((getErrorMask())|(FILE_PATH_DOES_NOT_EXIST)); - } - if(ret==FORCE_UPDATE) - updateReceiver(); + } else + setErrorMask((getErrorMask())|(RECEIVER_PARAMETER_NOT_SET)); } + if(ret==FORCE_UPDATE) + updateReceiver(); - pthread_mutex_lock(&ms); - s = fileIO::getFilePath(); - pthread_mutex_unlock(&ms); - - return s; + return getFilePath(); } string slsDetector::getFileName() { - return setFileName(); + return thisDetector->receiver_fileName; } string slsDetector::setFileName(string s) { + + if (s.empty()) + return getFileName(); + + int fnum=F_SET_RECEIVER_FILE_NAME; int ret = FAIL; char arg[MAX_STR_LENGTH]=""; char retval[MAX_STR_LENGTH]=""; - string sretval=""; - - /*if(!s.empty()){ - pthread_mutex_lock(&ms); - fileIO::setFileName(s); - s=multiDet->createReceiverFilePrefix(); - pthread_mutex_unlock(&ms); - }*/ + strcpy(arg,s.c_str()); if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){ - strcpy(arg,s.c_str()); #ifdef VERBOSE std::cout << "Sending file name to receiver " << arg << std::endl; #endif @@ -8798,40 +6670,23 @@ string slsDetector::setFileName(string s) { ret=thisReceiver->sendString(fnum,retval,arg); disconnectData(); } - if(ret!=FAIL){ -#ifdef VERBOSE - std::cout << "Complete file prefix from receiver: " << retval << std::endl; -#endif - /* - pthread_mutex_lock(&ms); - fileIO::setFileName(multiDet->getNameFromReceiverFilePrefix(string(retval))); - pthread_mutex_unlock(&ms); - */ - sretval = fileIO::getNameFromReceiverFilePrefix(string(retval)); - } - + if (ret == FAIL) + setErrorMask((getErrorMask())|(RECEIVER_PARAMETER_NOT_SET)); + else + strcpy(thisDetector->receiver_fileName,retval); if(ret==FORCE_UPDATE) updateReceiver(); - return sretval; - - } else { - if(!s.empty()){ - pthread_mutex_lock(&ms); - fileIO::setFileName(s); - pthread_mutex_unlock(&ms); - } - pthread_mutex_lock(&ms); - s = fileIO::getFileName(); - pthread_mutex_unlock(&ms); - - return s; - } + return getFileName(); } int slsDetector::setReceiverFramesPerFile(int f) { + + if(f < 0) + return thisDetector->receiver_framesPerFile; + int fnum = F_SET_RECEIVER_FRAMES_PER_FILE; int ret = FAIL; int retval = -1; @@ -8846,11 +6701,10 @@ int slsDetector::setReceiverFramesPerFile(int f) { ret=thisReceiver->sendInt(fnum,retval,arg); disconnectData(); } - if(ret==FAIL) + if (ret == FAIL) setErrorMask((getErrorMask())|(RECEIVER_PARAMETER_NOT_SET)); - else if(ret!=FAIL && retval > -1){ + else thisDetector->receiver_framesPerFile = retval; - } if(ret==FORCE_UPDATE) updateReceiver(); } @@ -8914,22 +6768,15 @@ int slsDetector::setReceiverPartialFramesPadding(int f) { } slsReceiverDefs::fileFormat slsDetector::setFileFormat(fileFormat f) { + + if (f == GET_FILE_FORMAT) + return getFileFormat(); + int fnum=F_SET_RECEIVER_FILE_FORMAT; int ret = FAIL; int arg = -1; int retval = -1; - - - if(thisDetector->receiverOnlineFlag==OFFLINE_FLAG){ - if(f>=0){ - pthread_mutex_lock(&ms); - fileIO::setFileFormat(f); - pthread_mutex_unlock(&ms); - } - } - - else{ arg = (int)f; #ifdef VERBOSE std::cout << "Sending file format to receiver " << arg << std::endl; @@ -8938,46 +6785,37 @@ slsReceiverDefs::fileFormat slsDetector::setFileFormat(fileFormat f) { ret=thisReceiver->sendInt(fnum,retval,arg); disconnectData(); } - if(ret == FAIL) + if (ret == FAIL) setErrorMask((getErrorMask())|(RECEIVER_FILE_FORMAT)); - else{ - pthread_mutex_lock(&ms); - fileIO::setFileFormat(retval); - pthread_mutex_unlock(&ms); - if(ret==FORCE_UPDATE) - updateReceiver(); - } - } + else + thisDetector->receiver_fileFormatType = (fileFormat)retval; + if(ret==FORCE_UPDATE) + updateReceiver(); - return fileIO::getFileFormat(); + return getFileFormat(); } slsReceiverDefs::fileFormat slsDetector::getFileFormat() { - return setFileFormat(); + return thisDetector->receiver_fileFormatType; } int slsDetector::getFileIndex() { - return setFileIndex(); + return thisDetector->receiver_fileIndex; } int slsDetector::setFileIndex(int i) { + + if (i < 0) + return getFileIndex(); + int fnum=F_SET_RECEIVER_FILE_INDEX; int ret = FAIL; int retval=-1; int arg = i; - if(thisDetector->receiverOnlineFlag==OFFLINE_FLAG){ - if(i>=0){ - pthread_mutex_lock(&ms); - fileIO::setFileIndex(i); - pthread_mutex_unlock(&ms); - } - } - - else{ #ifdef VERBOSE std::cout << "Sending file index to receiver " << arg << std::endl; #endif @@ -8985,19 +6823,24 @@ int slsDetector::setFileIndex(int i) { ret=thisReceiver->sendInt(fnum,retval,arg); disconnectData(); } - if(ret!=FAIL){ - pthread_mutex_lock(&ms); - fileIO::setFileIndex(retval); - pthread_mutex_unlock(&ms); - } + if (ret == FAIL) + setErrorMask((getErrorMask())|(RECEIVER_PARAMETER_NOT_SET)); + else + thisDetector->receiver_fileIndex = retval; if(ret==FORCE_UPDATE) updateReceiver(); - } - return fileIO::getFileIndex(); + + return getFileIndex(); } +int slsDetector::incrementFileIndex() { + if (thisDetector->receiver_fileWriteEnable) + return setFileIndex(thisDetector->receiver_fileIndex+1); + return thisDetector->receiver_fileIndex; +} + @@ -9058,32 +6901,6 @@ int slsDetector::stopReceiver() { -slsDetectorDefs::runStatus slsDetector::startReceiverReadout() { - int fnum=F_START_RECEIVER_READOUT; - int ret = FAIL; - int retval=-1; - runStatus s=ERROR; - - if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { -#ifdef VERBOSE - std::cout << "Starting Receiver Readout" << std::endl; -#endif - if (connectData() == OK){ - ret=thisReceiver->getInt(fnum,retval); - disconnectData(); - } - if(retval!=-1) - s=(runStatus)retval; - if(ret==FORCE_UPDATE) - ret=updateReceiver(); - } - - return s; -} - - - - slsDetectorDefs::runStatus slsDetector::getReceiverStatus() { int fnum=F_GET_RECEIVER_STATUS; @@ -9192,21 +7009,17 @@ int slsDetector::resetFramesCaught() { int slsDetector::enableWriteToFile(int enable) { + + if (enable < 0) + return thisDetector->receiver_fileWriteEnable; + int fnum=F_ENABLE_RECEIVER_FILE_WRITE; int ret = FAIL; int retval=-1; int arg = enable; - if(thisDetector->receiverOnlineFlag==OFFLINE_FLAG){ - if(enable>=0){ - pthread_mutex_lock(&ms); - multiDet->enableWriteToFileMask(enable); - pthread_mutex_unlock(&ms); - } - } - - else if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){ + if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){ #ifdef VERBOSE std::cout << "Sending enable file write to receiver " << arg << std::endl; #endif @@ -9214,41 +7027,33 @@ int slsDetector::enableWriteToFile(int enable) { ret=thisReceiver->sendInt(fnum,retval,arg); disconnectData(); } - if(ret!=FAIL){ - pthread_mutex_lock(&ms); - multiDet->enableWriteToFileMask(retval); - pthread_mutex_unlock(&ms); - } + if (ret == FAIL) + setErrorMask((getErrorMask())|(RECEIVER_PARAMETER_NOT_SET)); + else + thisDetector->receiver_fileWriteEnable = retval; if(ret==FORCE_UPDATE) updateReceiver(); } - pthread_mutex_lock(&ms); - retval = multiDet->enableWriteToFileMask(); - pthread_mutex_unlock(&ms); - return retval; + return thisDetector->receiver_fileWriteEnable; } int slsDetector::overwriteFile(int enable) { + + if (enable < 0) + return thisDetector->receiver_overWriteEnable; + int fnum=F_ENABLE_RECEIVER_OVERWRITE; int ret = FAIL; int retval=-1; int arg = enable; - if(thisDetector->receiverOnlineFlag==OFFLINE_FLAG){ - if(enable>=0){ - pthread_mutex_lock(&ms); - multiDet->enableOverwriteMask(enable); - pthread_mutex_unlock(&ms); - } - } - - else if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){ + if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){ #ifdef VERBOSE std::cout << "Sending enable file write to receiver " << arg << std::endl; #endif @@ -9256,20 +7061,15 @@ int slsDetector::overwriteFile(int enable) { ret=thisReceiver->sendInt(fnum,retval,arg); disconnectData(); } - if(ret!=FAIL){ - pthread_mutex_lock(&ms); - multiDet->enableOverwriteMask(retval); - pthread_mutex_unlock(&ms); - } + if (ret == FAIL) + setErrorMask((getErrorMask())|(RECEIVER_PARAMETER_NOT_SET)); + else + thisDetector->receiver_overWriteEnable = retval; if(ret==FORCE_UPDATE) updateReceiver(); } - pthread_mutex_lock(&ms); - retval = multiDet->enableOverwriteMask(); - pthread_mutex_unlock(&ms); - - return retval; + return thisDetector->receiver_overWriteEnable; } @@ -9278,12 +7078,6 @@ int slsDetector::overwriteFile(int enable) { - - - - - - int slsDetector::setReadReceiverFrequency(int freq) { if (freq >= 0) { @@ -9390,31 +7184,6 @@ int slsDetector::enableDataStreamingFromReceiver(int enable) { -int slsDetector::enableReceiverCompression(int i) { - int fnum=F_ENABLE_RECEIVER_COMPRESSION; - int ret = FAIL; - int retval=-1; - - - if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){ -#ifdef VERBOSE - std::cout << "Getting/Enabling/Disabling Receiver Compression with argument " - << i << std::endl; -#endif - if (connectData() == OK){ - ret=thisReceiver->sendInt(fnum,retval,i); - disconnectData(); - } - if(ret==FAIL) - setErrorMask((getErrorMask())|(COULDNOT_ENABLE_COMPRESSION)); - } - return retval; -} - - - - - int slsDetector::enableTenGigabitEthernet(int i) { int ret=FAIL; @@ -9756,3 +7525,411 @@ int slsDetector::setCTBPatWaitTime(int level, uint64_t t) { +int slsDetector::readCalibrationFile(std::string fname, double &gain, double &offset) { + + std::string str; + std::ifstream infile; +#ifdef VERBOSE + std::cout<< "Opening file "<< fname << std::endl; +#endif + infile.open(fname.c_str(), std::ios_base::in); + if (infile.is_open()) { + getline(infile,str); +#ifdef VERBOSE + std::cout<< str << std::endl; +#endif + std::istringstream ssstr(str); + ssstr >> offset >> gain; + infile.close(); + std::cout << "Calibration file loaded: " << fname << std::endl; + } else { + std::cout<< "Could not open calibration file "<< fname << std::endl; + gain=0.; + offset=0.; + return FAIL; + } + return OK; +} + + + +int slsDetector::writeCalibrationFile(std::string fname, double gain, double offset) { + + std::ofstream outfile; + outfile.open (fname.c_str()); + + if (outfile.is_open()) { + outfile << offset << " " << gain << std::endl; + } else { + std::cout<< "Could not open calibration file "<< fname << " for writing" << std::endl; + + return FAIL; + } + + outfile.close(); + return OK; +} + + +int slsDetector::readCalibrationFile(std::string fname, int *gain, int *offset) { + + std::string str; + std::ifstream infile; + double o,g; + int ig=0; +#ifdef VERBOSE + std::cout<< "Opening file "<< fname << std::endl; +#endif + infile.open(fname.c_str(), std::ios_base::in); + if (infile.is_open()) { + //get gain and offset + for (ig=0; ig<4; ig++) { + //while ( (getline(infile,str)) > -1) { + getline(infile,str); +#ifdef VERBOSE + std::cout<< str << std::endl; +#endif + std::istringstream ssstr(str); + ssstr >> o >> g; + offset[ig]=(int)(o*1000); + gain[ig]=(int)(g*1000); + // ig++; + if (ig>=4) + break; + } + infile.close(); + std::cout << "Calibration file loaded: " << fname << std::endl; + } else { + std::cout << "Could not open calibration file: "<< fname << std::endl; + gain[0]=0; + offset[0]=0; + return FAIL; + } + + return OK; +} + + +int slsDetector::writeCalibrationFile(std::string fname, int *gain, int *offset){ + + std::ofstream outfile; + outfile.open (fname.c_str()); + + if (outfile.is_open()) { + for (int ig=0; ig<4; ig++) + outfile << ((double)offset[ig]/1000) << " " << ((double)gain[ig]/1000) << std::endl; + } else { + std::cout<< "Could not open calibration file "<< fname << " for writing" << std::endl; + return FAIL; + } + + outfile.close(); + return OK; +} + + + +slsDetectorDefs::sls_detector_module* slsDetector::interpolateTrim( + sls_detector_module* a, sls_detector_module* b, + const int energy, const int e1, const int e2, int tb) { + + // only implemented for eiger currently (in terms of which dacs) + if(thisDetector->myDetectorType != EIGER) { + printf("Interpolation of Trim values not implemented for this detector!\n"); + return NULL; + } + + sls_detector_module* myMod = createModule(thisDetector->myDetectorType); + enum eiger_DacIndex{SVP,VTR,VRF,VRS,SVN,VTGSTV,VCMP_LL,VCMP_LR,CAL, + VCMP_RL,RXB_RB,RXB_LB,VCMP_RR,VCP,VCN,VIS}; + + //Copy other dacs + int dacs_to_copy[] = {SVP,VTR,SVN,VTGSTV,RXB_RB,RXB_LB,VCN,VIS}; + int num_dacs_to_copy = sizeof(dacs_to_copy) / sizeof(dacs_to_copy[0]); + for (int i = 0; i < num_dacs_to_copy; ++i) { + if(a->dacs[dacs_to_copy[i]] != b->dacs[dacs_to_copy[i]]) { + deleteModule(myMod); + return NULL; + } + myMod->dacs[dacs_to_copy[i]] = a->dacs[dacs_to_copy[i]]; + } + + + //Copy irrelevant dacs (without failing): CAL + if (a->dacs[CAL] != b->dacs[CAL]) { + printf("Warning: DAC CAL differs in both energies (%d, %d)! ", + a->dacs[CAL], b->dacs[CAL]); + printf("Taking first: %d\n", a->dacs[CAL]); + } + myMod->dacs[CAL] = a->dacs[CAL]; + + + //Interpolate vrf, vcmp, vcp + int dacs_to_interpolate[] = {VRF,VCMP_LL,VCMP_LR,VCMP_RL,VCMP_RR,VCP, VRS}; + int num_dacs_to_interpolate = sizeof(dacs_to_interpolate) / sizeof(dacs_to_interpolate[0]); + for (int i = 0; i < num_dacs_to_interpolate; ++i) { + myMod->dacs[dacs_to_interpolate[i]] = linearInterpolation(energy, e1, e2, + a->dacs[dacs_to_interpolate[i]], b->dacs[dacs_to_interpolate[i]]); + } + + //Interpolate all trimbits + if(tb) { + for (int i = 0; inchan; i++) + myMod->chanregs[i] = linearInterpolation(energy, e1, e2, a->chanregs[i], b->chanregs[i]); + } + return myMod; +} + + + + +slsDetectorDefs::sls_detector_module* slsDetector::readSettingsFile(std::string fname, + int& iodelay, int& tau, sls_detector_module* myMod, int tb){ + + + int nflag=0; + if (myMod==NULL) { + myMod=createModule(thisDetector->myDetectorType); + nflag=1; + } + + int id=0,i; + std::string names[100]; + std::string myfname; + std::string str; + std::ifstream infile; + std::ostringstream oss; + int iline=0; + std::string sargname; + int ival; + int idac=0; + + //ascii settings/trim file + switch (thisDetector->myDetectorType) { + case GOTTHARD: + names[id++]="Vref"; + names[id++]="VcascN"; + names[id++]="VcascP"; + names[id++]="Vout"; + names[id++]="Vcasc"; + names[id++]="Vin"; + names[id++]="Vref_comp"; + names[id++]="Vib_test"; + break; + case EIGER: + break; + case JUNGFRAU: + names[id++]="VDAC0"; + names[id++]="VDAC1"; + names[id++]="VDAC2"; + names[id++]="VDAC3"; + names[id++]="VDAC4"; + names[id++]="VDAC5"; + names[id++]="VDAC6"; + names[id++]="VDAC7"; + names[id++]="VDAC8"; + names[id++]="VDAC9"; + names[id++]="VDAC10"; + names[id++]="VDAC11"; + names[id++]="VDAC12"; + names[id++]="VDAC13"; + names[id++]="VDAC14"; + names[id++]="VDAC15"; + break; + default: + std::cout << "Unknown detector type - unknown format for settings file" << std::endl; + return NULL; + } + +#ifdef VERBOSE + std::cout<< "reading settings file" << std::endl; +#endif + myfname=fname; +#ifdef VERBOSE + std::cout<< "file name is "<< myfname << std::endl; +#endif + + switch (thisDetector->myDetectorType) { + + case EIGER: + infile.open(myfname.c_str(),std::ifstream::binary); + if (infile.is_open()) { + infile.read((char*) myMod->dacs,sizeof(dacs_t)*(myMod->ndac)); + infile.read((char*)&iodelay,sizeof(iodelay)); + infile.read((char*)&tau,sizeof(tau)); +#ifdef VERBOSE + for(int i=0;indac;i++) + std::cout << "dac " << i << ":" << myMod->dacs[i] << std::endl; + std::cout << "iodelay:" << iodelay << std::endl; + std::cout << "tau:" << tau << std::endl; +#endif + if(tb) { + infile.read((char*) myMod->chanregs,sizeof(int)*(myMod->nchan)); + if(infile.eof()){ + std::cout<settingsFile,fname.c_str()); + printf("Settings file loaded: %s\n",thisDetector->settingsFile); + return myMod; + + } + + break; + + case GOTTHARD: + case JUNGFRAU: + //---------------dacs--------------- + infile.open(myfname.c_str(), std::ios_base::in); + if (infile.is_open()) { + while(infile.good()) { + getline(infile,str); + iline++; +#ifdef VERBOSE + std::cout<< str << std::endl; +#endif + std::istringstream ssstr(str); + ssstr >> sargname >> ival; + for (i=0;idacs[i]=ival; + idac++; +#ifdef VERBOSE + std::cout<< sargname << " dac nr. " << idac << " is " << ival << std::endl; +#endif + break; + } + } + } + if (i < id) { +#ifdef VERBOSE + std::cout<< sargname << " dac nr. " << idac << " is " << ival << std::endl; +#endif + }else + std::cout<< "Unknown dac " << sargname << std::endl; + + infile.close(); + strcpy(thisDetector->settingsFile,fname.c_str()); + printf("Settings file loaded: %s\n",thisDetector->settingsFile); + return myMod; + + } + + //---------------------------------- + break; + + default: + std::cout<< "Unknown detector type - don't know how to read file" << myfname << std::endl; + infile.close(); + deleteModule(myMod); + return NULL; + + } + + printf("Error: Could not open settings file %s\n", myfname.c_str()); + if (nflag) + deleteModule(myMod); + + return NULL; + + + +} + + +int slsDetector::writeSettingsFile(std::string fname, sls_detector_module mod, + int iodelay, int tau){ + + std::ofstream outfile; + + std::string names[100]; + int id=0; + switch (thisDetector->myDetectorType) { + case GOTTHARD: + names[id++]="Vref"; + names[id++]="VcascN"; + names[id++]="VcascP"; + names[id++]="Vout"; + names[id++]="Vcasc"; + names[id++]="Vin"; + names[id++]="Vref_comp"; + names[id++]="Vib_test"; + break; + case EIGER: + break; + case JUNGFRAU: + names[id++]="VDAC0"; + names[id++]="VDAC1"; + names[id++]="VDAC2"; + names[id++]="VDAC3"; + names[id++]="VDAC4"; + names[id++]="VDAC5"; + names[id++]="VDAC6"; + names[id++]="VDAC7"; + names[id++]="VDAC8"; + names[id++]="VDAC9"; + names[id++]="VDAC10"; + names[id++]="VDAC11"; + names[id++]="VDAC12"; + names[id++]="VDAC13"; + names[id++]="VDAC14"; + names[id++]="VDAC15"; + break; + default: + std::cout << "Unknown detector type - unknown format for settings file" << std::endl; + return FAIL; + } + + int iv; + int idac; + + switch (thisDetector->myDetectorType) { + case EIGER: + outfile.open(fname.c_str(), std::ofstream::binary); + if (outfile.is_open()) { + iv = 1150; +#ifdef VERBOSE + for(int i=0;i(&iodelay), sizeof(iodelay)); + outfile.write(reinterpret_cast(&tau), sizeof(tau)); + outfile.write((char*)mod.chanregs, sizeof(int)*(mod.nchan)); + + outfile.close(); + return slsDetectorDefs::OK; + } + + printf("Could not open Settings file %s\n", fname.c_str()); + return slsDetectorDefs::FAIL; + default: + + + outfile.open(fname.c_str(), std::ios_base::out); + + if (outfile.is_open()) { + for (idac=0; idac0 otherwise - */ - int setFlatFieldCorrection(std::string fname=""); - - /** - * Set flat field corrections (Mythen) - * @param corr if !=NULL the flat field corrections will be filled with - * corr (NULL usets ff corrections) - * @param ecorr if !=NULL the flat field correction errors will be filled - * with ecorr (1 otherwise) - * @returns 0 if ff correction disabled, >0 otherwise - */ - int setFlatFieldCorrection(double *corr, double *ecorr=NULL); - - /** - * Get flat field corrections (Mythen) - * @param corr if !=NULL will be filled with the correction coefficients - * @param ecorr if !=NULL will be filled with the correction coefficients errors - * @returns 0 if ff correction disabled, >0 otherwise - */ - int getFlatFieldCorrection(double *corr=NULL, double *ecorr=NULL); - - /** - * Flat field correct data (Mythen) - * @param datain data array - * @param errin error array on data (if NULL will default to sqrt(datain) - * @param dataout array of corrected data - * @param errout error on corrected data (if not NULL) - * @returns 0 - */ - int flatFieldCorrect(double* datain, double *errin, double* dataout, double *errout); - - /** - * Set bad channels correction (Mythen) - * @param fname file with bad channel list ("" disable) - * @returns 0 if bad channel disabled, >0 otherwise - */ - int setBadChannelCorrection(std::string fname=""); - - /** - * Set bad channels correction (Mythen) - * @param nch number of bad channels - * @param chs array of channels - * @param ff 0 if normal bad channels, 1 if ff bad channels - * @returns 0 if bad channel disabled, >0 otherwise - */ - int setBadChannelCorrection(int nch, int *chs, int ff=0); - - /** - * Get bad channels correction (Mythen) - * @param bad pointer to array that if bad!=NULL will be filled with the - * bad channel list - * @returns 0 if bad channel disabled or no bad channels, >0 otherwise - */ - int getBadChannelCorrection(int *bad=NULL); - - /** - * Reads an angular conversion file (Mythen, Gotthard) - * \sa angleConversionConstant mythenDetector::readAngularConversion - * @param fname file to be read - * @returns 0 if angular conversion disabled, >0 otherwise - */ - int readAngularConversionFile(std::string fname=""); - - /** - * Reads an angular conversion file (Mythen, Gotthard) - * \sa angleConversionConstant mythenDetector::readAngularConversion - * @param ifs input stream - * @returns 0 if angular conversion disabled, >0 otherwise - */ - int readAngularConversion(std::ifstream& ifs); - - /** - * Writes an angular conversion file (Mythen, Gotthard) - * \sa angleConversionConstant mythenDetector::writeAngularConversion - * @param fname file to be written - * @returns 0 if angular conversion disabled, >0 otherwise - */ - int writeAngularConversion(std::string fname=""); - - /** - * Writes an angular conversion file (Mythen, Gotthard) - * \sa angleConversionConstant mythenDetector::writeAngularConversion - * @param ofs output stream - * @returns 0 if angular conversion disabled, >0 otherwise - */ - int writeAngularConversion(std::ofstream &ofs); - - /** - * Get angular conversion (Mythen, Gotthard) - * \sa angleConversionConstant mythenDetector::getAngularConversion - * @param direction reference to diffractometer - * @param angconv array that will be filled with the angular conversion constants - * @returns 0 if angular conversion disabled, >0 otherwise - */ - int getAngularConversion(int &direction, angleConversionConstant *angconv=NULL) ; - - /** - * Return angular conversion pointer (Mythen, Gotthard) - * @param imod module number - * @returns angular conversion pointer - */ - angleConversionConstant *getAngularConversionPointer(int imod=0); - /** * Prints receiver configuration * @returns OK or FAIL @@ -2035,7 +1544,7 @@ public: * @param s file directory * @returns file dir */ - std::string setFilePath(std::string s=""); + std::string setFilePath(std::string s); /** * Returns file name prefix @@ -2048,14 +1557,14 @@ public: * @param s file name prefix * @returns file name prefix */ - std::string setFileName(std::string s=""); + std::string setFileName(std::string s); /** * Sets the max frames per file in receiver * @param f max frames per file * @returns max frames per file in receiver */ - int setReceiverFramesPerFile(int f = -1); + int setReceiverFramesPerFile(int f=-1); /** * Sets the frames discard policy in receiver @@ -2082,7 +1591,7 @@ public: * @param f file format * @returns file format */ - fileFormat setFileFormat(fileFormat f=GET_FILE_FORMAT); + fileFormat setFileFormat(fileFormat f); /** * Returns file index @@ -2095,7 +1604,13 @@ public: * @param i file index * @returns file index */ - int setFileIndex(int i=-1); + int setFileIndex(int i); + + /** + * increments file index + * @returns the file index + */ + int incrementFileIndex(); /** * Receiver starts listening to packets @@ -2109,13 +1624,6 @@ public: */ int stopReceiver(); - /** - * Sets the receiver to start any readout remaining in the fifo and - * change status to transmitting (Mythen) - * The status changes to run_finished when fifo is empty - */ - runStatus startReceiverReadout(); - /** * Gets the status of the listening mode of receiver * @returns status @@ -2194,13 +1702,6 @@ public: */ int enableDataStreamingFromReceiver(int enable=-1); - /** - * Enable/disable or get data compression in receiver - * @param i is -1 to get, 0 to disable and 1 to enable - * @returns data compression in receiver - */ - int enableReceiverCompression(int i = -1); - /** * Enable/disable or 10Gbe * @param i is -1 to get, 0 to disable and 1 to enable @@ -2348,20 +1849,6 @@ private: */ void deleteModule(sls_detector_module *myMod); - /** - * Send a sls_detector_channel structure over socket - * @param myChan channel structure to send - * @returns number of bytes sent to the detector - */ - int sendChannel(sls_detector_channel* myChan); - - /** - * Send a sls_detector_chip structure over socket - * @param myChip chip structure to send - * @returns number of bytes sent to the detector - */ - int sendChip(sls_detector_chip* myChip); - /** * Send a sls_detector_module structure over socket * @param myMod module structure to send @@ -2369,20 +1856,6 @@ private: */ int sendModule(sls_detector_module* myMod); - /** - * Receive a sls_detector_channel structure over socket - * @param myChan channel structure to receive - * @returns number of bytes received from the detector - */ - int receiveChannel(sls_detector_channel* myChan); - - /** - * Receive a sls_detector_chip structure over socket - * @param myChip chip structure to receive - * @returns number of bytes received from the detector - */ - int receiveChip(sls_detector_chip* myChip); - /** * Receive a sls_detector_module structure over socket * @param myMod module structure to receive @@ -2431,7 +1904,6 @@ private: */ std::string setDetectorNetworkParameter(networkParameter index, int delay); - /** * Get MAC from the receiver using udpip and * set up UDP connection in detector @@ -2439,6 +1911,94 @@ private: */ int setUDPConnection(); + /** + * reads a calibration file + * @param fname file to be read + * @param gain reference to the gain variable + * @param offset reference to the offset variable + * @returns OK if successful, else FAIL or -1 + */ + static int readCalibrationFile(std::string fname, double &gain, double &offset); + + /** + * writes a calibration file + * @param fname file to be written + * @param gain + * @param offset + * @returns OK if successful, else FAIL or -1 + */ + static int writeCalibrationFile(std::string fname, double gain, double offset); + + /** + * reads a calibration file + * @param fname file to be read + * @param gain reference to the gain variable + * @param offset reference to the offset variable + * @returns OK if successful, else FAIL or -1 + */ + static int readCalibrationFile(std::string fname, int *gain, int *offset); + + /** + * writes a calibration file + * @param fname file to be written + * @param gain reference to the gain variable + * @param offset reference to the offset variable + * @returns OK if successful, else FAIL or -1 + */ + static int writeCalibrationFile(std::string fname, int *gain, int *offset); + + /* + * Template function to do linear interpolation between two points (Eiger only) + */ + template + V linearInterpolation(const E x, const E x1, const E x2, const V y1, const V y2){ + double k = static_cast(y2-y1)/(x2-x1); + double m = y1-k*x1; + int y = round( k*x+m ); + return static_cast(y); + } + + /** + * interpolates dacs and trimbits between 2 trim files + * @param a first module structure + * @param b second module structure + * @param energy energy to trim at + * @param e1 reference trim value + * @param e2 reference trim value + * @param tb 1 to include trimbits, 0 to exclude (used for eiger) + * @returns the pointer to the module structure with interpolated values or NULL if error + */ + sls_detector_module* interpolateTrim( + sls_detector_module* a, sls_detector_module* b, const int energy, + const int e1, const int e2, int tb=1); + + /** + * reads a trim/settings file + * @param fname name of the file to be read + * @param iodelay io delay (detector specific) + * @param tau tau (detector specific) + * @param myMod pointer to the module structure which has to be set.
+ * If it is NULL a new module structure will be created + * @param tb 1 to include trimbits, 0 to exclude (used for eiger) + * @returns the pointer to myMod or NULL if reading the file failed + */ + + sls_detector_module* readSettingsFile(std::string fname, + int& iodelay, int& tau, + sls_detector_module* myMod=NULL, int tb=1); + + /** + * writes a trim/settings file + * @param fname name of the file to be written + * @param mod module structure which has to be written to file + * @param iodelay io delay (detector specific) + * @param tau tau (detector specific) + * @returns OK or FAIL if the file could not be written + */ + int writeSettingsFile(std::string fname, + sls_detector_module mod, int iodelay, int tau); + + /** slsDetector Id or position in the detectors list */ int detId; @@ -2462,12 +2022,6 @@ private: /** socket for data acquisition */ MySocketTCP *dataSocket; - /** pointer to flat field coefficients in shared memory */ - double *ffcoefficients; - - /** pointer to flat field coefficient errors in shared memory */ - double *fferrors; - /** pointer to detector module structures in shared memory */ sls_detector_module *detectorModules; diff --git a/slsDetectorSoftware/slsDetector/slsDetectorBase.h b/slsDetectorSoftware/slsDetector/slsDetectorBase.h index e4a25d621..42f699418 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorBase.h +++ b/slsDetectorSoftware/slsDetector/slsDetectorBase.h @@ -84,114 +84,6 @@ class slsDetectorBase : public virtual slsDetectorDefs, public virtual errorDef std::string getDetectorDeveloper(){return std::string("PSI");}; // protected: - /** - set angular conversion - \param fname file with angular conversion constants ("" disable) - \returns 0 if angular conversion disabled, >0 otherwise - */ - virtual int setAngularConversionFile(std::string fname="")=0; - - - /** - pure virtual function - returns the angular conversion file - */ - virtual std::string getAngularConversionFile()=0; - - - - /** - set action - \param iaction can be enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript, MAX_ACTIONS} - \param fname for script ("" disable) - \returns 0 if action disabled, >0 otherwise - */ - virtual int setActionScript(int iaction, std::string fname="")=0; - - /** - set action - \param iaction can be enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript, MAX_ACTIONS} - \param par for script ("" disable) - \returns 0 if action disabled, >0 otherwise - */ - virtual int setActionParameter(int iaction, std::string par="")=0; - - /** - returns action script - \param iaction can be enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript} - \returns action script - */ - virtual std::string getActionScript(int iaction)=0; - - /** - returns action parameter - \param iaction can be enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript} - \returns action parameter - */ - virtual std::string getActionParameter(int iaction)=0; - - /** - set scan script - \param index is the scan index (0 or 1) - \param script fname for script ("" disable, "none" disables and overwrites current, "threshold" makes threshold scan, "trimbits" make trimbits scan, "energy" makes energy scan) - \returns 0 if scan disabled, >0 otherwise - */ - virtual int setScanScript(int index, std::string script="")=0; - - /** - set scan script parameter - \param index is the scan index (0 or 1) - \param spar parameter to be passed to the scan script with syntax par=spar - \returns 0 if scan disabled, >0 otherwise - */ - virtual int setScanParameter(int index, std::string spar="")=0; - - - /** set scan precision - \param index is the scan index (0 or 1) - \param precision number of decimals to use for the scan variable in the file name - \returns 0 if scan disabled, >0 otherwise */ - virtual int setScanPrecision(int index, int precision=-1)=0; - - /** - set scan steps (passed to the scan script as var=step) - \param index is the scan index (0 or 1) - \param nvalues is the number of steps - \param values array of steps - \returns 0 if scan disabled, >0 otherwise*/ - - virtual int setScanSteps(int index, int nvalues=-1, double *values=NULL)=0; - - /** - get scan script - \param index is the scan index (0 or 1) - \returns "none" if disables, "threshold" threshold scan, "trimbits" trimbits scan, "energy" energy scan or scan script name - */ - virtual std::string getScanScript(int index)=0; - - /** - get scan script - \param index is the scan index (0 or 1) - \returns scan script parameter - */ - virtual std::string getScanParameter(int index)=0; - - /** - get scan precision - \param index is the scan index (0 or 1) - \returns precision i.e. number of decimals to use for the scan variable in the file name - */ - virtual int getScanPrecision(int index)=0; - - /** - get scan steps - \param index is the scan index (0 or 1) - \param values pointer to array of values (must be allocated in advance) - \returns number of steps - */ - virtual int getScanSteps(int index, double *values=NULL)=0; - - /** Writes the configuration file -- will contain all the informations needed for the configuration (e.g. for a PSI detector caldir, settingsdir, angconv, badchannels etc.) \param fname file name @@ -208,26 +100,6 @@ class slsDetectorBase : public virtual slsDetectorDefs, public virtual errorDef */ virtual int loadImageToDetector(imageType index,std::string const fname)=0; - /** - \returns number of positions - */ - virtual int getNumberOfPositions()=0;// {return 0;}; - - /** - \returns action mask - */ - virtual int getActionMask()=0;// {return 0;}; - /** - \param index scan level index - \returns current scan variable - */ - virtual double getCurrentScanVariable(int index)=0;// {return 0;}; - - /** - \returns current position index - */ - virtual int getCurrentPositionIndex()=0;// {return 0;}; - /** \returns total number of channels */ @@ -238,28 +110,15 @@ class slsDetectorBase : public virtual slsDetectorDefs, public virtual errorDef */ virtual int getTotalNumberOfChannels(dimension d)=0; - /** generates file name without extension */ - virtual std::string createFileName()=0; virtual void incrementProgress()=0; virtual void setCurrentProgress(int i=0)=0; virtual double getCurrentProgress()=0; - virtual void incrementFileIndex()=0; virtual int setTotalProgress()=0; - virtual double* decodeData(int *datain, int &nn, double *fdata=NULL)=0; - - virtual std::string getCurrentFileName()=0; - - - virtual int getFileIndexFromFileName(std::string fname)=0; - - virtual int getIndicesFromFileName(std::string fname,int &index)=0; - - virtual double *convertAngles()=0; /** set rate correction \param t dead time in ns - if 0 disable correction, if >0 set dead time to t, if <0 set deadtime to default dead time for current settings @@ -279,10 +138,6 @@ class slsDetectorBase : public virtual slsDetectorDefs, public virtual errorDef \returns 0 if rate correction disabled, >0 otherwise */ virtual int getRateCorrection()=0; - - virtual int setFlatFieldCorrection(std::string fname="")=0; - - int setFlatFieldCorrectionFile(std::string fname=""){return setFlatFieldCorrection(fname);}; /** set/get dynamic range @@ -290,22 +145,6 @@ class slsDetectorBase : public virtual slsDetectorDefs, public virtual errorDef \returns current dynamic range */ virtual int setDynamicRange(int i=-1)=0; - // int setBitDepth(int i=-1){return setDynamicRange(i);}; - - /** - set/get the size of the detector - \param i number of modules - \param d dimension - \returns current number of modules in direction d - */ - virtual int setNumberOfModules(int i=-1, dimension d=X)=0; - - // int setDetectorSize(int x0=-1, int y0=-1, int nx=-1, int ny=-1){return setNumberOfModules(nx/getChansPerMod(0),X);}; - - // int getDetectorSize(int &x0, int &y0, int &nx, int &ny){x0=0; nx=setNumberOfModules(-1,X)*getChansPerMod(0); return nx;}; - - virtual int getMaxNumberOfModules(dimension d=X)=0; // - // int getMaximumDetectorSize(int &nx, int &ny){nx=getMaxNumberOfModules(X)*getChansPerMod(0); ny=1; return nx;}; /** Locks/Unlocks the connection to the server @@ -329,12 +168,6 @@ class slsDetectorBase : public virtual slsDetectorDefs, public virtual errorDef int startMeasurement(){acquire(0); return OK;}; - /** - asks and receives a data frame from the detector, writes it to disk and processes the data - \returns pointer to the data or NULL (unused!!!). - */ - virtual int* readFrame()=0; - /** get detector ids/versions for module=0 @@ -343,8 +176,6 @@ class slsDetectorBase : public virtual slsDetectorDefs, public virtual errorDef \returns id */ virtual int64_t getId(idMode mode, int imod=0)=0; - int64_t getModuleFirmwareVersion(){return getId(MODULE_FIRMWARE_VERSION,-1);}; - int64_t getModuleSerialNumber(int imod=-1){return getId(MODULE_SERIAL_NUMBER,imod);}; int64_t getDetectorFirmwareVersion(){return getId(DETECTOR_FIRMWARE_VERSION,-1);}; int64_t getDetectorSerialNumber(){return getId(DETECTOR_SERIAL_NUMBER,-1);}; int64_t getDetectorSoftwareVersion(){return getId(DETECTOR_SOFTWARE_VERSION,-1);}; @@ -361,14 +192,13 @@ class slsDetectorBase : public virtual slsDetectorDefs, public virtual errorDef */ virtual int stopAcquisition()=0; int stopMeasurement(){return stopAcquisition();}; - virtual int getChansPerMod(int imod=0)=0; /** set/get timer value \param index timer index - \param t time in ns or number of...(e.g. frames, gates, probes) + \param t time in ns or number of...(e.g. frames, gates) \param imod module number - \returns timer set value in ns or number of...(e.g. frames, gates, probes) + \returns timer set value in ns or number of...(e.g. frames, gates) */ virtual int64_t setTimer(timerIndex index, int64_t t=-1, int imod = -1)=0; int64_t setExposureTime(int64_t t=-1, int imod = -1){return setTimer(ACQUISITION_TIME,t,imod);}; @@ -457,7 +287,6 @@ class slsDetectorBase : public virtual slsDetectorDefs, public virtual errorDef virtual dacs_t setDAC(dacs_t val, dacIndex index , int mV, int imod=-1)=0; int setDACValue(int val, int index , int imod=-1) { return (int)setDAC((dacs_t)val,(dacIndex)index,0,imod);}; - /** gets ADC value \param index ADC index @@ -466,7 +295,7 @@ class slsDetectorBase : public virtual slsDetectorDefs, public virtual errorDef */ virtual dacs_t getADC(dacIndex index, int imod=-1)=0; int getADCValue(int index, int imod=-1){return (int)getADC((dacIndex)index, imod);}; - /////////////////////////////////////////////////////////////////////////////////////////// + /** @short get run status \returns status mask @@ -557,6 +386,12 @@ class slsDetectorBase : public virtual slsDetectorDefs, public virtual errorDef */ virtual int setFileIndex(int i)=0; + /** + @short increments file index + \returns the file index + */ + virtual int incrementFileIndex()=0; + //receiver /** @@ -627,76 +462,33 @@ virtual int enableDataStreamingFromReceiver(int enable=-1)=0; */ virtual int setReadReceiverFrequency(int freq=-1)=0; - /** Sets the receiver to start any readout remaining in the fifo and - * change status to transmitting. - * The status changes to run_finished when fifo is empty - */ - virtual runStatus startReceiverReadout()=0; - /** returns detector type std::string from detector type index - \param t std::string can be Mythen, Pilatus, Eiger, Gotthard, Agipd, Unknown - \returns MYTHEN, PILATUS, EIGER, GOTTHARD, AGIPD, MÖNCH, GENERIC + \param t std::string can be Eiger, Gotthard, Jungfrau, Unknown + \returns EIGER, GOTTHARD, JUNGFRAU, GENERIC */ static std::string getDetectorType(detectorType t){\ switch (t) {\ - case MYTHEN: return std::string("Mythen"); \ - case PILATUS: return std::string("Pilatus"); \ case EIGER: return std::string("Eiger"); \ case GOTTHARD: return std::string("Gotthard"); \ - case AGIPD: return std::string("Agipd"); \ - case MOENCH: return std::string("Moench"); \ case JUNGFRAU: return std::string("Jungfrau"); \ case JUNGFRAUCTB: return std::string("JungfrauCTB"); \ - case PROPIX: return std::string("Propix"); \ default: return std::string("Unknown"); \ }}; /** returns detector type index from detector type std::string - \param type can be MYTHEN, PILATUS, EIGER, GOTTHARD, AGIPD, GENERIC - \returns Mythen, Pilatus, Eiger, Gotthard, Agipd, Mönch, Unknown + \param type can be EIGER, GOTTHARD, JUNGFRAU, GENERIC + \returns Eiger, Gotthard, Jungfrau, Unknown */ static detectorType getDetectorType(std::string const type){\ - if (type=="Mythen") return MYTHEN;\ - if (type=="Pilatus") return PILATUS; \ if (type=="Eiger") return EIGER; \ if (type=="Gotthard") return GOTTHARD; \ - if (type=="Agipd") return AGIPD; \ - if (type=="Moench") return MOENCH; \ if (type=="Jungfrau") return JUNGFRAU; \ if (type=="JungfrauCTB") return JUNGFRAUCTB; \ - if (type=="Propix") return PROPIX; \ return GENERIC;}; - /** returns synchronization type index from std::string - \param type can be none, gating, trigger, complementary - \returns ONE, MASTER_GATES, MASTER_TRIGGERS, SLAVE_STARTS_WHEN_MASTER_STOPS - */ - static synchronizationMode getSyncType(std::string const type){\ - if (type=="none") return NO_SYNCHRONIZATION;\ - if (type=="gating") return MASTER_GATES;\ - if (type=="trigger") return MASTER_TRIGGERS; \ - if (type=="complementary") return SLAVE_STARTS_WHEN_MASTER_STOPS; \ - return GET_SYNCHRONIZATION_MODE; \ - }; - - /** returns synchronization type std::string from index - \param s can be NONE, MASTER_GATES, MASTER_TRIGGERS, SLAVE_STARTS_WHEN_MASTER_STOPS - \returns none, gating, trigger, complementary, unknown - */ - static std::string getSyncType(synchronizationMode s ){\ - switch(s) { \ - case NO_SYNCHRONIZATION: return std::string("none"); \ - case MASTER_GATES: return std::string("gating"); \ - case MASTER_TRIGGERS: return std::string("trigger"); \ - case SLAVE_STARTS_WHEN_MASTER_STOPS: return std::string("complementary"); \ - default: return std::string("unknown"); \ - }}; - - - /** returns std::string from external signal type index \param f can be SIGNAL_OFF, GATE_IN_ACTIVE_HIGH, GATE_IN_ACTIVE_LOW, TRIGGER_IN_RISING_EDGE, TRIGGER_IN_FALLING_EDGE, RO_TRIGGER_IN_RISING_EDGE, RO_TRIGGER_IN_FALLING_EDGE, GATE_OUT_ACTIVE_HIGH, GATE_OUT_ACTIVE_LOW, =TRIGGER_OUT_RISING_EDGE, TRIGGER_OUT_FALLING_EDGE, RO_TRIGGER_OUT_RISING_EDGE, RO_TRIGGER_OUT_FALLING_EDGE, OUTPUT_LOW, OUTPUT_HIGH, MASTER_SLAVE_SYNCHRONIZATION, GET_EXTERNAL_SIGNAL_FLAG \returns std::string off, gate_in_active_high, gate_in_active_low, trigger_in_rising_edge, trigger_in_falling_edge, ro_trigger_in_rising_edge, ro_trigger_in_falling_edge, gate_out_active_high, gate_out_active_low, trigger_out_rising_edge, trigger_out_falling_edge, ro_trigger_out_rising_edge, ro_trigger_out_falling_edge, gnd, vcc, sync, unknown @@ -862,8 +654,8 @@ virtual int enableDataStreamingFromReceiver(int enable=-1)=0; }}; /** returns std::string from timer index - \param s can be FRAME_NUMBER,ACQUISITION_TIME,FRAME_PERIOD, DELAY_AFTER_TRIGGER,GATES_NUMBER,PROBES_NUMBER, CYCLES_NUMBER, ACTUAL_TIME,MEASUREMENT_TIME, PROGRESS,MEASUREMENTS_NUMBER,FRAMES_FROM_START,FRAMES_FROM_START_PG,SAMPLES_JCTB,SUBFRAME_ACQUISITION_TIME,STORAGE_CELL_NUMBER, SUBFRAME_DEADTIME - \returns std::string frame_number,acquisition_time,frame_period, delay_after_trigger,gates_number,probes_number, cycles_number, actual_time,measurement_time, progress,measurements_number,frames_from_start,frames_from_start_pg,samples_jctb,subframe_acquisition_time,storage_cell_number, SUBFRAME_DEADTIME + \param s can be FRAME_NUMBER,ACQUISITION_TIME,FRAME_PERIOD, DELAY_AFTER_TRIGGER,GATES_NUMBER, CYCLES_NUMBER, ACTUAL_TIME,MEASUREMENT_TIME, PROGRESS,MEASUREMENTS_NUMBER,FRAMES_FROM_START,FRAMES_FROM_START_PG,SAMPLES_JCTB,SUBFRAME_ACQUISITION_TIME,STORAGE_CELL_NUMBER, SUBFRAME_DEADTIME + \returns std::string frame_number,acquisition_time,frame_period, delay_after_trigger,gates_number, cycles_number, actual_time,measurement_time, progress,measurements_number,frames_from_start,frames_from_start_pg,samples_jctb,subframe_acquisition_time,storage_cell_number, SUBFRAME_DEADTIME */ static std::string getTimerType(timerIndex t){ \ switch (t) { \ @@ -872,7 +664,6 @@ virtual int enableDataStreamingFromReceiver(int enable=-1)=0; case FRAME_PERIOD: return std::string("frame_period"); \ case DELAY_AFTER_TRIGGER: return std::string("delay_after_trigger"); \ case GATES_NUMBER: return std::string("gates_number"); \ - case PROBES_NUMBER: return std::string("probes_number"); \ case CYCLES_NUMBER: return std::string("cycles_number"); \ case ACTUAL_TIME: return std::string("actual_time"); \ case MEASUREMENT_TIME: return std::string("measurement_time"); \ diff --git a/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp b/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp index 398c937f9..012f53dca 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp @@ -56,10 +56,9 @@ The commands are sudivided into different pages depending on their functionaliti - \ref acquisition "Acquisition": commands to start/stop the acquisition and retrieve data - \ref config "Configuration": commands to configure the detector - \ref timing "Timing": commands to configure the detector timing - - \ref data "Data postprocessing": commands to process the data - mainly for MYTHEN except for rate corrections. + - \ref data "Data postprocessing": commands to process the data - \ref settings "Settings": commands to define detector settings/threshold. - \ref output "Output": commands to define output file destination and format - - \ref actions "Actions": commands to define scripts to be executed during the acquisition flow - \ref network "Network": commands to setup the network between client, detector and receiver - \ref receiver "Receiver": commands to configure the receiver - \ref ctb "Chiptest board": commands specific for the new chiptest board as pattern generator @@ -121,13 +120,6 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) { descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdDigiTest; ++i; - /*! \page test - - bustest performs test of the bus interface between FPGA and embedded Linux system. Can last up to a few minutes. Cannot set! Used for Mythen only. Only get! - */ - descrToFuncMap[i].m_pFuncName="bustest"; // - descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdDigiTest; - ++i; - /*! \page test - digibittest:[i] performs digital test of the module i. Returns 0 if succeeded, otherwise error mask. Only put! */ @@ -170,14 +162,6 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) { descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdRegister; ++i; - /*! \page test - - r_compression [i] sets/gets compression in receiver. 1 sets, 0 unsets. Not implemented. - */ - descrToFuncMap[i].m_pFuncName="r_compression"; // - descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdReceiver; - ++i; - - /* Acquisition and status commands */ /*! \page acquisition Acquition commands @@ -185,7 +169,7 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) { */ /*! \page acquisition - \b acquire blocking acquisition (like calling sls_detector_acquire). Starts receiver and detector, writes and processes the data, stops detector. Only get! - \c Returns (string)\c "acquire unsuccessful" if fails, else "" for MYTHEN, \c "Acquired (int)" for others, where int is number of frames caught. + \c Returns (string)\c "acquire unsuccessful" if fails, else \c "Acquired (int)", where int is number of frames caught. */ descrToFuncMap[i].m_pFuncName="acquire"; // descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdAcquire; @@ -206,19 +190,12 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) { ++i; /*! \page acquisition - - \b data gets all data from the detector (if any) processes them and writes them to file according to the preferences already setup (MYTHEN only). Only get! + - \b data gets all data from the detector (if any) processes them and writes them to file according to the preferences already setup (Eigerr store in ram only). Only get! */ descrToFuncMap[i].m_pFuncName="data"; // descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdData; ++i; - /*! \page acquisition - - \b frame gets a single frame from the detector (if any) processes it and writes it to file according to the preferences already setup (MYTHEN only). Only get! - */ - descrToFuncMap[i].m_pFuncName="frame"; // - descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdFrame; - ++i; - /*! \page acquisition - readctr Reads the counters from the detector memory (analog detector returning values translated into number of photons - only GOTTHARD). Cannot put. */ @@ -297,20 +274,6 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) { descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdUser; ++i; - /*! \page config - - master i \c put sets the position of the master of the acquisition (-1 if none). Returns the position of the master of the detector structure (-1 if none). - */ - descrToFuncMap[i].m_pFuncName="master"; //OK - descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdMaster; - ++i; - - /*! \page config - - sync Sets/gets the synchronization mode of the detectors in the multi-detector structure. Can be: \c none, \c gating, \c trigger, \c complementary. Mainly used by MYTHEN/GOTTHARD. - */ - descrToFuncMap[i].m_pFuncName="sync"; //OK - descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdSync; - ++i; - /*! \page config \section configstatus Status commands to configure detector status @@ -343,22 +306,9 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) { commands to configure detector data size */ - /*! \page config - - nmod [i] sets/gets the number of modules of the detector. Used for MYTHEN only. \c Returns \c (int) - */ - descrToFuncMap[i].m_pFuncName="nmod"; // - descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdDetectorSize; - ++i; /*! \page config - - maxmod Gets the maximum number of modules of the detector. Used for MYTHEN only. Cannot put! \c Returns \c (int) - */ - descrToFuncMap[i].m_pFuncName="maxmod"; // - descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdDetectorSize; - ++i; - - /*! \page config - - dr [i] sets/gets the dynamic range of detector. Mythen [4,8,16,24]. Eiger [4,8,16,32]. Others cannot put! \c Returns \c (int) + - dr [i] sets/gets the dynamic range of detector. Eiger [4,8,16,32]. Others cannot put! \c Returns \c (int) */ descrToFuncMap[i].m_pFuncName="dr"; // descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdDetectorSize; @@ -378,13 +328,6 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) { descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdDetectorSize; ++i; - /*! \page config - - roimask [i] ?? \c Returns \c (int) in hexadecimal - */ - descrToFuncMap[i].m_pFuncName="roimask"; // - descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdDetectorSize; - ++i; - /*! \page config - flippeddatax [i] enables/disables data being flipped across x axis. 1 enables, 0 disables. Used for EIGER only. 1 for bottom half-module, 0 for top-half module. \c Returns \c (int) */ @@ -415,7 +358,7 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) { */ /*! \page config - - flags [flag] sets/gets the readout flags to mode. Options: none, storeinram, tot, continous, parallel, nonparallel, safe, digital, analog_digital, overflow, nooverflow, unknown. Used for MYTHEN and EIGER only. \c Returns \c (string). put takes one string and \c returns concatenation of all active flags separated by spaces. + - flags [flag] sets/gets the readout flags to mode. Options: none, storeinram, tot, continous, parallel, nonparallel, safe, digital, analog_digital, overflow, nooverflow, unknown. Used for EIGER only. \c Returns \c (string). put takes one string and \c returns concatenation of all active flags separated by spaces. */ descrToFuncMap[i].m_pFuncName="flags"; descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdAdvanced; @@ -424,7 +367,7 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) { /*! \page config - extsig:[i] [flag] sets/gets the mode of the external signal i. Options: \c off, \c gate_in_active_high, \c gate_in_active_low, \c trigger_in_rising_edge, \c trigger_in_falling_edge, \c ro_trigger_in_rising_edge, \c ro_trigger_in_falling_edge, \c gate_out_active_high, \c gate_out_active_low, \c trigger_out_rising_edge, \c trigger_out_falling_edge, \c ro_trigger_out_rising_edge, - \c ro_trigger_out_falling_edge. \n Used in MYTHEN, GOTTHARD, PROPIX only. \c Returns \c (string) + \c ro_trigger_out_falling_edge. \n Used in GOTTHARDonly. \c Returns \c (string) */ descrToFuncMap[i].m_pFuncName="extsig"; /* find command! */ descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdAdvanced; @@ -435,7 +378,7 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) { /*! \page config - - programfpga [file] programs the FPGA with file f (with .pof extension). Used for JUNGFRAU, MOENCH only. Only put! \c Returns \c ("successful", "unsuccessful") + - programfpga [file] programs the FPGA with file f (with .pof extension). Used for JUNGFRAU only. Only put! \c Returns \c ("successful", "unsuccessful") */ descrToFuncMap[i].m_pFuncName="programfpga"; descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdAdvanced; @@ -522,13 +465,6 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) { ++i; - /*! \page config - - moduleversion:[i] Gets the firmware version of module i. Used for MYTHEN only. Only get! \c Returns \c (long int) in hexadecimal or "undefined module number" - */ - descrToFuncMap[i].m_pFuncName="moduleversion"; // - descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdSN; - ++i; - /*! \page config - detectornumber Gets the serial number or MAC of detector. Only get! \c Returns \c (long int) in hexadecimal */ @@ -536,12 +472,6 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) { descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdSN; ++i; - /*! \page config - - modulenumber:[i] Gets the serial number of module i. Used for MYTHEN only. Only get! \c Returns \c (long int) in hexadecimal or "undefined module number" - */ - descrToFuncMap[i].m_pFuncName="modulenumber"; /* find command! */ - descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdSN; - ++i; /*! \page config - detectorversion Gets the firmware version of detector. Only get! \c Returns \c (long int) in hexadecimal @@ -611,14 +541,14 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) { ++i; /*! \page timing - - delay [i] sets/gets delay in s. Used in MYTHEN, GOTTHARD only. \c Returns \c (double with 9 decimal digits) + - delay [i] sets/gets delay in s. Used in GOTTHARD only. \c Returns \c (double with 9 decimal digits) */ descrToFuncMap[i].m_pFuncName="delay"; // descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdTimer; ++i; /*! \page timing - - gates [i] sets/gets number of gates. Used in MYTHEN, GOTTHARD only. \c Returns \c (long long int) + - gates [i] sets/gets number of gates. Used in GOTTHARD only. \c Returns \c (long long int) */ descrToFuncMap[i].m_pFuncName="gates"; // descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdTimer; @@ -638,13 +568,6 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) { descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdTimer; ++i; - /*! \page timing - - probes [i] sets/gets number of probes to accumulate. When setting, max 3! cycles should be set to 1, frames to the number of pump-probe events. Used in MYTHEN only. \c Returns \c (long long int) - */ - descrToFuncMap[i].m_pFuncName="probes"; // - descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdTimer; - ++i; - /*! \page timing - measurements [i] sets/gets number of measurements. \c Returns \c (long long int) */ @@ -676,74 +599,63 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) { /* read only timers */ /*! \page timing - - exptimel gets exposure time left. Used in MYTHEN, GOTTHARD only. Only get! \c Returns \c (double with 9 decimal digits) + - exptimel gets exposure time left. Used in GOTTHARD only. Only get! \c Returns \c (double with 9 decimal digits) */ descrToFuncMap[i].m_pFuncName="exptimel"; // descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdTimeLeft; ++i; /*! \page timing - - periodl gets frame period left. Used in MYTHEN, GOTTHARD only. Only get! \c Returns \c (double with 9 decimal digits) + - periodl gets frame period left. Used in GOTTHARD and Jungfrau only. Only get! \c Returns \c (double with 9 decimal digits) */ descrToFuncMap[i].m_pFuncName="periodl"; // descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdTimeLeft; ++i; /*! \page timing - - delayl gets delay left. Used in MYTHEN, GOTTHARD only. Only get! \c Returns \c (double with 9 decimal digits) + - delayl gets delay left. Used in GOTTHARD only. Only get! \c Returns \c (double with 9 decimal digits) */ descrToFuncMap[i].m_pFuncName="delayl"; // descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdTimeLeft; ++i; /*! \page timing - - gatesl gets number of gates left. Used in MYTHEN, GOTTHARD only. Only get! \c Returns \c (double with 9 decimal digits) + - gatesl gets number of gates left. Used in GOTTHARD only. Only get! \c Returns \c (double with 9 decimal digits) */ descrToFuncMap[i].m_pFuncName="gatesl"; // descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdTimeLeft; ++i; /*! \page config - - framesl gets number of frames left. Used in MYTHEN, GOTTHARD only. Only get! \c Returns \c (double with 9 decimal digits) + - framesl gets number of frames left. Used in GOTTHARD and Jungfrau only. Only get! \c Returns \c (double with 9 decimal digits) */ descrToFuncMap[i].m_pFuncName="framesl"; // descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdTimeLeft; ++i; /*! \page timing - - cyclesl gets number of cylces left. Used in MYTHEN, GOTTHARD only. Only get! \c Returns \c (double with 9 decimal digits) + - cyclesl gets number of cylces left. Used in GOTTHARD and Jungfrau only. Only get! \c Returns \c (double with 9 decimal digits) */ descrToFuncMap[i].m_pFuncName="cyclesl"; // descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdTimeLeft; ++i; /*! \page timing - - probesl gets number of probes left. Used in MYTHEN, GOTTHARD only. Only get! \c Returns \c (double with 9 decimal digits) - */ - descrToFuncMap[i].m_pFuncName="probesl"; // - descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdTimeLeft; - ++i; - - // descrToFuncMap[i].m_pFuncName="progress"; - // descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdTimer; - // ++i; - - /*! \page timing - - now Actual time of the detector. Only get! + - now Getting actual time of the detector from start. For Jungfrau only. Only get! */ descrToFuncMap[i].m_pFuncName="now"; // descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdTimeLeft; ++i; /*! \page timing - - timestamp Last frame timestamp for MYTHEN. Only get! + - timestamp Getting timestamp. For Jungfrau only. Only get! */ descrToFuncMap[i].m_pFuncName="timestamp"; // descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdTimeLeft; ++i; /*! \page timing - - nframes ??? Only get! + - nframes Frames from start run control. Only Jungfrau. Only get! */ descrToFuncMap[i].m_pFuncName="nframes"; // descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdTimeLeft; @@ -770,40 +682,12 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) { */ /*! \page config - - clkdivider [i] sets/gets the readout clock divider. EIGER, JUNGFRAU [0(fast speed), 1(half speed), 2(quarter speed)]. Jungfrau, full speed is not implemented and overwrites adcphase to recommended default. MYTHEN[???]. \c Returns \c (int) + - clkdivider [i] sets/gets the readout clock divider. EIGER, JUNGFRAU [0(fast speed), 1(half speed), 2(quarter speed)]. Jungfrau, full speed is not implemented and overwrites adcphase to recommended default. \c Returns \c (int) */ descrToFuncMap[i].m_pFuncName="clkdivider"; // descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdSpeed; ++i; - /*! \page config - - setlength [i] sets/gets length of set/reset signals (in clock cycles). Used in MYTHEN only. \c Returns \c (int) - */ - descrToFuncMap[i].m_pFuncName="setlength"; // - descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdSpeed; - ++i; - - /*! \page config - - waitstates [i] sets/gets waitstates of the bus interface (in clock cycles). Used in MYTHEN only. \c Returns \c (int) - */ - descrToFuncMap[i].m_pFuncName="waitstates"; // - descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdSpeed; - ++i; - - /*! \page config - - totdivider [i] sets/gets clock divider in tot mode. Used in MYTHEN only. \c Returns \c (int) - */ - descrToFuncMap[i].m_pFuncName="totdivider"; // - descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdSpeed; - ++i; - - /*! \page config - - totdutycycle [i] sets/gets duty cycle of the tot clock. Used in MYTHEN only. \c Returns \c (int) - */ - descrToFuncMap[i].m_pFuncName="totdutycycle"; // - descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdSpeed; - ++i; - /*! \page config - phasestep [i] Only put for gotthard. Moves the phase of the ADC clock.\c Returns \c (int) */ @@ -826,7 +710,7 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) { ++i; /*! \page config - - adcphase [i] Sets/gets phase of the sampling clock. For JUNGFRAU, setting speed (clkdivider) overwrites adcphase to its default recommended value. (Not for EIGER) \c Returns \c (int) + - adcphase [i] Sets/gets phase of the sampling clock. For JUNGFRAU, setting speed (clkdivider) overwrites adcphase to its default recommended value. \c Returns \c (int) */ descrToFuncMap[i].m_pFuncName="adcphase"; // descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdSpeed; @@ -902,94 +786,16 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) { /* data processing commands */ /*! \page data Data processing commands - Commands to setup the data processing (mainly MYTHEN related) + Commands to setup the data processing */ - /*! \page data - - flatfield [fn] \c put sets flatfield file to \c fn (relative to \c ffdir). \get returns the flatfield file name relative to \c ffdir (string). If \fn is specified, it writes the flat field correction factors and errors to \c fn. \c Returns \c (string) fn - \c none disables flat field corrections. - */ - descrToFuncMap[i].m_pFuncName="flatfield"; // - descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdFlatField; - ++i; /*! \page data - - ffdir [d] Sets/gets the directory in which the flat field file is located. \c Returns \c (string) ffdir - */ - descrToFuncMap[i].m_pFuncName="ffdir"; // - descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdFlatField; - ++i; - - /*! \page data - - ratecorr [ns] Returns the dead time used for rate correections in ns (int). \c put sets the deadtime correction constant in ns, -1 will set it to default tau of settings (0 unset). \c Returns \c (double with 9 decimal digit precision) + - ratecorr [ns] Returns the dead time used for rate correections in ns (int). \c put sets the deadtime correction constant in ns, -1 will set it to default tau of settings (0 unset). \c Returns \c (double with 9 decimal digit precision). For Eiger only. */ descrToFuncMap[i].m_pFuncName="ratecorr"; // descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdRateCorr; ++i; - /*! \page data - - badchannels [fn] \c put sets the badchannels file to \c fn . \get returns the bad channels file name. If \fn is specified, it writes the badchannels to \c fn. \c none disables badchannel corrections. - */ - descrToFuncMap[i].m_pFuncName="badchannels"; // - descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdBadChannels; - ++i; - - /*! \page data - - angconv [fn] \c put sets the angular conversion file to \c fn . \get returns the angular conversion file name. If \fn is specified, it writes the angular conversion factors to \c fn. \c none disables angular corrections. - */ - descrToFuncMap[i].m_pFuncName="angconv"; // - descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdAngConv; - ++i; - - /*! \page data - - globaloff [f] Sets/gets the beamline angular global offset (float). - */ - descrToFuncMap[i].m_pFuncName="globaloff"; // - descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdAngConv; - ++i; - - /*! \page data - - fineoff [f] Sets/gets the angular fine offset of the measurement (float). - */ - //2017/08/15 - descrToFuncMap[i].m_pFuncName="fineoff"; // - descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdAngConv; - ++i; - - /*! \page data - - binsize [f] Sets/gets the bin size used for the angular conversion (float). - */ - descrToFuncMap[i].m_pFuncName="binsize" ;// - descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdAngConv; - ++i; - - /*! \page data - - angdir [i] Sets/gets the angular direction. 1 means increasing channels number as increasing angle, -1 increasing channel number decreasing angle. - */ - descrToFuncMap[i].m_pFuncName="angdir" ;// - descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdAngConv; - ++i; - - /*! \page data - - moveflag [i] Sets/gets the flag for physically moving the detector during the acquisition of several positions. 1 sets (moves), 0 unsets. - */ - descrToFuncMap[i].m_pFuncName="moveflag" ;// - descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdAngConv; - ++i; - - /*! \page data - - samplex [f] Sets/gets the sample displacement in th direction parallel to the beam in um. Unused! - */ - descrToFuncMap[i].m_pFuncName="samplex" ;// - descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdAngConv; - ++i; - - /*! \page data - - sampley [f] Sets/gets the sample displacement in th direction orthogonal to the beam in um. Unused! - */ - descrToFuncMap[i].m_pFuncName="sampley" ;// - descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdAngConv; - ++i; - /*! \page data - threaded [i] Sets/gets the data processing threaded flag. 1 is threaded, 0 unthreaded. */ @@ -998,14 +804,14 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) { ++i; /*! \page data - - darkimage fn Loads the dark image to the detector from file fn (pedestal image). Cannot get. + - darkimage fn Loads the dark image to the detector from file fn (pedestal image). Cannot get. For Gotthard only. */ descrToFuncMap[i].m_pFuncName="darkimage"; // descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdImage; ++i; /*! \page data - - gainimage fn Loads the gain image to the detector from file fn (gain map for translation into number of photons of an analog detector). Cannot get. + - gainimage fn Loads the gain image to the detector from file fn (gain map for translation into number of photons of an analog detector). Cannot get. For Gotthard only. */ descrToFuncMap[i].m_pFuncName="gainimage"; // descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdImage; @@ -1095,13 +901,6 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) { descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdSettings; ++i; - /*! \page settings - - trim:[mode] [fname] trims the detector according to mode and saves resulting trimbits to file. Mode: noise, beam, improve, fix. Used in MYTHEN only. Only put! \c Returns \c ("done") - */ - descrToFuncMap[i].m_pFuncName="trim"; // - descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdSettings; - ++i; - /*! \page settings - trimval [i] sets all trimbits to i. Used in EIGER only. \c Returns \c (int) */ @@ -1257,40 +1056,6 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) { descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdDAC; ++i; - /*! \page settings - - dac[0..7] [i] [mv] Sets/gets dac[0..7] for MOENCH02. Normally in DAC units unless \c mv is specified at the end of the command line. \c Returns \c (int ["mV"]) - */ - descrToFuncMap[i].m_pFuncName="dac0"; // - descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdDAC; - ++i; - - descrToFuncMap[i].m_pFuncName="dac1"; // - descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdDAC; - ++i; - - descrToFuncMap[i].m_pFuncName="dac2"; // - descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdDAC; - ++i; - - descrToFuncMap[i].m_pFuncName="dac3"; // - descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdDAC; - ++i; - - descrToFuncMap[i].m_pFuncName="dac4"; // - descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdDAC; - ++i; - - descrToFuncMap[i].m_pFuncName="dac5"; // - descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdDAC; - ++i; - - descrToFuncMap[i].m_pFuncName="dac6"; // - descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdDAC; - ++i; - - descrToFuncMap[i].m_pFuncName="dac7"; // - descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdDAC; - ++i; /*! \page settings - vsvp [i] [mv] Sets/gets vsvp. Normally in DAC units unless \c mv is specified at the end of the command line. \c Returns \c (int ["mV"]) @@ -1769,13 +1534,6 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) { descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdOverwrite; ++i; - /*! \page output - - currentfname gets the filename for the data without index and extension. MYTHEN only. \c Returns \c (string) - */ - descrToFuncMap[i].m_pFuncName="currentfname"; //OK - descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdFileName; - ++i; - /*! \page output - fileformat sets/gets the file format for data in receiver. Options: [ascii, binary, hdf5]. Ascii is not implemented in Receiver. \c Returns \c (string) */ @@ -1785,192 +1543,6 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) { - /* Acquisition actions */ - - /*! \page actions Actions - Commands to define scripts to be executed during the acquisition flow - */ - - /*! \page actions - - positions [n [p0..pn-1]] sets/gets number of angular position and positions to be acquired.. \c Returns \c (int int..) n [p0..pn-1] - */ - descrToFuncMap[i].m_pFuncName="positions"; // - descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdPositions; - ++i; - - /*! \page actions - - startscript [s] sets/gets the script to be executed at the beginning of the acquisition. \c none unsets. \c Returns \c (string) - */ - descrToFuncMap[i].m_pFuncName="startscript"; // - descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdScripts; - ++i; - - /*! \page actions - - startscriptpar [s] sets/gets a string to be passed as a parameter to the startscript. \c Returns \c (string) - */ - descrToFuncMap[i].m_pFuncName="startscriptpar"; // - descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdScripts; - ++i; - - /*! \page actions - - stopscript [s] sets/gets the script to be executed at the end of the acquisition. \c none unsets. \c Returns \c (string) - */ - descrToFuncMap[i].m_pFuncName="stopscript"; // - descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdScripts; - ++i; - - /*! \page actions - - stopscriptpar [s] sets/gets a string to be passed as a parameter to the stopscript. \c Returns \c (string) - */ - descrToFuncMap[i].m_pFuncName="stopscriptpar"; // - descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdScripts; - ++i; - - /*! \page actions - - scriptbefore [s] sets/gets the script to be executed before starting the detector every time in the acquisition. \c none unsets. \c Returns \c (string) - */ - descrToFuncMap[i].m_pFuncName="scriptbefore"; // - descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdScripts; - ++i; - - /*! \page actions - - scriptbeforepar [s] sets/gets a string to be passed as a parameter to the scriptbefore. \c Returns \c (string) - */ - descrToFuncMap[i].m_pFuncName="scriptbeforepar"; // - descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdScripts; - ++i; - - /*! \page actions - - scriptafter [s] sets/gets the script to be executed after the detector has finished every time in the acquisition. \c none unsets. \c Returns \c (string) - */ - descrToFuncMap[i].m_pFuncName="scriptafter"; // - descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdScripts; - ++i; - - /*! \page actions - - scriptafterpar [s] sets/gets a string to be passed as a parameter to the scriptafter. \c Returns \c (string) - */ - descrToFuncMap[i].m_pFuncName="scriptafterpar"; // - descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdScripts; - ++i; - - /*! \page actions - - headerafter [s] sets/gets the script to be executed for logging the detector parameters. \c none unsets. \c Returns \c (string) - */ - descrToFuncMap[i].m_pFuncName="headerafter"; // - descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdScripts; - ++i; - - /*! \page actions - - headerbefore [s] sets/gets the script to be executed for logging the detector parameters. \c none unsets. \c Returns \c (string) - */ - descrToFuncMap[i].m_pFuncName="headerbefore"; // - descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdScripts; - ++i; - - /*! \page actions - - headerbeforepar [s] sets/gets a string to be passed as a parameter to the headerbefore script. \c Returns \c (string) - */ - descrToFuncMap[i].m_pFuncName="headerbeforepar"; // - descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdScripts; - ++i; - - /*! \page actions - - headerafterpar [s] sets/gets a string to be passed as a parameter to the headerafter script. \c Returns \c (string) - */ - descrToFuncMap[i].m_pFuncName="headerafterpar"; // - descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdScripts; - ++i; - - /*! \page actions - - enacallog [i] enables/disables logging of the parameters necessary for the energy calibration. 1 sets, 0 unsets. \c Returns \c (int) - */ - descrToFuncMap[i].m_pFuncName="encallog"; // - descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdScripts; - ++i; - - /*! \page actions - - angcallog [i] enables/disables logging of the parameters necessary for the angular calibration. 1 sets, 0 unsets. \c Returns \c (int) - */ - descrToFuncMap[i].m_pFuncName="angcallog"; // - descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdScripts; - ++i; - - /*! \page actions - - scan0script [s] sets/gets the script to be executed for the scan 0 level. \c none unsets. - */ - descrToFuncMap[i].m_pFuncName="scan0script"; // - descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdScans; - ++i; - - /*! \page actions - - scan0par [s] sets/gets a string to be passed as a parameter to the scan0script - */ - descrToFuncMap[i].m_pFuncName="scan0par"; // - descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdScans; - ++i; - - /*! \page actions - - scan0prec [i] sets/gets number of digits to be used for the scan0 variable in the file name. - */ - descrToFuncMap[i].m_pFuncName="scan0prec"; // - descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdScans; - ++i; - - /*! \page actions - - scan0steps [i [s0..sn-1]] sets/gets number of steps (int) of the scan0 level and their values (float). - */ - descrToFuncMap[i].m_pFuncName="scan0steps"; // - descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdScans; - ++i; - - - /*! \page actions - - scan0range [smin smax sstep] sets scan0 min, max and step, returns the number of steps and their values as scan0steps. - */ - descrToFuncMap[i].m_pFuncName="scan0range"; // - descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdScans; - ++i; - - /*! \page actions - - scan1script [s] sets/gets the script to be executed for the scan1 level. \c none unsets. - */ - descrToFuncMap[i].m_pFuncName="scan1script"; // - descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdScans; - ++i; - - /*! \page actions - - scan1par [s] sets/gets a string to be passed as a parameter to the scan1script - */ - descrToFuncMap[i].m_pFuncName="scan1par"; // - descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdScans; - ++i; - - /*! \page actions - - scan1prec [i] sets/gets number of digits to be used for the scan1 variable in the file name. - */ - descrToFuncMap[i].m_pFuncName="scan1prec"; // - descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdScans; - ++i; - - /*! \page actions - - scan1steps [i [s0..sn-1]] sets/gets number of steps (int) of the scan1 level and their values (float). - */ - descrToFuncMap[i].m_pFuncName="scan1steps"; // - descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdScans; - ++i; - - /*! \page actions - - scan1range [smin smax sstep] sets scan1 min, max and step, returns the number of steps and their values as scan1steps. - */ - descrToFuncMap[i].m_pFuncName="scan1range"; // - descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdScans; - ++i; - - - - - /* communication configuration */ /*! \page network Network @@ -2166,7 +1738,7 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) { /* receiver functions */ /*! \page receiver Receiver commands - Commands to configure the receiver. Not used in MYTHEN. + Commands to configure the receiver. */ /*! \page receiver @@ -2601,38 +2173,6 @@ string slsDetectorCommand::helpData(int narg, char *args[], int action){ } -string slsDetectorCommand::cmdFrame(int narg, char *args[], int action) { - - int b; -#ifdef VERBOSE - cout << string("Executing command ")+string(args[0])+string(" ( ")+cmd+string(" )\n"); -#endif - if (action==PUT_ACTION) { - return string("cannot set"); - } else if (action==HELP_ACTION) { - return helpFrame(narg,args,HELP_ACTION); - } else { - b=myDet->setThreadedProcessing(-1); - myDet->setThreadedProcessing(0); - myDet->setOnline(ONLINE_FLAG); - myDet->setReceiverOnline(ONLINE_FLAG); - myDet->readFrame(); - //processdata in receiver is useful only for gui purposes - if(myDet->setReceiverOnline()==OFFLINE_FLAG) - myDet->processData(1); - myDet->setThreadedProcessing(b); - return string("ok"); - } - -} - -string slsDetectorCommand::helpFrame(int narg, char *args[], int action) { - - if (action==PUT_ACTION) - return string(""); - return string("frame \t gets a single frame from the detector (if any) processes it and writes it to file according to the preferences already setup\n"); - -} string slsDetectorCommand::cmdStatus(int narg, char *args[], int action) { @@ -2848,70 +2388,6 @@ string slsDetectorCommand::helpUser(int narg, char *args[], int action){ -string slsDetectorCommand::cmdMaster(int narg, char *args[], int action){ -#ifdef VERBOSE - cout << string("Executing command ")+string(args[0])+string(" ( ")+cmd+string(" )\n"); - -#endif - - ostringstream os; - int ival; - - - if (action==HELP_ACTION) { - return helpMaster(narg,args,HELP_ACTION); - } - myDet->setOnline(ONLINE_FLAG); - if (action==PUT_ACTION) { - istringstream vvstr(args[1]); - vvstr >> ival; - if (vvstr.fail()) - return helpMaster(narg,args,HELP_ACTION); - myDet->setMaster(ival); - } - os << myDet->setMaster(); - return os.str(); - -} - - -string slsDetectorCommand::helpMaster(int narg, char *args[], int action){ - - ostringstream os; - if (action==GET_ACTION || action==HELP_ACTION) - os << string("master \t gets the master of the detector structure (-1 if none)\n"); - if (action==PUT_ACTION || action==HELP_ACTION) - os << string("master pos \t sets position of the master of the detector structure (-1 if none) \n"); - return os.str(); - -} - -string slsDetectorCommand::cmdSync(int narg, char *args[], int action){ -#ifdef VERBOSE - cout << string("Executing command ")+string(args[0])+string(" ( ")+cmd+string(" )\n"); -#endif - - if (action==HELP_ACTION) { - return helpSync(narg,args,HELP_ACTION); - } - myDet->setOnline(ONLINE_FLAG); - if (action==PUT_ACTION) { - if (myDet->getSyncType(string(args[1]))==GET_SYNCHRONIZATION_MODE) return helpSync(narg,args, action); - myDet->setSynchronization(myDet->getSyncType(string(args[1]))); - } - return myDet->getSyncType(myDet->setSynchronization()); - -} -string slsDetectorCommand::helpSync(int narg, char *args[], int action){ - - ostringstream os; - if (action==GET_ACTION || action==HELP_ACTION) - os << string("sync \t gets the synchronization mode of the structure\n"); - if (action==PUT_ACTION || action==HELP_ACTION) - os << string("sync mode \t sets synchronization mode of the structure. Cane be none, gating, trigger, complementary \n"); - return os.str(); -} - string slsDetectorCommand::cmdHelp(int narg, char *args[], int action){ #ifdef VERBOSE cout << string("Executing command ")+string(args[0])+string(" ( ")+cmd+string(" )\n"); @@ -3118,7 +2594,7 @@ string slsDetectorCommand::cmdFileName(int narg, char *args[], int action){ } return myDet->fileFormats(myDet->getFileFormat()); } - return string(myDet->getCurrentFileName()); + return string("unknown command") + cmd; } @@ -3233,83 +2709,6 @@ string slsDetectorCommand::helpFileIndex(int narg, char *args[], int action){ } -string slsDetectorCommand::cmdFlatField(int narg, char *args[], int action){ - - if (action==HELP_ACTION) { - return helpFlatField(narg, args, action); - } - string sval; - - if (string(args[0])==string("ffdir")) { - if (action==PUT_ACTION) { - sval=string(args[1]); - if (sval=="none") - sval=""; - myDet->setFlatFieldCorrectionDir(sval); - } - return string(myDet->getFlatFieldCorrectionDir()); - - } else if (string(args[0])==string("flatfield")) { - - if (action==PUT_ACTION) { - sval=string(args[1]); - if (sval=="none") - sval=""; - myDet->setFlatFieldCorrection(sval); - return string(myDet->getFlatFieldCorrectionFile()); - - } else {// if (action==GET_ACTION) { - if (narg>1) - sval=string(args[1]); - else - sval="none"; - // cout << myDet->getMaxNumberOfChannels() << endl; - double corr[ myDet->getMaxNumberOfChannels()], ecorr[myDet->getMaxNumberOfChannels()]; - if (myDet->getFlatFieldCorrection(corr,ecorr)) { - if (sval!="none") { - myDet->writeDataFile(sval,corr,ecorr,NULL,'i'); - return sval; - } - return string(myDet->getFlatFieldCorrectionFile()); - } else { - return string("none"); - } - } - } - return string("could not decode flat field action ")+cmd; - -} - - -string slsDetectorCommand::helpFlatField(int narg, char *args[], int action){ - - int t=0; - ostringstream os; - if (string(args[0])==string("ffdir")) { - t=1; - } else if (string(args[0])==string("flatfield")) { - t=2; - } - if (t!=1) { - - if (action==GET_ACTION || action==HELP_ACTION) { - os << string("flatfield [fn]\t gets the flat field file name. the coorection values and errors can be dumped to fn if specified. \n"); - } if (action==PUT_ACTION || action==HELP_ACTION) - os << string("flatfield s \t sets the flat field file name\n"); - } - if (t!=2) { - - if (action==GET_ACTION || action==HELP_ACTION) - os << string("ffdir \t gets the path for the flat field files \n"); - if (action==PUT_ACTION || action==HELP_ACTION) - os << string("ffdir s \t sets the path for flat field files\n"); - } - return os.str(); - -} - - - string slsDetectorCommand::cmdRateCorr(int narg, char *args[], int action){ @@ -3348,195 +2747,6 @@ string slsDetectorCommand::helpRateCorr(int narg, char *args[], int action){ - -string slsDetectorCommand::cmdBadChannels(int narg, char *args[], int action){ - - string sval; - - if (action==HELP_ACTION) { - return helpBadChannels(narg, args, action); - } - if (action==PUT_ACTION) { - sval=string(args[1]); - if (sval=="none") - sval=""; - myDet->setBadChannelCorrection(sval); - } else if (action==GET_ACTION) { - if (narg>1) - sval=string(args[1]); - else - sval="none"; - int bch[myDet->getMaxNumberOfChannels()], nbch; - if ((nbch=myDet->getBadChannelCorrection(bch))) { - if (sval!="none") { - ofstream outfile; - outfile.open (sval.c_str(),ios_base::out); - if (outfile.is_open()) { - for (int ich=0; ichgetBadChannelCorrectionFile()); - -} - - -string slsDetectorCommand::helpBadChannels(int narg, char *args[], int action){ - ostringstream os; - if (action==GET_ACTION || action==HELP_ACTION) - os << string("badchannels [fn]\t returns the badchannels file. Prints the list of bad channels in fn, if specified. \n"); - if (action==PUT_ACTION || action==HELP_ACTION) - os << string("badchannels \t sets the bad channels list\n"); - - return os.str(); -} - - - -string slsDetectorCommand::cmdAngConv(int narg, char *args[], int action){ - - if (action==HELP_ACTION) { - return helpAngConv(narg, args, action); - } - string sval; - char answer[1000]; - double fval; - angleConversionParameter c; - - if (string(args[0])==string("angconv")) { - if (action==PUT_ACTION) { - sval=string(args[1]); - - if (sval=="none") - sval=""; - - myDet->setAngularConversionFile(sval); - - return string(myDet->getAngularConversionFile()); - } else if (action==GET_ACTION) { - if (narg>1) - sval=string(args[1]); - else - sval="none"; - int dir; - if (myDet->getAngularConversion(dir)) { - if (sval!="none") { - myDet->writeAngularConversion(sval.c_str()); - return sval; - } - return string(myDet->getAngularConversionFile()); - } else { - return string("none"); - } - } - } else if (string(args[0])==string("globaloff")) { - c=GLOBAL_OFFSET; - - - } else if (string(args[0])==string("fineoff")) { - c=FINE_OFFSET; - - - } else if (string(args[0])==string("binsize")) { - c=BIN_SIZE; - - } else if (string(args[0])==string("angdir")) { - c=ANGULAR_DIRECTION; - - } else if (string(args[0])==string("moveflag")) { - c=MOVE_FLAG; - } else if (string(args[0])==string("samplex")) { - c=SAMPLE_X; - } else if (string(args[0])==string("sampley")) { - c=SAMPLE_Y; - } - - - else - return string("could not decode angular conversion parameter ")+cmd; - - - - if (action==PUT_ACTION) { - if (sscanf(args[1],"%lf",&fval)) - myDet->setAngularConversionParameter(c,fval); - } - sprintf(answer,"%f",myDet->getAngularConversionParameter(c)); - return string(answer); - - -} - - -string slsDetectorCommand::helpAngConv(int narg, char *args[], int action){ - - - int t=0xffff; - ostringstream os; - - if (string(args[0])==string("angconv")) { - t=1; - } else if (string(args[0])==string("globaloff")) { - t=2; - } else if (string(args[0])==string("fineoff")) { - t=4; - } else if (string(args[0])==string("binsize")) { - t=8; - } else if (string(args[0])==string("samplex")) { - t=16; - } else if (string(args[0])==string("sampley")) { - t=32; - } - if (t&1) { - if (action==GET_ACTION || action==HELP_ACTION) - os << string("angconv [fn]\t returns the constants used for angular conversion prints them to the file fn if specified \n"); - if (action==PUT_ACTION || action==HELP_ACTION) - os << string("angconv fn\t sets the angualr conversion constants (none unsets) \n"); - } if (t&2) { - if (action==GET_ACTION || action==HELP_ACTION) - os << string("globaloff\t returns the global offset used for angular conversion \n"); - if (action==PUT_ACTION || action==HELP_ACTION) - os << string("globaloff f\t sets the global offset used for the angular conversion \n"); - - - } if (t&4) { - if (action==GET_ACTION || action==HELP_ACTION) - os << string("fineoff\t returns the fine offset used for angular conversion \n"); - if (action==PUT_ACTION || action==HELP_ACTION) - os << string("fineoff f\t sets the fine offset used for the angular conversion \n"); - - - - } if (t&8) { - if (action==GET_ACTION || action==HELP_ACTION) - os << string("binsize\t returns the bin size used for the angular conversion \n"); - if (action==PUT_ACTION || action==HELP_ACTION) - os << string("binsize f\t sets the bin size used for the angular conversion \n"); - - } - if (t&16) { - if (action==GET_ACTION || action==HELP_ACTION) - os << string("samplex \t gets the sample displacement in th direction parallel to the beam \n"); - if (action==PUT_ACTION || action==HELP_ACTION) - os << string("samplex f\t sets the sample displacement in th direction parallel to the beam \n"); - } - if (t&32) { - if (action==GET_ACTION || action==HELP_ACTION) - os << string("sampley \t gets the sample displacement in the direction orthogonal to the beam \n"); - if (action==PUT_ACTION || action==HELP_ACTION) - os << string("sampley f\t sets the sample displacement in the direction orthogonal to the beam \n"); - } - - return os.str(); -} - - string slsDetectorCommand::cmdThreaded(int narg, char *args[], int action){ int ival; char answer[1000]; @@ -3671,343 +2881,6 @@ string slsDetectorCommand::helpCounter(int narg, char *args[], int action){ -string slsDetectorCommand::cmdPositions(int narg, char *args[], int action){ - int ival; - int ip; - - char answer[1000]; - - if (action==HELP_ACTION) return helpPositions(narg,args,action); - - if (action==PUT_ACTION) { - if (sscanf(args[1],"%d",&ival)) { - double pos[ival]; - for (ip=0; ipsetPositions(ip,pos); - } - } - int npos=myDet->getPositions(); - sprintf(answer,"%d",npos); - double opos[npos]; - myDet->getPositions(opos); - for (int ip=0; ipsetActionParameter(ia, args[1]); - } - return string(myDet->getActionParameter(ia)); - - } else { - - if (ia==enCalLog || ia==angCalLog) { - - - if (action==PUT_ACTION) { - - int arg=-1; - - - sscanf(args[1],"%d",&arg); - - if (arg==0) - myDet->setActionScript(ia,"none"); - else - myDet->setActionScript(ia,args[1]); - - } - - sprintf(answer,"%d",myDet->getActionMode(ia)); - return string(answer); - - } - - - if (action==PUT_ACTION) { - myDet->setActionScript(ia, args[1]); - } - return string(myDet->getActionScript(ia)); - - } - return string("could not decode command")+cmd; - - - - -} - -string slsDetectorCommand::helpScripts(int narg, char *args[], int action) { - - ostringstream os; - - if (narg>0) { - if ((string(args[0]).find("start")!=string::npos) || (string(args[0]).find("stop")!=string::npos) || (string(args[0]).find("scriptbefore")!=string::npos) || \ - (string(args[0]).find("scriptafter")!=string::npos) || (string(args[0]).find("headerafter")!=string::npos) || (string(args[0]).find("headerbefore")!=string::npos)) { - - - if (action==PUT_ACTION || action==HELP_ACTION) - os << args[0] << " script \t sets the script to execute for the corresponding action"<< std::endl; - if (action==GET_ACTION || action==HELP_ACTION) - os << args[0] << " \t returns the script to execute for the corresponding action"<< std::endl; - - } - - - if ((string(args[0]).find("encallog")!=string::npos) || (string(args[0]).find("angcallog")!=string::npos)) { - - - - if (action==PUT_ACTION || action==HELP_ACTION) - os << args[0] << " i \t enables (1) or disables (0) the logging for the calibration"<< std::endl; - if (action==GET_ACTION || action==HELP_ACTION) - os << args[0] << " \t returns the calibration log mode"<< std::endl; - } - } - return os.str(); - -} - -string slsDetectorCommand::cmdScans(int narg, char *args[], int action) { - - int is=-1, ival, ns=0; - char answer[MAX_SCAN_STEPS*10]; - double *values; - if (action==HELP_ACTION) - return helpScans(narg,args,action); - - - if (cmd.find("0")!=string::npos) is=0; - else if (cmd.find("1")!=string::npos) is=1; - else return string("cannot define scan level ")+cmd; - - if (cmd.find("par")!=string::npos) { - if (action==PUT_ACTION) { - myDet->setScanParameter(is, args[1]); - } - return myDet->getScanParameter(is); - } - if (cmd.find("script")!=string::npos) { - if (action==PUT_ACTION) { - myDet->setScanScript(is, args[1]); - } - return myDet->getScanScript(is); - } - if (cmd.find("prec")!=string::npos) { - if (action==PUT_ACTION) { - if (sscanf(args[1],"%d",&ival)) { - myDet->setScanPrecision(is, ival); - } else - return string("invalid precision ")+cmd; - } - sprintf(answer,"%d", myDet->getScanPrecision(is)); - return string(answer); - } - if (cmd.find("steps")!=string::npos) { - - if (action==PUT_ACTION) { - if (sscanf(args[1],"%d",&ival)) { - - if (ival>MAX_SCAN_STEPS) - return string("too many steps required!"); - - values=new double[ival]; - for (int i=0; i=(i+2)) { - if (sscanf(args[i+2],"%lf",values+i)) - ++ns; - else - break; - } else - break; - } - myDet->setScanSteps(is, ns, values); - delete [] values; - } else { - return string("invalid number of steps ")+string(args[1]); - } - } - ns=myDet->getScanSteps(is); - sprintf(answer,"%d ",ns); - if (ns>0) { - values=new double[ns]; - ns=myDet->getScanSteps(is, values); - int p=myDet->getScanPrecision(is); - char format[1000]; - sprintf(format, "%%s %%0.%df",p); - for (int i=0; iMAX_SCAN_STEPS) - return string("too many steps required!"); - - if (fmax>fmin) - if (fstep<0) - fstep=-1*fstep; - - if (fmax0) - fstep=-1*fstep; - - - values=new double[ns]; - for (int i=0; isetScanSteps(is, ns, values); - delete [] values; - } - - ns=myDet->getScanSteps(is); - values=new double[ns]; - ns=myDet->getScanSteps(is, values); - int p=myDet->getScanPrecision(is); - char format[1000]; - sprintf(format, "%%s %%0.%df",p); - sprintf(answer,"%d ",ns); - for (int i=0; isetReceiverOnline(ONLINE_FLAG); if (action==PUT_ACTION) { - if (cmd=="maxmod") - return string("cannot put!"); - else if (cmd=="roimask"){ - if (!sscanf(args[1],"%d",&val)) - return string("could not scan ")+string(args[0])+string(" ")+string(args[1]); - } - else if (!sscanf(args[1],"%d",&val)) + if (!sscanf(args[1],"%d",&val)) return string("could not scan ")+string(args[0])+string(" ")+string(args[1]); if (cmd=="roi"){ @@ -4525,11 +3392,7 @@ string slsDetectorCommand::cmdDetectorSize(int narg, char *args[], int action) { } - if (cmd=="nmod" || cmd=="roimask") { - ret=myDet->setNumberOfModules(val); - } else if (cmd=="maxmod") { - ret=myDet->getMaxNumberOfModules(); - } else if (cmd=="dr") { + if (cmd=="dr") { myDet->setReceiverOnline(ONLINE_FLAG); ret=myDet->setDynamicRange(val); } else if (cmd=="roi") { @@ -4557,10 +3420,7 @@ string slsDetectorCommand::cmdDetectorSize(int narg, char *args[], int action) { else return string("unknown command ")+cmd; - if (cmd=="roimask") - sprintf(ans,"0x%x",ret); - else - sprintf(ans,"%d",ret); + sprintf(ans,"%d",ret); return string(ans); @@ -4571,7 +3431,6 @@ string slsDetectorCommand::helpDetectorSize(int narg, char *args[], int action) ostringstream os; if (action==PUT_ACTION || action==HELP_ACTION) { - os << "nmod i \n sets the number of modules of the detector"<< std::endl; os << "dr i \n sets the dynamic range of the detector"<< std::endl; os << "roi i xmin xmax ymin ymax \n sets region of interest where i is number of rois;i=0 to clear rois"<< std::endl; os << "detsizechan x y \n sets the maximum number of channels for complete detector set in both directions; -1 is no limit"<< std::endl; @@ -4580,8 +3439,6 @@ string slsDetectorCommand::helpDetectorSize(int narg, char *args[], int action) os << "gappixels i \n enables/disables gap pixels in system (detector & receiver). 1 sets, 0 unsets. Used in EIGER only and multidetector level." << std::endl; } if (action==GET_ACTION || action==HELP_ACTION) { - os << "nmod \n gets the number of modules of the detector"<< std::endl; - os << "maxmod \n gets the maximum number of modules of the detector"<< std::endl; os << "dr \n gets the dynamic range of the detector"<< std::endl; os << "roi \n gets region of interest"<< std::endl; os << "detsizechan \n gets the maximum number of channels for complete detector set in both directions; -1 is no limit"<< std::endl; @@ -4679,44 +3536,6 @@ string slsDetectorCommand::cmdSettings(int narg, char *args[], int action) { else return string("not successful"); } return myDet->getSettingsFile(); - } else if (cmd=="trim") { - if (action==GET_ACTION) - return string("cannot get!"); - - trimMode mode=NOISE_TRIMMING; - int par1=0, par2=0; - if (string(args[0]).find("trim:")==string::npos) - return helpSettings(narg,args,action); - else if (string(args[0]).find("noise")!=string::npos) { - // par1 is countlim; par2 is nsigma - mode=NOISE_TRIMMING; - par1=500; - par2=4; - } else if (string(args[0]).find("beam")!=string::npos){ - // par1 is countlim; par2 is nsigma - mode=BEAM_TRIMMING; - par1=1000; - par2=4; - } else if (string(args[0]).find("improve")!=string::npos) { - // par1 is maxit; if par2!=0 vthresh will be optimized - mode=IMPROVE_TRIMMING; - par1=5; - par2=0; - } else if (string(args[0]).find("fix")!=string::npos) { - // par1 is countlim; if par2<0 then trimwithlevel else trim with median - mode=FIXEDSETTINGS_TRIMMING; - par1=1000; - par2=1; - // }else if (string(args[0]).find("fix")!=string::npos) { - //mode=OFFLINE_TRIMMING; - } else { - return string("Unknown trim mode ")+cmd; - } - myDet->executeTrimming(mode, par1, par2); - string sval=string(args[1]); - myDet->saveSettingsFile(sval, -1); - return string("done"); - } else if (cmd=="trimval") { if (action==PUT_ACTION){ if (sscanf(args[1],"%d",&val)) @@ -4750,7 +3569,6 @@ string slsDetectorCommand::helpSettings(int narg, char *args[], int action) { os << "threshold eV [sett]\n sets the detector threshold in eV. If sett is provided for eiger, uses settings sett"<< std::endl; os << "thresholdnotb eV [sett]\n sets the detector threshold in eV without loading trimbits. If sett is provided for eiger, uses settings sett"<< std::endl; os << "trimbits fname\n loads the trimfile fname to the detector. If no extension is specified, the serial number of each module will be attached."<< std::endl; - os << "trim:mode fname\n trims the detector according to mode (can be noise, beam, improve, fix) and saves the resulting trimbits to file fname."<< std::endl; os << "trimval i \n sets all the trimbits to i" << std::endl; os << "pedestal i \n starts acquisition for i frames, calculates pedestal and writes back to fpga."<< std::endl; @@ -4801,18 +3619,6 @@ string slsDetectorCommand::cmdSN(int narg, char *args[], int action) { myDet->setOnline(ONLINE_FLAG); - if (cmd=="moduleversion") { - int ival=-1; - if (sscanf(args[0],"moduleversion:%d",&ival)) { - int64_t retval = myDet->getId(MODULE_FIRMWARE_VERSION, ival); - if (retval < 0) - sprintf(answer, "%d", -1); - else - sprintf(answer,"0x%lx", retval); - return string(answer); - } else - return string("undefined module number"); - } if (cmd=="detectornumber") { int64_t retval = myDet->getId(DETECTOR_SERIAL_NUMBER); if (retval < 0) @@ -4821,18 +3627,6 @@ string slsDetectorCommand::cmdSN(int narg, char *args[], int action) { sprintf(answer,"0x%lx", retval); return string(answer); } - if (cmd.find("modulenumber")!=string::npos) { - int ival=-1; - if (sscanf(args[0],"modulenumber:%d",&ival)) { - int64_t retval = myDet->getId(MODULE_SERIAL_NUMBER, ival); - if (retval < 0) - sprintf(answer, "%d", -1); - else - sprintf(answer,"0x%lx", retval); - return string(answer); - } else - return string("undefined module number"); - } if (cmd=="detectorversion") { int64_t retval = myDet->getId(DETECTOR_FIRMWARE_VERSION); @@ -4889,8 +3683,6 @@ string slsDetectorCommand::helpSN(int narg, char *args[], int action) { if (action==GET_ACTION || action==HELP_ACTION) { os << "checkdetversion \n gets the version compatibility with detector server (if hostname is in shared memory). Only for Eiger, Jungfrau & Gotthard. Prints compatible/ incompatible."<< std::endl; os << "checkrecversion \n gets the version compatibility with receiver server (if rx_hostname is in shared memory). Only for Eiger, Jungfrau & Gotthard. Prints compatible/ incompatible."<< std::endl; - os << "moduleversion:i \n gets the firmwareversion of the module i"<< std::endl; - os << "modulenumber:i \n gets the serial number of the module i"<< std::endl; os << "detectornumber \n gets the serial number of the detector (MAC)"<< std::endl; os << "detectorversion \n gets the firmware version of the detector"<< std::endl; os << "softwareversion \n gets the software version of the detector"<< std::endl; @@ -4914,13 +3706,6 @@ string slsDetectorCommand::cmdDigiTest(int narg, char *args[], int action) { myDet->setOnline(ONLINE_FLAG); - if (cmd=="bustest"){ - if (action==PUT_ACTION) - return string("cannot set ")+cmd; - sprintf(answer,"0x%x",myDet->digitalTest(DETECTOR_BUS_TEST)); - return string(answer); - } - if (cmd=="digitest") { if (action==PUT_ACTION) return string("cannot set ")+cmd; @@ -4958,7 +3743,6 @@ string slsDetectorCommand::helpDigiTest(int narg, char *args[], int action) { ostringstream os; if (action==GET_ACTION || action==HELP_ACTION) { os << "digitaltest:i \t performs digital test of the module i. Returns 0 if succeeded, otherwise error mask."<< std::endl; - os << "bustest \t performs test of the bus interface between FPGA and embedded Linux system. Can last up to a few minutes."<< std::endl; } if (action==PUT_ACTION || action==HELP_ACTION) { os << "digibittest i\t will perform test which will plot the unique channel identifier, instead of data."<< std::endl; @@ -5157,24 +3941,6 @@ string slsDetectorCommand::cmdDAC(int narg, char *args[], int action) { else if (cmd=="ib_test_c") dac=G_IB_TESTC; - else if (cmd=="dac0") - dac=V_DAC0; - else if (cmd=="dac1") - dac=V_DAC1; - else if (cmd=="dac2") - dac=V_DAC2; - else if (cmd=="dac3") - dac=V_DAC3; - else if (cmd=="dac4") - dac=V_DAC4; - else if (cmd=="dac5") - dac=V_DAC5; - else if (cmd=="dac6") - dac=V_DAC6; - else if (cmd=="dac7") - dac=V_DAC7; - - else if (cmd== "vsvp") @@ -5332,15 +4098,6 @@ string slsDetectorCommand::helpDAC(int narg, char *args[], int action) { os << "ib_test_c " << "dacu\t sets ib_test_c" << std::endl; - os << "dac0 " << "dacu\t sets dac 0" << std::endl; - os << "dac1 " << "dacu\t sets dac 1" << std::endl; - os << "dac2 " << "dacu\t sets dac 2" << std::endl; - os << "dac3 " << "dacu\t sets dac 3" << std::endl; - os << "dac4 " << "dacu\t sets dac 4" << std::endl; - os << "dac5 " << "dacu\t sets dac 5" << std::endl; - os << "dac6 " << "dacu\t sets dac 6" << std::endl; - os << "dac7 " << "dacu\t sets dac 7" << std::endl; - os << "vsvp" << "dacu\t sets vsvp" << std::endl; os << "vsvn" << "dacu\t sets vsvn" << std::endl; os << "vtr" << "dacu\t sets vtr" << std::endl; @@ -5398,16 +4155,6 @@ string slsDetectorCommand::helpDAC(int narg, char *args[], int action) { os << "vref_comp " << "\t gets vref_comp" << std::endl; os << "ib_test_c " << "\t gets ib_test_c" << std::endl; - - os << "dac0 " << "\t gets dac 0" << std::endl; - os << "dac1 " << "\t gets dac 1" << std::endl; - os << "dac2 " << "\t gets dac 2" << std::endl; - os << "dac3 " << "\t gets dac 3" << std::endl; - os << "dac4 " << "\t gets dac 4" << std::endl; - os << "dac5 " << "\t gets dac 5" << std::endl; - os << "dac6 " << "\t gets dac 6" << std::endl; - os << "dac7 " << "\t gets dac 7" << std::endl; - os << "vsvp" << "dacu\t gets vsvp" << std::endl; os << "vsvn" << "dacu\t gets vsvn" << std::endl; os << "vtr" << "dacu\t gets vtr" << std::endl; @@ -5668,8 +4415,6 @@ string slsDetectorCommand::cmdTimer(int narg, char *args[], int action) { index=FRAME_NUMBER; else if (cmd=="cycles") index=CYCLES_NUMBER; - else if (cmd=="probes") - index=PROBES_NUMBER; else if (cmd=="measurements") index=MEASUREMENTS_NUMBER; else if (cmd=="samples") @@ -5737,7 +4482,6 @@ string slsDetectorCommand::helpTimer(int narg, char *args[], int action) { os << "delay t \t sets the delay after trigger in s" << std::endl; os << "frames t \t sets the number of frames per cycle (e.g. after each trigger)" << std::endl; os << "cycles t \t sets the number of cycles (e.g. number of triggers)" << std::endl; - os << "probes t \t sets the number of probes to accumulate (max 3! cycles should be set to 1, frames to the number of pump-probe events)" << std::endl; os << "samples t \t sets the number of samples expected from the jctb" << std::endl; os << "storagecells t \t sets number of storage cells per acquisition. For very advanced users only! For JUNGFRAU only. Range: 0-15. The #images = #frames * #cycles * (#storagecells+1)." << std::endl; os << "storagecell_start t \t sets the storage cell that stores the first acquisition of the series. Default is 15(0xf). For very advanced users only! For JUNGFRAU only. Range: 0-15." << std::endl; @@ -5754,7 +4498,6 @@ string slsDetectorCommand::helpTimer(int narg, char *args[], int action) { os << "delay \t gets the delay after trigger in s" << std::endl; os << "frames \t gets the number of frames per cycle (e.g. after each trigger)" << std::endl; os << "cycles \t gets the number of cycles (e.g. number of triggers)" << std::endl; - os << "probes \t gets the number of probes to accumulate" << std::endl; os << "samples \t gets the number of samples expected from the jctb" << std::endl; os << "storagecells \t gets number of storage cells per acquisition.For JUNGFRAU only." << std::endl; os << "storagecell_start \t gets the storage cell that stores the first acquisition of the series." << std::endl; @@ -5797,8 +4540,6 @@ string slsDetectorCommand::cmdTimeLeft(int narg, char *args[], int action) { index=FRAME_NUMBER; else if (cmd=="cyclesl") index=CYCLES_NUMBER; - else if (cmd=="probesl") - index=PROBES_NUMBER; else if (cmd=="now") index=ACTUAL_TIME; else if (cmd=="timestamp") @@ -5851,7 +4592,6 @@ string slsDetectorCommand::helpTimeLeft(int narg, char *args[], int action) { os << "delayl \t gets the delay left" << std::endl; os << "framesl \t gets the number of frames left" << std::endl; os << "cyclesl \t gets the number of cycles left" << std::endl; - os << "probesl \t gets the number of probes left" << std::endl; os << "measuredperiod \t gets the measured frame period (time between last frame and the previous one) in s. For Eiger only. Makes sense only for acquisitions of more than 1 frame." << std::endl; os << "measuredsubperiod \t gets the measured subframe period (time between last subframe and the previous one) in s. For Eiger only and in 32 bit mode." << std::endl; os << std::endl; @@ -5883,14 +4623,6 @@ string slsDetectorCommand::cmdSpeed(int narg, char *args[], int action) { if (cmd=="clkdivider") index=CLOCK_DIVIDER; - else if (cmd=="setlength") - index=SET_SIGNAL_LENGTH; - else if (cmd=="waitstates") - index=WAIT_STATES; - else if (cmd=="totdivider") - index=TOT_CLOCK_DIVIDER; - else if (cmd=="totdutycycle") - index=TOT_DUTY_CYCLE; else if (cmd=="phasestep") { index=PHASE_SHIFT; t=100000; @@ -5941,10 +4673,6 @@ string slsDetectorCommand::helpSpeed(int narg, char *args[], int action) { if (action==PUT_ACTION || action==HELP_ACTION) { os << "clkdivider c \t sets readout clock divider. For Jungfrau, it also overwrites adcphase to recommended default" << std::endl; - os << "setlength c\t sets the length of the set/reset signals (in clock cycles)" << std::endl; - os << "waitstates c \t sets the waitstates of the bus interface" << std::endl; - os << "totdivider c\t sets the clock divider in tot mode" << std::endl; - os << "totdutycycle c\t sets the duty cycle of the tot clock" << std::endl; os << "adcphase c\t Sets phase of the sampling clock. For JUNGFRAU, setting speed (clkdivider) overwrites adcphase to its default recommended value. (Not for EIGER)" << std::endl; os << std::endl; @@ -5952,11 +4680,7 @@ string slsDetectorCommand::helpSpeed(int narg, char *args[], int action) { if (action==GET_ACTION || action==HELP_ACTION) { os << "clkdivider \t gets readout clock divider. For Jungfrau, it also overwrites adcphase to recommended default" << std::endl; - os << "setlength \t gets the length of the set/reset signals (in clock cycles)" << std::endl; - os << "waitstates \t gets the waitstates of the bus interface" << std::endl; - os << "totdivider \t gets the clock divider in tot mode" << std::endl; - os << "totdutycycle \t gets the duty cycle of the tot clock" << std::endl; - os << "adcphase \t gets phase of the sampling clock. For JUNGFRAU, setting speed (clkdivider) overwrites adcphase to its default recommended value. (Not for EIGER)" << std::endl; + os << "adcphase \t gets phase of the sampling clock. For JUNGFRAU, setting speed (clkdivider) overwrites adcphase to its default recommended value. (Not for EIGER)" << std::endl; os << std::endl; } @@ -6328,17 +5052,6 @@ string slsDetectorCommand::cmdReceiver(int narg, char *args[], int action) { sprintf(answer,"%d",myDet->setReadReceiverFrequency()); return string(answer); - } - else if(cmd=="r_compression"){ - if (action==PUT_ACTION){ - if (!sscanf(args[1],"%d",&ival)) - return string("Could not scan receiver compression input ")+string(args[1]); - if(ival>=0) - sprintf(answer,"%d",myDet->enableReceiverCompression(ival)); - }else - sprintf(answer,"%d",myDet->enableReceiverCompression()); - return string(answer); - } else if(cmd=="tengiga"){ diff --git a/slsDetectorSoftware/slsDetector/slsDetectorCommand.h b/slsDetectorSoftware/slsDetector/slsDetectorCommand.h index a4a43e2a4..b02dcbe32 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorCommand.h +++ b/slsDetectorSoftware/slsDetector/slsDetectorCommand.h @@ -36,14 +36,11 @@ class slsDetectorCommand : public virtual slsDetectorDefs { std::string helpLine(int narg, char *args[], int action=HELP_ACTION); static std::string helpAcquire(int narg, char *args[], int action); static std::string helpData(int narg, char *args[], int action); - static std::string helpFrame(int narg, char *args[], int action); static std::string helpStatus(int narg, char *args[], int action); static std::string helpDataStream(int narg, char *args[], int action); static std::string helpFree(int narg, char *args[], int action); static std::string helpHostname(int narg, char *args[], int action); static std::string helpUser(int narg, char *args[], int action); - static std::string helpMaster(int narg, char *args[], int action); - static std::string helpSync(int narg, char *args[], int action); static std::string helpExitServer(int narg, char *args[], int action); static std::string helpSettingsDir(int narg, char *args[], int action); static std::string helpCalDir(int narg, char *args[], int action); @@ -51,14 +48,8 @@ class slsDetectorCommand : public virtual slsDetectorDefs { static std::string helpOutDir(int narg, char *args[], int action); static std::string helpFileName(int narg, char *args[], int action); static std::string helpFileIndex(int narg, char *args[], int action); - static std::string helpFlatField(int narg, char *args[], int action); static std::string helpRateCorr(int narg, char *args[], int action); - static std::string helpBadChannels(int narg, char *args[], int action); - static std::string helpAngConv(int narg, char *args[], int action); static std::string helpThreaded(int narg, char *args[], int action); - static std::string helpPositions(int narg, char *args[], int action); - static std::string helpScripts(int narg, char *args[], int action); - static std::string helpScans(int narg, char *args[], int action); static std::string helpNetworkParameter(int narg, char *args[], int action); static std::string helpPort(int narg, char *args[], int action); static std::string helpLock(int narg, char *args[], int action); @@ -107,14 +98,11 @@ class slsDetectorCommand : public virtual slsDetectorDefs { std::string cmdUnknown(int narg, char *args[], int action); std::string cmdAcquire(int narg, char *args[], int action); std::string cmdData(int narg, char *args[], int action); - std::string cmdFrame(int narg, char *args[], int action); std::string cmdStatus(int narg, char *args[], int action); std::string cmdDataStream(int narg, char *args[], int action); std::string cmdFree(int narg, char *args[], int action); std::string cmdHostname(int narg, char *args[], int action); std::string cmdUser(int narg, char *args[], int action); - std::string cmdMaster(int narg, char *args[], int action); - std::string cmdSync(int narg, char *args[], int action); std::string cmdHelp(int narg, char *args[], int action); std::string cmdExitServer(int narg, char *args[], int action); std::string cmdSettingsDir(int narg, char *args[], int action); @@ -123,14 +111,8 @@ class slsDetectorCommand : public virtual slsDetectorDefs { std::string cmdOutDir(int narg, char *args[], int action); std::string cmdFileName(int narg, char *args[], int action); std::string cmdFileIndex(int narg, char *args[], int action); - std::string cmdFlatField(int narg, char *args[], int action); std::string cmdRateCorr(int narg, char *args[], int action); - std::string cmdBadChannels(int narg, char *args[], int action); - std::string cmdAngConv(int narg, char *args[], int action); std::string cmdThreaded(int narg, char *args[], int action); - std::string cmdPositions(int narg, char *args[], int action); - std::string cmdScripts(int narg, char *args[], int action); - std::string cmdScans(int narg, char *args[], int action); std::string cmdNetworkParameter(int narg, char *args[], int action); std::string cmdPort(int narg, char *args[], int action); std::string cmdLock(int narg, char *args[], int action); diff --git a/slsDetectorSoftware/slsDetector/slsDetectorUsers.cpp b/slsDetectorSoftware/slsDetector/slsDetectorUsers.cpp index b76d9da18..0b16a636e 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorUsers.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetectorUsers.cpp @@ -72,55 +72,14 @@ int slsDetectorUsers::setFileIndex(int i){ return (int)myDetector->setFileIndex(i); } -string slsDetectorUsers::getFlatFieldCorrectionDir(){ - return myDetector->getFlatFieldCorrectionDir(); -} - -string slsDetectorUsers::setFlatFieldCorrectionDir(string dir){ - return myDetector->setFlatFieldCorrectionDir(dir); -} - -string slsDetectorUsers::getFlatFieldCorrectionFile(){ - return myDetector->getFlatFieldCorrectionFile(); -} - -int slsDetectorUsers::setFlatFieldCorrectionFile(string fname){ - return myDetector->setFlatFieldCorrectionFile(fname); -} - -int slsDetectorUsers::enableFlatFieldCorrection(int i){ - return myDetector->enableFlatFieldCorrection(i); -} - int slsDetectorUsers::enableCountRateCorrection(int i){ return myDetector->enableCountRateCorrection(i); } -int slsDetectorUsers::enablePixelMaskCorrection(int i){ - return myDetector->enablePixelMaskCorrection(i); -} -int slsDetectorUsers::enableAngularConversion(int i){ - return myDetector->enableAngularConversion(i); -} int slsDetectorUsers::enableWriteToFile(int i){ return myDetector->enableWriteToFile(i); } -int slsDetectorUsers::setPositions(int nPos, double *pos){ - return myDetector->setPositions(nPos, pos); -} - -int slsDetectorUsers::getPositions(double *pos){ - return myDetector->getPositions(pos); -} - -int slsDetectorUsers::setDetectorSize(int x0, int y0, int nx, int ny){ - if(myDetector->getTotalNumberOfChannels(slsDetectorDefs::Y)>1) - return 1; - int nmod=nx/(myDetector->getChansPerMod(0)); - cout << myDetector->getChansPerMod(0) << " " << nx << " " << nmod << endl; - return myDetector->setNumberOfModules(nmod)*myDetector->getChansPerMod(0);} - int slsDetectorUsers::getDetectorSize(int &x0, int &y0, int &nx, int &ny){ y0=0; x0=0; @@ -226,19 +185,6 @@ string slsDetectorUsers::getDetectorType(){ return myDetector->sgetDetectorsType(); } -void slsDetectorUsers::initDataset(int refresh){ - myDetector->initDataset(refresh); -} - -void slsDetectorUsers::addFrame(double *data, double pos, double i0, double t, string fname, double var){ - myDetector->addFrame(data,pos,i0,t,fname,var); -} - - -void slsDetectorUsers::finalizeDataset(double *a, double *v, double *e, int &np){ - myDetector->finalizeDataset(a, v, e, np); -} - int slsDetectorUsers::setReceiverMode(int n){ return myDetector->setReadReceiverFrequency(n); } @@ -267,14 +213,6 @@ string slsDetectorUsers::setClientDataStreamingInIP(string ip){ return myDetector->setClientDataStreamingInIP(ip); } -int64_t slsDetectorUsers::getModuleFirmwareVersion(){ - return myDetector->getModuleFirmwareVersion(); -} - -int64_t slsDetectorUsers::getModuleSerialNumber(int imod){ - return myDetector->getModuleSerialNumber(imod); -} - int64_t slsDetectorUsers::getDetectorFirmwareVersion(){ return myDetector->getDetectorFirmwareVersion(); } @@ -337,39 +275,10 @@ void slsDetectorUsers::registerDataCallback(int( *userCallback)(detectorData*, i myDetector->registerDataCallback(userCallback,pArg); } -void slsDetectorUsers::registerRawDataCallback(int( *userCallback)(double*, int, void*), void *pArg){ - myDetector->registerRawDataCallback(userCallback,pArg); -} - void slsDetectorUsers::registerAcquisitionFinishedCallback(int( *func)(double,int, void*), void *pArg){ myDetector->registerAcquisitionFinishedCallback(func,pArg); } -void slsDetectorUsers::registerGetPositionCallback( double (*func)(void*),void *arg){ - myDetector->registerGetPositionCallback(func,arg); -} - -void slsDetectorUsers::registerConnectChannelsCallback( int (*func)(void*),void *arg){ - myDetector->registerConnectChannelsCallback(func,arg); -} - -void slsDetectorUsers::registerDisconnectChannelsCallback( int (*func)(void*),void *arg){ - myDetector->registerDisconnectChannelsCallback(func,arg); -} - -void slsDetectorUsers::registerGoToPositionCallback( int (*func)(double,void*),void *arg){ - myDetector->registerGoToPositionCallback(func,arg); -} - -void slsDetectorUsers::registerGoToPositionNoWaitCallback( int (*func)(double,void*),void *arg){ - myDetector->registerGoToPositionNoWaitCallback(func,arg); -} - -void slsDetectorUsers::registerGetI0Callback( double (*func)(int,void*),void *arg){ - myDetector->registerGetI0Callback(func,arg); -} - - string slsDetectorUsers::putCommand(int narg, char *args[], int pos){ if(narg < 2) return string("Error: Insufficient Parameters"); @@ -455,8 +364,8 @@ int slsDetectorUsers::setTenGigabitEthernet(int i) { return myDetector->enableTenGigabitEthernet(i); } -int slsDetectorUsers::getNMods() { - return myDetector->getNMods(); +int slsDetectorUsers::getNumberOfDetectors() { + return myDetector->getNumberOfDetectors(); } double slsDetectorUsers::setSubFrameExposureTime(double t, bool inseconds, int imod){ diff --git a/slsDetectorSoftware/slsDetector/slsDetectorUsers.h b/slsDetectorSoftware/slsDetector/slsDetectorUsers.h index f9976a70b..1ca5e633b 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorUsers.h +++ b/slsDetectorSoftware/slsDetector/slsDetectorUsers.h @@ -62,7 +62,6 @@ You can find examples of how this classes can be instatiated in mainClient.cpp \authors Anna Bergamaschi, Dhanya Thattil @version 3.0

Currently supported detectors

-\li MYTHEN \li GOTTHARD controls \li GOTTHARD data receiver \li EIGER @@ -171,41 +170,6 @@ class slsDetectorUsers */ int setFileIndex(int i); - /** - @short get flat field corrections file directory - \returns flat field correction file directory - */ - std::string getFlatFieldCorrectionDir(); - - /** - @short set flat field corrections file directory - \param dir flat field correction file directory - \returns flat field correction file directory - */ - std::string setFlatFieldCorrectionDir(std::string dir); - - /** - @short get flat field corrections file name - \returns flat field correction file name - */ - std::string getFlatFieldCorrectionFile(); - - /** - @short set flat field correction file - \param fname name of the flat field file (or "" if disable) - \returns 0 if disable (or file could not be read), >0 otherwise - */ - int setFlatFieldCorrectionFile(std::string fname=""); - - - - /** - @short enable/disable flat field corrections (without changing file name) - \param i 0 disables, 1 enables, -1 gets - \returns 0 if ff corrections disabled, 1 if enabled - */ - int enableFlatFieldCorrection(int i=-1); - /** @short enable/disable count rate corrections \param i 0 disables, 1 enables with default values, -1 gets @@ -213,49 +177,10 @@ class slsDetectorUsers */ int enableCountRateCorrection(int i=-1); - /** - @short enable/disable bad channel corrections - \param i 0 disables, 1 enables, -1 gets - \returns 0 if bad channels corrections disabled, 1 if enabled - */ - int enablePixelMaskCorrection(int i=-1); - - /** - @short enable/disable angular conversion - \param i 0 disables, 1 enables, -1 gets - \returns 0 if angular conversion disabled, 1 if enabled - */ - int enableAngularConversion(int i=-1); - /**Enable write file function included*/ int enableWriteToFile(int i=-1); - /** - @short set positions for the acquisition - \param nPos number of positions - \param pos array with the encoder positions - \returns number of positions - */ - int setPositions(int nPos, double *pos); - - /** - @short get positions for the acquisition - \param pos array which will contain the encoder positions - \returns number of positions - */ - int getPositions(double *pos=NULL); - - /** - @short sets the detector size - \param x0 horizontal position origin in channel number (-1 unchanged) - \param y0 vertical position origin in channel number (-1 unchanged) - \param nx number of channels in horiziontal (-1 unchanged) - \param ny number of channels in vertical (-1 unchanged) - \returns OK/FAIL - */ - int setDetectorSize(int x0=-1, int y0=-1, int nx=-1, int ny=-1); - /** @short gets detector size @@ -419,43 +344,6 @@ class slsDetectorUsers void registerDataCallback(int( *userCallback)(detectorData* d, int f, int s, void*), void *pArg); - /** - @short register callback for accessing raw data - if the rawDataCallback is registered, no filewriting/postprocessing will be carried on automatically by the software - the raw data are deleted by the software - \param userCallback function for postprocessing and saving the data - p is the pointer to the data, n is the number of channels - \param pArg argument - */ - - void registerRawDataCallback(int( *userCallback)(double* p, int n, void*), void *pArg); - - /** - @short function to initalize a set of measurements (reset binning if angular conversion, reset summing otherwise) - can be overcome by the user's functions thanks to the virtual property - \param refresh if 1, all parameters like ffcoefficients, badchannels, ratecorrections etc. are reset (should be called at least onece with this option), if 0 simply reset merging/ summation - */ - - virtual void initDataset(int refresh); - - - /** - @short adds frame to merging/summation - can be overcome by the user's functions thanks to the virtual property - \param data pointer to the raw data - \param pos encoder position - \param i0 beam monitor readout for intensity normalization (if 0 not performed) - \param t exposure time in seconds, required only if rate corrections - \param fname file name (unused since filewriting would be performed by the user) - \param var optional parameter - unused. - */ - - virtual void addFrame(double *data, double pos, double i0, double t, std::string fname, double var); - - /** - @short finalizes the data set returning the array of angles, values and errors to be used as final data - can be overcome by the user's functions thanks to the virtual property - \param a pointer to the array of angles - can be null if no angular coversion is required - \param v pointer to the array of values - \param e pointer to the array of errors - \param np reference returning the number of points - */ - - virtual void finalizeDataset(double *a, double *v, double *e, int &np); /** Enable or disable streaming data from receiver (creates transmitting sockets) @@ -503,19 +391,6 @@ class slsDetectorUsers */ std::string setClientDataStreamingInIP(std::string ip=""); - /** - get get Module Firmware Version - \returns id - */ - int64_t getModuleFirmwareVersion(); - - /** - get get Module Serial Number - @param imod module number - \returns id - */ - int64_t getModuleSerialNumber(int imod=-1); - /** get get Detector Firmware Version \returns id @@ -599,44 +474,6 @@ class slsDetectorUsers */ void registerAcquisitionFinishedCallback(int( *func)(double,int, void*), void *pArg); - /** - @short register calbback for reading detector position - \param func function for reading the detector position - \param arg argument - */ - - void registerGetPositionCallback( double (*func)(void*),void *arg); - /** - @short register callback for connecting to the epics channels - \param func function for connecting to the epics channels - \param arg argument - */ - void registerConnectChannelsCallback( int (*func)(void*),void *arg); - /** - @short register callback to disconnect the epics channels - \param func function to disconnect the epics channels - \param arg argument - */ - void registerDisconnectChannelsCallback( int (*func)(void*),void *arg); - /** - @short register callback for moving the detector - \param func function for moving the detector - \param arg argument - */ - void registerGoToPositionCallback( int (*func)(double,void*),void *arg); - /** - @short register callback for moving the detector without waiting - \param func function for moving the detector - \param arg argument - */ - void registerGoToPositionNoWaitCallback( int (*func)(double,void*),void *arg); - /** - @short register calbback reading to I0 - \param func function for reading the I0 (called with parameter 0 before the acquisition, 1 after and the return value used as I0) - \param arg argument - */ - void registerGetI0Callback( double (*func)(int,void*),void *arg); - /** @short sets parameters in command interface http://www.psi.ch/detectors/UsersSupportEN/slsDetectorClientHowTo.pdf \param narg value to be set @@ -775,10 +612,10 @@ class slsDetectorUsers int setTenGigabitEthernet(int i = -1); /** - * returns total number of detector modules - * @returns the total number of detector modules + * returns total number of detectors + * @returns the total number of detectors */ - int getNMods(); + int getNumberOfDetectors(); /** * Set sub frame exposure time (only for Eiger) diff --git a/slsDetectorSoftware/slsDetector/slsDetectorUtils.cpp b/slsDetectorSoftware/slsDetector/slsDetectorUtils.cpp index e81ee57f5..2f01d3c30 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorUtils.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetectorUtils.cpp @@ -1,9 +1,7 @@ #include "slsDetectorUtils.h" -#include "usersFunctions.h" #include "slsDetectorCommand.h" #include "postProcessing.h" -#include "enCalLogClass.h" -#include "angCalLogClass.h" + #include #include @@ -12,32 +10,26 @@ #include using namespace std; -slsDetectorUtils::slsDetectorUtils() { - - +slsDetectorUtils::slsDetectorUtils(): + stoppedFlag(0), + timerValue(0), + currentSettings(0), + currentThresholdEV(0), + totalProgress(0), + progressIndex(0), + acquisition_finished(NULL), + measurement_finished(NULL), + acqFinished_p(NULL), + measFinished_p(NULL), + progress_call(0), + pProgressCallArg(0) + { #ifdef VERBOSE - cout << "setting callbacks" << endl; -#endif - acquisition_finished=NULL; - acqFinished_p=NULL; - measurement_finished=NULL; - measFinished_p=NULL; - progress_call=0; - pProgressCallArg=0; - registerGetPositionCallback(&defaultGetPosition, NULL); - registerConnectChannelsCallback(&defaultConnectChannels,NULL); - registerDisconnectChannelsCallback(&defaultDisconnectChannels,NULL); - registerGoToPositionCallback(&defaultGoToPosition,NULL); - registerGoToPositionNoWaitCallback(&defaultGoToPositionNoWait,NULL); - registerGetI0Callback(&defaultGetI0,NULL); -#ifdef VERBOSE - registerAcquisitionFinishedCallback(&dummyAcquisitionFinished,this); registerMeasurementFinishedCallback(&dummyMeasurementFinished,this); cout << "done " << endl; #endif - -}; +} @@ -61,73 +53,16 @@ int slsDetectorUtils::acquire(int delflag){ bool receiver = (setReceiverOnline()==ONLINE_FLAG); - if(!receiver){ - setDetectorIndex(-1); - } - - int nc=setTimer(CYCLES_NUMBER,-1); - int nf=setTimer(FRAME_NUMBER,-1); - if (nc==0) nc=1; - if (nf==0) nf=1; - int multiframe = nc*nf; progressIndex=0; *stoppedFlag=0; - - angCalLogClass *aclog=NULL; - enCalLogClass *eclog=NULL; - int connectChannels=0; - -#ifdef VERBOSE - cout << "Acquire function "<< delflag << endl; - cout << "Stopped flag is "<< stoppedFlag << delflag << endl; -#endif - void *status; - if ((*correctionMask&(1<< ANGULAR_CONVERSION)) || (*correctionMask&(1<< I0_NORMALIZATION)) || getActionMode(angCalLog) || (getScanMode(0)==positionScan)|| (getScanMode(1)==positionScan)) { - if (connectChannels==0) - if (connect_channels) { - connect_channels(CCarg); - connectChannels=1; - } - } - if (getActionMode(angCalLog)) { - aclog=new angCalLogClass(this); - } - if (getActionMode(enCalLog)) { - eclog=new enCalLogClass(this); - - } - - setJoinThread(0); - positionFinished(0); - int nm=timerValue[MEASUREMENTS_NUMBER]; if (nm<1) nm=1; - - int np=getNumberOfPositions(); - if (np<1) - np=1; - - - int ns0=1; - if (*actionMask & (1 << MAX_ACTIONS)) { - ns0=getScanSteps(0); - if (ns0<1) - ns0=1; - } - - int ns1=1; - if (*actionMask & (1 << (MAX_ACTIONS+1))) { - ns1=getScanSteps(1); - if (ns1<1) - ns1=1; - } - // verify receiver is idle if(receiver){ pthread_mutex_lock(&mg); @@ -137,12 +72,10 @@ int slsDetectorUtils::acquire(int delflag){ pthread_mutex_unlock(&mg); } - + // start processing thread if (*threadedProcessing) startThread(delflag); -#ifdef VERBOSE - cout << " starting thread " << endl; -#endif + //resets frames caught in receiver if(receiver){ @@ -152,304 +85,84 @@ int slsDetectorUtils::acquire(int delflag){ pthread_mutex_unlock(&mg); } - + // loop through measurements for(int im=0;im0) { - moveDetector(detPositions[ip]); - IncrementPositionIndex(); -#ifdef VERBOSE - std::cout<< "moving to position" << std::endl; -#endif - } - } else - break; - - - pthread_mutex_lock(&mp); - createFileName(); - pthread_mutex_unlock(&mp); - - // script before - if (*stoppedFlag==0) { - executeAction(scriptBefore); - } else - break; - - - // header before - if (*stoppedFlag==0) { - executeAction(headerBefore); - - if (*correctionMask&(1<< ANGULAR_CONVERSION) || aclog){ - positionFinished(0); - setCurrentPosition(getDetectorPosition()); - } - - if (aclog) - aclog->addStep(getCurrentPosition(), getCurrentFileName()); - - if (eclog) - eclog->addStep(setDAC(-1,THRESHOLD,0), getCurrentFileName()); - - - if (*correctionMask&(1<< I0_NORMALIZATION)) { - if (get_i0) - get_i0(0, IOarg); - } - - setCurrentFrameIndex(0); - - if (multiframe>1) - setFrameIndex(0); - else - setFrameIndex(-1); - - // file name and start receiver - if(receiver){ - pthread_mutex_lock(&mp); - createFileName(); - pthread_mutex_unlock(&mp); - //send receiver file name - pthread_mutex_lock(&mg); - setFileName(fileIO::getFileName()); - - if(startReceiver() == FAIL) { - cout << "Start receiver failed " << endl; - stopReceiver(); - *stoppedFlag=1; - pthread_mutex_unlock(&mg); - break; - } -#ifdef VERBOSE - cout << "Receiver started " << endl; -#endif - pthread_mutex_unlock(&mg); - - //let processing thread listen to these packets - sem_post(&sem_newRTAcquisition); - } -#ifdef VERBOSE - cout << "Acquiring " << endl; -#endif - startAndReadAll(); -#ifdef VERBOSE - cout << "detector finished" << endl; - cout << "returned! " << endl; -#endif - - - if (*correctionMask&(1<< I0_NORMALIZATION)) { - if (get_i0) - currentI0=get_i0(1,IOarg); - } -#ifdef VERBOSE - cout << "pos finished? " << endl; -#endif - - positionFinished(1); - -#ifdef VERBOSE - cout << "done! " << endl; -#endif - - - if (*threadedProcessing==0){ -#ifdef VERBOSE - cout << "start unthreaded process data " << endl; -#endif - processData(delflag); - } - - } else - break; - - while (dataQueueSize()) usleep(100000); - - // close file - if(!receiver){ - detectorType type = getDetectorsType(); - if ((type==GOTTHARD) || (type==MOENCH) || (type==JUNGFRAUCTB) ){ - if((*correctionMask)&(1<0) - nc=timerValue[CYCLES_NUMBER]; + if (timerValue[FRAME_NUMBER]) + nf=timerValue[FRAME_NUMBER]; - if (timerValue[MEASUREMENTS_NUMBER]>0) - nm=timerValue[MEASUREMENTS_NUMBER]; + if (timerValue[CYCLES_NUMBER]>0) + nc=timerValue[CYCLES_NUMBER]; - if (*numberOfPositions>0) - npos=*numberOfPositions; + if (timerValue[STORAGE_CELL_NUMBER]>0) + ns=timerValue[STORAGE_CELL_NUMBER]+1; - if ((nScanSteps[0]>0) && (*actionMask & (1 << MAX_ACTIONS))) - nscan[0]=nScanSteps[0]; + if (timerValue[MEASUREMENTS_NUMBER]>0) + nm=timerValue[MEASUREMENTS_NUMBER]; - if ((nScanSteps[1]>0) && (*actionMask & (1 << (MAX_ACTIONS+1)))) - nscan[1]=nScanSteps[1]; - - totalProgress=nm*nf*nc*npos*nscan[0]*nscan[1]; + totalProgress=nm*nf*nc*ns; #ifdef VERBOSE - cout << "nc " << nc << endl; - cout << "nm " << nm << endl; - cout << "nf " << nf << endl; - cout << "npos " << npos << endl; - cout << "nscan[0] " << nscan[0] << endl; - cout << "nscan[1] " << nscan[1] << endl; - - cout << "Set total progress " << totalProgress << endl; + cout << "nm " << nm << endl; + cout << "nf " << nf << endl; + cout << "nc " << nc << endl; + cout << "ns " << ns << endl; + cout << "Set total progress " << totalProgress << endl; #endif - return totalProgress; + return totalProgress; } - - - - - - -int slsDetectorUtils::setBadChannelCorrection(string fname, int &nbadtot, int *badchanlist, int off){ - - int nbad; - int badlist[MAX_BADCHANS]; - - ifstream infile; - string str; - //int interrupt=0; - //int ich; - //int chmin,chmax; -#ifdef VERBOSE - std::cout << "utils: Setting bad channel correction to " << fname << std::endl; -#endif - // int modmi=0; - int modma=1; - int singlefile=0; - - string fn; - int offset=off; - - - nbadtot=0; - - if (fname=="" || fname=="none") { - ; - } else { - - if (fname.find(".sn")==string::npos && fname.find(".chans")==string::npos) { - modma=setNumberOfModules(); - singlefile=1; - } - - for (int im=0; im0 && nbadtotexecuteLine(1,args,GET_ACTION) << std::endl; } - - strcpy(args[0],names[iv].c_str()); - if (level==2) { - fname1=fname+string(".ff"); - strcpy(args[1],fname1.c_str()); - } - outfile << names[iv] << " " << cmd->executeLine(nargs,args,GET_ACTION) << std::endl; - iv++; - - strcpy(args[0],names[iv].c_str()); - if (level==2) { - fname1=fname+string(".bad"); - strcpy(args[1],fname1.c_str()); - } - outfile << names[iv] << " " << cmd->executeLine(nargs,args,GET_ACTION) << std::endl; - iv++; - - - - if (level==2) { - strcpy(args[0],names[iv].c_str()); - size_t c=fname.rfind('/'); - if (cexecuteLine(nargs,args,GET_ACTION) << std::endl; - iv++; - - - } - - delete cmd; outfile.close(); @@ -948,3 +477,72 @@ int slsDetectorUtils::dumpDetectorSetup(string const fname, int level){ } + + +int slsDetectorUtils::readDataFile(std::string fname, short int *data, int nch) { + std::ifstream infile; + int iline=0; + std::string str; + infile.open(fname.c_str(), std::ios_base::in); + if (infile.is_open()) { + iline=readDataFile(infile, data, nch, 0); + infile.close(); + } else { + std::cout<< "Could not read file " << fname << std::endl; + return -1; + } + return iline; +} + + +int slsDetectorUtils::readDataFile(std::ifstream &infile, short int *data, int nch, int offset) { + int ichan, iline=0; + short int idata; + int interrupt=0; + std::string str; + while (infile.good() and interrupt==0) { + getline(infile,str); + std::istringstream ssstr(str); + ssstr >> ichan >> idata; + if (ssstr.fail() || ssstr.bad()) { + interrupt=1; + break; + } + if (iline=offset) { + data[iline]=idata; + iline++; + } + } else { + interrupt=1; + break; + } + return iline; + }; + return iline; +} + + +int slsDetectorUtils::writeDataFile(std::string fname,int nch, short int *data) { + std::ofstream outfile; + if (data==NULL) + return slsDetectorDefs::FAIL; + outfile.open (fname.c_str(),std::ios_base::out); + if (outfile.is_open()) { + writeDataFile(outfile, nch, data, 0); + outfile.close(); + return slsDetectorDefs::OK; + } else { + std::cout<< "Could not open file " << fname << "for writing"<< std::endl; + return slsDetectorDefs::FAIL; + } +} + + +int slsDetectorUtils::writeDataFile(std::ofstream &outfile,int nch, short int *data, int offset) { + if (data==NULL) + return slsDetectorDefs::FAIL; + for (int ichan=0; ichan0) setFlatFieldCorrectionFile("default"); else if (i==0) setFlatFieldCorrectionFile(""); return getFlatFieldCorrection();}; - int enablePixelMaskCorrection(int i=-1) {if (i>0) setBadChannelCorrection("default"); else if (i==0) setBadChannelCorrection(""); return getBadChannelCorrection();}; - int enableCountRateCorrection(int i=-1) {if (i>0) setRateCorrection(-1); else if (i==0) setRateCorrection(0); return getRateCorrection();}; + /** + * Get user details of shared memory + * Should only be called from multi detector level + * @returns string with user details + */ + virtual std::string getUserDetails() = 0; + + /** + * Sets the hostname of all sls detectors in shared memory + * Connects to them to set up online flag + * @param name concatenated hostname of all the sls detectors + */ + virtual void setHostname(const char* name)=0; + + /** + * Gets the hostname of detector at particular position + * or concatenated hostnames of all the sls detectors + * @param pos position of detector in array, -1 for all detectors + * @returns concatenated hostnames of all detectors or hostname of specific one + */ + virtual std::string getHostname(int pos=-1)=0; + + /** + * Appends detectors to the end of the list in shared memory + * Connects to them to set up online flag + * @param name concatenated hostname of the sls detectors to be appended to the list + */ + virtual void addMultipleDetectors(const char* name)=0; - /** - * Set/Get receiver streaming out ZMQ port - * For multi modules, it calculates (increments) and sets the ports - * @param i sets, -1 gets - * @returns receiver streaming out ZMQ port - */ - int setReceiverDataStreamingOutPort(int i) { \ - if (i >= 0) { \ - std::ostringstream ss; ss << i; std::string s = ss.str(); \ - int prev_streaming = enableDataStreamingFromReceiver(); \ - setNetworkParameter(RECEIVER_STREAMING_PORT, s); \ - if (prev_streaming) { \ - enableDataStreamingFromReceiver(0); \ - enableDataStreamingFromReceiver(1);}} \ - return atoi(getNetworkParameter(RECEIVER_STREAMING_PORT).c_str());}; \ + using slsDetectorBase::getDetectorsType; + /** + * Concatenates string types of all sls detectors or + * returns the detector type of the first sls detector + * @param pos position of sls detector in array, if -1, returns first detector type + * @returns detector type of sls detector in position pos, if -1, concatenates + */ + virtual std::string sgetDetectorsType(int pos=-1)=0; - /** - * Set/Get client streaming in ZMQ port - * For multi modules, it calculates (increments) and sets the ports - * @param i sets, -1 gets - * @returns client streaming in ZMQ port - */ - int setClientDataStreamingInPort(int i){ \ - if (i >= 0) { \ - std::ostringstream ss; ss << i; std::string s = ss.str(); \ - int prev_streaming = enableDataStreamingToClient(); \ - setNetworkParameter(CLIENT_STREAMING_PORT, s); \ - if (prev_streaming) { \ - enableDataStreamingToClient(0); \ - enableDataStreamingToClient(1);}} \ - return atoi(getNetworkParameter(CLIENT_STREAMING_PORT).c_str());}; \ + /** + * Returns the number of detectors in the multidetector structure + * @returns number of detectors + */ + virtual int getNumberOfDetectors(){return 1;}; - /** - * Set/Get receiver streaming out ZMQ port - * For multi modules, it calculates (increments) and sets the ports - * @param i sets, -1 gets - * @returns receiver streaming out ZMQ port - */ - std::string setReceiverDataStreamingOutIP(std::string ip) { \ + /** + * Returns the total number of channels of all sls detectors from shared memory + * @returns the total number of channels of all sls detectors + */ + virtual int getTotalNumberOfChannels()=0; + + /** + * Returns the total number of channels of all sls detectors in dimension d + * from shared memory + * @param d dimension d + * @returns the total number of channels of all sls detectors in dimension d + */ + virtual int getTotalNumberOfChannels(dimension d)=0; + + /** + * Returns the maximum number of channels of all sls detectors in each dimension d + * from shared memory. multi detector shared memory variable to calculate + * offsets for each sls detector + * @param d dimension d + * @returns the maximum number of channels of all sls detectors in dimension d + */ + virtual int getMaxNumberOfChannelsPerDetector(dimension d){return -1;}; + + /** + * Sets the maximum number of channels of all sls detectors in each dimension d + * from shared memory, multi detector shared memory variable to calculate + * offsets for each sls detector + * @param d dimension d + * @param i maximum number of channels for multi structure in dimension d + * @returns the maximum number of channels of all sls detectors in dimension d + */ + virtual int setMaxNumberOfChannelsPerDetector(dimension d,int i){return -1;}; + + /** + * Checks if each of the detectors are online/offline + * @returns empty string if they are all online, + * else returns concatenation of strings of all detectors that are offline + */ + virtual std::string checkOnline()=0; + + /** + * Set/Gets TCP Port of detector or receiver + * @param t port type + * @param num port number (-1 gets) + * @returns port number + */ + virtual int setPort(portType t, int num=-1)=0; + + /** + * Get last client IP saved on detector server + * @returns last client IP saved on detector server + */ + virtual std::string getLastClientIP()=0; + + /** + * Exit detector server + * @returns OK or FAIL + */ + virtual int exitServer()=0; + + /** + * Write current configuration to a file + * @param fname configuration file name + * @returns OK or FAIL + */ + virtual int writeConfigurationFile(std::string const fname)=0; + + /** + * Returns the trimfile or settings file name (Useless??) + * @returns the trimfile or settings file name + */ + virtual std::string getSettingsFile()=0; + + /** + * Set threshold energy (Mythen and Eiger) + * @param e_eV threshold in eV + * @param imod module number (-1 all) + * @param isettings ev. change settings + * @param tb 1 to include trimbits, 0 to exclude + * @returns current threshold value for imod in ev (-1 failed) + */ + virtual int setThresholdEnergy(int e_eV, int imod=-1, detectorSettings isettings=GET_SETTINGS,int tb=1)=0; + + /** + * Returns the detector trimbit/settings directory \sa sharedSlsDetector + * @returns the trimbit/settings directory + */ + virtual std::string getSettingsDir()=0; + + /** + * Sets the detector trimbit/settings directory \sa sharedSlsDetector + * @param s trimbits/settings directory + * @returns the trimbit/settings directory + */ + virtual std::string setSettingsDir(std::string s)=0; + + /** + * Returns the calibration files directory \sa sharedSlsDetector (Mythen) + * @returns the calibration files directory + */ + virtual std::string getCalDir()=0; + + /** + * Sets the calibration files directory \sa sharedSlsDetector (Mythen) + * @param s the calibration files directory + * @returns the calibration files directory + */ + virtual std::string setCalDir(std::string s)=0; + + /** + * Loads the modules settings/trimbits reading from a specific file + * file name extension is automatically generated. + * @param fname specific settings/trimbits file + * @param imod module number (-1 for all) + * returns OK or FAIL + */ + virtual int loadSettingsFile(std::string fname, int imod=-1)=0; + + /** + * Saves the modules settings/trimbits to a specific file + * file name extension is automatically generated. + * @param fname specific settings/trimbits file + * @param imod module number (-1 for all) + * returns OK or FAIL + */ + virtual int saveSettingsFile(std::string fname, int imod=-1)=0; + + /** + * Give an internal software trigger to the detector (Eiger only) + * @return OK or FAIL + */ + virtual int sendSoftwareTrigger()=0; + + /** + * Start detector acquisition and read all data (Blocking until end of acquisition) + * @returns OK or FAIL + */ + virtual int startAndReadAll()=0; + + /** + * Requests and receives all data from the detector (Eiger store in ram) + * @returns OK or FAIL + */ + virtual int readAll()=0; + + /** + * Configures in detector the destination for UDP packets (Not Mythen) + * @returns OK or FAIL + */ + virtual int configureMAC()=0; + + /** + * Set/get timer value left in acquisition (not all implemented for all detectors) + * @param index timer index + * @param t time in ns or number of...(e.g. frames, gates, probes) + * @param imod module number + * @returns timer set value in ns or number of...(e.g. frames, gates, probes) + */ + virtual int64_t getTimeLeft(timerIndex index, int imod = -1)=0; + + /** + * Set speed + * @param sp speed type (clkdivider option for Jungfrau and Eiger, others for Mythen/Gotthard) + * @param value (clkdivider 0,1,2 for full, half and quarter speed). Other values check manual + * @returns value of speed set + */ + virtual int setSpeed(speedVariable sp, int value=-1)=0; + + /** + * Set/get dacs value + * @param val value (in V) + * @param index DAC index + * @param mV 0 in dac units or 1 in mV + * @param imod module number (if -1 all modules) + * @returns current DAC value + */ + virtual dacs_t setDAC(dacs_t val, dacIndex index , int mV, int imod=-1)=0; + + /** + * Get adc value + * @param index adc(DAC) index + * @param imod module number (if -1 all modules) + * @returns current adc value (temperature for eiger and jungfrau in millidegrees) + */ + virtual dacs_t getADC(dacIndex index, int imod=-1)=0; + + /** + * Set/get external signal flags (to specify triggerinrising edge etc) (Gotthard, Mythen) + * @param pol external signal flag (-1 gets) + * @param signalindex singal index (0 - 3) + * @returns current timing mode + */ + virtual externalSignalFlag setExternalSignalFlags(externalSignalFlag pol=GET_EXTERNAL_SIGNAL_FLAG , int signalindex=0)=0; + + /** + * Set/get readout flags (Eiger, Mythen) + * @param flag readout flag (Eiger options: parallel, nonparallel, safe etc.) (-1 gets) + * @returns readout flag + */ + virtual int setReadOutFlags(readOutFlags flag=GET_READOUT_FLAGS)=0; + + /** + * Write in a register. For Advanced users + * @param addr address of register + * @param val value to write into register + * @returns value read after writing + */ + virtual uint32_t writeRegister(uint32_t addr, uint32_t val)=0; + + /** + * Read from a register. For Advanced users + * @param addr address of register + * @returns value read from register + */ + virtual uint32_t readRegister(uint32_t addr)=0; + + /** + * Set bit in a register. For Advanced users + * @param addr address of register + * @param n nth bit + * @returns value read from register + */ + virtual uint32_t setBit(uint32_t addr, int n)=0; + + /** + * Clear bit in a register. For Advanced users + * @param addr address of register + * @param n nth bit + * @returns value read from register + */ + virtual uint32_t clearBit(uint32_t addr, int n)=0; + + /** + * Set network parameter + * @param p network parameter type + * @param s network parameter value + * @returns network parameter value set (from getNetworkParameter) + */ + virtual std::string setNetworkParameter(networkParameter p, std::string s)=0; + + /** + * Get network parameter + * @param p network parameter type + * @returns network parameter value set (from getNetworkParameter) + */ + virtual std::string getNetworkParameter(networkParameter)=0; + + /** + * Execute a digital test (Gotthard, Mythen) + * @param mode testmode type + * @param imod module index (-1 for all) + * @returns result of test + */ + virtual int digitalTest(digitalTestMode mode, int imod=0)=0; + + /** + * Load dark or gain image to detector (Gotthard) + * @param index image type + * @param fname file name from which to load image + * @returns OK or FAIL + */ + virtual int loadImageToDetector(imageType index,std::string const fname)=0; + + /** + * Writes the counter memory block from the detector (Gotthard) + * @param fname file name to load data from + * @param startACQ is 1 to start acquisition after reading counter + * @returns OK or FAIL + */ + virtual int writeCounterBlockFile(std::string const fname,int startACQ=0)=0; + + /** + * Resets counter in detector (Gotthard) + * @param startACQ is 1 to start acquisition after resetting counter + * @returns OK or FAIL + */ + virtual int resetCounterBlock(int startACQ=0)=0; + + /** + * Set/get counter bit in detector (Gotthard) + * @param i is -1 to get, 0 to reset and any other value to set the counter bit + * @returns the counter bit in detector + */ + virtual int setCounterBit(int i = -1)=0; + + /** + * Set ROI (Gotthard) + * At the moment only one set allowed + * @param n number of rois + * @param roiLimits array of roi + * @returns OK or FAIL + */ + virtual int setROI(int n=-1,ROI roiLimits[]=NULL)=0; + + /** + * Get ROI from each detector and convert it to the multi detector scale (Gotthard) + * @param n number of rois + * @returns OK or FAIL + */ + virtual ROI* getROI(int &n)=0; + + /** + * Write to ADC register (Gotthard, Jungfrau, ChipTestBoard). For expert users + * @param addr address of adc register + * @param val value + * @returns return value (mostly -1 as it can't read adc register) + */ + virtual int writeAdcRegister(int addr, int val)=0; + + /** + * Returns the enable if data will be flipped across x or y axis (Eiger) + * @param d axis across which data is flipped + * @returns 1 for flipped, else 0 + */ + virtual int getFlippedData(dimension d=X)=0; + + /** + * Sets the enable which determines if + * data will be flipped across x or y axis (Eiger) + * @param d axis across which data is flipped + * @param value 0 or 1 to reset/set or -1 to get value + * @returns enable flipped data across x or y axis + */ + virtual int setFlippedData(dimension d=X, int value=-1)=0; + + /** + * Sets all the trimbits to a particular value (Eiger) + * @param val trimbit value + * @param imod module number, -1 means all modules + * @returns OK or FAIL + */ + virtual int setAllTrimbits(int val, int imod=-1)=0; + + /** + * Enable gap pixels, only for Eiger and for 8,16 and 32 bit mode. (Eiger) + * 4 bit mode gap pixels only in gui call back + * @param val 1 sets, 0 unsets, -1 gets + * @returns gap pixel enable or -1 for error + */ + virtual int enableGapPixels(int val=-1)=0; + + /** + * Sets the number of trim energies and their value (Eiger) + * \sa sharedSlsDetector + * @param nen number of energies + * @param en array of energies + * @returns number of trim energies + */ + virtual int setTrimEn(int nen, int *en=NULL)=0; + + /** + * Returns the number of trim energies and their value (Eiger) + * \sa sharedSlsDetector + * @param en array of energies + * @returns number of trim energies + */ + virtual int getTrimEn(int *en=NULL)=0; + + /** + * Pulse Pixel (Eiger) + * @param n is number of times to pulse + * @param x is x coordinate + * @param y is y coordinate + * @returns OK or FAIL + */ + virtual int pulsePixel(int n=0,int x=0,int y=0)=0; + + /** + * Pulse Pixel and move by a relative value (Eiger) + * @param n is number of times to pulse + * @param x is relative x value + * @param y is relative y value + * @returns OK or FAIL + */ + virtual int pulsePixelNMove(int n=0,int x=0,int y=0)=0; + + /** + * Pulse Chip (Eiger) + * @param n is number of times to pulse + * @returns OK or FAIL + */ + virtual int pulseChip(int n=0)=0; + + /** + * Set/gets threshold temperature (Jungfrau) + * @param val value in millidegrees, -1 gets + * @param imod module number, -1 is all + * @returns threshold temperature in millidegrees + */ + virtual int setThresholdTemperature(int val=-1, int imod=-1)=0; + + /** + * Enables/disables temperature control (Jungfrau) + * @param val value, -1 gets + * @param imod module number, -1 is all + * @returns temperature control enable + */ + virtual int setTemperatureControl(int val=-1, int imod=-1)=0; + + /** + * Resets/ gets over-temperature event (Jungfrau) + * @param val value, -1 gets + * @param imod module number, -1 is all + * @returns over-temperature event + */ + virtual int setTemperatureEvent(int val=-1, int imod=-1)=0; + + /** + * Set storage cell that stores first acquisition of the series (Jungfrau) + * @param value storage cell index. Value can be 0 to 15. (-1 gets) + * @returns the storage cell that stores the first acquisition of the series + */ + virtual int setStoragecellStart(int pos=-1)=0; + + /** + * Programs FPGA with pof file (Jungfrau) + * @param fname file name + * @returns OK or FAIL + */ + virtual int programFPGA(std::string fname)=0; + + /** + * Resets FPGA (Jungfrau) + * @returns OK or FAIL + */ + virtual int resetFPGA()=0; + + /** + * Power on/off Chip (Jungfrau) + * @param ival on is 1, off is 0, -1 to get + * @returns OK or FAIL + */ + virtual int powerChip(int ival= -1)=0; + + /** + * Automatic comparator disable (Jungfrau) + * @param ival on is 1, off is 0, -1 to get + * @returns OK or FAIL + */ + virtual int setAutoComparatorDisableMode(int ival= -1)=0; + + /** + * Calibrate Pedestal (ChipTestBoard) + * Starts acquisition, calibrates pedestal and writes to fpga + * @param frames number of frames + * @returns number of frames + */ + virtual int calibratePedestal(int frames = 0)=0; + + /** + * Get rate correction tau (Mythen, Eiger) + * @returns 0 if rate correction disabled, otherwise the tau used for the correction + */ + virtual double getRateCorrectionTau()=0; + + /** + * Checks if the receiver is really online + * @returns empty string if all online, else concatenates hostnames of all + * detectors that are offline + */ + virtual std::string checkReceiverOnline()=0; + + /** + * Locks/Unlocks the connection to the receiver + * @param lock sets (1), usets (0), gets (-1) the lock + * @returns lock status of the receiver + */ + virtual int lockReceiver(int lock=-1)=0; + + /** + * Returns the IP of the last client connecting to the receiver + * @returns IP of last client connecting to receiver + */ + virtual std::string getReceiverLastClientIP()=0; + + /** + * Turns off the receiver server! + * @returns OK or FAIL + */ + virtual int exitReceiver()=0; + + /** + * Returns output file directory + * @returns output file directory + */ + virtual std::string getFilePath()=0; + + /** + * Sets up the file directory + * @param s file directory + * @returns file dir + */ + virtual std::string setFilePath(std::string s)=0; + + /** + * Returns file name prefix + * @returns file name prefix + */ + virtual std::string getFileName()=0; + + /** + * Sets up the file name prefix + * @param s file name prefix + * @returns file name prefix + */ + virtual std::string setFileName(std::string s)=0; + + /** + * Sets the max frames per file in receiver + * @param f max frames per file + * @returns max frames per file in receiver + */ + virtual int setReceiverFramesPerFile(int f=-1)=0; + + /** + * Sets the frames discard policy in receiver + * @param f frames discard policy + * @returns frames discard policy set in receiver + */ + virtual frameDiscardPolicy setReceiverFramesDiscardPolicy(frameDiscardPolicy f = GET_FRAME_DISCARD_POLICY)=0; + + /** + * Sets the partial frames padding enable in receiver + * @param f partial frames padding enable + * @returns partial frames padding enable in receiver + */ + virtual int setReceiverPartialFramesPadding(int f = -1)=0; + + /** + * Returns file format + * @returns file name + */ + virtual fileFormat getFileFormat()=0; + + /** + * Sets up the file format + * @param f file format + * @returns file format + */ + virtual fileFormat setFileFormat(fileFormat f)=0; + + /** + * Gets the number of frames caught by receiver + * @returns number of frames caught by receiver + */ + virtual int getFramesCaughtByReceiver()=0; + + /** + * Gets the number of frames caught by any one receiver (to avoid using threadpool) + * @returns number of frames caught by any one receiver (master receiver if exists) + */ + virtual int getFramesCaughtByAnyReceiver()=0; + + /** + * Gets the current frame index of receiver + * @returns current frame index of receiver + */ + virtual int getReceiverCurrentFrameIndex()=0; + + /** + * Resets framescaught in receiver + * Use this when using startAcquisition instead of acquire + * @returns OK or FAIL + */ + virtual int resetFramesCaught()=0; + + /** + * Create Receiving Data Sockets + * @param destroy is true to destroy all the sockets + * @returns OK or FAIL + */ + virtual int createReceivingDataSockets(const bool destroy = false){return -1;}; + + /** + * Reads frames from receiver through a constant socket + * Called during acquire() when call back registered or when using gui + */ + virtual void readFrameFromReceiver(){}; + + /** + * Sets/Gets receiver file write enable + * @param enable 1 or 0 to set/reset file write enable + * @returns file write enable + */ + virtual int enableWriteToFile(int enable=-1)=0; + + /** + * Sets/Gets file overwrite enable + * @param enable 1 or 0 to set/reset file overwrite enable + * @returns file overwrite enable + */ + virtual int overwriteFile(int enable=-1)=0; + + /** + * Sets the read receiver frequency + * if data required from receiver randomly readRxrFrequency=0, + * else every nth frame to be sent to gui/callback + * @param freq is the receiver read frequency. Value 0 is 200 ms timer (other + * frames not sent), 1 is every frame, 2 is every second frame etc. + * @returns read receiver frequency + */ + virtual int setReadReceiverFrequency(int freq=-1)=0; + + /** + * Enable data streaming to client + * @param enable 0 to disable, 1 to enable, -1 to get the value + * @returns data streaming to client enable + */ + virtual int enableDataStreamingToClient(int enable=-1)=0; + + /** + * Enable or disable streaming data from receiver to client + * @param enable 0 to disable 1 to enable -1 to only get the value + * @returns data streaming from receiver enable + */ + virtual int enableDataStreamingFromReceiver(int enable=-1)=0; + + /** + * Enable/disable or 10Gbe + * @param i is -1 to get, 0 to disable and 1 to enable + * @returns if 10Gbe is enabled + */ + virtual int enableTenGigabitEthernet(int i = -1)=0; + + /** + * Set/get receiver fifo depth + * @param i is -1 to get, any other value to set the fifo deph + * @returns the receiver fifo depth + */ + virtual int setReceiverFifoDepth(int i = -1)=0; + + /** + * Set/get receiver silent mode + * @param i is -1 to get, 0 unsets silent mode, 1 sets silent mode + * @returns the receiver silent mode enable + */ + virtual int setReceiverSilentMode(int i = -1)=0; + + /** + * Opens pattern file and sends pattern to CTB + * @param fname pattern file to open + * @returns OK/FAIL + */ + virtual int setCTBPattern(std::string fname)=0; + + /** + * Writes a pattern word to the CTB + * @param addr address of the word, -1 is I/O control register, + * -2 is clk control register + * @param word 64bit word to be written, -1 gets + * @returns actual value + */ + virtual uint64_t setCTBWord(int addr,uint64_t word=-1)=0; + + /** + * Sets the pattern or loop limits in the CTB + * @param level -1 complete pattern, 0,1,2, loop level + * @param start start address if >=0 + * @param stop stop address if >=0 + * @param n number of loops (if level >=0) + * @returns OK/FAIL + */ + virtual int setCTBPatLoops(int level,int &start, int &stop, int &n)=0; + + /** + * Sets the wait address in the CTB + * @param level 0,1,2, wait level + * @param addr wait address, -1 gets + * @returns actual value + */ + virtual int setCTBPatWaitAddr(int level, int addr=-1)=0; + + /** + * Sets the wait time in the CTB + * @param level 0,1,2, wait level + * @param t wait time, -1 gets + * @returns actual value + */ + virtual int setCTBPatWaitTime(int level, uint64_t t=-1)=0; + + + + + + + + + + + + + int enableCountRateCorrection(int i=-1) {if (i>0) setRateCorrection(-1); else if (i==0) setRateCorrection(0); return getRateCorrection();}; + + /** + * Set/Get receiver streaming out ZMQ port + * For multi modules, it calculates (increments) and sets the ports + * @param i sets, -1 gets + * @returns receiver streaming out ZMQ port + */ + int setReceiverDataStreamingOutPort(int i) { \ + if (i >= 0) { \ + std::ostringstream ss; ss << i; std::string s = ss.str(); \ + int prev_streaming = enableDataStreamingFromReceiver(); \ + setNetworkParameter(RECEIVER_STREAMING_PORT, s); \ + if (prev_streaming) { \ + enableDataStreamingFromReceiver(0); \ + enableDataStreamingFromReceiver(1);}} \ + return atoi(getNetworkParameter(RECEIVER_STREAMING_PORT).c_str());}; \ + + /** + * Set/Get client streaming in ZMQ port + * For multi modules, it calculates (increments) and sets the ports + * @param i sets, -1 gets + * @returns client streaming in ZMQ port + */ + int setClientDataStreamingInPort(int i){ \ + if (i >= 0) { \ + std::ostringstream ss; ss << i; std::string s = ss.str(); \ + int prev_streaming = enableDataStreamingToClient(); \ + setNetworkParameter(CLIENT_STREAMING_PORT, s); \ + if (prev_streaming) { \ + enableDataStreamingToClient(0); \ + enableDataStreamingToClient(1);}} \ + return atoi(getNetworkParameter(CLIENT_STREAMING_PORT).c_str());}; \ + + /** + * Set/Get receiver streaming out ZMQ port + * For multi modules, it calculates (increments) and sets the ports + * @param i sets, -1 gets + * @returns receiver streaming out ZMQ port + */ + std::string setReceiverDataStreamingOutIP(std::string ip) { \ if (ip.length()) { \ int prev_streaming = enableDataStreamingFromReceiver(); \ setNetworkParameter(RECEIVER_STREAMING_SRC_IP, ip); \ if (prev_streaming) { \ enableDataStreamingFromReceiver(0); \ enableDataStreamingFromReceiver(1);}} \ - return getNetworkParameter(RECEIVER_STREAMING_SRC_IP);}; \ + return getNetworkParameter(RECEIVER_STREAMING_SRC_IP);}; \ - /** - * Set/Get client streaming in ZMQ port - * For multi modules, it calculates (increments) and sets the ports - * @param i sets, -1 gets - * @returns client streaming in ZMQ port - */ - std::string setClientDataStreamingInIP(std::string ip){ \ + /** + * Set/Get client streaming in ZMQ port + * For multi modules, it calculates (increments) and sets the ports + * @param i sets, -1 gets + * @returns client streaming in ZMQ port + */ + std::string setClientDataStreamingInIP(std::string ip){ \ if (ip.length()) { \ int prev_streaming = enableDataStreamingToClient(); \ setNetworkParameter(CLIENT_STREAMING_SRC_IP, ip); \ if (prev_streaming) { \ enableDataStreamingToClient(0); \ enableDataStreamingToClient(1);}} \ - return getNetworkParameter(CLIENT_STREAMING_SRC_IP);}; \ - -// string getFilePath(){return fileIO::getFilePath();};; - // string setFilePath(string s){return fileIO::setFilePath(s);}; - - // string getFileName(){return fileIO::getFileName();}; - // string setFileName(string s){return fileIO::setFileName(s);}; - - // int getFileIndex(){return fileIO::getFileIndex();}; - // int setFileIndex(int s){return fileIO::setFileIndex(s);}; - - /* - int getScanPrecision(int i){return slsDetectorActions::getScanPrecision(i);}; - - int getActionMask() {return slsDetectorActions::getActionMask();}; - float getCurrentScanVariable(int i) {return slsDetectorActions::getCurrentScanVariable(i);}; - int getCurrentPositionIndex(){return angularConversion::getCurrentPositionIndex();}; - int getNumberOfPositions(){return angularConversion::getNumberOfPositions();}; - */ - - // int getActionMask() {return slsDetectorActions::getActionMask();}; - // double getCurrentScanVariable(int i) {return slsDetectorActions::getCurrentScanVariable(i);}; - // int getCurrentPositionIndex(){return angularConversion::getCurrentPositionIndex();}; - // int getNumberOfPositions(){return angularConversion::getNumberOfPositions();}; + return getNetworkParameter(CLIENT_STREAMING_SRC_IP);}; \ - // string getFlatFieldCorrectionDir(){return postProcessing::getFlatFieldCorrectionDir();}; - // string setFlatFieldCorrectionDir(string s){return postProcessing::setFlatFieldCorrectionDir(s);}; - // string getFlatFieldCorrectionFile(){return postProcessing::getFlatFieldCorrectionFile();}; - // int enableBadChannelCorrection(int i){return postProcessing::enableBadChannelCorrection(i);}; - // int enableAngularConversion(int i){return postProcessing::enableAngularConversion(i);}; - + int setFlowControl10G(int i = -1) { + std::string sret=""; + if (i != -1) { + std::ostringstream o; + o << ((i >= 1) ? 1 : 0); + std::string sval = o.str(); + sret = setNetworkParameter(FLOW_CONTROL_10G, sval); + } else + sret = getNetworkParameter(FLOW_CONTROL_10G); - /** returns the detector hostname - \param pos position in the multi detector structure (is -1 returns concatenated hostnames divided by a +) - \returns hostname - */ - virtual std::string getHostname(int pos=-1)=0; - - - /** sets the detector hostname - \param name hostname - */ - virtual void setHostname(const char* name)=0; - - /** adds the detector hostnames to the end of the list - \param name hostname - */ - virtual void addMultipleDetectors(const char* name)=0; - - /** returns the detector type - \param pos position in the multi detector structure (is -1 returns type of detector with id -1) - \returns type - */ - virtual std::string sgetDetectorsType(int pos=-1)=0; - - /** - gets the network parameters (implemented for gotthard) - \param i network parameter type can be RECEIVER_IP, RECEIVER_MAC, SERVER_MAC - \returns parameter - - */ - virtual std::string getNetworkParameter(networkParameter i)=0; - - /** - sets the network parameters - must restart streaming in client/receiver if to do with zmq after calling this function - \param i network parameter type - \param s value to be set - \returns parameter - - */ - virtual std::string setNetworkParameter(networkParameter i, std::string s)=0; - - int setFlowControl10G(int i = -1) { - std::string sret=""; - if (i != -1) { - std::ostringstream o; - o << ((i >= 1) ? 1 : 0); - std::string sval = o.str(); - sret = setNetworkParameter(FLOW_CONTROL_10G, sval); - } else - sret = getNetworkParameter(FLOW_CONTROL_10G); - - return atoi(sret.c_str()); - } - - /** - changes/gets the port number - \param t type port type can be CONTROL_PORT, DATA_PORT, STOP_PORT - \param i new port number (<1024 gets) - \returns actual port number - */ - virtual int setPort(portType t, int i=-1)=0; - - /** - checks if the detector(s) are online/offline - \returns hostname if offline - */ - virtual std::string checkOnline()=0; - - /** - Digital test of the modules - \param mode test mode - \param imod module number for chip test or module firmware test - \returns OK or error mask - */ - virtual int digitalTest(digitalTestMode mode, int imod=0)=0; - - /** - execute trimming - \param mode trim mode - \param par1 if noise, beam or fixed setting trimming it is count limit, if improve maximum number of iterations - \param par2 if noise or beam nsigma, if improve par2!=means vthreshold will be optimized, if fixed settings par2<0 trimwith median, par2>=0 trim with level - \param imod module number (-1 all) - \returns OK or FAIl (FAIL also if some channel are 0 or 63 - */ - virtual int executeTrimming(trimMode mode, int par1, int par2, int imod=-1)=0; + return atoi(sret.c_str()); + } - /** - returns currently the loaded trimfile/settingsfile name - */ - virtual std::string getSettingsFile()=0; + /** performs a complete acquisition including scansand data processing + * moves the detector to next position
+ * starts and reads the detector
+ * reads the IC (if required)
+ * reads the encoder (iof required for angualr conversion)
+ * processes the data (flat field, rate, angular conversion and merging ::processData()) + * @param delflag 0 leaves the data in the final data queue + * @returns OK or FAIL depending on if it already started + */ + int acquire(int delflag=1); - - /** - get current timer value - \param index timer index - \param imod module number - \returns elapsed time value in ns or number of...(e.g. frames, gates, probes) - */ - virtual int64_t getTimeLeft(timerIndex index, int imod = -1)=0; + int setTotalProgress(); - /** - * set storage cell that stores first acquisition of the series (Jungfrau only) - * \param value storage cell index. Value can be 0 to 15. (-1 gets) - * \returns the storage cell that stores the first acquisition of the series - */ - virtual int setStoragecellStart(int pos=-1)=0; + double getCurrentProgress(); + void incrementProgress(); - - /** sets the number of trim energies and their value \sa sharedSlsDetector - \param nen number of energies - \param en array of energies - \returns number of trim energies - - unused! - - */ - virtual int setTrimEn(int nen, int *en=NULL)=0; - - /** returns the number of trim energies and their value \sa sharedSlsDetector - \param en pointer to the array that will contain the trim energies (in ev) - \returns number of trim energies - - unused! - */ - virtual int getTrimEn(int *en=NULL)=0; - - - - /** - set/get the use of an external signal - \param pol meaning of the signal \sa externalSignalFlag - \param signalindex index of the signal - \returns current meaning of signal signalIndex - */ - virtual externalSignalFlag setExternalSignalFlags(externalSignalFlag pol=GET_EXTERNAL_SIGNAL_FLAG , int signalindex=0)=0; - - - - - /** sets/gets the value of important readout speed parameters - \param sp is the parameter to be set/get - \param value is the value to be set, if -1 get value - \returns current value for the specified parameter - \sa speedVariable - */ - virtual int setSpeed(speedVariable sp, int value=-1)=0; - - - - - - - /** - set/get readout flags - \param flag readout flag to be set - \returns current flag - */ - virtual int setReadOutFlags(readOutFlags flag=GET_READOUT_FLAGS)=0; - - - - - - int setBadChannelCorrection(std::string fname, int &nbadtot, int *badchanlist, int off=0); - - - - - - /** sets/gets position of the master in a multi detector structure - \param i position of the detector in the multidetector structure - \returns position of the master in a multi detector structure (-1 no master or always in slsDetector) - */ - virtual int setMaster(int i=-1){return -1;}; - - /** - Sets/gets the synchronization mode of the various detectors - \param sync syncronization mode - \returns current syncronization mode - */ - virtual synchronizationMode setSynchronization(synchronizationMode sync=GET_SYNCHRONIZATION_MODE)=0; - - - /** - returns the detector trimbit/settings directory - */ - virtual std::string getSettingsDir()=0; - - /** sets the detector trimbit/settings directory */ - virtual std::string setSettingsDir(std::string s)=0; - - /** - returns the location of the calibration files - */ - virtual std::string getCalDir()=0; - - /** - sets the location of the calibration files - */ - virtual std::string setCalDir(std::string s)=0; - - /** Frees the shared memory - should not be used except for debugging*/ - virtual void freeSharedMemory()=0; + void setCurrentProgress(int i=0); /** - * Get user details of shared memory - * @returns string with user details + * Saves the detector setup to file + * @param fname file to write to + * @param level if 2 reads also trimbits, flat field, angular correction etc. + * and writes them to files with automatically added extension + * @returns OK or FAIL */ - virtual std::string getUserDetails() = 0; - - /** adds the detector name in position pos - \param name of the detector to be added (should already exist in shared memory or at least be online) - \param pos position where it should be added (normally at the end of the list (default to -1) - \return the actual number of detectors or -1 if it failed (always for slsDetector) - */ - virtual int addSlsDetector(char* name, int pos=-1){return -1;}; - - - /** - Turns off the server - do not use except for debugging! - */ - virtual int exitServer()=0; - - - - - /** - Loads dark image or gain image to the detector - \param index can be DARK_IMAGE or GAIN_IMAGE - \fname file name to load data from - \returns OK or FAIL - */ - virtual int loadImageToDetector(imageType index,std::string const fname)=0; - - - /** - writes the counter memory block from the detector - \param startACQ is 1 to start acquisition after reading counter - \fname file fname to load data from - \returns OK or FAIL - */ - virtual int writeCounterBlockFile(std::string const fname,int startACQ=0)=0; - - - /** - Resets counter memory block in detector - \param startACQ is 1 to start acquisition after resetting counter - \returns OK or FAIL - */ - virtual int resetCounterBlock(int startACQ=0)=0; - - /** set/get counter bit in detector - * @param i is -1 to get, 0 to reset and any other value to set the counter bit - /returns the counter bit in detector - */ - virtual int setCounterBit(int i = -1)=0; - - - /** - asks and receives all data from the detector and puts them in a data queue - \returns pointer to the front of the queue or NULL. - */ - virtual int* readAll()=0; - - - - - /** performs a complete acquisition including scansand data processing - moves the detector to next position
- starts and reads the detector
- reads the IC (if required)
- reads the encoder (iof required for angualr conversion)
- processes the data (flat field, rate, angular conversion and merging ::processData()) - \param delflag 0 leaves the data in the final data queue - \returns OK or FAIL depending on if it already started - */ - - int acquire(int delflag=1); - - /** - * Give an internal software trigger to the detector (Eiger only) - * @return OK or FAIL - */ - virtual int sendSoftwareTrigger()=0; - - - - // double* convertAngles(){return convertAngles(currentPosition);}; - // virtual double* convertAngles(double pos)=0; - - virtual int setThresholdEnergy(int, int im=-1, detectorSettings isettings=GET_SETTINGS, int tb=1)=0; - virtual int setChannel(int64_t, int ich=-1, int ichip=-1, int imod=-1)=0; - - virtual double getRateCorrectionTau()=0; - virtual int* startAndReadAll()=0; - - virtual int getTotalNumberOfChannels()=0; - virtual int getTotalNumberOfChannels(dimension d)=0; - virtual int getMaxNumberOfChannels()=0; - virtual int getMaxNumberOfChannels(dimension d)=0; - - /** returns the enable if data will be flipped across x or y axis - * \param d axis across which data is flipped - * returns 1 or 0 - */ - virtual int getFlippedData(dimension d=X)=0; - - // virtual int getParameters(); - - - - - int setTotalProgress(); - - double getCurrentProgress(); - - - void incrementProgress(); - void setCurrentProgress(int i=0); - - - /** - write register - \param addr address - \param val value - \returns current register value - - DO NOT USE!!! ONLY EXPERT USER!!! - */ - virtual uint32_t writeRegister(uint32_t addr, uint32_t val)=0; - - - /** - write ADC register - \param addr address - \param val value - \returns current register value - - DO NOT USE!!! ONLY EXPERT USER!!! - */ - virtual int writeAdcRegister(int addr, int val)=0; - - - /** - read register - \param addr address - \returns current register value - - DO NOT USE!!! ONLY EXPERT USER!!! - */ - virtual uint32_t readRegister(uint32_t addr)=0; - - - /** - sets a bit in a register - \param addr address - \param n nth bit ranging from 0 to 31 - \returns current register value - - DO NOT USE!!! ONLY EXPERT USER!!! - */ - virtual uint32_t setBit(uint32_t addr, int n)=0; - - - /** - clear a bit in a register - \param addr address - \param n nth bit ranging from 0 to 31 - \returns current register value - - DO NOT USE!!! ONLY EXPERT USER!!! - */ - virtual uint32_t clearBit(uint32_t addr, int n)=0; - - - /** - Returns the IP of the last client connecting to the detector - */ - virtual std::string getLastClientIP()=0; - - - - /** - configures mac for gotthard readout - \returns OK or FAIL - */ - - virtual int configureMAC()=0; - - - /** loads the modules settings/trimbits reading from a file - \param fname file name . If not specified, extension is automatically generated! - \param imod module number, -1 means all modules - \returns OK or FAIL - */ - virtual int loadSettingsFile(std::string fname, int imod=-1)=0; - - /** programs FPGA with pof file - \param fname file name - \returns OK or FAIL - */ - virtual int programFPGA(std::string fname)=0; - - /** resets FPGA - \returns OK or FAIL - */ - virtual int resetFPGA()=0; - - /** power on/off the chip - \param ival on is 1, off is 0, -1 to get - \returns OK or FAIL - */ - virtual int powerChip(int ival= -1)=0; - - /** automatic comparator disable for Jungfrau only - \param ival on is 1, off is 0, -1 to get - \returns OK or FAIL - */ - virtual int setAutoComparatorDisableMode(int ival= -1)=0; - - /** saves the modules settings/trimbits writing to a file - \param fname file name . Axtension is automatically generated! - \param imod module number, -1 means all modules - \returns OK or FAIL - */ - virtual int saveSettingsFile(std::string fname, int imod=-1)=0; - - /** sets all the trimbits to a particular value - \param val trimbit value - \param imod module number, -1 means all modules - \returns OK or FAIL - */ - virtual int setAllTrimbits(int val, int imod=-1)=0; - - - - - /** - set dacs value - \param val value (in V) - \param index DAC index - \param mV 0 in dac units or 1 in mV - \param imod module number (if -1 alla modules) - \returns current DAC value - */ - virtual dacs_t setDAC(dacs_t val, dacIndex index , int mV, int imod=-1)=0; - - - /** - gets ADC value - \param index ADC index - \param imod module number - \returns current ADC value - */ - virtual dacs_t getADC(dacIndex index, int imod=-1)=0; - - /** - set/gets threshold temperature (Jungfrau only) - \param val value in millidegrees, -1 gets - \param imod module number, -1 is all - \returns threshold temperature in millidegrees - */ - virtual int setThresholdTemperature(int val=-1, int imod=-1)=0; - - /** - enables/disables temperature control (Jungfrau only) - \param val value, -1 gets - \param imod module number, -1 is all - \returns temperature control enable - */ - virtual int setTemperatureControl(int val=-1, int imod=-1)=0; - - /** - Resets/ gets over-temperature event (Jungfrau only) - \param val value, -1 gets - \param imod module number, -1 is all - \returns over-temperature event - */ - virtual int setTemperatureEvent(int val=-1, int imod=-1)=0; - - /** - get the maximum size of the detector - \param d dimension - \returns maximum number of modules that can be installed in direction d - */ - virtual int getMaxNumberOfModules(dimension d=X)=0; - - double moveDetector(double pos){if (go_to_position) go_to_position (pos,GTarg); else cout << "no move detector callback registered" << endl; return getDetectorPosition();}; - double getDetectorPosition(){double pos=-1; if (get_position) pos=get_position(POarg); else cout << "no get position callback registered" << endl; return pos;}; - - /** - Writes the configuration file -- will contain all the informations needed for the configuration (e.g. for a PSI detector caldir, settingsdir, angconv, badchannels etc.) - \param fname file name - \returns OK or FAIL - */ - virtual int writeConfigurationFile(std::string const fname)=0; - - - void registerGetPositionCallback( double (*func)(void*),void *arg){get_position=func; POarg=arg;}; - void registerConnectChannelsCallback( int (*func)(void*),void *arg){connect_channels=func; CCarg=arg;}; - void registerDisconnectChannelsCallback(int (*func)(void*),void*arg){disconnect_channels=func;DCarg=arg;}; - - void registerGoToPositionCallback( int (*func)(double, void*),void *arg){go_to_position=func;GTarg=arg;}; - void registerGoToPositionNoWaitCallback(int (*func)(double, void*),void*arg){go_to_position_no_wait=func;GTNarg=arg;}; - void registerGetI0Callback( double (*func)(int, void*),void *arg){get_i0=func;IOarg=arg;}; - - void registerAcquisitionFinishedCallback(int( *func)(double,int, void*), void *pArg){acquisition_finished=func; acqFinished_p=pArg;}; - void registerMeasurementFinishedCallback(int( *func)(int,int, void*), void *pArg){measurement_finished=func; measFinished_p=pArg;}; - - void registerProgressCallback(int( *func)(double,void*), void *pArg){progress_call=func; pProgressCallArg=pArg;}; - - - /** - Saves the detector setup to file - \param fname file to write to - \param level if 2 reads also trimbits, flat field, angular correction etc. and writes them to files with automatically added extension - \returns OK or FAIL - - */ - int dumpDetectorSetup(std::string const fname, int level=0); - - - /** - Loads the detector setup from file - \param fname file to read from - \param level if 2 reads also reads trimbits, angular conversion coefficients etc. from files with default extensions as generated by dumpDetectorSetup - \returns OK or FAIL - - */ - int retrieveDetectorSetup(std::string const fname, int level=0); - - static int dummyAcquisitionFinished(double prog,int status,void* p){cout <<"Acquisition finished callback! " << prog << " " << status << endl; return 0;} - static int dummyMeasurementFinished(int im,int findex,void* p){cout <<"Measurement finished callback! " << im << " " << findex << endl; return 0;} - - - - - //receiver - - - /** - Checks if the receiver is really online - */ - virtual std::string checkReceiverOnline()=0; - - /** - Returns the IP of the last client connecting to the receiver - */ - virtual std::string getReceiverLastClientIP()=0; - - - /** - Sets up the file directory - @param fileName fileDir file directory - \returns file dir - */ - virtual std::string setFilePath(std::string s="")=0; - - /** - Sets up the file name - @param fileName file name - \returns file name - */ - virtual std::string setFileName(std::string s="")=0; - - /** - Sets the max frames per file in receiver - @param f max frames per file - \returns max frames per file in receiver - */ - virtual int setReceiverFramesPerFile(int f = -1) = 0; - - /** - Sets the frames discard policy in receiver - @param f frames discard policy - \returns frames discard policy set in receiver - */ - virtual frameDiscardPolicy setReceiverFramesDiscardPolicy(frameDiscardPolicy f = GET_FRAME_DISCARD_POLICY) = 0; - - /** - Sets the partial frames padding enable in receiver - @param f partial frames padding enable - \returns partial frames padding enable in receiver - */ - virtual int setReceiverPartialFramesPadding(int f = -1) = 0; - - /** - Sets up the file format - @param f file format - \returns file format - */ - virtual fileFormat setFileFormat(fileFormat f=GET_FILE_FORMAT)=0; - - /** - \returns file dir - */ - virtual std::string getFilePath()=0; - - /** - \returns file name - */ - virtual std::string getFileName()=0; - - /** - \returns file name - */ - virtual fileFormat getFileFormat()=0; - - /** - \returns frames caught by receiver - */ - virtual int getFramesCaughtByReceiver()=0; - - /** gets the number of frames caught by any one receiver (to avoid using threadpool) - \returns number of frames caught by any one receiver (master receiver if exists) - */ - virtual int getFramesCaughtByAnyReceiver()=0; - - /** - \returns current frame index of receiver - */ -virtual int getReceiverCurrentFrameIndex()=0; - -/** - * resets framescaught - * @param index frames caught by receiver -*/ -virtual int resetFramesCaught()=0; - -/** - * Create Receiving Data Sockets - * @param destroy is true to destroy all the sockets - * @return OK or FAIL - */ -virtual int createReceivingDataSockets(const bool destroy = false){return -1;}; - - -/** Reads frames from receiver through a constant socket -*/ - -virtual void readFrameFromReceiver(){}; - -/** - Turns off the receiver server! -*/ -virtual int exitReceiver()=0; - -/** - Sets/Gets file overwrite enable - @param enable 1 or 0 to set/reset file overwrite enable - /returns file overwrite enable -*/ -virtual int overwriteFile(int enable=-1)=0; - - -/** - Sets/Gets receiver file write enable - @param enable 1 or 0 to set/reset file write enable - /returns file write enable -*/ -virtual int enableWriteToFile(int enable=-1)=0; - -/** Starts acquisition, calibrates pedestal and writes to fpga - /returns number of frames -*/ -virtual int calibratePedestal(int frames = 0)=0; - - -/** - set roi - \param n number of rois - \param roiLimits array of roi - \returns success or failure -*/ -virtual int setROI(int n=-1,ROI roiLimits[]=NULL)=0; - -/** - get roi from each detector and convert it to the multi detector scale - \param n number of rois - \returns an array of multidetector's rois -*/ -virtual ROI* getROI(int &n)=0; - -/** Sets the read receiver frequency - if data required from receiver randomly readRxrFrequency=0, - else every nth frame to be sent to gui - @param freq is the receiver read frequency - /returns read receiver frequency - */ -virtual int setReadReceiverFrequency(int freq=-1)=0; - -/** - * Enable data streaming to client - * @param enable 0 to disable, 1 to enable, -1 to get the value - * @returns data streaming to client enable - */ -virtual int enableDataStreamingToClient(int enable=-1)=0; - -/** Enable or disable streaming data from receiver to client - * @param enable 0 to disable 1 to enable -1 to only get the value - * @returns data streaming from receiver enable -*/ -virtual int enableDataStreamingFromReceiver(int enable=-1)=0; - - -/** enable/disable or get data compression in receiver - * @param i is -1 to get, 0 to disable and 1 to enable - /returns data compression in receiver - */ -virtual int enableReceiverCompression(int i = -1)=0; - -/** enable/disable or 10Gbe - * @param i is -1 to get, 0 to disable and 1 to enable - /returns if 10Gbe is enabled - */ -virtual int enableTenGigabitEthernet(int i = -1)=0; - -/** set/get receiver fifo depth - * @param i is -1 to get, any other value to set the fifo deph - /returns the receiver fifo depth - */ -virtual int setReceiverFifoDepth(int i = -1)=0; - -/** set/get receiver silent mode - * @param i is -1 to get, 0 unsets silent mode, 1 sets silent mode - /returns the receiver silent mode enable - */ -virtual int setReceiverSilentMode(int i = -1)=0; - - /******** CTB funcs */ - - /** opens pattern file and sends pattern to CTB - @param fname pattern file to open - @returns OK/FAIL - */ - virtual int setCTBPattern(std::string fname)=0; - - - /** Writes a pattern word to the CTB - @param addr address of the word, -1 is I/O control register, -2 is clk control register - @param word 64bit word to be written, -1 gets - @returns actual value - */ - virtual uint64_t setCTBWord(int addr,uint64_t word=-1)=0; - - /** Sets the pattern or loop limits in the CTB - @param level -1 complete pattern, 0,1,2, loop level - @param start start address if >=0 - @param stop stop address if >=0 - @param n number of loops (if level >=0) - @returns OK/FAIL - */ - virtual int setCTBPatLoops(int level,int &start, int &stop, int &n)=0; - - - /** Sets the wait address in the CTB - @param level 0,1,2, wait level - @param addr wait address, -1 gets - @returns actual value - */ - virtual int setCTBPatWaitAddr(int level, int addr=-1)=0; - - /** Sets the wait time in the CTB - @param level 0,1,2, wait level - @param t wait time, -1 gets - @returns actual value - */ - virtual int setCTBPatWaitTime(int level, uint64_t t=-1)=0; - - /** - Pulse Pixel - \param n is number of times to pulse - \param x is x coordinate - \param y is y coordinate - \returns OK or FAIL - */ - virtual int pulsePixel(int n=0,int x=0,int y=0)=0; - - /** - Pulse Pixel and move by a relative value - \param n is number of times to pulse - \param x is relative x value - \param y is relative y value - \returns OK or FAIL - */ - virtual int pulsePixelNMove(int n=0,int x=0,int y=0)=0; - - /** - Pulse Chip - \param n is number of times to pulse - \returns OK or FAIL - */ - virtual int pulseChip(int n=0)=0; - - /** - Set acquiring flag in shared memory - \param b acquiring flag - */ - virtual void setAcquiringFlag(bool b=false)=0; - - /** - Get acquiring flag from shared memory - \returns acquiring flag - */ - virtual bool getAcquiringFlag() = 0; - - - /** - * Check if acquiring flag is set, set error if set - * \returns FAIL if not ready, OK if ready - */ - virtual bool isAcquireReady() = 0; - - - /** - * Check version compatibility with detector/receiver software - * (if hostname/rx_hostname has been set/ sockets created) - * \param p port type control port or data (receiver) port - * \returns FAIL for incompatibility, OK for compatibility - */ - virtual int checkVersionCompatibility(portType t) = 0; - - protected: - - - static const int64_t thisSoftwareVersion=0x20141013; - - - - //protected: - int *stoppedFlag; - int64_t *timerValue; - detectorSettings *currentSettings; - int *currentThresholdEV; - - - int totalProgress; - - int progressIndex; - - double (*get_position)(void*); - int (*go_to_position)(double, void*); - int (*go_to_position_no_wait)(double, void*); - int (*connect_channels)(void*); - int (*disconnect_channels)(void*); - double (*get_i0)(int, void*); - void *POarg,*CCarg,*DCarg,*GTarg,*GTNarg,*IOarg; - int (*acquisition_finished)(double,int,void*); - int (*measurement_finished)(int,int,void*); - void *acqFinished_p, *measFinished_p; - int (*progress_call)(double,void*); - void *pProgressCallArg; - - /** semaphore to let postprocessing thread continue for next scan/measurement */ - sem_t sem_newRTAcquisition; - /** semaphore to let main thread know it got all the dummy packets (also from ext. process) */ - sem_t sem_endRTAcquisition; - + int dumpDetectorSetup(std::string const fname, int level=0); + + /** (used by multi and sls) + * reads a short int rawdata file + * @param name of the file to be read + * @param data array of data value + * @param nch number of channels + * @returns OK or FAIL if it could not read the file or data=NULL + */ + int readDataFile(std::string fname, short int *data, int nch); + + /** (used by multi and sls) + * reads a short int raw data file + * @param infile input file stream + * @param data array of data values + * @param nch number of channels + * @param offset start channel value + * @returns OK or FAIL if it could not read the file or data=NULL + */ + int readDataFile(std::ifstream &infile, short int *data, int nch, int offset); + + /** + * reads a short int raw data file + * @param fname of the file to be read + * @param data array of data values + * @returns OK or FAIL if it could not read the file or data=NULL + */ + int readDataFile(std::string fname, short int *data){ + return readDataFile(fname, data, getTotalNumberOfChannels()); + }; + /** + * reads a short int raw data file + * @param infile input file stream + * @param data array of data values + * @param offset first channel number to be expected + * @returns OK or FAIL if it could not read the file or data=NULL + */ + int readDataFile(std::ifstream &infile, short int *data, int offset=0){ + return readDataFile(infile, data, getTotalNumberOfChannels(),offset); + }; + + /** (used by multi and sls) + * writes a short int raw data file + * @param fname of the file to be written + * @param nch number of channels + * @param data array of data values + * @returns OK or FAIL if it could not write the file or data=NULL + */ + int writeDataFile(std::string fname,int nch, short int *data); + + /** (used by multi and sls) + * writes a short int raw data file + * @param outfile output file stream + * @param nch number of channels + * @param data array of data values + * @param offset start channel number + * @returns OK or FAIL if it could not write the file or data=NULL + */ + int writeDataFile(std::ofstream &outfile,int nch, short int *data, int offset=0) ; + + /** + * writes a data file of short ints + * @param fname of the file to be written + * @param data array of data values + * @returns OK or FAIL if it could not write the file or data=NULL + */ + int writeDataFile(std::string fname, short int *data){ + return writeDataFile(fname, getTotalNumberOfChannels(), data); + }; + + /** + * writes a data file of short ints + * @param outfile output file stream + * @param data array of data values + * @param offset start channel number + * @returns OK or FAIL if it could not write the file or data=NULL + */ + int writeDataFile(std::ofstream &outfile, short int *data, int offset=0){ + return writeDataFile(outfile, getTotalNumberOfChannels(), data, offset); + }; + + /** + * Loads the detector setup from file + * @param fname file to read from + * @param level if 2 reads also reads trimbits, angular conversion coefficients etc. + * from files with default extensions as generated by dumpDetectorSetup + * @returns OK or FAIL + */ + int retrieveDetectorSetup(std::string const fname, int level=0); + + void registerAcquisitionFinishedCallback(int( *func)(double,int, void*), void *pArg){acquisition_finished=func; acqFinished_p=pArg;}; + + void registerMeasurementFinishedCallback(int( *func)(int,int, void*), void *pArg){measurement_finished=func; measFinished_p=pArg;}; + + void registerProgressCallback(int( *func)(double,void*), void *pArg){progress_call=func; pProgressCallArg=pArg;}; + + static int dummyAcquisitionFinished(double prog,int status,void* p){std::cout <<"Acquisition finished callback! " << prog << " " << status << std::endl; return 0;} + + static int dummyMeasurementFinished(int im,int findex,void* p){std::cout <<"Measurement finished callback! " << im << " " << findex << std::endl; return 0;} + + +protected: + + static const int64_t thisSoftwareVersion=0x20141013; + + int *stoppedFlag; + int64_t *timerValue; + detectorSettings *currentSettings; + int *currentThresholdEV; + + int totalProgress; + int progressIndex; + + int (*acquisition_finished)(double,int,void*); + int (*measurement_finished)(int,int,void*); + void *acqFinished_p, *measFinished_p; + int (*progress_call)(double,void*); + void *pProgressCallArg; + + /** semaphore to let postprocessing thread continue for next scan/measurement */ + sem_t sem_newRTAcquisition; + + /** semaphore to let main thread know it got all the dummy packets (also from ext. process) */ + sem_t sem_endRTAcquisition; }; diff --git a/slsDetectorSoftware/slsDetectorAnalysis/AngularConversion_Standalone.cpp b/slsDetectorSoftware/slsDetectorAnalysis/AngularConversion_Standalone.cpp deleted file mode 100644 index 36f40e2bd..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/AngularConversion_Standalone.cpp +++ /dev/null @@ -1,527 +0,0 @@ -#include "AngularConversion_Standalone.h" - -#include -#include -#include -#include -#include "usersFunctions.h" - -using namespace std; - -angularConversion::angularConversion( int *np, double *pos, double *bs, double *fo, double *go): currentPosition(0), - currentPositionIndex(0), - numberOfPositions(np), - detPositions(pos), - binSize(bs), - fineOffset(fo), - globalOffset(go) - -{ - //angleFunctionPointer=0; - registerAngleFunctionCallback(&defaultAngleFunction,NULL); - registerCallBackGetChansPerMod(&defaultGetChansPerMod,this); - registerCallBackGetNumberofChannel(&defaultGetNumberofChannel,this); -} - -angularConversion::~angularConversion(){ - -} - -// 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* angularConversion::convertAngles(double pos) { - int imod=0; - double *ang=new double[totalNumberOfChannels]; - double enc=pos; - angleConversionConstant *p=NULL; - - int ch0=0; - int chlast=getChansPerMods(imod); - int nchmod=getChansPerMods(imod); - p=angConvs+imod; - if (moveFlag[imod]==0) - enc=0; - else - enc=pos; - - for (int ip=0; ip=chlast) { - imod++; - p=angConvs+imod; - if (moveFlag[imod]==0) - enc=0; - else - enc=pos; - - ch0=chlast; - nchmod=getChansPerMods(imod); - if (nchmod>0) - chlast+=nchmod; - } - - if (p) - ang[ip]=angle(ip-ch0, \ - enc, \ - (*fineOffset)+(*globalOffset), \ - p->r_conversion, \ - p->center, \ - p->offset, \ - p->tilt, \ - *angDirection ); - } - return ang; -} - - - -//static! -int angularConversion::readAngularConversion(string fname, int nmod, angleConversionConstant *angOff) { - - ifstream infile; - string ss; - -#ifdef VERBOSE - std::cout<< "Opening file "<< fname << std::endl; -#endif - infile.open(fname.c_str(), ios_base::in); - if (infile.is_open()) { - readAngularConversion(infile, nmod, angOff); - infile.close(); - } else { - std::cout<< "Could not open calibration file "<< fname << std::endl; - return -1; - } - return 0; -} - - -//static -int angularConversion::readAngularConversion( ifstream& infile, int nmod, angleConversionConstant *angOff) { - string str; - int mod; - double center, ecenter; - double r_conv, er_conv; - double off, eoff; - string ss; - int interrupt=0; - int nm=0; - //" module %i center %E +- %E conversion %E +- %E offset %f +- %f \n" - while (infile.good() and interrupt==0) { - getline(infile,str); -#ifdef VERBOSE - cout << "** mod " << nm << " " ; - std::cout<< str << std::endl; -#endif - istringstream ssstr(str); - ssstr >> ss >> mod; - ssstr >> ss >> center; - ssstr >> ss >> ecenter; - ssstr >> ss >> r_conv; - ssstr >> ss >> er_conv; - ssstr >> ss >> off; - ssstr >> ss >> eoff; - if (nm=0 ) { - angOff[nm].center=center; - angOff[nm].r_conversion=r_conv; - angOff[nm].offset=off; - angOff[nm].ecenter=ecenter; - angOff[nm].er_conversion=er_conv; - angOff[nm].eoffset=eoff; - } else - break; - //cout << nm<<" " << angOff[nm].offset << endl; - nm++; - if (nm>=nmod) - break; - - } - return nm; - } - -//static -int angularConversion:: writeAngularConversion(string fname, int nmod, angleConversionConstant *angOff) { - - ofstream outfile; - outfile.open (fname.c_str(),ios_base::out); - if (outfile.is_open()) - { - writeAngularConversion(outfile, nmod, angOff); - outfile.close(); - } else { - std::cout<< "Could not open file " << fname << "for writing"<< std::endl; - return -1; - } - //" module %i center %E +- %E conversion %E +- %E offset %f +- %f \n" - return 0; -} - - - -//static -int angularConversion:: writeAngularConversion(ofstream& outfile, int nmod, angleConversionConstant *angOff) { - - for (int imod=0; imod0) { - -#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++; - } - } - return np; -} - -//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 ) { - - - double binmi=-180.; - int ibin=0; - - if (p1==NULL) - return 0; - if (v1==NULL) - return FAIL; - - if (mp==NULL) //can be changed if we want to use a fixed bin algorithm! - return FAIL; - - if (mv==NULL) - return FAIL; - if (me==NULL) - return FAIL; - if (mm==NULL) - return FAIL; - if (nchans==0) - return FAIL; - - if (binsize<=0) - return FAIL; - - if (nbins<=0) - return FAIL; - - for (int ip=0; ip=0) { - mp[ibin]+=p1[ip]; - mv[ibin]+=v1[ip]; - if (e1) - me[ibin]+=(e1[ip]*e1[ip]); - 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; - } - - - 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 -#include - - - - //double angle(int ichan, double encoder, double totalOffset, double conv_r, double center, double offset, double tilt, int direction) - - -using namespace std; - -/** - @short Angular conversion constants needed for a detector module - */ -typedef struct { - double center; /**< center of the module (channel at which the radius is perpendicular to the module surface) */ - double ecenter; /**< error in the center determination */ - double r_conversion; /**< detector pixel size (or strip pitch) divided by the diffractometer radius */ - double er_conversion; /**< error in the r_conversion determination */ - double offset; /**< the module offset i.e. the position of channel 0 with respect to the diffractometer 0 */ - double eoffset; /**< error in the offset determination */ - double tilt; /**< ossible tilt in the orthogonal direction (unused)*/ - double etilt; /**< error in the tilt determination */ -} angleConversionConstant; - - -/** - -@short methods to set/unset the angular conversion and merge the data -class containing the methods to set/unset the angular conversion and merge the data - - -The angular conversion itself is defined by the angle() function defined in usersFunctions.cpp - -*/ -class angularConversion : public virtual slsDetectorDefs { //: public virtual slsDetectorBase { - - public: - /** default constructor */ - angularConversion(int*, double*, double*, double*, double*); - /** virtual destructor */ - virtual ~angularConversion(); - - - - //virtual int readAngularConversion(string fname)=0; - - - - - /** - - reads an angular conversion file - \param fname file to be read - \param nmod number of modules (maximum) to be read - \param angOff pointer to array of angleConversionConstants - \returns OK or FAIL - */ - static int readAngularConversion(string fname, int nmod, angleConversionConstant *angOff); - - /** - reads an angular conversion file - \param ifstream input file stream to be read - \param nmod number of modules (maximum) to be read - \param angOff pointer to array of angleConversionConstants - \returns OK or FAIL - - */ - static int readAngularConversion(ifstream& ifs, int nmod, angleConversionConstant *angOff); - /** - writes an angular conversion file - \param fname file to be written - \param nmod number of modules to be written - \param angOff pointer to array of angleConversionConstants - \returns OK or FAIL - */ - static int writeAngularConversion(string fname, int nmod, angleConversionConstant *angOff); - - /** - writes an angular conversion file - \param ofstream output file stream - \param nmod number of modules to be written - \param angOff pointer to array of angleConversionConstants - \returns OK or FAIL - */ - static int writeAngularConversion(ofstream& ofs, int nmod, angleConversionConstant *angOff); - - /** - sets the arrays of the merged data to 0. NB The array should be created with size nbins >= 360./getBinSize(); - \param mp already merged postions - \param mv already merged data - \param me already merged errors (squared sum) - \param mm multiplicity of merged arrays - \param nbins number of bins - \returns OK or FAIL - */ - static int resetMerging(double *mp, double *mv,double *me, int *mm, int nbins); - /** - sets the arrays of the merged data to 0. NB The array should be created with size >= 360./getBinSize(); - \param mp already merged postions - \param mv already merged data - \param me already merged errors (squared sum) - \param mm multiplicity of merged arrays - \returns OK or FAIL - */ - int resetMerging(double *mp, double *mv,double *me, int *mm); - - /** - creates the arrays for merging the data and sets them to 0. - */ - int resetMerging(); - - /** - merge dataset - \param p1 angular positions of dataset - \param v1 data - \param e1 errors - \param mp already merged postions - \param mv already merged data - \param me already merged errors (squared sum) - \param mm multiplicity of merged arrays - \param nchans number of channels - \param binsize size of angular bin - \param nb number of angular bins - \param badChanMask badchannelmask (if NULL does not correct for bad channels) - \returns OK or FAIL - */ - - static int addToMerging(double *p1, double *v1, double *e1, double *mp, double *mv,double *me, int *mm, int nchans, double binsize,int nb, int *badChanMask ); - - /** - merge dataset - \param p1 angular positions of dataset - \param v1 data - \param e1 errors - \param mp already merged postions - \param mv already merged data - \param me already merged errors (squared sum) - \param mm multiplicity of merged arrays - \param badChanMask badchannelmask (if NULL does not correct for bad channels) - \returns OK or FAIL - */ - - int addToMerging(double *p1, double *v1, double *e1, double *mp, double *mv,double *me, int *mm, int *badChanMask); - /** - merge dataset - \param p1 angular positions of dataset - \param v1 data - \param e1 errors - \param badChanMask badchannelmask (if NULL does not correct for bad channels) - \returns OK or FAIL - */ - - int addToMerging(double *p1, double *v1, double *e1,int *badChanMask); - - /** - calculates the "final" positions, data value and errors for the merged data - \param mp already merged postions - \param mv already merged data - \param me already merged errors (squared sum) - \param mm multiplicity of merged arrays - \param nb number of bins - \returns FAIL or the number of non empty bins (i.e. points belonging to the pattern) - */ - - static int finalizeMerging(double *mp, double *mv,double *me, int *mm, int nb); - /** - calculates the "final" positions, data value and errors for the merged data - \param mp already merged postions - \param mv already merged data - \param me already merged errors (squared sum) - \param mm multiplicity of merged arrays - \returns FAIL or the number of non empty bins (i.e. points belonging to the pattern) - */ - - int finalizeMerging(double *mp, double *mv,double *me, int *mm); - -/** - calculates the "final" positions, data value and errors for the merged data - \returns FAIL or the number of non empty bins (i.e. points belonging to the pattern) - */ - - int finalizeMerging(); - - - /** - set detector global offset - \param f global offset to be set - \returns actual global offset - */ - double setGlobalOffset(double f){return setAngularConversionParameter(GLOBAL_OFFSET,f);}; - - - /** - set detector fine offset - \param f global fine to be set - \returns actual fine offset - */ - double setFineOffset(double f){return setAngularConversionParameter(FINE_OFFSET,f);}; - - /** - get detector fine offset - \returns actual fine offset - */ - double getFineOffset(){return getAngularConversionParameter(FINE_OFFSET);}; - - /** - get detector global offset - \returns actual global offset - */ - double getGlobalOffset(){return getAngularConversionParameter(GLOBAL_OFFSET);}; - - /** - - set detector bin size - \param bs bin size to be set - \returns actual bin size - */ - double setBinSize(double bs){if (bs>0) nBins=360/bs; return setAngularConversionParameter(BIN_SIZE,bs);}; - - /** - get detector bin size - \returns detector bin size used for merging (approx angular resolution) - */ - double getBinSize() {return getAngularConversionParameter(BIN_SIZE);}; - - - - /** - - get angular direction - \returns actual angular direction (1 is channel number increasing with angle, -1 decreasing) - */ - int getAngularDirection(){return (int)getAngularConversionParameter(ANGULAR_DIRECTION);}; - - - /** - - set angular direction - \param d angular direction to be set (1 is channel number increasing with angle, -1 decreasing) - \returns actual angular direction (1 is channel number increasing with angle, -1 decreasing) - */ - int setAngularDirection(int d){return (int)setAngularConversionParameter(ANGULAR_DIRECTION, (double)d);}; - - /** - \returns number of angular bins in the merging (360./binsize) - */ - int getNumberOfAngularBins(){return nBins;}; - - - - /** - set angular conversion parameter - \param c parameter type (globaloffset, fineoffset, binsize, angular direction, move flag) - \param v value to be set - \returns actual value - */ - double setAngularConversionParameter(angleConversionParameter c, double v); - /** - get angular conversion parameter - \param c parameter type (globaloffset, fineoffset, binsize, angular direction, move flag) - \returns actual value - */ - double getAngularConversionParameter(angleConversionParameter c); - - - - - /** - set positions for the acquisition - \param nPos number of positions - \param pos array with the encoder positions - \returns number of positions - */ - virtual int setPositions(int nPos, double *pos); - /** - get positions for the acquisition - \param pos array which will contain the encoder positions - \returns number of positions - */ - virtual int getPositions(double *pos=NULL); - - /** - deletes the array of merged data - \returns OK - */ - int deleteMerging(); - - /** - \returns pointer to the array o merged positions - */ - double *getMergedPositions(){return mergingBins;}; - /** - \returns pointer to the array of merged counts - */ - double *getMergedCounts(){return mergingCounts;}; - /** - \returns pointer to the array of merged errors - */ - double *getMergedErrors(){return mergingErrors;}; - - - - -/* /\** */ -/* reads teh angular conversion file for the (multi)detector and writes it to shared memory */ -/* *\/ */ -/* virtual int readAngularConversionFile(string fname="")=0; */ - -/* /\** */ -/* get angular conversion */ -/* \param direction reference to diffractometer direction */ -/* \param angconv array that will be filled with the angular conversion constants */ -/* \returns 0 if angular conversion disabled, >0 otherwise */ -/* *\/ */ - virtual int getAngularConversion(int &direction, angleConversionConstant *angoff=NULL); - -/* /\** */ -/* pure virtual function */ -/* \param file name to be written (nmod and array of angular conversion constants default to the ones ot the slsDetector */ -/* *\/ */ -/* virtual int writeAngularConversion(string fname)=0; */ - - - - -/* /\** */ -/* \returns number of modules of the (multi)detector */ -/* *\/ */ -/* virtual int getNMods()=0; */ - -/* /\** */ -/* returns number of channels in the module */ -/* \param imod module number */ -/* \returns number of channels in the module */ -/* *\/ */ - - - static int defaultGetNumberofChannel(int nch, void *p=NULL ) { ((angularConversion*)p)->setTotalNumberOfChannels(nch); return 0;}; - static int defaultGetChansPerMod(int imod=0, void *p=NULL){ ((angularConversion*)p)->setChansPerMod(0,imod); return 0;}; - - int setChansPerMod(int nch, int imod=0){if (nch<0) return -1; if (imod>=0 && imod=0){ totalNumberOfChannels=i; return totalNumberOfChannels;} else return -1;}; - - -/* /\** */ -/* get the angular conversion contant of one modules */ -/* \param imod module number */ -/* \returns pointer to the angular conversion constant */ -/* *\/ */ -/* virtual angleConversionConstant *getAngularConversionPointer(int imod=0)=0; */ -/* /\** */ -/* \param imod module number */ -/* \returns move flag of the module (1 encoder is added to the angle, 0 not) */ -/* *\/ */ -/* virtual int getMoveFlag(int imod)=0; */ - -/* /\** */ -/* enables/disable the angular conversion */ -/* \param i 1 sets, 0 unsets,, -1 gets */ -/* \returns actual angular conversion flag */ -/* *\/ */ -/* virtual int setAngularCorrectionMask(int i=-1)=0; */ - - - - /** - converts channel number to angle - \param pos encoder position - \returns array of angles corresponding to the channels - */ - double* convertAngles(double pos); - /** - converts channel number to angle for the current encoder position - \returns array of angles corresponding to the channels - */ - double *convertAngles(){return convertAngles(currentPosition);}; - - - /** - returns number of positions - */ - int getNumberOfPositions() {return *numberOfPositions;}; - - int getChansPerMods(int imod) { return chansPerMod[imod];}; - int getTotalNumberofChannels(){ return totalNumberOfChannels;}; - - - void incrementPositionIndex() {currentPositionIndex++;}; - - void registerCallBackGetChansPerMod(int (*func)(int, void *),void *arg){ getChansPerModule=func;pChpermod=arg;}; - void registerCallBackGetNumberofChannel(int (*func)(int, void *),void *arg){ getNumberofChannel=func;pNumberofChannel=arg;}; - - protected: - - - - private: - - - int (*getChansPerModule)(int, void*); - int (*getNumberofChannel)(int, void*); - - void *pChpermod,*angPtr,*pNumberofChannel; - - - /** merging bins */ - double *mergingBins; - - /** merging counts */ - double *mergingCounts; - - /** merging errors */ - double *mergingErrors; - - /** merging multiplicity */ - int *mergingMultiplicity; - - double (*angle)(double, double, double, double, double, double, double, int); - - - - int totalNumberOfChannels; - - int moveFlag[MAXMODS*MAXDET]; - - /** pointer to number of positions for the acquisition*/ - int *numberOfPositions; - - /** pointer to the detector positions for the acquisition*/ - double *detPositions; - - - /** pointer to angular bin size*/ - double *binSize; - - int *correctionMask; - int chansPerMod[MAXMODS*MAXDET]; - int nMod; - angleConversionConstant angConvs[MAXMODS*MAXDET]; - int directions[MAXMODS*MAXDET]; - - - /** pointer to beamline fine offset*/ - double *fineOffset; - /** pointer to beamline global offset*/ - double *globalOffset; - /** pointer to beamline angular direction*/ - int *angDirection; - - /** pointer to detector move flag (1 moves with encoder, 0 not)*/ - // int *moveFlag; - - /** number of bins for angular conversion (360./binsize)*/ - int nBins; - - - - /** - current position of the detector - */ - double currentPosition; - /** - current position index of the detector - */ - int currentPositionIndex; - - - /** - returns current position index - */ - int getCurrentPositionIndex() {return currentPositionIndex;}; - - - - - - void registerAngleFunctionCallback(double( *fun)(double, double, double, double, double, double, double, int),void* arg) {angle = fun; angPtr=arg;}; - - -}; - -#endif diff --git a/slsDetectorSoftware/slsDetectorAnalysis/FileIO_Standalone.cpp b/slsDetectorSoftware/slsDetectorAnalysis/FileIO_Standalone.cpp deleted file mode 100644 index 27bee95b3..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/FileIO_Standalone.cpp +++ /dev/null @@ -1,650 +0,0 @@ -#include "FileIO_Standalone.h" - - - - - -string fileIO::createFileName(char *filepath, char *filename, int aMask, double sv0, int prec0, double sv1, int prec1, int pindex, int npos, int findex) { - ostringstream osfn; - // string fn; - /*directory name +root file name */ - osfn << filepath << "/" << filename; - - // cout << osfn.str() << endl; - - // scan level 0 - if ( aMask& (1 << (MAX_ACTIONS))) - osfn << "_S" << fixed << setprecision(prec0) << sv0; - - //cout << osfn.str() << endl; - - //scan level 1 - if (aMask & (1 << (MAX_ACTIONS+1))) - osfn << "_s" << fixed << setprecision(prec1) << sv1; - - //cout << osfn.str() << endl; - - - //position - if (pindex>0 && pindex<=npos) - osfn << "_p" << pindex; - - //cout << osfn.str() << endl; - - // file index - osfn << "_" << findex; - - //cout << osfn.str() << endl; - - -#ifdef VERBOSE - cout << "created file name " << osfn.str() << endl; -#endif - - //cout << osfn.str() << endl; - //fn=oosfn.str()sfn.str(); - return osfn.str(); - -} - - - /* I/O */ - -/* generates file name without extension*/ - -string fileIO::createFileName(int aMask, double sv0, int prec0, double sv1, int prec1, int pindex, int npos) { - currentFileName=createFileName(filePath, \ - fileName, \ - aMask, \ - sv0, \ - prec0, \ - sv1, \ - prec1, \ - pindex, \ - npos, \ - *fileIndex \ - ); - return currentFileName; - -} - - -int fileIO::getFileIndexFromFileName(string fname) { - int i; - size_t dot=fname.rfind("."); - if (dot==string::npos) - return -1; - size_t uscore=fname.rfind("_"); - if (uscore==string::npos) - return -1; - - if (sscanf( fname.substr(uscore+1,dot-uscore-1).c_str(),"%d",&i)) { - - return i; - } - //#ifdef VERBOSE - cout << "******************************** cannot parse file index" << endl; - //#endif - return 0; -} - -int fileIO::getVariablesFromFileName(string fname, int &index, int &p_index, double &sv0, double &sv1) { - - int i; - double f; - string s; - - - index=-1; - p_index=-1; - sv0=-1; - sv1=-1; - - - // size_t dot=fname.rfind("."); - //if (dot==string::npos) - // return -1; - size_t uscore=fname.rfind("_"); - if (uscore==string::npos) - return -1; - s=fname; - - //if (sscanf(s.substr(uscore+1,dot-uscore-1).c_str(),"%d",&i)) { - if (sscanf(s.substr(uscore+1,s.size()-uscore-1).c_str(),"%d",&i)) { - index=i; -#ifdef VERBOSE - cout << "******************************** file index is " << index << endl; -#endif - //return i; - s=fname.substr(0,uscore); - } - else - cout << "******************************** cannot parse file index" << endl; - -#ifdef VERBOSE - cout << s << endl; -#endif - - - uscore=s.rfind("_"); - - - - - if (sscanf( s.substr(uscore+1,s.size()-uscore-1).c_str(),"p%d",&i)) { - p_index=i; -#ifdef VERBOSE - cout << "******************************** position index is " << p_index << endl; -#endif - s=fname.substr(0,uscore); - } - else - cout << "******************************** cannot parse position index" << endl; - -#ifdef VERBOSE - cout << s << endl; -#endif - - - - - uscore=s.rfind("_"); - - - - - if (sscanf( s.substr(uscore+1,s.size()-uscore-1).c_str(),"s%f",&f)) { - sv1=f; -#ifdef VERBOSE - cout << "******************************** scan variable 1 is " << sv1 << endl; -#endif - s=fname.substr(0,uscore); - } - else - cout << "******************************** cannot parse scan varable 1" << endl; - -#ifdef VERBOSE - cout << s << endl; - - -#endif - - uscore=s.rfind("_"); - - - - - if (sscanf( s.substr(uscore+1,s.size()-uscore-1).c_str(),"S%f",&f)) { - sv0=f; -#ifdef VERBOSE - cout << "******************************** scan variable 0 is " << sv0 << endl; -#endif - } - else - cout << "******************************** cannot parse scan varable 0" << endl; - -#ifdef VERBOSE -#endif - - - - return index; -} - - - - - -int fileIO::writeDataFile(string fname, int nch, double *data, double *err, double *ang, char dataformat){ - - - ofstream outfile; - // int idata; - if (data==NULL) - return FAIL; - - // args|=0x10; // one line per channel! - - outfile.open (fname.c_str(),ios_base::out); - if (outfile.is_open()) - { - writeDataFile(outfile, nch, data, err, ang, dataformat, 0); - outfile.close(); - return OK; - } else { - std::cout<< "Could not open file " << fname << "for writing"<< std::endl; - return FAIL; - } -}; - - -int fileIO::writeDataFile(ofstream &outfile, int nch, double *data, double *err, double *ang, char dataformat, int offset){ - - - int idata; - if (data==NULL) - return FAIL; - - // args|=0x10; // one line per channel! - - cout << "Static file " << endl; - - - for (int ichan=0; ichan> ichan >> fdata; - //ich=ichan; - if (ssstr.fail() || ssstr.bad()) { - interrupt=1; - break; - } - // if (ich!=iline) - // std::cout<< "Channel number " << ichan << " does not match with line number " << iline << " " << dataformat << std::endl; - ich=iline; - if (ichan> fang >> fdata; - ich=iline; - } - if (ssstr.fail() || ssstr.bad()) { - interrupt=1; - break; - } - if (err) - ssstr >> ferr; - if (ssstr.fail() || ssstr.bad()) { - interrupt=1; - break; - } - if (ich=nch) { - interrupt=1; - break; - } - } - return iline; -}; - - - -int fileIO::readDataFile(string fname, int *data, int nch){ - - ifstream infile; - int iline=0;//ichan, idata, - //int interrupt=0; - string str; - -#ifdef VERBOSE - std::cout<< "Opening file "<< fname << std::endl; -#endif - infile.open(fname.c_str(), ios_base::in); - if (infile.is_open()) { - iline=readDataFile(infile, data, nch, 0); - infile.close(); - } else { - std::cout<< "Could not read file " << fname << std::endl; - return -1; - } - return iline; -}; - -int fileIO::readDataFile(ifstream &infile, int *data, int nch, int offset){ - - int ichan, idata, iline=0; - int interrupt=0; - string str; - - - while (infile.good() and interrupt==0) { - getline(infile,str); -#ifdef VERBOSE - std::cout<< str << std::endl; -#endif - istringstream ssstr(str); - ssstr >> ichan >> idata; - if (ssstr.fail() || ssstr.bad()) { - interrupt=1; - break; - } - // if (ichan!=iline) { -// std::cout<< " Expected channel "<< iline <<" but read channel "<< ichan << std::endl; -// interrupt=1; -// break; -// } else { - if (iline=offset) { - data[iline]=idata; - iline++; - } - } else { - interrupt=1; - break; - } - // } - } - return iline; -}; - - -int fileIO::readDataFile(string fname, short int *data, int nch){ - - ifstream infile; - int iline=0;//ichan, - //int interrupt=0; - string str; - -#ifdef VERBOSE - std::cout<< "Opening file "<< fname << std::endl; -#endif - infile.open(fname.c_str(), ios_base::in); - if (infile.is_open()) { - iline=readDataFile(infile, data, nch, 0); - infile.close(); - } else { - std::cout<< "Could not read file " << fname << std::endl; - return -1; - } - return iline; -}; - -int fileIO::readDataFile(ifstream &infile, short int *data, int nch, int offset){ - - int ichan, iline=0; - short int idata; - int interrupt=0; - string str; - while (infile.good() and interrupt==0) { - getline(infile,str); -#ifdef VERBOSE - ;//std::cout<< str << std::endl; -#endif - istringstream ssstr(str); - ssstr >> ichan >> idata; - if (ssstr.fail() || ssstr.bad()) { - interrupt=1; - break; - } - // if (ichan!=iline) { -// std::cout<< " Expected channel "<< iline <<" but read channel "<< ichan << std::endl; -// interrupt=1; -// break; -// } else { - if (iline=offset) { - data[iline]=idata; - iline++; - } - } else { - interrupt=1; - break; - } - // } -#ifdef VERBOSE - ;//std::cout<< "read " << iline <<" channels " << std::endl; -#endif - } - return iline; -} - - - -/*writes raw data file */ - -int fileIO::writeDataFile(string fname, double *data, double *err, double *ang, char dataformat, int nch){ - if (nch==-1) - nch=getTotalNumberofChannels();//getTotalNumberOfChannels(); - - return writeDataFile(fname, nch, data, err, ang, dataformat); - -} -int fileIO::writeDataFile(ofstream &outfile, double *data, double *err, double *ang, char dataformat, int nch, int offset){ - if (nch==-1) - nch=getTotalNumberofChannels(); - - return writeDataFile(outfile, nch, data, err, ang, dataformat, offset); - -} - - - - -int fileIO::writeDataFile(string fname, int *data){ - - return writeDataFile(fname, getTotalNumberofChannels(), data); -} - -int fileIO::writeDataFile(ofstream &outfile, int *data, int offset){ - - return writeDataFile(outfile, getTotalNumberofChannels(), data, offset); -} - - - - - -int fileIO::writeDataFile(string fname, short int *data){ - - return writeDataFile(fname, getTotalNumberofChannels(), data); -} - -int fileIO::writeDataFile(ofstream &outfile, short int *data, int offset){ - - return writeDataFile(outfile,getTotalNumberofChannels() , data, offset); -} - - - - -int fileIO::readDataFile(string fname, double *data, double *err, double *ang, char dataformat) { - return readDataFile(getTotalNumberofChannels(), fname, data, err, ang, dataformat); - -} - -int fileIO::readDataFile(ifstream &infile, double *data, double *err, double *ang, char dataformat, int offset) { - return readDataFile(getTotalNumberofChannels(), infile, data, err, ang, dataformat, offset); - -} - - - -int fileIO::readDataFile(string fname, int *data){ - - return readDataFile(fname, data, getTotalNumberofChannels()); -}; - - -int fileIO::readDataFile(ifstream &infile, int *data, int offset){ - - return readDataFile(infile, data, getTotalNumberofChannels(), offset); -}; - - - - - -int fileIO::readDataFile(string fname, short int *data){ - - return readDataFile(fname, data, getTotalNumberofChannels()); -}; - - -int fileIO::readDataFile(ifstream &infile, short int *data, int offset){ - - return readDataFile(infile, data, getTotalNumberofChannels(),offset); -}; - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/FileIO_Standalone.h b/slsDetectorSoftware/slsDetectorAnalysis/FileIO_Standalone.h deleted file mode 100644 index b94f6366f..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/FileIO_Standalone.h +++ /dev/null @@ -1,410 +0,0 @@ -#ifndef FILEIOSTD_H -#define FILEIOSTD_H - -//#include "slsDetectorBase.h" -#include "sls_detector_defs.h" -#include -#include -#include -#include -#include -#include -#include -#include - -; -/** - @short class handling the data file I/O flags -*/ - -class fileIO : public virtual slsDetectorDefs {//public virtual slsDetectorBase { - - - - public: - /** default constructor */ - fileIO(){}; - /** virtual destructor */ - virtual ~fileIO(){}; - - int setTotalNumberofChannels(int i){ if (i>=0) {totalNumberofChannels=i; return totalNumberofChannels;} else return -1;}; - int getTotalNumberofChannels(){ return totalNumberofChannels; }; - /** - sets the default output files path - \param s file path - \return actual file path - */ - string setFilePath(string s) {sprintf(filePath, s.c_str()); return string(filePath);}; - - /** - sets the default output files root name - \param s file name to be set - \returns actual file name - */ - string setFileName(string s) {sprintf(fileName, s.c_str()); return string(fileName);}; - - /** - sets the default output file index - \param i start file index to be set - \returns actual file index - */ - int setFileIndex(int i) {*fileIndex=i; return *fileIndex;}; - - - - /** - \returns the output files path - - */ - string getFilePath() {return string(filePath);}; - - /** - \returns the output files root name - */ - string getFileName() {return string(fileName);}; - - /** - \returns the output file index - */ - int getFileIndex() {return *fileIndex;}; - - - - - - - /** generates file name without extension - - always appends to file path and file name the run index. - - in case also appends the position index and the two level of scan varaibles with the specified precision - - Filenames will be of the form: filepath/filename(_Sy_sw_px)_i - where y is the scan0 variable, W is the scan 1 variable, x is the position index and i is the run index - \param filepath outdir - \param filename file root name - \param aMask action mask (scans, positions) - \param sv0 scan variable 0 - \param prec0 scan precision 0 - \param sv1 scan variable 1 - \param prec1 scan precision 1 - \param pindex position index - \param number of positions - \param findex file index - \returns file name without extension - */ - static string createFileName(char *filepath, char *filename, int aMask, double sv0, int prec0, double sv1, int prec1, int pindex, int npos, int findex); - - - string createFileName(int aMask, double sv0, int prec0, double sv1, int prec1, int pindex, int npos); - - - /** static function that returns the file index from the file name - \param fname file name - \returns file index - */ - int getFileIndexFromFileName(string fname); - - /** static function that returns the variables from the file name - \param fname file name - \param index reference to index - \param p_index reference to position index - \param sv0 reference to scan variable 0 - \param sv1 reference to scan variable 1 - \returns file index - */ - static int getVariablesFromFileName(string fname, int &index, int &p_index, double &sv0, double &sv1); - - - - - /** - - writes a data file - \param fname of the file to be written - \param data array of data values - \param err array of arrors on the data. If NULL no errors will be written - - \param ang array of angular values. If NULL data will be in the form chan-val(-err) otherwise ang-val(-err) - \param dataformat format of the data: can be 'i' integer or 'f' double (default) - \param nch number of channels to be written to file. if -1 defaults to the number of installed channels of the detector - \returns OK or FAIL if it could not write the file or data=NULL - - */ - virtual int writeDataFile(string fname, double *data, double *err=NULL, double *ang=NULL, char dataformat='f', int nch=-1); - - - /** - - writes a data file - \paramoutfile output file stream - \param data array of data values - \param err array of arrors on the data. If NULL no errors will be written - - \param ang array of angular values. If NULL data will be in the form chan-val(-err) otherwise ang-val(-err) - \param dataformat format of the data: can be 'i' integer or 'f' double (default) - \param nch number of channels to be written to file. if -1 defaults to the number of installed channels of the detector - \param offset start channel number - \returns OK or FAIL if it could not write the file or data=NULL - - */ - int writeDataFile(ofstream &outfile, double *data, double *err=NULL, double *ang=NULL, char dataformat='f', int nch=-1, int offset=0); - - - /** - writes a data file - \param fname of the file to be written - \param data array of data values - \returns OK or FAIL if it could not write the file or data=NULL - */ - virtual int writeDataFile(string fname, int *data); - - /** - writes a data file - \param outfile output file stream - \param data array of data values - \param offset start channel number - \returns OK or FAIL if it could not write the file or data=NULL - */ - int writeDataFile(ofstream &outfile, int *data, int offset=0); - - - - /** - writes a data file of short ints - \param fname of the file to be written - \param data array of data values - \returns OK or FAIL if it could not write the file or data=NULL - */ - virtual int writeDataFile(string fname, short int *data); - - /** - writes a data file of short ints - \param outfile output file stream - \param data array of data values - \param offset start channel number - \returns OK or FAIL if it could not write the file or data=NULL - */ - int writeDataFile(ofstream &outfile, short int *data, int offset=0); - - - /** - reads a data file - \param fname of the file to be read - \param data array of data values to be filled - \param err array of arrors on the data. If NULL no errors are expected on the file - - \param ang array of angular values. If NULL data are expected in the form chan-val(-err) otherwise ang-val(-err) - \param dataformat format of the data: can be 'i' integer or 'f' double (default) - \returns OK or FAIL if it could not read the file or data=NULL - */ - virtual int readDataFile(string fname, double *data, double *err=NULL, double *ang=NULL, char dataformat='f'); - - /** - reads a data file - \param ifstream input file stream - \param data array of data values to be filled - \param err array of arrors on the data. If NULL no errors are expected on the file - - \param ang array of angular values. If NULL data are expected in the form chan-val(-err) otherwise ang-val(-err) - \param offset start channel number to be expected - \returns OK or FAIL if it could not read the file or data=NULL - */ - int readDataFile(ifstream& infile, double *data, double *err=NULL, double *ang=NULL, char dataformat='f', int offset=0); - - /** - reads a raw data file - \param fname of the file to be read - \param data array of data values - \returns OK or FAIL if it could not read the file or data=NULL - */ - virtual int readDataFile(string fname, int *data); /** - reads a raw data file - \param infile input file stream - \param data array of data values - \param offset first channel number to be expected - \returns OK or FAIL if it could not read the file or data=NULL - */ - int readDataFile(ifstream &infile, int *data, int offset=0); - - /** - - reads a short int raw data file - \param fname of the file to be read - \param data array of data values - \returns OK or FAIL if it could not read the file or data=NULL - */ - virtual int readDataFile(string fname, short int *data); - /** - reads a short int raw data file - \param infile input file stream - \param data array of data values - \param offset first channel number to be expected - \returns OK or FAIL if it could not read the file or data=NULL - */ - int readDataFile(ifstream &infile, short int *data, int offset=0); - - /** - - writes a data file - \param fname of the file to be written - \param nch number of channels to be written - \param data array of data values - \param err array of arrors on the data. If NULL no errors will be written - \param ang array of angular values. If NULL data will be in the form chan-val(-err) otherwise ang-val(-err) - \param dataformat format of the data: can be 'i' integer or 'f' double (default) - \returns OK or FAIL if it could not write the file or data=NULL - - */ - - static int writeDataFile(string fname, int nch, double *data, double *err=NULL, double *ang=NULL, char dataformat='f'); - /** - writes a data file - \param outfile output file stream - \param nch number of channels to be written - \param data array of data values - \param err array of arrors on the data. If NULL no errors will be written - \param ang array of angular values. If NULL data will be in the form chan-val(-err) otherwise ang-val(-err) - \param dataformat format of the data: can be 'i' integer or 'f' double (default) - \param offset start channel number - \returns OK or FAIL if it could not write the file or data=NULL - */ - static int writeDataFile(ofstream &outfile, int nch, double *data, double *err=NULL, double *ang=NULL, char dataformat='f', int offset=0); - - /** - writes a raw data file - \param fname of the file to be written - \param nch number of channels - \param data array of data values - \returns OK or FAIL if it could not write the file or data=NULL - */ - static int writeDataFile(string fname,int nch, int *data); - - /** - writes a raw data file - \param outfile output file stream - \param nch number of channels - \param data array of data values - \param offset start channel number - \returns OK or FAIL if it could not write the file or data=NULL - */ - static int writeDataFile(ofstream &outfile,int nch, int *data, int offset=0); - - - /** - - writes a short int raw data file - \param fname of the file to be written - \param nch number of channels - \param data array of data values - \returns OK or FAIL if it could not write the file or data=NULL - */ - static int writeDataFile(string fname,int nch, short int *data); - - /** - writes a short int raw data file - \param outfile output file stream - \param nch number of channels - \param data array of data values - \param offset start channel number - \returns OK or FAIL if it could not write the file or data=NULL - */ - static int writeDataFile(ofstream &outfile,int nch, short int *data, int offset=0); - - - /** - reads a data file - \param nch number of channels - \param fname of the file to be read - \param data array of data values to be filled - \param err array of arrors on the data. If NULL no errors are expected on the file - \param ang array of angular values. If NULL data are expected in the form chan-val(-err) otherwise ang-val(-err) - \param dataformat format of the data: can be 'i' integer or 'f' double (default) - \returns number of channels read or -1 if it could not read the file or data=NULL - - */ - static int readDataFile(int nch, string fname, double *data, double *err=NULL, double *ang=NULL, char dataformat='f'); - /** - reads a data file - \param nch number of channels - \param infile input file stream - \param data array of data values to be filled - \param err array of arrors on the data. If NULL no errors are expected on the file - \param ang array of angular values. If NULL data are expected in the form chan-val(-err) otherwise ang-val(-err) - \param dataformat format of the data: can be 'i' integer or 'f' double (default) - \param offset start channel number - \returns number of channels read or -1 if it could not read the file or data=NULL - - */ - static int readDataFile(int nch, ifstream &infile, double *data, double *err=NULL, double *ang=NULL, char dataformat='f', int offset=0); - - /** - reads a raw data file - \param fname of the file to be read - \param data array of data values - \param nch number of channels - \returns OK or FAIL if it could not read the file or data=NULL - */ - static int readDataFile(string fname, int *data, int nch); - - /** - reads a raw data file - \param infile input file stream - \param data array of data values - \param nch number of channels - \param offset start channel value - \returns OK or FAIL if it could not read the file or data=NULL - */ - static int readDataFile(ifstream &infile, int *data, int nch, int offset); - - /** - reads a short int rawdata file - \param name of the file to be read - \param data array of data values - \param nch number of channels - \returns OK or FAIL if it could not read the file or data=NULL - */ - static int readDataFile(string fname, short int *data, int nch); - /** - reads a short int raw data file - \param infile input file stream - \param data array of data values - \param nch number of channels - \param offset start channel value - \returns OK or FAIL if it could not read the file or data=NULL - */ - static int readDataFile(ifstream &infile, short int *data, int nch, int offset); - - - - - - void incrementFileIndex() { (*fileIndex)++;}; - - string getCurrentFileName(){return currentFileName;}; - - protected: - string currentFileName; - - - int mask_action; - double currentscan_variable[1]; - int scan_precision[1]; - int currentpostion_i; - int noposition; - - /** output directory */ - char *filePath; - /** file root name */ - char *fileName; - /** file index */ - int *fileIndex; - - private: - - int totalNumberofChannels; - - -}; - -#endif diff --git a/slsDetectorSoftware/slsDetectorAnalysis/Makefile b/slsDetectorSoftware/slsDetectorAnalysis/Makefile deleted file mode 100644 index 1b137d512..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/Makefile +++ /dev/null @@ -1,87 +0,0 @@ -#--------------------------------------------------- - - -include Makefile.arch - -#------------------------------------------------------------------------------ - -SLSDETO = TSlsDetectorDict.$(ObjSuf) energyCalibration.$(ObjSuf) angularCalibration.$(ObjSuf) - -SLSDETSO = libTSlsDetector.$(DllSuf) - -CXXFLAGS += -Wno-deprecated -#LIBS += -L../slsDetectorSoftware -lSlsDetector -pthread - -CXXFLAGS += -I ../usersFunctions - -HEADERS= energyCalibration.h angularCalibration.h -#------------------------------------------------------------------------------- - -#----------- do the shared library -$(SLSDETSO): $(SLSDETO) - @echo "Generating shared library $@..." - $(LD) $(SOFLAGS) $(LDFLAGS) -o $@ $(LIBS) $^ - - -# ---------- Default rule - -%.$(ObjSuf): %.cpp - @echo "Compiling source $@..." - $(CXX) $(CXXFLAGS) -c $< - - -#----------- do the dictionary -TSlsDetectorDict.$(SrcSuf): $(HEADERS) - @echo "Generating dictionary $@..." - rootcint -f $@ -c -p $^ - -#------------------------------------------------------------------------------- -all: $(SLSDETSO) - -clean: - @rm -f $(SLSDETO) core - -distclean: clean - @rm -f *Dict.* *.so *.o - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/Makefile.arch b/slsDetectorSoftware/slsDetectorAnalysis/Makefile.arch deleted file mode 100644 index 707a4e35b..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/Makefile.arch +++ /dev/null @@ -1,575 +0,0 @@ -# -*- mode: makefile -*- -# -# Makefile containing platform dependencies for ROOT based projects. -# -# Copyright (c) 2000 Rene Brun and Fons Rademakers -# -# Author: Fons Rademakers, 29/2/2000 - -ROOTCONFIG := root-config - -ARCH := $(shell $(ROOTCONFIG) --arch) -PLATFORM := $(shell $(ROOTCONFIG) --platform) -ALTCC := $(shell $(ROOTCONFIG) --cc) -ALTCXX := $(shell $(ROOTCONFIG) --cxx) -ALTF77 := $(shell $(ROOTCONFIG) --f77) -ALTLD := $(shell $(ROOTCONFIG) --ld) - -#CXX = -ObjSuf = o -SrcSuf = cpp -ExeSuf = -DllSuf = so -OutPutOpt = -o # keep whitespace after "-o" - -ifeq (debug,$(findstring debug,$(ROOTBUILD))) -OPT = -g -OPT2 = -g -else -ifneq ($(findstring debug, $(strip $(shell $(ROOTCONFIG) --config))),) -OPT = -g -OPT2 = -g -else -OPT = -O -OPT2 = -O2 -endif -endif - -ROOTCFLAGS := $(shell $(ROOTCONFIG) --cflags) -ROOTLDFLAGS := $(shell $(ROOTCONFIG) --ldflags) -ROOTLIBS := $(shell $(ROOTCONFIG) --libs) -ROOTGLIBS := $(shell $(ROOTCONFIG) --glibs) -HASTHREAD := $(shell $(ROOTCONFIG) --has-thread) -ROOTDICTTYPE := $(shell $(ROOTCONFIG) --dicttype) -NOSTUBS := $(shell $(ROOTCONFIG) --nostubs) -ROOTCINT := rootcint - -# Stub Functions Generation -ifeq ($(NOSTUBS),yes) - ROOTCINT = export CXXFLAGS="$(CXXFLAGS)"; $(ROOTSYS)/core/utils/src/rootcint_nostubs.sh -$(ROOTDICTTYPE) -endif - -ifeq ($(ARCH),hpuxacc) -# HP-UX 10.x with aCC -CXX = aCC -CXXFLAGS = $(OPT) +Z -LD = aCC -LDFLAGS = $(OPT) -z -SOFLAGS = -b -endif - -ifeq ($(ARCH),hpuxia64acc) -# HP-UX 11i 1.5 (IA-64) with aCC -CXX = aCC -CXXFLAGS = +DD64 $(OPT) +Z -LD = aCC -LDFLAGS = +DD64 $(OPT) -z -SOFLAGS = -b -endif - -ifeq ($(ARCH),hpuxgcc) -# HP-UX 10.x with g++ -CXXFLAGS = $(OPT) -fPIC -CXX = g++ -LD = g++ -LDFLAGS = $(OPT) -SOFLAGS = -fPIC -shared -endif - -ifeq ($(ARCH),hurddeb) -# GNU/Hurd -CXX = g++ -CXXFLAGS = $(OPT2) -Wall -fPIC -LD = g++ -LDFLAGS = $(OPT2) -SOFLAGS = -shared -endif - -ifeq ($(ARCH),aix) -# IBM AIX xlC 4.x -CXX = xlC -CXXFLAGS = $(OPT) -LD = xlC -LDFLAGS = $(OPT) -SOFLAGS = -DllSuf = a -endif - -ifeq ($(ARCH),aix5) -# IBM AIX xlC 5.x -CXX = xlC -CXXFLAGS = $(OPT) -LD = xlC -LDFLAGS = $(OPT) -SOFLAGS = -DllSuf = a -endif - -ifeq ($(ARCH),aixgcc) -# IBM AIX with GCC -CXX = g++ -CXXFLAGS = $(OPT) -LD = g++ -LDFLAGS = $(OPT) -SOFLAGS = -shared -DllSuf = a -EXPLLINKLIBS = $(ROOTLIBS) $(ROOTGLIBS) -endif - -ifeq ($(ARCH),solaris) -# Solaris CC -CXX = /opt/SUNWspro/bin/CC -CXXFLAGS = $(OPT) -KPIC -LD = /opt/SUNWspro/bin/CC -LDFLAGS = $(OPT) -SOFLAGS = -G -endif - -ifeq ($(ARCH),solarisCC5) -# Solaris CC 5.0 -CXX = CC -CXXFLAGS = $(OPT) -KPIC -LD = CC -LDFLAGS = $(OPT) -SOFLAGS = -G -endif - -ifeq ($(ARCH),solarisgcc) -# Solaris gcc -CXX = g++ -CXXFLAGS = $(OPT) -fPIC -LD = g++ -LDFLAGS = $(OPT) -SOFLAGS = -shared -endif - -ifeq ($(ARCH),solariskcc) -# Solaris kcc -CXX = KCC --one_instantiation_per_object -CXXFLAGS = -O4 -KPIC -LD = KCC -LDFLAGS = -O4 -SOFLAGS = -endif - -ifeq ($(ARCH),solarisx86) -# Solaris CC on Intel -CXX = CC -CXXFLAGS = $(OPT) -KPIC -LD = CC -LDFLAGS = $(OPT) -SOFLAGS = -G -endif - -ifeq ($(ARCH),sgicc) -# SGI -CXX = CC -n32 -I/usr/include/CC.sgi -CXXFLAGS = $(OPT) -LD = CC -n32 -LANG:std -I/usr/include/CC.sgi -LDFLAGS = $(OPT) -SOFLAGS = -shared -endif - -ifeq ($(ARCH),sgicc64) -# SGI -CXX = CC -64 -I/usr/include/CC.sgi -CXXFLAGS = $(OPT) -LD = CC -64 -LANG:std -I/usr/include/CC.sgi -LDFLAGS = $(OPT) -SOFLAGS = -shared -endif - -ifeq ($(ARCH),sgigcc) -# SGI 6.x with gcc -CXX = g++ -CXXFLAGS = $(OPT) -Wall -fPIC -LD = g++ -LDFLAGS = $(OPT) -Wl,-u,__builtin_new -Wl,-u,__builtin_delete -Wl,-u,__nw__FUiPv -SOFLAGS = -shared -endif - -ifeq ($(ARCH),sgin32gcc) -# SGI 6.x with gcc for n32 ABI -CXX = g++ -CXXFLAGS = $(OPT) -Wall -fPIC -LD = g++ -LDFLAGS = $(OPT) -L/usr/lib32 -Wl,-woff,134 -lgen -SOFLAGS = -shared -endif - -ifeq ($(ARCH),sgikcc) -# SGI with KCC -CXX = KCC -n32 --one_instantiation_per_object -CXXFLAGS = $(OPT) -LD = KCC -n32 -LDFLAGS = $(OPT) -SOFLAGS = -endif - -ifeq ($(ARCH),alphagcc) -# Alpha/OSF with gcc -CXX = g++ -CXXFLAGS = $(OPT2) -Wall -fPIC -LD = g++ -LDFLAGS = $(OPT2) -SOFLAGS = -Wl,-expect_unresolved,* -shared -endif - -ifeq ($(ARCH),alphakcc) -# Alpha/OSF with kai compiler (not yet valid) -CXX = KCC --one_instantiation_per_object -CXXFLAGS = $(OPT) -fPIC -LD = KCC -LDFLAGS = $(OPT) -SOFLAGS = -Wl,-expect_unresolved,* -shared -endif - -ifeq ($(ARCH),alphacxx6) -# Alpha/OSF with cxx6 -CXX = cxx -CXXFLAGS = $(OPT) -LD = cxx -LDFLAGS = $(OPT) -SOFLAGS = -shared -nocxxstd -Wl,-expect_unresolved,*,-msym -endif - -ifeq ($(ARCH),linuxdeb2ppc) -# Debian/Linux on the PowerPC -CXX = g++ -CXXFLAGS = $(OPT2) -Wall -fPIC -LD = g++ -LDFLAGS = $(OPT2) -SOFLAGS = -shared -endif - -ifeq ($(ARCH),linux) -# Linux with egcs, gcc 2.9x, gcc 3.x -CXX = g++ -CXXFLAGS = $(OPT2) -Wall -fPIC -LD = g++ -LDFLAGS = $(OPT2) -SOFLAGS = -shared -endif - -ifeq ($(ARCH),linuxkcc) -# Linux with the KAI compiler -CXX = KCC --one_instantiation_per_object -CXXFLAGS = $(OPT) -fPIC +K0 -LD = KCC -LDFLAGS = $(OPT) $(shell $(ROOTCONFIG) --cflags) -SOFLAGS = -endif - -ifeq ($(ARCH),linuxicc) -# Linux with Intel icc compiler -ICC_MAJOR := $(shell icc -v 2>&1 | awk '{ if (NR==1) print $$2 }' | \ - cut -d'.' -f1) -ICC_MINOR := $(shell icc -v 2>&1 | awk '{ if (NR==1) print $$2 }' | \ - cut -d'.' -f2) -CXX = icc -CXXFLAGS = $(OPT) -fPIC -wd1476 -LD = icpc -LDFLAGS = $(OPT) -SOFLAGS = -shared -endif - -ifeq ($(ARCH),linuxppcgcc) -# PPC Linux with gcc and glibc -CXX = g++ -CXXFLAGS = $(OPT2) -Wall -fPIC -LD = g++ -LDFLAGS = $(OPT2) -SOFLAGS = -shared -endif - -ifeq ($(ARCH),linuxia64gcc) -# Itanium Linux with gcc 2.9x -CXX = g++ -CXXFLAGS = $(OPT2) -Wall -fPIC -LD = g++ -LDFLAGS = $(OPT2) -SOFLAGS = -shared -endif - -ifeq ($(ARCH),linuxia64sgi) -# Itanium Linux with sgiCC -CXX = sgiCC -CXXFLAGS = $(OPT) -Wall -fPIC -LD = gsgiCC -LDFLAGS = $(OPT) -SOFLAGS = -shared -endif - -ifeq ($(ARCH),linuxia64ecc) -# Itanium Linux with Intel icc (was ecc) -ICC_MAJOR := $(shell icc -v 2>&1 | awk '{ if (NR==1) print $$2 }' | \ - cut -d'.' -f1) -ICC_MINOR := $(shell icc -v 2>&1 | awk '{ if (NR==1) print $$2 }' | \ - cut -d'.' -f2) -CXX = icc -CXXFLAGS = $(OPT) -fPIC -wd1476 -ftz -LD = icpc -LDFLAGS = $(OPT) -SOFLAGS = -shared -endif - -ifeq ($(ARCH),linuxx8664gcc) -# AMD Opteron and Intel EM64T (64 bit mode) Linux with gcc 3.x -CXX = g++ -CXXFLAGS = $(OPT2) -Wall -fPIC -LD = g++ -LDFLAGS = $(OPT2) -SOFLAGS = -shared -endif - -ifeq ($(ARCH),linuxppc64gcc) -# PPC64 Linux with gcc 3.x -CXX = g++ -CXXFLAGS = $(OPT) -Wall -fPIC -LD = g++ -LDFLAGS = $(OPT) -SOFLAGS = -shared -endif - -ifeq ($(ARCH),linuxx8664icc) -# AMD Opteron and Intel EM64T (64 bit mode) Linux with Intel icc compiler -CXX = icc -CXXFLAGS = $(OPT) -fPIC -wd1476 -wd1572 -LD = icpc -LDFLAGS = $(OPT) -SOFLAGS = -shared -endif - -ifeq ($(ARCH),linuxalphagcc) -# Alpha Linux with gcc -CXX = g++ -CXXFLAGS = $(OPT2) -Wall -fPIC -LD = g++ -LDFLAGS = $(OPT2) -SOFLAGS = -shared -endif - -ifeq ($(ARCH),linuxmips) -# GNU/Linux on mips (BE/LE, O32/N32/N64) with gcc -CXX = g++ -CXXFLAGS = $(OPT2) -Wall -fPIC -LD = g++ -LDFLAGS = $(OPT2) -SOFLAGS = -shared -endif - -ifeq ($(ARCH),linuxhppa) -# GNU/Linux on hppa with gcc -CXX = g++ -CXXFLAGS = $(OPT2) -Wall -fPIC -LD = g++ -LDFLAGS = $(OPT2) -SOFLAGS = -shared -endif - -ifeq ($(ARCH),linuxarm) -# ARM Linux with egcs -CXX = g++ -CXXFLAGS = $(OPT) -Wall -fPIC -LD = g++ -LDFLAGS = $(OPT) -SOFLAGS = -shared -endif - -ifeq ($(ARCH),freebsd4) -# FreeBSD with glibc -CXX = g++ -CXXFLAGS = $(OPT) -W -Wall -fPIC -LD = $(CXX) -LDFLAGS = $(OPT) -SOFLAGS = -shared -Wl,-x -endif - -ifeq ($(ARCH),freebsd5) -# FreeBSD with glibc -CXX = g++ -CXXFLAGS = $(OPT) -W -Wall -fPIC -LD = $(CXX) -LDFLAGS = $(OPT) -SOFLAGS = -shared -Wl,-x -endif - -ifeq ($(ARCH),freebsd7) -# FreeBSD with libc -CXX = g++ -CXXFLAGS = $(OPT) -W -Wall -fPIC -LD = $(CXX) -LDFLAGS = $(OPT) -SOFLAGS = -shared -Wl,-x -endif - -ifeq ($(ARCH),openbsd) -# OpenBSD with libc -CXX = g++ -CXXFLAGS = $(OPT) -pipe -W -Wall -fPIC -LD = g++ -LDFLAGS = $(OPT) -SOFLAGS = -shared -Wl,-x -endif - -ifeq ($(ARCH),macosx) -# MacOS X with cc (GNU cc 2.95.2 and gcc 3.3) -MACOSX_MINOR := $(shell sw_vers | sed -n 's/ProductVersion://p' | cut -d . -f 2) -MACOSXTARGET := MACOSX_DEPLOYMENT_TARGET=10.$(MACOSX_MINOR) -CXX = g++ -CXXFLAGS = $(OPT2) -pipe -Wall -W -Woverloaded-virtual -LD = $(MACOSXTARGET) g++ -LDFLAGS = $(OPT2) -# The SOFLAGS will be used to create the .dylib, -# the .so will be created separately -ifeq ($(subst $(MACOSX_MINOR),,1234),1234) -DllSuf = so -else -DllSuf = dylib -endif -UNDEFOPT = dynamic_lookup -ifneq ($(subst $(MACOSX_MINOR),,12),12) -UNDEFOPT = suppress -LD = g++ -endif -SOFLAGS = -dynamiclib -single_module -undefined $(UNDEFOPT) -install_name $(CURDIR)/ -endif - -ifeq ($(ARCH),macosxicc) -# MacOS X with Intel icc compiler -MACOSX_MINOR := $(shell sw_vers | sed -n 's/ProductVersion://p' | cut -d . -f 2) -MACOSXTARGET := MACOSX_DEPLOYMENT_TARGET=10.$(MACOSX_MINOR) -ifeq ($(MACOSX_MINOR),5) -MACOSX_MINOR := 4 -endif -CXX = icc -CXXFLAGS = $(OPT) -fPIC -wd1476 -LD = $(MACOSXTARGET) icpc -LDFLAGS = $(OPT) -# The SOFLAGS will be used to create the .dylib, -# the .so will be created separately -ifeq ($(subst $(MACOSX_MINOR),,1234),1234) -DllSuf = so -else -DllSuf = dylib -endif -SOFLAGS = -dynamiclib -single_module -undefined dynamic_lookup -install_name $(CURDIR)/ -endif - -ifeq ($(ARCH),macosx64) -# MacOS X >= 10.4 with gcc 64 bit mode (GNU gcc 4.*) -# Only specific option (-m64) comes from root-config -MACOSX_MINOR := $(shell sw_vers | sed -n 's/ProductVersion://p' | cut -d . -f 2) -MACOSXTARGET := MACOSX_DEPLOYMENT_TARGET=10.$(MACOSX_MINOR) -CXX = g++ -CXXFLAGS = $(OPT2) -pipe -Wall -W -Woverloaded-virtual -LD = $(MACOSXTARGET) g++ -LDFLAGS = $(OPT2) -# The SOFLAGS will be used to create the .dylib, -# the .so will be created separately -ifeq ($(subst $(MACOSX_MINOR),,1234),1234) -DllSuf = so -else -DllSuf = dylib -endif -SOFLAGS = -dynamiclib -single_module -undefined dynamic_lookup -install_name $(CURDIR)/ -endif - -ifeq ($(ARCH),macosxxlc) -# MacOS X with IBM xlC compiler -MACOSX_MINOR := $(shell sw_vers | sed -n 's/ProductVersion://p' | cut -d . -f 2) -MACOSXTARGET := MACOSX_DEPLOYMENT_TARGET=10.$(MACOSX_MINOR) -CXX = xlC -CXXFLAGS = $(OPT) -LD = $(MACOSXTARGET) xlC -LDFLAGS = $(OPT) -Wl,-bind_at_load -# The SOFLAGS will be used to create the .dylib, -# the .so will be created separately -DllSuf = dylib -UNDEFOPT = dynamic_lookup -ifneq ($(subst $(MACOSX_MINOR),,12),12) -UNDEFOPT = suppress -LD = xlC -endif -SOFLAGS = -qmkshrobj -single_module -undefined $(UNDEFOPT) -install_name $(CURDIR)/ -endif - -ifeq ($(ARCH),win32) -# Windows with the VC++ compiler -VC_MAJOR := $(shell unset VS_UNICODE_OUTPUT; cl.exe 2>&1 | awk '{ if (NR==1) print $$8 }' | \ - cut -d'.' -f1) -ObjSuf = obj -SrcSuf = cxx -ExeSuf = .exe -DllSuf = dll -OutPutOpt = -out: -CXX = cl -ifeq (debug,$(findstring debug,$(ROOTBUILD))) -CXXOPT = -Z7 -LDOPT = -debug -else -ifneq ($(findstring debug, $(strip $(shell $(ROOTCONFIG) --config))),) -CXXOPT = -Z7 -LDOPT = -debug -else -CXXOPT = -O2 -LDOPT = -opt:ref -endif -endif -ROOTINCDIR := -I$(shell cygpath -m `$(ROOTCONFIG) --incdir`) -CXXFLAGS = $(CXXOPT) -nologo $(ROOTINCDIR) -FIw32pragma.h -LD = link -LDFLAGS = $(LDOPT) -nologo -SOFLAGS = -DLL - -EXPLLINKLIBS = $(ROOTLIBS) $(ROOTGLIBS) -ifneq (,$(findstring $(VC_MAJOR),14 15)) -MT_EXE = mt -nologo -manifest $@.manifest -outputresource:$@\;1; rm -f $@.manifest -MT_DLL = mt -nologo -manifest $@.manifest -outputresource:$@\;2; rm -f $@.manifest -else -MT_EXE = -MT_DLL = -endif -endif - -ifeq ($(ARCH),win32gcc) -# Windows with gcc -DllSuf = dll -ExeSuf = .exe -CXX = g++ -CXXFLAGS = $(OPT) -pipe -Wall -Woverloaded-virtual -I/usr/X11R6/include -LD = g++ -LDFLAGS = $(OPT) -Wl,--enable-auto-import \ - -Wl,--enable-runtime-pseudo-reloc \ - -L/usr/X11R6/lib -SOFLAGS = -shared -Wl,--enable-auto-image-base \ - -Wl,--export-all-symbols -EXPLLINKLIBS = $(ROOTLIBS) $(ROOTGLIBS) -endif - -ifeq ($(CXX),) -$(error $(ARCH) invalid architecture) -endif - -CXXFLAGS += $(ROOTCFLAGS) -LDFLAGS += $(ROOTLDFLAGS) -LIBS = $(ROOTLIBS) $(SYSLIBS) -GLIBS = $(ROOTGLIBS) $(SYSLIBS) - -ifneq ($(ALTCC),) - CC = $(ALTCC) -endif -ifneq ($(ALTCXX),) - CXX = $(ALTCXX) -endif -ifneq ($(ALTF77),) - F77 = $(ALTF77) -endif -ifneq ($(ALTLD),) - LD = $(ALTLD) -endif - -ifneq ($(findstring g++, $(CXX)),) -GCC_MAJOR := $(shell $(CXX) -dumpversion 2>&1 | cut -d'.' -f1) -GCC_MINOR := $(shell $(CXX) -dumpversion 2>&1 | cut -d'.' -f2) -endif diff --git a/slsDetectorSoftware/slsDetectorAnalysis/TSlsDetectorDict.cpp b/slsDetectorSoftware/slsDetectorAnalysis/TSlsDetectorDict.cpp deleted file mode 100644 index 67c907790..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/TSlsDetectorDict.cpp +++ /dev/null @@ -1,691 +0,0 @@ -// -// File generated by rootcint at Thu Mar 29 16:09:00 2012 - -// Do NOT change. Changes will be lost next time file is generated -// - -#include "RConfig.h" //rootcint 4834 -#if !defined(R__ACCESS_IN_SYMBOL) -//Break the privacy of classes -- Disabled for the moment -#define private public -#define protected public -#endif - -// Since CINT ignores the std namespace, we need to do so in this file. -namespace std {} using namespace std; -#include "TSlsDetectorDict.h" - -#include "TClass.h" -#include "TBuffer.h" -#include "TMemberInspector.h" -#include "TError.h" - -#ifndef G__ROOT -#define G__ROOT -#endif - -#include "RtypesImp.h" -#include "TIsAProxy.h" - -// START OF SHADOWS - -namespace ROOT { - namespace Shadow { - } // of namespace Shadow -} // of namespace ROOT -// END OF SHADOWS - -namespace ROOT { - void energyCalibration_ShowMembers(void *obj, TMemberInspector &R__insp, char *R__parent); - static void energyCalibration_Dictionary(); - static void *new_energyCalibration(void *p = 0); - static void *newArray_energyCalibration(Long_t size, void *p); - static void delete_energyCalibration(void *p); - static void deleteArray_energyCalibration(void *p); - static void destruct_energyCalibration(void *p); - - // Function generating the singleton type initializer - static TGenericClassInfo *GenerateInitInstanceLocal(const ::energyCalibration*) - { - ::energyCalibration *ptr = 0; - static ::TVirtualIsAProxy* isa_proxy = new ::TIsAProxy(typeid(::energyCalibration),0); - static ::ROOT::TGenericClassInfo - instance("energyCalibration", "./energyCalibration.h", 168, - typeid(::energyCalibration), DefineBehavior(ptr, ptr), - 0, &energyCalibration_Dictionary, isa_proxy, 0, - sizeof(::energyCalibration) ); - instance.SetNew(&new_energyCalibration); - instance.SetNewArray(&newArray_energyCalibration); - instance.SetDelete(&delete_energyCalibration); - instance.SetDeleteArray(&deleteArray_energyCalibration); - instance.SetDestructor(&destruct_energyCalibration); - return &instance; - } - TGenericClassInfo *GenerateInitInstance(const ::energyCalibration*) - { - return GenerateInitInstanceLocal((::energyCalibration*)0); - } - // Static variable to force the class initialization - static ::ROOT::TGenericClassInfo *_R__UNIQUE_(Init) = GenerateInitInstanceLocal((const ::energyCalibration*)0x0); R__UseDummy(_R__UNIQUE_(Init)); - - // Dictionary for non-ClassDef classes - static void energyCalibration_Dictionary() { - ::ROOT::GenerateInitInstanceLocal((const ::energyCalibration*)0x0)->GetClass(); - } - -} // end of namespace ROOT - -namespace ROOT { - void angularCalibration_ShowMembers(void *obj, TMemberInspector &R__insp, char *R__parent); - static void angularCalibration_Dictionary(); - static void *new_angularCalibration(void *p = 0); - static void *newArray_angularCalibration(Long_t size, void *p); - static void delete_angularCalibration(void *p); - static void deleteArray_angularCalibration(void *p); - static void destruct_angularCalibration(void *p); - - // Function generating the singleton type initializer - static TGenericClassInfo *GenerateInitInstanceLocal(const ::angularCalibration*) - { - ::angularCalibration *ptr = 0; - static ::TVirtualIsAProxy* isa_proxy = new ::TIsAProxy(typeid(::angularCalibration),0); - static ::ROOT::TGenericClassInfo - instance("angularCalibration", "./angularCalibration.h", 35, - typeid(::angularCalibration), DefineBehavior(ptr, ptr), - 0, &angularCalibration_Dictionary, isa_proxy, 0, - sizeof(::angularCalibration) ); - instance.SetNew(&new_angularCalibration); - instance.SetNewArray(&newArray_angularCalibration); - instance.SetDelete(&delete_angularCalibration); - instance.SetDeleteArray(&deleteArray_angularCalibration); - instance.SetDestructor(&destruct_angularCalibration); - return &instance; - } - TGenericClassInfo *GenerateInitInstance(const ::angularCalibration*) - { - return GenerateInitInstanceLocal((::angularCalibration*)0); - } - // Static variable to force the class initialization - static ::ROOT::TGenericClassInfo *_R__UNIQUE_(Init) = GenerateInitInstanceLocal((const ::angularCalibration*)0x0); R__UseDummy(_R__UNIQUE_(Init)); - - // Dictionary for non-ClassDef classes - static void angularCalibration_Dictionary() { - ::ROOT::GenerateInitInstanceLocal((const ::angularCalibration*)0x0)->GetClass(); - } - -} // end of namespace ROOT - -namespace ROOT { - // Wrappers around operator new - static void *new_energyCalibration(void *p) { - return p ? ::new((::ROOT::TOperatorNewHelper*)p) ::energyCalibration : new ::energyCalibration; - } - static void *newArray_energyCalibration(Long_t nElements, void *p) { - return p ? ::new((::ROOT::TOperatorNewHelper*)p) ::energyCalibration[nElements] : new ::energyCalibration[nElements]; - } - // Wrapper around operator delete - static void delete_energyCalibration(void *p) { - delete ((::energyCalibration*)p); - } - static void deleteArray_energyCalibration(void *p) { - delete [] ((::energyCalibration*)p); - } - static void destruct_energyCalibration(void *p) { - typedef ::energyCalibration current_t; - ((current_t*)p)->~current_t(); - } -} // end of namespace ROOT for class ::energyCalibration - -namespace ROOT { - // Wrappers around operator new - static void *new_angularCalibration(void *p) { - return p ? ::new((::ROOT::TOperatorNewHelper*)p) ::angularCalibration : new ::angularCalibration; - } - static void *newArray_angularCalibration(Long_t nElements, void *p) { - return p ? ::new((::ROOT::TOperatorNewHelper*)p) ::angularCalibration[nElements] : new ::angularCalibration[nElements]; - } - // Wrapper around operator delete - static void delete_angularCalibration(void *p) { - delete ((::angularCalibration*)p); - } - static void deleteArray_angularCalibration(void *p) { - delete [] ((::angularCalibration*)p); - } - static void destruct_angularCalibration(void *p) { - typedef ::angularCalibration current_t; - ((current_t*)p)->~current_t(); - } -} // end of namespace ROOT for class ::angularCalibration - -/******************************************************** -* TSlsDetectorDict.cpp -* CAUTION: DON'T CHANGE THIS FILE. THIS FILE IS AUTOMATICALLY GENERATED -* FROM HEADER FILES LISTED IN G__setup_cpp_environmentXXX(). -* CHANGE THOSE HEADER FILES AND REGENERATE THIS FILE. -********************************************************/ - -#ifdef G__MEMTEST -#undef malloc -#undef free -#endif - -#if defined(__GNUC__) && (__GNUC__ > 3) && (__GNUC_MINOR__ > 1) -#pragma GCC diagnostic ignored "-Wstrict-aliasing" -#endif - -extern "C" void G__cpp_reset_tagtableTSlsDetectorDict(); - -extern "C" void G__set_cpp_environmentTSlsDetectorDict() { - G__add_compiledheader("TObject.h"); - G__add_compiledheader("TMemberInspector.h"); - G__add_compiledheader("energyCalibration.h"); - G__add_compiledheader("angularCalibration.h"); - G__cpp_reset_tagtableTSlsDetectorDict(); -} -#include -extern "C" int G__cpp_dllrevTSlsDetectorDict() { return(30051515); } - -/********************************************************* -* Member function Interface Method -*********************************************************/ - -/* energyCalibration */ -static int G__TSlsDetectorDict_85_0_1(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash) -{ - energyCalibration* p = NULL; - char* gvp = (char*) G__getgvp(); - int n = G__getaryconstruct(); - if (n) { - if ((gvp == (char*)G__PVOID) || (gvp == 0)) { - p = new energyCalibration[n]; - } else { - p = new((void*) gvp) energyCalibration[n]; - } - } else { - if ((gvp == (char*)G__PVOID) || (gvp == 0)) { - p = new energyCalibration; - } else { - p = new((void*) gvp) energyCalibration; - } - } - result7->obj.i = (long) p; - result7->ref = (long) p; - result7->type = 'u'; - result7->tagnum = G__get_linked_tagnum(&G__TSlsDetectorDictLN_energyCalibration); - return(1 || funcname || hash || result7 || libp) ; -} - -static int G__TSlsDetectorDict_85_0_2(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash) -{ - switch (libp->paran) { - case 1: - G__letint(result7, 105, (long) ((energyCalibration*) G__getstructoffset())->setPlotFlag((int) G__int(libp->para[0]))); - break; - case 0: - G__letint(result7, 105, (long) ((energyCalibration*) G__getstructoffset())->setPlotFlag()); - break; - } - return(1 || funcname || hash || result7 || libp) ; -} - -static int G__TSlsDetectorDict_85_0_3(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash) -{ - switch (libp->paran) { - case 1: - G__letint(result7, 105, (long) ((energyCalibration*) G__getstructoffset())->setScanSign((int) G__int(libp->para[0]))); - break; - case 0: - G__letint(result7, 105, (long) ((energyCalibration*) G__getstructoffset())->setScanSign()); - break; - } - return(1 || funcname || hash || result7 || libp) ; -} - -static int G__TSlsDetectorDict_85_0_4(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash) -{ - switch (libp->paran) { - case 1: - G__letint(result7, 105, (long) ((energyCalibration*) G__getstructoffset())->setChargeSharing((int) G__int(libp->para[0]))); - break; - case 0: - G__letint(result7, 105, (long) ((energyCalibration*) G__getstructoffset())->setChargeSharing()); - break; - } - return(1 || funcname || hash || result7 || libp) ; -} - -// automatic copy constructor -static int G__TSlsDetectorDict_85_0_5(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash) - -{ - energyCalibration* p; - void* tmp = (void*) G__int(libp->para[0]); - p = new energyCalibration(*(energyCalibration*) tmp); - result7->obj.i = (long) p; - result7->ref = (long) p; - result7->type = 'u'; - result7->tagnum = G__get_linked_tagnum(&G__TSlsDetectorDictLN_energyCalibration); - return(1 || funcname || hash || result7 || libp) ; -} - -// automatic destructor -typedef energyCalibration G__TenergyCalibration; -static int G__TSlsDetectorDict_85_0_6(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash) -{ - char* gvp = (char*) G__getgvp(); - long soff = G__getstructoffset(); - int n = G__getaryconstruct(); - // - //has_a_delete: 0 - //has_own_delete1arg: 0 - //has_own_delete2arg: 0 - // - if (!soff) { - return(1); - } - if (n) { - if (gvp == (char*)G__PVOID) { - delete[] (energyCalibration*) soff; - } else { - G__setgvp((long) G__PVOID); - for (int i = n - 1; i >= 0; --i) { - ((energyCalibration*) (soff+(sizeof(energyCalibration)*i)))->~G__TenergyCalibration(); - } - G__setgvp((long)gvp); - } - } else { - if (gvp == (char*)G__PVOID) { - delete (energyCalibration*) soff; - } else { - G__setgvp((long) G__PVOID); - ((energyCalibration*) (soff))->~G__TenergyCalibration(); - G__setgvp((long)gvp); - } - } - G__setnull(result7); - return(1 || funcname || hash || result7 || libp) ; -} - -// automatic assignment operator -static int G__TSlsDetectorDict_85_0_7(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash) -{ - energyCalibration* dest = (energyCalibration*) G__getstructoffset(); - *dest = *(energyCalibration*) libp->para[0].ref; - const energyCalibration& obj = *dest; - result7->ref = (long) (&obj); - result7->obj.i = (long) (&obj); - return(1 || funcname || hash || result7 || libp) ; -} - - -/* angularCalibration */ -static int G__TSlsDetectorDict_87_0_1(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash) -{ - angularCalibration* p = NULL; - char* gvp = (char*) G__getgvp(); - int n = G__getaryconstruct(); - if (n) { - if ((gvp == (char*)G__PVOID) || (gvp == 0)) { - p = new angularCalibration[n]; - } else { - p = new((void*) gvp) angularCalibration[n]; - } - } else { - if ((gvp == (char*)G__PVOID) || (gvp == 0)) { - p = new angularCalibration; - } else { - p = new((void*) gvp) angularCalibration; - } - } - result7->obj.i = (long) p; - result7->ref = (long) p; - result7->type = 'u'; - result7->tagnum = G__get_linked_tagnum(&G__TSlsDetectorDictLN_angularCalibration); - return(1 || funcname || hash || result7 || libp) ; -} - -static int G__TSlsDetectorDict_87_0_2(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash) -{ - switch (libp->paran) { - case 1: - G__letint(result7, 105, (long) ((angularCalibration*) G__getstructoffset())->setDirection((int) G__int(libp->para[0]))); - break; - case 0: - G__letint(result7, 105, (long) ((angularCalibration*) G__getstructoffset())->setDirection()); - break; - } - return(1 || funcname || hash || result7 || libp) ; -} - -static int G__TSlsDetectorDict_87_0_3(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash) -{ - G__letdouble(result7, 102, (double) ((angularCalibration*) G__getstructoffset())->setEncoder((double) G__double(libp->para[0]))); - return(1 || funcname || hash || result7 || libp) ; -} - -static int G__TSlsDetectorDict_87_0_4(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash) -{ - G__letdouble(result7, 102, (double) ((angularCalibration*) G__getstructoffset())->getEncoder()); - return(1 || funcname || hash || result7 || libp) ; -} - -static int G__TSlsDetectorDict_87_0_5(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash) -{ - G__letdouble(result7, 102, (double) ((angularCalibration*) G__getstructoffset())->setTotalOffset((double) G__double(libp->para[0]))); - return(1 || funcname || hash || result7 || libp) ; -} - -static int G__TSlsDetectorDict_87_0_6(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash) -{ - G__letdouble(result7, 102, (double) ((angularCalibration*) G__getstructoffset())->getTotalOffset()); - return(1 || funcname || hash || result7 || libp) ; -} - -static int G__TSlsDetectorDict_87_0_7(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash) -{ - ((angularCalibration*) G__getstructoffset())->setAngularRange((double) G__double(libp->para[0]), (double) G__double(libp->para[1])); - G__setnull(result7); - return(1 || funcname || hash || result7 || libp) ; -} - -static int G__TSlsDetectorDict_87_0_8(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash) -{ - ((angularCalibration*) G__getstructoffset())->getAngularRange(*(double*) G__doubleref(&libp->para[0]), *(double*) G__doubleref(&libp->para[1])); - G__setnull(result7); - return(1 || funcname || hash || result7 || libp) ; -} - -// automatic copy constructor -static int G__TSlsDetectorDict_87_0_9(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash) - -{ - angularCalibration* p; - void* tmp = (void*) G__int(libp->para[0]); - p = new angularCalibration(*(angularCalibration*) tmp); - result7->obj.i = (long) p; - result7->ref = (long) p; - result7->type = 'u'; - result7->tagnum = G__get_linked_tagnum(&G__TSlsDetectorDictLN_angularCalibration); - return(1 || funcname || hash || result7 || libp) ; -} - -// automatic destructor -typedef angularCalibration G__TangularCalibration; -static int G__TSlsDetectorDict_87_0_10(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash) -{ - char* gvp = (char*) G__getgvp(); - long soff = G__getstructoffset(); - int n = G__getaryconstruct(); - // - //has_a_delete: 0 - //has_own_delete1arg: 0 - //has_own_delete2arg: 0 - // - if (!soff) { - return(1); - } - if (n) { - if (gvp == (char*)G__PVOID) { - delete[] (angularCalibration*) soff; - } else { - G__setgvp((long) G__PVOID); - for (int i = n - 1; i >= 0; --i) { - ((angularCalibration*) (soff+(sizeof(angularCalibration)*i)))->~G__TangularCalibration(); - } - G__setgvp((long)gvp); - } - } else { - if (gvp == (char*)G__PVOID) { - delete (angularCalibration*) soff; - } else { - G__setgvp((long) G__PVOID); - ((angularCalibration*) (soff))->~G__TangularCalibration(); - G__setgvp((long)gvp); - } - } - G__setnull(result7); - return(1 || funcname || hash || result7 || libp) ; -} - -// automatic assignment operator -static int G__TSlsDetectorDict_87_0_11(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash) -{ - angularCalibration* dest = (angularCalibration*) G__getstructoffset(); - *dest = *(angularCalibration*) libp->para[0].ref; - const angularCalibration& obj = *dest; - result7->ref = (long) (&obj); - result7->obj.i = (long) (&obj); - return(1 || funcname || hash || result7 || libp) ; -} - - -/* Setting up global function */ - -/********************************************************* -* Member function Stub -*********************************************************/ - -/* energyCalibration */ - -/* angularCalibration */ - -/********************************************************* -* Global function Stub -*********************************************************/ - -/********************************************************* -* Get size of pointer to member function -*********************************************************/ -class G__Sizep2memfuncTSlsDetectorDict { - public: - G__Sizep2memfuncTSlsDetectorDict(): p(&G__Sizep2memfuncTSlsDetectorDict::sizep2memfunc) {} - size_t sizep2memfunc() { return(sizeof(p)); } - private: - size_t (G__Sizep2memfuncTSlsDetectorDict::*p)(); -}; - -size_t G__get_sizep2memfuncTSlsDetectorDict() -{ - G__Sizep2memfuncTSlsDetectorDict a; - G__setsizep2memfunc((int)a.sizep2memfunc()); - return((size_t)a.sizep2memfunc()); -} - - -/********************************************************* -* virtual base class offset calculation interface -*********************************************************/ - - /* Setting up class inheritance */ - -/********************************************************* -* Inheritance information setup/ -*********************************************************/ -extern "C" void G__cpp_setup_inheritanceTSlsDetectorDict() { - - /* Setting up class inheritance */ -} - -/********************************************************* -* typedef information setup/ -*********************************************************/ -extern "C" void G__cpp_setup_typetableTSlsDetectorDict() { - - /* Setting up typedef entry */ -} - -/********************************************************* -* Data Member information setup/ -*********************************************************/ - - /* Setting up class,struct,union tag member variable */ - - /* energyCalibration */ -static void G__setup_memvarenergyCalibration(void) { - G__tag_memvar_setup(G__get_linked_tagnum(&G__TSlsDetectorDictLN_energyCalibration)); - { energyCalibration *p; p=(energyCalibration*)0x1000; if (p) { } - G__memvar_setup((void*)0,85,0,0,G__get_linked_tagnum(&G__TSlsDetectorDictLN_energyCalibrationFunctions),-1,-1,4,"funcs=",0,(char*)NULL); - G__memvar_setup((void*)0,105,0,0,-1,-1,-1,4,"plot_flag=",0,"*< 0 does not plot, >0 plots (flags?) */"); - G__memvar_setup((void*)0,105,0,0,-1,-1,-1,4,"cs_flag=",0,"*< 0 functions without charge sharing contribution, >0 with charge sharing contribution */"); - } - G__tag_memvar_reset(); -} - - - /* angularCalibration */ -static void G__setup_memvarangularCalibration(void) { - G__tag_memvar_setup(G__get_linked_tagnum(&G__TSlsDetectorDictLN_angularCalibration)); - { angularCalibration *p; p=(angularCalibration*)0x1000; if (p) { } - G__memvar_setup((void*)0,105,0,0,-1,-1,-1,4,"direction=",0,"*< angulat direction of the detector -can be +1 or -1 */"); - G__memvar_setup((void*)0,102,0,0,-1,-1,-1,4,"encoder=",0,"*< position of the detector encoder */"); - G__memvar_setup((void*)0,102,0,0,-1,-1,-1,4,"totalOffset=",0,"*< total offset of the detector */"); - G__memvar_setup((void*)0,102,0,0,-1,-1,-1,4,"ang_min=",0,"*< minimum of the angular range for peak fitting*/"); - G__memvar_setup((void*)0,102,0,0,-1,-1,-1,4,"ang_max=",0,"*< maximum of the angular range for peak fitting */"); - } - G__tag_memvar_reset(); -} - -extern "C" void G__cpp_setup_memvarTSlsDetectorDict() { -} -/*********************************************************** -************************************************************ -************************************************************ -************************************************************ -************************************************************ -************************************************************ -************************************************************ -***********************************************************/ - -/********************************************************* -* Member function information setup for each class -*********************************************************/ -static void G__setup_memfuncenergyCalibration(void) { - /* energyCalibration */ - G__tag_memfunc_setup(G__get_linked_tagnum(&G__TSlsDetectorDictLN_energyCalibration)); - G__memfunc_setup("energyCalibration",1778,G__TSlsDetectorDict_85_0_1, 105, G__get_linked_tagnum(&G__TSlsDetectorDictLN_energyCalibration), -1, 0, 0, 1, 1, 0, "", (char*)NULL, (void*) NULL, 0); - G__memfunc_setup("setPlotFlag",1125,G__TSlsDetectorDict_85_0_2, 105, -1, -1, 0, 1, 1, 1, 0, "i - - 0 '-1' p", (char*)NULL, (void*) NULL, 0); - G__memfunc_setup("setScanSign",1122,G__TSlsDetectorDict_85_0_3, 105, -1, -1, 0, 1, 1, 1, 0, "i - - 0 '0' s", (char*)NULL, (void*) NULL, 0); - G__memfunc_setup("setChargeSharing",1634,G__TSlsDetectorDict_85_0_4, 105, -1, -1, 0, 1, 1, 1, 0, "i - - 0 '-1' p", (char*)NULL, (void*) NULL, 0); - // automatic copy constructor - G__memfunc_setup("energyCalibration", 1778, G__TSlsDetectorDict_85_0_5, (int) ('i'), G__get_linked_tagnum(&G__TSlsDetectorDictLN_energyCalibration), -1, 0, 1, 1, 1, 0, "u 'energyCalibration' - 11 - -", (char*) NULL, (void*) NULL, 0); - // automatic destructor - G__memfunc_setup("~energyCalibration", 1904, G__TSlsDetectorDict_85_0_6, (int) ('y'), -1, -1, 0, 0, 1, 1, 0, "", (char*) NULL, (void*) NULL, 0); - // automatic assignment operator - G__memfunc_setup("operator=", 937, G__TSlsDetectorDict_85_0_7, (int) ('u'), G__get_linked_tagnum(&G__TSlsDetectorDictLN_energyCalibration), -1, 1, 1, 1, 1, 0, "u 'energyCalibration' - 11 - -", (char*) NULL, (void*) NULL, 0); - G__tag_memfunc_reset(); -} - -static void G__setup_memfuncangularCalibration(void) { - /* angularCalibration */ - G__tag_memfunc_setup(G__get_linked_tagnum(&G__TSlsDetectorDictLN_angularCalibration)); - G__memfunc_setup("angularCalibration",1874,G__TSlsDetectorDict_87_0_1, 105, G__get_linked_tagnum(&G__TSlsDetectorDictLN_angularCalibration), -1, 0, 0, 1, 1, 0, "", (char*)NULL, (void*) NULL, 0); - G__memfunc_setup("setDirection",1261,G__TSlsDetectorDict_87_0_2, 105, -1, -1, 0, 1, 1, 1, 0, "i - - 0 '0' d", (char*)NULL, (void*) NULL, 0); - G__memfunc_setup("setEncoder",1036,G__TSlsDetectorDict_87_0_3, 102, -1, -1, 0, 1, 1, 1, 0, "f - - 0 - f", (char*)NULL, (void*) NULL, 0); - G__memfunc_setup("getEncoder",1024,G__TSlsDetectorDict_87_0_4, 102, -1, -1, 0, 0, 1, 1, 0, "", (char*)NULL, (void*) NULL, 0); - G__memfunc_setup("setTotalOffset",1463,G__TSlsDetectorDict_87_0_5, 102, -1, -1, 0, 1, 1, 1, 0, "f - - 0 - f", (char*)NULL, (void*) NULL, 0); - G__memfunc_setup("getTotalOffset",1451,G__TSlsDetectorDict_87_0_6, 102, -1, -1, 0, 0, 1, 1, 0, "", (char*)NULL, (void*) NULL, 0); - G__memfunc_setup("setAngularRange",1539,G__TSlsDetectorDict_87_0_7, 121, -1, -1, 0, 2, 1, 1, 0, -"f - - 0 - mi f - - 0 - ma", (char*)NULL, (void*) NULL, 0); - G__memfunc_setup("getAngularRange",1527,G__TSlsDetectorDict_87_0_8, 121, -1, -1, 0, 2, 1, 1, 0, -"f - - 1 - mi f - - 1 - ma", (char*)NULL, (void*) NULL, 0); - // automatic copy constructor - G__memfunc_setup("angularCalibration", 1874, G__TSlsDetectorDict_87_0_9, (int) ('i'), G__get_linked_tagnum(&G__TSlsDetectorDictLN_angularCalibration), -1, 0, 1, 1, 1, 0, "u 'angularCalibration' - 11 - -", (char*) NULL, (void*) NULL, 0); - // automatic destructor - G__memfunc_setup("~angularCalibration", 2000, G__TSlsDetectorDict_87_0_10, (int) ('y'), -1, -1, 0, 0, 1, 1, 0, "", (char*) NULL, (void*) NULL, 0); - // automatic assignment operator - G__memfunc_setup("operator=", 937, G__TSlsDetectorDict_87_0_11, (int) ('u'), G__get_linked_tagnum(&G__TSlsDetectorDictLN_angularCalibration), -1, 1, 1, 1, 1, 0, "u 'angularCalibration' - 11 - -", (char*) NULL, (void*) NULL, 0); - G__tag_memfunc_reset(); -} - - -/********************************************************* -* Member function information setup -*********************************************************/ -extern "C" void G__cpp_setup_memfuncTSlsDetectorDict() { -} - -/********************************************************* -* Global variable information setup for each class -*********************************************************/ -static void G__cpp_setup_global0() { - - /* Setting up global variables */ - G__resetplocal(); - - - G__resetglobalenv(); -} -extern "C" void G__cpp_setup_globalTSlsDetectorDict() { - G__cpp_setup_global0(); -} - -/********************************************************* -* Global function information setup for each class -*********************************************************/ -static void G__cpp_setup_func0() { - G__lastifuncposition(); - -} - -static void G__cpp_setup_func1() { -} - -static void G__cpp_setup_func2() { - - G__resetifuncposition(); -} - -extern "C" void G__cpp_setup_funcTSlsDetectorDict() { - G__cpp_setup_func0(); - G__cpp_setup_func1(); - G__cpp_setup_func2(); -} - -/********************************************************* -* Class,struct,union,enum tag information setup -*********************************************************/ -/* Setup class/struct taginfo */ -G__linked_taginfo G__TSlsDetectorDictLN_energyCalibrationFunctions = { "energyCalibrationFunctions" , 99 , -1 }; -G__linked_taginfo G__TSlsDetectorDictLN_energyCalibration = { "energyCalibration" , 99 , -1 }; -G__linked_taginfo G__TSlsDetectorDictLN_angularCalibration = { "angularCalibration" , 99 , -1 }; - -/* Reset class/struct taginfo */ -extern "C" void G__cpp_reset_tagtableTSlsDetectorDict() { - G__TSlsDetectorDictLN_energyCalibrationFunctions.tagnum = -1 ; - G__TSlsDetectorDictLN_energyCalibration.tagnum = -1 ; - G__TSlsDetectorDictLN_angularCalibration.tagnum = -1 ; -} - - -extern "C" void G__cpp_setup_tagtableTSlsDetectorDict() { - - /* Setting up class,struct,union tag entry */ - G__get_linked_tagnum_fwd(&G__TSlsDetectorDictLN_energyCalibrationFunctions); - G__tagtable_setup(G__get_linked_tagnum(&G__TSlsDetectorDictLN_energyCalibration),sizeof(energyCalibration),-1,1280,(char*)NULL,G__setup_memvarenergyCalibration,G__setup_memfuncenergyCalibration); - G__tagtable_setup(G__get_linked_tagnum(&G__TSlsDetectorDictLN_angularCalibration),sizeof(angularCalibration),-1,1280,(char*)NULL,G__setup_memvarangularCalibration,G__setup_memfuncangularCalibration); -} -extern "C" void G__cpp_setupTSlsDetectorDict(void) { - G__check_setup_version(30051515,"G__cpp_setupTSlsDetectorDict()"); - G__set_cpp_environmentTSlsDetectorDict(); - G__cpp_setup_tagtableTSlsDetectorDict(); - - G__cpp_setup_inheritanceTSlsDetectorDict(); - - G__cpp_setup_typetableTSlsDetectorDict(); - - G__cpp_setup_memvarTSlsDetectorDict(); - - G__cpp_setup_memfuncTSlsDetectorDict(); - G__cpp_setup_globalTSlsDetectorDict(); - G__cpp_setup_funcTSlsDetectorDict(); - - if(0==G__getsizep2memfunc()) G__get_sizep2memfuncTSlsDetectorDict(); - return; -} -class G__cpp_setup_initTSlsDetectorDict { - public: - G__cpp_setup_initTSlsDetectorDict() { G__add_setup_func("TSlsDetectorDict",(G__incsetup)(&G__cpp_setupTSlsDetectorDict)); G__call_setup_funcs(); } - ~G__cpp_setup_initTSlsDetectorDict() { G__remove_setup_func("TSlsDetectorDict"); } -}; -G__cpp_setup_initTSlsDetectorDict G__cpp_setup_initializerTSlsDetectorDict; - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/TSlsDetectorDict.h b/slsDetectorSoftware/slsDetectorAnalysis/TSlsDetectorDict.h deleted file mode 100644 index 0d2cea9fb..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/TSlsDetectorDict.h +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************** -* TSlsDetectorDict.h -* CAUTION: DON'T CHANGE THIS FILE. THIS FILE IS AUTOMATICALLY GENERATED -* FROM HEADER FILES LISTED IN G__setup_cpp_environmentXXX(). -* CHANGE THOSE HEADER FILES AND REGENERATE THIS FILE. -********************************************************************/ -#ifdef __CINT__ -#error TSlsDetectorDict.h/C is only for compilation. Abort cint. -#endif -#include -#include -#include -#include -#include -#define G__ANSIHEADER -#define G__DICTIONARY -#include "cint/G__ci.h" -extern "C" { -extern void G__cpp_setup_tagtableTSlsDetectorDict(); -extern void G__cpp_setup_inheritanceTSlsDetectorDict(); -extern void G__cpp_setup_typetableTSlsDetectorDict(); -extern void G__cpp_setup_memvarTSlsDetectorDict(); -extern void G__cpp_setup_globalTSlsDetectorDict(); -extern void G__cpp_setup_memfuncTSlsDetectorDict(); -extern void G__cpp_setup_funcTSlsDetectorDict(); -extern void G__set_cpp_environmentTSlsDetectorDict(); -} - - -#include "TObject.h" -#include "TMemberInspector.h" -#include "energyCalibration.h" -#include "angularCalibration.h" - -#ifndef G__MEMFUNCBODY -#endif - -extern G__linked_taginfo G__TSlsDetectorDictLN_energyCalibrationFunctions; -extern G__linked_taginfo G__TSlsDetectorDictLN_energyCalibration; -extern G__linked_taginfo G__TSlsDetectorDictLN_angularCalibration; - -/* STUB derived class for protected member access */ diff --git a/slsDetectorSoftware/slsDetectorAnalysis/angCalLogClass.h b/slsDetectorSoftware/slsDetectorAnalysis/angCalLogClass.h deleted file mode 100644 index b366b58a1..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/angCalLogClass.h +++ /dev/null @@ -1,153 +0,0 @@ -#ifndef ANGCALLOGCLASS_H -#define ANGCALLOGCLASS_H - -#include -#include -#ifdef __CINT__ -#define MYROOT -#endif - -#ifndef MYROOT -#include "slsDetectorCommand.h" -#include "slsDetectorUtils.h" -#include "sls_detector_defs.h" -#endif - -; - -class angCalLogClass { - - - public: - - -#ifndef MYROOT - angCalLogClass(slsDetectorUtils *det){ createVars(); - char cmd[1000]; \ - char *argv[2]; \ - argv[0]=cmd; \ - sprintf(cmd,"_%d.angcal",det->getFileIndex()); \ - outfile.open( std::string(det->getFilePath()+ std::string("/")+det->getFileName()+ std::string(cmd)).c_str()); \ - outfile.precision(8); - myDet=new slsDetectorCommand(det); \ - if (outfile.is_open()) { \ - for (int iv=0; ivexecuteLine(1,argv,slsDetectorDefs::GET_ACTION) << endl; \ - }; \ - }; \ - }; - ~angCalLogClass(){delete myDet; outfile.close();}; -#else - angCalLogClass() { createVars(); }; - ~angCalLogClass(){}; -#endif - - - int addStep(double pos, std::string fname) {std::cout.precision(5); outfile << pos << " " << fname << endl; return 0;}; - - - // - - int readHeader(std::ifstream &infile, int &maxmod, int &nmod, int &chanspermod, char *angconvfile, double &globaloff, double &fineoff, int &angdir, char *ffdir, char *fffile, char *badfile ) { \ - nmod=0; chanspermod=0; globaloff=0; fineoff=0; angdir=1; \ - strcpy(angconvfile,"none"); strcpy(ffdir,"none"); strcpy(fffile,"none"); strcpy(badfile,"none"); \ - char line[1000], myvar[100], myarg[100]; \ - float v; \ - for (int iv=0; ivcenter; \ - ecenter=acc->ecenter; \ - r_conversion=acc->r_conversion; \ - er_conversion=acc->er_conversion; \ - offset=acc->offset; \ - eoffset=acc->eoffset; \ - tilt=acc->tilt; \ - etilt=acc->etilt; \ - }; - - - -}; - -#endif diff --git a/slsDetectorSoftware/slsDetectorAnalysis/angularCalibration.cpp b/slsDetectorSoftware/slsDetectorAnalysis/angularCalibration.cpp deleted file mode 100644 index 08fa890a3..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/angularCalibration.cpp +++ /dev/null @@ -1,471 +0,0 @@ -#include "angularCalibration.h" - -#include -#ifdef ROOT -#include -#include -#endif - -#include "usersFunctions.h" - -#ifdef __CINT -#include "usersFunctions.cpp" -#endif - -using namespace std; - -angularCalibration::angularCalibration(int nm): direction(1), -#ifdef ROOT - fpeak(NULL), - fangle(NULL), -#endif - encoder(0), - totalOffset(0), - ang_min(-180), - ang_max(180), - nmod(nm), - nchmod(1280), - angConv(NULL) -{ - -#ifdef ROOT -// Creates a Root function based on function peakfunction - TF1 *fpeak = new TF1("fpeak",this,&angularCalibration::peakFunction,ang_min,ang_max,5,"angularCalibration","peakFunction"); - -// Sets initial values and parameter names - // func->SetParameters((Double_t) PEAKHEIGHT, (Double_t) maxch,(Double_t) PEAKWIDTH,(Double_t) PEAKBACK); - fpeak->SetParNames("Number of Photons","Peak Position","Peak Width RMS","Background Offset", "Background Slope"); - - - TF1 *fangle = new TF1("fangle",this,&angularCalibration::angleFunction,0,1280,3,"angularCalibration","angleFunction"); - fangle->SetParNames("Center","Conversion Radius","Offset"); - -#endif - - angConv=new angleConversionConstant[nmod]; - -} - -angularCalibration::~angularCalibration(){ -#ifdef ROOT - delete fpeak; - delete fangle; - -#endif -} - - - -angleConversionConstant* angularCalibration::getAngularConversionConstant(int imod) { - if (imod>=0 && imod=0 && imodcenter; - angConv[imod].ecenter=a->ecenter; - angConv[imod].r_conversion=a->r_conversion; - angConv[imod].er_conversion=a->er_conversion; - angConv[imod].offset=a->offset; - angConv[imod].eoffset=a->eoffset; - angConv[imod].tilt=a->tilt; - angConv[imod].etilt=a->etilt; - - return angConv+imod; - } - return NULL; - - -} - - - - - -#ifdef ROOT - -Double_t angularCalibration::peakFunction(Double_t *x, Double_t *par) { - Double_t arg = 0; - if (par[2] != 0) arg = (x[0] - par[1])/par[2]; - return par[0]*TMath::Exp(-0.5*arg*arg)+par[3]+par[4]*(x[0]-par[1]); - -} - -Double_t angularCalibration::angleFunction(Double_t *x, Double_t *par) { - return par[2]-angle((int)x[0],0,0,par[1],par[0],0,0,direction); -} - - - - - - - -TF1 *fitPeak(TH1 *h) { - - TF1 *fitfun=NULL; - int chmod, imod; - double ang; - -// reads in a run and fits a gaussian to the peak as function -// of channel number also reads optical encoder - - -// find angular range in channels - -// is it necessary to discard fit with too many points? - for (int i=0;iGetNbinsX();i++) { - imod=i/nchmod; - chmod=i%(imod*nchmod); - ang=angle(chmod,encoder,totalOffset,angConv[imod].r_conversion, angConv[imod].center, angConv[imod].offset, angConv[imod].tilt, direction); - if ((ang>ang_min) && (angminang) && (angle(i)MAXINPEAK) { -// printf("too many points in angular range !\n"); -// return -1; // too many points in range -// } -// if ( data[i]> max) { -// max = (int) data[i]; -// maxch = i; -// } -// } -// } -// } else -// return -1; - -// npoints--; -// chmin= (int) x[0]; -// chmax= (int) x[npoints]; - -// printf("number of points in range %f-%f: %i \n",minang,maxang,npoints); -// printf("channel from minang to maxang %i - %i \n",chmin,chmax); -// printf("channel with max intensity %i \n",maxch); - -// TCanvas *c1; - -// TGraph *gr1 = new TGraph(npoints,anglefit,y); -// TGraph *gr2 = new TGraph(npoints,x,y); -// if (plotflag) { -// /* create canvas */ - -// c1 = new TCanvas(); -// c1->SetTitle("Si calibration data"); -// c1->Divide(1,2); - -// /* create graph */ - -// sprintf(name,"run number %i",nr); -// gr1->SetTitle(name); -// gr2->SetTitle(name); - -// c1->cd(1); -// gr1->Draw("AL*"); -// c1->cd(2); -// gr2->Draw("AL*"); -// } - -// /* do not fit if peak is close to edge of module */ -// if (abs(modfromchannel(maxch)*NCHMOD-maxch)Fit("fitpeak","B"); -// else -// gr2->Fit("fitpeak","B0"); - -// TF1 *fit = gr2->GetFunction("fitpeak"); - -// // writes the fit results into the par array -// fit->GetParameters(mypar); - -// printf("\n"); -// for (i=0;i<4;i++) { -// myerr[i] = fit->GetParError(i); // obtain fit parameter errors -// printf("parameter %i: %f +- %f \n",i,mypar[i],myerr[i]); -// } - -// chi2=fit->GetChisquare(); -// printf("chi2: %e\n",chi2); -// printf("\n\n"); - -// if (chi2>CHIMAX) { -// printf("chi2 too large!\n"); -// return -1; -// } - -// if (plotflag) -// c1->Update(); // necessary for axis titles! -// // c1->WaitPrimitive(); - -// return 0; - - return fitfun; - -} - - -#endif - - - -// // -// // for detector angular calibration -// // -// // loops over runs fits a peak in each run and then fits the parameters for -// // the angular calibration to the fitted peak and optical encoder values -// // -// // -// // note: -// // setting global offset is important to find peak in peak fitting! -// // also set peak height,width and background in defines at beginning -// // - -// void fitangle(char fname[80],char extension[10], int start, int stop, double startangle, double stopangle) { - -// int i,nfit,mod,npoints,nnpoints; -// double x[MAXINMODULE],y[MAXINMODULE],ex[MAXINMODULE],ey[MAXINMODULE],min,max; -// double xx[MAXINMODULE],yy[MAXINMODULE],exx[MAXINMODULE],eyy[MAXINMODULE]; - -// double channelfit[MAXRUN], channelerror[MAXRUN], encoderfit[MAXRUN]; -// int runnrfit[MAXRUN], modulenr[MAXRUN]; - - -// FILE *fp; -// char name[80]; -// TCanvas *c1,*c2; -// gROOT->Reset(); // reset root -// // gStyle->SetOptFit(1110); - -// nfit=0; -// for (i=start;iSetTitle("Si calibration data"); -// /* create graph for angle vs fitted channel number */ -// gr3->Draw("AL*"); - -// c1->Update(); // necessary for axis titles! -// c1->WaitPrimitive(); - -// delete c1; -// } -// TH1F *herr=new TH1F("herr","",100,0,0.002); - - -// for (mod=0;mod5) { - -// // create canvas -// if (plotflag) { -// TCanvas *c2 = new TCanvas(); -// c2->SetTitle("Si calibration data"); -// c2->Divide(1,3); -// } -// // create graph -// TGraphErrors *gr1 = new TGraphErrors(npoints,x,y,ex,ey); -// sprintf(name,"module number %i",mod); -// gr1->SetTitle(name); -// if (plotflag) { -// c2->cd(1); -// gr1->Draw("ALP"); -// } - - -// // Creates a Root function based on function anglefunction -// if (x[0]>x[npoints-1]) { -// min=x[npoints-1]; -// max=x[0]; -// } else { -// max=x[npoints-1]; -// min=x[0]; -// } - - -// TF1 *func = new TF1("fitangle",anglefunction,min,max,3); - -// // Sets initial values and parameter names -// func->SetParameters(640,0.0000656,-mod*5.0); -// func->SetParNames("center","conversion","offset"); -// func->FixParameter(0,640.0); -// if (plotflag) { -// gr1->Fit("fitangle"); // fit the function -// } else -// gr1->Fit("fitangle","0"); // fit the function - - -// // calculate the deviations of data points from fitted function and plot them -// for (i=0;iEval(x[i])-y[i]; -// } -// TGraph *gr4 = new TGraph(npoints,x,ey); -// sprintf(name,"module number %i deviations from fit",mod); -// gr4->SetTitle(name); - -// if (plotflag) { -// gr4->SetMarkerStyle(24); -// c2->cd(2); -// gr4->Draw("ALP"); -// } - - -// // iterate fit with outlying points excluded -// nnpoints=0; -// for (i=0;iFit("fitangle"); // fit the function -// } else -// gr3->Fit("fitangle","0"); // fit the function - - -// // calculate the deviations of data points from fitted function and plot them -// for (i=0;iEval(xx[i])-yy[i]; -// herr->Fill(eyy[i]); -// } - -// TGraph *gr5 = new TGraph(nnpoints,xx,eyy); -// sprintf(name,"module number %i deviations from fit second iteration",mod); -// if (plotflag) { -// c2->cd(3); -// gr5->SetTitle(name); -// gr5->SetMarkerStyle(24); - -// gr5->Draw("ALP"); - - -// c2->Update(); // necessary for axis titles? -// c2->WaitPrimitive(); - -// } - -// // writes the fit results into the par array -// // -// // get fit parameter -// func->GetParameters(mypar); - -// for (i=0;i<3;i++) { -// myerr[i] = func->GetParError(i); // obtain fit parameter errors -// printf("parameter %i: %E +- %E \n",i,mypar[i],myerr[i]); -// } -// printf("\n\n"); - -// center[mod]=mypar[0]; -// errcenter[mod]=myerr[0]; -// conversion[mod]=mypar[1]; -// errconversion[mod]=myerr[1]; -// moffset[mod]=mypar[2]; -// erroff[mod]=myerr[2]; - -// delete gr1; -// delete gr4; -// delete gr5; -// delete func; -// delete c2; -// } -// } -// //herr->GetXaxis()->SetMaxDigits(3); -// herr->GetXaxis()->SetTitle("Deviations from fit (deg)"); -// herr->Draw(); - - -// printf("\n\n\n"); -// for (mod=0;mod -#include -class TH1; -#endif - - //double angle(int ichan, double encoder, double totalOffset, double conv_r, double center, double offset, double tilt, int direction) - - - -class angularCalibration { - - public: - angularCalibration(int nm=48); - ~angularCalibration(); - - /** - sets the angular direction of the detector - \par d 1 or -1 set the angular direction, other valuse simply get - \returns the angular direction of the detector - */ - int setDirection(int d=0){if (d==-1 || d==1) direction=d; return direction;}; - - /** - sets the encoder position - \param f encoder position to be set - \returns current encoder position - */ - double setEncoder(double f) {encoder=f; return encoder;}; - - /** - gets the encoder position - \returns encoder position - */ - double getEncoder() {return encoder;}; - - /** - sets the totalOffset of the detector - \param f total offset to be set - \returns current total offset - */ - double setTotalOffset(double f) {totalOffset=f; return totalOffset;}; - - /** - gets the encoder position - \returns encoder position - */ - double getTotalOffset() {return totalOffset;}; - - - - - /** - sets the angular range for peak fitting - \param mi minimum of the angular range - \param ma maximum of the angular range - */ - void setAngularRange(double mi, double ma){ang_min=mi; ang_max=ma;}; - - - /** - gets the angular range for peak fitting - \param mi reference to the minimum of the angular range - \param ma reference to the maximum of the angular range - */ - void getAngularRange(double &mi, double &ma){mi=ang_min; ma=ang_max;}; - - - /** sets and returns the number of modules - \param nm number of modules to be set (<0 gets) - \return current number of modules - */ - int setNumberOfModules(int nm=-1) {if (nm>=0) nmod=nm; return nmod;}; - - /** sets and returns the number of channels per module - \param n number of channels per module to be set (<0 gets) - \return current number of channels per module - */ - int setChannelsPerModule(int n=-1) {if (n>0) nchmod=n; return nchmod;}; - - angleConversionConstant *getAngularConversionConstant(int imod=0); - angleConversionConstant *setAngularConversionConstant(angleConversionConstant *a, int imod=0); - - -#ifdef ROOT - - /** - Gaussian with pedestal describing a peak - par[0] is the heigh of the pean - par[1] is the peak position - par[2] is the peak width - par[3] is the background offset - par[4] is the background slope - */ - Double_t peakFunction(Double_t *x, Double_t *par); - - - /** - Angular conversion function - par[0] is the module center - par[1] is the conversion radius (pitch/radius) - par[2] is the module offset - */ - Double_t angleFunction(Double_t *x, Double_t *par); - - /** - Fits a peak for the angular calibration - \param h histogram channels versus intensity - \returns fitted function or NULL if fit failed - */ - TF1 *fitPeak(TH1 *h); - -#endif - - - private: - - int direction; /**< angular direction of the detector -can be +1 or -1 */ - -#ifdef ROOT - TF1 *fpeak; /**< Root function based on function peakFunction */ - - TF1 *fangle; /**< Root function based on function angleFunction */ - -#endif - double encoder; /**< position of the detector encoder */ - double totalOffset; /**< total offset of the detector */ - double ang_min; /**< minimum of the angular range for peak fitting*/ - double ang_max; /**< maximum of the angular range for peak fitting */ - - int nmod; - int nchmod; - - angleConversionConstant angConv[MAXMOD*MAXDET]; - - - - - -/* void fitangle(char fname[80],char extension[10], int start, int stop, double startangle, double stopangle); //fits all datasets and extracts the constants */ -/* int fitpeak(char fname[80],char extension[10], int nr, double minang, double maxang); // fits a peak from a pattern using nominal calibration constant */ - - -}; - -#endif diff --git a/slsDetectorSoftware/slsDetectorAnalysis/angularConversion.cpp b/slsDetectorSoftware/slsDetectorAnalysis/angularConversion.cpp deleted file mode 100644 index 226e2dbc0..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/angularConversion.cpp +++ /dev/null @@ -1,308 +0,0 @@ -#include "angularConversion.h" - -#include -#include -#include -#include -#include - - -using namespace std; - -angularConversion::angularConversion(): angularConversionStatic(), currentPosition(0), - currentPositionIndex(0) - -{ - //angleFunctionPointer=0; - // registerAngleFunctionCallback(&defaultAngleFunction); - -} - -angularConversion::~angularConversion(){ - -} - - - - -double* angularConversion::convertAngles(double pos) { - - int nmod=getNMods(); - int *chansPerMod=new int[nmod]; - angleConversionConstant **angOff=new angleConversionConstant*[nmod]; - int *mF=new int[nmod]; - double fo=*fineOffset; - double go=*globalOffset; - int angdir=*angDirection; - - - - for (int im=0; im0) { - *binSize=v; - nBins=(int)(360./(*binSize))+1; - } - return *binSize; - case MOVE_FLAG: - if (moveFlag) { - if (v>0) - *moveFlag=1; - else if (v==0) - *moveFlag=0; - return *moveFlag; - } - return -1; - case SAMPLE_X: - if (sampleDisplacement) { - sampleDisplacement[X]=v; - return sampleDisplacement[X]; - } - return 0; - case SAMPLE_Y: - if (sampleDisplacement) { - sampleDisplacement[Y]=v; - return sampleDisplacement[Y]; - } - return 0; - 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=(int)(360./(*binSize))+1; - 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 -#include - -#include "angularConversionStatic.h" - - //double angle(int ichan, double encoder, double totalOffset, double conv_r, double center, double offset, double tilt, int direction) - - -// - -/** - @short Angular conversion constants needed for a detector module - */ - - -/** - -@short methods to set/unset the angular conversion and merge the data -class containing the methods to set/unset the angular conversion and merge the data - - -The angular conversion itself is defined by the angle() function defined in usersFunctions.cpp - -*/ -class angularConversion : public virtual slsDetectorBase, public angularConversionStatic - -{ - - public: - /** default constructor */ - angularConversion(); - /** virtual destructor */ - virtual ~angularConversion(); - - - - //virtual int readAngularConversion(string fname)=0; - - using angularConversionStatic::writeAngularConversion; - using angularConversionStatic::readAngularConversion; - - - - /** - pure virtual function - \param file name to be written (nmod and array of angular conversion constants default to the ones ot the slsDetector - */ - virtual int writeAngularConversion(std::string fname)=0; - /** - sets the arrays of the merged data to 0. NB The array should be created with size >= 360./getBinSize(); - \param mp already merged postions - \param mv already merged data - \param me already merged errors (squared sum) - \param mm multiplicity of merged arrays - \returns OK or FAIL - */ - int resetMerging(double *mp, double *mv,double *me, int *mm); - - /** - creates the arrays for merging the data and sets them to 0. - */ - int resetMerging(); - - - /** - merge dataset - \param p1 angular positions of dataset - \param v1 data - \param e1 errors - \param mp already merged postions - \param mv already merged data - \param me already merged errors (squared sum) - \param mm multiplicity of merged arrays - \param badChanMask badchannelmask (if NULL does not correct for bad channels) - \returns OK or FAIL - */ - - int addToMerging(double *p1, double *v1, double *e1, double *mp, double *mv,double *me, int *mm, int *badChanMask); - /** - merge dataset - \param p1 angular positions of dataset - \param v1 data - \param e1 errors - \param badChanMask badchannelmask (if NULL does not correct for bad channels) - \returns OK or FAIL - */ - - int addToMerging(double *p1, double *v1, double *e1,int *badChanMask); - - /** - calculates the "final" positions, data value and errors for the merged data - \param mp already merged postions - \param mv already merged data - \param me already merged errors (squared sum) - \param mm multiplicity of merged arrays - \returns FAIL or the number of non empty bins (i.e. points belonging to the pattern) - */ - - int finalizeMerging(double *mp, double *mv,double *me, int *mm); - -/** - calculates the "final" positions, data value and errors for the merged data - \returns FAIL or the number of non empty bins (i.e. points belonging to the pattern) - */ - - int finalizeMerging(); - - - /** - set detector global offset - \param f global offset to be set - \returns actual global offset - */ - double setGlobalOffset(double f){return setAngularConversionParameter(GLOBAL_OFFSET,f);}; - - - /** - set detector fine offset - \param f global fine to be set - \returns actual fine offset - */ - double setFineOffset(double f){return setAngularConversionParameter(FINE_OFFSET,f);}; - - /** - get detector fine offset - \returns actual fine offset - */ - double getFineOffset(){return getAngularConversionParameter(FINE_OFFSET);}; - - /** - get detector global offset - \returns actual global offset - */ - double getGlobalOffset(){return getAngularConversionParameter(GLOBAL_OFFSET);}; - - /** - - set detector bin size - \param bs bin size to be set - \returns actual bin size - */ - double setBinSize(double bs){if (bs>0) nBins=(int)(360./bs); return setAngularConversionParameter(BIN_SIZE,bs);}; - - /** - get detector bin size - \returns detector bin size used for merging (approx angular resolution) - */ - double getBinSize() {return getAngularConversionParameter(BIN_SIZE);}; - - - - /** - - get angular direction - \returns actual angular direction (1 is channel number increasing with angle, -1 decreasing) - */ - int getAngularDirection(){return (int)getAngularConversionParameter(ANGULAR_DIRECTION);}; - - - /** - - set angular direction - \param d angular direction to be set (1 is channel number increasing with angle, -1 decreasing) - \returns actual angular direction (1 is channel number increasing with angle, -1 decreasing) - */ - int setAngularDirection(int d){return (int)setAngularConversionParameter(ANGULAR_DIRECTION, (double)d);}; - - /** - \returns number of angular bins in the merging (360./binsize) - */ - int getNumberOfAngularBins(){return nBins;}; - - /** - get angular conversion - \param direction reference to diffractometer direction - \param angconv array that will be filled with the angular conversion constants - \returns 0 if angular conversion disabled, >0 otherwise - */ - virtual int getAngularConversion(int &direction, angleConversionConstant *angconv=NULL)=0; - - - /** - set angular conversion parameter - \param c parameter type (globaloffset, fineoffset, binsize, angular direction, move flag) - \param v value to be set - \returns actual value - */ - double setAngularConversionParameter(angleConversionParameter c, double v); - /** - get angular conversion parameter - \param c parameter type (globaloffset, fineoffset, binsize, angular direction, move flag) - \returns actual value - */ - double getAngularConversionParameter(angleConversionParameter c); - - - - - /** - set positions for the acquisition - \param nPos number of positions - \param pos array with the encoder positions - \returns number of positions - */ - virtual int setPositions(int nPos, double *pos); - /** - get positions for the acquisition - \param pos array which will contain the encoder positions - \returns number of positions - */ - virtual int getPositions(double *pos=NULL); - - /** - deletes the array of merged data - \returns OK - */ - int deleteMerging(); - - /** - \returns pointer to the array o merged positions - */ - double *getMergedPositions(){return mergingBins;}; - /** - \returns pointer to the array of merged counts - */ - double *getMergedCounts(){return mergingCounts;}; - /** - \returns pointer to the array of merged errors - */ - double *getMergedErrors(){return mergingErrors;}; - - - - /** - sets the angular conversion file - \param fname file to read - \returns angular conversion flag - */ - - int setAngularConversionFile(std::string fname); - - - /** - returns the angular conversion file - */ - std::string getAngularConversionFile(){if (setAngularCorrectionMask()) return std::string(angConvFile); else return std::string("none");}; - - - /** - reads teh angular conversion file for the (multi)detector and writes it to shared memory - */ - virtual int readAngularConversionFile(std::string fname="")=0; - - - - - - /** - \returns number of modules of the (multi)detector - */ - virtual int getNMods()=0; - - /** - returns number of channels in the module - \param imod module number - \returns number of channels in the module - */ - virtual int getChansPerMod(int imod=0)=0; - - /** - get the angular conversion contant of one modules - \param imod module number - \returns pointer to the angular conversion constant - */ - virtual angleConversionConstant *getAngularConversionPointer(int imod=0)=0; - - /** - converts channel number to angle - \param pos encoder position - \returns array of angles corresponding to the channels - */ - double* convertAngles(double pos); - - - - /** - converts channel number to angle for the current encoder position - \returns array of angles corresponding to the channels - */ - double *convertAngles(){return convertAngles(currentPosition);}; - - /** - \param imod module number - \returns move flag of the module (1 encoder is added to the angle, 0 not) - Shold be module dependent! - */ - virtual int getMoveFlag(int imod)=0; - - /** - returns number of positions - */ - int getNumberOfPositions() {return *numberOfPositions;}; - - - - protected: - - - /** pointer to number of positions for the acquisition*/ - int *numberOfPositions; - - /** pointer to the detector positions for the acquisition*/ - double *detPositions; - - /** pointer to angular conversion file name*/ - char *angConvFile; - - /** pointer to angular bin size*/ - double *binSize; - - /** pointer to beamlien fine offset*/ - double *fineOffset; - /** pointer to beamlien global offset*/ - double *globalOffset; - /** pointer to beamlien angular direction*/ - int *angDirection; - /** pointer to detector move flag (1 moves with encoder, 0 not)*/ - int *moveFlag; - - /** number of bins for angular conversion (360./binsize)*/ - int nBins; - - - - double *sampleDisplacement; - - /** - current position of the detector - */ - double currentPosition; - /** - current position index of the detector - */ - int currentPositionIndex; - - - /** - enables/disable the angular conversion - \param i 1 sets, 0 unsets,, -1 gets - \returns actual angular conversion flag - */ - virtual int setAngularCorrectionMask(int i=-1)=0; - - /** - returns current position index - */ - int getCurrentPositionIndex() {return currentPositionIndex;}; - void incrementPositionIndex() {currentPositionIndex++;}; - void resetPositionIndex() {currentPositionIndex=0;}; - - - - - - - private: - - - - - // int nChans; - // int nMods; - // int chansPerMod; - // int moveFlag; - - - - - /** merging bins */ - double *mergingBins; - - /** merging counts */ - double *mergingCounts; - - /** merging errors */ - double *mergingErrors; - - /** merging multiplicity */ - int *mergingMultiplicity; - -}; - -#endif diff --git a/slsDetectorSoftware/slsDetectorAnalysis/angularConversionStatic.cpp b/slsDetectorSoftware/slsDetectorAnalysis/angularConversionStatic.cpp deleted file mode 100644 index 2e380323c..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/angularConversionStatic.cpp +++ /dev/null @@ -1,461 +0,0 @@ -#include "angularConversionStatic.h" - -#include -#include -#include -#include -#include "angleConversionConstant.h" - -#include "sls_detector_defs.h" -#include "angleFunction.h" -using namespace std; - -angularConversionStatic::angularConversionStatic() -{ - //angleFunctionPointer=0; - registerAngleFunctionCallback(&defaultAngleFunction); - -} - -angularConversionStatic::~angularConversionStatic(){ - -} - - - -double* angularConversionStatic::convertAngles(double pos, int nch, int *chansPerMod, angleConversionConstant **angOff, int *mF, double fo, double go, int angdir) { - - // cout << "PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP convert angles " << endl; - - int imod=0; - double *ang=new double[nch]; - double enc=pos; - angleConversionConstant *p=NULL; - - int ch0=0; - int chlast=chansPerMod[0]-1; - int nchmod=chansPerMod[0]; - p=angOff[imod]; - if (mF[imod]==0) - enc=0; - else - enc=pos; - - for (int ip=0; ipchlast) { - imod++; - p=angOff[imod]; - if (mF[imod]==0) - enc=0; - else - enc=pos; - -#ifdef VERBOSE - if (p) - cout << enc << endl << fo+go << endl << p->r_conversion << endl << p->center << endl << p->offset << endl << p->tilt << angdir << endl; - else - cout << "no ang conv " << endl; -#endif - - ch0=chlast+1; - nchmod=chansPerMod[imod]; - if (nchmod>0) - chlast=ch0+nchmod-1; - } - - if (p) - ang[ip]=angle(ip-ch0, \ - enc, \ - fo+go, \ - p->r_conversion, \ - p->center, \ - p->offset, \ - p->tilt, \ - angdir ); -#ifdef VERBOSE - cout << "ip " << ip << " ch0 " << ch0 << " chlast " << chlast << " imod " << imod << endl; -#endif - } - return ang; -} - - - - - - -double angularConversionStatic::convertAngle(double pos, int ich, angleConversionConstant *p, int mF, double fo, double go, int angdir) { - - // cout << "PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP convert angle " << endl; - // if (p) - // cout << pos << endl << fo+go << endl << p->r_conversion << endl << p->center << endl << p->offset << endl << mF << endl << angdir << endl; - // else - // cout << "no ang conv " << endl; - - double enc=0, trans=0; - double ang; - - switch (mF) { - case 0: - enc=0; - trans=0; - break; - case 1: - enc=pos; - trans=0; - break; - case -1: - enc=-pos; - trans=0; - break; - case 2: - enc=0; - trans=pos; - break; - case -2: - enc=0; - trans=-pos; - break; - default: - enc=0; - trans=0; - } - - if (p) - ang=angle(ich, \ - enc, \ - fo+go, \ - p->r_conversion, \ - p->center, \ - p->offset, \ - trans, \ - angdir ); - // cout << ich << " " << ang << endl << endl; - return ang; - - - -} - - - - - - - - - - - -double angularConversionStatic::convertAngle(double pos, int ich, int *chansPerMod, angleConversionConstant **angOff, int *mF, double fo, double go, int angdir) { - - // cout << "PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP convert angles xx" << endl; - int imod=0; - double ang; - // double enc=0, trans=0; - angleConversionConstant *p=NULL; - - int ch0=0; - int chlast=chansPerMod[0]-1; - int nchmod=chansPerMod[0]; - - - - while (ich>chlast) { - imod++; - ch0=chlast+1; - nchmod=chansPerMod[imod]; - chlast=ch0+nchmod-1; - } - - p=angOff[imod]; - - - ang=convertAngle(pos, ich-ch0, p, mF[imod], fo, go, angdir); - - return ang; - -} - - - -//static! -int angularConversionStatic::readAngularConversion(string fname, int nmod, angleConversionConstant *angOff) { - - ifstream infile; - string ss; - -#ifdef VERBOSE - std::cout<< "Opening file "<< fname << std::endl; -#endif - infile.open(fname.c_str(), ios_base::in); - if (infile.is_open()) { - readAngularConversion(infile, nmod, angOff); - infile.close(); - } else { - std::cout<< "Could not open calibration file "<< fname << std::endl; - return -1; - } - return 0; -} - - -//static -int angularConversionStatic::readAngularConversion( ifstream& infile, int nmod, angleConversionConstant *angOff) { - string str; - int mod; - double center, ecenter, pitch, epitch; - double r_conv, er_conv; - double off, eoff; - string ss; - int interrupt=0; - int nm=0; - int newangconv=0; - //" module %i center %E +- %E conversion %E +- %E offset %f +- %f \n" - while (infile.good() and interrupt==0) { - getline(infile,str); -#ifdef VERBOSE - cout << "** mod " << nm << " " ; - std::cout<< str << std::endl; -#endif - istringstream ssstr(str); - ssstr >> ss >> mod; - ssstr >> ss >> center; - if (ss==string("center")) - newangconv=0; - else - newangconv=1; - ssstr >> ss >> ecenter; - if (newangconv) { - ssstr >> ss >> pitch; - ssstr >> ss >> epitch; - } - ssstr >> ss >> r_conv; - ssstr >> ss >> er_conv; - ssstr >> ss >> off; - ssstr >> ss >> eoff; -#ifdef VERBOSE - cout << nm << " " << nmod << endl; -#endif - if (nm=0 ) { - angOff[nm].center=center; - angOff[nm].r_conversion=r_conv; - angOff[nm].offset=off; - angOff[nm].ecenter=ecenter; - angOff[nm].er_conversion=er_conv; - angOff[nm].eoffset=eoff; - - if (newangconv!=0) { - // } else { - - angOff[nm].tilt=pitch; - angOff[nm].etilt=epitch; - - } - // cout << angOff[nm].center << " " << - // angOff[nm].r_conversion << " " << - // angOff[nm].offset << endl; - - } else - break; -#ifdef VERBOSE - cout << nm<<" " << angOff[nm].offset << endl; -#endif - nm++; - if (nm>=nmod) - break; - - - - - } - return nm; - } - -//static -int angularConversionStatic:: writeAngularConversion(string fname, int nmod, angleConversionConstant *angOff) { - - ofstream outfile; - outfile.open (fname.c_str(),ios_base::out); - if (outfile.is_open()) - { - writeAngularConversion(outfile, nmod, angOff); - outfile.close(); - } else { - std::cout<< "Could not open file " << fname << "for writing"<< std::endl; - return -1; - } - //" module %i center %E +- %E conversion %E +- %E offset %f +- %f \n" - return 0; -} - - - -//static -int angularConversionStatic:: writeAngularConversion(ofstream& outfile, int nmod, angleConversionConstant *angOff) { - - for (int imod=0; imod0) { - #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++; - } - } - // cout << endl ; - return np; -} - -//static -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 ) { - - - // cout << "PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP add to merging " << endl; - double binmi=-180.; - int ibin=0; - - if (p1==NULL) - return 0; - if (v1==NULL) - return slsDetectorDefs::FAIL; - - if (mp==NULL) //can be changed if we want to use a fixed bin algorithm! - return slsDetectorDefs::FAIL; - - if (mv==NULL) - return slsDetectorDefs::FAIL; - if (me==NULL) - return slsDetectorDefs::FAIL; - if (mm==NULL) - return slsDetectorDefs::FAIL; - if (nchans==0) - return slsDetectorDefs::FAIL; - - if (binsize<=0) - return slsDetectorDefs::FAIL; - - if (nbins<=0) - return slsDetectorDefs::FAIL; - - for (int ip=0; ip=0) { - mp[ibin]+=p1[ip]; - mv[ibin]+=v1[ip]; - if (e1) - me[ibin]+=(e1[ip]*e1[ip]); - else - me[ibin]+=v1[ip]; - mm[ibin]++; - -// #ifdef VERBOSE -// cout << "add " << ibin << " "<< mm[ibin] << " " << mp[ibin]<< mv[ibin] << me[ibin] << endl; -// #endif - } else - return slsDetectorDefs::FAIL; - } - - - return slsDetectorDefs::OK; - -} - -int angularConversionStatic::addPointToMerging(double p1, double v1, double e1, double *mp, double *mv,double *me, int *mm, double binsize,int nbins) { - - - // cout << "PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP add point to merging "<< v1 << " " << e1 << endl; - double binmi=-180.; - int ibin=0; - - - if (mp==NULL) //can be changed if we want to use a fixed bin algorithm! - return slsDetectorDefs::FAIL; - - if (mv==NULL) - return slsDetectorDefs::FAIL; - if (me==NULL) - return slsDetectorDefs::FAIL; - if (mm==NULL) - return slsDetectorDefs::FAIL; - - if (binsize<=0) - return slsDetectorDefs::FAIL; - - if (nbins<=0) - return slsDetectorDefs::FAIL; - - - ibin=(int)((p1-binmi)/binsize); - - - if (ibin=0) { - // cout << "before " << ibin << " " << mp[ibin] << " " << mv[ibin] << " " << me[ibin] << endl; - mp[ibin]+=p1; - mv[ibin]+=v1; - if (e1) - me[ibin]+=(e1*e1); - else - me[ibin]+=v1; - mm[ibin]++; - // cout << "after " << ibin << " " << mp[ibin] << " " << mv[ibin] << " " << me[ibin] << endl; - -// #ifdef VERBOSE -// cout << "add " << ibin << " "<< mm[ibin] << " " << mp[ibin]<< mv[ibin] << me[ibin] << endl; -// #endif - } else { - cout << "Bin out of range! " << ibin << endl; - return slsDetectorDefs::FAIL; - } - - return slsDetectorDefs::OK; - -} diff --git a/slsDetectorSoftware/slsDetectorAnalysis/angularConversionStatic.h b/slsDetectorSoftware/slsDetectorAnalysis/angularConversionStatic.h deleted file mode 100644 index ec1b47d6b..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/angularConversionStatic.h +++ /dev/null @@ -1,184 +0,0 @@ - -#ifndef ANGULARCONVERSIONSTATIC_H -#define ANGULARCONVERSIONSTATIC_H - -#ifdef __CINT -#define MYROOT -#endif - - - - -#include -#include - -//#include "angleConversionConstant.h" - - - //double angle(int ichan, double encoder, double totalOffset, double conv_r, double center, double offset, double tilt, int direction) - -class angleConversionConstant; - -; - -/** - @short Angular conversion constants needed for a detector module - */ - - -/** - -@short methods to set/unset the angular conversion and merge the data -class containing the methods to set/unset the angular conversion and merge the data - - -The angular conversion itself is defined by the angle() function defined in usersFunctions.cpp - -*/ -class angularConversionStatic -// : public virtual slsDetectorDefs -{ - - public: - /** default constructor */ - angularConversionStatic(); - /** virtual destructor */ - virtual ~angularConversionStatic(); - - - - //virtual int readAngularConversion(std::string fname)=0; - - - - - /** - - reads an angular conversion file - \param fname file to be read - \param nmod number of modules (maximum) to be read - \param angOff pointer to array of angleConversionConstants - \returns OK or FAIL - */ - static int readAngularConversion(std::string fname, int nmod, angleConversionConstant *angOff); - - /** - reads an angular conversion file - \param ifstream input file stream to be read - \param nmod number of modules (maximum) to be read - \param angOff pointer to array of angleConversionConstants - \returns OK or FAIL - - */ - static int readAngularConversion(std::ifstream& ifs, int nmod, angleConversionConstant *angOff); - /** - writes an angular conversion file - \param fname file to be written - \param nmod number of modules to be written - \param angOff pointer to array of angleConversionConstants - \returns OK or FAIL - */ - static int writeAngularConversion(std::string fname, int nmod, angleConversionConstant *angOff); - - /** - writes an angular conversion file - \param ofstream output file stream - \param nmod number of modules to be written - \param angOff pointer to array of angleConversionConstants - \returns OK or FAIL - */ - static int writeAngularConversion(std::ofstream& ofs, int nmod, angleConversionConstant *angOff); - - /** - sets the arrays of the merged data to 0. NB The array should be created with size nbins >= 360./getBinSize(); - \param mp already merged postions - \param mv already merged data - \param me already merged errors (squared sum) - \param mm multiplicity of merged arrays - \param nbins number of bins - \returns OK or FAIL - */ - static int resetMerging(double *mp, double *mv,double *me, int *mm, int nbins); - - /** - merge dataset - \param p1 angular positions of dataset - \param v1 data - \param e1 errors - \param mp already merged postions - \param mv already merged data - \param me already merged errors (squared sum) - \param mm multiplicity of merged arrays - \param nchans number of channels - \param binsize size of angular bin - \param nb number of angular bins - \param badChanMask badchannelmask (if NULL does not correct for bad channels) - \returns OK or FAIL - */ - - static int addToMerging(double *p1, double *v1, double *e1, double *mp, double *mv,double *me, int *mm, int nchans, double binsize,int nb, int *badChanMask=NULL); - - - /** - merge dataset - \param p1 angular positions of dataset - \param v1 data - \param e1 errors - \param mp already merged postions - \param mv already merged data - \param me already merged errors (squared sum) - \param mm multiplicity of merged arrays - \param nchans number of channels - \param binsize size of angular bin - \param nb number of angular bins - \param badChanMask badchannelmask (if NULL does not correct for bad channels) - \returns OK or FAIL - */ - - static int addPointToMerging(double p1, double v1, double e1, double *mp, double *mv,double *me, int *mm, double binsize, int nb); - - - /** - calculates the "final" positions, data value and errors for the merged data - \param mp already merged postions - \param mv already merged data - \param me already merged errors (squared sum) - \param mm multiplicity of merged arrays - \param nb number of bins - \returns FAIL or the number of non empty bins (i.e. points belonging to the pattern) - */ - - static int finalizeMerging(double *mp, double *mv,double *me, int *mm, int nb); - - /** - converts channel number to angle - \param pos encoder position - \returns array of angles corresponding to the channels - */ - - double* convertAngles(double pos, int nch, int *chansPerMod, angleConversionConstant **angOff, int *mF, double fo, double go, int angdir); - - double convertAngle(double pos, int ich, int *chansPerMod, angleConversionConstant **angOff, int *mF, double fo, double go, int angdir); - - - double convertAngle(double pos, int ich, angleConversionConstant *angOff, int mF, double fo, double go, int angdir); - - - - protected: - - - - - int registerAngleFunctionCallback(double (*fun)(double, double, double, double, double, double, double, int)) {angle = fun; return 0;}; - - - double (*angle)(double, double, double, double, double, double, double, int); - - - // private: - - -}; - -#endif diff --git a/slsDetectorSoftware/slsDetectorAnalysis/badChannelCorrections.h b/slsDetectorSoftware/slsDetectorAnalysis/badChannelCorrections.h deleted file mode 100644 index 5cc290e1c..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/badChannelCorrections.h +++ /dev/null @@ -1,69 +0,0 @@ -#ifndef BAD_CHANNEL_CORRECTIONS_H -#define BAD_CHANNEL_CORRECTIONS_H - - -#include -#include -#include -#include - -// -class badChannelCorrections{ - - public: - - static int readBadChannelCorrectionFile(std::string fname, int &nbad, int *badlist){ std::ifstream infile(fname.c_str()); int nb=-1; if (infile.is_open()) {nb=readBadChannelCorrectionFile(infile,nbad,badlist); infile.close();}; return nb;}; - - - - static int readBadChannelCorrectionFile(std::ifstream &infile, int &nbad, int *badlist, int moff=0){ \ - int interrupt=0; \ - int ich; \ - int chmin,chmax; \ - std::string str; \ - nbad=0; \ - while (infile.good() and interrupt==0) { \ - getline(infile,str); \ - std::istringstream ssstr; \ - ssstr.str(str); \ - if (ssstr.bad() || ssstr.fail() || infile.eof()) { \ - interrupt=1; \ - break; \ - } \ - if (str.find('-')!=std::string::npos) { \ - ssstr >> chmin ; \ - ssstr.str(str.substr(str.find('-')+1,str.size())); \ - ssstr >> chmax; \ - for (ich=chmin; ich<=chmax; ich++) { \ - badlist[nbad]=ich; \ - nbad++; \ - } \ - } else { \ - ssstr >> ich; \ - badlist[nbad]=ich; \ - nbad++; \ - } \ - } \ - return nbad; }; - - - static int setBadChannelCorrection(std::ifstream &infile, int &nbad, int *badlist, int moff){ \ - int retval=readBadChannelCorrectionFile(infile,nbad,badlist); \ - for (int ich=0; ich - -Class List - - - - - - -

Class List

Here are the classes, structs, unions and interfaces with brief descriptions: - - -
energyCalibration
energyCalibrationFunctionsEnergy calibration functions
-
Generated on Tue Mar 27 16:32:29 2012 by  - -doxygen 1.4.7
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/classenergyCalibration-members.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/classenergyCalibration-members.html deleted file mode 100644 index 4923725d9..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/classenergyCalibration-members.html +++ /dev/null @@ -1,55 +0,0 @@ - - -Member List - - - - - - -

energyCalibration Member List

This is the complete list of members for energyCalibration, including all inherited members.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
amplenergyCalibration [private]
bg_offsetenergyCalibration [private]
bg_slopeenergyCalibration [private]
calibrate(int nscan, Double_t *en, Double_t *een, TH1F **h1, Double_t &gain, Double_t &off, Double_t &egain, Double_t &eoff, int integral=1)energyCalibration [private]
calibrateScurves(int nscan, Double_t *en, Double_t *een, TH1F **h1, Double_t &gain, Double_t &off, Double_t &egain, Double_t &eoff)energyCalibration [inline]
calibrateSpectra(int nscan, Double_t *en, Double_t *een, TH1F **h1, Double_t &gain, Double_t &off, Double_t &egain, Double_t &eoff)energyCalibration [inline]
cs_flagenergyCalibration [private]
cs_slopeenergyCalibration [private]
energyCalibration()energyCalibration
fit_maxenergyCalibration [private]
fit_minenergyCalibration [private]
fitFunction(TF1 *fun, TH1 *h1, Double_t *mypar, Double_t *emypar)energyCalibration [private]
fitSCurve(TH1 *h1, Double_t *mypar, Double_t *emypar)energyCalibration
fitSpectrum(TH1 *h1, Double_t *mypar, Double_t *emypar)energyCalibration
flexenergyCalibration [private]
fscurveenergyCalibration [private]
fspectrumenergyCalibration [private]
funcsenergyCalibration [private]
getFitRange(Double_t &mi, Double_t &ma)energyCalibration [inline]
getStartParameters(Double_t *par)energyCalibration
initFitFunction(TF1 *fun, TH1 *h1)energyCalibration [private]
linearCalibration(int nscan, Double_t *en, Double_t *een, Double_t *fl, Double_t *efl, Double_t &gain, Double_t &off, Double_t &egain, Double_t &eoff)energyCalibration
noiseenergyCalibration [private]
plot_flagenergyCalibration [private]
setChargeSharing(int p=-1)energyCalibration
setFitRange(Double_t mi, Double_t ma)energyCalibration [inline]
setPlotFlag(int p=-1)energyCalibration [inline]
setScanSign(int s=0)energyCalibration [inline]
setStartParameters(Double_t *par)energyCalibration
~energyCalibration()energyCalibration


Generated on Tue Mar 27 16:32:29 2012 by  - -doxygen 1.4.7
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/classenergyCalibration.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/classenergyCalibration.html deleted file mode 100644 index 5ad0b2776..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/classenergyCalibration.html +++ /dev/null @@ -1,1026 +0,0 @@ - - -energyCalibration Class Reference - - - - - - -

energyCalibration Class Reference

#include <energyCalibration.h> -

-List of all members. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Public Member Functions

 energyCalibration ()
 ~energyCalibration ()
int setPlotFlag (int p=-1)
int setScanSign (int s=0)
int setChargeSharing (int p=-1)
void setFitRange (Double_t mi, Double_t ma)
void getFitRange (Double_t &mi, Double_t &ma)
void setStartParameters (Double_t *par)
void getStartParameters (Double_t *par)
TF1 * fitSCurve (TH1 *h1, Double_t *mypar, Double_t *emypar)
TF1 * fitSpectrum (TH1 *h1, Double_t *mypar, Double_t *emypar)
TGraphErrors * linearCalibration (int nscan, Double_t *en, Double_t *een, Double_t *fl, Double_t *efl, Double_t &gain, Double_t &off, Double_t &egain, Double_t &eoff)
TGraphErrors * calibrateScurves (int nscan, Double_t *en, Double_t *een, TH1F **h1, Double_t &gain, Double_t &off, Double_t &egain, Double_t &eoff)
TGraphErrors * calibrateSpectra (int nscan, Double_t *en, Double_t *een, TH1F **h1, Double_t &gain, Double_t &off, Double_t &egain, Double_t &eoff)

Private Member Functions

TGraphErrors * calibrate (int nscan, Double_t *en, Double_t *een, TH1F **h1, Double_t &gain, Double_t &off, Double_t &egain, Double_t &eoff, int integral=1)
void initFitFunction (TF1 *fun, TH1 *h1)
TF1 * fitFunction (TF1 *fun, TH1 *h1, Double_t *mypar, Double_t *emypar)

Private Attributes

int plot_flag
int cs_flag
Double_t fit_min
Double_t fit_max
Double_t bg_offset
Double_t bg_slope
Double_t flex
Double_t noise
Double_t ampl
Double_t cs_slope
energyCalibrationFunctionsfuncs
TF1 * fscurve
TF1 * fspectrum
-


Detailed Description

-class alowing the energy calibration of photon counting and anlogue detectors -

-


Constructor & Destructor Documentation

- -
-
- - - - - - - - -
energyCalibration::energyCalibration (  ) 
-
-
- -

-default constructor - creates the function with which the s-curves will be fitted -

-

- -

-
- - - - - - - - -
energyCalibration::~energyCalibration (  ) 
-
-
- -

-default destructor - deletes the function with which the s-curves will be fitted -

-

-


Member Function Documentation

- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
TGraphErrors* energyCalibration::calibrate (int  nscan,
Double_t *  en,
Double_t *  een,
TH1F **  h1,
Double_t &  gain,
Double_t &  off,
Double_t &  egain,
Double_t &  eoff,
int  integral = 1 
) [private]
-
-
- -

-calculates gain and offset for the set of energies

Parameters:
- - - - - - - - -
nscan number of energy scans
en array of energies (nscan long)
een array of errors on energies (nscan long) - can be NULL!
h1 array of TH1
gain reference to gain resulting from the fit
offset reference to offset resulting from the fit
integral 1 is an s-curve set (default), 0 spectra
-
-
Returns:
graph energy vs peak/inflection point
- -
-

- -

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
TGraphErrors* energyCalibration::calibrateScurves (int  nscan,
Double_t *  en,
Double_t *  een,
TH1F **  h1,
Double_t &  gain,
Double_t &  off,
Double_t &  egain,
Double_t &  eoff 
) [inline]
-
-
- -

-calculates gain and offset for the set of energy scans

Parameters:
- - - - - - - - - -
nscan number of energy scans
en array of energies (nscan long)
een array of errors on energies (nscan long) - can be NULL!
h1 array of TH1
gain reference to gain resulting from the fit
off reference to offset resulting from the fit
egain reference to error on the gain resulting from the fit
eoff reference to the error on the offset resulting from the fit
-
-
Returns:
graph energy vs inflection point
- -
-

- -

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
TGraphErrors* energyCalibration::calibrateSpectra (int  nscan,
Double_t *  en,
Double_t *  een,
TH1F **  h1,
Double_t &  gain,
Double_t &  off,
Double_t &  egain,
Double_t &  eoff 
) [inline]
-
-
- -

-calculates gain and offset for the set of energy spectra

Parameters:
- - - - - - - - - -
nscan number of energy scans
en array of energies (nscan long)
een array of errors on energies (nscan long) - can be NULL!
h1 array of TH1
gain reference to gain resulting from the fit
off reference to offset resulting from the fit
egain reference to error on the gain resulting from the fit
eoff reference to the error on the offset resulting from the fit
-
-
Returns:
graph energy vs peak
- -
-

- -

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
TF1* energyCalibration::fitFunction (TF1 *  fun,
TH1 *  h1,
Double_t *  mypar,
Double_t *  emypar 
) [private]
-
-
- -

-Perfors the fit according to the flags specified and returns the fitted function

Parameters:
- - - - - -
fun function to fit
h1 histogram to fit
mypar pointer to fit parameters array
emypar pointer to fit parameter errors
-
-
Returns:
the fitted function - can be used e.g. to get the Chi2 or similar
- -
-

- -

-
- - - - - - - - - - - - - - - - - - - - - - - - -
TF1* energyCalibration::fitSCurve (TH1 *  h1,
Double_t *  mypar,
Double_t *  emypar 
)
-
-
- -

-fits histogram with the s-curve function

Parameters:
- - - - -
h1 1d-histogram to be fitted
mypar pointer to fit parameters array
emypar pointer to fit parameter errors
-
-
Returns:
the fitted function - can be used e.g. to get the Chi2 or similar
- -
-

- -

-
- - - - - - - - - - - - - - - - - - - - - - - - -
TF1* energyCalibration::fitSpectrum (TH1 *  h1,
Double_t *  mypar,
Double_t *  emypar 
)
-
-
- -

-fits histogram with the spectrum

Parameters:
- - - - -
h1 1d-histogram to be fitted
mypar pointer to fit parameters array
emypar pointer to fit parameter errors
-
-
Returns:
the fitted function - can be used e.g. to get the Chi2 or similar
- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
void energyCalibration::getFitRange (Double_t &  mi,
Double_t &  ma 
) [inline]
-
-
- -

-gets the s-curve fit range

Parameters:
- - - -
mi reference for minimum of the fit range (-1 is histogram x-min)
ma reference for maximum of the fit range (-1 is histogram x-max)
-
- -
-

- -

-
- - - - - - - - - -
void energyCalibration::getStartParameters (Double_t *  par  ) 
-
-
- -

-get start parameters for the s-curve function

Parameters:
- - -
par parameters, -1 means auto-calculated par[0] is the pedestal par[1] is the slope of the pedestal par[2] is the inflection point par[3] is the RMS par[4] is the amplitude par[5] is the angual coefficient of the charge sharing slope (scales with par[3]) -- always positive
-
- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
void energyCalibration::initFitFunction (TF1 *  fun,
TH1 *  h1 
) [private]
-
-
- -

-Initializes the start parameters and the range of the fit depending on the histogram characteristics and/or on the start parameters specified by the user

Parameters:
- - - -
fun pointer to function to be initialized
h1 histogram from which to extract the range and start parameters, if not already specified by the user
-
- -
-

- -

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
TGraphErrors* energyCalibration::linearCalibration (int  nscan,
Double_t *  en,
Double_t *  een,
Double_t *  fl,
Double_t *  efl,
Double_t &  gain,
Double_t &  off,
Double_t &  egain,
Double_t &  eoff 
)
-
-
- -

-calculates gain and offset for the set of inflection points

Parameters:
- - - - - - - - - - -
nscan number of energy scans
en array of energies (nscan long)
een array of errors on energies (nscan long) - can be NULL!
fl array of inflection points (nscan long)
efl array of errors on the inflection points (nscan long)
gain reference to gain resulting from the fit
off reference to offset resulting from the fit
egain reference to error on the gain resulting from the fit
eoff reference to the error on the offset resulting from the fit
-
-
Returns:
graph energy vs inflection point
- -
-

- -

-
- - - - - - - - - -
int energyCalibration::setChargeSharing (int  p = -1  ) 
-
-
- -

-sets plot flag

Parameters:
- - -
p plot flag (-1 gets, 0 unsets, >0 plot)
-
-
Returns:
current plot flag
- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
void energyCalibration::setFitRange (Double_t  mi,
Double_t  ma 
) [inline]
-
-
- -

-sets the s-curve fit range

Parameters:
- - - -
mi minimum of the fit range (-1 is histogram x-min)
ma maximum of the fit range (-1 is histogram x-max)
-
- -
-

- -

-
- - - - - - - - - -
int energyCalibration::setPlotFlag (int  p = -1  )  [inline]
-
-
- -

-sets plot flag

Parameters:
- - -
p plot flag (-1 gets, 0 unsets, >0 plot)
-
-
Returns:
current plot flag
- -
-

- -

-
- - - - - - - - - -
int energyCalibration::setScanSign (int  s = 0  )  [inline]
-
-
- -

-sets scan sign

Parameters:
- - -
s can be 1 (energy and x-axis have the same direction) or -1 (energy and x-axis have opposite directions) otherwise gets
-
-
Returns:
current scan sign can be 1 (energy and x-axis have the same direction) or -1 (energy and x-axis have opposite directions)
- -
-

- -

-
- - - - - - - - - -
void energyCalibration::setStartParameters (Double_t *  par  ) 
-
-
- -

-set start parameters for the s-curve function

Parameters:
- - -
par parameters, -1 sets to auto-calculation par[0] is the pedestal par[1] is the slope of the pedestal par[2] is the inflection point par[3] is the RMS par[4] is the amplitude par[5] is the angual coefficient of the charge sharing slope (scales with par[3]) -- always positive
-
- -
-

-


Member Data Documentation

- -
-
- - - - -
Double_t energyCalibration::ampl [private]
-
-
- -

-start value for the number of photons -

-

- -

-
- - - - -
Double_t energyCalibration::bg_offset [private]
-
-
- -

-start value for the background pedestal -

-

- -

-
- - - - -
Double_t energyCalibration::bg_slope [private]
-
-
- -

-start value for the background slope -

-

- -

-
- - - - -
int energyCalibration::cs_flag [private]
-
-
- -

-0 functions without charge sharing contribution, >0 with charge sharing contribution -

-

- -

-
- - - - -
Double_t energyCalibration::cs_slope [private]
-
-
- -

-start value for the charge sharing slope -

-

- -

-
- - - - -
Double_t energyCalibration::fit_max [private]
-
-
- -

-maximum of the s-curve fitting range, -1 is histogram x-max -

-

- -

-
- - - - -
Double_t energyCalibration::fit_min [private]
-
-
- -

-minimum of the s-curve fitting range, -1 is histogram x-min -

-

- -

-
- - - - -
Double_t energyCalibration::flex [private]
-
-
- -

-start value for the inflection point -

-

- -

-
- - - - -
TF1* energyCalibration::fscurve [private]
-
-
- -

-function with which the s-curve will be fitted -

-

- -

-
- - - - -
TF1* energyCalibration::fspectrum [private]
-
-
- -

-function with which the spectrum will be fitted -

-

- -

- -
- -

- -

-

- -

-
- - - - -
Double_t energyCalibration::noise [private]
-
-
- -

-start value for the noise -

-

- -

-
- - - - -
int energyCalibration::plot_flag [private]
-
-
- -

-0 does not plot, >0 plots (flags?) -

-

-


The documentation for this class was generated from the following file: -
Generated on Tue Mar 27 16:32:29 2012 by  - -doxygen 1.4.7
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/classenergyCalibrationFunctions-members.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/classenergyCalibrationFunctions-members.html deleted file mode 100644 index 6e87b92ca..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/classenergyCalibrationFunctions-members.html +++ /dev/null @@ -1,38 +0,0 @@ - - -Member List - - - - - - -

energyCalibrationFunctions Member List

This is the complete list of members for energyCalibrationFunctions, including all inherited members.

- - - - - - - - - - - - - -
energyCalibrationFunctions(int s=-1)energyCalibrationFunctions [inline]
erfFuncFluo(Double_t *x, Double_t *par)energyCalibrationFunctions
erfFunction(Double_t *x, Double_t *par)energyCalibrationFunctions
erfFunctionChargeSharing(Double_t *x, Double_t *par)energyCalibrationFunctions
gaussChargeSharing(Double_t *x, Double_t *par)energyCalibrationFunctions
kth_smallest(int *a, int n, int k)energyCalibrationFunctions [static]
median(float *x, int n)energyCalibrationFunctions [static]
quick_select(int arr[], int n)energyCalibrationFunctions [static]
scurve(Double_t *x, Double_t *par)energyCalibrationFunctions
scurveFluo(Double_t *x, Double_t *par)energyCalibrationFunctions
setScanSign(int s=0)energyCalibrationFunctions [inline]
signenergyCalibrationFunctions [private]
spectrum(Double_t *x, Double_t *par)energyCalibrationFunctions


Generated on Tue Mar 27 16:32:29 2012 by  - -doxygen 1.4.7
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/classenergyCalibrationFunctions.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/classenergyCalibrationFunctions.html deleted file mode 100644 index 2a0dfd405..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/classenergyCalibrationFunctions.html +++ /dev/null @@ -1,428 +0,0 @@ - - -energyCalibrationFunctions Class Reference - - - - - - -

energyCalibrationFunctions Class Reference

Energy calibration functions. -More... -

-#include <energyCalibration.h> -

-List of all members. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Public Member Functions

 energyCalibrationFunctions (int s=-1)
int setScanSign (int s=0)
Double_t gaussChargeSharing (Double_t *x, Double_t *par)
Double_t erfFunction (Double_t *x, Double_t *par)
Double_t erfFunctionChargeSharing (Double_t *x, Double_t *par)
Double_t erfFuncFluo (Double_t *x, Double_t *par)
Double_t spectrum (Double_t *x, Double_t *par)
Double_t scurve (Double_t *x, Double_t *par)
Double_t scurveFluo (Double_t *x, Double_t *par)

Static Public Member Functions

static float median (float *x, int n)
static int quick_select (int arr[], int n)
static int kth_smallest (int *a, int n, int k)

Private Attributes

int sign
-


Detailed Description

-Energy calibration functions. -

-class containing all the possible energy calibration functions (scurves with and without charge sharing, gaussian spectrum with and without charge sharing, possibility of chosing the sign of the X-axis) -

-


Constructor & Destructor Documentation

- -
-
- - - - - - - - - -
energyCalibrationFunctions::energyCalibrationFunctions (int  s = -1  )  [inline]
-
-
- -

- -

-

-


Member Function Documentation

- -
-
- - - - - - - - - - - - - - - - - - -
Double_t energyCalibrationFunctions::erfFuncFluo (Double_t *  x,
Double_t *  par 
)
-
-
- -

-Double Erf function with charge sharing slope par[0] is the pedestal par[1] is the slope of the pedestal par[2] is the inflection point of the first energy par[3] is the RMS of the first energy par[4] is the amplitude of the first energy par[5] is the angual coefficient of the charge sharing slope of the first energy (scales with par[3]) par[6] is the inflection point of the second energy par[7] is the RMS of the second energy par[8] is the amplitude of the second energy par[9] is the angual coefficient of the charge sharing slope of the second energy (scales with par[8]) -

-

- -

-
- - - - - - - - - - - - - - - - - - -
Double_t energyCalibrationFunctions::erfFunction (Double_t *  x,
Double_t *  par 
)
-
-
- -

-Basic erf function par[0] is the inflection point par[1] is the RMS par[2] is the amplitude -

-

- -

-
- - - - - - - - - - - - - - - - - - -
Double_t energyCalibrationFunctions::erfFunctionChargeSharing (Double_t *  x,
Double_t *  par 
)
-
-
- -

-Erf function with charge sharing slope par[0] is the pedestal par[1] is the slope of the pedestal par[2] is the inflection point par[3] is the RMS par[4] is the amplitude par[5] is the angual coefficient of the charge sharing slope (scales with par[3]) -

-

- -

-
- - - - - - - - - - - - - - - - - - -
Double_t energyCalibrationFunctions::gaussChargeSharing (Double_t *  x,
Double_t *  par 
)
-
-
- -

-Gaussian Function with charge sharing pedestal par[0] is the absolute height of the background pedestal par[1] is the slope of the background pedestal par[2] is the gaussian peak position par[3] is the RMS of the gaussian (and of the pedestal) par[4] is the height of the function par[5] is the fractional height of the charge sharing pedestal (scales with par[3]) -

-

- -

-
- - - - - - - - - - - - - - - - - - - - - - - - -
static int energyCalibrationFunctions::kth_smallest (int *  a,
int  n,
int  k 
) [static]
-
-
- -

-Calculates the median of an array of n elements (swaps the arrays!) -

-

- -

-
- - - - - - - - - - - - - - - - - - -
static float energyCalibrationFunctions::median (float *  x,
int  n 
) [static]
-
-
- -

-Calculates the median of an array of n elements -

-

- -

-
- - - - - - - - - - - - - - - - - - -
static int energyCalibrationFunctions::quick_select (int  arr[],
int  n 
) [static]
-
-
- -

-Calculates the median of an array of n elements (swaps the arrays!) -

-

- -

-
- - - - - - - - - - - - - - - - - - -
Double_t energyCalibrationFunctions::scurve (Double_t *  x,
Double_t *  par 
)
-
-
- -

-Erf function with charge sharing slope with the correct scan sign par[0] is the pedestal par[1] is the slope of the pedestal par[2] is the inflection point par[3] is the RMS par[4] is the amplitude par[5] is the angual coefficient of the charge sharing slope (scales with par[3]) -

-

- -

-
- - - - - - - - - - - - - - - - - - -
Double_t energyCalibrationFunctions::scurveFluo (Double_t *  x,
Double_t *  par 
)
-
-
- -

-Double Erf function with charge sharing slope par[0] is the pedestal par[1] is the slope of the pedestal par[2] is the inflection point of the first energy par[3] is the RMS of the first energy par[4] is the amplitude of the first energy par[5] is the angual coefficient of the charge sharing slope of the first energy (scales with par[3]) par[6] is the inflection point of the second energy par[7] is the RMS of the second energy par[8] is the amplitude of the second energy par[9] is the angual coefficient of the charge sharing slope of the second energy (scales with par[8]) -

-

- -

-
- - - - - - - - - -
int energyCalibrationFunctions::setScanSign (int  s = 0  )  [inline]
-
-
- -

-sets scan sign

Parameters:
- - -
s can be 1 (energy and x-axis have the same direction) or -1 (energy and x-axis have opposite directions) otherwise gets
-
-
Returns:
current scan sign can be 1 (energy and x-axis have the same direction) or -1 (energy and x-axis have opposite directions)
- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
Double_t energyCalibrationFunctions::spectrum (Double_t *  x,
Double_t *  par 
)
-
-
- -

-static function Gaussian with charge sharing pedestal with the correct scan sign par[0] is the absolute height of the background pedestal par[1] is the fractional height of the charge sharing pedestal (scales with par[3] par[2] is the gaussian peak position par[3] is the RMS of the gaussian (and of the pedestal) par[4] is the height of the function -

-

-


Member Data Documentation

- -
-
- - - - -
int energyCalibrationFunctions::sign [private]
-
-
- -

- -

-

-


The documentation for this class was generated from the following file: -
Generated on Tue Mar 27 16:32:29 2012 by  - -doxygen 1.4.7
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/classes.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/classes.html deleted file mode 100644 index 4cc7a4ddd..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/classes.html +++ /dev/null @@ -1,69 +0,0 @@ - - - - - -Alphabetical List - - - - - - - - - -
-

Class Index

- -
  E  
-
energyCalibration   energyCalibrationFunctions   
-
- - - - -
- -
- -
Generated on Tue Mar 20 17:21:14 2012 by  - -doxygen 1.6.0
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/doxygen.css b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/doxygen.css deleted file mode 100644 index 5d583694e..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/doxygen.css +++ /dev/null @@ -1,358 +0,0 @@ -BODY,H1,H2,H3,H4,H5,H6,P,CENTER,TD,TH,UL,DL,DIV { - font-family: Geneva, Arial, Helvetica, sans-serif; -} -BODY,TD { - font-size: 90%; -} -H1 { - text-align: center; - font-size: 160%; -} -H2 { - font-size: 120%; -} -H3 { - font-size: 100%; -} -CAPTION { font-weight: bold } -DIV.qindex { - width: 100%; - background-color: #e8eef2; - border: 1px solid #84b0c7; - text-align: center; - margin: 2px; - padding: 2px; - line-height: 140%; -} -DIV.nav { - width: 100%; - background-color: #e8eef2; - border: 1px solid #84b0c7; - text-align: center; - margin: 2px; - padding: 2px; - line-height: 140%; -} -DIV.navtab { - background-color: #e8eef2; - border: 1px solid #84b0c7; - text-align: center; - margin: 2px; - margin-right: 15px; - padding: 2px; -} -TD.navtab { - font-size: 70%; -} -A.qindex { - text-decoration: none; - font-weight: bold; - color: #1A419D; -} -A.qindex:visited { - text-decoration: none; - font-weight: bold; - color: #1A419D -} -A.qindex:hover { - text-decoration: none; - background-color: #ddddff; -} -A.qindexHL { - text-decoration: none; - font-weight: bold; - background-color: #6666cc; - color: #ffffff; - border: 1px double #9295C2; -} -A.qindexHL:hover { - text-decoration: none; - background-color: #6666cc; - color: #ffffff; -} -A.qindexHL:visited { text-decoration: none; background-color: #6666cc; color: #ffffff } -A.el { text-decoration: none; font-weight: bold } -A.elRef { font-weight: bold } -A.code:link { text-decoration: none; font-weight: normal; color: #0000FF} -A.code:visited { text-decoration: none; font-weight: normal; color: #0000FF} -A.codeRef:link { font-weight: normal; color: #0000FF} -A.codeRef:visited { font-weight: normal; color: #0000FF} -A:hover { text-decoration: none; background-color: #f2f2ff } -DL.el { margin-left: -1cm } -.fragment { - font-family: monospace, fixed; - font-size: 95%; -} -PRE.fragment { - border: 1px solid #CCCCCC; - background-color: #f5f5f5; - margin-top: 4px; - margin-bottom: 4px; - margin-left: 2px; - margin-right: 8px; - padding-left: 6px; - padding-right: 6px; - padding-top: 4px; - padding-bottom: 4px; -} -DIV.ah { background-color: black; font-weight: bold; color: #ffffff; margin-bottom: 3px; margin-top: 3px } - -DIV.groupHeader { - margin-left: 16px; - margin-top: 12px; - margin-bottom: 6px; - font-weight: bold; -} -DIV.groupText { margin-left: 16px; font-style: italic; font-size: 90% } -BODY { - background: white; - color: black; - margin-right: 20px; - margin-left: 20px; -} -TD.indexkey { - background-color: #e8eef2; - font-weight: bold; - padding-right : 10px; - padding-top : 2px; - padding-left : 10px; - padding-bottom : 2px; - margin-left : 0px; - margin-right : 0px; - margin-top : 2px; - margin-bottom : 2px; - border: 1px solid #CCCCCC; -} -TD.indexvalue { - background-color: #e8eef2; - font-style: italic; - padding-right : 10px; - padding-top : 2px; - padding-left : 10px; - padding-bottom : 2px; - margin-left : 0px; - margin-right : 0px; - margin-top : 2px; - margin-bottom : 2px; - border: 1px solid #CCCCCC; -} -TR.memlist { - background-color: #f0f0f0; -} -P.formulaDsp { text-align: center; } -IMG.formulaDsp { } -IMG.formulaInl { vertical-align: middle; } -SPAN.keyword { color: #008000 } -SPAN.keywordtype { color: #604020 } -SPAN.keywordflow { color: #e08000 } -SPAN.comment { color: #800000 } -SPAN.preprocessor { color: #806020 } -SPAN.stringliteral { color: #002080 } -SPAN.charliteral { color: #008080 } -.mdescLeft { - padding: 0px 8px 4px 8px; - font-size: 80%; - font-style: italic; - background-color: #FAFAFA; - border-top: 1px none #E0E0E0; - border-right: 1px none #E0E0E0; - border-bottom: 1px none #E0E0E0; - border-left: 1px none #E0E0E0; - margin: 0px; -} -.mdescRight { - padding: 0px 8px 4px 8px; - font-size: 80%; - font-style: italic; - background-color: #FAFAFA; - border-top: 1px none #E0E0E0; - border-right: 1px none #E0E0E0; - border-bottom: 1px none #E0E0E0; - border-left: 1px none #E0E0E0; - margin: 0px; -} -.memItemLeft { - padding: 1px 0px 0px 8px; - margin: 4px; - border-top-width: 1px; - border-right-width: 1px; - border-bottom-width: 1px; - border-left-width: 1px; - border-top-color: #E0E0E0; - border-right-color: #E0E0E0; - border-bottom-color: #E0E0E0; - border-left-color: #E0E0E0; - border-top-style: solid; - border-right-style: none; - border-bottom-style: none; - border-left-style: none; - background-color: #FAFAFA; - font-size: 80%; -} -.memItemRight { - padding: 1px 8px 0px 8px; - margin: 4px; - border-top-width: 1px; - border-right-width: 1px; - border-bottom-width: 1px; - border-left-width: 1px; - border-top-color: #E0E0E0; - border-right-color: #E0E0E0; - border-bottom-color: #E0E0E0; - border-left-color: #E0E0E0; - border-top-style: solid; - border-right-style: none; - border-bottom-style: none; - border-left-style: none; - background-color: #FAFAFA; - font-size: 80%; -} -.memTemplItemLeft { - padding: 1px 0px 0px 8px; - margin: 4px; - border-top-width: 1px; - border-right-width: 1px; - border-bottom-width: 1px; - border-left-width: 1px; - border-top-color: #E0E0E0; - border-right-color: #E0E0E0; - border-bottom-color: #E0E0E0; - border-left-color: #E0E0E0; - border-top-style: none; - border-right-style: none; - border-bottom-style: none; - border-left-style: none; - background-color: #FAFAFA; - font-size: 80%; -} -.memTemplItemRight { - padding: 1px 8px 0px 8px; - margin: 4px; - border-top-width: 1px; - border-right-width: 1px; - border-bottom-width: 1px; - border-left-width: 1px; - border-top-color: #E0E0E0; - border-right-color: #E0E0E0; - border-bottom-color: #E0E0E0; - border-left-color: #E0E0E0; - border-top-style: none; - border-right-style: none; - border-bottom-style: none; - border-left-style: none; - background-color: #FAFAFA; - font-size: 80%; -} -.memTemplParams { - padding: 1px 0px 0px 8px; - margin: 4px; - border-top-width: 1px; - border-right-width: 1px; - border-bottom-width: 1px; - border-left-width: 1px; - border-top-color: #E0E0E0; - border-right-color: #E0E0E0; - border-bottom-color: #E0E0E0; - border-left-color: #E0E0E0; - border-top-style: solid; - border-right-style: none; - border-bottom-style: none; - border-left-style: none; - color: #606060; - background-color: #FAFAFA; - font-size: 80%; -} -.search { color: #003399; - font-weight: bold; -} -FORM.search { - margin-bottom: 0px; - margin-top: 0px; -} -INPUT.search { font-size: 75%; - color: #000080; - font-weight: normal; - background-color: #e8eef2; -} -TD.tiny { font-size: 75%; -} -a { - color: #1A41A8; -} -a:visited { - color: #2A3798; -} -.dirtab { padding: 4px; - border-collapse: collapse; - border: 1px solid #84b0c7; -} -TH.dirtab { background: #e8eef2; - font-weight: bold; -} -HR { height: 1px; - border: none; - border-top: 1px solid black; -} - -/* Style for detailed member documentation */ -.memtemplate { - font-size: 80%; - color: #606060; - font-weight: normal; -} -.memnav { - background-color: #e8eef2; - border: 1px solid #84b0c7; - text-align: center; - margin: 2px; - margin-right: 15px; - padding: 2px; -} -.memitem { - padding: 4px; - background-color: #eef3f5; - border-width: 1px; - border-style: solid; - border-color: #dedeee; - -moz-border-radius: 8px 8px 8px 8px; -} -.memname { - white-space: nowrap; - font-weight: bold; -} -.memdoc{ - padding-left: 10px; -} -.memproto { - background-color: #d5e1e8; - width: 100%; - border-width: 1px; - border-style: solid; - border-color: #84b0c7; - font-weight: bold; - -moz-border-radius: 8px 8px 8px 8px; -} -.paramkey { - text-align: right; -} -.paramtype { - white-space: nowrap; -} -.paramname { - color: #602020; - font-style: italic; -} -/* End Styling for detailed member documentation */ - -/* for the tree view */ -.ftvtree { - font-family: sans-serif; - margin:0.5em; -} -.directory { font-size: 9pt; font-weight: bold; } -.directory h3 { margin: 0px; margin-top: 1em; font-size: 11pt; } -.directory > h3 { margin-top: 0; } -.directory p { margin: 0px; white-space: nowrap; } -.directory div { display: none; margin: 0px; } -.directory img { vertical-align: -30%; } - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/doxygen.png b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/doxygen.png deleted file mode 100644 index f0a274bba..000000000 Binary files a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/doxygen.png and /dev/null differ diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/energyCalibration_8h-source.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/energyCalibration_8h-source.html deleted file mode 100644 index 64e8c0558..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/energyCalibration_8h-source.html +++ /dev/null @@ -1,164 +0,0 @@ - - -energyCalibration.h Source File - - - - - - -

energyCalibration.h

Go to the documentation of this file.
00001 
-00002 #ifndef ENERGYCALIBRATION_H
-00003 #define ENERGYCALIBRATION_H
-00004 
-00005 #include <TROOT.h>
-00006 #include <TF1.h>
-00007 
-00008 using namespace std;
-00009 
-00010 class TH1F;
-00011 class TGraphErrors;
-00012 
-00013 
-00014 
-00015 
-00016 
-00017 const float conven=1000./3.6; 
-00018 const float el=1.67E-4; 
-00050 class energyCalibrationFunctions {
-00051 
-00052  public:
-00053   
-00054   energyCalibrationFunctions(int s=-1) {setScanSign(s);};
-00055   
-00060   int setScanSign(int s=0) {if (s==1 || s==-1) sign=s; return sign;};;
-00061   
-00062 
-00072   Double_t gaussChargeSharing(Double_t *x, Double_t *par);
-00073 
-00080 Double_t erfFunction(Double_t *x, Double_t *par) ;
-00081 
-00090 Double_t erfFunctionChargeSharing(Double_t *x, Double_t *par);
-00091   
-00105 Double_t erfFuncFluo(Double_t *x, Double_t *par);
-00106 
-00107 
-00109   static float median(float *x, int n);
-00111   static int quick_select(int arr[], int n);
-00113   static int kth_smallest(int *a, int n, int k);
-00114 
-00115   
-00124   Double_t spectrum(Double_t *x, Double_t *par);
-00125 
-00126 
-00135   Double_t scurve(Double_t *x, Double_t *par);
-00136 
-00137 
-00138 
-00151   Double_t scurveFluo(Double_t *x, Double_t *par);
-00152 
-00153 
-00154  private:
-00155   int sign;
-00156     
-00157 
-00158 };
-00159 
-00165 class energyCalibration  {
-00166 
-00167 
-00168  public:
-00172   energyCalibration();
-00173     
-00177   ~energyCalibration();
-00178     
-00183   int setPlotFlag(int p=-1) {if (p>=0) plot_flag=p; return plot_flag;};
-00184 
-00189   int setScanSign(int s=0) {return funcs->setScanSign(s);};
-00190   
-00195   int setChargeSharing(int p=-1);
-00196   
-00201   void setFitRange(Double_t mi, Double_t ma){fit_min=mi; fit_max=ma;};
-00202 
-00207   void getFitRange(Double_t &mi, Double_t &ma){mi=fit_min; ma=fit_max;};
-00208 
-00209 
-00219   void setStartParameters(Double_t *par);
-00220   
-00230   void getStartParameters(Double_t *par);
-00231 
-00239   TF1 *fitSCurve(TH1 *h1, Double_t *mypar, Double_t *emypar);
-00240 
-00241 
-00249   TF1 *fitSpectrum(TH1 *h1, Double_t *mypar, Double_t *emypar);
-00250 
-00251 
-00265   TGraphErrors* linearCalibration(int nscan, Double_t *en, Double_t *een, Double_t *fl, Double_t *efl, Double_t &gain, Double_t &off, Double_t &egain, Double_t &eoff);  
-00266 
-00279   TGraphErrors* calibrateScurves(int nscan, Double_t *en, Double_t *een, TH1F **h1, Double_t &gain, Double_t &off, Double_t &egain, Double_t &eoff){return calibrate(nscan, en, een, h1, gain, off, egain, eoff, 1);};    
-00280 
-00293   TGraphErrors* calibrateSpectra(int nscan, Double_t *en, Double_t *een, TH1F **h1, Double_t &gain, Double_t &off, Double_t &egain, Double_t &eoff){return calibrate(nscan, en, een, h1, gain, off, egain, eoff, 0);};  
-00294 
-00295 
-00296 
-00297  private:
-00309   TGraphErrors* calibrate(int nscan, Double_t *en, Double_t *een, TH1F **h1, Double_t &gain, Double_t &off, Double_t &egain, Double_t &eoff, int integral=1);  
-00310 
-00311 
-00319   void initFitFunction(TF1 *fun, TH1 *h1);
-00320 
-00321 
-00330   TF1 *fitFunction(TF1 *fun, TH1 *h1, Double_t *mypar, Double_t *emypar);  
-00331 
-00332 
-00333   int plot_flag; 
-00335   int cs_flag; 
-00337   Double_t fit_min; 
-00338   Double_t fit_max; 
-00340   Double_t bg_offset; 
-00341   Double_t bg_slope; 
-00342   Double_t flex; 
-00343   Double_t noise; 
-00344   Double_t ampl; 
-00345   Double_t cs_slope; 
-00347   energyCalibrationFunctions *funcs;
-00348 
-00349   TF1 *fscurve; 
-00351   TF1 *fspectrum; 
-00354 };
-00355 
-00356 #endif
-00357 
-00358 
-00359 
-00360 
-00361 
-00362 
-00363 
-00364 
-00365 
-00366 
-00367 
-00368 
-00369 
-00370 
-00371 
-00372 
-00373 
-00374 
-00375 
-

Generated on Tue Mar 27 16:32:29 2012 by  - -doxygen 1.4.7
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/energyCalibration_8h.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/energyCalibration_8h.html deleted file mode 100644 index a25ed2496..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/energyCalibration_8h.html +++ /dev/null @@ -1,76 +0,0 @@ - - -energyCalibration.h File Reference - - - - - - -

energyCalibration.h File Reference

#include <TROOT.h>
-#include <TF1.h>
- -

-Go to the source code of this file. - - - - - - - - - - - - - - - -

Namespaces

namespace  std

Classes

class  energyCalibrationFunctions
 Energy calibration functions. More...
class  energyCalibration

Variables

const float conven = 1000./3.6
const float el = 1.67E-4
-


Variable Documentation

- -
-
- - - - -
const float conven = 1000./3.6
-
-
- -

-electrons/keV -

-

- -

-
- - - - -
const float el = 1.67E-4
-
-
- -

-electron charge in fC -

-

-


Generated on Tue Mar 27 16:32:29 2012 by  - -doxygen 1.4.7
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/energyCalibration_8h_source.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/energyCalibration_8h_source.html deleted file mode 100644 index fc14ca380..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/energyCalibration_8h_source.html +++ /dev/null @@ -1,190 +0,0 @@ - - - - - -energyCalibration.h Source File - - - - - - - - - - - - - -
- -
- -
Generated on Tue Mar 20 17:21:14 2012 by  - -doxygen 1.6.0
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/files.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/files.html deleted file mode 100644 index a0ea14100..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/files.html +++ /dev/null @@ -1,27 +0,0 @@ - - -File Index - - - - - - -

File List

Here is a list of all files with brief descriptions: - -
energyCalibration.h [code]
-
Generated on Tue Mar 27 16:32:29 2012 by  - -doxygen 1.4.7
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/functions.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/functions.html deleted file mode 100644 index 2dc86e2c0..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/functions.html +++ /dev/null @@ -1,126 +0,0 @@ - - -Class Members - - - - - - -
- -
-
- -
- -

-Here is a list of all class members with links to the classes they belong to: -

-

- a -

-

- b -

-

- c -

-

- e -

-

- f -

-

- g -

-

- i -

-

- k -

-

- l -

-

- m -

-

- n -

-

- p -

-

- q -

-

- s -

-

- ~ -

-
Generated on Tue Mar 27 16:32:29 2012 by  - -doxygen 1.4.7
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/functions_func.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/functions_func.html deleted file mode 100644 index a82a14a3a..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/functions_func.html +++ /dev/null @@ -1,63 +0,0 @@ - - -Class Members - Functions - - - - - - -
- -
-  -

-

-
Generated on Tue Mar 27 16:32:29 2012 by  - -doxygen 1.4.7
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/functions_vars.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/functions_vars.html deleted file mode 100644 index 3eb5ab2c3..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/functions_vars.html +++ /dev/null @@ -1,49 +0,0 @@ - - -Class Members - Variables - - - - - - -
- -
-  -

-

-
Generated on Tue Mar 27 16:32:29 2012 by  - -doxygen 1.4.7
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/globals.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/globals.html deleted file mode 100644 index 6867e7583..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/globals.html +++ /dev/null @@ -1,36 +0,0 @@ - - -Class Members - - - - - - -
- -
-Here is a list of all file members with links to the files they belong to: -

-

-
Generated on Tue Mar 27 16:32:29 2012 by  - -doxygen 1.4.7
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/globals_vars.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/globals_vars.html deleted file mode 100644 index efb3d3424..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/globals_vars.html +++ /dev/null @@ -1,36 +0,0 @@ - - -Class Members - - - - - - -
- -
-  -

-

-
Generated on Tue Mar 27 16:32:29 2012 by  - -doxygen 1.4.7
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/index.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/index.html deleted file mode 100644 index 8e6122ad2..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/index.html +++ /dev/null @@ -1,25 +0,0 @@ - - -Common Root library for SLS detectors data analysis - - - - - -

Common Root library for SLS detectors data analysis

-

-

-Introduction

-We know very well s-curves etc. but at the end everybody uses different functions ;-).

-Motivation

-It would be greate to use everybody the same functions...
Generated on Tue Mar 27 16:32:29 2012 by  - -doxygen 1.4.7
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/installdox b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/installdox deleted file mode 100755 index 9b89fe025..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/installdox +++ /dev/null @@ -1,117 +0,0 @@ -#!/usr/bin/perl - -%subst = ( ); -$quiet = 0; - -if (open(F,"search.cfg")) -{ - $_= ; s/[ \t\n]*$//g ; $subst{"_doc"} = $_; - $_= ; s/[ \t\n]*$//g ; $subst{"_cgi"} = $_; -} - -while ( @ARGV ) { - $_ = shift @ARGV; - if ( s/^-// ) { - if ( /^l(.*)/ ) { - $v = ($1 eq "") ? shift @ARGV : $1; - ($v =~ /\/$/) || ($v .= "/"); - $_ = $v; - if ( /(.+)\@(.+)/ ) { - if ( exists $subst{$1} ) { - $subst{$1} = $2; - } else { - print STDERR "Unknown tag file $1 given with option -l\n"; - &usage(); - } - } else { - print STDERR "Argument $_ is invalid for option -l\n"; - &usage(); - } - } - elsif ( /^q/ ) { - $quiet = 1; - } - elsif ( /^\?|^h/ ) { - &usage(); - } - else { - print STDERR "Illegal option -$_\n"; - &usage(); - } - } - else { - push (@files, $_ ); - } -} - -foreach $sub (keys %subst) -{ - if ( $subst{$sub} eq "" ) - { - print STDERR "No substitute given for tag file `$sub'\n"; - &usage(); - } - elsif ( ! $quiet && $sub ne "_doc" && $sub ne "_cgi" ) - { - print "Substituting $subst{$sub} for each occurence of tag file $sub\n"; - } -} - -if ( ! @files ) { - if (opendir(D,".")) { - foreach $file ( readdir(D) ) { - $match = ".html"; - next if ( $file =~ /^\.\.?$/ ); - ($file =~ /$match/) && (push @files, $file); - ($file =~ "tree.js") && (push @files, $file); - } - closedir(D); - } -} - -if ( ! @files ) { - print STDERR "Warning: No input files given and none found!\n"; -} - -foreach $f (@files) -{ - if ( ! $quiet ) { - print "Editing: $f...\n"; - } - $oldf = $f; - $f .= ".bak"; - unless (rename $oldf,$f) { - print STDERR "Error: cannot rename file $oldf\n"; - exit 1; - } - if (open(F,"<$f")) { - unless (open(G,">$oldf")) { - print STDERR "Error: opening file $oldf for writing\n"; - exit 1; - } - if ($oldf ne "tree.js") { - while () { - s/doxygen\=\"([^ \"\:\t\>\<]*)\:([^ \"\t\>\<]*)\" (href|src)=\"\2/doxygen\=\"$1:$subst{$1}\" \3=\"$subst{$1}/g; - print G "$_"; - } - } - else { - while () { - s/\"([^ \"\:\t\>\<]*)\:([^ \"\t\>\<]*)\", \"\2/\"$1:$subst{$1}\" ,\"$subst{$1}/g; - print G "$_"; - } - } - } - else { - print STDERR "Warning file $f does not exist\n"; - } - unlink $f; -} - -sub usage { - print STDERR "Usage: installdox [options] [html-file [html-file ...]]\n"; - print STDERR "Options:\n"; - print STDERR " -l tagfile\@linkName tag file + URL or directory \n"; - print STDERR " -q Quiet mode\n\n"; - exit 1; -} diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/namespaces.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/namespaces.html deleted file mode 100644 index f3343cb4d..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/namespaces.html +++ /dev/null @@ -1,22 +0,0 @@ - - -Namespace Index - - - - - -

Namespace List

Here is a list of all namespaces with brief descriptions: - -
std
-
Generated on Tue Mar 27 16:32:29 2012 by  - -doxygen 1.4.7
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/namespacestd.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/namespacestd.html deleted file mode 100644 index 7f96b5d3c..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/namespacestd.html +++ /dev/null @@ -1,24 +0,0 @@ - - -std Namespace Reference - - - - - -

std Namespace Reference

-

- - -
-


Generated on Tue Mar 27 16:32:29 2012 by  - -doxygen 1.4.7
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_61.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_61.html deleted file mode 100644 index dbc525140..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_61.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - -
-
Loading...
-
-
- ampl - energyCalibration -
-
-
Searching...
-
No Matches
- -
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_62.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_62.html deleted file mode 100644 index 1587baf85..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_62.html +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - -
-
Loading...
-
-
- bg_offset - energyCalibration -
-
-
-
- bg_slope - energyCalibration -
-
-
Searching...
-
No Matches
- -
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_63.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_63.html deleted file mode 100644 index 9f05baa3d..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_63.html +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - -
-
Loading...
-
-
- calibrate - energyCalibration -
-
-
-
- conven - energyCalibration.h -
-
-
-
- cs_slope - energyCalibration -
-
-
Searching...
-
No Matches
- -
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_65.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_65.html deleted file mode 100644 index d8cc513ff..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_65.html +++ /dev/null @@ -1,66 +0,0 @@ - - - - - - -
-
Loading...
-
-
- el - energyCalibration.h -
-
- - - -
-
- erfFuncFluo - energyCalibrationFunctions -
-
-
-
- erfFunction - energyCalibrationFunctions -
-
-
-
- erfFunctionChargeSharing - energyCalibrationFunctions -
-
-
Searching...
-
No Matches
- -
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_66.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_66.html deleted file mode 100644 index bd1572f3b..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_66.html +++ /dev/null @@ -1,55 +0,0 @@ - - - - - - -
-
Loading...
-
-
- fit_max - energyCalibration -
-
-
-
- fit_min - energyCalibration -
-
-
-
- fitSCurve - energyCalibration -
-
-
-
- flex - energyCalibration -
-
-
-
- fscurve - energyCalibration -
-
-
-
- funcs - energyCalibration -
-
-
Searching...
-
No Matches
- -
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_67.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_67.html deleted file mode 100644 index a5fbc8718..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_67.html +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - -
-
Loading...
-
-
- gaussChargeSharing - energyCalibrationFunctions -
-
-
-
- getFitRange - energyCalibration -
-
-
-
- getStartParameters - energyCalibration -
-
-
Searching...
-
No Matches
- -
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_6b.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_6b.html deleted file mode 100644 index 40cf25174..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_6b.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - -
-
Loading...
-
-
- kth_smallest - energyCalibrationFunctions -
-
-
Searching...
-
No Matches
- -
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_6c.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_6c.html deleted file mode 100644 index 6ddf1903c..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_6c.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - -
-
Loading...
-
-
- linearCalibration - energyCalibration -
-
-
Searching...
-
No Matches
- -
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_6d.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_6d.html deleted file mode 100644 index d7612fe26..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_6d.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - -
-
Loading...
-
-
- median - energyCalibrationFunctions -
-
-
Searching...
-
No Matches
- -
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_6e.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_6e.html deleted file mode 100644 index 7ee4200c2..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_6e.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - -
-
Loading...
-
-
- noise - energyCalibration -
-
-
Searching...
-
No Matches
- -
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_70.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_70.html deleted file mode 100644 index 402fa63cb..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_70.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - -
-
Loading...
-
-
- plot_flag - energyCalibration -
-
-
Searching...
-
No Matches
- -
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_71.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_71.html deleted file mode 100644 index 0c68aa1c7..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_71.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - -
-
Loading...
-
-
- quick_select - energyCalibrationFunctions -
-
-
Searching...
-
No Matches
- -
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_73.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_73.html deleted file mode 100644 index 52cede178..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_73.html +++ /dev/null @@ -1,70 +0,0 @@ - - - - - - -
-
Loading...
-
-
- scurve - energyCalibrationFunctions -
-
-
-
- scurveFluo - energyCalibrationFunctions -
-
-
-
- setFitRange - energyCalibration -
-
-
-
- setPlotFlag - energyCalibration -
-
- -
-
- setStartParameters - energyCalibration -
-
-
-
- sign - energyCalibrationFunctions -
-
-
-
- spectrum - energyCalibrationFunctions -
-
-
Searching...
-
No Matches
- -
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_7e.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_7e.html deleted file mode 100644 index 22b73eeab..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_7e.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - -
-
Loading...
-
-
- ~energyCalibration - energyCalibration -
-
-
Searching...
-
No Matches
- -
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/classes_65.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/classes_65.html deleted file mode 100644 index 0cd426302..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/classes_65.html +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - -
-
Loading...
- - -
Searching...
-
No Matches
- -
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/close.png b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/close.png deleted file mode 100644 index 9342d3dfe..000000000 Binary files a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/close.png and /dev/null differ diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/files_65.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/files_65.html deleted file mode 100644 index 72afed66a..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/files_65.html +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - -
-
Loading...
- -
Searching...
-
No Matches
- -
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/functions_63.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/functions_63.html deleted file mode 100644 index dbde61421..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/functions_63.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - -
-
Loading...
-
-
- calibrate - energyCalibration -
-
-
Searching...
-
No Matches
- -
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/functions_65.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/functions_65.html deleted file mode 100644 index 4aac8500d..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/functions_65.html +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - -
-
Loading...
-
-
- energyCalibration - energyCalibration -
-
-
-
- energyCalibrationFunctions - energyCalibrationFunctions -
-
-
-
- erfFuncFluo - energyCalibrationFunctions -
-
-
-
- erfFunction - energyCalibrationFunctions -
-
-
-
- erfFunctionChargeSharing - energyCalibrationFunctions -
-
-
Searching...
-
No Matches
- -
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/functions_66.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/functions_66.html deleted file mode 100644 index e1b9f157c..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/functions_66.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - -
-
Loading...
-
-
- fitSCurve - energyCalibration -
-
-
Searching...
-
No Matches
- -
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/functions_67.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/functions_67.html deleted file mode 100644 index a5fbc8718..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/functions_67.html +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - -
-
Loading...
-
-
- gaussChargeSharing - energyCalibrationFunctions -
-
-
-
- getFitRange - energyCalibration -
-
-
-
- getStartParameters - energyCalibration -
-
-
Searching...
-
No Matches
- -
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/functions_6b.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/functions_6b.html deleted file mode 100644 index 40cf25174..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/functions_6b.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - -
-
Loading...
-
-
- kth_smallest - energyCalibrationFunctions -
-
-
Searching...
-
No Matches
- -
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/functions_6c.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/functions_6c.html deleted file mode 100644 index 6ddf1903c..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/functions_6c.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - -
-
Loading...
-
-
- linearCalibration - energyCalibration -
-
-
Searching...
-
No Matches
- -
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/functions_6d.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/functions_6d.html deleted file mode 100644 index d7612fe26..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/functions_6d.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - -
-
Loading...
-
-
- median - energyCalibrationFunctions -
-
-
Searching...
-
No Matches
- -
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/functions_71.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/functions_71.html deleted file mode 100644 index 0c68aa1c7..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/functions_71.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - -
-
Loading...
-
-
- quick_select - energyCalibrationFunctions -
-
-
Searching...
-
No Matches
- -
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/functions_73.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/functions_73.html deleted file mode 100644 index 4daf9bb0f..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/functions_73.html +++ /dev/null @@ -1,64 +0,0 @@ - - - - - - -
-
Loading...
-
-
- scurve - energyCalibrationFunctions -
-
-
-
- scurveFluo - energyCalibrationFunctions -
-
-
-
- setFitRange - energyCalibration -
-
-
-
- setPlotFlag - energyCalibration -
-
- -
-
- setStartParameters - energyCalibration -
-
-
-
- spectrum - energyCalibrationFunctions -
-
-
Searching...
-
No Matches
- -
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/functions_7e.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/functions_7e.html deleted file mode 100644 index 22b73eeab..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/functions_7e.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - -
-
Loading...
-
-
- ~energyCalibration - energyCalibration -
-
-
Searching...
-
No Matches
- -
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/nomatches.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/nomatches.html deleted file mode 100644 index fd9248fe3..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/nomatches.html +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - -
-
No Matches
-
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/search.css b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/search.css deleted file mode 100644 index d263b9724..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/search.css +++ /dev/null @@ -1,198 +0,0 @@ -/*---------------- Search Box */ - -#MSearchBox { - padding: 0px; - margin: 0px; - border: none; - border: 1px solid #84B0C7; - white-space: nowrap; - -moz-border-radius: 8px; - -webkit-border-top-left-radius: 8px; - -webkit-border-top-right-radius: 8px; - -webkit-border-bottom-left-radius: 8px; - -webkit-border-bottom-right-radius: 8px; -} -#MSearchField { - font: 9pt Arial, Verdana, sans-serif; - color: #999999; - background-color: #FFFFFF; - font-style: normal; - cursor: text; - padding: 1px 1px; - margin: 0px 6px 0px 0px; - border: none; - outline: none; - vertical-align: middle; -} -.MSearchBoxActive #MSearchField { - color: #000000; -} -#MSearchSelect { - float : none; - display : inline; - background : none; - font: 9pt Verdana, sans-serif; - border: none; - margin: 0px 0px 0px 6px; - vertical-align: middle; - padding: 0px 0px; -} - -#MSearchClose { - float : none; - display : none; - background : none; - border: none; - margin: 0px 4px 0px 0px; - padding: 0px 0px; - outline: none; -} - -#MSearchCloseImg { - vertical-align: middle; -} - -.MSearchBoxLeft { - display: block; - text-align: left; - float: left; - margin-left: 6px; -} -.MSearchBoxRight { - display: block; - float: right; - text-align: right; - margin-right: 6px; -} -.MSearchBoxSpacer { - font-size: 0px; - clear: both; -} -.MSearchBoxRow { - font-size: 0px; - clear: both; -} - -/*---------------- Search filter selection */ - -#MSearchSelectWindow { - display: none; - position: absolute; - left: 0; top: 0; - border: 1px solid #A0A0A0; - background-color: #FAFAFA; - z-index: 1; - padding-top: 4px; - padding-bottom: 4px; - -moz-border-radius: 4px; - -webkit-border-top-left-radius: 4px; - -webkit-border-top-right-radius: 4px; - -webkit-border-bottom-left-radius: 4px; - -webkit-border-bottom-right-radius: 4px; - -webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); - } -.SelectItem { - font: 8pt Arial, Verdana, sans-serif; - padding-left: 2px; - padding-right: 12px; - border: 0px; -} -span.SelectionMark { - margin-right: 4px; - font-family: monospace; - outline-style: none; - text-decoration: none; -} -a.SelectItem { - display: block; - outline-style: none; - color: #000000; - text-decoration: none; - padding-left: 6px; - padding-right: 12px; -} -a.SelectItem:focus, -a.SelectItem:active { - color: #000000; - outline-style: none; - text-decoration: none; -} -a.SelectItem:hover { - color: #FFFFFF; - background-color: #2A50E4; - outline-style: none; - text-decoration: none; - cursor: pointer; - display: block; -} - -/*---------------- Search results window */ - -iframe#MSearchResults { - width: 60ex; - height: 15em; - } -#MSearchResultsWindow { - display: none; - position: absolute; - left: 0; top: 0; - border: 1px solid #000000; - background-color: #EEF3F5; - } - -/* ----------------------------------- */ - - -#SRIndex { - clear:both; - padding-bottom: 15px; -} - -.SREntry { - font-size: 10pt; - padding-left: 1ex; -} -.SRPage .SREntry { - font-size: 8pt; - padding: 1px 5px; -} -body.SRPage { - margin: 5px 2px; -} - -.SRChildren { - padding-left: 3ex; padding-bottom: .5em -} -.SRPage .SRChildren { - display: none; -} -.SRSymbol { - font-weight: bold; color: #153788; - font-family: Arial, Verdana, sans-serif; - text-decoration: none; - outline: none; -} - -a.SRScope { - display: block; - color: #153788; - font-family: Arial, Verdana, sans-serif; - text-decoration: none; - outline: none; -} - -a.SRSymbol:focus, a.SRSymbol:active, -a.SRScope:focus, a.SRScope:active { - text-decoration: underline; -} - -.SRPage .SRStatus { - padding: 2px 5px; - font-size: 8pt; - font-style: italic; -} - -.SRResult { - display: none; -} - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/search.js b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/search.js deleted file mode 100644 index 4fadd5247..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/search.js +++ /dev/null @@ -1,734 +0,0 @@ -// Search script generated by doxygen -// Copyright (C) 2009 by Dimitri van Heesch. - -// The code in this file is loosly based on main.js, part of Natural Docs, -// which is Copyright (C) 2003-2008 Greg Valure -// Natural Docs is licensed under the GPL. - -var indexSectionsWithContent = -{ - 0: "000000000000000000000000000000000000000000000000000000000000000001110111000111101101000000000010", - 1: "000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000", - 2: "000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000", - 3: "000000000000000000000000000000000000000000000000000000000000000000010111000111000101000000000010", - 4: "000000000000000000000000000000000000000000000000000000000000000001110110000000101001000000000000" -}; - -var indexSectionNames = -{ - 0: "all", - 1: "classes", - 2: "files", - 3: "functions", - 4: "variables" -}; - -function convertToId(search) -{ - var result = ''; - for (i=0;i do a search - { - this.Search(); - } - } - - this.OnSearchSelectKey = function(evt) - { - var e = (evt) ? evt : window.event; // for IE - if (e.keyCode==40 && this.searchIndex0) // Up - { - this.searchIndex--; - this.OnSelectItem(this.searchIndex); - } - else if (e.keyCode==13 || e.keyCode==27) - { - this.OnSelectItem(this.searchIndex); - this.CloseSelectionWindow(); - this.DOMSearchField().focus(); - } - return false; - } - - // --------- Actions - - // Closes the results window. - this.CloseResultsWindow = function() - { - this.DOMPopupSearchResultsWindow().style.display = 'none'; - this.DOMSearchClose().style.display = 'none'; - this.Activate(false); - } - - this.CloseSelectionWindow = function() - { - this.DOMSearchSelectWindow().style.display = 'none'; - } - - // Performs a search. - this.Search = function() - { - this.keyTimeout = 0; - - // strip leading whitespace - var searchValue = this.DOMSearchField().value.replace(/^ +/, ""); - - var code = searchValue.toLowerCase().charCodeAt(0); - var hexCode; - if (code<16) - { - hexCode="0"+code.toString(16); - } - else - { - hexCode=code.toString(16); - } - - var resultsPage; - var resultsPageWithSearch; - var hasResultsPage; - - if (indexSectionsWithContent[this.searchIndex].charAt(code-32) == '1') - { - resultsPage = this.resultsPath + '/' + indexSectionNames[this.searchIndex] + '_' + hexCode + '.html'; - resultsPageWithSearch = resultsPage+'?'+escape(searchValue); - hasResultsPage = true; - } - else // nothing available for this search term - { - resultsPage = this.resultsPath + '/nomatches.html'; - resultsPageWithSearch = resultsPage; - hasResultsPage = false; - } - - window.frames.MSearchResults.location.href = resultsPageWithSearch; - var domPopupSearchResultsWindow = this.DOMPopupSearchResultsWindow(); - - if (domPopupSearchResultsWindow.style.display!='block') - { - var domSearchBox = this.DOMSearchBox(); - this.DOMSearchClose().style.display = 'inline'; - if (this.insideFrame) - { - var domPopupSearchResults = this.DOMPopupSearchResults(); - domPopupSearchResultsWindow.style.position = 'relative'; - domPopupSearchResultsWindow.style.display = 'block'; - var width = document.body.clientWidth - 8; // the -8 is for IE :-( - domPopupSearchResultsWindow.style.width = width + 'px'; - domPopupSearchResults.style.width = width + 'px'; - } - else - { - var domPopupSearchResults = this.DOMPopupSearchResults(); - var left = getXPos(domSearchBox) + domSearchBox.offsetWidth; - var top = getYPos(domSearchBox) + domSearchBox.offsetHeight + 1; - domPopupSearchResultsWindow.style.display = 'block'; - left -= domPopupSearchResults.offsetWidth; - domPopupSearchResultsWindow.style.top = top + 'px'; - domPopupSearchResultsWindow.style.left = left + 'px'; - } - } - - this.lastSearchValue = searchValue; - this.lastResultsPage = resultsPage; - } - - // -------- Activation Functions - - // Activates or deactivates the search panel, resetting things to - // their default values if necessary. - this.Activate = function(isActive) - { - if (isActive || // open it - this.DOMPopupSearchResultsWindow().style.display == 'block' - ) - { - this.DOMSearchBox().className = 'MSearchBoxActive'; - - var searchField = this.DOMSearchField(); - - if (searchField.value == this.searchLabel) // clear "Search" term upon entry - { - searchField.value = ''; - this.searchActive = true; - } - } - else if (!isActive) // directly remove the panel - { - this.DOMSearchBox().className = 'MSearchBoxInactive'; - this.DOMSearchField().value = this.searchLabel; - this.searchActive = false; - this.lastSearchValue = '' - this.lastResultsPage = ''; - } - } -} - -// ----------------------------------------------------------------------- - -// The class that handles everything on the search results page. -function SearchResults(name) -{ - // The number of matches from the last run of . - this.lastMatchCount = 0; - this.lastKey = 0; - this.repeatOn = false; - - // Toggles the visibility of the passed element ID. - this.FindChildElement = function(id) - { - var parentElement = document.getElementById(id); - var element = parentElement.firstChild; - - while (element && element!=parentElement) - { - if (element.nodeName == 'DIV' && element.className == 'SRChildren') - { - return element; - } - - if (element.nodeName == 'DIV' && element.hasChildNodes()) - { - element = element.firstChild; - } - else if (element.nextSibling) - { - element = element.nextSibling; - } - else - { - do - { - element = element.parentNode; - } - while (element && element!=parentElement && !element.nextSibling); - - if (element && element!=parentElement) - { - element = element.nextSibling; - } - } - } - } - - this.Toggle = function(id) - { - var element = this.FindChildElement(id); - if (element) - { - if (element.style.display == 'block') - { - element.style.display = 'none'; - } - else - { - element.style.display = 'block'; - } - } - } - - // Searches for the passed string. If there is no parameter, - // it takes it from the URL query. - // - // Always returns true, since other documents may try to call it - // and that may or may not be possible. - this.Search = function(search) - { - if (!search) // get search word from URL - { - search = window.location.search; - search = search.substring(1); // Remove the leading '?' - search = unescape(search); - } - - search = search.replace(/^ +/, ""); // strip leading spaces - search = search.replace(/ +$/, ""); // strip trailing spaces - search = search.toLowerCase(); - search = convertToId(search); - - var resultRows = document.getElementsByTagName("div"); - var matches = 0; - - var i = 0; - while (i < resultRows.length) - { - var row = resultRows.item(i); - if (row.className == "SRResult") - { - var rowMatchName = row.id.toLowerCase(); - rowMatchName = rowMatchName.replace(/^sr\d*_/, ''); // strip 'sr123_' - - if (search.length<=rowMatchName.length && - rowMatchName.substr(0, search.length)==search) - { - row.style.display = 'block'; - matches++; - } - else - { - row.style.display = 'none'; - } - } - i++; - } - document.getElementById("Searching").style.display='none'; - if (matches == 0) // no results - { - document.getElementById("NoMatches").style.display='block'; - } - else // at least one result - { - document.getElementById("NoMatches").style.display='none'; - } - this.lastMatchCount = matches; - return true; - } - - // return the first item with index index or higher that is visible - this.NavNext = function(index) - { - var focusItem; - while (1) - { - var focusName = 'Item'+index; - focusItem = document.getElementById(focusName); - if (focusItem && focusItem.parentNode.parentNode.style.display=='block') - { - break; - } - else if (!focusItem) // last element - { - break; - } - focusItem=null; - index++; - } - return focusItem; - } - - this.NavPrev = function(index) - { - var focusItem; - while (1) - { - var focusName = 'Item'+index; - focusItem = document.getElementById(focusName); - if (focusItem && focusItem.parentNode.parentNode.style.display=='block') - { - break; - } - else if (!focusItem) // last element - { - break; - } - focusItem=null; - index--; - } - return focusItem; - } - - this.ProcessKeys = function(e) - { - if (e.type == "keydown") - { - this.repeatOn = false; - this.lastKey = e.keyCode; - } - else if (e.type == "keypress") - { - if (!this.repeatOn) - { - if (this.lastKey) this.repeatOn = true; - return false; // ignore first keypress after keydown - } - } - else if (e.type == "keyup") - { - this.lastKey = 0; - this.repeatOn = false; - } - return this.lastKey!=0; - } - - this.Nav = function(evt,itemIndex) - { - var e = (evt) ? evt : window.event; // for IE - if (e.keyCode==13) return true; - if (!this.ProcessKeys(e)) return false; - - if (this.lastKey==38) // Up - { - var newIndex = itemIndex-1; - var focusItem = this.NavPrev(newIndex); - if (focusItem) - { - var child = this.FindChildElement(focusItem.parentNode.parentNode.id); - if (child && child.style.display == 'block') // children visible - { - var n=0; - var tmpElem; - while (1) // search for last child - { - tmpElem = document.getElementById('Item'+newIndex+'_c'+n); - if (tmpElem) - { - focusItem = tmpElem; - } - else // found it! - { - break; - } - n++; - } - } - } - if (focusItem) - { - focusItem.focus(); - } - else // return focus to search field - { - parent.document.getElementById("MSearchField").focus(); - } - } - else if (this.lastKey==40) // Down - { - var newIndex = itemIndex+1; - var focusItem; - var item = document.getElementById('Item'+itemIndex); - var elem = this.FindChildElement(item.parentNode.parentNode.id); - if (elem && elem.style.display == 'block') // children visible - { - focusItem = document.getElementById('Item'+itemIndex+'_c0'); - } - if (!focusItem) focusItem = this.NavNext(newIndex); - if (focusItem) focusItem.focus(); - } - else if (this.lastKey==39) // Right - { - var item = document.getElementById('Item'+itemIndex); - var elem = this.FindChildElement(item.parentNode.parentNode.id); - if (elem) elem.style.display = 'block'; - } - else if (this.lastKey==37) // Left - { - var item = document.getElementById('Item'+itemIndex); - var elem = this.FindChildElement(item.parentNode.parentNode.id); - if (elem) elem.style.display = 'none'; - } - else if (this.lastKey==27) // Escape - { - parent.searchBox.CloseResultsWindow(); - parent.document.getElementById("MSearchField").focus(); - } - else if (this.lastKey==13) // Enter - { - return true; - } - return false; - } - - this.NavChild = function(evt,itemIndex,childIndex) - { - var e = (evt) ? evt : window.event; // for IE - if (e.keyCode==13) return true; - if (!this.ProcessKeys(e)) return false; - - if (this.lastKey==38) // Up - { - if (childIndex>0) - { - var newIndex = childIndex-1; - document.getElementById('Item'+itemIndex+'_c'+newIndex).focus(); - } - else // already at first child, jump to parent - { - document.getElementById('Item'+itemIndex).focus(); - } - } - else if (this.lastKey==40) // Down - { - var newIndex = childIndex+1; - var elem = document.getElementById('Item'+itemIndex+'_c'+newIndex); - if (!elem) // last child, jump to parent next parent - { - elem = this.NavNext(itemIndex+1); - } - if (elem) - { - elem.focus(); - } - } - else if (this.lastKey==27) // Escape - { - parent.searchBox.CloseResultsWindow(); - parent.document.getElementById("MSearchField").focus(); - } - else if (this.lastKey==13) // Enter - { - return true; - } - return false; - } -} diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/search.png b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/search.png deleted file mode 100644 index 9dd2396db..000000000 Binary files a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/search.png and /dev/null differ diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/variables_61.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/variables_61.html deleted file mode 100644 index dbc525140..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/variables_61.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - -
-
Loading...
-
-
- ampl - energyCalibration -
-
-
Searching...
-
No Matches
- -
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/variables_62.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/variables_62.html deleted file mode 100644 index 1587baf85..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/variables_62.html +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - -
-
Loading...
-
-
- bg_offset - energyCalibration -
-
-
-
- bg_slope - energyCalibration -
-
-
Searching...
-
No Matches
- -
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/variables_63.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/variables_63.html deleted file mode 100644 index 6a2de4531..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/variables_63.html +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - -
-
Loading...
-
-
- conven - energyCalibration.h -
-
-
-
- cs_slope - energyCalibration -
-
-
Searching...
-
No Matches
- -
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/variables_65.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/variables_65.html deleted file mode 100644 index b199804b0..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/variables_65.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - -
-
Loading...
-
-
- el - energyCalibration.h -
-
-
Searching...
-
No Matches
- -
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/variables_66.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/variables_66.html deleted file mode 100644 index d0ae5492f..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/variables_66.html +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - -
-
Loading...
-
-
- fit_max - energyCalibration -
-
-
-
- fit_min - energyCalibration -
-
-
-
- flex - energyCalibration -
-
-
-
- fscurve - energyCalibration -
-
-
-
- funcs - energyCalibration -
-
-
Searching...
-
No Matches
- -
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/variables_6e.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/variables_6e.html deleted file mode 100644 index 7ee4200c2..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/variables_6e.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - -
-
Loading...
-
-
- noise - energyCalibration -
-
-
Searching...
-
No Matches
- -
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/variables_70.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/variables_70.html deleted file mode 100644 index 402fa63cb..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/variables_70.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - -
-
Loading...
-
-
- plot_flag - energyCalibration -
-
-
Searching...
-
No Matches
- -
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/variables_73.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/variables_73.html deleted file mode 100644 index 786cf3968..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/variables_73.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - -
-
Loading...
-
-
- sign - energyCalibrationFunctions -
-
-
Searching...
-
No Matches
- -
- - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/tab_b.gif b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/tab_b.gif deleted file mode 100644 index 0d623483f..000000000 Binary files a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/tab_b.gif and /dev/null differ diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/tab_l.gif b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/tab_l.gif deleted file mode 100644 index 9b1e6337c..000000000 Binary files a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/tab_l.gif and /dev/null differ diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/tab_r.gif b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/tab_r.gif deleted file mode 100644 index ce9dd9f53..000000000 Binary files a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/tab_r.gif and /dev/null differ diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/tabs.css b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/tabs.css deleted file mode 100644 index a61552a67..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/tabs.css +++ /dev/null @@ -1,102 +0,0 @@ -/* tabs styles, based on http://www.alistapart.com/articles/slidingdoors */ - -DIV.tabs -{ - float : left; - width : 100%; - background : url("tab_b.gif") repeat-x bottom; - margin-bottom : 4px; -} - -DIV.tabs UL -{ - margin : 0px; - padding-left : 10px; - list-style : none; -} - -DIV.tabs LI, DIV.tabs FORM -{ - display : inline; - margin : 0px; - padding : 0px; -} - -DIV.tabs FORM -{ - float : right; -} - -DIV.tabs A -{ - float : left; - background : url("tab_r.gif") no-repeat right top; - border-bottom : 1px solid #84B0C7; - font-size : x-small; - font-weight : bold; - text-decoration : none; -} - -DIV.tabs A:hover -{ - background-position: 100% -150px; -} - -DIV.tabs A:link, DIV.tabs A:visited, -DIV.tabs A:active, DIV.tabs A:hover -{ - color: #1A419D; -} - -DIV.tabs SPAN -{ - float : left; - display : block; - background : url("tab_l.gif") no-repeat left top; - padding : 5px 9px; - white-space : nowrap; -} - -DIV.tabs INPUT -{ - float : right; - display : inline; - font-size : 1em; -} - -DIV.tabs TD -{ - font-size : x-small; - font-weight : bold; - text-decoration : none; -} - - - -/* Commented Backslash Hack hides rule from IE5-Mac \*/ -DIV.tabs SPAN {float : none;} -/* End IE5-Mac hack */ - -DIV.tabs A:hover SPAN -{ - background-position: 0% -150px; -} - -DIV.tabs LI#current A -{ - background-position: 100% -150px; - border-width : 0px; -} - -DIV.tabs LI#current SPAN -{ - background-position: 0% -150px; - padding-bottom : 6px; -} - -DIV.nav -{ - background : none; - border : none; - border-bottom : 1px solid #84B0C7; -} diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/FreeSans.ttf b/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/FreeSans.ttf deleted file mode 100644 index b550b90ba..000000000 Binary files a/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/FreeSans.ttf and /dev/null differ diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/Makefile b/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/Makefile deleted file mode 100644 index 776fcf968..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/Makefile +++ /dev/null @@ -1,39 +0,0 @@ -all: clean refman.dvi - -ps: refman.ps - -pdf: refman.pdf - -ps_2on1: refman_2on1.ps - -pdf_2on1: refman_2on1.pdf - -refman.ps: refman.dvi - dvips -o refman.ps refman.dvi - -refman.pdf: refman.ps - ps2pdf refman.ps refman.pdf - -refman.dvi: refman.tex doxygen.sty - echo "Running latex..." - latex refman.tex - echo "Running makeindex..." - makeindex refman.idx - echo "Rerunning latex...." - latex refman.tex - latex_count=5 ; \ - while egrep -s 'Rerun (LaTeX|to get cross-references right)' refman.log && [ $$latex_count -gt 0 ] ;\ - do \ - echo "Rerunning latex...." ;\ - latex refman.tex ;\ - latex_count=`expr $$latex_count - 1` ;\ - done - -refman_2on1.ps: refman.ps - psnup -2 refman.ps >refman_2on1.ps - -refman_2on1.pdf: refman_2on1.ps - ps2pdf refman_2on1.ps refman_2on1.pdf - -clean: - rm -f *.ps *.dvi *.aux *.toc *.idx *.ind *.ilg *.log *.out refman.pdf diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/annotated.tex b/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/annotated.tex deleted file mode 100644 index dc3097571..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/annotated.tex +++ /dev/null @@ -1,5 +0,0 @@ -\section{Class List} -Here are the classes, structs, unions and interfaces with brief descriptions:\begin{CompactList} -\item\contentsline{section}{\bf{energy\-Calibration} }{\pageref{classenergyCalibration}}{} -\item\contentsline{section}{\bf{energy\-Calibration\-Functions} (Energy calibration functions )}{\pageref{classenergyCalibrationFunctions}}{} -\end{CompactList} diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/classenergyCalibration.tex b/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/classenergyCalibration.tex deleted file mode 100644 index ca62e39dd..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/classenergyCalibration.tex +++ /dev/null @@ -1,337 +0,0 @@ -\section{energy\-Calibration Class Reference} -\label{classenergyCalibration}\index{energyCalibration@{energyCalibration}} -{\tt \#include $<$energy\-Calibration.h$>$} - -\subsection*{Public Member Functions} -\begin{CompactItemize} -\item -\bf{energy\-Calibration} () -\item -\bf{$\sim$energy\-Calibration} () -\item -int \bf{set\-Plot\-Flag} (int p=-1) -\item -int \bf{set\-Scan\-Sign} (int s=0) -\item -int \bf{set\-Charge\-Sharing} (int p=-1) -\item -void \bf{set\-Fit\-Range} (Double\_\-t mi, Double\_\-t ma) -\item -void \bf{get\-Fit\-Range} (Double\_\-t \&mi, Double\_\-t \&ma) -\item -void \bf{set\-Start\-Parameters} (Double\_\-t $\ast$par) -\item -void \bf{get\-Start\-Parameters} (Double\_\-t $\ast$par) -\item -TF1 $\ast$ \bf{fit\-SCurve} (TH1 $\ast$h1, Double\_\-t $\ast$mypar, Double\_\-t $\ast$emypar) -\item -TF1 $\ast$ \bf{fit\-Spectrum} (TH1 $\ast$h1, Double\_\-t $\ast$mypar, Double\_\-t $\ast$emypar) -\item -TGraph\-Errors $\ast$ \bf{linear\-Calibration} (int nscan, Double\_\-t $\ast$en, Double\_\-t $\ast$een, Double\_\-t $\ast$fl, Double\_\-t $\ast$efl, Double\_\-t \&gain, Double\_\-t \&off, Double\_\-t \&egain, Double\_\-t \&eoff) -\item -TGraph\-Errors $\ast$ \bf{calibrate\-Scurves} (int nscan, Double\_\-t $\ast$en, Double\_\-t $\ast$een, TH1F $\ast$$\ast$h1, Double\_\-t \&gain, Double\_\-t \&off, Double\_\-t \&egain, Double\_\-t \&eoff) -\item -TGraph\-Errors $\ast$ \bf{calibrate\-Spectra} (int nscan, Double\_\-t $\ast$en, Double\_\-t $\ast$een, TH1F $\ast$$\ast$h1, Double\_\-t \&gain, Double\_\-t \&off, Double\_\-t \&egain, Double\_\-t \&eoff) -\end{CompactItemize} -\subsection*{Private Member Functions} -\begin{CompactItemize} -\item -TGraph\-Errors $\ast$ \bf{calibrate} (int nscan, Double\_\-t $\ast$en, Double\_\-t $\ast$een, TH1F $\ast$$\ast$h1, Double\_\-t \&gain, Double\_\-t \&off, Double\_\-t \&egain, Double\_\-t \&eoff, int integral=1) -\item -void \bf{init\-Fit\-Function} (TF1 $\ast$fun, TH1 $\ast$h1) -\item -TF1 $\ast$ \bf{fit\-Function} (TF1 $\ast$fun, TH1 $\ast$h1, Double\_\-t $\ast$mypar, Double\_\-t $\ast$emypar) -\end{CompactItemize} -\subsection*{Private Attributes} -\begin{CompactItemize} -\item -int \bf{plot\_\-flag} -\item -int \bf{cs\_\-flag} -\item -Double\_\-t \bf{fit\_\-min} -\item -Double\_\-t \bf{fit\_\-max} -\item -Double\_\-t \bf{bg\_\-offset} -\item -Double\_\-t \bf{bg\_\-slope} -\item -Double\_\-t \bf{flex} -\item -Double\_\-t \bf{noise} -\item -Double\_\-t \bf{ampl} -\item -Double\_\-t \bf{cs\_\-slope} -\item -\bf{energy\-Calibration\-Functions} $\ast$ \bf{funcs} -\item -TF1 $\ast$ \bf{fscurve} -\item -TF1 $\ast$ \bf{fspectrum} -\end{CompactItemize} - - -\subsection{Detailed Description} -class alowing the energy calibration of photon counting and anlogue detectors - - - -\subsection{Constructor \& Destructor Documentation} -\index{energyCalibration@{energy\-Calibration}!energyCalibration@{energyCalibration}} -\index{energyCalibration@{energyCalibration}!energyCalibration@{energy\-Calibration}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}energy\-Calibration::energy\-Calibration ()}\label{classenergyCalibration_16f0658d2b526f52784057b2166efd22} - - -default constructor - creates the function with which the s-curves will be fitted \index{energyCalibration@{energy\-Calibration}!~energyCalibration@{$\sim$energyCalibration}} -\index{~energyCalibration@{$\sim$energyCalibration}!energyCalibration@{energy\-Calibration}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}energy\-Calibration::$\sim$energy\-Calibration ()}\label{classenergyCalibration_3bae2b9c26893daa8f583758509c844f} - - -default destructor - deletes the function with which the s-curves will be fitted - -\subsection{Member Function Documentation} -\index{energyCalibration@{energy\-Calibration}!calibrate@{calibrate}} -\index{calibrate@{calibrate}!energyCalibration@{energy\-Calibration}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}TGraph\-Errors$\ast$ energy\-Calibration::calibrate (int {\em nscan}, Double\_\-t $\ast$ {\em en}, Double\_\-t $\ast$ {\em een}, TH1F $\ast$$\ast$ {\em h1}, Double\_\-t \& {\em gain}, Double\_\-t \& {\em off}, Double\_\-t \& {\em egain}, Double\_\-t \& {\em eoff}, int {\em integral} = {\tt 1})\hspace{0.3cm}{\tt [private]}}\label{classenergyCalibration_378daeddde40b6127ee6ed595506928c} - - -calculates gain and offset for the set of energies \begin{Desc} -\item[Parameters:] -\begin{description} -\item[{\em nscan}]number of energy scans \item[{\em en}]array of energies (nscan long) \item[{\em een}]array of errors on energies (nscan long) - can be NULL! \item[{\em h1}]array of TH1 \item[{\em gain}]reference to gain resulting from the fit \item[{\em offset}]reference to offset resulting from the fit \item[{\em integral}]1 is an s-curve set (default), 0 spectra \end{description} -\end{Desc} -\begin{Desc} -\item[Returns:]graph energy vs peak/inflection point \end{Desc} -\index{energyCalibration@{energy\-Calibration}!calibrateScurves@{calibrateScurves}} -\index{calibrateScurves@{calibrateScurves}!energyCalibration@{energy\-Calibration}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}TGraph\-Errors$\ast$ energy\-Calibration::calibrate\-Scurves (int {\em nscan}, Double\_\-t $\ast$ {\em en}, Double\_\-t $\ast$ {\em een}, TH1F $\ast$$\ast$ {\em h1}, Double\_\-t \& {\em gain}, Double\_\-t \& {\em off}, Double\_\-t \& {\em egain}, Double\_\-t \& {\em eoff})\hspace{0.3cm}{\tt [inline]}}\label{classenergyCalibration_6f5ee6771522a31e4fe1eca143e2aa9b} - - -calculates gain and offset for the set of energy scans \begin{Desc} -\item[Parameters:] -\begin{description} -\item[{\em nscan}]number of energy scans \item[{\em en}]array of energies (nscan long) \item[{\em een}]array of errors on energies (nscan long) - can be NULL! \item[{\em h1}]array of TH1 \item[{\em gain}]reference to gain resulting from the fit \item[{\em off}]reference to offset resulting from the fit \item[{\em egain}]reference to error on the gain resulting from the fit \item[{\em eoff}]reference to the error on the offset resulting from the fit \end{description} -\end{Desc} -\begin{Desc} -\item[Returns:]graph energy vs inflection point \end{Desc} -\index{energyCalibration@{energy\-Calibration}!calibrateSpectra@{calibrateSpectra}} -\index{calibrateSpectra@{calibrateSpectra}!energyCalibration@{energy\-Calibration}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}TGraph\-Errors$\ast$ energy\-Calibration::calibrate\-Spectra (int {\em nscan}, Double\_\-t $\ast$ {\em en}, Double\_\-t $\ast$ {\em een}, TH1F $\ast$$\ast$ {\em h1}, Double\_\-t \& {\em gain}, Double\_\-t \& {\em off}, Double\_\-t \& {\em egain}, Double\_\-t \& {\em eoff})\hspace{0.3cm}{\tt [inline]}}\label{classenergyCalibration_092637f656c0b88d57797e3ebd0f3e58} - - -calculates gain and offset for the set of energy spectra \begin{Desc} -\item[Parameters:] -\begin{description} -\item[{\em nscan}]number of energy scans \item[{\em en}]array of energies (nscan long) \item[{\em een}]array of errors on energies (nscan long) - can be NULL! \item[{\em h1}]array of TH1 \item[{\em gain}]reference to gain resulting from the fit \item[{\em off}]reference to offset resulting from the fit \item[{\em egain}]reference to error on the gain resulting from the fit \item[{\em eoff}]reference to the error on the offset resulting from the fit \end{description} -\end{Desc} -\begin{Desc} -\item[Returns:]graph energy vs peak \end{Desc} -\index{energyCalibration@{energy\-Calibration}!fitFunction@{fitFunction}} -\index{fitFunction@{fitFunction}!energyCalibration@{energy\-Calibration}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}TF1$\ast$ energy\-Calibration::fit\-Function (TF1 $\ast$ {\em fun}, TH1 $\ast$ {\em h1}, Double\_\-t $\ast$ {\em mypar}, Double\_\-t $\ast$ {\em emypar})\hspace{0.3cm}{\tt [private]}}\label{classenergyCalibration_fe1c6dc5f56d12fe06569f401da19729} - - -Perfors the fit according to the flags specified and returns the fitted function \begin{Desc} -\item[Parameters:] -\begin{description} -\item[{\em fun}]function to fit \item[{\em h1}]histogram to fit \item[{\em mypar}]pointer to fit parameters array \item[{\em emypar}]pointer to fit parameter errors \end{description} -\end{Desc} -\begin{Desc} -\item[Returns:]the fitted function - can be used e.g. to get the Chi2 or similar \end{Desc} -\index{energyCalibration@{energy\-Calibration}!fitSCurve@{fitSCurve}} -\index{fitSCurve@{fitSCurve}!energyCalibration@{energy\-Calibration}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}TF1$\ast$ energy\-Calibration::fit\-SCurve (TH1 $\ast$ {\em h1}, Double\_\-t $\ast$ {\em mypar}, Double\_\-t $\ast$ {\em emypar})}\label{classenergyCalibration_0dcd8e06e31f7b70488a012db12b2bf8} - - -fits histogram with the s-curve function \begin{Desc} -\item[Parameters:] -\begin{description} -\item[{\em h1}]1d-histogram to be fitted \item[{\em mypar}]pointer to fit parameters array \item[{\em emypar}]pointer to fit parameter errors \end{description} -\end{Desc} -\begin{Desc} -\item[Returns:]the fitted function - can be used e.g. to get the Chi2 or similar \end{Desc} -\index{energyCalibration@{energy\-Calibration}!fitSpectrum@{fitSpectrum}} -\index{fitSpectrum@{fitSpectrum}!energyCalibration@{energy\-Calibration}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}TF1$\ast$ energy\-Calibration::fit\-Spectrum (TH1 $\ast$ {\em h1}, Double\_\-t $\ast$ {\em mypar}, Double\_\-t $\ast$ {\em emypar})}\label{classenergyCalibration_7d22b28cd2fad3d334f15f3d6dc7975a} - - -fits histogram with the spectrum \begin{Desc} -\item[Parameters:] -\begin{description} -\item[{\em h1}]1d-histogram to be fitted \item[{\em mypar}]pointer to fit parameters array \item[{\em emypar}]pointer to fit parameter errors \end{description} -\end{Desc} -\begin{Desc} -\item[Returns:]the fitted function - can be used e.g. to get the Chi2 or similar \end{Desc} -\index{energyCalibration@{energy\-Calibration}!getFitRange@{getFitRange}} -\index{getFitRange@{getFitRange}!energyCalibration@{energy\-Calibration}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void energy\-Calibration::get\-Fit\-Range (Double\_\-t \& {\em mi}, Double\_\-t \& {\em ma})\hspace{0.3cm}{\tt [inline]}}\label{classenergyCalibration_bfb02327a6897bd97525c01697a1ba4f} - - -gets the s-curve fit range \begin{Desc} -\item[Parameters:] -\begin{description} -\item[{\em mi}]reference for minimum of the fit range (-1 is histogram x-min) \item[{\em ma}]reference for maximum of the fit range (-1 is histogram x-max) \end{description} -\end{Desc} -\index{energyCalibration@{energy\-Calibration}!getStartParameters@{getStartParameters}} -\index{getStartParameters@{getStartParameters}!energyCalibration@{energy\-Calibration}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void energy\-Calibration::get\-Start\-Parameters (Double\_\-t $\ast$ {\em par})}\label{classenergyCalibration_fc7411b7a3191748dfcc90f86b823bf4} - - -get start parameters for the s-curve function \begin{Desc} -\item[Parameters:] -\begin{description} -\item[{\em par}]parameters, -1 means auto-calculated par[0] is the pedestal par[1] is the slope of the pedestal par[2] is the inflection point par[3] is the RMS par[4] is the amplitude par[5] is the angual coefficient of the charge sharing slope (scales with par[3]) -- always positive \end{description} -\end{Desc} -\index{energyCalibration@{energy\-Calibration}!initFitFunction@{initFitFunction}} -\index{initFitFunction@{initFitFunction}!energyCalibration@{energy\-Calibration}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void energy\-Calibration::init\-Fit\-Function (TF1 $\ast$ {\em fun}, TH1 $\ast$ {\em h1})\hspace{0.3cm}{\tt [private]}}\label{classenergyCalibration_3e84328c11772b6263224340ec924e37} - - -Initializes the start parameters and the range of the fit depending on the histogram characteristics and/or on the start parameters specified by the user \begin{Desc} -\item[Parameters:] -\begin{description} -\item[{\em fun}]pointer to function to be initialized \item[{\em h1}]histogram from which to extract the range and start parameters, if not already specified by the user \end{description} -\end{Desc} -\index{energyCalibration@{energy\-Calibration}!linearCalibration@{linearCalibration}} -\index{linearCalibration@{linearCalibration}!energyCalibration@{energy\-Calibration}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}TGraph\-Errors$\ast$ energy\-Calibration::linear\-Calibration (int {\em nscan}, Double\_\-t $\ast$ {\em en}, Double\_\-t $\ast$ {\em een}, Double\_\-t $\ast$ {\em fl}, Double\_\-t $\ast$ {\em efl}, Double\_\-t \& {\em gain}, Double\_\-t \& {\em off}, Double\_\-t \& {\em egain}, Double\_\-t \& {\em eoff})}\label{classenergyCalibration_c7f46f2d051f28211681e851f99d3fc4} - - -calculates gain and offset for the set of inflection points \begin{Desc} -\item[Parameters:] -\begin{description} -\item[{\em nscan}]number of energy scans \item[{\em en}]array of energies (nscan long) \item[{\em een}]array of errors on energies (nscan long) - can be NULL! \item[{\em fl}]array of inflection points (nscan long) \item[{\em efl}]array of errors on the inflection points (nscan long) \item[{\em gain}]reference to gain resulting from the fit \item[{\em off}]reference to offset resulting from the fit \item[{\em egain}]reference to error on the gain resulting from the fit \item[{\em eoff}]reference to the error on the offset resulting from the fit \end{description} -\end{Desc} -\begin{Desc} -\item[Returns:]graph energy vs inflection point \end{Desc} -\index{energyCalibration@{energy\-Calibration}!setChargeSharing@{setChargeSharing}} -\index{setChargeSharing@{setChargeSharing}!energyCalibration@{energy\-Calibration}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int energy\-Calibration::set\-Charge\-Sharing (int {\em p} = {\tt -1})}\label{classenergyCalibration_e2809b419799e8b199944f185d4ebab8} - - -sets plot flag \begin{Desc} -\item[Parameters:] -\begin{description} -\item[{\em p}]plot flag (-1 gets, 0 unsets, $>$0 plot) \end{description} -\end{Desc} -\begin{Desc} -\item[Returns:]current plot flag \end{Desc} -\index{energyCalibration@{energy\-Calibration}!setFitRange@{setFitRange}} -\index{setFitRange@{setFitRange}!energyCalibration@{energy\-Calibration}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void energy\-Calibration::set\-Fit\-Range (Double\_\-t {\em mi}, Double\_\-t {\em ma})\hspace{0.3cm}{\tt [inline]}}\label{classenergyCalibration_695cef5428a833d515172d987774f67b} - - -sets the s-curve fit range \begin{Desc} -\item[Parameters:] -\begin{description} -\item[{\em mi}]minimum of the fit range (-1 is histogram x-min) \item[{\em ma}]maximum of the fit range (-1 is histogram x-max) \end{description} -\end{Desc} -\index{energyCalibration@{energy\-Calibration}!setPlotFlag@{setPlotFlag}} -\index{setPlotFlag@{setPlotFlag}!energyCalibration@{energy\-Calibration}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int energy\-Calibration::set\-Plot\-Flag (int {\em p} = {\tt -1})\hspace{0.3cm}{\tt [inline]}}\label{classenergyCalibration_3d9af0857f7a68b7e4519917ea97e6be} - - -sets plot flag \begin{Desc} -\item[Parameters:] -\begin{description} -\item[{\em p}]plot flag (-1 gets, 0 unsets, $>$0 plot) \end{description} -\end{Desc} -\begin{Desc} -\item[Returns:]current plot flag \end{Desc} -\index{energyCalibration@{energy\-Calibration}!setScanSign@{setScanSign}} -\index{setScanSign@{setScanSign}!energyCalibration@{energy\-Calibration}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int energy\-Calibration::set\-Scan\-Sign (int {\em s} = {\tt 0})\hspace{0.3cm}{\tt [inline]}}\label{classenergyCalibration_7dbf1676b30ffe90c5aa917f1b2b77ee} - - -sets scan sign \begin{Desc} -\item[Parameters:] -\begin{description} -\item[{\em s}]can be 1 (energy and x-axis have the same direction) or -1 (energy and x-axis have opposite directions) otherwise gets \end{description} -\end{Desc} -\begin{Desc} -\item[Returns:]current scan sign can be 1 (energy and x-axis have the same direction) or -1 (energy and x-axis have opposite directions) \end{Desc} -\index{energyCalibration@{energy\-Calibration}!setStartParameters@{setStartParameters}} -\index{setStartParameters@{setStartParameters}!energyCalibration@{energy\-Calibration}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void energy\-Calibration::set\-Start\-Parameters (Double\_\-t $\ast$ {\em par})}\label{classenergyCalibration_ba156f5290f7b404d7b8ea735fd7e7bf} - - -set start parameters for the s-curve function \begin{Desc} -\item[Parameters:] -\begin{description} -\item[{\em par}]parameters, -1 sets to auto-calculation par[0] is the pedestal par[1] is the slope of the pedestal par[2] is the inflection point par[3] is the RMS par[4] is the amplitude par[5] is the angual coefficient of the charge sharing slope (scales with par[3]) -- always positive \end{description} -\end{Desc} - - -\subsection{Member Data Documentation} -\index{energyCalibration@{energy\-Calibration}!ampl@{ampl}} -\index{ampl@{ampl}!energyCalibration@{energy\-Calibration}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}Double\_\-t \bf{energy\-Calibration::ampl}\hspace{0.3cm}{\tt [private]}}\label{classenergyCalibration_77b954cd513271d2cfafee6033435584} - - -start value for the number of photons \index{energyCalibration@{energy\-Calibration}!bg_offset@{bg\_\-offset}} -\index{bg_offset@{bg\_\-offset}!energyCalibration@{energy\-Calibration}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}Double\_\-t \bf{energy\-Calibration::bg\_\-offset}\hspace{0.3cm}{\tt [private]}}\label{classenergyCalibration_aa11f256a8b0a94c28a98d068013b327} - - -start value for the background pedestal \index{energyCalibration@{energy\-Calibration}!bg_slope@{bg\_\-slope}} -\index{bg_slope@{bg\_\-slope}!energyCalibration@{energy\-Calibration}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}Double\_\-t \bf{energy\-Calibration::bg\_\-slope}\hspace{0.3cm}{\tt [private]}}\label{classenergyCalibration_9676e5cc2757c723c2262d641fb4b8b4} - - -start value for the background slope \index{energyCalibration@{energy\-Calibration}!cs_flag@{cs\_\-flag}} -\index{cs_flag@{cs\_\-flag}!energyCalibration@{energy\-Calibration}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int \bf{energy\-Calibration::cs\_\-flag}\hspace{0.3cm}{\tt [private]}}\label{classenergyCalibration_ce0be11dcc8418db3c7c2b139a015c96} - - -0 functions without charge sharing contribution, $>$0 with charge sharing contribution \index{energyCalibration@{energy\-Calibration}!cs_slope@{cs\_\-slope}} -\index{cs_slope@{cs\_\-slope}!energyCalibration@{energy\-Calibration}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}Double\_\-t \bf{energy\-Calibration::cs\_\-slope}\hspace{0.3cm}{\tt [private]}}\label{classenergyCalibration_ca1efedbfea0ad5c9ea2d794e3fb368d} - - -start value for the charge sharing slope \index{energyCalibration@{energy\-Calibration}!fit_max@{fit\_\-max}} -\index{fit_max@{fit\_\-max}!energyCalibration@{energy\-Calibration}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}Double\_\-t \bf{energy\-Calibration::fit\_\-max}\hspace{0.3cm}{\tt [private]}}\label{classenergyCalibration_e979386a3f787ef706f4a9ec5bf41d7d} - - -maximum of the s-curve fitting range, -1 is histogram x-max \index{energyCalibration@{energy\-Calibration}!fit_min@{fit\_\-min}} -\index{fit_min@{fit\_\-min}!energyCalibration@{energy\-Calibration}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}Double\_\-t \bf{energy\-Calibration::fit\_\-min}\hspace{0.3cm}{\tt [private]}}\label{classenergyCalibration_262f574732186cdd8d3a11344d03d0bb} - - -minimum of the s-curve fitting range, -1 is histogram x-min \index{energyCalibration@{energy\-Calibration}!flex@{flex}} -\index{flex@{flex}!energyCalibration@{energy\-Calibration}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}Double\_\-t \bf{energy\-Calibration::flex}\hspace{0.3cm}{\tt [private]}}\label{classenergyCalibration_b99d770f1c9af68d591ed20847813ad1} - - -start value for the inflection point \index{energyCalibration@{energy\-Calibration}!fscurve@{fscurve}} -\index{fscurve@{fscurve}!energyCalibration@{energy\-Calibration}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}TF1$\ast$ \bf{energy\-Calibration::fscurve}\hspace{0.3cm}{\tt [private]}}\label{classenergyCalibration_57706a328324c25dd9f8ba6d1486e4ce} - - -function with which the s-curve will be fitted \index{energyCalibration@{energy\-Calibration}!fspectrum@{fspectrum}} -\index{fspectrum@{fspectrum}!energyCalibration@{energy\-Calibration}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}TF1$\ast$ \bf{energy\-Calibration::fspectrum}\hspace{0.3cm}{\tt [private]}}\label{classenergyCalibration_2ee734ab28b78dc5786a7ba430f8baa5} - - -function with which the spectrum will be fitted \index{energyCalibration@{energy\-Calibration}!funcs@{funcs}} -\index{funcs@{funcs}!energyCalibration@{energy\-Calibration}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}\bf{energy\-Calibration\-Functions}$\ast$ \bf{energy\-Calibration::funcs}\hspace{0.3cm}{\tt [private]}}\label{classenergyCalibration_e9b3307bf858331241871bde42fdd24e} - - -\index{energyCalibration@{energy\-Calibration}!noise@{noise}} -\index{noise@{noise}!energyCalibration@{energy\-Calibration}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}Double\_\-t \bf{energy\-Calibration::noise}\hspace{0.3cm}{\tt [private]}}\label{classenergyCalibration_4461206397e2442c92be9151ee231ec5} - - -start value for the noise \index{energyCalibration@{energy\-Calibration}!plot_flag@{plot\_\-flag}} -\index{plot_flag@{plot\_\-flag}!energyCalibration@{energy\-Calibration}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int \bf{energy\-Calibration::plot\_\-flag}\hspace{0.3cm}{\tt [private]}}\label{classenergyCalibration_4edfb157df3624be677177dec0f9555b} - - -0 does not plot, $>$0 plots (flags?) - -The documentation for this class was generated from the following file:\begin{CompactItemize} -\item -\bf{energy\-Calibration.h}\end{CompactItemize} diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/classenergyCalibrationFunctions.tex b/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/classenergyCalibrationFunctions.tex deleted file mode 100644 index 1e8920959..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/classenergyCalibrationFunctions.tex +++ /dev/null @@ -1,135 +0,0 @@ -\section{energy\-Calibration\-Functions Class Reference} -\label{classenergyCalibrationFunctions}\index{energyCalibrationFunctions@{energyCalibrationFunctions}} -Energy calibration functions. - - -{\tt \#include $<$energy\-Calibration.h$>$} - -\subsection*{Public Member Functions} -\begin{CompactItemize} -\item -\bf{energy\-Calibration\-Functions} (int s=-1) -\item -int \bf{set\-Scan\-Sign} (int s=0) -\item -Double\_\-t \bf{gauss\-Charge\-Sharing} (Double\_\-t $\ast$x, Double\_\-t $\ast$par) -\item -Double\_\-t \bf{erf\-Function} (Double\_\-t $\ast$x, Double\_\-t $\ast$par) -\item -Double\_\-t \bf{erf\-Function\-Charge\-Sharing} (Double\_\-t $\ast$x, Double\_\-t $\ast$par) -\item -Double\_\-t \bf{erf\-Func\-Fluo} (Double\_\-t $\ast$x, Double\_\-t $\ast$par) -\item -Double\_\-t \bf{spectrum} (Double\_\-t $\ast$x, Double\_\-t $\ast$par) -\item -Double\_\-t \bf{scurve} (Double\_\-t $\ast$x, Double\_\-t $\ast$par) -\item -Double\_\-t \bf{scurve\-Fluo} (Double\_\-t $\ast$x, Double\_\-t $\ast$par) -\end{CompactItemize} -\subsection*{Static Public Member Functions} -\begin{CompactItemize} -\item -static float \bf{median} (float $\ast$x, int n) -\item -static int \bf{quick\_\-select} (int arr[$\,$], int n) -\item -static int \bf{kth\_\-smallest} (int $\ast$a, int n, int k) -\end{CompactItemize} -\subsection*{Private Attributes} -\begin{CompactItemize} -\item -int \bf{sign} -\end{CompactItemize} - - -\subsection{Detailed Description} -Energy calibration functions. - -class containing all the possible energy calibration functions (scurves with and without charge sharing, gaussian spectrum with and without charge sharing, possibility of chosing the sign of the X-axis) - - - -\subsection{Constructor \& Destructor Documentation} -\index{energyCalibrationFunctions@{energy\-Calibration\-Functions}!energyCalibrationFunctions@{energyCalibrationFunctions}} -\index{energyCalibrationFunctions@{energyCalibrationFunctions}!energyCalibrationFunctions@{energy\-Calibration\-Functions}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}energy\-Calibration\-Functions::energy\-Calibration\-Functions (int {\em s} = {\tt -1})\hspace{0.3cm}{\tt [inline]}}\label{classenergyCalibrationFunctions_8c17162b89f3b2e642004e7c88a22ac2} - - - - -\subsection{Member Function Documentation} -\index{energyCalibrationFunctions@{energy\-Calibration\-Functions}!erfFuncFluo@{erfFuncFluo}} -\index{erfFuncFluo@{erfFuncFluo}!energyCalibrationFunctions@{energy\-Calibration\-Functions}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}Double\_\-t energy\-Calibration\-Functions::erf\-Func\-Fluo (Double\_\-t $\ast$ {\em x}, Double\_\-t $\ast$ {\em par})}\label{classenergyCalibrationFunctions_a5fbe9da48bc2ef90b699e06ea8c5111} - - -Double Erf function with charge sharing slope par[0] is the pedestal par[1] is the slope of the pedestal par[2] is the inflection point of the first energy par[3] is the RMS of the first energy par[4] is the amplitude of the first energy par[5] is the angual coefficient of the charge sharing slope of the first energy (scales with par[3]) par[6] is the inflection point of the second energy par[7] is the RMS of the second energy par[8] is the amplitude of the second energy par[9] is the angual coefficient of the charge sharing slope of the second energy (scales with par[8]) \index{energyCalibrationFunctions@{energy\-Calibration\-Functions}!erfFunction@{erfFunction}} -\index{erfFunction@{erfFunction}!energyCalibrationFunctions@{energy\-Calibration\-Functions}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}Double\_\-t energy\-Calibration\-Functions::erf\-Function (Double\_\-t $\ast$ {\em x}, Double\_\-t $\ast$ {\em par})}\label{classenergyCalibrationFunctions_2da1e3b9a10d23233256f8c2234f2457} - - -Basic erf function par[0] is the inflection point par[1] is the RMS par[2] is the amplitude \index{energyCalibrationFunctions@{energy\-Calibration\-Functions}!erfFunctionChargeSharing@{erfFunctionChargeSharing}} -\index{erfFunctionChargeSharing@{erfFunctionChargeSharing}!energyCalibrationFunctions@{energy\-Calibration\-Functions}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}Double\_\-t energy\-Calibration\-Functions::erf\-Function\-Charge\-Sharing (Double\_\-t $\ast$ {\em x}, Double\_\-t $\ast$ {\em par})}\label{classenergyCalibrationFunctions_8d1b3d0f8b30423dad56d8ce5323a4a8} - - -Erf function with charge sharing slope par[0] is the pedestal par[1] is the slope of the pedestal par[2] is the inflection point par[3] is the RMS par[4] is the amplitude par[5] is the angual coefficient of the charge sharing slope (scales with par[3]) \index{energyCalibrationFunctions@{energy\-Calibration\-Functions}!gaussChargeSharing@{gaussChargeSharing}} -\index{gaussChargeSharing@{gaussChargeSharing}!energyCalibrationFunctions@{energy\-Calibration\-Functions}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}Double\_\-t energy\-Calibration\-Functions::gauss\-Charge\-Sharing (Double\_\-t $\ast$ {\em x}, Double\_\-t $\ast$ {\em par})}\label{classenergyCalibrationFunctions_e9582e5c46d27ad25d6139d0386698f7} - - -Gaussian Function with charge sharing pedestal par[0] is the absolute height of the background pedestal par[1] is the slope of the background pedestal par[2] is the gaussian peak position par[3] is the RMS of the gaussian (and of the pedestal) par[4] is the height of the function par[5] is the fractional height of the charge sharing pedestal (scales with par[3]) \index{energyCalibrationFunctions@{energy\-Calibration\-Functions}!kth_smallest@{kth\_\-smallest}} -\index{kth_smallest@{kth\_\-smallest}!energyCalibrationFunctions@{energy\-Calibration\-Functions}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}static int energy\-Calibration\-Functions::kth\_\-smallest (int $\ast$ {\em a}, int {\em n}, int {\em k})\hspace{0.3cm}{\tt [static]}}\label{classenergyCalibrationFunctions_7d9a7b8d0c8ff69638a5fbb9f4c04b90} - - -Calculates the median of an array of n elements (swaps the arrays!) \index{energyCalibrationFunctions@{energy\-Calibration\-Functions}!median@{median}} -\index{median@{median}!energyCalibrationFunctions@{energy\-Calibration\-Functions}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}static float energy\-Calibration\-Functions::median (float $\ast$ {\em x}, int {\em n})\hspace{0.3cm}{\tt [static]}}\label{classenergyCalibrationFunctions_37f557bacb75213073c8d421cc1240f4} - - -Calculates the median of an array of n elements \index{energyCalibrationFunctions@{energy\-Calibration\-Functions}!quick_select@{quick\_\-select}} -\index{quick_select@{quick\_\-select}!energyCalibrationFunctions@{energy\-Calibration\-Functions}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}static int energy\-Calibration\-Functions::quick\_\-select (int {\em arr}[$\,$], int {\em n})\hspace{0.3cm}{\tt [static]}}\label{classenergyCalibrationFunctions_a3ab0e7c3c862fb51dfda78f1b09a55c} - - -Calculates the median of an array of n elements (swaps the arrays!) \index{energyCalibrationFunctions@{energy\-Calibration\-Functions}!scurve@{scurve}} -\index{scurve@{scurve}!energyCalibrationFunctions@{energy\-Calibration\-Functions}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}Double\_\-t energy\-Calibration\-Functions::scurve (Double\_\-t $\ast$ {\em x}, Double\_\-t $\ast$ {\em par})}\label{classenergyCalibrationFunctions_e220482622e88a46b12498b0e4d8113a} - - -Erf function with charge sharing slope with the correct scan sign par[0] is the pedestal par[1] is the slope of the pedestal par[2] is the inflection point par[3] is the RMS par[4] is the amplitude par[5] is the angual coefficient of the charge sharing slope (scales with par[3]) \index{energyCalibrationFunctions@{energy\-Calibration\-Functions}!scurveFluo@{scurveFluo}} -\index{scurveFluo@{scurveFluo}!energyCalibrationFunctions@{energy\-Calibration\-Functions}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}Double\_\-t energy\-Calibration\-Functions::scurve\-Fluo (Double\_\-t $\ast$ {\em x}, Double\_\-t $\ast$ {\em par})}\label{classenergyCalibrationFunctions_4eba39623b518d67a63192970a78f530} - - -Double Erf function with charge sharing slope par[0] is the pedestal par[1] is the slope of the pedestal par[2] is the inflection point of the first energy par[3] is the RMS of the first energy par[4] is the amplitude of the first energy par[5] is the angual coefficient of the charge sharing slope of the first energy (scales with par[3]) par[6] is the inflection point of the second energy par[7] is the RMS of the second energy par[8] is the amplitude of the second energy par[9] is the angual coefficient of the charge sharing slope of the second energy (scales with par[8]) \index{energyCalibrationFunctions@{energy\-Calibration\-Functions}!setScanSign@{setScanSign}} -\index{setScanSign@{setScanSign}!energyCalibrationFunctions@{energy\-Calibration\-Functions}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int energy\-Calibration\-Functions::set\-Scan\-Sign (int {\em s} = {\tt 0})\hspace{0.3cm}{\tt [inline]}}\label{classenergyCalibrationFunctions_716759a1ae09ea3c841f824af3ece415} - - -sets scan sign \begin{Desc} -\item[Parameters:] -\begin{description} -\item[{\em s}]can be 1 (energy and x-axis have the same direction) or -1 (energy and x-axis have opposite directions) otherwise gets \end{description} -\end{Desc} -\begin{Desc} -\item[Returns:]current scan sign can be 1 (energy and x-axis have the same direction) or -1 (energy and x-axis have opposite directions) \end{Desc} -\index{energyCalibrationFunctions@{energy\-Calibration\-Functions}!spectrum@{spectrum}} -\index{spectrum@{spectrum}!energyCalibrationFunctions@{energy\-Calibration\-Functions}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}Double\_\-t energy\-Calibration\-Functions::spectrum (Double\_\-t $\ast$ {\em x}, Double\_\-t $\ast$ {\em par})}\label{classenergyCalibrationFunctions_015eb05dc34b77642ab2a2a9f126f170} - - -static function Gaussian with charge sharing pedestal with the correct scan sign par[0] is the absolute height of the background pedestal par[1] is the fractional height of the charge sharing pedestal (scales with par[3] par[2] is the gaussian peak position par[3] is the RMS of the gaussian (and of the pedestal) par[4] is the height of the function - -\subsection{Member Data Documentation} -\index{energyCalibrationFunctions@{energy\-Calibration\-Functions}!sign@{sign}} -\index{sign@{sign}!energyCalibrationFunctions@{energy\-Calibration\-Functions}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int \bf{energy\-Calibration\-Functions::sign}\hspace{0.3cm}{\tt [private]}}\label{classenergyCalibrationFunctions_4fc7c435169b5bf4672cf654270097d0} - - - - -The documentation for this class was generated from the following file:\begin{CompactItemize} -\item -\bf{energy\-Calibration.h}\end{CompactItemize} diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/doxygen.sty b/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/doxygen.sty deleted file mode 100644 index ff2b57e23..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/doxygen.sty +++ /dev/null @@ -1,78 +0,0 @@ -\NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{doxygen} -\RequirePackage{calc} -\RequirePackage{array} -\pagestyle{fancyplain} -\newcommand{\clearemptydoublepage}{\newpage{\pagestyle{empty}\cleardoublepage}} -\renewcommand{\chaptermark}[1]{\markboth{#1}{}} -\renewcommand{\sectionmark}[1]{\markright{\thesection\ #1}} -\lhead[\fancyplain{}{\bfseries\thepage}] - {\fancyplain{}{\bfseries\rightmark}} -\rhead[\fancyplain{}{\bfseries\leftmark}] - {\fancyplain{}{\bfseries\thepage}} -\rfoot[\fancyplain{}{\bfseries\scriptsize Generated on Tue Mar 27 16:32:29 2012 by Doxygen }]{} -\lfoot[]{\fancyplain{}{\bfseries\scriptsize Generated on Tue Mar 27 16:32:29 2012 by Doxygen }} -\cfoot{} -\newenvironment{Code} -{\footnotesize} -{\normalsize} -\newcommand{\doxyref}[3]{\textbf{#1} (\textnormal{#2}\,\pageref{#3})} -\newenvironment{DocInclude} -{\footnotesize} -{\normalsize} -\newenvironment{VerbInclude} -{\footnotesize} -{\normalsize} -\newenvironment{Image} -{\begin{figure}[H]} -{\end{figure}} -\newenvironment{ImageNoCaption}{}{} -\newenvironment{CompactList} -{\begin{list}{}{ - \setlength{\leftmargin}{0.5cm} - \setlength{\itemsep}{0pt} - \setlength{\parsep}{0pt} - \setlength{\topsep}{0pt} - \renewcommand{\makelabel}{\hfill}}} -{\end{list}} -\newenvironment{CompactItemize} -{ - \begin{itemize} - \setlength{\itemsep}{-3pt} - \setlength{\parsep}{0pt} - \setlength{\topsep}{0pt} - \setlength{\partopsep}{0pt} -} -{\end{itemize}} -\newcommand{\PBS}[1]{\let\temp=\\#1\let\\=\temp} -\newlength{\tmplength} -\newenvironment{TabularC}[1] -{ -\setlength{\tmplength} - {\linewidth/(#1)-\tabcolsep*2-\arrayrulewidth*(#1+1)/(#1)} - \par\begin{tabular*}{\linewidth} - {*{#1}{|>{\PBS\raggedright\hspace{0pt}}p{\the\tmplength}}|} -} -{\end{tabular*}\par} -\newcommand{\entrylabel}[1]{ - {\parbox[b]{\labelwidth-4pt}{\makebox[0pt][l]{\textbf{#1}}\vspace{1.5\baselineskip}}}} -\newenvironment{Desc} -{\begin{list}{} - { - \settowidth{\labelwidth}{40pt} - \setlength{\leftmargin}{\labelwidth} - \setlength{\parsep}{0pt} - \setlength{\itemsep}{-4pt} - \renewcommand{\makelabel}{\entrylabel} - } -} -{\end{list}} -\newenvironment{Indent} - {\begin{list}{}{\setlength{\leftmargin}{0.5cm}} - \item[]\ignorespaces} - {\unskip\end{list}} -\setlength{\parindent}{0cm} -\setlength{\parskip}{0.2cm} -\addtocounter{secnumdepth}{1} -\sloppy -\usepackage[T1]{fontenc} diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/energyCalibration_8h.tex b/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/energyCalibration_8h.tex deleted file mode 100644 index 3c9d9f6c8..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/energyCalibration_8h.tex +++ /dev/null @@ -1,37 +0,0 @@ -\section{energy\-Calibration.h File Reference} -\label{energyCalibration_8h}\index{energyCalibration.h@{energyCalibration.h}} -{\tt \#include $<$TROOT.h$>$}\par -{\tt \#include $<$TF1.h$>$}\par -\subsection*{Namespaces} -\begin{CompactItemize} -\item -namespace \bf{std} -\end{CompactItemize} -\subsection*{Classes} -\begin{CompactItemize} -\item -class \bf{energy\-Calibration\-Functions} -\begin{CompactList}\small\item\em Energy calibration functions. \item\end{CompactList}\item -class \bf{energy\-Calibration} -\end{CompactItemize} -\subsection*{Variables} -\begin{CompactItemize} -\item -const float \bf{conven} = 1000./3.6 -\item -const float \bf{el} = 1.67E-4 -\end{CompactItemize} - - -\subsection{Variable Documentation} -\index{energyCalibration.h@{energy\-Calibration.h}!conven@{conven}} -\index{conven@{conven}!energyCalibration.h@{energy\-Calibration.h}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}const float \bf{conven} = 1000./3.6}\label{energyCalibration_8h_a48a6c1eb7d418c5d0618fbb161ae321} - - -electrons/ke\-V \index{energyCalibration.h@{energy\-Calibration.h}!el@{el}} -\index{el@{el}!energyCalibration.h@{energy\-Calibration.h}} -\subsubsection{\setlength{\rightskip}{0pt plus 5cm}const float \bf{el} = 1.67E-4}\label{energyCalibration_8h_d1db7b454cab6ae1749310d7f444849b} - - -electron charge in f\-C \ No newline at end of file diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/files.tex b/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/files.tex deleted file mode 100644 index d3d460d1e..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/files.tex +++ /dev/null @@ -1,4 +0,0 @@ -\section{File List} -Here is a list of all files with brief descriptions:\begin{CompactList} -\item\contentsline{section}{\bf{energy\-Calibration.h} }{\pageref{energyCalibration_8h}}{} -\end{CompactList} diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/index.tex b/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/index.tex deleted file mode 100644 index 4b31a1dff..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/index.tex +++ /dev/null @@ -1,3 +0,0 @@ -\section{Introduction}\label{index_intro_sec} -We know very well s-curves etc. but at the end everybody uses different functions ;-).\subsection{Motivation}\label{index_mot_sec} -It would be greate to use everybody the same functions... \ No newline at end of file diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/namespaces.tex b/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/namespaces.tex deleted file mode 100644 index c2ca33382..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/namespaces.tex +++ /dev/null @@ -1,4 +0,0 @@ -\section{Namespace List} -Here is a list of all namespaces with brief descriptions:\begin{CompactList} -\item\contentsline{section}{\bf{std} }{\pageref{namespacestd}}{} -\end{CompactList} diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/namespacestd.tex b/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/namespacestd.tex deleted file mode 100644 index a1732dd75..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/namespacestd.tex +++ /dev/null @@ -1,4 +0,0 @@ -\section{std Namespace Reference} -\label{namespacestd}\index{std@{std}} - - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/refman.tex b/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/refman.tex deleted file mode 100644 index 110991b6b..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/refman.tex +++ /dev/null @@ -1,46 +0,0 @@ -\documentclass[a4paper]{book} -\usepackage{a4wide} -\usepackage{makeidx} -\usepackage{fancyhdr} -\usepackage{graphicx} -\usepackage{multicol} -\usepackage{float} -\usepackage{textcomp} -\usepackage{alltt} -\usepackage{doxygen} -\makeindex -\setcounter{tocdepth}{1} -\renewcommand{\footrulewidth}{0.4pt} -\begin{document} -\begin{titlepage} -\vspace*{7cm} -\begin{center} -{\Large Reference Manual}\\ -\vspace*{1cm} -{\large Generated by Doxygen 1.4.7}\\ -\vspace*{0.5cm} -{\small Tue Mar 27 16:32:29 2012}\\ -\end{center} -\end{titlepage} -\clearemptydoublepage -\pagenumbering{roman} -\tableofcontents -\clearemptydoublepage -\pagenumbering{arabic} -\chapter{Common Root library for SLS detectors data analysis } -\label{index}\input{index} -\chapter{Namespace Index} -\input{namespaces} -\chapter{Class Index} -\input{annotated} -\chapter{File Index} -\input{files} -\chapter{Namespace Documentation} -\input{namespacestd} -\chapter{Class Documentation} -\input{classenergyCalibration} -\include{classenergyCalibrationFunctions} -\chapter{File Documentation} -\input{energyCalibration_8h} -\printindex -\end{document} diff --git a/slsDetectorSoftware/slsDetectorAnalysis/doxy.config b/slsDetectorSoftware/slsDetectorAnalysis/doxy.config deleted file mode 100644 index c6f5f7f13..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/doxy.config +++ /dev/null @@ -1,65 +0,0 @@ -# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in -# documentation are documented, even if no documentation was available. -# Private class members and static file members will be hidden unless -# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES - -EXTRACT_ALL = YES - -# If the EXTRACT_PRIVATE tag is set to YES all private members of a class -# will be included in the documentation. - -EXTRACT_PRIVATE = YES - -# If the EXTRACT_STATIC tag is set to YES all static members of a file -# will be included in the documentation. - -EXTRACT_STATIC = YES - -# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) -# defined locally in source files will be included in the documentation. -# If set to NO only classes defined in header files are included. - -EXTRACT_LOCAL_CLASSES = YES - -# This flag is only useful for Objective-C code. When set to YES local -# methods, which are defined in the implementation section but not in -# the interface are included in the documentation. -# If set to NO (the default) only methods in the interface are included. - -EXTRACT_LOCAL_METHODS = YES - -# If this flag is set to YES, the members of anonymous namespaces will be -# extracted and appear in the documentation as a namespace called -# 'anonymous_namespace{file}', where file will be replaced with the base -# name of the file that contains the anonymous namespace. By default -# anonymous namespace are hidden. - -EXTRACT_ANON_NSPACES = NO - -# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all -# undocumented members of documented classes, files or namespaces. -# If set to NO (the default) these members will be included in the -# various overviews, but no documentation section is generated. -# This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_MEMBERS = NO - -# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all -# undocumented classes that are normally visible in the class hierarchy. -# If set to NO (the default) these classes will be included in the various -# overviews. This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_CLASSES = NO - -# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all -# friend (class|struct|union) declarations. -# If set to NO (the default) these declarations will be included in the -# documentation. - -HIDE_FRIEND_COMPOUNDS = NO - -INPUT = energyCalibration.h - - -OUTPUT_DIRECTORY = docs - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/enCalLogClass.h b/slsDetectorSoftware/slsDetectorAnalysis/enCalLogClass.h deleted file mode 100644 index e3a010df4..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/enCalLogClass.h +++ /dev/null @@ -1,133 +0,0 @@ -#ifndef ENCALLOGCLASS_H -#define ENCALLOGCLASS_H - -#include -#include - - -#ifdef __CINT__ -#define MYROOT -#endif - -#ifndef MYROOT -#include "slsDetectorCommand.h" -#include "slsDetectorUtils.h" -#include "sls_detector_defs.h" -#endif - -; - -class enCalLogClass { - - - public: - -#ifndef MYROOT - enCalLogClass(slsDetectorUtils *det){ \ - char cmd[1000]; \ - char *argv[2]; \ - strcpy(vars[0],"settings"); \ - strcpy(vars[1],"type"); \ - strcpy(vars[2],"nmod"); \ - strcpy(vars[3],"modulenumber"); \ - argv[0]=cmd; \ - sprintf(cmd,"_%d.encal",det->getFileIndex()); \ - outfile.open(std::string(det->getFilePath()+std::string("/")+det->getFileName()+std::string(cmd)).c_str()); \ - myDet=new slsDetectorCommand(det); \ - strcpy(cmd,vars[0]); \ - outfile << cmd << " " << myDet->executeLine(1,argv,slsDetectorDefs::GET_ACTION) << endl; \ - strcpy(cmd,vars[1]); \ - outfile << cmd << " " << myDet->executeLine(1,argv,slsDetectorDefs::GET_ACTION) << endl; \ - strcpy(cmd,vars[2]); \ - outfile << cmd << " " << myDet->executeLine(1,argv,slsDetectorDefs::GET_ACTION) << endl; \ - for (int im=0; imsetNumberOfModules(); im++) { \ - sprintf(cmd,"%s:%d",vars[3],im); \ - outfile << cmd << " " << myDet->executeLine(1,argv,slsDetectorDefs::GET_ACTION) << endl; \ - } \ - }; - - ~enCalLogClass(){delete myDet; outfile.close();}; -#else - enCalLogClass() { \ - strcpy(vars[0],"settings"); \ - strcpy(vars[1],"type"); \ - strcpy(vars[2],"nmod"); \ - strcpy(vars[3],"modulenumber"); \ - }; - ~enCalLogClass(){}; -#endif - - - int addStep(double threshold, std::string fname) {outfile << threshold << " " << fname << endl; return 0;}; - - - // - - int readHeader(std::ifstream &infile, char *settings, int &nmod, int &chanspermod, int *mods ) { \ - nmod=0; strcpy(settings,"unknown"); chanspermod=0; \ - char line[1000],myarg[100]; \ - int dum; \ - for (int iv=0; iv<3; iv++) { \ - infile.getline(line,1000); \ - switch (iv) { \ - case 0: \ - sscanf(line,"settings %s", settings); \ - break; \ - case 1: \ - sscanf(line,"type %s", myarg); \ - if (std::string(myarg).find("Mythen")!=std::string::npos) \ - chanspermod=1280; \ - else if (std::string(myarg).find("Gotthard")!=std::string::npos) \ - chanspermod=1280; \ - else \ - chanspermod=65535; \ - break; \ - case 2: \ - sscanf(line,"nmod %d", &nmod); \ - break; \ - default: \ - ; \ - }; \ - if (infile.bad() || infile.eof()) { cout << "bad file "<< iv << endl; return -1;} \ - } \ - for (int im=0; im -#include -#include -#include -#endif - -#include - -#define max(a,b) ((a) > (b) ? (a) : (b)) -#define min(a,b) ((a) < (b) ? (a) : (b)) -#define ELEM_SWAP(a,b) { register int t=(a);(a)=(b);(b)=t; } - - -using namespace std; - -#ifdef MYROOT -Double_t energyCalibrationFunctions::gaussChargeSharing(Double_t *x, Double_t *par) { - Double_t f, arg=0; - if (par[3]!=0) arg=(x[0]-par[2])/par[3]; - f=par[4]*TMath::Exp(-1*arg*arg/2.); - f=f+par[5]*(par[4]/2*(TMath::Erfc(sign*arg/(TMath::Sqrt(2.)))))+par[0]-par[1]*sign*x[0]; - return f; -} - -// basic erf function -Double_t energyCalibrationFunctions::erfFunction(Double_t *x, Double_t *par) { - double arg=0; - if (par[1]!=0) arg=(par[0]-x[0])/par[1]; - return ((par[2]/2.*(1+TMath::Erf(sign*arg/(TMath::Sqrt(2)))))); -}; - - -Double_t energyCalibrationFunctions::erfFunctionChargeSharing(Double_t *x, Double_t *par) { - Double_t f; - - f=erfFunction(x, par+2)*(1+par[5]*(par[2]-x[0]))+par[0]-par[1]*x[0]*sign; - return f; -}; - - -Double_t energyCalibrationFunctions::erfFuncFluo(Double_t *x, Double_t *par) { - Double_t f; - f=erfFunctionChargeSharing(x, par)+erfFunction(x, par+6)*(1+par[9]*(par[6]-x[0])); - return f; -}; -#endif - -double energyCalibrationFunctions::median(double *x, int n){ - // sorts x into xmed array and returns median - // n is number of values already in the xmed array - double xmed[n]; - int k,i,j; - - for (i=0; i*(x+j)) - k++; - if (*(x+i)==*(x+j)) { - if (i>j) - k++; - } - } - xmed[k]=*(x+i); - } - k=n/2; - return xmed[k]; -} - - -int energyCalibrationFunctions::quick_select(int arr[], int n){ - int low, high ; - int median; - int middle, ll, hh; - - low = 0 ; high = n-1 ; median = (low + high) / 2; - for (;;) { - if (high <= low) /* One element only */ - return arr[median] ; - - if (high == low + 1) { /* Two elements only */ - if (arr[low] > arr[high]) - ELEM_SWAP(arr[low], arr[high]) ; - return arr[median] ; - } - - /* Find median of low, middle and high items; swap into position low */ - middle = (low + high) / 2; - if (arr[middle] > arr[high]) ELEM_SWAP(arr[middle], arr[high]) ; - if (arr[low] > arr[high]) ELEM_SWAP(arr[low], arr[high]) ; - if (arr[middle] > arr[low]) ELEM_SWAP(arr[middle], arr[low]) ; - - /* Swap low item (now in position middle) into position (low+1) */ - ELEM_SWAP(arr[middle], arr[low+1]) ; - - /* Nibble from each end towards middle, swapping items when stuck */ - ll = low + 1; - hh = high; - for (;;) { - do ll++; while (arr[low] > arr[ll]) ; - do hh--; while (arr[hh] > arr[low]) ; - - if (hh < ll) - break; - - ELEM_SWAP(arr[ll], arr[hh]) ; - } - - /* Swap middle item (in position low) back into correct position */ - ELEM_SWAP(arr[low], arr[hh]) ; - - /* Re-set active partition */ - if (hh <= median) - low = ll; - if (hh >= median) - high = hh - 1; - } -} - -int energyCalibrationFunctions::kth_smallest(int *a, int n, int k){ - register int i,j,l,m ; - register double x ; - - l=0 ; m=n-1 ; - while (lSetParNames("Background Offset","Background Slope","Inflection Point","Noise RMS", "Number of Photons","Charge Sharing Slope"); - - fspectrum=new TF1("fspectrum",funcs,&energyCalibrationFunctions::spectrum,0,1000,6,"energyCalibrationFunctions","spectrum"); - fspectrum->SetParNames("Background Pedestal","Background slope", "Peak position","Noise RMS", "Number of Photons","Charge Sharing Pedestal"); - -#endif - - -} - - - -void energyCalibration::fixParameter(int ip, Double_t val){ - - fscurve->FixParameter(ip, val); - fspectrum->FixParameter(ip, val); -} - - -void energyCalibration::releaseParameter(int ip){ - - fscurve->ReleaseParameter(ip); - fspectrum->ReleaseParameter(ip); -} - - - - - - - -energyCalibration::~energyCalibration(){ -#ifdef MYROOT - delete fscurve; - delete fspectrum; -#endif - -} - -#ifdef MYROOT - - - -TH1F* energyCalibration::createMedianHistogram(TH2F* h2, int ch0, int nch) { - - if (h2==NULL || nch==0) - return NULL; - - double *x=new double[nch]; - TH1F *h1=NULL; - - double val=-1; - double me=0; - - - h1=new TH1F("median","Median",h2->GetYaxis()->GetNbins(),h2->GetYaxis()->GetXmin(),h2->GetYaxis()->GetXmax()); - - - for (int ib=0; ibGetXaxis()->GetNbins(); ib++) { - me=0; - for (int ich=0; ichGetBinContent(ch0+ich+1,ib+1); - me+=x[ich]; - } - cout << ib << " calculating median ch0=" << ch0 << " nch=" << nch << endl; - val=energyCalibrationFunctions::median(x, nch); - cout << "median=" << val << " mean= " << me/nch << endl; - h1->SetBinContent(ib+1,val); - } - delete [] x; - return h1; - - - -} - - - - - - - - - - - - - - -void energyCalibration::setStartParameters(Double_t *par){ - bg_offset=par[0]; - bg_slope=par[1]; - flex=par[2]; - noise=par[3]; - ampl=par[4]; - cs_slope=par[5]; -} - - -void energyCalibration::getStartParameters(Double_t *par){ - par[0]=bg_offset; - par[1]=bg_slope; - par[2]=flex; - par[3]=noise; - par[4]=ampl; - par[5]=cs_slope; -} - -#endif -int energyCalibration::setChargeSharing(int p) { - if (p>=0) { - cs_flag=p; -#ifdef MYROOT - if (p) { - fscurve->ReleaseParameter(5); - fspectrum->ReleaseParameter(1); - } else { - fscurve->FixParameter(5,0); - fspectrum->FixParameter(1,0); - } -#endif - } - - return cs_flag; -} - - -#ifdef MYROOT -void energyCalibration::initFitFunction(TF1 *fun, TH1 *h1) { - - Double_t min=fit_min, max=fit_max; - - Double_t mypar[6]; - - if (max==-1) - max=h1->GetXaxis()->GetXmax(); - - if (min==-1) - min=h1->GetXaxis()->GetXmin(); - - - if (bg_offset==-1) - mypar[0]=0; - else - mypar[0]=bg_offset; - - - if (bg_slope==-1) - mypar[1]=0; - else - mypar[1]=bg_slope; - - - if (flex==-1) - mypar[2]=(min+max)/2.; - else - mypar[2]=flex; - - - if (noise==-1) - mypar[3]=0.1; - else - mypar[3]=noise; - - if (ampl==-1) - mypar[4]=h1->GetBinContent(h1->GetXaxis()->FindBin(0.5*(max+min))); - else - mypar[4]=ampl; - - if (cs_slope==-1) - mypar[5]=0; - else - mypar[5]=cs_slope; - - fun->SetParameters(mypar); - - fun->SetRange(min,max); - -} - - -TF1* energyCalibration::fitFunction(TF1 *fun, TH1 *h1, Double_t *mypar, Double_t *emypar) { - - - TF1* fitfun; - - char fname[100]; - - strcpy(fname, fun->GetName()); - - if (plot_flag) { - h1->Fit(fname,"R"); - } else - h1->Fit(fname,"R0Q"); - - - fitfun= h1->GetFunction(fname); - fitfun->GetParameters(mypar); - for (int ip=0; ip<6; ip++) { - emypar[ip]=fitfun->GetParError(ip); - } - return fitfun; -} - -TF1* energyCalibration::fitSCurve(TH1 *h1, Double_t *mypar, Double_t *emypar) { - initFitFunction(fscurve,h1); - return fitFunction(fscurve, h1, mypar, emypar); -} - - - - - -TF1* energyCalibration::fitSpectrum(TH1 *h1, Double_t *mypar, Double_t *emypar) { - initFitFunction(fspectrum,h1); - return fitFunction(fspectrum, h1, mypar, emypar); -} - - - -TGraphErrors* energyCalibration::linearCalibration(int nscan, Double_t *en, Double_t *een, Double_t *fl, Double_t *efl, Double_t &gain, Double_t &off, Double_t &egain, Double_t &eoff) { - - TGraphErrors *gr; - - Double_t mypar[2]; - - gr = new TGraphErrors(nscan,en,fl,een,efl); - - if (plot_flag) { - gr->Fit("pol1"); - gr->SetMarkerStyle(20); - } else - gr->Fit("pol1","0Q"); - - TF1 *fitfun= gr->GetFunction("pol1"); - fitfun->GetParameters(mypar); - - egain=fitfun->GetParError(1); - eoff=fitfun->GetParError(0); - - gain=funcs->setScanSign()*mypar[1]; - off=mypar[0]; - - return gr; -} - - -TGraphErrors* energyCalibration::calibrate(int nscan, Double_t *en, Double_t *een, TH1F **h1, Double_t &gain, Double_t &off, Double_t &egain, Double_t &eoff, int integral) { - - TH1F *h; - - Double_t mypar[6], emypar[6]; - Double_t fl[nscan], efl[nscan]; - - - for (int ien=0; ien -#include -class TH1F; -class TH2F; -class TGraphErrors; -#endif - - - - - - - -const double conven=1000./3.6; /**< electrons/keV */ -const double el=1.67E-4; /**< electron charge in fC */ - - - -/** - \mainpage Common Root library for SLS detectors data analysis - * - * \section intro_sec Introduction - We know very well s-curves etc. but at the end everybody uses different functions ;-). - - * \subsection mot_sec Motivation - It would be greate to use everybody the same functions... - -*/ - - -/** - * - * -@libdoc The energiCalibration class contains all the necessary functions for s-curve fitting and linear calibration of the threshold. - * - * @short Energy calibration functions - * @author Anna Bergamaschi - * @version 0.1alpha - - - */ - -/** - class containing all the possible energy calibration functions (scurves with and without charge sharing, gaussian spectrum with and without charge sharing, possibility of chosing the sign of the X-axis) - -*/ -class energyCalibrationFunctions { - - public: - - energyCalibrationFunctions(int s=-1) {setScanSign(s);}; - - /** sets scan sign - \param s can be 1 (energy and x-axis have the same direction) or -1 (energy and x-axis have opposite directions) otherwise gets - \returns current scan sign can be 1 (energy and x-axis have the same direction) or -1 (energy and x-axis have opposite directions) - */ - int setScanSign(int s=0) {if (s==1 || s==-1) sign=s; return sign;};; - - -#ifdef MYROOT - /** - Gaussian Function with charge sharing pedestal - par[0] is the absolute height of the background pedestal - par[1] is the slope of the background pedestal - par[2] is the gaussian peak position - par[3] is the RMS of the gaussian (and of the pedestal) - par[4] is the height of the function - par[5] is the fractional height of the charge sharing pedestal (scales with par[3]) - */ - Double_t gaussChargeSharing(Double_t *x, Double_t *par); - - /** - Basic erf function - par[0] is the inflection point - par[1] is the RMS - par[2] is the amplitude - */ -Double_t erfFunction(Double_t *x, Double_t *par) ; - - /** Erf function with charge sharing slope - par[0] is the pedestal - par[1] is the slope of the pedestal - par[2] is the inflection point - par[3] is the RMS - par[4] is the amplitude - par[5] is the angual coefficient of the charge sharing slope (scales with par[3]) - */ -Double_t erfFunctionChargeSharing(Double_t *x, Double_t *par); - - /** Double Erf function with charge sharing slope - par[0] is the pedestal - par[1] is the slope of the pedestal - par[2] is the inflection point of the first energy - par[3] is the RMS of the first energy - par[4] is the amplitude of the first energy - par[5] is the angual coefficient of the charge sharing slope of the first energy (scales with par[3]) - par[6] is the inflection point of the second energy - par[7] is the RMS of the second energy - par[8] is the amplitude of the second energy - par[9] is the angual coefficient of the charge sharing slope of the second energy (scales with par[8]) - */ - -Double_t erfFuncFluo(Double_t *x, Double_t *par); - - - /** - static function Gaussian with charge sharing pedestal with the correct scan sign - par[0] is the absolute height of the background pedestal - par[1] is the fractional height of the charge sharing pedestal (scales with par[3] - par[2] is the gaussian peak position - par[3] is the RMS of the gaussian (and of the pedestal) - par[4] is the height of the function - */ - Double_t spectrum(Double_t *x, Double_t *par); - - - /** Erf function with charge sharing slope with the correct scan sign - par[0] is the pedestal - par[1] is the slope of the pedestal - par[2] is the inflection point - par[3] is the RMS - par[4] is the amplitude - par[5] is the angual coefficient of the charge sharing slope (scales with par[3]) - */ - Double_t scurve(Double_t *x, Double_t *par); - - - - /** Double Erf function with charge sharing slope - par[0] is the pedestal - par[1] is the slope of the pedestal - par[2] is the inflection point of the first energy - par[3] is the RMS of the first energy - par[4] is the amplitude of the first energy - par[5] is the angual coefficient of the charge sharing slope of the first energy (scales with par[3]) - par[6] is the inflection point of the second energy - par[7] is the RMS of the second energy - par[8] is the amplitude of the second energy - par[9] is the angual coefficient of the charge sharing slope of the second energy (scales with par[8]) - */ - Double_t scurveFluo(Double_t *x, Double_t *par); - -#endif - -/** Calculates the median of an array of n elements */ - static double median(double *x, int n); -/** Calculates the median of an array of n elements (swaps the arrays!)*/ - static int quick_select(int arr[], int n); -/** Calculates the median of an array of n elements (swaps the arrays!)*/ - static int kth_smallest(int *a, int n, int k); - - private: - int sign; - - -}; - -/** - class alowing the energy calibration of photon counting and anlogue detectors - -*/ - -class energyCalibration { - - - public: - /** - default constructor - creates the function with which the s-curves will be fitted - */ - energyCalibration(); - - /** - default destructor - deletes the function with which the s-curves will be fitted - */ - ~energyCalibration(); - - /** sets plot flag - \param p plot flag (-1 gets, 0 unsets, >0 plot) - \returns current plot flag - */ - int setPlotFlag(int p=-1) {if (p>=0) plot_flag=p; return plot_flag;}; - - /** sets scan sign - \param s can be 1 (energy and x-axis have the same direction) or -1 (energy and x-axis have opposite directions) otherwise gets - \returns current scan sign can be 1 (energy and x-axis have the same direction) or -1 (energy and x-axis have opposite directions) - */ - int setScanSign(int s=0) {return funcs->setScanSign(s);}; - - /** sets plot flag - \param p plot flag (-1 gets, 0 unsets, >0 plot) - \returns current plot flag - */ - int setChargeSharing(int p=-1); - - - void fixParameter(int ip, Double_t val); - - void releaseParameter(int ip); - -#ifdef MYROOT - - static TH1F* createMedianHistogram(TH2F* h2, int ch0, int nch); - - - /** sets the s-curve fit range - \param mi minimum of the fit range (-1 is histogram x-min) - \param ma maximum of the fit range (-1 is histogram x-max) - */ - void setFitRange(Double_t mi, Double_t ma){fit_min=mi; fit_max=ma;}; - - /** gets the s-curve fit range - \param mi reference for minimum of the fit range (-1 is histogram x-min) - \param ma reference for maximum of the fit range (-1 is histogram x-max) - */ - void getFitRange(Double_t &mi, Double_t &ma){mi=fit_min; ma=fit_max;}; - - -/** set start parameters for the s-curve function - \param par parameters, -1 sets to auto-calculation - par[0] is the pedestal - par[1] is the slope of the pedestal - par[2] is the inflection point - par[3] is the RMS - par[4] is the amplitude - par[5] is the angual coefficient of the charge sharing slope (scales with par[3]) -- always positive - */ - void setStartParameters(Double_t *par); - -/** get start parameters for the s-curve function - \param par parameters, -1 means auto-calculated - par[0] is the pedestal - par[1] is the slope of the pedestal - par[2] is the inflection point - par[3] is the RMS - par[4] is the amplitude - par[5] is the angual coefficient of the charge sharing slope (scales with par[3]) -- always positive - */ - void getStartParameters(Double_t *par); - - /** - fits histogram with the s-curve function - \param h1 1d-histogram to be fitted - \param mypar pointer to fit parameters array - \param emypar pointer to fit parameter errors - \returns the fitted function - can be used e.g. to get the Chi2 or similar - */ - TF1 *fitSCurve(TH1 *h1, Double_t *mypar, Double_t *emypar); - - - /** - fits histogram with the spectrum - \param h1 1d-histogram to be fitted - \param mypar pointer to fit parameters array - \param emypar pointer to fit parameter errors - \returns the fitted function - can be used e.g. to get the Chi2 or similar - */ - TF1 *fitSpectrum(TH1 *h1, Double_t *mypar, Double_t *emypar); - - - /** - calculates gain and offset for the set of inflection points - \param nscan number of energy scans - \param en array of energies (nscan long) - \param een array of errors on energies (nscan long) - can be NULL! - \param fl array of inflection points (nscan long) - \param efl array of errors on the inflection points (nscan long) - \param gain reference to gain resulting from the fit - \param off reference to offset resulting from the fit - \param egain reference to error on the gain resulting from the fit - \param eoff reference to the error on the offset resulting from the fit - \returns graph energy vs inflection point - */ - TGraphErrors* linearCalibration(int nscan, Double_t *en, Double_t *een, Double_t *fl, Double_t *efl, Double_t &gain, Double_t &off, Double_t &egain, Double_t &eoff); - - /** - calculates gain and offset for the set of energy scans - \param nscan number of energy scans - \param en array of energies (nscan long) - \param een array of errors on energies (nscan long) - can be NULL! - \param h1 array of TH1 - \param gain reference to gain resulting from the fit - \param off reference to offset resulting from the fit - \param egain reference to error on the gain resulting from the fit - \param eoff reference to the error on the offset resulting from the fit - \returns graph energy vs inflection point - */ - TGraphErrors* calibrateScurves(int nscan, Double_t *en, Double_t *een, TH1F **h1, Double_t &gain, Double_t &off, Double_t &egain, Double_t &eoff){return calibrate(nscan, en, een, h1, gain, off, egain, eoff, 1);}; - - /** - calculates gain and offset for the set of energy spectra - \param nscan number of energy scans - \param en array of energies (nscan long) - \param een array of errors on energies (nscan long) - can be NULL! - \param h1 array of TH1 - \param gain reference to gain resulting from the fit - \param off reference to offset resulting from the fit - \param egain reference to error on the gain resulting from the fit - \param eoff reference to the error on the offset resulting from the fit - \returns graph energy vs peak - */ - TGraphErrors* calibrateSpectra(int nscan, Double_t *en, Double_t *een, TH1F **h1, Double_t &gain, Double_t &off, Double_t &egain, Double_t &eoff){return calibrate(nscan, en, een, h1, gain, off, egain, eoff, 0);}; - - -#endif - private: - -#ifdef MYROOT - /** - calculates gain and offset for the set of energies - \param nscan number of energy scans - \param en array of energies (nscan long) - \param een array of errors on energies (nscan long) - can be NULL! - \param h1 array of TH1 - \param gain reference to gain resulting from the fit - \param off reference to offset resulting from the fit - \param egain reference to error on the gain resulting from the fit - \param eoff reference to the error on the offset resulting from the fit - \param integral 1 is an s-curve set (default), 0 spectra - \returns graph energy vs peak/inflection point - */ - TGraphErrors* calibrate(int nscan, Double_t *en, Double_t *een, TH1F **h1, Double_t &gain, Double_t &off, Double_t &egain, Double_t &eoff, int integral=1); - - - /** - Initializes the start parameters and the range of the fit depending on the histogram characteristics and/or on the start parameters specified by the user - \param fun pointer to function to be initialized - \param h1 histogram from which to extract the range and start parameters, if not already specified by the user - -*/ - - void initFitFunction(TF1 *fun, TH1 *h1); - - - /** - Performs the fit according to the flags specified and returns the fitted function - \param fun function to fit - \param h1 histogram to fit - \param mypar pointer to fit parameters array - \param emypar pointer to fit parameter errors - \returns the fitted function - can be used e.g. to get the Chi2 or similar - */ - TF1 *fitFunction(TF1 *fun, TH1 *h1, Double_t *mypar, Double_t *emypar); - -#endif - -#ifdef MYROOT - Double_t fit_min; /**< minimum of the s-curve fitting range, -1 is histogram x-min */ - Double_t fit_max; /**< maximum of the s-curve fitting range, -1 is histogram x-max */ - - Double_t bg_offset; /**< start value for the background pedestal */ - Double_t bg_slope; /**< start value for the background slope */ - Double_t flex; /**< start value for the inflection point */ - Double_t noise; /**< start value for the noise */ - Double_t ampl; /**< start value for the number of photons */ - Double_t cs_slope; /**< start value for the charge sharing slope */ - - - TF1 *fscurve; /**< function with which the s-curve will be fitted */ - - TF1 *fspectrum; /**< function with which the spectrum will be fitted */ - -#endif - - energyCalibrationFunctions *funcs; - int plot_flag; /**< 0 does not plot, >0 plots (flags?) */ - - int cs_flag; /**< 0 functions without charge sharing contribution, >0 with charge sharing contribution */ - -}; - -#endif - - - - - - - - - - - - - - - - - - - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/energyCalibrationMacro.C b/slsDetectorSoftware/slsDetectorAnalysis/energyCalibrationMacro.C deleted file mode 100644 index 5a4c4386f..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/energyCalibrationMacro.C +++ /dev/null @@ -1,24 +0,0 @@ -{ - - TH1F *h1[3]; - TH2F *h2=createScan("/scratch/stability_test/ag_source_S%d_10.raw",500,900,10,1280*2); - h1[0]=getCh(h2,500); - h1[1]=getCh(h2,300); - h1[2]=getCh(h2,700); - Double_t gain, offset, eg, eo; - Double_t en[3]={20,22,24}; - TH1F *h; - energyCalibration *e=new energyCalibration(); - e->setFitRange(500,700); - Double_t mypar[6]; - mypar[0]=0; //pedestal - mypar[1]=0; //pedestal slope - mypar[2]=-1; //inflection point - must be free for all energies and will be set at half of the scan range - mypar[3]=10; //noise rms - mypar[4]=1000; //number of photons - mypar[5]=0; //charge sharing slope - e->setFitParameters(mypar); - - TGraphErrors *gr=e->calibrate(3,en,NULL,h1,gain,offset,eg,eo); - -} diff --git a/slsDetectorSoftware/slsDetectorAnalysis/energyConversion.cpp b/slsDetectorSoftware/slsDetectorAnalysis/energyConversion.cpp deleted file mode 100644 index 91a555caa..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/energyConversion.cpp +++ /dev/null @@ -1,614 +0,0 @@ -#include "energyConversion.h" - -#include -#include -#include -#include - -#include "fileIOStatic.h" - -using namespace std; - - - - -int energyConversion::readCalibrationFile(string fname, double &gain, double &offset){ - - string str; - ifstream infile; -#ifdef VERBOSE - std::cout<< "Opening file "<< fname << std::endl; -#endif - infile.open(fname.c_str(), ios_base::in); - if (infile.is_open()) { - getline(infile,str); -#ifdef VERBOSE - std::cout<< str << std::endl; -#endif - istringstream ssstr(str); - ssstr >> offset >> gain; - infile.close(); - cout << "Calibration file loaded: " << fname << endl; - } else { - std::cout<< "Could not open calibration file "<< fname << std::endl; - gain=0.; - offset=0.; -#ifndef MYROOT - return FAIL; -#endif - return -1; - } -#ifndef MYROOT - return OK; -#endif - return 0; -}; - -int energyConversion::writeCalibrationFile(string fname, double gain, double offset){ - //std::cout<< "Function not yet implemented " << std::endl; - ofstream outfile; - outfile.open (fname.c_str()); - - // >> i/o operations here << - if (outfile.is_open()) { - outfile << offset << " " << gain << std::endl; - } else { - std::cout<< "Could not open calibration file "<< fname << " for writing" << std::endl; -#ifndef MYROOT - return FAIL; -#endif - return -1; - } - - outfile.close(); - -#ifndef MYROOT - return OK; -#endif - return 0; -}; - - -int energyConversion::readCalibrationFile(string fname, int *gain, int *offset){ - - string str; - ifstream infile; - double o,g; - int ig=0; -#ifdef VERBOSE - std::cout<< "Opening file "<< fname << std::endl; -#endif - infile.open(fname.c_str(), ios_base::in); - if (infile.is_open()) { - //get gain and offset - for (ig=0; ig<4; ig++) { - //while ( (getline(infile,str)) > -1) { - getline(infile,str); -#ifdef VERBOSE - std::cout<< str << std::endl; -#endif - istringstream ssstr(str); - ssstr >> o >> g; - offset[ig]=(int)(o*1000); - gain[ig]=(int)(g*1000); - // ig++; - if (ig>=4) - break; - } - infile.close(); - cout << "Calibration file loaded: " << fname << endl; - } else { - cout << "Could not open calibration file: "<< fname << std::endl; - gain[0]=0; - offset[0]=0; -#ifndef MYROOT - return FAIL; -#endif - return -1; - } -#ifndef MYROOT - return OK; -#endif - return 0; - -}; - -int energyConversion::writeCalibrationFile(string fname, int *gain, int *offset){ - //std::cout<< "Function not yet implemented " << std::endl; - ofstream outfile; - outfile.open (fname.c_str()); - // >> i/o operations here << - if (outfile.is_open()) { - for (int ig=0; ig<4; ig++) - outfile << ((double)offset[ig]/1000) << " " << ((double)gain[ig]/1000) << std::endl; - } else { - std::cout<< "Could not open calibration file "<< fname << " for writing" << std::endl; -#ifndef MYROOT - return FAIL; -#endif - return -1; - } - - outfile.close(); -#ifndef MYROOT - return OK; -#endif - return 0; -}; - - - -slsDetectorDefs::sls_detector_module* energyConversion::interpolateTrim(detectorType myDetectorType, sls_detector_module* a, sls_detector_module* b, const int energy, const int e1, const int e2, int tb){ - // only implemented for eiger currently (in terms of which dacs) - if(myDetectorType != EIGER) { - printf("Interpolation of Trim values not implemented for this detector!\n"); - return NULL; - } - - sls_detector_module* myMod = createModule(myDetectorType); - enum eiger_DacIndex{SVP,VTR,VRF,VRS,SVN,VTGSTV,VCMP_LL,VCMP_LR,CAL,VCMP_RL,RXB_RB,RXB_LB,VCMP_RR,VCP,VCN,VIS}; - - //Copy other dacs - int dacs_to_copy[] = {SVP,VTR,SVN,VTGSTV,RXB_RB,RXB_LB,VCN,VIS}; - int num_dacs_to_copy = sizeof(dacs_to_copy) / sizeof(dacs_to_copy[0]); - for (int i = 0; i < num_dacs_to_copy; ++i) { - if(a->dacs[dacs_to_copy[i]] != b->dacs[dacs_to_copy[i]]) { - deleteModule(myMod); - return NULL; - } - myMod->dacs[dacs_to_copy[i]] = a->dacs[dacs_to_copy[i]]; - } - - - //Copy irrelevant dacs (without failing): CAL - if (a->dacs[CAL] != b->dacs[CAL]) { - printf("Warning: DAC CAL differs in both energies (%d, %d)! ", - a->dacs[CAL], b->dacs[CAL]); - printf("Taking first: %d\n", a->dacs[CAL]); - } - myMod->dacs[CAL] = a->dacs[CAL]; - - - //Interpolate vrf, vcmp, vcp - int dacs_to_interpolate[] = {VRF,VCMP_LL,VCMP_LR,VCMP_RL,VCMP_RR,VCP, VRS}; - int num_dacs_to_interpolate = sizeof(dacs_to_interpolate) / sizeof(dacs_to_interpolate[0]); - for (int i = 0; i < num_dacs_to_interpolate; ++i) { - myMod->dacs[dacs_to_interpolate[i]] = linearInterpolation(energy, e1, e2, - a->dacs[dacs_to_interpolate[i]], b->dacs[dacs_to_interpolate[i]]); - } - - //Interpolate all trimbits - if(tb) { - for (int i = 0; inchan; i++) - myMod->chanregs[i] = linearInterpolation(energy, e1, e2, a->chanregs[i], b->chanregs[i]); - } - return myMod; -} - - - -#ifndef MYROOT - -/* I/O */ - - -slsDetectorDefs::sls_detector_module* energyConversion::readSettingsFile(string fname, detectorType myDetectorType, int& iodelay, int& tau, sls_detector_module* myMod, int tb){ - - - - - int nflag=0; - - - if (myMod==NULL) { - myMod=createModule(myDetectorType); - nflag=1; - } - - int id=0,i; - string names[100]; - string myfname; - string str; - ifstream infile; - ostringstream oss; - int iline=0; - string sargname; - int ival; - int ichan=0, ichip=0, idac=0; - int nch=((myMod->nchan)/(myMod->nchip)); - - //ascii settings/trim file - switch (myDetectorType) { - case MYTHEN: - break; - case MOENCH: - names[id++]="Vdac0"; - names[id++]="Vdac1"; - names[id++]="Vdac2"; - names[id++]="Vdac3"; - names[id++]="Vdac4"; - names[id++]="Vdac5"; - names[id++]="Vdac6"; - names[id++]="Vdac7"; - break; - case GOTTHARD: - case PROPIX: - names[id++]="Vref"; - names[id++]="VcascN"; - names[id++]="VcascP"; - names[id++]="Vout"; - names[id++]="Vcasc"; - names[id++]="Vin"; - names[id++]="Vref_comp"; - names[id++]="Vib_test"; - break; - case EIGER: - break; - case JUNGFRAU: - names[id++]="VDAC0"; - names[id++]="VDAC1"; - names[id++]="VDAC2"; - names[id++]="VDAC3"; - names[id++]="VDAC4"; - names[id++]="VDAC5"; - names[id++]="VDAC6"; - names[id++]="VDAC7"; - names[id++]="VDAC8"; - names[id++]="VDAC9"; - names[id++]="VDAC10"; - names[id++]="VDAC11"; - names[id++]="VDAC12"; - names[id++]="VDAC13"; - names[id++]="VDAC14"; - names[id++]="VDAC15"; - break; - default: - cout << "Unknown detector type - unknown format for settings file" << endl; - return NULL; - } - -#ifdef VERBOSE - std::cout<< "reading settings file for module number "<< myMod->module << std::endl; -#endif - myfname=fname; -#ifdef VERBOSE - std::cout<< "file name is "<< myfname << std::endl; -#endif - - switch (myDetectorType) { - - case MYTHEN: - infile.open(myfname.c_str(), ios_base::in); - if (infile.is_open()) { - for (int iarg=0; iargndac; iarg++) { - getline(infile,str); - iline++; - istringstream ssstr(str); - ssstr >> sargname >> ival; -#ifdef VERBOSE - std::cout<< sargname << " dac nr. " << idac << " is " << ival << std::endl; -#endif - myMod->dacs[idac]=ival; - idac++; - } - for (ichip=0; ichipnchip; ichip++) { - getline(infile,str); - iline++; -#ifdef VERYVERBOSE - std::cout<< str << std::endl; -#endif - istringstream ssstr(str); - ssstr >> sargname >> ival; -#ifdef VERYVERBOSE - std::cout<< "chip " << ichip << " " << sargname << " is " << ival << std::endl; -#endif - - myMod->chipregs[ichip]=ival; - for (ichan=0; ichannChans <<" iline " << iline<< std::endl; -#endif - iline++; - myMod->chanregs[ichip*nch+ichan]=0; - for (int iarg=0; iarg<6 ; iarg++) { - ssstr >> ival; - //if (ssstr.good()) { - switch (iarg) { - case 0: -#ifdef VERYVERBOSE - std::cout<< "trimbits " << ival ; -#endif - myMod->chanregs[ichip*nch+ichan]|=ival&TRIMBITMASK; - break; - case 1: -#ifdef VERYVERBOSE - std::cout<< " compen " << ival ; -#endif - myMod->chanregs[ichip*nch+ichan]|=ival<<9; - break; - case 2: -#ifdef VERYVERBOSE - std::cout<< " anen " << ival ; -#endif - myMod->chanregs[ichip*nch+ichan]|=ival<<8; - break; - case 3: -#ifdef VERYVERBOSE - std::cout<< " calen " << ival ; -#endif - myMod->chanregs[ichip*nch+ichan]|=ival<<7; - break; - case 4: -#ifdef VERBOSE - std::cout<< " outcomp " << ival ; -#endif - myMod->chanregs[ichip*nch+ichan]|=ival<<10; - break; - case 5: -#ifdef VERBOSE - std::cout<< " counts " << ival << std::endl; -#endif - myMod->chanregs[ichip*nch+ichan]|=ival<<11; - break; - default: - std::cout<< " too many columns" << std::endl; - break; - } - } - } - // } - } -#ifdef VERBOSE - std::cout<< "read " << ichan*ichip << " channels" <dacs,sizeof(dacs_t)*(myMod->ndac)); - infile.read((char*)&iodelay,sizeof(iodelay)); - infile.read((char*)&tau,sizeof(tau)); -#ifdef VERBOSE - for(int i=0;indac;i++) - std::cout << "dac " << i << ":" << myMod->dacs[i] << std::endl; - std::cout << "iodelay:" << iodelay << std::endl; - std::cout << "tau:" << tau << std::endl; -#endif - if(tb) { - infile.read((char*) myMod->chanregs,sizeof(int)*(myMod->nchan)); - if(infile.eof()){ - cout<> sargname >> ival; - for (i=0;idacs[i]=ival; - idac++; -#ifdef VERBOSE - std::cout<< sargname << " dac nr. " << idac << " is " << ival << std::endl; -#endif - break; - } - } - } - if (i < id) { -#ifdef VERBOSE - std::cout<< sargname << " dac nr. " << idac << " is " << ival << std::endl; -#endif - }else - std::cout<< "Unknown dac " << sargname << std::endl; - - infile.close(); - strcpy(settingsFile,fname.c_str()); - printf("Settings file loaded: %s\n",settingsFile); - return myMod; - - } - - //---------------------------------- - break; - - default: - std::cout<< "Unknown detector type - don't know how to read file" << myfname << std::endl; - infile.close(); - deleteModule(myMod); - return NULL; - - } - - printf("Error: Could not open settings file %s\n", myfname.c_str()); - if (nflag) - deleteModule(myMod); - - return NULL; - - - -}; - - -int energyConversion::writeSettingsFile(string fname, detectorType myDetectorType, sls_detector_module mod, int iodelay, int tau){ - - ofstream outfile; - - int nch=((mod.nchan)/(mod.nchip)); - - string names[100]; - int id=0; - switch (myDetectorType) { - case MYTHEN: - names[id++]="Vtrim"; - names[id++]="Vthresh"; - names[id++]="Rgsh1"; - names[id++]="Rgsh2"; - names[id++]="Rgpr"; - names[id++]="Vcal"; - names[id++]="outBuffEnable"; - break; - case MOENCH: - names[id++]="Vdac0"; - names[id++]="Vdac1"; - names[id++]="Vdac2"; - names[id++]="Vdac3"; - names[id++]="Vdac4"; - names[id++]="Vdac5"; - names[id++]="Vdac6"; - names[id++]="Vdac7"; - break; - case GOTTHARD: - case PROPIX: - names[id++]="Vref"; - names[id++]="VcascN"; - names[id++]="VcascP"; - names[id++]="Vout"; - names[id++]="Vcasc"; - names[id++]="Vin"; - names[id++]="Vref_comp"; - names[id++]="Vib_test"; - break; - case EIGER: - break; - case JUNGFRAU: - names[id++]="VDAC0"; - names[id++]="VDAC1"; - names[id++]="VDAC2"; - names[id++]="VDAC3"; - names[id++]="VDAC4"; - names[id++]="VDAC5"; - names[id++]="VDAC6"; - names[id++]="VDAC7"; - names[id++]="VDAC8"; - names[id++]="VDAC9"; - names[id++]="VDAC10"; - names[id++]="VDAC11"; - names[id++]="VDAC12"; - names[id++]="VDAC13"; - names[id++]="VDAC14"; - names[id++]="VDAC15"; - break; - default: - cout << "Unknown detector type - unknown format for settings file" << endl; - return FAIL; - } - - int iv, ichan, ichip; - int iv1, idac; - int nb; - - switch (myDetectorType) { - case EIGER: - outfile.open(fname.c_str(), ofstream::binary); - if (outfile.is_open()) { - iv = 1150; -#ifdef VERBOSE - for(int i=0;i(&iodelay), sizeof(iodelay)); - outfile.write(reinterpret_cast(&tau), sizeof(tau)); - outfile.write((char*)mod.chanregs, sizeof(int)*(mod.nchan)); - - outfile.close(); - return slsDetectorDefs::OK; - } - - printf("Could not open Settings file %s\n", fname.c_str()); - return slsDetectorDefs::FAIL; - default: - - - outfile.open(fname.c_str(), ios_base::out); - - if (outfile.is_open()) { - for (idac=0; idac>nb); - outfile << iv1 << " "; - nb=8; - iv1=((iv&(1<>nb); - outfile << iv1 << " "; - nb=7; - iv1=((iv&(1<>nb); - outfile <>nb); - outfile << iv1 << " "; - nb=11; - iv1= ((iv&0xfffff800)>>nb); - outfile << iv1 << std::endl; - } - } - } - outfile.close(); - return OK; - } - std::cout<< "could not open SETTINGS file " << fname << std::endl; - return FAIL; - - } - - -}; - - - -#endif diff --git a/slsDetectorSoftware/slsDetectorAnalysis/energyConversion.h b/slsDetectorSoftware/slsDetectorAnalysis/energyConversion.h deleted file mode 100644 index 518c75c34..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/energyConversion.h +++ /dev/null @@ -1,147 +0,0 @@ -#ifndef ENERGYCONVERSION_H -#define ENERGYCONVERSION_H - -#ifdef __CINT__ -#define MYROOT -#define __cplusplus -#endif - -//#ifndef MYROOT -//#include "sls_receiver_defs.h" -#include "sls_detector_defs.h" -//#endif -#include -#include - - -/** - @short class handling the energy calibration and trim files IO -*/ - - -class energyConversion -//#ifndef MYROOT -: private virtual slsDetectorDefs - //#endif -{ - public: - /** default constrauctor */ - energyConversion(){}; - /** default destructor */ - virtual ~energyConversion(){}; - - - /** - reads a calibration file - \param fname file to be read - \param gain reference to the gain variable - \param offset reference to the offset variable - \returns OK if successful, else FAIL or -1 - - */ - static int readCalibrationFile(std::string fname, double &gain, double &offset); - - /** - writes a calibration file - \param fname file to be written - \param gain - \param offset - \returns OK if successful, else FAIL or -1 - */ - static int writeCalibrationFile(std::string fname, double gain, double offset); - - /** - reads a calibration file - \param fname file to be read - \param gain reference to the gain variable - \param offset reference to the offset variable - \returns OK if successful, else FAIL or -1 - */ - static int readCalibrationFile(std::string fname, int *gain, int *offset); - - /** - writes a calibration file - \param fname file to be written - \param gain reference to the gain variable - \param offset reference to the offset variable - \returns OK if successful, else FAIL or -1 - */ - static int writeCalibrationFile(std::string fname, int *gain, int *offset); - - - - //Template function to do linear interpolation between two points - template - V linearInterpolation(const E x, const E x1, const E x2, const V y1, const V y2){ - double k = static_cast(y2-y1)/(x2-x1); - double m = y1-k*x1; - int y = round( k*x+m ); - return static_cast(y); - } - - - /** - * interpolates dacs and trimbits between 2 trim files - \param myDetectorType detector type (needed for which dacs that neeeds to be interpolated & which kept same) - \param a first module structure - \param b second module structure - \param energy energy to trim at - \param e1 reference trim value - \param e2 reference trim value - \param tb 1 to include trimbits, 0 to exclude (used for eiger) - \returns the pointer to the module structure with interpolated values or NULL if error - */ - sls_detector_module* interpolateTrim(detectorType myDetectorType, sls_detector_module* a, sls_detector_module* b, const int energy, const int e1, const int e2, int tb=1); - - - -#ifndef MYROOT - - /** - reads a trim/settings file - \param fname name of the file to be read - \param myDetectorType detector type (needed for number of channels, chips, dacs etc.) - \param iodelay io delay (detector specific) - \param tau tau (detector specific) - \param myMod pointer to the module structure which has to be set.
If it is NULL a new module structure will be created - \param tb 1 to include trimbits, 0 to exclude (used for eiger) - \returns the pointer to myMod or NULL if reading the file failed - */ - - sls_detector_module* readSettingsFile(std::string fname, detectorType myDetectorType, int& iodelay, int& tau, sls_detector_module* myMod=NULL, int tb=1); - - /** - writes a trim/settings file - \param fname name of the file to be written - \param myDetectorType detector type (needed for number of channels, chips, dacs etc.) - \param mod module structure which has to be written to file - \param iodelay io delay (detector specific) - \param tau tau (detector specific) - \returns OK or FAIL if the file could not be written - - \sa ::sls_detector_module mythenDetector::writeSettingsFile(string, sls_detector_module) - */ - int writeSettingsFile(std::string fname, detectorType myDetectorType, sls_detector_module mod, int iodelay, int tau); - - /** allocates the momery for a detector module structure - \param myDetectorType detector type (needed for number of channels, chips, dacs etc.) - \returns pointer to detector module - */ - virtual sls_detector_module* createModule(detectorType myDetectorType)=0; - - /** - frees the memory of a detector module structure - \param myMod pointer to memeory to be freed - */ - virtual void deleteModule(sls_detector_module *myMod)=0; - - - protected: - /** pointer to settings file name */ - char *settingsFile; - - -#endif - -}; -#endif diff --git a/slsDetectorSoftware/slsDetectorAnalysis/fileIO.cpp b/slsDetectorSoftware/slsDetectorAnalysis/fileIO.cpp deleted file mode 100644 index 051094145..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/fileIO.cpp +++ /dev/null @@ -1,204 +0,0 @@ -#include "fileIO.h" - -using namespace std; - - -/* I/O */ - -/* generates file name without extension*/ - -string fileIO::createFileName() { - - pthread_mutex_lock(&mf); - currentFileName=fileIOStatic::createFileName(filePath, \ - fileName, \ - getActionMask(), \ - getCurrentScanVariable(0), \ - getScanPrecision(0), \ - getCurrentScanVariable(1), \ - getScanPrecision(1), \ - getCurrentPositionIndex(), \ - getNumberOfPositions(), \ - *fileIndex, \ - frameIndex, \ - detIndex \ - ); - - //if (getDetectorsType()==JUNGFRAUCTB) { - // nBytes=2*getTotalNumberOfChannels(); - //} else - nBytes=getDataBytes(); - pthread_mutex_unlock(&mf); - return currentFileName; - -} - - - -/* generates file prefix for receivers */ - -string fileIO::createReceiverFilePrefix() { - pthread_mutex_lock(&mf); - currentReceiverFilePrefix=fileIOStatic::createReceiverFilePrefix(fileName, \ - getActionMask(), \ - getCurrentScanVariable(0), \ - getScanPrecision(0), \ - getCurrentScanVariable(1), \ - getScanPrecision(1), \ - getCurrentPositionIndex(), \ - getNumberOfPositions(), \ - detIndex \ - ); - pthread_mutex_unlock(&mf); - return currentReceiverFilePrefix; - -} - - - -/*writes raw data file */ - -int fileIO::writeDataFile(string fname, double *data, double *err, double *ang, char dataformat, int nch){ - if (nch==-1) - nch=getTotalNumberOfChannels(); - - // cout << "Write filexxx...." << endl; - - return fileIOStatic::writeDataFile(fname, nch, data, err, ang, dataformat); - -} -int fileIO::writeDataFile(ofstream &outfile, double *data, double *err, double *ang, char dataformat, int nch, int offset){ - if (nch==-1) - nch=getTotalNumberOfChannels(); - - //cout << "Write file...." << endl; - - return fileIOStatic::writeDataFile(outfile, nch, data, err, ang, dataformat, offset); - -} - - -int fileIO::writeDataFile(string fname, int *data){ - - return fileIOStatic::writeDataFile(fname, getTotalNumberOfChannels(), data); -} - - - - -int fileIO::writeDataFile(ofstream &outfile, int *data, int offset){ - - // cout << "Write raw file...." << endl; - return fileIOStatic::writeDataFile(outfile, getTotalNumberOfChannels(), data, offset); -} - - - -int fileIO::writeDataFile(void *data, int iframe) { - - if (iframe<0) - iframe=frameIndex; - - if ((*framesPerFile)<2) - iframe=-1; - - if ((iframe%(*framesPerFile))==0 || (iframe<0) || filefd==0) { - createFileName(); - filefd = fopen((currentFileName+string(".raw")).c_str(), "w"); - } - - if (filefd){ -// fileIOStatic::writeBinaryDataFile(filefd,getDataBytes(), data); - cout <<"Writing "<< nBytes<< " dataBytes"<< endl; - fileIOStatic::writeBinaryDataFile(filefd,nBytes, data); - iframe++; - } - - if ((iframe%(*framesPerFile)==0) || (iframe<0)) { - if (filefd) - fclose(filefd); - filefd=NULL; - } - return 0; -} - - - -int fileIO::closeDataFile() { - cout << "close file...." << endl; - if (filefd) - fclose(filefd); - filefd=NULL; - return 0; -} - - - - - -int fileIO::writeDataFile(string fname, short int *data){ - - cout << "Write raw file...." << endl; - return fileIOStatic::writeDataFile(fname, getTotalNumberOfChannels(), data); -} - - - - - - - - - -int fileIO::writeDataFile(ofstream &outfile, short int *data, int offset){ - - return fileIOStatic::writeDataFile(outfile, getTotalNumberOfChannels(), data, offset); -} - - - - - - - - - - -int fileIO::readDataFile(string fname, double *data, double *err, double *ang, char dataformat) { - return fileIOStatic::readDataFile(getTotalNumberOfChannels(), fname, data, err, ang, dataformat); - -} - -int fileIO::readDataFile(ifstream &infile, double *data, double *err, double *ang, char dataformat, int offset) { - return fileIOStatic::readDataFile(getTotalNumberOfChannels(), infile, data, err, ang, dataformat, offset); - -} - - - -int fileIO::readDataFile(string fname, int *data){ - - return fileIOStatic::readDataFile(fname, data, getTotalNumberOfChannels()); -}; - - -int fileIO::readDataFile(ifstream &infile, int *data, int offset){ - - return fileIOStatic::readDataFile(infile, data, getTotalNumberOfChannels(), offset); -}; - - - - - -int fileIO::readDataFile(string fname, short int *data){ - - return fileIOStatic::readDataFile(fname, data, getTotalNumberOfChannels()); -}; - - -int fileIO::readDataFile(ifstream &infile, short int *data, int offset){ - - return fileIOStatic::readDataFile(infile, data, getTotalNumberOfChannels(),offset); -}; - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/fileIO.h b/slsDetectorSoftware/slsDetectorAnalysis/fileIO.h deleted file mode 100644 index 2bc416991..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/fileIO.h +++ /dev/null @@ -1,420 +0,0 @@ -#ifndef FILEIO_H -#define FILEIO_H - -#include "slsDetectorBase.h" -#include "fileIOStatic.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// -/** - @short class handling the data file I/O flags -*/ - -class fileIO : public fileIOStatic, public virtual slsDetectorBase { - - - public: - - /* enum rawFileFormat { */ -/* ASCII, */ -/* BINARY */ -/* } */ - - - /** default constructor */ - fileIO(): fileIOStatic(){ - currentFrameIndex=-1; - frameIndex=-1; - detIndex=-1; - framesPerFile=&nframes; - nframes=1; - filefd = NULL; - pthread_mutex_t mp1 = PTHREAD_MUTEX_INITIALIZER; - mf=mp1; - pthread_mutex_init(&mf, NULL); - }; - - /** virtual destructor */ - virtual ~fileIO(){}; - - using fileIOStatic::readDataFile; - using fileIOStatic::writeDataFile; - using fileIOStatic::createFileName; - - int getFileIndexFromFileName(std::string fname){ - int ret; - pthread_mutex_lock(&mf); - ret=fileIOStatic::getFileIndexFromFileName(fname); - pthread_mutex_unlock(&mf); - return ret; - }; - int getIndicesFromFileName(std::string fname, int &index){ - int ret; - pthread_mutex_lock(&mf); - ret=fileIOStatic::getIndicesFromFileName(fname,index); - pthread_mutex_unlock(&mf); - return ret; - }; - - - - int getVariablesFromFileName(std::string fname, int &index, int &p_index, double &sv0, double &sv1){ - - int ret; - pthread_mutex_lock(&mf); - ret=fileIOStatic::getVariablesFromFileName(fname, index, p_index, sv0, sv1); - pthread_mutex_unlock(&mf); - return ret; - }; - - int getVariablesFromFileName(std::string fname, int &index, int &f_index, int &p_index, double &sv0, double &sv1, int &detindex){ - - - int ret; - pthread_mutex_lock(&mf); - ret=fileIOStatic::getVariablesFromFileName(fname, f_index, index, p_index, sv0, sv1, detindex); - pthread_mutex_unlock(&mf); - return ret; - }; - - /** - sets the default output files path - \param s file path - \return actual file path - */ - virtual std::string setFilePath(std::string s) { - pthread_mutex_lock(&mf); - sprintf(filePath, s.c_str()); - pthread_mutex_unlock(&mf); - return std::string(filePath); - }; - - /** - sets the default output files root name - \param s file name to be set - \returns actual file name - */ - virtual std::string setFileName(std::string s) { - pthread_mutex_lock(&mf); - sprintf(fileName, s.c_str()); - pthread_mutex_unlock(&mf); - return std::string(fileName);}; - - /** - sets the default output file index - \param i start file index to be set - \returns actual file index - */ - virtual int setFileIndex(int i) { - pthread_mutex_lock(&mf); - *fileIndex=i; - pthread_mutex_unlock(&mf); - return *fileIndex; - }; - - /** - sets the default output file frame index - \param i file frame index to be set - \returns actual file frame index - */ - virtual int setFrameIndex(int i) { - pthread_mutex_lock(&mf); - frameIndex=i; - pthread_mutex_unlock(&mf); - return frameIndex;}; - - /** - sets the default output current frame index - \param i current frame index to be set - \returns actual current frame index - */ - virtual int setCurrentFrameIndex(int i) { - pthread_mutex_lock(&mf); - currentFrameIndex=i; - pthread_mutex_unlock(&mf); - return currentFrameIndex; - }; - - /** - sets the default output file index - \param i frame index to be set - \returns actual frame index - */ - virtual int setFramesPerFile(int i) { - pthread_mutex_lock(&mf); - if (i>0) *framesPerFile=i; - pthread_mutex_unlock(&mf); - return *framesPerFile;}; - - /** - sets the default output file index - \param i detector index to be set - \returns actual detector index - */ - virtual int setDetectorIndex(int i) { - pthread_mutex_lock(&mf); - detIndex=i; - pthread_mutex_unlock(&mf); - return detIndex;}; - - /** - sets the default file format - \param i file format to be set - \returns actual file frame format - */ - virtual fileFormat setFileFormat(int i) { - pthread_mutex_lock(&mf); - *fileFormatType=(fileFormat)i; - pthread_mutex_unlock(&mf); - return *fileFormatType; }; - - - - /** - \returns the output files path - - */ - virtual std::string getFilePath() {return std::string(filePath);}; - /** - \returns the output files root name - */ - virtual std::string getFileName() {return std::string(fileName);}; - - /** - \returns the output file index - */ - virtual int getFileIndex() {return *fileIndex;}; - - /** - \returns the output file frame index - */ - virtual int getFrameIndex() {return frameIndex;}; - - /** - \returns the output current frame index - */ - virtual int getCurrentFrameIndex() {return currentFrameIndex;}; - - /** - \returns the detector index - */ - virtual int getDetectorIndex() {return detIndex;}; - - /** - \returns the max frames per file - */ - virtual int getFramesPerFile() {return *framesPerFile;}; - - /** - \returns the max frames per file - */ - virtual fileFormat getFileFormat() {return *fileFormatType;}; - - - std::string createFileName(); - - std::string createReceiverFilePrefix(); - - - /** - writes a data file - \param fname of the file to be written - \param data array of data values - \param err array of arrors on the data. If NULL no errors will be written - \param ang array of angular values. If NULL data will be in the form chan-val(-err) otherwise ang-val(-err) - \param dataformat format of the data: can be 'i' integer or 'f' double (default) - \param nch number of channels to be written to file. if -1 defaults to the number of installed channels of the detector - \returns OK or FAIL if it could not write the file or data=NULL - */ - virtual int writeDataFile(std::string fname, double *data, double *err=NULL, double *ang=NULL, char dataformat='f', int nch=-1); - - - /** - - writes a data file - \param outfile output file stream - \param data array of data values - \param err array of arrors on the data. If NULL no errors will be written - - \param ang array of angular values. If NULL data will be in the form chan-val(-err) otherwise ang-val(-err) - \param dataformat format of the data: can be 'i' integer or 'f' double (default) - \param nch number of channels to be written to file. if -1 defaults to the number of installed channels of the detector - \param offset start channel number - \returns OK or FAIL if it could not write the file or data=NULL - - */ - virtual int writeDataFile(std::ofstream &outfile, double *data, double *err=NULL, double *ang=NULL, char dataformat='f', int nch=-1, int offset=0); - - - /** - writes a data file - \param fname of the file to be written - \param data array of data values - \returns OK or FAIL if it could not write the file or data=NULL - */ - virtual int writeDataFile(std::string fname, int *data); - - - virtual int writeDataFile(void *data, int iframe=-1); - - int closeDataFile(); - /** - writes a data file - \param outfile output file stream - \param data array of data values - \param offset start channel number - \returns OK or FAIL if it could not write the file or data=NULL - */ - virtual int writeDataFile(std::ofstream &outfile, int *data, int offset=0); - - - - /** - writes a data file of short ints - \param fname of the file to be written - \param data array of data values - \returns OK or FAIL if it could not write the file or data=NULL - */ - virtual int writeDataFile(std::string fname, short int *data); - - - - - - - - /** - writes a data file of short ints - \param outfile output file stream - \param data array of data values - \param offset start channel number - \returns OK or FAIL if it could not write the file or data=NULL - */ - virtual int writeDataFile(std::ofstream &outfile, short int *data, int offset=0); - - - /** - reads a data file - \param fname of the file to be read - \param data array of data values to be filled - \param err array of arrors on the data. If NULL no errors are expected on the file - - \param ang array of angular values. If NULL data are expected in the form chan-val(-err) otherwise ang-val(-err) - \param dataformat format of the data: can be 'i' integer or 'f' double (default) - \returns OK or FAIL if it could not read the file or data=NULL - */ - virtual int readDataFile(std::string fname, double *data, double *err=NULL, double *ang=NULL, char dataformat='f'); - - /** - reads a data file - \param ifstream input file stream - \param data array of data values to be filled - \param err array of arrors on the data. If NULL no errors are expected on the file - - \param ang array of angular values. If NULL data are expected in the form chan-val(-err) otherwise ang-val(-err) - \param offset start channel number to be expected - \returns OK or FAIL if it could not read the file or data=NULL - */ - int readDataFile(std::ifstream& infile, double *data, double *err=NULL, double *ang=NULL, char dataformat='f', int offset=0); - - /** - reads a raw data file - \param fname of the file to be read - \param data array of data values - \returns OK or FAIL if it could not read the file or data=NULL -yes */ - virtual int readDataFile(std::string fname, int *data); - -/** - reads a raw data file - \param infile input file stream - \param data array of data values - \param offset first channel number to be expected - \returns OK or FAIL if it could not read the file or data=NULL - */ - int readDataFile(std::ifstream &infile, int *data, int offset=0); - - /** - - reads a short int raw data file - \param fname of the file to be read - \param data array of data values - \returns OK or FAIL if it could not read the file or data=NULL - */ - virtual int readDataFile(std::string fname, short int *data); - /** - reads a short int raw data file - \param infile input file stream - \param data array of data values - \param offset first channel number to be expected - \returns OK or FAIL if it could not read the file or data=NULL - */ - int readDataFile(std::ifstream &infile, short int *data, int offset=0); - - virtual int getDataBytes ( )=0; - friend class slsDetector; - - std::string getCurrentFileName(){return currentFileName;}; - protected: - - - void incrementFileIndex() { (*fileIndex)++; }; - - void incrementFrameIndex(int i) { frameIndex=frameIndex+i; }; - - void incrementCurrentFrameIndex() { (currentFrameIndex)++; }; - - void incrementDetectorIndex() { (detIndex)++; }; - - - std::string getCurrentReceiverFilePrefix(){return currentReceiverFilePrefix;}; - - - std::string currentFileName; - - std::string currentReceiverFilePrefix; - - - /** output directory */ - char *filePath; - /** file root name */ - char *fileName; - /** file index */ - int *fileIndex; - /** file frame index */ - int frameIndex; - /** current frame index */ - int currentFrameIndex; - /** detector id */ - int detIndex; - /** frames per file */ - int *framesPerFile; - /** file format */ - fileFormat *fileFormatType; - - private: - - - FILE *filefd; - std::ofstream fstream; - - int nframes; - // int fformat; - - - int nBytes; - - /** mutex to synchronize read/write fname */ - pthread_mutex_t mf; -}; - -#endif diff --git a/slsDetectorSoftware/slsDetectorAnalysis/fileIOStatic.h b/slsDetectorSoftware/slsDetectorAnalysis/fileIOStatic.h deleted file mode 100644 index c76800791..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/fileIOStatic.h +++ /dev/null @@ -1,730 +0,0 @@ -#ifndef FILEIO_STATIC_H -#define FILEIO_STATIC_H - -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef __CINT -#define MYROOT -#endif - -using std::endl; -using std::cout; - -#include "sls_detector_defs.h" -// -/** - @short class handling the data file I/O flags -*/ - -class fileIOStatic { - - - - - public: - /** default constructor */ - fileIOStatic(){}; - /** virtual de`structor */ - virtual ~fileIOStatic(){}; - - - - - /** generates file name without extension - - always appends to file path and file name the run index. - - in case also appends the position index and the two level of scan varaibles with the specified precision - - Filenames will be of the form: filepath/(dz_)filename(_Sy_sw_px_fv)_i - where z is the detector index, y is the scan0 variable, W is the scan 1 variable, x is the position index, v is the frame index and i is the run index - \param filepath outdir - \param filename file root name - \param aMask action mask (scans, positions) - \param sv0 scan variable 0 - \param prec0 scan precision 0 - \param sv1 scan variable 1 - \param prec1 scan precision 1 - \param pindex position index - \param npos number of positions - \param findex file index - \param frameindex frame index - \param detindex detector id - \returns file name without extension - */ - static std::string createFileName(char *filepath, char *filename, int aMask, double sv0, int prec0, double sv1, int prec1, int pindex, int npos, int findex, int frameindex=-1, int detindex=-1){ \ - std::ostringstream osfn; \ - osfn << filepath << "/" << filename; \ - if ( aMask& (1 << (slsDetectorDefs::MAX_ACTIONS))) osfn << "_S" << std::fixed << std::setprecision(prec0) << sv0; \ - if (aMask & (1 << (slsDetectorDefs::MAX_ACTIONS+1))) osfn << "_s" << std::fixed << std::setprecision(prec1) << sv1; \ - if (pindex>0 && pindex<=npos) osfn << "_p" << pindex; \ - if(detindex>=0) osfn << "_d"<< detindex; \ - if(frameindex>=0) osfn << "_f" << frameindex; \ - osfn << "_" << findex; \ - return osfn.str(); \ - }; - - - /** generates file prefix for receivers without file path, frame index, file index or extension - - in case also appends the position index and the two level of scan varaibles with the specified precision - - File prefix will be of the form: (dz_)filename(_Sy_sw_px_) - where z is the detector index, y is the scan0 variable, W is the scan 1 variable and x is the position index - \param filename file root name - \param aMask action mask (scans, positions) - \param sv0 scan variable 0 - \param prec0 scan precision 0 - \param sv1 scan variable 1 - \param prec1 scan precision 1 - \param pindex position index - \param npos number of positions - \param detindex detector id - \returns file name without extension - */ - static std::string createReceiverFilePrefix(char *filename, int aMask, double sv0, int prec0, double sv1, int prec1, int pindex, int npos,int detindex=-1){ \ - std::ostringstream osfn; \ - osfn << filename; \ - if ( aMask& (1 << (slsDetectorDefs::MAX_ACTIONS))) osfn << "_S" << std::fixed << std::setprecision(prec0) << sv0; \ - if (aMask & (1 << (slsDetectorDefs::MAX_ACTIONS+1))) osfn << "_s" << std::fixed << std::setprecision(prec1) << sv1; \ - if (pindex>0 && pindex<=npos) osfn << "_p" << pindex; \ - if(detindex!=-1) osfn << "_d"<< detindex; \ - return osfn.str(); \ - }; - - - /** static function that returns the file index from the file name - \param fname file name - \returns file index - */ - static int getFileIndexFromFileName(std::string fname){ \ - int i; \ - size_t dot=fname.rfind("."); \ - if (dot==std::string::npos) \ - return -1; \ - size_t uscore=fname.rfind("_"); \ - if (uscore==std::string::npos) return -1; \ - if (sscanf( fname.substr(uscore+1,dot-uscore-1).c_str(),"%d",&i)) return i; \ - cout << "******************************** cannot parse file index" << endl; \ - return 0; \ - }; - - /** static function that returns the frame index and file index from the file name - \param fname file name - \param index reference to index - \returns frame index - */ - static int getIndicesFromFileName(std::string fname,int &index){ \ - int i; \ - std::string s; \ - size_t uscore=fname.rfind("_"); \ - if (uscore==std::string::npos) return -1; \ - s=fname; \ - if (sscanf(s.substr(uscore+1,s.size()-uscore-1).c_str(),"%d",&i)){ \ - index=i; \ - s=fname.substr(0,uscore); \ - } \ - /*else cout << "******************************** cannot parse file index" << endl; \*/ - uscore=s.rfind("_"); \ - if (sscanf( s.substr(uscore+1,s.size()-uscore-1).c_str(),"f%d",&i)){ \ - if(i==-1)return 0; \ - else return i; } \ - /*cout << "******************************** cannot parse frame index" << endl; \*/ - return 0; \ - }; - - - /** static function that returns the variables from the file name - \param fname file name - \param index reference to index - \param p_index reference to position index - \param sv0 reference to scan variable 0 - \param sv1 reference to scan variable 1 - \returns file index - */ - static int getVariablesFromFileName(std::string fname, int &index, int &p_index, double &sv0, double &sv1) { \ - int i; \ - double f; \ - std::string s; \ - index=-1; \ - p_index=-1; \ - sv0=-1; \ - sv1=-1; \ - size_t uscore=fname.rfind("_"); \ - if (uscore==std::string::npos) return -1; \ - s=fname; \ - if (sscanf(s.substr(uscore+1,s.size()-uscore-1).c_str(),"%d",&i)) { \ - index=i; \ - s=fname.substr(0,uscore); \ - } \ - /* else cout << "Warning: ******************************** cannot parse file index from " << s << endl; \*/ - uscore=s.rfind("_"); \ - if (sscanf( s.substr(uscore+1,s.size()-uscore-1).c_str(),"f%d",&i)) \ - s=fname.substr(0,uscore); \ - /*else cout << "Warning: ******************************** cannot parse frame index from " << s << endl; \*/ - uscore=s.rfind("_"); \ - if (sscanf( s.substr(uscore+1,s.size()-uscore-1).c_str(),"d%d",&i)) \ - s=fname.substr(0,uscore); \ - /* else cout << "Warning: ******************************** cannot parse detector index from " << s << endl; \*/ - uscore=s.rfind("_"); \ - if (sscanf( s.substr(uscore+1,s.size()-uscore-1).c_str(),"p%d",&i)) { \ - p_index=i; \ - s=fname.substr(0,uscore); \ - } \ - /* else cout << "Warning: ******************************** cannot parse position index from " << s << endl; \*/ - uscore=s.rfind("_"); \ - if (sscanf( s.substr(uscore+1,s.size()-uscore-1).c_str(),"s%lf",&f)) { \ - sv1=f; \ - s=fname.substr(0,uscore); \ - } \ - /* else cout << "Warning: ******************************** cannot parse scan varable 1 from " << s << endl; \*/ - uscore=s.rfind("_"); \ - if (sscanf( s.substr(uscore+1,s.size()-uscore-1).c_str(),"S%lf",&f)) { \ - sv0=f; \ - } \ - /* else cout << "Warning: ******************************** cannot parse scan varable 0 from " << s << endl; \*/ - return index; \ - }; - - - /** static function that returns the variables from the file name - \param fname file name - \param index reference to index - \param f_index reference to frame index - \param p_index reference to position index - \param sv0 reference to scan variable 0 - \param sv1 reference to scan variable 1 - \param detindex reference to detector id - \returns file index - */ - static int getVariablesFromFileName(std::string fname, int &index, int &f_index, int &p_index, double &sv0, double &sv1, int &detindex) { \ - int i; \ - double f; \ - std::string s; \ - index=-1; \ - p_index=-1; \ - sv0=-1; \ - sv1=-1; \ - size_t uscore=fname.rfind("_"); \ - if (uscore==std::string::npos) return -1; \ - s=fname; \ - if (sscanf(s.substr(uscore+1,s.size()-uscore-1).c_str(),"%d",&i)) { \ - index=i; \ - s=fname.substr(0,uscore); \ - } \ - /*else cout << "Warning: ******************************** cannot parse file index" << endl; \*/ - uscore=s.rfind("_"); \ - if (sscanf( s.substr(uscore+1,s.size()-uscore-1).c_str(),"f%d",&i)) { \ - f_index=i; \ - s=fname.substr(0,uscore); \ - } \ - /*else cout << "Warning: ******************************** cannot parse frame index" << endl; \*/ - uscore=s.rfind("_"); \ - if (sscanf( s.substr(uscore+1,s.size()-uscore-1).c_str(),"d%d",&i)) { \ - detindex=i; \ - s=fname.substr(0,uscore); \ - } \ - /* else cout << "Warning: ******************************** cannot parse detector id" << endl; \*/ - uscore=s.rfind("_"); \ - if (sscanf( s.substr(uscore+1,s.size()-uscore-1).c_str(),"p%d",&i)) { \ - p_index=i; \ - s=fname.substr(0,uscore); \ - } \ - /*else cout << "Warning: ******************************** cannot parse position index" << endl; \*/ - uscore=s.rfind("_"); \ - if (sscanf( s.substr(uscore+1,s.size()-uscore-1).c_str(),"s%lf",&f)) { \ - sv1=f; \ - s=fname.substr(0,uscore); \ - } \ - /*else cout << "Warning: ******************************** cannot parse scan varable 1" << endl; \*/ - uscore=s.rfind("_"); \ - if (sscanf( s.substr(uscore+1,s.size()-uscore-1).c_str(),"S%lf",&f)) { \ - sv0=f; \ - s=fname.substr(0,uscore); \ - } \ - /*else cout << "Warning: ******************************** cannot parse scan varable 0" << endl; \*/ - - return index; \ - }; - - - /** static function that verifies if the new file name containing new parameters matches all the given parameters - \param fname new complete file name prefix - \param index reference to index - \param f_index reference to frame index - \param p_index reference to position index - \param sv0 reference to scan variable 0 - \param sv1 reference to scan variable 1 - \param detindex reference to detector id - \returns file name - */ - static int verifySameFrame(std::string fname, int index, int f_index, int p_index, double sv0, double sv1, int detindex) { \ - int new_index=-1; - int new_f_index=-1; - int new_p_index=-1; - int new_det_index=-1; - double new_sv0=-1; - double new_sv1=-1; - getVariablesFromFileName(fname,new_index, new_f_index, new_p_index, new_sv0, new_sv1, new_det_index); - if(index!=new_index) return 0; - if(f_index!=new_f_index) return 0; - if(p_index!=new_p_index) return 0; - if(sv0!=new_sv0) return 0; - if(sv1!=new_sv1) return 0; - return 1; - } - - - /** static function that returns the name variable from the receiver complete file name prefix - \param fname complete file name prefix - \returns file name - */ - static std::string getNameFromReceiverFilePrefix(std::string fname) { \ - int i; \ - double f; \ - std::string s; \ - s=fname; \ - size_t uscore=s.rfind("_"); \ - if (sscanf( s.substr(uscore+1,s.size()-uscore-1).c_str(),"d%d",&i)) \ - s=fname.substr(0,uscore); \ - uscore=s.rfind("_"); \ - if (sscanf( s.substr(uscore+1,s.size()-uscore-1).c_str(),"p%d",&i)) \ - s=fname.substr(0,uscore); \ - uscore=s.rfind("_"); \ - if (sscanf( s.substr(uscore+1,s.size()-uscore-1).c_str(),"s%lf",&f)) \ - s=fname.substr(0,uscore); \ - uscore=s.rfind("_"); \ - if (sscanf( s.substr(uscore+1,s.size()-uscore-1).c_str(),"S%lf",&f)) \ - s=fname.substr(0,uscore); \ - - - return s; \ - }; - - - - - /** static function that returns the entire filename ithout file name prefix, detector index or extension - This will be concatenated with all the other detector file names for the gui - \param fname complete file name - \returns file name without file name prefix, detector index or extension - */ - static std::string getReceiverFileNameToConcatenate(std::string fname) { \ - int i;double f; \ - std::string s=fname; \ - if(fname.empty()) return fname; \ - size_t dot=s.find("."); - size_t uscore=s.rfind("_"); \ - - if (uscore==std::string::npos) return "??"; \ - if (sscanf(s.substr(uscore+1,s.size()-uscore-1).c_str(),"%d",&i)) \ - s=fname.substr(0,uscore); \ - uscore=s.rfind("_"); \ - if (sscanf( s.substr(uscore+1,s.size()-uscore-1).c_str(),"f%d",&i)) \ - s=fname.substr(0,uscore); \ - uscore=s.rfind("_"); \ - if (sscanf( s.substr(uscore+1,s.size()-uscore-1).c_str(),"d%d",&i)) \ - s=fname.substr(0,uscore); \ - uscore=s.rfind("_"); \ - if (sscanf( s.substr(uscore+1,s.size()-uscore-1).c_str(),"p%d",&i)) \ - s=fname.substr(0,uscore); \ - uscore=s.rfind("_"); \ - if (sscanf( s.substr(uscore+1,s.size()-uscore-1).c_str(),"s%lf",&f)) \ - s=fname.substr(0,uscore); \ - uscore=s.rfind("_"); \ - if (sscanf( s.substr(uscore+1,s.size()-uscore-1).c_str(),"S%lf",&f)) \ - s=fname.substr(0,uscore); \ - return(fname.substr(s.size(),dot-s.size()));\ - \ - }; - - - - - /** - - writes a data file - \param fname of the file to be written - \param nch number of channels to be written - \param data array of data values - \param err array of arrors on the data. If NULL no errors will be written - \param ang array of angular values. If NULL data will be in the form chan-val(-err) otherwise ang-val(-err) - \param dataformat format of the data: can be 'i' integer or 'f' double - \returns OK or FAIL if it could not write the file or data=NULL - - */ - - static int writeDataFile(std::string fname, int nch, double *data, double *err=NULL, double *ang=NULL, char dataformat='f'){ \ - std::ofstream outfile; \ - if (data==NULL) { \ - cout << "No data to write!" << endl; \ - return slsDetectorDefs::FAIL; \ - } \ - outfile.open (fname.c_str(),std::ios_base::out); \ - if (outfile.is_open()) { \ - writeDataFile(outfile, nch, data, err, ang, dataformat, 0); \ - outfile.close(); \ - return slsDetectorDefs::OK; \ - } else { \ - std::cout<< "Could not open file " << fname << "for writing"<< std::endl; \ - return slsDetectorDefs::FAIL; \ - } \ - }; - - - - - /** - writes a data file - \param outfile output file stream - \param nch number of channels to be written - \param data array of data values - \param err array of arrors on the data. If NULL no errors will be written - \param ang array of angular values. If NULL data will be in the form chan-val(-err) otherwise ang-val(-err) - \param dataformat format of the data: can be 'i' integer or 'f' double (default) - \param offset start channel number - \returns OK or FAIL if it could not write the file or data=NULL - */ - static int writeDataFile(std::ofstream &outfile, int nch, double *data, double *err=NULL, double *ang=NULL, char dataformat='f', int offset=0){ - int idata; \ - if (data==NULL || nch==0) { \ - cout << "No data to write!" << endl; \ - return slsDetectorDefs::FAIL; \ - } \ - for (int ichan=0; ichan> ichan >> fdata; \ - if (ssstr.fail() || ssstr.bad()) { \ - interrupt=1; \ - break; \ - } \ - ich=iline; \ - if (ichan> fang >> fdata; \ - ich=iline; \ - } \ - if (ssstr.fail() || ssstr.bad()) { \ - interrupt=1; \ - break; \ - } \ - if (err) \ - ssstr >> ferr; \ - if (ssstr.fail() || ssstr.bad()) { \ - interrupt=1; \ - break; \ - } \ - if (ich=nch) { \ - interrupt=1; \ - break; \ - } \ - } \ - return iline; \ - }; - - - /** - reads a raw data file - \param fname of the file to be read - \param data array of data values - \param nch number of channels - \returns OK or FAIL if it could not read the file or data=NULL - */ - static int readDataFile(std::string fname, int *data, int nch) { \ - std::ifstream infile; \ - int iline=0; \ - std::string str; \ - infile.open(fname.c_str(), std::ios_base::in); \ - if (infile.is_open()) { \ - iline=readDataFile(infile, data, nch, 0); \ - infile.close(); \ - } else { \ - std::cout<< "Could not read file " << fname << std::endl; \ - return -1; \ - } \ - return iline; \ - }; - - - /** - reads a raw data file - \param infile input file stream - \param data array of data values - \param nch number of channels - \param offset start channel value - \returns OK or FAIL if it could not read the file or data=NULL - */ - static int readDataFile(std::ifstream &infile, int *data, int nch, int offset) { \ - int ichan, idata, iline=0; \ - int interrupt=0; \ - std::string str; \ - while (infile.good() and interrupt==0) { \ - getline(infile,str); \ - std::istringstream ssstr(str); \ - ssstr >> ichan >> idata; \ - if (ssstr.fail() || ssstr.bad()) { \ - interrupt=1; \ - break; \ - } \ - if (iline=offset) { \ - data[iline]=idata; \ - iline++; \ - } \ - } else { \ - interrupt=1; \ - break; \ - } \ - } \ - return iline; \ - }; - - /** - reads a short int rawdata file - \param name of the file to be read - \param data array of data values - \param nch number of channels - \returns OK or FAIL if it could not read the file or data=NULL - */ - static int readDataFile(std::string fname, short int *data, int nch){ \ - std::ifstream infile; \ - int iline=0; \ - std::string str; \ - infile.open(fname.c_str(), std::ios_base::in); \ - if (infile.is_open()) { \ - iline=readDataFile(infile, data, nch, 0); \ - infile.close(); \ - } else { \ - std::cout<< "Could not read file " << fname << std::endl; \ - return -1; \ - } \ - return iline; \ - }; - - /** - reads a short int raw data file - \param infile input file stream - \param data array of data values - \param nch number of channels - \param offset start channel value - \returns OK or FAIL if it could not read the file or data=NULL - */ - static int readDataFile(std::ifstream &infile, short int *data, int nch, int offset) { \ - int ichan, iline=0; \ - short int idata; \ - int interrupt=0; \ - std::string str; \ - while (infile.good() and interrupt==0) { \ - getline(infile,str); \ - std::istringstream ssstr(str); \ - ssstr >> ichan >> idata; \ - if (ssstr.fail() || ssstr.bad()) { \ - interrupt=1; \ - break; \ - } \ - if (iline=offset) { \ - data[iline]=idata; \ - iline++; \ - } \ - } else { \ - interrupt=1; \ - break; \ - } \ - return iline; \ - }; \ - return iline; \ - }; -}; - -#endif diff --git a/slsDetectorSoftware/slsDetectorAnalysis/movingStat.h b/slsDetectorSoftware/slsDetectorAnalysis/movingStat.h deleted file mode 100644 index f81fab696..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/movingStat.h +++ /dev/null @@ -1,147 +0,0 @@ - /********************************************//** - * @file movingStat.h - * @short handles pedestal data and moves accordingly - ***********************************************/ -#ifndef MOVINGSTAT_H -#define MOVINGSTAT_H - -//#include "sls_detector_defs.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include - -; - - -typedef double double32_t; -typedef float float32_t; -typedef int int32_t; - - -/** - @short class handling pedestal data and moves according to data - */ - -class movingStat{ - -public: - /** - * Constructor - */ - movingStat() : n(0), m_n(0), m_oldM(0), m_newM(0), m_oldM2(0), m_newM2(0){} - - /** - * Clear number of data values - */ - inline void Clear(){ - m_n = 0; - } - - /** - * Set Pedestal - */ - inline void SetN(int i) {n=i;}; - - /** - * Get Pedestal - */ - inline int GetN() {return n;}; - - /** - * Calculate Pedestal - */ - inline void Calc(double x) { - if (m_n 0) ? m_newM/m_n : 0.0; - } - - /** - * Get mean 2 - */ - inline double M2() const{ - return ( (m_n > 1) ? m_newM2/m_n : 0.0 ); - } - - /** - * Get variance - */ - inline double Variance() const{ - return ( (m_n > 1) ? (M2()-Mean()*Mean()) : 0.0 ); - } - - /** - * Get standard deviation - */ - inline double StandardDeviation() const{ - return ( (Variance() > 0) ? sqrt( Variance() ) : -1 ); - } - -private: - /** pedestal */ - int n; - /** number of data values */ - int m_n; - - /** old and new mean */ - double m_oldM, m_newM, m_oldM2, m_newM2; -}; - - -#endif diff --git a/slsDetectorSoftware/slsDetectorAnalysis/postProcessing.cpp b/slsDetectorSoftware/slsDetectorAnalysis/postProcessing.cpp index 86f9faaf8..0575e88da 100644 --- a/slsDetectorSoftware/slsDetectorAnalysis/postProcessing.cpp +++ b/slsDetectorSoftware/slsDetectorAnalysis/postProcessing.cpp @@ -1,15 +1,7 @@ #include "postProcessing.h" -#include "postProcessingFuncs.h" -#include "angleConversionConstant.h" -#ifdef VERBOSE -#include "usersFunctions.h" -#elif EXTPP -#include "usersFunctions.h" -#endif + #include -using namespace std; -//#define VERBOSE static void* startProcessData(void *n){ postProcessing *myDet=(postProcessing*)n; @@ -38,7 +30,15 @@ int postProcessing::kbhit(){ } -postProcessing::postProcessing(): expTime(NULL), badChannelMask(NULL), ang(NULL), val(NULL), err(NULL), numberOfChannels(0) { +postProcessing::postProcessing(): + threadedProcessing(0), + jointhread(0), + acquiringDone(0), + fdata(0), + thisData(0), + dataReady(0), + pCallbackArg(0) + { pthread_mutex_t mp1 = PTHREAD_MUTEX_INITIALIZER; mp=mp1; pthread_mutex_init(&mp, NULL); @@ -47,23 +47,6 @@ postProcessing::postProcessing(): expTime(NULL), badChannelMask(NULL), ang(NULL) ms=mp1; pthread_mutex_init(&ms, NULL); - //cout << "reg callback "<< endl; - dataReady = 0; - pCallbackArg = 0; - //cout << "done "<< endl; - rawDataReady = 0; - pRawDataArg = 0; - - - //#ifdef VERBOSE - // registerDataCallback(&defaultDataReadyFunc, NULL); - //#endif -#ifdef EXTPP - registerRawDataCallback(&defaultRawDataReadyFunc, NULL); -#endif - - ppFun=new postProcessingFuncs(); - } @@ -71,436 +54,12 @@ postProcessing::postProcessing(): expTime(NULL), badChannelMask(NULL), ang(NULL) postProcessing::~postProcessing(){ - delete ppFun; -}; - - - - - - - - -void postProcessing::processFrame(int *myData, int delflag, int jctb) { - - string fname; - int nn; - //double *fdata=NULL; - -#ifdef VERBOSE - cout << "start processing"<< endl; -#endif - - incrementProgress(); - -#ifdef VERBOSE - cout << "prog incremented"<< endl; -#endif - - /** decode data */ - - // cout << "decode 0"<< endl; - // if (getDetectorsType()==MYTHEN) { - - - // for (int ib=0; ib<1000; ib++) - // cout << ((*(((u_int64_t*)myData)+ib))>>17&1) ; - // cout << endl; - - - fdata=decodeData(myData,nn, fdata); - - //#ifdef VERBOSE - // cout << "decode 1"<< endl; - //#endif - // } else - // fdata=NULL; - if (rawDataReady) { -#ifdef VERBOSE - cout << "decoded data size is "<=0){ - if (getDetectorsType()==MYTHEN) - incrementFrameIndex(1); - else if((currentFrameIndex%getFramesPerFile())==0) - incrementFrameIndex(getFramesPerFile()); - } - - - - - if (fdata) - delete [] fdata; - fdata=NULL; - - - // if (jctb==0) { - delete [] myData; - myData=NULL; - -#ifdef VERBOSE - cout << "Pop data queue " << *fileIndex << endl; -#endif - - popDataQueue(); //remove the data from the queue - -#ifdef VERBOSE - cout << "Data queue popped" << endl; -#endif - - -#ifdef VERBOSE - cout << "process frame returning " << endl; -#endif - // } - } - - -void postProcessing::doProcessing(double *lfdata, int delflag, string fname) { - - #ifdef VERBOSE - cout << "??????????????????????????????????????????? do processing - data size is " << arraySize << endl; - #endif - - - int np; - -#ifdef VERBOSE - cout << "arrays allocated " << endl; -#endif - int npos=getNumberOfPositions(); - - string ext=".dat"; - -#ifdef VERBOSE - cout << "npos is "<< npos << endl; -#endif - - double t=0; - - if (expTime) - t=(*expTime)*1E-9; - else - cout << "no pointer to exptime" << endl; -#ifdef VERBOSE - cout << "exptime is "<< t << endl; -#endif - - if (GetCurrentPositionIndex()<=1 || npos<2) { -#ifdef VERBOSE - cout << "init dataset" << endl; -#endif - - - if (*correctionMask&(1<< ANGULAR_CONVERSION)) - ang=new double[arraySize]; - else - ang=NULL; - - val=new double[arraySize]; - err=new double[arraySize]; - - initDataset(0); - } - -#ifdef VERBOSE - cout << "add frame" << endl; -#endif - - /**ot them -start processing -prog incremented -decode -fname is //run_f0_0 -??????????????????????????????????????????? do processing - data size is 30720 -arrays allocated -npos is 0 -exptime is 10.00 -init dataset -add frame -data queue size lock -data queue size unlock - **/ - - addFrame(lfdata,currentPosition, currentI0, t, fname, 0); - // cout << "++++++++++++++++++++" << GetCurrentPositionIndex() << " " << npos << " " << positionFinished() << " " << dataQueueSize() << endl; - if ((GetCurrentPositionIndex()>=npos && dataQueueSize()) || npos<2) { - //&& - - while(positionFinished()==0 && npos>1) { - ; - } -#ifdef VERBOSE - cout << "finalize dataset" << endl; -#endif - - finalizeDataset(ang, val, err, np); - //if (npos<2) { - IncrementPositionIndex(); - - pthread_mutex_lock(&mp); - fname=createFileName(); - pthread_mutex_unlock(&mp); - //} - - if((*correctionMask)&(1<0) { - - int *badChansList=new int[nbad]; - #ifdef VERBOSE - cout << "get badch array " << nbad << endl; - #endif - getBadChannelCorrection(badChansList); - #ifdef VERBOSE - cout << "done " << nbad << endl; - #endif - - if (badChannelMask) - delete [] badChannelMask; - - -#ifdef VERBOSE - cout << " nchans " << getTotalNumberOfChannels() << endl; -#endif - - badChannelMask=new int[getTotalNumberOfChannels()]; - -#ifdef VERBOSE - cout << " pointer to bad channel mask is " << badChannelMask << endl; -#endif - for (int ichan=0; ichan=0 ) { - if (badChannelMask[badChansList[ichan]]==0) { - badChannelMask[badChansList[ichan]]=1; - // cout << "bad: " << ichan << " " << badChansList[ichan] << endl; - } else - nbad--; - } - } - delete [] badChansList; - - } else { - if (badChannelMask) { -#ifdef VERBOSE - cout << "deleting bad channel mask beacuse number of bad channels is 0" << endl; -#endif - - delete [] badChannelMask; - badChannelMask=NULL; - } - } - - } else { -#ifdef VERBOSE - cout << "bad channel correction is disabled " << nbad << endl; -#endif - if (badChannelMask) { -#ifdef VERBOSE - cout << "deleting bad channel mask beacuse no bad channel correction is selected" << endl; -#endif - delete [] badChannelMask; - badChannelMask=NULL; - } - } - -#ifdef VERBOSE - cout << "number of bad channels is " << nbad << endl; -#endif - return nbad; - -} - - - - - - void* postProcessing::processData(int delflag) { if(setReceiverOnline()==OFFLINE_FLAG){ - -#ifdef VERBOSE - std::cout<< " ??????????????????????????????????????????? processing data - threaded mode " << *threadedProcessing << endl; -#endif - - - - - queuesize=dataQueueSize(); - - - int *myData; - int dum=1; -// int nf=1, ii, nch; -// int jctb=0; - - -// if (getDetectorsType()==JUNGFRAUCTB) { -// nch=getTotalNumberOfChannels(); -// nf= getDataBytes()/(nch*2); -// cout << "WILL PROCESS " << nf << "SAMPLES AND " << nch <<"CHANNELS PER FRAME!" << endl; -// jctb=1; -// }// else -// // cout << "NOOT A JCTB" << endl; - - fdata=NULL; - - while(dum | *threadedProcessing) { // ???????????????????????? - /* IF THERE ARE DATA PROCESS THEM*/ - // cout << "loop" << endl; - while((queuesize=dataQueueSize())>0) { - /** Pop data queue */ - #ifdef VERBOSE - cout << "data found"<< endl<r_conversion; - angOff[im]=p->offset; - angCenter[im]=p->center; - -#ifdef VERBOSE - cout << im << " " << angCenter[im] << " " << angRad[im] << " " << angOff[im] << endl; -#endif - - - } - sx=getAngularConversionParameter(SAMPLE_X); - sy=getAngularConversionParameter(SAMPLE_Y); - - } - - -#ifdef VERBOSE - cout << "init dataset" << endl; -#endif - // cout << "pp bad channel mask " << badChannelMask << endl; - fillBadChannelMask(); - // cout << "pp bad channel mask " << badChannelMask << endl; - - //cout << "EEEEEEEEEEEEEEEEEEEE init dataset " << endl; - ppFun->initDataset(&nmod,chPM,mM,badChannelMask, ffcoeff, fferr, &tdead, &angdir, angRad, angOff, angCenter, &to, &bs, &sx, &sy); - -#ifdef VERBOSE - cout << "done" << endl; -#endif - - delete [] chPM; - delete [] mM; - if (ffcoeff != NULL) delete [] ffcoeff; - if (fferr != NULL) delete [] fferr; - if (angRad != NULL) delete [] angRad; - if (angOff != NULL) delete [] angOff; - if (angCenter != NULL) delete [] angCenter; - - - if (*correctionMask&(1<< ANGULAR_CONVERSION)) { - arraySize=getNumberOfAngularBins(); - if (arraySize<=0) - arraySize=totch; - } else { - arraySize=totch; - } - - numberOfChannels=totch; - - queuesize=dataQueueSize(); - - // resetFinalDataQueue(); - resetDataQueue(); - - - } else { - - // cout << "EEEEEEEEEEEEEEEEEEEE init dataset XXXX " << endl; - - ppFun->initDataset(); - - - } - -} - - - - - - -void postProcessing::addFrame(double *data, double pos, double i0, double t, string fname, double var) { - // cout << "EEEEEEEEEEEEEEEEEEEE add frame " << pos << " " << i0 << endl; - - if (*correctionMask&(1<< I0_NORMALIZATION)) - ppFun->addFrame(data, &pos, &i0, &t, fname.c_str(), &var); - else - ppFun->addFrame(data, &pos,NULL, &t, fname.c_str(), &var); - - - -} - -void postProcessing::finalizeDataset(double *a, double *v, double *e, int &np) { - - // cout << "EEEEEEEEEEEEEEEEEEEE finalize dataset " << endl; - ppFun->finalizeDataset(a, v, e, &np); - -} - - - - - - - - - - - - - - - void postProcessing::startThread(int delflag) { - /////////////////////////////////// Initialize dataset - - //resetDataQueue(); setTotalProgress(); - initDataset(1); - - /////////////////////////////////// Start thread //////////////////////////////////////////////////////// #ifdef VERBOSE - cout << "start thread stuff" << endl; + std::cout << "start thread stuff" << std::endl; #endif pthread_attr_t tattr; @@ -873,15 +162,8 @@ void postProcessing::startThread(int delflag) { pthread_attr_init(&tattr); pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_JOINABLE); - - - // param.sched_priority = 5; - // scheduling parameters of main thread ret = pthread_setschedparam(pthread_self(), policy, &mparam); - //#ifdef VERBOSE - // printf("current priority is %d\n",param.sched_priority); - //#endif if (delflag) ret = pthread_create(&dataProcessingThread, &tattr,startProcessData, (void*)this); else diff --git a/slsDetectorSoftware/slsDetectorAnalysis/postProcessing.h b/slsDetectorSoftware/slsDetectorAnalysis/postProcessing.h index 7903688dd..00de291cd 100644 --- a/slsDetectorSoftware/slsDetectorAnalysis/postProcessing.h +++ b/slsDetectorSoftware/slsDetectorAnalysis/postProcessing.h @@ -4,9 +4,6 @@ #include "detectorData.h" #include "slsDetectorBase.h" -#include "angularConversion.h" -#include "badChannelCorrections.h" -#include "fileIO.h" #include #include @@ -18,368 +15,89 @@ #include #include -class postProcessingFuncs; - - -// - -#define MAX_BADCHANS 20000 - - -#define defaultTDead {170,90,750} /**< should be changed in order to have it separate for the different detector types */ /** @short methods for data postprocessing - (including thread for writing data files and plotting in parallel with the acquisition) */ -class postProcessing : public angularConversion, public fileIO, public badChannelCorrections { +class postProcessing: public virtual slsDetectorBase { -//public virtual angularConversion, public virtual fileIO { - - public: - postProcessing(); - virtual ~postProcessing(); +public: + postProcessing(); + virtual ~postProcessing(); - - - /** - get bad channels correction - \param bad pointer to array that if bad!=NULL will be filled with the bad channel list - \returns 0 if bad channel disabled or no bad channels, >0 otherwise - */ - virtual int getBadChannelCorrection(int *bad=NULL)=0; - - - /** - get flat field corrections - \param corr if !=NULL will be filled with the correction coefficients - \param ecorr if !=NULL will be filled with the correction coefficients errors - \returns 0 if ff correction disabled, >0 otherwise - */ - virtual int getFlatFieldCorrection(double *corr=NULL, double *ecorr=NULL)=0; - - /** - set flat field corrections - \param corr if !=NULL the flat field corrections will be filled with corr (NULL usets ff corrections) - \param ecorr if !=NULL the flat field correction errors will be filled with ecorr (1 otherwise) - \returns 0 if ff correction disabled, >0 otherwise - */ - virtual int setFlatFieldCorrection(double *corr, double *ecorr=NULL)=0; - - /** - set bad channels correction - \param fname file with bad channel list ("" disable) - \returns 0 if bad channel disabled, >0 otherwise - */ - virtual int setBadChannelCorrection(std::string fname="")=0; - - - /** - set bad channels correction - \param fname file with bad channel list ("" disable) - \param nbad reference to number of bad channels - \param badlist array of badchannels - \returns 0 if bad channel disabled, >0 otherwise - */ - virtual int setBadChannelCorrection(std::string fname, int &nbad, int *badlist, int off=0)=0; - using badChannelCorrections::setBadChannelCorrection; - - /** - set bad channels correction - \param nch number of bad channels - \param chs array of channels - \param ff 0 if normal bad channels, 1 if ff bad channels - \returns 0 if bad channel disabled, >0 otherwise - */ - virtual int setBadChannelCorrection(int nch, int *chs, int ff=0)=0; - - - - int enableWriteToFileMask(int i=-1) {if (i>0) ((*correctionMask)|=(1<>WRITE_FILE) ;}; - - int enableOverwriteMask(int i=-1) {if (i>0) ((*correctionMask)|=(1<>OVERWRITE_FILE) ;}; - - int setAngularCorrectionMask(int i=-1){if (i==0) (*correctionMask)&=~(1<< ANGULAR_CONVERSION); if (i>0) (*correctionMask)|=(1<< ANGULAR_CONVERSION); return (((*correctionMask)&(1<< ANGULAR_CONVERSION))>>ANGULAR_CONVERSION);}; - - - - int enableAngularConversion(int i=-1) {if (i>0) return setAngularConversionFile("default"); if (i==0) return setAngularConversionFile(""); return setAngularCorrectionMask();}; - - - int enableBadChannelCorrection(int i=-1) {if (i>0) return setBadChannelCorrection("default"); if (i==0) return setBadChannelCorrection(""); return (((*correctionMask)&(1<< DISCARD_BAD_CHANNELS))>>DISCARD_BAD_CHANNELS);}; - - - - - /** returns the bad channel list file */ - std::string getBadChannelCorrectionFile() {if ((*correctionMask)&(1<< DISCARD_BAD_CHANNELS)) return std::string(badChanFile); else return std::string("none");}; - - - /** - get flat field corrections file directory - \returns flat field correction file directory - */ - std::string getFlatFieldCorrectionDir(){return std::string(flatFieldDir);}; - /** - set flat field corrections file directory - \param flat field correction file directory - \returns flat field correction file directory - */ - std::string setFlatFieldCorrectionDir(std::string dir){strcpy(flatFieldDir,dir.c_str()); return std::string(flatFieldDir);}; - - /** - get flat field corrections file name - \returns flat field correction file name - */ - std::string getFlatFieldCorrectionFile(){ if ((*correctionMask)&(1<=0) *threadedProcessing=b; return *threadedProcessing;}; + int setThreadedProcessing(int b=-1) {if (b>=0) *threadedProcessing=b; return *threadedProcessing;}; - - - - /** processes the data + /** processes the data \param delflag 0 leaves the data in the final data queue \returns nothing - - */ - void *processData(int delflag); + */ + void *processData(int delflag); - /** processes the data - \param delflag 0 leaves the data in the final data queue - \returns nothing - - */ - void processFrame(int* myData, int delflag, int jctb=0); + int checkJoinThread(); + void setJoinThread(int v); - /** processes the data - \param delflag 0 leaves the data in the final data queue - \returns nothing - - */ - void doProcessing(double* myData, int delflag, std::string fname); + void registerDataCallback(int( *userCallback)(detectorData*, int, int, void*), void *pArg) { \ + dataReady = userCallback; \ + pCallbackArg = pArg; \ + if (setReceiverOnline() == slsDetectorDefs::ONLINE_FLAG) { \ + enableDataStreamingToClient(1); \ + enableDataStreamingFromReceiver(1);}}; \ - /** - pops the data from the data queue - \returns pointer to the popped data or NULL if the queue is empty. - \sa dataQueue - */ - int* popDataQueue(); - int* dataQueueFront(); - int dataQueueSize(); -/* /\** */ -/* pops the data from thepostprocessed data queue */ -/* \returns pointer to the popped data or NULL if the queue is empty. */ -/* \sa finalDataQueue */ -/* *\/ */ -/* detectorData* popFinalDataQueue(); */ +protected: + /** + start data processing thread + */ + void startThread(int delflag=1); - int checkJoinThread(); - void setJoinThread(int v); + /** mutex to synchronize main and data processing threads */ + pthread_mutex_t mp; + /** mutex to synchronizedata processing and plotting threads */ + pthread_mutex_t mg; - /** - resets the raw data queue - \sa dataQueue - */ - void resetDataQueue(); + /** mutex to synchronize slsdetector threads */ + pthread_mutex_t ms; -/* /\** */ -/* resets the postprocessed data queue */ -/* \sa finalDataQueue */ -/* *\/ */ -/* void resetFinalDataQueue(); */ + int *threadedProcessing; + /** sets when the acquisition is finished */ + int jointhread; + /** set when detector finishes acquiring */ + int acquiringDone; + /** the data processing thread */ - int fillBadChannelMask(); - + pthread_t dataProcessingThread; + double *fdata; + detectorData *thisData; + int (*dataReady)(detectorData*,int, int, void*); + void *pCallbackArg; - virtual int rateCorrect(double*, double*, double*, double*)=0; - virtual int flatFieldCorrect(double*, double*, double*, double*)=0; - - - virtual int fillModuleMask(int *mM)=0; - - virtual int getNMods()=0; - - - - int GetCurrentPositionIndex(){ pthread_mutex_lock(&mp); int retval=getCurrentPositionIndex(); pthread_mutex_unlock(&mp); return retval;}; - void IncrementPositionIndex(){ pthread_mutex_lock(&mp); incrementPositionIndex(); pthread_mutex_unlock(&mp);}; - - void IncrementFileIndex(){ pthread_mutex_lock(&mp); incrementFileIndex(); pthread_mutex_unlock(&mp); }; - int GetFileIndex(){ pthread_mutex_lock(&mp); int i=*fileIndex; pthread_mutex_unlock(&mp); return i;}; - - void ResetPositionIndex(){pthread_mutex_lock(&mp); resetPositionIndex(); pthread_mutex_unlock(&mp);}; - - - void registerDataCallback(int( *userCallback)(detectorData*, int, int, void*), void *pArg) { \ - dataReady = userCallback; \ - pCallbackArg = pArg; \ - if (setReceiverOnline() == slsDetectorDefs::ONLINE_FLAG) { \ - enableDataStreamingToClient(1); \ - enableDataStreamingFromReceiver(1);}}; \ - - - void registerRawDataCallback(int( *userCallback)(double*, int, void*), void *pArg) {rawDataReady = userCallback; pRawDataArg = pArg;}; - - virtual double getRateCorrectionTau()=0; - - - int positionFinished(int v=-1){pthread_mutex_lock(&mp); if (v>=0) posfinished=v; int retval=posfinished; pthread_mutex_unlock(&mp); return retval;}; - - double getCurrentPosition() {double p; pthread_mutex_lock(&mp); p=currentPosition; pthread_mutex_unlock(&mp); return p;}; - double setCurrentPosition(double v) { pthread_mutex_lock(&mp); currentPosition=v; pthread_mutex_unlock(&mp); return currentPosition;}; - - - - - void initDataset(int refresh); - void addFrame(double *data, double pos, double i0, double t, std::string fname, double var); - void finalizeDataset(double *a, double *v, double *e, int &np); - - virtual detectorType getDetectorsType(int pos=-1)=0; - - protected: - - int *threadedProcessing; - - int *correctionMask; - - char *flatFieldDir; - char *flatFieldFile; - - int64_t *expTime; - - /** mutex to synchronize main and data processing threads */ - pthread_mutex_t mp; - - - /** mutex to synchronizedata processing and plotting threads */ - pthread_mutex_t mg; - - /** mutex to synchronize slsdetector threads */ - pthread_mutex_t ms; - - /** sets when the acquisition is finished */ - int jointhread; - - /** sets when the position is finished */ - int posfinished; - - /** - data queue - */ - std::queue dataQueue; - /** - queue containing the postprocessed data - */ - std::queue finalDataQueue; - - /** data queue size */ - int queuesize; - - /** queue mutex */ - sem_t sem_queue; - /** set when detector finishes acquiring */ - int acquiringDone; - - - /** - start data processing thread - */ - void startThread(int delflag=1); // - /** the data processing thread */ - - pthread_t dataProcessingThread; - - - - /** pointer to bad channel mask 0 is channel is good 1 if it is bad \sa fillBadChannelMask() */ - int *badChannelMask; - - - - - /** - I0 measured - */ - double currentI0; - - - int arraySize; - - - - double *fdata; - int (*dataReady)(detectorData*,int, int, void*); - void *pCallbackArg; - detectorData *thisData; - - private: - int kbhit(void); - - // double *fdata; - // int (*dataReady)(detectorData*,int, int,void*); - // void *pCallbackArg; - - int (*rawDataReady)(double*,int,void*); - void *pRawDataArg; - - - postProcessingFuncs *ppFun; - //detectorData *thisData; - - - double *ang; - double *val; - double *err; - - int numberOfChannels; +private: + int kbhit(void); }; -/* static void* startProcessData(void *n){\ */ -/* postProcessing *myDet=(postProcessing*)n;\ */ -/* myDet->processData(1);\ */ -/* pthread_exit(NULL);\ */ - -/* }; */ - -/* static void* startProcessDataNoDelete(void *n){\ */ -/* postProcessing *myDet=(postProcessing*)n;\ */ -/* myDet->processData(0);\ */ -/* pthread_exit(NULL);\ */ - -/* }; */ - - - - #endif diff --git a/slsDetectorSoftware/slsDetectorAnalysis/postProcessingFileIO_Standalone.cpp b/slsDetectorSoftware/slsDetectorAnalysis/postProcessingFileIO_Standalone.cpp deleted file mode 100644 index 275003a6c..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/postProcessingFileIO_Standalone.cpp +++ /dev/null @@ -1,602 +0,0 @@ -#include "postProcessingFileIO_Standalone.h" -#include "usersFunctions.h" -//#include "externPostProcessing.h" - -postProcessing::postProcessing(){ - - pthread_mutex_t mp1 = PTHREAD_MUTEX_INITIALIZER; - mp=mp1; - pthread_mutex_init(&mp, NULL); - mg=mp1; - pthread_mutex_init(&mg, NULL); - //cout << "reg callback "<< endl; - dataReady = 0; - pCallbackArg = 0; - registerDataCallback(&defaultDataReadyFunc, NULL); - //cout << "done "<< endl; - angConv=new angularConversion(numberOfPositions,detPositions,binSize, fineOffset, globalOffset); - IOfile= new fileIO(); - - //registerCallBackGetChansPerMod(&getChannelPerMod,this); - registerCallBackGetNumberofChannel(&defaultGetTotalNumberofChannels,this); - //registerAngularConversionCallback(&defaultAngularConversion,this); -} - - - - - - -int postProcessing::flatFieldCorrect(double datain, double errin, double &dataout, double &errout, double ffcoefficient, double fferr){ - double e; - - dataout=datain*ffcoefficient; - - if (errin==0 && datain>=0) - e=sqrt(datain); - else - e=errin; - - if (dataout>0) - errout=sqrt(e*ffcoefficient*e*ffcoefficient+datain*fferr*datain*fferr); - else - errout=1.0; - - return 0; -}; - - - int postProcessing::rateCorrect(double datain, double errin, double &dataout, double &errout, double tau, double t){ - - // double data; - double e; - - dataout=(datain*exp(tau*datain/t)); - - if (errin==0 && datain>=0) - e=sqrt(datain); - else - e=errin; - - if (dataout>0) - errout=e*dataout*sqrt((1/(datain*datain)+tau*tau/(t*t))); - else - errout=1.; - return 0; - -}; - - - - - -int postProcessing::setBadChannelCorrection(ifstream &infile, int &nbad, int *badlist, int moff){ - - int interrupt=0; - int ich; - int chmin,chmax; - string str; - - - - nbad=0; - while (infile.good() and interrupt==0) { - getline(infile,str); -#ifdef VERBOSE - std::cout << str << std::endl; -#endif - istringstream ssstr; - ssstr.str(str); - if (ssstr.bad() || ssstr.fail() || infile.eof()) { - interrupt=1; - break; - } - if (str.find('-')!=string::npos) { - ssstr >> chmin ; - ssstr.str(str.substr(str.find('-')+1,str.size())); - ssstr >> chmax; -#ifdef VERBOSE - std::cout << "channels between"<< chmin << " and " << chmax << std::endl; -#endif - for (ich=chmin; ich<=chmax; ich++) { - if (nbad> ich; -#ifdef VERBOSE - std::cout << "channel "<< ich << std::endl; -#endif - if (nbadcreateFileName(getActionMask(),getCurrentScanVariable(0),getScanPrecision(0),getCurrentScanVariable(1),getScanPrecision(1),getCurrentPositionIndex(),getNumberOfPositions()); - -//Checking for write flag - if(*correctionMask&(1<writeDataFile (fname+string(".raw"),fdata, NULL, NULL, 'i'); - - } - - doProcessing(fdata,delflag, fname); - - delete [] myData; - myData=NULL; - fdata=NULL; - -#ifdef VERBOSE - cout << "Pop data queue " << *fileIndex << endl; -#endif - - pthread_mutex_lock(&mp); - dataQueue.pop(); //remove the data from the queue - queuesize=dataQueue.size(); - pthread_mutex_unlock(&mp); - - -} - - - - -void postProcessing::doProcessing(double *lfdata, int delflag, string fname) { - - -// /** write raw data file */ -// if (*correctionMask==0 && delflag==1) { -// // delete [] fdata; -// ; -// } else { - - - - double *rcdata=NULL, *rcerr=NULL; - double *ffcdata=NULL, *ffcerr=NULL; - double *ang=NULL; - // int imod; - int np; - //string fname; - detectorData *thisData; - - - string ext=".dat"; - // fname=createFileName(); - - /** rate correction */ - if (*correctionMask&(1<writeDataFile (fname+ext, ffcdata, ffcerr,ang);} - } - - if (*correctionMask&(1<< ANGULAR_CONVERSION) && getNumberOfPositions()>0) { -#ifdef VERBOSE - cout << "**************Current position index is " << getCurrentPositionIndex() << endl; -#endif - // if (*numberOfPositions>0) {setTotalNumberOfChannels - if (getCurrentPositionIndex()<=1) { - -#ifdef VERBOSE - cout << "reset merging " << endl; -#endif - angConv->resetMerging(); - } - -#ifdef VERBOSE - cout << "add to merging "<< getCurrentPositionIndex() << endl; -#endif - - angConv->addToMerging(ang, ffcdata, ffcerr, badChannelMask ); - -#ifdef VERBOSE - cout << getCurrentPositionIndex() << " " << getNumberOfPositions() << endl; - -#endif - - - // cout << "lock 1" << endl; - pthread_mutex_lock(&mp); - if ((getCurrentPositionIndex()>=getNumberOfPositions() && posfinished==1 && queuesize==1)) { - -#ifdef VERBOSE - cout << "finalize merging " << getCurrentPositionIndex()<< endl; -#endif - np=angConv->finalizeMerging(); - /** file writing */ - angConv->incrementPositionIndex(); - // cout << "unlock 1" << endl; - pthread_mutex_unlock(&mp); - - - fname=IOfile->createFileName(getActionMask(),getCurrentScanVariable(0),getScanPrecision(0),getCurrentScanVariable(1),getScanPrecision(1),getCurrentPositionIndex(),getNumberOfPositions()); - -#ifdef VERBOSE - cout << "writing merged data file" << endl; -#endif - if(*correctionMask&(1<writeDataFile (fname+ext,np,angConv->getMergedCounts(), angConv->getMergedErrors(), angConv->getMergedPositions(),'f');} -#ifdef VERBOSE - cout << " done" << endl; -#endif - - - -// if (delflag) { -// deleteMerging(); -// } else { - thisData=new detectorData(angConv->getMergedCounts(),angConv->getMergedErrors(),angConv->getMergedPositions(),getCurrentProgress(),(fname+ext).c_str(),np); - - // // cout << "lock 2" << endl; -// pthread_mutex_lock(&mg); -// finalDataQueue.push(thisData); -// // cout << "unlock 2" << endl; - -// pthread_mutex_unlock(&mg); - - if (dataReady) { - - dataReady(thisData, pCallbackArg); - delete thisData; - } - -// } - // cout << "lock 3" << endl; - pthread_mutex_lock(&mp); - } - // cout << "unlock 3" << endl; - pthread_mutex_unlock(&mp); - - if (ffcdata) - delete [] ffcdata; - - ffcdata=NULL; - - if (ffcerr) - delete [] ffcerr; - ffcerr=NULL; - - if (ang) - delete [] ang; - ang=NULL; - - } else { -// if (delflag) { -// if (ffcdata) -// delete [] ffcdata; -// if (ffcerr) -// delete [] ffcerr; -// if ( ang) -// delete [] ang; -// } else { - thisData=new detectorData(ffcdata,ffcerr,NULL,getCurrentProgress(),(fname+ext).c_str(),getTotalNumberOfChannels()); - - - if (dataReady) { - dataReady(thisData, pCallbackArg); - delete thisData; - } -// pthread_mutex_lock(&mg); -// finalDataQueue.push(thisData); - - -// pthread_mutex_unlock(&mg); -// } - } - //} - - if(*correctionMask&(1<incrementFileIndex();} -#ifdef VERBOSE - cout << "fdata is " << fdata << endl; -#endif - -} - - - - - -int postProcessing::fillBadChannelMask() { - - int nbad=0; - - if (*correctionMask&(1<< DISCARD_BAD_CHANNELS)) { - nbad=getBadChannelCorrection(); -#ifdef VERBOSE - cout << "number of bad channels is " << nbad << endl; -#endif - if (nbad>0) { - - int *badChansList=new int[nbad]; - getBadChannelCorrection(badChansList); - - if (badChannelMask) - delete [] badChannelMask; - badChannelMask=new int[getTotalNumberOfChannels()]; - -#ifdef VERBOSE - cout << " pointer to bad channel mask is " << badChannelMask << endl; -#endif - for (int ichan=0; ichan=0 ) { - if (badChannelMask[badChansList[ichan]]==0) - nbad++; - badChannelMask[badChansList[ichan]]=1; - - } - } - delete [] badChansList; - - } else { - if (badChannelMask) { -#ifdef VERBOSE - cout << "deleting bad channel mask beacuse number of bad channels is 0" << endl; -#endif - - delete [] badChannelMask; - badChannelMask=NULL; - } - } - - } else { -#ifdef VERBOSE - cout << "bad channel correction is disabled " << nbad << endl; -#endif - if (badChannelMask) { -#ifdef VERBOSE - cout << "deleting bad channel mask beacuse no bad channel correction is selected" << endl; -#endif - delete [] badChannelMask; - badChannelMask=NULL; - } - } - -#ifdef VERBOSE - cout << "number of bad channels is " << nbad << endl; -#endif - return nbad; - -} - - - - - - -void* postProcessing::processData(int delflag) { - - -#ifdef VERBOSE - std::cout<< " processing data - threaded mode " << *threadedProcessing << endl; -#endif - - - angConv->setTotalNumberOfChannels(getTotalNumberOfChannels()); - IOfile->setTotalNumberofChannels(getTotalNumberOfChannels()); - setTotalProgress(); - pthread_mutex_lock(&mp); - queuesize=dataQueue.size(); - pthread_mutex_unlock(&mp); - - int *myData; - int dum=1; - - fdata=NULL; - - - while(dum | *threadedProcessing) { // ???????????????????????? - - - /* IF THERE ARE DATA PROCESS THEM*/ - pthread_mutex_lock(&mp); - while((queuesize=dataQueue.size())>0) { - /** Pop data queue */ - myData=dataQueue.front(); // get the data from the queue - pthread_mutex_unlock(&mp); - - if (myData) { - processFrame(myData,delflag); - //usleep(1000); - } - pthread_mutex_lock(&mp); - - } - pthread_mutex_unlock(&mp); - - /* IF THERE ARE NO DATA look if acquisition is finished */ - pthread_mutex_lock(&mp); - if (jointhread) { - if (dataQueue.size()==0) { - pthread_mutex_unlock(&mp); - break; - } - pthread_mutex_unlock(&mp); - } else { - pthread_mutex_unlock(&mp); - } - dum=0; - } - - if (fdata) { -#ifdef VERBOSE - cout << "delete fdata" << endl; -#endif - delete [] fdata; -#ifdef VERBOSE - cout << "done " << endl; -#endif - } - return 0; -} - - -int* postProcessing::popDataQueue() { - int *retval=NULL; - if( !dataQueue.empty() ) { - retval=dataQueue.front(); - dataQueue.pop(); - } - return retval; -} - -detectorData* postProcessing::popFinalDataQueue() { - detectorData *retval=NULL; - pthread_mutex_unlock(&mg); - if( !finalDataQueue.empty() ) { - retval=finalDataQueue.front(); - finalDataQueue.pop(); - } - pthread_mutex_unlock(&mg); - return retval; -} - -void postProcessing::resetDataQueue() { - int *retval=NULL; - while( !dataQueue.empty() ) { - retval=dataQueue.front(); - dataQueue.pop(); - delete [] retval; - } - -} - -void postProcessing::resetFinalDataQueue() { - detectorData *retval=NULL; - pthread_mutex_lock(&mg); - while( !finalDataQueue.empty() ) { - retval=finalDataQueue.front(); - finalDataQueue.pop(); - delete retval; - } - pthread_mutex_unlock(&mg); -} - - -void postProcessing::startThread(int delflag) { - pthread_attr_t tattr; - int ret; - sched_param param, mparam; - int policy= SCHED_OTHER; - - - // set the priority; others are unchanged - //newprio = 30; - mparam.sched_priority =1; - param.sched_priority =1; - - - /* Initialize and set thread detached attribute */ - pthread_attr_init(&tattr); - pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_JOINABLE); - - - - // param.sched_priority = 5; - // scheduling parameters of main thread - ret = pthread_setschedparam(pthread_self(), policy, &mparam); - //#ifdef VERBOSE - // printf("current priority is %d\n",param.sched_priority); - //#endif - if (delflag) - ret = pthread_create(&dataProcessingThread, &tattr,startProcessData, (void*)this); - else - ret = pthread_create(&dataProcessingThread, &tattr,startProcessDataNoDelete, (void*)this); - - pthread_attr_destroy(&tattr); - // scheduling parameters of target thread - ret = pthread_setschedparam(dataProcessingThread, policy, ¶m); - -} - - - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/postProcessingFileIO_Standalone.h b/slsDetectorSoftware/slsDetectorAnalysis/postProcessingFileIO_Standalone.h deleted file mode 100644 index 7edfddc0b..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/postProcessingFileIO_Standalone.h +++ /dev/null @@ -1,391 +0,0 @@ -#ifndef POSTPROCESSING_H -#define POSTPROCESSING_H - - -#include "detectorData.h" -#include "sls_detector_defs.h" -#include "slsDetectorBase_Standalone.h" -#include "slsDetectorUsers.h" -#include "FileIO_Standalone.h" -#include "AngularConversion_Standalone.h" -//#include "externPostProcessing.h" - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - - -class angularConversion; -class fileIO; - -; - -#define MAX_BADCHANS 2000 - - -#define defaultTDead {170,90,750} /**< should be changed in order to have it separate for the different detector types */ - - -/** - @short methods for data postprocessing - - (including thread for writing data files and plotting in parallel with the acquisition) -*/ - -class postProcessing : public virtual slsDetectorBase1 { - - -//: public angularConversion, public fileIO - - public: - postProcessing(); - virtual ~postProcessing(){}; - - - - /** - get bad channels correction - \param bad pointer to array that if bad!=NULL will be filled with the bad channel list - \returns 0 if bad channel disabled or no bad channels, >0 otherwise - */ - virtual int getBadChannelCorrection(int *bad=NULL)=0; - - - /** - get flat field corrections - \param corr if !=NULL will be filled with the correction coefficients - \param ecorr if !=NULL will be filled with the correction coefficients errors - \returns 0 if ff correction disabled, >0 otherwise - */ - virtual int getFlatFieldCorrection(double *corr=NULL, double *ecorr=NULL)=0; - - /** - set flat field corrections - \param corr if !=NULL the flat field corrections will be filled with corr (NULL usets ff corrections) - \param ecorr if !=NULL the flat field correction errors will be filled with ecorr (1 otherwise) - \returns 0 if ff correction disabled, >0 otherwise - */ - virtual int setFlatFieldCorrection(double *corr, double *ecorr=NULL)=0; - - /** - set bad channels correction - \param fname file with bad channel list ("" disable) - \returns 0 if bad channel disabled, >0 otherwise - */ - virtual int setBadChannelCorrection(string fname="")=0; - - static int setBadChannelCorrection(ifstream &infile, int &nbad, int *badlist, int moff=0); - /** - set bad channels correction - \param fname file with bad channel list ("" disable) - \param nbad reference to number of bad channels - \param badlist array of badchannels - \returns 0 if bad channel disabled, >0 otherwise - */ - virtual int setBadChannelCorrection(string fname, int &nbad, int *badlist, int off=0)=0; - - - /** - set bad channels correction - \param nch number of bad channels - \param chs array of channels - \param ff 0 if normal bad channels, 1 if ff bad channels - \returns 0 if bad channel disabled, >0 otherwise - */ - virtual int setBadChannelCorrection(int nch, int *chs, int ff=0)=0; - - /** - flat field correct data - \param datain data - \param errin error on data (if<=0 will default to sqrt(datain) - \param dataout corrected data - \param errout error on corrected data - \param ffcoefficient flat field correction coefficient - \param fferr erro on ffcoefficient - \returns 0 - */ - static int flatFieldCorrect(double datain, double errin, double &dataout, double &errout, double ffcoefficient, double fferr); - - /** - rate correct data - \param datain data - \param errin error on data (if<=0 will default to sqrt(datain) - \param dataout corrected data - \param errout error on corrected data - \param tau dead time 9in ns) - \param t acquisition time (in ns) - \returns 0 - */ - static int rateCorrect(double datain, double errin, double &dataout, double &errout, double tau, double t); - - - int enableWriteToFile(int i=-1) {if (i>0) ((*correctionMask)|=(1<0) (*correctionMask)|=(1<< ANGULAR_CONVERSION); return ((*correctionMask)&(1<< ANGULAR_CONVERSION));}; - - - - int enableAngularConversion(int i=-1) {if (i>0) return setAngularConversionFile("default"); if (i==0) return setAngularConversionFile(""); return setAngularCorrectionMask();}; - - - int enableBadChannelCorrection(int i=-1) {if (i>0) return setBadChannelCorrection("default"); if (i==0) return setBadChannelCorrection(""); return ((*correctionMask)&(1<< DISCARD_BAD_CHANNELS));}; - - - - - /** returns the bad channel list file */ - string getBadChannelCorrectionFile() {if ((*correctionMask)&(1<< DISCARD_BAD_CHANNELS)) return string(badChanFile); else return string("none");}; - - - /** - get flat field corrections file directory - \returns flat field correction file directory - */ - string getFlatFieldCorrectionDir(){return string(flatFieldDir);}; - /** - set flat field corrections file directory - \param flat field correction file directory - \returns flat field correction file directory - */ - string setFlatFieldCorrectionDir(string dir){strcpy(flatFieldDir,dir.c_str()); return string(flatFieldDir);}; - - /** - get flat field corrections file name - \returns flat field correction file name - */ - string getFlatFieldCorrectionFile(){ if ((*correctionMask)&(1<=0) *threadedProcessing=b; return *threadedProcessing;}; - - - - - /** processes the data - \param delflag 0 leaves the data in the final data queue - \returns nothing - - */ - void *processData(int delflag); - - /** processes the data - \param delflag 0 leaves the data in the final data queue - \returns nothing - - */ - void processFrame(int* myData, int delflag); - - /** processes the data - \param delflag 0 leaves the data in the final data queue - \returns nothing - - */ - void doProcessing(double* myData, int delflag, string fname); - - - /** - pops the data from the data queue - \returns pointer to the popped data or NULL if the queue is empty. - \sa dataQueue - */ - int* popDataQueue(); - - /** - pops the data from thepostprocessed data queue - \returns pointer to the popped data or NULL if the queue is empty. - \sa finalDataQueue - */ - detectorData* popFinalDataQueue(); - - - /** - resets the raw data queue - \sa dataQueue - */ - void resetDataQueue(); - - /** - resets the postprocessed data queue - \sa finalDataQueue - */ - void resetFinalDataQueue(); - - - - - - int fillBadChannelMask(); - - - - - virtual int rateCorrect(double*, double*, double*, double*)=0; - virtual int flatFieldCorrect(double*, double*, double*, double*)=0; - - - - - - //void registerAngularConversionCallback(int (*sAngularConversion)(int & ,angleConversionConstant* ,void *), void *arg){seAngularConversion=sAngularConversion; pAngular= arg; }; - - void registerDataCallback(int( *userCallback)(detectorData*, void*), void *pArg) {dataReady = userCallback; pCallbackArg = pArg;}; - - void registerCallBackGetNumberofChannel(int (*func)(int, void *),void *arg){ getNoChannel=func;pNumberofChannel=arg;}; - - - - /** - sets the angular conversion file - \param fname file to read - \returns angular conversion flag - */ - - int setAngularConversionFile(string fname); - - //static int defaultAngularConversion(int &direc, angleConversionConstant *angoff,void *p=NULL){ return ((postProcessing *)p)->getAngularConversion( direc,angleConversionConstant *angoff=NULL);}; - /** - returns the angular conversion file - */ - string getAngularConversionFile(){if (setAngularCorrectionMask()) return string(angConvFile); else return string("none");}; - - //static int setAngularConversion(); - - static int defaultGetTotalNumberofChannels (int nChannel, void *p=NULL){ if(nChannel>=0){ return ((postProcessing*)p)->getTotalNumberOfChannels();} else return -1;}; - - protected: - - int *threadedProcessing; - - int *correctionMask; - - char *flatFieldDir; - char *flatFieldFile; - - char *badChanFile; - int *nBadChans; - int *badChansList; - int *nBadFF; - int *badFFList; - int *direction; - - /** pointer to angular conversion file name*/ - char *angConvFile; - - - /** mutex to synchronize main and data processing threads */ - pthread_mutex_t mp; - - - /** mutex to synchronizedata processing and plotting threads */ - pthread_mutex_t mg; - - /** sets when the acquisition is finished */ - int jointhread; - - /** sets when the position is finished */ - int posfinished; - - /** - data queue - */ - queue dataQueue; - /** - queue containing the postprocessed data - */ - queue finalDataQueue; - - - /** data queue size */ - int queuesize; - - - - - /** - start data processing thread - */ - void startThread(int delflag=1); // - /** the data processing thread */ - - pthread_t dataProcessingThread; - - - - /** pointer to bad channel mask 0 is channel is good 1 if it is bad \sa fillBadChannelMask() */ - int *badChannelMask; - - - - - /** - I0 measured - */ - double currentI0; - - double *fdata; - - int (*seAngularConversion)(int & ,angleConversionConstant* ,void*); - int (*getNoChannel)(int ,void*); - int (*dataReady)(detectorData*,void*); - void *pCallbackArg, *pChpermod,*pNumberofChannel,*pAngular; - - - - private: - - angularConversion *angConv; - fileIO *IOfile; - - /** pointer to beamlien fine offset*/ - double *fineOffset; - /** pointer to beamlien global offset*/ - double *globalOffset; - /** pointer to number of positions for the acquisition*/ - int *numberOfPositions; - - /** pointer to the detector positions for the acquisition*/ - double *detPositions; - - angleConversionConstant angcc[MAXMODS*MAXDET]; - - - /** pointer to angular bin size*/ - double *binSize; - - -}; - - -static void* startProcessData(void *n){\ - postProcessing *myDet=(postProcessing*)n;\ - myDet->processData(1);\ - pthread_exit(NULL);\ - -}; - -static void* startProcessDataNoDelete(void *n){\ - postProcessing *myDet=(postProcessing*)n;\ - myDet->processData(0);\ - pthread_exit(NULL);\ - -}; - - - -#endif diff --git a/slsDetectorSoftware/slsDetectorAnalysis/postProcessingFuncs.cpp b/slsDetectorSoftware/slsDetectorAnalysis/postProcessingFuncs.cpp deleted file mode 100644 index f92d132ad..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/postProcessingFuncs.cpp +++ /dev/null @@ -1,566 +0,0 @@ -#include "postProcessingFuncs.h" -#include "angleConversionConstant.h" -using namespace std; -//#define VERBOSE - -postProcessingFuncs::postProcessingFuncs(int *nModules,int *chPerMod,int modMask[],int badCh[], double ffcoeff[], double fferr[], double* t, int *dir, double angRadius[], double angOffset[], double angCentre[], double* to, double* bs, double *sX, double *sY): - nMods(0), chansPerMod(NULL), moduleMask(NULL), badChannelMask(NULL), ffCoeff(NULL), ffErr(NULL), tDead(0), angDir(1), angConv(NULL), totalOffset(0), binSize(0), sampleX(0), sampleY(0), totalChans(0), nBins(0), mp(NULL), mv(NULL), me(NULL), mm(NULL) -{ - initDataset(nModules, chPerMod,modMask,badCh, ffcoeff, fferr, t, dir, angRadius, angOffset, angCentre, to, bs, sX, sY); - -} - -int postProcessingFuncs::initDataset() { - - // cout << "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA init dataset " << endl; - - if (nBins) { - mp=new double[nBins]; - mv=new double[nBins]; - me=new double[nBins]; - mm=new int[nBins]; - resetMerging(mp,mv,me,mm, nBins); - // cout << "nbins " << nBins << endl; - } else { - mv=new double[totalChans]; - me=new double[totalChans]; - // cout << "nchans " << totalChans << endl; - } - totalI0=0; - - return 0; - -} - -int postProcessingFuncs::finalizeDataset(double *ang, double *val, double *err, int *np) { - - // cout << "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA finalize dataset " << endl; - - if (nBins) - *np=finalizeMerging(mp,mv,me,mm,nBins); - else - *np=totalChans; - - - - if (totalI0<=0) - totalI0=1.; - - - for (int ip=0; ip<(*np); ip++) { - - if (ang) - if (mp) - ang[ip]=mp[ip]; - - if (mv) - val[ip]=mv[ip]*totalI0; - - if (me) - err[ip]=me[ip]*totalI0; - - } - - - // cout << "delete mp " <0) { - i0=*I0; - totalI0+=i0; - } else - i0=-1; - -// if (badChannelMask) -// cout << "---------------- Discarding bad chans " << endl; - - // cout << "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA add frame " << i0 << endl; - - for (int ich=0; ichchlast) { - // cout << *pos << " " << moduleMask[imod] << endl; - imod++; - ch0=chlast+1; - nchmod=chansPerMod[imod]; - chlast=ch0+nchmod-1; - } - - vin=data[ich]; - ein=0; - vout=data[ich]; - if (vout>=0) - eout=sqrt(vout); - else - eout=0; - - - if (tDead) { - //#ifdef VERBOSE - // cout << "ppFuncs ratecorrect" << endl; - //#endif - rateCorrect(vin, ein, vout, eout, tDead, *expTime); - vin=vout; - ein=eout; - } - //ffcorrect - - if (ffCoeff) { - //#ifdef VERBOSE - // cout << "ppFuncs ffcorrect" << endl; - //#endif - if (ffErr) - e=ffErr[ich]; - else - e=0; - flatFieldCorrect(vin, ein, vout, eout, ffCoeff[ich], e); - } - - - //i0correct - if (i0>0) { - //#ifdef VERBOSE - // cout << "ppFuncs i0 norm" << endl; - //#endif - vout/=i0; - eout/=i0; - } - - if (badChannelMask) { - //#ifdef VERBOSE - // cout << "ppFuncs badchans" << endl; - //#endif - if (badChannelMask[ich]) { - // cout << "------------------ Discarding channel " << ich << endl; - continue; - } - } - if (nBins) { - //angconv - -// #ifdef VERBOSE -// cout << "ppFuncs angconv" << endl; -// #endif -// //check module mask?!?!?!? - - - p1=convertAngle(*pos,ich-ch0,angConv[imod],moduleMask[imod],totalOffset,0,angDir); - -// #ifdef VERBOSE -// cout << "************************** ppFuncs merge" << endl; -// #endif - addPointToMerging(p1,vout,eout,mp,mv,me,mm, binSize, nBins); - - - } else { -#ifdef VERBOSE - cout << "ppFuncs merge" << endl; -#endif - //mp[ich]=ich; - mv[ich]+=vout; - me[ich]+=eout*eout; - } - } - return 0; -} - - - - - -int postProcessingFuncs::initDataset(int *nModules,int *chPerMod,int modMask[],int badCh[], double ffcoeff[], double fferr[], double* t, int *dir, double angRadius[], double angOffset[], double angCenter[], double* to, double* bs, double *sX, double *sY) { - - // cout << "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA init dataset XXXXXX " << endl; - //#ifdef VERBOSE - // cout << "delete pointers " << endl; - //#endif - - deletePointers(); - - - //#ifdef VERBOSE - // cout << "nmod " << endl; - //#endif - - if (nModules) - nMods=*nModules; - else - nMods=0; - - - //#ifdef VERBOSE - //cout << nMods << endl; - //#endif -#ifdef VERBOSE - cout << "tdead " << endl; -#endif - - if (t) - tDead=*t; - else - tDead=0; - -#ifdef VERBOSE - cout << tDead << endl; -#endif -#ifdef VERBOSE - cout << "toffset " << endl; -#endif - - if (to) - totalOffset=*to; - else - totalOffset=0; -#ifdef VERBOSE - cout << totalOffset << endl; -#endif - - - //#ifdef VERBOSE - // cout << "binsize " << endl; - //#endif - if (bs) - binSize=*bs; - else - binSize=0; - - - //#ifdef VERBOSE - // cout << binSize << endl; - //#endif -#ifdef VERBOSE - cout << "samplex " << endl; -#endif - if (sX) - sampleX=*sX; - else - sampleX=0; - -#ifdef VERBOSE - cout << sampleX << endl; -#endif -#ifdef VERBOSE - cout << "sampley " << endl; -#endif - if (sY) - sampleY=*sY; - else - sampleY=0; - -#ifdef VERBOSE - cout << sampleY << endl; -#endif - //#ifdef VERBOSE - // cout << "angdir " << endl; - //#endif - if (dir) - angDir=*dir; - else - angDir=1; - - //#ifdef VERBOSE - // cout << angDir << endl; - //#endif - totalChans=0; - - - if (nMods) - chansPerMod=new int [nMods]; - - if (nMods) - moduleMask=new int [nMods]; - - nBins=0; - if (angRadius && angOffset && angCenter && (binSize>0)) { - // cout << "??????? creating angConv"<< endl; - if (nMods) - angConv=new angleConversionConstant*[nMods]; - nBins=(int)(360./binSize)+1; - } - //#ifdef VERBOSE - //cout << "nBins " << nBins << endl; - //#endif - for (int im=0; im=0) - e=sqrt(datain); - else - e=errin; - - if (dataout>0) - errout=sqrt(e*ffcoefficient*e*ffcoefficient+datain*fferr*datain*fferr); - else - errout=1.0; - - return 0; -}; - - - int postProcessingFuncs::rateCorrect(double datain, double errin, double &dataout, double &errout, double tau, double t){ - - // double data; - double e; - - dataout=(datain*exp(tau*datain/t)); - - if (errin==0 && datain>=0) - e=sqrt(datain); - else - e=errin; - - if (dataout>0) - errout=e*dataout*sqrt((1/(datain*datain)+tau*tau/(t*t))); - else - errout=1.; - return 0; - -}; - - -int postProcessingFuncs::calculateFlatField(int* nModules, int *chPerMod, int *moduleMask, int *badChannelMask, double *ffData, double *ffCoeff, double *ffErr) { - int nmed=0, im=0; - double *xmed; - - // cout << "Claculate flat field " << endl; - - if (chPerMod==NULL) - return -1; - // if (moduleMask==NULL) - // return -1; - if (ffData==NULL) - return -1; - - if (ffErr==NULL) - return -1; - - - // cout << *nModules << " pp chpm0 " << chPerMod[0] << endl; - int totch=0; - int nm= *nModules; - for (int im=0; im0) { - im=0; - while ((imim; i--) - xmed[i]=xmed[i-1]; - - xmed[im]=ffData[ich]; - nmed++; - - } - - - - } - - - if (nmed>1 && xmed[nmed/2]>0) { - //#ifdef VERBOSE - // std::cout<< "Flat field median is " << xmed[nmed/2] << " calculated using "<< nmed << " points" << std::endl; - //#endif - - - // cout << "checking bad channel mask " << endl; - for (int ich=0; ich0) { - ffCoeff[ich]=xmed[nmed/2]/ffData[ich]; - ffErr[ich]=ffCoeff[ich]*sqrt(ffData[ich])/ffData[ich]; - } else { - ffCoeff[ich]=0.; - ffErr[ich]=1.; - } - cout << ich << " " << ffData[ich] << " " << ffCoeff[ich] << endl; - } - - } - cout << "done " << endl; - - delete [] xmed; - xmed=NULL; - - return 0; - -} - - - - - - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/postProcessingFuncs.h b/slsDetectorSoftware/slsDetectorAnalysis/postProcessingFuncs.h deleted file mode 100644 index abffb54eb..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/postProcessingFuncs.h +++ /dev/null @@ -1,80 +0,0 @@ -#ifndef POSTPROCESSINGFUNCS_H -#define POSTPROCESSINGFUNC_H - - - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "angularConversionStatic.h" -class angleConversionConstant; - - - - -class postProcessingFuncs : public virtual angularConversionStatic - -{ - - public: - postProcessingFuncs(int *nModules=NULL,int *chPerMod=NULL,int *modMask=NULL,int *badChMask=NULL, double *ffcoeff=NULL, double *fferr=NULL, double* t=NULL, int *dir=NULL, double *angRadius=NULL, double *angOffset=NULL, double *angCentre=NULL, double* to=NULL, double* bs=NULL, double *sX=NULL, double *sY=NULL); - - - ~postProcessingFuncs(); - - - int initDataset(int *nModules,int *chPerMod,int modMask[],int badCh[], double ffcoeff[], double fferr[], double* tDead, int *dir, double angRadius[], double angOffset[], double angCentre[], double* to, double* bs, double *sX, double *sY); - - int initDataset(); - - - int finalizeDataset(double ang[], double val[], double err[], int *np); - - int addFrame(double data[], double *pos, double *IO, double *expTime, const char *filename, double *var=0); - - static int calculateFlatField(int* nModules, int *chPerMod, int moduleMask[], int badChannelMask[], double ffData[], double ffCoeff[], double ffErr[]); - - static int flatFieldCorrect(double datain, double errin, double &dataout, double &errout, double ffcoefficient, double fferr); - - - static int rateCorrect(double datain, double errin, double &dataout, double &errout, double tau, double t); - - private: - void deletePointers(); - - - int nMods; - int *chansPerMod; - int *moduleMask; - int *badChannelMask; - double *ffCoeff; - double *ffErr; - double tDead; - int angDir; - angleConversionConstant **angConv; - double totalOffset; - double binSize; - double sampleX; - double sampleY; - int totalChans; - - int nBins; - - double totalI0; - - - double *mp, *mv,*me; - int *mm; - -}; - - -#endif diff --git a/slsDetectorSoftware/slsDetectorAnalysis/postProcessing_Standalone.cpp b/slsDetectorSoftware/slsDetectorAnalysis/postProcessing_Standalone.cpp deleted file mode 100644 index 185d811ad..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/postProcessing_Standalone.cpp +++ /dev/null @@ -1,593 +0,0 @@ -#include "postProcessing.h" -#include "usersFunctions.h" -//#include "angularConversion.h" - -//#include "AngularConversion_Standalone.h" - -postProcessing::postProcessing(){ - pthread_mutex_t mp1 = PTHREAD_MUTEX_INITIALIZER; - mp=mp1; - pthread_mutex_init(&mp, NULL); - mg=mp1; - pthread_mutex_init(&mg, NULL); - //cout << "reg callback "<< endl; - dataReady = 0; - pCallbackArg = 0; - registerDataCallback(&defaultDataReadyFunc, NULL); - //tregisterCallBackGetChansPerMod(&defaultGetChansPerMod,NULL); - //cout << "done "<< endl; - angConv=new angularConversion(numberOfPositions,detPositions,binSize, fineOffset, globalOffset); -} - - - - - - -int postProcessing::flatFieldCorrect(double datain, double errin, double &dataout, double &errout, double ffcoefficient, double fferr){ - double e; - - dataout=datain*ffcoefficient; - - if (errin==0 && datain>=0) - e=sqrt(datain); - else - e=errin; - - if (dataout>0) - errout=sqrt(e*ffcoefficient*e*ffcoefficient+datain*fferr*datain*fferr); - else - errout=1.0; - - return 0; -}; - - - int postProcessing::rateCorrect(double datain, double errin, double &dataout, double &errout, double tau, double t){ - - // double data; - double e; - - dataout=(datain*exp(tau*datain/t)); - - if (errin==0 && datain>=0) - e=sqrt(datain); - else - e=errin; - - if (dataout>0) - errout=e*dataout*sqrt((1/(datain*datain)+tau*tau/(t*t))); - else - errout=1.; - return 0; - -}; - - - - - -int postProcessing::setBadChannelCorrection(ifstream &infile, int &nbad, int *badlist, int moff){ - - int interrupt=0; - int ich; - int chmin,chmax; - string str; - - - - nbad=0; - while (infile.good() and interrupt==0) { - getline(infile,str); -#ifdef VERBOSE - std::cout << str << std::endl; -#endif - istringstream ssstr; - ssstr.str(str); - if (ssstr.bad() || ssstr.fail() || infile.eof()) { - interrupt=1; - break; - } - if (str.find('-')!=string::npos) { - ssstr >> chmin ; - ssstr.str(str.substr(str.find('-')+1,str.size())); - ssstr >> chmax; -#ifdef VERBOSE - std::cout << "channels between"<< chmin << " and " << chmax << std::endl; -#endif - for (ich=chmin; ich<=chmax; ich++) { - if (nbad> ich; -#ifdef VERBOSE - std::cout << "channel "<< ich << std::endl; -#endif - if (nbad0) { -#ifdef VERBOSE - cout << "**************Current position index is " << getCurrentPositionIndex() << endl; -#endif - // if (*numberOfPositions>0) { - if (getCurrentPositionIndex()<=1) { - -#ifdef VERBOSE - cout << "reset merging " << endl; -#endif - angConv->resetMerging(); - } - -#ifdef VERBOSE - cout << "add to merging "<< getCurrentPositionIndex() << endl; -#endif - - angConv->addToMerging(ang, ffcdata, ffcerr, badChannelMask ); - -#ifdef VERBOSE - cout << getCurrentPositionIndex() << " " << getNumberOfPositions() << endl; - -#endif - - - // cout << "lock 1" << endl; - pthread_mutex_lock(&mp); - if ((getCurrentPositionIndex()>=getNumberOfPositions() && posfinished==1 && queuesize==1)) { - -#ifdef VERBOSE - cout << "finalize merging " << getCurrentPositionIndex()<< endl; -#endif - np=angConv->finalizeMerging(); - /** file writing */ - angConv->incrementPositionIndex(); - // cout << "unlock 1" << endl; - pthread_mutex_unlock(&mp); - - - fname=createFileName(); - -#ifdef VERBOSE - cout << "writing merged data file" << endl; -#endif - writeDataFile (fname+ext,np,angConv->getMergedCounts(), angConv->getMergedErrors(), angConv->getMergedPositions(),'f'); -#ifdef VERBOSE - cout << " done" << endl; -#endif - - - -// if (delflag) { -// deleteMerging(); -// } else { - thisData=new detectorData(angConv->getMergedCounts(),angConv->getMergedErrors(),angConv->getMergedPositions(),getCurrentProgress(),(fname+ext).c_str(),np); - - // // cout << "lock 2" << endl; -// pthread_mutex_lock(&mg); -// finalDataQueue.push(thisData); -// // cout << "unlock 2" << endl; - -// pthread_mutex_unlock(&mg); - - if (dataReady) { - - dataReady(thisData, pCallbackArg); - delete thisData; - } - -// } - // cout << "lock 3" << endl; - pthread_mutex_lock(&mp); - } - // cout << "unlock 3" << endl; - pthread_mutex_unlock(&mp); - - if (ffcdata) - delete [] ffcdata; - - ffcdata=NULL; - - if (ffcerr) - delete [] ffcerr; - ffcerr=NULL; - - if (ang) - delete [] ang; - ang=NULL; - - } else { -// if (delflag) { -// if (ffcdata) -// delete [] ffcdata; -// if (ffcerr) -// delete [] ffcerr; -// if ( ang) -// delete [] ang; -// } else { - thisData=new detectorData(ffcdata,ffcerr,NULL,getCurrentProgress(),(fname+ext).c_str(),getTotalNumberOfChannels()); - - - if (dataReady) { - dataReady(thisData, pCallbackArg); - delete thisData; - } -// pthread_mutex_lock(&mg); -// finalDataQueue.push(thisData); - - -// pthread_mutex_unlock(&mg); -// } - } - //} - - incrementFileIndex(); -#ifdef VERBOSE - cout << "fdata is " << fdata << endl; -#endif - -} - - - - - -int postProcessing::fillBadChannelMask() { - - int nbad=0; - - if (*correctionMask&(1<< DISCARD_BAD_CHANNELS)) { - nbad=getBadChannelCorrection(); -#ifdef VERBOSE - cout << "number of bad channels is " << nbad << endl; -#endif - if (nbad>0) { - - int *badChansList=new int[nbad]; - getBadChannelCorrection(badChansList); - - if (badChannelMask) - delete [] badChannelMask; - badChannelMask=new int[getTotalNumberOfChannels()]; - -#ifdef VERBOSE - cout << " pointer to bad channel mask is " << badChannelMask << endl; -#endif - for (int ichan=0; ichan=0 ) { - if (badChannelMask[badChansList[ichan]]==0) - nbad++; - badChannelMask[badChansList[ichan]]=1; - - } - } - delete [] badChansList; - - } else { - if (badChannelMask) { -#ifdef VERBOSE - cout << "deleting bad channel mask beacuse number of bad channels is 0" << endl; -#endif - - delete [] badChannelMask; - badChannelMask=NULL; - } - } - - } else { -#ifdef VERBOSE - cout << "bad channel correction is disabled " << nbad << endl; -#endif - if (badChannelMask) { -#ifdef VERBOSE - cout << "deleting bad channel mask beacuse no bad channel correction is selected" << endl; -#endif - delete [] badChannelMask; - badChannelMask=NULL; - } - } - -#ifdef VERBOSE - cout << "number of bad channels is " << nbad << endl; -#endif - return nbad; - -} - - - - - - -void* postProcessing::processData(int delflag) { - - -#ifdef VERBOSE - std::cout<< " processing data - threaded mode " << *threadedProcessing << endl; -#endif - - - angConv->setTotalNumberOfChannels(getTotalNumberOfChannels()); - setTotalProgress(); - pthread_mutex_lock(&mp); - queuesize=dataQueue.size(); - pthread_mutex_unlock(&mp); - - int *myData; - int dum=1; - - fdata=NULL; - - - while(dum | *threadedProcessing) { // ???????????????????????? - - - /* IF THERE ARE DATA PROCESS THEM*/ - pthread_mutex_lock(&mp); - while((queuesize=dataQueue.size())>0) { - /** Pop data queue */ - myData=dataQueue.front(); // get the data from the queue - pthread_mutex_unlock(&mp); - - if (myData) { - processFrame(myData,delflag); - //usleep(1000); - } - pthread_mutex_lock(&mp); - - } - pthread_mutex_unlock(&mp); - - /* IF THERE ARE NO DATA look if acquisition is finished */ - pthread_mutex_lock(&mp); - if (jointhread) { - if (dataQueue.size()==0) { - pthread_mutex_unlock(&mp); - break; - } - pthread_mutex_unlock(&mp); - } else { - pthread_mutex_unlock(&mp); - } - dum=0; - } - - if (fdata) { -#ifdef VERBOSE - cout << "delete fdata" << endl; -#endif - delete [] fdata; -#ifdef VERBOSE - cout << "done " << endl; -#endif - } - return 0; -} - - -int* postProcessing::popDataQueue() { - int *retval=NULL; - if( !dataQueue.empty() ) { - retval=dataQueue.front(); - dataQueue.pop(); - } - return retval; -} - -detectorData* postProcessing::popFinalDataQueue() { - detectorData *retval=NULL; - pthread_mutex_unlock(&mg); - if( !finalDataQueue.empty() ) { - retval=finalDataQueue.front(); - finalDataQueue.pop(); - } - pthread_mutex_unlock(&mg); - return retval; -} - -void postProcessing::resetDataQueue() { - int *retval=NULL; - while( !dataQueue.empty() ) { - retval=dataQueue.front(); - dataQueue.pop(); - delete [] retval; - } - -} - -void postProcessing::resetFinalDataQueue() { - detectorData *retval=NULL; - pthread_mutex_lock(&mg); - while( !finalDataQueue.empty() ) { - retval=finalDataQueue.front(); - finalDataQueue.pop(); - delete retval; - } - pthread_mutex_unlock(&mg); -} - - -void postProcessing::startThread(int delflag) { - pthread_attr_t tattr; - int ret; - sched_param param, mparam; - int policy= SCHED_OTHER; - - - // set the priority; others are unchanged - //newprio = 30; - mparam.sched_priority =1; - param.sched_priority =1; - - - /* Initialize and set thread detached attribute */ - pthread_attr_init(&tattr); - pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_JOINABLE); - - - - // param.sched_priority = 5; - // scheduling parameters of main thread - ret = pthread_setschedparam(pthread_self(), policy, &mparam); - //#ifdef VERBOSE - // printf("current priority is %d\n",param.sched_priority); - //#endif - if (delflag) - ret = pthread_create(&dataProcessingThread, &tattr,startProcessData, (void*)this); - else - ret = pthread_create(&dataProcessingThread, &tattr,startProcessDataNoDelete, (void*)this); - - pthread_attr_destroy(&tattr); - // scheduling parameters of target thread - ret = pthread_setschedparam(dataProcessingThread, policy, ¶m); - -} - - - diff --git a/slsDetectorSoftware/slsDetectorAnalysis/postProcessing_Standalone.h b/slsDetectorSoftware/slsDetectorAnalysis/postProcessing_Standalone.h deleted file mode 100644 index 213ed6de4..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/postProcessing_Standalone.h +++ /dev/null @@ -1,367 +0,0 @@ -#ifndef POSTPROCESSING_H -#define POSTPROCESSING_H - - -#include "detectorData.h" -#include "fileIO.h" -#include - -#include -#include -#include -#include -#include -#include -#include -#include - - -class angularConversion; - -; - -#define MAX_BADCHANS 2000 - - -#define defaultTDead {170,90,750} /**< should be changed in order to have it separate for the different detector types */ - - -/** - @short methods for data postprocessing - - (including thread for writing data files and plotting in parallel with the acquisition) -*/ - -class postProcessing : public virtual fileIO { - - -//: public angularConversion, public fileIO - - public: - postProcessing(); - virtual ~postProcessing(){}; - - - - - /** - get bad channels correction - \param bad pointer to array that if bad!=NULL will be filled with the bad channel list - \returns 0 if bad channel disabled or no bad channels, >0 otherwise - */ - virtual int getBadChannelCorrection(int *bad=NULL)=0; - - - /** - get flat field corrections - \param corr if !=NULL will be filled with the correction coefficients - \param ecorr if !=NULL will be filled with the correction coefficients errors - \returns 0 if ff correction disabled, >0 otherwise - */ - virtual int getFlatFieldCorrection(float *corr=NULL, float *ecorr=NULL)=0; - - /** - set flat field corrections - \param corr if !=NULL the flat field corrections will be filled with corr (NULL usets ff corrections) - \param ecorr if !=NULL the flat field correction errors will be filled with ecorr (1 otherwise) - \returns 0 if ff correction disabled, >0 otherwise - */ - virtual int setFlatFieldCorrection(float *corr, float *ecorr=NULL)=0; - - /** - set bad channels correction - \param fname file with bad channel list ("" disable) - \returns 0 if bad channel disabled, >0 otherwise - */ - virtual int setBadChannelCorrection(string fname="")=0; - - static int setBadChannelCorrection(ifstream &infile, int &nbad, int *badlist, int moff=0); - /** - set bad channels correction - \param fname file with bad channel list ("" disable) - -ff - \param nbad reference to number of bad channels - \param badlist array of badchannels - \returns 0 if bad channel disabled, >0 otherwise - */ - virtual int setBadChannelCorrection(string fname, int &nbad, int *badlist, int off=0)=0; - - - /** - set bad channels correction - \param nch number of bad channels - \param chs array of channels - \param ff 0 if normal bad channels, 1 if ff bad channels - \returns 0 if bad channel disabled, >0 otherwise - */ - virtual int setBadChannelCorrection(int nch, int *chs, int ff=0)=0; - - /** - flat field correct data - \param datain data - \param errin error on data (if<=0 will default to sqrt(datain) - \param dataout corrected data - \param errout error on corrected data - \param ffcoefficient flat field correction coefficient - \param fferr erro on ffcoefficient - \returns 0 - */ - static int flatFieldCorrect(float datain, float errin, float &dataout, float &errout, float ffcoefficient, float fferr); - - /** - rate correct data - \param datain data - \param errin error on data (if<=0 will default to sqrt(datain) - \param dataout corrected data - \param errout error on corrected data - \param tau dead time 9in ns) - \param t acquisition time (in ns) - \returns 0 - */ - static int rateCorrect(float datain, float errin, float &dataout, float &errout, float tau, float t); - - - int enableWriteToFile(int i=-1) {if (i>0) ((*correctionMask)|=(1<0) (*correctionMask)|=(1<< ANGULAR_CONVERSION); return ((*correctionMask)&(1<< ANGULAR_CONVERSION));}; - - - - int enableAngularConversion(int i=-1) {if (i>0) return setAngularConversionFile("default"); if (i==0) return setAngularConversionFile(""); return setAngularCorrectionMask();}; - - - int enableBadChannelCorrection(int i=-1) {if (i>0) return setBadChannelCorrection("default"); if (i==0) return setBadChannelCorrection(""); return ((*correctionMask)&(1<< DISCARD_BAD_CHANNELS));}; - - - - - /** returns the bad channel list file */ - string getBadChannelCorrectionFile() {if ((*correctionMask)&(1<< DISCARD_BAD_CHANNELS)) return string(badChanFile); else return string("none");}; - - - /** - get flat field corrections file directory - \returns flat field correction file directory - */ - string getFlatFieldCorrectionDir(){return string(flatFieldDir);}; - /** - set flat field corrections file directory - \param flat field correction file directory - \returns flat field correction file directory - */ - string setFlatFieldCorrectionDir(string dir){strcpy(flatFieldDir,dir.c_str()); return string(flatFieldDir);}; - - /** - get flat field corrections file name - \returns flat field correction file name - */ - string getFlatFieldCorrectionFile(){ if ((*correctionMask)&(1<=0) *threadedProcessing=b; return *threadedProcessing;}; - - - - - /** processes the data - \param delflag 0 leaves the data in the final data queue - \returns nothing - - */ - void *processData(int delflag); - - /** processes the data - \param delflag 0 leaves the data in the final data queue - \returns nothing - - */ - void processFrame(int* myData, int delflag); - - /** processes the data - \param delflag 0 leaves the data in the final data queue - \returns nothing - - */ - void doProcessing(float* myData, int delflag, string fname); - - - /** - pops the data from the data queue - \returns pointer to the popped data or NULL if the queue is empty. - \sa dataQueue - */ - int* popDataQueue(); - - /** - pops the data from thepostprocessed data queue - \returns pointer to the popped data or NULL if the queue is empty. - \sa finalDataQueue - */ - detectorData* popFinalDataQueue(); - - - /** - resets the raw data queue - \sa dataQueue - */ - void resetDataQueue(); - - /** - resets the postprocessed data queue - \sa finalDataQueue - */ - void resetFinalDataQueue(); - - - - - - int fillBadChannelMask(); - - - - - virtual int rateCorrect(float*, float*, float*, float*)=0; - virtual int flatFieldCorrect(float*, float*, float*, float*)=0; - - - - - - - - void registerDataCallback(int( *userCallback)(detectorData*, void*), void *pArg) {dataReady = userCallback; pCallbackArg = pArg;}; - //void registerCallBackGetChansPerMod(int (*func)(int, void *),void *arg){ getChansPerMod=func;pChpermod=arg;} - - - - /** - sets the angular conversion file - \param fname file to read - \returns angular conversion flag - */ - - int setAngularConversionFile(string fname); - - - /** - returns the angular conversion file - */ - string getAngularConversionFile(){if (setAngularCorrectionMask()) return string(angConvFile); else return string("none");}; - - - - protected: - - int *threadedProcessing; - - int *correctionMask; - - char *flatFieldDir; - char *flatFieldFile; - - char *badChanFile; - int *nBadChans; - int *badChansList; - int *nBadFF; - int *badFFList; - - /** pointer to angular conversion file name*/ - char *angConvFile; - - - /** mutex to synchronize main and data processing threads */ - pthread_mutex_t mp; - - - /** mutex to synchronizedata processing and plotting threads */ - pthread_mutex_t mg; - - /** sets when the acquisition is finished */ - int jointhread; - - /** sets when the position is finished */ - int posfinished; - - /** - data queue - */ - queue dataQueue; - /** - queue containing the postprocessed data - */ - queue finalDataQueue; - - - /** data queue size */ - int queuesize; - - - - - /** - start data processing thread - */ - void startThread(int delflag=1); // - /** the data processing thread */ - - pthread_t dataProcessingThread; - - - - /** pointer to bad channel mask 0 is channel is good 1 if it is bad \sa fillBadChannelMask() */ - int *badChannelMask; - - - - - /** - I0 measured - */ - float currentI0; - - float *fdata; - - - //int (*getChansPerMod)(int, void*); - - - int (*dataReady)(detectorData*,void*); - void *pCallbackArg, *pChpermod; - - - - private: - angularConversion *angConv; - - -}; - - -static void* startProcessData(void *n){\ - postProcessing *myDet=(postProcessing*)n;\ - myDet->processData(1);\ - pthread_exit(NULL);\ - -}; - -static void* startProcessDataNoDelete(void *n){\ - postProcessing *myDet=(postProcessing*)n;\ - myDet->processData(0);\ - pthread_exit(NULL);\ - -}; - - - -#endif diff --git a/slsDetectorSoftware/slsDetectorAnalysis/runningStat.h b/slsDetectorSoftware/slsDetectorAnalysis/runningStat.h deleted file mode 100644 index 98ab7986f..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/runningStat.h +++ /dev/null @@ -1,92 +0,0 @@ - /********************************************//** - * @file runningStat.h - * @short handles pedestal data and doesnt move - ***********************************************/ -#ifndef RUNNINGSTAT_H -#define RUNNINGSTAT_H - -#include - -//#include "sls_detector_defs.h" -#include -typedef double double32_t; -typedef float float32_t; -typedef int int32_t; - -/** - @short class handling pedestal data that is static - */ - -class runningStat{ - -public: - /** - * Constructor - */ - runningStat() : m_n(0),m_oldM(0),m_newM(0),m_oldS(0),m_newS(0) {} - - /** - * Clear number of data values - */ - void Clear(){ - m_n = 0; - } - - /** - * Push Pedestal - */ - void Push(double x){ - m_n++; - - // See Knuth TAOCP vol 2, 3rd edition, page 232 - if (m_n == 1){ - m_oldM = m_newM = x; - m_oldS = 0.0; - }else{ - m_newM = m_oldM + (x - m_oldM)/m_n; - m_newS = m_oldS + (x - m_oldM)*(x - m_newM); - - // set up for next iteration - m_oldM = m_newM; - m_oldS = m_newS; - } - } - - /** - * Get number of data values - */ - int NumDataValues() const{ - return m_n; - } - - /** - * Get mean - */ - double Mean() const{ - return (m_n > 0) ? m_newM : 0.0; - } - - /** - * Get variance - */ - double Variance() const{ - return ( (m_n > 1) ? m_newS/(m_n - 1) : 0.0 ); - } - - /** - * Get standard deviation - */ - double StandardDeviation() const{ - return sqrt( Variance() ); - } - -private: - /** number of data values */ - int m_n; - - /** old and new mean */ - double m_oldM, m_newM, m_oldS, m_newS; - -}; - -#endif diff --git a/slsDetectorSoftware/slsDetectorAnalysis/singlePhotonFilter.cpp b/slsDetectorSoftware/slsDetectorAnalysis/singlePhotonFilter.cpp deleted file mode 100644 index ee9dc95e7..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/singlePhotonFilter.cpp +++ /dev/null @@ -1,678 +0,0 @@ - /********************************************//** - * @file singlePhotonFilter.cpp - * @short single photon filter using trees - ***********************************************/ -#include "singlePhotonFilter.h" -#include - - -#define FILE_BUF_SIZE (16*1024*1024) //16mb -#define HEADER_SIZE_NUM_FRAMES 2 -#define HEADER_SIZE_NUM_PACKETS 1 - - -singlePhotonFilter::singlePhotonFilter(int nx, int ny, - int fmask, int pmask, int foffset, int poffset, int pperf, int iValue, - int16_t *m, int16_t *s, CircularFifo* f, int d, int* tfcaught, int* fcaught,uint32_t* cframenum): -#ifdef MYROOT1 - myTree(NULL), -#else - - nHitsPerFile(0), - nTotalHits(0), -#endif - myFile(NULL), - nHitsPerFrame(0), - nChannelsX(nx), - nChannelsY(ny), - nClusterX(CLUSTER_SIZE), - nClusterY(CLUSTER_SIZE), - map(m), - dataSize(d), - mask(s), - nped(DEFAULT_NUM_PEDESTAL), - nsigma(DEFAULT_SIGMA), - nbackground(DEFAULT_BACKGROUND), - outcorr(DEFAULT_CORRECTION), - fnum(0), - pnum(0), - ptot(0), - f0(0), - frame_index_mask(fmask), - packet_index_mask(pmask), - frame_index_offset(foffset), - packet_index_offset(poffset), - packets_per_frame(pperf), - incrementValue(iValue), - firstTime(true), - ret(0), - pIndex(0), - fIndex(0), - thread_started(0), - threads_mask(0x0), - currentThread(-1), - thisThreadIndex(-1), - fileIndex(0), - fifo(f), - totalFramesCaught(tfcaught), - framesCaught(fcaught), - currentframenum(cframenum), - freeFifoCallBack(NULL), - pFreeFifo(NULL){ - //cluster - if (nChannelsX) - nClusterX = 1; - -#ifndef MYROOT1 - //photonHitList=(single_photon_hit**) (new int*[nChannelsX*nChannelsY/(nClusterX*nClusterY)*1000]); - photonHitList=new single_photon_hit*[nChannelsX*nChannelsY/(nClusterX*nClusterY)*1000]; - for (int ii=0; iidata = new double[nClusterX*nClusterY]; - myPhotonHit->x = 0; - myPhotonHit->y = 0; - myPhotonHit->rms = 0; - myPhotonHit->ped = 0; - myPhotonHit->iframe = -1; - - for(int i=0;i < NUM_THREADS; i++){ - /*smp[i] = NULL;*/ - mem0[i]=NULL; - } - numFramesAlloted = new int[NUM_THREADS]; - - strcpy(savefilename,""); - strcpy(filePath,""); - strcpy(fileName,"run"); - - pthread_mutex_init(&write_mutex,NULL); - pthread_mutex_init(&running_mutex,NULL); - pthread_mutex_init(&frnum_mutex,NULL); - - - -} - - -singlePhotonFilter::~singlePhotonFilter(){ - enableCompression(false); - if(numFramesAlloted) delete [] numFramesAlloted; - writeToFile(); - closeFile(); - if(myFile) delete myFile; - if(mask) delete mask; - if(stat) delete stat; - if(nHitStat) delete nHitStat; - /*if(smp) delete []smp;*/ - if(mem0) delete [] mem0; - if(fifo) delete fifo; -} - - - - - - -int singlePhotonFilter::enableCompression(bool enable){ -//#ifdef VERBOSE - cout << "Compression set to " << enable; -#ifdef MYROOT1 - cout << " with root" << endl; -#else - cout << " without root" << endl; -#endif -//#endif - if(enable){ - threads_mask = 0x0; - currentThread = -1; - - for(int i=0; ifindHits(); - return this_pointer; -} - - - -int singlePhotonFilter::initTree(){ -#ifdef MYROOT1 - writeToFile(); - closeFile(); - sprintf(savefilename, "%s/%s_%d_.root", filePath,fileName,fileIndex); - - //file - myFile = new TFile(savefilename, "RECREATE"); /** later return error if it exists */ - cout<<"File created: "<Branch("iframe",&myPhotonHit->iframe,"iframe/I"); - myTree->Branch("x",&myPhotonHit->x,"x/I"); - myTree->Branch("y",&myPhotonHit->y,"y/I"); - myTree->Branch("data",myPhotonHit->data,cdata); - myTree->Branch("pedestal",&myPhotonHit->ped,"pedestal/D"); - myTree->Branch("rms",&myPhotonHit->rms,"rms/D"); -#else - - writeToFile(); - closeFile(); - sprintf(savefilename, "%s/%s_f%012d_%d.raw", filePath,fileName,nTotalHits,fileIndex); - myFile = fopen(savefilename, "w"); - setvbuf(myFile,NULL,_IOFBF,FILE_BUF_SIZE); - cout<<"File created: "<Write(); - nHitsPerFrame = 0; - return OK; - }else - cout << "ERROR: Could not write to " << nHitsPerFrame << " hits to file as file or tree doesnt exist" << endl; -#else - if(myFile){ - int ii; - /*cout<<"writing "<< nHitsPerFrame << " hits to file" << endl;*/ - for (ii=0; iiwrite(myFile); - // delete photonHitList[ii]; - } - // delete photonHitList[ii]; - // photonHitList[0]=new single_photon_hit(nClusterX,nClusterY); - - // fwrite((void*)(photonHitList), 1, sizeof(single_photon_hit)*nHitsPerFrame, myFile); - /*framesInFile += nHitsPerFrame;*/ - nHitsPerFrame = 0; - //cout<<"Exiting writeToFile"<GetCurrentFile(); - myFile->Close(); - myFile = NULL;//delete myFile; - } - myTree = NULL;//delete myTree; - } -#else - if(myFile) - fclose(myFile); - myFile = NULL; -#endif - return OK; -} - - - - - -void singlePhotonFilter::setupAcquisitionParameters(char *outfpath, char* outfname, int outfIndex){ - fileIndex = outfIndex; - strcpy(filePath,outfpath); - strcpy(fileName,outfname); - - fnum = 0; pnum = 0; ptot = 0; f0 = 0; firstTime = true; currentThread = -1; - *framesCaught = 0; - *currentframenum = 0; - - //initialize - for (int ir=0; irClear(); - nHitStat->SetN(nbackground); -#ifndef MYROOT1 - nTotalHits = 0; -#endif -} - - -/* - rets -case 0: waiting for next packet of new frame -case 1: finished with full frame, - start new frame -case -1: last packet of current frame, - invalidate remaining packets, - start new frame -case -2: first packet of new frame, - invalidate remaining packets, - check buffer needs to be pushed, - start new frame with the current packet, - then ret = 0 -case -3: last packet of new frame, - invalidate remaining packets, - check buffer needs to be pushed, - start new frame with current packet, - then ret = -1 (invalidate remaining packets and start a new frame) - */ -int singlePhotonFilter::verifyFrame(char *inData){ - ret = 0; - pIndex = 0; - fIndex = 0; - fIndex = (((uint32_t)(*((uint32_t*)inData)))& frame_index_mask) >> frame_index_offset; - pIndex = (((uint32_t)(*((uint32_t*)inData)))& packet_index_mask) >> packet_index_offset; - - //check validity of packet index - if ((pIndex < 0) && (pIndex >= packets_per_frame)){ - cout << "cannot decode packet index:" << pIndex << endl; - //its already dealt with cuz this frame will be discarded in the end - } - pIndex += incrementValue; - - //for moench, put first packet last - if (pIndex == 0) - pIndex = packets_per_frame; -//#ifdef VERYVERBOSE - cout<<"fi:"<>frame_index_offset); - //progress - if((clusteriframe + PROGRESS_INCREMENT) > *currentframenum){ - pthread_mutex_lock(&frnum_mutex); - *currentframenum = clusteriframe; - pthread_mutex_unlock(&frnum_mutex); - /*cout<<"currentframenum:"<data; - - //for each pixel - for (ir=0; ir= (dataSize))){ - cout << "Bad Channel Mapping index: " << map[currentIndex] << endl; - continue; - } - - //if frame within pedestal number - if (clusteriframe < nped){ - stat[currentIndex].Calc((double)(mask[currentIndex] ^ myData[map[currentIndex]])); - // frame outside pedestal number - }else{ - - dum = 1; - tot = 0; - clusterrms = stat[currentIndex].StandardDeviation();//-1 - clusterped = stat[currentIndex].Mean();//0 - sigmarms = clusterrms * nsigma; - - - clusterData[clusterCenterPixel] = ((double)(mask[currentIndex] ^ myData[map[currentIndex]])) - clusterped; - for (r=-deltaX; r <= deltaX; ++r ){ - if (((ir+r) < 0) || ((ir+r) >= nChannelsX)) - continue; - for(c=-1; c <= 1; ++c){ - if (((ic+c) < 0) || ((ic+c) >= nChannelsY)) - continue; - - - pixelIndex = currentIndex + (r*nChannelsY+c); - - if ((map[pixelIndex] < 0) || (map[pixelIndex] >= dataSize)){ - cout << "Bad Channel Mapping index: " << map[pixelIndex] << endl; - continue; - } - - clusterIndex = pixelIndex-(currentIndex - deltaX * nChannelsY - 1); - clusterData[clusterIndex] = ((double)(mask[pixelIndex] ^ myData[map[pixelIndex]])) - stat[pixelIndex].Mean(); - tot += clusterData[clusterIndex]; - //discard negative events - if (clusterData[clusterIndex] > clusterData[clusterCenterPixel]) - dum = 2; - - } - - } - - - if (tot < sqrtCluster * sigmarms) - dum = 0; - //discard events (for pedestal) where sum of the neighbours is too large. - if (clusterData[clusterCenterPixel] < sigmarms && dum != 0) - dum = 3; - //Appriximated running average - if (clusterData[clusterCenterPixel] > -sigmarms && - clusterData[clusterCenterPixel] < sigmarms && - dum == 0){ - stat[currentIndex].Calc((double)(mask[currentIndex]^myData[map[currentIndex]])); - } - // this is an event and we are in the center - else if (dum == 1){ - pthread_mutex_lock(&write_mutex); -#ifdef MYROOT1 - myTree->Fill(); -#else - for (int ix=0; ixdata[ix] = clusterData[ix]; - - photonHitList[nHitsPerFrame]->x = ic; - photonHitList[nHitsPerFrame]->y = ir; - photonHitList[nHitsPerFrame]->rms = clusterrms; - photonHitList[nHitsPerFrame]->ped = clusterped; - photonHitList[nHitsPerFrame]->iframe = clusteriframe; - //hit.write(myFile); - - nHitsPerFrame++; - - // cout << nHitsPerFrame << " " << nChannelsX*nChannelsY/(nClusterX*nClusterY)*1000 << endl; - - // photonHitList[nHitsPerFrame]=new single_photon_hit(nClusterX,nClusterY); - // cout << "done" << endl; - nHitsPerFile++; - nTotalHits++; - if(nHitsPerFile >= MAX_HITS_PER_FILE-1) - initTree(); -#endif - pthread_mutex_unlock(&write_mutex); - } - - } - } - } - }else{ - //cout<< "did no receiver fulll frame"<Calc((double)nHitsPerFrame); - //write for each frame, not packet - - pthread_mutex_lock(&write_mutex); - cout << "write to file " << nHitsPerFrame << endl; - writeToFile(); - pthread_mutex_unlock(&write_mutex); - - //increment offset - isData += dataSize; - - /* - if ((clusteriframe%1000 == 0) && (clusteriframe != 0) ){ - cout << dec << "Frame: " << clusteriframe << " Hit Avg over last frames: " << - nHitStat->Mean() << " .. "<StandardDeviation() << endl; - cout<<"writing "<< nHitsPerFrame << " hits to file" << endl; - } - */ - } - - pthread_mutex_lock(&write_mutex); - if(freeFifoCallBack) - freeFifoCallBack(freeData,pFreeFifo); - //fifo->push(freeData);//fifo->push(isData); - pthread_mutex_unlock(&write_mutex); - - //thread not running - pthread_mutex_lock(&running_mutex); - threads_mask^=(1<=25000) { - cout<<"*****************problem: "<<((theData-listmem0)/4096)<<" :"< -#include -#include -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "circularFifo.h" -#include "runningStat.h" -#include "movingStat.h" -#include "single_photon_hit.h" - - - -typedef double double32_t; -typedef float float32_t; -typedef int int32_t; -#define MAX_STR_LENGTH 1000 - -/** - return values -*/ -enum { - OK, /**< function succeeded */ - FAIL /**< function failed */ -}; - - -/** - @short class handling trees and its data file - */ - -class singlePhotonFilter{ -public: - /** - * Constructor - * @param nx Number of Channels in X direction - * @param ny Number of Channels in Y direction - * @param fmask frame index mask - * @param pmask packet index mask - * @param foffset frame index offset - * @param poffset packet index offset - * @param pperf packets per frame - * @param iValue increment value (only for gotthard to increment index to have matching frame number) - * @param m Map to data without headers - * @param s mask as to which adcs are inverted - * @param f circular fifo buffer, which needs to be freed - * @param d Size of data with the headers - * @param tfcaught pointer to total frames caught- needs updation for client - * @param fcaught pointer to frames caught - needs updation for client - * @param cframenum pointer to currentframe num- needs updation for progress for gui - */ - singlePhotonFilter( - int nx, - int ny, - int fmask, - int pmask, - int foffset, - int poffset, - int pperf, - int iValue, - int16_t *m, - int16_t *s, - CircularFifo* f, - int d, - int* tfcaught, - int* fcaught, - uint32_t* cframenum); - - /** virtual destructor */ - virtual ~singlePhotonFilter(); - -#ifdef MYROOT1 - /** - * returns tree - */ - TTree *getTree(){ return myTree; }; -#endif - - /** - * Returns packets per frame - */ - int getPacketsPerFrame(){ return packets_per_frame;}; - - /** - * returns struct - */ - single_photon_hit* getStructure(){ return myPhotonHit; }; - - /** Set number of frames to calculate pedestal at beginning */ - void setNPed(int n){ nped = n; }; - - /** Get number of frames to calculate pedestal at beginning */ - int getNPed(){return nped;}; - - /** Set Distance from pedestal to detect a hit */ - void setNSigma(int n){ nsigma = n; }; - - /** Get Distance from pedestal to detect a hit */ - int getNSigma(){return nsigma;}; - - /** Set background */ - void setNBackground(int n){ nbackground = n; }; - - /** Get background */ - int getNBackground(){return nbackground;}; - - /** Set correction */ - void setOutCorr(double d){ outcorr = d; }; - - /** Get correction */ - double getOutCorr(){return outcorr;}; - - /** - * Construct a tree, populate struct for the single photon hit and provide all the masks and offsets - * @param outdir Output file directory/Output file name - * returns OK if successful, else FAIL - - */ - int initTree(); - - /** - * Writes tree/struct to file - * returns OK if successful, else FAIL - */ - int writeToFile(); - - /** - * Closes file - * returns OK if successful, else FAIL - */ - int closeFile(); - - /** - * Reset Indices before starting acquisition - */ - void setupAcquisitionParameters(char *outfpath, char* outfname, int outfIndex); - - /** reconstruct the frame with all the right packets - * @param inData the data from socket to be verified - * returns - * 0: waiting for next packet of new frame - * 1: finished with full frame, - * start new frame - * -1: last packet of current frame, - * invalidate remaining packets, - * start new frame - * -2: first packet of new frame, - * invalidate remaining packets, - * check buffer needs to be pushed, - * start new frame with the current packet, - * then ret = 0 - * -3: last packet of new frame, - * invalidate remaining packets, - * check buffer needs to be pushed, - * start new frame with current packet, - * then ret = -1 (invalidate remaining packets and start a new frame) - */ - int verifyFrame(char *inData); - - /** - * Find Hits frame by frame and save it in file/tree - */ - void findHits(); - - /** Enable or disable compression - * @param enable true to enable compression and false to disable - * returns OK for success or FAIL for failure, incase threads fail to start - * */ - int enableCompression(bool enable); - - /** create threads for compression - * @param this_pointer obejct of this class - * */ - static void* createThreads(void *this_pointer); - - /** assignjobs to each thread - * @param thisData a bunch of frames - * @param numThisData number of frames - * */ - void assignJobsForThread(char *thisData, int numThisData); - - /** Checks if all the threads are done processing - * @param returns 1 for jobs done and 0 for jobs not done - * */ - int checkIfJobsDone(); - - /** - * call back to free fifo - * call back arguments are - * fbuffer buffer address to be freed - */ - void registerCallBackFreeFifo(void (*func)(char*, void*),void *arg){freeFifoCallBack=func; pFreeFifo=arg;}; - - - -private: - -#ifdef MYROOT1 - /** Tree where the hits are stored */ - TTree *myTree; - - /** File where the tree is saved */ - TFile *myFile; -#else - FILE *myFile; - - /** pointer to array of structs when only using files */ - //single_photon_hit* photonHitList; - single_photon_hit ** photonHitList; - - /** Number of Hits per file */ - int nHitsPerFile; - - /** Total Number of Hits Per Acquisition */ - int nTotalHits; -#endif - - /** Number of Hits per frame*/ - int nHitsPerFrame; - - /** Maximum Number of hits written to file */ - const static int MAX_HITS_PER_FILE = 2000000; - - /** Number of Channels in X direction */ - int nChannelsX; - - /** Number of Channels in Y direction */ - int nChannelsY; - - /** Cluster size in X direction */ - int nClusterX; - - /** Cluster size in Y direction */ - int nClusterY; - - /** map to the data without headers */ - int16_t *map; - - /** Size of data with headers */ - int dataSize; - - /** mask as to which adcs are inverted */ - int16_t *mask; - - /** movingStat object */ - movingStat *stat; - - movingStat *nHitStat; - - /** single Photon Hit structure */ - single_photon_hit* myPhotonHit; - - /** Cluster size */ - const static int CLUSTER_SIZE = 3; - - /** Default Number of frames at the beginning to calculate pedestal */ - const static int DEFAULT_NUM_PEDESTAL = 500; - - /** Default Distance from pedestal to detect a hit */ - const static int DEFAULT_SIGMA = 5; - - /** Default Background */ - const static int DEFAULT_BACKGROUND = 1000; - - /** Default Correction Percentage */ - const static double DEFAULT_CORRECTION = 1.0; - - /** Number of frames at the beginning to calculate pedestal */ - int nped; - - /** Distance from pedestal to detect a hit */ - int nsigma; - - /** background */ - int nbackground; - - /** correction */ - double outcorr; - - /** previous frame index */ - unsigned int fnum; - - /** previous packet index */ - unsigned int pnum; - - /** total packets received */ - unsigned int ptot; - - /** first frame number */ - unsigned int f0; - - /** frame index mask */ - int frame_index_mask; - - /** packet index mask */ - int packet_index_mask; - - /** frame index offset */ - int frame_index_offset; - - /** packet index offset */ - int packet_index_offset; - - /** number of packets per frame */ - int packets_per_frame; - - /** increment value for index for gotthard */ - int incrementValue; - - /** first packet */ - bool firstTime; - - /** return status */ - int ret; - - /** current packet index */ - int pIndex; - - /** current frame index */ - int fIndex; - - /** thread related variables */ - static const int NUM_THREADS = 15; - pthread_t find_hits_thread[NUM_THREADS]; - volatile int thread_started; - volatile int threads_mask; - pthread_mutex_t write_mutex; - pthread_mutex_t running_mutex; - pthread_mutex_t frnum_mutex; - - static const int PROGRESS_INCREMENT = 100; - /** current thread the job being allotted to */ - int currentThread; - - /** current index alloted for each thread */ - int thisThreadIndex; - - /** semaphore to synchronize between different jobs on same thread */ - sem_t smp[NUM_THREADS]; - - /** starting memory of data for different threads */ - char* mem0[NUM_THREADS]; - - /** number of frames alloted for each thread to process */ - int* numFramesAlloted; - - - - /** final file name */ - char savefilename[MAX_STR_LENGTH]; - - /** file path */ - char filePath[MAX_STR_LENGTH]; - - /** file prefix */ - char fileName[MAX_STR_LENGTH]; - - /** file acquisition index */ - int fileIndex; - - - /** 0 for 1d and 1 for 2d */ - int deltaX; - - /** index of center of cluster for 1d and for 2d*/ - int clusterCenterPixel; - - /** squareroot of cluster */ - double sqrtCluster; - - /** circular fifo buffer to be freed */ - CircularFifo* fifo; - - /**total frames caught */ - int* totalFramesCaught; - - /** frames caught */ - int* framesCaught; - - /** current frame number */ - uint32_t* currentframenum; - - /** call back function */ - void (*freeFifoCallBack)(char*, void*); - - /** call back arguments */ - void *pFreeFifo; -}; - - - - -#endif diff --git a/slsDetectorSoftware/slsDetectorAnalysis/single_photon_hit.h b/slsDetectorSoftware/slsDetectorAnalysis/single_photon_hit.h deleted file mode 100644 index 278c9f691..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/single_photon_hit.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef SINGLE_PHOTON_HIT_H -#define SINGLE_PHOTON_HIT_h - -typedef double double32_t; -typedef float float32_t; -typedef int int32_t; - -/* /\** */ -/* @short structure for a single photon hit */ -/* *\/ */ -/* typedef struct{ */ -/* double* data; /\**< data size *\/ */ -/* int x; /\**< x-coordinate of the center of hit *\/ */ -/* int y; /\**< x-coordinate of the center of hit *\/ */ -/* double rms; /\**< noise of central pixel *\/ */ -/* double ped; /\**< pedestal of the central pixel *\/ */ -/* int iframe; /\**< frame number *\/ */ -/* }single_photon_hit; */ - - -class single_photon_hit { - - public: - single_photon_hit(int nx, int ny=1): dx(nx), dy(ny) {data=new double[dx*dy];}; - ~single_photon_hit(){delete [] data;}; - void write(FILE *myFile) {fwrite((void*)this, 1, 3*sizeof(int)+2*sizeof(double), myFile); fwrite((void*)data, 1, dx*dy*sizeof(double), myFile);}; - void read(FILE *myFile) {fread((void*)this, 1, 3*sizeof(int)+2*sizeof(double), myFile); fread((void*)data, 1, dx*dy*sizeof(double), myFile);}; - void set_data(double v, int ix, int iy=0){data[(iy+dy/2)*dx+ix+dx/2]=v;}; - double get_data(int ix, int iy=0){return data[(iy+dy/2)*dx+ix+dx/2];}; - - - int x; /**< x-coordinate of the center of hit */ - int y; /**< x-coordinate of the center of hit */ - double rms; /**< noise of central pixel */ - double ped; /**< pedestal of the central pixel */ - int iframe; /**< frame number */ - double *data; /**< data size */ - const int dx; - const int dy; -}; - - - -#endif diff --git a/slsDetectorSoftware/threadFiles/Task.h b/slsDetectorSoftware/threadFiles/Task.h index 585f4a119..9b926aadf 100644 --- a/slsDetectorSoftware/threadFiles/Task.h +++ b/slsDetectorSoftware/threadFiles/Task.h @@ -126,10 +126,10 @@ protected: func3_t * m13; func2_t * m14; func3_t * m15; - func4_t * m16; - func4_t * m17; - func4_t * m18; - func1_t * m19; + func4_t * m16; + func4_t * m17; + func1_t * m18; + func1_t * m19; }; class Task: public virtual SuperTask { @@ -152,10 +152,10 @@ public: Task(func3_t * t): SuperTask(),fnum(13){m13 = t;}; Task(func2_t * t): SuperTask(),fnum(14){m14 = t;}; Task(func3_t * t): SuperTask(),fnum(15){m15 = t;}; - Task(func4_t * t): SuperTask(),fnum(16){m16 = t;}; - Task(func4_t * t): SuperTask(),fnum(17){m17 = t;}; - Task(func4_t * t): SuperTask(),fnum(18){m18 = t;}; - Task(func1_t * t): SuperTask(),fnum(19){m19 = t;}; + Task(func4_t * t): SuperTask(),fnum(16){m16 = t;}; + Task(func4_t * t): SuperTask(),fnum(17){m17 = t;}; + Task(func1_t * t): SuperTask(),fnum(18){m18 = t;}; + Task(func1_t * t): SuperTask(),fnum(19){m19 = t;}; virtual ~Task(){ switch(fnum) { diff --git a/slsDetectorSoftware/usersFunctions/angleFunction.h b/slsDetectorSoftware/usersFunctions/angleFunction.h deleted file mode 100644 index d06adaf3b..000000000 --- a/slsDetectorSoftware/usersFunctions/angleFunction.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef DEFAULT_ANGLE_FUNCTION_H -#define DEFAULT_ANGLE_FUNCTION_H -#include - -/* - contains the conversion channel-angle for a module channel - conv_r=pitch/radius -*/ -#define PI 3.14159265358979323846 -#include - -double defaultAngleFunction(double ichan, double encoder, double totalOffset, double conv_r, double center, double offset, double tilt, int direction) {\ - (void) tilt; - double ang; - - ang=180./PI*(center*conv_r+direction*atan((double)(ichan-center)*conv_r))+encoder+totalOffset+offset; - - - //#ifdef VERBOSE - // printf("%d %f %f %f %f %f %f %d\n", ichan, ang, center, encoder, totalOffset, conv_r, offset, direction); - //#endif - - return ang; \ - return 180./PI*(center*conv_r+direction*atan((double)(ichan-center)*conv_r))+encoder+totalOffset+offset; }; - -#endif diff --git a/slsDetectorSoftware/usersFunctions/usersFunctions.cpp b/slsDetectorSoftware/usersFunctions/usersFunctions.cpp deleted file mode 100644 index 0d7b5318a..000000000 --- a/slsDetectorSoftware/usersFunctions/usersFunctions.cpp +++ /dev/null @@ -1,347 +0,0 @@ -#include "usersFunctions.h" -#include -#include - - -float pos; -float i0=0; -#ifdef EPICS - -#include -#include - -static double timeout = 3.0; - -chid ch_pos,ch_i0, ch_getpos; - - - - -/* connect to a PV */ -int connect_channel(const char *name, chid *ch_id) { - int status = ECA_NORMAL; - status = ca_create_channel(name, NULL, NULL, CA_PRIORITY_DEFAULT, ch_id); - if (status != ECA_NORMAL) - return status; - - status = ca_pend_io(timeout); - return status; -} - -/* disconnect to a PV */ -int disconnect_channel(chid ch_id) -{ - ca_clear_channel(ch_id); - ca_flush_io(); -} - -int caget(chid ch_id, double *value) { - - int status = ECA_NORMAL; - - status = ca_get(DBR_DOUBLE, ch_id, value); - if (status != ECA_NORMAL) { - return status; - } - - status = ca_pend_io(timeout); - if (status != ECA_NORMAL) { - return status; - } - - return status; -} - -int caputq(chid ch_id, double value) { - // does not wait! - int status = ECA_NORMAL; - - status = ca_put(DBR_DOUBLE, ch_id, &value); - if (status != ECA_NORMAL) - return status; - - status = ca_pend_io(timeout); - if (status != ECA_NORMAL) { - return status; - } - - return status; -} - -void put_callback(struct event_handler_args args) -{ - epicsEventId eid = (epicsEventId)args.usr; - epicsEventSignal(eid); -} - -int caput(chid ch_id, double value) { - - // waits! - int status = ECA_NORMAL; - epicsEventId eid = epicsEventCreate(epicsEventEmpty); - - status = ca_put_callback(DBR_DOUBLE, - ch_id, - &value, - put_callback, - eid); - status = ca_pend_io(timeout); - if (status != ECA_NORMAL) - return status; - - if (epicsEventWait(eid) != epicsEventWaitOK) - status = ECA_TIMEOUT; - - return status; -} - -//int main(int argc, char *argv[]) { - - - - - - - - -#endif - - - - - - - -// /* -// contains the conversion channel-angle for a module channel -// conv_r=pitch/radius -// */ - - -// double defaultAngleFunction(double ichan, double encoder, double totalOffset, double conv_r, double center, double offset, double tilt, int direction) { - - -// (void) tilt; /* to avoid warning: unused parameter */ -// double ang; - -// ang=180./PI*(center*conv_r+direction*atan((double)(ichan-center)*conv_r))+encoder+totalOffset+offset; - - -// //#ifdef VERBOSE -// printf("%d %f \n", ichan, ang); -// //#endif - -// return ang; - -// } - -/* reads the encoder and returns the position */ - -double defaultGetPosition(void*) { -#ifdef VERBOSE - printf("Getting motor position \n"); -#endif - // caget X04SA-ES2-TH2:RO.RBV - -#ifdef EPICS - int status; - - double value = 256; - if (ch_getpos<0) return -1; - -/* /\* caget *\/ */ - if (caget(ch_getpos, &value) == ECA_NORMAL) { -#ifdef VERBOSE - printf("caget: %f\n", value); -#endif - pos=value; - } else - printf(ca_message(status)); -#endif - - - - return pos; -} - -/* moves the encoder to position p */ - - -int defaultGoToPosition(double p, void*) { -#ifdef VERBOSE - printf("Setting motor position \n"); -#endif - -#ifdef EPICS - int status; - if (ch_pos<0) return -1; - /* /\* caput and wait until done *\/ */ - if ((status = caput(ch_pos, p)) == ECA_NORMAL) { - ; -#ifdef VERBOSE - printf("caput %f: success\n", p); -#endif - } else - printf(ca_message(status)); -#else - pos=p; -#endif - //"caputq X04SA-ES2-TH2:RO p" - //cawait -nounit -timeout 3600 X04SA-ES2-TH2:RO.DMOV '==1' - - return (int)p; -} - -/* moves the encoder to position p without waiting */ - -int defaultGoToPositionNoWait(double p, void*) { -#ifdef VERBOSE - printf("Setting motor position no wait \n"); -#endif - - -#ifdef EPICS - int status; - if (ch_pos<0) return -1; - /* /\* caput and wait until done *\/ */ - if ((status = caputq(ch_pos, p)) == ECA_NORMAL) { - ; -#ifdef VERBOSE - printf("caputq: success\n"); -#endif - } else - printf(ca_message(status)); -#else - pos=p; -#endif - //"caputq X04SA-ES2-TH2:RO p" - - return (int)p; - - pos=p; - return (int)pos; -} - - -/* reads I0 and returns the intensity */ - -double defaultGetI0(int t, void*) { -#ifdef VERBOSE - printf("Getting I0 readout \n"); -#endif - -#ifdef EPICS - int status; - - double value = 256; -/* /\* caget *\/ */ - if (ch_i0<0) return -1; - if (caget(ch_i0, &value) == ECA_NORMAL) { -#ifdef VERBOSE - printf("caget: %f\n", value); -#endif - - - if (t==0) - i0=value; - else - i0=value-i0; - - - - } else - printf(ca_message(status)); -#else - i0++; -#endif - - //"ca_get X04SA-ES2-SC:CH6" - return i0; - -} - - -int defaultConnectChannels(void *) { -#ifdef EPICS - //double value = 256; - /* channel name */ - //const char *name = "ARIDI-PCT:CURRENT"; - /* channel id */ - /* status code */ - int status; - -#ifdef VERBOSE - printf("starting...\n"); -#endif - - /* init channel access context before any caget/put */ - ca_context_create(ca_enable_preemptive_callback); -#ifdef VERBOSE - printf("context created\n"); -#endif - //"caputq X04SA-ES2-TH2:RO p" - - //"ca_get X04SA-ES2-SC:CH6" - - /* open the channel by name and return ch_id */ - status = connect_channel("X04SA-ES2-SC:CH6", &ch_i0); - if (status == ECA_NORMAL) { -#ifdef VERBOSE - printf("I0 channel connected \n"); -#endif - ; - } else { - printf(ca_message(status)); - //ch_i0=-1;; - } - status = connect_channel("X04SA-ES2-TH2:RO", &ch_pos); - if (status == ECA_NORMAL) { -#ifdef VERBOSE - printf("Detector position channel connected \n"); -#endif - ; - } else { - printf(ca_message(status)); - //ch_i0=-1;; - } - status = connect_channel("X04SA-ES2-TH2:RO.RBV", &ch_getpos); - if (status == ECA_NORMAL) { -#ifdef VERBOSE - printf("Detector get position channel connected \n"); -#endif - ; - } else { - printf(ca_message(status)); - //ch_getpos=-1;; - } - - // caget X04SA-ES2-TH2:RO.RBV - - //cawait -nounit -timeout 3600 X04SA-ES2-TH2:RO.DMOV '==1' -#endif - return 0; -} - -int defaultDisconnectChannels(void*) { -#ifdef EPICS - /* close channel connect */ - disconnect_channel(ch_i0); - disconnect_channel(ch_pos); - disconnect_channel(ch_getpos); - - /* delete channel access context before program exits */ - ca_context_destroy(); -#endif - return 0; -} - - - -int defaultDataReadyFunc(detectorData* d) { -#ifdef VERBOSE - printf("UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU Data received \n"); -#endif - return 0; -} - - diff --git a/slsDetectorSoftware/usersFunctions/usersFunctions.h b/slsDetectorSoftware/usersFunctions/usersFunctions.h deleted file mode 100644 index d2cc60f71..000000000 --- a/slsDetectorSoftware/usersFunctions/usersFunctions.h +++ /dev/null @@ -1,49 +0,0 @@ -#ifndef USERS_FUNCTIONS_H -#define USERS_FUNCTIONS_H -/****************************************************************** - -Functions depending on the experimental setup should be defined here - -******************************************************************/ - -#define PI 3.14159265358979323846 - - -#ifdef EPICS -#include -#include -#endif -#include "detectorData.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef EPICS - int connect_channel(const char *name, chid *ch_id); - int disconnect_channel(chid ch_id); - int caget(chid ch_id, double *value); - int caputq(chid ch_id, double value); - void put_callback(struct event_handler_args args); - int caput(chid ch_id, double value); -#endif - - - // double defaultAngleFunction(double ichan, double encoder, double totalOffset, double conv_r, double center, double offset, double tilt, int direction); - double defaultGetPosition(void*); - int defaultGoToPosition(double p, void*); - int defaultGoToPositionNoWait(double p, void*); - int defaultConnectChannels(void*); - int defaultDisconnectChannels(void*); - double defaultGetI0(int t, void*); - - int defaultDataReadyFunc(detectorData* d, void*); - - - -#ifdef __cplusplus -}; -#endif - - -#endif diff --git a/slsReceiverSoftware/gitInfo.txt b/slsReceiverSoftware/gitInfo.txt index 32c36d448..2ca9c2b3a 100644 --- a/slsReceiverSoftware/gitInfo.txt +++ b/slsReceiverSoftware/gitInfo.txt @@ -1,9 +1,9 @@ Path: slsDetectorsPackage/slsReceiverSoftware URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git -Repsitory UUID: d2bce7e372c241cd235977b92be18555bca6a77d -Revision: 839 -Branch: 4.0.0 +Repsitory UUID: def79807f6f40ed1797b8154240adbc0e35c95e0 +Revision: 840 +Branch: refactor Last Changed Author: Dhanya_Thattil -Last Changed Rev: 4020 -Last Changed Date: 2018-09-27 17:58:04.000000002 +0200 ./src/UDPStandardImplementation.cpp +Last Changed Rev: 4039 +Last Changed Date: 2018-10-02 10:40:58.000000002 +0200 ./include/sls_receiver_defs.h diff --git a/slsReceiverSoftware/include/gitInfoReceiver.h b/slsReceiverSoftware/include/gitInfoReceiver.h index 96c53f374..fbb980f19 100644 --- a/slsReceiverSoftware/include/gitInfoReceiver.h +++ b/slsReceiverSoftware/include/gitInfoReceiver.h @@ -1,6 +1,6 @@ #define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git" -#define GITREPUUID "d2bce7e372c241cd235977b92be18555bca6a77d" +#define GITREPUUID "def79807f6f40ed1797b8154240adbc0e35c95e0" #define GITAUTH "Dhanya_Thattil" -#define GITREV 0x4020 -#define GITDATE 0x20180927 -#define GITBRANCH "4.0.0" +#define GITREV 0x4039 +#define GITDATE 0x20181002 +#define GITBRANCH "refactor" diff --git a/slsReceiverSoftware/include/sls_receiver_defs.h b/slsReceiverSoftware/include/sls_receiver_defs.h index c23558fa8..0903259f1 100755 --- a/slsReceiverSoftware/include/sls_receiver_defs.h +++ b/slsReceiverSoftware/include/sls_receiver_defs.h @@ -67,12 +67,8 @@ public: enum detectorType { GET_DETECTOR_TYPE=-1, /**< the detector will return its type */ GENERIC, /**< generic sls detector */ - MYTHEN, /**< mythen */ - PILATUS, /**< pilatus */ EIGER, /**< eiger */ GOTTHARD, /**< gotthard */ - PICASSO, /**< picasso */ - AGIPD, /**< agipd */ MOENCH, /**< moench */ JUNGFRAU, /**< jungfrau */ JUNGFRAUCTB, /**< jungfrauCTBversion */ @@ -101,7 +97,6 @@ public: FRAME_PERIOD, /**< period between exposures */ DELAY_AFTER_TRIGGER, /**< delay between trigger and start of exposure or readout (in triggered mode) */ GATES_NUMBER, /**< number of gates per frame (in gated mode) */ - PROBES_NUMBER, /**< number of probe types in pump-probe mode */ CYCLES_NUMBER, /**< number of cycles: total number of acquisitions is number or frames*number of cycles */ ACTUAL_TIME, /**< Actual time of the detector's internal timer */ MEASUREMENT_TIME, /**< Time of the measurement from the detector (fifo) */ @@ -234,11 +229,8 @@ public: */ static std::string getDetectorType(detectorType t){ \ switch (t) { \ - case MYTHEN: return std::string("Mythen"); \ - case PILATUS: return std::string("Pilatus"); \ case EIGER: return std::string("Eiger"); \ case GOTTHARD: return std::string("Gotthard"); \ - case AGIPD: return std::string("Agipd"); \ case MOENCH: return std::string("Moench"); \ case JUNGFRAU: return std::string("Jungfrau"); \ case JUNGFRAUCTB: return std::string("JungfrauCTB"); \ @@ -252,11 +244,8 @@ public: \returns Mythen, Pilatus, Eiger, Gotthard, Agipd, Mönch, Unknown */ static detectorType getDetectorType(std::string const type){\ - if (type=="Mythen") return MYTHEN; \ - if (type=="Pilatus") return PILATUS; \ if (type=="Eiger") return EIGER; \ if (type=="Gotthard") return GOTTHARD; \ - if (type=="Agipd") return AGIPD; \ if (type=="Moench") return MOENCH; \ if (type=="Jungfrau") return JUNGFRAU; \ if (type=="JungfrauCTB") return JUNGFRAUCTB; \ diff --git a/slsReceiverSoftware/include/sls_receiver_funcs.h b/slsReceiverSoftware/include/sls_receiver_funcs.h index 281088f19..a380e44b7 100644 --- a/slsReceiverSoftware/include/sls_receiver_funcs.h +++ b/slsReceiverSoftware/include/sls_receiver_funcs.h @@ -34,7 +34,6 @@ enum recFuncs{ F_GET_RECEIVER_STATUS, /**< gets the status of receiver listening mode */ F_START_RECEIVER, /**< starts the receiver listening mode */ F_STOP_RECEIVER, /**< stops the receiver listening mode */ - F_START_RECEIVER_READOUT, /**< acquisition has stopped. start remaining readout in receiver */ //file functions F_SET_RECEIVER_FILE_PATH, /**< sets receiver file directory */