LArSoft
v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
energy.h
Go to the documentation of this file.
1
18
#ifndef LARDATAALG_UTILITIES_QUANTITIES_ENERGY_H
19
#define LARDATAALG_UTILITIES_QUANTITIES_ENERGY_H
20
21
// LArSoft libraries
22
#include "
lardataalg/Utilities/quantities.h
"
23
24
// C/C++ standard libraries
25
#include <ratio>
26
#include <string_view>
27
28
//------------------------------------------------------------------------------
29
namespace
util::quantities
{
30
31
namespace
units {
32
33
using namespace
std::string_view_literals
;
// for operator""sv()
34
35
struct
ElectronVolt
:
public
concepts::UnitBase
{
36
static
constexpr
auto
symbol =
"eV"
sv;
37
static
constexpr
auto
name =
"electronvolt"
sv;
38
};
39
40
}
// namespace units
41
42
// -- BEGIN Particle energy --------------------------------------------------
58
61
template
<
typename
R,
typename
T =
double
>
62
using
scaled_electronvolt
=
concepts::scaled_quantity<units::ElectronVolt, R, T>
;
63
64
//
65
// electronvolt
66
//
68
template
<
typename
T =
double
>
69
using
electronvolt_as
=
scaled_electronvolt<std::ratio<1>
, T>;
70
72
using
electronvolt
=
electronvolt_as<>
;
73
74
//
75
// microelectronvolt
76
//
78
template
<
typename
T =
double
>
79
using
microelectronvolt_as
=
concepts::rescale<electronvolt_as<T>
, std::micro>;
80
82
using
microelectronvolt
=
microelectronvolt_as<>
;
83
84
//
85
// millielectronvolt
86
//
88
template
<
typename
T =
double
>
89
using
millielectronvolt_as
=
concepts::rescale<electronvolt_as<T>
, std::milli>;
90
92
using
millielectronvolt
=
millielectronvolt_as<>
;
93
94
//
95
// kiloelectronvolt
96
//
98
template
<
typename
T =
double
>
99
using
kiloelectronvolt_as
=
concepts::rescale<electronvolt_as<T>
, std::kilo>;
100
102
using
kiloelectronvolt
=
kiloelectronvolt_as<>
;
103
104
//
105
// megaelectronvolt
106
//
108
template
<
typename
T =
double
>
109
using
megaelectronvolt_as
=
concepts::rescale<electronvolt_as<T>
, std::mega>;
110
112
using
megaelectronvolt
=
megaelectronvolt_as<>
;
113
114
//
115
// gigaelectronvolt
116
//
118
template
<
typename
T =
double
>
119
using
gigaelectronvolt_as
=
concepts::rescale<electronvolt_as<T>
, std::giga>;
120
122
using
gigaelectronvolt
=
gigaelectronvolt_as<>
;
123
124
//
125
// teraelectronvolt
126
//
128
template
<
typename
T =
double
>
129
using
teraelectronvolt_as
=
concepts::rescale<electronvolt_as<T>
, std::tera>;
130
132
using
teraelectronvolt
=
teraelectronvolt_as<>
;
133
135
// -- END Particle energy ----------------------------------------------------
136
154
namespace
energy_literals {
155
156
// @{
158
constexpr
electronvolt
operator
""
_eV(
long
double
v)
159
{
160
return
electronvolt
{
static_cast<
double
>
(v)};
161
}
162
constexpr
electronvolt
operator
""
_eV(
unsigned
long
long
int
v)
163
{
164
return
electronvolt
{
static_cast<
double
>
(v)};
165
}
166
// @}
167
168
// @{
170
constexpr
microelectronvolt
operator
""
_ueV(
long
double
v)
171
{
172
return
microelectronvolt
{
static_cast<
double
>
(v)};
173
}
174
constexpr
microelectronvolt
operator
""
_ueV(
unsigned
long
long
int
v)
175
{
176
return
microelectronvolt
{
static_cast<
double
>
(v)};
177
}
178
// @}
179
180
// @{
182
constexpr
millielectronvolt
operator
""
_meV(
long
double
v)
183
{
184
return
millielectronvolt
{
static_cast<
double
>
(v)};
185
}
186
constexpr
millielectronvolt
operator
""
_meV(
unsigned
long
long
int
v)
187
{
188
return
millielectronvolt
{
static_cast<
double
>
(v)};
189
}
190
// @}
191
192
// @{
194
constexpr
kiloelectronvolt
operator
""
_keV(
long
double
v)
195
{
196
return
kiloelectronvolt
{
static_cast<
double
>
(v)};
197
}
198
constexpr
kiloelectronvolt
operator
""
_keV(
unsigned
long
long
int
v)
199
{
200
return
kiloelectronvolt
{
static_cast<
double
>
(v)};
201
}
202
// @}
203
204
// @{
206
constexpr
megaelectronvolt
operator
""
_MeV(
long
double
v)
207
{
208
return
megaelectronvolt
{
static_cast<
double
>
(v)};
209
}
210
constexpr
megaelectronvolt
operator
""
_MeV(
unsigned
long
long
int
v)
211
{
212
return
megaelectronvolt
{
static_cast<
double
>
(v)};
213
}
214
// @}
215
216
// @{
218
constexpr
gigaelectronvolt
operator
""
_GeV(
long
double
v)
219
{
220
return
gigaelectronvolt
{
static_cast<
double
>
(v)};
221
}
222
constexpr
gigaelectronvolt
operator
""
_GeV(
unsigned
long
long
int
v)
223
{
224
return
gigaelectronvolt
{
static_cast<
double
>
(v)};
225
}
226
// @}
227
228
// @{
230
constexpr
teraelectronvolt
operator
""
_TeV(
long
double
v)
231
{
232
return
teraelectronvolt
{
static_cast<
double
>
(v)};
233
}
234
constexpr
teraelectronvolt
operator
""
_TeV(
unsigned
long
long
int
v)
235
{
236
return
teraelectronvolt
{
static_cast<
double
>
(v)};
237
}
238
// @}
239
240
}
// energy_literals
241
242
}
// namespace util::quantities
243
244
//------------------------------------------------------------------------------
245
246
#endif // LARDATAALG_UTILITIES_QUANTITIES_ENERGY_H
string_view_literals
util::quantities::concepts::Quantity
A value measured in the specified unit.
Definition:
quantities.h:554
util::quantities::concepts::UnitBase
Definition:
quantities.h:359
quantities.h
Numeric variable proxies with embedded unit of measurement.
util::quantities::units::ElectronVolt
Definition:
energy.h:35
util::quantities
Types of variables with a unit.
Definition:
intervals.h:20
lardataalg
v09_17_03
source
lardataalg
Utilities
quantities
energy.h
Generated on Thu May 2 2024 20:59:37 for LArSoft by
1.8.11