Jpp test-rotations-new
the software that should make you happy
Loading...
Searching...
No Matches
JMATH::JGauss3D< ID_t, normalise > Struct Template Reference

3D correlated Gauss function. More...

#include <JMathlib3D.hh>

Inheritance diagram for JMATH::JGauss3D< ID_t, normalise >:
JMATH::JMathlib< JGauss3D< ID_t, false > > JMATH::JGauss< ID_t, false > JMATH::JGauss_t JMATH::JMathlib< JGauss< ID_t > > JMATH::JCalculus< JGauss< ID_t > > JMATH::JMath< JGauss_t > JLANG::JEquals< JFirst_t, JSecond_t >

Public Types

typedef double JGauss::* parameter_type
 Type definition of fit parameter.
 

Public Member Functions

 JGauss3D ()
 Default constructor.
 
 JGauss3D (const double mean, const double sigma)
 Constructor.
 
double getValue (const double x, const double y, const double z) const
 Function value.
 
const JGauss3DgetGradient (const double x, const double y, const double z) const
 Get gradient.
 
double operator() (const Args &...args) const
 Function value.
 
double getValue (const double x) const
 Function value.
 
double getDerivative (const double x) const
 Derivative value.
 
double getDerivative (const double x) const
 Derivative value.
 
double operator() (const double x) const
 Function value.
 
double operator() (const Args &...args) const
 Function value.
 
const JGauss_tgetGradient (const double x) const
 Get gradient.
 
bool equals (const JGauss_t &gauss, const double eps=std::numeric_limits< double >::min()) const
 Equality.
 
JGauss_tadd (const JGauss_t &gauss)
 Add gauss.
 
JGauss< ID_t > & add (const JGauss< ID_t > &f1)
 Add function.
 
JGauss_tsub (const JGauss_t &gauss)
 Subtract gauss.
 
JGauss< ID_t > & sub (const JGauss< ID_t > &f1)
 Subtract function.
 
JGauss_tmul (const double factor)
 Scale gauss.
 
JGauss_tmul (const JSecond_t &object)
 Multiply with object.
 
JGauss< ID_t > & mul (const double factor)
 Scale function.
 
JGauss< ID_t > & negate ()
 Negate function.
 
JGauss< ID_t > & div (const double factor)
 Scale function.
 

Public Attributes

double center
 center
 
double sigma
 sigma
 
double mean
 
double signal
 
double background
 

Static Public Attributes

static const int ID
 
static const parameter_list< JGaussparameters
 parameters
 

Private Member Functions

double get (const double u) const
 Get ordinate value.
 
double get (const double u) const
 Get ordinate value.
 

Private Attributes

JGauss_t gradient
 

Detailed Description

template<int ID_t, bool normalise = false>
struct JMATH::JGauss3D< ID_t, normalise >

3D correlated Gauss function.

Definition at line 267 of file JMathlib3D.hh.

Member Typedef Documentation

◆ parameter_type

double JGauss::* JMATH::JGauss< ID_t, normalised >::parameter_type
inherited

Type definition of fit parameter.

Definition at line 179 of file JGauss.hh.

Constructor & Destructor Documentation

◆ JGauss3D() [1/2]

template<int ID_t, bool normalise = false>
JMATH::JGauss3D< ID_t, normalise >::JGauss3D ( )
inline

Default constructor.

Definition at line 277 of file JMathlib3D.hh.

278 {}

◆ JGauss3D() [2/2]

template<int ID_t, bool normalise = false>
JMATH::JGauss3D< ID_t, normalise >::JGauss3D ( const double mean,
const double sigma )
inline

Constructor.

Parameters
meanmean
sigmasigma

Definition at line 287 of file JMathlib3D.hh.

Member Function Documentation

◆ getValue() [1/2]

template<int ID_t, bool normalise = false>
double JMATH::JGauss3D< ID_t, normalise >::getValue ( const double x,
const double y,
const double z ) const
inline

Function value.

