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
LandauDistribution.hpp
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file LandauDistribution.hpp
1
// This file is part of the Acts project.
2
//
3
// Copyright (C) 2018-2020 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 <limits>
12
#include <random>
13
14
namespace
ActsFatras {
15
19
class
LandauDistribution
{
20
public
:
22
struct
param_type
{
24
using
distribution_type
=
LandauDistribution
;
25
29
double
location
= 0.0;
31
double
scale
= 1.0;
32
34
param_type
(
double
location_,
double
scale_)
35
:
location
(location_),
scale
(scale_) {}
36
// Explicitlely defaulted construction and assignment
37
param_type
() =
default
;
38
param_type
(
const
param_type
&) =
default
;
39
param_type
(
param_type
&&) =
default
;
40
param_type
&
operator=
(
const
param_type
&) =
default
;
41
param_type
&
operator=
(
param_type
&&) =
default
;
42
44
friend
bool
operator==
(
const
param_type
&
lhs
,
const
param_type
&
rhs
) {
45
return
(lhs.
location
== rhs.
location
) and (lhs.
scale
== rhs.
scale
);
46
}
47
friend
bool
operator!=
(
const
param_type
&
lhs
,
const
param_type
&
rhs
) {
48
return
not(lhs == rhs);
49
}
50
};
52
using
result_type
=
double
;
53
55
LandauDistribution
(
double
location,
double
scale) :
m_cfg
(location, scale) {}
57
LandauDistribution
(
const
param_type
&
cfg
) :
m_cfg
(cfg) {}
58
// Explicitlely defaulted construction and assignment
59
LandauDistribution
() =
default
;
60
LandauDistribution
(
const
LandauDistribution
&) =
default
;
61
LandauDistribution
(
LandauDistribution
&&) =
default
;
62
LandauDistribution
&
operator=
(
const
LandauDistribution
&) =
default
;
63
LandauDistribution
&
operator=
(
LandauDistribution
&&) =
default
;
64
66
void
reset
() {}
68
param_type
param
()
const
{
return
m_cfg
; }
70
void
param
(
const
param_type
&
cfg
) {
m_cfg
=
cfg
; }
71
73
result_type
min
()
const
{
return
-std::numeric_limits<double>::infinity(); }
75
result_type
max
()
const
{
return
std::numeric_limits<double>::infinity(); }
76
78
template
<
typename
Generator>
79
result_type
operator()
(
Generator
&
generator
) {
80
return
(*
this
)(
generator
,
m_cfg
);
81
}
83
template
<
typename
Generator>
84
result_type
operator()
(
Generator
&
generator
,
const
param_type
¶ms) {
85
const
auto
z
= std::uniform_real_distribution<double>()(generator);
86
return
params.
location
+ params.
scale
*
quantile
(
z
);
87
}
88
90
friend
bool
operator==
(
const
LandauDistribution
&
lhs
,
91
const
LandauDistribution
&
rhs
) {
92
return
lhs.
m_cfg
== rhs.
m_cfg
;
93
}
94
friend
bool
operator!=
(
const
LandauDistribution
&
lhs
,
95
const
LandauDistribution
&
rhs
) {
96
return
!(lhs ==
rhs
);
97
}
98
99
private
:
100
param_type
m_cfg
;
101
102
static
double
quantile
(
double
z
);
103
};
104
105
}
// namespace ActsFatras
acts
blob
sPHENIX
Fatras
include
ActsFatras
Utilities
LandauDistribution.hpp
Built by
Jin Huang
. updated:
Sat Feb 17 2024 22:17:41
using
1.8.2 with
sPHENIX GitHub integration