13 <noexecute>Definition of plotting class</noexecute>
14 <description>Creation of KLM K0L validation plots.</description>
20 from ROOT
import Belle2
21 from ROOT
import TNamed
28 """ Class for creation of KLM K0L validation plots. """
30 def __init__(self, output_file, evtgen, check_eklm):
38 self.
output_fileoutput_file = ROOT.TFile(output_file,
'recreate')
39 contact =
'Leo Piilonen (piilonen@vt.edu)'
41 self.
hist_nklhist_nkl = ROOT.TH1F(
'k0l_number',
42 'Number of KLM clusters per 1 MC particle',
44 self.
hist_nklhist_nkl.SetXTitle(
'KLM clusters')
45 self.
hist_nklhist_nkl.SetYTitle(
'Events')
46 functions = self.
hist_nklhist_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',
57 self.
hist_xreshist_xres.SetYTitle(
'Events')
58 functions = self.
hist_xreshist_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',
68 self.
hist_yreshist_yres.SetYTitle(
'Events')
69 functions = self.
hist_yreshist_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',
79 self.
hist_zreshist_zres.SetYTitle(
'Events')
80 functions = self.
hist_zreshist_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',
90 self.
hist_treshist_tres.SetYTitle(
'Events')
91 functions = self.
hist_treshist_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',
101 self.
hist_preshist_pres.SetYTitle(
'Events')
102 functions = self.
hist_preshist_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_ptreshist_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_ppreshist_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',
133 self.
hist_covmathist_covmat.GetXaxis().SetBinLabel(1,
'xx')
134 self.
hist_covmathist_covmat.GetXaxis().SetBinLabel(2,
'xy')
135 self.
hist_covmathist_covmat.GetXaxis().SetBinLabel(3,
'xz')
136 self.
hist_covmathist_covmat.GetXaxis().SetBinLabel(4,
'yy')
137 self.
hist_covmathist_covmat.GetXaxis().SetBinLabel(5,
'yz')
138 self.
hist_covmathist_covmat.GetXaxis().SetBinLabel(6,
'zz')
139 self.
hist_covmathist_covmat.SetYTitle(
'Covariance, cm^{2}')
140 functions = self.
hist_covmathist_covmat.GetListOfFunctions()
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',
149 self.
hist_corrmathist_corrmat.GetXaxis().SetBinLabel(1,
'xx')
150 self.
hist_corrmathist_corrmat.GetXaxis().SetBinLabel(2,
'xy')
151 self.
hist_corrmathist_corrmat.GetXaxis().SetBinLabel(3,
'xz')
152 self.
hist_corrmathist_corrmat.GetXaxis().SetBinLabel(4,
'xp')
153 self.
hist_corrmathist_corrmat.GetXaxis().SetBinLabel(5,
'yy')
154 self.
hist_corrmathist_corrmat.GetXaxis().SetBinLabel(6,
'yz')
155 self.
hist_corrmathist_corrmat.GetXaxis().SetBinLabel(7,
'yp')
156 self.
hist_corrmathist_corrmat.GetXaxis().SetBinLabel(8,
'zz')
157 self.
hist_corrmathist_corrmat.GetXaxis().SetBinLabel(9,
'zp')
158 self.
hist_corrmathist_corrmat.GetXaxis().SetBinLabel(10,
'pp')
159 self.
hist_corrmathist_corrmat.SetYTitle(
'Correlation coefficient')
160 functions = self.
hist_corrmathist_corrmat.GetListOfFunctions()
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_nklhist_nkl.Fill(len(klm_clusters))
206 for klm_cluster
in klm_clusters:
207 vertex_k = XYZVector(klm_cluster.getClusterPosition()) - vertex
208 self.
vertexvertex.append(vertex_k)
210 self.
momentummomentum.append(klm_cluster.getMomentumMag())
212 klm_cluster.getMomentumMag()
213 time_k = klm_cluster.getTime()
214 four_momentum_k = klm_cluster.getMomentum()
215 self.
hist_xreshist_xres.Fill(vertex_k.X())
216 self.
hist_yreshist_yres.Fill(vertex_k.Y())
217 self.
hist_zreshist_zres.Fill(vertex_k.Z())
218 self.
hist_treshist_tres.Fill(time_k - time)
219 self.
hist_preshist_pres.Fill(four_momentum_k.P() - momentum.R())
220 self.
hist_ptreshist_ptres.Fill(four_momentum_k.Theta() - momentum.Theta())
221 self.
hist_ppreshist_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.
vertexvertex)):
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.
vertexvertex) - 1)
266 for i
in range(len(self.
vertexvertex)):
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] /
301 ((len(self.
vertexvertex) - 2) * len(self.
vertexvertex)))
302 self.
hist_covmathist_covmat.SetBinContent(1, cov_mat[0][0])
303 self.
hist_covmathist_covmat.SetBinContent(2, cov_mat[0][1])
304 self.
hist_covmathist_covmat.SetBinContent(3, cov_mat[0][2])
305 self.
hist_covmathist_covmat.SetBinContent(4, cov_mat[1][1])
306 self.
hist_covmathist_covmat.SetBinContent(5, cov_mat[1][2])
307 self.
hist_covmathist_covmat.SetBinContent(6, cov_mat[2][2])
308 self.
hist_covmathist_covmat.SetBinError(1, cov_mat_err[0][0])
309 self.
hist_covmathist_covmat.SetBinError(2, cov_mat_err[0][1])
310 self.
hist_covmathist_covmat.SetBinError(3, cov_mat_err[0][2])
311 self.
hist_covmathist_covmat.SetBinError(4, cov_mat_err[1][1])
312 self.
hist_covmathist_covmat.SetBinError(5, cov_mat_err[1][2])
313 self.
hist_covmathist_covmat.SetBinError(6, cov_mat_err[2][2])
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] * \
321 self.
hist_corrmathist_corrmat.SetBinContent(1, corr_mat[0][0])
322 self.
hist_corrmathist_corrmat.SetBinContent(2, corr_mat[0][1])
323 self.
hist_corrmathist_corrmat.SetBinContent(3, corr_mat[0][2])
324 self.
hist_corrmathist_corrmat.SetBinContent(4, corr_mat[0][3])
325 self.
hist_corrmathist_corrmat.SetBinContent(5, corr_mat[1][1])
326 self.
hist_corrmathist_corrmat.SetBinContent(6, corr_mat[1][2])
327 self.
hist_corrmathist_corrmat.SetBinContent(7, corr_mat[1][3])
328 self.
hist_corrmathist_corrmat.SetBinContent(8, corr_mat[2][2])
329 self.
hist_corrmathist_corrmat.SetBinContent(9, corr_mat[2][3])
330 self.
hist_corrmathist_corrmat.SetBinContent(10, corr_mat[3][3])
331 self.
hist_corrmathist_corrmat.SetBinError(1, corr_mat_err[0][0])
332 self.
hist_corrmathist_corrmat.SetBinError(2, corr_mat_err[0][1])
333 self.
hist_corrmathist_corrmat.SetBinError(3, corr_mat_err[0][2])
334 self.
hist_corrmathist_corrmat.SetBinError(4, corr_mat_err[0][3])
335 self.
hist_corrmathist_corrmat.SetBinError(5, corr_mat_err[1][1])
336 self.
hist_corrmathist_corrmat.SetBinError(6, corr_mat_err[1][2])
337 self.
hist_corrmathist_corrmat.SetBinError(7, corr_mat_err[1][3])
338 self.
hist_corrmathist_corrmat.SetBinError(8, corr_mat_err[2][2])
339 self.
hist_corrmathist_corrmat.SetBinError(9, corr_mat_err[2][3])
340 self.
hist_corrmathist_corrmat.SetBinError(10, corr_mat_err[3][3])
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.