ECCE @ EIC Software
Reference for
ECCE @ EIC
simulation and reconstruction software on GitHub
Home page
Related Pages
Modules
Namespaces
Classes
Files
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
84
85
namespace
UnitConstants {
86
// Length, native unit mm
87
constexpr
double
fm
= 1
e
-12;
88
constexpr
double
pm
= 1
e
-9;
89
constexpr
double
um
= 1
e
-3;
90
constexpr
double
nm
= 1
e
-6;
91
constexpr
double
mm
= 1.0;
92
constexpr
double
cm
= 10.0;
93
constexpr
double
m
= 1
e3
;
94
constexpr
double
km
= 1
e6
;
95
// Shortcuts for commonly used area and volume units. This intentionally
96
// contains not all possible combinations to avoid cluttering the namespace.
97
// Missing area or volume units can always be defined on the fly using the
98
// existing length units e.g. 1fm³ -> 1fm * 1fm * 1fm
99
// Area, native unit mm²
100
constexpr
double
mm2
=
mm
*
mm
;
101
constexpr
double
cm2
=
cm
*
cm
;
102
constexpr
double
m2
=
m
*
m
;
103
// Volume, native unit mm³
104
constexpr
double
mm3
=
mm
*
mm
*
mm
;
105
constexpr
double
cm3
=
cm
*
cm
*
cm
;
106
constexpr
double
m3
=
m
*
m
*
m
;
107
// Time, native unit mm = [speed-of-light * time] = mm/s * s
108
constexpr
double
s
= 299792458000.0;
109
constexpr
double
fs
= 1
e
-15 *
s
;
110
constexpr
double
ps
= 1
e
-12 *
s
;
111
constexpr
double
ns
= 1
e
-9 *
s
;
112
constexpr
double
us
= 1
e
-6 *
s
;
113
constexpr
double
ms
= 1
e
-3 *
s
;
114
constexpr
double
min
= 60.0 *
s
;
115
constexpr
double
h
= 3600.0 *
s
;
116
// Angles, native unit radian
117
constexpr
double
mrad
= 1
e
-3;
118
constexpr
double
rad
= 1.0;
119
constexpr
double
degree
= 0.017453292519943295;
// pi / 180
120
// Energy/mass/momentum, native unit GeV
121
constexpr
double
eV
= 1
e
-9;
122
constexpr
double
keV
= 1
e
-6;
123
constexpr
double
MeV
= 1
e
-3;
124
constexpr
double
GeV
= 1.0;
125
constexpr
double
TeV
= 1
e3
;
126
// atomic mass unit u
127
constexpr
double
u
= 0.93149410242;
128
// 1eV/c² == 1.782662e-36kg
129
// 1GeV/c² == 1.782662e-27kg
130
// -> 1kg == (1/1.782662e-27)GeV/c²
131
// -> 1g == (1/(1e3*1.782662e-27))GeV/c²
132
constexpr
double
g
= 1.0 / 1.782662e-24;
133
constexpr
double
kg
= 1.0 / 1.782662e-27;
134
// Charge, native unit e (elementary charge)
135
constexpr
double
e
= 1.0;
136
constexpr
double
C
= 1.602176634e19;
137
// Magnetic field, native unit GeV/(e*mm)
138
constexpr
double
T
= 0.000299792458;
// equivalent to c in appropriate SI units
139
constexpr
double
Gauss
= 1
e
-4 *
T
;
140
constexpr
double
kGauss
= 1
e
-1 *
T
;
141
}
// namespace UnitConstants
142
143
namespace
UnitLiterals {
144
// define user literal functions for the given unit constant
145
#define ACTS_DEFINE_UNIT_LITERAL(name) \
146
constexpr double operator"" _##name(long double x) { \
147
return ::Acts::UnitConstants::name * x; \
148
} \
149
constexpr double operator"" _##name(unsigned long long x) { \
150
return ::Acts::UnitConstants::name * x; \
151
}
152
ACTS_DEFINE_UNIT_LITERAL
(
fm
)
153
ACTS_DEFINE_UNIT_LITERAL
(
pm
)
154
ACTS_DEFINE_UNIT_LITERAL
(
nm
)
155
ACTS_DEFINE_UNIT_LITERAL
(
um
)
156
ACTS_DEFINE_UNIT_LITERAL
(
mm
)
157
ACTS_DEFINE_UNIT_LITERAL
(
cm
)
158
ACTS_DEFINE_UNIT_LITERAL
(
m
)
159
ACTS_DEFINE_UNIT_LITERAL
(
km
)
160
ACTS_DEFINE_UNIT_LITERAL
(
mm2
)
161
ACTS_DEFINE_UNIT_LITERAL
(
cm2
)
162
ACTS_DEFINE_UNIT_LITERAL
(
m2
)
163
ACTS_DEFINE_UNIT_LITERAL
(
mm3
)
164
ACTS_DEFINE_UNIT_LITERAL
(
cm3
)
165
ACTS_DEFINE_UNIT_LITERAL
(
m3
)
166
ACTS_DEFINE_UNIT_LITERAL
(
fs
)
167
ACTS_DEFINE_UNIT_LITERAL
(
ps
)
168
ACTS_DEFINE_UNIT_LITERAL
(
ns
)
169
ACTS_DEFINE_UNIT_LITERAL
(
us
)
170
ACTS_DEFINE_UNIT_LITERAL
(
ms
)
171
ACTS_DEFINE_UNIT_LITERAL
(
s
)
172
ACTS_DEFINE_UNIT_LITERAL
(
min
)
173
ACTS_DEFINE_UNIT_LITERAL
(
h
)
174
ACTS_DEFINE_UNIT_LITERAL
(
mrad
)
175
ACTS_DEFINE_UNIT_LITERAL
(
rad
)
176
ACTS_DEFINE_UNIT_LITERAL
(
degree
)
177
ACTS_DEFINE_UNIT_LITERAL
(
eV
)
178
ACTS_DEFINE_UNIT_LITERAL
(
keV
)
179
ACTS_DEFINE_UNIT_LITERAL
(
MeV
)
180
ACTS_DEFINE_UNIT_LITERAL
(
GeV
)
181
ACTS_DEFINE_UNIT_LITERAL
(
TeV
)
182
ACTS_DEFINE_UNIT_LITERAL
(
u
)
183
ACTS_DEFINE_UNIT_LITERAL
(
g
)
184
ACTS_DEFINE_UNIT_LITERAL
(
kg
)
185
ACTS_DEFINE_UNIT_LITERAL
(
e
)
186
ACTS_DEFINE_UNIT_LITERAL
(
C
)
187
ACTS_DEFINE_UNIT_LITERAL
(
T
)
188
ACTS_DEFINE_UNIT_LITERAL
(
Gauss
)
189
ACTS_DEFINE_UNIT_LITERAL
(
kGauss
)
190
// not needed anymore. undef to prevent littering the namespace
191
#undef ACTS_DEFINE_UNIT_LITERAL
192
}
// namespace UnitLiterals
193
195
namespace
units {
196
199
constexpr
double
_km
=
UnitConstants::km
;
200
constexpr
double
_m
=
UnitConstants::m
;
201
constexpr
double
_cm
=
UnitConstants::cm
;
202
constexpr
double
_mm
=
UnitConstants::mm
;
203
constexpr
double
_um
=
UnitConstants::um
;
204
constexpr
double
_nm
=
UnitConstants::nm
;
205
constexpr
double
_pm
=
UnitConstants::pm
;
206
constexpr
double
_fm
=
UnitConstants::fm
;
208
constexpr
double
_mm2
=
_mm
*
_mm
;
210
213
constexpr
double
_h
=
UnitConstants::h
;
214
constexpr
double
_s
=
UnitConstants::s
;
215
constexpr
double
_ms
=
UnitConstants::ms
;
217
220
constexpr
double
_GeV
=
UnitConstants::GeV
;
221
constexpr
double
_TeV
=
UnitConstants::TeV
;
222
constexpr
double
_MeV
=
UnitConstants::MeV
;
223
constexpr
double
_keV
=
UnitConstants::keV
;
224
constexpr
double
_eV
=
UnitConstants::eV
;
225
constexpr
double
_g
=
UnitConstants::g
;
226
constexpr
double
_kg
=
UnitConstants::kg
;
228
231
constexpr
double
_C
=
UnitConstants::C
;
232
constexpr
double
_e
=
UnitConstants::e
;
234
constexpr
double
_e2
=
_e
*
_e
;
236
239
constexpr
double
_T
=
UnitConstants::T
;
240
constexpr
double
_Gauss
=
UnitConstants::Gauss
;
241
constexpr
double
_kGauss
=
UnitConstants::kGauss
;
243
244
}
// namespace units
245
}
// namespace Acts
acts
blob
master
Core
include
Acts
Utilities
Units.hpp
Built by
Jin Huang
. updated:
Wed Jun 29 2022 17:24:22
using
1.8.2 with
ECCE GitHub integration