# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Anaconda Python 3
#     language: python
#     name: anaconda
# ---

import matplotlib.pyplot as plt

from hepvector.phsp import gen_phase_space

# Calculate using TGenPhaseSpace-like phase space. This is a bit faster if you have Numba.

res, wt = gen_phase_space(1.8, [.15, .15, .5], 10_000_000)

# Now, compute masses of pairs of particles for DalitzPlot.

m12 = (res[:,0] + res[:,1]).mag2()
m23 = (res[:,1] + res[:,2]).mag2()

# Now, plot the histogram, taking care to include the weights from the gen_phase_space algorithm.

plt.hist2d(m12, m23, bins=200, weights=wt, cmin=1)
plt.xlabel('m12 [GeV]')
plt.xlabel('m23 [GeV]');

StarcoderdataJupyterScriptsDedupFiltered