Analysis Software
Documentation for
sPHENIX
simulation software
Home page
Related Pages
Modules
Namespaces
Classes
Files
Examples
External Links
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
RandomNumberDistributions.hpp
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file RandomNumberDistributions.hpp
1
// This file is part of the Acts project.
2
//
3
// Copyright (C) 2018 CERN for the benefit of the Acts project
4
//
5
// This Source Code Form is subject to the terms of the Mozilla Public
6
// License, v. 2.0. If a copy of the MPL was not distributed with this
7
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
8
9
#pragma once
10
11
#include "
Fatras/Kernel/detail/LandauQuantile.hpp
"
12
#include <random>
13
14
namespace
Fatras {
15
18
using
GaussDist
= std::normal_distribution<double>;
19
using
UniformDist
= std::uniform_real_distribution<double>;
20
using
GammaDist
= std::gamma_distribution<double>;
21
using
PoissonDist
= std::poisson_distribution<int>;
22
23
24
25
class
LandauDist
{
26
public
:
28
struct
param_type
{
29
double
mean
= 0.;
30
double
scale
= 1.;
31
33
param_type
() =
default
;
34
param_type
(
double
mean
,
double
scale
);
35
37
param_type
(
const
param_type
&) =
default
;
38
param_type
&
operator=
(
const
param_type
&) =
default
;
39
41
bool
operator==
(
const
param_type
&other)
const
;
42
bool
operator!=
(
const
param_type
&other)
const
{
return
!(*
this
== other); }
43
45
using
distribution_type
=
LandauDist
;
46
};
47
50
LandauDist
() =
default
;
51
LandauDist
(
double
mean
,
double
scale);
52
LandauDist
(
const
param_type
&
cfg
);
53
55
LandauDist
(
const
LandauDist
&) =
default
;
56
LandauDist
&
operator=
(
const
LandauDist
&) =
default
;
57
59
void
reset
() {
/* There is currently no state to reset here */
60
}
61
param_type
param
()
const
{
return
m_cfg
; }
62
void
param
(
const
param_type
&
p
) {
m_cfg
=
p
; }
63
66
using
result_type
=
double
;
67
result_type
min
()
const
;
68
result_type
max
()
const
;
69
71
template
<
typename
Generator>
result_type
operator()
(
Generator
&
engine
) {
72
return
(*
this
)(
engine
,
m_cfg
);
73
}
74
76
template
<
typename
Generator>
77
result_type
operator()
(
Generator
&
engine
,
const
param_type
¶ms) {
78
double
x
= std::generate_canonical<float, 10>(
engine
);
79
double
res = params.
mean
+
landau_quantile
(x, params.
scale
);
80
return
res;
81
}
82
84
bool
operator==
(
const
LandauDist
&other)
const
;
85
bool
operator!=
(
const
LandauDist
&other)
const
{
return
!(*
this
== other); }
86
87
private
:
88
param_type
m_cfg
;
89
};
90
}
// namespace Fatras
acts-fatras
blob
master
Core
include
Fatras
Kernel
detail
RandomNumberDistributions.hpp
Built by
Jin Huang
. updated:
Sat Feb 17 2024 22:17:32
using
1.8.2 with
sPHENIX GitHub integration