GeoModel - GeoModelCore
Units.h
1 // This is essentially a copy of CLHEP/Units/PhysicalConstants.h and CLHEP/Units/SystemOfUnits.h
2 // where they claim it came from Geant4.
3 // @TODO: Make clearer statement where this comes from, maybe simplify to Geant4 directly
4 
5 #ifndef GEOMODELKERNEL_UNITS_H
6 #define GEOMODELKERNEL_UNITS_H
7 
8 namespace GeoModelKernelUnits {
9 
10 static constexpr double pi = 3.14159265358979323846;
11 static constexpr double twopi = 2*pi;
12 static constexpr double halfpi = pi/2;
13 static constexpr double pi2 = pi*pi;
14 
15 //
16 // Length [L]
17 //
18 static constexpr double millimeter = 1.;
19 static constexpr double millimeter2 = millimeter*millimeter;
20 static constexpr double millimeter3 = millimeter*millimeter*millimeter;
21 
22 static constexpr double centimeter = 10.*millimeter;
23 static constexpr double centimeter2 = centimeter*centimeter;
24 static constexpr double centimeter3 = centimeter*centimeter*centimeter;
25 
26 static constexpr double meter = 1000.*millimeter;
27 static constexpr double meter2 = meter*meter;
28 static constexpr double meter3 = meter*meter*meter;
29 
30 static constexpr double kilometer = 1000.*meter;
31 static constexpr double kilometer2 = kilometer*kilometer;
32 static constexpr double kilometer3 = kilometer*kilometer*kilometer;
33 
34 static constexpr double parsec = 3.0856775807e+16*meter;
35 
36 static constexpr double micrometer = 1.e-6 *meter;
37 static constexpr double nanometer = 1.e-9 *meter;
38 static constexpr double angstrom = 1.e-10*meter;
39 static constexpr double fermi = 1.e-15*meter;
40 
41 static constexpr double barn = 1.e-28*meter2;
42 static constexpr double millibarn = 1.e-3 *barn;
43 static constexpr double microbarn = 1.e-6 *barn;
44 static constexpr double nanobarn = 1.e-9 *barn;
45 static constexpr double picobarn = 1.e-12*barn;
46 
47 // symbols
48 static constexpr double nm = nanometer;
49 static constexpr double um = micrometer;
50 
51 static constexpr double mm = millimeter;
52 static constexpr double mm2 = millimeter2;
53 static constexpr double mm3 = millimeter3;
54 
55 static constexpr double cm = centimeter;
56 static constexpr double cm2 = centimeter2;
57 static constexpr double cm3 = centimeter3;
58 
59 static constexpr double liter = 1.e+3*cm3;
60 static constexpr double L = liter;
61 static constexpr double dL = 1.e-1*liter;
62 static constexpr double cL = 1.e-2*liter;
63 static constexpr double mL = 1.e-3*liter;
64 
65 static constexpr double m = meter;
66 static constexpr double m2 = meter2;
67 static constexpr double m3 = meter3;
68 
69 static constexpr double km = kilometer;
70 static constexpr double km2 = kilometer2;
71 static constexpr double km3 = kilometer3;
72 
73 static constexpr double pc = parsec;
74 
75 //
76 // Angle
77 //
78 static constexpr double radian = 1.;
79 static constexpr double milliradian = 1.e-3*radian;
80 static constexpr double degree = (pi/180.0)*radian;
81 
82 static constexpr double steradian = 1.;
83 
84 // symbols
85 static constexpr double rad = radian;
86 static constexpr double mrad = milliradian;
87 static constexpr double sr = steradian;
88 static constexpr double deg = degree;
89 
90 //
91 // Time [T]
92 //
93 static constexpr double nanosecond = 1.;
94 static constexpr double second = 1.e+9 *nanosecond;
95 static constexpr double millisecond = 1.e-3 *second;
96 static constexpr double microsecond = 1.e-6 *second;
97 static constexpr double picosecond = 1.e-12*second;
98 
99 static constexpr double hertz = 1./second;
100 static constexpr double kilohertz = 1.e+3*hertz;
101 static constexpr double megahertz = 1.e+6*hertz;
102 
103 // symbols
104 static constexpr double ns = nanosecond;
105 static constexpr double s = second;
106 static constexpr double ms = millisecond;
107 static constexpr double us = microsecond;
108 static constexpr double ps = picosecond;
109 
110 //
111 // Electric charge [Q]
112 //
113 static constexpr double eplus = 1. ;// positron charge
114 static constexpr double e_SI = 1.602176487e-19;// positron charge in coulomb
115 static constexpr double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus
116 
117 //
118 // Energy [E]
119 //
120 static constexpr double megaelectronvolt = 1. ;
121 static constexpr double electronvolt = 1.e-6*megaelectronvolt;
122 static constexpr double kiloelectronvolt = 1.e-3*megaelectronvolt;
123 static constexpr double gigaelectronvolt = 1.e+3*megaelectronvolt;
124 static constexpr double teraelectronvolt = 1.e+6*megaelectronvolt;
125 static constexpr double petaelectronvolt = 1.e+9*megaelectronvolt;
126 
127 static constexpr double joule = electronvolt/e_SI;// joule = 6.24150 e+12 * MeV
128 
129 // symbols
130 static constexpr double MeV = megaelectronvolt;
131 static constexpr double eV = electronvolt;
132 static constexpr double keV = kiloelectronvolt;
133 static constexpr double GeV = gigaelectronvolt;
134 static constexpr double TeV = teraelectronvolt;
135 static constexpr double PeV = petaelectronvolt;
136 
137 //
138 // Mass [E][T^2][L^-2]
139 //
140 static constexpr double kilogram = joule*second*second/(meter*meter);
141 static constexpr double gram = 1.e-3*kilogram;
142 static constexpr double milligram = 1.e-3*gram;
143 
144 // symbols
145 static constexpr double kg = kilogram;
146 static constexpr double g = gram;
147 static constexpr double mg = milligram;
148 
149 //
150 // Power [E][T^-1]
151 //
152 static constexpr double watt = joule/second;// watt = 6.24150 e+3 * MeV/ns
153 
154 //
155 // Force [E][L^-1]
156 //
157 static constexpr double newton = joule/meter;// newton = 6.24150 e+9 * MeV/mm
158 
159 //
160 // Pressure [E][L^-3]
161 //
162 #define pascal hep_pascal // a trick to avoid warnings
163 static constexpr double hep_pascal = newton/m2; // pascal = 6.24150 e+3 * MeV/mm3
164 static constexpr double bar = 100000*pascal; // bar = 6.24150 e+8 * MeV/mm3
165 static constexpr double atmosphere = 101325*pascal; // atm = 6.32420 e+8 * MeV/mm3
166 
167 //
168 // Electric current [Q][T^-1]
169 //
170 static constexpr double ampere = coulomb/second; // ampere = 6.24150 e+9 * eplus/ns
171 static constexpr double milliampere = 1.e-3*ampere;
172 static constexpr double microampere = 1.e-6*ampere;
173 static constexpr double nanoampere = 1.e-9*ampere;
174 
175 //
176 // Electric potential [E][Q^-1]
177 //
178 static constexpr double megavolt = megaelectronvolt/eplus;
179 static constexpr double kilovolt = 1.e-3*megavolt;
180 static constexpr double volt = 1.e-6*megavolt;
181 
182 //
183 // Electric resistance [E][T][Q^-2]
184 //
185 static constexpr double ohm = volt/ampere;// ohm = 1.60217e-16*(MeV/eplus)/(eplus/ns)
186 
187 //
188 // Electric capacitance [Q^2][E^-1]
189 //
190 static constexpr double farad = coulomb/volt;// farad = 6.24150e+24 * eplus/Megavolt
191 static constexpr double millifarad = 1.e-3*farad;
192 static constexpr double microfarad = 1.e-6*farad;
193 static constexpr double nanofarad = 1.e-9*farad;
194 static constexpr double picofarad = 1.e-12*farad;
195 
196 //
197 // Magnetic Flux [T][E][Q^-1]
198 //
199 static constexpr double weber = volt*second;// weber = 1000*megavolt*ns
200 
201 //
202 // Magnetic Field [T][E][Q^-1][L^-2]
203 //
204 static constexpr double tesla = volt*second/meter2;// tesla =0.001*megavolt*ns/mm2
205 
206 static constexpr double gauss = 1.e-4*tesla;
207 static constexpr double kilogauss = 1.e-1*tesla;
208 
209 //
210 // Inductance [T^2][E][Q^-2]
211 //
212 static constexpr double henry = weber/ampere;// henry = 1.60217e-7*MeV*(ns/eplus)**2
213 
214 //
215 // Temperature
216 //
217 static constexpr double kelvin = 1.;
218 
219 //
220 // Amount of substance
221 //
222 static constexpr double mole = 1.;
223 
224 //
225 // Activity [T^-1]
226 //
227 static constexpr double becquerel = 1./second ;
228 static constexpr double curie = 3.7e+10 * becquerel;
229 static constexpr double kilobecquerel = 1.e+3*becquerel;
230 static constexpr double megabecquerel = 1.e+6*becquerel;
231 static constexpr double gigabecquerel = 1.e+9*becquerel;
232 static constexpr double millicurie = 1.e-3*curie;
233 static constexpr double microcurie = 1.e-6*curie;
234 static constexpr double Bq = becquerel;
235 static constexpr double kBq = kilobecquerel;
236 static constexpr double MBq = megabecquerel;
237 static constexpr double GBq = gigabecquerel;
238 static constexpr double Ci = curie;
239 static constexpr double mCi = millicurie;
240 static constexpr double uCi = microcurie;
241 
242 //
243 // Absorbed dose [L^2][T^-2]
244 //
245 static constexpr double gray = joule/kilogram ;
246 static constexpr double kilogray = 1.e+3*gray;
247 static constexpr double milligray = 1.e-3*gray;
248 static constexpr double microgray = 1.e-6*gray;
249 
250 //
251 // Luminous intensity [I]
252 //
253 static constexpr double candela = 1.;
254 
255 //
256 // Luminous flux [I]
257 //
258 static constexpr double lumen = candela*steradian;
259 
260 //
261 // Illuminance [I][L^-2]
262 //
263 static constexpr double lux = lumen/meter2;
264 
265 //
266 // Miscellaneous
267 //
268 static constexpr double perCent = 0.01 ;
269 static constexpr double perThousand = 0.001;
270 static constexpr double perMillion = 0.000001;
271 
272 
273 static constexpr double Avogadro = 6.02214179e+23/mole;
274 
275 //
276 // c = 299.792458 mm/ns
277 // c^2 = 898.7404 (mm/ns)^2
278 //
279 static constexpr double c_light = 2.99792458e+8 * m/s;
280 static constexpr double c_squared = c_light * c_light;
281 
282 //
283 // h = 4.13566e-12 MeV*ns
284 // hbar = 6.58212e-13 MeV*ns
285 // hbarc = 197.32705e-12 MeV*mm
286 //
287 static constexpr double h_Planck = 6.62606896e-34 * joule*s;
288 static constexpr double hbar_Planck = h_Planck/twopi;
289 static constexpr double hbarc = hbar_Planck * c_light;
290 static constexpr double hbarc_squared = hbarc * hbarc;
291 
292 //
293 //
294 //
295 static constexpr double electron_charge = - eplus; // see SystemOfUnits.h
296 static constexpr double e_squared = eplus * eplus;
297 
298 //
299 // amu_c2 - atomic equivalent mass unit
300 // - AKA, unified atomic mass unit (u)
301 // amu - atomic mass unit
302 //
303 static constexpr double electron_mass_c2 = 0.510998910 * MeV;
304 static constexpr double proton_mass_c2 = 938.272013 * MeV;
305 static constexpr double neutron_mass_c2 = 939.56536 * MeV;
306 static constexpr double amu_c2 = 931.494028 * MeV;
307 static constexpr double amu = amu_c2/c_squared;
308 
309 //
310 // permeability of free space mu0 = 2.01334e-16 Mev*(ns*eplus)^2/mm
311 // permittivity of free space epsil0 = 5.52636e+10 eplus^2/(MeV*mm)
312 //
313 static constexpr double mu0 = 4*pi*1.e-7 * henry/m;
314 static constexpr double epsilon0 = 1./(c_squared*mu0);
315 
316 //
317 // electromagnetic coupling = 1.43996e-12 MeV*mm/(eplus^2)
318 //
319 static constexpr double elm_coupling = e_squared/(4*pi*epsilon0);
320 static constexpr double fine_structure_const = elm_coupling/hbarc;
321 static constexpr double classic_electr_radius = elm_coupling/electron_mass_c2;
322 static constexpr double electron_Compton_length = hbarc/electron_mass_c2;
323 static constexpr double Bohr_radius = electron_Compton_length/fine_structure_const;
324 
325 static constexpr double alpha_rcl2 = fine_structure_const
326 *classic_electr_radius
327 *classic_electr_radius;
328 
329 static constexpr double twopi_mc2_rcl2 = twopi*electron_mass_c2
330 *classic_electr_radius
331 *classic_electr_radius;
332 //
333 //
334 //
335 static constexpr double k_Boltzmann = 8.617343e-11 * MeV/kelvin;
336 
337 //
338 //
339 //
340 static constexpr double STP_Temperature = 273.15*kelvin;
341 static constexpr double STP_Pressure = 1.*atmosphere;
342 static constexpr double kGasThreshold = 10.*mg/cm3;
343 
344 //
345 //
346 //
347 static constexpr double universe_mean_density = 1.e-25*g/cm3;
348 
349 }
350 
351 
352 #endif