EIC Software
Reference for
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
86
87
namespace
UnitConstants {
88
// Length, native unit mm
89
constexpr
double
fm
= 1
e
-12;
90
constexpr
double
pm
= 1
e
-9;
91
constexpr
double
um
= 1
e
-3;
92
constexpr
double
nm
= 1
e
-6;
93
constexpr
double
mm
= 1.0;
94
constexpr
double
cm
= 10.0;
95
constexpr
double
m
= 1e3;
96
constexpr
double
km
= 1e6;
97
// Shortcuts for commonly used area and volume units. This intentionally
98
// contains not all possible combinations to avoid cluttering the namespace.
99
// Missing area or volume units can always be defined on the fly using the
100
// existing length units e.g. 1fm³ -> 1fm * 1fm * 1fm
101
// Area, native unit mm²
102
constexpr
double
mm2
=
mm
*
mm
;
103
constexpr
double
cm2
=
cm
*
cm
;
104
constexpr
double
m2
=
m
*
m
;
105
// Volume, native unit mm³
106
constexpr
double
mm3
=
mm
*
mm
*
mm
;
107
constexpr
double
cm3
=
cm
*
cm
*
cm
;
108
constexpr
double
m3
=
m
*
m
*
m
;
109
// Time, native unit mm = [speed-of-light * time] = mm/s * s
110
constexpr
double
s
= 299792458000.0;
111
constexpr
double
fs
= 1
e
-15 *
s
;
112
constexpr
double
ps
= 1
e
-12 *
s
;
113
constexpr
double
ns
= 1
e
-9 *
s
;
114
constexpr
double
us
= 1
e
-6 *
s
;
115
constexpr
double
ms
= 1
e
-3 *
s
;
116
constexpr
double
min
= 60.0 *
s
;
117
constexpr
double
h
= 3600.0 *
s
;
118
// Angles, native unit radian
119
constexpr
double
mrad
= 1
e
-3;
120
constexpr
double
rad
= 1.0;
121
constexpr
double
degree
= 0.017453292519943295;
// pi / 180
122
// Energy/mass/momentum, native unit GeV
123
constexpr
double
eV
= 1
e
-9;
124
constexpr
double
keV
= 1
e
-6;
125
constexpr
double
MeV
= 1
e
-3;
126
constexpr
double
GeV
= 1.0;
127
constexpr
double
TeV
= 1e3;
128
// atomic mass unit u
129
constexpr
double
u
= 0.93149410242;
130
// 1eV/c² == 1.782662e-36kg
131
// 1GeV/c² == 1.782662e-27kg
132
// -> 1kg == (1/1.782662e-27)GeV/c²
133
// -> 1g == (1/(1e3*1.782662e-27))GeV/c²
134
constexpr
double
g
= 1.0 / 1.782662e-24;
135
constexpr
double
kg
= 1.0 / 1.782662e-27;
136
// Charge, native unit e (elementary charge)
137
constexpr
double
e
= 1.0;
138
constexpr
double
C
= 1.602176634e19;
139
// Magnetic field, native unit GeV/(e*mm)
140
constexpr
double
T
= 0.000299792458;
// equivalent to c in appropriate SI units
141
constexpr
double
Gauss
= 1
e
-4 *
T
;
142
constexpr
double
kGauss
= 1
e
-1 *
T
;
143
// Amount of substance, native unit mol
144
constexpr
double
mol
= 1.0;
145
}
// namespace UnitConstants
146
147
namespace
UnitLiterals {
148
// define user literal functions for the given unit constant
149
#define ACTS_DEFINE_UNIT_LITERAL(name) \
150
constexpr double operator"" _##name(long double x) { \
151
return ::Acts::UnitConstants::name * x; \
152
} \
153
constexpr double operator"" _##name(unsigned long long x) { \
154
return ::Acts::UnitConstants::name * x; \
155
}
156
ACTS_DEFINE_UNIT_LITERAL
(
fm
)
157
ACTS_DEFINE_UNIT_LITERAL
(
pm
)
158
ACTS_DEFINE_UNIT_LITERAL
(
nm
)
159
ACTS_DEFINE_UNIT_LITERAL
(
um
)
160
ACTS_DEFINE_UNIT_LITERAL
(
mm
)
161
ACTS_DEFINE_UNIT_LITERAL
(
cm
)
162
ACTS_DEFINE_UNIT_LITERAL
(
m
)
163
ACTS_DEFINE_UNIT_LITERAL
(
km
)
164
ACTS_DEFINE_UNIT_LITERAL
(
mm2
)
165
ACTS_DEFINE_UNIT_LITERAL
(
cm2
)
166
ACTS_DEFINE_UNIT_LITERAL
(
m2
)
167
ACTS_DEFINE_UNIT_LITERAL
(
mm3
)
168
ACTS_DEFINE_UNIT_LITERAL
(
cm3
)
169
ACTS_DEFINE_UNIT_LITERAL
(
m3
)
170
ACTS_DEFINE_UNIT_LITERAL
(
fs
)
171
ACTS_DEFINE_UNIT_LITERAL
(
ps
)
172
ACTS_DEFINE_UNIT_LITERAL
(
ns
)
173
ACTS_DEFINE_UNIT_LITERAL
(
us
)
174
ACTS_DEFINE_UNIT_LITERAL
(
ms
)
175
ACTS_DEFINE_UNIT_LITERAL
(
s
)
176
ACTS_DEFINE_UNIT_LITERAL
(
min
)
177
ACTS_DEFINE_UNIT_LITERAL
(
h
)
178
ACTS_DEFINE_UNIT_LITERAL
(
mrad
)
179
ACTS_DEFINE_UNIT_LITERAL
(
rad
)
180
ACTS_DEFINE_UNIT_LITERAL
(
degree
)
181
ACTS_DEFINE_UNIT_LITERAL
(
eV
)
182
ACTS_DEFINE_UNIT_LITERAL
(
keV
)
183
ACTS_DEFINE_UNIT_LITERAL
(
MeV
)
184
ACTS_DEFINE_UNIT_LITERAL
(
GeV
)
185
ACTS_DEFINE_UNIT_LITERAL
(
TeV
)
186
ACTS_DEFINE_UNIT_LITERAL
(
u
)
187
ACTS_DEFINE_UNIT_LITERAL
(
g
)
188
ACTS_DEFINE_UNIT_LITERAL
(
kg
)
189
ACTS_DEFINE_UNIT_LITERAL
(
e
)
190
ACTS_DEFINE_UNIT_LITERAL
(
C
)
191
ACTS_DEFINE_UNIT_LITERAL
(
T
)
192
ACTS_DEFINE_UNIT_LITERAL
(
Gauss
)
193
ACTS_DEFINE_UNIT_LITERAL
(
kGauss
)
194
ACTS_DEFINE_UNIT_LITERAL
(
mol
)
195
// not needed anymore. undef to prevent littering the namespace
196
#undef ACTS_DEFINE_UNIT_LITERAL
197
}
// namespace UnitLiterals
198
}
// namespace Acts
acts
blob
sPHENIX
Core
include
Acts
Utilities
Units.hpp
Built by
Jin Huang
. updated:
Mon Jan 22 2024 12:43:24
using
1.8.2 with
EIC GitHub integration