Parameters
xabscissa value
yabscissa value
zabscissa value
Returns
function value

Definition at line 301 of file JMathlib3D.hh.

302 {
303 typedef JGauss<ID_t, normalise> JGauss_t;
304
305 return (static_cast<const JGauss_t&>(*this).getValue(x) *
306 static_cast<const JGauss_t&>(*this).getValue(y) *
307 static_cast<const JGauss_t&>(*this).getValue(z));
308 }
JGauss_t()
Default constructor.
Definition JGauss.hh:36

◆ getGradient() [1/2]

template<int ID_t, bool normalise = false>
const JGauss3D & JMATH::JGauss3D< ID_t, normalise >::getGradient ( const double x,
const double y,
const double z ) const
inline

Get gradient.

Parameters
xabscissa value
yabscissa value
zabscissa value
Returns
gradient

Definition at line 319 of file JMathlib3D.hh.

320 {
321 static JGauss3D gradient;
322
323 typedef JGauss<ID_t, normalise> JGauss_t;
324
325 static_cast<JGauss_t&>(gradient) = JGauss_t(static_cast<const JGauss_t&>(*this).getGradient(x)).mul(static_cast<const JGauss_t&>(*this).getValue(y) * static_cast<const JGauss_t&>(*this).getValue(z));
326 static_cast<JGauss_t&>(gradient) += JGauss_t(static_cast<const JGauss_t&>(*this).getGradient(y)).mul(static_cast<const JGauss_t&>(*this).getValue(x) * static_cast<const JGauss_t&>(*this).getValue(z));
327 static_cast<JGauss_t&>(gradient) += JGauss_t(static_cast<const JGauss_t&>(*this).getGradient(z)).mul(static_cast<const JGauss_t&>(*this).getValue(x) * static_cast<const JGauss_t&>(*this).getValue(y));
328
329 return gradient;
330 }
JGauss3D()
Default constructor.
JGauss_t & mul(const double factor)
Scale gauss.
Definition JGauss.hh:120

◆ operator()() [1/3]

double JMATH::JMathlib< JGauss3D< ID_t, false > >::operator() ( const Args &... args) const
inlineinherited

Function value.

Parameters
argsabscissa value(s)
Returns
function value

Definition at line 362 of file JMathlib.hh.

363 {
364 return static_cast<const JF1_t&>(*this).getValue(args...);
365 }

◆ getValue() [2/2]

double JMATH::JGauss< ID_t, normalised >::getValue ( const double x) const
inlineinherited

Function value.

Parameters
xabscissa value
Returns
function value

Definition at line 222 of file JGauss.hh.

223 {
224 const double u = (x - mean) / sigma;
225
226 return signal * get(u) + background;
227 }
double background
Definition JGauss.hh:164
double signal
Definition JGauss.hh:163

◆ getDerivative() [1/2]

double JMATH::JGauss< ID_t, normalised >::getDerivative ( const double x) const
inlineinherited

Derivative value.

Parameters
xabscissa value
Returns
derivative value

Definition at line 236 of file JGauss.hh.

237 {
238 const double u = (x - mean) / sigma;
239
240 return signal * get(u) * -u / sigma;
241 }

◆ getDerivative() [2/2]

double JMATH::JGauss< ID_t, normalised >::getDerivative ( const double x) const
inlineinherited

Derivative value.

Parameters
xabscissa value
Returns
derivative value

Definition at line 1635 of file JMathlib.hh.

1636 {
1637 const double w = 1.0 / sigma;
1638 const double u = (x - center) / sigma;
1639
1640 return get(u) * -u * w;
1641 }

◆ operator()() [2/3]

double JMATH::JGauss< ID_t, normalised >::operator() ( const double x) const
inlineinherited

Function value.

Parameters
xabscissa value
Returns
function value

Definition at line 250 of file JGauss.hh.

251 {
252 return getValue(x);
253 }
double getValue(const double x) const
Definition JGauss.hh:222

