Belle II Software development
PulseHeightGenerator Class Reference

Generates pulse height according to distribution: P(x) = (x/x0)^p1 * exp(-(x/x0)^p2), p1 >= 0, p2 > 0 in the range 0 to xmax. More...

#include <PulseHeightGenerator.h>

Public Member Functions

 PulseHeightGenerator ()
 Default constructor.
 
 PulseHeightGenerator (double x0, double p1, double p2, double xmax)
 Constructor.
 
double getValue (double x) const
 Returns distribution value at x.
 
double generate () const
 Returns generated pulse height.
 

Private Attributes

double m_x0 = 0
 distribution parameter [ADC counts]
 
double m_p1 = 0
 distribution parameter, must be non-negative
 
double m_p2 = 0
 distribution parameter
 
double m_xmax = 0
 upper bound of range [ADC counts]
 
double m_vPeak = 0
 peak value
 

Detailed Description

Generates pulse height according to distribution: P(x) = (x/x0)^p1 * exp(-(x/x0)^p2), p1 >= 0, p2 > 0 in the range 0 to xmax.

Definition at line 25 of file PulseHeightGenerator.h.

Constructor & Destructor Documentation

◆ PulseHeightGenerator() [1/2]

Default constructor.

Definition at line 32 of file PulseHeightGenerator.h.

33 {}

◆ PulseHeightGenerator() [2/2]

PulseHeightGenerator ( double  x0,
double  p1,
double  p2,
double  xmax 
)

Constructor.

Parameters
x0distribution parameter [ADC counts]
p1distribution parameter, must be non-negative
p2distribution parameter
xmaxupper bound of range in which to generate [ADC counts]

Definition at line 25 of file PulseHeightGenerator.cc.

26 :
27 m_x0(x0), m_p1(p1), m_p2(p2), m_xmax(xmax)
28 {
29 if (x0 <= 0)
30 B2FATAL("TOP::PulseHeightGenerator: parameter x0 must be positive");
31 if (p1 < 0)
32 B2FATAL("TOP::PulseHeightGenerator: parameter p1 must be non-negative");
33 if (p2 <= 0)
34 B2FATAL("TOP::PulseHeightGenerator: parameter p2 must be positive");
35
36 double xPeak = pow((p1 / p2), 1 / p2) * x0;
37 if (m_xmax < xPeak) xPeak = m_xmax;
38 m_vPeak = getValue(xPeak);
39
40 }
double getValue(double x) const
Returns distribution value at x.
double m_p2
distribution parameter
double m_xmax
upper bound of range [ADC counts]
double m_x0
distribution parameter [ADC counts]
double m_p1
distribution parameter, must be non-negative

Member Function Documentation

◆ generate()

double generate ( ) const

Returns generated pulse height.

Returns
height [ADC counts]

Definition at line 43 of file PulseHeightGenerator.cc.

44 {
45 if (m_xmax <= 0) return 0;
46 while (true) {
47 double x = gRandom->Uniform(m_xmax);
48 if (gRandom->Uniform(m_vPeak) < getValue(x)) return x;
49 }
50 }

◆ getValue()

double getValue ( double  x) const
inline

Returns distribution value at x.

Parameters
xargument [ADC counts]
Returns
value

Definition at line 49 of file PulseHeightGenerator.h.

50 {
51 x /= m_x0;
52 return pow(x, m_p1) * exp(-pow(x, m_p2));
53 }

Member Data Documentation

◆ m_p1

double m_p1 = 0
private

distribution parameter, must be non-negative

Definition at line 64 of file PulseHeightGenerator.h.

◆ m_p2

double m_p2 = 0
private

distribution parameter

Definition at line 65 of file PulseHeightGenerator.h.

◆ m_vPeak

double m_vPeak = 0
private

peak value

Definition at line 67 of file PulseHeightGenerator.h.

◆ m_x0

double m_x0 = 0
private

distribution parameter [ADC counts]

Definition at line 63 of file PulseHeightGenerator.h.

◆ m_xmax

double m_xmax = 0
private

upper bound of range [ADC counts]

Definition at line 66 of file PulseHeightGenerator.h.


The documentation for this class was generated from the following files: