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
ECCE @ EIC Software
Deprecated List
Modules
Namespaces
Classes
Files
File List
acts
blob
master
CI
Core
doc
Examples
Fatras
Plugins
Tests
Benchmarks
CommonHelpers
IntegrationTests
UnitTests
Benchmarks
Core
EventData
Fitter
Geometry
MagneticField
Material
Propagator
Seeding
Surfaces
TrackFinder
Utilities
AnnealingUtilityTests.cpp
AxesTests.cpp
BFieldMapUtilsTests.cpp
BinningDataTests.cpp
BinUtilityTests.cpp
BoundingBoxTest.cpp
ExtendableTests.cpp
FiniteStateMachineTests.cpp
FrustumTest.cpp
GridTests.cpp
HelpersTests.cpp
InterpolationTests.cpp
IntersectionTests.cpp
LoggerTests.cpp
MaterialMapUtilsTests.cpp
MPLTests.cpp
MultiIndexTests.cpp
RayTest.cpp
RealQuadraticEquationTests.cpp
ResultTests.cpp
TypeTraitsTest.cpp
UnitConversionTests.cpp
UnitVectorsTests.cpp
Vertexing
Visualization
Fatras
Plugins
thirdparty
analysis
coresoftware
Doxygen_Assist
ecce-detectors
fun4all_eicdetectors
geant4
macros
online_distribution
tutorials
doxygen_mainpage.h
File Members
External Links
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
UnitConversionTests.cpp
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file UnitConversionTests.cpp
1
// This file is part of the Acts project.
2
//
3
// Copyright (C) 2017-2018 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
#include <boost/test/unit_test.hpp>
10
11
#include "
Acts/Tests/CommonHelpers/FloatComparisons.hpp
"
12
#include "
Acts/Utilities/Units.hpp
"
13
14
using namespace
Acts::UnitLiterals;
15
16
BOOST_AUTO_TEST_SUITE(unit_conversions)
17
18
BOOST_AUTO_TEST_CASE
(length_conversions) {
19
CHECK_CLOSE_REL
(1
_m
, 1
e
-3
_km
, 1
e
-15);
20
CHECK_CLOSE_REL
(1
_m
, 1e2_cm, 1
e
-15);
21
CHECK_CLOSE_REL
(1
_m
, 1e3_mm, 1
e
-15);
22
CHECK_CLOSE_REL
(1
_m
, 1e6_um, 1
e
-15);
23
CHECK_CLOSE_REL
(1
_m
, 1e9_nm, 1
e
-15);
24
CHECK_CLOSE_REL
(1
_m
, 1e12_pm, 1
e
-15);
25
CHECK_CLOSE_REL
(1
_m
, 1e15_fm, 1
e
-15);
26
}
27
28
BOOST_AUTO_TEST_CASE
(area_conversions) {
29
CHECK_CLOSE_REL
(1
_mm
* 1
_mm
, 1
_mm2
, 1
e
-15);
30
CHECK_CLOSE_REL
(1_mm * 1_mm, 0.01_cm2, 1
e
-15);
31
CHECK_CLOSE_REL
(1_mm * 1_mm, 0.000001_m2, 1
e
-15);
32
CHECK_CLOSE_REL
(1
_cm
* 1
_cm
, 100
_mm2
, 1
e
-15);
33
CHECK_CLOSE_REL
(1_cm * 1_cm, 1_cm2, 1
e
-15);
34
CHECK_CLOSE_REL
(1_cm * 1_cm, 0.0001_m2, 1
e
-15);
35
CHECK_CLOSE_REL
(1
_m
* 1
_m
, 1000000
_mm2
, 1
e
-15);
36
CHECK_CLOSE_REL
(1_m * 1_m, 10000_cm2, 1
e
-15);
37
CHECK_CLOSE_REL
(1_m * 1_m, 1_m2, 1
e
-15);
38
}
39
40
BOOST_AUTO_TEST_CASE
(volume_conversions) {
41
CHECK_CLOSE_REL
(1
_mm
* 1
_mm
* 1
_mm
, 1_mm3, 1
e
-15);
42
CHECK_CLOSE_REL
(1
_mm2
* 1_mm, 1_mm3, 1
e
-15);
43
CHECK_CLOSE_REL
(1
_cm
* 1
_cm
* 1
_cm
, 1_cm3, 1
e
-15);
44
CHECK_CLOSE_REL
(1_cm2 * 1_cm, 1_cm3, 1
e
-15);
45
CHECK_CLOSE_REL
(1
_m
* 1
_m
* 1
_m
, 1_m3, 1
e
-15);
46
CHECK_CLOSE_REL
(1_m2 * 1_m, 1_m3, 1
e
-15);
47
}
48
49
BOOST_AUTO_TEST_CASE
(time_conversions) {
50
CHECK_CLOSE_REL
(1
_h
, 60_min, 1
e
-15);
51
CHECK_CLOSE_REL
(1
_h
, 3600
_s
, 1
e
-15);
52
CHECK_CLOSE_REL
(1_min, 60
_s
, 1
e
-15);
53
CHECK_CLOSE_REL
(1
_s
, 1e3_ms, 1
e
-15);
54
CHECK_CLOSE_REL
(1
_s
, 1e6_us, 1
e
-15);
55
CHECK_CLOSE_REL
(1
_s
, 1e9_ns, 1
e
-15);
56
CHECK_CLOSE_REL
(1
_s
, 1e12_ps, 1
e
-15);
57
CHECK_CLOSE_REL
(1
_s
, 1e15_fs, 1
e
-15);
58
}
59
60
BOOST_AUTO_TEST_CASE
(angle_conversions) {
61
CHECK_CLOSE_REL
(45_degree,
M_PI
/ 4 * 1_rad, 1
e
-15);
62
CHECK_CLOSE_REL
(90_degree,
M_PI
/ 2 * 1_rad, 1
e
-15);
63
CHECK_CLOSE_REL
(180_degree,
M_PI
* 1_rad, 1
e
-15);
64
CHECK_CLOSE_REL
(360_degree, 2 *
M_PI
* 1_rad, 1
e
-15);
65
CHECK_CLOSE_REL
(1
_mm
/ 1
_m
, 1_mrad, 1
e
-15);
66
CHECK_CLOSE_REL
(1
_um
/ 1
_mm
, 1_mrad, 1
e
-15);
67
}
68
69
BOOST_AUTO_TEST_CASE
(energy_conversions) {
70
CHECK_CLOSE_REL
(1
_MeV
, 1e6_eV, 1
e
-15);
71
CHECK_CLOSE_REL
(1
_MeV
, 1e3_keV, 1
e
-15);
72
CHECK_CLOSE_REL
(1
_MeV
, 1
e
-3
_GeV
, 1
e
-15);
73
CHECK_CLOSE_REL
(1
_MeV
, 1
e
-6
_TeV
, 1
e
-15);
74
}
75
76
BOOST_AUTO_TEST_CASE
(mass_conversions) {
77
CHECK_CLOSE_REL
(1
_kg
, 1000
_g
, 1
e
-15);
78
CHECK_CLOSE_REL
(0.001
_kg
, 1
_g
, 1
e
-15);
79
CHECK_CLOSE_REL
(1_u, 931.49410242
_MeV
, 1
e
-15);
80
CHECK_CLOSE_REL
(1_u, 1.66053906660
e
-24
_g
, 1
e
-7);
81
}
82
83
BOOST_AUTO_TEST_CASE
(mass_energy_conversions) {
84
// always assumes c == 1
85
CHECK_CLOSE_REL
(1.782662
e
-36
_kg
, 1
_eV
, 1
e
-15);
86
CHECK_CLOSE_REL
(1.782662
e
-33
_kg
, 1
_keV
, 1
e
-15);
87
CHECK_CLOSE_REL
(1.782662
e
-30
_kg
, 1
_MeV
, 1
e
-15);
88
CHECK_CLOSE_REL
(1.782662
e
-27
_kg
, 1
_GeV
, 1
e
-15);
89
CHECK_CLOSE_REL
(1.782662
e
-33
_g
, 1
_eV
, 1
e
-15);
90
CHECK_CLOSE_REL
(1.782662
e
-30
_g
, 1
_keV
, 1
e
-15);
91
CHECK_CLOSE_REL
(1.782662
e
-27
_g
, 1
_MeV
, 1
e
-15);
92
CHECK_CLOSE_REL
(1.782662
e
-24
_g
, 1
_GeV
, 1
e
-15);
93
}
94
95
BOOST_AUTO_TEST_CASE
(charge_conversions) {
96
CHECK_CLOSE_REL
(1
_C
, 1.602176634e19_e, 1
e
-15);
97
}
98
99
BOOST_AUTO_TEST_CASE
(magnetic_field_conversions) {
100
CHECK_CLOSE_REL
(10
_kGauss
, 1
_T
, 1
e
-15);
101
CHECK_CLOSE_REL
(1
_kGauss
, 1000
_Gauss
, 1
e
-15);
102
}
103
104
BOOST_AUTO_TEST_CASE
(momentum_to_radius_conversion) {
105
// note: no conversion factors necessary
106
CHECK_CLOSE_REL
(1
_GeV
/ (1
_e
* 1
_T
), 3.3336
_m
, 1
e
-3);
107
CHECK_CLOSE_REL
(1
_GeV
/ (1
_e
* 2_T), 166.8
_cm
, 1
e
-3);
108
CHECK_CLOSE_REL
(1
_GeV
/ (2
_e
* 1_T), 166.8
_cm
, 1
e
-3);
109
CHECK_CLOSE_REL
(1
_GeV
/ (1
_e
* 4_T), 83.39
_cm
, 1
e
-3);
110
CHECK_CLOSE_REL
(1
_GeV
/ (2
_e
* 2_T), 83.39
_cm
, 1
e
-3);
111
}
112
113
BOOST_AUTO_TEST_SUITE_END()
acts
blob
master
Tests
UnitTests
Core
Utilities
UnitConversionTests.cpp
Built by
Jin Huang
. updated:
Wed Jun 29 2022 17:24:27
using
1.8.2 with
ECCE GitHub integration