diff --git a/slsDetectorSoftware/Makefile b/slsDetectorSoftware/Makefile index e5899effe..0dabb964a 100644 --- a/slsDetectorSoftware/Makefile +++ b/slsDetectorSoftware/Makefile @@ -1,15 +1,18 @@ CFLAGS= -DC_ONLY #FLAGS=-DVERBOSE -INCLUDES= -IcommonFiles -IslsDetector -IMySocketTCP -IusersFunctions -ImultiSlsDetector -IslsDetectorUtils -IslsDetectorCommand +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=g++ -SRC_CLNT= slsDetector/slsDetector.cpp MySocketTCP/MySocketTCP.cpp usersFunctions/usersFunctions.cpp multiSlsDetector/multiSlsDetector.cpp slsDetector/slsDetectorUtils.cpp slsDetector/slsDetectorCommand.cpp +SRC_CLNT= slsDetectorAnalysis/fileIO.cpp slsDetector/slsDetector.cpp MySocketTCP/MySocketTCP.cpp usersFunctions/usersFunctions.cpp multiSlsDetector/multiSlsDetector.cpp slsDetector/slsDetectorUtils.cpp slsDetector/slsDetectorCommand.cpp slsDetectorAnalysis/angularConversion.cpp slsDetectorAnalysis/energyConversion.cpp slsDetector/slsDetectorActions.cpp slsDetectorAnalysis/postProcessing.cpp OBJS = $(SRC_CLNT:.cpp=.o) +HEADERS = $(SRC_CLNT:.cpp=.h) commonFiles/sls_detector_defs.h slsDetectorAnalysis/detectorData.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 @@ -56,14 +59,8 @@ install_lib: lib install_inc: $(shell test -d $(DESTDIR) || mkdir -p $(DESTDIR)) - cp -P ../slsDetectorSoftware/MySocketTCP/MySocketTCP.h $(DESTDIR) - cp -P ../slsDetectorSoftware/slsDetector/slsDetectorBase.h $(DESTDIR) - cp -P ../slsDetectorSoftware/slsDetector/slsDetector.h $(DESTDIR) - cp -P ../slsDetectorSoftware/slsDetector/slsDetectorUtils.h $(DESTDIR) - cp -P ../slsDetectorSoftware/slsDetector/slsDetectorCommand.h $(DESTDIR) - cp -P ../slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h $(DESTDIR) - cp -P ../slsDetectorSoftware/commonFiles/sls_detector_defs.h $(DESTDIR) - cp -P ../slsDetectorSoftware/usersFunctions/usersFunctions.h $(DESTDIR) + cp -P $(HEADERS) $(DESTDIR) + install_doc: $(shell test -d $(DESTDIR) || mkdir -p $(DESTDIR)) diff --git a/slsDetectorSoftware/commonFiles/sls_detector_defs.h b/slsDetectorSoftware/commonFiles/sls_detector_defs.h index 95631dbb7..21af10e43 100755 --- a/slsDetectorSoftware/commonFiles/sls_detector_defs.h +++ b/slsDetectorSoftware/commonFiles/sls_detector_defs.h @@ -7,7 +7,10 @@ #define MAX_STR_LENGTH 1000 /** 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 typedef float float32_t; typedef int int32_t; @@ -453,26 +456,27 @@ enum imageType { -/** - angular conversion constant for a module - */ -typedef struct { - float center; /**< center of the module (channel at which the radius is perpendicular to the module surface) */ - float ecenter; /**< error in the center determination */ - float r_conversion; /**< detector pixel size (or strip pitch) divided by the diffractometer radius */ - float er_conversion; /**< error in the r_conversion determination */ - float offset; /**< the module offset i.e. the position of channel 0 with respect to the diffractometer 0 */ - float eoffset; /**< error in the offset determination */ - float tilt; /**< ossible tilt in the orthogonal direction (unused)*/ - float etilt; /**< error in the tilt determination */ -} angleConversionConstant; +/* /\** */ +/* angular conversion constant for a module */ +/* *\/ */ +/* typedef struct { */ +/* float center; /\**< center of the module (channel at which the radius is perpendicular to the module surface) *\/ */ +/* float ecenter; /\**< error in the center determination *\/ */ +/* float r_conversion; /\**< detector pixel size (or strip pitch) divided by the diffractometer radius *\/ */ +/* float er_conversion; /\**< error in the r_conversion determination *\/ */ +/* float offset; /\**< the module offset i.e. the position of channel 0 with respect to the diffractometer 0 *\/ */ +/* float eoffset; /\**< error in the offset determination *\/ */ +/* float tilt; /\**< ossible tilt in the orthogonal direction (unused)*\/ */ +/* float etilt; /\**< error in the tilt determination *\/ */ +/* } angleConversionConstant; */ enum angleConversionParameter { ANGULAR_DIRECTION, /**< angular direction of the diffractometer */ GLOBAL_OFFSET, /**< global offset of the diffractometer */ FINE_OFFSET, /**< fine offset of the diffractometer */ - BIN_SIZE /**< angular bin size */ + BIN_SIZE, /**< angular bin size */ + MOVE_FLAG /**< wether the detector moves with the motor or not in a multi detector system */ }; diff --git a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp index 0e25cee3d..bfc35d665 100644 --- a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp +++ b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp @@ -189,6 +189,10 @@ multiSlsDetector::multiSlsDetector(int id) : slsDetectorUtils(), shmId(-1) cout << thisMultiDetector->detectorIds[i] << endl; #endif detectors[i]=new slsDetector(thisMultiDetector->detectorIds[i]); + + + // setAngularConversionPointer(detectors[i]->getAngularConversionPointer(),detectors[i]->getNModsPointer(),detectors[i]->getNChans()*detectors[i]->getNChips(), i); + } for (int i=thisMultiDetector->numberOfDetectors; ilastPID=getpid(); - getPointers(&thisMultiDetector->stoppedFlag, \ - &thisMultiDetector->threadedProcessing, \ - &thisMultiDetector->actionMask, \ - thisMultiDetector->actionScript, \ - thisMultiDetector->actionParameter, \ - thisMultiDetector->nScanSteps, \ - thisMultiDetector->scanMode, \ - thisMultiDetector->scanScript, \ - thisMultiDetector->scanParameter, \ - thisMultiDetector->scanSteps, \ - thisMultiDetector->scanPrecision, \ - &thisMultiDetector->numberOfPositions, \ - thisMultiDetector->detPositions, \ - thisMultiDetector->angConvFile, \ - &thisMultiDetector->correctionMask, \ - &thisMultiDetector->binSize, \ - &thisMultiDetector->fineOffset, \ - &thisMultiDetector->globalOffset, \ - &thisMultiDetector->angDirection, \ - thisMultiDetector->flatFieldDir, \ - thisMultiDetector->flatFieldFile, \ - thisMultiDetector->badChanFile, \ - thisMultiDetector->timerValue, \ - &thisMultiDetector->currentSettings, \ - &thisMultiDetector->currentThresholdEV, \ - thisMultiDetector->filePath, \ - thisMultiDetector->fileName, \ - &thisMultiDetector->fileIndex); + + +// getPointers(&thisMultiDetector->stoppedFlag, \ +// &thisMultiDetector->threadedProcessing, \ +// &thisMultiDetector->actionMask, \ +// thisMultiDetector->actionScript, \ +// thisMultiDetector->actionParameter, \ +// thisMultiDetector->nScanSteps, \ +// thisMultiDetector->scanMode, \ +// thisMultiDetector->scanScript, \ +// thisMultiDetector->scanParameter, \ +// thisMultiDetector->scanSteps, \ +// thisMultiDetector->scanPrecision, \ +// &thisMultiDetector->numberOfPositions, \ +// thisMultiDetector->detPositions, \ +// thisMultiDetector->angConvFile, \ +// &thisMultiDetector->correctionMask, \ +// &thisMultiDetector->binSize, \ +// &thisMultiDetector->fineOffset, \ +// &thisMultiDetector->globalOffset, \ +// &thisMultiDetector->angDirection, \ +// thisMultiDetector->flatFieldDir, \ +// thisMultiDetector->flatFieldFile, \ +// thisMultiDetector->badChanFile, \ +// thisMultiDetector->timerValue, \ +// &thisMultiDetector->currentSettings, \ +// &thisMultiDetector->currentThresholdEV, \ +// thisMultiDetector->filePath, \ +// thisMultiDetector->fileName, \ +// &thisMultiDetector->fileIndex); -// #ifdef VERBOSE -// cout << "filling bad channel mask" << endl; -// #endif -// /** fill the BadChannelMask \sa fillBadChannelMask */ -// fillBadChannelMask(); - -// #ifdef VERBOSE -// cout << "done" << endl; -// #endif + + stoppedFlag=&thisMultiDetector->stoppedFlag; + threadedProcessing=&thisMultiDetector->threadedProcessing; + actionMask=&thisMultiDetector->actionMask; + actionScript=thisMultiDetector->actionScript; + actionParameter=thisMultiDetector->actionParameter; + nScanSteps=thisMultiDetector->nScanSteps; + scanMode=thisMultiDetector->scanMode; + scanScript=thisMultiDetector->scanScript; + scanParameter=thisMultiDetector->scanParameter; + scanSteps=thisMultiDetector->scanSteps; + scanPrecision=thisMultiDetector->scanPrecision; + numberOfPositions=&thisMultiDetector->numberOfPositions; + detPositions=thisMultiDetector->detPositions; + angConvFile=thisMultiDetector->angConvFile; + correctionMask=&thisMultiDetector->correctionMask; + binSize=&thisMultiDetector->binSize; + fineOffset=&thisMultiDetector->fineOffset; + globalOffset=&thisMultiDetector->globalOffset; + angDirection=&thisMultiDetector->angDirection; + flatFieldDir=thisMultiDetector->flatFieldDir; + flatFieldFile=thisMultiDetector->flatFieldFile; + badChanFile=thisMultiDetector->badChanFile; + timerValue=thisMultiDetector->timerValue; + currentSettings=&thisMultiDetector->currentSettings; + currentThresholdEV=&thisMultiDetector->currentThresholdEV; + filePath=thisMultiDetector->filePath; + fileName=thisMultiDetector->fileName; + fileIndex=&thisMultiDetector->fileIndex; + moveFlag=NULL; + + } multiSlsDetector::~multiSlsDetector() { @@ -1617,11 +1646,53 @@ int multiSlsDetector::getFlatFieldCorrection(float *corr, float *ecorr) { +int multiSlsDetector::getNMods(){ + int nm=0; + for (int idet=0; idetnumberOfDetectors; idet++) { + if (detectors[idet]) { + nm+=detectors[idet]->getNMods(); + } + } + return nm; +} + + +int multiSlsDetector::getChansPerMod(int imod){ + int id=-1, im=-1; + if (decodeNMod(imod, id, im)>=0) { + if (detectors[id]) { + return detectors[id]->getChansPerMod(im); + } + } + return -1; + +} + +int multiSlsDetector::getMoveFlag(int imod){ + int id=-1, im=-1; + decodeNMod(imod, id, im); + if (id>=0) { + if (detectors[id]) { + return detectors[id]->getMoveFlag(im); + } + } + //default!!! + return 1; +} +angleConversionConstant * multiSlsDetector::getAngularConversionPointer(int imod){ + int id=-1, im=-1; + if (decodeNMod(imod, id, im)>=0) { + if (detectors[id]) { + return detectors[id]->getAngularConversionPointer(im); + } + } + return NULL; +} @@ -1648,6 +1719,8 @@ int multiSlsDetector::flatFieldCorrect(float* datain, float *errin, float* datao + + int multiSlsDetector::setRateCorrection(float t){ // float tdead[]=defaultTDead; @@ -1831,30 +1904,11 @@ int multiSlsDetector::setBadChannelCorrection(int nbad, int *badlist, int ff) { } -int multiSlsDetector::setAngularConversion(string fname) { - if (fname=="") { - thisMultiDetector->correctionMask&=~(1<< ANGULAR_CONVERSION); - //strcpy(thisDetector->angConvFile,"none"); -#ifdef VERBOSE - std::cout << "Unsetting angular conversion" << std::endl; -#endif - } else { - if (fname=="default") { - fname=string(thisMultiDetector->angConvFile); - } - -#ifdef VERBOSE - std::cout << "Setting angular conversion to " << fname << std:: endl; -#endif - if (readAngularConversion(fname)>=0) { - thisMultiDetector->correctionMask|=(1<< ANGULAR_CONVERSION); - strcpy(thisMultiDetector->angConvFile,fname.c_str()); - } - } - return thisMultiDetector->correctionMask&(1<< ANGULAR_CONVERSION); -} -int multiSlsDetector::readAngularConversion(string fname) { + + + +int multiSlsDetector::readAngularConversionFile(string fname) { ifstream infile; @@ -2022,33 +2076,33 @@ float multiSlsDetector::setAngularConversionParameter(angleConversionParameter c -float* multiSlsDetector::convertAngles(float pos) { - float *ang=new float[thisMultiDetector->numberOfChannels]; +// float* multiSlsDetector::convertAngles(float pos) { +// float *ang=new float[thisMultiDetector->numberOfChannels]; - float *p=ang; - int choff=0; +// float *p=ang; +// int choff=0; - for (int idet=0; idetnumberOfDetectors; idet++) { +// for (int idet=0; idetnumberOfDetectors; idet++) { - if (detectors[idet]) { -#ifdef EPICS - // cout << "convert angle det " << idet << endl; - if (idet<2) -#endif - p=detectors[idet]->convertAngles(pos); -#ifdef EPICS - else //////////// GOOD ONLY AT THE BEAMLINE!!!!!!!!!!!!! - p=detectors[idet]->convertAngles(0); -#endif - for (int ich=0; ichgetTotalNumberOfChannels(); ich++) { - ang[choff+ich]=p[ich]; - } - choff+=detectors[idet]->getTotalNumberOfChannels(); - delete [] p; - } - } - return ang; -} +// if (detectors[idet]) { +// #ifdef EPICS +// // cout << "convert angle det " << idet << endl; +// if (idet<2) +// #endif +// p=detectors[idet]->convertAngles(pos); +// #ifdef EPICS +// else //////////// GOOD ONLY AT THE BEAMLINE!!!!!!!!!!!!! +// p=detectors[idet]->convertAngles(0); +// #endif +// for (int ich=0; ichgetTotalNumberOfChannels(); ich++) { +// ang[choff+ich]=p[ich]; +// } +// choff+=detectors[idet]->getTotalNumberOfChannels(); +// delete [] p; +// } +// } +// return ang; +// } int multiSlsDetector::getBadChannelCorrection(int *bad) { diff --git a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h index cfe587ccc..6c0df4d00 100644 --- a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h +++ b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h @@ -19,7 +19,6 @@ class slsDetector; //#include "sls_detector_defs.h" -#define MAXDET 100 //using namespace std; @@ -137,6 +136,12 @@ class multiSlsDetector : public slsDetectorUtils { /** angular conversion file */ char angConvFile[MAX_STR_LENGTH]; + + + + + + /** array of angular conversion constants for each module \see ::angleConversionConstant */ //angleConversionConstant angOff[MAXMODS]; /** angular direction (1 if it corresponds to the encoder direction i.e. channel 0 is 0, maxchan is positive high angle, 0 otherwise */ @@ -145,12 +150,18 @@ class multiSlsDetector : public slsDetectorUtils { float fineOffset; /** beamline offset (might be a few degrees beacuse of encoder offset - normally it is kept fixed for a long period of time) */ float globalOffset; + /** bin size for data merging */ + float binSize; + + /** number of positions at which the detector should acquire */ int numberOfPositions; /** list of encoder positions at which the detector should acquire */ float detPositions[MAXPOS]; - /** bin size for data merging */ - float binSize; + + + + /** Scans and scripts */ @@ -274,6 +285,14 @@ class multiSlsDetector : public slsDetectorUtils { \returns number of detectors */ int getNumberOfDetectors() {return thisMultiDetector->numberOfDetectors;}; + + + + int getNMods(); + int getChansPerMod(int imod=0); + angleConversionConstant *getAngularConversionPointer(int imod=0); + + int getTotalNumberOfChannels(){return thisMultiDetector->numberOfChannels;}; int getMaxNumberOfChannels(){return thisMultiDetector->maxNumberOfChannels;}; @@ -687,13 +706,12 @@ class multiSlsDetector : public slsDetectorUtils { /////////////////////////////////////////////////// virtual int getAngularConversion(int &direction, angleConversionConstant *angconv=NULL); - int setAngularConversion(string fname); - int readAngularConversion(string fname); + int readAngularConversionFile(string fname); int writeAngularConversion(string fname); - float* convertAngles(float pos); + // float* convertAngles(float pos); @@ -772,10 +790,10 @@ class multiSlsDetector : public slsDetectorUtils { /** calcualtes the total number of steps of the acquisition. called when number of frames, number of cycles, number of positions and scan steps change */ - int setTotalProgress(); + /////////////////////////////////////// int setTotalProgress(); ////////////// from slsDetectorUtils! /** returns the current progress in % */ - float getCurrentProgress(); + ////////////////////////////////float getCurrentProgress();////////////// from slsDetectorUtils! /** @@ -966,6 +984,7 @@ class multiSlsDetector : public slsDetectorUtils { */ int resetCounterBlock(int startACQ=0); + int getMoveFlag(int imod); protected: diff --git a/slsDetectorSoftware/slsDetector/slsDetector.cpp b/slsDetectorSoftware/slsDetector/slsDetector.cpp index 5232d85ba..4ff9feba4 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetector.cpp @@ -41,12 +41,12 @@ int slsDetector::initSharedMemory(detectorType type, int id) { nd=13; // dacs+adcs break; case EIGER: - nch=65535; // one EIGER module + nch=65536; // one EIGER half module nm=1; //modules/detector - nc=8; //chips + nc=4; //chips nd=16; //dacs+adcs default: - nch=0; // one EIGER module + nch=0; // dum! nm=0; //modules/detector nc=0; //chips nd=0; //dacs+adcs @@ -81,9 +81,6 @@ int slsDetector::initSharedMemory(detectorType type, int id) { } - - - /** shm_id returns -1 is shared memory initialization fails */ @@ -111,20 +108,6 @@ int slsDetector::freeSharedMemory() { - - - - - - - - - - - - - - slsDetector::slsDetector(int id) :slsDetectorUtils(), thisDetector(NULL), detId(id), @@ -480,6 +463,7 @@ int slsDetector::initializeDetectorSize(detectorType type) { thisDetector->nModMax[X]=24; thisDetector->nModMax[Y]=1; thisDetector->dynamicRange=24; + thisDetector->moveFlag=1; break; case PICASSO: thisDetector->nChans=128; @@ -635,36 +619,69 @@ int slsDetector::initializeDetectorSize(detectorType type) { cout << "passing pointers" << endl; #endif - getPointers(&thisDetector->stoppedFlag, \ - &thisDetector->threadedProcessing, \ - &thisDetector->actionMask, \ - thisDetector->actionScript, \ - thisDetector->actionParameter, \ - thisDetector->nScanSteps, \ - thisDetector->scanMode, \ - thisDetector->scanScript, \ - thisDetector->scanParameter, \ - thisDetector->scanSteps, \ - thisDetector->scanPrecision, \ - &thisDetector->numberOfPositions, \ - thisDetector->detPositions, \ - thisDetector->angConvFile, \ - &thisDetector->correctionMask, \ - &thisDetector->binSize, \ - &thisDetector->fineOffset, \ - &thisDetector->globalOffset, \ - &thisDetector->angDirection, \ - thisDetector->flatFieldDir, \ - thisDetector->flatFieldFile, \ - thisDetector->badChanFile, \ - thisDetector->timerValue, \ - &thisDetector->currentSettings, \ - &thisDetector->currentThresholdEV, \ - thisDetector->filePath, \ - thisDetector->fileName, \ - &thisDetector->fileIndex); +// getPointers(&thisDetector->stoppedFlag, \ +// &thisDetector->threadedProcessing, \ +// &thisDetector->actionMask, \ +// thisDetector->actionScript, \ +// thisDetector->actionParameter, \ +// thisDetector->nScanSteps, \ +// thisDetector->scanMode, \ +// thisDetector->scanScript, \ +// thisDetector->scanParameter, \ +// thisDetector->scanSteps, \ +// thisDetector->scanPrecision, \ +// &thisDetector->numberOfPositions, \ +// thisDetector->detPositions, \ +// thisDetector->angConvFile, \ +// &thisDetector->correctionMask, \ +// &thisDetector->binSize, \ +// &thisDetector->fineOffset, \ +// &thisDetector->globalOffset, \ +// &thisDetector->angDirection, \ +// thisDetector->flatFieldDir, \ +// thisDetector->flatFieldFile, \ +// thisDetector->badChanFile, \ +// thisDetector->timerValue, \ +// &thisDetector->currentSettings, \ +// &thisDetector->currentThresholdEV, \ +// thisDetector->filePath, \ +// thisDetector->fileName, \ +// &thisDetector->fileIndex); + stoppedFlag=&thisDetector->stoppedFlag; + threadedProcessing=&thisDetector->threadedProcessing; + actionMask=&thisDetector->actionMask; + actionScript=thisDetector->actionScript; + actionParameter=thisDetector->actionParameter; + nScanSteps=thisDetector->nScanSteps; + scanMode=thisDetector->scanMode; + scanScript=thisDetector->scanScript; + scanParameter=thisDetector->scanParameter; + scanSteps=thisDetector->scanSteps; + scanPrecision=thisDetector->scanPrecision; + numberOfPositions=&thisDetector->numberOfPositions; + detPositions=thisDetector->detPositions; + angConvFile=thisDetector->angConvFile; + correctionMask=&thisDetector->correctionMask; + binSize=&thisDetector->binSize; + fineOffset=&thisDetector->fineOffset; + globalOffset=&thisDetector->globalOffset; + angDirection=&thisDetector->angDirection; + flatFieldDir=thisDetector->flatFieldDir; + flatFieldFile=thisDetector->flatFieldFile; + badChanFile=thisDetector->badChanFile; + timerValue=thisDetector->timerValue; + currentSettings=&thisDetector->currentSettings; + currentThresholdEV=&thisDetector->currentThresholdEV; + filePath=thisDetector->filePath; + fileName=thisDetector->fileName; + fileIndex=&thisDetector->fileIndex; + moveFlag=&thisDetector->moveFlag; + + settingsFile=thisDetector->settingsFile; + + // setAngularConversionPointer(thisDetector->angOff,&thisDetector->nMods, thisDetector->nChans*thisDetector->nChips); #ifdef VERBOSE cout << "done" << endl; @@ -741,17 +758,55 @@ int slsDetector::initializeDetectorStructure() { return 0; } -slsDetectorDefs::sls_detector_module* slsDetector::createModule() { +slsDetectorDefs::sls_detector_module* slsDetector::createModule(detectorType t) { sls_detector_module *myMod=(sls_detector_module*)malloc(sizeof(sls_detector_module)); - float *dacs=new float[thisDetector->nDacs]; - float *adcs=new float[thisDetector->nAdcs]; - int *chipregs=new int[thisDetector->nChips]; - int *chanregs=new int[thisDetector->nChips*thisDetector->nChans]; - myMod->ndac=thisDetector->nDacs; - myMod->nadc=thisDetector->nAdcs; - myMod->nchip=thisDetector->nChips; - myMod->nchan=thisDetector->nChips*thisDetector->nChans; + + + int nch, nm, nc, nd, na=0; + + switch(t) { + case MYTHEN: + nch=128; // complete mythen system + nm=24; + nc=10; + nd=6; // dacs + break; + case PICASSO: + nch=128; // complete mythen system + nm=24; + nc=12; + nd=6; // dacs+adcs + break; + case GOTTHARD: + nch=128; + nm=1; + nc=10; + nd=8; // dacs+adcs + na=5; + break; + case EIGER: + nch=65536; // one EIGER half module + nm=1; //modules/detector + nc=4; //chips + nd=16; //dacs + na=16; + default: + nch=0; // dum! + nm=0; //modules/detector + nc=0; //chips + nd=0; //dacs+adcs + na=0; + } + + float *dacs=new float[nd]; + float *adcs=new float[na]; + int *chipregs=new int[nc]; + int *chanregs=new int[nch*nc]; + myMod->ndac=nd; + myMod->nadc=na; + myMod->nchip=nc; + myMod->nchan=nch*nc; myMod->dacs=dacs; myMod->adcs=adcs; @@ -2727,7 +2782,7 @@ slsDetectorDefs::detectorSettings slsDetector::setSettings( detectorSettings ise #ifdef VERBOSE cout << "the settings name is "<myDetectorType, myMod)) { calfname=oscfn.str(); #ifdef VERBOSE cout << calfname << endl; @@ -2750,7 +2805,7 @@ slsDetectorDefs::detectorSettings slsDetector::setSettings( detectorSettings ise cout << settingsfname << endl; cout << calfname << endl; #endif - if (readSettingsFile(settingsfname,myMod)) { + if (readSettingsFile(settingsfname,thisDetector->myDetectorType, myMod)) { calfname=oscfn.str(); readCalibrationFile(calfname,myMod->gain, myMod->offset); setModule(*myMod); @@ -4499,29 +4554,6 @@ int slsDetector::configureMAC(){ //Corrections -int slsDetector::setAngularConversion(string fname) { - if (fname=="") { - thisDetector->correctionMask&=~(1<< ANGULAR_CONVERSION); - //strcpy(thisDetector->angConvFile,"none"); -#ifdef VERBOSE - std::cout << "Unsetting angular conversion" << std::endl; -#endif - } else { - if (fname=="default") { - fname=string(thisDetector->angConvFile); - } - -#ifdef VERBOSE - std::cout << "Setting angular conversion to" << fname << std:: endl; -#endif - if (readAngularConversion(fname)>=0) { - thisDetector->correctionMask|=(1<< ANGULAR_CONVERSION); - strcpy(thisDetector->angConvFile,fname.c_str()); - } - } - return thisDetector->correctionMask&(1<< ANGULAR_CONVERSION); -} - @@ -4550,7 +4582,7 @@ int slsDetector::getAngularConversion(int &direction, angleConversionConstant * - int slsDetector::readAngularConversion(string fname) { + int slsDetector::readAngularConversionFile(string fname) { return readAngularConversion(fname,thisDetector->nModsMax, thisDetector->angOff); @@ -4573,24 +4605,23 @@ int slsDetector::getAngularConversion(int &direction, angleConversionConstant * -float* slsDetector::convertAngles(float pos) { - int imod; - float *ang=new float[thisDetector->nChans*thisDetector->nChips*thisDetector->nMods]; - for (int ip=0; ipnChans*thisDetector->nChips*thisDetector->nMods; ip++) { - imod=ip/(thisDetector->nChans*thisDetector->nChips); - ang[ip]=angle(ip%(thisDetector->nChans*thisDetector->nChips),\ - pos, \ - thisDetector->fineOffset+thisDetector->globalOffset, \ - thisDetector->angOff[imod].r_conversion, \ - thisDetector->angOff[imod].center, \ - thisDetector->angOff[imod].offset, \ - thisDetector->angOff[imod].tilt, \ - thisDetector->angDirection - ); - // cout << imod << " " << thisDetector->angOff[imod].offset << " " << ang[ip] << endl; - } - return ang; -} +// float* slsDetector::convertAngles(float pos) { +// int imod; +// float *ang=new float[thisDetector->nChans*thisDetector->nChips*thisDetector->nMods]; +// for (int ip=0; ipnChans*thisDetector->nChips*thisDetector->nMods; ip++) { +// imod=ip/(thisDetector->nChans*thisDetector->nChips); +// ang[ip]=angle(ip%(thisDetector->nChans*thisDetector->nChips),\ +// pos, \ +// thisDetector->fineOffset+thisDetector->globalOffset, \ +// thisDetector->angOff[imod].r_conversion, \ +// thisDetector->angOff[imod].center, \ +// thisDetector->angOff[imod].offset, \ +// thisDetector->angOff[imod].tilt, \ +// thisDetector->angDirection +// ); +// } +// return ang; +// } @@ -5191,293 +5222,9 @@ int slsDetector::retrieveDetectorSetup(string fname1, int level){ - - - - - - - - - - - - - - - - - - - - - - - - - - - - /* I/O */ - - - slsDetectorDefs::sls_detector_module* slsDetector::readSettingsFile(string fname, sls_detector_module *myMod){ - - int nflag=0; - - - if (myMod==NULL) { - myMod=createModule(); - nflag=1; - } - - string myfname; - string str; - ifstream infile; - ostringstream oss; - int iline=0; - // string names[]={"Vtrim", "Vthresh", "Rgsh1", "Rgsh2", "Rgpr", "Vcal", "outBuffEnable"}; - string sargname; - int ival; - int ichan=0, ichip=0, idac=0; - - - -#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 - infile.open(myfname.c_str(), ios_base::in); - if (infile.is_open()) { - - - switch (thisDetector->myDetectorType) { - - case MYTHEN: - - for (int iarg=0; iargnDacs; 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; ichipnChips; ichip++) { - getline(infile,str); - iline++; -#ifdef VERBOSE - // std::cout<< str << std::endl; -#endif - istringstream ssstr(str); - ssstr >> sargname >> ival; -#ifdef VERBOSE - // std::cout<< "chip " << ichip << " " << sargname << " is " << ival << std::endl; -#endif - - myMod->chipregs[ichip]=ival; - for (ichan=0; ichannChans; ichan++) { - getline(infile,str); -#ifdef VERBOSE - // std::cout<< str << std::endl; -#endif - istringstream ssstr(str); - -#ifdef VERBOSE - // std::cout<< "channel " << ichan+ichip*thisDetector->nChans <<" iline " << iline<< std::endl; -#endif - iline++; - myMod->chanregs[ichip*thisDetector->nChans+ichan]=0; - for (int iarg=0; iarg<6 ; iarg++) { - ssstr >> ival; - //if (ssstr.good()) { - switch (iarg) { - case 0: -#ifdef VERBOSE - // std::cout<< "trimbits " << ival ; -#endif - myMod->chanregs[ichip*thisDetector->nChans+ichan]|=ival&0x3f; - break; - case 1: -#ifdef VERBOSE - //std::cout<< " compen " << ival ; -#endif - myMod->chanregs[ichip*thisDetector->nChans+ichan]|=ival<<9; - break; - case 2: -#ifdef VERBOSE - //std::cout<< " anen " << ival ; -#endif - myMod->chanregs[ichip*thisDetector->nChans+ichan]|=ival<<8; - break; - case 3: -#ifdef VERBOSE - //std::cout<< " calen " << ival ; -#endif - myMod->chanregs[ichip*thisDetector->nChans+ichan]|=ival<<7; - break; - case 4: -#ifdef VERBOSE - //std::cout<< " outcomp " << ival ; -#endif - myMod->chanregs[ichip*thisDetector->nChans+ichan]|=ival<<10; - break; - case 5: -#ifdef VERBOSE - //std::cout<< " counts " << ival << std::endl; -#endif - myMod->chanregs[ichip*thisDetector->nChans+ichan]|=ival<<11; - break; - default: - std::cout<< " too many columns" << std::endl; - break; - } - } - } - // } - } -#ifdef VERBOSE - std::cout<< "read " << ichan*ichip << " channels" <nDacs; iarg++) { - getline(infile,str); - iline++; -#ifdef VERBOSE - std::cout<< str << std::endl; -#endif - istringstream ssstr(str); - ssstr >> sargname >> ival; -#ifdef VERBOSE - std::cout<< sargname << " dac nr. " << idac << " is " << ival << std::endl; -#endif - myMod->dacs[idac]=ival; - idac++; - } - break; - - - default: - std::cout<< "Unknown detector type - don't know how to read file" << myfname << std::endl; - infile.close(); - deleteModule(myMod); - return NULL; - - } - - infile.close(); - strcpy(thisDetector->settingsFile,fname.c_str()); - return myMod; - - } else { - std::cout<< "could not open settings file " << myfname << std::endl; - - if (nflag) - deleteModule(myMod); - - return NULL; - } - -}; - - -int slsDetector::writeSettingsFile(string fname, sls_detector_module mod){ - - ofstream outfile; - - string names[100]; - int id=0; - switch (thisDetector->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 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"; - names[id++]="config"; - names[id++]="HV"; - names[id++]="macaddress"; - names[id++]="ipaddress"; - break; - default: - cout << "Unknown detector type - unknown format for settings file" << endl; - return FAIL; - } - - int iv, ichan, ichip; - int iv1, idac; - int nb; - outfile.open(fname.c_str(), ios_base::out); - - if (outfile.is_open()) { - for (idac=0; idacnChans; ichan++) { - iv=mod.chanregs[ichip*thisDetector->nChans+ichan]; - iv1= (iv&0x3f); - outfile <>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; - } else { - std::cout<< "could not open SETTINGS file " << fname << std::endl; - return FAIL; - } - -}; - - - - int slsDetector::writeSettingsFile(string fname, int imod){ - return writeSettingsFile(fname,detectorModules[imod]); + return writeSettingsFile(fname,thisDetector->myDetectorType, detectorModules[imod]); }; @@ -5500,7 +5247,7 @@ int slsDetector::loadSettingsFile(string fname, int imod) { ostfn << fname << ".sn" << setfill('0') << setw(3) << hex << getId(MODULE_SERIAL_NUMBER, im); fn=ostfn.str(); } - myMod=readSettingsFile(fn); + myMod=readSettingsFile(fn, thisDetector->myDetectorType); if (myMod) { myMod->module=im; setModule(*myMod); @@ -5527,7 +5274,7 @@ int slsDetector::saveSettingsFile(string fname, int imod) { ostringstream ostfn; ostfn << fname << ".sn" << setfill('0') << setw(3) << hex << getId(MODULE_SERIAL_NUMBER, im); if ((myMod=getModule(im))) { - ret=writeSettingsFile(ostfn.str(),*myMod); + ret=writeSettingsFile(ostfn.str(), thisDetector->myDetectorType, *myMod); deleteModule(myMod); } } diff --git a/slsDetectorSoftware/slsDetector/slsDetector.h b/slsDetectorSoftware/slsDetector/slsDetector.h index 725c57126..3cb1b96dc 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.h +++ b/slsDetectorSoftware/slsDetector/slsDetector.h @@ -5,17 +5,9 @@ #define SLS_DETECTOR_H -class MySocketTCP; #include "slsDetectorUtils.h" #include "MySocketTCP.h" -//#include "slsDetectorCommand.h" - - -//enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript, MAX_ACTIONS}; - - - //using namespace std; @@ -54,17 +46,20 @@ Then in your software you should use the class related to the detector you want * @short This is the base class for all SLS detector functionalities * @author Anna Bergamaschi * @version 0.1alpha - - */ -class slsDetector : public slsDetectorUtils { +#define NMODMAXX 24 +#define NMODMAXY 24 +#define NCHIPSMAX 10 +#define NCHANSMAX 65536 +#define NDACSMAX 16 + +class slsDetector : public slsDetectorUtils, public energyConversion { public: - /* /\** online flags enum \sa setOnline*\/ */ /* enum {GET_ONLINE_FLAG=-1, /\**< returns wether the detector is in online or offline state *\/ */ /* OFFLINE_FLAG=0, /\**< detector in offline state (i.e. no communication to the detector - using only local structure - no data acquisition possible!) *\/ */ @@ -180,27 +175,32 @@ typedef struct sharedSlsDetector { /** file with the angular conversion factors */ char angConvFile[MAX_STR_LENGTH]; /** array of angular conversion constants for each module \see ::angleConversionConstant */ - angleConversionConstant angOff[MAXMODS]; + angleConversionConstant angOff[MAXMODS]; /** 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) */ - float fineOffset; + int angDirection; + /** beamline fine offset (of the order of mdeg, might be adjusted for each measurements) */ + float fineOffset; /** beamline offset (might be a few degrees beacuse of encoder offset - normally it is kept fixed for a long period of time) */ - float globalOffset; + float globalOffset; /** number of positions at which the detector should acquire */ - int numberOfPositions; + int numberOfPositions; /** list of encoder positions at which the detector should acquire */ - float detPositions[MAXPOS]; + float detPositions[MAXPOS]; /** bin size for data merging */ float binSize; + /** add encoder value flag (i.e. wether the detector is moving - 1 - or stationary - 0) */ + int moveFlag; + /* infos necessary for the readout to determine the size of the data */ - /** number of rois defined */ - int nROI; - /** list of rois */ - ROI roiLimits[MAX_ROIS]; - /** readout flags */ - readOutFlags roFlags; + + /** number of rois defined */ + int nROI; + /** list of rois */ + ROI roiLimits[MAX_ROIS]; + + /** readout flags */ + readOutFlags roFlags; /* detector setup - not needed */ @@ -268,17 +268,19 @@ typedef struct sharedSlsDetector { - - using slsDetectorUtils::getDetectorType; - using slsDetectorUtils::flatFieldCorrect; - using slsDetectorUtils::rateCorrect; - using slsDetectorUtils::setBadChannelCorrection; + using postProcessing::flatFieldCorrect; + using postProcessing::rateCorrect; + using postProcessing::setBadChannelCorrection; + + using angularConversion::readAngularConversion; + using angularConversion::writeAngularConversion; + + using slsDetectorUtils::getAngularConversion; + + - using slsDetectorUtils::readAngularConversion; - using slsDetectorUtils::writeAngularConversion; - // using slsDetectorBase::getDataFromDetector; @@ -487,40 +489,17 @@ typedef struct sharedSlsDetector { */ int setTrimEn(int nen, int *en=NULL) {if (en) {for (int ien=0; ientrimEnergies[ien]=en[ien]; thisDetector->nTrimEn=nen;} return (thisDetector->nTrimEn);}; - /** - Pure virtual function - reads a trim/settings file - \param fname name of the file to be read - \param myMod pointer to the module structure which has to be set.
If it is NULL a new module structure will be created - \returns the pointer to myMod or NULL if reading the file failed - \sa mythenDetector::readSettingsFile - */ - - sls_detector_module* readSettingsFile(string fname, sls_detector_module* myMod=NULL); - //virtual sls_detector_module* readSettingsFile(string fname, sls_detector_module* myMod=NULL); - - /** - Pure virtual function - 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 - \returns OK or FAIL if the file could not be written - - \sa ::sls_detector_module mythenDetector::writeSettingsFile(string, sls_detector_module) - */ - int writeSettingsFile(string fname, sls_detector_module mod); - //virtual int writeSettingsFile(string fname, sls_detector_module mod); /** - Pure virtual function writes a trim/settings file for module number imod - the values will be read from the current detector structure \param fname name of the file to be written \param imod module number \returns OK or FAIL if the file could not be written \sa ::sls_detector_module sharedSlsDetector mythenDetector::writeSettingsFile(string, int) */ + using energyConversion::writeSettingsFile; int writeSettingsFile(string fname, int imod); @@ -560,7 +539,7 @@ typedef struct sharedSlsDetector { \param fname file to be read \sa angleConversionConstant mythenDetector::readAngularConversion */ - int readAngularConversion(string fname=""); + int readAngularConversionFile(string fname=""); /** @@ -603,6 +582,8 @@ typedef struct sharedSlsDetector { /** Returns the number of modules (without connecting to the detector) */ int getNMods(){return thisDetector->nMods;}; // + + int getChansPerMod(int imod=0){return thisDetector->nChans*thisDetector->nChips;}; /** Returns the number of modules (without connecting to the detector) */ int getMaxMods(){return thisDetector->nModsMax;}; // @@ -1161,14 +1142,7 @@ typedef struct sharedSlsDetector { */ int getBadChannelCorrection(int *bad=NULL); - - /** - set angular conversion - \param fname file with angular conversion constants ("" disable) - \returns 0 if angular conversion disabled, >0 otherwise - \sa mythenDetector::setAngularConversion - */ - int setAngularConversion(string fname=""); + /** pure virtual function get angular conversion @@ -1179,7 +1153,7 @@ typedef struct sharedSlsDetector { */ int getAngularConversion(int &direction, angleConversionConstant *angconv=NULL) ; - + angleConversionConstant *getAngularConversionPointer(int imod=0) {return &thisDetector->angOff[imod];}; @@ -1218,43 +1192,43 @@ typedef struct sharedSlsDetector { int rateCorrect(float* datain, float *errin, float* dataout, float *errout); - /** - pure virtual function - 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 - \sa mythenDetector::resetMerging - */ +/* /\** */ +/* pure virtual function */ +/* 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 */ +/* \sa mythenDetector::resetMerging */ +/* *\/ */ - int resetMerging(float *mp, float *mv,float *me, int *mm); +/* int resetMerging(float *mp, float *mv,float *me, int *mm); */ - /** - pure virtual function - 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 - \sa mythenDetector::addToMerging - */ - int addToMerging(float *p1, float *v1, float *e1, float *mp, float *mv,float *me, int *mm); +/* /\** */ +/* pure virtual function */ +/* 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 */ +/* \sa mythenDetector::addToMerging */ +/* *\/ */ +/* int addToMerging(float *p1, float *v1, float *e1, float *mp, float *mv,float *me, int *mm); */ - /** pure virtual function - calculates the "final" positions, data value and errors for the emrged 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) - \sa mythenDetector::finalizeMerging - */ - int finalizeMerging(float *mp, float *mv,float *me, int *mm); +/* /\** pure virtual function */ +/* calculates the "final" positions, data value and errors for the emrged 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) */ +/* \sa mythenDetector::finalizeMerging */ +/* *\/ */ +/* int finalizeMerging(float *mp, float *mv,float *me, int *mm); */ /** turns off server @@ -1266,7 +1240,15 @@ typedef struct sharedSlsDetector { \returns myMod the pointer to the allocate dmemory location */ - sls_detector_module* createModule(); + sls_detector_module* createModule(){return createModule(thisDetector->myDetectorType);}; + + + /** Allocates the memory for a sls_detector_module structure and initializes it + \returns myMod the pointer to the allocate dmemory location + + */ + sls_detector_module* createModule(detectorType myDetectorType); + /** frees the memory for a sls_detector_module structure \param myMod the pointer to the memory to be freed @@ -1284,7 +1266,7 @@ typedef struct sharedSlsDetector { float getCurrentProgress(); - float* convertAngles(float pos); + // float* convertAngles(float pos); @@ -1376,6 +1358,8 @@ typedef struct sharedSlsDetector { int resetCounterBlock(int startACQ=0); + int getMoveFlag(int imod){if (moveFlag) return *moveFlag; else return 1;}; + protected: diff --git a/slsDetectorSoftware/slsDetector/slsDetectorActions.cpp b/slsDetectorSoftware/slsDetector/slsDetectorActions.cpp new file mode 100644 index 000000000..a20121263 --- /dev/null +++ b/slsDetectorSoftware/slsDetector/slsDetectorActions.cpp @@ -0,0 +1,401 @@ +#include "slsDetectorActions.h" + + + /** + set action + \param iaction can be enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript, MAX_ACTIONS} + \param fname for script ("" disable but leaves script unchanged, "none" disables and overwrites) + \returns 0 if action disabled, >0 otherwise + */ +int slsDetectorActions::setAction(int iaction, string fname, string par) { + + int am; + + + if (iaction>=0 && iaction=0 && iaction=0 && iaction=0 && iaction=0 && iaction0 otherwise + */ +int slsDetectorActions::setScan(int iscan, string script, int nvalues, float *values, string par, int precision) { + if (iscan>=0 && iscan=0) { + if (nvalues==0) + scanMode[iscan]=0; + else { + nScanSteps[iscan]=nvalues; + if (nvalues>MAX_SCAN_STEPS) + nScanSteps[iscan]=MAX_SCAN_STEPS; + } + } + + if (values && scanMode[iscan]>0 ) { + for (int iv=0; iv=0) + scanPrecision[iscan]=precision; + + if (scanMode[iscan]>0){ + *actionMask |= 1<< (iscan+MAX_ACTIONS); + } else { + *actionMask &= ~(1 << (iscan+MAX_ACTIONS)); + } + + + + setTotalProgress(); + + + + + + + + + + + return scanMode[iscan]; + } else + return -1; + +} + +int slsDetectorActions::setScanScript(int iscan, string script) { + if (iscan>=0 && iscan0){ + *actionMask |= (1 << (iscan+MAX_ACTIONS)); + } else { + *actionMask &= ~(1 << (iscan+MAX_ACTIONS)); + } + + setTotalProgress(); + +#ifdef VERBOSE + cout << "Action mask is " << hex << actionMask << dec << endl; +#endif + return scanMode[iscan]; + } else + return -1; +} + + + +int slsDetectorActions::setScanParameter(int iscan, string par) { + + + if (iscan>=0 && iscan=0 && iscan=0) + scanPrecision[iscan]=precision; + return scanMode[iscan]; + } else + return -1; + +} + +int slsDetectorActions::setScanSteps(int iscan, int nvalues, float *values) { + + if (iscan>=0 && iscan=0) { + if (nvalues==0) + scanMode[iscan]=0; + else { + nScanSteps[iscan]=nvalues; + if (nvalues>MAX_SCAN_STEPS) + nScanSteps[iscan]=MAX_SCAN_STEPS; + } + } + + if (values) { + for (int iv=0; iv0){ + *actionMask |= (1 << (iscan+MAX_ACTIONS)); + } else { + *actionMask &= ~(1 << (iscan+MAX_ACTIONS)); + } + +#ifdef VERBOSE + cout << "Action mask is " << hex << actionMask << dec << endl; +#endif + setTotalProgress(); + + + + + return scanMode[iscan]; + + + } else + return -1; + + + + +} + + + + /** + returns scan script + \param iscan can be (0,1) + \returns scan script + */ +string slsDetectorActions::getScanScript(int iscan){ + if (iscan>=0 && iscan=0 && iscan=0 && iscan=0 && iscan=0 && iscan +#include + + + +#define MAX_SCAN_LEVELS 2 + +using namespace std; + +/** + +class implementing the script and scan utilities of the detectors + + +*/ + +class slsDetectorActions : public slsDetectorDefs { + public : + slsDetectorActions(){}; + virtual ~slsDetectorActions(){}; + + /** + set action + \param iaction can be enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript, MAX_ACTIONS} + \param fname for script ("" disable) + \param par for script + \returns 0 if action disabled, >0 otherwise + */ + int setAction(int iaction, string fname="", string par=""); + + /** + 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 + */ + int setActionScript(int iaction, string fname=""); + /** + 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 + */ + int setActionParameter(int iaction, string par=""); + + /** + returns action script + \param iaction can be enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript} + \returns action script + */ + string getActionScript(int iaction); + + /** + returns action parameter + \param iaction can be enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript} + \returns action parameter + */ + string getActionParameter(int iaction); + + /** + returns action mode + \param iaction can be enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript} + \returns action mode + */ + int getActionMode(int iaction); + + + /** + set scan + \param index of the scan (0,1) + \param fname for script ("" disables, "none" disables and overwrites current) + \param nvalues number of steps (0 disables, -1 leaves current value) + \param values pointer to steps (if NULL leaves current values) + \param par parameter for the scan script ("" leaves unchanged) + \returns 0 is scan disabled, >0 otherwise + */ + int setScan(int index, string script="", int nvalues=-1, float *values=NULL, string par="", int precision=-1); + + int setScanScript(int index, string script=""); + int setScanParameter(int index, string par=""); + int setScanPrecision(int index, int precision=-1); + int setScanSteps(int index, int nvalues=-1, float *values=NULL); + float getScanStep(int index, int istep){if (index0 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 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 @@ -273,111 +182,40 @@ class slsDetectorBase : public slsDetectorDefs */ virtual int getRateCorrection(float &t)=0; - /** - get rate correction tau - \returns 0 if rate correction disabled, otherwise the tau used for the correction - */ - virtual float getRateCorrectionTau()=0; - /** get rate correction \returns 0 if rate correction disabled, >0 otherwise */ virtual int getRateCorrection()=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; - - /** - 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; - - /** - 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; - - /** - returns the bad channel list file - */ - virtual string getBadChannelCorrectionFile()=0; - - /** - set angular conversion - \param fname file with angular conversion constants ("" disable) - \returns 0 if angular conversion disabled, >0 otherwise - */ - virtual int setAngularConversion(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 *angconv=NULL)=0; - - /** - pure virtual function - returns the angular conversion file - */ - virtual string getAngularConversion()=0; - - /** - 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 - */ - - virtual float setAngularConversionParameter(angleConversionParameter c, float v)=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 - */ - virtual float getAngularConversionParameter(angleConversionParameter c)=0; - -/* /\** */ -/* writes a data file */ -/* \param name 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' float (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 */ +/* /\** */ +/* returns the bad channel list file */ /* *\/ */ -/* virtual int writeDataFile(string fname, float *data, float *err=NULL, float *ang=NULL, char dataformat='f', int nch=-1)=0; */ +/* virtual string getBadChannelCorrectionFile()=0; */ + + + + + virtual int enableBadChannelCorrection(int i=-1)=0; + + virtual int enableAngularConversion(int i=-1)=0; + + +/* /\** */ +/* set angular conversion */ +/* \param fname file with angular conversion constants ("" disable) */ +/* \returns 0 if angular conversion disabled, >0 otherwise */ +/* *\/ */ +/* virtual int setAngularConversionFile(string fname="")=0; */ + /* /\** */ -/* writes an angular conversion file */ -/* \param fname file to be written */ -/* \return OK/FAIL */ +/* pure virtual function */ +/* returns the angular conversion file */ /* *\/ */ -/* virtual int writeAngularConversion(string fname)=0; */ +/* virtual string getAngularConversionFile()=0; */ + -/* /\** */ -/* set/get if the data processing and file writing should be done by a separate thread - do not use except for debugging! */ -/* \param i 0 sequencial data acquisition and file writing, 1 separate thread, -1 get */ -/* \returns thread flag */ -/* *\/ */ -/* virtual int setThreadedProcessing(int i=-1)=0; */ - /** set positions for the acquisition \param nPos number of positions @@ -393,122 +231,97 @@ class slsDetectorBase : public slsDetectorDefs */ virtual int getPositions(float *pos=NULL)=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, string fname="")=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, 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, string par="")=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, string par="")=0; */ - /** - returns action script - \param iaction can be enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript} - \returns action script - */ - virtual string getActionScript(int iaction)=0; +/* /\** */ +/* returns action script */ +/* \param iaction can be enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript} */ +/* \returns action script */ +/* *\/ */ +/* virtual string getActionScript(int iaction)=0; */ - /** - returns action parameter - \param iaction can be enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript} - \returns action parameter - */ - virtual string getActionParameter(int iaction)=0; +/* /\** */ +/* returns action parameter */ +/* \param iaction can be enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript} */ +/* \returns action parameter */ +/* *\/ */ +/* virtual 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, string script="")=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, 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, string spar="")=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, 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 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, float *values=NULL)=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, float *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 string getScanScript(int index)=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 string getScanScript(int index)=0; */ - /** - get scan script - \param index is the scan index (0 or 1) - \returns scan script parameter - */ - virtual string getScanParameter(int index)=0; +/* /\** */ +/* get scan script */ +/* \param index is the scan index (0 or 1) */ +/* \returns scan script parameter */ +/* *\/ */ +/* virtual 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 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, float *values=NULL)=0; - - /** - gets the network parameters (implemented for gotthard) - \param i network parameter type can be CLIENT_IP, CLIENT_MAC, SERVER_MAC - \returns parameter - - */ - virtual char *getNetworkParameter(networkParameter i)=0; - - /** - sets the network parameters (implemented for gotthard) - \param i network parameter type can be CLIENT_IP, CLIENT_MAC, SERVER_MAC - \param s value to be set - \returns parameter - - */ - virtual char *setNetworkParameter(networkParameter i, string s)=0; - -/** - 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; +/* /\** */ +/* 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, float *values=NULL)=0; */ /** Locks/Unlocks the connection to the server /param lock sets (1), usets (0), gets (-1) the lock @@ -516,19 +329,6 @@ class slsDetectorBase : public slsDetectorDefs */ virtual int lockServer(int i=-1)=0; - /** - Returns the IP of the last client connecting to the detector - */ - virtual string getLastClientIP()=0; - - - - /** - configures mac for gotthard readout - \returns OK or FAIL - */ - - virtual int configureMAC()=0; /** @@ -540,13 +340,6 @@ class slsDetectorBase : public slsDetectorDefs virtual int setNumberOfModules(int i=-1, dimension d=X)=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; - /** set/get dynamic range @@ -589,78 +382,7 @@ class slsDetectorBase : public slsDetectorDefs */ virtual int setThresholdEnergy(int e_eV, int imod=-1, detectorSettings isettings=GET_SETTINGS)=0; - /** - get detector ids/versions for module - \param mode which id/version has to be read - \param imod module number for module serial number - \returns id - */ - virtual int64_t getId(idMode mode, int imod=0)=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; - - /** - ex cute 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; - - - - /** - returns currently the loaded trimfile/settingsfile name - */ - virtual const char *getSettingsFile()=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(string fname, int imod=-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(string fname, int imod=-1)=0; - - - - - - /** - set dacs value - \param val value (in V) - \param index DAC index - \param imod module number (if -1 alla modules) - \returns current DAC value - */ - virtual float setDAC(float val, dacIndex index , int imod=-1)=0; - - - /** - gets ADC value - \param index ADC index - \param imod module number - \returns current ADC value - */ - virtual float getADC(dacIndex index, int imod=0)=0; /** @@ -672,60 +394,6 @@ class slsDetectorBase : public slsDetectorDefs virtual int64_t setTimer(timerIndex index, int64_t t=-1)=0; - /** - get current timer value - \param index timer index - \returns elapsed time value in ns or number of...(e.g. frames, gates, probes) - */ - virtual int64_t getTimeLeft(timerIndex index)=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; - - - - /** 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; - - /** - set/get readout flags - \param flag readout flag to be set - \returns current flag - */ - virtual int setReadOutFlags(readOutFlags flag=GET_READOUT_FLAGS)=0; - /** set/get the external communication mode @@ -736,19 +404,19 @@ class slsDetectorBase : public slsDetectorDefs /** - Reads the configuration file + Reads 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 readConfigurationFile(string const fname)=0; - /** - Writes the configuration file - \param fname file name - \returns OK or FAIL - */ - virtual int writeConfigurationFile(string const fname)=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 */ +/* \returns OK or FAIL */ +/* *\/ */ +/* virtual int writeConfigurationFile(string const fname)=0; */ /** Reads the parameters from the detector and writes them to file diff --git a/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp b/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp index f18fede31..6e833ea93 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp @@ -114,6 +114,13 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) { descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdAngConv; i++; + + descrToFuncMap[i].m_pFuncName="moveflag" ;// + descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdAngConv; + i++; + + + descrToFuncMap[i].m_pFuncName="threaded"; // descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdThreaded; i++; @@ -1508,9 +1515,9 @@ string slsDetectorCommand::cmdAngConv(int narg, char *args[], int action){ if (sval=="none") sval=""; - myDet->setAngularConversion(sval); + myDet->setAngularConversionFile(sval); - return string(myDet->getAngularConversion()); + return string(myDet->getAngularConversionFile()); } else if (action==GET_ACTION) { if (narg>1) sval=string(args[1]); @@ -1522,7 +1529,7 @@ string slsDetectorCommand::cmdAngConv(int narg, char *args[], int action){ myDet->writeAngularConversion(sval.c_str()); return sval; } - return string(myDet->getAngularConversion()); + return string(myDet->getAngularConversionFile()); } else { return string("none"); } @@ -1541,6 +1548,8 @@ string slsDetectorCommand::cmdAngConv(int narg, char *args[], int action){ } else if (string(args[0])==string("angdir")) { c=ANGULAR_DIRECTION; + } else if (string(args[0])==string("moveflag")) { + c=MOVE_FLAG; } else return string("could not decode angular conversion parameter ")+cmd; diff --git a/slsDetectorSoftware/slsDetector/slsDetectorUtils.cpp b/slsDetectorSoftware/slsDetector/slsDetectorUtils.cpp index 6f207057d..77eec9d68 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorUtils.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetectorUtils.cpp @@ -5,1271 +5,8 @@ #include -slsDetectorUtils::slsDetectorUtils() : queuesize(0), - currentPosition(0), - currentPositionIndex(0), - currentI0(0), - mergingBins(NULL), - mergingCounts(NULL), - mergingErrors(NULL), - mergingMultiplicity(NULL), - badChannelMask(NULL) +slsDetectorUtils::slsDetectorUtils() {}; -{ - pthread_mutex_t mp1 = PTHREAD_MUTEX_INITIALIZER; - mp=mp1; - pthread_mutex_init(&mp, NULL); - mg=mp1; - pthread_mutex_init(&mg, NULL); -} - - -int slsDetectorUtils::getPointers(int * const l_stoppedFlag, \ - int * const l_threadedProcessing, \ - int * const l_actionMask, \ - mystring * const l_actionScript, \ - mystring * const l_actionParameter, \ - int * const l_nScanSteps, \ - int * const l_scanMode, \ - mystring * const l_scanScript, \ - mystring * const l_scanParameter, \ - mysteps * const l_scanSteps, \ - int * const l_scanPrecision, \ - int * const l_numberOfPositions, \ - float * const l_detPositions, \ - char * const l_angConvFile, \ - int * const l_correctionMask, \ - float * const l_binSize, \ - float * const l_fineOffset, \ - float * const l_globalOffset, \ - int * const l_angDirection, \ - char * const l_flatFieldDir, \ - char * const l_flatFieldFile, \ - char * const l_badChanFile, \ - int64_t * const l_timerValue, \ - detectorSettings * const l_currentSettings, \ - int * const l_currentThresholdEV, \ - char * const l_filePath, \ - char * const l_fileName, \ - int * const l_fileIndex) -{ - - stoppedFlag=l_stoppedFlag; - threadedProcessing=l_threadedProcessing; - actionMask=l_actionMask; - actionScript=l_actionScript; - actionParameter=l_actionParameter; - - nScanSteps=l_nScanSteps; - scanSteps=l_scanSteps; - scanScript=l_scanScript; - scanParameter=l_scanParameter; - scanMode=l_scanMode; - scanPrecision=l_scanPrecision; - - numberOfPositions=l_numberOfPositions; - detPositions=l_detPositions; - angConvFile=l_angConvFile; - correctionMask=l_correctionMask; - binSize=l_binSize; - fineOffset=l_fineOffset; - globalOffset=l_globalOffset; - angDirection=l_angDirection; - flatFieldDir=l_flatFieldDir; - flatFieldFile=l_flatFieldFile; - badChanFile=l_badChanFile; - // nBadChans=l_nBadChans; - // badChansList=l_badChansList; - // nBadFF=l_nBadFF; - // badFFList=l_badFFList; - timerValue=l_timerValue; - currentSettings=l_currentSettings; - currentThresholdEV=l_currentThresholdEV; - filePath=l_filePath; - fileName=l_fileName; - fileIndex=l_fileIndex; - -#ifdef VERBOSE - cout << "pointer to badChannelMask is "<< badChannelMask << endl; -#endif - fillBadChannelMask(); -#ifdef VERBOSE - cout << "pointer to badChannelMask is "<< badChannelMask << endl; -#endif - return OK; - - -} - - - -string slsDetectorUtils::createFileName(char *filepath, char *filename, int aMask, float sv0, int prec0, float 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 slsDetectorUtils::createFileName() { - return createFileName(filePath, \ - fileName, \ - *actionMask, \ - currentScanVariable[0], \ - scanPrecision[0], \ - currentScanVariable[1], \ - scanPrecision[1], \ - currentPositionIndex, \ - *numberOfPositions, \ - *fileIndex\ - ); - -} - - - -int slsDetectorUtils::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 slsDetectorUtils::getVariablesFromFileName(string fname, int &index, int &p_index, float &sv0, float &sv1) { - - int i; - float 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 slsDetectorUtils::flatFieldCorrect(float datain, float errin, float &dataout, float &errout, float ffcoefficient, float fferr){ - float 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.; - - return 0; -}; - - - int slsDetectorUtils::rateCorrect(float datain, float errin, float &dataout, float &errout, float tau, float t){ - - // float data; - float 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 slsDetectorUtils::setBadChannelCorrection(string fname, int &nbad, int *badlist){ - ifstream infile; - string str; - int interrupt=0; - int ich; - int chmin,chmax; -#ifdef VERBOSE - std::cout << "Setting bad channel correction to " << fname << std::endl; -#endif - - if (fname=="" || fname=="none") { - nbad=0; - return 0; - } else { - infile.open(fname.c_str(), ios_base::in); - if (infile.is_open()==0) { - std::cout << "could not open file " << fname <> 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 && nbad> 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; - } - - - - - -int slsDetectorUtils:: 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; -} - - - - -int slsDetectorUtils:: writeAngularConversion(ofstream& outfile, int nmod, angleConversionConstant *angOff) { - - for (int imod=0; imod0) { - 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; -} - - - - - -int slsDetectorUtils::addToMerging(float *p1, float *v1, float *e1, float *mp, float *mv,float *me, int *mm, int nchans, float binsize,int angDir, int cm, int *badChanMask ) { - - float binmi=-180., binma; - int ibin=0; - // int imod; - float ang=0, angold; - - - binmi=-180.; - binma=binmi+binsize; -#ifdef VERBOSE - cout << "pointer to badchan mask is " << badChanMask << endl; -#endif - - // if (angDir>0) { - for (int ip=0; ipang) { - ibin--; - binmi-=binsize; - binma-=binsize; - } - } - if (ibin<(360./binsize) && ibin>=0) { - angold=ang; - mp[ibin]+=ang; - mv[ibin]+=v1[ip]; - if (e1) - me[ibin]+=(e1[ip]*e1[ip]); - else - me[ibin]+=v1[ip]; - mm[ibin]++; - } else - return FAIL; - } - -// } else { -// for (int ip=nchans-1; ip>=0; ip--) { -// if ((cm)&(1<< DISCARD_BAD_CHANNELS)) { -// if (badChanMask[ip]) -// continue; - -// } - -// while (binma0) - binsize=*binSize; - else - return FAIL; - - return resetMerging(mp, mv, me, mm, binsize); -} - - -int slsDetectorUtils::finalizeMerging(float *mp, float *mv, float *me, int *mm) { - float binsize; - - if (*binSize>0) - binsize=*binSize; - else - return FAIL; - - return finalizeMerging(mp, mv, me, mm, binsize); -} - - - - - - -int slsDetectorUtils::addToMerging(float *p1, float *v1, float *e1, float *mp, float *mv,float *me, int *mm) { - - float binsize; - - - - // int ibin=0; - // int imod; - - int del=0; - - if (*binSize>0) - binsize=*binSize; - else - return FAIL; - - if (p1==NULL) { - - del=1; - p1=convertAngles(currentPosition); - - } - - int ret=addToMerging(p1, v1, e1, mp, mv,me, mm,getTotalNumberOfChannels(), binsize,*angDirection, *correctionMask, badChannelMask ); - - - if (del) { - delete [] p1; - p1=NULL; - } - return ret; -} - - - - -int slsDetectorUtils::writeDataFile(string fname, int nch, float *data, float *err, float *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 slsDetectorUtils::writeDataFile(ofstream &outfile, int nch, float *data, float *err, float *ang, char dataformat, int offset){ - - - int idata; - if (data==NULL) - return FAIL; - - // args|=0x10; // one line per channel! - - - 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 slsDetectorUtils::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 slsDetectorUtils::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 slsDetectorUtils::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 slsDetectorUtils::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 slsDetectorUtils::writeDataFile(string fname, float *data, float *err, float *ang, char dataformat, int nch){ - if (nch==-1) - nch=getTotalNumberOfChannels(); - - return writeDataFile(fname, nch, data, err, ang, dataformat); - -} -int slsDetectorUtils::writeDataFile(ofstream &outfile, float *data, float *err, float *ang, char dataformat, int nch, int offset){ - if (nch==-1) - nch=getTotalNumberOfChannels(); - - return writeDataFile(outfile, nch, data, err, ang, dataformat, offset); - -} - - - - -int slsDetectorUtils::writeDataFile(string fname, int *data){ - - return writeDataFile(fname, getTotalNumberOfChannels(), data); -} - -int slsDetectorUtils::writeDataFile(ofstream &outfile, int *data, int offset){ - - return writeDataFile(outfile, getTotalNumberOfChannels(), data, offset); -} - - - - - -int slsDetectorUtils::writeDataFile(string fname, short int *data){ - - return writeDataFile(fname, getTotalNumberOfChannels(), data); -} - -int slsDetectorUtils::writeDataFile(ofstream &outfile, short int *data, int offset){ - - return writeDataFile(outfile, getTotalNumberOfChannels(), data, offset); -} - - - - -int slsDetectorUtils::readDataFile(string fname, float *data, float *err, float *ang, char dataformat) { - return readDataFile(getTotalNumberOfChannels(), fname, data, err, ang, dataformat); - -} - -int slsDetectorUtils::readDataFile(ifstream &infile, float *data, float *err, float *ang, char dataformat, int offset) { - return readDataFile(getTotalNumberOfChannels(), infile, data, err, ang, dataformat, offset); - -} - - - -int slsDetectorUtils::readDataFile(string fname, int *data){ - - return readDataFile(fname, data, getTotalNumberOfChannels()); -}; - - -int slsDetectorUtils::readDataFile(ifstream &infile, int *data, int offset){ - - return readDataFile(infile, data, getTotalNumberOfChannels(), offset); -}; - - - - - -int slsDetectorUtils::readDataFile(string fname, short int *data){ - - return readDataFile(fname, data, getTotalNumberOfChannels()); -}; - - -int slsDetectorUtils::readDataFile(ifstream &infile, short int *data, int offset){ - - return readDataFile(infile, data, getTotalNumberOfChannels(),offset); -}; - - - -int slsDetectorUtils::readCalibrationFile(string fname, float &gain, float &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(); - } else { - std::cout<< "Could not open calibration file "<< fname << std::endl; - gain=0.; - offset=0.; - return -1; - } - return 0; -}; - -int slsDetectorUtils::writeCalibrationFile(string fname, float gain, float 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; - return -1; - } - - outfile.close(); - - return 0; -}; - - @@ -1501,11 +238,11 @@ void slsDetectorUtils::acquire(int delflag){ *currentSettings, \ *currentThresholdEV, \ getBadChannelCorrectionFile().c_str(), \ - getAngularConversion().c_str(), \ + angularConversion::getAngularConversionFile().c_str(), \ *globalOffset, \ *fineOffset,\ - getFlatFieldCorrectionDir(),\ - getFlatFieldCorrectionFile(), \ + getFlatFieldCorrectionDir().c_str(),\ + getFlatFieldCorrectionFile().c_str(), \ getRateCorrectionTau(),\ getActionParameter(headerBefore).c_str()\ ); @@ -1578,11 +315,11 @@ void slsDetectorUtils::acquire(int delflag){ *currentSettings, \ *currentThresholdEV, \ getBadChannelCorrectionFile().c_str(), \ - getAngularConversion().c_str(), \ + angularConversion::getAngularConversionFile().c_str(), \ *globalOffset, \ *fineOffset, \ - getFlatFieldCorrectionDir(), \ - getFlatFieldCorrectionFile(), \ + getFlatFieldCorrectionDir().c_str(), \ + getFlatFieldCorrectionFile().c_str(), \ getRateCorrectionTau(), \ getActionParameter(headerAfter).c_str()); #ifdef VERBOSE @@ -1690,1232 +427,10 @@ void slsDetectorUtils::acquire(int delflag){ - - - - -void slsDetectorUtils::processFrame(int *myData, int delflag) { - - string fname; - float *fdata; - - progressIndex++; - //#ifdef VERBOSE - cout << fixed << setprecision(2) << setw (6) << getCurrentProgress() << " \%"; -#ifdef VERBOSE - cout << endl; -#else - cout << "\r" << flush; -#endif - - //process data - /** decode data */ - fdata=decodeData(myData); - - fname=createFileName(); - - - //uses static function?!?!?!? - // writeDataFile (fname+string(".raw"), getTotalNumberOfChannels(),fdata, NULL, NULL, 'i'); - writeDataFile (fname+string(".raw"),fdata, NULL, NULL, 'i'); - - doProcessing(fdata,delflag); - - delete [] myData; - myData=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 slsDetectorUtils::doProcessing(float *fdata, int delflag) { - - - float *rcdata=NULL, *rcerr=NULL; - float *ffcdata=NULL, *ffcerr=NULL; - float *ang=NULL; - float bs=0.004; - // int imod; - int nb; - int np; - string ext; - string fname; - detectorData *thisData; - - - - if (*correctionMask!=0) { - ext=".dat"; - } else { - ext=".raw"; - } - - fname=createFileName(); - - /** write raw data file */ - if (*correctionMask==0 && delflag==1) { - delete [] fdata; - } else { - - /** rate correction */ - if (*correctionMask&(1<0) { -#ifdef VERBOSE - cout << "**************Current position index is " << currentPositionIndex << endl; -#endif - // if (*numberOfPositions>0) { - if (currentPositionIndex<=1) { - if (*binSize>0) - bs=*binSize; - else - *binSize=bs; - - - nb=(int)(360./bs)+1; - -#ifdef VERBOSE - cout << "creating merging arrays "<< nb << endl; -#endif - mergingBins=new float[nb]; - mergingCounts=new float[nb]; - mergingErrors=new float[nb]; - mergingMultiplicity=new int[nb]; -#ifdef VERBOSE - cout << "reset merging " << endl; -#endif - resetMerging(mergingBins, mergingCounts,mergingErrors, mergingMultiplicity, bs); - } - -#ifdef VERBOSE - cout << "add to merging "<< currentPositionIndex << endl; -#endif - addToMerging(ang, ffcdata, ffcerr, mergingBins, mergingCounts,mergingErrors, mergingMultiplicity, getTotalNumberOfChannels(), bs, *angDirection, *correctionMask, badChannelMask ); - -#ifdef VERBOSE - cout << currentPositionIndex << " " << (*numberOfPositions) << endl; - -#endif - - - pthread_mutex_lock(&mp); - if ((currentPositionIndex>=(*numberOfPositions) && posfinished==1 && queuesize==1)) { - -#ifdef VERBOSE - cout << "finalize merging " << currentPositionIndex<< endl; -#endif - np=finalizeMerging(mergingBins, mergingCounts,mergingErrors, mergingMultiplicity, bs); - /** file writing */ - - currentPositionIndex++; - pthread_mutex_unlock(&mp); - - - fname=createFileName(); - -#ifdef VERBOSE - cout << "writing merged data file" << endl; -#endif - writeDataFile (fname+string(".dat"),np,mergingCounts, mergingErrors, mergingBins,'f'); -#ifdef VERBOSE - cout << " done" << endl; -#endif - - - - if (delflag) { - - if (mergingBins) { - delete [] mergingBins; - mergingBins=NULL; - } - if (mergingCounts) { - delete [] mergingCounts; - mergingCounts=NULL; - } - if (mergingErrors) { - delete [] mergingErrors; - mergingErrors=NULL; - } - if (mergingMultiplicity){ - delete [] mergingMultiplicity; - mergingMultiplicity=NULL; - } -#ifdef VERBOSE - cout << "deleting merged data done " << endl; -#endif - } else { - thisData=new detectorData(mergingCounts,mergingErrors,mergingBins,getCurrentProgress(),(fname+string(ext)).c_str(),np); - - pthread_mutex_lock(&mg); - finalDataQueue.push(thisData); - pthread_mutex_unlock(&mg); - } - pthread_mutex_lock(&mp); - } - 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+string(ext)).c_str(),getTotalNumberOfChannels()); - pthread_mutex_lock(&mg); - finalDataQueue.push(thisData); - pthread_mutex_unlock(&mg); - } - } - } - (*fileIndex)++; -#ifdef VERBOSE - cout << "Incrementing file index " << *fileIndex << endl; -#endif - - -} - - - - - - - - -void* slsDetectorUtils::processData(int delflag) { - - -#ifdef VERBOSE - std::cout<< " processing data - threaded mode " << *threadedProcessing << endl; -#endif - - setTotalProgress(); - //cout << "thread mutex lock line 6505" << endl; - pthread_mutex_lock(&mp); - queuesize=dataQueue.size(); - pthread_mutex_unlock(&mp); - //cout << "thread mutex unlock line 6505" << endl; - - int *myData; -// float *fdata=NULL; -// float *rcdata=NULL, *rcerr=NULL; -// float *ffcdata=NULL, *ffcerr=NULL; -// float *ang=NULL; -// float bs=0.004; -// // int imod; -// int nb; -// int np; -// detectorData *thisData; - int dum=1; -// string ext; -// string fname; - - - - while(dum | *threadedProcessing) { // ???????????????????????? - - - // while( !dataQueue.empty() ) { - // cout << "thread mutex lock line 6539" << endl; - pthread_mutex_lock(&mp); - while((queuesize=dataQueue.size())>0) { - -#ifdef VERBOSE - // std::cout<< " queue size " << queuesize << endl; -#endif - - // cout << "thread mutex unlock line 6543" << endl; - //queuesize=dataQueue.size(); - - /** Pop data queue */ - myData=dataQueue.front(); // get the data from the queue - pthread_mutex_unlock(&mp); - - - if (myData) { - - processFrame(myData,delflag); - -// progressIndex++; -// //#ifdef VERBOSE -// cout << fixed << setprecision(2) << setw (6) << getCurrentProgress() << " \%"; -// #ifdef VERBOSE -// cout << endl; -// #else -// cout << "\r" << flush; -// #endif - -// //process data -// /** decode data */ -// fdata=decodeData(myData); - -// fname=createFileName(); - - -// //uses static function?!?!?!? -// // writeDataFile (fname+string(".raw"), getTotalNumberOfChannels(),fdata, NULL, NULL, 'i'); -// writeDataFile (fname+string(".raw"),fdata, NULL, NULL, 'i'); - - -// /** write raw data file */ -// if (*correctionMask==0 && delflag==1) { -// delete [] fdata; -// } else { - -// /** rate correction */ -// if (*correctionMask&(1<0 || delflag==0) { - -// if (currentPositionIndex<=1) { -// if (*binSize>0) -// bs=*binSize; -// else -// *binSize=bs; - - -// nb=(int)(360./bs)+1; - -// #ifdef VERBOSE -// // cout << "creating merging arrays "<< nb << endl; -// #endif -// mergingBins=new float[nb]; -// mergingCounts=new float[nb]; -// mergingErrors=new float[nb]; -// mergingMultiplicity=new int[nb]; - -// #ifdef VERBOSE -// cout << mergingBins<< " "<< mergingCounts<< " "<< mergingErrors<< " "<< mergingMultiplicity<< " " << endl; -// #endif - -// #ifdef VERBOSE -// // cout << "reset merging " << endl; -// #endif -// resetMerging(mergingBins, mergingCounts,mergingErrors, mergingMultiplicity, bs); -// } -// } -// /* it would be better to create an ang0 with 0 encoder position and add to merging/write to file simply specifying that offset so that when it cycles writing the data or adding to merging it also calculates the angular position */ - -// #ifdef VERBOSE -// // cout << "convert angles" << endl; -// #endif -// ang=convertAngles(currentPosition); - -// // if (*correctionMask!=0) { -// // if (*numberOfPositions>1) { -// //uses static function?!?!?!? -// //writeDataFile (fname+string(".dat"), getTotalNumberOfChannels(), ffcdata, ffcerr,ang); -// #ifdef VERBOSE -// // cout << "Write angular converted file for position " << currentPositionIndex << endl; -// #endif - -// writeDataFile (fname+string(".dat"), ffcdata, ffcerr,ang); -// // } -// // } -// #ifdef VERBOSE -// // cout << "add to merging "<< currentPositionIndex << endl; -// #endif -// if (*numberOfPositions>0 || delflag==0) { -// addToMerging(ang, ffcdata, ffcerr, mergingBins, mergingCounts,mergingErrors, mergingMultiplicity, getTotalNumberOfChannels(), bs, *angDirection, *correctionMask, badChannelMask ); - -// #ifdef VERBOSE -// cout << currentPositionIndex << " " << (*numberOfPositions) << endl; - -// #endif - - -// pthread_mutex_lock(&mp); -// if ((currentPositionIndex>=(*numberOfPositions) && posfinished==1 && queuesize==1)) { - - -// // if ((currentPositionIndex>=(*numberOfPositions)) || (currentPositionIndex==0)) { -// #ifdef VERBOSE -// // cout << "finalize merging " << currentPositionIndex<< endl; -// #endif -// np=finalizeMerging(mergingBins, mergingCounts,mergingErrors, mergingMultiplicity, bs); -// /** file writing */ - - - - -// currentPositionIndex++; -// pthread_mutex_unlock(&mp); - - -// fname=createFileName(); - - -// #ifdef VERBOSE -// // cout << "writing merged data file" << endl; -// #endif -// writeDataFile (fname+string(".dat"),np,mergingCounts, mergingErrors, mergingBins,'f'); -// #ifdef VERBOSE -// // cout << " done" << endl; -// #endif - - - -// if (delflag) { -// #ifdef VERBOSE -// // cout << mergingBins<< " " << mergingCounts<< " " << mergingErrors << " " << mergingMultiplicity << " " << endl; -// #endif - -// if (mergingBins) { -// #ifdef VERBOSE -// // cout << "deleting merged bins "<< mergingBins << " size " << sizeof(mergingBins) << endl; -// #endif -// delete [] mergingBins; -// mergingBins=NULL; -// } -// if (mergingCounts) { -// #ifdef VERBOSE -// // cout << "deleting merged counts "<< mergingCounts << endl; -// #endif -// delete [] mergingCounts; -// mergingCounts=NULL; -// } -// if (mergingErrors) { -// #ifdef VERBOSE -// // cout << "deleting merged errors "<< mergingErrors << endl; -// #endif -// delete [] mergingErrors; -// mergingErrors=NULL; -// } -// if (mergingMultiplicity){ -// #ifdef VERBOSE -// // cout << "deleting merged multiplicity "<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; -} - - - - - - - /* - set positions for the acquisition - \param nPos number of positions - \param pos array with the encoder positions - \returns number of positions - */ -int slsDetectorUtils::setPositions(int nPos, float *pos){ - if (nPos>=0) - *numberOfPositions=nPos; - for (int ip=0; ip0 otherwise - */ -int slsDetectorUtils::setAction(int iaction, string fname, string par) { - - int am; - - - if (iaction>=0 && iaction=0 && iaction=0 && iaction=0 && iaction=0 && iaction0 otherwise - */ -int slsDetectorUtils::setScan(int iscan, string script, int nvalues, float *values, string par, int precision) { - if (iscan>=0 && iscan=0) { - if (nvalues==0) - scanMode[iscan]=0; - else { - nScanSteps[iscan]=nvalues; - if (nvalues>MAX_SCAN_STEPS) - nScanSteps[iscan]=MAX_SCAN_STEPS; - } - } - - if (values && scanMode[iscan]>0 ) { - for (int iv=0; iv=0) - scanPrecision[iscan]=precision; - - if (scanMode[iscan]>0){ - *actionMask |= 1<< (iscan+MAX_ACTIONS); - } else { - *actionMask &= ~(1 << (iscan+MAX_ACTIONS)); - } - - - - setTotalProgress(); - - - - - - - - - - - return scanMode[iscan]; - } else - return -1; - -} - -int slsDetectorUtils::setScanScript(int iscan, string script) { - if (iscan>=0 && iscan0){ - *actionMask |= (1 << (iscan+MAX_ACTIONS)); - } else { - *actionMask &= ~(1 << (iscan+MAX_ACTIONS)); - } - - setTotalProgress(); - -#ifdef VERBOSE - cout << "Action mask is " << hex << actionMask << dec << endl; -#endif - return scanMode[iscan]; - } else - return -1; -} - - - -int slsDetectorUtils::setScanParameter(int iscan, string par) { - - - if (iscan>=0 && iscan=0 && iscan=0) - scanPrecision[iscan]=precision; - return scanMode[iscan]; - } else - return -1; - -} - -int slsDetectorUtils::setScanSteps(int iscan, int nvalues, float *values) { - - if (iscan>=0 && iscan=0) { - if (nvalues==0) - scanMode[iscan]=0; - else { - nScanSteps[iscan]=nvalues; - if (nvalues>MAX_SCAN_STEPS) - nScanSteps[iscan]=MAX_SCAN_STEPS; - } - } - - if (values) { - for (int iv=0; iv0){ - *actionMask |= (1 << (iscan+MAX_ACTIONS)); - } else { - *actionMask &= ~(1 << (iscan+MAX_ACTIONS)); - } - -#ifdef VERBOSE - cout << "Action mask is " << hex << actionMask << dec << endl; -#endif - setTotalProgress(); - - - - - return scanMode[iscan]; - - - } else - return -1; - - - - -} - - - - /** - returns scan script - \param iscan can be (0,1) - \returns scan script - */ -string slsDetectorUtils::getScanScript(int iscan){ - if (iscan>=0 && iscan=0 && iscan=0 && iscan=0 && iscan=0 && iscan=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; + + + /** + returns currently the loaded trimfile/settingsfile name + */ + virtual const char *getSettingsFile()=0; + + + /** + get current timer value + \param index timer index + \returns elapsed time value in ns or number of...(e.g. frames, gates, probes) + */ + virtual int64_t getTimeLeft(timerIndex index)=0; + + + + /** 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; + + + + + + + + + + + /** 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 char* getSettingsDir()=0; + + /** sets the detector trimbit/settings directory */ + virtual char* setSettingsDir(string s)=0; + + /** + returns the location of the calibration files + */ + virtual char* getCalDir()=0; + + /** + sets the location of the calibration files + */ + virtual char* setCalDir(string s)=0; + /** Frees the shared memory - should not be used except for debugging*/ virtual int freeSharedMemory()=0; @@ -154,509 +326,6 @@ class slsDetectorUtils : public slsDetectorBase { - /** generates file name without extension - - always appends to file path and file name the run index. - - in case also appends the position index - - Filenames will be of the form: filepath/filename(_px)_i - where 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, float sv0, int prec0, float sv1, int prec1, int pindex, int npos, int findex); - - virtual string createFileName(); - - - /** static function that returns the file index from the file name - \param fname file name - \returns file index*/ - static 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, float &sv0, float &sv1); - - - - - - /** - - writes a data file - \param name 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' float (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, float *data, float *err=NULL, float *ang=NULL, char dataformat='f', int nch=-1); - int writeDataFile(ofstream &outfile, float *data, float *err=NULL, float *ang=NULL, char dataformat='f', int nch=-1, int offset=0); - - - /** - - writes a data file - \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 - */ - virtual int writeDataFile(string fname, int *data); - int writeDataFile(ofstream &outfile, int *data, int offset=0); - - - /** - - writes a data file - \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 - */ - virtual int writeDataFile(string fname, short int *data); - int writeDataFile(ofstream &outfile, short int *data, int offset=0); - - - /** - - 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' float (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 - - */ - virtual int readDataFile(string fname, float *data, float *err=NULL, float *ang=NULL, char dataformat='f'); - int readDataFile(ifstream& infile, float *data, float *err=NULL, float *ang=NULL, char dataformat='f', int offset=0); - - /** - - 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 - */ - virtual int readDataFile(string fname, int *data); - int readDataFile(ifstream &infile, int *data, int offset=0); - - /** - - 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 - */ - virtual int readDataFile(string fname, short int *data); - int readDataFile(ifstream &infile, short int *data, int offset=0); - - /** - - writes a data file - \param name 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' float (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 - - */ - - static int writeDataFile(string fname, int nch, float *data, float *err=NULL, float *ang=NULL, char dataformat='f'); - static int writeDataFile(ofstream &outfile, int nch, float *data, float *err=NULL, float *ang=NULL, char dataformat='f', int offset=0); - - /** - - writes a data file - \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 - */ - static int writeDataFile(string fname,int nch, int *data); - static int writeDataFile(ofstream &outfile,int nch, int *data, int offset=0); - - /** - - writes a data file - \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 - */ - static int writeDataFile(string fname,int nch, short int *data); - static int writeDataFile(ofstream &outfile,int nch, short int *data, int offset=0); - /** - - 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' float (default) - \param nch number of channels to be written to file. if <=0 defaults to the number of installed channels of the detector - \returns number of channels read or -1 if it could not read the file or data=NULL - - \sa mythenDetector::readDataFile - */ - static int readDataFile(int nch, string fname, float *data, float *err=NULL, float *ang=NULL, char dataformat='f'); - static int readDataFile(int nch, ifstream &infile, float *data, float *err=NULL, float *ang=NULL, char dataformat='f', int offset=0); - - /** - - 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 - */ - static int readDataFile(string fname, int *data, int nch); - static int readDataFile(ifstream &infile, int *data, int nch, int offset); - - /** - - 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 - */ - static int readDataFile(string fname, short int *data, int nch); - static int readDataFile(ifstream &infile, short int *data, int nch, int offset); - - /** - - reads an angular conversion file - \param fname file to be read - */ - static int readAngularConversion(string fname, int nmod, angleConversionConstant *angOff); - - /** - - reads an angular conversion file - \param fname file to be read - */ - static int readAngularConversion(ifstream& ifs, int nmod, angleConversionConstant *angOff); - /** - writes an angular conversion file - \param fname file to be written - \sa angleConversionConstant mythenDetector::writeAngularConversion - */ - static int writeAngularConversion(string fname, int nmod, angleConversionConstant *angOff); - /** - writes an angular conversion file - \param fname file to be written - \sa angleConversionConstant mythenDetector::writeAngularConversion - */ - static int writeAngularConversion(ofstream& ofs, int nmod, angleConversionConstant *angOff); - - - - virtual int writeAngularConversion(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 - */ - static int setBadChannelCorrection(string fname, int &nbad, int *badlist); - - - /** - 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); - /** - pure virtual function - 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 - \sa mythenDetector::resetMerging - */ - static int resetMerging(float *mp, float *mv,float *me, int *mm, float binsize); - int resetMerging(float *mp, float *mv,float *me, int *mm); - - /** - pure virtual function - 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 - \sa mythenDetector::addToMerging - */ - - static int addToMerging(float *p1, float *v1, float *e1, float *mp, float *mv,float *me, int *mm, int nchans, float binsize,int angDirection, int correctionMask, int *badChanMask ); - - int addToMerging(float *p1, float *v1, float *e1, float *mp, float *mv,float *me, int *mm); - - /** pure virtual function - calculates the "final" positions, data value and errors for the emrged 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) - \sa mythenDetector::finalizeMerging - */ - - static int finalizeMerging(float *mp, float *mv,float *me, int *mm, float binsize); - - int finalizeMerging(float *mp, float *mv,float *me, int *mm); - - - - - - /** - - reads a calibration file - \param fname file to be read - \param gain reference to the gain variable - \offset reference to the offset variable - \sa sharedSlsDetector mythenDetector::readCalibrationFile - */ - static int readCalibrationFile(string fname, float &gain, float &offset); - //virtual int readCalibrationFile(string fname, float &gain, float &offset); - - /** - - writes a calibration file - \param fname file to be written - \param gain - \param offset - \sa sharedSlsDetector mythenDetector::writeCalibrationFile - */ - static int writeCalibrationFile(string fname, float gain, float offset); - //virtual int writeCalibrationFile(string fname, float gain, float offset); - - - - - /** - sets the default output files path - */ - char* setFilePath(string s) {sprintf(filePath, s.c_str()); return filePath;}; - - /** - sets the default output files root name - */ - char* setFileName(string s) {sprintf(fileName, s.c_str()); return fileName;}; - - /** - sets the default output file index - */ - int setFileIndex(int i) {*fileIndex=i; return *fileIndex;}; - - /** - returns the default output files path - \sa sharedSlsDetector - */ - char* getFilePath() {return filePath;}; - - /** - returns the default output files root name - */ - char* getFileName() {return fileName;}; - - /** - returns the default output file index - */ - int getFileIndex() {return *fileIndex;}; - - - - - /** - - 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, float *pos); - /** - get positions for the acquisition - \param pos array which will contain the encoder positions - \returns number of positions - */ - int getPositions(float *pos=NULL); - - - - - - /** - set action - \param iaction can be enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript, MAX_ACTIONS} - \param fname for script ("" disable) - \param par for script - \returns 0 if action disabled, >0 otherwise - */ - int setAction(int iaction, string fname="", string par=""); - - /** - 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 - */ - int setActionScript(int iaction, string fname=""); - /** - 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 - */ - int setActionParameter(int iaction, string par=""); - - /** - returns action script - \param iaction can be enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript} - \returns action script - */ - string getActionScript(int iaction); - - /** - returns action parameter - \param iaction can be enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript} - \returns action parameter - */ - string getActionParameter(int iaction); - - /** - returns action mode - \param iaction can be enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript} - \returns action mode - */ - int getActionMode(int iaction); - - - /** - set scan - \param index of the scan (0,1) - \param fname for script ("" disables, "none" disables and overwrites current) - \param nvalues number of steps (0 disables, -1 leaves current value) - \param values pointer to steps (if NULL leaves current values) - \param par parameter for the scan script ("" leaves unchanged) - \returns 0 is scan disabled, >0 otherwise - */ - int setScan(int index, string script="", int nvalues=-1, float *values=NULL, string par="", int precision=-1); - - int setScanScript(int index, string script=""); - int setScanParameter(int index, string par=""); - int setScanPrecision(int index, int precision=-1); - int setScanSteps(int index, int nvalues=-1, float *values=NULL); - float getScanStep(int index, int istep){if (index=0) *threadedProcessing=b; return *threadedProcessing;} - - - - - /** Loads dark image or gain image to the detector \param index can be DARK_IMAGE or GAIN_IMAGE @@ -686,116 +355,11 @@ s - - - - - - /** - pure virtual function - set detector global offset - \sa mythenDetector::setGlobalOffset + 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. */ - float setGlobalOffset(float f){return setAngularConversionParameter(GLOBAL_OFFSET,f);}; - - /** - pure virtual function - set detector fine offset - \sa mythenDetector::setFineOffset - */ - float setFineOffset(float f){return setAngularConversionParameter(FINE_OFFSET,f);}; - /** - pure virtual function - get detector fine offset - \sa mythenDetector::getFineOffset - */ - float getFineOffset(){return getAngularConversionParameter(FINE_OFFSET);}; - - /** - pure virtual function - get detector global offset - \sa mythenDetector::getGlobalOffset - */ - float getGlobalOffset(){return getAngularConversionParameter(GLOBAL_OFFSET);}; - - - - /** pure virtual function - set detector bin size used for merging (approx angular resolution) - \param bs bin size in degrees - \returns current bin size - \sa mythenDetector::setBinSize -*/ - float setBinSize(float bs){return setAngularConversionParameter(BIN_SIZE,bs);}; - - /** pure virtual function - return detector bin size used for merging (approx angular resolution) - \sa mythenDetector::getBinSize - */ - float getBinSize() {return getAngularConversionParameter(BIN_SIZE);}; - - - /** - 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 - */ - - float setAngularConversionParameter(angleConversionParameter c, float v); - - /** - returns the value of an angular conversion parameter - \param c can be ANGULAR_DIRECTION, GLOBAL_OFFSET, FINE_OFFSET, BIN_SIZE - \returns the actual value - - */ - - float getAngularConversionParameter(angleConversionParameter c); - - - - - - /** - pure virtual function - returns the angular conversion file - \sa mythenDetector::getAngularConversion */ - string getAngularConversion(){if ((*correctionMask)&(1<< ANGULAR_CONVERSION)) return string(angConvFile); else return string("none");}; - - - /** 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 - */ - char *getFlatFieldCorrectionDir(){return flatFieldDir;}; - /** - set flat field corrections file directory - \param flat field correction file directory - \returns flat field correction file directory - */ - char *setFlatFieldCorrectionDir(string dir){strcpy(flatFieldDir,dir.c_str()); return flatFieldDir;}; - - /** - get flat field corrections file name - \returns flat field correction file name - */ - char *getFlatFieldCorrectionFile(){ if ((*correctionMask)&(1< dataQueue; - /** - queue containing the postprocessed data - */ - queue finalDataQueue; - - - - private: - - - - int totalProgress; - - int progressIndex; - int *stoppedFlag; - int *threadedProcessing; - - - int *actionMask; - mystring *actionScript; - mystring *actionParameter; - - int *nScanSteps; - mysteps *scanSteps; - int *scanMode; - int *scanPrecision; - mystring *scanScript; - mystring *scanParameter; - - int *numberOfPositions; - float *detPositions; - - - char *angConvFile; - int *correctionMask; - float *binSize; - float *fineOffset; - float *globalOffset; - int *angDirection; - - char *flatFieldDir; - char *flatFieldFile; - - char *badChanFile; - int *nBadChans; - int *badChansList; - int *nBadFF; - int *badFFList; + //protected: + int *stoppedFlag; int64_t *timerValue; detectorSettings *currentSettings; int *currentThresholdEV; - char *filePath; - char *fileName; - int *fileIndex; - - /** 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 size */ - int queuesize; - - - - - /** - current position of the detector - */ - float currentPosition; - /** - current position index of the detector - */ - int currentPositionIndex; - - /** - I0 measured - */ - float currentI0; - - - - - /** - current scan variable of the detector - */ - float currentScanVariable[MAX_SCAN_LEVELS]; - - /** - current scan variable index of the detector - */ - int currentScanIndex[MAX_SCAN_LEVELS]; - - - - /** merging bins */ - float *mergingBins; - - /** merging counts */ - float *mergingCounts; - - /** merging errors */ - float *mergingErrors; - - /** merging multiplicity */ - int *mergingMultiplicity; - - - - - /** pointer to bad channel mask 0 is channel is good 1 if it is bad \sa fillBadChannelMask() */ - int *badChannelMask; - - - /** - start data processing thread - */ - void startThread(int delflag=1); // - /** the data processing thread */ - - pthread_t dataProcessingThread; - - /* /\** */ -/* 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; */ - + int totalProgress; + + int progressIndex; + }; -static void* startProcessData(void *n){\ - slsDetectorUtils *myDet=(slsDetectorUtils*)n;\ - myDet->processData(1);\ - pthread_exit(NULL);\ - -}; - -static void* startProcessDataNoDelete(void *n){\ - slsDetectorUtils *myDet=(slsDetectorUtils*)n;\ - myDet->processData(0);\ - pthread_exit(NULL);\ - -}; - - #endif diff --git a/slsDetectorSoftware/slsDetectorAnalysis/Makefile b/slsDetectorSoftware/slsDetectorAnalysis/Makefile new file mode 100644 index 000000000..1b137d512 --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/Makefile @@ -0,0 +1,87 @@ +#--------------------------------------------------- + + +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 new file mode 100644 index 000000000..707a4e35b --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/Makefile.arch @@ -0,0 +1,575 @@ +# -*- 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 new file mode 100644 index 000000000..4cbd4858d --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/TSlsDetectorDict.cpp @@ -0,0 +1,691 @@ +// +// 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((float) 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((float) 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((float) G__double(libp->para[0]), (float) 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(*(float*) G__Floatref(&libp->para[0]), *(float*) G__Floatref(&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 new file mode 100644 index 000000000..0d2cea9fb --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/TSlsDetectorDict.h @@ -0,0 +1,42 @@ +/******************************************************************** +* 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/angularCalibration.cpp b/slsDetectorSoftware/slsDetectorAnalysis/angularCalibration.cpp new file mode 100644 index 000000000..362e80555 --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/angularCalibration.cpp @@ -0,0 +1,471 @@ +#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; + float 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, float startangle, float stopangle) { + +// int i,nfit,mod,npoints,nnpoints; +// float x[MAXINMODULE],y[MAXINMODULE],ex[MAXINMODULE],ey[MAXINMODULE],min,max; +// float 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 + + //float angle(int ichan, float encoder, float totalOffset, float conv_r, float center, float offset, float tilt, int direction) + + + +/** + angular conversion constant for a module + */ +typedef struct { + float center; /**< center of the module (channel at which the radius is perpendicular to the module surface) */ + float ecenter; /**< error in the center determination */ + float r_conversion; /**< detector pixel size (or strip pitch) divided by the diffractometer radius */ + float er_conversion; /**< error in the r_conversion determination */ + float offset; /**< the module offset i.e. the position of channel 0 with respect to the diffractometer 0 */ + float eoffset; /**< error in the offset determination */ + float tilt; /**< ossible tilt in the orthogonal direction (unused)*/ + float etilt; /**< error in the tilt determination */ +} angleConversionConstant; + + + +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 + */ + float setEncoder(float f) {encoder=f; return encoder;}; + + /** + gets the encoder position + \returns encoder position + */ + float getEncoder() {return encoder;}; + + /** + sets the totalOffset of the detector + \param f total offset to be set + \returns current total offset + */ + float setTotalOffset(float f) {totalOffset=f; return totalOffset;}; + + /** + gets the encoder position + \returns encoder position + */ + float 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(float mi, float 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(float &mi, float &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 + float encoder; /**< position of the detector encoder */ + float totalOffset; /**< total offset of the detector */ + float ang_min; /**< minimum of the angular range for peak fitting*/ + float ang_max; /**< maximum of the angular range for peak fitting */ + + int nmod; + int nchmod; + + angleConversionConstant *angConv; + + + + + +/* void fitangle(char fname[80],char extension[10], int start, int stop, float startangle, float stopangle); //fits all datasets and extracts the constants */ +/* int fitpeak(char fname[80],char extension[10], int nr, float minang, float maxang); // fits a peak from a pattern using nominal calibration constant */ + + +}; + +#endif diff --git a/slsDetectorSoftware/slsDetectorAnalysis/angularConversion.cpp b/slsDetectorSoftware/slsDetectorAnalysis/angularConversion.cpp new file mode 100644 index 000000000..ea999360b --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/angularConversion.cpp @@ -0,0 +1,481 @@ +#include "angularConversion.h" + +#include +#include +#include +#include +#include "usersFunctions.h" + +using namespace std; + +angularConversion::angularConversion(): currentPosition(0), + currentPositionIndex(0) +{ + + +} + +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; +// } + + + + +float* angularConversion::convertAngles(float pos) { + int imod; + float *ang=new float[getTotalNumberOfChannels()]; + float enc=pos; + angleConversionConstant *p=NULL; + for (int ip=0; ipr_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; + float center, ecenter; + float r_conv, er_conv; + float 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) { + 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(float *p1, float *v1, float *e1, float *mp, float *mv,float *me, int *mm, int nchans, float binsize,int nbins, int *badChanMask ) { + + float binmi=-180.; + int ibin=0; + + 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]++; + } else + return FAIL; + } + + + return OK; + +} + +int angularConversion::deleteMerging() { + + if (mergingBins) + delete [] mergingBins; + + if (mergingCounts) + delete [] mergingCounts; + + if (mergingErrors) + delete [] mergingErrors; + +} + + +int angularConversion::resetMerging() { + + mergingBins=new float[nBins]; + + + mergingCounts=new float[nBins]; + + + mergingErrors=new float[nBins]; + + + mergingMultiplicity=new int[nBins]; + + return resetMerging(mergingBins, mergingCounts, mergingErrors, mergingMultiplicity); + +} + +int angularConversion::resetMerging(float *mp, float *mv, float *me, int *mm) { + 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(float *mp, float *mv, float *me, int *mm) { + + if (nBins) + return finalizeMerging(mp, mv, me, mm, nBins); + else + return FAIL; +} + +int angularConversion::addToMerging(float *p1, float *v1, float *e1, int *badChanMask ) { + + return addToMerging(p1,v1,e1,mergingBins,mergingCounts, mergingErrors, mergingMultiplicity, badChanMask); + + +} + + +int angularConversion::addToMerging(float *p1, float *v1, float *e1, float *mp, float *mv,float *me, int *mm, int *badChanMask ) { + + + int del=0; + + if (*binSize==0) + return FAIL; + + if (nBins==0) + 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 + */ + +float angularConversion::setAngularConversionParameter(angleConversionParameter c, float 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 + + */ + +float angularConversion::getAngularConversionParameter(angleConversionParameter c) { + + switch (c) { + case ANGULAR_DIRECTION: + return *angDirection; + case GLOBAL_OFFSET: + return *globalOffset; + case FINE_OFFSET: + return *fineOffset; + case BIN_SIZE: + return *binSize; + case MOVE_FLAG: + return *moveFlag; + 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, float *pos){ + if (nPos>=0) + *numberOfPositions=nPos; + for (int ip=0; ip +#include + + + + //float angle(int ichan, float encoder, float totalOffset, float conv_r, float center, float offset, float tilt, int direction) + + +using namespace std; + +/** + angular conversion constant for a module + */ +typedef struct { + float center; /**< center of the module (channel at which the radius is perpendicular to the module surface) */ + float ecenter; /**< error in the center determination */ + float r_conversion; /**< detector pixel size (or strip pitch) divided by the diffractometer radius */ + float er_conversion; /**< error in the r_conversion determination */ + float offset; /**< the module offset i.e. the position of channel 0 with respect to the diffractometer 0 */ + float eoffset; /**< error in the offset determination */ + float tilt; /**< ossible tilt in the orthogonal direction (unused)*/ + float etilt; /**< error in the tilt determination */ +} angleConversionConstant; + + +/** + class containing the methods to set/unset the angular conversion and merge the data + The angular conversion itself is stored in the slsDetector/multiSlsDetector class! + +*/ +class angularConversion : public slsDetectorDefs { + + public: + angularConversion(); + virtual ~angularConversion(); + + + + //virtual int readAngularConversion(string fname)=0; + + + + + /** + + reads an angular conversion file + \param fname file to be read + */ + static int readAngularConversion(string fname, int nmod, angleConversionConstant *angOff); + + /** + + MOVE TO ANGULAR CALIBRATION?!?!??!? + reads an angular conversion file + \param fname file to be read + */ + static int readAngularConversion(ifstream& ifs, int nmod, angleConversionConstant *angOff); + /** + MOVE TO ANGULAR CALIBRATION?!?!??!? + writes an angular conversion file + \param fname file to be written + \sa angleConversionConstant mythenDetector::writeAngularConversion + */ + static int writeAngularConversion(string fname, int nmod, angleConversionConstant *angOff); + /** + MOVE TO ANGULAR CALIBRATION?!?!??!? + writes an angular conversion file + \param fname file to be written + \sa angleConversionConstant mythenDetector::writeAngularConversion + */ + static int writeAngularConversion(ofstream& ofs, int nmod, angleConversionConstant *angOff); + + virtual int writeAngularConversion(string fname)=0; + + /** + MOVE TO ANGULAR CALIBRATION?!?!??!? + 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 + \sa mythenDetector::resetMerging + */ + static int resetMerging(float *mp, float *mv,float *me, int *mm, int nbins); + int resetMerging(float *mp, float *mv,float *me, int *mm); + 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(float *p1, float *v1, float *e1, float *mp, float *mv,float *me, int *mm, int nchans, float binsize,int nb, int *badChanMask ); + + int addToMerging(float *p1, float *v1, float *e1, float *mp, float *mv,float *me, int *mm, int *badChanMask); + + int addToMerging(float *p1, float *v1, float *e1,int *badChanMask); + + /** + MOVE TO ANGULAR CALIBRATION?!?!??!? + calculates the "final" positions, data value and errors for the emrged 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) + \sa mythenDetector::finalizeMerging + */ + + static int finalizeMerging(float *mp, float *mv,float *me, int *mm, int nb); + + int finalizeMerging(float *mp, float *mv,float *me, int *mm); + int finalizeMerging(); + + + /** + pure virtual function + set detector global offset + \sa mythenDetector::setGlobalOffset + */ + float setGlobalOffset(float f){return setAngularConversionParameter(GLOBAL_OFFSET,f);}; + + /** + pure virtual function + set detector fine offset + \sa mythenDetector::setFineOffset + */ + float setFineOffset(float f){return setAngularConversionParameter(FINE_OFFSET,f);}; + /** + pure virtual function + get detector fine offset + \sa mythenDetector::getFineOffset + */ + float getFineOffset(){return getAngularConversionParameter(FINE_OFFSET);}; + + /** + pure virtual function + get detector global offset + \sa mythenDetector::getGlobalOffset + */ + float getGlobalOffset(){return getAngularConversionParameter(GLOBAL_OFFSET);}; + + /** + + set detector bin size used for merging (approx angular resolution) + \param bs bin size in degrees + \returns current bin size + \sa mythenDetector::setBinSize +*/ + float setBinSize(float bs){return setAngularConversionParameter(BIN_SIZE,bs);}; + + /** + return detector bin size used for merging (approx angular resolution) + \sa mythenDetector::getBinSize + */ + float getBinSize() {return getAngularConversionParameter(BIN_SIZE);}; + + + + int getAngularDirection(){return (int)getAngularConversionParameter(ANGULAR_DIRECTION);}; + + + int setAngularDirection(int d){return (int)setAngularConversionParameter(ANGULAR_DIRECTION, (float)d);}; + + + 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; + + float setAngularConversionParameter(angleConversionParameter c, float v); + + float getAngularConversionParameter(angleConversionParameter c); + + + virtual int getTotalNumberOfChannels()=0; + + + + /** + 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, float *pos); + /** + get positions for the acquisition + \param pos array which will contain the encoder positions + \returns number of positions + */ + virtual int getPositions(float *pos=NULL); + + int deleteMerging(); + + float *getMergedPositions(){return mergingBins;}; + float *getMergedCounts(){return mergingCounts;}; + float *getMergedErrors(){return mergingErrors;}; + + + + /** + 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");}; + + + virtual int readAngularConversionFile(string fname="")=0; + + + // int setAngularConversionPointer(angleConversionConstant *p, int *nm, int nch, int idet=0); + + + + + virtual int getNMods()=0; + virtual int getChansPerMod(int imod=0)=0; + virtual angleConversionConstant *getAngularConversionPointer(int imod=0)=0; + + float* convertAngles(float pos); + + float *convertAngles(){return convertAngles(currentPosition);}; + + virtual int getMoveFlag(int imod)=0; + + int getCurrentPositionIndex() {return currentPositionIndex;}; + int getNumberOfPositions() {return *numberOfPositions;}; + + protected: + + + int *numberOfPositions; + float *detPositions; + + char *angConvFile; + + float *binSize; + float *fineOffset; + float *globalOffset; + int *angDirection; + int *moveFlag; + + + int nBins; + + + + /** + current position of the detector + */ + float currentPosition; + + /** + current position index of the detector + */ + int currentPositionIndex; + + virtual int setAngularCorrectionMask(int i=-1)=0; + + + private: + /** merging bins */ + float *mergingBins; + + /** merging counts */ + float *mergingCounts; + + /** merging errors */ + float *mergingErrors; + + /** merging multiplicity */ + int *mergingMultiplicity; + + /** pointer to the angular conversion constants for the (multi)detector class*/ + +/* angleConversionConstant *angOff[MAXDET]; */ +/* int *nMods[MAXDET]; */ +/* int nCh[MAXDET]; */ + + + +}; + +#endif diff --git a/slsDetectorSoftware/slsDetectorAnalysis/detectorData.h b/slsDetectorSoftware/slsDetectorAnalysis/detectorData.h new file mode 100644 index 000000000..febe62883 --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/detectorData.h @@ -0,0 +1,32 @@ + +#include +#include + +/** + data structure to hold the detector data after postprocessing (e.g. to plot, store in a root tree etc.) + */ +class detectorData { + public: + /** The constructor + \param val pointer to the data + \param err pointer to errors + \param ang pointer to the angles + \param f_ind file index + \param fname file name to which the data are saved + \param np number of points defaults to the number of detector channels + */ + detectorData(float *val=NULL, float *err=NULL, float *ang=NULL, float p_ind=-1, const char *fname="", int np=-1) : values(val), errors(err), angles(ang), progressIndex(p_ind), npoints(np){strcpy(fileName,fname);}; + /** + the destructor + deletes also the arrays pointing to data/errors/angles if not NULL + */ + ~detectorData() {if (values) delete [] values; if (errors) delete [] errors; if (angles) delete [] angles;}; + //private: + float *values; /**< pointer to the data */ + float *errors; /**< pointer to the errors */ + float *angles;/**< pointer to the angles */ + float progressIndex;/**< file index */ + char fileName[1000];/**< file name */ + int npoints;/**< number of points */ +}; + diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/annotated.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/annotated.html new file mode 100644 index 000000000..0af77f9f8 --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/annotated.html @@ -0,0 +1,28 @@ + + +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 new file mode 100644 index 000000000..4923725d9 --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/classenergyCalibration-members.html @@ -0,0 +1,55 @@ + + +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 new file mode 100644 index 000000000..5ad0b2776 --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/classenergyCalibration.html @@ -0,0 +1,1026 @@ + + +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 new file mode 100644 index 000000000..6e87b92ca --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/classenergyCalibrationFunctions-members.html @@ -0,0 +1,38 @@ + + +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 new file mode 100644 index 000000000..2a0dfd405 --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/classenergyCalibrationFunctions.html @@ -0,0 +1,428 @@ + + +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 new file mode 100644 index 000000000..4cc7a4ddd --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/classes.html @@ -0,0 +1,69 @@ + + + + + +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 new file mode 100644 index 000000000..5d583694e --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/doxygen.css @@ -0,0 +1,358 @@ +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 new file mode 100644 index 000000000..f0a274bba Binary files /dev/null and b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/doxygen.png differ diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/energyCalibration_8h-source.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/energyCalibration_8h-source.html new file mode 100644 index 000000000..64e8c0558 --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/energyCalibration_8h-source.html @@ -0,0 +1,164 @@ + + +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 new file mode 100644 index 000000000..a25ed2496 --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/energyCalibration_8h.html @@ -0,0 +1,76 @@ + + +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 new file mode 100644 index 000000000..fc14ca380 --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/energyCalibration_8h_source.html @@ -0,0 +1,190 @@ + + + + + +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 new file mode 100644 index 000000000..a0ea14100 --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/files.html @@ -0,0 +1,27 @@ + + +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 new file mode 100644 index 000000000..2dc86e2c0 --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/functions.html @@ -0,0 +1,126 @@ + + +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 new file mode 100644 index 000000000..a82a14a3a --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/functions_func.html @@ -0,0 +1,63 @@ + + +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 new file mode 100644 index 000000000..3eb5ab2c3 --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/functions_vars.html @@ -0,0 +1,49 @@ + + +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 new file mode 100644 index 000000000..6867e7583 --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/globals.html @@ -0,0 +1,36 @@ + + +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 new file mode 100644 index 000000000..efb3d3424 --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/globals_vars.html @@ -0,0 +1,36 @@ + + +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 new file mode 100644 index 000000000..8e6122ad2 --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/index.html @@ -0,0 +1,25 @@ + + +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 new file mode 100755 index 000000000..9b89fe025 --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/installdox @@ -0,0 +1,117 @@ +#!/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 new file mode 100644 index 000000000..f3343cb4d --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/namespaces.html @@ -0,0 +1,22 @@ + + +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 new file mode 100644 index 000000000..7f96b5d3c --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/namespacestd.html @@ -0,0 +1,24 @@ + + +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 new file mode 100644 index 000000000..dbc525140 --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_61.html @@ -0,0 +1,25 @@ + + + + + + +
+
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 new file mode 100644 index 000000000..1587baf85 --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_62.html @@ -0,0 +1,31 @@ + + + + + + +
+
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 new file mode 100644 index 000000000..9f05baa3d --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_63.html @@ -0,0 +1,37 @@ + + + + + + +
+
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 new file mode 100644 index 000000000..d8cc513ff --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_65.html @@ -0,0 +1,66 @@ + + + + + + +
+
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 new file mode 100644 index 000000000..bd1572f3b --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_66.html @@ -0,0 +1,55 @@ + + + + + + +
+
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 new file mode 100644 index 000000000..a5fbc8718 --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_67.html @@ -0,0 +1,37 @@ + + + + + + +
+
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 new file mode 100644 index 000000000..40cf25174 --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_6b.html @@ -0,0 +1,25 @@ + + + + + + +
+
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 new file mode 100644 index 000000000..6ddf1903c --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_6c.html @@ -0,0 +1,25 @@ + + + + + + +
+
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 new file mode 100644 index 000000000..d7612fe26 --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_6d.html @@ -0,0 +1,25 @@ + + + + + + +
+
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 new file mode 100644 index 000000000..7ee4200c2 --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_6e.html @@ -0,0 +1,25 @@ + + + + + + +
+
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 new file mode 100644 index 000000000..402fa63cb --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_70.html @@ -0,0 +1,25 @@ + + + + + + +
+
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 new file mode 100644 index 000000000..0c68aa1c7 --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_71.html @@ -0,0 +1,25 @@ + + + + + + +
+
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 new file mode 100644 index 000000000..52cede178 --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_73.html @@ -0,0 +1,70 @@ + + + + + + +
+
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 new file mode 100644 index 000000000..22b73eeab --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/all_7e.html @@ -0,0 +1,25 @@ + + + + + + +
+
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 new file mode 100644 index 000000000..0cd426302 --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/classes_65.html @@ -0,0 +1,29 @@ + + + + + + +
+
Loading...
+ + +
Searching...
+
No Matches
+ +
+ + diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/close.png b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/close.png new file mode 100644 index 000000000..9342d3dfe Binary files /dev/null and b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/close.png differ diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/files_65.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/files_65.html new file mode 100644 index 000000000..72afed66a --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/files_65.html @@ -0,0 +1,24 @@ + + + + + + +
+
Loading...
+ +
Searching...
+
No Matches
+ +
+ + diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/functions_63.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/functions_63.html new file mode 100644 index 000000000..dbde61421 --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/functions_63.html @@ -0,0 +1,25 @@ + + + + + + +
+
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 new file mode 100644 index 000000000..4aac8500d --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/functions_65.html @@ -0,0 +1,49 @@ + + + + + + +
+
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 new file mode 100644 index 000000000..e1b9f157c --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/functions_66.html @@ -0,0 +1,25 @@ + + + + + + +
+
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 new file mode 100644 index 000000000..a5fbc8718 --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/functions_67.html @@ -0,0 +1,37 @@ + + + + + + +
+
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 new file mode 100644 index 000000000..40cf25174 --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/functions_6b.html @@ -0,0 +1,25 @@ + + + + + + +
+
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 new file mode 100644 index 000000000..6ddf1903c --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/functions_6c.html @@ -0,0 +1,25 @@ + + + + + + +
+
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 new file mode 100644 index 000000000..d7612fe26 --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/functions_6d.html @@ -0,0 +1,25 @@ + + + + + + +
+
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 new file mode 100644 index 000000000..0c68aa1c7 --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/functions_71.html @@ -0,0 +1,25 @@ + + + + + + +
+
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 new file mode 100644 index 000000000..4daf9bb0f --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/functions_73.html @@ -0,0 +1,64 @@ + + + + + + +
+
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 new file mode 100644 index 000000000..22b73eeab --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/functions_7e.html @@ -0,0 +1,25 @@ + + + + + + +
+
Loading...
+
+
+ ~energyCalibration + energyCalibration +
+
+
Searching...
+
No Matches
+ +
+ + diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/nomatches.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/nomatches.html new file mode 100644 index 000000000..fd9248fe3 --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/nomatches.html @@ -0,0 +1,11 @@ + + + + + + +
+
No Matches
+
+ + diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/search.css b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/search.css new file mode 100644 index 000000000..d263b9724 --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/search.css @@ -0,0 +1,198 @@ +/*---------------- 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 new file mode 100644 index 000000000..4fadd5247 --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/search.js @@ -0,0 +1,734 @@ +// 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 new file mode 100644 index 000000000..9dd2396db Binary files /dev/null and b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/search.png differ diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/variables_61.html b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/variables_61.html new file mode 100644 index 000000000..dbc525140 --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/variables_61.html @@ -0,0 +1,25 @@ + + + + + + +
+
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 new file mode 100644 index 000000000..1587baf85 --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/variables_62.html @@ -0,0 +1,31 @@ + + + + + + +
+
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 new file mode 100644 index 000000000..6a2de4531 --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/variables_63.html @@ -0,0 +1,31 @@ + + + + + + +
+
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 new file mode 100644 index 000000000..b199804b0 --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/variables_65.html @@ -0,0 +1,25 @@ + + + + + + +
+
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 new file mode 100644 index 000000000..d0ae5492f --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/variables_66.html @@ -0,0 +1,49 @@ + + + + + + +
+
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 new file mode 100644 index 000000000..7ee4200c2 --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/variables_6e.html @@ -0,0 +1,25 @@ + + + + + + +
+
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 new file mode 100644 index 000000000..402fa63cb --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/variables_70.html @@ -0,0 +1,25 @@ + + + + + + +
+
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 new file mode 100644 index 000000000..786cf3968 --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/search/variables_73.html @@ -0,0 +1,25 @@ + + + + + + +
+
Loading...
+
+
+ sign + energyCalibrationFunctions +
+
+
Searching...
+
No Matches
+ +
+ + diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/tab_b.gif b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/tab_b.gif new file mode 100644 index 000000000..0d623483f Binary files /dev/null and b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/tab_b.gif differ diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/tab_l.gif b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/tab_l.gif new file mode 100644 index 000000000..9b1e6337c Binary files /dev/null and b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/tab_l.gif differ diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/tab_r.gif b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/tab_r.gif new file mode 100644 index 000000000..ce9dd9f53 Binary files /dev/null and b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/tab_r.gif differ diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/html/tabs.css b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/tabs.css new file mode 100644 index 000000000..a61552a67 --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/docs/html/tabs.css @@ -0,0 +1,102 @@ +/* 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 new file mode 100644 index 000000000..b550b90ba Binary files /dev/null and b/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/FreeSans.ttf differ diff --git a/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/Makefile b/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/Makefile new file mode 100644 index 000000000..776fcf968 --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/Makefile @@ -0,0 +1,39 @@ +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 new file mode 100644 index 000000000..dc3097571 --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/annotated.tex @@ -0,0 +1,5 @@ +\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 new file mode 100644 index 000000000..ca62e39dd --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/classenergyCalibration.tex @@ -0,0 +1,337 @@ +\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 new file mode 100644 index 000000000..1e8920959 --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/classenergyCalibrationFunctions.tex @@ -0,0 +1,135 @@ +\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 new file mode 100644 index 000000000..ff2b57e23 --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/doxygen.sty @@ -0,0 +1,78 @@ +\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 new file mode 100644 index 000000000..3c9d9f6c8 --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/energyCalibration_8h.tex @@ -0,0 +1,37 @@ +\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 new file mode 100644 index 000000000..d3d460d1e --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/files.tex @@ -0,0 +1,4 @@ +\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 new file mode 100644 index 000000000..4b31a1dff --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/index.tex @@ -0,0 +1,3 @@ +\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 new file mode 100644 index 000000000..c2ca33382 --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/namespaces.tex @@ -0,0 +1,4 @@ +\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 new file mode 100644 index 000000000..a1732dd75 --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/namespacestd.tex @@ -0,0 +1,4 @@ +\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 new file mode 100644 index 000000000..110991b6b --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/docs/latex/refman.tex @@ -0,0 +1,46 @@ +\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 new file mode 100644 index 000000000..c6f5f7f13 --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/doxy.config @@ -0,0 +1,65 @@ +# 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/energyCalibration.cpp b/slsDetectorSoftware/slsDetectorAnalysis/energyCalibration.cpp new file mode 100644 index 000000000..a6bcda4cc --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/energyCalibration.cpp @@ -0,0 +1,393 @@ +#include "energyCalibration.h" + +#ifdef ROOT +#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 ROOT +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) { + float 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 + +float energyCalibrationFunctions::median(float *x, int n){ + // sorts x into xmed array and returns median + // n is number of values already in the xmed array + float 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 float 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 + + +} + + +energyCalibration::~energyCalibration(){ +#ifdef ROOT + delete fscurve; + delete fspectrum; +#endif + +} + +#ifdef ROOT +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 ROOT + if (p) { + fscurve->ReleaseParameter(5); + fspectrum->ReleaseParameter(1); + } else { + fscurve->FixParameter(5,0); + fspectrum->FixParameter(1,0); + } +#endif + } + + return cs_flag; +} + + +#ifdef ROOT +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 TGraphErrors; +#endif + + +using namespace std; + + + + +const float conven=1000./3.6; /**< electrons/keV */ +const float 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 ROOT + /** + 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 float median(float *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); + +#ifdef ROOT + /** 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 ROOT + /** + 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); + + + /** + Perfors 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 ROOT + 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 new file mode 100644 index 000000000..5a4c4386f --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/energyCalibrationMacro.C @@ -0,0 +1,24 @@ +{ + + 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 new file mode 100644 index 000000000..4c25d7485 --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/energyConversion.cpp @@ -0,0 +1,317 @@ +#include "energyConversion.h" + +#include +#include +#include + + + +using namespace std; + + + + +int energyConversion::readCalibrationFile(string fname, float &gain, float &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(); + } else { + std::cout<< "Could not open calibration file "<< fname << std::endl; + gain=0.; + offset=0.; + return -1; + } + return 0; +}; + +int energyConversion::writeCalibrationFile(string fname, float gain, float 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; + return -1; + } + + outfile.close(); + + return 0; +}; + + + + /* I/O */ + + +slsDetectorDefs::sls_detector_module* energyConversion::readSettingsFile(string fname, detectorType myDetectorType, sls_detector_module *myMod){ + + int nflag=0; + + + if (myMod==NULL) { + myMod=createModule(myDetectorType); + nflag=1; + } + + 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)); + + +#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 + infile.open(myfname.c_str(), ios_base::in); + if (infile.is_open()) { + + + switch (myDetectorType) { + + case MYTHEN: + + 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 VERBOSE + // std::cout<< str << std::endl; +#endif + istringstream ssstr(str); + ssstr >> sargname >> ival; +#ifdef VERBOSE + // 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 VERBOSE + // std::cout<< "trimbits " << ival ; +#endif + myMod->chanregs[ichip*nch+ichan]|=ival&0x3f; + break; + case 1: +#ifdef VERBOSE + //std::cout<< " compen " << ival ; +#endif + myMod->chanregs[ichip*nch+ichan]|=ival<<9; + break; + case 2: +#ifdef VERBOSE + //std::cout<< " anen " << ival ; +#endif + myMod->chanregs[ichip*nch+ichan]|=ival<<8; + break; + case 3: +#ifdef VERBOSE + //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" <ndac; iarg++) { + getline(infile,str); + iline++; +#ifdef VERBOSE + std::cout<< str << std::endl; +#endif + istringstream ssstr(str); + ssstr >> sargname >> ival; +#ifdef VERBOSE + std::cout<< sargname << " dac nr. " << idac << " is " << ival << std::endl; +#endif + myMod->dacs[idac]=ival; + idac++; + } + break; + + + default: + std::cout<< "Unknown detector type - don't know how to read file" << myfname << std::endl; + infile.close(); + deleteModule(myMod); + return NULL; + + } + + infile.close(); + strcpy(settingsFile,fname.c_str()); + return myMod; + + } else { + std::cout<< "could not open settings file " << myfname << std::endl; + + if (nflag) + deleteModule(myMod); + + return NULL; + } + +}; + + +int energyConversion::writeSettingsFile(string fname, detectorType myDetectorType, sls_detector_module mod){ + + 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 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"; + names[id++]="config"; + names[id++]="HV"; + names[id++]="macaddress"; + names[id++]="ipaddress"; + break; + default: + cout << "Unknown detector type - unknown format for settings file" << endl; + return FAIL; + } + + int iv, ichan, ichip; + int iv1, idac; + int nb; + 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; + } else { + std::cout<< "could not open SETTINGS file " << fname << std::endl; + return FAIL; + } + +}; + + + + diff --git a/slsDetectorSoftware/slsDetectorAnalysis/energyConversion.h b/slsDetectorSoftware/slsDetectorAnalysis/energyConversion.h new file mode 100644 index 000000000..2584de613 --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/energyConversion.h @@ -0,0 +1,68 @@ +#ifndef ENERGYCONVERSION_H +#define ENERGYCONVERSION_H + +#include "sls_detector_defs.h" +#include + +using namespace std; + + + +class energyConversion: public slsDetectorDefs { + + public: + energyConversion(){}; + virtual ~energyConversion(){}; + + + /** + + reads a calibration file MOVE TO ENERGY CALIBRATION?!?!??!? + \param fname file to be read + \param gain reference to the gain variable + \offset reference to the offset variable + */ + static int readCalibrationFile(string fname, float &gain, float &offset); + + /** + + writes a calibration file MOVE TO ENERGY CALIBRATION?!?!??!? + \param fname file to be written + \param gain + \param offset + */ + static int writeCalibrationFile(string fname, float gain, float offset); + + + /** + reads a trim/settings file + \param fname name of the file to be read + \param myMod pointer to the module structure which has to be set.
If it is NULL a new module structure will be created + \returns the pointer to myMod or NULL if reading the file failed + \sa mythenDetector::readSettingsFile + */ + + sls_detector_module* readSettingsFile(string fname, detectorType myDetectorType, sls_detector_module* myMod=NULL); + + /** + 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 + \returns OK or FAIL if the file could not be written + + \sa ::sls_detector_module mythenDetector::writeSettingsFile(string, sls_detector_module) + */ + int writeSettingsFile(string fname, detectorType myDetectorType, sls_detector_module mod); + + + virtual sls_detector_module* createModule(detectorType myDetectorType)=0; + + virtual void deleteModule(sls_detector_module *myMod)=0; + + protected: + char *settingsFile; + + + +}; +#endif diff --git a/slsDetectorSoftware/slsDetectorAnalysis/fileIO.cpp b/slsDetectorSoftware/slsDetectorAnalysis/fileIO.cpp new file mode 100644 index 000000000..f31895d83 --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/fileIO.cpp @@ -0,0 +1,646 @@ +#include "fileIO.h" + + + + +string fileIO::createFileName(char *filepath, char *filename, int aMask, float sv0, int prec0, float 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() { + return createFileName(filePath, \ + fileName, \ + getActionMask(), \ + getCurrentScanVariable(0), \ + getScanPrecision(0), \ + getCurrentScanVariable(1), \ + getScanPrecision(1), \ + getCurrentPositionIndex(), \ + getNumberOfPositions(), \ + *fileIndex \ + ); + +} + + +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, float &sv0, float &sv1) { + + int i; + float 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, float *data, float *err, float *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, float *data, float *err, float *ang, char dataformat, int offset){ + + + int idata; + if (data==NULL) + return FAIL; + + // args|=0x10; // one line per channel! + + + 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, float *data, float *err, float *ang, char dataformat, int nch){ + if (nch==-1) + nch=getTotalNumberOfChannels(); + + return writeDataFile(fname, nch, data, err, ang, dataformat); + +} +int fileIO::writeDataFile(ofstream &outfile, float *data, float *err, float *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, float *data, float *err, float *ang, char dataformat) { + return readDataFile(getTotalNumberOfChannels(), fname, data, err, ang, dataformat); + +} + +int fileIO::readDataFile(ifstream &infile, float *data, float *err, float *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.h b/slsDetectorSoftware/slsDetectorAnalysis/fileIO.h new file mode 100644 index 000000000..15254439d --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/fileIO.h @@ -0,0 +1,284 @@ +#ifndef FILEIO_H +#define FILEIO_H + +#include "sls_detector_defs.h" +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace std; + +class fileIO : public slsDetectorDefs { + + + + public: + fileIO(){}; + virtual ~fileIO(){}; + + + /** + sets the default output files path + */ + string setFilePath(string s) {sprintf(filePath, s.c_str()); return string(filePath);}; + + /** + sets the default output files root name + */ + string setFileName(string s) {sprintf(fileName, s.c_str()); return string(fileName);}; + + /** + sets the default output file index + */ + int setFileIndex(int i) {*fileIndex=i; return *fileIndex;}; + + /** + returns the default output files path + \sa sharedSlsDetector + */ + string getFilePath() {return string(filePath);}; + + /** + returns the default output files root name + */ + string getFileName() {return string(fileName);}; + + /** + returns the default 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 + + Filenames will be of the form: filepath/filename(_px)_i + where 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, float sv0, int prec0, float sv1, int prec1, int pindex, int npos, int findex); + + virtual string createFileName(); + + + /** static function that returns the file index from the file name + \param fname file name + \returns file index*/ + static 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, float &sv0, float &sv1); + + + + + /** + + writes a data file + \param name 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' float (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, float *data, float *err=NULL, float *ang=NULL, char dataformat='f', int nch=-1); + int writeDataFile(ofstream &outfile, float *data, float *err=NULL, float *ang=NULL, char dataformat='f', int nch=-1, int offset=0); + + + /** + + writes a data file + \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 + */ + virtual int writeDataFile(string fname, int *data); + int writeDataFile(ofstream &outfile, int *data, int offset=0); + + + + /** + + writes a data file + \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 + */ + virtual int writeDataFile(string fname, short int *data); + int writeDataFile(ofstream &outfile, short int *data, int offset=0); + + + /** + + 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' float (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 + + */ + virtual int readDataFile(string fname, float *data, float *err=NULL, float *ang=NULL, char dataformat='f'); + int readDataFile(ifstream& infile, float *data, float *err=NULL, float *ang=NULL, char dataformat='f', int offset=0); + + /** + + 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 + */ + virtual int readDataFile(string fname, int *data); + int readDataFile(ifstream &infile, int *data, int offset=0); + + /** + + 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 + */ + virtual int readDataFile(string fname, short int *data); + int readDataFile(ifstream &infile, short int *data, int offset=0); + + /** + + writes a data file + \param name 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' float (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 + + */ + + static int writeDataFile(string fname, int nch, float *data, float *err=NULL, float *ang=NULL, char dataformat='f'); + static int writeDataFile(ofstream &outfile, int nch, float *data, float *err=NULL, float *ang=NULL, char dataformat='f', int offset=0); + + /** + + writes a data file + \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 + */ + static int writeDataFile(string fname,int nch, int *data); + static int writeDataFile(ofstream &outfile,int nch, int *data, int offset=0); + + + + /** + + writes a data file + \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 + */ + static int writeDataFile(string fname,int nch, short int *data); + static int writeDataFile(ofstream &outfile,int nch, short int *data, int offset=0); + /** + + 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' float (default) + \param nch number of channels to be written to file. if <=0 defaults to the number of installed channels of the detector + \returns number of channels read or -1 if it could not read the file or data=NULL + + \sa mythenDetector::readDataFile + */ + static int readDataFile(int nch, string fname, float *data, float *err=NULL, float *ang=NULL, char dataformat='f'); + static int readDataFile(int nch, ifstream &infile, float *data, float *err=NULL, float *ang=NULL, char dataformat='f', int offset=0); + + /** + + 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 + */ + static int readDataFile(string fname, int *data, int nch); + static int readDataFile(ifstream &infile, int *data, int nch, int offset); + + /** + + 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 + */ + static int readDataFile(string fname, short int *data, int nch); + static int readDataFile(ifstream &infile, short int *data, int nch, int offset); + + + virtual int getActionMask() {return 0;}; + + virtual float getCurrentScanVariable(int index) {return 0;}; + virtual int getScanPrecision(int index) {return 0;}; + + virtual int getCurrentPositionIndex() {return 0;}; + virtual int getNumberOfPositions() {return 0;}; + + virtual int getTotalNumberOfChannels()=0; + + protected: + + + + + char *filePath; + char *fileName; + int *fileIndex; + + +}; + +#endif diff --git a/slsDetectorSoftware/slsDetectorAnalysis/postProcessing.cpp b/slsDetectorSoftware/slsDetectorAnalysis/postProcessing.cpp new file mode 100644 index 000000000..411acb802 --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/postProcessing.cpp @@ -0,0 +1,557 @@ +#include "postProcessing.h" + + +postProcessing::postProcessing(){ + pthread_mutex_t mp1 = PTHREAD_MUTEX_INITIALIZER; + mp=mp1; + pthread_mutex_init(&mp, NULL); + mg=mp1; + pthread_mutex_init(&mg, NULL); +} + + +int postProcessing::flatFieldCorrect(float datain, float errin, float &dataout, float &errout, float ffcoefficient, float fferr){ + float 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.; + + return 0; +}; + + + int postProcessing::rateCorrect(float datain, float errin, float &dataout, float &errout, float tau, float t){ + + // float data; + float 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(string fname, int &nbad, int *badlist){ + ifstream infile; + string str; + int interrupt=0; + int ich; + int chmin,chmax; +#ifdef VERBOSE + std::cout << "Setting bad channel correction to " << fname << std::endl; +#endif + + if (fname=="" || fname=="none") { + nbad=0; + return 0; + } else { + infile.open(fname.c_str(), ios_base::in); + if (infile.is_open()==0) { + std::cout << "could not open file " << fname <> 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 && nbad0) { +#ifdef VERBOSE + cout << "**************Current position index is " << currentPositionIndex << endl; +#endif + // if (*numberOfPositions>0) { + if (currentPositionIndex<=1) { + + + +#ifdef VERBOSE + cout << "reset merging " << endl; +#endif + resetMerging(); + } + +#ifdef VERBOSE + cout << "add to merging "<< currentPositionIndex << endl; +#endif + + if (*correctionMask&(1<< ANGULAR_CONVERSION)) + addToMerging(ang, ffcdata, ffcerr, badChannelMask ); + + +#ifdef VERBOSE + cout << currentPositionIndex << " " << (*numberOfPositions) << endl; + +#endif + + + pthread_mutex_lock(&mp); + if ((currentPositionIndex>=(*numberOfPositions) && posfinished==1 && queuesize==1)) { + +#ifdef VERBOSE + cout << "finalize merging " << currentPositionIndex<< endl; +#endif + np=finalizeMerging(); + /** file writing */ + + currentPositionIndex++; + pthread_mutex_unlock(&mp); + + + fname=createFileName(); + +#ifdef VERBOSE + cout << "writing merged data file" << endl; +#endif + writeDataFile (fname+string(".dat"),np,getMergedCounts(), getMergedErrors(), getMergedPositions(),'f'); +#ifdef VERBOSE + cout << " done" << endl; +#endif + + + + if (delflag) { + deleteMerging(); + } else { + thisData=new detectorData(getMergedCounts(),getMergedErrors(),getMergedPositions(),getCurrentProgress(),(fname+string(ext)).c_str(),np); + + pthread_mutex_lock(&mg); + finalDataQueue.push(thisData); + pthread_mutex_unlock(&mg); + } + pthread_mutex_lock(&mp); + } + 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+string(ext)).c_str(),getTotalNumberOfChannels()); + pthread_mutex_lock(&mg); + finalDataQueue.push(thisData); + pthread_mutex_unlock(&mg); + } + } + } + incrementFileIndex(); + + +} + + + + + +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 + + setTotalProgress(); + pthread_mutex_lock(&mp); + queuesize=dataQueue.size(); + pthread_mutex_unlock(&mp); + + int *myData; + int dum=1; + + + + while(dum | *threadedProcessing) { // ???????????????????????? + + + 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_unlock(&mp); + usleep(1000); + + } + + + pthread_mutex_unlock(&mp); + 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; + } + 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.h b/slsDetectorSoftware/slsDetectorAnalysis/postProcessing.h new file mode 100644 index 000000000..3663f1655 --- /dev/null +++ b/slsDetectorSoftware/slsDetectorAnalysis/postProcessing.h @@ -0,0 +1,379 @@ +#ifndef POSTPROCESSING_H +#define POSTPROCESSING_H + + +#include "sls_detector_defs.h" +#include "detectorData.h" +#include "angularConversion.h" +#include "fileIO.h" +#include + +#include +#include +#include +#include +#include +#include +#include +#include + + +using namespace std; + +#define MAX_BADCHANS 2000 + + +#define defaultTDead {170,90,750} /**< should be changed in order to have it separate for the different detector types */ + +class postProcessing : 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; + + + + + /** + 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 + */ + static int setBadChannelCorrection(string fname, int &nbad, int *badlist); + + + /** + 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 setAngularCorrectionMask(int i=-1){if (i==0) (*correctionMask)&=~(1<< ANGULAR_CONVERSION); if (i>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); + + + /** + 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 void incrementProgress()=0; + virtual float getCurrentProgress()=0; + virtual void incrementFileIndex()=0; + virtual int setTotalProgress()=0; + + + virtual float* decodeData(int *datain)=0; + virtual int getTotalNumberOfChannels()=0; + + + + + virtual int rateCorrect(float*, float*, float*, float*)=0; + virtual int flatFieldCorrect(float*, float*, float*, float*)=0; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + protected: + + int *threadedProcessing; + + int *correctionMask; + + char *flatFieldDir; + char *flatFieldFile; + + char *badChanFile; + int *nBadChans; + int *badChansList; + int *nBadFF; + int *badFFList; + + + /** 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; + + + + + +}; + + +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/usersFunctions/usersFunctions.cpp b/slsDetectorSoftware/usersFunctions/usersFunctions.cpp index 74c76f357..08e52d9aa 100644 --- a/slsDetectorSoftware/usersFunctions/usersFunctions.cpp +++ b/slsDetectorSoftware/usersFunctions/usersFunctions.cpp @@ -118,20 +118,17 @@ int caput(chid ch_id, double value) { */ -float angle(int ichan, float encoder, float totalOffset, float conv_r, float center, float offset, float tilt, int direction) { +float angle(float ichan, float encoder, float totalOffset, float conv_r, float center, float offset, float tilt, int direction) { (void) tilt; /* to avoid warning: unused parameter */ float ang; - ang=180./PI*(center*conv_r+atan((float)(ichan-center)*conv_r))+encoder+totalOffset+offset; + ang=180./PI*(center*conv_r+direction*atan((float)(ichan-center)*conv_r))+encoder+totalOffset+offset; - // printf("*** %f %f\n",offset,ang); - - - return direction*ang; + return ang; } diff --git a/slsDetectorSoftware/usersFunctions/usersFunctions.h b/slsDetectorSoftware/usersFunctions/usersFunctions.h index e6cd9cd43..9c454cc5b 100644 --- a/slsDetectorSoftware/usersFunctions/usersFunctions.h +++ b/slsDetectorSoftware/usersFunctions/usersFunctions.h @@ -29,7 +29,7 @@ extern "C" { #endif - float angle(int ichan, float encoder, float totalOffset, float conv_r, float center, float offset, float tilt, int direction); + float angle(float ichan, float encoder, float totalOffset, float conv_r, float center, float offset, float tilt, int direction); float get_position(); int go_to_position(float p); int go_to_position_no_wait(float p);