13 <noexecute>Definition of plotting class</noexecute>
14 <description>Creation of KLM K0L validation plots.</description>
20from ROOT import Belle2
21from ROOT import TNamed
22from ROOT.Math import XYZVector
27class KLMK0LPlotModule(basf2.Module):
28 """ Class for creation of KLM K0L validation plots. """
30 def __init__(self, output_file, evtgen, check_eklm):
39 contact =
'Leo Piilonen (piilonen@vt.edu)'
42 'Number of KLM clusters per 1 MC particle',
44 self.
hist_nkl.SetXTitle(
'KLM clusters')
46 functions = self.
hist_nkl.GetListOfFunctions()
47 functions.Add(TNamed(
'Description',
'Number of KLM clusters per 1 MC particle'))
48 functions.Add(TNamed(
'Check',
'No efficiency decrease or multiple candidates \
50 functions.Add(TNamed(
'Contact', contact))
51 functions.Add(TNamed(
'MetaOptions',
'shifter'))
54 'KLM K0L decay vertex X resolution',
58 functions = self.
hist_xres.GetListOfFunctions()
59 functions.Add(TNamed(
'Description',
'X resolution'))
60 functions.Add(TNamed(
'Check',
'No bias, resolution ~ 16 cm.'))
61 functions.Add(TNamed(
'Contact', contact))
62 functions.Add(TNamed(
'MetaOptions',
'shifter'))
65 'KLM K0L decay vertex Y resolution',
69 functions = self.
hist_yres.GetListOfFunctions()
70 functions.Add(TNamed(
'Description',
'Y resolution'))
71 functions.Add(TNamed(
'Check',
'No bias, resolution ~ 16 cm.'))
72 functions.Add(TNamed(
'Contact', contact))
73 functions.Add(TNamed(
'MetaOptions',
'shifter'))
76 'KLM K0L decay vertex Z resolution',
80 functions = self.
hist_zres.GetListOfFunctions()
81 functions.Add(TNamed(
'Description',
'Z resolution'))
82 functions.Add(TNamed(
'Check',
'No bias, resolution ~ 16 cm.'))
83 functions.Add(TNamed(
'Contact', contact))
84 functions.Add(TNamed(
'MetaOptions',
'shifter'))
87 'KLM K0L decay time resolution',
91 functions = self.
hist_tres.GetListOfFunctions()
92 functions.Add(TNamed(
'Description',
'Time resolution'))
93 functions.Add(TNamed(
'Check',
'No bias.'))
94 functions.Add(TNamed(
'Contact', contact))
95 functions.Add(TNamed(
'MetaOptions',
'shifter'))
98 'KLM K0L momentum resolution',
102 functions = self.
hist_pres.GetListOfFunctions()
103 functions.Add(TNamed(
'Description',
'Momentum resolution'))
104 functions.Add(TNamed(
'Check',
'No bias.'))
105 functions.Add(TNamed(
'Contact', contact))
106 functions.Add(TNamed(
'MetaOptions',
'shifter'))
109 'KLM K0L momentum theta resolution',
113 functions = self.
hist_ptres.GetListOfFunctions()
114 functions.Add(TNamed(
'Description',
'Momentum theta resolution'))
115 functions.Add(TNamed(
'Check',
'No bias, resolution ~ 0.06'))
116 functions.Add(TNamed(
'Contact', contact))
117 functions.Add(TNamed(
'MetaOptions',
'shifter'))
120 'KLM K0L momentum phi resolution',
124 functions = self.
hist_ppres.GetListOfFunctions()
125 functions.Add(TNamed(
'Description',
'Momentum phi resolution'))
126 functions.Add(TNamed(
'Check',
'No bias, resolution ~ 0.07'))
127 functions.Add(TNamed(
'Contact', contact))
128 functions.Add(TNamed(
'MetaOptions',
'shifter'))
131 'KLM K0L coordinates covariance matrix',
141 functions.Add(TNamed(
'Description',
'Momentum phi resolution'))
142 functions.Add(TNamed(
'Check',
'No large off-diagonal elements.'))
143 functions.Add(TNamed(
'Contact', contact))
144 functions.Add(TNamed(
'MetaOptions',
'shifter'))
147 'KLM K0L correlation matrix',
161 functions.Add(TNamed(
'Description',
'Momentum phi resolution'))
162 functions.Add(TNamed(
'Check',
'No large off-diagonal elements.'))
163 functions.Add(TNamed(
'Contact', contact))
164 functions.Add(TNamed(
'MetaOptions',
'shifter'))
175 """ Event function. """
177 for mc_particle
in mc_particles:
179 if (mc_particle.getPDG() != 130):
183 b_pdg = abs(mc_particle.getMother().getPDG())
184 if (not(b_pdg == 511)):
187 if (mc_particle.getProductionTime() > 0):
189 vertex = mc_particle.getDecayVertex()
190 time = mc_particle.getDecayTime()
191 momentum = mc_particle.getMomentum()
196 r = math.sqrt(x * x + y * y)
197 if (r < 132.5
or r > 329.0):
199 if (abs(x) < 8.2
or abs(y) < 8.2):
201 if (not((z > -315.1
and z < -183.0)
or
202 (z > 277.0
and z < 409.1))):
204 klm_clusters = mc_particle.getRelationsFrom(
'KLMClusters')
205 self.
hist_nkl.Fill(len(klm_clusters))
206 for klm_cluster
in klm_clusters:
207 vertex_k = XYZVector(klm_cluster.getClusterPosition()) - vertex
208 self.
vertex.append(vertex_k)
210 self.
momentum.append(klm_cluster.getMomentumMag())
212 klm_cluster.getMomentumMag()
213 time_k = klm_cluster.getTime()
214 four_momentum_k = klm_cluster.getMomentum()
219 self.
hist_pres.Fill(four_momentum_k.P() - momentum.R())
220 self.
hist_ptres.Fill(four_momentum_k.Theta() - momentum.Theta())
221 self.
hist_ppres.Fill(four_momentum_k.Phi() - momentum.Phi())
224 """ Termination function. """
228 cov_mat = numpy.zeros((4, 4))
229 cov_mat_err = numpy.zeros((4, 4))
230 corr_mat = numpy.zeros((4, 4))
231 corr_mat_err = numpy.zeros((4, 4))
232 for i
in range(len(self.
vertex)):
233 cov_mat[0][0] = cov_mat[0][0] + \
236 cov_mat[0][1] = cov_mat[0][1] + \
239 cov_mat[0][2] = cov_mat[0][2] + \
242 cov_mat[0][3] = cov_mat[0][3] + \
245 cov_mat[1][1] = cov_mat[1][1] + \
248 cov_mat[1][2] = cov_mat[1][2] + \
251 cov_mat[1][3] = cov_mat[1][3] + \
254 cov_mat[2][2] = cov_mat[2][2] + \
257 cov_mat[2][3] = cov_mat[2][3] + \
260 cov_mat[3][3] = cov_mat[3][3] + \
263 for i
in range(0, 4):
264 for j
in range(i, 4):
265 cov_mat[i][j] = cov_mat[i][j] / (len(self.
vertex) - 1)
266 for i
in range(len(self.
vertex)):
267 cov_mat_err[0][0] = cov_mat_err[0][0] + \
270 cov_mat_err[0][1] = cov_mat_err[0][1] + \
273 cov_mat_err[0][2] = cov_mat_err[0][2] + \
276 cov_mat_err[0][3] = cov_mat_err[0][3] + \
279 cov_mat_err[1][1] = cov_mat_err[1][1] + \
282 cov_mat_err[1][2] = cov_mat_err[1][2] + \
285 cov_mat_err[1][3] = cov_mat_err[1][3] + \
288 cov_mat_err[2][2] = cov_mat_err[2][2] + \
291 cov_mat_err[2][3] = cov_mat_err[2][3] + \
294 cov_mat_err[3][3] = cov_mat_err[3][3] + \
297 for i
in range(0, 4):
298 for j
in range(i, 4):
299 cov_mat_err[i][j] = \
300 math.sqrt(cov_mat_err[i][j] /
314 for i
in range(0, 4):
315 for j
in range(i, 4):
316 corr_mat[i][j] = cov_mat[i][j] / \
317 math.sqrt(cov_mat[i][i]) / math.sqrt(cov_mat[j][j])
319 corr_mat_err[i][j] = cov_mat_err[i][j] / cov_mat[i][j] * \
A (simplified) python wrapper for StoreArray.
hist_corrmat
Correlation matrix histogram.
vertex_k_av
Average vertex.
hist_tres
Time resolution histogram.
hist_nkl
Number of K0L histogram.
check_eklm
Whether to check if cluster is in EKLM.
evtgen
True for evtgen events, false for particle gun.
hist_pres
Momentum resolution histogram.
hist_xres
X resolution histogram.
hist_zres
Z resolution histogram.
hist_yres
Y resolution histogram.
momentum_av
Average momentum.
def __init__(self, output_file, evtgen, check_eklm)
hist_covmat
Covariance matrix histogram.
hist_ptres
Momentum theta resolution histogram.
hist_ppres
Momentum phi resolution histogram.