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