JAPAn
Just Another Parity Analyzer
Loading...
Searching...
No Matches
QwUnits.h
Go to the documentation of this file.
1/*!
2 * \file QwUnits.h
3 * \brief Physical units and constants for Qweak analysis
4 */
5
6#pragma once
7
8/**
9 * \ingroup QwAnalysis
10 *
11 * \section unitsoverview Units in the QwAnalysis framework
12 *
13 * As more and more analyzers start contributing code to the Qweak analysis
14 * code, it is important to use some conventions to avoid confusion. One of
15 * the conventions is the use of a standard system of coordinates. The other
16 * is a unified set of units. This way we will avoid errors when angles are
17 * not converted from degrees to radians, or centimeters and inches are in
18 * mixed up.
19 *
20 * The basic units in the QwAnalysis framework are:
21 * \li Length: <b>cm</b>
22 * \li Time: <b>ms</b>
23 * \li Energy: <b>MeV</b>
24 * \li Angles: <b>rad</b>
25 * \li Magnetic field: <b>T</b>
26 *
27 * How are these units to be used? Any variable that is being used inside
28 * subsystems and <b>especially when passing information to other subsystems</b>
29 * should have values in these units.
30 *
31 * This does not mean that every single constant has to be defined in these
32 * units, or that output has to use these units. A set of conversion constants
33 * is defined to make life easier.
34 *
35 * Take as an example the magnetic field map. The values stored in the map file
36 * by the external program are in kG. To convert those values, we would write:
37 * \code
38 * double bx, by, bz;
39 * mapfile >> bx >> by >> bz; // read values
40 * bx *= Qw::kG; by *= Qw::kG; bz *= Qw::kG; // define the units (kG)
41 * \endcode
42 * From now on, the values in bx, by, bz are in standard Qweak units (T). To
43 * write out the values in Gauss we write:
44 * \code
45 * cout << bx/Qw::G << "," << by/Qw::G << "," << bz/Qw::G << " G" << endl;
46 * \endcode
47 * For Tesla we would write
48 * \code
49 * cout << bx/Qw::T << "," << by/Qw::T << "," << bz/Qw::T << " T" << endl;
50 * \endcode
51 *
52 * If there are hard-coded values in the analyzer (which should be avoided),
53 * we should use these units to define them:
54 * \code
55 * const double position_r3 = 398.8 * Qw::cm;
56 * const double helicity_window = 1.0 * Qw::ms;
57 * const double noise_frequency = 60.0 * Qw::Hz;
58 * \endcode
59 */
60namespace Qw {
61
62 /// Length units: base unit is mm
63 //@{
64 // metric
65 static const double mm = 1.0;
66 static const double um = 1.0e-3 * mm;
67 static const double cm = 1.0e1 * mm;
68 static const double m = 1.0e2 * cm;
69 static const double km = 1.0e3 * m;
70 // imperial
71 static const double in = 2.54 * cm;
72 static const double mil = 0.001 * in;
73 //@}
74
75 /// Time units: base unit is ms
76 //@{
77 static const double ms = 1.0;
78 static const double us = 1.0e-3 * ms;
79 static const double ns = 1.0e-6 * ms;
80 static const double sec = 1.0e3 * ms; // SI notation is s, but sec avoids ambiguity
81 static const double min = 60.0 * sec;
82 static const double hour = 60.0 * min;
83 static const double day = 24.0 * hour;
84 //@}
85
86 /// Frequency units: base unit is kHz
87 //@{
88 static const double Hz = 1.0 / sec;
89 static const double kHz = 1.0 / ms;
90 static const double MHz = 1.0e3 * kHz;
91 //@}
92
93 //@{
94 /// Energy: base unit is MeV
95 static const double V = 1.0;
96 static const double e = 1.0e-6;
97 static const double eV = 1.0e-6;
98 static const double keV = 1.0e-3;
99 static const double MeV = 1.0;
100 static const double GeV = 1.0e3;
101 static const double MeV2 = MeV * MeV;
102 static const double GeV2 = GeV * GeV;
103 //@}
104
105 //@{
106 /// Angles: base unit is radian
107 static const double pi = 3.14159265;
108 static const double deg2rad = pi / 180.0;
109 static const double rad2deg = 180.0 / pi;
110 static const double rad = 1.0;
111 static const double deg = deg2rad;
112 //@}
113
114 //@{
115 /// Magnetic field: base unit is T
116 static const double T = V * sec / (m * m);
117 static const double G = 1.0e-4 * T;
118 static const double kG = 1.0e3 * G;
119 //@}
120
121 //@{
122 /// Beam current: base unit is microamp
123 static const double uA = 1.0;
124 //@}
125
126 //@{
127 /// Signal levels: base unit is volt, and is already defined above
128 static const double V_uA = V/uA; ///< Signal volts per microamp
129 static const double mV_uA = 1.0e-3 * V_uA; ///< Signal volts per microamp
130 //@}
131
132 //@{
133 /// Physical constants
134 static const double c = 299792458. * m / sec; ///< Speed of light
135 static const double Mp = 938.272013 * MeV; ///< Mass of the proton
136 //@}
137
138 //@{
139 //Asymmetry: base unit is 1
140 static const double ppm=1e-6;
141 static const double ppb=1e-9;
142 //@}
143
144} // namespace Qw
Definition QwColor.h:74
static const double G
Definition QwUnits.h:117
static const double GeV
Definition QwUnits.h:100
static const double eV
Definition QwUnits.h:97
static const double min
Definition QwUnits.h:81
static const double ppm
Definition QwUnits.h:140
static const double sec
Definition QwUnits.h:80
static const double ppb
Definition QwUnits.h:141
static const double rad
Definition QwUnits.h:110
static const double T
Magnetic field: base unit is T.
Definition QwUnits.h:116
static const double e
Definition QwUnits.h:96
static const double V_uA
Signal levels: base unit is volt, and is already defined above.
Definition QwUnits.h:128
static const double uA
Beam current: base unit is microamp.
Definition QwUnits.h:123
static const double um
Definition QwUnits.h:66
static const double ms
Time units: base unit is ms.
Definition QwUnits.h:77
static const double keV
Definition QwUnits.h:98
static const double ns
Definition QwUnits.h:79
static const double mV_uA
Signal volts per microamp.
Definition QwUnits.h:129
static const double MeV2
Definition QwUnits.h:101
static const double kG
Definition QwUnits.h:118
static const double deg
Definition QwUnits.h:111
static const double kHz
Definition QwUnits.h:89
static const double c
Physical constants.
Definition QwUnits.h:134
static const double Mp
Mass of the proton.
Definition QwUnits.h:135
static const double Hz
Frequency units: base unit is kHz.
Definition QwUnits.h:88
static const double cm
Definition QwUnits.h:67
static const double in
Definition QwUnits.h:71
static const double V
Energy: base unit is MeV.
Definition QwUnits.h:95
static const double mm
Length units: base unit is mm.
Definition QwUnits.h:65
static const double MHz
Definition QwUnits.h:90
static const double deg2rad
Definition QwUnits.h:108
static const double pi
Angles: base unit is radian.
Definition QwUnits.h:107
static const double mil
Definition QwUnits.h:72
static const double km
Definition QwUnits.h:69
static const double rad2deg
Definition QwUnits.h:109
static const double day
Definition QwUnits.h:83
static const double m
Definition QwUnits.h:68
static const double hour
Definition QwUnits.h:82
static const double us
Definition QwUnits.h:78
static const double MeV
Definition QwUnits.h:99
static const double GeV2
Definition QwUnits.h:102