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
Units.hpp
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file Units.hpp
1
// This file is part of the Acts project.
2
//
3
// Copyright (C) 2016-2019 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
namespace
Acts {
12
133
137
138
namespace
UnitConstants {
139
// Length, native unit mm
140
constexpr
double
mm
= 1.0;
141
constexpr
double
fm
= 1
e
-12 *
mm
;
142
constexpr
double
pm
= 1
e
-9 *
mm
;
143
constexpr
double
nm
= 1
e
-6 *
mm
;
144
constexpr
double
um
= 1
e
-3 *
mm
;
145
constexpr
double
cm
= 1e1 *
mm
;
146
constexpr
double
m
= 1e3 *
mm
;
147
constexpr
double
km
= 1e6 *
mm
;
148
// Shortcuts for commonly used area and volume units. This intentionally
149
// contains not all possible combinations to avoid cluttering the namespace.
150
// Missing area or volume units can always be defined on the fly using the
151
// existing length units e.g. 1fm³ -> 1fm * 1fm * 1fm
152
// Area, native unit mm²
153
constexpr
double
mm2
=
mm
*
mm
;
154
constexpr
double
cm2
=
cm
*
cm
;
155
constexpr
double
m2
=
m
*
m
;
156
// Volume, native unit mm³
157
constexpr
double
mm3
=
mm
*
mm
*
mm
;
158
constexpr
double
cm3
=
cm
*
cm
*
cm
;
159
constexpr
double
m3
=
m
*
m
*
m
;
160
// Time, native unit mm = [speed-of-light * time] = mm/s * s
162
constexpr
double
s
= 299792458000.0;
// = 299792458.0 * (m / 1.0) * 1.0;
163
constexpr
double
fs
= 1
e
-15 *
s
;
164
constexpr
double
ps
= 1
e
-12 *
s
;
165
constexpr
double
ns
= 1
e
-9 *
s
;
166
constexpr
double
us
= 1
e
-6 *
s
;
167
constexpr
double
ms
= 1
e
-3 *
s
;
168
constexpr
double
min
= 60.0 *
s
;
169
constexpr
double
h
= 3600.0 *
s
;
170
// Angles, native unit radian
171
constexpr
double
mrad
= 1
e
-3;
172
constexpr
double
rad
= 1.0;
173
constexpr
double
degree
= 0.017453292519943295;
// = M_PI / 180.0 * rad;
174
// Energy/mass/momentum, native unit GeV
175
constexpr
double
GeV
= 1.0;
176
constexpr
double
eV
= 1
e
-9 *
GeV
;
177
constexpr
double
keV
= 1
e
-6 *
GeV
;
178
constexpr
double
MeV
= 1
e
-3 *
GeV
;
179
constexpr
double
TeV
= 1e3 *
GeV
;
180
constexpr
double
J
= 6241509074.460763 *
GeV
;
182
constexpr
double
u
= 0.93149410242;
183
// 1eV/c² == 1.782662e-36kg
184
// 1GeV/c² == 1.782662e-27kg
185
// -> 1kg == (1/1.782662e-27)GeV/c²
186
// -> 1g == (1/(1e3*1.782662e-27))GeV/c²
187
constexpr
double
g
= 1.0 / 1.782662e-24;
188
constexpr
double
kg
= 1.0 / 1.782662e-27;
190
constexpr
double
e
= 1.0;
193
constexpr
double
T
= 0.000299792458;
// = eV * s / (e * m2);
194
constexpr
double
Gauss
= 1
e
-4 *
T
;
195
constexpr
double
kGauss
= 1
e
-1 *
T
;
197
constexpr
double
mol
= 1.0;
198
}
// namespace UnitConstants
199
200
namespace
UnitLiterals {
201
// define user literal functions for the given unit constant
202
#define ACTS_DEFINE_UNIT_LITERAL(name) \
203
constexpr double operator"" _##name(long double x) { \
204
return ::Acts::UnitConstants::name * x; \
205
} \
206
constexpr double operator"" _##name(unsigned long long x) { \
207
return ::Acts::UnitConstants::name * x; \
208
}
209
ACTS_DEFINE_UNIT_LITERAL
(
fm
)
210
ACTS_DEFINE_UNIT_LITERAL
(
pm
)
211
ACTS_DEFINE_UNIT_LITERAL
(
nm
)
212
ACTS_DEFINE_UNIT_LITERAL
(
um
)
213
ACTS_DEFINE_UNIT_LITERAL
(
mm
)
214
ACTS_DEFINE_UNIT_LITERAL
(
cm
)
215
ACTS_DEFINE_UNIT_LITERAL
(
m
)
216
ACTS_DEFINE_UNIT_LITERAL
(
km
)
217
ACTS_DEFINE_UNIT_LITERAL
(
mm2
)
218
ACTS_DEFINE_UNIT_LITERAL
(
cm2
)
219
ACTS_DEFINE_UNIT_LITERAL
(
m2
)
220
ACTS_DEFINE_UNIT_LITERAL
(
mm3
)
221
ACTS_DEFINE_UNIT_LITERAL
(
cm3
)
222
ACTS_DEFINE_UNIT_LITERAL
(
m3
)
223
ACTS_DEFINE_UNIT_LITERAL
(
fs
)
224
ACTS_DEFINE_UNIT_LITERAL
(
ps
)
225
ACTS_DEFINE_UNIT_LITERAL
(
ns
)
226
ACTS_DEFINE_UNIT_LITERAL
(
us
)
227
ACTS_DEFINE_UNIT_LITERAL
(
ms
)
228
ACTS_DEFINE_UNIT_LITERAL
(
s
)
229
ACTS_DEFINE_UNIT_LITERAL
(
min
)
230
ACTS_DEFINE_UNIT_LITERAL
(
h
)
231
ACTS_DEFINE_UNIT_LITERAL
(
mrad
)
232
ACTS_DEFINE_UNIT_LITERAL
(
rad
)
233
ACTS_DEFINE_UNIT_LITERAL
(
degree
)
234
ACTS_DEFINE_UNIT_LITERAL
(
eV
)
235
ACTS_DEFINE_UNIT_LITERAL
(
keV
)
236
ACTS_DEFINE_UNIT_LITERAL
(
MeV
)
237
ACTS_DEFINE_UNIT_LITERAL
(
GeV
)
238
ACTS_DEFINE_UNIT_LITERAL
(
TeV
)
239
ACTS_DEFINE_UNIT_LITERAL
(
J
)
240
ACTS_DEFINE_UNIT_LITERAL
(
u
)
241
ACTS_DEFINE_UNIT_LITERAL
(
g
)
242
ACTS_DEFINE_UNIT_LITERAL
(
kg
)
243
ACTS_DEFINE_UNIT_LITERAL
(
e
)
244
ACTS_DEFINE_UNIT_LITERAL
(
T
)
245
ACTS_DEFINE_UNIT_LITERAL
(
Gauss
)
246
ACTS_DEFINE_UNIT_LITERAL
(
kGauss
)
247
ACTS_DEFINE_UNIT_LITERAL
(
mol
)
248
// not needed anymore. undef to prevent littering the namespace
249
#undef ACTS_DEFINE_UNIT_LITERAL
250
}
// namespace UnitLiterals
251
255
namespace
PhysicalConstants {
256
// Speed of light
257
constexpr
double
c
= 1.0;
261
constexpr
double
hbar
=
262
6.582119569509066e-25 *
UnitConstants::GeV
*
UnitConstants::s
;
263
}
// namespace PhysicalConstants
264
265
}
// namespace Acts
acts
blob
sPHENIX
Core
include
Acts
Definitions
Units.hpp
Built by
Jin Huang
. updated:
Sat Feb 17 2024 22:17:32
using
1.8.2 with
sPHENIX GitHub integration