Belle II Software  release-08-01-10
vertex_plots.py
1 
8 import matplotlib.pyplot as plt
9 import uproot
10 
11 plt.style.use("belle2")
12 
13 # Declare list of variables to load, then open root file into pandas DataFrame
14 var_list = ["Jpsi_dz", "Jpsi_mcDecayVertexZ", "Jpsi_chiProb"]
15 df = uproot.open("Bd2JpsiKS.root:tree").arrays(var_list, library="pd")
16 
17 m_bins = 50 # number of bins for the histograms of both plots
18 
19 # Z position
20 
21 fig, ax = plt.subplots(figsize=(8, 6))
22 m_range = [-0.1, 0.1]
23 ax.set_xlim(left=-0.1, right=0.15)
24 ax.hist(df["Jpsi_dz"], bins=m_bins, range=m_range, label=r"$J/\psi$ vertex")
25 ax.hist(
26  df["Jpsi_mcDecayVertexZ"],
27  histtype="step",
28  lw=2,
29  color="black",
30  linestyle="--",
31  bins=m_bins,
32  range=m_range,
33  label=r"$J/\psi$ vertex(MC)",
34 )
35 ax.set_xlabel("dz[cm]")
36 ax.set_ylabel("Events")
37 ax.legend()
38 fig.savefig("vertex_jpsi_dz.svg")
39 
40 # P-value
41 
42 fig, ax = plt.subplots(figsize=(8, 6))
43 m_range = [0, 1]
44 ax.set_xlim(left=-0.05, right=1.05)
45 ax.hist(
46  df["Jpsi_chiProb"],
47  bins=m_bins,
48  range=m_range,
49  label=r"$J/\psi$ vertex",
50 )
51 ax.set_yscale("log") # set a logarithmic scale in the y-axis
52 ax.set_xlabel("p-value")
53 ax.set_ylabel("Events")
54 ax.legend()
55 fig.savefig("vertex_pValue.svg")