Analysis Software
Documentation for sPHENIX simulation 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 
133 
137 
138 namespace UnitConstants {
139 // Length, native unit mm
140 constexpr double mm = 1.0;
141 constexpr double fm = 1e-12 * mm;
142 constexpr double pm = 1e-9 * mm;
143 constexpr double nm = 1e-6 * mm;
144 constexpr double um = 1e-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 = 1e-15 * s;
164 constexpr double ps = 1e-12 * s;
165 constexpr double ns = 1e-9 * s;
166 constexpr double us = 1e-6 * s;
167 constexpr double ms = 1e-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 = 1e-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 = 1e-9 * GeV;
177 constexpr double keV = 1e-6 * GeV;
178 constexpr double MeV = 1e-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 = 1e-4 * T;
195 constexpr double kGauss = 1e-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  }
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