◆ operator()() [3/3]

double JMATH::JMathlib< JGauss< ID_t > >::operator() ( const Args &... args) const
inlineinherited

Function value.

Parameters
argsabscissa value(s)
Returns
function value

Definition at line 362 of file JMathlib.hh.

363 {
364 return static_cast<const JF1_t&>(*this).getValue(args...);
365 }

◆ getGradient() [2/2]

const JGauss_t & JMATH::JGauss< ID_t, normalised >::getGradient ( const double x) const
inlineinherited

Get gradient.

Parameters
xabscissa value
Returns
gradient

Definition at line 262 of file JGauss.hh.

263 {
264 const double w = 1.0 / sigma;
265 const double u = (x - mean) * w;
266 const double f0 = get(u);
267 const double fs = signal * f0;
268
269 gradient.mean = fs * (u) * w; // d(f)/d(mean)
270 gradient.sigma = fs * (u + 1.0) * (u - 1.0) * w; // d(f)/d(sigma)
271 gradient.signal = f0; // d(f)/d(signal)
272 gradient.background = 1.0; // d(f)/d(background)
273
274 return gradient;
275 }

◆ get() [1/2]

double JMATH::JGauss< ID_t, normalised >::get ( const double u) const
inlineprivateinherited

Get ordinate value.

Parameters
uabscissa value
Returns
ordinate value

Definition at line 284 of file JGauss.hh.

285 {
286 return exp(-0.5*u*u) / (sqrt(2.0*PI) * sigma);
287 }

◆ get() [2/2]

double JMATH::JGauss< ID_t, normalised >::get ( const double u) const
inlineprivateinherited

Get ordinate value.

Parameters
uabscissa value
Returns
ordinate value

Definition at line 1675 of file JMathlib.hh.

1676 {
1677 return exp(-0.5*u*u);
1678 }

◆ equals()

bool JMATH::JGauss_t::equals ( const JGauss_t & gauss,
const double eps = std::numeric_limits<double>::min() ) const
inlineinherited

Equality.

Parameters
gaussgauss
epsnumerical precision
Returns
true if gauss's identical; else false

Definition at line 70 of file JGauss.hh.

72 {
73 return (fabs(mean - gauss.mean) <= eps &&
74 fabs(sigma - gauss.sigma) <= eps &&
75 fabs(signal - gauss.signal) <= eps &&
76 fabs(background - gauss.background) <= eps);
77 }
double gauss(const double x, const double sigma)
Gauss function (normalised to 1 at x = 0).

◆ add() [1/2]

JGauss_t & JMATH::JGauss_t::add ( const JGauss_t & gauss)
inlineinherited

Add gauss.

Parameters
gaussgauss
Returns
this gauss

Definition at line 86 of file JGauss.hh.

87 {
88 mean += gauss.mean;
89 sigma += gauss.sigma;
90 signal += gauss.signal;
91 background += gauss.background;
92
93 return *this;
94 }

◆ add() [2/2]

JGauss< ID_t > & JMATH::JCalculus< JGauss< ID_t > >::add ( const JGauss< ID_t > & f1)
inlineinherited

Add function.

Parameters
f1function
Returns
this function

Definition at line 219 of file JMathlib.hh.

220 {
221 for (const auto& i : JF1_t::parameters) {
222 static_cast<JF1_t&>(*this).*i += f1.*i;
223 }
224
225 return static_cast<JF1_t&>(*this);
226 }
const JPolynome f1(1.0, 2.0, 3.0)
Function.

◆ sub() [1/2]

JGauss_t & JMATH::JGauss_t::sub ( const JGauss_t & gauss)
inlineinherited

Subtract gauss.

Parameters
gaussgauss
Returns
this gauss

Definition at line 103 of file JGauss.hh.

104 {
105 mean -= gauss.mean;
106 sigma -= gauss.sigma;
107 signal -= gauss.signal;
108 background -= gauss.background;
109
110 return *this;
111 }

