mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-26 08:10:02 +02:00
added acquisition finished callback when the acquisition returns registerAcquisitionFinishedCallback
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@237 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
parent
2b59857032
commit
43c51f5be5
@ -1,6 +1,11 @@
|
|||||||
#ifndef SLS_DETECTOR_DEFS_H
|
#ifndef SLS_DETECTOR_DEFS_H
|
||||||
#define SLS_DETECTOR_DEFS_H
|
#define SLS_DETECTOR_DEFS_H
|
||||||
|
|
||||||
|
#ifdef __CINT__
|
||||||
|
#define MYROOT
|
||||||
|
#define __cplusplus
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
/** default maximum string length */
|
/** default maximum string length */
|
||||||
@ -507,11 +512,15 @@ enum angleConversionParameter {
|
|||||||
protected:
|
protected:
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef MYROOT
|
||||||
#include "sls_detector_funcs.h"
|
#include "sls_detector_funcs.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
;
|
||||||
#endif
|
#endif
|
||||||
|
;
|
||||||
|
@ -352,6 +352,13 @@ class slsDetectorUsers
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
virtual void registerDataCallback(int( *userCallback)(detectorData*, void*), void *pArg)=0;
|
virtual void registerDataCallback(int( *userCallback)(detectorData*, void*), void *pArg)=0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
@short register calbback for accessing detector final data
|
||||||
|
\param func function to be called at the end of the acquisition. gets detector status and progress index as arguments
|
||||||
|
*/
|
||||||
|
|
||||||
|
virtual void registerAcquisitionFinishedCallback(int( *func)(double,int, void*), void *pArg)=0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@short register calbback for reading detector position
|
@short register calbback for reading detector position
|
||||||
|
@ -17,6 +17,8 @@ slsDetectorUtils::slsDetectorUtils() {
|
|||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
cout << "setting callbacks" << endl;
|
cout << "setting callbacks" << endl;
|
||||||
#endif
|
#endif
|
||||||
|
acquisition_finished=NULL;
|
||||||
|
acqFinished_p=NULL;
|
||||||
registerGetPositionCallback(&defaultGetPosition, NULL);
|
registerGetPositionCallback(&defaultGetPosition, NULL);
|
||||||
registerConnectChannelsCallback(&defaultConnectChannels,NULL);
|
registerConnectChannelsCallback(&defaultConnectChannels,NULL);
|
||||||
registerDisconnectChannelsCallback(&defaultDisconnectChannels,NULL);
|
registerDisconnectChannelsCallback(&defaultDisconnectChannels,NULL);
|
||||||
@ -323,6 +325,11 @@ void slsDetectorUtils::acquire(int delflag){
|
|||||||
if (eclog)
|
if (eclog)
|
||||||
delete eclog;
|
delete eclog;
|
||||||
|
|
||||||
|
|
||||||
|
if (acquisition_finished) {
|
||||||
|
acquisition_finished(getCurrentProgress(),getDetectorStatus(),acqFinished_p);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -537,6 +537,10 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
|
|||||||
void registerGoToPositionNoWaitCallback(int (*func)(double, void*),void*arg){go_to_position_no_wait=func;GTNarg=arg;};
|
void registerGoToPositionNoWaitCallback(int (*func)(double, void*),void*arg){go_to_position_no_wait=func;GTNarg=arg;};
|
||||||
void registerGetI0Callback( double (*func)(int, void*),void *arg){get_i0=func;IOarg=arg;};
|
void registerGetI0Callback( double (*func)(int, void*),void *arg){get_i0=func;IOarg=arg;};
|
||||||
|
|
||||||
|
virtual void registerAcquisitionFinishedCallback(int( *func)(double,int, void*), void *pArg){acquisition_finished=func; acqFinished_p=pArg;};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Saves the detector setup to file
|
Saves the detector setup to file
|
||||||
\param fname file to write to
|
\param fname file to write to
|
||||||
@ -583,7 +587,8 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
|
|||||||
int (*disconnect_channels)(void*);
|
int (*disconnect_channels)(void*);
|
||||||
double (*get_i0)(int, void*);
|
double (*get_i0)(int, void*);
|
||||||
void *POarg,*CCarg,*DCarg,*GTarg,*GTNarg,*IOarg;
|
void *POarg,*CCarg,*DCarg,*GTarg,*GTNarg,*IOarg;
|
||||||
|
int (*acquisition_finished)(double,int,void*);
|
||||||
|
void *acqFinished_p;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -1,8 +1,14 @@
|
|||||||
#include "energyCalibration.h"
|
#include "energyCalibration.h"
|
||||||
|
|
||||||
#ifdef ROOT
|
#ifdef __CINT
|
||||||
|
#define MYROOT
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef MYROOT
|
||||||
#include <TMath.h>
|
#include <TMath.h>
|
||||||
#include <TH1F.h>
|
#include <TH1F.h>
|
||||||
|
#include <TH2F.h>
|
||||||
#include <TGraphErrors.h>
|
#include <TGraphErrors.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -15,7 +21,7 @@
|
|||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
#ifdef ROOT
|
#ifdef MYROOT
|
||||||
Double_t energyCalibrationFunctions::gaussChargeSharing(Double_t *x, Double_t *par) {
|
Double_t energyCalibrationFunctions::gaussChargeSharing(Double_t *x, Double_t *par) {
|
||||||
Double_t f, arg=0;
|
Double_t f, arg=0;
|
||||||
if (par[3]!=0) arg=(x[0]-par[2])/par[3];
|
if (par[3]!=0) arg=(x[0]-par[2])/par[3];
|
||||||
@ -144,7 +150,7 @@ int energyCalibrationFunctions::kth_smallest(int *a, int n, int k){
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef ROOT
|
#ifdef MYROOT
|
||||||
Double_t energyCalibrationFunctions::spectrum(Double_t *x, Double_t *par) {
|
Double_t energyCalibrationFunctions::spectrum(Double_t *x, Double_t *par) {
|
||||||
return gaussChargeSharing(x,par);
|
return gaussChargeSharing(x,par);
|
||||||
}
|
}
|
||||||
@ -161,7 +167,7 @@ Double_t energyCalibrationFunctions::scurveFluo(Double_t *x, Double_t *par) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
energyCalibration::energyCalibration() :
|
energyCalibration::energyCalibration() :
|
||||||
#ifdef ROOT
|
#ifdef MYROOT
|
||||||
fit_min(-1),
|
fit_min(-1),
|
||||||
fit_max(-1),
|
fit_max(-1),
|
||||||
bg_offset(-1),
|
bg_offset(-1),
|
||||||
@ -178,7 +184,7 @@ energyCalibration::energyCalibration() :
|
|||||||
cs_flag(1)
|
cs_flag(1)
|
||||||
{
|
{
|
||||||
|
|
||||||
#ifdef ROOT
|
#ifdef MYROOT
|
||||||
funcs=new energyCalibrationFunctions();
|
funcs=new energyCalibrationFunctions();
|
||||||
|
|
||||||
fscurve=new TF1("fscurve",funcs,&energyCalibrationFunctions::scurve,0,1000,6,"energyCalibrationFunctions","scurve");
|
fscurve=new TF1("fscurve",funcs,&energyCalibrationFunctions::scurve,0,1000,6,"energyCalibrationFunctions","scurve");
|
||||||
@ -193,15 +199,77 @@ energyCalibration::energyCalibration() :
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void energyCalibration::fixParameter(int ip, Double_t val){
|
||||||
|
|
||||||
|
fscurve->FixParameter(ip, val);
|
||||||
|
fspectrum->FixParameter(ip, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void energyCalibration::releaseParameter(int ip){
|
||||||
|
|
||||||
|
fscurve->ReleaseParameter(ip);
|
||||||
|
fspectrum->ReleaseParameter(ip);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
energyCalibration::~energyCalibration(){
|
energyCalibration::~energyCalibration(){
|
||||||
#ifdef ROOT
|
#ifdef MYROOT
|
||||||
delete fscurve;
|
delete fscurve;
|
||||||
delete fspectrum;
|
delete fspectrum;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ROOT
|
#ifdef MYROOT
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
TH1F* energyCalibration::createMedianHistogram(TH2F* h2, int ch0, int nch) {
|
||||||
|
|
||||||
|
if (h2==NULL || nch==0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
double *x=new double[nch];
|
||||||
|
TH1F *h1=NULL;
|
||||||
|
|
||||||
|
double val=-1;
|
||||||
|
|
||||||
|
h1=new TH1F("median","Median",h2->GetYaxis()->GetNbins(),h2->GetYaxis()->GetXmin(),h2->GetYaxis()->GetXmax());
|
||||||
|
|
||||||
|
|
||||||
|
for (int ib=0; ib<h1->GetXaxis()->GetNbins(); ib++) {
|
||||||
|
for (int ich=0; ich<nch; ich++) {
|
||||||
|
x[ich]=h2->GetBinContent(ch0+ich+1,ib+1);
|
||||||
|
}
|
||||||
|
val=energyCalibrationFunctions::median(x, nch);
|
||||||
|
h1->SetBinContent(ib+1,val);
|
||||||
|
}
|
||||||
|
return h1;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void energyCalibration::setStartParameters(Double_t *par){
|
void energyCalibration::setStartParameters(Double_t *par){
|
||||||
bg_offset=par[0];
|
bg_offset=par[0];
|
||||||
bg_slope=par[1];
|
bg_slope=par[1];
|
||||||
@ -225,7 +293,7 @@ void energyCalibration::getStartParameters(Double_t *par){
|
|||||||
int energyCalibration::setChargeSharing(int p) {
|
int energyCalibration::setChargeSharing(int p) {
|
||||||
if (p>=0) {
|
if (p>=0) {
|
||||||
cs_flag=p;
|
cs_flag=p;
|
||||||
#ifdef ROOT
|
#ifdef MYROOT
|
||||||
if (p) {
|
if (p) {
|
||||||
fscurve->ReleaseParameter(5);
|
fscurve->ReleaseParameter(5);
|
||||||
fspectrum->ReleaseParameter(1);
|
fspectrum->ReleaseParameter(1);
|
||||||
@ -240,7 +308,7 @@ int energyCalibration::setChargeSharing(int p) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef ROOT
|
#ifdef MYROOT
|
||||||
void energyCalibration::initFitFunction(TF1 *fun, TH1 *h1) {
|
void energyCalibration::initFitFunction(TF1 *fun, TH1 *h1) {
|
||||||
|
|
||||||
Double_t min=fit_min, max=fit_max;
|
Double_t min=fit_min, max=fit_max;
|
||||||
@ -291,7 +359,6 @@ void energyCalibration::initFitFunction(TF1 *fun, TH1 *h1) {
|
|||||||
|
|
||||||
fun->SetRange(min,max);
|
fun->SetRange(min,max);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -319,9 +386,6 @@ TF1* energyCalibration::fitFunction(TF1 *fun, TH1 *h1, Double_t *mypar, Double_t
|
|||||||
}
|
}
|
||||||
|
|
||||||
TF1* energyCalibration::fitSCurve(TH1 *h1, Double_t *mypar, Double_t *emypar) {
|
TF1* energyCalibration::fitSCurve(TH1 *h1, Double_t *mypar, Double_t *emypar) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
initFitFunction(fscurve,h1);
|
initFitFunction(fscurve,h1);
|
||||||
return fitFunction(fscurve, h1, mypar, emypar);
|
return fitFunction(fscurve, h1, mypar, emypar);
|
||||||
}
|
}
|
||||||
|
@ -2,11 +2,16 @@
|
|||||||
#ifndef ENERGYCALIBRATION_H
|
#ifndef ENERGYCALIBRATION_H
|
||||||
#define ENERGYCALIBRATION_H
|
#define ENERGYCALIBRATION_H
|
||||||
|
|
||||||
|
#ifdef __CINT
|
||||||
|
#define MYROOT
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef ROOT
|
|
||||||
|
#ifdef MYROOT
|
||||||
#include <TROOT.h>
|
#include <TROOT.h>
|
||||||
#include <TF1.h>
|
#include <TF1.h>
|
||||||
class TH1F;
|
class TH1F;
|
||||||
|
class TH2F;
|
||||||
class TGraphErrors;
|
class TGraphErrors;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -62,7 +67,7 @@ class energyCalibrationFunctions {
|
|||||||
int setScanSign(int s=0) {if (s==1 || s==-1) sign=s; return sign;};;
|
int setScanSign(int s=0) {if (s==1 || s==-1) sign=s; return sign;};;
|
||||||
|
|
||||||
|
|
||||||
#ifdef ROOT
|
#ifdef MYROOT
|
||||||
/**
|
/**
|
||||||
Gaussian Function with charge sharing pedestal
|
Gaussian Function with charge sharing pedestal
|
||||||
par[0] is the absolute height of the background pedestal
|
par[0] is the absolute height of the background pedestal
|
||||||
@ -197,7 +202,16 @@ class energyCalibration {
|
|||||||
*/
|
*/
|
||||||
int setChargeSharing(int p=-1);
|
int setChargeSharing(int p=-1);
|
||||||
|
|
||||||
#ifdef ROOT
|
|
||||||
|
void fixParameter(int ip, Double_t val);
|
||||||
|
|
||||||
|
void releaseParameter(int ip);
|
||||||
|
|
||||||
|
#ifdef MYROOT
|
||||||
|
|
||||||
|
static TH1F* createMedianHistogram(TH2F* h2, int ch0, int nch);
|
||||||
|
|
||||||
|
|
||||||
/** sets the s-curve fit range
|
/** sets the s-curve fit range
|
||||||
\param mi minimum of the fit range (-1 is histogram x-min)
|
\param mi minimum of the fit range (-1 is histogram x-min)
|
||||||
\param ma maximum of the fit range (-1 is histogram x-max)
|
\param ma maximum of the fit range (-1 is histogram x-max)
|
||||||
@ -300,7 +314,7 @@ class energyCalibration {
|
|||||||
#endif
|
#endif
|
||||||
private:
|
private:
|
||||||
|
|
||||||
#ifdef ROOT
|
#ifdef MYROOT
|
||||||
/**
|
/**
|
||||||
calculates gain and offset for the set of energies
|
calculates gain and offset for the set of energies
|
||||||
\param nscan number of energy scans
|
\param nscan number of energy scans
|
||||||
@ -328,7 +342,7 @@ class energyCalibration {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Perfors the fit according to the flags specified and returns the fitted function
|
Performs the fit according to the flags specified and returns the fitted function
|
||||||
\param fun function to fit
|
\param fun function to fit
|
||||||
\param h1 histogram to fit
|
\param h1 histogram to fit
|
||||||
\param mypar pointer to fit parameters array
|
\param mypar pointer to fit parameters array
|
||||||
@ -339,7 +353,7 @@ class energyCalibration {
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ROOT
|
#ifdef MYROOT
|
||||||
Double_t fit_min; /**< minimum of the s-curve fitting range, -1 is histogram x-min */
|
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 fit_max; /**< maximum of the s-curve fitting range, -1 is histogram x-max */
|
||||||
|
|
||||||
|
@ -56,6 +56,7 @@ int energyConversion::writeCalibrationFile(string fname, double gain, double off
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef MYROOT
|
||||||
|
|
||||||
/* I/O */
|
/* I/O */
|
||||||
|
|
||||||
@ -314,4 +315,4 @@ int energyConversion::writeSettingsFile(string fname, detectorType myDetectorTyp
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
@ -1,7 +1,14 @@
|
|||||||
#ifndef ENERGYCONVERSION_H
|
#ifndef ENERGYCONVERSION_H
|
||||||
#define ENERGYCONVERSION_H
|
#define ENERGYCONVERSION_H
|
||||||
|
|
||||||
|
#ifdef __CINT
|
||||||
|
#define MYROOT
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef MYROOT
|
||||||
#include "sls_detector_defs.h"
|
#include "sls_detector_defs.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
@ -10,8 +17,11 @@ using namespace std;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
class energyConversion: private virtual slsDetectorDefs {
|
class energyConversion
|
||||||
|
#ifndef MYROOT
|
||||||
|
: private virtual slsDetectorDefs
|
||||||
|
#endif
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
/** default constrauctor */
|
/** default constrauctor */
|
||||||
energyConversion(){};
|
energyConversion(){};
|
||||||
@ -37,6 +47,7 @@ class energyConversion: private virtual slsDetectorDefs {
|
|||||||
*/
|
*/
|
||||||
static int writeCalibrationFile(string fname, double gain, double offset);
|
static int writeCalibrationFile(string fname, double gain, double offset);
|
||||||
|
|
||||||
|
#ifndef MYROOT
|
||||||
|
|
||||||
/**
|
/**
|
||||||
reads a trim/settings file
|
reads a trim/settings file
|
||||||
@ -76,6 +87,7 @@ class energyConversion: private virtual slsDetectorDefs {
|
|||||||
char *settingsFile;
|
char *settingsFile;
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user