FairShip
Loading...
Searching...
No Matches
ShipUnit.h
Go to the documentation of this file.
1// SPDX-License-Identifier: LGPL-3.0-or-later
2// SPDX-FileCopyrightText: Copyright CERN for the benefit of the SHiP
3// Collaboration
4
5// Units of the FairShip C++ code, the same as python/shipunit.py and VMC:
6// lengths in cm, energies in GeV and magnetic fields in kilogauss. Times are
7// in ns here; VMC (gMC->TrackTime(), FairPrimaryGenerator::AddTrack) uses
8// seconds, so a time t in ns is t / ShipUnit::s in seconds. The exception is
9// geant4_vmc's gMC->ParticleLifeTime(), which returns the unconverted Geant4
10// value in ns.
11//
12// Multiply a value by its unit to express it in these units, and divide by a
13// unit to express a value in that unit. Angles are not defined here: TGeo
14// takes degrees, ROOT and the standard library radians. Use TMath for
15// physical constants.
16
17#ifndef SHIPDATA_SHIPUNIT_H_
18#define SHIPDATA_SHIPUNIT_H_
19
20namespace ShipUnit {
21
22// length
23constexpr double cm = 1.;
24constexpr double m = 100. * cm;
25constexpr double mm = 0.1 * cm;
26constexpr double um = 1e-6 * m;
27constexpr double km = 1000. * m;
28
29// time
30constexpr double ns = 1.;
31constexpr double s = 1e9 * ns;
32
33// energy
34constexpr double GeV = 1.;
35constexpr double MeV = 1e-3 * GeV;
36constexpr double keV = 1e-6 * GeV;
37
38// magnetic field
39constexpr double kilogauss = 1.;
40constexpr double gauss = 1e-3 * kilogauss;
41constexpr double tesla = 10. * kilogauss;
42
43// speed of light in vacuum, 29.98 cm/ns
44constexpr double c_light = 299792458. * m / s;
45
46} // namespace ShipUnit
47
48#endif // SHIPDATA_SHIPUNIT_H_
constexpr double um
Definition ShipUnit.h:26
constexpr double cm
Definition ShipUnit.h:23
constexpr double gauss
Definition ShipUnit.h:40
constexpr double MeV
Definition ShipUnit.h:35
constexpr double mm
Definition ShipUnit.h:25
constexpr double km
Definition ShipUnit.h:27
constexpr double m
Definition ShipUnit.h:24
constexpr double c_light
Definition ShipUnit.h:44
constexpr double ns
Definition ShipUnit.h:30
constexpr double keV
Definition ShipUnit.h:36
constexpr double tesla
Definition ShipUnit.h:41
constexpr double kilogauss
Definition ShipUnit.h:39
constexpr double GeV
Definition ShipUnit.h:34
constexpr double s
Definition ShipUnit.h:31