Speed up of SExpRlx by a factor of ~5 by using static TF1s. Might not be thread save.
This commit is contained in:
parent
57931f0487
commit
685aca6c9a
10
src/external/libBNMR/TBNMR.cpp
vendored
10
src/external/libBNMR/TBNMR.cpp
vendored
@ -30,9 +30,6 @@
|
|||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#include "TBNMR.h"
|
#include "TBNMR.h"
|
||||||
#include "TF1.h"
|
|
||||||
#include "Math/WrappedTF1.h"
|
|
||||||
#include "Math/GaussIntegrator.h"
|
|
||||||
|
|
||||||
#define tau_Li 1210
|
#define tau_Li 1210
|
||||||
#define gamma_Li 6.3018 // In units kHz/mT
|
#define gamma_Li 6.3018 // In units kHz/mT
|
||||||
@ -65,6 +62,11 @@ double ExpRlx::operator()(double x, const vector<double> &par) const {
|
|||||||
return y;
|
return y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//initialize Integrators
|
||||||
|
TF1 SExpRlx::sexp1=TF1("sexp", "exp(-([0]-x)/[3])*exp(-pow(([1]*([0]-x)),[2]))", 0.0, 20000.0);
|
||||||
|
TF1 SExpRlx::sexp2=TF1("sexp", "exp(-([3]-x)/[4])*exp(-pow(([1]*([0]-x)),[2]))", 0.0, 20000.0);
|
||||||
|
|
||||||
double SExpRlx::operator()(double x, const vector<double> &par) const {
|
double SExpRlx::operator()(double x, const vector<double> &par) const {
|
||||||
assert(par.size()==3); // make sure the number of parameters handed to the function is correct
|
assert(par.size()==3); // make sure the number of parameters handed to the function is correct
|
||||||
|
|
||||||
@ -88,7 +90,7 @@ double SExpRlx::operator()(double x, const vector<double> &par) const {
|
|||||||
} else {
|
} else {
|
||||||
y = 0;
|
y = 0;
|
||||||
}
|
}
|
||||||
return y;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
double MLRes::operator()(double x, const vector<double> &par) const {
|
double MLRes::operator()(double x, const vector<double> &par) const {
|
||||||
|
8
src/external/libBNMR/TBNMR.h
vendored
8
src/external/libBNMR/TBNMR.h
vendored
@ -31,6 +31,9 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "PUserFcnBase.h"
|
#include "PUserFcnBase.h"
|
||||||
|
#include "TF1.h"
|
||||||
|
#include "Math/WrappedTF1.h"
|
||||||
|
#include "Math/GaussIntegrator.h"
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@ -63,7 +66,7 @@ class SExpRlx : public PUserFcnBase {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// default constructor and destructor
|
// default constructor and destructor
|
||||||
SExpRlx(){}
|
SExpRlx(){sexp1.SetNpx(1000); sexp2.SetNpx(1000);}
|
||||||
~SExpRlx(){}
|
~SExpRlx(){}
|
||||||
|
|
||||||
Bool_t NeedGlobalPart() const { return false; }
|
Bool_t NeedGlobalPart() const { return false; }
|
||||||
@ -72,6 +75,9 @@ public:
|
|||||||
|
|
||||||
// function operator
|
// function operator
|
||||||
double operator()(double, const vector<double>&) const;
|
double operator()(double, const vector<double>&) const;
|
||||||
|
private:
|
||||||
|
static TF1 sexp1;
|
||||||
|
static TF1 sexp2;
|
||||||
|
|
||||||
// definition of the class for the ROOT-dictionary
|
// definition of the class for the ROOT-dictionary
|
||||||
ClassDef(SExpRlx,1)
|
ClassDef(SExpRlx,1)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user