Jpp 19.3.0-rc.1
the software that should make you happy
Loading...
Searching...
No Matches
JTOOLS::JResultDerivative< JResult_t > Struct Template Reference

Data structure for result including value and first derivative of function. More...

#include <JResult.hh>

Inheritance diagram for JTOOLS::JResultDerivative< JResult_t >:
JMATH::JMath< JFirst_t, JSecond_t > JTOOLS::JResultHesse< JResult_t >

Public Types

typedef JLANG::JClass< JResult_t >::argument_type argument_type
 

Public Member Functions

 JResultDerivative ()
 Default constructor.
 
 JResultDerivative (argument_type f, argument_type fp)
 Constructor.
 
JResultDerivativenegate ()
 Prefix unary minus for function value of PDF.
 
JResultDerivativeadd (const JResultDerivative &value)
 Addition operator for function value of PDF.
 
JResultDerivativesub (const JResultDerivative &value)
 Subtraction operator for function value of PDF.
 
JResultDerivativemul (const double value)
 Multiplication operator for function value of PDF.
 
JResultDerivativediv (const double value)
 Division operator for function value of PDF.
 
double getP (const bool hit) const
 Get probability.
 
double getChi2 (const bool hit) const
 Get chi2.
 
double getDerivativeOfChi2 (const bool hit) const
 Get derivative of chi2.
 
JFirst_t & mul (const JSecond_t &object)
 Multiply with object.
 

Public Attributes

JResult_t f
 function value
 
JResult_t fp
 first derivative
 

Detailed Description

template<class JResult_t>
struct JTOOLS::JResultDerivative< JResult_t >

Data structure for result including value and first derivative of function.

This data structure contains the following data mambers:

   JResultDerivative::f   = function value;
   JResultDerivative::fp  = first  derivative;

This class implements the JMATH::JMath interface.

Definition at line 43 of file JResult.hh.

Member Typedef Documentation

◆ argument_type

template<class JResult_t >
JLANG::JClass<JResult_t>::argument_type JTOOLS::JResultDerivative< JResult_t >::argument_type

Definition at line 47 of file JResult.hh.

Constructor & Destructor Documentation

◆ JResultDerivative() [1/2]

template<class JResult_t >
JTOOLS::JResultDerivative< JResult_t >::JResultDerivative ( )
inline

Default constructor.

Definition at line 53 of file JResult.hh.

53 :
54 f (JMATH::zero),
56 {}
static const JZero zero
Function object to assign zero value.
Definition JZero.hh:105
JResult_t f
function value
Definition JResult.hh:194
JResult_t fp
first derivative
Definition JResult.hh:195

◆ JResultDerivative() [2/2]

template<class JResult_t >
JTOOLS::JResultDerivative< JResult_t >::JResultDerivative ( argument_type f,
argument_type fp )
inline

Constructor.

Parameters
ffunction value
fpfirst derivative

Definition at line 65 of file JResult.hh.

66 :
67 f (f ),
68 fp (fp)
69 {}

Member Function Documentation

◆ negate()

template<class JResult_t >
JResultDerivative & JTOOLS::JResultDerivative< JResult_t >::negate ( )
inline

Prefix unary minus for function value of PDF.

Returns
function value of PDF

Definition at line 77 of file JResult.hh.

78 {
79 f = -f;
80 fp = -fp;
81
82 return *this;
83 }

◆ add()

template<class JResult_t >
JResultDerivative & JTOOLS::JResultDerivative< JResult_t >::add ( const JResultDerivative< JResult_t > & value)
inline

Addition operator for function value of PDF.

Parameters
valuefunction value of PDF
Returns
function value of PDF

Definition at line 92 of file JResult.hh.

93 {
94 f += value.f;
95 fp += value.fp;
96
97 return *this;
98 }

◆ sub()

template<class JResult_t >
JResultDerivative & JTOOLS::JResultDerivative< JResult_t >::sub ( const JResultDerivative< JResult_t > & value)
inline

Subtraction operator for function value of PDF.

Parameters
valuefunction value of PDF
Returns
function value of PDF

Definition at line 107 of file JResult.hh.

108 {
109 f -= value.f;
110 fp -= value.fp;
111
112 return *this;
113 }

◆ mul() [1/2]

template<class JResult_t >
JResultDerivative & JTOOLS::JResultDerivative< JResult_t >::mul ( const double value)
inline

Multiplication operator for function value of PDF.

Parameters
valuemultiplication factor
Returns
function value of PDF

Definition at line 122 of file JResult.hh.

123 {
124 f *= value;
125 fp *= value;
126
127 return *this;
128 }

◆ div()

template<class JResult_t >
JResultDerivative & JTOOLS::JResultDerivative< JResult_t >::div ( const double value)
inline

Division operator for function value of PDF.

Parameters
valuemultiplication factor
Returns
function value of PDF

Definition at line 137 of file JResult.hh.

138 {
139 f /= value;
140 fp /= value;
141
142 return *this;
143 }

◆ getP()

template<class JResult_t >
double JTOOLS::JResultDerivative< JResult_t >::getP ( const bool hit) const
inline

Get probability.


If the given hit is false (true), the return value corresponds to the Poisson probability that zero (one or more) hits occur for the given expectation value JResultDerivative::f.

Parameters
hithit (or not)
Returns
probability

Definition at line 154 of file JResult.hh.

155 {
156 if (!hit)
157 return exp(-f); // probability of 0 hits
158 else
159 return 1.0 - getP(false); // probability of 1 or more hits
160 }
double getP(const bool hit) const
Get probability.
Definition JResult.hh:154

◆ getChi2()

template<class JResult_t >
double JTOOLS::JResultDerivative< JResult_t >::getChi2 ( const bool hit) const
inline

Get chi2.

The chi2 corresponds to -log(P), where P is the probability JResultDerivative::f.

Parameters
hithit (or not)
Returns
chi2

Definition at line 170 of file JResult.hh.

171 {
172 if (!hit)
173 return f; // = -log(getP(false))
174 else
175 return -log(getP(true));
176 }

◆ getDerivativeOfChi2()

template<class JResult_t >
double JTOOLS::JResultDerivative< JResult_t >::getDerivativeOfChi2 ( const bool hit) const
inline

Get derivative of chi2.

Parameters
hithit (or not)
Returns
derivative

Definition at line 185 of file JResult.hh.

186 {
187 if (!hit)
188 return fp;
189 else
190 return -fp * getP(false) / getP(true);
191 }

◆ mul() [2/2]

template<class JFirst_t , class JSecond_t >
JFirst_t & JMATH::JMath< JFirst_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 }

Member Data Documentation

◆ f

template<class JResult_t >
JResult_t JTOOLS::JResultDerivative< JResult_t >::f

function value

Definition at line 194 of file JResult.hh.

◆ fp

template<class JResult_t >
JResult_t JTOOLS::JResultDerivative< JResult_t >::fp

first derivative

Definition at line 195 of file JResult.hh.


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