Belle II Software  release-05-01-25
invariant_mass_plot.py
1 #!/usr/bin/env python3
2 
3 import matplotlib as mpl
4 import matplotlib.pyplot as plt
5 from root_pandas import read_root
6 
7 # Only include this line if you're running from ipython an a remote server
8 mpl.use("Agg")
9 
10 plt.style.use("belle2") # use the official Belle II plotting style
11 
12 # Make sure that the .root file is in the same directory to find it
13 df = read_root("Bd2JpsiKS.root")
14 
15 # Let's only consider signal J/Psi
16 df_signal_only = df.query("Jpsi_isSignal == 1")
17 
18 fig, ax = plt.subplots()
19 
20 ax.hist(df_signal_only["Jpsi_M_uncorrected"], label="w/o brems corr", alpha=0.5)
21 ax.hist(df_signal_only["Jpsi_M"], label="with brems corr", alpha=0.5)
22 
23 ax.set_yscale("log") # set a logarithmic scale in the y-axis
24 ax.set_xlabel("Invariant mass of the J/Psi")
25 ax.set_ylabel("Events")
26 ax.legend() # show legend
27 
28 plt.savefig("brems_corr_invariant_mass.png")