◆ sub() [2/2]

JGauss< ID_t > & JMATH::JCalculus< JGauss< ID_t > >::sub ( const JGauss< ID_t > & f1)
inlineinherited

Subtract function.

Parameters
f1function
Returns
this function

Definition at line 235 of file JMathlib.hh.

236 {
237 for (const auto& i : JF1_t::parameters) {
238 static_cast<JF1_t&>(*this).*i -= f1.*i;
239 }
240
241 return static_cast<JF1_t&>(*this);
242 }

◆ mul() [1/3]

JGauss_t & JMATH::JGauss_t::mul ( const double factor)
inlineinherited

Scale gauss.

Parameters
factormultiplication factor
Returns
this gauss

Definition at line 120 of file JGauss.hh.

121 {
122 mean *= factor;
123 sigma *= factor;
124 signal *= factor;
125 background *= factor;
126
127 return *this;
128 }

◆ mul() [2/3]

JGauss_t & JMATH::JMath< JGauss_t, JSecond_t >::mul ( const JSecond_t & object)
inlineinherited

Multiply with object.

Parameters
objectobject
Returns
result object

Definition at line 354 of file JMath.hh.

355 {
356 return static_cast<JFirst_t&>(*this) = JFirst_t().mul(static_cast<const JFirst_t&>(*this), object);
357 }

◆ mul() [3/3]

JGauss< ID_t > & JMATH::JCalculus< JGauss< ID_t > >::mul ( const double factor)
inlineinherited

Scale function.

Parameters
factorfactor
Returns
this function

Definition at line 251 of file JMathlib.hh.

252 {
253 for (const auto& i : JF1_t::parameters) {
254 static_cast<JF1_t&>(*this).*i *= factor;
255 }
256
257 return static_cast<JF1_t&>(*this);
258 }

◆ negate()

JGauss< ID_t > & JMATH::JCalculus< JGauss< ID_t > >::negate ( )
inlineinherited

Negate function.

Returns
this function

Definition at line 203 of file JMathlib.hh.

204 {
205 for (const auto& i : JF1_t::parameters) {
206 static_cast<JF1_t&>(*this).*i = -(static_cast<JF1_t&>(*this).*i);
207 }
208
209 return static_cast<JF1_t&>(*this);
210 }

◆ div()

JGauss< ID_t > & JMATH::JCalculus< JGauss< ID_t > >::div ( const double factor)
inlineinherited

Scale function.

Parameters
factorfactor
Returns
this function

Definition at line 267 of file JMathlib.hh.

268 {
269 for (const auto& i : JF1_t::parameters) {
270 static_cast<JF1_t&>(*this).*i /= factor;
271 }
272
273 return static_cast<JF1_t&>(*this);
274 }

Member Data Documentation

◆ gradient

JGauss_t JMATH::JGauss< ID_t, normalised >::gradient
mutableprivateinherited

Definition at line 289 of file JGauss.hh.

◆ ID

const int JMATH::JGauss< ID_t, normalised >::ID
staticinherited

Definition at line 1590 of file JMathlib.hh.

◆ center

double JMATH::JGauss< ID_t, normalised >::center
inherited

center

Definition at line 1664 of file JMathlib.hh.

◆ sigma

double JMATH::JGauss< ID_t, normalised >::sigma
inherited

sigma

Definition at line 1665 of file JMathlib.hh.

◆ parameters

const parameter_list< JGauss< ID_t, true > > JMATH::JGauss< ID_t >::parameters
staticinherited

parameters

Set parameters.

Definition at line 1666 of file JMathlib.hh.

◆ mean

double JMATH::JGauss_t::mean
inherited

Definition at line 161 of file JGauss.hh.

◆ signal

double JMATH::JGauss_t::signal
inherited

Definition at line 163 of file JGauss.hh.

◆ background

double JMATH::JGauss_t::background
inherited

Definition at line 164 of file JGauss.hh.


The documentation for this struct was generated from the following file: