<jupyter_start><jupyter_text>Mass plotsDraw plots of mass spectra with toy $J/\psi \to \mu^{+}\mu^{-}$ and $B_{s}^{0} \to J/\psi\phi(1020)$ data.<jupyter_code>import matplotlib.pyplot as plt
import numpy as np
JPSI_MASS = 3097
JPSI_RESOLUTION = 7.5
WINDOW = (JPSI_MASS - 20*JPSI_RESOLUTION, JPSI_MASS + 20*JPSI_RESOLUTION)

bkg = np.random.uniform(*WINDOW, size=5000)
sig = np.random.normal(loc=JPSI_MASS, scale=JPSI_RESOLUTION, size=1000)
data = np.concatenate([sig, bkg])
# One bin per 5 MeV
nbins = int(np.diff(WINDOW)/5)

fig, ax = plt.subplots()
ax.hist(data, range=WINDOW, bins=nbins, histtype='step')
ax.set_title(r'Invariant mass spetrum of $J/\psi \to \mu^{+}\mu^{-}$ candidates')
ax.set_xlabel(r'$m(\mu^{+}\mu^{-})$ [MeV/$c^{2}$]')
ax.set_ylabel(r'Candidates / 5 MeV/$c^{2}$')
fig.tight_layout()
fig.savefig('dimuon_mass.png', dpi=150)
BS_MASS = 5367
BS_RESOLUTION = 10
WINDOW = (BS_MASS - 15*BS_RESOLUTION, BS_MASS + 25*BS_RESOLUTION)

bkg = np.random.exponential(scale=100, size=50000) + WINDOW[0]
sig = np.random.normal(loc=BS_MASS, scale=BS_RESOLUTION, size=5000)
data = np.concatenate([sig, bkg])
# One bin per 5 MeV
nbins = int(np.diff(WINDOW)/5)

fig, ax = plt.subplots()
ax.hist(data, range=WINDOW, bins=nbins, histtype='step')
ax.set_title(r'Invariant mass spetrum of $B_{s}^{0} \to J/\psi\phi(1020)$ candidates')
ax.set_xlabel(r'$m(\mu^{+}\mu^{-}K^{+}K^{-})$ [MeV/$c^{2}$]')
ax.set_ylabel(r'Candidates / 5 MeV/$c^{2}$')
fig.tight_layout()
fig.savefig('jpsiphi_mass.png', dpi=150)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.2014388489208633, 'fraction_numerical': 0.04381948986265533, 'mean_word_length': 5.986301369863014, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '470912', 'license': 'CC-BY-4.0', 'n_tokens_mistral': 733, 'n_tokens_neox': 667, 'n_words': 122, 'path': 'first-analysis-steps/code/plots/mass_plots.ipynb', 'repo_name': 'abmorris/starterkit-lessons', 'size': '1529'}