|
| constexpr double | cm = 1e1 * mm |
| | Centimeter - 1e-2 meter.
|
| constexpr double | cm2 = cm * cm |
| | Square centimeter.
|
| constexpr double | cm3 = cm * cm * cm |
| | Cubic centimeter.
|
| constexpr double | degree = std::numbers::pi / 180. / rad |
| | Degree - pi/180 radians.
|
| constexpr double | e = 1.0 |
| | Charge, native unit e (elementary charge).
|
| constexpr double | eV = 1e-9 * GeV |
| | Electronvolt - 1e-9 GeV.
|
| constexpr double | fm = 1e-12 * mm |
| | Femtometer - 1e-15 meter.
|
| constexpr double | fs = 1e-15 * s |
| | Femtosecond - 1e-15 second.
|
| constexpr double | g = 1.0 / 1.782662e-24 |
| | Gram in GeV/c²
|
| constexpr double | Gauss = 1e-4 * T |
| | Gauss - 1e-4 Tesla.
|
| constexpr double | GeV = 1.0 |
| | Gigaelectronvolt - native unit for energy/mass/momentum.
|
| constexpr double | h = 3600.0 * s |
| | Hour - 3600 seconds.
|
| constexpr double | J = 6241509074.460763 * GeV |
| | Joule in GeV.
|
| constexpr double | keV = 1e-6 * GeV |
| | Kiloelectronvolt - 1e-6 GeV.
|
| constexpr double | kg = 1.0 / 1.782662e-27 |
| | Kilogram in GeV/c²
|
| constexpr double | kGauss = 1e-1 * T |
| | Kilogauss - 1e-1 Tesla.
|
| constexpr double | km = 1e6 * mm |
| | Kilometer - 1e3 meter.
|
| constexpr double | m = 1e3 * mm |
| | Meter.
|
| constexpr double | m2 = m * m |
| | Square meter.
|
| constexpr double | m3 = m * m * m |
| | Cubic meter.
|
| constexpr double | MeV = 1e-3 * GeV |
| | Megaelectronvolt - 1e-3 GeV.
|
| constexpr double | min = 60.0 * s |
| | Minute - 60 seconds.
|
| constexpr double | mm = 1.0 |
| | Millimeter - native unit for length.
|
| constexpr double | mm2 = mm * mm |
| | Square millimeter - native unit for area.
|
| constexpr double | mm3 = mm * mm * mm |
| | Cubic millimeter - native unit for volume.
|
| constexpr double | mol = 1.0 |
| | Amount of substance, native unit mol.
|
| constexpr double | mrad = 1e-3 |
| | Milliradian - 1e-3 radian.
|
| constexpr double | ms = 1e-3 * s |
| | Millisecond - 1e-3 second.
|
| constexpr double | nm = 1e-6 * mm |
| | Nanometer - 1e-9 meter.
|
| constexpr double | ns = 1e-9 * s |
| | Nanosecond - 1e-9 second.
|
| constexpr double | pm = 1e-9 * mm |
| | Picometer - 1e-12 meter.
|
| constexpr double | ps = 1e-12 * s |
| | Picosecond - 1e-12 second.
|
| constexpr double | rad = 1.0 |
| | Radian - native unit for angle.
|
| constexpr double | s = 299792458000.0 |
| constexpr double | T = 0.000299792458 |
| | Magnetic field, native unit (eV*s)/(e*m²).
|
| constexpr double | TeV = 1e3 * GeV |
| | Teraelectronvolt - 1e3 GeV.
|
| constexpr double | u = 0.93149410242 |
| | atomic mass unit u
|
| constexpr double | um = 1e-3 * mm |
| | Micrometer - 1e-6 meter.
|
| constexpr double | us = 1e-6 * s |
| | Microsecond - 1e-6 second.
|
Constants and helper literals for physical units.
All physical quantities have both a numerical value and a unit. For the computations we always choose a particular unit for a given physical quantity so we only need to consider the numerical values as such. The chosen base unit for a particular physical dimension, e.g. length, time, or energy, within this code base is called the native unit. The base units should be chosen such that they are internally consistent, require the least amount of explicit conversion factors (ideally none at all), and have typical numerical values close to unity to reduce numerical issues.
Here, the following native units are used:
- Length is expressed in mm.
- Time is expressed in [speed-of-light * time] == mm. A consequence of this choice is that the speed-of-light expressed in native units is 1.
- Angles are expressed in radian.
- Energy, mass, and momentum are all expressed in GeV (consistent with speed-of-light == 1).
- Electric charge is expressed in e, i.e. units of the elementary charge.
The magnetic field is expressed in GeV/(e*mm). The magnetic field connects momentum to length, e.g. in SI units the radius of a charged particle trajectory in a constant magnetic field is given by
\( \text{radius} = - \frac{\text{momentum} }{ \text{charge} } / \text{field}
\)
With the chosen magnetic field unit the expression above stays the same and no additional conversion factors are necessary.
Depending on the context a physical quantity might not be given in the native units. In this case we need to convert to the native unit first before the value can be used. The necessary conversion factors are defined in Acts::UnitConstants. Multiplying a value with the unit constant produces the equivalent value in the native unit, e.g.
To further simplify the usage, physical quantities can also be expressed via C++ user literals defined in Acts::UnitLiterals. This allows us to express quantities in a concise way:
double length = 1_m;
double momentum = 1.25_TeV;
double lengthInUm = length / 1_um;
double momentumInMeV = momentum / 1_MeV;
- Warning
- Since using user-defined literals requires a namespace import of Acts::UnitLiterals it should not be used in headers since it would (accidentally) modify the namespace wherever the header is included.
To ensure consistent computations and results the following guidelines must be followed when handling physical quantities with units:
double momentumInMeV = 10.0;
double energyGeV = 100.0;
double output_in_meters = distance / 1_m;
Here's a comprehensive example showing various ways to work with units:
double length = 23_cm;
double time = 1214.2_ns;
double angle = 123_degree;
double particleMomentum = 2.5_TeV;
double mass = 511_keV;
double velocity = 345_m / 1_s;
double bfield = 3.9_T;
Converting output values from native units:
- Note
- A helper script is available in Core/scripts/print_units_physical_constants.py to validate some of the numerical values.