Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:14:33

0001 // -*- C++ -*-
0002 // ----------------------------------------------------------------------
0003 
0004 #include "Evaluator/Evaluator.h"
0005 #include "Evaluator/detail/Evaluator.h"
0006 
0007 /// Namespace for the AIDA detector description toolkit
0008 namespace dd4hep  {
0009 
0010   namespace tools {
0011 
0012     void Evaluator::Object::setSystemOfUnits(double meter,
0013                          double kilogram,
0014                          double second,
0015                          double ampere,
0016                          double kelvin,
0017                          double mole,
0018                          double candela,
0019                          double radians)
0020     {
0021       const double kilo_  = 1.e+03; // chilioi (Greek) "thousand"
0022       const double mega_  = 1.e+06; // megas (Greek) "large"
0023       const double giga_  = 1.e+09; // gigas (Greek) "giant"
0024       const double tera_  = 1.e+12; // teras (Greek) "monster"
0025       const double peta_  = 1.e+15; // pente (Greek) "five"
0026 
0027       const double deci_  = 1.e-01; // decimus (Latin) "tenth"
0028       const double centi_ = 1.e-02; // centum  (Latin) "hundred"
0029       const double milli_ = 1.e-03; // mille   (Latin) "thousand"
0030       const double micro_ = 1.e-06; // micro (Latin) or mikros (Greek) "small"
0031       const double nano_  = 1.e-09; // nanus (Latin) or nanos  (Greek) "dwarf"
0032       const double pico_  = 1.e-12; // pico (Spanish) "bit"
0033       const double femto_ = 1.e-15; // femto
0034 
0035       // ======================================================================
0036       //
0037       // Base (default) SI units
0038       // for the basic measurable quantities (dimensions):
0039       //
0040       // ======================================================================
0041 
0042       // Length
0043       // metrum (Latin) and metron (Greek) "measure"
0044       const double m = meter;
0045       setVariableNoLock("meter", m);
0046       setVariableNoLock("metre", m);
0047       setVariableNoLock("m",     m);
0048 
0049       // Mass
0050       const double kg = kilogram;
0051       setVariableNoLock("kilogram", kg);
0052       setVariableNoLock("kg",       kg);
0053 
0054       // Time
0055       // minuta secundam (Latin) "second small one"
0056       const double s = second;
0057       setVariableNoLock("second", s);
0058       setVariableNoLock("s",      s);
0059 
0060       // Current
0061       // ---  honors Andre-Marie Ampere (1775-1836) of France
0062       const double A = ampere;
0063       setVariableNoLock("ampere", A);
0064       setVariableNoLock("amp",    A);
0065       setVariableNoLock("A",      A);
0066 
0067       // Temperature
0068       // ---  honors William Thomson, 1st Baron Lord Kelvin (1824-1907) of England
0069       const double K = kelvin;
0070       setVariableNoLock("kelvin", K);
0071       setVariableNoLock("K",      K);
0072 
0073       // Amount of substance
0074       const double mol = mole;
0075       setVariableNoLock("mole", mol);
0076       setVariableNoLock("mol",  mol);
0077 
0078       // Luminous intensity
0079       const double cd  = candela;
0080       setVariableNoLock("candela", cd);
0081       setVariableNoLock("cd",      cd);
0082 
0083       // ======================================================================
0084       //
0085       // Supplementary SI units having special symbols:
0086       //
0087       // ======================================================================
0088 
0089       const double pi  = 3.14159265358979323846;
0090       // Plane angle
0091       // const double rad = 1.;  // Geant4 (rad units)
0092       //const double rad = pi;    // Degree units
0093 
0094       const double rad = radians ;
0095 
0096       setVariableNoLock("radian", rad);
0097       setVariableNoLock("rad",    rad);
0098       setVariableNoLock("milliradian", milli_ * rad);
0099       setVariableNoLock("mrad",        milli_ * rad);
0100 
0101       const double deg = rad*pi/180.;
0102 
0103       setVariableNoLock("degree", deg);
0104       setVariableNoLock("deg",    deg);
0105 
0106       // Solid angle
0107       const double sr  = 1.;
0108       setVariableNoLock("steradian", sr);
0109       setVariableNoLock("sr",        sr);
0110 
0111       // ======================================================================
0112       //
0113       // Derived SI units having special symbols:
0114       //
0115       // ======================================================================
0116 
0117       // Frequency
0118       // ---  honors Heinrich Rudolf Hertz (1857-1894) of Germany
0119       const double Hz = 1./s;
0120       setVariableNoLock("hertz", Hz);
0121       setVariableNoLock("Hz",    Hz);
0122 
0123       // Force
0124       // ---  honors Sir Isaac Newton (1642-1727) of England
0125       const double N = m * kg / (s*s);
0126       setVariableNoLock("newton", N);
0127       setVariableNoLock("N",      N);
0128 
0129       // Pressure
0130       // ---  honors Blaise Pascal (1623-1662) of France
0131       const double Pa = N / (m*m);
0132       setVariableNoLock("pascal",    Pa);
0133       setVariableNoLock("Pa",        Pa);
0134       setVariableNoLock("hPa", 100.0*Pa);
0135 
0136       const double atm = 101325. * Pa;
0137       setVariableNoLock("atmosphere", atm);
0138       setVariableNoLock("atm",        atm);
0139 
0140       const double bar = 100000*Pa;
0141       setVariableNoLock("bar", bar);
0142 
0143       // Energy
0144       // ---  honors James Prescott Joule (1818-1889) of England
0145       const double J = N * m;
0146       setVariableNoLock("joule", J);
0147       setVariableNoLock("J",     J);
0148 
0149       // Power
0150       // ---  honors James Watt (1736-1819) of Scotland
0151       const double W = J / s;
0152       setVariableNoLock("watt", W);
0153       setVariableNoLock("W",    W);
0154 
0155       // Electric charge
0156       // ---  honors Charles-Augustin de Coulomb (1736-1806) of France
0157       const double C = A * s;
0158       setVariableNoLock("coulomb", C);
0159       setVariableNoLock("C",       C);
0160 
0161       // Electric potential
0162       // ---  honors Count Alessandro Volta (1745-1827) of Italy
0163       const double V = J / C;
0164       setVariableNoLock("volt", V);
0165       setVariableNoLock("V",    V);
0166 
0167       // Electric resistance
0168       // ---  honors Georg Simon Ohm (1787-1854) of Germany
0169       const double ohm = V / A;
0170       setVariableNoLock("ohm", ohm);
0171 
0172       // Electric conductance
0173       // ---  honors Ernst Werner von Siemens (1816-1892) or
0174       //      his brother Sir William (Karl Wilhelm von) Siemens (1823-1883)
0175       //      of Germany (England)
0176       const double S = 1./ ohm;
0177       setVariableNoLock("siemens", S);
0178       setVariableNoLock("S",       S);
0179 
0180       // Electric capacitance
0181       // ---  honors Michael Faraday (1791-1867) of England
0182       const double F = C / V;
0183       setVariableNoLock("farad", F);
0184       setVariableNoLock("F",     F);
0185 
0186       // Magnetic flux density
0187       // ---  honors Nikola Tesla (1856-1943) of Croatia (United States)
0188       const double T = V * s / (m*m);
0189       setVariableNoLock("tesla", T);
0190       setVariableNoLock("T",     T);
0191 
0192       // ---  honors Karl Friedrich Gauss (1777-1855) of Germany
0193       const double Gs = 1.e-4*T;
0194       setVariableNoLock("gauss", Gs);
0195       setVariableNoLock("Gs",    Gs);
0196 
0197       // Magnetic flux
0198       // ---  honors Wilhelm Eduard Weber (1804-1891) of Germany
0199       const double Wb = V * s;
0200       setVariableNoLock("weber", Wb);
0201       setVariableNoLock("Wb",    Wb);
0202 
0203       // Inductance
0204       // ---  honors Joseph Henry (1797-1878) of the United States
0205       const double H = Wb / A;
0206       setVariableNoLock("henry", H);
0207       setVariableNoLock("H",     H);
0208 
0209       // Luminous flux
0210       const double lm = cd * sr;
0211       setVariableNoLock("lumen", lm);
0212       setVariableNoLock("lm",    lm);
0213 
0214       // Illuminace
0215       const double lx = lm / (m*m);
0216       setVariableNoLock("lux", lx);
0217       setVariableNoLock("lx",  lx);
0218 
0219       // Radioactivity
0220       // ---  honors Antoine-Henri Becquerel (1852-1908) of France
0221       const double Bq = 1./s;
0222       setVariableNoLock("becquerel", Bq);
0223       setVariableNoLock("Bq",        Bq);
0224 
0225       // ---  honors Pierre Curie (1859-1906) of France
0226       //      and Marie Sklodowska Curie (1867-1934) of Poland
0227       setVariableNoLock("curie", 3.7e+10 * Bq);
0228       setVariableNoLock("Ci",    3.7e+10 * Bq);
0229 
0230       // Specific energy
0231       // ---  honors Louis Harold Gray, F.R.S. (1905-1965) of England
0232       const double Gy = J / kg;
0233       setVariableNoLock("gray", Gy);
0234       setVariableNoLock("Gy",   Gy);
0235 
0236       // Dose equivalent
0237       const double Sv = J / kg;
0238       setVariableNoLock("sievert", Sv);
0239       setVariableNoLock("Sv",      Sv);
0240 
0241       // ======================================================================
0242       //
0243       // Selected units:
0244       //
0245       // ======================================================================
0246 
0247       // Length
0248 
0249       const double mm = milli_ * m;
0250       setVariableNoLock("millimeter", mm);
0251       setVariableNoLock("mm",         mm);
0252 
0253       const double cm = centi_ * m;
0254       setVariableNoLock("centimeter", cm);
0255       setVariableNoLock("cm",         cm);
0256 
0257       setVariableNoLock("decimeter",  deci_ * m);
0258 
0259       const double km = kilo_ * m;
0260       setVariableNoLock("kilometer",  km);
0261       setVariableNoLock("km",         km);
0262 
0263       setVariableNoLock("micrometer", micro_ * m);
0264       setVariableNoLock("micron",     micro_ * m);
0265       setVariableNoLock("mum",        micro_ * m);
0266       setVariableNoLock("um",         micro_ * m);
0267       setVariableNoLock("nanometer",  nano_  * m);
0268       setVariableNoLock("nm",         nano_  * m);
0269 
0270       // ---  honors Anders Jonas Angstrom (1814-1874) of Sweden
0271       setVariableNoLock("angstrom",   1.e-10 * m);
0272 
0273       // ---  honors Enrico Fermi (1901-1954) of Italy
0274       setVariableNoLock("fermi",      1.e-15 * m);
0275       setVariableNoLock("femtometer", femto_ * m);
0276       setVariableNoLock("fm",         femto_ * m);
0277 
0278       // Length^2
0279 
0280       setVariableNoLock("m2",  m*m);
0281       setVariableNoLock("mm2", mm*mm);
0282       setVariableNoLock("cm2", cm*cm);
0283       setVariableNoLock("km2", km*km);
0284 
0285       const double barn = 1.e-28 * m*m;
0286       setVariableNoLock("barn",      barn);
0287       setVariableNoLock("millibarn", milli_ * barn);
0288       setVariableNoLock("mbarn",     milli_ * barn);
0289       setVariableNoLock("microbarn", micro_ * barn);
0290       setVariableNoLock("nanobarn",  nano_  * barn);
0291       setVariableNoLock("picobarn",  pico_  * barn);
0292 
0293       // LengthL^3
0294 
0295       setVariableNoLock("m3",  m*m*m);
0296       setVariableNoLock("mm3", mm*mm*mm);
0297       setVariableNoLock("cm3", cm*cm*cm);
0298       setVariableNoLock("cc",  cm*cm*cm);
0299       setVariableNoLock("km3", km*km*km);
0300 
0301       const double L = 1.e-3*m*m*m;
0302       setVariableNoLock("liter", L);
0303       setVariableNoLock("litre", L);
0304       setVariableNoLock("L",     L);
0305       setVariableNoLock("centiliter",  centi_ * L);
0306       setVariableNoLock("cL",          centi_ * L);
0307       setVariableNoLock("milliliter",  milli_ * L);
0308       setVariableNoLock("mL",          milli_ * L);
0309 
0310       // Length^-1
0311 
0312       const double dpt = 1./m;
0313       setVariableNoLock("diopter", dpt);
0314       setVariableNoLock("dioptre", dpt);
0315       setVariableNoLock("dpt",     dpt);
0316 
0317       // Mass
0318 
0319       const double g = 0.001*kg;
0320       setVariableNoLock("gram", g);
0321       setVariableNoLock("g",    g);
0322       setVariableNoLock("milligram",   milli_ * g);
0323       setVariableNoLock("mg",          milli_ * g);
0324 
0325       // Time
0326 
0327       setVariableNoLock("millisecond", milli_ * s);
0328       setVariableNoLock("ms",          milli_ * s);
0329       setVariableNoLock("microsecond", micro_ * s);
0330       setVariableNoLock("nanosecond",  nano_  * s);
0331       setVariableNoLock("ns",          nano_  * s);
0332       setVariableNoLock("picosecond",  pico_  * s);
0333 
0334       // Current
0335 
0336       setVariableNoLock("milliampere", milli_ * A);
0337       setVariableNoLock("mA",          milli_ * A);
0338       setVariableNoLock("microampere", micro_ * A);
0339       setVariableNoLock("nanoampere",  nano_  * A);
0340 
0341       // Frequency
0342 
0343       setVariableNoLock("kilohertz",   kilo_ * Hz);
0344       setVariableNoLock("kHz",         kilo_ * Hz);
0345       setVariableNoLock("megahertz",   mega_ * Hz);
0346       setVariableNoLock("MHz",         mega_ * Hz);
0347 
0348       // Force
0349       setVariableNoLock("kilonewton",  kilo_ * N);
0350       setVariableNoLock("kN",          kilo_ * N);
0351 
0352       // Pressure
0353       setVariableNoLock("kilobar",     kilo_ * bar);
0354       setVariableNoLock("kbar",        kilo_ * bar);
0355       setVariableNoLock("millibar",    milli_ * bar);
0356       setVariableNoLock("mbar",        milli_ * bar);
0357 
0358       // Energy
0359       setVariableNoLock("kilojoule",   kilo_ * J);
0360       setVariableNoLock("kJ",          kilo_ * J);
0361       setVariableNoLock("megajoule",   mega_ * J);
0362       setVariableNoLock("MJ",          mega_ * J);
0363       setVariableNoLock("gigajoule",   giga_ * J);
0364       setVariableNoLock("GJ",          giga_ * J);
0365 
0366       const double e_SI  = 1.60217733e-19;  // positron charge in coulomb
0367       const double ePlus = e_SI * C;        // positron charge
0368       const double eV    = ePlus * V;
0369       setVariableNoLock("electronvolt", eV);
0370       setVariableNoLock("eV",           eV);
0371       setVariableNoLock("kiloelectronvolt", kilo_ * eV);
0372       setVariableNoLock("keV",              kilo_ * eV);
0373       setVariableNoLock("megaelectronvolt", mega_ * eV);
0374       setVariableNoLock("MeV",              mega_ * eV);
0375       setVariableNoLock("gigaelectronvolt", giga_ * eV);
0376       setVariableNoLock("GeV",              giga_ * eV);
0377       setVariableNoLock("teraelectronvolt", tera_ * eV);
0378       setVariableNoLock("TeV",              tera_ * eV);
0379       setVariableNoLock("petaelectronvolt", peta_ * eV);
0380       setVariableNoLock("PeV",              peta_ * eV);
0381 
0382       // Power
0383       setVariableNoLock("kilowatt",    kilo_ * W);
0384       setVariableNoLock("kW",          kilo_ * W);
0385       setVariableNoLock("megawatt",    mega_ * W);
0386       setVariableNoLock("MW",          mega_ * W);
0387       setVariableNoLock("gigawatt",    giga_ * W);
0388       setVariableNoLock("GW",          giga_ * W);
0389 
0390       // Electric potential
0391       setVariableNoLock("kilovolt",    kilo_ * V);
0392       setVariableNoLock("kV",          kilo_ * V);
0393       setVariableNoLock("megavolt",    mega_ * V);
0394       setVariableNoLock("MV",          mega_ * V);
0395 
0396       // Electric capacitance
0397       setVariableNoLock("millifarad",  milli_ * F);
0398       setVariableNoLock("mF",          milli_ * F);
0399       setVariableNoLock("microfarad",  micro_ * F);
0400       setVariableNoLock("uF",          micro_ * F);
0401       setVariableNoLock("nanofarad",   nano_  * F);
0402       setVariableNoLock("nF",          nano_  * F);
0403       setVariableNoLock("picofarad",   pico_  * F);
0404       setVariableNoLock("pF",          pico_  * F);
0405 
0406       // Magnetic flux density
0407       setVariableNoLock("kilogauss",   kilo_ * Gs);
0408       setVariableNoLock("kGs",         kilo_ * Gs);
0409     }
0410 
0411   } // namespace tools
0412 }  // namespace dd4hep