DD4hep  1.31.0
Detector Description Toolkit for High Energy Physics
setSystemOfUnits.cpp
Go to the documentation of this file.
1 // -*- C++ -*-
2 // ----------------------------------------------------------------------
3 
4 #include "Evaluator/Evaluator.h"
5 #include "Evaluator/detail/Evaluator.h"
6 
8 namespace dd4hep {
9 
10  namespace tools {
11 
12  void Evaluator::Object::setSystemOfUnits(double meter,
13  double kilogram,
14  double second,
15  double ampere,
16  double kelvin,
17  double mole,
18  double candela,
19  double radians)
20  {
21  const double kilo_ = 1.e+03; // chilioi (Greek) "thousand"
22  const double mega_ = 1.e+06; // megas (Greek) "large"
23  const double giga_ = 1.e+09; // gigas (Greek) "giant"
24  const double tera_ = 1.e+12; // teras (Greek) "monster"
25  const double peta_ = 1.e+15; // pente (Greek) "five"
26 
27  const double deci_ = 1.e-01; // decimus (Latin) "tenth"
28  const double centi_ = 1.e-02; // centum (Latin) "hundred"
29  const double milli_ = 1.e-03; // mille (Latin) "thousand"
30  const double micro_ = 1.e-06; // micro (Latin) or mikros (Greek) "small"
31  const double nano_ = 1.e-09; // nanus (Latin) or nanos (Greek) "dwarf"
32  const double pico_ = 1.e-12; // pico (Spanish) "bit"
33  const double femto_ = 1.e-15; // femto
34 
35  // ======================================================================
36  //
37  // Base (default) SI units
38  // for the basic measurable quantities (dimensions):
39  //
40  // ======================================================================
41 
42  // Length
43  // metrum (Latin) and metron (Greek) "measure"
44  const double m = meter;
45  setVariableNoLock("meter", m);
46  setVariableNoLock("metre", m);
47  setVariableNoLock("m", m);
48 
49  // Mass
50  const double kg = kilogram;
51  setVariableNoLock("kilogram", kg);
52  setVariableNoLock("kg", kg);
53 
54  // Time
55  // minuta secundam (Latin) "second small one"
56  const double s = second;
57  setVariableNoLock("second", s);
58  setVariableNoLock("s", s);
59 
60  // Current
61  // --- honors Andre-Marie Ampere (1775-1836) of France
62  const double A = ampere;
63  setVariableNoLock("ampere", A);
64  setVariableNoLock("amp", A);
65  setVariableNoLock("A", A);
66 
67  // Temperature
68  // --- honors William Thomson, 1st Baron Lord Kelvin (1824-1907) of England
69  const double K = kelvin;
70  setVariableNoLock("kelvin", K);
71  setVariableNoLock("K", K);
72 
73  // Amount of substance
74  const double mol = mole;
75  setVariableNoLock("mole", mol);
76  setVariableNoLock("mol", mol);
77 
78  // Luminous intensity
79  const double cd = candela;
80  setVariableNoLock("candela", cd);
81  setVariableNoLock("cd", cd);
82 
83  // ======================================================================
84  //
85  // Supplementary SI units having special symbols:
86  //
87  // ======================================================================
88 
89  const double pi = 3.14159265358979323846;
90  // Plane angle
91  // const double rad = 1.; // Geant4 (rad units)
92  //const double rad = pi; // Degree units
93 
94  const double rad = radians ;
95 
96  setVariableNoLock("radian", rad);
97  setVariableNoLock("rad", rad);
98  setVariableNoLock("milliradian", milli_ * rad);
99  setVariableNoLock("mrad", milli_ * rad);
100 
101  const double deg = rad*pi/180.;
102 
103  setVariableNoLock("degree", deg);
104  setVariableNoLock("deg", deg);
105 
106  // Solid angle
107  const double sr = 1.;
108  setVariableNoLock("steradian", sr);
109  setVariableNoLock("sr", sr);
110 
111  // ======================================================================
112  //
113  // Derived SI units having special symbols:
114  //
115  // ======================================================================
116 
117  // Frequency
118  // --- honors Heinrich Rudolf Hertz (1857-1894) of Germany
119  const double Hz = 1./s;
120  setVariableNoLock("hertz", Hz);
121  setVariableNoLock("Hz", Hz);
122 
123  // Force
124  // --- honors Sir Isaac Newton (1642-1727) of England
125  const double N = m * kg / (s*s);
126  setVariableNoLock("newton", N);
127  setVariableNoLock("N", N);
128 
129  // Pressure
130  // --- honors Blaise Pascal (1623-1662) of France
131  const double Pa = N / (m*m);
132  setVariableNoLock("pascal", Pa);
133  setVariableNoLock("Pa", Pa);
134  setVariableNoLock("hPa", 100.0*Pa);
135 
136  const double atm = 101325. * Pa;
137  setVariableNoLock("atmosphere", atm);
138  setVariableNoLock("atm", atm);
139 
140  const double bar = 100000*Pa;
141  setVariableNoLock("bar", bar);
142 
143  // Energy
144  // --- honors James Prescott Joule (1818-1889) of England
145  const double J = N * m;
146  setVariableNoLock("joule", J);
147  setVariableNoLock("J", J);
148 
149  // Power
150  // --- honors James Watt (1736-1819) of Scotland
151  const double W = J / s;
152  setVariableNoLock("watt", W);
153  setVariableNoLock("W", W);
154 
155  // Electric charge
156  // --- honors Charles-Augustin de Coulomb (1736-1806) of France
157  const double C = A * s;
158  setVariableNoLock("coulomb", C);
159  setVariableNoLock("C", C);
160 
161  // Electric potential
162  // --- honors Count Alessandro Volta (1745-1827) of Italy
163  const double V = J / C;
164  setVariableNoLock("volt", V);
165  setVariableNoLock("V", V);
166 
167  // Electric resistance
168  // --- honors Georg Simon Ohm (1787-1854) of Germany
169  const double ohm = V / A;
170  setVariableNoLock("ohm", ohm);
171 
172  // Electric conductance
173  // --- honors Ernst Werner von Siemens (1816-1892) or
174  // his brother Sir William (Karl Wilhelm von) Siemens (1823-1883)
175  // of Germany (England)
176  const double S = 1./ ohm;
177  setVariableNoLock("siemens", S);
178  setVariableNoLock("S", S);
179 
180  // Electric capacitance
181  // --- honors Michael Faraday (1791-1867) of England
182  const double F = C / V;
183  setVariableNoLock("farad", F);
184  setVariableNoLock("F", F);
185 
186  // Magnetic flux density
187  // --- honors Nikola Tesla (1856-1943) of Croatia (United States)
188  const double T = V * s / (m*m);
189  setVariableNoLock("tesla", T);
190  setVariableNoLock("T", T);
191 
192  // --- honors Karl Friedrich Gauss (1777-1855) of Germany
193  const double Gs = 1.e-4*T;
194  setVariableNoLock("gauss", Gs);
195  setVariableNoLock("Gs", Gs);
196 
197  // Magnetic flux
198  // --- honors Wilhelm Eduard Weber (1804-1891) of Germany
199  const double Wb = V * s;
200  setVariableNoLock("weber", Wb);
201  setVariableNoLock("Wb", Wb);
202 
203  // Inductance
204  // --- honors Joseph Henry (1797-1878) of the United States
205  const double H = Wb / A;
206  setVariableNoLock("henry", H);
207  setVariableNoLock("H", H);
208 
209  // Luminous flux
210  const double lm = cd * sr;
211  setVariableNoLock("lumen", lm);
212  setVariableNoLock("lm", lm);
213 
214  // Illuminace
215  const double lx = lm / (m*m);
216  setVariableNoLock("lux", lx);
217  setVariableNoLock("lx", lx);
218 
219  // Radioactivity
220  // --- honors Antoine-Henri Becquerel (1852-1908) of France
221  const double Bq = 1./s;
222  setVariableNoLock("becquerel", Bq);
223  setVariableNoLock("Bq", Bq);
224 
225  // --- honors Pierre Curie (1859-1906) of France
226  // and Marie Sklodowska Curie (1867-1934) of Poland
227  setVariableNoLock("curie", 3.7e+10 * Bq);
228  setVariableNoLock("Ci", 3.7e+10 * Bq);
229 
230  // Specific energy
231  // --- honors Louis Harold Gray, F.R.S. (1905-1965) of England
232  const double Gy = J / kg;
233  setVariableNoLock("gray", Gy);
234  setVariableNoLock("Gy", Gy);
235 
236  // Dose equivalent
237  const double Sv = J / kg;
238  setVariableNoLock("sievert", Sv);
239  setVariableNoLock("Sv", Sv);
240 
241  // ======================================================================
242  //
243  // Selected units:
244  //
245  // ======================================================================
246 
247  // Length
248 
249  const double mm = milli_ * m;
250  setVariableNoLock("millimeter", mm);
251  setVariableNoLock("mm", mm);
252 
253  const double cm = centi_ * m;
254  setVariableNoLock("centimeter", cm);
255  setVariableNoLock("cm", cm);
256 
257  setVariableNoLock("decimeter", deci_ * m);
258 
259  const double km = kilo_ * m;
260  setVariableNoLock("kilometer", km);
261  setVariableNoLock("km", km);
262 
263  setVariableNoLock("micrometer", micro_ * m);
264  setVariableNoLock("micron", micro_ * m);
265  setVariableNoLock("mum", micro_ * m);
266  setVariableNoLock("um", micro_ * m);
267  setVariableNoLock("nanometer", nano_ * m);
268  setVariableNoLock("nm", nano_ * m);
269 
270  // --- honors Anders Jonas Angstrom (1814-1874) of Sweden
271  setVariableNoLock("angstrom", 1.e-10 * m);
272 
273  // --- honors Enrico Fermi (1901-1954) of Italy
274  setVariableNoLock("fermi", 1.e-15 * m);
275  setVariableNoLock("femtometer", femto_ * m);
276  setVariableNoLock("fm", femto_ * m);
277 
278  // Length^2
279 
280  setVariableNoLock("m2", m*m);
281  setVariableNoLock("mm2", mm*mm);
282  setVariableNoLock("cm2", cm*cm);
283  setVariableNoLock("km2", km*km);
284 
285  const double barn = 1.e-28 * m*m;
286  setVariableNoLock("barn", barn);
287  setVariableNoLock("millibarn", milli_ * barn);
288  setVariableNoLock("mbarn", milli_ * barn);
289  setVariableNoLock("microbarn", micro_ * barn);
290  setVariableNoLock("nanobarn", nano_ * barn);
291  setVariableNoLock("picobarn", pico_ * barn);
292 
293  // LengthL^3
294 
295  setVariableNoLock("m3", m*m*m);
296  setVariableNoLock("mm3", mm*mm*mm);
297  setVariableNoLock("cm3", cm*cm*cm);
298  setVariableNoLock("cc", cm*cm*cm);
299  setVariableNoLock("km3", km*km*km);
300 
301  const double L = 1.e-3*m*m*m;
302  setVariableNoLock("liter", L);
303  setVariableNoLock("litre", L);
304  setVariableNoLock("L", L);
305  setVariableNoLock("centiliter", centi_ * L);
306  setVariableNoLock("cL", centi_ * L);
307  setVariableNoLock("milliliter", milli_ * L);
308  setVariableNoLock("mL", milli_ * L);
309 
310  // Length^-1
311 
312  const double dpt = 1./m;
313  setVariableNoLock("diopter", dpt);
314  setVariableNoLock("dioptre", dpt);
315  setVariableNoLock("dpt", dpt);
316 
317  // Mass
318 
319  const double g = 0.001*kg;
320  setVariableNoLock("gram", g);
321  setVariableNoLock("g", g);
322  setVariableNoLock("milligram", milli_ * g);
323  setVariableNoLock("mg", milli_ * g);
324 
325  // Time
326 
327  setVariableNoLock("millisecond", milli_ * s);
328  setVariableNoLock("ms", milli_ * s);
329  setVariableNoLock("microsecond", micro_ * s);
330  setVariableNoLock("nanosecond", nano_ * s);
331  setVariableNoLock("ns", nano_ * s);
332  setVariableNoLock("picosecond", pico_ * s);
333 
334  // Current
335 
336  setVariableNoLock("milliampere", milli_ * A);
337  setVariableNoLock("mA", milli_ * A);
338  setVariableNoLock("microampere", micro_ * A);
339  setVariableNoLock("nanoampere", nano_ * A);
340 
341  // Frequency
342 
343  setVariableNoLock("kilohertz", kilo_ * Hz);
344  setVariableNoLock("kHz", kilo_ * Hz);
345  setVariableNoLock("megahertz", mega_ * Hz);
346  setVariableNoLock("MHz", mega_ * Hz);
347 
348  // Force
349  setVariableNoLock("kilonewton", kilo_ * N);
350  setVariableNoLock("kN", kilo_ * N);
351 
352  // Pressure
353  setVariableNoLock("kilobar", kilo_ * bar);
354  setVariableNoLock("kbar", kilo_ * bar);
355  setVariableNoLock("millibar", milli_ * bar);
356  setVariableNoLock("mbar", milli_ * bar);
357 
358  // Energy
359  setVariableNoLock("kilojoule", kilo_ * J);
360  setVariableNoLock("kJ", kilo_ * J);
361  setVariableNoLock("megajoule", mega_ * J);
362  setVariableNoLock("MJ", mega_ * J);
363  setVariableNoLock("gigajoule", giga_ * J);
364  setVariableNoLock("GJ", giga_ * J);
365 
366  const double e_SI = 1.60217733e-19; // positron charge in coulomb
367  const double ePlus = e_SI * C; // positron charge
368  const double eV = ePlus * V;
369  setVariableNoLock("electronvolt", eV);
370  setVariableNoLock("eV", eV);
371  setVariableNoLock("kiloelectronvolt", kilo_ * eV);
372  setVariableNoLock("keV", kilo_ * eV);
373  setVariableNoLock("megaelectronvolt", mega_ * eV);
374  setVariableNoLock("MeV", mega_ * eV);
375  setVariableNoLock("gigaelectronvolt", giga_ * eV);
376  setVariableNoLock("GeV", giga_ * eV);
377  setVariableNoLock("teraelectronvolt", tera_ * eV);
378  setVariableNoLock("TeV", tera_ * eV);
379  setVariableNoLock("petaelectronvolt", peta_ * eV);
380  setVariableNoLock("PeV", peta_ * eV);
381 
382  // Power
383  setVariableNoLock("kilowatt", kilo_ * W);
384  setVariableNoLock("kW", kilo_ * W);
385  setVariableNoLock("megawatt", mega_ * W);
386  setVariableNoLock("MW", mega_ * W);
387  setVariableNoLock("gigawatt", giga_ * W);
388  setVariableNoLock("GW", giga_ * W);
389 
390  // Electric potential
391  setVariableNoLock("kilovolt", kilo_ * V);
392  setVariableNoLock("kV", kilo_ * V);
393  setVariableNoLock("megavolt", mega_ * V);
394  setVariableNoLock("MV", mega_ * V);
395 
396  // Electric capacitance
397  setVariableNoLock("millifarad", milli_ * F);
398  setVariableNoLock("mF", milli_ * F);
399  setVariableNoLock("microfarad", micro_ * F);
400  setVariableNoLock("uF", micro_ * F);
401  setVariableNoLock("nanofarad", nano_ * F);
402  setVariableNoLock("nF", nano_ * F);
403  setVariableNoLock("picofarad", pico_ * F);
404  setVariableNoLock("pF", pico_ * F);
405 
406  // Magnetic flux density
407  setVariableNoLock("kilogauss", kilo_ * Gs);
408  setVariableNoLock("kGs", kilo_ * Gs);
409  }
410 
411  } // namespace tools
412 } // namespace dd4hep
dd4hep
Namespace for the AIDA detector description toolkit.
Definition: AlignmentsCalib.h:28