EIC Software
 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 = 1e-12;
90 constexpr double pm = 1e-9;
91 constexpr double um = 1e-3;
92 constexpr double nm = 1e-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 = 1e-15 * s;
112 constexpr double ps = 1e-12 * s;
113 constexpr double ns = 1e-9 * s;
114 constexpr double us = 1e-6 * s;
115 constexpr double ms = 1e-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 = 1e-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 = 1e-9;
124 constexpr double keV = 1e-6;
125 constexpr double MeV = 1e-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 = 1e-4 * T;
142 constexpr double kGauss = 1e-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  }
195 // not needed anymore. undef to prevent littering the namespace
196 #undef ACTS_DEFINE_UNIT_LITERAL
197 } // namespace UnitLiterals
198 } // namespace Acts