StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
SystemOfUnits.h
1 /***************************************************************************
2  *
3  * $Id: SystemOfUnits.h,v 1.7 2012/06/11 15:29:27 fisyak Exp $
4  *
5  * Author: blasiuk adapted from CLHEP
6  ***************************************************************************
7  *
8  * Description: This file is based on the SystemOfUnits provided
9  * in the CLHEP library v1.2: The units remain the same.
10  * It is just the naming conventions that are different:
11  *
12  * 1) No single letter unit:
13  * : m --> meter
14  * : s --> second
15  * : g --> gram
16  *
17  * 2) All prefixes are spelled out explicitly (except electron Volt):
18  * : ns --> nanosecond
19  * : mm --> millimeter
20  *
21  * 3) All units with proper names follow the international standard
22  * of being lower case:
23  * : farad --> farad
24  * : volt --> volt
25  *
26  * The basic units are :
27  * centimeter (centimeter)
28  * second (second)
29  * Giga electron Volt (GeV)
30  * positron charge (eplus)
31  * degree Kelvin (kelvin)
32  * the amount of substance (mole)
33  * radian (radian)
34  * steradian (steradian)
35  ***************************************************************************
36  *
37  * $Log: SystemOfUnits.h,v $
38  * Revision 1.7 2012/06/11 15:29:27 fisyak
39  * std namespace
40  *
41  * Revision 1.6 2007/08/17 16:04:46 fine
42  * Eliminate the redundant semicolon - causes the compilation error with the pedantic compilation flag
43  *
44  * Revision 1.5 2003/09/02 17:59:35 perev
45  * gcc 3.2 updates + WarnOff
46  *
47  * Revision 1.4 1999/03/22 16:21:38 fisyak
48  * Add anti CINT flags
49  *
50  * Revision 1.3 1999/03/11 14:53:07 ullrich
51  * Added definition of inch.
52  *
53  * Revision 1.2 1999/03/02 20:15:08 ullrich
54  * Added millivolt.
55  *
56  * Revision 1.1 1999/01/30 03:59:06 fisyak
57  * Root Version of StarClassLibrary
58  *
59  * Revision 1.1 1999/01/23 00:28:08 ullrich
60  * Initial Revision
61  *
62  **************************************************************************/
63 #ifndef HEP_SYSTEM_OF_UNITS_H
64 #define HEP_SYSTEM_OF_UNITS_H
65 
66 #include <math.h>
67 
68 namespace units {
69  // new macro for CLHEP SystemOfUnits: at end of file
70  // ST_ADD_OLD_CLHEP_SYSTEM_OF_UNITS
71  //
72  // Length [L]
73  //
74  static const double millimeter = 0.1;
75  static const double millimeter2 = millimeter*millimeter;
76  static const double millimeter3 = millimeter*millimeter*millimeter;
77 
78  static const double centimeter = 10*millimeter;
79  static const double centimeter2 = centimeter*centimeter;
80  static const double centimeter3 = centimeter*centimeter*centimeter;
81 
82  static const double meter = 100.*centimeter;
83  static const double meter2 = meter*meter;
84  static const double meter3 = meter*meter*meter;
85 
86  static const double kilometer = 1000.*meter;
87  static const double kilometer2 = kilometer*kilometer;
88  static const double kilometer3 = kilometer*kilometer*kilometer;
89 
90  static const double micrometer = 1.e-6*meter;
91  static const double nanometer = 1.e-9*meter;
92  static const double femtometer = 1.e-15*meter;
93  static const double fermi = 1*femtometer;
94 
95  static const double barn = 1.e-28*meter2;
96  static const double millibarn = 1.e-3*barn;
97  static const double microbarn = 1.e-6*barn;
98  static const double nanobarn = 1.e-9*barn;
99  static const double inch = 2.54*centimeter;
100 
101  //
102  // Angle
103  //
104  static const double radian = 1.;
105  static const double milliradian = 1.e-3*radian;
106 #ifndef __CINT__
107  static const double degree = (M_PI/180.0)*radian;
108 #endif
109  static const double steradian = 1.;
110 
111  //
112  // Time [T]
113  //
114  static const double second = 1;
115  static const double millisecond = 1.e-3*second;
116  static const double microsecond = 1.e-3*millisecond;
117  static const double nanosecond = 1.e-3*microsecond;
118 
119  static const double hertz = 1./second;
120  static const double kilohertz = 1.e+3*hertz;
121  static const double Megahertz = 1.e+6*hertz;
122 
123  // but these are also unambiguous and unlikely to be used as variable!
124  static const double Hz = 1*hertz;
125  static const double kHz = 1*kilohertz;
126  static const double MHz = 1*Megahertz;
127 
128  //
129  // Electric charge [Q]
130  //
131  static const double eplus = 1. ; // positron charge
132  static const double e_SI = 1.60217733e-19; // positron charge in coulomb
133  static const double coulomb = eplus/e_SI;
134 
135  //
136  // Energy [E]
137  //
138  static const double Gigaelectronvolt = 1.;
139  static const double Megaelectronvolt = 1.e-3*Gigaelectronvolt;
140  static const double electronvolt = 1.e-6*Megaelectronvolt;
141  static const double kiloelectronvolt = 1.e+3*electronvolt;
142  static const double Teraelectronvolt = 1.e+3*Gigaelectronvolt;
143 
144  // but these are also unambiguous and unlikely to be used as variables
145  static const double MeV = Megaelectronvolt;
146  static const double eV = electronvolt;
147  static const double keV = kiloelectronvolt;
148  static const double GeV = Gigaelectronvolt;
149  static const double TeV = Teraelectronvolt;
150  static const double amu = 931.49406121 * MeV;// unified Atomic mass unit
151  static const double joule = electronvolt/e_SI;
152 
153  //
154  // Mass [E][T^2][L^-2]
155  //
156  static const double kilogram = joule*second*second/(meter*meter);
157  static const double gram = 1.e-3*kilogram;
158  static const double milligram = 1.e-3*gram;
159 
160  //
161  // Power [E][T^-1]
162  //
163  static const double watt = joule/second;
164 
165  //
166  // Force [E][L^-1]
167  //
168  static const double newton = joule/meter;
169 
170  //
171  // Pressure [E][L^-3]
172  //
173 #ifndef __CINT__
174 #define pascal hep_pascal // a trick to avoid warnings
175  static const double hep_pascal = newton/meter2;
176 #else
177  static const double pascal = newton/meter2;
178 #endif
179  static const double bar = 100000*pascal;
180  static const double atmosphere = 101325*pascal;
181 
182  //
183  // Electric current [Q][T^-1]
184  //
185  static const double ampere = coulomb/second;
186 
187  //
188  // Electric potential [E][Q^-1]
189  //
190  static const double Megavolt = MeV/eplus;
191  static const double kilovolt = 1.e-3*Megavolt;
192  static const double volt = 1.e-6*Megavolt;
193  static const double millivolt = 1.e-3*volt;
194 
195  //
196  // Electric resistance [E][T][Q^-2]
197  //
198  static const double ohm = volt/ampere;
199 
200  //
201  // Electric capacitance [Q^2][E^-1]
202  //
203  static const double farad = coulomb/volt;
204  static const double millifarad = 1.e-3*farad;
205  static const double microfarad = 1.e-6*farad;
206  static const double nanofarad = 1.e-9*farad;
207  static const double picofarad = 1.e-12*farad;
208 
209  //
210  // Magnetic Flux [T][E][Q^-1]
211  //
212  static const double weber = volt*second;
213 
214  //
215  // Magnetic Field [T][E][Q^-1][L^-2]
216  //
217  static const double tesla = volt*second/meter2;
218 
219  static const double gauss = 1.e-4*tesla;
220  static const double kilogauss = 1.e-1*tesla;
221 
222  //
223  // Inductance [T^2][E][Q^-2]
224  //
225  static const double henry = weber/ampere;
226 
227  //
228  // Temperature
229  //
230  static const double kelvin = 1.;
231 
232  //
233  // Amount of substance
234  //
235  static const double mole = 1.;
236 
237  //
238  // Activity [T^-1]
239  //
240  static const double becquerel = 1./second;
241  static const double curie = 3.7e+10 * becquerel;
242 
243  //
244  // Absorbed dose [L^2][T^-2]
245  //
246  static const double gray = joule/kilogram ;
247 
248  //
249  // Miscellaneous
250  //
251  static const double perCent = 0.01 ;
252  static const double perThousand = 0.001;
253  static const double perMillion = 0.000001;
254 
255 #ifdef ST_ADD_OLD_CLHEP_SYSTEM_OF_UNITS
256 
257  static const double mm = 0.1; // millimeter
258  static const double mm2 = mm*mm;
259  static const double mm3 = mm*mm*mm;
260 
261  static const double cm = 10.*mm; // centimeter
262  static const double cm2 = cm*cm;
263  static const double cm3 = cm*cm*cm;
264 
265  static const double m = 1000.*mm; // meter
266  static const double m2 = m*m;
267  static const double m3 = m*m*m;
268 
269  static const double km = 1000.*m; // kilometer
270  static const double km2 = km*km;
271  static const double km3 = km*km*km;
272 
273  static const double microm = 1.e-6*m; // micro meter
274  static const double nanom = 1.e-9*m;
275  //static const double fermi = 1.e-15*m;
276 
277  //
278  // Angle
279  //
280  static const double rad = 1.; // radian
281  static const double mrad = 1.e-3*rad; // milliradian
282  static const double deg = (M_PI/180.0)*rad;
283 
284  static const double st = 1.; // steradian
285 
286  //
287  // Time [T]
288  //
289  static const double s = 1; // second
290  static const double ns = 1.e-9*s; // nano second
291  static const double ms = 1.e-3*s; // milli second
292 
293  // Mass [E][T^2][L^-2]
294  //
295  static const double kg = joule*second*second/(meter*meter); // kg = 6.24150 e+24 * MeV*ns*ns/(mm*mm)
296  static const double g = 1.e-3*kg;
297  static const double mg = 1.e-3*g;
298 
299 #endif
300 
301 }
302 using namespace units;
303 #endif /* HEP_SYSTEM_OF_UNITS_H */