Belle II Software
release-05-01-25
PulseHeightGenerator.cc
1
/**************************************************************************
2
* BASF2 (Belle Analysis Framework 2) *
3
* Copyright(C) 2017 - Belle II Collaboration *
4
* *
5
* Author: The Belle II Collaboration *
6
* Contributors: Marko Staric *
7
* *
8
* This software is provided "as is" without any warranty. *
9
**************************************************************************/
10
11
#include <top/modules/TOPDigitizer/PulseHeightGenerator.h>
12
#include <framework/logging/Logger.h>
13
14
#include <TRandom.h>
15
16
#include <iostream>
17
18
using namespace
std;
19
20
namespace
Belle2
{
25
namespace
TOP {
26
27
PulseHeightGenerator::PulseHeightGenerator(
double
x0,
double
p1,
double
p2,
28
double
xmax):
29
m_x0(x0), m_p1(p1), m_p2(p2), m_xmax(xmax)
30
{
31
if
(x0 <= 0)
32
B2FATAL(
"TOP::PulseHeightGenerator: parameter x0 must be positive"
);
33
if
(p1 < 0)
34
B2FATAL(
"TOP::PulseHeightGenerator: parameter p1 must be non-negative"
);
35
if
(p2 <= 0)
36
B2FATAL(
"TOP::PulseHeightGenerator: parameter p2 must be positive"
);
37
38
double
xPeak = pow((p1 / p2), 1 / p2) * x0;
39
if
(
m_xmax
< xPeak) xPeak =
m_xmax
;
40
m_vPeak
=
getValue
(xPeak);
41
42
}
43
44
45
double
PulseHeightGenerator::generate
()
const
46
{
47
if
(
m_xmax
<= 0)
return
0;
48
while
(
true
) {
49
double
x = gRandom->Uniform(
m_xmax
);
50
if
(gRandom->Uniform(
m_vPeak
) <
getValue
(x))
return
x;
51
}
52
}
53
54
}
// TOP
56
}
// Belle2
Belle2::TOP::PulseHeightGenerator::m_vPeak
double m_vPeak
peak value
Definition:
PulseHeightGenerator.h:77
Belle2::TOP::PulseHeightGenerator::m_xmax
double m_xmax
upper bound of range [ADC counts]
Definition:
PulseHeightGenerator.h:76
Belle2::TOP::PulseHeightGenerator::generate
double generate() const
Returns generated pulse height.
Definition:
PulseHeightGenerator.cc:45
Belle2
Abstract base class for different kinds of events.
Definition:
MillepedeAlgorithm.h:19
Belle2::TOP::PulseHeightGenerator::getValue
double getValue(double x) const
Returns distribution value at x.
Definition:
PulseHeightGenerator.h:59
top
modules
TOPDigitizer
src
PulseHeightGenerator.cc
Generated on Fri Nov 5 2021 03:59:25 for Belle II Software by
1.8.17