Belle II Software development
Unit.h
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#pragma once
10
11#include <string>
12#include <map>
13
14namespace Belle2 {
40 class Unit {
41
42 public:
43
47 static const double cm;
48 static const double ns;
49 static const double GHz;
50 static const double rad;
51 static const double GeV;
52 static const double K;
53 static const double e;
60 static const double g_cm3;
67 // length units
68 static const double km;
69 static const double m;
70 static const double mm;
71 static const double um;
72 static const double nm;
73 static const double pm;
74 static const double fm;
76 // area units
77 static const double m2;
78 static const double cm2;
79 static const double mm2;
81 static const double b;
82 static const double mb;
83 static const double ub;
84 static const double nb;
85 static const double pb;
86 static const double fb;
87 static const double ab;
89 // volume units
90 static const double m3;
91 static const double cm3;
92 static const double mm3;
94 // time units
95 static const double s;
96 static const double ms;
97 static const double us;
98 static const double ps;
99 static const double fs;
101 // frequency units
102 static const double Hz;
103 static const double kHz;
104 static const double MHz;
105 static const double mHz;
107 // angle units
108 static const double mrad;
109 static const double deg;
111 // energy units
112 static const double eV;
113 static const double keV;
114 static const double MeV;
115 static const double TeV;
116 static const double J;
117 static const double V;
119 // magnetic field units
120 static const double T;
121 static const double mT;
122 static const double Gauss;
123 static const double kGauss;
125 // charge units
126 static const double C;
127 static const double fC;
129 // density units
130 static const double mg_cm3;
131 static const double kg_cm3;
132 static const double g_mm3;
133 static const double mg_mm3;
134 static const double kg_mm3;
146 static double convertValue(double value, const std::string& unitString);
147
157 static double convertValueToUnit(double value, const std::string& unitString);
158
159 protected:
161 static double registerConversion(const std::string& name, double value);
163 static std::map<std::string, double> s_conversionFactors;
164
165 private:
170 Unit() = delete;
171 Unit(const Unit&) = delete;
172 Unit& operator=(const Unit&) = delete;
173 ~Unit() = delete;
175 };
176
178}
The Unit class.
Definition: Unit.h:40
static const double cm3
[cubic centimeters]
Definition: Unit.h:91
static const double pm
[picometers]
Definition: Unit.h:73
static const double Hz
[Hertz]
Definition: Unit.h:102
static const double mm
[millimeters]
Definition: Unit.h:70
static const double ps
[picosecond]
Definition: Unit.h:98
static const double mrad
[millirad]
Definition: Unit.h:108
static const double e
Standard of [electric charge].
Definition: Unit.h:53
static const double deg
degree to radians
Definition: Unit.h:109
static const double mm3
[cubic millimeters]
Definition: Unit.h:92
static const double ub
[microbarn]
Definition: Unit.h:83
static const double fb
[femtobarn]
Definition: Unit.h:86
static const double ms
[millisecond]
Definition: Unit.h:96
static const double GHz
Standard of [frequency].
Definition: Unit.h:49
static const double m3
[cubic meters]
Definition: Unit.h:90
static const double mb
[millibarn]
Definition: Unit.h:82
static const double fm
[femtometers]
Definition: Unit.h:74
static const double pb
[picobarn]
Definition: Unit.h:85
static const double rad
Standard of [angle].
Definition: Unit.h:50
static const double kg_cm3
[kg/cm^3]
Definition: Unit.h:131
Unit()=delete
no Unit instances allowed.
static const double mg_mm3
[mg/mm^3]
Definition: Unit.h:133
static const double nm
[nanometers]
Definition: Unit.h:72
static const double g_mm3
[g/mm^3]
Definition: Unit.h:132
static const double Gauss
[gauss]
Definition: Unit.h:122
static const double keV
[kiloelectronvolt]
Definition: Unit.h:113
static const double um
[micrometers]
Definition: Unit.h:71
static const double us
[microsecond]
Definition: Unit.h:97
static const double TeV
[teraelectronvolt]
Definition: Unit.h:115
static const double V
[voltage]
Definition: Unit.h:117
static const double eV
[electronvolt]
Definition: Unit.h:112
static const double kg_mm3
[kg/mm^3]
Definition: Unit.h:134
static const double m2
[square meters]
Definition: Unit.h:77
static const double b
[barn]
Definition: Unit.h:81
static const double mm2
[square millimeters]
Definition: Unit.h:79
static const double mT
[millitesla]
Definition: Unit.h:121
static const double m
[meters]
Definition: Unit.h:69
static const double C
[coulomb]
Definition: Unit.h:126
static const double nb
[nanobarn]
Definition: Unit.h:84
static const double km
Derived units.
Definition: Unit.h:68
static const double J
[joule]
Definition: Unit.h:116
static const double ab
[attobarn]
Definition: Unit.h:87
static const double kGauss
[kilogauss]
Definition: Unit.h:123
static const double MHz
[Megahertz]
Definition: Unit.h:104
static const double MeV
[megaelectronvolt]
Definition: Unit.h:114
static const double fC
[femtocoulomb]
Definition: Unit.h:127
static const double cm
Standard units with the value = 1.
Definition: Unit.h:47
static const double K
Standard of [temperature].
Definition: Unit.h:52
static const double g_cm3
Practical units with the value set at 1.
Definition: Unit.h:60
static const double mg_cm3
[mg/cm^3]
Definition: Unit.h:130
static const double ns
Standard of [time].
Definition: Unit.h:48
static const double fs
[femtosecond]
Definition: Unit.h:99
static const double s
[second]
Definition: Unit.h:95
static const double kHz
[Kilohertz]
Definition: Unit.h:103
static const double GeV
Standard of [energy, momentum, mass].
Definition: Unit.h:51
static const double T
[tesla]
Definition: Unit.h:120
static const double cm2
[square centimeters]
Definition: Unit.h:78
static const double mHz
[Millihertz]
Definition: Unit.h:105
static std::map< std::string, double > s_conversionFactors
Map to be able to convert between units using string representations of the unit name.
Definition: Unit.h:163
static double registerConversion(const std::string &name, double value)
registers the name and value of a conversion in s_conversionFactors.
Definition: UnitConst.cc:149
static double convertValueToUnit(double value, const std::string &unitString)
Converts a floating point value from the standard framework unit to the given unit.
Definition: UnitConst.cc:139
static double convertValue(double value, const std::string &unitString)
Converts a floating point value to the standard framework unit.
Definition: UnitConst.cc:129
Abstract base class for different kinds of events.