Belle II Software development
variables.py
1
8"""
9Physics variable metadata classes and unit definitions for alignment validation.
10"""
11
12
13class Unit:
14 """Pair of display/residual unit strings and the conversion factor between them.
15
16 Parameters
17 ----------
18 name : str
19 Unit label used on standard axes (e.g. ``" [cm]"``).
20 dname : str
21 Unit label used on residual/difference axes, after applying the
22 conversion factor (e.g. ``r" [$\\mu$m]"``).
23 multiplier : float
24 Factor to convert from ``name`` units to ``dname`` units
25 (e.g. ``1e4`` to go from cm to μm).
26 """
27
28 def __init__(self, name, dname, multiplier):
29 """Initialize a unit definition.
30
31 Parameters
32 ----------
33 name : str
34 Unit label used on standard axes (e.g. ``" [cm]"``).
35 dname : str
36 Unit label used on residual/difference axes.
37 multiplier : float
38 Conversion factor from ``name`` units to ``dname`` units.
39 """
40
41 self.name = name
42
43 self.dname = dname
44
45 self.convert = multiplier
46
47
49 """Metadata for a scalar observable stored in a single ROOT branch per event.
50
51 Parameters
52 ----------
53 name : str
54 ROOT branch name.
55 latex : str
56 LaTeX string for axis labels (e.g. ``r"$M_{inv}$"``).
57 unit : Unit
58 Unit instance describing display and residual units.
59 plaintext : str
60 Short plain-text identifier used for file names (e.g. ``"run"``).
61 """
62
63 def __init__(self, name, latex, unit, plaintext):
64 """Initialize a global variable description.
65
66 Parameters
67 ----------
68 name : str
69 ROOT branch name.
70 latex : str
71 LaTeX string for axis labels.
72 unit : Unit
73 Unit instance describing display and residual units.
74 plaintext : str
75 Short plain-text identifier used for file names.
76 """
77
78 self.name = name
79
80 self.latex = latex
81
82 self.unit = unit
83
84 self.plaintext = plaintext
85
86 def getName(self):
87 """Return a list containing the single ROOT branch name.
88
89 Returns
90 -------
91 list of str
92 """
93 return [self.name]
94
95
97 """Metadata for an observable with one ROOT branch per track.
98
99 Used for two-track events (cosmics, dimuons) where each track has its
100 own branch.
101
102 Parameters
103 ----------
104 name1 : str
105 ROOT branch name for the first track.
106 name2 : str
107 ROOT branch name for the second track.
108 latex : str
109 LaTeX string for axis labels (e.g. ``r"d$_0$"``).
110 unit : Unit
111 Unit instance describing display and residual units.
112 plaintext : str
113 Short plain-text identifier used for file names (e.g. ``"d"``).
114 """
115
116 def __init__(self, name1, name2, latex, unit, plaintext):
117 """Initialize a two-track variable description.
118
119 Parameters
120 ----------
121 name1 : str
122 ROOT branch name for the first track.
123 name2 : str
124 ROOT branch name for the second track.
125 latex : str
126 LaTeX string for axis labels.
127 unit : Unit
128 Unit instance describing display and residual units.
129 plaintext : str
130 Short plain-text identifier used for file names.
131 """
132
133 self.name1 = name1
134
135 self.name2 = name2
136
137 self.latex = latex
138
139 self.unit = unit
140
141 self.plaintext = plaintext
142
143 def getName(self):
144 """Return a list of both ROOT branch names (track 1 then track 2).
145
146 Returns
147 -------
148 list of str
149 """
150 return [self.name1, self.name2]
151
152
153# Unit instances
154
155s = Unit(" [s]", "s", 1)
156
157cm = Unit(" [cm]", r" [$\mu$m]", 1e4)
158
159rad = Unit(" [rad]", " [mrad]", 1e3)
160
161unit = Unit(" [1]", r" [$10^{-3}$]", 1e3)
162
163inverse_cm = Unit(" [1/cm]", r" [1/cm $\cdot 10^{-4}$]", 1e4)
164
165gev = Unit(" [GeV/c]", r" [GeV/c]", 1)
plaintext
Plain-text identifier for file naming.
Definition variables.py:84
unit
Unit descriptor for plotting and residuals.
Definition variables.py:82
latex
LaTeX string for axis labels.
Definition variables.py:80
__init__(self, name, latex, unit, plaintext)
Definition variables.py:63
plaintext
Plain-text identifier for file naming.
Definition variables.py:141
name1
ROOT branch name for the first track.
Definition variables.py:133
unit
Unit descriptor for plotting and residuals.
Definition variables.py:139
__init__(self, name1, name2, latex, unit, plaintext)
Definition variables.py:116
latex
LaTeX string for axis labels.
Definition variables.py:137
name2
ROOT branch name for the second track.
Definition variables.py:135
basf2 (Belle II Analysis Software Framework) # Author: The Belle II Collaboration # # See git log for...
Definition variables.py:13
convert
Conversion factor from name to dname units.
Definition variables.py:45
dname
Unit name used for residual axes.
Definition variables.py:43
__init__(self, name, dname, multiplier)
Definition variables.py:28
name
Unit name shown in plots.
Definition variables.py:41