6 <contact>Kirill Chilikin (chilikin@lebedev.ru)</contact>
7 <description>Creation of KLM K0L validation plots.</description>
13 from ROOT
import Belle2
14 from ROOT
import TNamed
20 """ Class for creation of KLM K0L validation plots. """
22 def __init__(self, output_file, evtgen, check_eklm):
24 super(KLMK0LPlotModule, self).
__init__()
31 contact =
'Kirill Chilikin (chilikin@lebedev.ru)'
34 'Number of KLM clusters per 1 MC particle',
36 self.
hist_nkl.SetXTitle(
'KLM clusters')
38 functions = self.
hist_nkl.GetListOfFunctions()
39 functions.Add(TNamed(
'Description',
'Number of KLM clusters per 1 MC particle'))
40 functions.Add(TNamed(
'Check',
'No efficiency decrease or multiple candidates \
42 functions.Add(TNamed(
'Contact', contact))
43 functions.Add(TNamed(
'MetaOptions',
'shifter'))
46 'KLM K0L decay vertex X resolution',
50 functions = self.
hist_xres.GetListOfFunctions()
51 functions.Add(TNamed(
'Description',
'X resolution'))
52 functions.Add(TNamed(
'Check',
'No bias, resolution ~ 16 cm.'))
53 functions.Add(TNamed(
'Contact', contact))
54 functions.Add(TNamed(
'MetaOptions',
'shifter'))
57 'KLM K0L decay vertex Y resolution',
61 functions = self.
hist_yres.GetListOfFunctions()
62 functions.Add(TNamed(
'Description',
'Y resolution'))
63 functions.Add(TNamed(
'Check',
'No bias, resolution ~ 16 cm.'))
64 functions.Add(TNamed(
'Contact', contact))
65 functions.Add(TNamed(
'MetaOptions',
'shifter'))
68 'KLM K0L decay vertex Z resolution',
72 functions = self.
hist_zres.GetListOfFunctions()
73 functions.Add(TNamed(
'Description',
'Z resolution'))
74 functions.Add(TNamed(
'Check',
'No bias, resolution ~ 16 cm.'))
75 functions.Add(TNamed(
'Contact', contact))
76 functions.Add(TNamed(
'MetaOptions',
'shifter'))
79 'KLM K0L decay time resolution',
83 functions = self.
hist_tres.GetListOfFunctions()
84 functions.Add(TNamed(
'Description',
'Time resolution'))
85 functions.Add(TNamed(
'Check',
'No bias.'))
86 functions.Add(TNamed(
'Contact', contact))
87 functions.Add(TNamed(
'MetaOptions',
'shifter'))
90 'KLM K0L momentum resolution',
94 functions = self.
hist_pres.GetListOfFunctions()
95 functions.Add(TNamed(
'Description',
'Momentum resolution'))
96 functions.Add(TNamed(
'Check',
'No bias.'))
97 functions.Add(TNamed(
'Contact', contact))
98 functions.Add(TNamed(
'MetaOptions',
'shifter'))
101 'KLM K0L momentum theta resolution',
105 functions = self.
hist_ptres.GetListOfFunctions()
106 functions.Add(TNamed(
'Description',
'Momentum theta resolution'))
107 functions.Add(TNamed(
'Check',
'No bias, resolution ~ 0.06'))
108 functions.Add(TNamed(
'Contact', contact))
109 functions.Add(TNamed(
'MetaOptions',
'shifter'))
112 'KLM K0L momentum phi resolution',
116 functions = self.
hist_ppres.GetListOfFunctions()
117 functions.Add(TNamed(
'Description',
'Momentum phi resolution'))
118 functions.Add(TNamed(
'Check',
'No bias, resolution ~ 0.07'))
119 functions.Add(TNamed(
'Contact', contact))
120 functions.Add(TNamed(
'MetaOptions',
'shifter'))
123 'KLM K0L coordinates covariance matrix',
133 functions.Add(TNamed(
'Description',
'Momentum phi resolution'))
134 functions.Add(TNamed(
'Check',
'No large off-diagonal elements.'))
135 functions.Add(TNamed(
'Contact', contact))
136 functions.Add(TNamed(
'MetaOptions',
'shifter'))
139 'KLM K0L correlation matrix',
153 functions.Add(TNamed(
'Description',
'Momentum phi resolution'))
154 functions.Add(TNamed(
'Check',
'No large off-diagonal elements.'))
155 functions.Add(TNamed(
'Contact', contact))
156 functions.Add(TNamed(
'MetaOptions',
'shifter'))
167 """ Event function. """
169 for mc_particle
in mc_particles:
171 if (mc_particle.getPDG() != 130):
175 b_pdg = abs(mc_particle.getMother().getPDG())
176 if (not(b_pdg == 511)):
179 if (mc_particle.getProductionTime() > 0):
181 vertex = mc_particle.getDecayVertex()
182 time = mc_particle.getDecayTime()
183 momentum = mc_particle.getMomentum()
188 r = math.sqrt(x * x + y * y)
189 if (r < 132.5
or r > 329.0):
191 if (abs(x) < 8.2
or abs(y) < 8.2):
193 if (not((z > -315.1
and z < -183.0)
or
194 (z > 277.0
and z < 409.1))):
196 klm_clusters = mc_particle.getRelationsFrom(
'KLMClusters')
197 self.
hist_nkl.Fill(len(klm_clusters))
198 for klm_cluster
in klm_clusters:
199 vertex_k = klm_cluster.getClusterPosition() - vertex
200 self.
vertex.append(vertex_k)
202 self.
momentum.append(klm_cluster.getMomentumMag())
204 klm_cluster.getMomentumMag()
205 time_k = klm_cluster.getTime()
206 momentum_k = klm_cluster.getMomentum().Vect()
211 self.
hist_pres.Fill(momentum_k.Mag() - momentum.Mag())
212 self.
hist_ptres.Fill(momentum_k.Theta() - momentum.Theta())
213 self.
hist_ppres.Fill(momentum_k.Phi() - momentum.Phi())
216 """ Termination function. """
220 cov_mat = numpy.zeros((4, 4))
221 cov_mat_err = numpy.zeros((4, 4))
222 corr_mat = numpy.zeros((4, 4))
223 corr_mat_err = numpy.zeros((4, 4))
224 for i
in range(len(self.
vertex)):
225 cov_mat[0][0] = cov_mat[0][0] + \
228 cov_mat[0][1] = cov_mat[0][1] + \
231 cov_mat[0][2] = cov_mat[0][2] + \
234 cov_mat[0][3] = cov_mat[0][3] + \
237 cov_mat[1][1] = cov_mat[1][1] + \
240 cov_mat[1][2] = cov_mat[1][2] + \
243 cov_mat[1][3] = cov_mat[1][3] + \
246 cov_mat[2][2] = cov_mat[2][2] + \
249 cov_mat[2][3] = cov_mat[2][3] + \
252 cov_mat[3][3] = cov_mat[3][3] + \
255 for i
in range(0, 4):
256 for j
in range(i, 4):
257 cov_mat[i][j] = cov_mat[i][j] / (len(self.
vertex) - 1)
258 for i
in range(len(self.
vertex)):
259 cov_mat_err[0][0] = cov_mat_err[0][0] + \
262 cov_mat_err[0][1] = cov_mat_err[0][1] + \
265 cov_mat_err[0][2] = cov_mat_err[0][2] + \
268 cov_mat_err[0][3] = cov_mat_err[0][3] + \
271 cov_mat_err[1][1] = cov_mat_err[1][1] + \
274 cov_mat_err[1][2] = cov_mat_err[1][2] + \
277 cov_mat_err[1][3] = cov_mat_err[1][3] + \
280 cov_mat_err[2][2] = cov_mat_err[2][2] + \
283 cov_mat_err[2][3] = cov_mat_err[2][3] + \
286 cov_mat_err[3][3] = cov_mat_err[3][3] + \
289 for i
in range(0, 4):
290 for j
in range(i, 4):
291 cov_mat_err[i][j] = \
292 math.sqrt(cov_mat_err[i][j] /
306 for i
in range(0, 4):
307 for j
in range(i, 4):
308 corr_mat[i][j] = cov_mat[i][j] / \
309 math.sqrt(cov_mat[i][i]) / math.sqrt(cov_mat[j][j])
311 corr_mat_err[i][j] = cov_mat_err[i][j] / cov_mat[i][j] * \