File indexing completed on 2025-01-18 09:14:33
0001
0002
0003
0004 #include "Evaluator/Evaluator.h"
0005 #include "Evaluator/detail/Evaluator.h"
0006
0007
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;
0022 const double mega_ = 1.e+06;
0023 const double giga_ = 1.e+09;
0024 const double tera_ = 1.e+12;
0025 const double peta_ = 1.e+15;
0026
0027 const double deci_ = 1.e-01;
0028 const double centi_ = 1.e-02;
0029 const double milli_ = 1.e-03;
0030 const double micro_ = 1.e-06;
0031 const double nano_ = 1.e-09;
0032 const double pico_ = 1.e-12;
0033 const double femto_ = 1.e-15;
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044 const double m = meter;
0045 setVariableNoLock("meter", m);
0046 setVariableNoLock("metre", m);
0047 setVariableNoLock("m", m);
0048
0049
0050 const double kg = kilogram;
0051 setVariableNoLock("kilogram", kg);
0052 setVariableNoLock("kg", kg);
0053
0054
0055
0056 const double s = second;
0057 setVariableNoLock("second", s);
0058 setVariableNoLock("s", s);
0059
0060
0061
0062 const double A = ampere;
0063 setVariableNoLock("ampere", A);
0064 setVariableNoLock("amp", A);
0065 setVariableNoLock("A", A);
0066
0067
0068
0069 const double K = kelvin;
0070 setVariableNoLock("kelvin", K);
0071 setVariableNoLock("K", K);
0072
0073
0074 const double mol = mole;
0075 setVariableNoLock("mole", mol);
0076 setVariableNoLock("mol", mol);
0077
0078
0079 const double cd = candela;
0080 setVariableNoLock("candela", cd);
0081 setVariableNoLock("cd", cd);
0082
0083
0084
0085
0086
0087
0088
0089 const double pi = 3.14159265358979323846;
0090
0091
0092
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
0107 const double sr = 1.;
0108 setVariableNoLock("steradian", sr);
0109 setVariableNoLock("sr", sr);
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119 const double Hz = 1./s;
0120 setVariableNoLock("hertz", Hz);
0121 setVariableNoLock("Hz", Hz);
0122
0123
0124
0125 const double N = m * kg / (s*s);
0126 setVariableNoLock("newton", N);
0127 setVariableNoLock("N", N);
0128
0129
0130
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
0144
0145 const double J = N * m;
0146 setVariableNoLock("joule", J);
0147 setVariableNoLock("J", J);
0148
0149
0150
0151 const double W = J / s;
0152 setVariableNoLock("watt", W);
0153 setVariableNoLock("W", W);
0154
0155
0156
0157 const double C = A * s;
0158 setVariableNoLock("coulomb", C);
0159 setVariableNoLock("C", C);
0160
0161
0162
0163 const double V = J / C;
0164 setVariableNoLock("volt", V);
0165 setVariableNoLock("V", V);
0166
0167
0168
0169 const double ohm = V / A;
0170 setVariableNoLock("ohm", ohm);
0171
0172
0173
0174
0175
0176 const double S = 1./ ohm;
0177 setVariableNoLock("siemens", S);
0178 setVariableNoLock("S", S);
0179
0180
0181
0182 const double F = C / V;
0183 setVariableNoLock("farad", F);
0184 setVariableNoLock("F", F);
0185
0186
0187
0188 const double T = V * s / (m*m);
0189 setVariableNoLock("tesla", T);
0190 setVariableNoLock("T", T);
0191
0192
0193 const double Gs = 1.e-4*T;
0194 setVariableNoLock("gauss", Gs);
0195 setVariableNoLock("Gs", Gs);
0196
0197
0198
0199 const double Wb = V * s;
0200 setVariableNoLock("weber", Wb);
0201 setVariableNoLock("Wb", Wb);
0202
0203
0204
0205 const double H = Wb / A;
0206 setVariableNoLock("henry", H);
0207 setVariableNoLock("H", H);
0208
0209
0210 const double lm = cd * sr;
0211 setVariableNoLock("lumen", lm);
0212 setVariableNoLock("lm", lm);
0213
0214
0215 const double lx = lm / (m*m);
0216 setVariableNoLock("lux", lx);
0217 setVariableNoLock("lx", lx);
0218
0219
0220
0221 const double Bq = 1./s;
0222 setVariableNoLock("becquerel", Bq);
0223 setVariableNoLock("Bq", Bq);
0224
0225
0226
0227 setVariableNoLock("curie", 3.7e+10 * Bq);
0228 setVariableNoLock("Ci", 3.7e+10 * Bq);
0229
0230
0231
0232 const double Gy = J / kg;
0233 setVariableNoLock("gray", Gy);
0234 setVariableNoLock("Gy", Gy);
0235
0236
0237 const double Sv = J / kg;
0238 setVariableNoLock("sievert", Sv);
0239 setVariableNoLock("Sv", Sv);
0240
0241
0242
0243
0244
0245
0246
0247
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
0271 setVariableNoLock("angstrom", 1.e-10 * m);
0272
0273
0274 setVariableNoLock("fermi", 1.e-15 * m);
0275 setVariableNoLock("femtometer", femto_ * m);
0276 setVariableNoLock("fm", femto_ * m);
0277
0278
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
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
0311
0312 const double dpt = 1./m;
0313 setVariableNoLock("diopter", dpt);
0314 setVariableNoLock("dioptre", dpt);
0315 setVariableNoLock("dpt", dpt);
0316
0317
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
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
0335
0336 setVariableNoLock("milliampere", milli_ * A);
0337 setVariableNoLock("mA", milli_ * A);
0338 setVariableNoLock("microampere", micro_ * A);
0339 setVariableNoLock("nanoampere", nano_ * A);
0340
0341
0342
0343 setVariableNoLock("kilohertz", kilo_ * Hz);
0344 setVariableNoLock("kHz", kilo_ * Hz);
0345 setVariableNoLock("megahertz", mega_ * Hz);
0346 setVariableNoLock("MHz", mega_ * Hz);
0347
0348
0349 setVariableNoLock("kilonewton", kilo_ * N);
0350 setVariableNoLock("kN", kilo_ * N);
0351
0352
0353 setVariableNoLock("kilobar", kilo_ * bar);
0354 setVariableNoLock("kbar", kilo_ * bar);
0355 setVariableNoLock("millibar", milli_ * bar);
0356 setVariableNoLock("mbar", milli_ * bar);
0357
0358
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;
0367 const double ePlus = e_SI * C;
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
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
0391 setVariableNoLock("kilovolt", kilo_ * V);
0392 setVariableNoLock("kV", kilo_ * V);
0393 setVariableNoLock("megavolt", mega_ * V);
0394 setVariableNoLock("MV", mega_ * V);
0395
0396
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
0407 setVariableNoLock("kilogauss", kilo_ * Gs);
0408 setVariableNoLock("kGs", kilo_ * Gs);
0409 }
0410
0411 }
0412 }