SystemOfUnits.h 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. /***************************************************************************
  2. *
  3. * Description: This file is based on the SystemOfUnits provided
  4. * in the CLHEP library v1.2: The units remain the same.
  5. * It is just the naming conventions that are different:
  6. *
  7. * 1) No single letter unit:
  8. * : m --> meter
  9. * : s --> second
  10. * : g --> gram
  11. *
  12. * 2) All prefixes are spelled out explicitly (except electron Volt):
  13. * : ns --> nanosecond
  14. * : mm --> millimeter
  15. *
  16. * 3) All units with proper names follow the international standard
  17. * of being lower case:
  18. * : farad --> farad
  19. * : volt --> volt
  20. *
  21. * The basic units are :
  22. * centimeter (centimeter)
  23. * second (second)
  24. * Giga electron Volt (GeV)
  25. * positron charge (eplus)
  26. * degree Kelvin (kelvin)
  27. * the amount of substance (mole)
  28. * radian (radian)
  29. * steradian (steradian)
  30. ***************************************************************************/
  31. // #ifdef _VANILLA_ROOT_
  32. #ifndef HEP_SYSTEM_OF_UNITS_H
  33. #define HEP_SYSTEM_OF_UNITS_H
  34. // C++ headers
  35. #include <math.h>
  36. namespace units {
  37. // new macro for CLHEP SystemOfUnits: at end of file
  38. // ST_ADD_OLD_CLHEP_SYSTEM_OF_UNITS
  39. //
  40. // Length [L]
  41. //
  42. static const double millimeter = 0.1;
  43. static const double millimeter2 = millimeter*millimeter;
  44. static const double millimeter3 = millimeter*millimeter*millimeter;
  45. static const double centimeter = 10 * millimeter;
  46. static const double centimeter2 = centimeter*centimeter;
  47. static const double centimeter3 = centimeter*centimeter*centimeter;
  48. static const double meter = 100. * centimeter;
  49. static const double meter2 = meter*meter;
  50. static const double meter3 = meter*meter*meter;
  51. static const double kilometer = 1000. * meter;
  52. static const double kilometer2 = kilometer*kilometer;
  53. static const double kilometer3 = kilometer*kilometer*kilometer;
  54. static const double micrometer = 1.e-6 * meter;
  55. static const double nanometer = 1.e-9 * meter;
  56. static const double femtometer = 1.e-15 * meter;
  57. static const double fermi = 1 * femtometer;
  58. static const double barn = 1.e-28 * meter2;
  59. static const double millibarn = 1.e-3 * barn;
  60. static const double microbarn = 1.e-6 * barn;
  61. static const double nanobarn = 1.e-9 * barn;
  62. static const double inch = 2.54 * centimeter;
  63. //
  64. // Angle
  65. //
  66. static const double radian = 1.;
  67. static const double milliradian = 1.e-3 * radian;
  68. #ifndef __CINT__
  69. static const double degree = (M_PI / 180.0) * radian;
  70. #endif
  71. static const double steradian = 1.;
  72. //
  73. // Time [T]
  74. //
  75. static const double second = 1;
  76. static const double millisecond = 1.e-3 * second;
  77. static const double microsecond = 1.e-3 * millisecond;
  78. static const double nanosecond = 1.e-3 * microsecond;
  79. static const double hertz = 1. / second;
  80. static const double kilohertz = 1.e+3 * hertz;
  81. static const double Megahertz = 1.e+6 * hertz;
  82. // but these are also unambiguous and unlikely to be used as variable!
  83. static const double Hz = 1 * hertz;
  84. static const double kHz = 1 * kilohertz;
  85. static const double MHz = 1 * Megahertz;
  86. //
  87. // Electric charge [Q]
  88. //
  89. static const double eplus = 1.; // positron charge
  90. static const double e_SI = 1.60217733e-19; // positron charge in coulomb
  91. static const double coulomb = eplus / e_SI;
  92. //
  93. // Energy [E]
  94. //
  95. static const double Gigaelectronvolt = 1.;
  96. static const double Megaelectronvolt = 1.e-3 * Gigaelectronvolt;
  97. static const double electronvolt = 1.e-6 * Megaelectronvolt;
  98. static const double kiloelectronvolt = 1.e+3 * electronvolt;
  99. static const double Teraelectronvolt = 1.e+3 * Gigaelectronvolt;
  100. // but these are also unambiguous and unlikely to be used as variables
  101. static const double MeV = Megaelectronvolt;
  102. static const double eV = electronvolt;
  103. static const double keV = kiloelectronvolt;
  104. static const double GeV = Gigaelectronvolt;
  105. static const double TeV = Teraelectronvolt;
  106. static const double amu = 931.49406121 * MeV; // unified Atomic mass unit
  107. static const double joule = electronvolt / e_SI;
  108. //
  109. // Mass [E][T^2][L^-2]
  110. //
  111. static const double kilogram = joule*second*second / (meter*meter);
  112. static const double gram = 1.e-3 * kilogram;
  113. static const double milligram = 1.e-3 * gram;
  114. //
  115. // Power [E][T^-1]
  116. //
  117. static const double watt = joule / second;
  118. //
  119. // Force [E][L^-1]
  120. //
  121. static const double newton = joule / meter;
  122. //
  123. // Pressure [E][L^-3]
  124. //
  125. #ifndef __CINT__
  126. #define pascal hep_pascal // a trick to avoid warnings
  127. static const double hep_pascal = newton / meter2;
  128. #else
  129. static const double pascal = newton / meter2;
  130. #endif
  131. static const double bar = 100000 * pascal;
  132. static const double atmosphere = 101325 * pascal;
  133. //
  134. // Electric current [Q][T^-1]
  135. //
  136. static const double ampere = coulomb / second;
  137. //
  138. // Electric potential [E][Q^-1]
  139. //
  140. static const double Megavolt = MeV / eplus;
  141. static const double kilovolt = 1.e-3 * Megavolt;
  142. static const double volt = 1.e-6 * Megavolt;
  143. static const double millivolt = 1.e-3 * volt;
  144. //
  145. // Electric resistance [E][T][Q^-2]
  146. //
  147. static const double ohm = volt / ampere;
  148. //
  149. // Electric capacitance [Q^2][E^-1]
  150. //
  151. static const double farad = coulomb / volt;
  152. static const double millifarad = 1.e-3 * farad;
  153. static const double microfarad = 1.e-6 * farad;
  154. static const double nanofarad = 1.e-9 * farad;
  155. static const double picofarad = 1.e-12 * farad;
  156. //
  157. // Magnetic Flux [T][E][Q^-1]
  158. //
  159. static const double weber = volt*second;
  160. //
  161. // Magnetic Field [T][E][Q^-1][L^-2]
  162. //
  163. static const double tesla = volt*second / meter2;
  164. static const double gauss = 1.e-4 * tesla;
  165. static const double kilogauss = 1.e-1 * tesla;
  166. //
  167. // Inductance [T^2][E][Q^-2]
  168. //
  169. static const double henry = weber / ampere;
  170. //
  171. // Temperature
  172. //
  173. static const double kelvin = 1.;
  174. //
  175. // Amount of substance
  176. //
  177. static const double mole = 1.;
  178. //
  179. // Activity [T^-1]
  180. //
  181. static const double becquerel = 1. / second;
  182. static const double curie = 3.7e+10 * becquerel;
  183. //
  184. // Absorbed dose [L^2][T^-2]
  185. //
  186. static const double gray = joule / kilogram;
  187. //
  188. // Miscellaneous
  189. //
  190. static const double perCent = 0.01;
  191. static const double perThousand = 0.001;
  192. static const double perMillion = 0.000001;
  193. #ifdef ST_ADD_OLD_CLHEP_SYSTEM_OF_UNITS
  194. static const double mm = 0.1; // millimeter
  195. static const double mm2 = mm*mm;
  196. static const double mm3 = mm*mm*mm;
  197. static const double cm = 10. * mm; // centimeter
  198. static const double cm2 = cm*cm;
  199. static const double cm3 = cm*cm*cm;
  200. static const double m = 1000. * mm; // meter
  201. static const double m2 = m*m;
  202. static const double m3 = m*m*m;
  203. static const double km = 1000. * m; // kilometer
  204. static const double km2 = km*km;
  205. static const double km3 = km*km*km;
  206. static const double microm = 1.e-6 * m; // micro meter
  207. static const double nanom = 1.e-9 * m;
  208. //static const double fermi = 1.e-15*m;
  209. //
  210. // Angle
  211. //
  212. static const double rad = 1.; // radian
  213. static const double mrad = 1.e-3 * rad; // milliradian
  214. static const double deg = (M_PI / 180.0) * rad;
  215. static const double st = 1.; // steradian
  216. //
  217. // Time [T]
  218. //
  219. static const double s = 1; // second
  220. static const double ns = 1.e-9 * s; // nano second
  221. static const double ms = 1.e-3 * s; // milli second
  222. // Mass [E][T^2][L^-2]
  223. //
  224. static const double kg = joule*second*second / (meter*meter); // kg = 6.24150 e+24 * MeV*ns*ns/(mm*mm)
  225. static const double g = 1.e-3 * kg;
  226. static const double mg = 1.e-3 * g;
  227. #endif
  228. }
  229. using namespace units;
  230. #endif /* HEP_SYSTEM_OF_UNITS_H */
  231. // #endif //#ifdef _VANILLA_ROOT_