ff = tfo.calculate_fit_fractions(fitted_model, norm_sample)
print(ff)

fitted_sample = tft.run_toymc(fitted_model,
                              phsp,
                              nnorm,
                              maximum=1.0e-20,
                              chunk=1000000,
                              components=True)

# Plot results
import matplotlib.pyplot as plt

tfp.set_lhcb_style(size=12,
                   usetex=False)  # Adjust plotting style for LHCb papers
fig, ax = plt.subplots(nrows=2, ncols=2,
                       figsize=(8, 6))  # Single subplot on the figure

# Plot 1D histogram from the toy MC sample
tfp.plot_distr2d(
    toy_sample[:, 0],
    toy_sample[:, 1],
    bins=(50, 50),
    ranges=((0.3, 3.1), (0.3, 3.1)),
    fig=fig,
    ax=ax[0, 0],
    labels=(r"$m^2(K_S^0\pi^+)$", r"$m^2(K_S^0\pi^-)$"),
    units=("MeV$^2$", "MeV$^2$"),
    log=True,
)
Beispiel #2
0
@atfi.function
def nll(pars):
    parslist = [pars[i[0]] for i in parameters_list]
    return atfl.unbinned_nll(model(data_sample, parslist),
                             atfl.integral(model(norm_sample, parslist)))


# Normalisation sample is a uniform random sample in 5D phase space
norm_sample = exp_phase_space.uniform_sample(norm_size)

# Data sample, run through phase space filter just in case
data_sample = exp_phase_space.filter(data_sample)

bins = ndim * [50]

tfp.set_lhcb_style(size=9, usetex=False)
fig, ax = plt.subplots(nrows=ndim, ncols=ndim, figsize=(8, 6))

# Initialise multidimensional density display object
display = tfp.MultidimDisplay(data_sample, norm_sample, bins,
                              observables_bounds, observables_titles, fig, ax)

print("Normalisation sample size = {len(norm_sample)}")
print(norm_sample)
print("Data sample size = {len(data_sample)}")
print(data_sample)

# Run minimisation 10 times, choose the best NLL value
best_nll = 1e10
for i in range(0, 3):
    for p in pars: