diff --git a/__pycache__/pdg_const1.cpython-37.pyc b/__pycache__/pdg_const1.cpython-37.pyc index 3b22672..9128726 100644 --- a/__pycache__/pdg_const1.cpython-37.pyc +++ b/__pycache__/pdg_const1.cpython-37.pyc Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288006/__pycache__/helperfunctions.cpython-37.pyc b/data/CLs/finished/f1d1/-+/D-True/2288006/__pycache__/helperfunctions.cpython-37.pyc new file mode 100644 index 0000000..3418c9d --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288006/__pycache__/helperfunctions.cpython-37.pyc Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288006/__pycache__/pdg_const1.cpython-37.pyc b/data/CLs/finished/f1d1/-+/D-True/2288006/__pycache__/pdg_const1.cpython-37.pyc new file mode 100644 index 0000000..f3ce152 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288006/__pycache__/pdg_const1.cpython-37.pyc Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288006/data/CLs/0.0001-0.003_20s--CLs_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288006/data/CLs/0.0001-0.003_20s--CLs_list.pkl new file mode 100644 index 0000000..33c08da --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288006/data/CLs/0.0001-0.003_20s--CLs_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288006/data/CLs/0.0001-0.003_20s1b1t--CLs_Nll_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288006/data/CLs/0.0001-0.003_20s1b1t--CLs_Nll_list.pkl new file mode 100644 index 0000000..61d947c --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288006/data/CLs/0.0001-0.003_20s1b1t--CLs_Nll_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288006/data/CLs/0.0001-0.003_20s1b1t--Ctt_error_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288006/data/CLs/0.0001-0.003_20s1b1t--Ctt_error_list.pkl new file mode 100644 index 0000000..ea93215 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288006/data/CLs/0.0001-0.003_20s1b1t--Ctt_error_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288006/data/CLs/0.0001-0.003_20s1b1t--Ctt_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288006/data/CLs/0.0001-0.003_20s1b1t--Ctt_list.pkl new file mode 100644 index 0000000..5d3f256 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288006/data/CLs/0.0001-0.003_20s1b1t--Ctt_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288006/data/CLs/0.0001-0.003_20s1b1t--pull_dic.pkl b/data/CLs/finished/f1d1/-+/D-True/2288006/data/CLs/0.0001-0.003_20s1b1t--pull_dic.pkl new file mode 100644 index 0000000..97276e8 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288006/data/CLs/0.0001-0.003_20s1b1t--pull_dic.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288006/data/CLs/variab.pkl b/data/CLs/finished/f1d1/-+/D-True/2288006/data/CLs/variab.pkl new file mode 100644 index 0000000..bb90dc0 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288006/data/CLs/variab.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288006/helperfunctions.py b/data/CLs/finished/f1d1/-+/D-True/2288006/helperfunctions.py new file mode 100644 index 0000000..88e120f --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288006/helperfunctions.py @@ -0,0 +1,33 @@ +# some helperfunctions + +import matplotlib +matplotlib.use("agg") +import matplotlib.pyplot as plt + +#Dislpay time (e.g. while generating points) + +display_intervals = ( + ('w', 604800), # 60 * 60 * 24 * 7 + ('d', 86400), # 60 * 60 * 24 + ('h', 3600), # 60 * 60 + ('min', 60), + ('s', 1), + ) + +def display_time(seconds, granularity=2): + result = [] + + for name, count in display_intervals: + value = seconds // count + if value: + seconds -= value * count + if value == 1: + name = name.rstrip('s') + result.append("{} {}".format(value, name)) + return ', '.join(result[:granularity]) + +def prepare_plot(title): + plt.title(title) + plt.grid() + plt.legend(loc = 'best') + plt.xlabel("q") diff --git a/data/CLs/finished/f1d1/-+/D-True/2288006/pdg_const1.py b/data/CLs/finished/f1d1/-+/D-True/2288006/pdg_const1.py new file mode 100644 index 0000000..70b3f30 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288006/pdg_const1.py @@ -0,0 +1,226 @@ +pdg = { + + + ###Particle masses### + + "mbstar" : 5415.4, + "mbstar0" : 5711.0, + "B0_M" : 5279.5, + "Bs_M" : 5366.7, + "Bplus_M" : 5279.3, + "Lb_M" : 5619.4, + "D0_M" : 1864.8, + "Dst_M" : 2010, + "pi_M" : 139.6, + "Jpsi_M" : 3096.9, + "Psi2s_M" : 3685.6, + "kaon_M" : 493.7, + "Ks_M" : 497.6, + "phi_M" : 1019.5, + "rho_M" : 775.26, + "rho_width" : 149.1, + "omega_M" : 782.65, + "omega_width" : 8.49, + + "muon_M" : 105.7, + "tau_M": 1776.86, + + "squark_M" : 95.0, + "bquark_M" : 4180.0, + "cquark_M" : 1275.0, + + "Bplus_tau" : 1.638e-12, + + ###Wilson coefficients### + + "C1" : -0.257, + "C2" : 1.009, + "C3" : -0.005, + "C4" : -0.078, + + "C7eff" : -0.306, + "C9eff" : 4.211, + "C10eff" : -4.103, + +# "C7eff": 0.0, +# "C9eff": 0.0, +# "C10eff": 0.0, + + ###Other constants + + "GF" : 1.1663787e-5, + "alpha_ew" : 1.0/137.0, + "Vts" : 0.0394, + "Vtb" : 1.019, + "number_of_decays": 5404696, + + #Formfactor z coefficients + + #"b0" : [0.285, 0.19, -0.17], + #"bplus" : [0.437, -1.41, -2.5], + #"bT" : [0.440, -1.47, -2.7] + + "b0" : [0.292, 0.281, 0.150], + "bplus" : [0.466, -0.885, -0.213], + "bT" : [0.460, -1.089, -1.114], + + "NR_BR": 4.37e-7, + "NR_auc": 0.00133, + + #Resonances format(mass, width, phase, scale) + + # pre scaling + +# "rho": (775.26, 149.0, -0.35, 1.0), + +# "omega": (782.7, 8.5, 0.26, 1.0), + +# "phi": (1019.46, 4.25, 0.5, 1.0), + +# "jpsi": (3096.0, 0.09, -1.5, 2e-2), +# "jpsi_auc": 0.2126825758464027, + +# "psi2s": (3686.0, 0.3, -1.5, 3.14e-3), +# "psi2s_auc": 2.802257483178487e-10, + +# "p3770": (3773.0, 27.2, -2.13, 1.0e-3), + +# "p4040": (4039.0, 80.0, -2.52, 2.0), + +# "p4160": (4191.0, 70.0, -1.9, 2.2), + +# "p4415": (4421.0, 62.0, -2.52, 1.0), + + + # after scaling (Phase combination --) + + # + # "rho": (743.2, 149.0, -0.22, 1.05), + # + # "omega": (782.7, 8.5, 0.38, 6.8), + # + # "phi": (1013.5, 4.25, 0.62, 19.2), + # + # "jpsi": (3096.1, 0.09, 1.63, 9897.0), + # "jpsi_auc": 0.2126825758464027, + # "jpsi_phase_unc": 0.05, + # + # "psi2s": (3686.0, 0.3, 1.8, 1396.0), + # "psi2s_auc": 0.0151332263, + # "psi2s_phase_unc": 0.1, + # + # "p3770": (3773.0, 27.2, -2.95, 2.5), + # + # "p4040": (4039.0, 80.0, -2.75, 1.01), + # + # "p4160": (4191.0, 70.0, -2.28, 2.2), + # + # "p4415": (4421.0, 62.0, -2.31, 1.24), + + # Phase combination of paper ++ + +# "rho": (743.2, 149.0, -0.35, 1.05), + +# "omega": (782.7, 8.5, 0.26, 6.8), + +# "phi": (1013.5, 4.25, 0.47, 19.2), + +# "jpsi": (3096.1, 0.09, -1.66, 9897.0), +# "jpsi_auc": 0.2126825758464027, +# "jpsi_phase_unc": 0.05, + +# "psi2s": (3686.0, 0.3, -1.93, 1396.0), +# "psi2s_auc": 0.0151332263, +# "psi2s_phase_unc": 0.1, + +# "p3770": (3773.0, 27.2, -2.13, 2.5), + +# "p4040": (4039.0, 80.0, -2.52, 1.01), + +# "p4160": (4191.0, 70.0, -1.90, 2.2), + +# "p4415": (4421.0, 62.0, -2.52, 1.24), + + # Phase combination of paper +- + +# "rho": (743.2, 149.0, -0.26, 1.05), + +# "omega": (782.7, 8.5, 0.35, 6.8), + +# "phi": (1013.5, 4.25, 0.58, 19.2), + +# "jpsi": (3096.1, 0.09, 1.47, 9897.0), +# "jpsi_auc": 0.2126825758464027, +# "jpsi_phase_unc": 0.05, + +# "psi2s": (3686.0, 0.3, -2.21, 1396.0), +# "psi2s_auc": 0.0151332263, +# "psi2s_phase_unc": 0.1, + +# "p3770": (3773.0, 27.2, -2.140, 2.5), + +# "p4040": (4039.0, 80.0, -2.64, 1.01), + +# "p4160": (4191.0, 70.0, -2.11, 2.2), + +# "p4415": (4421.0, 62.0, -2.42, 1.24), + + # Phase combination of paper -+ + + "rho": (743.2, 149.0, -0.30, 1.05), + + "omega": (782.7, 8.5, 0.30, 6.8), + + "phi": (1013.5, 4.25, 0.51, 19.2), + + "jpsi": (3096.1, 0.09, -1.5, 9897.0), + "jpsi_auc": 0.2126825758464027, + "jpsi_phase_unc": 0.05, + + "psi2s": (3686.0, 0.3, 2.08, 1396.0), + "psi2s_auc": 0.0151332263, + "psi2s_phase_unc": 0.1, + + "p3770": (3773.0, 27.2, -2.89, 2.5), + + "p4040": (4039.0, 80.0, -2.69, 1.01), + + "p4160": (4191.0, 70.0, -2.13, 2.2), + + "p4415": (4421.0, 62.0, -2.43, 1.24), + + + # zeroing resonances + +# "rho": (775.26, 149.0, -0.35, 0.0), +# "omega": (782.7, 8.5, 0.26, 0.0), +# "phi": (1019.46, 4.25, 0.5, 0.0), +# "jpsi": (3096.0, 0.09, -1.5, 0.0), +# "psi2s": (3686.0, 0.3, -1.5, 0.0), +# "p3770": (3773.0, 27.2, -2.13, 0.0), +# "p4040": (4039.0, 80.0, -2.52, 0.0), +# "p4160": (4147.0, 22.0, -1.9, 0.0), +# "p4415": (4421.0, 62.0, -2.52, 0.0), + + # 2P contributions format(mass, amp, phase) + +# "D_bar": ( + + #general + + "rho_BR": 1.7e-10, + "omega_BR": 4.9e-10, + "phi_BR": 2.5e-9, + "jpsi_BR": 6.02e-5, + "psi2s_BR": 4.97e-6, + "p3770_BR": 1.38e-9, + "p4040_BR": 4.2e-10, + "p4160_BR": 2.6e-9, + "p4415_BR": 6.1e-10, + +# Estimates + "Dbar_scale": 1.46, #with phase = pi + + "DDstar_scale": 2.41, #with phase = pi + + } diff --git a/data/CLs/finished/f1d1/-+/D-True/2288006/raremodel-nb.py b/data/CLs/finished/f1d1/-+/D-True/2288006/raremodel-nb.py new file mode 100644 index 0000000..c326c9c --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288006/raremodel-nb.py @@ -0,0 +1,2152 @@ +#!/usr/bin/env python +# coding: utf-8 + +# # Import + +# In[ ]: + + +import os + +# os.environ["CUDA_VISIBLE_DEVICES"] = "-1" +import random +import numpy as np +from pdg_const1 import pdg +import matplotlib +import matplotlib.pyplot as plt +import pickle as pkl +import sys +import time +from helperfunctions import display_time, prepare_plot +import cmath as c +import scipy.integrate as integrate +from scipy.optimize import fminbound +from array import array as arr +import collections +from itertools import compress +import tensorflow as tf +import zfit +from zfit import ztf +# from IPython.display import clear_output +import os +import tensorflow_probability as tfp +tfd = tfp.distributions + + +# In[ ]: + + +# chunksize = 10000 +# zfit.run.chunking.active = True +# zfit.run.chunking.max_n_points = chunksize + + +# # Build model and graphs +# ## Create graphs + +# In[ ]: + + + + + +# In[ ]: + + +def formfactor(q2, subscript, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2): #returns real value + #check if subscript is viable + + if subscript != "0" and subscript != "+" and subscript != "T": + raise ValueError('Wrong subscript entered, choose either 0, + or T') + + #get constants + + mK = ztf.constant(pdg['Ks_M']) + mbstar0 = ztf.constant(pdg["mbstar0"]) + mbstar = ztf.constant(pdg["mbstar"]) + + + mmu = ztf.constant(pdg['muon_M']) + mb = ztf.constant(pdg['bquark_M']) + ms = ztf.constant(pdg['squark_M']) + mB = ztf.constant(pdg['Bplus_M']) + + #N comes from derivation in paper + + N = 3 + + #some helperfunctions + + tpos = (mB - mK)**2 + tzero = (mB + mK)*(ztf.sqrt(mB)-ztf.sqrt(mK))**2 + + z_oben = ztf.sqrt(tpos - q2) - ztf.sqrt(tpos - tzero) + z_unten = ztf.sqrt(tpos - q2) + ztf.sqrt(tpos - tzero) + z = tf.divide(z_oben, z_unten) + + #calculate f0 + + if subscript == "0": + prefactor = 1/(1 - q2/(mbstar0**2)) + _sum = 0 + b0 = [b0_0, b0_1, b0_2] + + for i in range(N): + _sum += b0[i]*(tf.pow(z,i)) + + return ztf.to_complex(prefactor * _sum) + + #calculate f+ or fT + + else: + prefactor = 1/(1 - q2/(mbstar**2)) + _sum = 0 + + if subscript == "T": + bT = [bT_0, bT_1, bT_2] + for i in range(N): + _sum += bT[i] * (tf.pow(z, i) - ((-1)**(i-N)) * (i/N) * tf.pow(z, N)) + else: + bplus = [bplus_0, bplus_1, bplus_2] + for i in range(N): + _sum += bplus[i] * (tf.pow(z, i) - ((-1)**(i-N)) * (i/N) * tf.pow(z, N)) + + return ztf.to_complex(prefactor * _sum) + +def resonance(q, _mass, width, phase, scale): + + q2 = tf.pow(q, 2) + + mmu = ztf.constant(pdg['muon_M']) + + p = 0.5 * ztf.sqrt(q2 - 4*(mmu**2)) + + p0 = 0.5 * ztf.sqrt(_mass**2 - 4*mmu**2) + + gamma_j = tf.divide(p, q) * _mass * width / p0 + + #Calculate the resonance + + _top = tf.complex(_mass * width, ztf.constant(0.0)) + + _bottom = tf.complex(_mass**2 - q2, -_mass*gamma_j) + + com = _top/_bottom + + #Rotate by the phase + + r = ztf.to_complex(scale*tf.abs(com)) + + _phase = tf.angle(com) + + _phase += phase + + com = r * tf.exp(tf.complex(ztf.constant(0.0), _phase)) + + return com + + +def axiv_nonres(q, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2): + + GF = ztf.constant(pdg['GF']) + alpha_ew = ztf.constant(pdg['alpha_ew']) + Vtb = ztf.constant(pdg['Vtb']) + Vts = ztf.constant(pdg['Vts']) + C10eff = ztf.constant(pdg['C10eff']) + + mmu = ztf.constant(pdg['muon_M']) + mb = ztf.constant(pdg['bquark_M']) + ms = ztf.constant(pdg['squark_M']) + mK = ztf.constant(pdg['Ks_M']) + mB = ztf.constant(pdg['Bplus_M']) + + q2 = tf.pow(q, 2) + + #Some helperfunctions + + beta = 1. - 4. * mmu**2. / q2 + + kabs = ztf.sqrt(mB**2. + tf.pow(q2, 2)/mB**2. + mK**4./mB**2. - 2. * (mB**2. * mK**2. + mK**2. * q2 + mB**2. * q2) / mB**2.) + + #prefactor in front of whole bracket + + prefactor1 = GF**2. *alpha_ew**2. * (tf.abs(Vtb*Vts))**2. * kabs * beta / (128. * np.pi**5.) + + #left term in bracket + + bracket_left = 2./3. * tf.pow(kabs,2) * tf.pow(beta,2) * tf.pow(tf.abs(ztf.to_complex(C10eff)*formfactor(q2, "+", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2)),2) + + #middle term in bracket + + _top = 4. * mmu**2. * (mB**2. - mK**2.) * (mB**2. - mK**2.) + + _under = q2 * mB**2. + + bracket_middle = _top/_under *tf.pow(tf.abs(ztf.to_complex(C10eff) * formfactor(q2, "0", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2)), 2) + + #Note sqrt(q2) comes from derivation as we use q2 and plot q + + return prefactor1 * (bracket_left + bracket_middle) * 2 * q + +def vec(q, funcs, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2): + + q2 = tf.pow(q, 2) + + GF = ztf.constant(pdg['GF']) + alpha_ew = ztf.constant(pdg['alpha_ew']) + Vtb = ztf.constant(pdg['Vtb']) + Vts = ztf.constant(pdg['Vts']) + C7eff = ztf.constant(pdg['C7eff']) + + mmu = ztf.constant(pdg['muon_M']) + mb = ztf.constant(pdg['bquark_M']) + ms = ztf.constant(pdg['squark_M']) + mK = ztf.constant(pdg['Ks_M']) + mB = ztf.constant(pdg['Bplus_M']) + + #Some helperfunctions + + beta = 1. - 4. * mmu**2. / q2 + + kabs = ztf.sqrt(mB**2. + tf.pow(q2, 2)/mB**2. + mK**4./mB**2. - 2 * (mB**2 * mK**2 + mK**2 * q2 + mB**2 * q2) / mB**2) + + #prefactor in front of whole bracket + + prefactor1 = GF**2. *alpha_ew**2. * (tf.abs(Vtb*Vts))**2 * kabs * beta / (128. * np.pi**5.) + + #right term in bracket + + prefactor2 = tf.pow(kabs,2) * (1. - 1./3. * beta) + + abs_bracket = tf.pow(tf.abs(c9eff(q, funcs) * formfactor(q2, "+", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + ztf.to_complex(2.0 * C7eff * (mb + ms)/(mB + mK)) * formfactor(q2, "T", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2)),2) + + bracket_right = prefactor2 * abs_bracket + + #Note sqrt(q2) comes from derivation as we use q2 and plot q + + return prefactor1 * bracket_right * 2 * q + +def c9eff(q, funcs): + + C9eff_nr = ztf.to_complex(ztf.constant(pdg['C9eff'])) + + c9 = C9eff_nr + funcs + + return c9 + + +# In[ ]: + + +def G(y): + + def inner_rect_bracket(q): + return tf.log(ztf.to_complex((1+tf.sqrt(q))/(1-tf.sqrt(q)))-tf.complex(ztf.constant(0), -1*ztf.constant(np.pi))) + + def inner_right(q): + return ztf.to_complex(2 * tf.atan(1/tf.sqrt(tf.math.real(-q)))) + + big_bracket = tf.where(tf.math.real(y) > ztf.constant(0.0), inner_rect_bracket(y), inner_right(y)) + + return ztf.to_complex(tf.sqrt(tf.abs(y))) * big_bracket + +def h_S(m, q): + + return ztf.to_complex(2) - G(ztf.to_complex(1) - ztf.to_complex(4*tf.pow(m, 2)) / ztf.to_complex(tf.pow(q, 2))) + +def h_P(m, q): + + return ztf.to_complex(2/3) + (ztf.to_complex(1) - ztf.to_complex(4*tf.pow(m, 2)) / ztf.to_complex(tf.pow(q, 2))) * h_S(m,q) + +def two_p_ccbar(mD, m_D_bar, m_D_star, q): + + + #Load constants + nu_D_bar = ztf.to_complex(pdg["nu_D_bar"]) + nu_D = ztf.to_complex(pdg["nu_D"]) + nu_D_star = ztf.to_complex(pdg["nu_D_star"]) + + phase_D_bar = ztf.to_complex(pdg["phase_D_bar"]) + phase_D = ztf.to_complex(pdg["phase_D"]) + phase_D_star = ztf.to_complex(pdg["phase_D_star"]) + + #Calculation + left_part = nu_D_bar * tf.exp(tf.complex(ztf.constant(0.0), phase_D_bar)) * h_S(m_D_bar, q) + + right_part_D = nu_D * tf.exp(tf.complex(ztf.constant(0.0), phase_D)) * h_P(m_D, q) + + right_part_D_star = nu_D_star * tf.exp(tf.complex(ztf.constant(0.0), phase_D_star)) * h_P(m_D_star, q) + + return left_part + right_part_D + right_part_D_star + + +# ## Build pdf + +# In[ ]: + + +class total_pdf_cut(zfit.pdf.ZPDF): + _N_OBS = 1 # dimension, can be omitted + _PARAMS = ['b0_0', 'b0_1', 'b0_2', + 'bplus_0', 'bplus_1', 'bplus_2', + 'bT_0', 'bT_1', 'bT_2', + 'rho_mass', 'rho_scale', 'rho_phase', 'rho_width', + 'jpsi_mass', 'jpsi_scale', 'jpsi_phase', 'jpsi_width', + 'psi2s_mass', 'psi2s_scale', 'psi2s_phase', 'psi2s_width', + 'p3770_mass', 'p3770_scale', 'p3770_phase', 'p3770_width', + 'p4040_mass', 'p4040_scale', 'p4040_phase', 'p4040_width', + 'p4160_mass', 'p4160_scale', 'p4160_phase', 'p4160_width', + 'p4415_mass', 'p4415_scale', 'p4415_phase', 'p4415_width', + 'omega_mass', 'omega_scale', 'omega_phase', 'omega_width', + 'phi_mass', 'phi_scale', 'phi_phase', 'phi_width', + 'Dbar_mass', 'Dbar_scale', 'Dbar_phase', + 'Dstar_mass', 'DDstar_scale', 'DDstar_phase', 'D_mass', + 'tau_mass', 'C_tt'] +# the name of the parameters + + def _unnormalized_pdf(self, x): + + x = x.unstack_x() + + b0 = [self.params['b0_0'], self.params['b0_1'], self.params['b0_2']] + bplus = [self.params['bplus_0'], self.params['bplus_1'], self.params['bplus_2']] + bT = [self.params['bT_0'], self.params['bT_1'], self.params['bT_2']] + + def rho_res(q): + return resonance(q, _mass = self.params['rho_mass'], scale = self.params['rho_scale'], + phase = self.params['rho_phase'], width = self.params['rho_width']) + + def omega_res(q): + return resonance(q, _mass = self.params['omega_mass'], scale = self.params['omega_scale'], + phase = self.params['omega_phase'], width = self.params['omega_width']) + + def phi_res(q): + return resonance(q, _mass = self.params['phi_mass'], scale = self.params['phi_scale'], + phase = self.params['phi_phase'], width = self.params['phi_width']) + + def jpsi_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['jpsi_mass'], 2)) * resonance(q, _mass = self.params['jpsi_mass'], + scale = self.params['jpsi_scale'], + phase = self.params['jpsi_phase'], + width = self.params['jpsi_width']) + def psi2s_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['psi2s_mass'], 2)) * resonance(q, _mass = self.params['psi2s_mass'], + scale = self.params['psi2s_scale'], + phase = self.params['psi2s_phase'], + width = self.params['psi2s_width']) + def p3770_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p3770_mass'], 2)) * resonance(q, _mass = self.params['p3770_mass'], + scale = self.params['p3770_scale'], + phase = self.params['p3770_phase'], + width = self.params['p3770_width']) + + def p4040_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4040_mass'], 2)) * resonance(q, _mass = self.params['p4040_mass'], + scale = self.params['p4040_scale'], + phase = self.params['p4040_phase'], + width = self.params['p4040_width']) + + def p4160_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4160_mass'], 2)) * resonance(q, _mass = self.params['p4160_mass'], + scale = self.params['p4160_scale'], + phase = self.params['p4160_phase'], + width = self.params['p4160_width']) + + def p4415_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4415_mass'], 2)) * resonance(q, _mass = self.params['p4415_mass'], + scale = self.params['p4415_scale'], + phase = self.params['p4415_phase'], + width = self.params['p4415_width']) + + def P2_D(q): + Dbar_contrib = ztf.to_complex(self.params['Dbar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['Dbar_phase']))*ztf.to_complex(h_S(self.params['Dbar_mass'], q)) + DDstar_contrib = ztf.to_complex(self.params['DDstar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['DDstar_phase']))*(ztf.to_complex(h_P(self.params['Dstar_mass'], q)) + ztf.to_complex(h_P(self.params['D_mass'], q))) + return Dbar_contrib + DDstar_contrib + + def ttau_cusp(q): + return ztf.to_complex(self.params['C_tt'])*(ztf.to_complex((h_S(self.params['tau_mass'], q))) - ztf.to_complex(h_P(self.params['tau_mass'], q))) + + + funcs = rho_res(x) + omega_res(x) + phi_res(x) + jpsi_res(x) + psi2s_res(x) + p3770_res(x) + p4040_res(x)+ p4160_res(x) + p4415_res(x) + P2_D(x) + ttau_cusp(x) + + vec_f = vec(x, funcs, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + axiv_nr = axiv_nonres(x, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + tot = vec_f + axiv_nr + + #Cut out jpsi and psi2s + + tot = tf.where(tf.math.logical_or(x < ztf.constant(jpsi_mass-60.), x > ztf.constant(jpsi_mass+70.)), tot, 0.0*tot) + + tot = tf.where(tf.math.logical_or(x < ztf.constant(psi2s_mass-50.), x > ztf.constant(psi2s_mass+50.)), tot, 0.0*tot) + + return tot + +class total_pdf_full(zfit.pdf.ZPDF): + _N_OBS = 1 # dimension, can be omitted + _PARAMS = ['b0_0', 'b0_1', 'b0_2', + 'bplus_0', 'bplus_1', 'bplus_2', + 'bT_0', 'bT_1', 'bT_2', + 'rho_mass', 'rho_scale', 'rho_phase', 'rho_width', + 'jpsi_mass', 'jpsi_scale', 'jpsi_phase', 'jpsi_width', + 'psi2s_mass', 'psi2s_scale', 'psi2s_phase', 'psi2s_width', + 'p3770_mass', 'p3770_scale', 'p3770_phase', 'p3770_width', + 'p4040_mass', 'p4040_scale', 'p4040_phase', 'p4040_width', + 'p4160_mass', 'p4160_scale', 'p4160_phase', 'p4160_width', + 'p4415_mass', 'p4415_scale', 'p4415_phase', 'p4415_width', + 'omega_mass', 'omega_scale', 'omega_phase', 'omega_width', + 'phi_mass', 'phi_scale', 'phi_phase', 'phi_width', + 'Dbar_mass', 'Dbar_scale', 'Dbar_phase', + 'Dstar_mass', 'DDstar_scale', 'DDstar_phase', 'D_mass', + 'tau_mass', 'C_tt'] +# the name of the parameters + + def _unnormalized_pdf(self, x): + + x = x.unstack_x() + + b0 = [self.params['b0_0'], self.params['b0_1'], self.params['b0_2']] + bplus = [self.params['bplus_0'], self.params['bplus_1'], self.params['bplus_2']] + bT = [self.params['bT_0'], self.params['bT_1'], self.params['bT_2']] + + def rho_res(q): + return resonance(q, _mass = self.params['rho_mass'], scale = self.params['rho_scale'], + phase = self.params['rho_phase'], width = self.params['rho_width']) + + def omega_res(q): + return resonance(q, _mass = self.params['omega_mass'], scale = self.params['omega_scale'], + phase = self.params['omega_phase'], width = self.params['omega_width']) + + def phi_res(q): + return resonance(q, _mass = self.params['phi_mass'], scale = self.params['phi_scale'], + phase = self.params['phi_phase'], width = self.params['phi_width']) + + def jpsi_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['jpsi_mass'], 2)) * resonance(q, _mass = self.params['jpsi_mass'], + scale = self.params['jpsi_scale'], + phase = self.params['jpsi_phase'], + width = self.params['jpsi_width']) + def psi2s_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['psi2s_mass'], 2)) * resonance(q, _mass = self.params['psi2s_mass'], + scale = self.params['psi2s_scale'], + phase = self.params['psi2s_phase'], + width = self.params['psi2s_width']) + def p3770_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p3770_mass'], 2)) * resonance(q, _mass = self.params['p3770_mass'], + scale = self.params['p3770_scale'], + phase = self.params['p3770_phase'], + width = self.params['p3770_width']) + + def p4040_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4040_mass'], 2)) * resonance(q, _mass = self.params['p4040_mass'], + scale = self.params['p4040_scale'], + phase = self.params['p4040_phase'], + width = self.params['p4040_width']) + + def p4160_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4160_mass'], 2)) * resonance(q, _mass = self.params['p4160_mass'], + scale = self.params['p4160_scale'], + phase = self.params['p4160_phase'], + width = self.params['p4160_width']) + + def p4415_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4415_mass'], 2)) * resonance(q, _mass = self.params['p4415_mass'], + scale = self.params['p4415_scale'], + phase = self.params['p4415_phase'], + width = self.params['p4415_width']) + + def P2_D(q): + Dbar_contrib = ztf.to_complex(self.params['Dbar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['Dbar_phase']))*ztf.to_complex(h_S(self.params['Dbar_mass'], q)) + DDstar_contrib = ztf.to_complex(self.params['DDstar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['DDstar_phase']))*(ztf.to_complex(h_P(self.params['Dstar_mass'], q)) + ztf.to_complex(h_P(self.params['D_mass'], q))) + return Dbar_contrib + DDstar_contrib + + def ttau_cusp(q): + return ztf.to_complex(self.params['C_tt'])*(ztf.to_complex((h_S(self.params['tau_mass'], q))) - ztf.to_complex(h_P(self.params['tau_mass'], q))) + + + funcs = rho_res(x) + omega_res(x) + phi_res(x) + jpsi_res(x) + psi2s_res(x) + p3770_res(x) + p4040_res(x)+ p4160_res(x) + p4415_res(x) + P2_D(x) + ttau_cusp(x) + + vec_f = vec(x, funcs, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + axiv_nr = axiv_nonres(x, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + tot = vec_f + axiv_nr + + #Cut out jpsi and psi2s + +# tot = tf.where(tf.math.logical_or(x < ztf.constant(jpsi_mass-60.), x > ztf.constant(jpsi_mass+70.)), tot, 0.0*tot) + +# tot = tf.where(tf.math.logical_or(x < ztf.constant(psi2s_mass-50.), x > ztf.constant(psi2s_mass+50.)), tot, 0.0*tot) + + return tot + + +# ## Setup parameters + +# In[ ]: + + +# formfactors + +b0_0 = zfit.Parameter("b0_0", ztf.constant(0.292), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +b0_1 = zfit.Parameter("b0_1", ztf.constant(0.281), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +b0_2 = zfit.Parameter("b0_2", ztf.constant(0.150), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) + +bplus_0 = zfit.Parameter("bplus_0", ztf.constant(0.466), lower_limit = -2.0, upper_limit= 2.0) +bplus_1 = zfit.Parameter("bplus_1", ztf.constant(-0.885), lower_limit = -2.0, upper_limit= 2.0) +bplus_2 = zfit.Parameter("bplus_2", ztf.constant(-0.213), lower_limit = -2.0, upper_limit= 2.0) + +bT_0 = zfit.Parameter("bT_0", ztf.constant(0.460), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +bT_1 = zfit.Parameter("bT_1", ztf.constant(-1.089), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +bT_2 = zfit.Parameter("bT_2", ztf.constant(-1.114), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) + + +#rho + +rho_mass, rho_width, rho_phase, rho_scale = pdg["rho"] + +rho_m = zfit.Parameter("rho_m", ztf.constant(rho_mass), floating = False) #lower_limit = rho_mass - rho_width, upper_limit = rho_mass + rho_width) +rho_w = zfit.Parameter("rho_w", ztf.constant(rho_width), floating = False) +rho_p = zfit.Parameter("rho_p", ztf.constant(rho_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +rho_s = zfit.Parameter("rho_s", ztf.constant(rho_scale), lower_limit=rho_scale-np.sqrt(rho_scale), upper_limit=rho_scale+np.sqrt(rho_scale)) + +#omega + +omega_mass, omega_width, omega_phase, omega_scale = pdg["omega"] + +omega_m = zfit.Parameter("omega_m", ztf.constant(omega_mass), floating = False) +omega_w = zfit.Parameter("omega_w", ztf.constant(omega_width), floating = False) +omega_p = zfit.Parameter("omega_p", ztf.constant(omega_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +omega_s = zfit.Parameter("omega_s", ztf.constant(omega_scale), lower_limit=omega_scale-np.sqrt(omega_scale), upper_limit=omega_scale+np.sqrt(omega_scale)) + + +#phi + +phi_mass, phi_width, phi_phase, phi_scale = pdg["phi"] + +phi_m = zfit.Parameter("phi_m", ztf.constant(phi_mass), floating = False) +phi_w = zfit.Parameter("phi_w", ztf.constant(phi_width), floating = False) +phi_p = zfit.Parameter("phi_p", ztf.constant(phi_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +phi_s = zfit.Parameter("phi_s", ztf.constant(phi_scale), lower_limit=phi_scale-np.sqrt(phi_scale), upper_limit=phi_scale+np.sqrt(phi_scale)) + +#jpsi + +jpsi_mass, jpsi_width, jpsi_phase, jpsi_scale = pdg["jpsi"] + +jpsi_m = zfit.Parameter("jpsi_m", ztf.constant(jpsi_mass), floating = False) +jpsi_w = zfit.Parameter("jpsi_w", ztf.constant(jpsi_width), floating = False) +jpsi_p = zfit.Parameter("jpsi_p", ztf.constant(jpsi_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +jpsi_s = zfit.Parameter("jpsi_s", ztf.constant(jpsi_scale), floating = False) #, lower_limit=jpsi_scale-np.sqrt(jpsi_scale), upper_limit=jpsi_scale+np.sqrt(jpsi_scale)) + +#psi2s + +psi2s_mass, psi2s_width, psi2s_phase, psi2s_scale = pdg["psi2s"] + +psi2s_m = zfit.Parameter("psi2s_m", ztf.constant(psi2s_mass), floating = False) +psi2s_w = zfit.Parameter("psi2s_w", ztf.constant(psi2s_width), floating = False) +psi2s_p = zfit.Parameter("psi2s_p", ztf.constant(psi2s_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +psi2s_s = zfit.Parameter("psi2s_s", ztf.constant(psi2s_scale), floating = False) #, lower_limit=psi2s_scale-np.sqrt(psi2s_scale), upper_limit=psi2s_scale+np.sqrt(psi2s_scale)) + +#psi(3770) + +p3770_mass, p3770_width, p3770_phase, p3770_scale = pdg["p3770"] + +p3770_m = zfit.Parameter("p3770_m", ztf.constant(p3770_mass), floating = False) +p3770_w = zfit.Parameter("p3770_w", ztf.constant(p3770_width), floating = False) +p3770_p = zfit.Parameter("p3770_p", ztf.constant(p3770_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p3770_s = zfit.Parameter("p3770_s", ztf.constant(p3770_scale), lower_limit=p3770_scale-np.sqrt(p3770_scale), upper_limit=p3770_scale+np.sqrt(p3770_scale)) + +#psi(4040) + +p4040_mass, p4040_width, p4040_phase, p4040_scale = pdg["p4040"] + +p4040_m = zfit.Parameter("p4040_m", ztf.constant(p4040_mass), floating = False) +p4040_w = zfit.Parameter("p4040_w", ztf.constant(p4040_width), floating = False) +p4040_p = zfit.Parameter("p4040_p", ztf.constant(p4040_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p4040_s = zfit.Parameter("p4040_s", ztf.constant(p4040_scale), lower_limit=p4040_scale-np.sqrt(p4040_scale), upper_limit=p4040_scale+np.sqrt(p4040_scale)) + +#psi(4160) + +p4160_mass, p4160_width, p4160_phase, p4160_scale = pdg["p4160"] + +p4160_m = zfit.Parameter("p4160_m", ztf.constant(p4160_mass), floating = False) +p4160_w = zfit.Parameter("p4160_w", ztf.constant(p4160_width), floating = False) +p4160_p = zfit.Parameter("p4160_p", ztf.constant(p4160_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p4160_s = zfit.Parameter("p4160_s", ztf.constant(p4160_scale), lower_limit=p4160_scale-np.sqrt(p4160_scale), upper_limit=p4160_scale+np.sqrt(p4160_scale)) + +#psi(4415) + +p4415_mass, p4415_width, p4415_phase, p4415_scale = pdg["p4415"] + +p4415_m = zfit.Parameter("p4415_m", ztf.constant(p4415_mass), floating = False) +p4415_w = zfit.Parameter("p4415_w", ztf.constant(p4415_width), floating = False) +p4415_p = zfit.Parameter("p4415_p", ztf.constant(p4415_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p4415_s = zfit.Parameter("p4415_s", ztf.constant(p4415_scale), lower_limit=p4415_scale-np.sqrt(p4415_scale), upper_limit=p4415_scale+np.sqrt(p4415_scale)) + + +# ## Dynamic generation of 2 particle contribution + +# In[ ]: + + +m_c = 1300 + +Dbar_phase = 0.0 +DDstar_phase = 0.0 +Dstar_mass = pdg['Dst_M'] +Dbar_mass = pdg['D0_M'] +D_mass = pdg['D0_M'] + +Dbar_s = zfit.Parameter("Dbar_s", ztf.constant(0.0), lower_limit=-0.3, upper_limit=0.3) +Dbar_m = zfit.Parameter("Dbar_m", ztf.constant(Dbar_mass), floating = False) +Dbar_p = zfit.Parameter("Dbar_p", ztf.constant(Dbar_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi)#, floating = False) +DDstar_s = zfit.Parameter("DDstar_s", ztf.constant(0.0), lower_limit=-0.3, upper_limit=0.3)#, floating = False) +Dstar_m = zfit.Parameter("Dstar_m", ztf.constant(Dstar_mass), floating = False) +D_m = zfit.Parameter("D_m", ztf.constant(D_mass), floating = False) +DDstar_p = zfit.Parameter("DDstar_p", ztf.constant(DDstar_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi)#, floating = False) + + +# ## Tau parameters + +# In[ ]: + + +tau_m = zfit.Parameter("tau_m", ztf.constant(pdg['tau_M']), floating = False) +Ctt = zfit.Parameter("Ctt", ztf.constant(0.0), lower_limit=-2.5, upper_limit=2.5) + + +# ## Load data + +# In[ ]: + + +x_min = 2*pdg['muon_M'] +x_max = (pdg["Bplus_M"]-pdg["Ks_M"]-0.1) + +# # Full spectrum + +obs_toy = zfit.Space('q', limits = (x_min, x_max)) + +# Jpsi and Psi2s cut out + +obs1 = zfit.Space('q', limits = (x_min, jpsi_mass - 60.)) +obs2 = zfit.Space('q', limits = (jpsi_mass + 70., psi2s_mass - 50.)) +obs3 = zfit.Space('q', limits = (psi2s_mass + 50., x_max)) + +obs_fit = obs1 + obs2 + obs3 + +# with open(r"./data/slim_points/slim_points_toy_0_range({0}-{1}).pkl".format(int(x_min), int(x_max)), "rb") as input_file: +# part_set = pkl.load(input_file) + +# x_part = part_set['x_part'] + +# x_part = x_part.astype('float64') + +# data = zfit.data.Data.from_numpy(array=x_part, obs=obs) + + +# ## Setup pdf + +# In[ ]: + + +total_f = total_pdf_cut(obs=obs_toy, jpsi_mass = jpsi_m, jpsi_scale = jpsi_s, jpsi_phase = jpsi_p, jpsi_width = jpsi_w, + psi2s_mass = psi2s_m, psi2s_scale = psi2s_s, psi2s_phase = psi2s_p, psi2s_width = psi2s_w, + p3770_mass = p3770_m, p3770_scale = p3770_s, p3770_phase = p3770_p, p3770_width = p3770_w, + p4040_mass = p4040_m, p4040_scale = p4040_s, p4040_phase = p4040_p, p4040_width = p4040_w, + p4160_mass = p4160_m, p4160_scale = p4160_s, p4160_phase = p4160_p, p4160_width = p4160_w, + p4415_mass = p4415_m, p4415_scale = p4415_s, p4415_phase = p4415_p, p4415_width = p4415_w, + rho_mass = rho_m, rho_scale = rho_s, rho_phase = rho_p, rho_width = rho_w, + omega_mass = omega_m, omega_scale = omega_s, omega_phase = omega_p, omega_width = omega_w, + phi_mass = phi_m, phi_scale = phi_s, phi_phase = phi_p, phi_width = phi_w, + Dstar_mass = Dstar_m, DDstar_scale = DDstar_s, DDstar_phase = DDstar_p, D_mass = D_m, + Dbar_mass = Dbar_m, Dbar_scale = Dbar_s, Dbar_phase = Dbar_p, + tau_mass = tau_m, C_tt = Ctt, b0_0 = b0_0, b0_1 = b0_1, b0_2 = b0_2, + bplus_0 = bplus_0, bplus_1 = bplus_1, bplus_2 = bplus_2, + bT_0 = bT_0, bT_1 = bT_1, bT_2 = bT_2) + +total_f_fit = total_pdf_full(obs=obs_fit, jpsi_mass = jpsi_m, jpsi_scale = jpsi_s, jpsi_phase = jpsi_p, jpsi_width = jpsi_w, + psi2s_mass = psi2s_m, psi2s_scale = psi2s_s, psi2s_phase = psi2s_p, psi2s_width = psi2s_w, + p3770_mass = p3770_m, p3770_scale = p3770_s, p3770_phase = p3770_p, p3770_width = p3770_w, + p4040_mass = p4040_m, p4040_scale = p4040_s, p4040_phase = p4040_p, p4040_width = p4040_w, + p4160_mass = p4160_m, p4160_scale = p4160_s, p4160_phase = p4160_p, p4160_width = p4160_w, + p4415_mass = p4415_m, p4415_scale = p4415_s, p4415_phase = p4415_p, p4415_width = p4415_w, + rho_mass = rho_m, rho_scale = rho_s, rho_phase = rho_p, rho_width = rho_w, + omega_mass = omega_m, omega_scale = omega_s, omega_phase = omega_p, omega_width = omega_w, + phi_mass = phi_m, phi_scale = phi_s, phi_phase = phi_p, phi_width = phi_w, + Dstar_mass = Dstar_m, DDstar_scale = DDstar_s, DDstar_phase = DDstar_p, D_mass = D_m, + Dbar_mass = Dbar_m, Dbar_scale = Dbar_s, Dbar_phase = Dbar_p, + tau_mass = tau_m, C_tt = Ctt, b0_0 = b0_0, b0_1 = b0_1, b0_2 = b0_2, + bplus_0 = bplus_0, bplus_1 = bplus_1, bplus_2 = bplus_2, + bT_0 = bT_0, bT_1 = bT_1, bT_2 = bT_2) + +# print(total_pdf.obs) + +# print(calcs_test) + +# for param in total_f.get_dependents(): +# print(zfit.run(param)) + + +# In[ ]: + + +# total_f_fit.normalization(obs_fit) + + +# ## Test if graphs actually work and compute values + +# In[ ]: + + +# def total_test_tf(xq): + +# def jpsi_res(q): +# return resonance(q, jpsi_m, jpsi_s, jpsi_p, jpsi_w) + +# def psi2s_res(q): +# return resonance(q, psi2s_m, psi2s_s, psi2s_p, psi2s_w) + +# def cusp(q): +# return bifur_gauss(q, cusp_m, sig_L, sig_R, cusp_s) + +# funcs = jpsi_res(xq) + psi2s_res(xq) + cusp(xq) + +# vec_f = vec(xq, funcs) + +# axiv_nr = axiv_nonres(xq) + +# tot = vec_f + axiv_nr + +# return tot + +# def jpsi_res(q): +# return resonance(q, jpsi_m, jpsi_s, jpsi_p, jpsi_w) + +# calcs = zfit.run(total_test_tf(x_part)) + + + +test_q = np.linspace(x_min, x_max, int(2e6)) + +probs = total_f_fit.pdf(test_q, norm_range=False) + +calcs_test = zfit.run(probs) + +Ctt.set_value(0.5) + +calcs_test1 = zfit.run(probs) + +Ctt.set_value(0.0) + +Dbar_s.set_value(0.3) + +DDstar_s.set_value(0.3) + +calcs_test2 = zfit.run(probs) +# res_y = zfit.run(jpsi_res(test_q)) +# b0 = [b0_0, b0_1, b0_2] +# bplus = [bplus_0, bplus_1, bplus_2] +# bT = [bT_0, bT_1, bT_2] +# f0_y = zfit.run(tf.math.real(formfactor(test_q,"0", b0, bplus, bT))) +# fplus_y = zfit.run(tf.math.real(formfactor(test_q,"+", b0, bplus, bT))) +# fT_y = zfit.run(tf.math.real(formfactor(test_q,"T", b0, bplus, bT))) + + +# In[ ]: + + +plt.clf() +# plt.plot(x_part, calcs, '.') +plt.plot(test_q, calcs_test, label = 'pdf (Ctt = 0.0)') +plt.plot(test_q, calcs_test1, label = 'pdf (Ctt = 0.5)') +plt.plot(test_q, calcs_test2, label = 'pdf (D-contribs = 0.3)') +# plt.plot(test_q, f0_y, label = '0') +# plt.plot(test_q, fT_y, label = 'T') +# plt.plot(test_q, fplus_y, label = '+') +# plt.plot(test_q, res_y, label = 'res') +plt.legend() +plt.ylim(0.0, 1.5e-6) +# plt.yscale('log') +# plt.xlim(770, 785) +plt.savefig('test.png') +# print(jpsi_width) + + +# In[ ]: + + + + +# probs = mixture.prob(test_q) +# probs_np = zfit.run(probs) +# probs_np *= np.max(calcs_test) / np.max(probs_np) +# plt.figure() +# plt.semilogy(test_q, probs_np,label="importance sampling") +# plt.semilogy(test_q, calcs_test, label = 'pdf') + + +# In[ ]: + + +# 0.213/(0.00133+0.213+0.015) + + +# ## Adjust scaling of different parts + +# In[ ]: + + +total_f.update_integration_options(draws_per_dim=2000000, mc_sampler=None) +# inte = total_f.integrate(limits = (950., 1050.), norm_range=False) +# inte_fl = zfit.run(inte) +# print(inte_fl/4500) +# print(pdg["jpsi_BR"]/pdg["NR_BR"], inte_fl*pdg["psi2s_auc"]/pdg["NR_auc"]) + + +# In[ ]: + + +# # print("jpsi:", inte_fl) +# # print("Increase am by factor:", np.sqrt(pdg["jpsi_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) +# # print("New amp:", pdg["jpsi"][3]*np.sqrt(pdg["jpsi_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) + +# # print("psi2s:", inte_fl) +# # print("Increase am by factor:", np.sqrt(pdg["psi2s_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) +# # print("New amp:", pdg["psi2s"][3]*np.sqrt(pdg["psi2s_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) + +# name = "phi" + +# print(name+":", inte_fl) +# print("Increase am by factor:", np.sqrt(pdg[name+"_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) +# print("New amp:", pdg[name][0]*np.sqrt(pdg[name+"_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) + + +# print(x_min) +# print(x_max) +# # total_f.update_integration_options(draws_per_dim=2000000, mc_sampler=None) +# total_f.update_integration_options(mc_sampler=lambda dim, num_results, +# dtype: tf.random_uniform(maxval=1., shape=(num_results, dim), dtype=dtype), +# draws_per_dim=1000000) +# # _ = [] + +# # for i in range(10): + +# # inte = total_f.integrate(limits = (x_min, x_max)) +# # inte_fl = zfit.run(inte) +# # print(inte_fl) +# # _.append(inte_fl) + +# # print("mean:", np.mean(_)) + +# _ = time.time() + +# inte = total_f.integrate(limits = (x_min, x_max)) +# inte_fl = zfit.run(inte) +# print(inte_fl) +# print("Time taken: {}".format(display_time(int(time.time() - _)))) + +# print(pdg['NR_BR']/pdg['NR_auc']*inte_fl) +# print(0.25**2*4.2/1000) + + +# # Sampling +# ## Mixture distribution for sampling + +# In[ ]: + + + + +# print(list_of_borders[:9]) +# print(list_of_borders[-9:]) + + +class UniformSampleAndWeights(zfit.util.execution.SessionHolderMixin): + def __call__(self, limits, dtype, n_to_produce): + # n_to_produce = tf.cast(n_to_produce, dtype=tf.int32) + low, high = limits.limit1d + low = tf.cast(low, dtype=dtype) + high = tf.cast(high, dtype=dtype) +# uniform = tfd.Uniform(low=low, high=high) +# uniformjpsi = tfd.Uniform(low=tf.constant(3080, dtype=dtype), high=tf.constant(3112, dtype=dtype)) +# uniformpsi2s = tfd.Uniform(low=tf.constant(3670, dtype=dtype), high=tf.constant(3702, dtype=dtype)) + +# list_of_borders = [] +# _p = [] +# splits = 10 + +# _ = np.linspace(x_min, x_max, splits) + +# for i in range(splits): +# list_of_borders.append(tf.constant(_[i], dtype=dtype)) +# _p.append(tf.constant(1/splits, dtype=dtype)) + +# mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=_p[:(splits-1)]), +# components_distribution=tfd.Uniform(low=list_of_borders[:(splits-1)], +# high=list_of_borders[-(splits-1):])) + mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=[tf.constant(0.05, dtype=dtype), + tf.constant(0.93, dtype=dtype), + tf.constant(0.05, dtype=dtype), + tf.constant(0.065, dtype=dtype), + tf.constant(0.04, dtype=dtype), + tf.constant(0.05, dtype=dtype)]), + components_distribution=tfd.Uniform(low=[tf.constant(x_min, dtype=dtype), + tf.constant(3090, dtype=dtype), + tf.constant(3681, dtype=dtype), + tf.constant(3070, dtype=dtype), + tf.constant(1000, dtype=dtype), + tf.constant(3660, dtype=dtype)], + high=[tf.constant(x_max, dtype=dtype), + tf.constant(3102, dtype=dtype), + tf.constant(3691, dtype=dtype), + tf.constant(3110, dtype=dtype), + tf.constant(1040, dtype=dtype), + tf.constant(3710, dtype=dtype)])) +# dtype = tf.float64 +# mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=[tf.constant(0.04, dtype=dtype), +# tf.constant(0.90, dtype=dtype), +# tf.constant(0.02, dtype=dtype), +# tf.constant(0.07, dtype=dtype), +# tf.constant(0.02, dtype=dtype)]), +# components_distribution=tfd.Uniform(low=[tf.constant(x_min, dtype=dtype), +# tf.constant(3089, dtype=dtype), +# tf.constant(3103, dtype=dtype), +# tf.constant(3681, dtype=dtype), +# tf.constant(3691, dtype=dtype)], +# high=[tf.constant(3089, dtype=dtype), +# tf.constant(3103, dtype=dtype), +# tf.constant(3681, dtype=dtype), +# tf.constant(3691, dtype=dtype), +# tf.constant(x_max, dtype=dtype)])) +# mixture = tfd.Uniform(tf.constant(x_min, dtype=dtype), tf.constant(x_max, dtype=dtype)) +# sample = tf.random.uniform((n_to_produce, 1), dtype=dtype) + sample = mixture.sample((n_to_produce, 1)) +# sample = tf.random.uniform((n_to_produce, 1), dtype=dtype) + weights = mixture.prob(sample)[:,0] +# weights = tf.broadcast_to(tf.constant(1., dtype=dtype), shape=(n_to_produce,)) + # sample = tf.expand_dims(sample, axis=-1) +# print(sample, weights) + +# weights = tf.ones(shape=(n_to_produce,), dtype=dtype) + weights_max = None + thresholds = tf.random_uniform(shape=(n_to_produce,), dtype=dtype) + return sample, thresholds, weights, weights_max, n_to_produce + + +# In[ ]: + + +# total_f._sample_and_weights = UniformSampleAndWeights + + +# In[ ]: + + +# 0.00133/(0.00133+0.213+0.015)*(x_max-3750)/(x_max-x_min) + + +# In[ ]: + + +# zfit.settings.set_verbosity(10) + + +# In[ ]: + + +# # zfit.run.numeric_checks = False + +# nr_of_toys = 1 +# nevents = int(pdg["number_of_decays"]) +# nevents = pdg["number_of_decays"] +# event_stack = 1000000 +# # zfit.settings.set_verbosity(10) +# calls = int(nevents/event_stack + 1) + +# total_samp = [] + +# start = time.time() + +# sampler = total_f.create_sampler(n=event_stack) + +# for toy in range(nr_of_toys): + +# dirName = 'data/zfit_toys/toy_{0}'.format(toy) + +# if not os.path.exists(dirName): +# os.mkdir(dirName) +# print("Directory " , dirName , " Created ") + +# for call in range(calls): + +# sampler.resample(n=event_stack) +# s = sampler.unstack_x() +# sam = zfit.run(s) +# # clear_output(wait=True) + +# c = call + 1 + +# print("{0}/{1} of Toy {2}/{3}".format(c, calls, toy+1, nr_of_toys)) +# print("Time taken: {}".format(display_time(int(time.time() - start)))) +# print("Projected time left: {}".format(display_time(int((time.time() - start)/(c+calls*(toy))*((nr_of_toys-toy)*calls-c))))) + +# with open("data/zfit_toys/toy_{0}/{1}.pkl".format(toy, call), "wb") as f: +# pkl.dump(sam, f, pkl.HIGHEST_PROTOCOL) + + +# In[ ]: + + +# with open(r"data/zfit_toys/toy_0/0.pkl", "rb") as input_file: +# sam = pkl.load(input_file) +# print(sam[:10]) + +# with open(r"data/zfit_toys/toy_0/1.pkl", "rb") as input_file: +# sam2 = pkl.load(input_file) +# print(sam2[:10]) + +# print(np.sum(sam-sam2)) + + +# In[ ]: + + +# print("Time to generate full toy: {} s".format(int(time.time()-start))) + +# total_samp = [] + +# for call in range(calls): +# with open(r"data/zfit_toys/toy_0/{}.pkl".format(call), "rb") as input_file: +# sam = pkl.load(input_file) +# total_samp = np.append(total_samp, sam) + +# total_samp = total_samp.astype('float64') + +# data2 = zfit.data.Data.from_numpy(array=total_samp[:int(nevents)], obs=obs) + +# data3 = zfit.data.Data.from_numpy(array=total_samp, obs=obs) + +# print(total_samp[:nevents].shape) + + +# In[ ]: + + +# plt.clf() + +# bins = int((x_max-x_min)/7) + +# # calcs = zfit.run(total_test_tf(samp)) +# print(total_samp[:nevents].shape) + +# plt.hist(total_samp[:nevents], bins = bins, range = (x_min,x_max), label = 'data') +# # plt.plot(test_q, calcs_test*nevents , label = 'pdf') + +# # plt.plot(sam, calcs, '.') +# # plt.plot(test_q, calcs_test) +# # plt.yscale('log') +# plt.ylim(0, 200) +# # plt.xlim(3080, 3110) + +# plt.legend() + +# plt.savefig('test2.png') + + +# In[ ]: + + +# sampler = total_f.create_sampler(n=nevents) +# nll = zfit.loss.UnbinnedNLL(model=total_f, data=sampler, fit_range = (x_min, x_max)) + +# # for param in pdf.get_dependents(): +# # param.set_value(initial_value) + +# sampler.resample(n=nevents) + +# # Randomise initial values +# # for param in pdf.get_dependents(): +# # param.set_value(random value here) + +# # Minimise the NLL +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 10) +# minimum = minimizer.minimize(nll) + + +# In[ ]: + + +# jpsi_width + + +# In[ ]: + + +# plt.hist(sample, weights=1 / prob(sample)) + + +# # Fitting + +# In[ ]: + + +# start = time.time() + +# for param in total_f.get_dependents(): +# param.randomize() + +# # for param in total_f.get_dependents(): +# # print(zfit.run(param)) + +# nll = zfit.loss.UnbinnedNLL(model=total_f, data=data2, fit_range = (x_min, x_max)) + +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) +# # minimizer._use_tfgrad = False +# result = minimizer.minimize(nll) + +# # param_errors = result.error() + +# # for var, errors in param_errors.items(): +# # print('{}: ^{{+{}}}_{{{}}}'.format(var.name, errors['upper'], errors['lower'])) + +# print("Function minimum:", result.fmin) +# # print("Results:", result.params) +# print("Hesse errors:", result.hesse()) + + +# In[ ]: + + +# print("Time taken for fitting: {}".format(display_time(int(time.time()-start)))) + +# # probs = total_f.pdf(test_q) + +# calcs_test = zfit.run(probs) +# res_y = zfit.run(jpsi_res(test_q)) + + +# In[ ]: + + +# plt.clf() +# # plt.plot(x_part, calcs, '.') +# plt.plot(test_q, calcs_test, label = 'pdf') +# # plt.plot(test_q, res_y, label = 'res') +# plt.legend() +# plt.ylim(0.0, 10e-6) +# # plt.yscale('log') +# # plt.xlim(3080, 3110) +# plt.savefig('test3.png') +# # print(jpsi_width) + + +# In[ ]: + + +# _tot = 4.37e-7+6.02e-5+4.97e-6 +# _probs = [] +# _probs.append(6.02e-5/_tot) +# _probs.append(4.97e-6/_tot) +# _probs.append(4.37e-7/_tot) +# print(_probs) + + +# In[ ]: + + +# dtype = 'float64' +# # mixture = tfd.Uniform(tf.constant(x_min, dtype=dtype), tf.constant(x_max, dtype=dtype)) +# mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=[tf.constant(0.007, dtype=dtype), +# tf.constant(0.917, dtype=dtype), +# tf.constant(0.076, dtype=dtype)]), +# components_distribution=tfd.Uniform(low=[tf.constant(x_min, dtype=dtype), +# tf.constant(3080, dtype=dtype), +# tf.constant(3670, dtype=dtype)], +# high=[tf.constant(x_max, dtype=dtype), +# tf.constant(3112, dtype=dtype), +# tf.constant(3702, dtype=dtype)])) +# # for i in range(10): +# # print(zfit.run(mixture.prob(mixture.sample((10, 1))))) + + +# In[ ]: + + +# print((zfit.run(jpsi_p)%(2*np.pi))/np.pi) +# print((zfit.run(psi2s_p)%(2*np.pi))/np.pi) + + +# In[ ]: + + +# def jpsi_res(q): +# return resonance(q, _mass = jpsi_mass, scale = jpsi_scale, +# phase = jpsi_phase, width = jpsi_width) + +# def psi2s_res(q): +# return resonance(q, _mass = psi2s_mass, scale = psi2s_scale, +# phase = psi2s_phase, width = psi2s_width) + +# def p3770_res(q): +# return resonance(q, _mass = p3770_mass, scale = p3770_scale, +# phase = p3770_phase, width = p3770_width) + +# def p4040_res(q): +# return resonance(q, _mass = p4040_mass, scale = p4040_scale, +# phase = p4040_phase, width = p4040_width) + +# def p4160_res(q): +# return resonance(q, _mass = p4160_mass, scale = p4160_scale, +# phase = p4160_phase, width = p4160_width) + +# def p4415_res(q): +# return resonance(q, _mass = p4415_mass, scale = p4415_scale, +# phase = p4415_phase, width = p4415_width) + + +# In[ ]: + + +# 0.15**2*4.2/1000 +# result.hesse() + + +# ## Constraints + +# In[ ]: + + +# 1. Constraint - Real part of sum of Psi contrib and D contribs + +sum_list = [] + +sum_list.append(ztf.to_complex(jpsi_s) * tf.exp(tf.complex(ztf.constant(0.0), jpsi_p)) * ztf.to_complex(jpsi_w / (tf.pow(jpsi_m,3)))) +sum_list.append(ztf.to_complex(psi2s_s) * tf.exp(tf.complex(ztf.constant(0.0), psi2s_p)) * ztf.to_complex(psi2s_w / (tf.pow(psi2s_m,3)))) +sum_list.append(ztf.to_complex(p3770_s) * tf.exp(tf.complex(ztf.constant(0.0), p3770_p)) * ztf.to_complex(p3770_w / (tf.pow(p3770_m,3)))) +sum_list.append(ztf.to_complex(p4040_s) * tf.exp(tf.complex(ztf.constant(0.0), p4040_p)) * ztf.to_complex(p4040_w / (tf.pow(p4040_m,3)))) +sum_list.append(ztf.to_complex(p4160_s) * tf.exp(tf.complex(ztf.constant(0.0), p4160_p)) * ztf.to_complex(p4160_w / (tf.pow(p4160_m,3)))) +sum_list.append(ztf.to_complex(p4415_s) * tf.exp(tf.complex(ztf.constant(0.0), p4415_p)) * ztf.to_complex(p4415_w / (tf.pow(p4415_m,3)))) +sum_list.append(ztf.to_complex(DDstar_s) * tf.exp(tf.complex(ztf.constant(0.0), DDstar_p)) * (ztf.to_complex(1.0 / (10.0*tf.pow(Dstar_m,2)) + 1.0 / (10.0*tf.pow(D_m,2))))) +sum_list.append(ztf.to_complex(Dbar_s) * tf.exp(tf.complex(ztf.constant(0.0), Dbar_p)) * ztf.to_complex(1.0 / (6.0*tf.pow(Dbar_m,2)))) + +sum_ru_1 = ztf.to_complex(ztf.constant(0.0)) + +for part in sum_list: + sum_ru_1 += part + +sum_1 = tf.math.real(sum_ru_1) +# constraint1 = zfit.constraint.GaussianConstraint(params = sum_1, mu = ztf.constant(1.7*10**-8), +# sigma = ztf.constant(2.2*10**-8)) + +constraint1 = tf.pow((sum_1-ztf.constant(1.7*10**-8))/ztf.constant(2.2*10**-8),2)/ztf.constant(2.) + +# 2. Constraint - Abs. of sum of Psi contribs and D contribs + +sum_2 = tf.abs(sum_ru_1) +constraint2 = tf.cond(tf.greater_equal(sum_2, 5.0e-8), lambda: 100000., lambda: 0.) + +# 3. Constraint - Maximum eta of D contribs + +constraint3_0 = tf.cond(tf.greater_equal(tf.abs(Dbar_s), 0.2), lambda: 100000., lambda: 0.) + +constraint3_1 = tf.cond(tf.greater_equal(tf.abs(DDstar_s), 0.2), lambda: 100000., lambda: 0.) + +# 4. Constraint - Formfactor multivariant gaussian covariance fplus + +Cov_matrix = [[ztf.constant( 1.), ztf.constant( 0.45), ztf.constant( 0.19), ztf.constant(0.857), ztf.constant(0.598), ztf.constant(0.531), ztf.constant(0.752), ztf.constant(0.229), ztf.constant(0,117)], + [ztf.constant( 0.45), ztf.constant( 1.), ztf.constant(0.677), ztf.constant(0.708), ztf.constant(0.958), ztf.constant(0.927), ztf.constant(0.227), ztf.constant(0.443), ztf.constant(0.287)], + [ztf.constant( 0.19), ztf.constant(0.677), ztf.constant( 1.), ztf.constant(0.595), ztf.constant(0.770), ztf.constant(0.819),ztf.constant(-0.023), ztf.constant( 0.07), ztf.constant(0.196)], + [ztf.constant(0.857), ztf.constant(0.708), ztf.constant(0.595), ztf.constant( 1.), ztf.constant( 0.83), ztf.constant(0.766), ztf.constant(0.582), ztf.constant(0.237), ztf.constant(0.192)], + [ztf.constant(0.598), ztf.constant(0.958), ztf.constant(0.770), ztf.constant( 0.83), ztf.constant( 1.), ztf.constant(0.973), ztf.constant(0.324), ztf.constant(0.372), ztf.constant(0.272)], + [ztf.constant(0.531), ztf.constant(0.927), ztf.constant(0.819), ztf.constant(0.766), ztf.constant(0.973), ztf.constant( 1.), ztf.constant(0.268), ztf.constant(0.332), ztf.constant(0.269)], + [ztf.constant(0.752), ztf.constant(0.227),ztf.constant(-0.023), ztf.constant(0.582), ztf.constant(0.324), ztf.constant(0.268), ztf.constant( 1.), ztf.constant( 0.59), ztf.constant(0.515)], + [ztf.constant(0.229), ztf.constant(0.443), ztf.constant( 0.07), ztf.constant(0.237), ztf.constant(0.372), ztf.constant(0.332), ztf.constant( 0.59), ztf.constant( 1.), ztf.constant(0.897)], + [ztf.constant(0.117), ztf.constant(0.287), ztf.constant(0.196), ztf.constant(0.192), ztf.constant(0.272), ztf.constant(0.269), ztf.constant(0.515), ztf.constant(0.897), ztf.constant( 1.)]] + +def triGauss(val1,val2,val3,m = Cov_matrix): + + mean1 = ztf.constant(0.466) + mean2 = ztf.constant(-0.885) + mean3 = ztf.constant(-0.213) + sigma1 = ztf.constant(0.014) + sigma2 = ztf.constant(0.128) + sigma3 = ztf.constant(0.548) + x1 = (val1-mean1)/sigma1 + x2 = (val2-mean2)/sigma2 + x3 = (val3-mean3)/sigma3 + rho12 = m[0][1] + rho13 = m[0][2] + rho23 = m[1][2] + w = x1*x1*(rho23*rho23-1) + x2*x2*(rho13*rho13-1)+x3*x3*(rho12*rho12-1)+2*(x1*x2*(rho12-rho13*rho23)+x1*x3*(rho13-rho12*rho23)+x2*x3*(rho23-rho12*rho13)) + d = 2*(rho12*rho12+rho13*rho13+rho23*rho23-2*rho12*rho13*rho23-1) + + fcn = -w/d + chisq = -2*fcn + return chisq + +constraint4 = triGauss(bplus_0, bplus_1, bplus_2) + +# mean1 = ztf.constant(0.466) +# mean2 = ztf.constant(-0.885) +# mean3 = ztf.constant(-0.213) +# sigma1 = ztf.constant(0.014) +# sigma2 = ztf.constant(0.128) +# sigma3 = ztf.constant(0.548) +# constraint4_0 = tf.pow((bplus_0-mean1)/sigma1,2)/ztf.constant(2.) +# constraint4_1 = tf.pow((bplus_1-mean2)/sigma2,2)/ztf.constant(2.) +# constraint4_2 = tf.pow((bplus_2-mean3)/sigma3,2)/ztf.constant(2.) + +# 5. Constraint - Abs. of sum of light contribs + +sum_list_5 = [] + +sum_list_5.append(rho_s*rho_w/rho_m) +sum_list_5.append(omega_s*omega_w/omega_m) +sum_list_5.append(phi_s*phi_w/phi_m) + + +sum_ru_5 = ztf.constant(0.0) + +for part in sum_list_5: + sum_ru_5 += part + +constraint5 = tf.cond(tf.greater_equal(tf.abs(sum_ru_5), ztf.constant(0.02)), lambda: 100000., lambda: 0.) + +# 6. Constraint on phases of Jpsi and Psi2s for cut out fit + + +# constraint6_0 = zfit.constraint.GaussianConstraint(params = jpsi_p, mu = ztf.constant(pdg["jpsi_phase_unc"]), +# sigma = ztf.constant(jpsi_phase)) +# constraint6_1 = zfit.constraint.GaussianConstraint(params = psi2s_p, mu = ztf.constant(pdg["psi2s_phase_unc"]), +# sigma = ztf.constant(psi2s_phase)) + +constraint6_0 = tf.pow((jpsi_p-ztf.constant(jpsi_phase))/ztf.constant(pdg["jpsi_phase_unc"]),2)/ztf.constant(2.) +constraint6_1 = tf.pow((psi2s_p-ztf.constant(psi2s_phase))/ztf.constant(pdg["psi2s_phase_unc"]),2)/ztf.constant(2.) + +# 7. Constraint on Ctt with higher limits + +constraint7 = tf.cond(tf.greater_equal(Ctt*Ctt, 0.25), lambda: 100000., lambda: 0.) + +constraint7dtype = tf.float64 + +# zfit.run(constraint6_0) + +# ztf.convert_to_tensor(constraint6_0) + +#List of all constraints + +constraints = [constraint1, constraint2, constraint3_0, constraint3_1,# constraint4, #constraint4_0, constraint4_1, constraint4_2, + constraint6_0, constraint6_1]#, constraint7] + + +# ## Reset params + +# In[ ]: + + +param_values_dic = { + 'jpsi_m': jpsi_mass, + 'jpsi_s': jpsi_scale, + 'jpsi_p': jpsi_phase, + 'jpsi_w': jpsi_width, + 'psi2s_m': psi2s_mass, + 'psi2s_s': psi2s_scale, + 'psi2s_p': psi2s_phase, + 'psi2s_w': psi2s_width, + 'p3770_m': p3770_mass, + 'p3770_s': p3770_scale, + 'p3770_p': p3770_phase, + 'p3770_w': p3770_width, + 'p4040_m': p4040_mass, + 'p4040_s': p4040_scale, + 'p4040_p': p4040_phase, + 'p4040_w': p4040_width, + 'p4160_m': p4160_mass, + 'p4160_s': p4160_scale, + 'p4160_p': p4160_phase, + 'p4160_w': p4160_width, + 'p4415_m': p4415_mass, + 'p4415_s': p4415_scale, + 'p4415_p': p4415_phase, + 'p4415_w': p4415_width, + 'rho_m': rho_mass, + 'rho_s': rho_scale, + 'rho_p': rho_phase, + 'rho_w': rho_width, + 'omega_m': omega_mass, + 'omega_s': omega_scale, + 'omega_p': omega_phase, + 'omega_w': omega_width, + 'phi_m': phi_mass, + 'phi_s': phi_scale, + 'phi_p': phi_phase, + 'phi_w': phi_width, + 'Dstar_m': Dstar_mass, + 'DDstar_s': 0.0, + 'DDstar_p': 0.0, + 'D_m': D_mass, + 'Dbar_m': Dbar_mass, + 'Dbar_s': 0.0, + 'Dbar_p': 0.0, + 'tau_m': pdg['tau_M'], + 'Ctt': 0.0, + 'b0_0': 0.292, + 'b0_1': 0.281, + 'b0_2': 0.150, + 'bplus_0': 0.466, + 'bplus_1': -0.885, + 'bplus_2': -0.213, + 'bT_0': 0.460, + 'bT_1': -1.089, + 'bT_2': -1.114} + + +def reset_param_values(variation = 0.05): + for param in total_f_fit.get_dependents(): + if param.floating: + param.set_value(param_values_dic[param.name] + random.uniform(-1, 1) * param_values_dic[param.name]* variation) +# print(param.name) +# for param in totalf.get_dependents(): +# param.set_value() + + +# # Analysis + +# In[ ]: + + +# # zfit.run.numeric_checks = False + +# fitting_range = 'cut' +# total_BR = 1.7e-10 + 4.9e-10 + 2.5e-9 + 6.02e-5 + 4.97e-6 + 1.38e-9 + 4.2e-10 + 2.6e-9 + 6.1e-10 + 4.37e-7 +# cut_BR = 1.0 - (6.02e-5 + 4.97e-6)/total_BR + +# Ctt_list = [] +# Ctt_error_list = [] + +# nr_of_toys = 1 +# if fitting_range == 'cut': +# nevents = int(pdg["number_of_decays"]*cut_BR) +# else: +# nevents = int(pdg["number_of_decays"]) +# # nevents = pdg["number_of_decays"] +# event_stack = 1000000 +# # nevents *= 41 +# # zfit.settings.set_verbosity(10) +# calls = int(nevents/event_stack + 1) + +# total_samp = [] + +# start = time.time() + +# sampler = total_f.create_sampler(n=event_stack) + +# for toy in range(nr_of_toys): + +# ### Generate data + +# # clear_output(wait=True) + +# print("Toy {}: Generating data...".format(toy)) + +# dirName = 'data/zfit_toys/toy_{0}'.format(toy) + +# if not os.path.exists(dirName): +# os.mkdir(dirName) +# print("Directory " , dirName , " Created ") + +# reset_param_values() + +# if fitting_range == 'cut': + +# sampler.resample(n=nevents) +# s = sampler.unstack_x() +# sam = zfit.run(s) +# calls = 0 +# c = 1 + +# else: +# for call in range(calls): + +# sampler.resample(n=event_stack) +# s = sampler.unstack_x() +# sam = zfit.run(s) + +# c = call + 1 + +# with open("data/zfit_toys/toy_{0}/{1}.pkl".format(toy, call), "wb") as f: +# pkl.dump(sam, f, pkl.HIGHEST_PROTOCOL) + +# print("Toy {}: Data generation finished".format(toy)) + +# ### Load data + +# print("Toy {}: Loading data...".format(toy)) + +# if fitting_range == 'cut': + +# total_samp = sam + +# else: + +# for call in range(calls): +# with open(r"data/zfit_toys/toy_0/{}.pkl".format(call), "rb") as input_file: +# sam = pkl.load(input_file) +# total_samp = np.append(total_samp, sam) + +# total_samp = total_samp.astype('float64') + +# if fitting_range == 'full': + +# data = zfit.data.Data.from_numpy(array=total_samp[:int(nevents)], obs=obs) + +# print("Toy {}: Loading data finished".format(toy)) + +# ### Fit data + +# print("Toy {}: Fitting pdf...".format(toy)) + +# for param in total_f.get_dependents(): +# param.randomize() + +# nll = zfit.loss.UnbinnedNLL(model=total_f, data=data, fit_range = (x_min, x_max), constraints = constraints) + +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) +# # minimizer._use_tfgrad = False +# result = minimizer.minimize(nll) + +# print("Toy {}: Fitting finished".format(toy)) + +# print("Function minimum:", result.fmin) +# print("Hesse errors:", result.hesse()) + +# params = result.params +# Ctt_list.append(params[Ctt]['value']) +# Ctt_error_list.append(params[Ctt]['minuit_hesse']['error']) + +# #plotting the result + +# plotdirName = 'data/plots'.format(toy) + +# if not os.path.exists(plotdirName): +# os.mkdir(plotdirName) +# # print("Directory " , dirName , " Created ") + +# probs = total_f.pdf(test_q, norm_range=False) +# calcs_test = zfit.run(probs) +# plt.clf() +# plt.plot(test_q, calcs_test, label = 'pdf') +# plt.legend() +# plt.ylim(0.0, 6e-6) +# plt.savefig(plotdirName + '/toy_fit_full_range{}.png'.format(toy)) + +# print("Toy {0}/{1}".format(toy+1, nr_of_toys)) +# print("Time taken: {}".format(display_time(int(time.time() - start)))) +# print("Projected time left: {}".format(display_time(int((time.time() - start)/(c+calls*(toy))*((nr_of_toys-toy)*calls-c))))) + +# if fitting_range == 'cut': + +# _1 = np.where((total_samp >= x_min) & (total_samp <= (jpsi_mass - 60.))) + +# tot_sam_1 = total_samp[_1] + +# _2 = np.where((total_samp >= (jpsi_mass + 70.)) & (total_samp <= (psi2s_mass - 50.))) + +# tot_sam_2 = total_samp[_2] + +# _3 = np.where((total_samp >= (psi2s_mass + 50.)) & (total_samp <= x_max)) + +# tot_sam_3 = total_samp[_3] + +# tot_sam = np.append(tot_sam_1, tot_sam_2) +# tot_sam = np.append(tot_sam, tot_sam_3) + +# data = zfit.data.Data.from_numpy(array=tot_sam[:int(nevents)], obs=obs_fit) + +# print("Toy {}: Loading data finished".format(toy)) + +# ### Fit data + +# print("Toy {}: Fitting pdf...".format(toy)) + +# for param in total_f_fit.get_dependents(): +# param.randomize() + +# nll = zfit.loss.UnbinnedNLL(model=total_f_fit, data=data, constraints = constraints) + +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) +# # minimizer._use_tfgrad = False +# result = minimizer.minimize(nll) + +# print("Function minimum:", result.fmin) +# print("Hesse errors:", result.hesse()) + +# params = result.params + +# if result.converged: +# Ctt_list.append(params[Ctt]['value']) +# Ctt_error_list.append(params[Ctt]['minuit_hesse']['error']) + +# #plotting the result + +# plotdirName = 'data/plots'.format(toy) + +# if not os.path.exists(plotdirName): +# os.mkdir(plotdirName) +# # print("Directory " , dirName , " Created ") + +# plt.clf() +# plt.hist(tot_sam, bins = int((x_max-x_min)/7.), label = 'toy data') +# plt.savefig(plotdirName + '/toy_histo_cut_region{}.png'.format(toy)) + + +# probs = total_f_fit.pdf(test_q, norm_range=False) +# calcs_test = zfit.run(probs) +# plt.clf() +# plt.plot(test_q, calcs_test, label = 'pdf') +# plt.axvline(x=jpsi_mass-60.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.axvline(x=jpsi_mass+70.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.axvline(x=psi2s_mass-50.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.axvline(x=psi2s_mass+50.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.legend() +# plt.ylim(0.0, 1.5e-6) +# plt.savefig(plotdirName + '/toy_fit_cut_region{}.png'.format(toy)) + +# print("Toy {0}/{1}".format(toy+1, nr_of_toys)) +# print("Time taken: {}".format(display_time(int(time.time() - start)))) +# print("Projected time left: {}".format(display_time(int((time.time() - start)/(toy+1))*((nr_of_toys-toy-1))))) + + + +# In[ ]: + + +# with open("data/results/Ctt_list.pkl", "wb") as f: +# pkl.dump(Ctt_list, f, pkl.HIGHEST_PROTOCOL) +# with open("data/results/Ctt_error_list.pkl", "wb") as f: +# pkl.dump(Ctt_error_list, f, pkl.HIGHEST_PROTOCOL) + + +# In[ ]: + + +# print('{0}/{1} fits converged'.format(len(Ctt_list), nr_of_toys)) +# print('Mean Ctt value = {}'.format(np.mean(Ctt_list))) +# print('Mean Ctt error = {}'.format(np.mean(Ctt_error_list))) +# print('95 Sensitivy = {}'.format(((2*np.mean(Ctt_error_list))**2)*4.2/1000)) + + +# In[ ]: + + +# plt.hist(tot_sam, bins = int((x_max-x_min)/7.)) + +# plt.show() + +# # _ = np.where((total_samp >= x_min) & (total_samp <= (jpsi_mass - 50.))) + +# tot_sam.shape + + +# In[ ]: + + +# Ctt.floating = False + + +# In[ ]: + + +# zfit.run(nll.value()) + + +# In[ ]: + + +# result.fmin + + +# In[ ]: + + +# BR_steps = np.linspace(0.0, 1e-3, 11) +pull_dic = {} + +mi = 1e-4 +ma = 3e-3 +ste = 20 + +for param in total_f_fit.get_dependents(): + if param.floating: + pull_dic[param.name] = [] + for step in range(2*ste): + pull_dic[param.name].append([]) + + + +def save_pulls(step): + for param in total_f_fit.get_dependents(): + if param.floating: + pull_dic[param.name][step].append((params[param]['value'] - param_values_dic[param.name])/params[param]['minuit_hesse']['error']) + + + +# for key in pull_dic.keys(): +# print(np.shape(pull_dic[key])) +# save_pulls(New_step=True) +# params[Ctt]['value'] + + +# In[ ]: + + +# for param in total_f_fit.get_dependents(): +# if param.floating: +# print(param.name) + +# print(params[Ctt]) + + +# # CLS Code + +# In[ ]: + + +# zfit.run.numeric_checks = False + +load = False + +bo = True + +D_contribs = True + +if not D_contribs: + Dbar_s.floating = False + Dbar_p.floating = False + DDstar_s.floating = False + DDstar_p.floating = False + +bo_set = 1 + +fitting_range = 'cut' +total_BR = 1.7e-10 + 4.9e-10 + 2.5e-9 + 6.02e-5 + 4.97e-6 + 1.38e-9 + 4.2e-10 + 2.6e-9 + 6.1e-10 + 4.37e-7 +cut_BR = 1.0 - (6.02e-5 + 4.97e-6)/total_BR + +Ctt_list = [] +Ctt_error_list = [] + +nr_of_toys = 1 +nevents = int(pdg["number_of_decays"]*cut_BR) +# nevents = pdg["number_of_decays"] +event_stack = 1000000 +# nevents *= 41 +# zfit.settings.set_verbosity(10) + +# mi = 1e-4 +# ma = 3e-3 +# ste = 13 + +BR_steps = np.linspace(mi, ma, ste) + +BR_steps[0] = 0.0 + +print(BR_steps) + +Ctt_steps = np.sqrt(BR_steps/4.2*1000) + +print(Ctt_steps) + +# total_samp = [] + +start = time.time() + +Nll_list = [] + +sampler = total_f.create_sampler(n=nevents, fixed_params = False) +sampler.set_data_range(obs_fit) + +__ = -1 + +#----------------------------------------------------- + +if not load: + for Ctt_step in Ctt_steps: + + __ += 1 + + for i in range(2): + Ctt_list.append([]) + Ctt_error_list.append([]) + Nll_list.append([]) + + for param in total_f_fit.get_dependents(): + if param.floating: + pull_dic[param.name].append([]) + + for toy in range(nr_of_toys): + + newset = True + + while newset: + + for floaty in [True, False]: + Ctt.floating = floaty + + for bo_step in range(bo_set): + + print('Step: {0}/{1}'.format(int(__), ste)) + print('Current Ctt: {0}'.format(Ctt_step)) + print('Ctt floating: {0}'.format(floaty)) + + reset_param_values(variation = 0.0) + + if floaty: + print('Toy {0}/{1} - Fit {2}/{3}'.format(toy, nr_of_toys, bo_step, bo_set)) + Ctt.set_value(Ctt_step) + + else: + Ctt.set_value(0.0) + print('Toy {0}/{1} - Fit {2}/{3}'.format(toy, nr_of_toys, bo_step, bo_set)) + + if newset: + sampler.resample(n=nevents) + data = sampler + newset = False + + ### Fit data + + if floaty: + #plt.clf() + #plt.title('Ctt value: {:.2f}'.format(Ctt_step)) + #plt.hist(zfit.run(data), bins = int((x_max-x_min)/7), range = (x_min, x_max)) + #plt.savefig('data/CLs/plots/set_histo{}.png'.format(__)) + _step = 2*__ + else: + _step = 2*__+1 + + nll = zfit.loss.UnbinnedNLL(model=total_f_fit, data=data, constraints = constraints) + + minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) + # minimizer._use_tfgrad = False + result = minimizer.minimize(nll) + + print("Function minimum:", result.fmin) + print("Hesse errors:", result.hesse()) + + params = result.params + + if result.converged: + + save_pulls(step = _step) + + if floaty: + Nll_list[-2].append(result.fmin) + Ctt_list[-2].append(params[Ctt]['value']) + Ctt_error_list[-2].append(params[Ctt]['minuit_hesse']['error']) + + else: + Nll_list[-1].append(result.fmin) + Ctt_list[-1].append(0.0) + Ctt_error_list[-1].append(0.0) + + + else: + for _ in [1,2]: + del Nll_list[-_][toy*bo_set:] +# print(np.shape(Nll_list[-_])) + del Ctt_list[-_][toy*bo_set:] + del Ctt_error_list[-_][toy*bo_set:] + for param in total_f_fit.get_dependents(): + if param.floating: + del pull_dic[param.name][_step+1-_][toy*bo_set:] + newset = True + break + + if not result.converged: + break + + print() + print('Time taken: {}'.format(display_time(int(time.time()-start)))) + print('Estimated time left: {}'.format(display_time(int((time.time()-start)/(__+(toy+1)/nr_of_toys)*(ste-__-(nr_of_toys-toy-1)/nr_of_toys))))) + + +# In[ ]: + + +if load: + + phase_combi = '--' + + if D_contribs: + D_dir = 'D-True' + else: + D_dir = 'D-False' + + _dir = 'data/CLs/finished/f1d1/{}/{}/'.format(phase_combi, D_dir) + + jobs = os.listdir(_dir) + + First = True + +# print(jobs) + + for job in jobs: + + dirName = _dir + str(job) + '/data/CLs' + + if not os.path.exists("{}/{}-{}_{}s{}b{}t--CLs_Nll_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys)): +# print(job) + continue + + with open(r"{}/variab.pkl".format(dirName), "rb") as input_file: + variab = pkl.load(input_file) +# print(variab) + + ### sanity check: + if variab['mi'] != mi or variab['ma'] != ma or variab['ste'] != ste or bo_set != bo_set: + print('Fitting parameters of data dont equal the ones given -- Job {} skipped!'.format(job)) + + with open(r"{}/{}-{}_{}s{}b{}t--CLs_Nll_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _Nll_list = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s{}b{}t--Ctt_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _Ctt_list = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s{}b{}t--Ctt_error_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _Ctt_error_list = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s{}b{}t--pull_dic.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _pull_dic = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s--CLs_list.pkl".format(dirName, mi,ma,ste), "rb") as input_file: + _CLs_list = pkl.load(input_file) + + + if First: + Nll_list = _Nll_list + Ctt_list = _Ctt_list + Ctt_error_list = _Ctt_error_list + pull_dic = _pull_dic +# print(_pull_dic) + CLs_list = _CLs_list + First = False + else: + for step in range(2*ste): +# print(Nll_list[step], step) + Nll_list[step].extend(_Nll_list[step]) + Ctt_list[step].extend(_Ctt_list[step]) + Ctt_error_list[step].extend(_Ctt_error_list[step]) + for key in pull_dic.keys(): +# print(key, np.shape(pull_dic[key])) + pull_dic[key][step].extend(_pull_dic[key][step]) + for step in range(ste): + CLs_list[step].extend(_CLs_list[step]) + +# print('----------------------') + + +# In[ ]: + + +dirName = 'data/CLs' + +# if bo and not load: +# for s in range(2*ste): +# Nll_list[s] = [np.min(Nll_list[s])] + + +if not load: + + if not os.path.exists(dirName): + os.mkdir(dirName) + print("Directory " , dirName , " Created ") + + with open("{}/{}-{}_{}s{}b{}t--CLs_Nll_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(Nll_list, f, pkl.HIGHEST_PROTOCOL) + + with open("{}/{}-{}_{}s{}b{}t--Ctt_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(Ctt_list, f, pkl.HIGHEST_PROTOCOL) + + with open("{}/{}-{}_{}s{}b{}t--Ctt_error_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(Ctt_error_list, f, pkl.HIGHEST_PROTOCOL) + + with open("{}/{}-{}_{}s{}b{}t--pull_dic.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(pull_dic, f, pkl.HIGHEST_PROTOCOL) + + variab = {'mi': mi, + 'ma': ma, + 'ste': ste, + 'bo_set': bo_set, + 'nr_of_toys': nr_of_toys} + + with open("{}/variab.pkl".format(dirName), "wb") as f: + pkl.dump(variab, f, pkl.HIGHEST_PROTOCOL) + + CLs_values = [] + + toy_size = bo_set + + print(np.shape(Nll_list)) + print(Nll_list[0:1]) + + for step in range(ste): + CLs_values.append([]) + for toy in range(nr_of_toys): + float_min = np.min(Nll_list[2*step][toy*bo_set:(toy+1)*bo_set]) + fix_min = np.min(Nll_list[2*step+1][toy*bo_set:(toy+1)*bo_set]) + CLs_values[step].append(float_min-fix_min) + + + print(np.shape(CLs_values)) + + with open("{}/{}-{}_{}s--CLs_list.pkl".format(dirName, mi,ma,ste), "wb") as f: + pkl.dump(CLs_values, f, pkl.HIGHEST_PROTOCOL) + + +# In[ ]: + + +# print(variab['mi'] != mi) + + +# ## Plot + +# In[ ]: + + +l = [] + + +if load: + CLs_values = -1*np.array(CLs_list) + +if not os.path.exists('data/CLs/plots'): + os.mkdir('data/CLs/plots') + print("Directory " , 'data/CLs/plots' , " Created ") + +print(np.shape(CLs_values)) + +for step in range(1,ste): + plt.clf() + plt.title('Ctt value: {:.2f}'.format(Ctt_steps[step])) + plt.hist(CLs_values[0], bins = 150, range = (-25, 50), label = 'Ctt fixed to 0') + plt.hist(CLs_values[step], bins = 150, range = (-25, 50), label = 'Ctt floating') + plt.axvline(x=np.mean(CLs_values[0]),color='red', linewidth=1.0, linestyle = 'dotted') + plt.legend() + plt.savefig('data/CLs/plots/CLs-BR({:.1E}).png'.format(BR_steps[step])) + + l.append(len(np.where(np.array(CLs_values[step]) < np.mean(CLs_values[0]))[0])) + +for step in range(2*ste): + if step%2 == 0: + floaty = True + else: + floaty = False + for key in pull_dic.keys(): + if not os.path.exists('data/CLs/plots/{}'.format(key)): + os.mkdir('data/CLs/plots/{}'.format(key)) + plt.clf() + plt.title('Pull {} - Ctt value {:.2f} - floating {}'.format(key, Ctt_steps[int(step/2)], floaty)) + plt.hist(pull_dic[key][step], bins = 50, range = (-5,5)) + plt.xlabel('Pull') + plt.savefig('data/CLs/plots/{}/{:.2f}Ctt{}s{}f.png'.format(key, Ctt_steps[int(step/2)], step, floaty)) + + +# In[ ]: + + +for s in range(len(l)): + print('BR: {:.4f}'.format(BR_steps[s+1])) + print(2*l[s]/len(CLs_values[s])) + print() + + +# In[ ]: + + +# for step in range(2*ste): +# for key in pull_dic.keys(): +# print(pull_dic[key][step]) + + +# In[ ]: + + +# for param in total_f_fit.get_dependents(): +# if param.floating: +# print(params[param]['value']) + + +# In[ ]: + + +print(display_time(int(time.time()-start))) + + +# In[ ]: + + +# variab['mi'] =! mi + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + diff --git a/data/CLs/finished/f1d1/-+/D-True/2288007/__pycache__/helperfunctions.cpython-37.pyc b/data/CLs/finished/f1d1/-+/D-True/2288007/__pycache__/helperfunctions.cpython-37.pyc new file mode 100644 index 0000000..05ef727 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288007/__pycache__/helperfunctions.cpython-37.pyc Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288007/__pycache__/pdg_const1.cpython-37.pyc b/data/CLs/finished/f1d1/-+/D-True/2288007/__pycache__/pdg_const1.cpython-37.pyc new file mode 100644 index 0000000..b3eb28d --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288007/__pycache__/pdg_const1.cpython-37.pyc Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288007/data/CLs/0.0001-0.003_20s--CLs_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288007/data/CLs/0.0001-0.003_20s--CLs_list.pkl new file mode 100644 index 0000000..468f16a --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288007/data/CLs/0.0001-0.003_20s--CLs_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288007/data/CLs/0.0001-0.003_20s1b1t--CLs_Nll_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288007/data/CLs/0.0001-0.003_20s1b1t--CLs_Nll_list.pkl new file mode 100644 index 0000000..469ec93 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288007/data/CLs/0.0001-0.003_20s1b1t--CLs_Nll_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288007/data/CLs/0.0001-0.003_20s1b1t--Ctt_error_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288007/data/CLs/0.0001-0.003_20s1b1t--Ctt_error_list.pkl new file mode 100644 index 0000000..094f333 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288007/data/CLs/0.0001-0.003_20s1b1t--Ctt_error_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288007/data/CLs/0.0001-0.003_20s1b1t--Ctt_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288007/data/CLs/0.0001-0.003_20s1b1t--Ctt_list.pkl new file mode 100644 index 0000000..58ae4db --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288007/data/CLs/0.0001-0.003_20s1b1t--Ctt_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288007/data/CLs/0.0001-0.003_20s1b1t--pull_dic.pkl b/data/CLs/finished/f1d1/-+/D-True/2288007/data/CLs/0.0001-0.003_20s1b1t--pull_dic.pkl new file mode 100644 index 0000000..249eed8 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288007/data/CLs/0.0001-0.003_20s1b1t--pull_dic.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288007/data/CLs/variab.pkl b/data/CLs/finished/f1d1/-+/D-True/2288007/data/CLs/variab.pkl new file mode 100644 index 0000000..bb90dc0 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288007/data/CLs/variab.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288007/helperfunctions.py b/data/CLs/finished/f1d1/-+/D-True/2288007/helperfunctions.py new file mode 100644 index 0000000..88e120f --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288007/helperfunctions.py @@ -0,0 +1,33 @@ +# some helperfunctions + +import matplotlib +matplotlib.use("agg") +import matplotlib.pyplot as plt + +#Dislpay time (e.g. while generating points) + +display_intervals = ( + ('w', 604800), # 60 * 60 * 24 * 7 + ('d', 86400), # 60 * 60 * 24 + ('h', 3600), # 60 * 60 + ('min', 60), + ('s', 1), + ) + +def display_time(seconds, granularity=2): + result = [] + + for name, count in display_intervals: + value = seconds // count + if value: + seconds -= value * count + if value == 1: + name = name.rstrip('s') + result.append("{} {}".format(value, name)) + return ', '.join(result[:granularity]) + +def prepare_plot(title): + plt.title(title) + plt.grid() + plt.legend(loc = 'best') + plt.xlabel("q") diff --git a/data/CLs/finished/f1d1/-+/D-True/2288007/pdg_const1.py b/data/CLs/finished/f1d1/-+/D-True/2288007/pdg_const1.py new file mode 100644 index 0000000..70b3f30 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288007/pdg_const1.py @@ -0,0 +1,226 @@ +pdg = { + + + ###Particle masses### + + "mbstar" : 5415.4, + "mbstar0" : 5711.0, + "B0_M" : 5279.5, + "Bs_M" : 5366.7, + "Bplus_M" : 5279.3, + "Lb_M" : 5619.4, + "D0_M" : 1864.8, + "Dst_M" : 2010, + "pi_M" : 139.6, + "Jpsi_M" : 3096.9, + "Psi2s_M" : 3685.6, + "kaon_M" : 493.7, + "Ks_M" : 497.6, + "phi_M" : 1019.5, + "rho_M" : 775.26, + "rho_width" : 149.1, + "omega_M" : 782.65, + "omega_width" : 8.49, + + "muon_M" : 105.7, + "tau_M": 1776.86, + + "squark_M" : 95.0, + "bquark_M" : 4180.0, + "cquark_M" : 1275.0, + + "Bplus_tau" : 1.638e-12, + + ###Wilson coefficients### + + "C1" : -0.257, + "C2" : 1.009, + "C3" : -0.005, + "C4" : -0.078, + + "C7eff" : -0.306, + "C9eff" : 4.211, + "C10eff" : -4.103, + +# "C7eff": 0.0, +# "C9eff": 0.0, +# "C10eff": 0.0, + + ###Other constants + + "GF" : 1.1663787e-5, + "alpha_ew" : 1.0/137.0, + "Vts" : 0.0394, + "Vtb" : 1.019, + "number_of_decays": 5404696, + + #Formfactor z coefficients + + #"b0" : [0.285, 0.19, -0.17], + #"bplus" : [0.437, -1.41, -2.5], + #"bT" : [0.440, -1.47, -2.7] + + "b0" : [0.292, 0.281, 0.150], + "bplus" : [0.466, -0.885, -0.213], + "bT" : [0.460, -1.089, -1.114], + + "NR_BR": 4.37e-7, + "NR_auc": 0.00133, + + #Resonances format(mass, width, phase, scale) + + # pre scaling + +# "rho": (775.26, 149.0, -0.35, 1.0), + +# "omega": (782.7, 8.5, 0.26, 1.0), + +# "phi": (1019.46, 4.25, 0.5, 1.0), + +# "jpsi": (3096.0, 0.09, -1.5, 2e-2), +# "jpsi_auc": 0.2126825758464027, + +# "psi2s": (3686.0, 0.3, -1.5, 3.14e-3), +# "psi2s_auc": 2.802257483178487e-10, + +# "p3770": (3773.0, 27.2, -2.13, 1.0e-3), + +# "p4040": (4039.0, 80.0, -2.52, 2.0), + +# "p4160": (4191.0, 70.0, -1.9, 2.2), + +# "p4415": (4421.0, 62.0, -2.52, 1.0), + + + # after scaling (Phase combination --) + + # + # "rho": (743.2, 149.0, -0.22, 1.05), + # + # "omega": (782.7, 8.5, 0.38, 6.8), + # + # "phi": (1013.5, 4.25, 0.62, 19.2), + # + # "jpsi": (3096.1, 0.09, 1.63, 9897.0), + # "jpsi_auc": 0.2126825758464027, + # "jpsi_phase_unc": 0.05, + # + # "psi2s": (3686.0, 0.3, 1.8, 1396.0), + # "psi2s_auc": 0.0151332263, + # "psi2s_phase_unc": 0.1, + # + # "p3770": (3773.0, 27.2, -2.95, 2.5), + # + # "p4040": (4039.0, 80.0, -2.75, 1.01), + # + # "p4160": (4191.0, 70.0, -2.28, 2.2), + # + # "p4415": (4421.0, 62.0, -2.31, 1.24), + + # Phase combination of paper ++ + +# "rho": (743.2, 149.0, -0.35, 1.05), + +# "omega": (782.7, 8.5, 0.26, 6.8), + +# "phi": (1013.5, 4.25, 0.47, 19.2), + +# "jpsi": (3096.1, 0.09, -1.66, 9897.0), +# "jpsi_auc": 0.2126825758464027, +# "jpsi_phase_unc": 0.05, + +# "psi2s": (3686.0, 0.3, -1.93, 1396.0), +# "psi2s_auc": 0.0151332263, +# "psi2s_phase_unc": 0.1, + +# "p3770": (3773.0, 27.2, -2.13, 2.5), + +# "p4040": (4039.0, 80.0, -2.52, 1.01), + +# "p4160": (4191.0, 70.0, -1.90, 2.2), + +# "p4415": (4421.0, 62.0, -2.52, 1.24), + + # Phase combination of paper +- + +# "rho": (743.2, 149.0, -0.26, 1.05), + +# "omega": (782.7, 8.5, 0.35, 6.8), + +# "phi": (1013.5, 4.25, 0.58, 19.2), + +# "jpsi": (3096.1, 0.09, 1.47, 9897.0), +# "jpsi_auc": 0.2126825758464027, +# "jpsi_phase_unc": 0.05, + +# "psi2s": (3686.0, 0.3, -2.21, 1396.0), +# "psi2s_auc": 0.0151332263, +# "psi2s_phase_unc": 0.1, + +# "p3770": (3773.0, 27.2, -2.140, 2.5), + +# "p4040": (4039.0, 80.0, -2.64, 1.01), + +# "p4160": (4191.0, 70.0, -2.11, 2.2), + +# "p4415": (4421.0, 62.0, -2.42, 1.24), + + # Phase combination of paper -+ + + "rho": (743.2, 149.0, -0.30, 1.05), + + "omega": (782.7, 8.5, 0.30, 6.8), + + "phi": (1013.5, 4.25, 0.51, 19.2), + + "jpsi": (3096.1, 0.09, -1.5, 9897.0), + "jpsi_auc": 0.2126825758464027, + "jpsi_phase_unc": 0.05, + + "psi2s": (3686.0, 0.3, 2.08, 1396.0), + "psi2s_auc": 0.0151332263, + "psi2s_phase_unc": 0.1, + + "p3770": (3773.0, 27.2, -2.89, 2.5), + + "p4040": (4039.0, 80.0, -2.69, 1.01), + + "p4160": (4191.0, 70.0, -2.13, 2.2), + + "p4415": (4421.0, 62.0, -2.43, 1.24), + + + # zeroing resonances + +# "rho": (775.26, 149.0, -0.35, 0.0), +# "omega": (782.7, 8.5, 0.26, 0.0), +# "phi": (1019.46, 4.25, 0.5, 0.0), +# "jpsi": (3096.0, 0.09, -1.5, 0.0), +# "psi2s": (3686.0, 0.3, -1.5, 0.0), +# "p3770": (3773.0, 27.2, -2.13, 0.0), +# "p4040": (4039.0, 80.0, -2.52, 0.0), +# "p4160": (4147.0, 22.0, -1.9, 0.0), +# "p4415": (4421.0, 62.0, -2.52, 0.0), + + # 2P contributions format(mass, amp, phase) + +# "D_bar": ( + + #general + + "rho_BR": 1.7e-10, + "omega_BR": 4.9e-10, + "phi_BR": 2.5e-9, + "jpsi_BR": 6.02e-5, + "psi2s_BR": 4.97e-6, + "p3770_BR": 1.38e-9, + "p4040_BR": 4.2e-10, + "p4160_BR": 2.6e-9, + "p4415_BR": 6.1e-10, + +# Estimates + "Dbar_scale": 1.46, #with phase = pi + + "DDstar_scale": 2.41, #with phase = pi + + } diff --git a/data/CLs/finished/f1d1/-+/D-True/2288007/raremodel-nb.py b/data/CLs/finished/f1d1/-+/D-True/2288007/raremodel-nb.py new file mode 100644 index 0000000..c326c9c --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288007/raremodel-nb.py @@ -0,0 +1,2152 @@ +#!/usr/bin/env python +# coding: utf-8 + +# # Import + +# In[ ]: + + +import os + +# os.environ["CUDA_VISIBLE_DEVICES"] = "-1" +import random +import numpy as np +from pdg_const1 import pdg +import matplotlib +import matplotlib.pyplot as plt +import pickle as pkl +import sys +import time +from helperfunctions import display_time, prepare_plot +import cmath as c +import scipy.integrate as integrate +from scipy.optimize import fminbound +from array import array as arr +import collections +from itertools import compress +import tensorflow as tf +import zfit +from zfit import ztf +# from IPython.display import clear_output +import os +import tensorflow_probability as tfp +tfd = tfp.distributions + + +# In[ ]: + + +# chunksize = 10000 +# zfit.run.chunking.active = True +# zfit.run.chunking.max_n_points = chunksize + + +# # Build model and graphs +# ## Create graphs + +# In[ ]: + + + + + +# In[ ]: + + +def formfactor(q2, subscript, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2): #returns real value + #check if subscript is viable + + if subscript != "0" and subscript != "+" and subscript != "T": + raise ValueError('Wrong subscript entered, choose either 0, + or T') + + #get constants + + mK = ztf.constant(pdg['Ks_M']) + mbstar0 = ztf.constant(pdg["mbstar0"]) + mbstar = ztf.constant(pdg["mbstar"]) + + + mmu = ztf.constant(pdg['muon_M']) + mb = ztf.constant(pdg['bquark_M']) + ms = ztf.constant(pdg['squark_M']) + mB = ztf.constant(pdg['Bplus_M']) + + #N comes from derivation in paper + + N = 3 + + #some helperfunctions + + tpos = (mB - mK)**2 + tzero = (mB + mK)*(ztf.sqrt(mB)-ztf.sqrt(mK))**2 + + z_oben = ztf.sqrt(tpos - q2) - ztf.sqrt(tpos - tzero) + z_unten = ztf.sqrt(tpos - q2) + ztf.sqrt(tpos - tzero) + z = tf.divide(z_oben, z_unten) + + #calculate f0 + + if subscript == "0": + prefactor = 1/(1 - q2/(mbstar0**2)) + _sum = 0 + b0 = [b0_0, b0_1, b0_2] + + for i in range(N): + _sum += b0[i]*(tf.pow(z,i)) + + return ztf.to_complex(prefactor * _sum) + + #calculate f+ or fT + + else: + prefactor = 1/(1 - q2/(mbstar**2)) + _sum = 0 + + if subscript == "T": + bT = [bT_0, bT_1, bT_2] + for i in range(N): + _sum += bT[i] * (tf.pow(z, i) - ((-1)**(i-N)) * (i/N) * tf.pow(z, N)) + else: + bplus = [bplus_0, bplus_1, bplus_2] + for i in range(N): + _sum += bplus[i] * (tf.pow(z, i) - ((-1)**(i-N)) * (i/N) * tf.pow(z, N)) + + return ztf.to_complex(prefactor * _sum) + +def resonance(q, _mass, width, phase, scale): + + q2 = tf.pow(q, 2) + + mmu = ztf.constant(pdg['muon_M']) + + p = 0.5 * ztf.sqrt(q2 - 4*(mmu**2)) + + p0 = 0.5 * ztf.sqrt(_mass**2 - 4*mmu**2) + + gamma_j = tf.divide(p, q) * _mass * width / p0 + + #Calculate the resonance + + _top = tf.complex(_mass * width, ztf.constant(0.0)) + + _bottom = tf.complex(_mass**2 - q2, -_mass*gamma_j) + + com = _top/_bottom + + #Rotate by the phase + + r = ztf.to_complex(scale*tf.abs(com)) + + _phase = tf.angle(com) + + _phase += phase + + com = r * tf.exp(tf.complex(ztf.constant(0.0), _phase)) + + return com + + +def axiv_nonres(q, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2): + + GF = ztf.constant(pdg['GF']) + alpha_ew = ztf.constant(pdg['alpha_ew']) + Vtb = ztf.constant(pdg['Vtb']) + Vts = ztf.constant(pdg['Vts']) + C10eff = ztf.constant(pdg['C10eff']) + + mmu = ztf.constant(pdg['muon_M']) + mb = ztf.constant(pdg['bquark_M']) + ms = ztf.constant(pdg['squark_M']) + mK = ztf.constant(pdg['Ks_M']) + mB = ztf.constant(pdg['Bplus_M']) + + q2 = tf.pow(q, 2) + + #Some helperfunctions + + beta = 1. - 4. * mmu**2. / q2 + + kabs = ztf.sqrt(mB**2. + tf.pow(q2, 2)/mB**2. + mK**4./mB**2. - 2. * (mB**2. * mK**2. + mK**2. * q2 + mB**2. * q2) / mB**2.) + + #prefactor in front of whole bracket + + prefactor1 = GF**2. *alpha_ew**2. * (tf.abs(Vtb*Vts))**2. * kabs * beta / (128. * np.pi**5.) + + #left term in bracket + + bracket_left = 2./3. * tf.pow(kabs,2) * tf.pow(beta,2) * tf.pow(tf.abs(ztf.to_complex(C10eff)*formfactor(q2, "+", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2)),2) + + #middle term in bracket + + _top = 4. * mmu**2. * (mB**2. - mK**2.) * (mB**2. - mK**2.) + + _under = q2 * mB**2. + + bracket_middle = _top/_under *tf.pow(tf.abs(ztf.to_complex(C10eff) * formfactor(q2, "0", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2)), 2) + + #Note sqrt(q2) comes from derivation as we use q2 and plot q + + return prefactor1 * (bracket_left + bracket_middle) * 2 * q + +def vec(q, funcs, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2): + + q2 = tf.pow(q, 2) + + GF = ztf.constant(pdg['GF']) + alpha_ew = ztf.constant(pdg['alpha_ew']) + Vtb = ztf.constant(pdg['Vtb']) + Vts = ztf.constant(pdg['Vts']) + C7eff = ztf.constant(pdg['C7eff']) + + mmu = ztf.constant(pdg['muon_M']) + mb = ztf.constant(pdg['bquark_M']) + ms = ztf.constant(pdg['squark_M']) + mK = ztf.constant(pdg['Ks_M']) + mB = ztf.constant(pdg['Bplus_M']) + + #Some helperfunctions + + beta = 1. - 4. * mmu**2. / q2 + + kabs = ztf.sqrt(mB**2. + tf.pow(q2, 2)/mB**2. + mK**4./mB**2. - 2 * (mB**2 * mK**2 + mK**2 * q2 + mB**2 * q2) / mB**2) + + #prefactor in front of whole bracket + + prefactor1 = GF**2. *alpha_ew**2. * (tf.abs(Vtb*Vts))**2 * kabs * beta / (128. * np.pi**5.) + + #right term in bracket + + prefactor2 = tf.pow(kabs,2) * (1. - 1./3. * beta) + + abs_bracket = tf.pow(tf.abs(c9eff(q, funcs) * formfactor(q2, "+", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + ztf.to_complex(2.0 * C7eff * (mb + ms)/(mB + mK)) * formfactor(q2, "T", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2)),2) + + bracket_right = prefactor2 * abs_bracket + + #Note sqrt(q2) comes from derivation as we use q2 and plot q + + return prefactor1 * bracket_right * 2 * q + +def c9eff(q, funcs): + + C9eff_nr = ztf.to_complex(ztf.constant(pdg['C9eff'])) + + c9 = C9eff_nr + funcs + + return c9 + + +# In[ ]: + + +def G(y): + + def inner_rect_bracket(q): + return tf.log(ztf.to_complex((1+tf.sqrt(q))/(1-tf.sqrt(q)))-tf.complex(ztf.constant(0), -1*ztf.constant(np.pi))) + + def inner_right(q): + return ztf.to_complex(2 * tf.atan(1/tf.sqrt(tf.math.real(-q)))) + + big_bracket = tf.where(tf.math.real(y) > ztf.constant(0.0), inner_rect_bracket(y), inner_right(y)) + + return ztf.to_complex(tf.sqrt(tf.abs(y))) * big_bracket + +def h_S(m, q): + + return ztf.to_complex(2) - G(ztf.to_complex(1) - ztf.to_complex(4*tf.pow(m, 2)) / ztf.to_complex(tf.pow(q, 2))) + +def h_P(m, q): + + return ztf.to_complex(2/3) + (ztf.to_complex(1) - ztf.to_complex(4*tf.pow(m, 2)) / ztf.to_complex(tf.pow(q, 2))) * h_S(m,q) + +def two_p_ccbar(mD, m_D_bar, m_D_star, q): + + + #Load constants + nu_D_bar = ztf.to_complex(pdg["nu_D_bar"]) + nu_D = ztf.to_complex(pdg["nu_D"]) + nu_D_star = ztf.to_complex(pdg["nu_D_star"]) + + phase_D_bar = ztf.to_complex(pdg["phase_D_bar"]) + phase_D = ztf.to_complex(pdg["phase_D"]) + phase_D_star = ztf.to_complex(pdg["phase_D_star"]) + + #Calculation + left_part = nu_D_bar * tf.exp(tf.complex(ztf.constant(0.0), phase_D_bar)) * h_S(m_D_bar, q) + + right_part_D = nu_D * tf.exp(tf.complex(ztf.constant(0.0), phase_D)) * h_P(m_D, q) + + right_part_D_star = nu_D_star * tf.exp(tf.complex(ztf.constant(0.0), phase_D_star)) * h_P(m_D_star, q) + + return left_part + right_part_D + right_part_D_star + + +# ## Build pdf + +# In[ ]: + + +class total_pdf_cut(zfit.pdf.ZPDF): + _N_OBS = 1 # dimension, can be omitted + _PARAMS = ['b0_0', 'b0_1', 'b0_2', + 'bplus_0', 'bplus_1', 'bplus_2', + 'bT_0', 'bT_1', 'bT_2', + 'rho_mass', 'rho_scale', 'rho_phase', 'rho_width', + 'jpsi_mass', 'jpsi_scale', 'jpsi_phase', 'jpsi_width', + 'psi2s_mass', 'psi2s_scale', 'psi2s_phase', 'psi2s_width', + 'p3770_mass', 'p3770_scale', 'p3770_phase', 'p3770_width', + 'p4040_mass', 'p4040_scale', 'p4040_phase', 'p4040_width', + 'p4160_mass', 'p4160_scale', 'p4160_phase', 'p4160_width', + 'p4415_mass', 'p4415_scale', 'p4415_phase', 'p4415_width', + 'omega_mass', 'omega_scale', 'omega_phase', 'omega_width', + 'phi_mass', 'phi_scale', 'phi_phase', 'phi_width', + 'Dbar_mass', 'Dbar_scale', 'Dbar_phase', + 'Dstar_mass', 'DDstar_scale', 'DDstar_phase', 'D_mass', + 'tau_mass', 'C_tt'] +# the name of the parameters + + def _unnormalized_pdf(self, x): + + x = x.unstack_x() + + b0 = [self.params['b0_0'], self.params['b0_1'], self.params['b0_2']] + bplus = [self.params['bplus_0'], self.params['bplus_1'], self.params['bplus_2']] + bT = [self.params['bT_0'], self.params['bT_1'], self.params['bT_2']] + + def rho_res(q): + return resonance(q, _mass = self.params['rho_mass'], scale = self.params['rho_scale'], + phase = self.params['rho_phase'], width = self.params['rho_width']) + + def omega_res(q): + return resonance(q, _mass = self.params['omega_mass'], scale = self.params['omega_scale'], + phase = self.params['omega_phase'], width = self.params['omega_width']) + + def phi_res(q): + return resonance(q, _mass = self.params['phi_mass'], scale = self.params['phi_scale'], + phase = self.params['phi_phase'], width = self.params['phi_width']) + + def jpsi_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['jpsi_mass'], 2)) * resonance(q, _mass = self.params['jpsi_mass'], + scale = self.params['jpsi_scale'], + phase = self.params['jpsi_phase'], + width = self.params['jpsi_width']) + def psi2s_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['psi2s_mass'], 2)) * resonance(q, _mass = self.params['psi2s_mass'], + scale = self.params['psi2s_scale'], + phase = self.params['psi2s_phase'], + width = self.params['psi2s_width']) + def p3770_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p3770_mass'], 2)) * resonance(q, _mass = self.params['p3770_mass'], + scale = self.params['p3770_scale'], + phase = self.params['p3770_phase'], + width = self.params['p3770_width']) + + def p4040_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4040_mass'], 2)) * resonance(q, _mass = self.params['p4040_mass'], + scale = self.params['p4040_scale'], + phase = self.params['p4040_phase'], + width = self.params['p4040_width']) + + def p4160_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4160_mass'], 2)) * resonance(q, _mass = self.params['p4160_mass'], + scale = self.params['p4160_scale'], + phase = self.params['p4160_phase'], + width = self.params['p4160_width']) + + def p4415_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4415_mass'], 2)) * resonance(q, _mass = self.params['p4415_mass'], + scale = self.params['p4415_scale'], + phase = self.params['p4415_phase'], + width = self.params['p4415_width']) + + def P2_D(q): + Dbar_contrib = ztf.to_complex(self.params['Dbar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['Dbar_phase']))*ztf.to_complex(h_S(self.params['Dbar_mass'], q)) + DDstar_contrib = ztf.to_complex(self.params['DDstar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['DDstar_phase']))*(ztf.to_complex(h_P(self.params['Dstar_mass'], q)) + ztf.to_complex(h_P(self.params['D_mass'], q))) + return Dbar_contrib + DDstar_contrib + + def ttau_cusp(q): + return ztf.to_complex(self.params['C_tt'])*(ztf.to_complex((h_S(self.params['tau_mass'], q))) - ztf.to_complex(h_P(self.params['tau_mass'], q))) + + + funcs = rho_res(x) + omega_res(x) + phi_res(x) + jpsi_res(x) + psi2s_res(x) + p3770_res(x) + p4040_res(x)+ p4160_res(x) + p4415_res(x) + P2_D(x) + ttau_cusp(x) + + vec_f = vec(x, funcs, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + axiv_nr = axiv_nonres(x, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + tot = vec_f + axiv_nr + + #Cut out jpsi and psi2s + + tot = tf.where(tf.math.logical_or(x < ztf.constant(jpsi_mass-60.), x > ztf.constant(jpsi_mass+70.)), tot, 0.0*tot) + + tot = tf.where(tf.math.logical_or(x < ztf.constant(psi2s_mass-50.), x > ztf.constant(psi2s_mass+50.)), tot, 0.0*tot) + + return tot + +class total_pdf_full(zfit.pdf.ZPDF): + _N_OBS = 1 # dimension, can be omitted + _PARAMS = ['b0_0', 'b0_1', 'b0_2', + 'bplus_0', 'bplus_1', 'bplus_2', + 'bT_0', 'bT_1', 'bT_2', + 'rho_mass', 'rho_scale', 'rho_phase', 'rho_width', + 'jpsi_mass', 'jpsi_scale', 'jpsi_phase', 'jpsi_width', + 'psi2s_mass', 'psi2s_scale', 'psi2s_phase', 'psi2s_width', + 'p3770_mass', 'p3770_scale', 'p3770_phase', 'p3770_width', + 'p4040_mass', 'p4040_scale', 'p4040_phase', 'p4040_width', + 'p4160_mass', 'p4160_scale', 'p4160_phase', 'p4160_width', + 'p4415_mass', 'p4415_scale', 'p4415_phase', 'p4415_width', + 'omega_mass', 'omega_scale', 'omega_phase', 'omega_width', + 'phi_mass', 'phi_scale', 'phi_phase', 'phi_width', + 'Dbar_mass', 'Dbar_scale', 'Dbar_phase', + 'Dstar_mass', 'DDstar_scale', 'DDstar_phase', 'D_mass', + 'tau_mass', 'C_tt'] +# the name of the parameters + + def _unnormalized_pdf(self, x): + + x = x.unstack_x() + + b0 = [self.params['b0_0'], self.params['b0_1'], self.params['b0_2']] + bplus = [self.params['bplus_0'], self.params['bplus_1'], self.params['bplus_2']] + bT = [self.params['bT_0'], self.params['bT_1'], self.params['bT_2']] + + def rho_res(q): + return resonance(q, _mass = self.params['rho_mass'], scale = self.params['rho_scale'], + phase = self.params['rho_phase'], width = self.params['rho_width']) + + def omega_res(q): + return resonance(q, _mass = self.params['omega_mass'], scale = self.params['omega_scale'], + phase = self.params['omega_phase'], width = self.params['omega_width']) + + def phi_res(q): + return resonance(q, _mass = self.params['phi_mass'], scale = self.params['phi_scale'], + phase = self.params['phi_phase'], width = self.params['phi_width']) + + def jpsi_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['jpsi_mass'], 2)) * resonance(q, _mass = self.params['jpsi_mass'], + scale = self.params['jpsi_scale'], + phase = self.params['jpsi_phase'], + width = self.params['jpsi_width']) + def psi2s_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['psi2s_mass'], 2)) * resonance(q, _mass = self.params['psi2s_mass'], + scale = self.params['psi2s_scale'], + phase = self.params['psi2s_phase'], + width = self.params['psi2s_width']) + def p3770_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p3770_mass'], 2)) * resonance(q, _mass = self.params['p3770_mass'], + scale = self.params['p3770_scale'], + phase = self.params['p3770_phase'], + width = self.params['p3770_width']) + + def p4040_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4040_mass'], 2)) * resonance(q, _mass = self.params['p4040_mass'], + scale = self.params['p4040_scale'], + phase = self.params['p4040_phase'], + width = self.params['p4040_width']) + + def p4160_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4160_mass'], 2)) * resonance(q, _mass = self.params['p4160_mass'], + scale = self.params['p4160_scale'], + phase = self.params['p4160_phase'], + width = self.params['p4160_width']) + + def p4415_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4415_mass'], 2)) * resonance(q, _mass = self.params['p4415_mass'], + scale = self.params['p4415_scale'], + phase = self.params['p4415_phase'], + width = self.params['p4415_width']) + + def P2_D(q): + Dbar_contrib = ztf.to_complex(self.params['Dbar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['Dbar_phase']))*ztf.to_complex(h_S(self.params['Dbar_mass'], q)) + DDstar_contrib = ztf.to_complex(self.params['DDstar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['DDstar_phase']))*(ztf.to_complex(h_P(self.params['Dstar_mass'], q)) + ztf.to_complex(h_P(self.params['D_mass'], q))) + return Dbar_contrib + DDstar_contrib + + def ttau_cusp(q): + return ztf.to_complex(self.params['C_tt'])*(ztf.to_complex((h_S(self.params['tau_mass'], q))) - ztf.to_complex(h_P(self.params['tau_mass'], q))) + + + funcs = rho_res(x) + omega_res(x) + phi_res(x) + jpsi_res(x) + psi2s_res(x) + p3770_res(x) + p4040_res(x)+ p4160_res(x) + p4415_res(x) + P2_D(x) + ttau_cusp(x) + + vec_f = vec(x, funcs, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + axiv_nr = axiv_nonres(x, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + tot = vec_f + axiv_nr + + #Cut out jpsi and psi2s + +# tot = tf.where(tf.math.logical_or(x < ztf.constant(jpsi_mass-60.), x > ztf.constant(jpsi_mass+70.)), tot, 0.0*tot) + +# tot = tf.where(tf.math.logical_or(x < ztf.constant(psi2s_mass-50.), x > ztf.constant(psi2s_mass+50.)), tot, 0.0*tot) + + return tot + + +# ## Setup parameters + +# In[ ]: + + +# formfactors + +b0_0 = zfit.Parameter("b0_0", ztf.constant(0.292), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +b0_1 = zfit.Parameter("b0_1", ztf.constant(0.281), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +b0_2 = zfit.Parameter("b0_2", ztf.constant(0.150), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) + +bplus_0 = zfit.Parameter("bplus_0", ztf.constant(0.466), lower_limit = -2.0, upper_limit= 2.0) +bplus_1 = zfit.Parameter("bplus_1", ztf.constant(-0.885), lower_limit = -2.0, upper_limit= 2.0) +bplus_2 = zfit.Parameter("bplus_2", ztf.constant(-0.213), lower_limit = -2.0, upper_limit= 2.0) + +bT_0 = zfit.Parameter("bT_0", ztf.constant(0.460), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +bT_1 = zfit.Parameter("bT_1", ztf.constant(-1.089), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +bT_2 = zfit.Parameter("bT_2", ztf.constant(-1.114), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) + + +#rho + +rho_mass, rho_width, rho_phase, rho_scale = pdg["rho"] + +rho_m = zfit.Parameter("rho_m", ztf.constant(rho_mass), floating = False) #lower_limit = rho_mass - rho_width, upper_limit = rho_mass + rho_width) +rho_w = zfit.Parameter("rho_w", ztf.constant(rho_width), floating = False) +rho_p = zfit.Parameter("rho_p", ztf.constant(rho_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +rho_s = zfit.Parameter("rho_s", ztf.constant(rho_scale), lower_limit=rho_scale-np.sqrt(rho_scale), upper_limit=rho_scale+np.sqrt(rho_scale)) + +#omega + +omega_mass, omega_width, omega_phase, omega_scale = pdg["omega"] + +omega_m = zfit.Parameter("omega_m", ztf.constant(omega_mass), floating = False) +omega_w = zfit.Parameter("omega_w", ztf.constant(omega_width), floating = False) +omega_p = zfit.Parameter("omega_p", ztf.constant(omega_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +omega_s = zfit.Parameter("omega_s", ztf.constant(omega_scale), lower_limit=omega_scale-np.sqrt(omega_scale), upper_limit=omega_scale+np.sqrt(omega_scale)) + + +#phi + +phi_mass, phi_width, phi_phase, phi_scale = pdg["phi"] + +phi_m = zfit.Parameter("phi_m", ztf.constant(phi_mass), floating = False) +phi_w = zfit.Parameter("phi_w", ztf.constant(phi_width), floating = False) +phi_p = zfit.Parameter("phi_p", ztf.constant(phi_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +phi_s = zfit.Parameter("phi_s", ztf.constant(phi_scale), lower_limit=phi_scale-np.sqrt(phi_scale), upper_limit=phi_scale+np.sqrt(phi_scale)) + +#jpsi + +jpsi_mass, jpsi_width, jpsi_phase, jpsi_scale = pdg["jpsi"] + +jpsi_m = zfit.Parameter("jpsi_m", ztf.constant(jpsi_mass), floating = False) +jpsi_w = zfit.Parameter("jpsi_w", ztf.constant(jpsi_width), floating = False) +jpsi_p = zfit.Parameter("jpsi_p", ztf.constant(jpsi_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +jpsi_s = zfit.Parameter("jpsi_s", ztf.constant(jpsi_scale), floating = False) #, lower_limit=jpsi_scale-np.sqrt(jpsi_scale), upper_limit=jpsi_scale+np.sqrt(jpsi_scale)) + +#psi2s + +psi2s_mass, psi2s_width, psi2s_phase, psi2s_scale = pdg["psi2s"] + +psi2s_m = zfit.Parameter("psi2s_m", ztf.constant(psi2s_mass), floating = False) +psi2s_w = zfit.Parameter("psi2s_w", ztf.constant(psi2s_width), floating = False) +psi2s_p = zfit.Parameter("psi2s_p", ztf.constant(psi2s_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +psi2s_s = zfit.Parameter("psi2s_s", ztf.constant(psi2s_scale), floating = False) #, lower_limit=psi2s_scale-np.sqrt(psi2s_scale), upper_limit=psi2s_scale+np.sqrt(psi2s_scale)) + +#psi(3770) + +p3770_mass, p3770_width, p3770_phase, p3770_scale = pdg["p3770"] + +p3770_m = zfit.Parameter("p3770_m", ztf.constant(p3770_mass), floating = False) +p3770_w = zfit.Parameter("p3770_w", ztf.constant(p3770_width), floating = False) +p3770_p = zfit.Parameter("p3770_p", ztf.constant(p3770_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p3770_s = zfit.Parameter("p3770_s", ztf.constant(p3770_scale), lower_limit=p3770_scale-np.sqrt(p3770_scale), upper_limit=p3770_scale+np.sqrt(p3770_scale)) + +#psi(4040) + +p4040_mass, p4040_width, p4040_phase, p4040_scale = pdg["p4040"] + +p4040_m = zfit.Parameter("p4040_m", ztf.constant(p4040_mass), floating = False) +p4040_w = zfit.Parameter("p4040_w", ztf.constant(p4040_width), floating = False) +p4040_p = zfit.Parameter("p4040_p", ztf.constant(p4040_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p4040_s = zfit.Parameter("p4040_s", ztf.constant(p4040_scale), lower_limit=p4040_scale-np.sqrt(p4040_scale), upper_limit=p4040_scale+np.sqrt(p4040_scale)) + +#psi(4160) + +p4160_mass, p4160_width, p4160_phase, p4160_scale = pdg["p4160"] + +p4160_m = zfit.Parameter("p4160_m", ztf.constant(p4160_mass), floating = False) +p4160_w = zfit.Parameter("p4160_w", ztf.constant(p4160_width), floating = False) +p4160_p = zfit.Parameter("p4160_p", ztf.constant(p4160_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p4160_s = zfit.Parameter("p4160_s", ztf.constant(p4160_scale), lower_limit=p4160_scale-np.sqrt(p4160_scale), upper_limit=p4160_scale+np.sqrt(p4160_scale)) + +#psi(4415) + +p4415_mass, p4415_width, p4415_phase, p4415_scale = pdg["p4415"] + +p4415_m = zfit.Parameter("p4415_m", ztf.constant(p4415_mass), floating = False) +p4415_w = zfit.Parameter("p4415_w", ztf.constant(p4415_width), floating = False) +p4415_p = zfit.Parameter("p4415_p", ztf.constant(p4415_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p4415_s = zfit.Parameter("p4415_s", ztf.constant(p4415_scale), lower_limit=p4415_scale-np.sqrt(p4415_scale), upper_limit=p4415_scale+np.sqrt(p4415_scale)) + + +# ## Dynamic generation of 2 particle contribution + +# In[ ]: + + +m_c = 1300 + +Dbar_phase = 0.0 +DDstar_phase = 0.0 +Dstar_mass = pdg['Dst_M'] +Dbar_mass = pdg['D0_M'] +D_mass = pdg['D0_M'] + +Dbar_s = zfit.Parameter("Dbar_s", ztf.constant(0.0), lower_limit=-0.3, upper_limit=0.3) +Dbar_m = zfit.Parameter("Dbar_m", ztf.constant(Dbar_mass), floating = False) +Dbar_p = zfit.Parameter("Dbar_p", ztf.constant(Dbar_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi)#, floating = False) +DDstar_s = zfit.Parameter("DDstar_s", ztf.constant(0.0), lower_limit=-0.3, upper_limit=0.3)#, floating = False) +Dstar_m = zfit.Parameter("Dstar_m", ztf.constant(Dstar_mass), floating = False) +D_m = zfit.Parameter("D_m", ztf.constant(D_mass), floating = False) +DDstar_p = zfit.Parameter("DDstar_p", ztf.constant(DDstar_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi)#, floating = False) + + +# ## Tau parameters + +# In[ ]: + + +tau_m = zfit.Parameter("tau_m", ztf.constant(pdg['tau_M']), floating = False) +Ctt = zfit.Parameter("Ctt", ztf.constant(0.0), lower_limit=-2.5, upper_limit=2.5) + + +# ## Load data + +# In[ ]: + + +x_min = 2*pdg['muon_M'] +x_max = (pdg["Bplus_M"]-pdg["Ks_M"]-0.1) + +# # Full spectrum + +obs_toy = zfit.Space('q', limits = (x_min, x_max)) + +# Jpsi and Psi2s cut out + +obs1 = zfit.Space('q', limits = (x_min, jpsi_mass - 60.)) +obs2 = zfit.Space('q', limits = (jpsi_mass + 70., psi2s_mass - 50.)) +obs3 = zfit.Space('q', limits = (psi2s_mass + 50., x_max)) + +obs_fit = obs1 + obs2 + obs3 + +# with open(r"./data/slim_points/slim_points_toy_0_range({0}-{1}).pkl".format(int(x_min), int(x_max)), "rb") as input_file: +# part_set = pkl.load(input_file) + +# x_part = part_set['x_part'] + +# x_part = x_part.astype('float64') + +# data = zfit.data.Data.from_numpy(array=x_part, obs=obs) + + +# ## Setup pdf + +# In[ ]: + + +total_f = total_pdf_cut(obs=obs_toy, jpsi_mass = jpsi_m, jpsi_scale = jpsi_s, jpsi_phase = jpsi_p, jpsi_width = jpsi_w, + psi2s_mass = psi2s_m, psi2s_scale = psi2s_s, psi2s_phase = psi2s_p, psi2s_width = psi2s_w, + p3770_mass = p3770_m, p3770_scale = p3770_s, p3770_phase = p3770_p, p3770_width = p3770_w, + p4040_mass = p4040_m, p4040_scale = p4040_s, p4040_phase = p4040_p, p4040_width = p4040_w, + p4160_mass = p4160_m, p4160_scale = p4160_s, p4160_phase = p4160_p, p4160_width = p4160_w, + p4415_mass = p4415_m, p4415_scale = p4415_s, p4415_phase = p4415_p, p4415_width = p4415_w, + rho_mass = rho_m, rho_scale = rho_s, rho_phase = rho_p, rho_width = rho_w, + omega_mass = omega_m, omega_scale = omega_s, omega_phase = omega_p, omega_width = omega_w, + phi_mass = phi_m, phi_scale = phi_s, phi_phase = phi_p, phi_width = phi_w, + Dstar_mass = Dstar_m, DDstar_scale = DDstar_s, DDstar_phase = DDstar_p, D_mass = D_m, + Dbar_mass = Dbar_m, Dbar_scale = Dbar_s, Dbar_phase = Dbar_p, + tau_mass = tau_m, C_tt = Ctt, b0_0 = b0_0, b0_1 = b0_1, b0_2 = b0_2, + bplus_0 = bplus_0, bplus_1 = bplus_1, bplus_2 = bplus_2, + bT_0 = bT_0, bT_1 = bT_1, bT_2 = bT_2) + +total_f_fit = total_pdf_full(obs=obs_fit, jpsi_mass = jpsi_m, jpsi_scale = jpsi_s, jpsi_phase = jpsi_p, jpsi_width = jpsi_w, + psi2s_mass = psi2s_m, psi2s_scale = psi2s_s, psi2s_phase = psi2s_p, psi2s_width = psi2s_w, + p3770_mass = p3770_m, p3770_scale = p3770_s, p3770_phase = p3770_p, p3770_width = p3770_w, + p4040_mass = p4040_m, p4040_scale = p4040_s, p4040_phase = p4040_p, p4040_width = p4040_w, + p4160_mass = p4160_m, p4160_scale = p4160_s, p4160_phase = p4160_p, p4160_width = p4160_w, + p4415_mass = p4415_m, p4415_scale = p4415_s, p4415_phase = p4415_p, p4415_width = p4415_w, + rho_mass = rho_m, rho_scale = rho_s, rho_phase = rho_p, rho_width = rho_w, + omega_mass = omega_m, omega_scale = omega_s, omega_phase = omega_p, omega_width = omega_w, + phi_mass = phi_m, phi_scale = phi_s, phi_phase = phi_p, phi_width = phi_w, + Dstar_mass = Dstar_m, DDstar_scale = DDstar_s, DDstar_phase = DDstar_p, D_mass = D_m, + Dbar_mass = Dbar_m, Dbar_scale = Dbar_s, Dbar_phase = Dbar_p, + tau_mass = tau_m, C_tt = Ctt, b0_0 = b0_0, b0_1 = b0_1, b0_2 = b0_2, + bplus_0 = bplus_0, bplus_1 = bplus_1, bplus_2 = bplus_2, + bT_0 = bT_0, bT_1 = bT_1, bT_2 = bT_2) + +# print(total_pdf.obs) + +# print(calcs_test) + +# for param in total_f.get_dependents(): +# print(zfit.run(param)) + + +# In[ ]: + + +# total_f_fit.normalization(obs_fit) + + +# ## Test if graphs actually work and compute values + +# In[ ]: + + +# def total_test_tf(xq): + +# def jpsi_res(q): +# return resonance(q, jpsi_m, jpsi_s, jpsi_p, jpsi_w) + +# def psi2s_res(q): +# return resonance(q, psi2s_m, psi2s_s, psi2s_p, psi2s_w) + +# def cusp(q): +# return bifur_gauss(q, cusp_m, sig_L, sig_R, cusp_s) + +# funcs = jpsi_res(xq) + psi2s_res(xq) + cusp(xq) + +# vec_f = vec(xq, funcs) + +# axiv_nr = axiv_nonres(xq) + +# tot = vec_f + axiv_nr + +# return tot + +# def jpsi_res(q): +# return resonance(q, jpsi_m, jpsi_s, jpsi_p, jpsi_w) + +# calcs = zfit.run(total_test_tf(x_part)) + + + +test_q = np.linspace(x_min, x_max, int(2e6)) + +probs = total_f_fit.pdf(test_q, norm_range=False) + +calcs_test = zfit.run(probs) + +Ctt.set_value(0.5) + +calcs_test1 = zfit.run(probs) + +Ctt.set_value(0.0) + +Dbar_s.set_value(0.3) + +DDstar_s.set_value(0.3) + +calcs_test2 = zfit.run(probs) +# res_y = zfit.run(jpsi_res(test_q)) +# b0 = [b0_0, b0_1, b0_2] +# bplus = [bplus_0, bplus_1, bplus_2] +# bT = [bT_0, bT_1, bT_2] +# f0_y = zfit.run(tf.math.real(formfactor(test_q,"0", b0, bplus, bT))) +# fplus_y = zfit.run(tf.math.real(formfactor(test_q,"+", b0, bplus, bT))) +# fT_y = zfit.run(tf.math.real(formfactor(test_q,"T", b0, bplus, bT))) + + +# In[ ]: + + +plt.clf() +# plt.plot(x_part, calcs, '.') +plt.plot(test_q, calcs_test, label = 'pdf (Ctt = 0.0)') +plt.plot(test_q, calcs_test1, label = 'pdf (Ctt = 0.5)') +plt.plot(test_q, calcs_test2, label = 'pdf (D-contribs = 0.3)') +# plt.plot(test_q, f0_y, label = '0') +# plt.plot(test_q, fT_y, label = 'T') +# plt.plot(test_q, fplus_y, label = '+') +# plt.plot(test_q, res_y, label = 'res') +plt.legend() +plt.ylim(0.0, 1.5e-6) +# plt.yscale('log') +# plt.xlim(770, 785) +plt.savefig('test.png') +# print(jpsi_width) + + +# In[ ]: + + + + +# probs = mixture.prob(test_q) +# probs_np = zfit.run(probs) +# probs_np *= np.max(calcs_test) / np.max(probs_np) +# plt.figure() +# plt.semilogy(test_q, probs_np,label="importance sampling") +# plt.semilogy(test_q, calcs_test, label = 'pdf') + + +# In[ ]: + + +# 0.213/(0.00133+0.213+0.015) + + +# ## Adjust scaling of different parts + +# In[ ]: + + +total_f.update_integration_options(draws_per_dim=2000000, mc_sampler=None) +# inte = total_f.integrate(limits = (950., 1050.), norm_range=False) +# inte_fl = zfit.run(inte) +# print(inte_fl/4500) +# print(pdg["jpsi_BR"]/pdg["NR_BR"], inte_fl*pdg["psi2s_auc"]/pdg["NR_auc"]) + + +# In[ ]: + + +# # print("jpsi:", inte_fl) +# # print("Increase am by factor:", np.sqrt(pdg["jpsi_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) +# # print("New amp:", pdg["jpsi"][3]*np.sqrt(pdg["jpsi_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) + +# # print("psi2s:", inte_fl) +# # print("Increase am by factor:", np.sqrt(pdg["psi2s_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) +# # print("New amp:", pdg["psi2s"][3]*np.sqrt(pdg["psi2s_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) + +# name = "phi" + +# print(name+":", inte_fl) +# print("Increase am by factor:", np.sqrt(pdg[name+"_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) +# print("New amp:", pdg[name][0]*np.sqrt(pdg[name+"_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) + + +# print(x_min) +# print(x_max) +# # total_f.update_integration_options(draws_per_dim=2000000, mc_sampler=None) +# total_f.update_integration_options(mc_sampler=lambda dim, num_results, +# dtype: tf.random_uniform(maxval=1., shape=(num_results, dim), dtype=dtype), +# draws_per_dim=1000000) +# # _ = [] + +# # for i in range(10): + +# # inte = total_f.integrate(limits = (x_min, x_max)) +# # inte_fl = zfit.run(inte) +# # print(inte_fl) +# # _.append(inte_fl) + +# # print("mean:", np.mean(_)) + +# _ = time.time() + +# inte = total_f.integrate(limits = (x_min, x_max)) +# inte_fl = zfit.run(inte) +# print(inte_fl) +# print("Time taken: {}".format(display_time(int(time.time() - _)))) + +# print(pdg['NR_BR']/pdg['NR_auc']*inte_fl) +# print(0.25**2*4.2/1000) + + +# # Sampling +# ## Mixture distribution for sampling + +# In[ ]: + + + + +# print(list_of_borders[:9]) +# print(list_of_borders[-9:]) + + +class UniformSampleAndWeights(zfit.util.execution.SessionHolderMixin): + def __call__(self, limits, dtype, n_to_produce): + # n_to_produce = tf.cast(n_to_produce, dtype=tf.int32) + low, high = limits.limit1d + low = tf.cast(low, dtype=dtype) + high = tf.cast(high, dtype=dtype) +# uniform = tfd.Uniform(low=low, high=high) +# uniformjpsi = tfd.Uniform(low=tf.constant(3080, dtype=dtype), high=tf.constant(3112, dtype=dtype)) +# uniformpsi2s = tfd.Uniform(low=tf.constant(3670, dtype=dtype), high=tf.constant(3702, dtype=dtype)) + +# list_of_borders = [] +# _p = [] +# splits = 10 + +# _ = np.linspace(x_min, x_max, splits) + +# for i in range(splits): +# list_of_borders.append(tf.constant(_[i], dtype=dtype)) +# _p.append(tf.constant(1/splits, dtype=dtype)) + +# mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=_p[:(splits-1)]), +# components_distribution=tfd.Uniform(low=list_of_borders[:(splits-1)], +# high=list_of_borders[-(splits-1):])) + mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=[tf.constant(0.05, dtype=dtype), + tf.constant(0.93, dtype=dtype), + tf.constant(0.05, dtype=dtype), + tf.constant(0.065, dtype=dtype), + tf.constant(0.04, dtype=dtype), + tf.constant(0.05, dtype=dtype)]), + components_distribution=tfd.Uniform(low=[tf.constant(x_min, dtype=dtype), + tf.constant(3090, dtype=dtype), + tf.constant(3681, dtype=dtype), + tf.constant(3070, dtype=dtype), + tf.constant(1000, dtype=dtype), + tf.constant(3660, dtype=dtype)], + high=[tf.constant(x_max, dtype=dtype), + tf.constant(3102, dtype=dtype), + tf.constant(3691, dtype=dtype), + tf.constant(3110, dtype=dtype), + tf.constant(1040, dtype=dtype), + tf.constant(3710, dtype=dtype)])) +# dtype = tf.float64 +# mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=[tf.constant(0.04, dtype=dtype), +# tf.constant(0.90, dtype=dtype), +# tf.constant(0.02, dtype=dtype), +# tf.constant(0.07, dtype=dtype), +# tf.constant(0.02, dtype=dtype)]), +# components_distribution=tfd.Uniform(low=[tf.constant(x_min, dtype=dtype), +# tf.constant(3089, dtype=dtype), +# tf.constant(3103, dtype=dtype), +# tf.constant(3681, dtype=dtype), +# tf.constant(3691, dtype=dtype)], +# high=[tf.constant(3089, dtype=dtype), +# tf.constant(3103, dtype=dtype), +# tf.constant(3681, dtype=dtype), +# tf.constant(3691, dtype=dtype), +# tf.constant(x_max, dtype=dtype)])) +# mixture = tfd.Uniform(tf.constant(x_min, dtype=dtype), tf.constant(x_max, dtype=dtype)) +# sample = tf.random.uniform((n_to_produce, 1), dtype=dtype) + sample = mixture.sample((n_to_produce, 1)) +# sample = tf.random.uniform((n_to_produce, 1), dtype=dtype) + weights = mixture.prob(sample)[:,0] +# weights = tf.broadcast_to(tf.constant(1., dtype=dtype), shape=(n_to_produce,)) + # sample = tf.expand_dims(sample, axis=-1) +# print(sample, weights) + +# weights = tf.ones(shape=(n_to_produce,), dtype=dtype) + weights_max = None + thresholds = tf.random_uniform(shape=(n_to_produce,), dtype=dtype) + return sample, thresholds, weights, weights_max, n_to_produce + + +# In[ ]: + + +# total_f._sample_and_weights = UniformSampleAndWeights + + +# In[ ]: + + +# 0.00133/(0.00133+0.213+0.015)*(x_max-3750)/(x_max-x_min) + + +# In[ ]: + + +# zfit.settings.set_verbosity(10) + + +# In[ ]: + + +# # zfit.run.numeric_checks = False + +# nr_of_toys = 1 +# nevents = int(pdg["number_of_decays"]) +# nevents = pdg["number_of_decays"] +# event_stack = 1000000 +# # zfit.settings.set_verbosity(10) +# calls = int(nevents/event_stack + 1) + +# total_samp = [] + +# start = time.time() + +# sampler = total_f.create_sampler(n=event_stack) + +# for toy in range(nr_of_toys): + +# dirName = 'data/zfit_toys/toy_{0}'.format(toy) + +# if not os.path.exists(dirName): +# os.mkdir(dirName) +# print("Directory " , dirName , " Created ") + +# for call in range(calls): + +# sampler.resample(n=event_stack) +# s = sampler.unstack_x() +# sam = zfit.run(s) +# # clear_output(wait=True) + +# c = call + 1 + +# print("{0}/{1} of Toy {2}/{3}".format(c, calls, toy+1, nr_of_toys)) +# print("Time taken: {}".format(display_time(int(time.time() - start)))) +# print("Projected time left: {}".format(display_time(int((time.time() - start)/(c+calls*(toy))*((nr_of_toys-toy)*calls-c))))) + +# with open("data/zfit_toys/toy_{0}/{1}.pkl".format(toy, call), "wb") as f: +# pkl.dump(sam, f, pkl.HIGHEST_PROTOCOL) + + +# In[ ]: + + +# with open(r"data/zfit_toys/toy_0/0.pkl", "rb") as input_file: +# sam = pkl.load(input_file) +# print(sam[:10]) + +# with open(r"data/zfit_toys/toy_0/1.pkl", "rb") as input_file: +# sam2 = pkl.load(input_file) +# print(sam2[:10]) + +# print(np.sum(sam-sam2)) + + +# In[ ]: + + +# print("Time to generate full toy: {} s".format(int(time.time()-start))) + +# total_samp = [] + +# for call in range(calls): +# with open(r"data/zfit_toys/toy_0/{}.pkl".format(call), "rb") as input_file: +# sam = pkl.load(input_file) +# total_samp = np.append(total_samp, sam) + +# total_samp = total_samp.astype('float64') + +# data2 = zfit.data.Data.from_numpy(array=total_samp[:int(nevents)], obs=obs) + +# data3 = zfit.data.Data.from_numpy(array=total_samp, obs=obs) + +# print(total_samp[:nevents].shape) + + +# In[ ]: + + +# plt.clf() + +# bins = int((x_max-x_min)/7) + +# # calcs = zfit.run(total_test_tf(samp)) +# print(total_samp[:nevents].shape) + +# plt.hist(total_samp[:nevents], bins = bins, range = (x_min,x_max), label = 'data') +# # plt.plot(test_q, calcs_test*nevents , label = 'pdf') + +# # plt.plot(sam, calcs, '.') +# # plt.plot(test_q, calcs_test) +# # plt.yscale('log') +# plt.ylim(0, 200) +# # plt.xlim(3080, 3110) + +# plt.legend() + +# plt.savefig('test2.png') + + +# In[ ]: + + +# sampler = total_f.create_sampler(n=nevents) +# nll = zfit.loss.UnbinnedNLL(model=total_f, data=sampler, fit_range = (x_min, x_max)) + +# # for param in pdf.get_dependents(): +# # param.set_value(initial_value) + +# sampler.resample(n=nevents) + +# # Randomise initial values +# # for param in pdf.get_dependents(): +# # param.set_value(random value here) + +# # Minimise the NLL +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 10) +# minimum = minimizer.minimize(nll) + + +# In[ ]: + + +# jpsi_width + + +# In[ ]: + + +# plt.hist(sample, weights=1 / prob(sample)) + + +# # Fitting + +# In[ ]: + + +# start = time.time() + +# for param in total_f.get_dependents(): +# param.randomize() + +# # for param in total_f.get_dependents(): +# # print(zfit.run(param)) + +# nll = zfit.loss.UnbinnedNLL(model=total_f, data=data2, fit_range = (x_min, x_max)) + +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) +# # minimizer._use_tfgrad = False +# result = minimizer.minimize(nll) + +# # param_errors = result.error() + +# # for var, errors in param_errors.items(): +# # print('{}: ^{{+{}}}_{{{}}}'.format(var.name, errors['upper'], errors['lower'])) + +# print("Function minimum:", result.fmin) +# # print("Results:", result.params) +# print("Hesse errors:", result.hesse()) + + +# In[ ]: + + +# print("Time taken for fitting: {}".format(display_time(int(time.time()-start)))) + +# # probs = total_f.pdf(test_q) + +# calcs_test = zfit.run(probs) +# res_y = zfit.run(jpsi_res(test_q)) + + +# In[ ]: + + +# plt.clf() +# # plt.plot(x_part, calcs, '.') +# plt.plot(test_q, calcs_test, label = 'pdf') +# # plt.plot(test_q, res_y, label = 'res') +# plt.legend() +# plt.ylim(0.0, 10e-6) +# # plt.yscale('log') +# # plt.xlim(3080, 3110) +# plt.savefig('test3.png') +# # print(jpsi_width) + + +# In[ ]: + + +# _tot = 4.37e-7+6.02e-5+4.97e-6 +# _probs = [] +# _probs.append(6.02e-5/_tot) +# _probs.append(4.97e-6/_tot) +# _probs.append(4.37e-7/_tot) +# print(_probs) + + +# In[ ]: + + +# dtype = 'float64' +# # mixture = tfd.Uniform(tf.constant(x_min, dtype=dtype), tf.constant(x_max, dtype=dtype)) +# mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=[tf.constant(0.007, dtype=dtype), +# tf.constant(0.917, dtype=dtype), +# tf.constant(0.076, dtype=dtype)]), +# components_distribution=tfd.Uniform(low=[tf.constant(x_min, dtype=dtype), +# tf.constant(3080, dtype=dtype), +# tf.constant(3670, dtype=dtype)], +# high=[tf.constant(x_max, dtype=dtype), +# tf.constant(3112, dtype=dtype), +# tf.constant(3702, dtype=dtype)])) +# # for i in range(10): +# # print(zfit.run(mixture.prob(mixture.sample((10, 1))))) + + +# In[ ]: + + +# print((zfit.run(jpsi_p)%(2*np.pi))/np.pi) +# print((zfit.run(psi2s_p)%(2*np.pi))/np.pi) + + +# In[ ]: + + +# def jpsi_res(q): +# return resonance(q, _mass = jpsi_mass, scale = jpsi_scale, +# phase = jpsi_phase, width = jpsi_width) + +# def psi2s_res(q): +# return resonance(q, _mass = psi2s_mass, scale = psi2s_scale, +# phase = psi2s_phase, width = psi2s_width) + +# def p3770_res(q): +# return resonance(q, _mass = p3770_mass, scale = p3770_scale, +# phase = p3770_phase, width = p3770_width) + +# def p4040_res(q): +# return resonance(q, _mass = p4040_mass, scale = p4040_scale, +# phase = p4040_phase, width = p4040_width) + +# def p4160_res(q): +# return resonance(q, _mass = p4160_mass, scale = p4160_scale, +# phase = p4160_phase, width = p4160_width) + +# def p4415_res(q): +# return resonance(q, _mass = p4415_mass, scale = p4415_scale, +# phase = p4415_phase, width = p4415_width) + + +# In[ ]: + + +# 0.15**2*4.2/1000 +# result.hesse() + + +# ## Constraints + +# In[ ]: + + +# 1. Constraint - Real part of sum of Psi contrib and D contribs + +sum_list = [] + +sum_list.append(ztf.to_complex(jpsi_s) * tf.exp(tf.complex(ztf.constant(0.0), jpsi_p)) * ztf.to_complex(jpsi_w / (tf.pow(jpsi_m,3)))) +sum_list.append(ztf.to_complex(psi2s_s) * tf.exp(tf.complex(ztf.constant(0.0), psi2s_p)) * ztf.to_complex(psi2s_w / (tf.pow(psi2s_m,3)))) +sum_list.append(ztf.to_complex(p3770_s) * tf.exp(tf.complex(ztf.constant(0.0), p3770_p)) * ztf.to_complex(p3770_w / (tf.pow(p3770_m,3)))) +sum_list.append(ztf.to_complex(p4040_s) * tf.exp(tf.complex(ztf.constant(0.0), p4040_p)) * ztf.to_complex(p4040_w / (tf.pow(p4040_m,3)))) +sum_list.append(ztf.to_complex(p4160_s) * tf.exp(tf.complex(ztf.constant(0.0), p4160_p)) * ztf.to_complex(p4160_w / (tf.pow(p4160_m,3)))) +sum_list.append(ztf.to_complex(p4415_s) * tf.exp(tf.complex(ztf.constant(0.0), p4415_p)) * ztf.to_complex(p4415_w / (tf.pow(p4415_m,3)))) +sum_list.append(ztf.to_complex(DDstar_s) * tf.exp(tf.complex(ztf.constant(0.0), DDstar_p)) * (ztf.to_complex(1.0 / (10.0*tf.pow(Dstar_m,2)) + 1.0 / (10.0*tf.pow(D_m,2))))) +sum_list.append(ztf.to_complex(Dbar_s) * tf.exp(tf.complex(ztf.constant(0.0), Dbar_p)) * ztf.to_complex(1.0 / (6.0*tf.pow(Dbar_m,2)))) + +sum_ru_1 = ztf.to_complex(ztf.constant(0.0)) + +for part in sum_list: + sum_ru_1 += part + +sum_1 = tf.math.real(sum_ru_1) +# constraint1 = zfit.constraint.GaussianConstraint(params = sum_1, mu = ztf.constant(1.7*10**-8), +# sigma = ztf.constant(2.2*10**-8)) + +constraint1 = tf.pow((sum_1-ztf.constant(1.7*10**-8))/ztf.constant(2.2*10**-8),2)/ztf.constant(2.) + +# 2. Constraint - Abs. of sum of Psi contribs and D contribs + +sum_2 = tf.abs(sum_ru_1) +constraint2 = tf.cond(tf.greater_equal(sum_2, 5.0e-8), lambda: 100000., lambda: 0.) + +# 3. Constraint - Maximum eta of D contribs + +constraint3_0 = tf.cond(tf.greater_equal(tf.abs(Dbar_s), 0.2), lambda: 100000., lambda: 0.) + +constraint3_1 = tf.cond(tf.greater_equal(tf.abs(DDstar_s), 0.2), lambda: 100000., lambda: 0.) + +# 4. Constraint - Formfactor multivariant gaussian covariance fplus + +Cov_matrix = [[ztf.constant( 1.), ztf.constant( 0.45), ztf.constant( 0.19), ztf.constant(0.857), ztf.constant(0.598), ztf.constant(0.531), ztf.constant(0.752), ztf.constant(0.229), ztf.constant(0,117)], + [ztf.constant( 0.45), ztf.constant( 1.), ztf.constant(0.677), ztf.constant(0.708), ztf.constant(0.958), ztf.constant(0.927), ztf.constant(0.227), ztf.constant(0.443), ztf.constant(0.287)], + [ztf.constant( 0.19), ztf.constant(0.677), ztf.constant( 1.), ztf.constant(0.595), ztf.constant(0.770), ztf.constant(0.819),ztf.constant(-0.023), ztf.constant( 0.07), ztf.constant(0.196)], + [ztf.constant(0.857), ztf.constant(0.708), ztf.constant(0.595), ztf.constant( 1.), ztf.constant( 0.83), ztf.constant(0.766), ztf.constant(0.582), ztf.constant(0.237), ztf.constant(0.192)], + [ztf.constant(0.598), ztf.constant(0.958), ztf.constant(0.770), ztf.constant( 0.83), ztf.constant( 1.), ztf.constant(0.973), ztf.constant(0.324), ztf.constant(0.372), ztf.constant(0.272)], + [ztf.constant(0.531), ztf.constant(0.927), ztf.constant(0.819), ztf.constant(0.766), ztf.constant(0.973), ztf.constant( 1.), ztf.constant(0.268), ztf.constant(0.332), ztf.constant(0.269)], + [ztf.constant(0.752), ztf.constant(0.227),ztf.constant(-0.023), ztf.constant(0.582), ztf.constant(0.324), ztf.constant(0.268), ztf.constant( 1.), ztf.constant( 0.59), ztf.constant(0.515)], + [ztf.constant(0.229), ztf.constant(0.443), ztf.constant( 0.07), ztf.constant(0.237), ztf.constant(0.372), ztf.constant(0.332), ztf.constant( 0.59), ztf.constant( 1.), ztf.constant(0.897)], + [ztf.constant(0.117), ztf.constant(0.287), ztf.constant(0.196), ztf.constant(0.192), ztf.constant(0.272), ztf.constant(0.269), ztf.constant(0.515), ztf.constant(0.897), ztf.constant( 1.)]] + +def triGauss(val1,val2,val3,m = Cov_matrix): + + mean1 = ztf.constant(0.466) + mean2 = ztf.constant(-0.885) + mean3 = ztf.constant(-0.213) + sigma1 = ztf.constant(0.014) + sigma2 = ztf.constant(0.128) + sigma3 = ztf.constant(0.548) + x1 = (val1-mean1)/sigma1 + x2 = (val2-mean2)/sigma2 + x3 = (val3-mean3)/sigma3 + rho12 = m[0][1] + rho13 = m[0][2] + rho23 = m[1][2] + w = x1*x1*(rho23*rho23-1) + x2*x2*(rho13*rho13-1)+x3*x3*(rho12*rho12-1)+2*(x1*x2*(rho12-rho13*rho23)+x1*x3*(rho13-rho12*rho23)+x2*x3*(rho23-rho12*rho13)) + d = 2*(rho12*rho12+rho13*rho13+rho23*rho23-2*rho12*rho13*rho23-1) + + fcn = -w/d + chisq = -2*fcn + return chisq + +constraint4 = triGauss(bplus_0, bplus_1, bplus_2) + +# mean1 = ztf.constant(0.466) +# mean2 = ztf.constant(-0.885) +# mean3 = ztf.constant(-0.213) +# sigma1 = ztf.constant(0.014) +# sigma2 = ztf.constant(0.128) +# sigma3 = ztf.constant(0.548) +# constraint4_0 = tf.pow((bplus_0-mean1)/sigma1,2)/ztf.constant(2.) +# constraint4_1 = tf.pow((bplus_1-mean2)/sigma2,2)/ztf.constant(2.) +# constraint4_2 = tf.pow((bplus_2-mean3)/sigma3,2)/ztf.constant(2.) + +# 5. Constraint - Abs. of sum of light contribs + +sum_list_5 = [] + +sum_list_5.append(rho_s*rho_w/rho_m) +sum_list_5.append(omega_s*omega_w/omega_m) +sum_list_5.append(phi_s*phi_w/phi_m) + + +sum_ru_5 = ztf.constant(0.0) + +for part in sum_list_5: + sum_ru_5 += part + +constraint5 = tf.cond(tf.greater_equal(tf.abs(sum_ru_5), ztf.constant(0.02)), lambda: 100000., lambda: 0.) + +# 6. Constraint on phases of Jpsi and Psi2s for cut out fit + + +# constraint6_0 = zfit.constraint.GaussianConstraint(params = jpsi_p, mu = ztf.constant(pdg["jpsi_phase_unc"]), +# sigma = ztf.constant(jpsi_phase)) +# constraint6_1 = zfit.constraint.GaussianConstraint(params = psi2s_p, mu = ztf.constant(pdg["psi2s_phase_unc"]), +# sigma = ztf.constant(psi2s_phase)) + +constraint6_0 = tf.pow((jpsi_p-ztf.constant(jpsi_phase))/ztf.constant(pdg["jpsi_phase_unc"]),2)/ztf.constant(2.) +constraint6_1 = tf.pow((psi2s_p-ztf.constant(psi2s_phase))/ztf.constant(pdg["psi2s_phase_unc"]),2)/ztf.constant(2.) + +# 7. Constraint on Ctt with higher limits + +constraint7 = tf.cond(tf.greater_equal(Ctt*Ctt, 0.25), lambda: 100000., lambda: 0.) + +constraint7dtype = tf.float64 + +# zfit.run(constraint6_0) + +# ztf.convert_to_tensor(constraint6_0) + +#List of all constraints + +constraints = [constraint1, constraint2, constraint3_0, constraint3_1,# constraint4, #constraint4_0, constraint4_1, constraint4_2, + constraint6_0, constraint6_1]#, constraint7] + + +# ## Reset params + +# In[ ]: + + +param_values_dic = { + 'jpsi_m': jpsi_mass, + 'jpsi_s': jpsi_scale, + 'jpsi_p': jpsi_phase, + 'jpsi_w': jpsi_width, + 'psi2s_m': psi2s_mass, + 'psi2s_s': psi2s_scale, + 'psi2s_p': psi2s_phase, + 'psi2s_w': psi2s_width, + 'p3770_m': p3770_mass, + 'p3770_s': p3770_scale, + 'p3770_p': p3770_phase, + 'p3770_w': p3770_width, + 'p4040_m': p4040_mass, + 'p4040_s': p4040_scale, + 'p4040_p': p4040_phase, + 'p4040_w': p4040_width, + 'p4160_m': p4160_mass, + 'p4160_s': p4160_scale, + 'p4160_p': p4160_phase, + 'p4160_w': p4160_width, + 'p4415_m': p4415_mass, + 'p4415_s': p4415_scale, + 'p4415_p': p4415_phase, + 'p4415_w': p4415_width, + 'rho_m': rho_mass, + 'rho_s': rho_scale, + 'rho_p': rho_phase, + 'rho_w': rho_width, + 'omega_m': omega_mass, + 'omega_s': omega_scale, + 'omega_p': omega_phase, + 'omega_w': omega_width, + 'phi_m': phi_mass, + 'phi_s': phi_scale, + 'phi_p': phi_phase, + 'phi_w': phi_width, + 'Dstar_m': Dstar_mass, + 'DDstar_s': 0.0, + 'DDstar_p': 0.0, + 'D_m': D_mass, + 'Dbar_m': Dbar_mass, + 'Dbar_s': 0.0, + 'Dbar_p': 0.0, + 'tau_m': pdg['tau_M'], + 'Ctt': 0.0, + 'b0_0': 0.292, + 'b0_1': 0.281, + 'b0_2': 0.150, + 'bplus_0': 0.466, + 'bplus_1': -0.885, + 'bplus_2': -0.213, + 'bT_0': 0.460, + 'bT_1': -1.089, + 'bT_2': -1.114} + + +def reset_param_values(variation = 0.05): + for param in total_f_fit.get_dependents(): + if param.floating: + param.set_value(param_values_dic[param.name] + random.uniform(-1, 1) * param_values_dic[param.name]* variation) +# print(param.name) +# for param in totalf.get_dependents(): +# param.set_value() + + +# # Analysis + +# In[ ]: + + +# # zfit.run.numeric_checks = False + +# fitting_range = 'cut' +# total_BR = 1.7e-10 + 4.9e-10 + 2.5e-9 + 6.02e-5 + 4.97e-6 + 1.38e-9 + 4.2e-10 + 2.6e-9 + 6.1e-10 + 4.37e-7 +# cut_BR = 1.0 - (6.02e-5 + 4.97e-6)/total_BR + +# Ctt_list = [] +# Ctt_error_list = [] + +# nr_of_toys = 1 +# if fitting_range == 'cut': +# nevents = int(pdg["number_of_decays"]*cut_BR) +# else: +# nevents = int(pdg["number_of_decays"]) +# # nevents = pdg["number_of_decays"] +# event_stack = 1000000 +# # nevents *= 41 +# # zfit.settings.set_verbosity(10) +# calls = int(nevents/event_stack + 1) + +# total_samp = [] + +# start = time.time() + +# sampler = total_f.create_sampler(n=event_stack) + +# for toy in range(nr_of_toys): + +# ### Generate data + +# # clear_output(wait=True) + +# print("Toy {}: Generating data...".format(toy)) + +# dirName = 'data/zfit_toys/toy_{0}'.format(toy) + +# if not os.path.exists(dirName): +# os.mkdir(dirName) +# print("Directory " , dirName , " Created ") + +# reset_param_values() + +# if fitting_range == 'cut': + +# sampler.resample(n=nevents) +# s = sampler.unstack_x() +# sam = zfit.run(s) +# calls = 0 +# c = 1 + +# else: +# for call in range(calls): + +# sampler.resample(n=event_stack) +# s = sampler.unstack_x() +# sam = zfit.run(s) + +# c = call + 1 + +# with open("data/zfit_toys/toy_{0}/{1}.pkl".format(toy, call), "wb") as f: +# pkl.dump(sam, f, pkl.HIGHEST_PROTOCOL) + +# print("Toy {}: Data generation finished".format(toy)) + +# ### Load data + +# print("Toy {}: Loading data...".format(toy)) + +# if fitting_range == 'cut': + +# total_samp = sam + +# else: + +# for call in range(calls): +# with open(r"data/zfit_toys/toy_0/{}.pkl".format(call), "rb") as input_file: +# sam = pkl.load(input_file) +# total_samp = np.append(total_samp, sam) + +# total_samp = total_samp.astype('float64') + +# if fitting_range == 'full': + +# data = zfit.data.Data.from_numpy(array=total_samp[:int(nevents)], obs=obs) + +# print("Toy {}: Loading data finished".format(toy)) + +# ### Fit data + +# print("Toy {}: Fitting pdf...".format(toy)) + +# for param in total_f.get_dependents(): +# param.randomize() + +# nll = zfit.loss.UnbinnedNLL(model=total_f, data=data, fit_range = (x_min, x_max), constraints = constraints) + +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) +# # minimizer._use_tfgrad = False +# result = minimizer.minimize(nll) + +# print("Toy {}: Fitting finished".format(toy)) + +# print("Function minimum:", result.fmin) +# print("Hesse errors:", result.hesse()) + +# params = result.params +# Ctt_list.append(params[Ctt]['value']) +# Ctt_error_list.append(params[Ctt]['minuit_hesse']['error']) + +# #plotting the result + +# plotdirName = 'data/plots'.format(toy) + +# if not os.path.exists(plotdirName): +# os.mkdir(plotdirName) +# # print("Directory " , dirName , " Created ") + +# probs = total_f.pdf(test_q, norm_range=False) +# calcs_test = zfit.run(probs) +# plt.clf() +# plt.plot(test_q, calcs_test, label = 'pdf') +# plt.legend() +# plt.ylim(0.0, 6e-6) +# plt.savefig(plotdirName + '/toy_fit_full_range{}.png'.format(toy)) + +# print("Toy {0}/{1}".format(toy+1, nr_of_toys)) +# print("Time taken: {}".format(display_time(int(time.time() - start)))) +# print("Projected time left: {}".format(display_time(int((time.time() - start)/(c+calls*(toy))*((nr_of_toys-toy)*calls-c))))) + +# if fitting_range == 'cut': + +# _1 = np.where((total_samp >= x_min) & (total_samp <= (jpsi_mass - 60.))) + +# tot_sam_1 = total_samp[_1] + +# _2 = np.where((total_samp >= (jpsi_mass + 70.)) & (total_samp <= (psi2s_mass - 50.))) + +# tot_sam_2 = total_samp[_2] + +# _3 = np.where((total_samp >= (psi2s_mass + 50.)) & (total_samp <= x_max)) + +# tot_sam_3 = total_samp[_3] + +# tot_sam = np.append(tot_sam_1, tot_sam_2) +# tot_sam = np.append(tot_sam, tot_sam_3) + +# data = zfit.data.Data.from_numpy(array=tot_sam[:int(nevents)], obs=obs_fit) + +# print("Toy {}: Loading data finished".format(toy)) + +# ### Fit data + +# print("Toy {}: Fitting pdf...".format(toy)) + +# for param in total_f_fit.get_dependents(): +# param.randomize() + +# nll = zfit.loss.UnbinnedNLL(model=total_f_fit, data=data, constraints = constraints) + +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) +# # minimizer._use_tfgrad = False +# result = minimizer.minimize(nll) + +# print("Function minimum:", result.fmin) +# print("Hesse errors:", result.hesse()) + +# params = result.params + +# if result.converged: +# Ctt_list.append(params[Ctt]['value']) +# Ctt_error_list.append(params[Ctt]['minuit_hesse']['error']) + +# #plotting the result + +# plotdirName = 'data/plots'.format(toy) + +# if not os.path.exists(plotdirName): +# os.mkdir(plotdirName) +# # print("Directory " , dirName , " Created ") + +# plt.clf() +# plt.hist(tot_sam, bins = int((x_max-x_min)/7.), label = 'toy data') +# plt.savefig(plotdirName + '/toy_histo_cut_region{}.png'.format(toy)) + + +# probs = total_f_fit.pdf(test_q, norm_range=False) +# calcs_test = zfit.run(probs) +# plt.clf() +# plt.plot(test_q, calcs_test, label = 'pdf') +# plt.axvline(x=jpsi_mass-60.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.axvline(x=jpsi_mass+70.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.axvline(x=psi2s_mass-50.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.axvline(x=psi2s_mass+50.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.legend() +# plt.ylim(0.0, 1.5e-6) +# plt.savefig(plotdirName + '/toy_fit_cut_region{}.png'.format(toy)) + +# print("Toy {0}/{1}".format(toy+1, nr_of_toys)) +# print("Time taken: {}".format(display_time(int(time.time() - start)))) +# print("Projected time left: {}".format(display_time(int((time.time() - start)/(toy+1))*((nr_of_toys-toy-1))))) + + + +# In[ ]: + + +# with open("data/results/Ctt_list.pkl", "wb") as f: +# pkl.dump(Ctt_list, f, pkl.HIGHEST_PROTOCOL) +# with open("data/results/Ctt_error_list.pkl", "wb") as f: +# pkl.dump(Ctt_error_list, f, pkl.HIGHEST_PROTOCOL) + + +# In[ ]: + + +# print('{0}/{1} fits converged'.format(len(Ctt_list), nr_of_toys)) +# print('Mean Ctt value = {}'.format(np.mean(Ctt_list))) +# print('Mean Ctt error = {}'.format(np.mean(Ctt_error_list))) +# print('95 Sensitivy = {}'.format(((2*np.mean(Ctt_error_list))**2)*4.2/1000)) + + +# In[ ]: + + +# plt.hist(tot_sam, bins = int((x_max-x_min)/7.)) + +# plt.show() + +# # _ = np.where((total_samp >= x_min) & (total_samp <= (jpsi_mass - 50.))) + +# tot_sam.shape + + +# In[ ]: + + +# Ctt.floating = False + + +# In[ ]: + + +# zfit.run(nll.value()) + + +# In[ ]: + + +# result.fmin + + +# In[ ]: + + +# BR_steps = np.linspace(0.0, 1e-3, 11) +pull_dic = {} + +mi = 1e-4 +ma = 3e-3 +ste = 20 + +for param in total_f_fit.get_dependents(): + if param.floating: + pull_dic[param.name] = [] + for step in range(2*ste): + pull_dic[param.name].append([]) + + + +def save_pulls(step): + for param in total_f_fit.get_dependents(): + if param.floating: + pull_dic[param.name][step].append((params[param]['value'] - param_values_dic[param.name])/params[param]['minuit_hesse']['error']) + + + +# for key in pull_dic.keys(): +# print(np.shape(pull_dic[key])) +# save_pulls(New_step=True) +# params[Ctt]['value'] + + +# In[ ]: + + +# for param in total_f_fit.get_dependents(): +# if param.floating: +# print(param.name) + +# print(params[Ctt]) + + +# # CLS Code + +# In[ ]: + + +# zfit.run.numeric_checks = False + +load = False + +bo = True + +D_contribs = True + +if not D_contribs: + Dbar_s.floating = False + Dbar_p.floating = False + DDstar_s.floating = False + DDstar_p.floating = False + +bo_set = 1 + +fitting_range = 'cut' +total_BR = 1.7e-10 + 4.9e-10 + 2.5e-9 + 6.02e-5 + 4.97e-6 + 1.38e-9 + 4.2e-10 + 2.6e-9 + 6.1e-10 + 4.37e-7 +cut_BR = 1.0 - (6.02e-5 + 4.97e-6)/total_BR + +Ctt_list = [] +Ctt_error_list = [] + +nr_of_toys = 1 +nevents = int(pdg["number_of_decays"]*cut_BR) +# nevents = pdg["number_of_decays"] +event_stack = 1000000 +# nevents *= 41 +# zfit.settings.set_verbosity(10) + +# mi = 1e-4 +# ma = 3e-3 +# ste = 13 + +BR_steps = np.linspace(mi, ma, ste) + +BR_steps[0] = 0.0 + +print(BR_steps) + +Ctt_steps = np.sqrt(BR_steps/4.2*1000) + +print(Ctt_steps) + +# total_samp = [] + +start = time.time() + +Nll_list = [] + +sampler = total_f.create_sampler(n=nevents, fixed_params = False) +sampler.set_data_range(obs_fit) + +__ = -1 + +#----------------------------------------------------- + +if not load: + for Ctt_step in Ctt_steps: + + __ += 1 + + for i in range(2): + Ctt_list.append([]) + Ctt_error_list.append([]) + Nll_list.append([]) + + for param in total_f_fit.get_dependents(): + if param.floating: + pull_dic[param.name].append([]) + + for toy in range(nr_of_toys): + + newset = True + + while newset: + + for floaty in [True, False]: + Ctt.floating = floaty + + for bo_step in range(bo_set): + + print('Step: {0}/{1}'.format(int(__), ste)) + print('Current Ctt: {0}'.format(Ctt_step)) + print('Ctt floating: {0}'.format(floaty)) + + reset_param_values(variation = 0.0) + + if floaty: + print('Toy {0}/{1} - Fit {2}/{3}'.format(toy, nr_of_toys, bo_step, bo_set)) + Ctt.set_value(Ctt_step) + + else: + Ctt.set_value(0.0) + print('Toy {0}/{1} - Fit {2}/{3}'.format(toy, nr_of_toys, bo_step, bo_set)) + + if newset: + sampler.resample(n=nevents) + data = sampler + newset = False + + ### Fit data + + if floaty: + #plt.clf() + #plt.title('Ctt value: {:.2f}'.format(Ctt_step)) + #plt.hist(zfit.run(data), bins = int((x_max-x_min)/7), range = (x_min, x_max)) + #plt.savefig('data/CLs/plots/set_histo{}.png'.format(__)) + _step = 2*__ + else: + _step = 2*__+1 + + nll = zfit.loss.UnbinnedNLL(model=total_f_fit, data=data, constraints = constraints) + + minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) + # minimizer._use_tfgrad = False + result = minimizer.minimize(nll) + + print("Function minimum:", result.fmin) + print("Hesse errors:", result.hesse()) + + params = result.params + + if result.converged: + + save_pulls(step = _step) + + if floaty: + Nll_list[-2].append(result.fmin) + Ctt_list[-2].append(params[Ctt]['value']) + Ctt_error_list[-2].append(params[Ctt]['minuit_hesse']['error']) + + else: + Nll_list[-1].append(result.fmin) + Ctt_list[-1].append(0.0) + Ctt_error_list[-1].append(0.0) + + + else: + for _ in [1,2]: + del Nll_list[-_][toy*bo_set:] +# print(np.shape(Nll_list[-_])) + del Ctt_list[-_][toy*bo_set:] + del Ctt_error_list[-_][toy*bo_set:] + for param in total_f_fit.get_dependents(): + if param.floating: + del pull_dic[param.name][_step+1-_][toy*bo_set:] + newset = True + break + + if not result.converged: + break + + print() + print('Time taken: {}'.format(display_time(int(time.time()-start)))) + print('Estimated time left: {}'.format(display_time(int((time.time()-start)/(__+(toy+1)/nr_of_toys)*(ste-__-(nr_of_toys-toy-1)/nr_of_toys))))) + + +# In[ ]: + + +if load: + + phase_combi = '--' + + if D_contribs: + D_dir = 'D-True' + else: + D_dir = 'D-False' + + _dir = 'data/CLs/finished/f1d1/{}/{}/'.format(phase_combi, D_dir) + + jobs = os.listdir(_dir) + + First = True + +# print(jobs) + + for job in jobs: + + dirName = _dir + str(job) + '/data/CLs' + + if not os.path.exists("{}/{}-{}_{}s{}b{}t--CLs_Nll_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys)): +# print(job) + continue + + with open(r"{}/variab.pkl".format(dirName), "rb") as input_file: + variab = pkl.load(input_file) +# print(variab) + + ### sanity check: + if variab['mi'] != mi or variab['ma'] != ma or variab['ste'] != ste or bo_set != bo_set: + print('Fitting parameters of data dont equal the ones given -- Job {} skipped!'.format(job)) + + with open(r"{}/{}-{}_{}s{}b{}t--CLs_Nll_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _Nll_list = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s{}b{}t--Ctt_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _Ctt_list = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s{}b{}t--Ctt_error_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _Ctt_error_list = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s{}b{}t--pull_dic.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _pull_dic = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s--CLs_list.pkl".format(dirName, mi,ma,ste), "rb") as input_file: + _CLs_list = pkl.load(input_file) + + + if First: + Nll_list = _Nll_list + Ctt_list = _Ctt_list + Ctt_error_list = _Ctt_error_list + pull_dic = _pull_dic +# print(_pull_dic) + CLs_list = _CLs_list + First = False + else: + for step in range(2*ste): +# print(Nll_list[step], step) + Nll_list[step].extend(_Nll_list[step]) + Ctt_list[step].extend(_Ctt_list[step]) + Ctt_error_list[step].extend(_Ctt_error_list[step]) + for key in pull_dic.keys(): +# print(key, np.shape(pull_dic[key])) + pull_dic[key][step].extend(_pull_dic[key][step]) + for step in range(ste): + CLs_list[step].extend(_CLs_list[step]) + +# print('----------------------') + + +# In[ ]: + + +dirName = 'data/CLs' + +# if bo and not load: +# for s in range(2*ste): +# Nll_list[s] = [np.min(Nll_list[s])] + + +if not load: + + if not os.path.exists(dirName): + os.mkdir(dirName) + print("Directory " , dirName , " Created ") + + with open("{}/{}-{}_{}s{}b{}t--CLs_Nll_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(Nll_list, f, pkl.HIGHEST_PROTOCOL) + + with open("{}/{}-{}_{}s{}b{}t--Ctt_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(Ctt_list, f, pkl.HIGHEST_PROTOCOL) + + with open("{}/{}-{}_{}s{}b{}t--Ctt_error_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(Ctt_error_list, f, pkl.HIGHEST_PROTOCOL) + + with open("{}/{}-{}_{}s{}b{}t--pull_dic.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(pull_dic, f, pkl.HIGHEST_PROTOCOL) + + variab = {'mi': mi, + 'ma': ma, + 'ste': ste, + 'bo_set': bo_set, + 'nr_of_toys': nr_of_toys} + + with open("{}/variab.pkl".format(dirName), "wb") as f: + pkl.dump(variab, f, pkl.HIGHEST_PROTOCOL) + + CLs_values = [] + + toy_size = bo_set + + print(np.shape(Nll_list)) + print(Nll_list[0:1]) + + for step in range(ste): + CLs_values.append([]) + for toy in range(nr_of_toys): + float_min = np.min(Nll_list[2*step][toy*bo_set:(toy+1)*bo_set]) + fix_min = np.min(Nll_list[2*step+1][toy*bo_set:(toy+1)*bo_set]) + CLs_values[step].append(float_min-fix_min) + + + print(np.shape(CLs_values)) + + with open("{}/{}-{}_{}s--CLs_list.pkl".format(dirName, mi,ma,ste), "wb") as f: + pkl.dump(CLs_values, f, pkl.HIGHEST_PROTOCOL) + + +# In[ ]: + + +# print(variab['mi'] != mi) + + +# ## Plot + +# In[ ]: + + +l = [] + + +if load: + CLs_values = -1*np.array(CLs_list) + +if not os.path.exists('data/CLs/plots'): + os.mkdir('data/CLs/plots') + print("Directory " , 'data/CLs/plots' , " Created ") + +print(np.shape(CLs_values)) + +for step in range(1,ste): + plt.clf() + plt.title('Ctt value: {:.2f}'.format(Ctt_steps[step])) + plt.hist(CLs_values[0], bins = 150, range = (-25, 50), label = 'Ctt fixed to 0') + plt.hist(CLs_values[step], bins = 150, range = (-25, 50), label = 'Ctt floating') + plt.axvline(x=np.mean(CLs_values[0]),color='red', linewidth=1.0, linestyle = 'dotted') + plt.legend() + plt.savefig('data/CLs/plots/CLs-BR({:.1E}).png'.format(BR_steps[step])) + + l.append(len(np.where(np.array(CLs_values[step]) < np.mean(CLs_values[0]))[0])) + +for step in range(2*ste): + if step%2 == 0: + floaty = True + else: + floaty = False + for key in pull_dic.keys(): + if not os.path.exists('data/CLs/plots/{}'.format(key)): + os.mkdir('data/CLs/plots/{}'.format(key)) + plt.clf() + plt.title('Pull {} - Ctt value {:.2f} - floating {}'.format(key, Ctt_steps[int(step/2)], floaty)) + plt.hist(pull_dic[key][step], bins = 50, range = (-5,5)) + plt.xlabel('Pull') + plt.savefig('data/CLs/plots/{}/{:.2f}Ctt{}s{}f.png'.format(key, Ctt_steps[int(step/2)], step, floaty)) + + +# In[ ]: + + +for s in range(len(l)): + print('BR: {:.4f}'.format(BR_steps[s+1])) + print(2*l[s]/len(CLs_values[s])) + print() + + +# In[ ]: + + +# for step in range(2*ste): +# for key in pull_dic.keys(): +# print(pull_dic[key][step]) + + +# In[ ]: + + +# for param in total_f_fit.get_dependents(): +# if param.floating: +# print(params[param]['value']) + + +# In[ ]: + + +print(display_time(int(time.time()-start))) + + +# In[ ]: + + +# variab['mi'] =! mi + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + diff --git a/data/CLs/finished/f1d1/-+/D-True/2288009/__pycache__/helperfunctions.cpython-37.pyc b/data/CLs/finished/f1d1/-+/D-True/2288009/__pycache__/helperfunctions.cpython-37.pyc new file mode 100644 index 0000000..3afbcf9 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288009/__pycache__/helperfunctions.cpython-37.pyc Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288009/__pycache__/pdg_const1.cpython-37.pyc b/data/CLs/finished/f1d1/-+/D-True/2288009/__pycache__/pdg_const1.cpython-37.pyc new file mode 100644 index 0000000..8dc4191 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288009/__pycache__/pdg_const1.cpython-37.pyc Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288009/data/CLs/0.0001-0.003_20s--CLs_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288009/data/CLs/0.0001-0.003_20s--CLs_list.pkl new file mode 100644 index 0000000..3858eaf --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288009/data/CLs/0.0001-0.003_20s--CLs_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288009/data/CLs/0.0001-0.003_20s1b1t--CLs_Nll_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288009/data/CLs/0.0001-0.003_20s1b1t--CLs_Nll_list.pkl new file mode 100644 index 0000000..03e7220 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288009/data/CLs/0.0001-0.003_20s1b1t--CLs_Nll_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288009/data/CLs/0.0001-0.003_20s1b1t--Ctt_error_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288009/data/CLs/0.0001-0.003_20s1b1t--Ctt_error_list.pkl new file mode 100644 index 0000000..66ead2b --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288009/data/CLs/0.0001-0.003_20s1b1t--Ctt_error_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288009/data/CLs/0.0001-0.003_20s1b1t--Ctt_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288009/data/CLs/0.0001-0.003_20s1b1t--Ctt_list.pkl new file mode 100644 index 0000000..e3f4a25 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288009/data/CLs/0.0001-0.003_20s1b1t--Ctt_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288009/data/CLs/0.0001-0.003_20s1b1t--pull_dic.pkl b/data/CLs/finished/f1d1/-+/D-True/2288009/data/CLs/0.0001-0.003_20s1b1t--pull_dic.pkl new file mode 100644 index 0000000..8831ea6 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288009/data/CLs/0.0001-0.003_20s1b1t--pull_dic.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288009/data/CLs/variab.pkl b/data/CLs/finished/f1d1/-+/D-True/2288009/data/CLs/variab.pkl new file mode 100644 index 0000000..bb90dc0 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288009/data/CLs/variab.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288009/helperfunctions.py b/data/CLs/finished/f1d1/-+/D-True/2288009/helperfunctions.py new file mode 100644 index 0000000..88e120f --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288009/helperfunctions.py @@ -0,0 +1,33 @@ +# some helperfunctions + +import matplotlib +matplotlib.use("agg") +import matplotlib.pyplot as plt + +#Dislpay time (e.g. while generating points) + +display_intervals = ( + ('w', 604800), # 60 * 60 * 24 * 7 + ('d', 86400), # 60 * 60 * 24 + ('h', 3600), # 60 * 60 + ('min', 60), + ('s', 1), + ) + +def display_time(seconds, granularity=2): + result = [] + + for name, count in display_intervals: + value = seconds // count + if value: + seconds -= value * count + if value == 1: + name = name.rstrip('s') + result.append("{} {}".format(value, name)) + return ', '.join(result[:granularity]) + +def prepare_plot(title): + plt.title(title) + plt.grid() + plt.legend(loc = 'best') + plt.xlabel("q") diff --git a/data/CLs/finished/f1d1/-+/D-True/2288009/pdg_const1.py b/data/CLs/finished/f1d1/-+/D-True/2288009/pdg_const1.py new file mode 100644 index 0000000..70b3f30 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288009/pdg_const1.py @@ -0,0 +1,226 @@ +pdg = { + + + ###Particle masses### + + "mbstar" : 5415.4, + "mbstar0" : 5711.0, + "B0_M" : 5279.5, + "Bs_M" : 5366.7, + "Bplus_M" : 5279.3, + "Lb_M" : 5619.4, + "D0_M" : 1864.8, + "Dst_M" : 2010, + "pi_M" : 139.6, + "Jpsi_M" : 3096.9, + "Psi2s_M" : 3685.6, + "kaon_M" : 493.7, + "Ks_M" : 497.6, + "phi_M" : 1019.5, + "rho_M" : 775.26, + "rho_width" : 149.1, + "omega_M" : 782.65, + "omega_width" : 8.49, + + "muon_M" : 105.7, + "tau_M": 1776.86, + + "squark_M" : 95.0, + "bquark_M" : 4180.0, + "cquark_M" : 1275.0, + + "Bplus_tau" : 1.638e-12, + + ###Wilson coefficients### + + "C1" : -0.257, + "C2" : 1.009, + "C3" : -0.005, + "C4" : -0.078, + + "C7eff" : -0.306, + "C9eff" : 4.211, + "C10eff" : -4.103, + +# "C7eff": 0.0, +# "C9eff": 0.0, +# "C10eff": 0.0, + + ###Other constants + + "GF" : 1.1663787e-5, + "alpha_ew" : 1.0/137.0, + "Vts" : 0.0394, + "Vtb" : 1.019, + "number_of_decays": 5404696, + + #Formfactor z coefficients + + #"b0" : [0.285, 0.19, -0.17], + #"bplus" : [0.437, -1.41, -2.5], + #"bT" : [0.440, -1.47, -2.7] + + "b0" : [0.292, 0.281, 0.150], + "bplus" : [0.466, -0.885, -0.213], + "bT" : [0.460, -1.089, -1.114], + + "NR_BR": 4.37e-7, + "NR_auc": 0.00133, + + #Resonances format(mass, width, phase, scale) + + # pre scaling + +# "rho": (775.26, 149.0, -0.35, 1.0), + +# "omega": (782.7, 8.5, 0.26, 1.0), + +# "phi": (1019.46, 4.25, 0.5, 1.0), + +# "jpsi": (3096.0, 0.09, -1.5, 2e-2), +# "jpsi_auc": 0.2126825758464027, + +# "psi2s": (3686.0, 0.3, -1.5, 3.14e-3), +# "psi2s_auc": 2.802257483178487e-10, + +# "p3770": (3773.0, 27.2, -2.13, 1.0e-3), + +# "p4040": (4039.0, 80.0, -2.52, 2.0), + +# "p4160": (4191.0, 70.0, -1.9, 2.2), + +# "p4415": (4421.0, 62.0, -2.52, 1.0), + + + # after scaling (Phase combination --) + + # + # "rho": (743.2, 149.0, -0.22, 1.05), + # + # "omega": (782.7, 8.5, 0.38, 6.8), + # + # "phi": (1013.5, 4.25, 0.62, 19.2), + # + # "jpsi": (3096.1, 0.09, 1.63, 9897.0), + # "jpsi_auc": 0.2126825758464027, + # "jpsi_phase_unc": 0.05, + # + # "psi2s": (3686.0, 0.3, 1.8, 1396.0), + # "psi2s_auc": 0.0151332263, + # "psi2s_phase_unc": 0.1, + # + # "p3770": (3773.0, 27.2, -2.95, 2.5), + # + # "p4040": (4039.0, 80.0, -2.75, 1.01), + # + # "p4160": (4191.0, 70.0, -2.28, 2.2), + # + # "p4415": (4421.0, 62.0, -2.31, 1.24), + + # Phase combination of paper ++ + +# "rho": (743.2, 149.0, -0.35, 1.05), + +# "omega": (782.7, 8.5, 0.26, 6.8), + +# "phi": (1013.5, 4.25, 0.47, 19.2), + +# "jpsi": (3096.1, 0.09, -1.66, 9897.0), +# "jpsi_auc": 0.2126825758464027, +# "jpsi_phase_unc": 0.05, + +# "psi2s": (3686.0, 0.3, -1.93, 1396.0), +# "psi2s_auc": 0.0151332263, +# "psi2s_phase_unc": 0.1, + +# "p3770": (3773.0, 27.2, -2.13, 2.5), + +# "p4040": (4039.0, 80.0, -2.52, 1.01), + +# "p4160": (4191.0, 70.0, -1.90, 2.2), + +# "p4415": (4421.0, 62.0, -2.52, 1.24), + + # Phase combination of paper +- + +# "rho": (743.2, 149.0, -0.26, 1.05), + +# "omega": (782.7, 8.5, 0.35, 6.8), + +# "phi": (1013.5, 4.25, 0.58, 19.2), + +# "jpsi": (3096.1, 0.09, 1.47, 9897.0), +# "jpsi_auc": 0.2126825758464027, +# "jpsi_phase_unc": 0.05, + +# "psi2s": (3686.0, 0.3, -2.21, 1396.0), +# "psi2s_auc": 0.0151332263, +# "psi2s_phase_unc": 0.1, + +# "p3770": (3773.0, 27.2, -2.140, 2.5), + +# "p4040": (4039.0, 80.0, -2.64, 1.01), + +# "p4160": (4191.0, 70.0, -2.11, 2.2), + +# "p4415": (4421.0, 62.0, -2.42, 1.24), + + # Phase combination of paper -+ + + "rho": (743.2, 149.0, -0.30, 1.05), + + "omega": (782.7, 8.5, 0.30, 6.8), + + "phi": (1013.5, 4.25, 0.51, 19.2), + + "jpsi": (3096.1, 0.09, -1.5, 9897.0), + "jpsi_auc": 0.2126825758464027, + "jpsi_phase_unc": 0.05, + + "psi2s": (3686.0, 0.3, 2.08, 1396.0), + "psi2s_auc": 0.0151332263, + "psi2s_phase_unc": 0.1, + + "p3770": (3773.0, 27.2, -2.89, 2.5), + + "p4040": (4039.0, 80.0, -2.69, 1.01), + + "p4160": (4191.0, 70.0, -2.13, 2.2), + + "p4415": (4421.0, 62.0, -2.43, 1.24), + + + # zeroing resonances + +# "rho": (775.26, 149.0, -0.35, 0.0), +# "omega": (782.7, 8.5, 0.26, 0.0), +# "phi": (1019.46, 4.25, 0.5, 0.0), +# "jpsi": (3096.0, 0.09, -1.5, 0.0), +# "psi2s": (3686.0, 0.3, -1.5, 0.0), +# "p3770": (3773.0, 27.2, -2.13, 0.0), +# "p4040": (4039.0, 80.0, -2.52, 0.0), +# "p4160": (4147.0, 22.0, -1.9, 0.0), +# "p4415": (4421.0, 62.0, -2.52, 0.0), + + # 2P contributions format(mass, amp, phase) + +# "D_bar": ( + + #general + + "rho_BR": 1.7e-10, + "omega_BR": 4.9e-10, + "phi_BR": 2.5e-9, + "jpsi_BR": 6.02e-5, + "psi2s_BR": 4.97e-6, + "p3770_BR": 1.38e-9, + "p4040_BR": 4.2e-10, + "p4160_BR": 2.6e-9, + "p4415_BR": 6.1e-10, + +# Estimates + "Dbar_scale": 1.46, #with phase = pi + + "DDstar_scale": 2.41, #with phase = pi + + } diff --git a/data/CLs/finished/f1d1/-+/D-True/2288009/raremodel-nb.py b/data/CLs/finished/f1d1/-+/D-True/2288009/raremodel-nb.py new file mode 100644 index 0000000..c326c9c --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288009/raremodel-nb.py @@ -0,0 +1,2152 @@ +#!/usr/bin/env python +# coding: utf-8 + +# # Import + +# In[ ]: + + +import os + +# os.environ["CUDA_VISIBLE_DEVICES"] = "-1" +import random +import numpy as np +from pdg_const1 import pdg +import matplotlib +import matplotlib.pyplot as plt +import pickle as pkl +import sys +import time +from helperfunctions import display_time, prepare_plot +import cmath as c +import scipy.integrate as integrate +from scipy.optimize import fminbound +from array import array as arr +import collections +from itertools import compress +import tensorflow as tf +import zfit +from zfit import ztf +# from IPython.display import clear_output +import os +import tensorflow_probability as tfp +tfd = tfp.distributions + + +# In[ ]: + + +# chunksize = 10000 +# zfit.run.chunking.active = True +# zfit.run.chunking.max_n_points = chunksize + + +# # Build model and graphs +# ## Create graphs + +# In[ ]: + + + + + +# In[ ]: + + +def formfactor(q2, subscript, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2): #returns real value + #check if subscript is viable + + if subscript != "0" and subscript != "+" and subscript != "T": + raise ValueError('Wrong subscript entered, choose either 0, + or T') + + #get constants + + mK = ztf.constant(pdg['Ks_M']) + mbstar0 = ztf.constant(pdg["mbstar0"]) + mbstar = ztf.constant(pdg["mbstar"]) + + + mmu = ztf.constant(pdg['muon_M']) + mb = ztf.constant(pdg['bquark_M']) + ms = ztf.constant(pdg['squark_M']) + mB = ztf.constant(pdg['Bplus_M']) + + #N comes from derivation in paper + + N = 3 + + #some helperfunctions + + tpos = (mB - mK)**2 + tzero = (mB + mK)*(ztf.sqrt(mB)-ztf.sqrt(mK))**2 + + z_oben = ztf.sqrt(tpos - q2) - ztf.sqrt(tpos - tzero) + z_unten = ztf.sqrt(tpos - q2) + ztf.sqrt(tpos - tzero) + z = tf.divide(z_oben, z_unten) + + #calculate f0 + + if subscript == "0": + prefactor = 1/(1 - q2/(mbstar0**2)) + _sum = 0 + b0 = [b0_0, b0_1, b0_2] + + for i in range(N): + _sum += b0[i]*(tf.pow(z,i)) + + return ztf.to_complex(prefactor * _sum) + + #calculate f+ or fT + + else: + prefactor = 1/(1 - q2/(mbstar**2)) + _sum = 0 + + if subscript == "T": + bT = [bT_0, bT_1, bT_2] + for i in range(N): + _sum += bT[i] * (tf.pow(z, i) - ((-1)**(i-N)) * (i/N) * tf.pow(z, N)) + else: + bplus = [bplus_0, bplus_1, bplus_2] + for i in range(N): + _sum += bplus[i] * (tf.pow(z, i) - ((-1)**(i-N)) * (i/N) * tf.pow(z, N)) + + return ztf.to_complex(prefactor * _sum) + +def resonance(q, _mass, width, phase, scale): + + q2 = tf.pow(q, 2) + + mmu = ztf.constant(pdg['muon_M']) + + p = 0.5 * ztf.sqrt(q2 - 4*(mmu**2)) + + p0 = 0.5 * ztf.sqrt(_mass**2 - 4*mmu**2) + + gamma_j = tf.divide(p, q) * _mass * width / p0 + + #Calculate the resonance + + _top = tf.complex(_mass * width, ztf.constant(0.0)) + + _bottom = tf.complex(_mass**2 - q2, -_mass*gamma_j) + + com = _top/_bottom + + #Rotate by the phase + + r = ztf.to_complex(scale*tf.abs(com)) + + _phase = tf.angle(com) + + _phase += phase + + com = r * tf.exp(tf.complex(ztf.constant(0.0), _phase)) + + return com + + +def axiv_nonres(q, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2): + + GF = ztf.constant(pdg['GF']) + alpha_ew = ztf.constant(pdg['alpha_ew']) + Vtb = ztf.constant(pdg['Vtb']) + Vts = ztf.constant(pdg['Vts']) + C10eff = ztf.constant(pdg['C10eff']) + + mmu = ztf.constant(pdg['muon_M']) + mb = ztf.constant(pdg['bquark_M']) + ms = ztf.constant(pdg['squark_M']) + mK = ztf.constant(pdg['Ks_M']) + mB = ztf.constant(pdg['Bplus_M']) + + q2 = tf.pow(q, 2) + + #Some helperfunctions + + beta = 1. - 4. * mmu**2. / q2 + + kabs = ztf.sqrt(mB**2. + tf.pow(q2, 2)/mB**2. + mK**4./mB**2. - 2. * (mB**2. * mK**2. + mK**2. * q2 + mB**2. * q2) / mB**2.) + + #prefactor in front of whole bracket + + prefactor1 = GF**2. *alpha_ew**2. * (tf.abs(Vtb*Vts))**2. * kabs * beta / (128. * np.pi**5.) + + #left term in bracket + + bracket_left = 2./3. * tf.pow(kabs,2) * tf.pow(beta,2) * tf.pow(tf.abs(ztf.to_complex(C10eff)*formfactor(q2, "+", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2)),2) + + #middle term in bracket + + _top = 4. * mmu**2. * (mB**2. - mK**2.) * (mB**2. - mK**2.) + + _under = q2 * mB**2. + + bracket_middle = _top/_under *tf.pow(tf.abs(ztf.to_complex(C10eff) * formfactor(q2, "0", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2)), 2) + + #Note sqrt(q2) comes from derivation as we use q2 and plot q + + return prefactor1 * (bracket_left + bracket_middle) * 2 * q + +def vec(q, funcs, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2): + + q2 = tf.pow(q, 2) + + GF = ztf.constant(pdg['GF']) + alpha_ew = ztf.constant(pdg['alpha_ew']) + Vtb = ztf.constant(pdg['Vtb']) + Vts = ztf.constant(pdg['Vts']) + C7eff = ztf.constant(pdg['C7eff']) + + mmu = ztf.constant(pdg['muon_M']) + mb = ztf.constant(pdg['bquark_M']) + ms = ztf.constant(pdg['squark_M']) + mK = ztf.constant(pdg['Ks_M']) + mB = ztf.constant(pdg['Bplus_M']) + + #Some helperfunctions + + beta = 1. - 4. * mmu**2. / q2 + + kabs = ztf.sqrt(mB**2. + tf.pow(q2, 2)/mB**2. + mK**4./mB**2. - 2 * (mB**2 * mK**2 + mK**2 * q2 + mB**2 * q2) / mB**2) + + #prefactor in front of whole bracket + + prefactor1 = GF**2. *alpha_ew**2. * (tf.abs(Vtb*Vts))**2 * kabs * beta / (128. * np.pi**5.) + + #right term in bracket + + prefactor2 = tf.pow(kabs,2) * (1. - 1./3. * beta) + + abs_bracket = tf.pow(tf.abs(c9eff(q, funcs) * formfactor(q2, "+", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + ztf.to_complex(2.0 * C7eff * (mb + ms)/(mB + mK)) * formfactor(q2, "T", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2)),2) + + bracket_right = prefactor2 * abs_bracket + + #Note sqrt(q2) comes from derivation as we use q2 and plot q + + return prefactor1 * bracket_right * 2 * q + +def c9eff(q, funcs): + + C9eff_nr = ztf.to_complex(ztf.constant(pdg['C9eff'])) + + c9 = C9eff_nr + funcs + + return c9 + + +# In[ ]: + + +def G(y): + + def inner_rect_bracket(q): + return tf.log(ztf.to_complex((1+tf.sqrt(q))/(1-tf.sqrt(q)))-tf.complex(ztf.constant(0), -1*ztf.constant(np.pi))) + + def inner_right(q): + return ztf.to_complex(2 * tf.atan(1/tf.sqrt(tf.math.real(-q)))) + + big_bracket = tf.where(tf.math.real(y) > ztf.constant(0.0), inner_rect_bracket(y), inner_right(y)) + + return ztf.to_complex(tf.sqrt(tf.abs(y))) * big_bracket + +def h_S(m, q): + + return ztf.to_complex(2) - G(ztf.to_complex(1) - ztf.to_complex(4*tf.pow(m, 2)) / ztf.to_complex(tf.pow(q, 2))) + +def h_P(m, q): + + return ztf.to_complex(2/3) + (ztf.to_complex(1) - ztf.to_complex(4*tf.pow(m, 2)) / ztf.to_complex(tf.pow(q, 2))) * h_S(m,q) + +def two_p_ccbar(mD, m_D_bar, m_D_star, q): + + + #Load constants + nu_D_bar = ztf.to_complex(pdg["nu_D_bar"]) + nu_D = ztf.to_complex(pdg["nu_D"]) + nu_D_star = ztf.to_complex(pdg["nu_D_star"]) + + phase_D_bar = ztf.to_complex(pdg["phase_D_bar"]) + phase_D = ztf.to_complex(pdg["phase_D"]) + phase_D_star = ztf.to_complex(pdg["phase_D_star"]) + + #Calculation + left_part = nu_D_bar * tf.exp(tf.complex(ztf.constant(0.0), phase_D_bar)) * h_S(m_D_bar, q) + + right_part_D = nu_D * tf.exp(tf.complex(ztf.constant(0.0), phase_D)) * h_P(m_D, q) + + right_part_D_star = nu_D_star * tf.exp(tf.complex(ztf.constant(0.0), phase_D_star)) * h_P(m_D_star, q) + + return left_part + right_part_D + right_part_D_star + + +# ## Build pdf + +# In[ ]: + + +class total_pdf_cut(zfit.pdf.ZPDF): + _N_OBS = 1 # dimension, can be omitted + _PARAMS = ['b0_0', 'b0_1', 'b0_2', + 'bplus_0', 'bplus_1', 'bplus_2', + 'bT_0', 'bT_1', 'bT_2', + 'rho_mass', 'rho_scale', 'rho_phase', 'rho_width', + 'jpsi_mass', 'jpsi_scale', 'jpsi_phase', 'jpsi_width', + 'psi2s_mass', 'psi2s_scale', 'psi2s_phase', 'psi2s_width', + 'p3770_mass', 'p3770_scale', 'p3770_phase', 'p3770_width', + 'p4040_mass', 'p4040_scale', 'p4040_phase', 'p4040_width', + 'p4160_mass', 'p4160_scale', 'p4160_phase', 'p4160_width', + 'p4415_mass', 'p4415_scale', 'p4415_phase', 'p4415_width', + 'omega_mass', 'omega_scale', 'omega_phase', 'omega_width', + 'phi_mass', 'phi_scale', 'phi_phase', 'phi_width', + 'Dbar_mass', 'Dbar_scale', 'Dbar_phase', + 'Dstar_mass', 'DDstar_scale', 'DDstar_phase', 'D_mass', + 'tau_mass', 'C_tt'] +# the name of the parameters + + def _unnormalized_pdf(self, x): + + x = x.unstack_x() + + b0 = [self.params['b0_0'], self.params['b0_1'], self.params['b0_2']] + bplus = [self.params['bplus_0'], self.params['bplus_1'], self.params['bplus_2']] + bT = [self.params['bT_0'], self.params['bT_1'], self.params['bT_2']] + + def rho_res(q): + return resonance(q, _mass = self.params['rho_mass'], scale = self.params['rho_scale'], + phase = self.params['rho_phase'], width = self.params['rho_width']) + + def omega_res(q): + return resonance(q, _mass = self.params['omega_mass'], scale = self.params['omega_scale'], + phase = self.params['omega_phase'], width = self.params['omega_width']) + + def phi_res(q): + return resonance(q, _mass = self.params['phi_mass'], scale = self.params['phi_scale'], + phase = self.params['phi_phase'], width = self.params['phi_width']) + + def jpsi_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['jpsi_mass'], 2)) * resonance(q, _mass = self.params['jpsi_mass'], + scale = self.params['jpsi_scale'], + phase = self.params['jpsi_phase'], + width = self.params['jpsi_width']) + def psi2s_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['psi2s_mass'], 2)) * resonance(q, _mass = self.params['psi2s_mass'], + scale = self.params['psi2s_scale'], + phase = self.params['psi2s_phase'], + width = self.params['psi2s_width']) + def p3770_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p3770_mass'], 2)) * resonance(q, _mass = self.params['p3770_mass'], + scale = self.params['p3770_scale'], + phase = self.params['p3770_phase'], + width = self.params['p3770_width']) + + def p4040_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4040_mass'], 2)) * resonance(q, _mass = self.params['p4040_mass'], + scale = self.params['p4040_scale'], + phase = self.params['p4040_phase'], + width = self.params['p4040_width']) + + def p4160_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4160_mass'], 2)) * resonance(q, _mass = self.params['p4160_mass'], + scale = self.params['p4160_scale'], + phase = self.params['p4160_phase'], + width = self.params['p4160_width']) + + def p4415_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4415_mass'], 2)) * resonance(q, _mass = self.params['p4415_mass'], + scale = self.params['p4415_scale'], + phase = self.params['p4415_phase'], + width = self.params['p4415_width']) + + def P2_D(q): + Dbar_contrib = ztf.to_complex(self.params['Dbar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['Dbar_phase']))*ztf.to_complex(h_S(self.params['Dbar_mass'], q)) + DDstar_contrib = ztf.to_complex(self.params['DDstar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['DDstar_phase']))*(ztf.to_complex(h_P(self.params['Dstar_mass'], q)) + ztf.to_complex(h_P(self.params['D_mass'], q))) + return Dbar_contrib + DDstar_contrib + + def ttau_cusp(q): + return ztf.to_complex(self.params['C_tt'])*(ztf.to_complex((h_S(self.params['tau_mass'], q))) - ztf.to_complex(h_P(self.params['tau_mass'], q))) + + + funcs = rho_res(x) + omega_res(x) + phi_res(x) + jpsi_res(x) + psi2s_res(x) + p3770_res(x) + p4040_res(x)+ p4160_res(x) + p4415_res(x) + P2_D(x) + ttau_cusp(x) + + vec_f = vec(x, funcs, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + axiv_nr = axiv_nonres(x, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + tot = vec_f + axiv_nr + + #Cut out jpsi and psi2s + + tot = tf.where(tf.math.logical_or(x < ztf.constant(jpsi_mass-60.), x > ztf.constant(jpsi_mass+70.)), tot, 0.0*tot) + + tot = tf.where(tf.math.logical_or(x < ztf.constant(psi2s_mass-50.), x > ztf.constant(psi2s_mass+50.)), tot, 0.0*tot) + + return tot + +class total_pdf_full(zfit.pdf.ZPDF): + _N_OBS = 1 # dimension, can be omitted + _PARAMS = ['b0_0', 'b0_1', 'b0_2', + 'bplus_0', 'bplus_1', 'bplus_2', + 'bT_0', 'bT_1', 'bT_2', + 'rho_mass', 'rho_scale', 'rho_phase', 'rho_width', + 'jpsi_mass', 'jpsi_scale', 'jpsi_phase', 'jpsi_width', + 'psi2s_mass', 'psi2s_scale', 'psi2s_phase', 'psi2s_width', + 'p3770_mass', 'p3770_scale', 'p3770_phase', 'p3770_width', + 'p4040_mass', 'p4040_scale', 'p4040_phase', 'p4040_width', + 'p4160_mass', 'p4160_scale', 'p4160_phase', 'p4160_width', + 'p4415_mass', 'p4415_scale', 'p4415_phase', 'p4415_width', + 'omega_mass', 'omega_scale', 'omega_phase', 'omega_width', + 'phi_mass', 'phi_scale', 'phi_phase', 'phi_width', + 'Dbar_mass', 'Dbar_scale', 'Dbar_phase', + 'Dstar_mass', 'DDstar_scale', 'DDstar_phase', 'D_mass', + 'tau_mass', 'C_tt'] +# the name of the parameters + + def _unnormalized_pdf(self, x): + + x = x.unstack_x() + + b0 = [self.params['b0_0'], self.params['b0_1'], self.params['b0_2']] + bplus = [self.params['bplus_0'], self.params['bplus_1'], self.params['bplus_2']] + bT = [self.params['bT_0'], self.params['bT_1'], self.params['bT_2']] + + def rho_res(q): + return resonance(q, _mass = self.params['rho_mass'], scale = self.params['rho_scale'], + phase = self.params['rho_phase'], width = self.params['rho_width']) + + def omega_res(q): + return resonance(q, _mass = self.params['omega_mass'], scale = self.params['omega_scale'], + phase = self.params['omega_phase'], width = self.params['omega_width']) + + def phi_res(q): + return resonance(q, _mass = self.params['phi_mass'], scale = self.params['phi_scale'], + phase = self.params['phi_phase'], width = self.params['phi_width']) + + def jpsi_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['jpsi_mass'], 2)) * resonance(q, _mass = self.params['jpsi_mass'], + scale = self.params['jpsi_scale'], + phase = self.params['jpsi_phase'], + width = self.params['jpsi_width']) + def psi2s_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['psi2s_mass'], 2)) * resonance(q, _mass = self.params['psi2s_mass'], + scale = self.params['psi2s_scale'], + phase = self.params['psi2s_phase'], + width = self.params['psi2s_width']) + def p3770_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p3770_mass'], 2)) * resonance(q, _mass = self.params['p3770_mass'], + scale = self.params['p3770_scale'], + phase = self.params['p3770_phase'], + width = self.params['p3770_width']) + + def p4040_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4040_mass'], 2)) * resonance(q, _mass = self.params['p4040_mass'], + scale = self.params['p4040_scale'], + phase = self.params['p4040_phase'], + width = self.params['p4040_width']) + + def p4160_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4160_mass'], 2)) * resonance(q, _mass = self.params['p4160_mass'], + scale = self.params['p4160_scale'], + phase = self.params['p4160_phase'], + width = self.params['p4160_width']) + + def p4415_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4415_mass'], 2)) * resonance(q, _mass = self.params['p4415_mass'], + scale = self.params['p4415_scale'], + phase = self.params['p4415_phase'], + width = self.params['p4415_width']) + + def P2_D(q): + Dbar_contrib = ztf.to_complex(self.params['Dbar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['Dbar_phase']))*ztf.to_complex(h_S(self.params['Dbar_mass'], q)) + DDstar_contrib = ztf.to_complex(self.params['DDstar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['DDstar_phase']))*(ztf.to_complex(h_P(self.params['Dstar_mass'], q)) + ztf.to_complex(h_P(self.params['D_mass'], q))) + return Dbar_contrib + DDstar_contrib + + def ttau_cusp(q): + return ztf.to_complex(self.params['C_tt'])*(ztf.to_complex((h_S(self.params['tau_mass'], q))) - ztf.to_complex(h_P(self.params['tau_mass'], q))) + + + funcs = rho_res(x) + omega_res(x) + phi_res(x) + jpsi_res(x) + psi2s_res(x) + p3770_res(x) + p4040_res(x)+ p4160_res(x) + p4415_res(x) + P2_D(x) + ttau_cusp(x) + + vec_f = vec(x, funcs, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + axiv_nr = axiv_nonres(x, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + tot = vec_f + axiv_nr + + #Cut out jpsi and psi2s + +# tot = tf.where(tf.math.logical_or(x < ztf.constant(jpsi_mass-60.), x > ztf.constant(jpsi_mass+70.)), tot, 0.0*tot) + +# tot = tf.where(tf.math.logical_or(x < ztf.constant(psi2s_mass-50.), x > ztf.constant(psi2s_mass+50.)), tot, 0.0*tot) + + return tot + + +# ## Setup parameters + +# In[ ]: + + +# formfactors + +b0_0 = zfit.Parameter("b0_0", ztf.constant(0.292), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +b0_1 = zfit.Parameter("b0_1", ztf.constant(0.281), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +b0_2 = zfit.Parameter("b0_2", ztf.constant(0.150), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) + +bplus_0 = zfit.Parameter("bplus_0", ztf.constant(0.466), lower_limit = -2.0, upper_limit= 2.0) +bplus_1 = zfit.Parameter("bplus_1", ztf.constant(-0.885), lower_limit = -2.0, upper_limit= 2.0) +bplus_2 = zfit.Parameter("bplus_2", ztf.constant(-0.213), lower_limit = -2.0, upper_limit= 2.0) + +bT_0 = zfit.Parameter("bT_0", ztf.constant(0.460), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +bT_1 = zfit.Parameter("bT_1", ztf.constant(-1.089), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +bT_2 = zfit.Parameter("bT_2", ztf.constant(-1.114), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) + + +#rho + +rho_mass, rho_width, rho_phase, rho_scale = pdg["rho"] + +rho_m = zfit.Parameter("rho_m", ztf.constant(rho_mass), floating = False) #lower_limit = rho_mass - rho_width, upper_limit = rho_mass + rho_width) +rho_w = zfit.Parameter("rho_w", ztf.constant(rho_width), floating = False) +rho_p = zfit.Parameter("rho_p", ztf.constant(rho_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +rho_s = zfit.Parameter("rho_s", ztf.constant(rho_scale), lower_limit=rho_scale-np.sqrt(rho_scale), upper_limit=rho_scale+np.sqrt(rho_scale)) + +#omega + +omega_mass, omega_width, omega_phase, omega_scale = pdg["omega"] + +omega_m = zfit.Parameter("omega_m", ztf.constant(omega_mass), floating = False) +omega_w = zfit.Parameter("omega_w", ztf.constant(omega_width), floating = False) +omega_p = zfit.Parameter("omega_p", ztf.constant(omega_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +omega_s = zfit.Parameter("omega_s", ztf.constant(omega_scale), lower_limit=omega_scale-np.sqrt(omega_scale), upper_limit=omega_scale+np.sqrt(omega_scale)) + + +#phi + +phi_mass, phi_width, phi_phase, phi_scale = pdg["phi"] + +phi_m = zfit.Parameter("phi_m", ztf.constant(phi_mass), floating = False) +phi_w = zfit.Parameter("phi_w", ztf.constant(phi_width), floating = False) +phi_p = zfit.Parameter("phi_p", ztf.constant(phi_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +phi_s = zfit.Parameter("phi_s", ztf.constant(phi_scale), lower_limit=phi_scale-np.sqrt(phi_scale), upper_limit=phi_scale+np.sqrt(phi_scale)) + +#jpsi + +jpsi_mass, jpsi_width, jpsi_phase, jpsi_scale = pdg["jpsi"] + +jpsi_m = zfit.Parameter("jpsi_m", ztf.constant(jpsi_mass), floating = False) +jpsi_w = zfit.Parameter("jpsi_w", ztf.constant(jpsi_width), floating = False) +jpsi_p = zfit.Parameter("jpsi_p", ztf.constant(jpsi_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +jpsi_s = zfit.Parameter("jpsi_s", ztf.constant(jpsi_scale), floating = False) #, lower_limit=jpsi_scale-np.sqrt(jpsi_scale), upper_limit=jpsi_scale+np.sqrt(jpsi_scale)) + +#psi2s + +psi2s_mass, psi2s_width, psi2s_phase, psi2s_scale = pdg["psi2s"] + +psi2s_m = zfit.Parameter("psi2s_m", ztf.constant(psi2s_mass), floating = False) +psi2s_w = zfit.Parameter("psi2s_w", ztf.constant(psi2s_width), floating = False) +psi2s_p = zfit.Parameter("psi2s_p", ztf.constant(psi2s_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +psi2s_s = zfit.Parameter("psi2s_s", ztf.constant(psi2s_scale), floating = False) #, lower_limit=psi2s_scale-np.sqrt(psi2s_scale), upper_limit=psi2s_scale+np.sqrt(psi2s_scale)) + +#psi(3770) + +p3770_mass, p3770_width, p3770_phase, p3770_scale = pdg["p3770"] + +p3770_m = zfit.Parameter("p3770_m", ztf.constant(p3770_mass), floating = False) +p3770_w = zfit.Parameter("p3770_w", ztf.constant(p3770_width), floating = False) +p3770_p = zfit.Parameter("p3770_p", ztf.constant(p3770_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p3770_s = zfit.Parameter("p3770_s", ztf.constant(p3770_scale), lower_limit=p3770_scale-np.sqrt(p3770_scale), upper_limit=p3770_scale+np.sqrt(p3770_scale)) + +#psi(4040) + +p4040_mass, p4040_width, p4040_phase, p4040_scale = pdg["p4040"] + +p4040_m = zfit.Parameter("p4040_m", ztf.constant(p4040_mass), floating = False) +p4040_w = zfit.Parameter("p4040_w", ztf.constant(p4040_width), floating = False) +p4040_p = zfit.Parameter("p4040_p", ztf.constant(p4040_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p4040_s = zfit.Parameter("p4040_s", ztf.constant(p4040_scale), lower_limit=p4040_scale-np.sqrt(p4040_scale), upper_limit=p4040_scale+np.sqrt(p4040_scale)) + +#psi(4160) + +p4160_mass, p4160_width, p4160_phase, p4160_scale = pdg["p4160"] + +p4160_m = zfit.Parameter("p4160_m", ztf.constant(p4160_mass), floating = False) +p4160_w = zfit.Parameter("p4160_w", ztf.constant(p4160_width), floating = False) +p4160_p = zfit.Parameter("p4160_p", ztf.constant(p4160_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p4160_s = zfit.Parameter("p4160_s", ztf.constant(p4160_scale), lower_limit=p4160_scale-np.sqrt(p4160_scale), upper_limit=p4160_scale+np.sqrt(p4160_scale)) + +#psi(4415) + +p4415_mass, p4415_width, p4415_phase, p4415_scale = pdg["p4415"] + +p4415_m = zfit.Parameter("p4415_m", ztf.constant(p4415_mass), floating = False) +p4415_w = zfit.Parameter("p4415_w", ztf.constant(p4415_width), floating = False) +p4415_p = zfit.Parameter("p4415_p", ztf.constant(p4415_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p4415_s = zfit.Parameter("p4415_s", ztf.constant(p4415_scale), lower_limit=p4415_scale-np.sqrt(p4415_scale), upper_limit=p4415_scale+np.sqrt(p4415_scale)) + + +# ## Dynamic generation of 2 particle contribution + +# In[ ]: + + +m_c = 1300 + +Dbar_phase = 0.0 +DDstar_phase = 0.0 +Dstar_mass = pdg['Dst_M'] +Dbar_mass = pdg['D0_M'] +D_mass = pdg['D0_M'] + +Dbar_s = zfit.Parameter("Dbar_s", ztf.constant(0.0), lower_limit=-0.3, upper_limit=0.3) +Dbar_m = zfit.Parameter("Dbar_m", ztf.constant(Dbar_mass), floating = False) +Dbar_p = zfit.Parameter("Dbar_p", ztf.constant(Dbar_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi)#, floating = False) +DDstar_s = zfit.Parameter("DDstar_s", ztf.constant(0.0), lower_limit=-0.3, upper_limit=0.3)#, floating = False) +Dstar_m = zfit.Parameter("Dstar_m", ztf.constant(Dstar_mass), floating = False) +D_m = zfit.Parameter("D_m", ztf.constant(D_mass), floating = False) +DDstar_p = zfit.Parameter("DDstar_p", ztf.constant(DDstar_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi)#, floating = False) + + +# ## Tau parameters + +# In[ ]: + + +tau_m = zfit.Parameter("tau_m", ztf.constant(pdg['tau_M']), floating = False) +Ctt = zfit.Parameter("Ctt", ztf.constant(0.0), lower_limit=-2.5, upper_limit=2.5) + + +# ## Load data + +# In[ ]: + + +x_min = 2*pdg['muon_M'] +x_max = (pdg["Bplus_M"]-pdg["Ks_M"]-0.1) + +# # Full spectrum + +obs_toy = zfit.Space('q', limits = (x_min, x_max)) + +# Jpsi and Psi2s cut out + +obs1 = zfit.Space('q', limits = (x_min, jpsi_mass - 60.)) +obs2 = zfit.Space('q', limits = (jpsi_mass + 70., psi2s_mass - 50.)) +obs3 = zfit.Space('q', limits = (psi2s_mass + 50., x_max)) + +obs_fit = obs1 + obs2 + obs3 + +# with open(r"./data/slim_points/slim_points_toy_0_range({0}-{1}).pkl".format(int(x_min), int(x_max)), "rb") as input_file: +# part_set = pkl.load(input_file) + +# x_part = part_set['x_part'] + +# x_part = x_part.astype('float64') + +# data = zfit.data.Data.from_numpy(array=x_part, obs=obs) + + +# ## Setup pdf + +# In[ ]: + + +total_f = total_pdf_cut(obs=obs_toy, jpsi_mass = jpsi_m, jpsi_scale = jpsi_s, jpsi_phase = jpsi_p, jpsi_width = jpsi_w, + psi2s_mass = psi2s_m, psi2s_scale = psi2s_s, psi2s_phase = psi2s_p, psi2s_width = psi2s_w, + p3770_mass = p3770_m, p3770_scale = p3770_s, p3770_phase = p3770_p, p3770_width = p3770_w, + p4040_mass = p4040_m, p4040_scale = p4040_s, p4040_phase = p4040_p, p4040_width = p4040_w, + p4160_mass = p4160_m, p4160_scale = p4160_s, p4160_phase = p4160_p, p4160_width = p4160_w, + p4415_mass = p4415_m, p4415_scale = p4415_s, p4415_phase = p4415_p, p4415_width = p4415_w, + rho_mass = rho_m, rho_scale = rho_s, rho_phase = rho_p, rho_width = rho_w, + omega_mass = omega_m, omega_scale = omega_s, omega_phase = omega_p, omega_width = omega_w, + phi_mass = phi_m, phi_scale = phi_s, phi_phase = phi_p, phi_width = phi_w, + Dstar_mass = Dstar_m, DDstar_scale = DDstar_s, DDstar_phase = DDstar_p, D_mass = D_m, + Dbar_mass = Dbar_m, Dbar_scale = Dbar_s, Dbar_phase = Dbar_p, + tau_mass = tau_m, C_tt = Ctt, b0_0 = b0_0, b0_1 = b0_1, b0_2 = b0_2, + bplus_0 = bplus_0, bplus_1 = bplus_1, bplus_2 = bplus_2, + bT_0 = bT_0, bT_1 = bT_1, bT_2 = bT_2) + +total_f_fit = total_pdf_full(obs=obs_fit, jpsi_mass = jpsi_m, jpsi_scale = jpsi_s, jpsi_phase = jpsi_p, jpsi_width = jpsi_w, + psi2s_mass = psi2s_m, psi2s_scale = psi2s_s, psi2s_phase = psi2s_p, psi2s_width = psi2s_w, + p3770_mass = p3770_m, p3770_scale = p3770_s, p3770_phase = p3770_p, p3770_width = p3770_w, + p4040_mass = p4040_m, p4040_scale = p4040_s, p4040_phase = p4040_p, p4040_width = p4040_w, + p4160_mass = p4160_m, p4160_scale = p4160_s, p4160_phase = p4160_p, p4160_width = p4160_w, + p4415_mass = p4415_m, p4415_scale = p4415_s, p4415_phase = p4415_p, p4415_width = p4415_w, + rho_mass = rho_m, rho_scale = rho_s, rho_phase = rho_p, rho_width = rho_w, + omega_mass = omega_m, omega_scale = omega_s, omega_phase = omega_p, omega_width = omega_w, + phi_mass = phi_m, phi_scale = phi_s, phi_phase = phi_p, phi_width = phi_w, + Dstar_mass = Dstar_m, DDstar_scale = DDstar_s, DDstar_phase = DDstar_p, D_mass = D_m, + Dbar_mass = Dbar_m, Dbar_scale = Dbar_s, Dbar_phase = Dbar_p, + tau_mass = tau_m, C_tt = Ctt, b0_0 = b0_0, b0_1 = b0_1, b0_2 = b0_2, + bplus_0 = bplus_0, bplus_1 = bplus_1, bplus_2 = bplus_2, + bT_0 = bT_0, bT_1 = bT_1, bT_2 = bT_2) + +# print(total_pdf.obs) + +# print(calcs_test) + +# for param in total_f.get_dependents(): +# print(zfit.run(param)) + + +# In[ ]: + + +# total_f_fit.normalization(obs_fit) + + +# ## Test if graphs actually work and compute values + +# In[ ]: + + +# def total_test_tf(xq): + +# def jpsi_res(q): +# return resonance(q, jpsi_m, jpsi_s, jpsi_p, jpsi_w) + +# def psi2s_res(q): +# return resonance(q, psi2s_m, psi2s_s, psi2s_p, psi2s_w) + +# def cusp(q): +# return bifur_gauss(q, cusp_m, sig_L, sig_R, cusp_s) + +# funcs = jpsi_res(xq) + psi2s_res(xq) + cusp(xq) + +# vec_f = vec(xq, funcs) + +# axiv_nr = axiv_nonres(xq) + +# tot = vec_f + axiv_nr + +# return tot + +# def jpsi_res(q): +# return resonance(q, jpsi_m, jpsi_s, jpsi_p, jpsi_w) + +# calcs = zfit.run(total_test_tf(x_part)) + + + +test_q = np.linspace(x_min, x_max, int(2e6)) + +probs = total_f_fit.pdf(test_q, norm_range=False) + +calcs_test = zfit.run(probs) + +Ctt.set_value(0.5) + +calcs_test1 = zfit.run(probs) + +Ctt.set_value(0.0) + +Dbar_s.set_value(0.3) + +DDstar_s.set_value(0.3) + +calcs_test2 = zfit.run(probs) +# res_y = zfit.run(jpsi_res(test_q)) +# b0 = [b0_0, b0_1, b0_2] +# bplus = [bplus_0, bplus_1, bplus_2] +# bT = [bT_0, bT_1, bT_2] +# f0_y = zfit.run(tf.math.real(formfactor(test_q,"0", b0, bplus, bT))) +# fplus_y = zfit.run(tf.math.real(formfactor(test_q,"+", b0, bplus, bT))) +# fT_y = zfit.run(tf.math.real(formfactor(test_q,"T", b0, bplus, bT))) + + +# In[ ]: + + +plt.clf() +# plt.plot(x_part, calcs, '.') +plt.plot(test_q, calcs_test, label = 'pdf (Ctt = 0.0)') +plt.plot(test_q, calcs_test1, label = 'pdf (Ctt = 0.5)') +plt.plot(test_q, calcs_test2, label = 'pdf (D-contribs = 0.3)') +# plt.plot(test_q, f0_y, label = '0') +# plt.plot(test_q, fT_y, label = 'T') +# plt.plot(test_q, fplus_y, label = '+') +# plt.plot(test_q, res_y, label = 'res') +plt.legend() +plt.ylim(0.0, 1.5e-6) +# plt.yscale('log') +# plt.xlim(770, 785) +plt.savefig('test.png') +# print(jpsi_width) + + +# In[ ]: + + + + +# probs = mixture.prob(test_q) +# probs_np = zfit.run(probs) +# probs_np *= np.max(calcs_test) / np.max(probs_np) +# plt.figure() +# plt.semilogy(test_q, probs_np,label="importance sampling") +# plt.semilogy(test_q, calcs_test, label = 'pdf') + + +# In[ ]: + + +# 0.213/(0.00133+0.213+0.015) + + +# ## Adjust scaling of different parts + +# In[ ]: + + +total_f.update_integration_options(draws_per_dim=2000000, mc_sampler=None) +# inte = total_f.integrate(limits = (950., 1050.), norm_range=False) +# inte_fl = zfit.run(inte) +# print(inte_fl/4500) +# print(pdg["jpsi_BR"]/pdg["NR_BR"], inte_fl*pdg["psi2s_auc"]/pdg["NR_auc"]) + + +# In[ ]: + + +# # print("jpsi:", inte_fl) +# # print("Increase am by factor:", np.sqrt(pdg["jpsi_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) +# # print("New amp:", pdg["jpsi"][3]*np.sqrt(pdg["jpsi_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) + +# # print("psi2s:", inte_fl) +# # print("Increase am by factor:", np.sqrt(pdg["psi2s_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) +# # print("New amp:", pdg["psi2s"][3]*np.sqrt(pdg["psi2s_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) + +# name = "phi" + +# print(name+":", inte_fl) +# print("Increase am by factor:", np.sqrt(pdg[name+"_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) +# print("New amp:", pdg[name][0]*np.sqrt(pdg[name+"_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) + + +# print(x_min) +# print(x_max) +# # total_f.update_integration_options(draws_per_dim=2000000, mc_sampler=None) +# total_f.update_integration_options(mc_sampler=lambda dim, num_results, +# dtype: tf.random_uniform(maxval=1., shape=(num_results, dim), dtype=dtype), +# draws_per_dim=1000000) +# # _ = [] + +# # for i in range(10): + +# # inte = total_f.integrate(limits = (x_min, x_max)) +# # inte_fl = zfit.run(inte) +# # print(inte_fl) +# # _.append(inte_fl) + +# # print("mean:", np.mean(_)) + +# _ = time.time() + +# inte = total_f.integrate(limits = (x_min, x_max)) +# inte_fl = zfit.run(inte) +# print(inte_fl) +# print("Time taken: {}".format(display_time(int(time.time() - _)))) + +# print(pdg['NR_BR']/pdg['NR_auc']*inte_fl) +# print(0.25**2*4.2/1000) + + +# # Sampling +# ## Mixture distribution for sampling + +# In[ ]: + + + + +# print(list_of_borders[:9]) +# print(list_of_borders[-9:]) + + +class UniformSampleAndWeights(zfit.util.execution.SessionHolderMixin): + def __call__(self, limits, dtype, n_to_produce): + # n_to_produce = tf.cast(n_to_produce, dtype=tf.int32) + low, high = limits.limit1d + low = tf.cast(low, dtype=dtype) + high = tf.cast(high, dtype=dtype) +# uniform = tfd.Uniform(low=low, high=high) +# uniformjpsi = tfd.Uniform(low=tf.constant(3080, dtype=dtype), high=tf.constant(3112, dtype=dtype)) +# uniformpsi2s = tfd.Uniform(low=tf.constant(3670, dtype=dtype), high=tf.constant(3702, dtype=dtype)) + +# list_of_borders = [] +# _p = [] +# splits = 10 + +# _ = np.linspace(x_min, x_max, splits) + +# for i in range(splits): +# list_of_borders.append(tf.constant(_[i], dtype=dtype)) +# _p.append(tf.constant(1/splits, dtype=dtype)) + +# mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=_p[:(splits-1)]), +# components_distribution=tfd.Uniform(low=list_of_borders[:(splits-1)], +# high=list_of_borders[-(splits-1):])) + mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=[tf.constant(0.05, dtype=dtype), + tf.constant(0.93, dtype=dtype), + tf.constant(0.05, dtype=dtype), + tf.constant(0.065, dtype=dtype), + tf.constant(0.04, dtype=dtype), + tf.constant(0.05, dtype=dtype)]), + components_distribution=tfd.Uniform(low=[tf.constant(x_min, dtype=dtype), + tf.constant(3090, dtype=dtype), + tf.constant(3681, dtype=dtype), + tf.constant(3070, dtype=dtype), + tf.constant(1000, dtype=dtype), + tf.constant(3660, dtype=dtype)], + high=[tf.constant(x_max, dtype=dtype), + tf.constant(3102, dtype=dtype), + tf.constant(3691, dtype=dtype), + tf.constant(3110, dtype=dtype), + tf.constant(1040, dtype=dtype), + tf.constant(3710, dtype=dtype)])) +# dtype = tf.float64 +# mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=[tf.constant(0.04, dtype=dtype), +# tf.constant(0.90, dtype=dtype), +# tf.constant(0.02, dtype=dtype), +# tf.constant(0.07, dtype=dtype), +# tf.constant(0.02, dtype=dtype)]), +# components_distribution=tfd.Uniform(low=[tf.constant(x_min, dtype=dtype), +# tf.constant(3089, dtype=dtype), +# tf.constant(3103, dtype=dtype), +# tf.constant(3681, dtype=dtype), +# tf.constant(3691, dtype=dtype)], +# high=[tf.constant(3089, dtype=dtype), +# tf.constant(3103, dtype=dtype), +# tf.constant(3681, dtype=dtype), +# tf.constant(3691, dtype=dtype), +# tf.constant(x_max, dtype=dtype)])) +# mixture = tfd.Uniform(tf.constant(x_min, dtype=dtype), tf.constant(x_max, dtype=dtype)) +# sample = tf.random.uniform((n_to_produce, 1), dtype=dtype) + sample = mixture.sample((n_to_produce, 1)) +# sample = tf.random.uniform((n_to_produce, 1), dtype=dtype) + weights = mixture.prob(sample)[:,0] +# weights = tf.broadcast_to(tf.constant(1., dtype=dtype), shape=(n_to_produce,)) + # sample = tf.expand_dims(sample, axis=-1) +# print(sample, weights) + +# weights = tf.ones(shape=(n_to_produce,), dtype=dtype) + weights_max = None + thresholds = tf.random_uniform(shape=(n_to_produce,), dtype=dtype) + return sample, thresholds, weights, weights_max, n_to_produce + + +# In[ ]: + + +# total_f._sample_and_weights = UniformSampleAndWeights + + +# In[ ]: + + +# 0.00133/(0.00133+0.213+0.015)*(x_max-3750)/(x_max-x_min) + + +# In[ ]: + + +# zfit.settings.set_verbosity(10) + + +# In[ ]: + + +# # zfit.run.numeric_checks = False + +# nr_of_toys = 1 +# nevents = int(pdg["number_of_decays"]) +# nevents = pdg["number_of_decays"] +# event_stack = 1000000 +# # zfit.settings.set_verbosity(10) +# calls = int(nevents/event_stack + 1) + +# total_samp = [] + +# start = time.time() + +# sampler = total_f.create_sampler(n=event_stack) + +# for toy in range(nr_of_toys): + +# dirName = 'data/zfit_toys/toy_{0}'.format(toy) + +# if not os.path.exists(dirName): +# os.mkdir(dirName) +# print("Directory " , dirName , " Created ") + +# for call in range(calls): + +# sampler.resample(n=event_stack) +# s = sampler.unstack_x() +# sam = zfit.run(s) +# # clear_output(wait=True) + +# c = call + 1 + +# print("{0}/{1} of Toy {2}/{3}".format(c, calls, toy+1, nr_of_toys)) +# print("Time taken: {}".format(display_time(int(time.time() - start)))) +# print("Projected time left: {}".format(display_time(int((time.time() - start)/(c+calls*(toy))*((nr_of_toys-toy)*calls-c))))) + +# with open("data/zfit_toys/toy_{0}/{1}.pkl".format(toy, call), "wb") as f: +# pkl.dump(sam, f, pkl.HIGHEST_PROTOCOL) + + +# In[ ]: + + +# with open(r"data/zfit_toys/toy_0/0.pkl", "rb") as input_file: +# sam = pkl.load(input_file) +# print(sam[:10]) + +# with open(r"data/zfit_toys/toy_0/1.pkl", "rb") as input_file: +# sam2 = pkl.load(input_file) +# print(sam2[:10]) + +# print(np.sum(sam-sam2)) + + +# In[ ]: + + +# print("Time to generate full toy: {} s".format(int(time.time()-start))) + +# total_samp = [] + +# for call in range(calls): +# with open(r"data/zfit_toys/toy_0/{}.pkl".format(call), "rb") as input_file: +# sam = pkl.load(input_file) +# total_samp = np.append(total_samp, sam) + +# total_samp = total_samp.astype('float64') + +# data2 = zfit.data.Data.from_numpy(array=total_samp[:int(nevents)], obs=obs) + +# data3 = zfit.data.Data.from_numpy(array=total_samp, obs=obs) + +# print(total_samp[:nevents].shape) + + +# In[ ]: + + +# plt.clf() + +# bins = int((x_max-x_min)/7) + +# # calcs = zfit.run(total_test_tf(samp)) +# print(total_samp[:nevents].shape) + +# plt.hist(total_samp[:nevents], bins = bins, range = (x_min,x_max), label = 'data') +# # plt.plot(test_q, calcs_test*nevents , label = 'pdf') + +# # plt.plot(sam, calcs, '.') +# # plt.plot(test_q, calcs_test) +# # plt.yscale('log') +# plt.ylim(0, 200) +# # plt.xlim(3080, 3110) + +# plt.legend() + +# plt.savefig('test2.png') + + +# In[ ]: + + +# sampler = total_f.create_sampler(n=nevents) +# nll = zfit.loss.UnbinnedNLL(model=total_f, data=sampler, fit_range = (x_min, x_max)) + +# # for param in pdf.get_dependents(): +# # param.set_value(initial_value) + +# sampler.resample(n=nevents) + +# # Randomise initial values +# # for param in pdf.get_dependents(): +# # param.set_value(random value here) + +# # Minimise the NLL +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 10) +# minimum = minimizer.minimize(nll) + + +# In[ ]: + + +# jpsi_width + + +# In[ ]: + + +# plt.hist(sample, weights=1 / prob(sample)) + + +# # Fitting + +# In[ ]: + + +# start = time.time() + +# for param in total_f.get_dependents(): +# param.randomize() + +# # for param in total_f.get_dependents(): +# # print(zfit.run(param)) + +# nll = zfit.loss.UnbinnedNLL(model=total_f, data=data2, fit_range = (x_min, x_max)) + +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) +# # minimizer._use_tfgrad = False +# result = minimizer.minimize(nll) + +# # param_errors = result.error() + +# # for var, errors in param_errors.items(): +# # print('{}: ^{{+{}}}_{{{}}}'.format(var.name, errors['upper'], errors['lower'])) + +# print("Function minimum:", result.fmin) +# # print("Results:", result.params) +# print("Hesse errors:", result.hesse()) + + +# In[ ]: + + +# print("Time taken for fitting: {}".format(display_time(int(time.time()-start)))) + +# # probs = total_f.pdf(test_q) + +# calcs_test = zfit.run(probs) +# res_y = zfit.run(jpsi_res(test_q)) + + +# In[ ]: + + +# plt.clf() +# # plt.plot(x_part, calcs, '.') +# plt.plot(test_q, calcs_test, label = 'pdf') +# # plt.plot(test_q, res_y, label = 'res') +# plt.legend() +# plt.ylim(0.0, 10e-6) +# # plt.yscale('log') +# # plt.xlim(3080, 3110) +# plt.savefig('test3.png') +# # print(jpsi_width) + + +# In[ ]: + + +# _tot = 4.37e-7+6.02e-5+4.97e-6 +# _probs = [] +# _probs.append(6.02e-5/_tot) +# _probs.append(4.97e-6/_tot) +# _probs.append(4.37e-7/_tot) +# print(_probs) + + +# In[ ]: + + +# dtype = 'float64' +# # mixture = tfd.Uniform(tf.constant(x_min, dtype=dtype), tf.constant(x_max, dtype=dtype)) +# mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=[tf.constant(0.007, dtype=dtype), +# tf.constant(0.917, dtype=dtype), +# tf.constant(0.076, dtype=dtype)]), +# components_distribution=tfd.Uniform(low=[tf.constant(x_min, dtype=dtype), +# tf.constant(3080, dtype=dtype), +# tf.constant(3670, dtype=dtype)], +# high=[tf.constant(x_max, dtype=dtype), +# tf.constant(3112, dtype=dtype), +# tf.constant(3702, dtype=dtype)])) +# # for i in range(10): +# # print(zfit.run(mixture.prob(mixture.sample((10, 1))))) + + +# In[ ]: + + +# print((zfit.run(jpsi_p)%(2*np.pi))/np.pi) +# print((zfit.run(psi2s_p)%(2*np.pi))/np.pi) + + +# In[ ]: + + +# def jpsi_res(q): +# return resonance(q, _mass = jpsi_mass, scale = jpsi_scale, +# phase = jpsi_phase, width = jpsi_width) + +# def psi2s_res(q): +# return resonance(q, _mass = psi2s_mass, scale = psi2s_scale, +# phase = psi2s_phase, width = psi2s_width) + +# def p3770_res(q): +# return resonance(q, _mass = p3770_mass, scale = p3770_scale, +# phase = p3770_phase, width = p3770_width) + +# def p4040_res(q): +# return resonance(q, _mass = p4040_mass, scale = p4040_scale, +# phase = p4040_phase, width = p4040_width) + +# def p4160_res(q): +# return resonance(q, _mass = p4160_mass, scale = p4160_scale, +# phase = p4160_phase, width = p4160_width) + +# def p4415_res(q): +# return resonance(q, _mass = p4415_mass, scale = p4415_scale, +# phase = p4415_phase, width = p4415_width) + + +# In[ ]: + + +# 0.15**2*4.2/1000 +# result.hesse() + + +# ## Constraints + +# In[ ]: + + +# 1. Constraint - Real part of sum of Psi contrib and D contribs + +sum_list = [] + +sum_list.append(ztf.to_complex(jpsi_s) * tf.exp(tf.complex(ztf.constant(0.0), jpsi_p)) * ztf.to_complex(jpsi_w / (tf.pow(jpsi_m,3)))) +sum_list.append(ztf.to_complex(psi2s_s) * tf.exp(tf.complex(ztf.constant(0.0), psi2s_p)) * ztf.to_complex(psi2s_w / (tf.pow(psi2s_m,3)))) +sum_list.append(ztf.to_complex(p3770_s) * tf.exp(tf.complex(ztf.constant(0.0), p3770_p)) * ztf.to_complex(p3770_w / (tf.pow(p3770_m,3)))) +sum_list.append(ztf.to_complex(p4040_s) * tf.exp(tf.complex(ztf.constant(0.0), p4040_p)) * ztf.to_complex(p4040_w / (tf.pow(p4040_m,3)))) +sum_list.append(ztf.to_complex(p4160_s) * tf.exp(tf.complex(ztf.constant(0.0), p4160_p)) * ztf.to_complex(p4160_w / (tf.pow(p4160_m,3)))) +sum_list.append(ztf.to_complex(p4415_s) * tf.exp(tf.complex(ztf.constant(0.0), p4415_p)) * ztf.to_complex(p4415_w / (tf.pow(p4415_m,3)))) +sum_list.append(ztf.to_complex(DDstar_s) * tf.exp(tf.complex(ztf.constant(0.0), DDstar_p)) * (ztf.to_complex(1.0 / (10.0*tf.pow(Dstar_m,2)) + 1.0 / (10.0*tf.pow(D_m,2))))) +sum_list.append(ztf.to_complex(Dbar_s) * tf.exp(tf.complex(ztf.constant(0.0), Dbar_p)) * ztf.to_complex(1.0 / (6.0*tf.pow(Dbar_m,2)))) + +sum_ru_1 = ztf.to_complex(ztf.constant(0.0)) + +for part in sum_list: + sum_ru_1 += part + +sum_1 = tf.math.real(sum_ru_1) +# constraint1 = zfit.constraint.GaussianConstraint(params = sum_1, mu = ztf.constant(1.7*10**-8), +# sigma = ztf.constant(2.2*10**-8)) + +constraint1 = tf.pow((sum_1-ztf.constant(1.7*10**-8))/ztf.constant(2.2*10**-8),2)/ztf.constant(2.) + +# 2. Constraint - Abs. of sum of Psi contribs and D contribs + +sum_2 = tf.abs(sum_ru_1) +constraint2 = tf.cond(tf.greater_equal(sum_2, 5.0e-8), lambda: 100000., lambda: 0.) + +# 3. Constraint - Maximum eta of D contribs + +constraint3_0 = tf.cond(tf.greater_equal(tf.abs(Dbar_s), 0.2), lambda: 100000., lambda: 0.) + +constraint3_1 = tf.cond(tf.greater_equal(tf.abs(DDstar_s), 0.2), lambda: 100000., lambda: 0.) + +# 4. Constraint - Formfactor multivariant gaussian covariance fplus + +Cov_matrix = [[ztf.constant( 1.), ztf.constant( 0.45), ztf.constant( 0.19), ztf.constant(0.857), ztf.constant(0.598), ztf.constant(0.531), ztf.constant(0.752), ztf.constant(0.229), ztf.constant(0,117)], + [ztf.constant( 0.45), ztf.constant( 1.), ztf.constant(0.677), ztf.constant(0.708), ztf.constant(0.958), ztf.constant(0.927), ztf.constant(0.227), ztf.constant(0.443), ztf.constant(0.287)], + [ztf.constant( 0.19), ztf.constant(0.677), ztf.constant( 1.), ztf.constant(0.595), ztf.constant(0.770), ztf.constant(0.819),ztf.constant(-0.023), ztf.constant( 0.07), ztf.constant(0.196)], + [ztf.constant(0.857), ztf.constant(0.708), ztf.constant(0.595), ztf.constant( 1.), ztf.constant( 0.83), ztf.constant(0.766), ztf.constant(0.582), ztf.constant(0.237), ztf.constant(0.192)], + [ztf.constant(0.598), ztf.constant(0.958), ztf.constant(0.770), ztf.constant( 0.83), ztf.constant( 1.), ztf.constant(0.973), ztf.constant(0.324), ztf.constant(0.372), ztf.constant(0.272)], + [ztf.constant(0.531), ztf.constant(0.927), ztf.constant(0.819), ztf.constant(0.766), ztf.constant(0.973), ztf.constant( 1.), ztf.constant(0.268), ztf.constant(0.332), ztf.constant(0.269)], + [ztf.constant(0.752), ztf.constant(0.227),ztf.constant(-0.023), ztf.constant(0.582), ztf.constant(0.324), ztf.constant(0.268), ztf.constant( 1.), ztf.constant( 0.59), ztf.constant(0.515)], + [ztf.constant(0.229), ztf.constant(0.443), ztf.constant( 0.07), ztf.constant(0.237), ztf.constant(0.372), ztf.constant(0.332), ztf.constant( 0.59), ztf.constant( 1.), ztf.constant(0.897)], + [ztf.constant(0.117), ztf.constant(0.287), ztf.constant(0.196), ztf.constant(0.192), ztf.constant(0.272), ztf.constant(0.269), ztf.constant(0.515), ztf.constant(0.897), ztf.constant( 1.)]] + +def triGauss(val1,val2,val3,m = Cov_matrix): + + mean1 = ztf.constant(0.466) + mean2 = ztf.constant(-0.885) + mean3 = ztf.constant(-0.213) + sigma1 = ztf.constant(0.014) + sigma2 = ztf.constant(0.128) + sigma3 = ztf.constant(0.548) + x1 = (val1-mean1)/sigma1 + x2 = (val2-mean2)/sigma2 + x3 = (val3-mean3)/sigma3 + rho12 = m[0][1] + rho13 = m[0][2] + rho23 = m[1][2] + w = x1*x1*(rho23*rho23-1) + x2*x2*(rho13*rho13-1)+x3*x3*(rho12*rho12-1)+2*(x1*x2*(rho12-rho13*rho23)+x1*x3*(rho13-rho12*rho23)+x2*x3*(rho23-rho12*rho13)) + d = 2*(rho12*rho12+rho13*rho13+rho23*rho23-2*rho12*rho13*rho23-1) + + fcn = -w/d + chisq = -2*fcn + return chisq + +constraint4 = triGauss(bplus_0, bplus_1, bplus_2) + +# mean1 = ztf.constant(0.466) +# mean2 = ztf.constant(-0.885) +# mean3 = ztf.constant(-0.213) +# sigma1 = ztf.constant(0.014) +# sigma2 = ztf.constant(0.128) +# sigma3 = ztf.constant(0.548) +# constraint4_0 = tf.pow((bplus_0-mean1)/sigma1,2)/ztf.constant(2.) +# constraint4_1 = tf.pow((bplus_1-mean2)/sigma2,2)/ztf.constant(2.) +# constraint4_2 = tf.pow((bplus_2-mean3)/sigma3,2)/ztf.constant(2.) + +# 5. Constraint - Abs. of sum of light contribs + +sum_list_5 = [] + +sum_list_5.append(rho_s*rho_w/rho_m) +sum_list_5.append(omega_s*omega_w/omega_m) +sum_list_5.append(phi_s*phi_w/phi_m) + + +sum_ru_5 = ztf.constant(0.0) + +for part in sum_list_5: + sum_ru_5 += part + +constraint5 = tf.cond(tf.greater_equal(tf.abs(sum_ru_5), ztf.constant(0.02)), lambda: 100000., lambda: 0.) + +# 6. Constraint on phases of Jpsi and Psi2s for cut out fit + + +# constraint6_0 = zfit.constraint.GaussianConstraint(params = jpsi_p, mu = ztf.constant(pdg["jpsi_phase_unc"]), +# sigma = ztf.constant(jpsi_phase)) +# constraint6_1 = zfit.constraint.GaussianConstraint(params = psi2s_p, mu = ztf.constant(pdg["psi2s_phase_unc"]), +# sigma = ztf.constant(psi2s_phase)) + +constraint6_0 = tf.pow((jpsi_p-ztf.constant(jpsi_phase))/ztf.constant(pdg["jpsi_phase_unc"]),2)/ztf.constant(2.) +constraint6_1 = tf.pow((psi2s_p-ztf.constant(psi2s_phase))/ztf.constant(pdg["psi2s_phase_unc"]),2)/ztf.constant(2.) + +# 7. Constraint on Ctt with higher limits + +constraint7 = tf.cond(tf.greater_equal(Ctt*Ctt, 0.25), lambda: 100000., lambda: 0.) + +constraint7dtype = tf.float64 + +# zfit.run(constraint6_0) + +# ztf.convert_to_tensor(constraint6_0) + +#List of all constraints + +constraints = [constraint1, constraint2, constraint3_0, constraint3_1,# constraint4, #constraint4_0, constraint4_1, constraint4_2, + constraint6_0, constraint6_1]#, constraint7] + + +# ## Reset params + +# In[ ]: + + +param_values_dic = { + 'jpsi_m': jpsi_mass, + 'jpsi_s': jpsi_scale, + 'jpsi_p': jpsi_phase, + 'jpsi_w': jpsi_width, + 'psi2s_m': psi2s_mass, + 'psi2s_s': psi2s_scale, + 'psi2s_p': psi2s_phase, + 'psi2s_w': psi2s_width, + 'p3770_m': p3770_mass, + 'p3770_s': p3770_scale, + 'p3770_p': p3770_phase, + 'p3770_w': p3770_width, + 'p4040_m': p4040_mass, + 'p4040_s': p4040_scale, + 'p4040_p': p4040_phase, + 'p4040_w': p4040_width, + 'p4160_m': p4160_mass, + 'p4160_s': p4160_scale, + 'p4160_p': p4160_phase, + 'p4160_w': p4160_width, + 'p4415_m': p4415_mass, + 'p4415_s': p4415_scale, + 'p4415_p': p4415_phase, + 'p4415_w': p4415_width, + 'rho_m': rho_mass, + 'rho_s': rho_scale, + 'rho_p': rho_phase, + 'rho_w': rho_width, + 'omega_m': omega_mass, + 'omega_s': omega_scale, + 'omega_p': omega_phase, + 'omega_w': omega_width, + 'phi_m': phi_mass, + 'phi_s': phi_scale, + 'phi_p': phi_phase, + 'phi_w': phi_width, + 'Dstar_m': Dstar_mass, + 'DDstar_s': 0.0, + 'DDstar_p': 0.0, + 'D_m': D_mass, + 'Dbar_m': Dbar_mass, + 'Dbar_s': 0.0, + 'Dbar_p': 0.0, + 'tau_m': pdg['tau_M'], + 'Ctt': 0.0, + 'b0_0': 0.292, + 'b0_1': 0.281, + 'b0_2': 0.150, + 'bplus_0': 0.466, + 'bplus_1': -0.885, + 'bplus_2': -0.213, + 'bT_0': 0.460, + 'bT_1': -1.089, + 'bT_2': -1.114} + + +def reset_param_values(variation = 0.05): + for param in total_f_fit.get_dependents(): + if param.floating: + param.set_value(param_values_dic[param.name] + random.uniform(-1, 1) * param_values_dic[param.name]* variation) +# print(param.name) +# for param in totalf.get_dependents(): +# param.set_value() + + +# # Analysis + +# In[ ]: + + +# # zfit.run.numeric_checks = False + +# fitting_range = 'cut' +# total_BR = 1.7e-10 + 4.9e-10 + 2.5e-9 + 6.02e-5 + 4.97e-6 + 1.38e-9 + 4.2e-10 + 2.6e-9 + 6.1e-10 + 4.37e-7 +# cut_BR = 1.0 - (6.02e-5 + 4.97e-6)/total_BR + +# Ctt_list = [] +# Ctt_error_list = [] + +# nr_of_toys = 1 +# if fitting_range == 'cut': +# nevents = int(pdg["number_of_decays"]*cut_BR) +# else: +# nevents = int(pdg["number_of_decays"]) +# # nevents = pdg["number_of_decays"] +# event_stack = 1000000 +# # nevents *= 41 +# # zfit.settings.set_verbosity(10) +# calls = int(nevents/event_stack + 1) + +# total_samp = [] + +# start = time.time() + +# sampler = total_f.create_sampler(n=event_stack) + +# for toy in range(nr_of_toys): + +# ### Generate data + +# # clear_output(wait=True) + +# print("Toy {}: Generating data...".format(toy)) + +# dirName = 'data/zfit_toys/toy_{0}'.format(toy) + +# if not os.path.exists(dirName): +# os.mkdir(dirName) +# print("Directory " , dirName , " Created ") + +# reset_param_values() + +# if fitting_range == 'cut': + +# sampler.resample(n=nevents) +# s = sampler.unstack_x() +# sam = zfit.run(s) +# calls = 0 +# c = 1 + +# else: +# for call in range(calls): + +# sampler.resample(n=event_stack) +# s = sampler.unstack_x() +# sam = zfit.run(s) + +# c = call + 1 + +# with open("data/zfit_toys/toy_{0}/{1}.pkl".format(toy, call), "wb") as f: +# pkl.dump(sam, f, pkl.HIGHEST_PROTOCOL) + +# print("Toy {}: Data generation finished".format(toy)) + +# ### Load data + +# print("Toy {}: Loading data...".format(toy)) + +# if fitting_range == 'cut': + +# total_samp = sam + +# else: + +# for call in range(calls): +# with open(r"data/zfit_toys/toy_0/{}.pkl".format(call), "rb") as input_file: +# sam = pkl.load(input_file) +# total_samp = np.append(total_samp, sam) + +# total_samp = total_samp.astype('float64') + +# if fitting_range == 'full': + +# data = zfit.data.Data.from_numpy(array=total_samp[:int(nevents)], obs=obs) + +# print("Toy {}: Loading data finished".format(toy)) + +# ### Fit data + +# print("Toy {}: Fitting pdf...".format(toy)) + +# for param in total_f.get_dependents(): +# param.randomize() + +# nll = zfit.loss.UnbinnedNLL(model=total_f, data=data, fit_range = (x_min, x_max), constraints = constraints) + +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) +# # minimizer._use_tfgrad = False +# result = minimizer.minimize(nll) + +# print("Toy {}: Fitting finished".format(toy)) + +# print("Function minimum:", result.fmin) +# print("Hesse errors:", result.hesse()) + +# params = result.params +# Ctt_list.append(params[Ctt]['value']) +# Ctt_error_list.append(params[Ctt]['minuit_hesse']['error']) + +# #plotting the result + +# plotdirName = 'data/plots'.format(toy) + +# if not os.path.exists(plotdirName): +# os.mkdir(plotdirName) +# # print("Directory " , dirName , " Created ") + +# probs = total_f.pdf(test_q, norm_range=False) +# calcs_test = zfit.run(probs) +# plt.clf() +# plt.plot(test_q, calcs_test, label = 'pdf') +# plt.legend() +# plt.ylim(0.0, 6e-6) +# plt.savefig(plotdirName + '/toy_fit_full_range{}.png'.format(toy)) + +# print("Toy {0}/{1}".format(toy+1, nr_of_toys)) +# print("Time taken: {}".format(display_time(int(time.time() - start)))) +# print("Projected time left: {}".format(display_time(int((time.time() - start)/(c+calls*(toy))*((nr_of_toys-toy)*calls-c))))) + +# if fitting_range == 'cut': + +# _1 = np.where((total_samp >= x_min) & (total_samp <= (jpsi_mass - 60.))) + +# tot_sam_1 = total_samp[_1] + +# _2 = np.where((total_samp >= (jpsi_mass + 70.)) & (total_samp <= (psi2s_mass - 50.))) + +# tot_sam_2 = total_samp[_2] + +# _3 = np.where((total_samp >= (psi2s_mass + 50.)) & (total_samp <= x_max)) + +# tot_sam_3 = total_samp[_3] + +# tot_sam = np.append(tot_sam_1, tot_sam_2) +# tot_sam = np.append(tot_sam, tot_sam_3) + +# data = zfit.data.Data.from_numpy(array=tot_sam[:int(nevents)], obs=obs_fit) + +# print("Toy {}: Loading data finished".format(toy)) + +# ### Fit data + +# print("Toy {}: Fitting pdf...".format(toy)) + +# for param in total_f_fit.get_dependents(): +# param.randomize() + +# nll = zfit.loss.UnbinnedNLL(model=total_f_fit, data=data, constraints = constraints) + +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) +# # minimizer._use_tfgrad = False +# result = minimizer.minimize(nll) + +# print("Function minimum:", result.fmin) +# print("Hesse errors:", result.hesse()) + +# params = result.params + +# if result.converged: +# Ctt_list.append(params[Ctt]['value']) +# Ctt_error_list.append(params[Ctt]['minuit_hesse']['error']) + +# #plotting the result + +# plotdirName = 'data/plots'.format(toy) + +# if not os.path.exists(plotdirName): +# os.mkdir(plotdirName) +# # print("Directory " , dirName , " Created ") + +# plt.clf() +# plt.hist(tot_sam, bins = int((x_max-x_min)/7.), label = 'toy data') +# plt.savefig(plotdirName + '/toy_histo_cut_region{}.png'.format(toy)) + + +# probs = total_f_fit.pdf(test_q, norm_range=False) +# calcs_test = zfit.run(probs) +# plt.clf() +# plt.plot(test_q, calcs_test, label = 'pdf') +# plt.axvline(x=jpsi_mass-60.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.axvline(x=jpsi_mass+70.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.axvline(x=psi2s_mass-50.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.axvline(x=psi2s_mass+50.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.legend() +# plt.ylim(0.0, 1.5e-6) +# plt.savefig(plotdirName + '/toy_fit_cut_region{}.png'.format(toy)) + +# print("Toy {0}/{1}".format(toy+1, nr_of_toys)) +# print("Time taken: {}".format(display_time(int(time.time() - start)))) +# print("Projected time left: {}".format(display_time(int((time.time() - start)/(toy+1))*((nr_of_toys-toy-1))))) + + + +# In[ ]: + + +# with open("data/results/Ctt_list.pkl", "wb") as f: +# pkl.dump(Ctt_list, f, pkl.HIGHEST_PROTOCOL) +# with open("data/results/Ctt_error_list.pkl", "wb") as f: +# pkl.dump(Ctt_error_list, f, pkl.HIGHEST_PROTOCOL) + + +# In[ ]: + + +# print('{0}/{1} fits converged'.format(len(Ctt_list), nr_of_toys)) +# print('Mean Ctt value = {}'.format(np.mean(Ctt_list))) +# print('Mean Ctt error = {}'.format(np.mean(Ctt_error_list))) +# print('95 Sensitivy = {}'.format(((2*np.mean(Ctt_error_list))**2)*4.2/1000)) + + +# In[ ]: + + +# plt.hist(tot_sam, bins = int((x_max-x_min)/7.)) + +# plt.show() + +# # _ = np.where((total_samp >= x_min) & (total_samp <= (jpsi_mass - 50.))) + +# tot_sam.shape + + +# In[ ]: + + +# Ctt.floating = False + + +# In[ ]: + + +# zfit.run(nll.value()) + + +# In[ ]: + + +# result.fmin + + +# In[ ]: + + +# BR_steps = np.linspace(0.0, 1e-3, 11) +pull_dic = {} + +mi = 1e-4 +ma = 3e-3 +ste = 20 + +for param in total_f_fit.get_dependents(): + if param.floating: + pull_dic[param.name] = [] + for step in range(2*ste): + pull_dic[param.name].append([]) + + + +def save_pulls(step): + for param in total_f_fit.get_dependents(): + if param.floating: + pull_dic[param.name][step].append((params[param]['value'] - param_values_dic[param.name])/params[param]['minuit_hesse']['error']) + + + +# for key in pull_dic.keys(): +# print(np.shape(pull_dic[key])) +# save_pulls(New_step=True) +# params[Ctt]['value'] + + +# In[ ]: + + +# for param in total_f_fit.get_dependents(): +# if param.floating: +# print(param.name) + +# print(params[Ctt]) + + +# # CLS Code + +# In[ ]: + + +# zfit.run.numeric_checks = False + +load = False + +bo = True + +D_contribs = True + +if not D_contribs: + Dbar_s.floating = False + Dbar_p.floating = False + DDstar_s.floating = False + DDstar_p.floating = False + +bo_set = 1 + +fitting_range = 'cut' +total_BR = 1.7e-10 + 4.9e-10 + 2.5e-9 + 6.02e-5 + 4.97e-6 + 1.38e-9 + 4.2e-10 + 2.6e-9 + 6.1e-10 + 4.37e-7 +cut_BR = 1.0 - (6.02e-5 + 4.97e-6)/total_BR + +Ctt_list = [] +Ctt_error_list = [] + +nr_of_toys = 1 +nevents = int(pdg["number_of_decays"]*cut_BR) +# nevents = pdg["number_of_decays"] +event_stack = 1000000 +# nevents *= 41 +# zfit.settings.set_verbosity(10) + +# mi = 1e-4 +# ma = 3e-3 +# ste = 13 + +BR_steps = np.linspace(mi, ma, ste) + +BR_steps[0] = 0.0 + +print(BR_steps) + +Ctt_steps = np.sqrt(BR_steps/4.2*1000) + +print(Ctt_steps) + +# total_samp = [] + +start = time.time() + +Nll_list = [] + +sampler = total_f.create_sampler(n=nevents, fixed_params = False) +sampler.set_data_range(obs_fit) + +__ = -1 + +#----------------------------------------------------- + +if not load: + for Ctt_step in Ctt_steps: + + __ += 1 + + for i in range(2): + Ctt_list.append([]) + Ctt_error_list.append([]) + Nll_list.append([]) + + for param in total_f_fit.get_dependents(): + if param.floating: + pull_dic[param.name].append([]) + + for toy in range(nr_of_toys): + + newset = True + + while newset: + + for floaty in [True, False]: + Ctt.floating = floaty + + for bo_step in range(bo_set): + + print('Step: {0}/{1}'.format(int(__), ste)) + print('Current Ctt: {0}'.format(Ctt_step)) + print('Ctt floating: {0}'.format(floaty)) + + reset_param_values(variation = 0.0) + + if floaty: + print('Toy {0}/{1} - Fit {2}/{3}'.format(toy, nr_of_toys, bo_step, bo_set)) + Ctt.set_value(Ctt_step) + + else: + Ctt.set_value(0.0) + print('Toy {0}/{1} - Fit {2}/{3}'.format(toy, nr_of_toys, bo_step, bo_set)) + + if newset: + sampler.resample(n=nevents) + data = sampler + newset = False + + ### Fit data + + if floaty: + #plt.clf() + #plt.title('Ctt value: {:.2f}'.format(Ctt_step)) + #plt.hist(zfit.run(data), bins = int((x_max-x_min)/7), range = (x_min, x_max)) + #plt.savefig('data/CLs/plots/set_histo{}.png'.format(__)) + _step = 2*__ + else: + _step = 2*__+1 + + nll = zfit.loss.UnbinnedNLL(model=total_f_fit, data=data, constraints = constraints) + + minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) + # minimizer._use_tfgrad = False + result = minimizer.minimize(nll) + + print("Function minimum:", result.fmin) + print("Hesse errors:", result.hesse()) + + params = result.params + + if result.converged: + + save_pulls(step = _step) + + if floaty: + Nll_list[-2].append(result.fmin) + Ctt_list[-2].append(params[Ctt]['value']) + Ctt_error_list[-2].append(params[Ctt]['minuit_hesse']['error']) + + else: + Nll_list[-1].append(result.fmin) + Ctt_list[-1].append(0.0) + Ctt_error_list[-1].append(0.0) + + + else: + for _ in [1,2]: + del Nll_list[-_][toy*bo_set:] +# print(np.shape(Nll_list[-_])) + del Ctt_list[-_][toy*bo_set:] + del Ctt_error_list[-_][toy*bo_set:] + for param in total_f_fit.get_dependents(): + if param.floating: + del pull_dic[param.name][_step+1-_][toy*bo_set:] + newset = True + break + + if not result.converged: + break + + print() + print('Time taken: {}'.format(display_time(int(time.time()-start)))) + print('Estimated time left: {}'.format(display_time(int((time.time()-start)/(__+(toy+1)/nr_of_toys)*(ste-__-(nr_of_toys-toy-1)/nr_of_toys))))) + + +# In[ ]: + + +if load: + + phase_combi = '--' + + if D_contribs: + D_dir = 'D-True' + else: + D_dir = 'D-False' + + _dir = 'data/CLs/finished/f1d1/{}/{}/'.format(phase_combi, D_dir) + + jobs = os.listdir(_dir) + + First = True + +# print(jobs) + + for job in jobs: + + dirName = _dir + str(job) + '/data/CLs' + + if not os.path.exists("{}/{}-{}_{}s{}b{}t--CLs_Nll_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys)): +# print(job) + continue + + with open(r"{}/variab.pkl".format(dirName), "rb") as input_file: + variab = pkl.load(input_file) +# print(variab) + + ### sanity check: + if variab['mi'] != mi or variab['ma'] != ma or variab['ste'] != ste or bo_set != bo_set: + print('Fitting parameters of data dont equal the ones given -- Job {} skipped!'.format(job)) + + with open(r"{}/{}-{}_{}s{}b{}t--CLs_Nll_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _Nll_list = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s{}b{}t--Ctt_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _Ctt_list = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s{}b{}t--Ctt_error_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _Ctt_error_list = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s{}b{}t--pull_dic.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _pull_dic = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s--CLs_list.pkl".format(dirName, mi,ma,ste), "rb") as input_file: + _CLs_list = pkl.load(input_file) + + + if First: + Nll_list = _Nll_list + Ctt_list = _Ctt_list + Ctt_error_list = _Ctt_error_list + pull_dic = _pull_dic +# print(_pull_dic) + CLs_list = _CLs_list + First = False + else: + for step in range(2*ste): +# print(Nll_list[step], step) + Nll_list[step].extend(_Nll_list[step]) + Ctt_list[step].extend(_Ctt_list[step]) + Ctt_error_list[step].extend(_Ctt_error_list[step]) + for key in pull_dic.keys(): +# print(key, np.shape(pull_dic[key])) + pull_dic[key][step].extend(_pull_dic[key][step]) + for step in range(ste): + CLs_list[step].extend(_CLs_list[step]) + +# print('----------------------') + + +# In[ ]: + + +dirName = 'data/CLs' + +# if bo and not load: +# for s in range(2*ste): +# Nll_list[s] = [np.min(Nll_list[s])] + + +if not load: + + if not os.path.exists(dirName): + os.mkdir(dirName) + print("Directory " , dirName , " Created ") + + with open("{}/{}-{}_{}s{}b{}t--CLs_Nll_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(Nll_list, f, pkl.HIGHEST_PROTOCOL) + + with open("{}/{}-{}_{}s{}b{}t--Ctt_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(Ctt_list, f, pkl.HIGHEST_PROTOCOL) + + with open("{}/{}-{}_{}s{}b{}t--Ctt_error_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(Ctt_error_list, f, pkl.HIGHEST_PROTOCOL) + + with open("{}/{}-{}_{}s{}b{}t--pull_dic.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(pull_dic, f, pkl.HIGHEST_PROTOCOL) + + variab = {'mi': mi, + 'ma': ma, + 'ste': ste, + 'bo_set': bo_set, + 'nr_of_toys': nr_of_toys} + + with open("{}/variab.pkl".format(dirName), "wb") as f: + pkl.dump(variab, f, pkl.HIGHEST_PROTOCOL) + + CLs_values = [] + + toy_size = bo_set + + print(np.shape(Nll_list)) + print(Nll_list[0:1]) + + for step in range(ste): + CLs_values.append([]) + for toy in range(nr_of_toys): + float_min = np.min(Nll_list[2*step][toy*bo_set:(toy+1)*bo_set]) + fix_min = np.min(Nll_list[2*step+1][toy*bo_set:(toy+1)*bo_set]) + CLs_values[step].append(float_min-fix_min) + + + print(np.shape(CLs_values)) + + with open("{}/{}-{}_{}s--CLs_list.pkl".format(dirName, mi,ma,ste), "wb") as f: + pkl.dump(CLs_values, f, pkl.HIGHEST_PROTOCOL) + + +# In[ ]: + + +# print(variab['mi'] != mi) + + +# ## Plot + +# In[ ]: + + +l = [] + + +if load: + CLs_values = -1*np.array(CLs_list) + +if not os.path.exists('data/CLs/plots'): + os.mkdir('data/CLs/plots') + print("Directory " , 'data/CLs/plots' , " Created ") + +print(np.shape(CLs_values)) + +for step in range(1,ste): + plt.clf() + plt.title('Ctt value: {:.2f}'.format(Ctt_steps[step])) + plt.hist(CLs_values[0], bins = 150, range = (-25, 50), label = 'Ctt fixed to 0') + plt.hist(CLs_values[step], bins = 150, range = (-25, 50), label = 'Ctt floating') + plt.axvline(x=np.mean(CLs_values[0]),color='red', linewidth=1.0, linestyle = 'dotted') + plt.legend() + plt.savefig('data/CLs/plots/CLs-BR({:.1E}).png'.format(BR_steps[step])) + + l.append(len(np.where(np.array(CLs_values[step]) < np.mean(CLs_values[0]))[0])) + +for step in range(2*ste): + if step%2 == 0: + floaty = True + else: + floaty = False + for key in pull_dic.keys(): + if not os.path.exists('data/CLs/plots/{}'.format(key)): + os.mkdir('data/CLs/plots/{}'.format(key)) + plt.clf() + plt.title('Pull {} - Ctt value {:.2f} - floating {}'.format(key, Ctt_steps[int(step/2)], floaty)) + plt.hist(pull_dic[key][step], bins = 50, range = (-5,5)) + plt.xlabel('Pull') + plt.savefig('data/CLs/plots/{}/{:.2f}Ctt{}s{}f.png'.format(key, Ctt_steps[int(step/2)], step, floaty)) + + +# In[ ]: + + +for s in range(len(l)): + print('BR: {:.4f}'.format(BR_steps[s+1])) + print(2*l[s]/len(CLs_values[s])) + print() + + +# In[ ]: + + +# for step in range(2*ste): +# for key in pull_dic.keys(): +# print(pull_dic[key][step]) + + +# In[ ]: + + +# for param in total_f_fit.get_dependents(): +# if param.floating: +# print(params[param]['value']) + + +# In[ ]: + + +print(display_time(int(time.time()-start))) + + +# In[ ]: + + +# variab['mi'] =! mi + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + diff --git a/data/CLs/finished/f1d1/-+/D-True/2288018/__pycache__/helperfunctions.cpython-37.pyc b/data/CLs/finished/f1d1/-+/D-True/2288018/__pycache__/helperfunctions.cpython-37.pyc new file mode 100644 index 0000000..a7b97eb --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288018/__pycache__/helperfunctions.cpython-37.pyc Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288018/__pycache__/pdg_const1.cpython-37.pyc b/data/CLs/finished/f1d1/-+/D-True/2288018/__pycache__/pdg_const1.cpython-37.pyc new file mode 100644 index 0000000..0c8af9a --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288018/__pycache__/pdg_const1.cpython-37.pyc Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288018/data/CLs/0.0001-0.003_20s--CLs_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288018/data/CLs/0.0001-0.003_20s--CLs_list.pkl new file mode 100644 index 0000000..918d609 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288018/data/CLs/0.0001-0.003_20s--CLs_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288018/data/CLs/0.0001-0.003_20s1b1t--CLs_Nll_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288018/data/CLs/0.0001-0.003_20s1b1t--CLs_Nll_list.pkl new file mode 100644 index 0000000..f3d1534 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288018/data/CLs/0.0001-0.003_20s1b1t--CLs_Nll_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288018/data/CLs/0.0001-0.003_20s1b1t--Ctt_error_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288018/data/CLs/0.0001-0.003_20s1b1t--Ctt_error_list.pkl new file mode 100644 index 0000000..a0e8f7e --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288018/data/CLs/0.0001-0.003_20s1b1t--Ctt_error_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288018/data/CLs/0.0001-0.003_20s1b1t--Ctt_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288018/data/CLs/0.0001-0.003_20s1b1t--Ctt_list.pkl new file mode 100644 index 0000000..8c94bce --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288018/data/CLs/0.0001-0.003_20s1b1t--Ctt_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288018/data/CLs/0.0001-0.003_20s1b1t--pull_dic.pkl b/data/CLs/finished/f1d1/-+/D-True/2288018/data/CLs/0.0001-0.003_20s1b1t--pull_dic.pkl new file mode 100644 index 0000000..e485683 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288018/data/CLs/0.0001-0.003_20s1b1t--pull_dic.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288018/data/CLs/variab.pkl b/data/CLs/finished/f1d1/-+/D-True/2288018/data/CLs/variab.pkl new file mode 100644 index 0000000..bb90dc0 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288018/data/CLs/variab.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288018/helperfunctions.py b/data/CLs/finished/f1d1/-+/D-True/2288018/helperfunctions.py new file mode 100644 index 0000000..88e120f --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288018/helperfunctions.py @@ -0,0 +1,33 @@ +# some helperfunctions + +import matplotlib +matplotlib.use("agg") +import matplotlib.pyplot as plt + +#Dislpay time (e.g. while generating points) + +display_intervals = ( + ('w', 604800), # 60 * 60 * 24 * 7 + ('d', 86400), # 60 * 60 * 24 + ('h', 3600), # 60 * 60 + ('min', 60), + ('s', 1), + ) + +def display_time(seconds, granularity=2): + result = [] + + for name, count in display_intervals: + value = seconds // count + if value: + seconds -= value * count + if value == 1: + name = name.rstrip('s') + result.append("{} {}".format(value, name)) + return ', '.join(result[:granularity]) + +def prepare_plot(title): + plt.title(title) + plt.grid() + plt.legend(loc = 'best') + plt.xlabel("q") diff --git a/data/CLs/finished/f1d1/-+/D-True/2288018/pdg_const1.py b/data/CLs/finished/f1d1/-+/D-True/2288018/pdg_const1.py new file mode 100644 index 0000000..70b3f30 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288018/pdg_const1.py @@ -0,0 +1,226 @@ +pdg = { + + + ###Particle masses### + + "mbstar" : 5415.4, + "mbstar0" : 5711.0, + "B0_M" : 5279.5, + "Bs_M" : 5366.7, + "Bplus_M" : 5279.3, + "Lb_M" : 5619.4, + "D0_M" : 1864.8, + "Dst_M" : 2010, + "pi_M" : 139.6, + "Jpsi_M" : 3096.9, + "Psi2s_M" : 3685.6, + "kaon_M" : 493.7, + "Ks_M" : 497.6, + "phi_M" : 1019.5, + "rho_M" : 775.26, + "rho_width" : 149.1, + "omega_M" : 782.65, + "omega_width" : 8.49, + + "muon_M" : 105.7, + "tau_M": 1776.86, + + "squark_M" : 95.0, + "bquark_M" : 4180.0, + "cquark_M" : 1275.0, + + "Bplus_tau" : 1.638e-12, + + ###Wilson coefficients### + + "C1" : -0.257, + "C2" : 1.009, + "C3" : -0.005, + "C4" : -0.078, + + "C7eff" : -0.306, + "C9eff" : 4.211, + "C10eff" : -4.103, + +# "C7eff": 0.0, +# "C9eff": 0.0, +# "C10eff": 0.0, + + ###Other constants + + "GF" : 1.1663787e-5, + "alpha_ew" : 1.0/137.0, + "Vts" : 0.0394, + "Vtb" : 1.019, + "number_of_decays": 5404696, + + #Formfactor z coefficients + + #"b0" : [0.285, 0.19, -0.17], + #"bplus" : [0.437, -1.41, -2.5], + #"bT" : [0.440, -1.47, -2.7] + + "b0" : [0.292, 0.281, 0.150], + "bplus" : [0.466, -0.885, -0.213], + "bT" : [0.460, -1.089, -1.114], + + "NR_BR": 4.37e-7, + "NR_auc": 0.00133, + + #Resonances format(mass, width, phase, scale) + + # pre scaling + +# "rho": (775.26, 149.0, -0.35, 1.0), + +# "omega": (782.7, 8.5, 0.26, 1.0), + +# "phi": (1019.46, 4.25, 0.5, 1.0), + +# "jpsi": (3096.0, 0.09, -1.5, 2e-2), +# "jpsi_auc": 0.2126825758464027, + +# "psi2s": (3686.0, 0.3, -1.5, 3.14e-3), +# "psi2s_auc": 2.802257483178487e-10, + +# "p3770": (3773.0, 27.2, -2.13, 1.0e-3), + +# "p4040": (4039.0, 80.0, -2.52, 2.0), + +# "p4160": (4191.0, 70.0, -1.9, 2.2), + +# "p4415": (4421.0, 62.0, -2.52, 1.0), + + + # after scaling (Phase combination --) + + # + # "rho": (743.2, 149.0, -0.22, 1.05), + # + # "omega": (782.7, 8.5, 0.38, 6.8), + # + # "phi": (1013.5, 4.25, 0.62, 19.2), + # + # "jpsi": (3096.1, 0.09, 1.63, 9897.0), + # "jpsi_auc": 0.2126825758464027, + # "jpsi_phase_unc": 0.05, + # + # "psi2s": (3686.0, 0.3, 1.8, 1396.0), + # "psi2s_auc": 0.0151332263, + # "psi2s_phase_unc": 0.1, + # + # "p3770": (3773.0, 27.2, -2.95, 2.5), + # + # "p4040": (4039.0, 80.0, -2.75, 1.01), + # + # "p4160": (4191.0, 70.0, -2.28, 2.2), + # + # "p4415": (4421.0, 62.0, -2.31, 1.24), + + # Phase combination of paper ++ + +# "rho": (743.2, 149.0, -0.35, 1.05), + +# "omega": (782.7, 8.5, 0.26, 6.8), + +# "phi": (1013.5, 4.25, 0.47, 19.2), + +# "jpsi": (3096.1, 0.09, -1.66, 9897.0), +# "jpsi_auc": 0.2126825758464027, +# "jpsi_phase_unc": 0.05, + +# "psi2s": (3686.0, 0.3, -1.93, 1396.0), +# "psi2s_auc": 0.0151332263, +# "psi2s_phase_unc": 0.1, + +# "p3770": (3773.0, 27.2, -2.13, 2.5), + +# "p4040": (4039.0, 80.0, -2.52, 1.01), + +# "p4160": (4191.0, 70.0, -1.90, 2.2), + +# "p4415": (4421.0, 62.0, -2.52, 1.24), + + # Phase combination of paper +- + +# "rho": (743.2, 149.0, -0.26, 1.05), + +# "omega": (782.7, 8.5, 0.35, 6.8), + +# "phi": (1013.5, 4.25, 0.58, 19.2), + +# "jpsi": (3096.1, 0.09, 1.47, 9897.0), +# "jpsi_auc": 0.2126825758464027, +# "jpsi_phase_unc": 0.05, + +# "psi2s": (3686.0, 0.3, -2.21, 1396.0), +# "psi2s_auc": 0.0151332263, +# "psi2s_phase_unc": 0.1, + +# "p3770": (3773.0, 27.2, -2.140, 2.5), + +# "p4040": (4039.0, 80.0, -2.64, 1.01), + +# "p4160": (4191.0, 70.0, -2.11, 2.2), + +# "p4415": (4421.0, 62.0, -2.42, 1.24), + + # Phase combination of paper -+ + + "rho": (743.2, 149.0, -0.30, 1.05), + + "omega": (782.7, 8.5, 0.30, 6.8), + + "phi": (1013.5, 4.25, 0.51, 19.2), + + "jpsi": (3096.1, 0.09, -1.5, 9897.0), + "jpsi_auc": 0.2126825758464027, + "jpsi_phase_unc": 0.05, + + "psi2s": (3686.0, 0.3, 2.08, 1396.0), + "psi2s_auc": 0.0151332263, + "psi2s_phase_unc": 0.1, + + "p3770": (3773.0, 27.2, -2.89, 2.5), + + "p4040": (4039.0, 80.0, -2.69, 1.01), + + "p4160": (4191.0, 70.0, -2.13, 2.2), + + "p4415": (4421.0, 62.0, -2.43, 1.24), + + + # zeroing resonances + +# "rho": (775.26, 149.0, -0.35, 0.0), +# "omega": (782.7, 8.5, 0.26, 0.0), +# "phi": (1019.46, 4.25, 0.5, 0.0), +# "jpsi": (3096.0, 0.09, -1.5, 0.0), +# "psi2s": (3686.0, 0.3, -1.5, 0.0), +# "p3770": (3773.0, 27.2, -2.13, 0.0), +# "p4040": (4039.0, 80.0, -2.52, 0.0), +# "p4160": (4147.0, 22.0, -1.9, 0.0), +# "p4415": (4421.0, 62.0, -2.52, 0.0), + + # 2P contributions format(mass, amp, phase) + +# "D_bar": ( + + #general + + "rho_BR": 1.7e-10, + "omega_BR": 4.9e-10, + "phi_BR": 2.5e-9, + "jpsi_BR": 6.02e-5, + "psi2s_BR": 4.97e-6, + "p3770_BR": 1.38e-9, + "p4040_BR": 4.2e-10, + "p4160_BR": 2.6e-9, + "p4415_BR": 6.1e-10, + +# Estimates + "Dbar_scale": 1.46, #with phase = pi + + "DDstar_scale": 2.41, #with phase = pi + + } diff --git a/data/CLs/finished/f1d1/-+/D-True/2288018/raremodel-nb.py b/data/CLs/finished/f1d1/-+/D-True/2288018/raremodel-nb.py new file mode 100644 index 0000000..c326c9c --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288018/raremodel-nb.py @@ -0,0 +1,2152 @@ +#!/usr/bin/env python +# coding: utf-8 + +# # Import + +# In[ ]: + + +import os + +# os.environ["CUDA_VISIBLE_DEVICES"] = "-1" +import random +import numpy as np +from pdg_const1 import pdg +import matplotlib +import matplotlib.pyplot as plt +import pickle as pkl +import sys +import time +from helperfunctions import display_time, prepare_plot +import cmath as c +import scipy.integrate as integrate +from scipy.optimize import fminbound +from array import array as arr +import collections +from itertools import compress +import tensorflow as tf +import zfit +from zfit import ztf +# from IPython.display import clear_output +import os +import tensorflow_probability as tfp +tfd = tfp.distributions + + +# In[ ]: + + +# chunksize = 10000 +# zfit.run.chunking.active = True +# zfit.run.chunking.max_n_points = chunksize + + +# # Build model and graphs +# ## Create graphs + +# In[ ]: + + + + + +# In[ ]: + + +def formfactor(q2, subscript, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2): #returns real value + #check if subscript is viable + + if subscript != "0" and subscript != "+" and subscript != "T": + raise ValueError('Wrong subscript entered, choose either 0, + or T') + + #get constants + + mK = ztf.constant(pdg['Ks_M']) + mbstar0 = ztf.constant(pdg["mbstar0"]) + mbstar = ztf.constant(pdg["mbstar"]) + + + mmu = ztf.constant(pdg['muon_M']) + mb = ztf.constant(pdg['bquark_M']) + ms = ztf.constant(pdg['squark_M']) + mB = ztf.constant(pdg['Bplus_M']) + + #N comes from derivation in paper + + N = 3 + + #some helperfunctions + + tpos = (mB - mK)**2 + tzero = (mB + mK)*(ztf.sqrt(mB)-ztf.sqrt(mK))**2 + + z_oben = ztf.sqrt(tpos - q2) - ztf.sqrt(tpos - tzero) + z_unten = ztf.sqrt(tpos - q2) + ztf.sqrt(tpos - tzero) + z = tf.divide(z_oben, z_unten) + + #calculate f0 + + if subscript == "0": + prefactor = 1/(1 - q2/(mbstar0**2)) + _sum = 0 + b0 = [b0_0, b0_1, b0_2] + + for i in range(N): + _sum += b0[i]*(tf.pow(z,i)) + + return ztf.to_complex(prefactor * _sum) + + #calculate f+ or fT + + else: + prefactor = 1/(1 - q2/(mbstar**2)) + _sum = 0 + + if subscript == "T": + bT = [bT_0, bT_1, bT_2] + for i in range(N): + _sum += bT[i] * (tf.pow(z, i) - ((-1)**(i-N)) * (i/N) * tf.pow(z, N)) + else: + bplus = [bplus_0, bplus_1, bplus_2] + for i in range(N): + _sum += bplus[i] * (tf.pow(z, i) - ((-1)**(i-N)) * (i/N) * tf.pow(z, N)) + + return ztf.to_complex(prefactor * _sum) + +def resonance(q, _mass, width, phase, scale): + + q2 = tf.pow(q, 2) + + mmu = ztf.constant(pdg['muon_M']) + + p = 0.5 * ztf.sqrt(q2 - 4*(mmu**2)) + + p0 = 0.5 * ztf.sqrt(_mass**2 - 4*mmu**2) + + gamma_j = tf.divide(p, q) * _mass * width / p0 + + #Calculate the resonance + + _top = tf.complex(_mass * width, ztf.constant(0.0)) + + _bottom = tf.complex(_mass**2 - q2, -_mass*gamma_j) + + com = _top/_bottom + + #Rotate by the phase + + r = ztf.to_complex(scale*tf.abs(com)) + + _phase = tf.angle(com) + + _phase += phase + + com = r * tf.exp(tf.complex(ztf.constant(0.0), _phase)) + + return com + + +def axiv_nonres(q, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2): + + GF = ztf.constant(pdg['GF']) + alpha_ew = ztf.constant(pdg['alpha_ew']) + Vtb = ztf.constant(pdg['Vtb']) + Vts = ztf.constant(pdg['Vts']) + C10eff = ztf.constant(pdg['C10eff']) + + mmu = ztf.constant(pdg['muon_M']) + mb = ztf.constant(pdg['bquark_M']) + ms = ztf.constant(pdg['squark_M']) + mK = ztf.constant(pdg['Ks_M']) + mB = ztf.constant(pdg['Bplus_M']) + + q2 = tf.pow(q, 2) + + #Some helperfunctions + + beta = 1. - 4. * mmu**2. / q2 + + kabs = ztf.sqrt(mB**2. + tf.pow(q2, 2)/mB**2. + mK**4./mB**2. - 2. * (mB**2. * mK**2. + mK**2. * q2 + mB**2. * q2) / mB**2.) + + #prefactor in front of whole bracket + + prefactor1 = GF**2. *alpha_ew**2. * (tf.abs(Vtb*Vts))**2. * kabs * beta / (128. * np.pi**5.) + + #left term in bracket + + bracket_left = 2./3. * tf.pow(kabs,2) * tf.pow(beta,2) * tf.pow(tf.abs(ztf.to_complex(C10eff)*formfactor(q2, "+", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2)),2) + + #middle term in bracket + + _top = 4. * mmu**2. * (mB**2. - mK**2.) * (mB**2. - mK**2.) + + _under = q2 * mB**2. + + bracket_middle = _top/_under *tf.pow(tf.abs(ztf.to_complex(C10eff) * formfactor(q2, "0", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2)), 2) + + #Note sqrt(q2) comes from derivation as we use q2 and plot q + + return prefactor1 * (bracket_left + bracket_middle) * 2 * q + +def vec(q, funcs, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2): + + q2 = tf.pow(q, 2) + + GF = ztf.constant(pdg['GF']) + alpha_ew = ztf.constant(pdg['alpha_ew']) + Vtb = ztf.constant(pdg['Vtb']) + Vts = ztf.constant(pdg['Vts']) + C7eff = ztf.constant(pdg['C7eff']) + + mmu = ztf.constant(pdg['muon_M']) + mb = ztf.constant(pdg['bquark_M']) + ms = ztf.constant(pdg['squark_M']) + mK = ztf.constant(pdg['Ks_M']) + mB = ztf.constant(pdg['Bplus_M']) + + #Some helperfunctions + + beta = 1. - 4. * mmu**2. / q2 + + kabs = ztf.sqrt(mB**2. + tf.pow(q2, 2)/mB**2. + mK**4./mB**2. - 2 * (mB**2 * mK**2 + mK**2 * q2 + mB**2 * q2) / mB**2) + + #prefactor in front of whole bracket + + prefactor1 = GF**2. *alpha_ew**2. * (tf.abs(Vtb*Vts))**2 * kabs * beta / (128. * np.pi**5.) + + #right term in bracket + + prefactor2 = tf.pow(kabs,2) * (1. - 1./3. * beta) + + abs_bracket = tf.pow(tf.abs(c9eff(q, funcs) * formfactor(q2, "+", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + ztf.to_complex(2.0 * C7eff * (mb + ms)/(mB + mK)) * formfactor(q2, "T", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2)),2) + + bracket_right = prefactor2 * abs_bracket + + #Note sqrt(q2) comes from derivation as we use q2 and plot q + + return prefactor1 * bracket_right * 2 * q + +def c9eff(q, funcs): + + C9eff_nr = ztf.to_complex(ztf.constant(pdg['C9eff'])) + + c9 = C9eff_nr + funcs + + return c9 + + +# In[ ]: + + +def G(y): + + def inner_rect_bracket(q): + return tf.log(ztf.to_complex((1+tf.sqrt(q))/(1-tf.sqrt(q)))-tf.complex(ztf.constant(0), -1*ztf.constant(np.pi))) + + def inner_right(q): + return ztf.to_complex(2 * tf.atan(1/tf.sqrt(tf.math.real(-q)))) + + big_bracket = tf.where(tf.math.real(y) > ztf.constant(0.0), inner_rect_bracket(y), inner_right(y)) + + return ztf.to_complex(tf.sqrt(tf.abs(y))) * big_bracket + +def h_S(m, q): + + return ztf.to_complex(2) - G(ztf.to_complex(1) - ztf.to_complex(4*tf.pow(m, 2)) / ztf.to_complex(tf.pow(q, 2))) + +def h_P(m, q): + + return ztf.to_complex(2/3) + (ztf.to_complex(1) - ztf.to_complex(4*tf.pow(m, 2)) / ztf.to_complex(tf.pow(q, 2))) * h_S(m,q) + +def two_p_ccbar(mD, m_D_bar, m_D_star, q): + + + #Load constants + nu_D_bar = ztf.to_complex(pdg["nu_D_bar"]) + nu_D = ztf.to_complex(pdg["nu_D"]) + nu_D_star = ztf.to_complex(pdg["nu_D_star"]) + + phase_D_bar = ztf.to_complex(pdg["phase_D_bar"]) + phase_D = ztf.to_complex(pdg["phase_D"]) + phase_D_star = ztf.to_complex(pdg["phase_D_star"]) + + #Calculation + left_part = nu_D_bar * tf.exp(tf.complex(ztf.constant(0.0), phase_D_bar)) * h_S(m_D_bar, q) + + right_part_D = nu_D * tf.exp(tf.complex(ztf.constant(0.0), phase_D)) * h_P(m_D, q) + + right_part_D_star = nu_D_star * tf.exp(tf.complex(ztf.constant(0.0), phase_D_star)) * h_P(m_D_star, q) + + return left_part + right_part_D + right_part_D_star + + +# ## Build pdf + +# In[ ]: + + +class total_pdf_cut(zfit.pdf.ZPDF): + _N_OBS = 1 # dimension, can be omitted + _PARAMS = ['b0_0', 'b0_1', 'b0_2', + 'bplus_0', 'bplus_1', 'bplus_2', + 'bT_0', 'bT_1', 'bT_2', + 'rho_mass', 'rho_scale', 'rho_phase', 'rho_width', + 'jpsi_mass', 'jpsi_scale', 'jpsi_phase', 'jpsi_width', + 'psi2s_mass', 'psi2s_scale', 'psi2s_phase', 'psi2s_width', + 'p3770_mass', 'p3770_scale', 'p3770_phase', 'p3770_width', + 'p4040_mass', 'p4040_scale', 'p4040_phase', 'p4040_width', + 'p4160_mass', 'p4160_scale', 'p4160_phase', 'p4160_width', + 'p4415_mass', 'p4415_scale', 'p4415_phase', 'p4415_width', + 'omega_mass', 'omega_scale', 'omega_phase', 'omega_width', + 'phi_mass', 'phi_scale', 'phi_phase', 'phi_width', + 'Dbar_mass', 'Dbar_scale', 'Dbar_phase', + 'Dstar_mass', 'DDstar_scale', 'DDstar_phase', 'D_mass', + 'tau_mass', 'C_tt'] +# the name of the parameters + + def _unnormalized_pdf(self, x): + + x = x.unstack_x() + + b0 = [self.params['b0_0'], self.params['b0_1'], self.params['b0_2']] + bplus = [self.params['bplus_0'], self.params['bplus_1'], self.params['bplus_2']] + bT = [self.params['bT_0'], self.params['bT_1'], self.params['bT_2']] + + def rho_res(q): + return resonance(q, _mass = self.params['rho_mass'], scale = self.params['rho_scale'], + phase = self.params['rho_phase'], width = self.params['rho_width']) + + def omega_res(q): + return resonance(q, _mass = self.params['omega_mass'], scale = self.params['omega_scale'], + phase = self.params['omega_phase'], width = self.params['omega_width']) + + def phi_res(q): + return resonance(q, _mass = self.params['phi_mass'], scale = self.params['phi_scale'], + phase = self.params['phi_phase'], width = self.params['phi_width']) + + def jpsi_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['jpsi_mass'], 2)) * resonance(q, _mass = self.params['jpsi_mass'], + scale = self.params['jpsi_scale'], + phase = self.params['jpsi_phase'], + width = self.params['jpsi_width']) + def psi2s_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['psi2s_mass'], 2)) * resonance(q, _mass = self.params['psi2s_mass'], + scale = self.params['psi2s_scale'], + phase = self.params['psi2s_phase'], + width = self.params['psi2s_width']) + def p3770_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p3770_mass'], 2)) * resonance(q, _mass = self.params['p3770_mass'], + scale = self.params['p3770_scale'], + phase = self.params['p3770_phase'], + width = self.params['p3770_width']) + + def p4040_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4040_mass'], 2)) * resonance(q, _mass = self.params['p4040_mass'], + scale = self.params['p4040_scale'], + phase = self.params['p4040_phase'], + width = self.params['p4040_width']) + + def p4160_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4160_mass'], 2)) * resonance(q, _mass = self.params['p4160_mass'], + scale = self.params['p4160_scale'], + phase = self.params['p4160_phase'], + width = self.params['p4160_width']) + + def p4415_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4415_mass'], 2)) * resonance(q, _mass = self.params['p4415_mass'], + scale = self.params['p4415_scale'], + phase = self.params['p4415_phase'], + width = self.params['p4415_width']) + + def P2_D(q): + Dbar_contrib = ztf.to_complex(self.params['Dbar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['Dbar_phase']))*ztf.to_complex(h_S(self.params['Dbar_mass'], q)) + DDstar_contrib = ztf.to_complex(self.params['DDstar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['DDstar_phase']))*(ztf.to_complex(h_P(self.params['Dstar_mass'], q)) + ztf.to_complex(h_P(self.params['D_mass'], q))) + return Dbar_contrib + DDstar_contrib + + def ttau_cusp(q): + return ztf.to_complex(self.params['C_tt'])*(ztf.to_complex((h_S(self.params['tau_mass'], q))) - ztf.to_complex(h_P(self.params['tau_mass'], q))) + + + funcs = rho_res(x) + omega_res(x) + phi_res(x) + jpsi_res(x) + psi2s_res(x) + p3770_res(x) + p4040_res(x)+ p4160_res(x) + p4415_res(x) + P2_D(x) + ttau_cusp(x) + + vec_f = vec(x, funcs, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + axiv_nr = axiv_nonres(x, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + tot = vec_f + axiv_nr + + #Cut out jpsi and psi2s + + tot = tf.where(tf.math.logical_or(x < ztf.constant(jpsi_mass-60.), x > ztf.constant(jpsi_mass+70.)), tot, 0.0*tot) + + tot = tf.where(tf.math.logical_or(x < ztf.constant(psi2s_mass-50.), x > ztf.constant(psi2s_mass+50.)), tot, 0.0*tot) + + return tot + +class total_pdf_full(zfit.pdf.ZPDF): + _N_OBS = 1 # dimension, can be omitted + _PARAMS = ['b0_0', 'b0_1', 'b0_2', + 'bplus_0', 'bplus_1', 'bplus_2', + 'bT_0', 'bT_1', 'bT_2', + 'rho_mass', 'rho_scale', 'rho_phase', 'rho_width', + 'jpsi_mass', 'jpsi_scale', 'jpsi_phase', 'jpsi_width', + 'psi2s_mass', 'psi2s_scale', 'psi2s_phase', 'psi2s_width', + 'p3770_mass', 'p3770_scale', 'p3770_phase', 'p3770_width', + 'p4040_mass', 'p4040_scale', 'p4040_phase', 'p4040_width', + 'p4160_mass', 'p4160_scale', 'p4160_phase', 'p4160_width', + 'p4415_mass', 'p4415_scale', 'p4415_phase', 'p4415_width', + 'omega_mass', 'omega_scale', 'omega_phase', 'omega_width', + 'phi_mass', 'phi_scale', 'phi_phase', 'phi_width', + 'Dbar_mass', 'Dbar_scale', 'Dbar_phase', + 'Dstar_mass', 'DDstar_scale', 'DDstar_phase', 'D_mass', + 'tau_mass', 'C_tt'] +# the name of the parameters + + def _unnormalized_pdf(self, x): + + x = x.unstack_x() + + b0 = [self.params['b0_0'], self.params['b0_1'], self.params['b0_2']] + bplus = [self.params['bplus_0'], self.params['bplus_1'], self.params['bplus_2']] + bT = [self.params['bT_0'], self.params['bT_1'], self.params['bT_2']] + + def rho_res(q): + return resonance(q, _mass = self.params['rho_mass'], scale = self.params['rho_scale'], + phase = self.params['rho_phase'], width = self.params['rho_width']) + + def omega_res(q): + return resonance(q, _mass = self.params['omega_mass'], scale = self.params['omega_scale'], + phase = self.params['omega_phase'], width = self.params['omega_width']) + + def phi_res(q): + return resonance(q, _mass = self.params['phi_mass'], scale = self.params['phi_scale'], + phase = self.params['phi_phase'], width = self.params['phi_width']) + + def jpsi_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['jpsi_mass'], 2)) * resonance(q, _mass = self.params['jpsi_mass'], + scale = self.params['jpsi_scale'], + phase = self.params['jpsi_phase'], + width = self.params['jpsi_width']) + def psi2s_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['psi2s_mass'], 2)) * resonance(q, _mass = self.params['psi2s_mass'], + scale = self.params['psi2s_scale'], + phase = self.params['psi2s_phase'], + width = self.params['psi2s_width']) + def p3770_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p3770_mass'], 2)) * resonance(q, _mass = self.params['p3770_mass'], + scale = self.params['p3770_scale'], + phase = self.params['p3770_phase'], + width = self.params['p3770_width']) + + def p4040_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4040_mass'], 2)) * resonance(q, _mass = self.params['p4040_mass'], + scale = self.params['p4040_scale'], + phase = self.params['p4040_phase'], + width = self.params['p4040_width']) + + def p4160_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4160_mass'], 2)) * resonance(q, _mass = self.params['p4160_mass'], + scale = self.params['p4160_scale'], + phase = self.params['p4160_phase'], + width = self.params['p4160_width']) + + def p4415_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4415_mass'], 2)) * resonance(q, _mass = self.params['p4415_mass'], + scale = self.params['p4415_scale'], + phase = self.params['p4415_phase'], + width = self.params['p4415_width']) + + def P2_D(q): + Dbar_contrib = ztf.to_complex(self.params['Dbar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['Dbar_phase']))*ztf.to_complex(h_S(self.params['Dbar_mass'], q)) + DDstar_contrib = ztf.to_complex(self.params['DDstar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['DDstar_phase']))*(ztf.to_complex(h_P(self.params['Dstar_mass'], q)) + ztf.to_complex(h_P(self.params['D_mass'], q))) + return Dbar_contrib + DDstar_contrib + + def ttau_cusp(q): + return ztf.to_complex(self.params['C_tt'])*(ztf.to_complex((h_S(self.params['tau_mass'], q))) - ztf.to_complex(h_P(self.params['tau_mass'], q))) + + + funcs = rho_res(x) + omega_res(x) + phi_res(x) + jpsi_res(x) + psi2s_res(x) + p3770_res(x) + p4040_res(x)+ p4160_res(x) + p4415_res(x) + P2_D(x) + ttau_cusp(x) + + vec_f = vec(x, funcs, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + axiv_nr = axiv_nonres(x, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + tot = vec_f + axiv_nr + + #Cut out jpsi and psi2s + +# tot = tf.where(tf.math.logical_or(x < ztf.constant(jpsi_mass-60.), x > ztf.constant(jpsi_mass+70.)), tot, 0.0*tot) + +# tot = tf.where(tf.math.logical_or(x < ztf.constant(psi2s_mass-50.), x > ztf.constant(psi2s_mass+50.)), tot, 0.0*tot) + + return tot + + +# ## Setup parameters + +# In[ ]: + + +# formfactors + +b0_0 = zfit.Parameter("b0_0", ztf.constant(0.292), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +b0_1 = zfit.Parameter("b0_1", ztf.constant(0.281), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +b0_2 = zfit.Parameter("b0_2", ztf.constant(0.150), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) + +bplus_0 = zfit.Parameter("bplus_0", ztf.constant(0.466), lower_limit = -2.0, upper_limit= 2.0) +bplus_1 = zfit.Parameter("bplus_1", ztf.constant(-0.885), lower_limit = -2.0, upper_limit= 2.0) +bplus_2 = zfit.Parameter("bplus_2", ztf.constant(-0.213), lower_limit = -2.0, upper_limit= 2.0) + +bT_0 = zfit.Parameter("bT_0", ztf.constant(0.460), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +bT_1 = zfit.Parameter("bT_1", ztf.constant(-1.089), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +bT_2 = zfit.Parameter("bT_2", ztf.constant(-1.114), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) + + +#rho + +rho_mass, rho_width, rho_phase, rho_scale = pdg["rho"] + +rho_m = zfit.Parameter("rho_m", ztf.constant(rho_mass), floating = False) #lower_limit = rho_mass - rho_width, upper_limit = rho_mass + rho_width) +rho_w = zfit.Parameter("rho_w", ztf.constant(rho_width), floating = False) +rho_p = zfit.Parameter("rho_p", ztf.constant(rho_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +rho_s = zfit.Parameter("rho_s", ztf.constant(rho_scale), lower_limit=rho_scale-np.sqrt(rho_scale), upper_limit=rho_scale+np.sqrt(rho_scale)) + +#omega + +omega_mass, omega_width, omega_phase, omega_scale = pdg["omega"] + +omega_m = zfit.Parameter("omega_m", ztf.constant(omega_mass), floating = False) +omega_w = zfit.Parameter("omega_w", ztf.constant(omega_width), floating = False) +omega_p = zfit.Parameter("omega_p", ztf.constant(omega_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +omega_s = zfit.Parameter("omega_s", ztf.constant(omega_scale), lower_limit=omega_scale-np.sqrt(omega_scale), upper_limit=omega_scale+np.sqrt(omega_scale)) + + +#phi + +phi_mass, phi_width, phi_phase, phi_scale = pdg["phi"] + +phi_m = zfit.Parameter("phi_m", ztf.constant(phi_mass), floating = False) +phi_w = zfit.Parameter("phi_w", ztf.constant(phi_width), floating = False) +phi_p = zfit.Parameter("phi_p", ztf.constant(phi_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +phi_s = zfit.Parameter("phi_s", ztf.constant(phi_scale), lower_limit=phi_scale-np.sqrt(phi_scale), upper_limit=phi_scale+np.sqrt(phi_scale)) + +#jpsi + +jpsi_mass, jpsi_width, jpsi_phase, jpsi_scale = pdg["jpsi"] + +jpsi_m = zfit.Parameter("jpsi_m", ztf.constant(jpsi_mass), floating = False) +jpsi_w = zfit.Parameter("jpsi_w", ztf.constant(jpsi_width), floating = False) +jpsi_p = zfit.Parameter("jpsi_p", ztf.constant(jpsi_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +jpsi_s = zfit.Parameter("jpsi_s", ztf.constant(jpsi_scale), floating = False) #, lower_limit=jpsi_scale-np.sqrt(jpsi_scale), upper_limit=jpsi_scale+np.sqrt(jpsi_scale)) + +#psi2s + +psi2s_mass, psi2s_width, psi2s_phase, psi2s_scale = pdg["psi2s"] + +psi2s_m = zfit.Parameter("psi2s_m", ztf.constant(psi2s_mass), floating = False) +psi2s_w = zfit.Parameter("psi2s_w", ztf.constant(psi2s_width), floating = False) +psi2s_p = zfit.Parameter("psi2s_p", ztf.constant(psi2s_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +psi2s_s = zfit.Parameter("psi2s_s", ztf.constant(psi2s_scale), floating = False) #, lower_limit=psi2s_scale-np.sqrt(psi2s_scale), upper_limit=psi2s_scale+np.sqrt(psi2s_scale)) + +#psi(3770) + +p3770_mass, p3770_width, p3770_phase, p3770_scale = pdg["p3770"] + +p3770_m = zfit.Parameter("p3770_m", ztf.constant(p3770_mass), floating = False) +p3770_w = zfit.Parameter("p3770_w", ztf.constant(p3770_width), floating = False) +p3770_p = zfit.Parameter("p3770_p", ztf.constant(p3770_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p3770_s = zfit.Parameter("p3770_s", ztf.constant(p3770_scale), lower_limit=p3770_scale-np.sqrt(p3770_scale), upper_limit=p3770_scale+np.sqrt(p3770_scale)) + +#psi(4040) + +p4040_mass, p4040_width, p4040_phase, p4040_scale = pdg["p4040"] + +p4040_m = zfit.Parameter("p4040_m", ztf.constant(p4040_mass), floating = False) +p4040_w = zfit.Parameter("p4040_w", ztf.constant(p4040_width), floating = False) +p4040_p = zfit.Parameter("p4040_p", ztf.constant(p4040_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p4040_s = zfit.Parameter("p4040_s", ztf.constant(p4040_scale), lower_limit=p4040_scale-np.sqrt(p4040_scale), upper_limit=p4040_scale+np.sqrt(p4040_scale)) + +#psi(4160) + +p4160_mass, p4160_width, p4160_phase, p4160_scale = pdg["p4160"] + +p4160_m = zfit.Parameter("p4160_m", ztf.constant(p4160_mass), floating = False) +p4160_w = zfit.Parameter("p4160_w", ztf.constant(p4160_width), floating = False) +p4160_p = zfit.Parameter("p4160_p", ztf.constant(p4160_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p4160_s = zfit.Parameter("p4160_s", ztf.constant(p4160_scale), lower_limit=p4160_scale-np.sqrt(p4160_scale), upper_limit=p4160_scale+np.sqrt(p4160_scale)) + +#psi(4415) + +p4415_mass, p4415_width, p4415_phase, p4415_scale = pdg["p4415"] + +p4415_m = zfit.Parameter("p4415_m", ztf.constant(p4415_mass), floating = False) +p4415_w = zfit.Parameter("p4415_w", ztf.constant(p4415_width), floating = False) +p4415_p = zfit.Parameter("p4415_p", ztf.constant(p4415_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p4415_s = zfit.Parameter("p4415_s", ztf.constant(p4415_scale), lower_limit=p4415_scale-np.sqrt(p4415_scale), upper_limit=p4415_scale+np.sqrt(p4415_scale)) + + +# ## Dynamic generation of 2 particle contribution + +# In[ ]: + + +m_c = 1300 + +Dbar_phase = 0.0 +DDstar_phase = 0.0 +Dstar_mass = pdg['Dst_M'] +Dbar_mass = pdg['D0_M'] +D_mass = pdg['D0_M'] + +Dbar_s = zfit.Parameter("Dbar_s", ztf.constant(0.0), lower_limit=-0.3, upper_limit=0.3) +Dbar_m = zfit.Parameter("Dbar_m", ztf.constant(Dbar_mass), floating = False) +Dbar_p = zfit.Parameter("Dbar_p", ztf.constant(Dbar_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi)#, floating = False) +DDstar_s = zfit.Parameter("DDstar_s", ztf.constant(0.0), lower_limit=-0.3, upper_limit=0.3)#, floating = False) +Dstar_m = zfit.Parameter("Dstar_m", ztf.constant(Dstar_mass), floating = False) +D_m = zfit.Parameter("D_m", ztf.constant(D_mass), floating = False) +DDstar_p = zfit.Parameter("DDstar_p", ztf.constant(DDstar_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi)#, floating = False) + + +# ## Tau parameters + +# In[ ]: + + +tau_m = zfit.Parameter("tau_m", ztf.constant(pdg['tau_M']), floating = False) +Ctt = zfit.Parameter("Ctt", ztf.constant(0.0), lower_limit=-2.5, upper_limit=2.5) + + +# ## Load data + +# In[ ]: + + +x_min = 2*pdg['muon_M'] +x_max = (pdg["Bplus_M"]-pdg["Ks_M"]-0.1) + +# # Full spectrum + +obs_toy = zfit.Space('q', limits = (x_min, x_max)) + +# Jpsi and Psi2s cut out + +obs1 = zfit.Space('q', limits = (x_min, jpsi_mass - 60.)) +obs2 = zfit.Space('q', limits = (jpsi_mass + 70., psi2s_mass - 50.)) +obs3 = zfit.Space('q', limits = (psi2s_mass + 50., x_max)) + +obs_fit = obs1 + obs2 + obs3 + +# with open(r"./data/slim_points/slim_points_toy_0_range({0}-{1}).pkl".format(int(x_min), int(x_max)), "rb") as input_file: +# part_set = pkl.load(input_file) + +# x_part = part_set['x_part'] + +# x_part = x_part.astype('float64') + +# data = zfit.data.Data.from_numpy(array=x_part, obs=obs) + + +# ## Setup pdf + +# In[ ]: + + +total_f = total_pdf_cut(obs=obs_toy, jpsi_mass = jpsi_m, jpsi_scale = jpsi_s, jpsi_phase = jpsi_p, jpsi_width = jpsi_w, + psi2s_mass = psi2s_m, psi2s_scale = psi2s_s, psi2s_phase = psi2s_p, psi2s_width = psi2s_w, + p3770_mass = p3770_m, p3770_scale = p3770_s, p3770_phase = p3770_p, p3770_width = p3770_w, + p4040_mass = p4040_m, p4040_scale = p4040_s, p4040_phase = p4040_p, p4040_width = p4040_w, + p4160_mass = p4160_m, p4160_scale = p4160_s, p4160_phase = p4160_p, p4160_width = p4160_w, + p4415_mass = p4415_m, p4415_scale = p4415_s, p4415_phase = p4415_p, p4415_width = p4415_w, + rho_mass = rho_m, rho_scale = rho_s, rho_phase = rho_p, rho_width = rho_w, + omega_mass = omega_m, omega_scale = omega_s, omega_phase = omega_p, omega_width = omega_w, + phi_mass = phi_m, phi_scale = phi_s, phi_phase = phi_p, phi_width = phi_w, + Dstar_mass = Dstar_m, DDstar_scale = DDstar_s, DDstar_phase = DDstar_p, D_mass = D_m, + Dbar_mass = Dbar_m, Dbar_scale = Dbar_s, Dbar_phase = Dbar_p, + tau_mass = tau_m, C_tt = Ctt, b0_0 = b0_0, b0_1 = b0_1, b0_2 = b0_2, + bplus_0 = bplus_0, bplus_1 = bplus_1, bplus_2 = bplus_2, + bT_0 = bT_0, bT_1 = bT_1, bT_2 = bT_2) + +total_f_fit = total_pdf_full(obs=obs_fit, jpsi_mass = jpsi_m, jpsi_scale = jpsi_s, jpsi_phase = jpsi_p, jpsi_width = jpsi_w, + psi2s_mass = psi2s_m, psi2s_scale = psi2s_s, psi2s_phase = psi2s_p, psi2s_width = psi2s_w, + p3770_mass = p3770_m, p3770_scale = p3770_s, p3770_phase = p3770_p, p3770_width = p3770_w, + p4040_mass = p4040_m, p4040_scale = p4040_s, p4040_phase = p4040_p, p4040_width = p4040_w, + p4160_mass = p4160_m, p4160_scale = p4160_s, p4160_phase = p4160_p, p4160_width = p4160_w, + p4415_mass = p4415_m, p4415_scale = p4415_s, p4415_phase = p4415_p, p4415_width = p4415_w, + rho_mass = rho_m, rho_scale = rho_s, rho_phase = rho_p, rho_width = rho_w, + omega_mass = omega_m, omega_scale = omega_s, omega_phase = omega_p, omega_width = omega_w, + phi_mass = phi_m, phi_scale = phi_s, phi_phase = phi_p, phi_width = phi_w, + Dstar_mass = Dstar_m, DDstar_scale = DDstar_s, DDstar_phase = DDstar_p, D_mass = D_m, + Dbar_mass = Dbar_m, Dbar_scale = Dbar_s, Dbar_phase = Dbar_p, + tau_mass = tau_m, C_tt = Ctt, b0_0 = b0_0, b0_1 = b0_1, b0_2 = b0_2, + bplus_0 = bplus_0, bplus_1 = bplus_1, bplus_2 = bplus_2, + bT_0 = bT_0, bT_1 = bT_1, bT_2 = bT_2) + +# print(total_pdf.obs) + +# print(calcs_test) + +# for param in total_f.get_dependents(): +# print(zfit.run(param)) + + +# In[ ]: + + +# total_f_fit.normalization(obs_fit) + + +# ## Test if graphs actually work and compute values + +# In[ ]: + + +# def total_test_tf(xq): + +# def jpsi_res(q): +# return resonance(q, jpsi_m, jpsi_s, jpsi_p, jpsi_w) + +# def psi2s_res(q): +# return resonance(q, psi2s_m, psi2s_s, psi2s_p, psi2s_w) + +# def cusp(q): +# return bifur_gauss(q, cusp_m, sig_L, sig_R, cusp_s) + +# funcs = jpsi_res(xq) + psi2s_res(xq) + cusp(xq) + +# vec_f = vec(xq, funcs) + +# axiv_nr = axiv_nonres(xq) + +# tot = vec_f + axiv_nr + +# return tot + +# def jpsi_res(q): +# return resonance(q, jpsi_m, jpsi_s, jpsi_p, jpsi_w) + +# calcs = zfit.run(total_test_tf(x_part)) + + + +test_q = np.linspace(x_min, x_max, int(2e6)) + +probs = total_f_fit.pdf(test_q, norm_range=False) + +calcs_test = zfit.run(probs) + +Ctt.set_value(0.5) + +calcs_test1 = zfit.run(probs) + +Ctt.set_value(0.0) + +Dbar_s.set_value(0.3) + +DDstar_s.set_value(0.3) + +calcs_test2 = zfit.run(probs) +# res_y = zfit.run(jpsi_res(test_q)) +# b0 = [b0_0, b0_1, b0_2] +# bplus = [bplus_0, bplus_1, bplus_2] +# bT = [bT_0, bT_1, bT_2] +# f0_y = zfit.run(tf.math.real(formfactor(test_q,"0", b0, bplus, bT))) +# fplus_y = zfit.run(tf.math.real(formfactor(test_q,"+", b0, bplus, bT))) +# fT_y = zfit.run(tf.math.real(formfactor(test_q,"T", b0, bplus, bT))) + + +# In[ ]: + + +plt.clf() +# plt.plot(x_part, calcs, '.') +plt.plot(test_q, calcs_test, label = 'pdf (Ctt = 0.0)') +plt.plot(test_q, calcs_test1, label = 'pdf (Ctt = 0.5)') +plt.plot(test_q, calcs_test2, label = 'pdf (D-contribs = 0.3)') +# plt.plot(test_q, f0_y, label = '0') +# plt.plot(test_q, fT_y, label = 'T') +# plt.plot(test_q, fplus_y, label = '+') +# plt.plot(test_q, res_y, label = 'res') +plt.legend() +plt.ylim(0.0, 1.5e-6) +# plt.yscale('log') +# plt.xlim(770, 785) +plt.savefig('test.png') +# print(jpsi_width) + + +# In[ ]: + + + + +# probs = mixture.prob(test_q) +# probs_np = zfit.run(probs) +# probs_np *= np.max(calcs_test) / np.max(probs_np) +# plt.figure() +# plt.semilogy(test_q, probs_np,label="importance sampling") +# plt.semilogy(test_q, calcs_test, label = 'pdf') + + +# In[ ]: + + +# 0.213/(0.00133+0.213+0.015) + + +# ## Adjust scaling of different parts + +# In[ ]: + + +total_f.update_integration_options(draws_per_dim=2000000, mc_sampler=None) +# inte = total_f.integrate(limits = (950., 1050.), norm_range=False) +# inte_fl = zfit.run(inte) +# print(inte_fl/4500) +# print(pdg["jpsi_BR"]/pdg["NR_BR"], inte_fl*pdg["psi2s_auc"]/pdg["NR_auc"]) + + +# In[ ]: + + +# # print("jpsi:", inte_fl) +# # print("Increase am by factor:", np.sqrt(pdg["jpsi_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) +# # print("New amp:", pdg["jpsi"][3]*np.sqrt(pdg["jpsi_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) + +# # print("psi2s:", inte_fl) +# # print("Increase am by factor:", np.sqrt(pdg["psi2s_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) +# # print("New amp:", pdg["psi2s"][3]*np.sqrt(pdg["psi2s_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) + +# name = "phi" + +# print(name+":", inte_fl) +# print("Increase am by factor:", np.sqrt(pdg[name+"_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) +# print("New amp:", pdg[name][0]*np.sqrt(pdg[name+"_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) + + +# print(x_min) +# print(x_max) +# # total_f.update_integration_options(draws_per_dim=2000000, mc_sampler=None) +# total_f.update_integration_options(mc_sampler=lambda dim, num_results, +# dtype: tf.random_uniform(maxval=1., shape=(num_results, dim), dtype=dtype), +# draws_per_dim=1000000) +# # _ = [] + +# # for i in range(10): + +# # inte = total_f.integrate(limits = (x_min, x_max)) +# # inte_fl = zfit.run(inte) +# # print(inte_fl) +# # _.append(inte_fl) + +# # print("mean:", np.mean(_)) + +# _ = time.time() + +# inte = total_f.integrate(limits = (x_min, x_max)) +# inte_fl = zfit.run(inte) +# print(inte_fl) +# print("Time taken: {}".format(display_time(int(time.time() - _)))) + +# print(pdg['NR_BR']/pdg['NR_auc']*inte_fl) +# print(0.25**2*4.2/1000) + + +# # Sampling +# ## Mixture distribution for sampling + +# In[ ]: + + + + +# print(list_of_borders[:9]) +# print(list_of_borders[-9:]) + + +class UniformSampleAndWeights(zfit.util.execution.SessionHolderMixin): + def __call__(self, limits, dtype, n_to_produce): + # n_to_produce = tf.cast(n_to_produce, dtype=tf.int32) + low, high = limits.limit1d + low = tf.cast(low, dtype=dtype) + high = tf.cast(high, dtype=dtype) +# uniform = tfd.Uniform(low=low, high=high) +# uniformjpsi = tfd.Uniform(low=tf.constant(3080, dtype=dtype), high=tf.constant(3112, dtype=dtype)) +# uniformpsi2s = tfd.Uniform(low=tf.constant(3670, dtype=dtype), high=tf.constant(3702, dtype=dtype)) + +# list_of_borders = [] +# _p = [] +# splits = 10 + +# _ = np.linspace(x_min, x_max, splits) + +# for i in range(splits): +# list_of_borders.append(tf.constant(_[i], dtype=dtype)) +# _p.append(tf.constant(1/splits, dtype=dtype)) + +# mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=_p[:(splits-1)]), +# components_distribution=tfd.Uniform(low=list_of_borders[:(splits-1)], +# high=list_of_borders[-(splits-1):])) + mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=[tf.constant(0.05, dtype=dtype), + tf.constant(0.93, dtype=dtype), + tf.constant(0.05, dtype=dtype), + tf.constant(0.065, dtype=dtype), + tf.constant(0.04, dtype=dtype), + tf.constant(0.05, dtype=dtype)]), + components_distribution=tfd.Uniform(low=[tf.constant(x_min, dtype=dtype), + tf.constant(3090, dtype=dtype), + tf.constant(3681, dtype=dtype), + tf.constant(3070, dtype=dtype), + tf.constant(1000, dtype=dtype), + tf.constant(3660, dtype=dtype)], + high=[tf.constant(x_max, dtype=dtype), + tf.constant(3102, dtype=dtype), + tf.constant(3691, dtype=dtype), + tf.constant(3110, dtype=dtype), + tf.constant(1040, dtype=dtype), + tf.constant(3710, dtype=dtype)])) +# dtype = tf.float64 +# mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=[tf.constant(0.04, dtype=dtype), +# tf.constant(0.90, dtype=dtype), +# tf.constant(0.02, dtype=dtype), +# tf.constant(0.07, dtype=dtype), +# tf.constant(0.02, dtype=dtype)]), +# components_distribution=tfd.Uniform(low=[tf.constant(x_min, dtype=dtype), +# tf.constant(3089, dtype=dtype), +# tf.constant(3103, dtype=dtype), +# tf.constant(3681, dtype=dtype), +# tf.constant(3691, dtype=dtype)], +# high=[tf.constant(3089, dtype=dtype), +# tf.constant(3103, dtype=dtype), +# tf.constant(3681, dtype=dtype), +# tf.constant(3691, dtype=dtype), +# tf.constant(x_max, dtype=dtype)])) +# mixture = tfd.Uniform(tf.constant(x_min, dtype=dtype), tf.constant(x_max, dtype=dtype)) +# sample = tf.random.uniform((n_to_produce, 1), dtype=dtype) + sample = mixture.sample((n_to_produce, 1)) +# sample = tf.random.uniform((n_to_produce, 1), dtype=dtype) + weights = mixture.prob(sample)[:,0] +# weights = tf.broadcast_to(tf.constant(1., dtype=dtype), shape=(n_to_produce,)) + # sample = tf.expand_dims(sample, axis=-1) +# print(sample, weights) + +# weights = tf.ones(shape=(n_to_produce,), dtype=dtype) + weights_max = None + thresholds = tf.random_uniform(shape=(n_to_produce,), dtype=dtype) + return sample, thresholds, weights, weights_max, n_to_produce + + +# In[ ]: + + +# total_f._sample_and_weights = UniformSampleAndWeights + + +# In[ ]: + + +# 0.00133/(0.00133+0.213+0.015)*(x_max-3750)/(x_max-x_min) + + +# In[ ]: + + +# zfit.settings.set_verbosity(10) + + +# In[ ]: + + +# # zfit.run.numeric_checks = False + +# nr_of_toys = 1 +# nevents = int(pdg["number_of_decays"]) +# nevents = pdg["number_of_decays"] +# event_stack = 1000000 +# # zfit.settings.set_verbosity(10) +# calls = int(nevents/event_stack + 1) + +# total_samp = [] + +# start = time.time() + +# sampler = total_f.create_sampler(n=event_stack) + +# for toy in range(nr_of_toys): + +# dirName = 'data/zfit_toys/toy_{0}'.format(toy) + +# if not os.path.exists(dirName): +# os.mkdir(dirName) +# print("Directory " , dirName , " Created ") + +# for call in range(calls): + +# sampler.resample(n=event_stack) +# s = sampler.unstack_x() +# sam = zfit.run(s) +# # clear_output(wait=True) + +# c = call + 1 + +# print("{0}/{1} of Toy {2}/{3}".format(c, calls, toy+1, nr_of_toys)) +# print("Time taken: {}".format(display_time(int(time.time() - start)))) +# print("Projected time left: {}".format(display_time(int((time.time() - start)/(c+calls*(toy))*((nr_of_toys-toy)*calls-c))))) + +# with open("data/zfit_toys/toy_{0}/{1}.pkl".format(toy, call), "wb") as f: +# pkl.dump(sam, f, pkl.HIGHEST_PROTOCOL) + + +# In[ ]: + + +# with open(r"data/zfit_toys/toy_0/0.pkl", "rb") as input_file: +# sam = pkl.load(input_file) +# print(sam[:10]) + +# with open(r"data/zfit_toys/toy_0/1.pkl", "rb") as input_file: +# sam2 = pkl.load(input_file) +# print(sam2[:10]) + +# print(np.sum(sam-sam2)) + + +# In[ ]: + + +# print("Time to generate full toy: {} s".format(int(time.time()-start))) + +# total_samp = [] + +# for call in range(calls): +# with open(r"data/zfit_toys/toy_0/{}.pkl".format(call), "rb") as input_file: +# sam = pkl.load(input_file) +# total_samp = np.append(total_samp, sam) + +# total_samp = total_samp.astype('float64') + +# data2 = zfit.data.Data.from_numpy(array=total_samp[:int(nevents)], obs=obs) + +# data3 = zfit.data.Data.from_numpy(array=total_samp, obs=obs) + +# print(total_samp[:nevents].shape) + + +# In[ ]: + + +# plt.clf() + +# bins = int((x_max-x_min)/7) + +# # calcs = zfit.run(total_test_tf(samp)) +# print(total_samp[:nevents].shape) + +# plt.hist(total_samp[:nevents], bins = bins, range = (x_min,x_max), label = 'data') +# # plt.plot(test_q, calcs_test*nevents , label = 'pdf') + +# # plt.plot(sam, calcs, '.') +# # plt.plot(test_q, calcs_test) +# # plt.yscale('log') +# plt.ylim(0, 200) +# # plt.xlim(3080, 3110) + +# plt.legend() + +# plt.savefig('test2.png') + + +# In[ ]: + + +# sampler = total_f.create_sampler(n=nevents) +# nll = zfit.loss.UnbinnedNLL(model=total_f, data=sampler, fit_range = (x_min, x_max)) + +# # for param in pdf.get_dependents(): +# # param.set_value(initial_value) + +# sampler.resample(n=nevents) + +# # Randomise initial values +# # for param in pdf.get_dependents(): +# # param.set_value(random value here) + +# # Minimise the NLL +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 10) +# minimum = minimizer.minimize(nll) + + +# In[ ]: + + +# jpsi_width + + +# In[ ]: + + +# plt.hist(sample, weights=1 / prob(sample)) + + +# # Fitting + +# In[ ]: + + +# start = time.time() + +# for param in total_f.get_dependents(): +# param.randomize() + +# # for param in total_f.get_dependents(): +# # print(zfit.run(param)) + +# nll = zfit.loss.UnbinnedNLL(model=total_f, data=data2, fit_range = (x_min, x_max)) + +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) +# # minimizer._use_tfgrad = False +# result = minimizer.minimize(nll) + +# # param_errors = result.error() + +# # for var, errors in param_errors.items(): +# # print('{}: ^{{+{}}}_{{{}}}'.format(var.name, errors['upper'], errors['lower'])) + +# print("Function minimum:", result.fmin) +# # print("Results:", result.params) +# print("Hesse errors:", result.hesse()) + + +# In[ ]: + + +# print("Time taken for fitting: {}".format(display_time(int(time.time()-start)))) + +# # probs = total_f.pdf(test_q) + +# calcs_test = zfit.run(probs) +# res_y = zfit.run(jpsi_res(test_q)) + + +# In[ ]: + + +# plt.clf() +# # plt.plot(x_part, calcs, '.') +# plt.plot(test_q, calcs_test, label = 'pdf') +# # plt.plot(test_q, res_y, label = 'res') +# plt.legend() +# plt.ylim(0.0, 10e-6) +# # plt.yscale('log') +# # plt.xlim(3080, 3110) +# plt.savefig('test3.png') +# # print(jpsi_width) + + +# In[ ]: + + +# _tot = 4.37e-7+6.02e-5+4.97e-6 +# _probs = [] +# _probs.append(6.02e-5/_tot) +# _probs.append(4.97e-6/_tot) +# _probs.append(4.37e-7/_tot) +# print(_probs) + + +# In[ ]: + + +# dtype = 'float64' +# # mixture = tfd.Uniform(tf.constant(x_min, dtype=dtype), tf.constant(x_max, dtype=dtype)) +# mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=[tf.constant(0.007, dtype=dtype), +# tf.constant(0.917, dtype=dtype), +# tf.constant(0.076, dtype=dtype)]), +# components_distribution=tfd.Uniform(low=[tf.constant(x_min, dtype=dtype), +# tf.constant(3080, dtype=dtype), +# tf.constant(3670, dtype=dtype)], +# high=[tf.constant(x_max, dtype=dtype), +# tf.constant(3112, dtype=dtype), +# tf.constant(3702, dtype=dtype)])) +# # for i in range(10): +# # print(zfit.run(mixture.prob(mixture.sample((10, 1))))) + + +# In[ ]: + + +# print((zfit.run(jpsi_p)%(2*np.pi))/np.pi) +# print((zfit.run(psi2s_p)%(2*np.pi))/np.pi) + + +# In[ ]: + + +# def jpsi_res(q): +# return resonance(q, _mass = jpsi_mass, scale = jpsi_scale, +# phase = jpsi_phase, width = jpsi_width) + +# def psi2s_res(q): +# return resonance(q, _mass = psi2s_mass, scale = psi2s_scale, +# phase = psi2s_phase, width = psi2s_width) + +# def p3770_res(q): +# return resonance(q, _mass = p3770_mass, scale = p3770_scale, +# phase = p3770_phase, width = p3770_width) + +# def p4040_res(q): +# return resonance(q, _mass = p4040_mass, scale = p4040_scale, +# phase = p4040_phase, width = p4040_width) + +# def p4160_res(q): +# return resonance(q, _mass = p4160_mass, scale = p4160_scale, +# phase = p4160_phase, width = p4160_width) + +# def p4415_res(q): +# return resonance(q, _mass = p4415_mass, scale = p4415_scale, +# phase = p4415_phase, width = p4415_width) + + +# In[ ]: + + +# 0.15**2*4.2/1000 +# result.hesse() + + +# ## Constraints + +# In[ ]: + + +# 1. Constraint - Real part of sum of Psi contrib and D contribs + +sum_list = [] + +sum_list.append(ztf.to_complex(jpsi_s) * tf.exp(tf.complex(ztf.constant(0.0), jpsi_p)) * ztf.to_complex(jpsi_w / (tf.pow(jpsi_m,3)))) +sum_list.append(ztf.to_complex(psi2s_s) * tf.exp(tf.complex(ztf.constant(0.0), psi2s_p)) * ztf.to_complex(psi2s_w / (tf.pow(psi2s_m,3)))) +sum_list.append(ztf.to_complex(p3770_s) * tf.exp(tf.complex(ztf.constant(0.0), p3770_p)) * ztf.to_complex(p3770_w / (tf.pow(p3770_m,3)))) +sum_list.append(ztf.to_complex(p4040_s) * tf.exp(tf.complex(ztf.constant(0.0), p4040_p)) * ztf.to_complex(p4040_w / (tf.pow(p4040_m,3)))) +sum_list.append(ztf.to_complex(p4160_s) * tf.exp(tf.complex(ztf.constant(0.0), p4160_p)) * ztf.to_complex(p4160_w / (tf.pow(p4160_m,3)))) +sum_list.append(ztf.to_complex(p4415_s) * tf.exp(tf.complex(ztf.constant(0.0), p4415_p)) * ztf.to_complex(p4415_w / (tf.pow(p4415_m,3)))) +sum_list.append(ztf.to_complex(DDstar_s) * tf.exp(tf.complex(ztf.constant(0.0), DDstar_p)) * (ztf.to_complex(1.0 / (10.0*tf.pow(Dstar_m,2)) + 1.0 / (10.0*tf.pow(D_m,2))))) +sum_list.append(ztf.to_complex(Dbar_s) * tf.exp(tf.complex(ztf.constant(0.0), Dbar_p)) * ztf.to_complex(1.0 / (6.0*tf.pow(Dbar_m,2)))) + +sum_ru_1 = ztf.to_complex(ztf.constant(0.0)) + +for part in sum_list: + sum_ru_1 += part + +sum_1 = tf.math.real(sum_ru_1) +# constraint1 = zfit.constraint.GaussianConstraint(params = sum_1, mu = ztf.constant(1.7*10**-8), +# sigma = ztf.constant(2.2*10**-8)) + +constraint1 = tf.pow((sum_1-ztf.constant(1.7*10**-8))/ztf.constant(2.2*10**-8),2)/ztf.constant(2.) + +# 2. Constraint - Abs. of sum of Psi contribs and D contribs + +sum_2 = tf.abs(sum_ru_1) +constraint2 = tf.cond(tf.greater_equal(sum_2, 5.0e-8), lambda: 100000., lambda: 0.) + +# 3. Constraint - Maximum eta of D contribs + +constraint3_0 = tf.cond(tf.greater_equal(tf.abs(Dbar_s), 0.2), lambda: 100000., lambda: 0.) + +constraint3_1 = tf.cond(tf.greater_equal(tf.abs(DDstar_s), 0.2), lambda: 100000., lambda: 0.) + +# 4. Constraint - Formfactor multivariant gaussian covariance fplus + +Cov_matrix = [[ztf.constant( 1.), ztf.constant( 0.45), ztf.constant( 0.19), ztf.constant(0.857), ztf.constant(0.598), ztf.constant(0.531), ztf.constant(0.752), ztf.constant(0.229), ztf.constant(0,117)], + [ztf.constant( 0.45), ztf.constant( 1.), ztf.constant(0.677), ztf.constant(0.708), ztf.constant(0.958), ztf.constant(0.927), ztf.constant(0.227), ztf.constant(0.443), ztf.constant(0.287)], + [ztf.constant( 0.19), ztf.constant(0.677), ztf.constant( 1.), ztf.constant(0.595), ztf.constant(0.770), ztf.constant(0.819),ztf.constant(-0.023), ztf.constant( 0.07), ztf.constant(0.196)], + [ztf.constant(0.857), ztf.constant(0.708), ztf.constant(0.595), ztf.constant( 1.), ztf.constant( 0.83), ztf.constant(0.766), ztf.constant(0.582), ztf.constant(0.237), ztf.constant(0.192)], + [ztf.constant(0.598), ztf.constant(0.958), ztf.constant(0.770), ztf.constant( 0.83), ztf.constant( 1.), ztf.constant(0.973), ztf.constant(0.324), ztf.constant(0.372), ztf.constant(0.272)], + [ztf.constant(0.531), ztf.constant(0.927), ztf.constant(0.819), ztf.constant(0.766), ztf.constant(0.973), ztf.constant( 1.), ztf.constant(0.268), ztf.constant(0.332), ztf.constant(0.269)], + [ztf.constant(0.752), ztf.constant(0.227),ztf.constant(-0.023), ztf.constant(0.582), ztf.constant(0.324), ztf.constant(0.268), ztf.constant( 1.), ztf.constant( 0.59), ztf.constant(0.515)], + [ztf.constant(0.229), ztf.constant(0.443), ztf.constant( 0.07), ztf.constant(0.237), ztf.constant(0.372), ztf.constant(0.332), ztf.constant( 0.59), ztf.constant( 1.), ztf.constant(0.897)], + [ztf.constant(0.117), ztf.constant(0.287), ztf.constant(0.196), ztf.constant(0.192), ztf.constant(0.272), ztf.constant(0.269), ztf.constant(0.515), ztf.constant(0.897), ztf.constant( 1.)]] + +def triGauss(val1,val2,val3,m = Cov_matrix): + + mean1 = ztf.constant(0.466) + mean2 = ztf.constant(-0.885) + mean3 = ztf.constant(-0.213) + sigma1 = ztf.constant(0.014) + sigma2 = ztf.constant(0.128) + sigma3 = ztf.constant(0.548) + x1 = (val1-mean1)/sigma1 + x2 = (val2-mean2)/sigma2 + x3 = (val3-mean3)/sigma3 + rho12 = m[0][1] + rho13 = m[0][2] + rho23 = m[1][2] + w = x1*x1*(rho23*rho23-1) + x2*x2*(rho13*rho13-1)+x3*x3*(rho12*rho12-1)+2*(x1*x2*(rho12-rho13*rho23)+x1*x3*(rho13-rho12*rho23)+x2*x3*(rho23-rho12*rho13)) + d = 2*(rho12*rho12+rho13*rho13+rho23*rho23-2*rho12*rho13*rho23-1) + + fcn = -w/d + chisq = -2*fcn + return chisq + +constraint4 = triGauss(bplus_0, bplus_1, bplus_2) + +# mean1 = ztf.constant(0.466) +# mean2 = ztf.constant(-0.885) +# mean3 = ztf.constant(-0.213) +# sigma1 = ztf.constant(0.014) +# sigma2 = ztf.constant(0.128) +# sigma3 = ztf.constant(0.548) +# constraint4_0 = tf.pow((bplus_0-mean1)/sigma1,2)/ztf.constant(2.) +# constraint4_1 = tf.pow((bplus_1-mean2)/sigma2,2)/ztf.constant(2.) +# constraint4_2 = tf.pow((bplus_2-mean3)/sigma3,2)/ztf.constant(2.) + +# 5. Constraint - Abs. of sum of light contribs + +sum_list_5 = [] + +sum_list_5.append(rho_s*rho_w/rho_m) +sum_list_5.append(omega_s*omega_w/omega_m) +sum_list_5.append(phi_s*phi_w/phi_m) + + +sum_ru_5 = ztf.constant(0.0) + +for part in sum_list_5: + sum_ru_5 += part + +constraint5 = tf.cond(tf.greater_equal(tf.abs(sum_ru_5), ztf.constant(0.02)), lambda: 100000., lambda: 0.) + +# 6. Constraint on phases of Jpsi and Psi2s for cut out fit + + +# constraint6_0 = zfit.constraint.GaussianConstraint(params = jpsi_p, mu = ztf.constant(pdg["jpsi_phase_unc"]), +# sigma = ztf.constant(jpsi_phase)) +# constraint6_1 = zfit.constraint.GaussianConstraint(params = psi2s_p, mu = ztf.constant(pdg["psi2s_phase_unc"]), +# sigma = ztf.constant(psi2s_phase)) + +constraint6_0 = tf.pow((jpsi_p-ztf.constant(jpsi_phase))/ztf.constant(pdg["jpsi_phase_unc"]),2)/ztf.constant(2.) +constraint6_1 = tf.pow((psi2s_p-ztf.constant(psi2s_phase))/ztf.constant(pdg["psi2s_phase_unc"]),2)/ztf.constant(2.) + +# 7. Constraint on Ctt with higher limits + +constraint7 = tf.cond(tf.greater_equal(Ctt*Ctt, 0.25), lambda: 100000., lambda: 0.) + +constraint7dtype = tf.float64 + +# zfit.run(constraint6_0) + +# ztf.convert_to_tensor(constraint6_0) + +#List of all constraints + +constraints = [constraint1, constraint2, constraint3_0, constraint3_1,# constraint4, #constraint4_0, constraint4_1, constraint4_2, + constraint6_0, constraint6_1]#, constraint7] + + +# ## Reset params + +# In[ ]: + + +param_values_dic = { + 'jpsi_m': jpsi_mass, + 'jpsi_s': jpsi_scale, + 'jpsi_p': jpsi_phase, + 'jpsi_w': jpsi_width, + 'psi2s_m': psi2s_mass, + 'psi2s_s': psi2s_scale, + 'psi2s_p': psi2s_phase, + 'psi2s_w': psi2s_width, + 'p3770_m': p3770_mass, + 'p3770_s': p3770_scale, + 'p3770_p': p3770_phase, + 'p3770_w': p3770_width, + 'p4040_m': p4040_mass, + 'p4040_s': p4040_scale, + 'p4040_p': p4040_phase, + 'p4040_w': p4040_width, + 'p4160_m': p4160_mass, + 'p4160_s': p4160_scale, + 'p4160_p': p4160_phase, + 'p4160_w': p4160_width, + 'p4415_m': p4415_mass, + 'p4415_s': p4415_scale, + 'p4415_p': p4415_phase, + 'p4415_w': p4415_width, + 'rho_m': rho_mass, + 'rho_s': rho_scale, + 'rho_p': rho_phase, + 'rho_w': rho_width, + 'omega_m': omega_mass, + 'omega_s': omega_scale, + 'omega_p': omega_phase, + 'omega_w': omega_width, + 'phi_m': phi_mass, + 'phi_s': phi_scale, + 'phi_p': phi_phase, + 'phi_w': phi_width, + 'Dstar_m': Dstar_mass, + 'DDstar_s': 0.0, + 'DDstar_p': 0.0, + 'D_m': D_mass, + 'Dbar_m': Dbar_mass, + 'Dbar_s': 0.0, + 'Dbar_p': 0.0, + 'tau_m': pdg['tau_M'], + 'Ctt': 0.0, + 'b0_0': 0.292, + 'b0_1': 0.281, + 'b0_2': 0.150, + 'bplus_0': 0.466, + 'bplus_1': -0.885, + 'bplus_2': -0.213, + 'bT_0': 0.460, + 'bT_1': -1.089, + 'bT_2': -1.114} + + +def reset_param_values(variation = 0.05): + for param in total_f_fit.get_dependents(): + if param.floating: + param.set_value(param_values_dic[param.name] + random.uniform(-1, 1) * param_values_dic[param.name]* variation) +# print(param.name) +# for param in totalf.get_dependents(): +# param.set_value() + + +# # Analysis + +# In[ ]: + + +# # zfit.run.numeric_checks = False + +# fitting_range = 'cut' +# total_BR = 1.7e-10 + 4.9e-10 + 2.5e-9 + 6.02e-5 + 4.97e-6 + 1.38e-9 + 4.2e-10 + 2.6e-9 + 6.1e-10 + 4.37e-7 +# cut_BR = 1.0 - (6.02e-5 + 4.97e-6)/total_BR + +# Ctt_list = [] +# Ctt_error_list = [] + +# nr_of_toys = 1 +# if fitting_range == 'cut': +# nevents = int(pdg["number_of_decays"]*cut_BR) +# else: +# nevents = int(pdg["number_of_decays"]) +# # nevents = pdg["number_of_decays"] +# event_stack = 1000000 +# # nevents *= 41 +# # zfit.settings.set_verbosity(10) +# calls = int(nevents/event_stack + 1) + +# total_samp = [] + +# start = time.time() + +# sampler = total_f.create_sampler(n=event_stack) + +# for toy in range(nr_of_toys): + +# ### Generate data + +# # clear_output(wait=True) + +# print("Toy {}: Generating data...".format(toy)) + +# dirName = 'data/zfit_toys/toy_{0}'.format(toy) + +# if not os.path.exists(dirName): +# os.mkdir(dirName) +# print("Directory " , dirName , " Created ") + +# reset_param_values() + +# if fitting_range == 'cut': + +# sampler.resample(n=nevents) +# s = sampler.unstack_x() +# sam = zfit.run(s) +# calls = 0 +# c = 1 + +# else: +# for call in range(calls): + +# sampler.resample(n=event_stack) +# s = sampler.unstack_x() +# sam = zfit.run(s) + +# c = call + 1 + +# with open("data/zfit_toys/toy_{0}/{1}.pkl".format(toy, call), "wb") as f: +# pkl.dump(sam, f, pkl.HIGHEST_PROTOCOL) + +# print("Toy {}: Data generation finished".format(toy)) + +# ### Load data + +# print("Toy {}: Loading data...".format(toy)) + +# if fitting_range == 'cut': + +# total_samp = sam + +# else: + +# for call in range(calls): +# with open(r"data/zfit_toys/toy_0/{}.pkl".format(call), "rb") as input_file: +# sam = pkl.load(input_file) +# total_samp = np.append(total_samp, sam) + +# total_samp = total_samp.astype('float64') + +# if fitting_range == 'full': + +# data = zfit.data.Data.from_numpy(array=total_samp[:int(nevents)], obs=obs) + +# print("Toy {}: Loading data finished".format(toy)) + +# ### Fit data + +# print("Toy {}: Fitting pdf...".format(toy)) + +# for param in total_f.get_dependents(): +# param.randomize() + +# nll = zfit.loss.UnbinnedNLL(model=total_f, data=data, fit_range = (x_min, x_max), constraints = constraints) + +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) +# # minimizer._use_tfgrad = False +# result = minimizer.minimize(nll) + +# print("Toy {}: Fitting finished".format(toy)) + +# print("Function minimum:", result.fmin) +# print("Hesse errors:", result.hesse()) + +# params = result.params +# Ctt_list.append(params[Ctt]['value']) +# Ctt_error_list.append(params[Ctt]['minuit_hesse']['error']) + +# #plotting the result + +# plotdirName = 'data/plots'.format(toy) + +# if not os.path.exists(plotdirName): +# os.mkdir(plotdirName) +# # print("Directory " , dirName , " Created ") + +# probs = total_f.pdf(test_q, norm_range=False) +# calcs_test = zfit.run(probs) +# plt.clf() +# plt.plot(test_q, calcs_test, label = 'pdf') +# plt.legend() +# plt.ylim(0.0, 6e-6) +# plt.savefig(plotdirName + '/toy_fit_full_range{}.png'.format(toy)) + +# print("Toy {0}/{1}".format(toy+1, nr_of_toys)) +# print("Time taken: {}".format(display_time(int(time.time() - start)))) +# print("Projected time left: {}".format(display_time(int((time.time() - start)/(c+calls*(toy))*((nr_of_toys-toy)*calls-c))))) + +# if fitting_range == 'cut': + +# _1 = np.where((total_samp >= x_min) & (total_samp <= (jpsi_mass - 60.))) + +# tot_sam_1 = total_samp[_1] + +# _2 = np.where((total_samp >= (jpsi_mass + 70.)) & (total_samp <= (psi2s_mass - 50.))) + +# tot_sam_2 = total_samp[_2] + +# _3 = np.where((total_samp >= (psi2s_mass + 50.)) & (total_samp <= x_max)) + +# tot_sam_3 = total_samp[_3] + +# tot_sam = np.append(tot_sam_1, tot_sam_2) +# tot_sam = np.append(tot_sam, tot_sam_3) + +# data = zfit.data.Data.from_numpy(array=tot_sam[:int(nevents)], obs=obs_fit) + +# print("Toy {}: Loading data finished".format(toy)) + +# ### Fit data + +# print("Toy {}: Fitting pdf...".format(toy)) + +# for param in total_f_fit.get_dependents(): +# param.randomize() + +# nll = zfit.loss.UnbinnedNLL(model=total_f_fit, data=data, constraints = constraints) + +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) +# # minimizer._use_tfgrad = False +# result = minimizer.minimize(nll) + +# print("Function minimum:", result.fmin) +# print("Hesse errors:", result.hesse()) + +# params = result.params + +# if result.converged: +# Ctt_list.append(params[Ctt]['value']) +# Ctt_error_list.append(params[Ctt]['minuit_hesse']['error']) + +# #plotting the result + +# plotdirName = 'data/plots'.format(toy) + +# if not os.path.exists(plotdirName): +# os.mkdir(plotdirName) +# # print("Directory " , dirName , " Created ") + +# plt.clf() +# plt.hist(tot_sam, bins = int((x_max-x_min)/7.), label = 'toy data') +# plt.savefig(plotdirName + '/toy_histo_cut_region{}.png'.format(toy)) + + +# probs = total_f_fit.pdf(test_q, norm_range=False) +# calcs_test = zfit.run(probs) +# plt.clf() +# plt.plot(test_q, calcs_test, label = 'pdf') +# plt.axvline(x=jpsi_mass-60.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.axvline(x=jpsi_mass+70.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.axvline(x=psi2s_mass-50.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.axvline(x=psi2s_mass+50.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.legend() +# plt.ylim(0.0, 1.5e-6) +# plt.savefig(plotdirName + '/toy_fit_cut_region{}.png'.format(toy)) + +# print("Toy {0}/{1}".format(toy+1, nr_of_toys)) +# print("Time taken: {}".format(display_time(int(time.time() - start)))) +# print("Projected time left: {}".format(display_time(int((time.time() - start)/(toy+1))*((nr_of_toys-toy-1))))) + + + +# In[ ]: + + +# with open("data/results/Ctt_list.pkl", "wb") as f: +# pkl.dump(Ctt_list, f, pkl.HIGHEST_PROTOCOL) +# with open("data/results/Ctt_error_list.pkl", "wb") as f: +# pkl.dump(Ctt_error_list, f, pkl.HIGHEST_PROTOCOL) + + +# In[ ]: + + +# print('{0}/{1} fits converged'.format(len(Ctt_list), nr_of_toys)) +# print('Mean Ctt value = {}'.format(np.mean(Ctt_list))) +# print('Mean Ctt error = {}'.format(np.mean(Ctt_error_list))) +# print('95 Sensitivy = {}'.format(((2*np.mean(Ctt_error_list))**2)*4.2/1000)) + + +# In[ ]: + + +# plt.hist(tot_sam, bins = int((x_max-x_min)/7.)) + +# plt.show() + +# # _ = np.where((total_samp >= x_min) & (total_samp <= (jpsi_mass - 50.))) + +# tot_sam.shape + + +# In[ ]: + + +# Ctt.floating = False + + +# In[ ]: + + +# zfit.run(nll.value()) + + +# In[ ]: + + +# result.fmin + + +# In[ ]: + + +# BR_steps = np.linspace(0.0, 1e-3, 11) +pull_dic = {} + +mi = 1e-4 +ma = 3e-3 +ste = 20 + +for param in total_f_fit.get_dependents(): + if param.floating: + pull_dic[param.name] = [] + for step in range(2*ste): + pull_dic[param.name].append([]) + + + +def save_pulls(step): + for param in total_f_fit.get_dependents(): + if param.floating: + pull_dic[param.name][step].append((params[param]['value'] - param_values_dic[param.name])/params[param]['minuit_hesse']['error']) + + + +# for key in pull_dic.keys(): +# print(np.shape(pull_dic[key])) +# save_pulls(New_step=True) +# params[Ctt]['value'] + + +# In[ ]: + + +# for param in total_f_fit.get_dependents(): +# if param.floating: +# print(param.name) + +# print(params[Ctt]) + + +# # CLS Code + +# In[ ]: + + +# zfit.run.numeric_checks = False + +load = False + +bo = True + +D_contribs = True + +if not D_contribs: + Dbar_s.floating = False + Dbar_p.floating = False + DDstar_s.floating = False + DDstar_p.floating = False + +bo_set = 1 + +fitting_range = 'cut' +total_BR = 1.7e-10 + 4.9e-10 + 2.5e-9 + 6.02e-5 + 4.97e-6 + 1.38e-9 + 4.2e-10 + 2.6e-9 + 6.1e-10 + 4.37e-7 +cut_BR = 1.0 - (6.02e-5 + 4.97e-6)/total_BR + +Ctt_list = [] +Ctt_error_list = [] + +nr_of_toys = 1 +nevents = int(pdg["number_of_decays"]*cut_BR) +# nevents = pdg["number_of_decays"] +event_stack = 1000000 +# nevents *= 41 +# zfit.settings.set_verbosity(10) + +# mi = 1e-4 +# ma = 3e-3 +# ste = 13 + +BR_steps = np.linspace(mi, ma, ste) + +BR_steps[0] = 0.0 + +print(BR_steps) + +Ctt_steps = np.sqrt(BR_steps/4.2*1000) + +print(Ctt_steps) + +# total_samp = [] + +start = time.time() + +Nll_list = [] + +sampler = total_f.create_sampler(n=nevents, fixed_params = False) +sampler.set_data_range(obs_fit) + +__ = -1 + +#----------------------------------------------------- + +if not load: + for Ctt_step in Ctt_steps: + + __ += 1 + + for i in range(2): + Ctt_list.append([]) + Ctt_error_list.append([]) + Nll_list.append([]) + + for param in total_f_fit.get_dependents(): + if param.floating: + pull_dic[param.name].append([]) + + for toy in range(nr_of_toys): + + newset = True + + while newset: + + for floaty in [True, False]: + Ctt.floating = floaty + + for bo_step in range(bo_set): + + print('Step: {0}/{1}'.format(int(__), ste)) + print('Current Ctt: {0}'.format(Ctt_step)) + print('Ctt floating: {0}'.format(floaty)) + + reset_param_values(variation = 0.0) + + if floaty: + print('Toy {0}/{1} - Fit {2}/{3}'.format(toy, nr_of_toys, bo_step, bo_set)) + Ctt.set_value(Ctt_step) + + else: + Ctt.set_value(0.0) + print('Toy {0}/{1} - Fit {2}/{3}'.format(toy, nr_of_toys, bo_step, bo_set)) + + if newset: + sampler.resample(n=nevents) + data = sampler + newset = False + + ### Fit data + + if floaty: + #plt.clf() + #plt.title('Ctt value: {:.2f}'.format(Ctt_step)) + #plt.hist(zfit.run(data), bins = int((x_max-x_min)/7), range = (x_min, x_max)) + #plt.savefig('data/CLs/plots/set_histo{}.png'.format(__)) + _step = 2*__ + else: + _step = 2*__+1 + + nll = zfit.loss.UnbinnedNLL(model=total_f_fit, data=data, constraints = constraints) + + minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) + # minimizer._use_tfgrad = False + result = minimizer.minimize(nll) + + print("Function minimum:", result.fmin) + print("Hesse errors:", result.hesse()) + + params = result.params + + if result.converged: + + save_pulls(step = _step) + + if floaty: + Nll_list[-2].append(result.fmin) + Ctt_list[-2].append(params[Ctt]['value']) + Ctt_error_list[-2].append(params[Ctt]['minuit_hesse']['error']) + + else: + Nll_list[-1].append(result.fmin) + Ctt_list[-1].append(0.0) + Ctt_error_list[-1].append(0.0) + + + else: + for _ in [1,2]: + del Nll_list[-_][toy*bo_set:] +# print(np.shape(Nll_list[-_])) + del Ctt_list[-_][toy*bo_set:] + del Ctt_error_list[-_][toy*bo_set:] + for param in total_f_fit.get_dependents(): + if param.floating: + del pull_dic[param.name][_step+1-_][toy*bo_set:] + newset = True + break + + if not result.converged: + break + + print() + print('Time taken: {}'.format(display_time(int(time.time()-start)))) + print('Estimated time left: {}'.format(display_time(int((time.time()-start)/(__+(toy+1)/nr_of_toys)*(ste-__-(nr_of_toys-toy-1)/nr_of_toys))))) + + +# In[ ]: + + +if load: + + phase_combi = '--' + + if D_contribs: + D_dir = 'D-True' + else: + D_dir = 'D-False' + + _dir = 'data/CLs/finished/f1d1/{}/{}/'.format(phase_combi, D_dir) + + jobs = os.listdir(_dir) + + First = True + +# print(jobs) + + for job in jobs: + + dirName = _dir + str(job) + '/data/CLs' + + if not os.path.exists("{}/{}-{}_{}s{}b{}t--CLs_Nll_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys)): +# print(job) + continue + + with open(r"{}/variab.pkl".format(dirName), "rb") as input_file: + variab = pkl.load(input_file) +# print(variab) + + ### sanity check: + if variab['mi'] != mi or variab['ma'] != ma or variab['ste'] != ste or bo_set != bo_set: + print('Fitting parameters of data dont equal the ones given -- Job {} skipped!'.format(job)) + + with open(r"{}/{}-{}_{}s{}b{}t--CLs_Nll_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _Nll_list = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s{}b{}t--Ctt_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _Ctt_list = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s{}b{}t--Ctt_error_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _Ctt_error_list = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s{}b{}t--pull_dic.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _pull_dic = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s--CLs_list.pkl".format(dirName, mi,ma,ste), "rb") as input_file: + _CLs_list = pkl.load(input_file) + + + if First: + Nll_list = _Nll_list + Ctt_list = _Ctt_list + Ctt_error_list = _Ctt_error_list + pull_dic = _pull_dic +# print(_pull_dic) + CLs_list = _CLs_list + First = False + else: + for step in range(2*ste): +# print(Nll_list[step], step) + Nll_list[step].extend(_Nll_list[step]) + Ctt_list[step].extend(_Ctt_list[step]) + Ctt_error_list[step].extend(_Ctt_error_list[step]) + for key in pull_dic.keys(): +# print(key, np.shape(pull_dic[key])) + pull_dic[key][step].extend(_pull_dic[key][step]) + for step in range(ste): + CLs_list[step].extend(_CLs_list[step]) + +# print('----------------------') + + +# In[ ]: + + +dirName = 'data/CLs' + +# if bo and not load: +# for s in range(2*ste): +# Nll_list[s] = [np.min(Nll_list[s])] + + +if not load: + + if not os.path.exists(dirName): + os.mkdir(dirName) + print("Directory " , dirName , " Created ") + + with open("{}/{}-{}_{}s{}b{}t--CLs_Nll_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(Nll_list, f, pkl.HIGHEST_PROTOCOL) + + with open("{}/{}-{}_{}s{}b{}t--Ctt_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(Ctt_list, f, pkl.HIGHEST_PROTOCOL) + + with open("{}/{}-{}_{}s{}b{}t--Ctt_error_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(Ctt_error_list, f, pkl.HIGHEST_PROTOCOL) + + with open("{}/{}-{}_{}s{}b{}t--pull_dic.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(pull_dic, f, pkl.HIGHEST_PROTOCOL) + + variab = {'mi': mi, + 'ma': ma, + 'ste': ste, + 'bo_set': bo_set, + 'nr_of_toys': nr_of_toys} + + with open("{}/variab.pkl".format(dirName), "wb") as f: + pkl.dump(variab, f, pkl.HIGHEST_PROTOCOL) + + CLs_values = [] + + toy_size = bo_set + + print(np.shape(Nll_list)) + print(Nll_list[0:1]) + + for step in range(ste): + CLs_values.append([]) + for toy in range(nr_of_toys): + float_min = np.min(Nll_list[2*step][toy*bo_set:(toy+1)*bo_set]) + fix_min = np.min(Nll_list[2*step+1][toy*bo_set:(toy+1)*bo_set]) + CLs_values[step].append(float_min-fix_min) + + + print(np.shape(CLs_values)) + + with open("{}/{}-{}_{}s--CLs_list.pkl".format(dirName, mi,ma,ste), "wb") as f: + pkl.dump(CLs_values, f, pkl.HIGHEST_PROTOCOL) + + +# In[ ]: + + +# print(variab['mi'] != mi) + + +# ## Plot + +# In[ ]: + + +l = [] + + +if load: + CLs_values = -1*np.array(CLs_list) + +if not os.path.exists('data/CLs/plots'): + os.mkdir('data/CLs/plots') + print("Directory " , 'data/CLs/plots' , " Created ") + +print(np.shape(CLs_values)) + +for step in range(1,ste): + plt.clf() + plt.title('Ctt value: {:.2f}'.format(Ctt_steps[step])) + plt.hist(CLs_values[0], bins = 150, range = (-25, 50), label = 'Ctt fixed to 0') + plt.hist(CLs_values[step], bins = 150, range = (-25, 50), label = 'Ctt floating') + plt.axvline(x=np.mean(CLs_values[0]),color='red', linewidth=1.0, linestyle = 'dotted') + plt.legend() + plt.savefig('data/CLs/plots/CLs-BR({:.1E}).png'.format(BR_steps[step])) + + l.append(len(np.where(np.array(CLs_values[step]) < np.mean(CLs_values[0]))[0])) + +for step in range(2*ste): + if step%2 == 0: + floaty = True + else: + floaty = False + for key in pull_dic.keys(): + if not os.path.exists('data/CLs/plots/{}'.format(key)): + os.mkdir('data/CLs/plots/{}'.format(key)) + plt.clf() + plt.title('Pull {} - Ctt value {:.2f} - floating {}'.format(key, Ctt_steps[int(step/2)], floaty)) + plt.hist(pull_dic[key][step], bins = 50, range = (-5,5)) + plt.xlabel('Pull') + plt.savefig('data/CLs/plots/{}/{:.2f}Ctt{}s{}f.png'.format(key, Ctt_steps[int(step/2)], step, floaty)) + + +# In[ ]: + + +for s in range(len(l)): + print('BR: {:.4f}'.format(BR_steps[s+1])) + print(2*l[s]/len(CLs_values[s])) + print() + + +# In[ ]: + + +# for step in range(2*ste): +# for key in pull_dic.keys(): +# print(pull_dic[key][step]) + + +# In[ ]: + + +# for param in total_f_fit.get_dependents(): +# if param.floating: +# print(params[param]['value']) + + +# In[ ]: + + +print(display_time(int(time.time()-start))) + + +# In[ ]: + + +# variab['mi'] =! mi + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + diff --git a/data/CLs/finished/f1d1/-+/D-True/2288023/__pycache__/helperfunctions.cpython-37.pyc b/data/CLs/finished/f1d1/-+/D-True/2288023/__pycache__/helperfunctions.cpython-37.pyc new file mode 100644 index 0000000..45e49c1 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288023/__pycache__/helperfunctions.cpython-37.pyc Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288023/__pycache__/pdg_const1.cpython-37.pyc b/data/CLs/finished/f1d1/-+/D-True/2288023/__pycache__/pdg_const1.cpython-37.pyc new file mode 100644 index 0000000..886e361 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288023/__pycache__/pdg_const1.cpython-37.pyc Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288023/data/CLs/0.0001-0.003_20s--CLs_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288023/data/CLs/0.0001-0.003_20s--CLs_list.pkl new file mode 100644 index 0000000..3b5398d --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288023/data/CLs/0.0001-0.003_20s--CLs_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288023/data/CLs/0.0001-0.003_20s1b1t--CLs_Nll_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288023/data/CLs/0.0001-0.003_20s1b1t--CLs_Nll_list.pkl new file mode 100644 index 0000000..2587e94 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288023/data/CLs/0.0001-0.003_20s1b1t--CLs_Nll_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288023/data/CLs/0.0001-0.003_20s1b1t--Ctt_error_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288023/data/CLs/0.0001-0.003_20s1b1t--Ctt_error_list.pkl new file mode 100644 index 0000000..3378727 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288023/data/CLs/0.0001-0.003_20s1b1t--Ctt_error_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288023/data/CLs/0.0001-0.003_20s1b1t--Ctt_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288023/data/CLs/0.0001-0.003_20s1b1t--Ctt_list.pkl new file mode 100644 index 0000000..462072b --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288023/data/CLs/0.0001-0.003_20s1b1t--Ctt_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288023/data/CLs/0.0001-0.003_20s1b1t--pull_dic.pkl b/data/CLs/finished/f1d1/-+/D-True/2288023/data/CLs/0.0001-0.003_20s1b1t--pull_dic.pkl new file mode 100644 index 0000000..f91daab --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288023/data/CLs/0.0001-0.003_20s1b1t--pull_dic.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288023/data/CLs/variab.pkl b/data/CLs/finished/f1d1/-+/D-True/2288023/data/CLs/variab.pkl new file mode 100644 index 0000000..bb90dc0 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288023/data/CLs/variab.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288023/helperfunctions.py b/data/CLs/finished/f1d1/-+/D-True/2288023/helperfunctions.py new file mode 100644 index 0000000..88e120f --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288023/helperfunctions.py @@ -0,0 +1,33 @@ +# some helperfunctions + +import matplotlib +matplotlib.use("agg") +import matplotlib.pyplot as plt + +#Dislpay time (e.g. while generating points) + +display_intervals = ( + ('w', 604800), # 60 * 60 * 24 * 7 + ('d', 86400), # 60 * 60 * 24 + ('h', 3600), # 60 * 60 + ('min', 60), + ('s', 1), + ) + +def display_time(seconds, granularity=2): + result = [] + + for name, count in display_intervals: + value = seconds // count + if value: + seconds -= value * count + if value == 1: + name = name.rstrip('s') + result.append("{} {}".format(value, name)) + return ', '.join(result[:granularity]) + +def prepare_plot(title): + plt.title(title) + plt.grid() + plt.legend(loc = 'best') + plt.xlabel("q") diff --git a/data/CLs/finished/f1d1/-+/D-True/2288023/pdg_const1.py b/data/CLs/finished/f1d1/-+/D-True/2288023/pdg_const1.py new file mode 100644 index 0000000..70b3f30 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288023/pdg_const1.py @@ -0,0 +1,226 @@ +pdg = { + + + ###Particle masses### + + "mbstar" : 5415.4, + "mbstar0" : 5711.0, + "B0_M" : 5279.5, + "Bs_M" : 5366.7, + "Bplus_M" : 5279.3, + "Lb_M" : 5619.4, + "D0_M" : 1864.8, + "Dst_M" : 2010, + "pi_M" : 139.6, + "Jpsi_M" : 3096.9, + "Psi2s_M" : 3685.6, + "kaon_M" : 493.7, + "Ks_M" : 497.6, + "phi_M" : 1019.5, + "rho_M" : 775.26, + "rho_width" : 149.1, + "omega_M" : 782.65, + "omega_width" : 8.49, + + "muon_M" : 105.7, + "tau_M": 1776.86, + + "squark_M" : 95.0, + "bquark_M" : 4180.0, + "cquark_M" : 1275.0, + + "Bplus_tau" : 1.638e-12, + + ###Wilson coefficients### + + "C1" : -0.257, + "C2" : 1.009, + "C3" : -0.005, + "C4" : -0.078, + + "C7eff" : -0.306, + "C9eff" : 4.211, + "C10eff" : -4.103, + +# "C7eff": 0.0, +# "C9eff": 0.0, +# "C10eff": 0.0, + + ###Other constants + + "GF" : 1.1663787e-5, + "alpha_ew" : 1.0/137.0, + "Vts" : 0.0394, + "Vtb" : 1.019, + "number_of_decays": 5404696, + + #Formfactor z coefficients + + #"b0" : [0.285, 0.19, -0.17], + #"bplus" : [0.437, -1.41, -2.5], + #"bT" : [0.440, -1.47, -2.7] + + "b0" : [0.292, 0.281, 0.150], + "bplus" : [0.466, -0.885, -0.213], + "bT" : [0.460, -1.089, -1.114], + + "NR_BR": 4.37e-7, + "NR_auc": 0.00133, + + #Resonances format(mass, width, phase, scale) + + # pre scaling + +# "rho": (775.26, 149.0, -0.35, 1.0), + +# "omega": (782.7, 8.5, 0.26, 1.0), + +# "phi": (1019.46, 4.25, 0.5, 1.0), + +# "jpsi": (3096.0, 0.09, -1.5, 2e-2), +# "jpsi_auc": 0.2126825758464027, + +# "psi2s": (3686.0, 0.3, -1.5, 3.14e-3), +# "psi2s_auc": 2.802257483178487e-10, + +# "p3770": (3773.0, 27.2, -2.13, 1.0e-3), + +# "p4040": (4039.0, 80.0, -2.52, 2.0), + +# "p4160": (4191.0, 70.0, -1.9, 2.2), + +# "p4415": (4421.0, 62.0, -2.52, 1.0), + + + # after scaling (Phase combination --) + + # + # "rho": (743.2, 149.0, -0.22, 1.05), + # + # "omega": (782.7, 8.5, 0.38, 6.8), + # + # "phi": (1013.5, 4.25, 0.62, 19.2), + # + # "jpsi": (3096.1, 0.09, 1.63, 9897.0), + # "jpsi_auc": 0.2126825758464027, + # "jpsi_phase_unc": 0.05, + # + # "psi2s": (3686.0, 0.3, 1.8, 1396.0), + # "psi2s_auc": 0.0151332263, + # "psi2s_phase_unc": 0.1, + # + # "p3770": (3773.0, 27.2, -2.95, 2.5), + # + # "p4040": (4039.0, 80.0, -2.75, 1.01), + # + # "p4160": (4191.0, 70.0, -2.28, 2.2), + # + # "p4415": (4421.0, 62.0, -2.31, 1.24), + + # Phase combination of paper ++ + +# "rho": (743.2, 149.0, -0.35, 1.05), + +# "omega": (782.7, 8.5, 0.26, 6.8), + +# "phi": (1013.5, 4.25, 0.47, 19.2), + +# "jpsi": (3096.1, 0.09, -1.66, 9897.0), +# "jpsi_auc": 0.2126825758464027, +# "jpsi_phase_unc": 0.05, + +# "psi2s": (3686.0, 0.3, -1.93, 1396.0), +# "psi2s_auc": 0.0151332263, +# "psi2s_phase_unc": 0.1, + +# "p3770": (3773.0, 27.2, -2.13, 2.5), + +# "p4040": (4039.0, 80.0, -2.52, 1.01), + +# "p4160": (4191.0, 70.0, -1.90, 2.2), + +# "p4415": (4421.0, 62.0, -2.52, 1.24), + + # Phase combination of paper +- + +# "rho": (743.2, 149.0, -0.26, 1.05), + +# "omega": (782.7, 8.5, 0.35, 6.8), + +# "phi": (1013.5, 4.25, 0.58, 19.2), + +# "jpsi": (3096.1, 0.09, 1.47, 9897.0), +# "jpsi_auc": 0.2126825758464027, +# "jpsi_phase_unc": 0.05, + +# "psi2s": (3686.0, 0.3, -2.21, 1396.0), +# "psi2s_auc": 0.0151332263, +# "psi2s_phase_unc": 0.1, + +# "p3770": (3773.0, 27.2, -2.140, 2.5), + +# "p4040": (4039.0, 80.0, -2.64, 1.01), + +# "p4160": (4191.0, 70.0, -2.11, 2.2), + +# "p4415": (4421.0, 62.0, -2.42, 1.24), + + # Phase combination of paper -+ + + "rho": (743.2, 149.0, -0.30, 1.05), + + "omega": (782.7, 8.5, 0.30, 6.8), + + "phi": (1013.5, 4.25, 0.51, 19.2), + + "jpsi": (3096.1, 0.09, -1.5, 9897.0), + "jpsi_auc": 0.2126825758464027, + "jpsi_phase_unc": 0.05, + + "psi2s": (3686.0, 0.3, 2.08, 1396.0), + "psi2s_auc": 0.0151332263, + "psi2s_phase_unc": 0.1, + + "p3770": (3773.0, 27.2, -2.89, 2.5), + + "p4040": (4039.0, 80.0, -2.69, 1.01), + + "p4160": (4191.0, 70.0, -2.13, 2.2), + + "p4415": (4421.0, 62.0, -2.43, 1.24), + + + # zeroing resonances + +# "rho": (775.26, 149.0, -0.35, 0.0), +# "omega": (782.7, 8.5, 0.26, 0.0), +# "phi": (1019.46, 4.25, 0.5, 0.0), +# "jpsi": (3096.0, 0.09, -1.5, 0.0), +# "psi2s": (3686.0, 0.3, -1.5, 0.0), +# "p3770": (3773.0, 27.2, -2.13, 0.0), +# "p4040": (4039.0, 80.0, -2.52, 0.0), +# "p4160": (4147.0, 22.0, -1.9, 0.0), +# "p4415": (4421.0, 62.0, -2.52, 0.0), + + # 2P contributions format(mass, amp, phase) + +# "D_bar": ( + + #general + + "rho_BR": 1.7e-10, + "omega_BR": 4.9e-10, + "phi_BR": 2.5e-9, + "jpsi_BR": 6.02e-5, + "psi2s_BR": 4.97e-6, + "p3770_BR": 1.38e-9, + "p4040_BR": 4.2e-10, + "p4160_BR": 2.6e-9, + "p4415_BR": 6.1e-10, + +# Estimates + "Dbar_scale": 1.46, #with phase = pi + + "DDstar_scale": 2.41, #with phase = pi + + } diff --git a/data/CLs/finished/f1d1/-+/D-True/2288023/raremodel-nb.py b/data/CLs/finished/f1d1/-+/D-True/2288023/raremodel-nb.py new file mode 100644 index 0000000..c326c9c --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288023/raremodel-nb.py @@ -0,0 +1,2152 @@ +#!/usr/bin/env python +# coding: utf-8 + +# # Import + +# In[ ]: + + +import os + +# os.environ["CUDA_VISIBLE_DEVICES"] = "-1" +import random +import numpy as np +from pdg_const1 import pdg +import matplotlib +import matplotlib.pyplot as plt +import pickle as pkl +import sys +import time +from helperfunctions import display_time, prepare_plot +import cmath as c +import scipy.integrate as integrate +from scipy.optimize import fminbound +from array import array as arr +import collections +from itertools import compress +import tensorflow as tf +import zfit +from zfit import ztf +# from IPython.display import clear_output +import os +import tensorflow_probability as tfp +tfd = tfp.distributions + + +# In[ ]: + + +# chunksize = 10000 +# zfit.run.chunking.active = True +# zfit.run.chunking.max_n_points = chunksize + + +# # Build model and graphs +# ## Create graphs + +# In[ ]: + + + + + +# In[ ]: + + +def formfactor(q2, subscript, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2): #returns real value + #check if subscript is viable + + if subscript != "0" and subscript != "+" and subscript != "T": + raise ValueError('Wrong subscript entered, choose either 0, + or T') + + #get constants + + mK = ztf.constant(pdg['Ks_M']) + mbstar0 = ztf.constant(pdg["mbstar0"]) + mbstar = ztf.constant(pdg["mbstar"]) + + + mmu = ztf.constant(pdg['muon_M']) + mb = ztf.constant(pdg['bquark_M']) + ms = ztf.constant(pdg['squark_M']) + mB = ztf.constant(pdg['Bplus_M']) + + #N comes from derivation in paper + + N = 3 + + #some helperfunctions + + tpos = (mB - mK)**2 + tzero = (mB + mK)*(ztf.sqrt(mB)-ztf.sqrt(mK))**2 + + z_oben = ztf.sqrt(tpos - q2) - ztf.sqrt(tpos - tzero) + z_unten = ztf.sqrt(tpos - q2) + ztf.sqrt(tpos - tzero) + z = tf.divide(z_oben, z_unten) + + #calculate f0 + + if subscript == "0": + prefactor = 1/(1 - q2/(mbstar0**2)) + _sum = 0 + b0 = [b0_0, b0_1, b0_2] + + for i in range(N): + _sum += b0[i]*(tf.pow(z,i)) + + return ztf.to_complex(prefactor * _sum) + + #calculate f+ or fT + + else: + prefactor = 1/(1 - q2/(mbstar**2)) + _sum = 0 + + if subscript == "T": + bT = [bT_0, bT_1, bT_2] + for i in range(N): + _sum += bT[i] * (tf.pow(z, i) - ((-1)**(i-N)) * (i/N) * tf.pow(z, N)) + else: + bplus = [bplus_0, bplus_1, bplus_2] + for i in range(N): + _sum += bplus[i] * (tf.pow(z, i) - ((-1)**(i-N)) * (i/N) * tf.pow(z, N)) + + return ztf.to_complex(prefactor * _sum) + +def resonance(q, _mass, width, phase, scale): + + q2 = tf.pow(q, 2) + + mmu = ztf.constant(pdg['muon_M']) + + p = 0.5 * ztf.sqrt(q2 - 4*(mmu**2)) + + p0 = 0.5 * ztf.sqrt(_mass**2 - 4*mmu**2) + + gamma_j = tf.divide(p, q) * _mass * width / p0 + + #Calculate the resonance + + _top = tf.complex(_mass * width, ztf.constant(0.0)) + + _bottom = tf.complex(_mass**2 - q2, -_mass*gamma_j) + + com = _top/_bottom + + #Rotate by the phase + + r = ztf.to_complex(scale*tf.abs(com)) + + _phase = tf.angle(com) + + _phase += phase + + com = r * tf.exp(tf.complex(ztf.constant(0.0), _phase)) + + return com + + +def axiv_nonres(q, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2): + + GF = ztf.constant(pdg['GF']) + alpha_ew = ztf.constant(pdg['alpha_ew']) + Vtb = ztf.constant(pdg['Vtb']) + Vts = ztf.constant(pdg['Vts']) + C10eff = ztf.constant(pdg['C10eff']) + + mmu = ztf.constant(pdg['muon_M']) + mb = ztf.constant(pdg['bquark_M']) + ms = ztf.constant(pdg['squark_M']) + mK = ztf.constant(pdg['Ks_M']) + mB = ztf.constant(pdg['Bplus_M']) + + q2 = tf.pow(q, 2) + + #Some helperfunctions + + beta = 1. - 4. * mmu**2. / q2 + + kabs = ztf.sqrt(mB**2. + tf.pow(q2, 2)/mB**2. + mK**4./mB**2. - 2. * (mB**2. * mK**2. + mK**2. * q2 + mB**2. * q2) / mB**2.) + + #prefactor in front of whole bracket + + prefactor1 = GF**2. *alpha_ew**2. * (tf.abs(Vtb*Vts))**2. * kabs * beta / (128. * np.pi**5.) + + #left term in bracket + + bracket_left = 2./3. * tf.pow(kabs,2) * tf.pow(beta,2) * tf.pow(tf.abs(ztf.to_complex(C10eff)*formfactor(q2, "+", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2)),2) + + #middle term in bracket + + _top = 4. * mmu**2. * (mB**2. - mK**2.) * (mB**2. - mK**2.) + + _under = q2 * mB**2. + + bracket_middle = _top/_under *tf.pow(tf.abs(ztf.to_complex(C10eff) * formfactor(q2, "0", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2)), 2) + + #Note sqrt(q2) comes from derivation as we use q2 and plot q + + return prefactor1 * (bracket_left + bracket_middle) * 2 * q + +def vec(q, funcs, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2): + + q2 = tf.pow(q, 2) + + GF = ztf.constant(pdg['GF']) + alpha_ew = ztf.constant(pdg['alpha_ew']) + Vtb = ztf.constant(pdg['Vtb']) + Vts = ztf.constant(pdg['Vts']) + C7eff = ztf.constant(pdg['C7eff']) + + mmu = ztf.constant(pdg['muon_M']) + mb = ztf.constant(pdg['bquark_M']) + ms = ztf.constant(pdg['squark_M']) + mK = ztf.constant(pdg['Ks_M']) + mB = ztf.constant(pdg['Bplus_M']) + + #Some helperfunctions + + beta = 1. - 4. * mmu**2. / q2 + + kabs = ztf.sqrt(mB**2. + tf.pow(q2, 2)/mB**2. + mK**4./mB**2. - 2 * (mB**2 * mK**2 + mK**2 * q2 + mB**2 * q2) / mB**2) + + #prefactor in front of whole bracket + + prefactor1 = GF**2. *alpha_ew**2. * (tf.abs(Vtb*Vts))**2 * kabs * beta / (128. * np.pi**5.) + + #right term in bracket + + prefactor2 = tf.pow(kabs,2) * (1. - 1./3. * beta) + + abs_bracket = tf.pow(tf.abs(c9eff(q, funcs) * formfactor(q2, "+", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + ztf.to_complex(2.0 * C7eff * (mb + ms)/(mB + mK)) * formfactor(q2, "T", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2)),2) + + bracket_right = prefactor2 * abs_bracket + + #Note sqrt(q2) comes from derivation as we use q2 and plot q + + return prefactor1 * bracket_right * 2 * q + +def c9eff(q, funcs): + + C9eff_nr = ztf.to_complex(ztf.constant(pdg['C9eff'])) + + c9 = C9eff_nr + funcs + + return c9 + + +# In[ ]: + + +def G(y): + + def inner_rect_bracket(q): + return tf.log(ztf.to_complex((1+tf.sqrt(q))/(1-tf.sqrt(q)))-tf.complex(ztf.constant(0), -1*ztf.constant(np.pi))) + + def inner_right(q): + return ztf.to_complex(2 * tf.atan(1/tf.sqrt(tf.math.real(-q)))) + + big_bracket = tf.where(tf.math.real(y) > ztf.constant(0.0), inner_rect_bracket(y), inner_right(y)) + + return ztf.to_complex(tf.sqrt(tf.abs(y))) * big_bracket + +def h_S(m, q): + + return ztf.to_complex(2) - G(ztf.to_complex(1) - ztf.to_complex(4*tf.pow(m, 2)) / ztf.to_complex(tf.pow(q, 2))) + +def h_P(m, q): + + return ztf.to_complex(2/3) + (ztf.to_complex(1) - ztf.to_complex(4*tf.pow(m, 2)) / ztf.to_complex(tf.pow(q, 2))) * h_S(m,q) + +def two_p_ccbar(mD, m_D_bar, m_D_star, q): + + + #Load constants + nu_D_bar = ztf.to_complex(pdg["nu_D_bar"]) + nu_D = ztf.to_complex(pdg["nu_D"]) + nu_D_star = ztf.to_complex(pdg["nu_D_star"]) + + phase_D_bar = ztf.to_complex(pdg["phase_D_bar"]) + phase_D = ztf.to_complex(pdg["phase_D"]) + phase_D_star = ztf.to_complex(pdg["phase_D_star"]) + + #Calculation + left_part = nu_D_bar * tf.exp(tf.complex(ztf.constant(0.0), phase_D_bar)) * h_S(m_D_bar, q) + + right_part_D = nu_D * tf.exp(tf.complex(ztf.constant(0.0), phase_D)) * h_P(m_D, q) + + right_part_D_star = nu_D_star * tf.exp(tf.complex(ztf.constant(0.0), phase_D_star)) * h_P(m_D_star, q) + + return left_part + right_part_D + right_part_D_star + + +# ## Build pdf + +# In[ ]: + + +class total_pdf_cut(zfit.pdf.ZPDF): + _N_OBS = 1 # dimension, can be omitted + _PARAMS = ['b0_0', 'b0_1', 'b0_2', + 'bplus_0', 'bplus_1', 'bplus_2', + 'bT_0', 'bT_1', 'bT_2', + 'rho_mass', 'rho_scale', 'rho_phase', 'rho_width', + 'jpsi_mass', 'jpsi_scale', 'jpsi_phase', 'jpsi_width', + 'psi2s_mass', 'psi2s_scale', 'psi2s_phase', 'psi2s_width', + 'p3770_mass', 'p3770_scale', 'p3770_phase', 'p3770_width', + 'p4040_mass', 'p4040_scale', 'p4040_phase', 'p4040_width', + 'p4160_mass', 'p4160_scale', 'p4160_phase', 'p4160_width', + 'p4415_mass', 'p4415_scale', 'p4415_phase', 'p4415_width', + 'omega_mass', 'omega_scale', 'omega_phase', 'omega_width', + 'phi_mass', 'phi_scale', 'phi_phase', 'phi_width', + 'Dbar_mass', 'Dbar_scale', 'Dbar_phase', + 'Dstar_mass', 'DDstar_scale', 'DDstar_phase', 'D_mass', + 'tau_mass', 'C_tt'] +# the name of the parameters + + def _unnormalized_pdf(self, x): + + x = x.unstack_x() + + b0 = [self.params['b0_0'], self.params['b0_1'], self.params['b0_2']] + bplus = [self.params['bplus_0'], self.params['bplus_1'], self.params['bplus_2']] + bT = [self.params['bT_0'], self.params['bT_1'], self.params['bT_2']] + + def rho_res(q): + return resonance(q, _mass = self.params['rho_mass'], scale = self.params['rho_scale'], + phase = self.params['rho_phase'], width = self.params['rho_width']) + + def omega_res(q): + return resonance(q, _mass = self.params['omega_mass'], scale = self.params['omega_scale'], + phase = self.params['omega_phase'], width = self.params['omega_width']) + + def phi_res(q): + return resonance(q, _mass = self.params['phi_mass'], scale = self.params['phi_scale'], + phase = self.params['phi_phase'], width = self.params['phi_width']) + + def jpsi_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['jpsi_mass'], 2)) * resonance(q, _mass = self.params['jpsi_mass'], + scale = self.params['jpsi_scale'], + phase = self.params['jpsi_phase'], + width = self.params['jpsi_width']) + def psi2s_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['psi2s_mass'], 2)) * resonance(q, _mass = self.params['psi2s_mass'], + scale = self.params['psi2s_scale'], + phase = self.params['psi2s_phase'], + width = self.params['psi2s_width']) + def p3770_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p3770_mass'], 2)) * resonance(q, _mass = self.params['p3770_mass'], + scale = self.params['p3770_scale'], + phase = self.params['p3770_phase'], + width = self.params['p3770_width']) + + def p4040_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4040_mass'], 2)) * resonance(q, _mass = self.params['p4040_mass'], + scale = self.params['p4040_scale'], + phase = self.params['p4040_phase'], + width = self.params['p4040_width']) + + def p4160_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4160_mass'], 2)) * resonance(q, _mass = self.params['p4160_mass'], + scale = self.params['p4160_scale'], + phase = self.params['p4160_phase'], + width = self.params['p4160_width']) + + def p4415_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4415_mass'], 2)) * resonance(q, _mass = self.params['p4415_mass'], + scale = self.params['p4415_scale'], + phase = self.params['p4415_phase'], + width = self.params['p4415_width']) + + def P2_D(q): + Dbar_contrib = ztf.to_complex(self.params['Dbar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['Dbar_phase']))*ztf.to_complex(h_S(self.params['Dbar_mass'], q)) + DDstar_contrib = ztf.to_complex(self.params['DDstar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['DDstar_phase']))*(ztf.to_complex(h_P(self.params['Dstar_mass'], q)) + ztf.to_complex(h_P(self.params['D_mass'], q))) + return Dbar_contrib + DDstar_contrib + + def ttau_cusp(q): + return ztf.to_complex(self.params['C_tt'])*(ztf.to_complex((h_S(self.params['tau_mass'], q))) - ztf.to_complex(h_P(self.params['tau_mass'], q))) + + + funcs = rho_res(x) + omega_res(x) + phi_res(x) + jpsi_res(x) + psi2s_res(x) + p3770_res(x) + p4040_res(x)+ p4160_res(x) + p4415_res(x) + P2_D(x) + ttau_cusp(x) + + vec_f = vec(x, funcs, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + axiv_nr = axiv_nonres(x, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + tot = vec_f + axiv_nr + + #Cut out jpsi and psi2s + + tot = tf.where(tf.math.logical_or(x < ztf.constant(jpsi_mass-60.), x > ztf.constant(jpsi_mass+70.)), tot, 0.0*tot) + + tot = tf.where(tf.math.logical_or(x < ztf.constant(psi2s_mass-50.), x > ztf.constant(psi2s_mass+50.)), tot, 0.0*tot) + + return tot + +class total_pdf_full(zfit.pdf.ZPDF): + _N_OBS = 1 # dimension, can be omitted + _PARAMS = ['b0_0', 'b0_1', 'b0_2', + 'bplus_0', 'bplus_1', 'bplus_2', + 'bT_0', 'bT_1', 'bT_2', + 'rho_mass', 'rho_scale', 'rho_phase', 'rho_width', + 'jpsi_mass', 'jpsi_scale', 'jpsi_phase', 'jpsi_width', + 'psi2s_mass', 'psi2s_scale', 'psi2s_phase', 'psi2s_width', + 'p3770_mass', 'p3770_scale', 'p3770_phase', 'p3770_width', + 'p4040_mass', 'p4040_scale', 'p4040_phase', 'p4040_width', + 'p4160_mass', 'p4160_scale', 'p4160_phase', 'p4160_width', + 'p4415_mass', 'p4415_scale', 'p4415_phase', 'p4415_width', + 'omega_mass', 'omega_scale', 'omega_phase', 'omega_width', + 'phi_mass', 'phi_scale', 'phi_phase', 'phi_width', + 'Dbar_mass', 'Dbar_scale', 'Dbar_phase', + 'Dstar_mass', 'DDstar_scale', 'DDstar_phase', 'D_mass', + 'tau_mass', 'C_tt'] +# the name of the parameters + + def _unnormalized_pdf(self, x): + + x = x.unstack_x() + + b0 = [self.params['b0_0'], self.params['b0_1'], self.params['b0_2']] + bplus = [self.params['bplus_0'], self.params['bplus_1'], self.params['bplus_2']] + bT = [self.params['bT_0'], self.params['bT_1'], self.params['bT_2']] + + def rho_res(q): + return resonance(q, _mass = self.params['rho_mass'], scale = self.params['rho_scale'], + phase = self.params['rho_phase'], width = self.params['rho_width']) + + def omega_res(q): + return resonance(q, _mass = self.params['omega_mass'], scale = self.params['omega_scale'], + phase = self.params['omega_phase'], width = self.params['omega_width']) + + def phi_res(q): + return resonance(q, _mass = self.params['phi_mass'], scale = self.params['phi_scale'], + phase = self.params['phi_phase'], width = self.params['phi_width']) + + def jpsi_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['jpsi_mass'], 2)) * resonance(q, _mass = self.params['jpsi_mass'], + scale = self.params['jpsi_scale'], + phase = self.params['jpsi_phase'], + width = self.params['jpsi_width']) + def psi2s_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['psi2s_mass'], 2)) * resonance(q, _mass = self.params['psi2s_mass'], + scale = self.params['psi2s_scale'], + phase = self.params['psi2s_phase'], + width = self.params['psi2s_width']) + def p3770_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p3770_mass'], 2)) * resonance(q, _mass = self.params['p3770_mass'], + scale = self.params['p3770_scale'], + phase = self.params['p3770_phase'], + width = self.params['p3770_width']) + + def p4040_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4040_mass'], 2)) * resonance(q, _mass = self.params['p4040_mass'], + scale = self.params['p4040_scale'], + phase = self.params['p4040_phase'], + width = self.params['p4040_width']) + + def p4160_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4160_mass'], 2)) * resonance(q, _mass = self.params['p4160_mass'], + scale = self.params['p4160_scale'], + phase = self.params['p4160_phase'], + width = self.params['p4160_width']) + + def p4415_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4415_mass'], 2)) * resonance(q, _mass = self.params['p4415_mass'], + scale = self.params['p4415_scale'], + phase = self.params['p4415_phase'], + width = self.params['p4415_width']) + + def P2_D(q): + Dbar_contrib = ztf.to_complex(self.params['Dbar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['Dbar_phase']))*ztf.to_complex(h_S(self.params['Dbar_mass'], q)) + DDstar_contrib = ztf.to_complex(self.params['DDstar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['DDstar_phase']))*(ztf.to_complex(h_P(self.params['Dstar_mass'], q)) + ztf.to_complex(h_P(self.params['D_mass'], q))) + return Dbar_contrib + DDstar_contrib + + def ttau_cusp(q): + return ztf.to_complex(self.params['C_tt'])*(ztf.to_complex((h_S(self.params['tau_mass'], q))) - ztf.to_complex(h_P(self.params['tau_mass'], q))) + + + funcs = rho_res(x) + omega_res(x) + phi_res(x) + jpsi_res(x) + psi2s_res(x) + p3770_res(x) + p4040_res(x)+ p4160_res(x) + p4415_res(x) + P2_D(x) + ttau_cusp(x) + + vec_f = vec(x, funcs, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + axiv_nr = axiv_nonres(x, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + tot = vec_f + axiv_nr + + #Cut out jpsi and psi2s + +# tot = tf.where(tf.math.logical_or(x < ztf.constant(jpsi_mass-60.), x > ztf.constant(jpsi_mass+70.)), tot, 0.0*tot) + +# tot = tf.where(tf.math.logical_or(x < ztf.constant(psi2s_mass-50.), x > ztf.constant(psi2s_mass+50.)), tot, 0.0*tot) + + return tot + + +# ## Setup parameters + +# In[ ]: + + +# formfactors + +b0_0 = zfit.Parameter("b0_0", ztf.constant(0.292), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +b0_1 = zfit.Parameter("b0_1", ztf.constant(0.281), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +b0_2 = zfit.Parameter("b0_2", ztf.constant(0.150), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) + +bplus_0 = zfit.Parameter("bplus_0", ztf.constant(0.466), lower_limit = -2.0, upper_limit= 2.0) +bplus_1 = zfit.Parameter("bplus_1", ztf.constant(-0.885), lower_limit = -2.0, upper_limit= 2.0) +bplus_2 = zfit.Parameter("bplus_2", ztf.constant(-0.213), lower_limit = -2.0, upper_limit= 2.0) + +bT_0 = zfit.Parameter("bT_0", ztf.constant(0.460), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +bT_1 = zfit.Parameter("bT_1", ztf.constant(-1.089), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +bT_2 = zfit.Parameter("bT_2", ztf.constant(-1.114), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) + + +#rho + +rho_mass, rho_width, rho_phase, rho_scale = pdg["rho"] + +rho_m = zfit.Parameter("rho_m", ztf.constant(rho_mass), floating = False) #lower_limit = rho_mass - rho_width, upper_limit = rho_mass + rho_width) +rho_w = zfit.Parameter("rho_w", ztf.constant(rho_width), floating = False) +rho_p = zfit.Parameter("rho_p", ztf.constant(rho_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +rho_s = zfit.Parameter("rho_s", ztf.constant(rho_scale), lower_limit=rho_scale-np.sqrt(rho_scale), upper_limit=rho_scale+np.sqrt(rho_scale)) + +#omega + +omega_mass, omega_width, omega_phase, omega_scale = pdg["omega"] + +omega_m = zfit.Parameter("omega_m", ztf.constant(omega_mass), floating = False) +omega_w = zfit.Parameter("omega_w", ztf.constant(omega_width), floating = False) +omega_p = zfit.Parameter("omega_p", ztf.constant(omega_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +omega_s = zfit.Parameter("omega_s", ztf.constant(omega_scale), lower_limit=omega_scale-np.sqrt(omega_scale), upper_limit=omega_scale+np.sqrt(omega_scale)) + + +#phi + +phi_mass, phi_width, phi_phase, phi_scale = pdg["phi"] + +phi_m = zfit.Parameter("phi_m", ztf.constant(phi_mass), floating = False) +phi_w = zfit.Parameter("phi_w", ztf.constant(phi_width), floating = False) +phi_p = zfit.Parameter("phi_p", ztf.constant(phi_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +phi_s = zfit.Parameter("phi_s", ztf.constant(phi_scale), lower_limit=phi_scale-np.sqrt(phi_scale), upper_limit=phi_scale+np.sqrt(phi_scale)) + +#jpsi + +jpsi_mass, jpsi_width, jpsi_phase, jpsi_scale = pdg["jpsi"] + +jpsi_m = zfit.Parameter("jpsi_m", ztf.constant(jpsi_mass), floating = False) +jpsi_w = zfit.Parameter("jpsi_w", ztf.constant(jpsi_width), floating = False) +jpsi_p = zfit.Parameter("jpsi_p", ztf.constant(jpsi_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +jpsi_s = zfit.Parameter("jpsi_s", ztf.constant(jpsi_scale), floating = False) #, lower_limit=jpsi_scale-np.sqrt(jpsi_scale), upper_limit=jpsi_scale+np.sqrt(jpsi_scale)) + +#psi2s + +psi2s_mass, psi2s_width, psi2s_phase, psi2s_scale = pdg["psi2s"] + +psi2s_m = zfit.Parameter("psi2s_m", ztf.constant(psi2s_mass), floating = False) +psi2s_w = zfit.Parameter("psi2s_w", ztf.constant(psi2s_width), floating = False) +psi2s_p = zfit.Parameter("psi2s_p", ztf.constant(psi2s_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +psi2s_s = zfit.Parameter("psi2s_s", ztf.constant(psi2s_scale), floating = False) #, lower_limit=psi2s_scale-np.sqrt(psi2s_scale), upper_limit=psi2s_scale+np.sqrt(psi2s_scale)) + +#psi(3770) + +p3770_mass, p3770_width, p3770_phase, p3770_scale = pdg["p3770"] + +p3770_m = zfit.Parameter("p3770_m", ztf.constant(p3770_mass), floating = False) +p3770_w = zfit.Parameter("p3770_w", ztf.constant(p3770_width), floating = False) +p3770_p = zfit.Parameter("p3770_p", ztf.constant(p3770_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p3770_s = zfit.Parameter("p3770_s", ztf.constant(p3770_scale), lower_limit=p3770_scale-np.sqrt(p3770_scale), upper_limit=p3770_scale+np.sqrt(p3770_scale)) + +#psi(4040) + +p4040_mass, p4040_width, p4040_phase, p4040_scale = pdg["p4040"] + +p4040_m = zfit.Parameter("p4040_m", ztf.constant(p4040_mass), floating = False) +p4040_w = zfit.Parameter("p4040_w", ztf.constant(p4040_width), floating = False) +p4040_p = zfit.Parameter("p4040_p", ztf.constant(p4040_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p4040_s = zfit.Parameter("p4040_s", ztf.constant(p4040_scale), lower_limit=p4040_scale-np.sqrt(p4040_scale), upper_limit=p4040_scale+np.sqrt(p4040_scale)) + +#psi(4160) + +p4160_mass, p4160_width, p4160_phase, p4160_scale = pdg["p4160"] + +p4160_m = zfit.Parameter("p4160_m", ztf.constant(p4160_mass), floating = False) +p4160_w = zfit.Parameter("p4160_w", ztf.constant(p4160_width), floating = False) +p4160_p = zfit.Parameter("p4160_p", ztf.constant(p4160_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p4160_s = zfit.Parameter("p4160_s", ztf.constant(p4160_scale), lower_limit=p4160_scale-np.sqrt(p4160_scale), upper_limit=p4160_scale+np.sqrt(p4160_scale)) + +#psi(4415) + +p4415_mass, p4415_width, p4415_phase, p4415_scale = pdg["p4415"] + +p4415_m = zfit.Parameter("p4415_m", ztf.constant(p4415_mass), floating = False) +p4415_w = zfit.Parameter("p4415_w", ztf.constant(p4415_width), floating = False) +p4415_p = zfit.Parameter("p4415_p", ztf.constant(p4415_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p4415_s = zfit.Parameter("p4415_s", ztf.constant(p4415_scale), lower_limit=p4415_scale-np.sqrt(p4415_scale), upper_limit=p4415_scale+np.sqrt(p4415_scale)) + + +# ## Dynamic generation of 2 particle contribution + +# In[ ]: + + +m_c = 1300 + +Dbar_phase = 0.0 +DDstar_phase = 0.0 +Dstar_mass = pdg['Dst_M'] +Dbar_mass = pdg['D0_M'] +D_mass = pdg['D0_M'] + +Dbar_s = zfit.Parameter("Dbar_s", ztf.constant(0.0), lower_limit=-0.3, upper_limit=0.3) +Dbar_m = zfit.Parameter("Dbar_m", ztf.constant(Dbar_mass), floating = False) +Dbar_p = zfit.Parameter("Dbar_p", ztf.constant(Dbar_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi)#, floating = False) +DDstar_s = zfit.Parameter("DDstar_s", ztf.constant(0.0), lower_limit=-0.3, upper_limit=0.3)#, floating = False) +Dstar_m = zfit.Parameter("Dstar_m", ztf.constant(Dstar_mass), floating = False) +D_m = zfit.Parameter("D_m", ztf.constant(D_mass), floating = False) +DDstar_p = zfit.Parameter("DDstar_p", ztf.constant(DDstar_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi)#, floating = False) + + +# ## Tau parameters + +# In[ ]: + + +tau_m = zfit.Parameter("tau_m", ztf.constant(pdg['tau_M']), floating = False) +Ctt = zfit.Parameter("Ctt", ztf.constant(0.0), lower_limit=-2.5, upper_limit=2.5) + + +# ## Load data + +# In[ ]: + + +x_min = 2*pdg['muon_M'] +x_max = (pdg["Bplus_M"]-pdg["Ks_M"]-0.1) + +# # Full spectrum + +obs_toy = zfit.Space('q', limits = (x_min, x_max)) + +# Jpsi and Psi2s cut out + +obs1 = zfit.Space('q', limits = (x_min, jpsi_mass - 60.)) +obs2 = zfit.Space('q', limits = (jpsi_mass + 70., psi2s_mass - 50.)) +obs3 = zfit.Space('q', limits = (psi2s_mass + 50., x_max)) + +obs_fit = obs1 + obs2 + obs3 + +# with open(r"./data/slim_points/slim_points_toy_0_range({0}-{1}).pkl".format(int(x_min), int(x_max)), "rb") as input_file: +# part_set = pkl.load(input_file) + +# x_part = part_set['x_part'] + +# x_part = x_part.astype('float64') + +# data = zfit.data.Data.from_numpy(array=x_part, obs=obs) + + +# ## Setup pdf + +# In[ ]: + + +total_f = total_pdf_cut(obs=obs_toy, jpsi_mass = jpsi_m, jpsi_scale = jpsi_s, jpsi_phase = jpsi_p, jpsi_width = jpsi_w, + psi2s_mass = psi2s_m, psi2s_scale = psi2s_s, psi2s_phase = psi2s_p, psi2s_width = psi2s_w, + p3770_mass = p3770_m, p3770_scale = p3770_s, p3770_phase = p3770_p, p3770_width = p3770_w, + p4040_mass = p4040_m, p4040_scale = p4040_s, p4040_phase = p4040_p, p4040_width = p4040_w, + p4160_mass = p4160_m, p4160_scale = p4160_s, p4160_phase = p4160_p, p4160_width = p4160_w, + p4415_mass = p4415_m, p4415_scale = p4415_s, p4415_phase = p4415_p, p4415_width = p4415_w, + rho_mass = rho_m, rho_scale = rho_s, rho_phase = rho_p, rho_width = rho_w, + omega_mass = omega_m, omega_scale = omega_s, omega_phase = omega_p, omega_width = omega_w, + phi_mass = phi_m, phi_scale = phi_s, phi_phase = phi_p, phi_width = phi_w, + Dstar_mass = Dstar_m, DDstar_scale = DDstar_s, DDstar_phase = DDstar_p, D_mass = D_m, + Dbar_mass = Dbar_m, Dbar_scale = Dbar_s, Dbar_phase = Dbar_p, + tau_mass = tau_m, C_tt = Ctt, b0_0 = b0_0, b0_1 = b0_1, b0_2 = b0_2, + bplus_0 = bplus_0, bplus_1 = bplus_1, bplus_2 = bplus_2, + bT_0 = bT_0, bT_1 = bT_1, bT_2 = bT_2) + +total_f_fit = total_pdf_full(obs=obs_fit, jpsi_mass = jpsi_m, jpsi_scale = jpsi_s, jpsi_phase = jpsi_p, jpsi_width = jpsi_w, + psi2s_mass = psi2s_m, psi2s_scale = psi2s_s, psi2s_phase = psi2s_p, psi2s_width = psi2s_w, + p3770_mass = p3770_m, p3770_scale = p3770_s, p3770_phase = p3770_p, p3770_width = p3770_w, + p4040_mass = p4040_m, p4040_scale = p4040_s, p4040_phase = p4040_p, p4040_width = p4040_w, + p4160_mass = p4160_m, p4160_scale = p4160_s, p4160_phase = p4160_p, p4160_width = p4160_w, + p4415_mass = p4415_m, p4415_scale = p4415_s, p4415_phase = p4415_p, p4415_width = p4415_w, + rho_mass = rho_m, rho_scale = rho_s, rho_phase = rho_p, rho_width = rho_w, + omega_mass = omega_m, omega_scale = omega_s, omega_phase = omega_p, omega_width = omega_w, + phi_mass = phi_m, phi_scale = phi_s, phi_phase = phi_p, phi_width = phi_w, + Dstar_mass = Dstar_m, DDstar_scale = DDstar_s, DDstar_phase = DDstar_p, D_mass = D_m, + Dbar_mass = Dbar_m, Dbar_scale = Dbar_s, Dbar_phase = Dbar_p, + tau_mass = tau_m, C_tt = Ctt, b0_0 = b0_0, b0_1 = b0_1, b0_2 = b0_2, + bplus_0 = bplus_0, bplus_1 = bplus_1, bplus_2 = bplus_2, + bT_0 = bT_0, bT_1 = bT_1, bT_2 = bT_2) + +# print(total_pdf.obs) + +# print(calcs_test) + +# for param in total_f.get_dependents(): +# print(zfit.run(param)) + + +# In[ ]: + + +# total_f_fit.normalization(obs_fit) + + +# ## Test if graphs actually work and compute values + +# In[ ]: + + +# def total_test_tf(xq): + +# def jpsi_res(q): +# return resonance(q, jpsi_m, jpsi_s, jpsi_p, jpsi_w) + +# def psi2s_res(q): +# return resonance(q, psi2s_m, psi2s_s, psi2s_p, psi2s_w) + +# def cusp(q): +# return bifur_gauss(q, cusp_m, sig_L, sig_R, cusp_s) + +# funcs = jpsi_res(xq) + psi2s_res(xq) + cusp(xq) + +# vec_f = vec(xq, funcs) + +# axiv_nr = axiv_nonres(xq) + +# tot = vec_f + axiv_nr + +# return tot + +# def jpsi_res(q): +# return resonance(q, jpsi_m, jpsi_s, jpsi_p, jpsi_w) + +# calcs = zfit.run(total_test_tf(x_part)) + + + +test_q = np.linspace(x_min, x_max, int(2e6)) + +probs = total_f_fit.pdf(test_q, norm_range=False) + +calcs_test = zfit.run(probs) + +Ctt.set_value(0.5) + +calcs_test1 = zfit.run(probs) + +Ctt.set_value(0.0) + +Dbar_s.set_value(0.3) + +DDstar_s.set_value(0.3) + +calcs_test2 = zfit.run(probs) +# res_y = zfit.run(jpsi_res(test_q)) +# b0 = [b0_0, b0_1, b0_2] +# bplus = [bplus_0, bplus_1, bplus_2] +# bT = [bT_0, bT_1, bT_2] +# f0_y = zfit.run(tf.math.real(formfactor(test_q,"0", b0, bplus, bT))) +# fplus_y = zfit.run(tf.math.real(formfactor(test_q,"+", b0, bplus, bT))) +# fT_y = zfit.run(tf.math.real(formfactor(test_q,"T", b0, bplus, bT))) + + +# In[ ]: + + +plt.clf() +# plt.plot(x_part, calcs, '.') +plt.plot(test_q, calcs_test, label = 'pdf (Ctt = 0.0)') +plt.plot(test_q, calcs_test1, label = 'pdf (Ctt = 0.5)') +plt.plot(test_q, calcs_test2, label = 'pdf (D-contribs = 0.3)') +# plt.plot(test_q, f0_y, label = '0') +# plt.plot(test_q, fT_y, label = 'T') +# plt.plot(test_q, fplus_y, label = '+') +# plt.plot(test_q, res_y, label = 'res') +plt.legend() +plt.ylim(0.0, 1.5e-6) +# plt.yscale('log') +# plt.xlim(770, 785) +plt.savefig('test.png') +# print(jpsi_width) + + +# In[ ]: + + + + +# probs = mixture.prob(test_q) +# probs_np = zfit.run(probs) +# probs_np *= np.max(calcs_test) / np.max(probs_np) +# plt.figure() +# plt.semilogy(test_q, probs_np,label="importance sampling") +# plt.semilogy(test_q, calcs_test, label = 'pdf') + + +# In[ ]: + + +# 0.213/(0.00133+0.213+0.015) + + +# ## Adjust scaling of different parts + +# In[ ]: + + +total_f.update_integration_options(draws_per_dim=2000000, mc_sampler=None) +# inte = total_f.integrate(limits = (950., 1050.), norm_range=False) +# inte_fl = zfit.run(inte) +# print(inte_fl/4500) +# print(pdg["jpsi_BR"]/pdg["NR_BR"], inte_fl*pdg["psi2s_auc"]/pdg["NR_auc"]) + + +# In[ ]: + + +# # print("jpsi:", inte_fl) +# # print("Increase am by factor:", np.sqrt(pdg["jpsi_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) +# # print("New amp:", pdg["jpsi"][3]*np.sqrt(pdg["jpsi_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) + +# # print("psi2s:", inte_fl) +# # print("Increase am by factor:", np.sqrt(pdg["psi2s_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) +# # print("New amp:", pdg["psi2s"][3]*np.sqrt(pdg["psi2s_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) + +# name = "phi" + +# print(name+":", inte_fl) +# print("Increase am by factor:", np.sqrt(pdg[name+"_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) +# print("New amp:", pdg[name][0]*np.sqrt(pdg[name+"_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) + + +# print(x_min) +# print(x_max) +# # total_f.update_integration_options(draws_per_dim=2000000, mc_sampler=None) +# total_f.update_integration_options(mc_sampler=lambda dim, num_results, +# dtype: tf.random_uniform(maxval=1., shape=(num_results, dim), dtype=dtype), +# draws_per_dim=1000000) +# # _ = [] + +# # for i in range(10): + +# # inte = total_f.integrate(limits = (x_min, x_max)) +# # inte_fl = zfit.run(inte) +# # print(inte_fl) +# # _.append(inte_fl) + +# # print("mean:", np.mean(_)) + +# _ = time.time() + +# inte = total_f.integrate(limits = (x_min, x_max)) +# inte_fl = zfit.run(inte) +# print(inte_fl) +# print("Time taken: {}".format(display_time(int(time.time() - _)))) + +# print(pdg['NR_BR']/pdg['NR_auc']*inte_fl) +# print(0.25**2*4.2/1000) + + +# # Sampling +# ## Mixture distribution for sampling + +# In[ ]: + + + + +# print(list_of_borders[:9]) +# print(list_of_borders[-9:]) + + +class UniformSampleAndWeights(zfit.util.execution.SessionHolderMixin): + def __call__(self, limits, dtype, n_to_produce): + # n_to_produce = tf.cast(n_to_produce, dtype=tf.int32) + low, high = limits.limit1d + low = tf.cast(low, dtype=dtype) + high = tf.cast(high, dtype=dtype) +# uniform = tfd.Uniform(low=low, high=high) +# uniformjpsi = tfd.Uniform(low=tf.constant(3080, dtype=dtype), high=tf.constant(3112, dtype=dtype)) +# uniformpsi2s = tfd.Uniform(low=tf.constant(3670, dtype=dtype), high=tf.constant(3702, dtype=dtype)) + +# list_of_borders = [] +# _p = [] +# splits = 10 + +# _ = np.linspace(x_min, x_max, splits) + +# for i in range(splits): +# list_of_borders.append(tf.constant(_[i], dtype=dtype)) +# _p.append(tf.constant(1/splits, dtype=dtype)) + +# mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=_p[:(splits-1)]), +# components_distribution=tfd.Uniform(low=list_of_borders[:(splits-1)], +# high=list_of_borders[-(splits-1):])) + mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=[tf.constant(0.05, dtype=dtype), + tf.constant(0.93, dtype=dtype), + tf.constant(0.05, dtype=dtype), + tf.constant(0.065, dtype=dtype), + tf.constant(0.04, dtype=dtype), + tf.constant(0.05, dtype=dtype)]), + components_distribution=tfd.Uniform(low=[tf.constant(x_min, dtype=dtype), + tf.constant(3090, dtype=dtype), + tf.constant(3681, dtype=dtype), + tf.constant(3070, dtype=dtype), + tf.constant(1000, dtype=dtype), + tf.constant(3660, dtype=dtype)], + high=[tf.constant(x_max, dtype=dtype), + tf.constant(3102, dtype=dtype), + tf.constant(3691, dtype=dtype), + tf.constant(3110, dtype=dtype), + tf.constant(1040, dtype=dtype), + tf.constant(3710, dtype=dtype)])) +# dtype = tf.float64 +# mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=[tf.constant(0.04, dtype=dtype), +# tf.constant(0.90, dtype=dtype), +# tf.constant(0.02, dtype=dtype), +# tf.constant(0.07, dtype=dtype), +# tf.constant(0.02, dtype=dtype)]), +# components_distribution=tfd.Uniform(low=[tf.constant(x_min, dtype=dtype), +# tf.constant(3089, dtype=dtype), +# tf.constant(3103, dtype=dtype), +# tf.constant(3681, dtype=dtype), +# tf.constant(3691, dtype=dtype)], +# high=[tf.constant(3089, dtype=dtype), +# tf.constant(3103, dtype=dtype), +# tf.constant(3681, dtype=dtype), +# tf.constant(3691, dtype=dtype), +# tf.constant(x_max, dtype=dtype)])) +# mixture = tfd.Uniform(tf.constant(x_min, dtype=dtype), tf.constant(x_max, dtype=dtype)) +# sample = tf.random.uniform((n_to_produce, 1), dtype=dtype) + sample = mixture.sample((n_to_produce, 1)) +# sample = tf.random.uniform((n_to_produce, 1), dtype=dtype) + weights = mixture.prob(sample)[:,0] +# weights = tf.broadcast_to(tf.constant(1., dtype=dtype), shape=(n_to_produce,)) + # sample = tf.expand_dims(sample, axis=-1) +# print(sample, weights) + +# weights = tf.ones(shape=(n_to_produce,), dtype=dtype) + weights_max = None + thresholds = tf.random_uniform(shape=(n_to_produce,), dtype=dtype) + return sample, thresholds, weights, weights_max, n_to_produce + + +# In[ ]: + + +# total_f._sample_and_weights = UniformSampleAndWeights + + +# In[ ]: + + +# 0.00133/(0.00133+0.213+0.015)*(x_max-3750)/(x_max-x_min) + + +# In[ ]: + + +# zfit.settings.set_verbosity(10) + + +# In[ ]: + + +# # zfit.run.numeric_checks = False + +# nr_of_toys = 1 +# nevents = int(pdg["number_of_decays"]) +# nevents = pdg["number_of_decays"] +# event_stack = 1000000 +# # zfit.settings.set_verbosity(10) +# calls = int(nevents/event_stack + 1) + +# total_samp = [] + +# start = time.time() + +# sampler = total_f.create_sampler(n=event_stack) + +# for toy in range(nr_of_toys): + +# dirName = 'data/zfit_toys/toy_{0}'.format(toy) + +# if not os.path.exists(dirName): +# os.mkdir(dirName) +# print("Directory " , dirName , " Created ") + +# for call in range(calls): + +# sampler.resample(n=event_stack) +# s = sampler.unstack_x() +# sam = zfit.run(s) +# # clear_output(wait=True) + +# c = call + 1 + +# print("{0}/{1} of Toy {2}/{3}".format(c, calls, toy+1, nr_of_toys)) +# print("Time taken: {}".format(display_time(int(time.time() - start)))) +# print("Projected time left: {}".format(display_time(int((time.time() - start)/(c+calls*(toy))*((nr_of_toys-toy)*calls-c))))) + +# with open("data/zfit_toys/toy_{0}/{1}.pkl".format(toy, call), "wb") as f: +# pkl.dump(sam, f, pkl.HIGHEST_PROTOCOL) + + +# In[ ]: + + +# with open(r"data/zfit_toys/toy_0/0.pkl", "rb") as input_file: +# sam = pkl.load(input_file) +# print(sam[:10]) + +# with open(r"data/zfit_toys/toy_0/1.pkl", "rb") as input_file: +# sam2 = pkl.load(input_file) +# print(sam2[:10]) + +# print(np.sum(sam-sam2)) + + +# In[ ]: + + +# print("Time to generate full toy: {} s".format(int(time.time()-start))) + +# total_samp = [] + +# for call in range(calls): +# with open(r"data/zfit_toys/toy_0/{}.pkl".format(call), "rb") as input_file: +# sam = pkl.load(input_file) +# total_samp = np.append(total_samp, sam) + +# total_samp = total_samp.astype('float64') + +# data2 = zfit.data.Data.from_numpy(array=total_samp[:int(nevents)], obs=obs) + +# data3 = zfit.data.Data.from_numpy(array=total_samp, obs=obs) + +# print(total_samp[:nevents].shape) + + +# In[ ]: + + +# plt.clf() + +# bins = int((x_max-x_min)/7) + +# # calcs = zfit.run(total_test_tf(samp)) +# print(total_samp[:nevents].shape) + +# plt.hist(total_samp[:nevents], bins = bins, range = (x_min,x_max), label = 'data') +# # plt.plot(test_q, calcs_test*nevents , label = 'pdf') + +# # plt.plot(sam, calcs, '.') +# # plt.plot(test_q, calcs_test) +# # plt.yscale('log') +# plt.ylim(0, 200) +# # plt.xlim(3080, 3110) + +# plt.legend() + +# plt.savefig('test2.png') + + +# In[ ]: + + +# sampler = total_f.create_sampler(n=nevents) +# nll = zfit.loss.UnbinnedNLL(model=total_f, data=sampler, fit_range = (x_min, x_max)) + +# # for param in pdf.get_dependents(): +# # param.set_value(initial_value) + +# sampler.resample(n=nevents) + +# # Randomise initial values +# # for param in pdf.get_dependents(): +# # param.set_value(random value here) + +# # Minimise the NLL +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 10) +# minimum = minimizer.minimize(nll) + + +# In[ ]: + + +# jpsi_width + + +# In[ ]: + + +# plt.hist(sample, weights=1 / prob(sample)) + + +# # Fitting + +# In[ ]: + + +# start = time.time() + +# for param in total_f.get_dependents(): +# param.randomize() + +# # for param in total_f.get_dependents(): +# # print(zfit.run(param)) + +# nll = zfit.loss.UnbinnedNLL(model=total_f, data=data2, fit_range = (x_min, x_max)) + +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) +# # minimizer._use_tfgrad = False +# result = minimizer.minimize(nll) + +# # param_errors = result.error() + +# # for var, errors in param_errors.items(): +# # print('{}: ^{{+{}}}_{{{}}}'.format(var.name, errors['upper'], errors['lower'])) + +# print("Function minimum:", result.fmin) +# # print("Results:", result.params) +# print("Hesse errors:", result.hesse()) + + +# In[ ]: + + +# print("Time taken for fitting: {}".format(display_time(int(time.time()-start)))) + +# # probs = total_f.pdf(test_q) + +# calcs_test = zfit.run(probs) +# res_y = zfit.run(jpsi_res(test_q)) + + +# In[ ]: + + +# plt.clf() +# # plt.plot(x_part, calcs, '.') +# plt.plot(test_q, calcs_test, label = 'pdf') +# # plt.plot(test_q, res_y, label = 'res') +# plt.legend() +# plt.ylim(0.0, 10e-6) +# # plt.yscale('log') +# # plt.xlim(3080, 3110) +# plt.savefig('test3.png') +# # print(jpsi_width) + + +# In[ ]: + + +# _tot = 4.37e-7+6.02e-5+4.97e-6 +# _probs = [] +# _probs.append(6.02e-5/_tot) +# _probs.append(4.97e-6/_tot) +# _probs.append(4.37e-7/_tot) +# print(_probs) + + +# In[ ]: + + +# dtype = 'float64' +# # mixture = tfd.Uniform(tf.constant(x_min, dtype=dtype), tf.constant(x_max, dtype=dtype)) +# mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=[tf.constant(0.007, dtype=dtype), +# tf.constant(0.917, dtype=dtype), +# tf.constant(0.076, dtype=dtype)]), +# components_distribution=tfd.Uniform(low=[tf.constant(x_min, dtype=dtype), +# tf.constant(3080, dtype=dtype), +# tf.constant(3670, dtype=dtype)], +# high=[tf.constant(x_max, dtype=dtype), +# tf.constant(3112, dtype=dtype), +# tf.constant(3702, dtype=dtype)])) +# # for i in range(10): +# # print(zfit.run(mixture.prob(mixture.sample((10, 1))))) + + +# In[ ]: + + +# print((zfit.run(jpsi_p)%(2*np.pi))/np.pi) +# print((zfit.run(psi2s_p)%(2*np.pi))/np.pi) + + +# In[ ]: + + +# def jpsi_res(q): +# return resonance(q, _mass = jpsi_mass, scale = jpsi_scale, +# phase = jpsi_phase, width = jpsi_width) + +# def psi2s_res(q): +# return resonance(q, _mass = psi2s_mass, scale = psi2s_scale, +# phase = psi2s_phase, width = psi2s_width) + +# def p3770_res(q): +# return resonance(q, _mass = p3770_mass, scale = p3770_scale, +# phase = p3770_phase, width = p3770_width) + +# def p4040_res(q): +# return resonance(q, _mass = p4040_mass, scale = p4040_scale, +# phase = p4040_phase, width = p4040_width) + +# def p4160_res(q): +# return resonance(q, _mass = p4160_mass, scale = p4160_scale, +# phase = p4160_phase, width = p4160_width) + +# def p4415_res(q): +# return resonance(q, _mass = p4415_mass, scale = p4415_scale, +# phase = p4415_phase, width = p4415_width) + + +# In[ ]: + + +# 0.15**2*4.2/1000 +# result.hesse() + + +# ## Constraints + +# In[ ]: + + +# 1. Constraint - Real part of sum of Psi contrib and D contribs + +sum_list = [] + +sum_list.append(ztf.to_complex(jpsi_s) * tf.exp(tf.complex(ztf.constant(0.0), jpsi_p)) * ztf.to_complex(jpsi_w / (tf.pow(jpsi_m,3)))) +sum_list.append(ztf.to_complex(psi2s_s) * tf.exp(tf.complex(ztf.constant(0.0), psi2s_p)) * ztf.to_complex(psi2s_w / (tf.pow(psi2s_m,3)))) +sum_list.append(ztf.to_complex(p3770_s) * tf.exp(tf.complex(ztf.constant(0.0), p3770_p)) * ztf.to_complex(p3770_w / (tf.pow(p3770_m,3)))) +sum_list.append(ztf.to_complex(p4040_s) * tf.exp(tf.complex(ztf.constant(0.0), p4040_p)) * ztf.to_complex(p4040_w / (tf.pow(p4040_m,3)))) +sum_list.append(ztf.to_complex(p4160_s) * tf.exp(tf.complex(ztf.constant(0.0), p4160_p)) * ztf.to_complex(p4160_w / (tf.pow(p4160_m,3)))) +sum_list.append(ztf.to_complex(p4415_s) * tf.exp(tf.complex(ztf.constant(0.0), p4415_p)) * ztf.to_complex(p4415_w / (tf.pow(p4415_m,3)))) +sum_list.append(ztf.to_complex(DDstar_s) * tf.exp(tf.complex(ztf.constant(0.0), DDstar_p)) * (ztf.to_complex(1.0 / (10.0*tf.pow(Dstar_m,2)) + 1.0 / (10.0*tf.pow(D_m,2))))) +sum_list.append(ztf.to_complex(Dbar_s) * tf.exp(tf.complex(ztf.constant(0.0), Dbar_p)) * ztf.to_complex(1.0 / (6.0*tf.pow(Dbar_m,2)))) + +sum_ru_1 = ztf.to_complex(ztf.constant(0.0)) + +for part in sum_list: + sum_ru_1 += part + +sum_1 = tf.math.real(sum_ru_1) +# constraint1 = zfit.constraint.GaussianConstraint(params = sum_1, mu = ztf.constant(1.7*10**-8), +# sigma = ztf.constant(2.2*10**-8)) + +constraint1 = tf.pow((sum_1-ztf.constant(1.7*10**-8))/ztf.constant(2.2*10**-8),2)/ztf.constant(2.) + +# 2. Constraint - Abs. of sum of Psi contribs and D contribs + +sum_2 = tf.abs(sum_ru_1) +constraint2 = tf.cond(tf.greater_equal(sum_2, 5.0e-8), lambda: 100000., lambda: 0.) + +# 3. Constraint - Maximum eta of D contribs + +constraint3_0 = tf.cond(tf.greater_equal(tf.abs(Dbar_s), 0.2), lambda: 100000., lambda: 0.) + +constraint3_1 = tf.cond(tf.greater_equal(tf.abs(DDstar_s), 0.2), lambda: 100000., lambda: 0.) + +# 4. Constraint - Formfactor multivariant gaussian covariance fplus + +Cov_matrix = [[ztf.constant( 1.), ztf.constant( 0.45), ztf.constant( 0.19), ztf.constant(0.857), ztf.constant(0.598), ztf.constant(0.531), ztf.constant(0.752), ztf.constant(0.229), ztf.constant(0,117)], + [ztf.constant( 0.45), ztf.constant( 1.), ztf.constant(0.677), ztf.constant(0.708), ztf.constant(0.958), ztf.constant(0.927), ztf.constant(0.227), ztf.constant(0.443), ztf.constant(0.287)], + [ztf.constant( 0.19), ztf.constant(0.677), ztf.constant( 1.), ztf.constant(0.595), ztf.constant(0.770), ztf.constant(0.819),ztf.constant(-0.023), ztf.constant( 0.07), ztf.constant(0.196)], + [ztf.constant(0.857), ztf.constant(0.708), ztf.constant(0.595), ztf.constant( 1.), ztf.constant( 0.83), ztf.constant(0.766), ztf.constant(0.582), ztf.constant(0.237), ztf.constant(0.192)], + [ztf.constant(0.598), ztf.constant(0.958), ztf.constant(0.770), ztf.constant( 0.83), ztf.constant( 1.), ztf.constant(0.973), ztf.constant(0.324), ztf.constant(0.372), ztf.constant(0.272)], + [ztf.constant(0.531), ztf.constant(0.927), ztf.constant(0.819), ztf.constant(0.766), ztf.constant(0.973), ztf.constant( 1.), ztf.constant(0.268), ztf.constant(0.332), ztf.constant(0.269)], + [ztf.constant(0.752), ztf.constant(0.227),ztf.constant(-0.023), ztf.constant(0.582), ztf.constant(0.324), ztf.constant(0.268), ztf.constant( 1.), ztf.constant( 0.59), ztf.constant(0.515)], + [ztf.constant(0.229), ztf.constant(0.443), ztf.constant( 0.07), ztf.constant(0.237), ztf.constant(0.372), ztf.constant(0.332), ztf.constant( 0.59), ztf.constant( 1.), ztf.constant(0.897)], + [ztf.constant(0.117), ztf.constant(0.287), ztf.constant(0.196), ztf.constant(0.192), ztf.constant(0.272), ztf.constant(0.269), ztf.constant(0.515), ztf.constant(0.897), ztf.constant( 1.)]] + +def triGauss(val1,val2,val3,m = Cov_matrix): + + mean1 = ztf.constant(0.466) + mean2 = ztf.constant(-0.885) + mean3 = ztf.constant(-0.213) + sigma1 = ztf.constant(0.014) + sigma2 = ztf.constant(0.128) + sigma3 = ztf.constant(0.548) + x1 = (val1-mean1)/sigma1 + x2 = (val2-mean2)/sigma2 + x3 = (val3-mean3)/sigma3 + rho12 = m[0][1] + rho13 = m[0][2] + rho23 = m[1][2] + w = x1*x1*(rho23*rho23-1) + x2*x2*(rho13*rho13-1)+x3*x3*(rho12*rho12-1)+2*(x1*x2*(rho12-rho13*rho23)+x1*x3*(rho13-rho12*rho23)+x2*x3*(rho23-rho12*rho13)) + d = 2*(rho12*rho12+rho13*rho13+rho23*rho23-2*rho12*rho13*rho23-1) + + fcn = -w/d + chisq = -2*fcn + return chisq + +constraint4 = triGauss(bplus_0, bplus_1, bplus_2) + +# mean1 = ztf.constant(0.466) +# mean2 = ztf.constant(-0.885) +# mean3 = ztf.constant(-0.213) +# sigma1 = ztf.constant(0.014) +# sigma2 = ztf.constant(0.128) +# sigma3 = ztf.constant(0.548) +# constraint4_0 = tf.pow((bplus_0-mean1)/sigma1,2)/ztf.constant(2.) +# constraint4_1 = tf.pow((bplus_1-mean2)/sigma2,2)/ztf.constant(2.) +# constraint4_2 = tf.pow((bplus_2-mean3)/sigma3,2)/ztf.constant(2.) + +# 5. Constraint - Abs. of sum of light contribs + +sum_list_5 = [] + +sum_list_5.append(rho_s*rho_w/rho_m) +sum_list_5.append(omega_s*omega_w/omega_m) +sum_list_5.append(phi_s*phi_w/phi_m) + + +sum_ru_5 = ztf.constant(0.0) + +for part in sum_list_5: + sum_ru_5 += part + +constraint5 = tf.cond(tf.greater_equal(tf.abs(sum_ru_5), ztf.constant(0.02)), lambda: 100000., lambda: 0.) + +# 6. Constraint on phases of Jpsi and Psi2s for cut out fit + + +# constraint6_0 = zfit.constraint.GaussianConstraint(params = jpsi_p, mu = ztf.constant(pdg["jpsi_phase_unc"]), +# sigma = ztf.constant(jpsi_phase)) +# constraint6_1 = zfit.constraint.GaussianConstraint(params = psi2s_p, mu = ztf.constant(pdg["psi2s_phase_unc"]), +# sigma = ztf.constant(psi2s_phase)) + +constraint6_0 = tf.pow((jpsi_p-ztf.constant(jpsi_phase))/ztf.constant(pdg["jpsi_phase_unc"]),2)/ztf.constant(2.) +constraint6_1 = tf.pow((psi2s_p-ztf.constant(psi2s_phase))/ztf.constant(pdg["psi2s_phase_unc"]),2)/ztf.constant(2.) + +# 7. Constraint on Ctt with higher limits + +constraint7 = tf.cond(tf.greater_equal(Ctt*Ctt, 0.25), lambda: 100000., lambda: 0.) + +constraint7dtype = tf.float64 + +# zfit.run(constraint6_0) + +# ztf.convert_to_tensor(constraint6_0) + +#List of all constraints + +constraints = [constraint1, constraint2, constraint3_0, constraint3_1,# constraint4, #constraint4_0, constraint4_1, constraint4_2, + constraint6_0, constraint6_1]#, constraint7] + + +# ## Reset params + +# In[ ]: + + +param_values_dic = { + 'jpsi_m': jpsi_mass, + 'jpsi_s': jpsi_scale, + 'jpsi_p': jpsi_phase, + 'jpsi_w': jpsi_width, + 'psi2s_m': psi2s_mass, + 'psi2s_s': psi2s_scale, + 'psi2s_p': psi2s_phase, + 'psi2s_w': psi2s_width, + 'p3770_m': p3770_mass, + 'p3770_s': p3770_scale, + 'p3770_p': p3770_phase, + 'p3770_w': p3770_width, + 'p4040_m': p4040_mass, + 'p4040_s': p4040_scale, + 'p4040_p': p4040_phase, + 'p4040_w': p4040_width, + 'p4160_m': p4160_mass, + 'p4160_s': p4160_scale, + 'p4160_p': p4160_phase, + 'p4160_w': p4160_width, + 'p4415_m': p4415_mass, + 'p4415_s': p4415_scale, + 'p4415_p': p4415_phase, + 'p4415_w': p4415_width, + 'rho_m': rho_mass, + 'rho_s': rho_scale, + 'rho_p': rho_phase, + 'rho_w': rho_width, + 'omega_m': omega_mass, + 'omega_s': omega_scale, + 'omega_p': omega_phase, + 'omega_w': omega_width, + 'phi_m': phi_mass, + 'phi_s': phi_scale, + 'phi_p': phi_phase, + 'phi_w': phi_width, + 'Dstar_m': Dstar_mass, + 'DDstar_s': 0.0, + 'DDstar_p': 0.0, + 'D_m': D_mass, + 'Dbar_m': Dbar_mass, + 'Dbar_s': 0.0, + 'Dbar_p': 0.0, + 'tau_m': pdg['tau_M'], + 'Ctt': 0.0, + 'b0_0': 0.292, + 'b0_1': 0.281, + 'b0_2': 0.150, + 'bplus_0': 0.466, + 'bplus_1': -0.885, + 'bplus_2': -0.213, + 'bT_0': 0.460, + 'bT_1': -1.089, + 'bT_2': -1.114} + + +def reset_param_values(variation = 0.05): + for param in total_f_fit.get_dependents(): + if param.floating: + param.set_value(param_values_dic[param.name] + random.uniform(-1, 1) * param_values_dic[param.name]* variation) +# print(param.name) +# for param in totalf.get_dependents(): +# param.set_value() + + +# # Analysis + +# In[ ]: + + +# # zfit.run.numeric_checks = False + +# fitting_range = 'cut' +# total_BR = 1.7e-10 + 4.9e-10 + 2.5e-9 + 6.02e-5 + 4.97e-6 + 1.38e-9 + 4.2e-10 + 2.6e-9 + 6.1e-10 + 4.37e-7 +# cut_BR = 1.0 - (6.02e-5 + 4.97e-6)/total_BR + +# Ctt_list = [] +# Ctt_error_list = [] + +# nr_of_toys = 1 +# if fitting_range == 'cut': +# nevents = int(pdg["number_of_decays"]*cut_BR) +# else: +# nevents = int(pdg["number_of_decays"]) +# # nevents = pdg["number_of_decays"] +# event_stack = 1000000 +# # nevents *= 41 +# # zfit.settings.set_verbosity(10) +# calls = int(nevents/event_stack + 1) + +# total_samp = [] + +# start = time.time() + +# sampler = total_f.create_sampler(n=event_stack) + +# for toy in range(nr_of_toys): + +# ### Generate data + +# # clear_output(wait=True) + +# print("Toy {}: Generating data...".format(toy)) + +# dirName = 'data/zfit_toys/toy_{0}'.format(toy) + +# if not os.path.exists(dirName): +# os.mkdir(dirName) +# print("Directory " , dirName , " Created ") + +# reset_param_values() + +# if fitting_range == 'cut': + +# sampler.resample(n=nevents) +# s = sampler.unstack_x() +# sam = zfit.run(s) +# calls = 0 +# c = 1 + +# else: +# for call in range(calls): + +# sampler.resample(n=event_stack) +# s = sampler.unstack_x() +# sam = zfit.run(s) + +# c = call + 1 + +# with open("data/zfit_toys/toy_{0}/{1}.pkl".format(toy, call), "wb") as f: +# pkl.dump(sam, f, pkl.HIGHEST_PROTOCOL) + +# print("Toy {}: Data generation finished".format(toy)) + +# ### Load data + +# print("Toy {}: Loading data...".format(toy)) + +# if fitting_range == 'cut': + +# total_samp = sam + +# else: + +# for call in range(calls): +# with open(r"data/zfit_toys/toy_0/{}.pkl".format(call), "rb") as input_file: +# sam = pkl.load(input_file) +# total_samp = np.append(total_samp, sam) + +# total_samp = total_samp.astype('float64') + +# if fitting_range == 'full': + +# data = zfit.data.Data.from_numpy(array=total_samp[:int(nevents)], obs=obs) + +# print("Toy {}: Loading data finished".format(toy)) + +# ### Fit data + +# print("Toy {}: Fitting pdf...".format(toy)) + +# for param in total_f.get_dependents(): +# param.randomize() + +# nll = zfit.loss.UnbinnedNLL(model=total_f, data=data, fit_range = (x_min, x_max), constraints = constraints) + +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) +# # minimizer._use_tfgrad = False +# result = minimizer.minimize(nll) + +# print("Toy {}: Fitting finished".format(toy)) + +# print("Function minimum:", result.fmin) +# print("Hesse errors:", result.hesse()) + +# params = result.params +# Ctt_list.append(params[Ctt]['value']) +# Ctt_error_list.append(params[Ctt]['minuit_hesse']['error']) + +# #plotting the result + +# plotdirName = 'data/plots'.format(toy) + +# if not os.path.exists(plotdirName): +# os.mkdir(plotdirName) +# # print("Directory " , dirName , " Created ") + +# probs = total_f.pdf(test_q, norm_range=False) +# calcs_test = zfit.run(probs) +# plt.clf() +# plt.plot(test_q, calcs_test, label = 'pdf') +# plt.legend() +# plt.ylim(0.0, 6e-6) +# plt.savefig(plotdirName + '/toy_fit_full_range{}.png'.format(toy)) + +# print("Toy {0}/{1}".format(toy+1, nr_of_toys)) +# print("Time taken: {}".format(display_time(int(time.time() - start)))) +# print("Projected time left: {}".format(display_time(int((time.time() - start)/(c+calls*(toy))*((nr_of_toys-toy)*calls-c))))) + +# if fitting_range == 'cut': + +# _1 = np.where((total_samp >= x_min) & (total_samp <= (jpsi_mass - 60.))) + +# tot_sam_1 = total_samp[_1] + +# _2 = np.where((total_samp >= (jpsi_mass + 70.)) & (total_samp <= (psi2s_mass - 50.))) + +# tot_sam_2 = total_samp[_2] + +# _3 = np.where((total_samp >= (psi2s_mass + 50.)) & (total_samp <= x_max)) + +# tot_sam_3 = total_samp[_3] + +# tot_sam = np.append(tot_sam_1, tot_sam_2) +# tot_sam = np.append(tot_sam, tot_sam_3) + +# data = zfit.data.Data.from_numpy(array=tot_sam[:int(nevents)], obs=obs_fit) + +# print("Toy {}: Loading data finished".format(toy)) + +# ### Fit data + +# print("Toy {}: Fitting pdf...".format(toy)) + +# for param in total_f_fit.get_dependents(): +# param.randomize() + +# nll = zfit.loss.UnbinnedNLL(model=total_f_fit, data=data, constraints = constraints) + +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) +# # minimizer._use_tfgrad = False +# result = minimizer.minimize(nll) + +# print("Function minimum:", result.fmin) +# print("Hesse errors:", result.hesse()) + +# params = result.params + +# if result.converged: +# Ctt_list.append(params[Ctt]['value']) +# Ctt_error_list.append(params[Ctt]['minuit_hesse']['error']) + +# #plotting the result + +# plotdirName = 'data/plots'.format(toy) + +# if not os.path.exists(plotdirName): +# os.mkdir(plotdirName) +# # print("Directory " , dirName , " Created ") + +# plt.clf() +# plt.hist(tot_sam, bins = int((x_max-x_min)/7.), label = 'toy data') +# plt.savefig(plotdirName + '/toy_histo_cut_region{}.png'.format(toy)) + + +# probs = total_f_fit.pdf(test_q, norm_range=False) +# calcs_test = zfit.run(probs) +# plt.clf() +# plt.plot(test_q, calcs_test, label = 'pdf') +# plt.axvline(x=jpsi_mass-60.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.axvline(x=jpsi_mass+70.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.axvline(x=psi2s_mass-50.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.axvline(x=psi2s_mass+50.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.legend() +# plt.ylim(0.0, 1.5e-6) +# plt.savefig(plotdirName + '/toy_fit_cut_region{}.png'.format(toy)) + +# print("Toy {0}/{1}".format(toy+1, nr_of_toys)) +# print("Time taken: {}".format(display_time(int(time.time() - start)))) +# print("Projected time left: {}".format(display_time(int((time.time() - start)/(toy+1))*((nr_of_toys-toy-1))))) + + + +# In[ ]: + + +# with open("data/results/Ctt_list.pkl", "wb") as f: +# pkl.dump(Ctt_list, f, pkl.HIGHEST_PROTOCOL) +# with open("data/results/Ctt_error_list.pkl", "wb") as f: +# pkl.dump(Ctt_error_list, f, pkl.HIGHEST_PROTOCOL) + + +# In[ ]: + + +# print('{0}/{1} fits converged'.format(len(Ctt_list), nr_of_toys)) +# print('Mean Ctt value = {}'.format(np.mean(Ctt_list))) +# print('Mean Ctt error = {}'.format(np.mean(Ctt_error_list))) +# print('95 Sensitivy = {}'.format(((2*np.mean(Ctt_error_list))**2)*4.2/1000)) + + +# In[ ]: + + +# plt.hist(tot_sam, bins = int((x_max-x_min)/7.)) + +# plt.show() + +# # _ = np.where((total_samp >= x_min) & (total_samp <= (jpsi_mass - 50.))) + +# tot_sam.shape + + +# In[ ]: + + +# Ctt.floating = False + + +# In[ ]: + + +# zfit.run(nll.value()) + + +# In[ ]: + + +# result.fmin + + +# In[ ]: + + +# BR_steps = np.linspace(0.0, 1e-3, 11) +pull_dic = {} + +mi = 1e-4 +ma = 3e-3 +ste = 20 + +for param in total_f_fit.get_dependents(): + if param.floating: + pull_dic[param.name] = [] + for step in range(2*ste): + pull_dic[param.name].append([]) + + + +def save_pulls(step): + for param in total_f_fit.get_dependents(): + if param.floating: + pull_dic[param.name][step].append((params[param]['value'] - param_values_dic[param.name])/params[param]['minuit_hesse']['error']) + + + +# for key in pull_dic.keys(): +# print(np.shape(pull_dic[key])) +# save_pulls(New_step=True) +# params[Ctt]['value'] + + +# In[ ]: + + +# for param in total_f_fit.get_dependents(): +# if param.floating: +# print(param.name) + +# print(params[Ctt]) + + +# # CLS Code + +# In[ ]: + + +# zfit.run.numeric_checks = False + +load = False + +bo = True + +D_contribs = True + +if not D_contribs: + Dbar_s.floating = False + Dbar_p.floating = False + DDstar_s.floating = False + DDstar_p.floating = False + +bo_set = 1 + +fitting_range = 'cut' +total_BR = 1.7e-10 + 4.9e-10 + 2.5e-9 + 6.02e-5 + 4.97e-6 + 1.38e-9 + 4.2e-10 + 2.6e-9 + 6.1e-10 + 4.37e-7 +cut_BR = 1.0 - (6.02e-5 + 4.97e-6)/total_BR + +Ctt_list = [] +Ctt_error_list = [] + +nr_of_toys = 1 +nevents = int(pdg["number_of_decays"]*cut_BR) +# nevents = pdg["number_of_decays"] +event_stack = 1000000 +# nevents *= 41 +# zfit.settings.set_verbosity(10) + +# mi = 1e-4 +# ma = 3e-3 +# ste = 13 + +BR_steps = np.linspace(mi, ma, ste) + +BR_steps[0] = 0.0 + +print(BR_steps) + +Ctt_steps = np.sqrt(BR_steps/4.2*1000) + +print(Ctt_steps) + +# total_samp = [] + +start = time.time() + +Nll_list = [] + +sampler = total_f.create_sampler(n=nevents, fixed_params = False) +sampler.set_data_range(obs_fit) + +__ = -1 + +#----------------------------------------------------- + +if not load: + for Ctt_step in Ctt_steps: + + __ += 1 + + for i in range(2): + Ctt_list.append([]) + Ctt_error_list.append([]) + Nll_list.append([]) + + for param in total_f_fit.get_dependents(): + if param.floating: + pull_dic[param.name].append([]) + + for toy in range(nr_of_toys): + + newset = True + + while newset: + + for floaty in [True, False]: + Ctt.floating = floaty + + for bo_step in range(bo_set): + + print('Step: {0}/{1}'.format(int(__), ste)) + print('Current Ctt: {0}'.format(Ctt_step)) + print('Ctt floating: {0}'.format(floaty)) + + reset_param_values(variation = 0.0) + + if floaty: + print('Toy {0}/{1} - Fit {2}/{3}'.format(toy, nr_of_toys, bo_step, bo_set)) + Ctt.set_value(Ctt_step) + + else: + Ctt.set_value(0.0) + print('Toy {0}/{1} - Fit {2}/{3}'.format(toy, nr_of_toys, bo_step, bo_set)) + + if newset: + sampler.resample(n=nevents) + data = sampler + newset = False + + ### Fit data + + if floaty: + #plt.clf() + #plt.title('Ctt value: {:.2f}'.format(Ctt_step)) + #plt.hist(zfit.run(data), bins = int((x_max-x_min)/7), range = (x_min, x_max)) + #plt.savefig('data/CLs/plots/set_histo{}.png'.format(__)) + _step = 2*__ + else: + _step = 2*__+1 + + nll = zfit.loss.UnbinnedNLL(model=total_f_fit, data=data, constraints = constraints) + + minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) + # minimizer._use_tfgrad = False + result = minimizer.minimize(nll) + + print("Function minimum:", result.fmin) + print("Hesse errors:", result.hesse()) + + params = result.params + + if result.converged: + + save_pulls(step = _step) + + if floaty: + Nll_list[-2].append(result.fmin) + Ctt_list[-2].append(params[Ctt]['value']) + Ctt_error_list[-2].append(params[Ctt]['minuit_hesse']['error']) + + else: + Nll_list[-1].append(result.fmin) + Ctt_list[-1].append(0.0) + Ctt_error_list[-1].append(0.0) + + + else: + for _ in [1,2]: + del Nll_list[-_][toy*bo_set:] +# print(np.shape(Nll_list[-_])) + del Ctt_list[-_][toy*bo_set:] + del Ctt_error_list[-_][toy*bo_set:] + for param in total_f_fit.get_dependents(): + if param.floating: + del pull_dic[param.name][_step+1-_][toy*bo_set:] + newset = True + break + + if not result.converged: + break + + print() + print('Time taken: {}'.format(display_time(int(time.time()-start)))) + print('Estimated time left: {}'.format(display_time(int((time.time()-start)/(__+(toy+1)/nr_of_toys)*(ste-__-(nr_of_toys-toy-1)/nr_of_toys))))) + + +# In[ ]: + + +if load: + + phase_combi = '--' + + if D_contribs: + D_dir = 'D-True' + else: + D_dir = 'D-False' + + _dir = 'data/CLs/finished/f1d1/{}/{}/'.format(phase_combi, D_dir) + + jobs = os.listdir(_dir) + + First = True + +# print(jobs) + + for job in jobs: + + dirName = _dir + str(job) + '/data/CLs' + + if not os.path.exists("{}/{}-{}_{}s{}b{}t--CLs_Nll_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys)): +# print(job) + continue + + with open(r"{}/variab.pkl".format(dirName), "rb") as input_file: + variab = pkl.load(input_file) +# print(variab) + + ### sanity check: + if variab['mi'] != mi or variab['ma'] != ma or variab['ste'] != ste or bo_set != bo_set: + print('Fitting parameters of data dont equal the ones given -- Job {} skipped!'.format(job)) + + with open(r"{}/{}-{}_{}s{}b{}t--CLs_Nll_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _Nll_list = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s{}b{}t--Ctt_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _Ctt_list = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s{}b{}t--Ctt_error_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _Ctt_error_list = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s{}b{}t--pull_dic.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _pull_dic = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s--CLs_list.pkl".format(dirName, mi,ma,ste), "rb") as input_file: + _CLs_list = pkl.load(input_file) + + + if First: + Nll_list = _Nll_list + Ctt_list = _Ctt_list + Ctt_error_list = _Ctt_error_list + pull_dic = _pull_dic +# print(_pull_dic) + CLs_list = _CLs_list + First = False + else: + for step in range(2*ste): +# print(Nll_list[step], step) + Nll_list[step].extend(_Nll_list[step]) + Ctt_list[step].extend(_Ctt_list[step]) + Ctt_error_list[step].extend(_Ctt_error_list[step]) + for key in pull_dic.keys(): +# print(key, np.shape(pull_dic[key])) + pull_dic[key][step].extend(_pull_dic[key][step]) + for step in range(ste): + CLs_list[step].extend(_CLs_list[step]) + +# print('----------------------') + + +# In[ ]: + + +dirName = 'data/CLs' + +# if bo and not load: +# for s in range(2*ste): +# Nll_list[s] = [np.min(Nll_list[s])] + + +if not load: + + if not os.path.exists(dirName): + os.mkdir(dirName) + print("Directory " , dirName , " Created ") + + with open("{}/{}-{}_{}s{}b{}t--CLs_Nll_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(Nll_list, f, pkl.HIGHEST_PROTOCOL) + + with open("{}/{}-{}_{}s{}b{}t--Ctt_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(Ctt_list, f, pkl.HIGHEST_PROTOCOL) + + with open("{}/{}-{}_{}s{}b{}t--Ctt_error_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(Ctt_error_list, f, pkl.HIGHEST_PROTOCOL) + + with open("{}/{}-{}_{}s{}b{}t--pull_dic.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(pull_dic, f, pkl.HIGHEST_PROTOCOL) + + variab = {'mi': mi, + 'ma': ma, + 'ste': ste, + 'bo_set': bo_set, + 'nr_of_toys': nr_of_toys} + + with open("{}/variab.pkl".format(dirName), "wb") as f: + pkl.dump(variab, f, pkl.HIGHEST_PROTOCOL) + + CLs_values = [] + + toy_size = bo_set + + print(np.shape(Nll_list)) + print(Nll_list[0:1]) + + for step in range(ste): + CLs_values.append([]) + for toy in range(nr_of_toys): + float_min = np.min(Nll_list[2*step][toy*bo_set:(toy+1)*bo_set]) + fix_min = np.min(Nll_list[2*step+1][toy*bo_set:(toy+1)*bo_set]) + CLs_values[step].append(float_min-fix_min) + + + print(np.shape(CLs_values)) + + with open("{}/{}-{}_{}s--CLs_list.pkl".format(dirName, mi,ma,ste), "wb") as f: + pkl.dump(CLs_values, f, pkl.HIGHEST_PROTOCOL) + + +# In[ ]: + + +# print(variab['mi'] != mi) + + +# ## Plot + +# In[ ]: + + +l = [] + + +if load: + CLs_values = -1*np.array(CLs_list) + +if not os.path.exists('data/CLs/plots'): + os.mkdir('data/CLs/plots') + print("Directory " , 'data/CLs/plots' , " Created ") + +print(np.shape(CLs_values)) + +for step in range(1,ste): + plt.clf() + plt.title('Ctt value: {:.2f}'.format(Ctt_steps[step])) + plt.hist(CLs_values[0], bins = 150, range = (-25, 50), label = 'Ctt fixed to 0') + plt.hist(CLs_values[step], bins = 150, range = (-25, 50), label = 'Ctt floating') + plt.axvline(x=np.mean(CLs_values[0]),color='red', linewidth=1.0, linestyle = 'dotted') + plt.legend() + plt.savefig('data/CLs/plots/CLs-BR({:.1E}).png'.format(BR_steps[step])) + + l.append(len(np.where(np.array(CLs_values[step]) < np.mean(CLs_values[0]))[0])) + +for step in range(2*ste): + if step%2 == 0: + floaty = True + else: + floaty = False + for key in pull_dic.keys(): + if not os.path.exists('data/CLs/plots/{}'.format(key)): + os.mkdir('data/CLs/plots/{}'.format(key)) + plt.clf() + plt.title('Pull {} - Ctt value {:.2f} - floating {}'.format(key, Ctt_steps[int(step/2)], floaty)) + plt.hist(pull_dic[key][step], bins = 50, range = (-5,5)) + plt.xlabel('Pull') + plt.savefig('data/CLs/plots/{}/{:.2f}Ctt{}s{}f.png'.format(key, Ctt_steps[int(step/2)], step, floaty)) + + +# In[ ]: + + +for s in range(len(l)): + print('BR: {:.4f}'.format(BR_steps[s+1])) + print(2*l[s]/len(CLs_values[s])) + print() + + +# In[ ]: + + +# for step in range(2*ste): +# for key in pull_dic.keys(): +# print(pull_dic[key][step]) + + +# In[ ]: + + +# for param in total_f_fit.get_dependents(): +# if param.floating: +# print(params[param]['value']) + + +# In[ ]: + + +print(display_time(int(time.time()-start))) + + +# In[ ]: + + +# variab['mi'] =! mi + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + diff --git a/data/CLs/finished/f1d1/-+/D-True/2288024/__pycache__/helperfunctions.cpython-37.pyc b/data/CLs/finished/f1d1/-+/D-True/2288024/__pycache__/helperfunctions.cpython-37.pyc new file mode 100644 index 0000000..2973634 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288024/__pycache__/helperfunctions.cpython-37.pyc Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288024/__pycache__/pdg_const1.cpython-37.pyc b/data/CLs/finished/f1d1/-+/D-True/2288024/__pycache__/pdg_const1.cpython-37.pyc new file mode 100644 index 0000000..3249e80 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288024/__pycache__/pdg_const1.cpython-37.pyc Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288024/data/CLs/0.0001-0.003_20s--CLs_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288024/data/CLs/0.0001-0.003_20s--CLs_list.pkl new file mode 100644 index 0000000..3829713 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288024/data/CLs/0.0001-0.003_20s--CLs_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288024/data/CLs/0.0001-0.003_20s1b1t--CLs_Nll_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288024/data/CLs/0.0001-0.003_20s1b1t--CLs_Nll_list.pkl new file mode 100644 index 0000000..2ff5ff8 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288024/data/CLs/0.0001-0.003_20s1b1t--CLs_Nll_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288024/data/CLs/0.0001-0.003_20s1b1t--Ctt_error_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288024/data/CLs/0.0001-0.003_20s1b1t--Ctt_error_list.pkl new file mode 100644 index 0000000..21ecdfe --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288024/data/CLs/0.0001-0.003_20s1b1t--Ctt_error_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288024/data/CLs/0.0001-0.003_20s1b1t--Ctt_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288024/data/CLs/0.0001-0.003_20s1b1t--Ctt_list.pkl new file mode 100644 index 0000000..d9214ad --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288024/data/CLs/0.0001-0.003_20s1b1t--Ctt_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288024/data/CLs/0.0001-0.003_20s1b1t--pull_dic.pkl b/data/CLs/finished/f1d1/-+/D-True/2288024/data/CLs/0.0001-0.003_20s1b1t--pull_dic.pkl new file mode 100644 index 0000000..8fd72e1 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288024/data/CLs/0.0001-0.003_20s1b1t--pull_dic.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288024/data/CLs/variab.pkl b/data/CLs/finished/f1d1/-+/D-True/2288024/data/CLs/variab.pkl new file mode 100644 index 0000000..bb90dc0 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288024/data/CLs/variab.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288024/helperfunctions.py b/data/CLs/finished/f1d1/-+/D-True/2288024/helperfunctions.py new file mode 100644 index 0000000..88e120f --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288024/helperfunctions.py @@ -0,0 +1,33 @@ +# some helperfunctions + +import matplotlib +matplotlib.use("agg") +import matplotlib.pyplot as plt + +#Dislpay time (e.g. while generating points) + +display_intervals = ( + ('w', 604800), # 60 * 60 * 24 * 7 + ('d', 86400), # 60 * 60 * 24 + ('h', 3600), # 60 * 60 + ('min', 60), + ('s', 1), + ) + +def display_time(seconds, granularity=2): + result = [] + + for name, count in display_intervals: + value = seconds // count + if value: + seconds -= value * count + if value == 1: + name = name.rstrip('s') + result.append("{} {}".format(value, name)) + return ', '.join(result[:granularity]) + +def prepare_plot(title): + plt.title(title) + plt.grid() + plt.legend(loc = 'best') + plt.xlabel("q") diff --git a/data/CLs/finished/f1d1/-+/D-True/2288024/pdg_const1.py b/data/CLs/finished/f1d1/-+/D-True/2288024/pdg_const1.py new file mode 100644 index 0000000..70b3f30 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288024/pdg_const1.py @@ -0,0 +1,226 @@ +pdg = { + + + ###Particle masses### + + "mbstar" : 5415.4, + "mbstar0" : 5711.0, + "B0_M" : 5279.5, + "Bs_M" : 5366.7, + "Bplus_M" : 5279.3, + "Lb_M" : 5619.4, + "D0_M" : 1864.8, + "Dst_M" : 2010, + "pi_M" : 139.6, + "Jpsi_M" : 3096.9, + "Psi2s_M" : 3685.6, + "kaon_M" : 493.7, + "Ks_M" : 497.6, + "phi_M" : 1019.5, + "rho_M" : 775.26, + "rho_width" : 149.1, + "omega_M" : 782.65, + "omega_width" : 8.49, + + "muon_M" : 105.7, + "tau_M": 1776.86, + + "squark_M" : 95.0, + "bquark_M" : 4180.0, + "cquark_M" : 1275.0, + + "Bplus_tau" : 1.638e-12, + + ###Wilson coefficients### + + "C1" : -0.257, + "C2" : 1.009, + "C3" : -0.005, + "C4" : -0.078, + + "C7eff" : -0.306, + "C9eff" : 4.211, + "C10eff" : -4.103, + +# "C7eff": 0.0, +# "C9eff": 0.0, +# "C10eff": 0.0, + + ###Other constants + + "GF" : 1.1663787e-5, + "alpha_ew" : 1.0/137.0, + "Vts" : 0.0394, + "Vtb" : 1.019, + "number_of_decays": 5404696, + + #Formfactor z coefficients + + #"b0" : [0.285, 0.19, -0.17], + #"bplus" : [0.437, -1.41, -2.5], + #"bT" : [0.440, -1.47, -2.7] + + "b0" : [0.292, 0.281, 0.150], + "bplus" : [0.466, -0.885, -0.213], + "bT" : [0.460, -1.089, -1.114], + + "NR_BR": 4.37e-7, + "NR_auc": 0.00133, + + #Resonances format(mass, width, phase, scale) + + # pre scaling + +# "rho": (775.26, 149.0, -0.35, 1.0), + +# "omega": (782.7, 8.5, 0.26, 1.0), + +# "phi": (1019.46, 4.25, 0.5, 1.0), + +# "jpsi": (3096.0, 0.09, -1.5, 2e-2), +# "jpsi_auc": 0.2126825758464027, + +# "psi2s": (3686.0, 0.3, -1.5, 3.14e-3), +# "psi2s_auc": 2.802257483178487e-10, + +# "p3770": (3773.0, 27.2, -2.13, 1.0e-3), + +# "p4040": (4039.0, 80.0, -2.52, 2.0), + +# "p4160": (4191.0, 70.0, -1.9, 2.2), + +# "p4415": (4421.0, 62.0, -2.52, 1.0), + + + # after scaling (Phase combination --) + + # + # "rho": (743.2, 149.0, -0.22, 1.05), + # + # "omega": (782.7, 8.5, 0.38, 6.8), + # + # "phi": (1013.5, 4.25, 0.62, 19.2), + # + # "jpsi": (3096.1, 0.09, 1.63, 9897.0), + # "jpsi_auc": 0.2126825758464027, + # "jpsi_phase_unc": 0.05, + # + # "psi2s": (3686.0, 0.3, 1.8, 1396.0), + # "psi2s_auc": 0.0151332263, + # "psi2s_phase_unc": 0.1, + # + # "p3770": (3773.0, 27.2, -2.95, 2.5), + # + # "p4040": (4039.0, 80.0, -2.75, 1.01), + # + # "p4160": (4191.0, 70.0, -2.28, 2.2), + # + # "p4415": (4421.0, 62.0, -2.31, 1.24), + + # Phase combination of paper ++ + +# "rho": (743.2, 149.0, -0.35, 1.05), + +# "omega": (782.7, 8.5, 0.26, 6.8), + +# "phi": (1013.5, 4.25, 0.47, 19.2), + +# "jpsi": (3096.1, 0.09, -1.66, 9897.0), +# "jpsi_auc": 0.2126825758464027, +# "jpsi_phase_unc": 0.05, + +# "psi2s": (3686.0, 0.3, -1.93, 1396.0), +# "psi2s_auc": 0.0151332263, +# "psi2s_phase_unc": 0.1, + +# "p3770": (3773.0, 27.2, -2.13, 2.5), + +# "p4040": (4039.0, 80.0, -2.52, 1.01), + +# "p4160": (4191.0, 70.0, -1.90, 2.2), + +# "p4415": (4421.0, 62.0, -2.52, 1.24), + + # Phase combination of paper +- + +# "rho": (743.2, 149.0, -0.26, 1.05), + +# "omega": (782.7, 8.5, 0.35, 6.8), + +# "phi": (1013.5, 4.25, 0.58, 19.2), + +# "jpsi": (3096.1, 0.09, 1.47, 9897.0), +# "jpsi_auc": 0.2126825758464027, +# "jpsi_phase_unc": 0.05, + +# "psi2s": (3686.0, 0.3, -2.21, 1396.0), +# "psi2s_auc": 0.0151332263, +# "psi2s_phase_unc": 0.1, + +# "p3770": (3773.0, 27.2, -2.140, 2.5), + +# "p4040": (4039.0, 80.0, -2.64, 1.01), + +# "p4160": (4191.0, 70.0, -2.11, 2.2), + +# "p4415": (4421.0, 62.0, -2.42, 1.24), + + # Phase combination of paper -+ + + "rho": (743.2, 149.0, -0.30, 1.05), + + "omega": (782.7, 8.5, 0.30, 6.8), + + "phi": (1013.5, 4.25, 0.51, 19.2), + + "jpsi": (3096.1, 0.09, -1.5, 9897.0), + "jpsi_auc": 0.2126825758464027, + "jpsi_phase_unc": 0.05, + + "psi2s": (3686.0, 0.3, 2.08, 1396.0), + "psi2s_auc": 0.0151332263, + "psi2s_phase_unc": 0.1, + + "p3770": (3773.0, 27.2, -2.89, 2.5), + + "p4040": (4039.0, 80.0, -2.69, 1.01), + + "p4160": (4191.0, 70.0, -2.13, 2.2), + + "p4415": (4421.0, 62.0, -2.43, 1.24), + + + # zeroing resonances + +# "rho": (775.26, 149.0, -0.35, 0.0), +# "omega": (782.7, 8.5, 0.26, 0.0), +# "phi": (1019.46, 4.25, 0.5, 0.0), +# "jpsi": (3096.0, 0.09, -1.5, 0.0), +# "psi2s": (3686.0, 0.3, -1.5, 0.0), +# "p3770": (3773.0, 27.2, -2.13, 0.0), +# "p4040": (4039.0, 80.0, -2.52, 0.0), +# "p4160": (4147.0, 22.0, -1.9, 0.0), +# "p4415": (4421.0, 62.0, -2.52, 0.0), + + # 2P contributions format(mass, amp, phase) + +# "D_bar": ( + + #general + + "rho_BR": 1.7e-10, + "omega_BR": 4.9e-10, + "phi_BR": 2.5e-9, + "jpsi_BR": 6.02e-5, + "psi2s_BR": 4.97e-6, + "p3770_BR": 1.38e-9, + "p4040_BR": 4.2e-10, + "p4160_BR": 2.6e-9, + "p4415_BR": 6.1e-10, + +# Estimates + "Dbar_scale": 1.46, #with phase = pi + + "DDstar_scale": 2.41, #with phase = pi + + } diff --git a/data/CLs/finished/f1d1/-+/D-True/2288024/raremodel-nb.py b/data/CLs/finished/f1d1/-+/D-True/2288024/raremodel-nb.py new file mode 100644 index 0000000..c326c9c --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288024/raremodel-nb.py @@ -0,0 +1,2152 @@ +#!/usr/bin/env python +# coding: utf-8 + +# # Import + +# In[ ]: + + +import os + +# os.environ["CUDA_VISIBLE_DEVICES"] = "-1" +import random +import numpy as np +from pdg_const1 import pdg +import matplotlib +import matplotlib.pyplot as plt +import pickle as pkl +import sys +import time +from helperfunctions import display_time, prepare_plot +import cmath as c +import scipy.integrate as integrate +from scipy.optimize import fminbound +from array import array as arr +import collections +from itertools import compress +import tensorflow as tf +import zfit +from zfit import ztf +# from IPython.display import clear_output +import os +import tensorflow_probability as tfp +tfd = tfp.distributions + + +# In[ ]: + + +# chunksize = 10000 +# zfit.run.chunking.active = True +# zfit.run.chunking.max_n_points = chunksize + + +# # Build model and graphs +# ## Create graphs + +# In[ ]: + + + + + +# In[ ]: + + +def formfactor(q2, subscript, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2): #returns real value + #check if subscript is viable + + if subscript != "0" and subscript != "+" and subscript != "T": + raise ValueError('Wrong subscript entered, choose either 0, + or T') + + #get constants + + mK = ztf.constant(pdg['Ks_M']) + mbstar0 = ztf.constant(pdg["mbstar0"]) + mbstar = ztf.constant(pdg["mbstar"]) + + + mmu = ztf.constant(pdg['muon_M']) + mb = ztf.constant(pdg['bquark_M']) + ms = ztf.constant(pdg['squark_M']) + mB = ztf.constant(pdg['Bplus_M']) + + #N comes from derivation in paper + + N = 3 + + #some helperfunctions + + tpos = (mB - mK)**2 + tzero = (mB + mK)*(ztf.sqrt(mB)-ztf.sqrt(mK))**2 + + z_oben = ztf.sqrt(tpos - q2) - ztf.sqrt(tpos - tzero) + z_unten = ztf.sqrt(tpos - q2) + ztf.sqrt(tpos - tzero) + z = tf.divide(z_oben, z_unten) + + #calculate f0 + + if subscript == "0": + prefactor = 1/(1 - q2/(mbstar0**2)) + _sum = 0 + b0 = [b0_0, b0_1, b0_2] + + for i in range(N): + _sum += b0[i]*(tf.pow(z,i)) + + return ztf.to_complex(prefactor * _sum) + + #calculate f+ or fT + + else: + prefactor = 1/(1 - q2/(mbstar**2)) + _sum = 0 + + if subscript == "T": + bT = [bT_0, bT_1, bT_2] + for i in range(N): + _sum += bT[i] * (tf.pow(z, i) - ((-1)**(i-N)) * (i/N) * tf.pow(z, N)) + else: + bplus = [bplus_0, bplus_1, bplus_2] + for i in range(N): + _sum += bplus[i] * (tf.pow(z, i) - ((-1)**(i-N)) * (i/N) * tf.pow(z, N)) + + return ztf.to_complex(prefactor * _sum) + +def resonance(q, _mass, width, phase, scale): + + q2 = tf.pow(q, 2) + + mmu = ztf.constant(pdg['muon_M']) + + p = 0.5 * ztf.sqrt(q2 - 4*(mmu**2)) + + p0 = 0.5 * ztf.sqrt(_mass**2 - 4*mmu**2) + + gamma_j = tf.divide(p, q) * _mass * width / p0 + + #Calculate the resonance + + _top = tf.complex(_mass * width, ztf.constant(0.0)) + + _bottom = tf.complex(_mass**2 - q2, -_mass*gamma_j) + + com = _top/_bottom + + #Rotate by the phase + + r = ztf.to_complex(scale*tf.abs(com)) + + _phase = tf.angle(com) + + _phase += phase + + com = r * tf.exp(tf.complex(ztf.constant(0.0), _phase)) + + return com + + +def axiv_nonres(q, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2): + + GF = ztf.constant(pdg['GF']) + alpha_ew = ztf.constant(pdg['alpha_ew']) + Vtb = ztf.constant(pdg['Vtb']) + Vts = ztf.constant(pdg['Vts']) + C10eff = ztf.constant(pdg['C10eff']) + + mmu = ztf.constant(pdg['muon_M']) + mb = ztf.constant(pdg['bquark_M']) + ms = ztf.constant(pdg['squark_M']) + mK = ztf.constant(pdg['Ks_M']) + mB = ztf.constant(pdg['Bplus_M']) + + q2 = tf.pow(q, 2) + + #Some helperfunctions + + beta = 1. - 4. * mmu**2. / q2 + + kabs = ztf.sqrt(mB**2. + tf.pow(q2, 2)/mB**2. + mK**4./mB**2. - 2. * (mB**2. * mK**2. + mK**2. * q2 + mB**2. * q2) / mB**2.) + + #prefactor in front of whole bracket + + prefactor1 = GF**2. *alpha_ew**2. * (tf.abs(Vtb*Vts))**2. * kabs * beta / (128. * np.pi**5.) + + #left term in bracket + + bracket_left = 2./3. * tf.pow(kabs,2) * tf.pow(beta,2) * tf.pow(tf.abs(ztf.to_complex(C10eff)*formfactor(q2, "+", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2)),2) + + #middle term in bracket + + _top = 4. * mmu**2. * (mB**2. - mK**2.) * (mB**2. - mK**2.) + + _under = q2 * mB**2. + + bracket_middle = _top/_under *tf.pow(tf.abs(ztf.to_complex(C10eff) * formfactor(q2, "0", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2)), 2) + + #Note sqrt(q2) comes from derivation as we use q2 and plot q + + return prefactor1 * (bracket_left + bracket_middle) * 2 * q + +def vec(q, funcs, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2): + + q2 = tf.pow(q, 2) + + GF = ztf.constant(pdg['GF']) + alpha_ew = ztf.constant(pdg['alpha_ew']) + Vtb = ztf.constant(pdg['Vtb']) + Vts = ztf.constant(pdg['Vts']) + C7eff = ztf.constant(pdg['C7eff']) + + mmu = ztf.constant(pdg['muon_M']) + mb = ztf.constant(pdg['bquark_M']) + ms = ztf.constant(pdg['squark_M']) + mK = ztf.constant(pdg['Ks_M']) + mB = ztf.constant(pdg['Bplus_M']) + + #Some helperfunctions + + beta = 1. - 4. * mmu**2. / q2 + + kabs = ztf.sqrt(mB**2. + tf.pow(q2, 2)/mB**2. + mK**4./mB**2. - 2 * (mB**2 * mK**2 + mK**2 * q2 + mB**2 * q2) / mB**2) + + #prefactor in front of whole bracket + + prefactor1 = GF**2. *alpha_ew**2. * (tf.abs(Vtb*Vts))**2 * kabs * beta / (128. * np.pi**5.) + + #right term in bracket + + prefactor2 = tf.pow(kabs,2) * (1. - 1./3. * beta) + + abs_bracket = tf.pow(tf.abs(c9eff(q, funcs) * formfactor(q2, "+", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + ztf.to_complex(2.0 * C7eff * (mb + ms)/(mB + mK)) * formfactor(q2, "T", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2)),2) + + bracket_right = prefactor2 * abs_bracket + + #Note sqrt(q2) comes from derivation as we use q2 and plot q + + return prefactor1 * bracket_right * 2 * q + +def c9eff(q, funcs): + + C9eff_nr = ztf.to_complex(ztf.constant(pdg['C9eff'])) + + c9 = C9eff_nr + funcs + + return c9 + + +# In[ ]: + + +def G(y): + + def inner_rect_bracket(q): + return tf.log(ztf.to_complex((1+tf.sqrt(q))/(1-tf.sqrt(q)))-tf.complex(ztf.constant(0), -1*ztf.constant(np.pi))) + + def inner_right(q): + return ztf.to_complex(2 * tf.atan(1/tf.sqrt(tf.math.real(-q)))) + + big_bracket = tf.where(tf.math.real(y) > ztf.constant(0.0), inner_rect_bracket(y), inner_right(y)) + + return ztf.to_complex(tf.sqrt(tf.abs(y))) * big_bracket + +def h_S(m, q): + + return ztf.to_complex(2) - G(ztf.to_complex(1) - ztf.to_complex(4*tf.pow(m, 2)) / ztf.to_complex(tf.pow(q, 2))) + +def h_P(m, q): + + return ztf.to_complex(2/3) + (ztf.to_complex(1) - ztf.to_complex(4*tf.pow(m, 2)) / ztf.to_complex(tf.pow(q, 2))) * h_S(m,q) + +def two_p_ccbar(mD, m_D_bar, m_D_star, q): + + + #Load constants + nu_D_bar = ztf.to_complex(pdg["nu_D_bar"]) + nu_D = ztf.to_complex(pdg["nu_D"]) + nu_D_star = ztf.to_complex(pdg["nu_D_star"]) + + phase_D_bar = ztf.to_complex(pdg["phase_D_bar"]) + phase_D = ztf.to_complex(pdg["phase_D"]) + phase_D_star = ztf.to_complex(pdg["phase_D_star"]) + + #Calculation + left_part = nu_D_bar * tf.exp(tf.complex(ztf.constant(0.0), phase_D_bar)) * h_S(m_D_bar, q) + + right_part_D = nu_D * tf.exp(tf.complex(ztf.constant(0.0), phase_D)) * h_P(m_D, q) + + right_part_D_star = nu_D_star * tf.exp(tf.complex(ztf.constant(0.0), phase_D_star)) * h_P(m_D_star, q) + + return left_part + right_part_D + right_part_D_star + + +# ## Build pdf + +# In[ ]: + + +class total_pdf_cut(zfit.pdf.ZPDF): + _N_OBS = 1 # dimension, can be omitted + _PARAMS = ['b0_0', 'b0_1', 'b0_2', + 'bplus_0', 'bplus_1', 'bplus_2', + 'bT_0', 'bT_1', 'bT_2', + 'rho_mass', 'rho_scale', 'rho_phase', 'rho_width', + 'jpsi_mass', 'jpsi_scale', 'jpsi_phase', 'jpsi_width', + 'psi2s_mass', 'psi2s_scale', 'psi2s_phase', 'psi2s_width', + 'p3770_mass', 'p3770_scale', 'p3770_phase', 'p3770_width', + 'p4040_mass', 'p4040_scale', 'p4040_phase', 'p4040_width', + 'p4160_mass', 'p4160_scale', 'p4160_phase', 'p4160_width', + 'p4415_mass', 'p4415_scale', 'p4415_phase', 'p4415_width', + 'omega_mass', 'omega_scale', 'omega_phase', 'omega_width', + 'phi_mass', 'phi_scale', 'phi_phase', 'phi_width', + 'Dbar_mass', 'Dbar_scale', 'Dbar_phase', + 'Dstar_mass', 'DDstar_scale', 'DDstar_phase', 'D_mass', + 'tau_mass', 'C_tt'] +# the name of the parameters + + def _unnormalized_pdf(self, x): + + x = x.unstack_x() + + b0 = [self.params['b0_0'], self.params['b0_1'], self.params['b0_2']] + bplus = [self.params['bplus_0'], self.params['bplus_1'], self.params['bplus_2']] + bT = [self.params['bT_0'], self.params['bT_1'], self.params['bT_2']] + + def rho_res(q): + return resonance(q, _mass = self.params['rho_mass'], scale = self.params['rho_scale'], + phase = self.params['rho_phase'], width = self.params['rho_width']) + + def omega_res(q): + return resonance(q, _mass = self.params['omega_mass'], scale = self.params['omega_scale'], + phase = self.params['omega_phase'], width = self.params['omega_width']) + + def phi_res(q): + return resonance(q, _mass = self.params['phi_mass'], scale = self.params['phi_scale'], + phase = self.params['phi_phase'], width = self.params['phi_width']) + + def jpsi_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['jpsi_mass'], 2)) * resonance(q, _mass = self.params['jpsi_mass'], + scale = self.params['jpsi_scale'], + phase = self.params['jpsi_phase'], + width = self.params['jpsi_width']) + def psi2s_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['psi2s_mass'], 2)) * resonance(q, _mass = self.params['psi2s_mass'], + scale = self.params['psi2s_scale'], + phase = self.params['psi2s_phase'], + width = self.params['psi2s_width']) + def p3770_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p3770_mass'], 2)) * resonance(q, _mass = self.params['p3770_mass'], + scale = self.params['p3770_scale'], + phase = self.params['p3770_phase'], + width = self.params['p3770_width']) + + def p4040_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4040_mass'], 2)) * resonance(q, _mass = self.params['p4040_mass'], + scale = self.params['p4040_scale'], + phase = self.params['p4040_phase'], + width = self.params['p4040_width']) + + def p4160_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4160_mass'], 2)) * resonance(q, _mass = self.params['p4160_mass'], + scale = self.params['p4160_scale'], + phase = self.params['p4160_phase'], + width = self.params['p4160_width']) + + def p4415_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4415_mass'], 2)) * resonance(q, _mass = self.params['p4415_mass'], + scale = self.params['p4415_scale'], + phase = self.params['p4415_phase'], + width = self.params['p4415_width']) + + def P2_D(q): + Dbar_contrib = ztf.to_complex(self.params['Dbar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['Dbar_phase']))*ztf.to_complex(h_S(self.params['Dbar_mass'], q)) + DDstar_contrib = ztf.to_complex(self.params['DDstar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['DDstar_phase']))*(ztf.to_complex(h_P(self.params['Dstar_mass'], q)) + ztf.to_complex(h_P(self.params['D_mass'], q))) + return Dbar_contrib + DDstar_contrib + + def ttau_cusp(q): + return ztf.to_complex(self.params['C_tt'])*(ztf.to_complex((h_S(self.params['tau_mass'], q))) - ztf.to_complex(h_P(self.params['tau_mass'], q))) + + + funcs = rho_res(x) + omega_res(x) + phi_res(x) + jpsi_res(x) + psi2s_res(x) + p3770_res(x) + p4040_res(x)+ p4160_res(x) + p4415_res(x) + P2_D(x) + ttau_cusp(x) + + vec_f = vec(x, funcs, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + axiv_nr = axiv_nonres(x, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + tot = vec_f + axiv_nr + + #Cut out jpsi and psi2s + + tot = tf.where(tf.math.logical_or(x < ztf.constant(jpsi_mass-60.), x > ztf.constant(jpsi_mass+70.)), tot, 0.0*tot) + + tot = tf.where(tf.math.logical_or(x < ztf.constant(psi2s_mass-50.), x > ztf.constant(psi2s_mass+50.)), tot, 0.0*tot) + + return tot + +class total_pdf_full(zfit.pdf.ZPDF): + _N_OBS = 1 # dimension, can be omitted + _PARAMS = ['b0_0', 'b0_1', 'b0_2', + 'bplus_0', 'bplus_1', 'bplus_2', + 'bT_0', 'bT_1', 'bT_2', + 'rho_mass', 'rho_scale', 'rho_phase', 'rho_width', + 'jpsi_mass', 'jpsi_scale', 'jpsi_phase', 'jpsi_width', + 'psi2s_mass', 'psi2s_scale', 'psi2s_phase', 'psi2s_width', + 'p3770_mass', 'p3770_scale', 'p3770_phase', 'p3770_width', + 'p4040_mass', 'p4040_scale', 'p4040_phase', 'p4040_width', + 'p4160_mass', 'p4160_scale', 'p4160_phase', 'p4160_width', + 'p4415_mass', 'p4415_scale', 'p4415_phase', 'p4415_width', + 'omega_mass', 'omega_scale', 'omega_phase', 'omega_width', + 'phi_mass', 'phi_scale', 'phi_phase', 'phi_width', + 'Dbar_mass', 'Dbar_scale', 'Dbar_phase', + 'Dstar_mass', 'DDstar_scale', 'DDstar_phase', 'D_mass', + 'tau_mass', 'C_tt'] +# the name of the parameters + + def _unnormalized_pdf(self, x): + + x = x.unstack_x() + + b0 = [self.params['b0_0'], self.params['b0_1'], self.params['b0_2']] + bplus = [self.params['bplus_0'], self.params['bplus_1'], self.params['bplus_2']] + bT = [self.params['bT_0'], self.params['bT_1'], self.params['bT_2']] + + def rho_res(q): + return resonance(q, _mass = self.params['rho_mass'], scale = self.params['rho_scale'], + phase = self.params['rho_phase'], width = self.params['rho_width']) + + def omega_res(q): + return resonance(q, _mass = self.params['omega_mass'], scale = self.params['omega_scale'], + phase = self.params['omega_phase'], width = self.params['omega_width']) + + def phi_res(q): + return resonance(q, _mass = self.params['phi_mass'], scale = self.params['phi_scale'], + phase = self.params['phi_phase'], width = self.params['phi_width']) + + def jpsi_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['jpsi_mass'], 2)) * resonance(q, _mass = self.params['jpsi_mass'], + scale = self.params['jpsi_scale'], + phase = self.params['jpsi_phase'], + width = self.params['jpsi_width']) + def psi2s_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['psi2s_mass'], 2)) * resonance(q, _mass = self.params['psi2s_mass'], + scale = self.params['psi2s_scale'], + phase = self.params['psi2s_phase'], + width = self.params['psi2s_width']) + def p3770_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p3770_mass'], 2)) * resonance(q, _mass = self.params['p3770_mass'], + scale = self.params['p3770_scale'], + phase = self.params['p3770_phase'], + width = self.params['p3770_width']) + + def p4040_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4040_mass'], 2)) * resonance(q, _mass = self.params['p4040_mass'], + scale = self.params['p4040_scale'], + phase = self.params['p4040_phase'], + width = self.params['p4040_width']) + + def p4160_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4160_mass'], 2)) * resonance(q, _mass = self.params['p4160_mass'], + scale = self.params['p4160_scale'], + phase = self.params['p4160_phase'], + width = self.params['p4160_width']) + + def p4415_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4415_mass'], 2)) * resonance(q, _mass = self.params['p4415_mass'], + scale = self.params['p4415_scale'], + phase = self.params['p4415_phase'], + width = self.params['p4415_width']) + + def P2_D(q): + Dbar_contrib = ztf.to_complex(self.params['Dbar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['Dbar_phase']))*ztf.to_complex(h_S(self.params['Dbar_mass'], q)) + DDstar_contrib = ztf.to_complex(self.params['DDstar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['DDstar_phase']))*(ztf.to_complex(h_P(self.params['Dstar_mass'], q)) + ztf.to_complex(h_P(self.params['D_mass'], q))) + return Dbar_contrib + DDstar_contrib + + def ttau_cusp(q): + return ztf.to_complex(self.params['C_tt'])*(ztf.to_complex((h_S(self.params['tau_mass'], q))) - ztf.to_complex(h_P(self.params['tau_mass'], q))) + + + funcs = rho_res(x) + omega_res(x) + phi_res(x) + jpsi_res(x) + psi2s_res(x) + p3770_res(x) + p4040_res(x)+ p4160_res(x) + p4415_res(x) + P2_D(x) + ttau_cusp(x) + + vec_f = vec(x, funcs, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + axiv_nr = axiv_nonres(x, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + tot = vec_f + axiv_nr + + #Cut out jpsi and psi2s + +# tot = tf.where(tf.math.logical_or(x < ztf.constant(jpsi_mass-60.), x > ztf.constant(jpsi_mass+70.)), tot, 0.0*tot) + +# tot = tf.where(tf.math.logical_or(x < ztf.constant(psi2s_mass-50.), x > ztf.constant(psi2s_mass+50.)), tot, 0.0*tot) + + return tot + + +# ## Setup parameters + +# In[ ]: + + +# formfactors + +b0_0 = zfit.Parameter("b0_0", ztf.constant(0.292), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +b0_1 = zfit.Parameter("b0_1", ztf.constant(0.281), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +b0_2 = zfit.Parameter("b0_2", ztf.constant(0.150), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) + +bplus_0 = zfit.Parameter("bplus_0", ztf.constant(0.466), lower_limit = -2.0, upper_limit= 2.0) +bplus_1 = zfit.Parameter("bplus_1", ztf.constant(-0.885), lower_limit = -2.0, upper_limit= 2.0) +bplus_2 = zfit.Parameter("bplus_2", ztf.constant(-0.213), lower_limit = -2.0, upper_limit= 2.0) + +bT_0 = zfit.Parameter("bT_0", ztf.constant(0.460), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +bT_1 = zfit.Parameter("bT_1", ztf.constant(-1.089), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +bT_2 = zfit.Parameter("bT_2", ztf.constant(-1.114), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) + + +#rho + +rho_mass, rho_width, rho_phase, rho_scale = pdg["rho"] + +rho_m = zfit.Parameter("rho_m", ztf.constant(rho_mass), floating = False) #lower_limit = rho_mass - rho_width, upper_limit = rho_mass + rho_width) +rho_w = zfit.Parameter("rho_w", ztf.constant(rho_width), floating = False) +rho_p = zfit.Parameter("rho_p", ztf.constant(rho_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +rho_s = zfit.Parameter("rho_s", ztf.constant(rho_scale), lower_limit=rho_scale-np.sqrt(rho_scale), upper_limit=rho_scale+np.sqrt(rho_scale)) + +#omega + +omega_mass, omega_width, omega_phase, omega_scale = pdg["omega"] + +omega_m = zfit.Parameter("omega_m", ztf.constant(omega_mass), floating = False) +omega_w = zfit.Parameter("omega_w", ztf.constant(omega_width), floating = False) +omega_p = zfit.Parameter("omega_p", ztf.constant(omega_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +omega_s = zfit.Parameter("omega_s", ztf.constant(omega_scale), lower_limit=omega_scale-np.sqrt(omega_scale), upper_limit=omega_scale+np.sqrt(omega_scale)) + + +#phi + +phi_mass, phi_width, phi_phase, phi_scale = pdg["phi"] + +phi_m = zfit.Parameter("phi_m", ztf.constant(phi_mass), floating = False) +phi_w = zfit.Parameter("phi_w", ztf.constant(phi_width), floating = False) +phi_p = zfit.Parameter("phi_p", ztf.constant(phi_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +phi_s = zfit.Parameter("phi_s", ztf.constant(phi_scale), lower_limit=phi_scale-np.sqrt(phi_scale), upper_limit=phi_scale+np.sqrt(phi_scale)) + +#jpsi + +jpsi_mass, jpsi_width, jpsi_phase, jpsi_scale = pdg["jpsi"] + +jpsi_m = zfit.Parameter("jpsi_m", ztf.constant(jpsi_mass), floating = False) +jpsi_w = zfit.Parameter("jpsi_w", ztf.constant(jpsi_width), floating = False) +jpsi_p = zfit.Parameter("jpsi_p", ztf.constant(jpsi_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +jpsi_s = zfit.Parameter("jpsi_s", ztf.constant(jpsi_scale), floating = False) #, lower_limit=jpsi_scale-np.sqrt(jpsi_scale), upper_limit=jpsi_scale+np.sqrt(jpsi_scale)) + +#psi2s + +psi2s_mass, psi2s_width, psi2s_phase, psi2s_scale = pdg["psi2s"] + +psi2s_m = zfit.Parameter("psi2s_m", ztf.constant(psi2s_mass), floating = False) +psi2s_w = zfit.Parameter("psi2s_w", ztf.constant(psi2s_width), floating = False) +psi2s_p = zfit.Parameter("psi2s_p", ztf.constant(psi2s_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +psi2s_s = zfit.Parameter("psi2s_s", ztf.constant(psi2s_scale), floating = False) #, lower_limit=psi2s_scale-np.sqrt(psi2s_scale), upper_limit=psi2s_scale+np.sqrt(psi2s_scale)) + +#psi(3770) + +p3770_mass, p3770_width, p3770_phase, p3770_scale = pdg["p3770"] + +p3770_m = zfit.Parameter("p3770_m", ztf.constant(p3770_mass), floating = False) +p3770_w = zfit.Parameter("p3770_w", ztf.constant(p3770_width), floating = False) +p3770_p = zfit.Parameter("p3770_p", ztf.constant(p3770_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p3770_s = zfit.Parameter("p3770_s", ztf.constant(p3770_scale), lower_limit=p3770_scale-np.sqrt(p3770_scale), upper_limit=p3770_scale+np.sqrt(p3770_scale)) + +#psi(4040) + +p4040_mass, p4040_width, p4040_phase, p4040_scale = pdg["p4040"] + +p4040_m = zfit.Parameter("p4040_m", ztf.constant(p4040_mass), floating = False) +p4040_w = zfit.Parameter("p4040_w", ztf.constant(p4040_width), floating = False) +p4040_p = zfit.Parameter("p4040_p", ztf.constant(p4040_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p4040_s = zfit.Parameter("p4040_s", ztf.constant(p4040_scale), lower_limit=p4040_scale-np.sqrt(p4040_scale), upper_limit=p4040_scale+np.sqrt(p4040_scale)) + +#psi(4160) + +p4160_mass, p4160_width, p4160_phase, p4160_scale = pdg["p4160"] + +p4160_m = zfit.Parameter("p4160_m", ztf.constant(p4160_mass), floating = False) +p4160_w = zfit.Parameter("p4160_w", ztf.constant(p4160_width), floating = False) +p4160_p = zfit.Parameter("p4160_p", ztf.constant(p4160_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p4160_s = zfit.Parameter("p4160_s", ztf.constant(p4160_scale), lower_limit=p4160_scale-np.sqrt(p4160_scale), upper_limit=p4160_scale+np.sqrt(p4160_scale)) + +#psi(4415) + +p4415_mass, p4415_width, p4415_phase, p4415_scale = pdg["p4415"] + +p4415_m = zfit.Parameter("p4415_m", ztf.constant(p4415_mass), floating = False) +p4415_w = zfit.Parameter("p4415_w", ztf.constant(p4415_width), floating = False) +p4415_p = zfit.Parameter("p4415_p", ztf.constant(p4415_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p4415_s = zfit.Parameter("p4415_s", ztf.constant(p4415_scale), lower_limit=p4415_scale-np.sqrt(p4415_scale), upper_limit=p4415_scale+np.sqrt(p4415_scale)) + + +# ## Dynamic generation of 2 particle contribution + +# In[ ]: + + +m_c = 1300 + +Dbar_phase = 0.0 +DDstar_phase = 0.0 +Dstar_mass = pdg['Dst_M'] +Dbar_mass = pdg['D0_M'] +D_mass = pdg['D0_M'] + +Dbar_s = zfit.Parameter("Dbar_s", ztf.constant(0.0), lower_limit=-0.3, upper_limit=0.3) +Dbar_m = zfit.Parameter("Dbar_m", ztf.constant(Dbar_mass), floating = False) +Dbar_p = zfit.Parameter("Dbar_p", ztf.constant(Dbar_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi)#, floating = False) +DDstar_s = zfit.Parameter("DDstar_s", ztf.constant(0.0), lower_limit=-0.3, upper_limit=0.3)#, floating = False) +Dstar_m = zfit.Parameter("Dstar_m", ztf.constant(Dstar_mass), floating = False) +D_m = zfit.Parameter("D_m", ztf.constant(D_mass), floating = False) +DDstar_p = zfit.Parameter("DDstar_p", ztf.constant(DDstar_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi)#, floating = False) + + +# ## Tau parameters + +# In[ ]: + + +tau_m = zfit.Parameter("tau_m", ztf.constant(pdg['tau_M']), floating = False) +Ctt = zfit.Parameter("Ctt", ztf.constant(0.0), lower_limit=-2.5, upper_limit=2.5) + + +# ## Load data + +# In[ ]: + + +x_min = 2*pdg['muon_M'] +x_max = (pdg["Bplus_M"]-pdg["Ks_M"]-0.1) + +# # Full spectrum + +obs_toy = zfit.Space('q', limits = (x_min, x_max)) + +# Jpsi and Psi2s cut out + +obs1 = zfit.Space('q', limits = (x_min, jpsi_mass - 60.)) +obs2 = zfit.Space('q', limits = (jpsi_mass + 70., psi2s_mass - 50.)) +obs3 = zfit.Space('q', limits = (psi2s_mass + 50., x_max)) + +obs_fit = obs1 + obs2 + obs3 + +# with open(r"./data/slim_points/slim_points_toy_0_range({0}-{1}).pkl".format(int(x_min), int(x_max)), "rb") as input_file: +# part_set = pkl.load(input_file) + +# x_part = part_set['x_part'] + +# x_part = x_part.astype('float64') + +# data = zfit.data.Data.from_numpy(array=x_part, obs=obs) + + +# ## Setup pdf + +# In[ ]: + + +total_f = total_pdf_cut(obs=obs_toy, jpsi_mass = jpsi_m, jpsi_scale = jpsi_s, jpsi_phase = jpsi_p, jpsi_width = jpsi_w, + psi2s_mass = psi2s_m, psi2s_scale = psi2s_s, psi2s_phase = psi2s_p, psi2s_width = psi2s_w, + p3770_mass = p3770_m, p3770_scale = p3770_s, p3770_phase = p3770_p, p3770_width = p3770_w, + p4040_mass = p4040_m, p4040_scale = p4040_s, p4040_phase = p4040_p, p4040_width = p4040_w, + p4160_mass = p4160_m, p4160_scale = p4160_s, p4160_phase = p4160_p, p4160_width = p4160_w, + p4415_mass = p4415_m, p4415_scale = p4415_s, p4415_phase = p4415_p, p4415_width = p4415_w, + rho_mass = rho_m, rho_scale = rho_s, rho_phase = rho_p, rho_width = rho_w, + omega_mass = omega_m, omega_scale = omega_s, omega_phase = omega_p, omega_width = omega_w, + phi_mass = phi_m, phi_scale = phi_s, phi_phase = phi_p, phi_width = phi_w, + Dstar_mass = Dstar_m, DDstar_scale = DDstar_s, DDstar_phase = DDstar_p, D_mass = D_m, + Dbar_mass = Dbar_m, Dbar_scale = Dbar_s, Dbar_phase = Dbar_p, + tau_mass = tau_m, C_tt = Ctt, b0_0 = b0_0, b0_1 = b0_1, b0_2 = b0_2, + bplus_0 = bplus_0, bplus_1 = bplus_1, bplus_2 = bplus_2, + bT_0 = bT_0, bT_1 = bT_1, bT_2 = bT_2) + +total_f_fit = total_pdf_full(obs=obs_fit, jpsi_mass = jpsi_m, jpsi_scale = jpsi_s, jpsi_phase = jpsi_p, jpsi_width = jpsi_w, + psi2s_mass = psi2s_m, psi2s_scale = psi2s_s, psi2s_phase = psi2s_p, psi2s_width = psi2s_w, + p3770_mass = p3770_m, p3770_scale = p3770_s, p3770_phase = p3770_p, p3770_width = p3770_w, + p4040_mass = p4040_m, p4040_scale = p4040_s, p4040_phase = p4040_p, p4040_width = p4040_w, + p4160_mass = p4160_m, p4160_scale = p4160_s, p4160_phase = p4160_p, p4160_width = p4160_w, + p4415_mass = p4415_m, p4415_scale = p4415_s, p4415_phase = p4415_p, p4415_width = p4415_w, + rho_mass = rho_m, rho_scale = rho_s, rho_phase = rho_p, rho_width = rho_w, + omega_mass = omega_m, omega_scale = omega_s, omega_phase = omega_p, omega_width = omega_w, + phi_mass = phi_m, phi_scale = phi_s, phi_phase = phi_p, phi_width = phi_w, + Dstar_mass = Dstar_m, DDstar_scale = DDstar_s, DDstar_phase = DDstar_p, D_mass = D_m, + Dbar_mass = Dbar_m, Dbar_scale = Dbar_s, Dbar_phase = Dbar_p, + tau_mass = tau_m, C_tt = Ctt, b0_0 = b0_0, b0_1 = b0_1, b0_2 = b0_2, + bplus_0 = bplus_0, bplus_1 = bplus_1, bplus_2 = bplus_2, + bT_0 = bT_0, bT_1 = bT_1, bT_2 = bT_2) + +# print(total_pdf.obs) + +# print(calcs_test) + +# for param in total_f.get_dependents(): +# print(zfit.run(param)) + + +# In[ ]: + + +# total_f_fit.normalization(obs_fit) + + +# ## Test if graphs actually work and compute values + +# In[ ]: + + +# def total_test_tf(xq): + +# def jpsi_res(q): +# return resonance(q, jpsi_m, jpsi_s, jpsi_p, jpsi_w) + +# def psi2s_res(q): +# return resonance(q, psi2s_m, psi2s_s, psi2s_p, psi2s_w) + +# def cusp(q): +# return bifur_gauss(q, cusp_m, sig_L, sig_R, cusp_s) + +# funcs = jpsi_res(xq) + psi2s_res(xq) + cusp(xq) + +# vec_f = vec(xq, funcs) + +# axiv_nr = axiv_nonres(xq) + +# tot = vec_f + axiv_nr + +# return tot + +# def jpsi_res(q): +# return resonance(q, jpsi_m, jpsi_s, jpsi_p, jpsi_w) + +# calcs = zfit.run(total_test_tf(x_part)) + + + +test_q = np.linspace(x_min, x_max, int(2e6)) + +probs = total_f_fit.pdf(test_q, norm_range=False) + +calcs_test = zfit.run(probs) + +Ctt.set_value(0.5) + +calcs_test1 = zfit.run(probs) + +Ctt.set_value(0.0) + +Dbar_s.set_value(0.3) + +DDstar_s.set_value(0.3) + +calcs_test2 = zfit.run(probs) +# res_y = zfit.run(jpsi_res(test_q)) +# b0 = [b0_0, b0_1, b0_2] +# bplus = [bplus_0, bplus_1, bplus_2] +# bT = [bT_0, bT_1, bT_2] +# f0_y = zfit.run(tf.math.real(formfactor(test_q,"0", b0, bplus, bT))) +# fplus_y = zfit.run(tf.math.real(formfactor(test_q,"+", b0, bplus, bT))) +# fT_y = zfit.run(tf.math.real(formfactor(test_q,"T", b0, bplus, bT))) + + +# In[ ]: + + +plt.clf() +# plt.plot(x_part, calcs, '.') +plt.plot(test_q, calcs_test, label = 'pdf (Ctt = 0.0)') +plt.plot(test_q, calcs_test1, label = 'pdf (Ctt = 0.5)') +plt.plot(test_q, calcs_test2, label = 'pdf (D-contribs = 0.3)') +# plt.plot(test_q, f0_y, label = '0') +# plt.plot(test_q, fT_y, label = 'T') +# plt.plot(test_q, fplus_y, label = '+') +# plt.plot(test_q, res_y, label = 'res') +plt.legend() +plt.ylim(0.0, 1.5e-6) +# plt.yscale('log') +# plt.xlim(770, 785) +plt.savefig('test.png') +# print(jpsi_width) + + +# In[ ]: + + + + +# probs = mixture.prob(test_q) +# probs_np = zfit.run(probs) +# probs_np *= np.max(calcs_test) / np.max(probs_np) +# plt.figure() +# plt.semilogy(test_q, probs_np,label="importance sampling") +# plt.semilogy(test_q, calcs_test, label = 'pdf') + + +# In[ ]: + + +# 0.213/(0.00133+0.213+0.015) + + +# ## Adjust scaling of different parts + +# In[ ]: + + +total_f.update_integration_options(draws_per_dim=2000000, mc_sampler=None) +# inte = total_f.integrate(limits = (950., 1050.), norm_range=False) +# inte_fl = zfit.run(inte) +# print(inte_fl/4500) +# print(pdg["jpsi_BR"]/pdg["NR_BR"], inte_fl*pdg["psi2s_auc"]/pdg["NR_auc"]) + + +# In[ ]: + + +# # print("jpsi:", inte_fl) +# # print("Increase am by factor:", np.sqrt(pdg["jpsi_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) +# # print("New amp:", pdg["jpsi"][3]*np.sqrt(pdg["jpsi_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) + +# # print("psi2s:", inte_fl) +# # print("Increase am by factor:", np.sqrt(pdg["psi2s_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) +# # print("New amp:", pdg["psi2s"][3]*np.sqrt(pdg["psi2s_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) + +# name = "phi" + +# print(name+":", inte_fl) +# print("Increase am by factor:", np.sqrt(pdg[name+"_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) +# print("New amp:", pdg[name][0]*np.sqrt(pdg[name+"_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) + + +# print(x_min) +# print(x_max) +# # total_f.update_integration_options(draws_per_dim=2000000, mc_sampler=None) +# total_f.update_integration_options(mc_sampler=lambda dim, num_results, +# dtype: tf.random_uniform(maxval=1., shape=(num_results, dim), dtype=dtype), +# draws_per_dim=1000000) +# # _ = [] + +# # for i in range(10): + +# # inte = total_f.integrate(limits = (x_min, x_max)) +# # inte_fl = zfit.run(inte) +# # print(inte_fl) +# # _.append(inte_fl) + +# # print("mean:", np.mean(_)) + +# _ = time.time() + +# inte = total_f.integrate(limits = (x_min, x_max)) +# inte_fl = zfit.run(inte) +# print(inte_fl) +# print("Time taken: {}".format(display_time(int(time.time() - _)))) + +# print(pdg['NR_BR']/pdg['NR_auc']*inte_fl) +# print(0.25**2*4.2/1000) + + +# # Sampling +# ## Mixture distribution for sampling + +# In[ ]: + + + + +# print(list_of_borders[:9]) +# print(list_of_borders[-9:]) + + +class UniformSampleAndWeights(zfit.util.execution.SessionHolderMixin): + def __call__(self, limits, dtype, n_to_produce): + # n_to_produce = tf.cast(n_to_produce, dtype=tf.int32) + low, high = limits.limit1d + low = tf.cast(low, dtype=dtype) + high = tf.cast(high, dtype=dtype) +# uniform = tfd.Uniform(low=low, high=high) +# uniformjpsi = tfd.Uniform(low=tf.constant(3080, dtype=dtype), high=tf.constant(3112, dtype=dtype)) +# uniformpsi2s = tfd.Uniform(low=tf.constant(3670, dtype=dtype), high=tf.constant(3702, dtype=dtype)) + +# list_of_borders = [] +# _p = [] +# splits = 10 + +# _ = np.linspace(x_min, x_max, splits) + +# for i in range(splits): +# list_of_borders.append(tf.constant(_[i], dtype=dtype)) +# _p.append(tf.constant(1/splits, dtype=dtype)) + +# mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=_p[:(splits-1)]), +# components_distribution=tfd.Uniform(low=list_of_borders[:(splits-1)], +# high=list_of_borders[-(splits-1):])) + mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=[tf.constant(0.05, dtype=dtype), + tf.constant(0.93, dtype=dtype), + tf.constant(0.05, dtype=dtype), + tf.constant(0.065, dtype=dtype), + tf.constant(0.04, dtype=dtype), + tf.constant(0.05, dtype=dtype)]), + components_distribution=tfd.Uniform(low=[tf.constant(x_min, dtype=dtype), + tf.constant(3090, dtype=dtype), + tf.constant(3681, dtype=dtype), + tf.constant(3070, dtype=dtype), + tf.constant(1000, dtype=dtype), + tf.constant(3660, dtype=dtype)], + high=[tf.constant(x_max, dtype=dtype), + tf.constant(3102, dtype=dtype), + tf.constant(3691, dtype=dtype), + tf.constant(3110, dtype=dtype), + tf.constant(1040, dtype=dtype), + tf.constant(3710, dtype=dtype)])) +# dtype = tf.float64 +# mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=[tf.constant(0.04, dtype=dtype), +# tf.constant(0.90, dtype=dtype), +# tf.constant(0.02, dtype=dtype), +# tf.constant(0.07, dtype=dtype), +# tf.constant(0.02, dtype=dtype)]), +# components_distribution=tfd.Uniform(low=[tf.constant(x_min, dtype=dtype), +# tf.constant(3089, dtype=dtype), +# tf.constant(3103, dtype=dtype), +# tf.constant(3681, dtype=dtype), +# tf.constant(3691, dtype=dtype)], +# high=[tf.constant(3089, dtype=dtype), +# tf.constant(3103, dtype=dtype), +# tf.constant(3681, dtype=dtype), +# tf.constant(3691, dtype=dtype), +# tf.constant(x_max, dtype=dtype)])) +# mixture = tfd.Uniform(tf.constant(x_min, dtype=dtype), tf.constant(x_max, dtype=dtype)) +# sample = tf.random.uniform((n_to_produce, 1), dtype=dtype) + sample = mixture.sample((n_to_produce, 1)) +# sample = tf.random.uniform((n_to_produce, 1), dtype=dtype) + weights = mixture.prob(sample)[:,0] +# weights = tf.broadcast_to(tf.constant(1., dtype=dtype), shape=(n_to_produce,)) + # sample = tf.expand_dims(sample, axis=-1) +# print(sample, weights) + +# weights = tf.ones(shape=(n_to_produce,), dtype=dtype) + weights_max = None + thresholds = tf.random_uniform(shape=(n_to_produce,), dtype=dtype) + return sample, thresholds, weights, weights_max, n_to_produce + + +# In[ ]: + + +# total_f._sample_and_weights = UniformSampleAndWeights + + +# In[ ]: + + +# 0.00133/(0.00133+0.213+0.015)*(x_max-3750)/(x_max-x_min) + + +# In[ ]: + + +# zfit.settings.set_verbosity(10) + + +# In[ ]: + + +# # zfit.run.numeric_checks = False + +# nr_of_toys = 1 +# nevents = int(pdg["number_of_decays"]) +# nevents = pdg["number_of_decays"] +# event_stack = 1000000 +# # zfit.settings.set_verbosity(10) +# calls = int(nevents/event_stack + 1) + +# total_samp = [] + +# start = time.time() + +# sampler = total_f.create_sampler(n=event_stack) + +# for toy in range(nr_of_toys): + +# dirName = 'data/zfit_toys/toy_{0}'.format(toy) + +# if not os.path.exists(dirName): +# os.mkdir(dirName) +# print("Directory " , dirName , " Created ") + +# for call in range(calls): + +# sampler.resample(n=event_stack) +# s = sampler.unstack_x() +# sam = zfit.run(s) +# # clear_output(wait=True) + +# c = call + 1 + +# print("{0}/{1} of Toy {2}/{3}".format(c, calls, toy+1, nr_of_toys)) +# print("Time taken: {}".format(display_time(int(time.time() - start)))) +# print("Projected time left: {}".format(display_time(int((time.time() - start)/(c+calls*(toy))*((nr_of_toys-toy)*calls-c))))) + +# with open("data/zfit_toys/toy_{0}/{1}.pkl".format(toy, call), "wb") as f: +# pkl.dump(sam, f, pkl.HIGHEST_PROTOCOL) + + +# In[ ]: + + +# with open(r"data/zfit_toys/toy_0/0.pkl", "rb") as input_file: +# sam = pkl.load(input_file) +# print(sam[:10]) + +# with open(r"data/zfit_toys/toy_0/1.pkl", "rb") as input_file: +# sam2 = pkl.load(input_file) +# print(sam2[:10]) + +# print(np.sum(sam-sam2)) + + +# In[ ]: + + +# print("Time to generate full toy: {} s".format(int(time.time()-start))) + +# total_samp = [] + +# for call in range(calls): +# with open(r"data/zfit_toys/toy_0/{}.pkl".format(call), "rb") as input_file: +# sam = pkl.load(input_file) +# total_samp = np.append(total_samp, sam) + +# total_samp = total_samp.astype('float64') + +# data2 = zfit.data.Data.from_numpy(array=total_samp[:int(nevents)], obs=obs) + +# data3 = zfit.data.Data.from_numpy(array=total_samp, obs=obs) + +# print(total_samp[:nevents].shape) + + +# In[ ]: + + +# plt.clf() + +# bins = int((x_max-x_min)/7) + +# # calcs = zfit.run(total_test_tf(samp)) +# print(total_samp[:nevents].shape) + +# plt.hist(total_samp[:nevents], bins = bins, range = (x_min,x_max), label = 'data') +# # plt.plot(test_q, calcs_test*nevents , label = 'pdf') + +# # plt.plot(sam, calcs, '.') +# # plt.plot(test_q, calcs_test) +# # plt.yscale('log') +# plt.ylim(0, 200) +# # plt.xlim(3080, 3110) + +# plt.legend() + +# plt.savefig('test2.png') + + +# In[ ]: + + +# sampler = total_f.create_sampler(n=nevents) +# nll = zfit.loss.UnbinnedNLL(model=total_f, data=sampler, fit_range = (x_min, x_max)) + +# # for param in pdf.get_dependents(): +# # param.set_value(initial_value) + +# sampler.resample(n=nevents) + +# # Randomise initial values +# # for param in pdf.get_dependents(): +# # param.set_value(random value here) + +# # Minimise the NLL +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 10) +# minimum = minimizer.minimize(nll) + + +# In[ ]: + + +# jpsi_width + + +# In[ ]: + + +# plt.hist(sample, weights=1 / prob(sample)) + + +# # Fitting + +# In[ ]: + + +# start = time.time() + +# for param in total_f.get_dependents(): +# param.randomize() + +# # for param in total_f.get_dependents(): +# # print(zfit.run(param)) + +# nll = zfit.loss.UnbinnedNLL(model=total_f, data=data2, fit_range = (x_min, x_max)) + +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) +# # minimizer._use_tfgrad = False +# result = minimizer.minimize(nll) + +# # param_errors = result.error() + +# # for var, errors in param_errors.items(): +# # print('{}: ^{{+{}}}_{{{}}}'.format(var.name, errors['upper'], errors['lower'])) + +# print("Function minimum:", result.fmin) +# # print("Results:", result.params) +# print("Hesse errors:", result.hesse()) + + +# In[ ]: + + +# print("Time taken for fitting: {}".format(display_time(int(time.time()-start)))) + +# # probs = total_f.pdf(test_q) + +# calcs_test = zfit.run(probs) +# res_y = zfit.run(jpsi_res(test_q)) + + +# In[ ]: + + +# plt.clf() +# # plt.plot(x_part, calcs, '.') +# plt.plot(test_q, calcs_test, label = 'pdf') +# # plt.plot(test_q, res_y, label = 'res') +# plt.legend() +# plt.ylim(0.0, 10e-6) +# # plt.yscale('log') +# # plt.xlim(3080, 3110) +# plt.savefig('test3.png') +# # print(jpsi_width) + + +# In[ ]: + + +# _tot = 4.37e-7+6.02e-5+4.97e-6 +# _probs = [] +# _probs.append(6.02e-5/_tot) +# _probs.append(4.97e-6/_tot) +# _probs.append(4.37e-7/_tot) +# print(_probs) + + +# In[ ]: + + +# dtype = 'float64' +# # mixture = tfd.Uniform(tf.constant(x_min, dtype=dtype), tf.constant(x_max, dtype=dtype)) +# mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=[tf.constant(0.007, dtype=dtype), +# tf.constant(0.917, dtype=dtype), +# tf.constant(0.076, dtype=dtype)]), +# components_distribution=tfd.Uniform(low=[tf.constant(x_min, dtype=dtype), +# tf.constant(3080, dtype=dtype), +# tf.constant(3670, dtype=dtype)], +# high=[tf.constant(x_max, dtype=dtype), +# tf.constant(3112, dtype=dtype), +# tf.constant(3702, dtype=dtype)])) +# # for i in range(10): +# # print(zfit.run(mixture.prob(mixture.sample((10, 1))))) + + +# In[ ]: + + +# print((zfit.run(jpsi_p)%(2*np.pi))/np.pi) +# print((zfit.run(psi2s_p)%(2*np.pi))/np.pi) + + +# In[ ]: + + +# def jpsi_res(q): +# return resonance(q, _mass = jpsi_mass, scale = jpsi_scale, +# phase = jpsi_phase, width = jpsi_width) + +# def psi2s_res(q): +# return resonance(q, _mass = psi2s_mass, scale = psi2s_scale, +# phase = psi2s_phase, width = psi2s_width) + +# def p3770_res(q): +# return resonance(q, _mass = p3770_mass, scale = p3770_scale, +# phase = p3770_phase, width = p3770_width) + +# def p4040_res(q): +# return resonance(q, _mass = p4040_mass, scale = p4040_scale, +# phase = p4040_phase, width = p4040_width) + +# def p4160_res(q): +# return resonance(q, _mass = p4160_mass, scale = p4160_scale, +# phase = p4160_phase, width = p4160_width) + +# def p4415_res(q): +# return resonance(q, _mass = p4415_mass, scale = p4415_scale, +# phase = p4415_phase, width = p4415_width) + + +# In[ ]: + + +# 0.15**2*4.2/1000 +# result.hesse() + + +# ## Constraints + +# In[ ]: + + +# 1. Constraint - Real part of sum of Psi contrib and D contribs + +sum_list = [] + +sum_list.append(ztf.to_complex(jpsi_s) * tf.exp(tf.complex(ztf.constant(0.0), jpsi_p)) * ztf.to_complex(jpsi_w / (tf.pow(jpsi_m,3)))) +sum_list.append(ztf.to_complex(psi2s_s) * tf.exp(tf.complex(ztf.constant(0.0), psi2s_p)) * ztf.to_complex(psi2s_w / (tf.pow(psi2s_m,3)))) +sum_list.append(ztf.to_complex(p3770_s) * tf.exp(tf.complex(ztf.constant(0.0), p3770_p)) * ztf.to_complex(p3770_w / (tf.pow(p3770_m,3)))) +sum_list.append(ztf.to_complex(p4040_s) * tf.exp(tf.complex(ztf.constant(0.0), p4040_p)) * ztf.to_complex(p4040_w / (tf.pow(p4040_m,3)))) +sum_list.append(ztf.to_complex(p4160_s) * tf.exp(tf.complex(ztf.constant(0.0), p4160_p)) * ztf.to_complex(p4160_w / (tf.pow(p4160_m,3)))) +sum_list.append(ztf.to_complex(p4415_s) * tf.exp(tf.complex(ztf.constant(0.0), p4415_p)) * ztf.to_complex(p4415_w / (tf.pow(p4415_m,3)))) +sum_list.append(ztf.to_complex(DDstar_s) * tf.exp(tf.complex(ztf.constant(0.0), DDstar_p)) * (ztf.to_complex(1.0 / (10.0*tf.pow(Dstar_m,2)) + 1.0 / (10.0*tf.pow(D_m,2))))) +sum_list.append(ztf.to_complex(Dbar_s) * tf.exp(tf.complex(ztf.constant(0.0), Dbar_p)) * ztf.to_complex(1.0 / (6.0*tf.pow(Dbar_m,2)))) + +sum_ru_1 = ztf.to_complex(ztf.constant(0.0)) + +for part in sum_list: + sum_ru_1 += part + +sum_1 = tf.math.real(sum_ru_1) +# constraint1 = zfit.constraint.GaussianConstraint(params = sum_1, mu = ztf.constant(1.7*10**-8), +# sigma = ztf.constant(2.2*10**-8)) + +constraint1 = tf.pow((sum_1-ztf.constant(1.7*10**-8))/ztf.constant(2.2*10**-8),2)/ztf.constant(2.) + +# 2. Constraint - Abs. of sum of Psi contribs and D contribs + +sum_2 = tf.abs(sum_ru_1) +constraint2 = tf.cond(tf.greater_equal(sum_2, 5.0e-8), lambda: 100000., lambda: 0.) + +# 3. Constraint - Maximum eta of D contribs + +constraint3_0 = tf.cond(tf.greater_equal(tf.abs(Dbar_s), 0.2), lambda: 100000., lambda: 0.) + +constraint3_1 = tf.cond(tf.greater_equal(tf.abs(DDstar_s), 0.2), lambda: 100000., lambda: 0.) + +# 4. Constraint - Formfactor multivariant gaussian covariance fplus + +Cov_matrix = [[ztf.constant( 1.), ztf.constant( 0.45), ztf.constant( 0.19), ztf.constant(0.857), ztf.constant(0.598), ztf.constant(0.531), ztf.constant(0.752), ztf.constant(0.229), ztf.constant(0,117)], + [ztf.constant( 0.45), ztf.constant( 1.), ztf.constant(0.677), ztf.constant(0.708), ztf.constant(0.958), ztf.constant(0.927), ztf.constant(0.227), ztf.constant(0.443), ztf.constant(0.287)], + [ztf.constant( 0.19), ztf.constant(0.677), ztf.constant( 1.), ztf.constant(0.595), ztf.constant(0.770), ztf.constant(0.819),ztf.constant(-0.023), ztf.constant( 0.07), ztf.constant(0.196)], + [ztf.constant(0.857), ztf.constant(0.708), ztf.constant(0.595), ztf.constant( 1.), ztf.constant( 0.83), ztf.constant(0.766), ztf.constant(0.582), ztf.constant(0.237), ztf.constant(0.192)], + [ztf.constant(0.598), ztf.constant(0.958), ztf.constant(0.770), ztf.constant( 0.83), ztf.constant( 1.), ztf.constant(0.973), ztf.constant(0.324), ztf.constant(0.372), ztf.constant(0.272)], + [ztf.constant(0.531), ztf.constant(0.927), ztf.constant(0.819), ztf.constant(0.766), ztf.constant(0.973), ztf.constant( 1.), ztf.constant(0.268), ztf.constant(0.332), ztf.constant(0.269)], + [ztf.constant(0.752), ztf.constant(0.227),ztf.constant(-0.023), ztf.constant(0.582), ztf.constant(0.324), ztf.constant(0.268), ztf.constant( 1.), ztf.constant( 0.59), ztf.constant(0.515)], + [ztf.constant(0.229), ztf.constant(0.443), ztf.constant( 0.07), ztf.constant(0.237), ztf.constant(0.372), ztf.constant(0.332), ztf.constant( 0.59), ztf.constant( 1.), ztf.constant(0.897)], + [ztf.constant(0.117), ztf.constant(0.287), ztf.constant(0.196), ztf.constant(0.192), ztf.constant(0.272), ztf.constant(0.269), ztf.constant(0.515), ztf.constant(0.897), ztf.constant( 1.)]] + +def triGauss(val1,val2,val3,m = Cov_matrix): + + mean1 = ztf.constant(0.466) + mean2 = ztf.constant(-0.885) + mean3 = ztf.constant(-0.213) + sigma1 = ztf.constant(0.014) + sigma2 = ztf.constant(0.128) + sigma3 = ztf.constant(0.548) + x1 = (val1-mean1)/sigma1 + x2 = (val2-mean2)/sigma2 + x3 = (val3-mean3)/sigma3 + rho12 = m[0][1] + rho13 = m[0][2] + rho23 = m[1][2] + w = x1*x1*(rho23*rho23-1) + x2*x2*(rho13*rho13-1)+x3*x3*(rho12*rho12-1)+2*(x1*x2*(rho12-rho13*rho23)+x1*x3*(rho13-rho12*rho23)+x2*x3*(rho23-rho12*rho13)) + d = 2*(rho12*rho12+rho13*rho13+rho23*rho23-2*rho12*rho13*rho23-1) + + fcn = -w/d + chisq = -2*fcn + return chisq + +constraint4 = triGauss(bplus_0, bplus_1, bplus_2) + +# mean1 = ztf.constant(0.466) +# mean2 = ztf.constant(-0.885) +# mean3 = ztf.constant(-0.213) +# sigma1 = ztf.constant(0.014) +# sigma2 = ztf.constant(0.128) +# sigma3 = ztf.constant(0.548) +# constraint4_0 = tf.pow((bplus_0-mean1)/sigma1,2)/ztf.constant(2.) +# constraint4_1 = tf.pow((bplus_1-mean2)/sigma2,2)/ztf.constant(2.) +# constraint4_2 = tf.pow((bplus_2-mean3)/sigma3,2)/ztf.constant(2.) + +# 5. Constraint - Abs. of sum of light contribs + +sum_list_5 = [] + +sum_list_5.append(rho_s*rho_w/rho_m) +sum_list_5.append(omega_s*omega_w/omega_m) +sum_list_5.append(phi_s*phi_w/phi_m) + + +sum_ru_5 = ztf.constant(0.0) + +for part in sum_list_5: + sum_ru_5 += part + +constraint5 = tf.cond(tf.greater_equal(tf.abs(sum_ru_5), ztf.constant(0.02)), lambda: 100000., lambda: 0.) + +# 6. Constraint on phases of Jpsi and Psi2s for cut out fit + + +# constraint6_0 = zfit.constraint.GaussianConstraint(params = jpsi_p, mu = ztf.constant(pdg["jpsi_phase_unc"]), +# sigma = ztf.constant(jpsi_phase)) +# constraint6_1 = zfit.constraint.GaussianConstraint(params = psi2s_p, mu = ztf.constant(pdg["psi2s_phase_unc"]), +# sigma = ztf.constant(psi2s_phase)) + +constraint6_0 = tf.pow((jpsi_p-ztf.constant(jpsi_phase))/ztf.constant(pdg["jpsi_phase_unc"]),2)/ztf.constant(2.) +constraint6_1 = tf.pow((psi2s_p-ztf.constant(psi2s_phase))/ztf.constant(pdg["psi2s_phase_unc"]),2)/ztf.constant(2.) + +# 7. Constraint on Ctt with higher limits + +constraint7 = tf.cond(tf.greater_equal(Ctt*Ctt, 0.25), lambda: 100000., lambda: 0.) + +constraint7dtype = tf.float64 + +# zfit.run(constraint6_0) + +# ztf.convert_to_tensor(constraint6_0) + +#List of all constraints + +constraints = [constraint1, constraint2, constraint3_0, constraint3_1,# constraint4, #constraint4_0, constraint4_1, constraint4_2, + constraint6_0, constraint6_1]#, constraint7] + + +# ## Reset params + +# In[ ]: + + +param_values_dic = { + 'jpsi_m': jpsi_mass, + 'jpsi_s': jpsi_scale, + 'jpsi_p': jpsi_phase, + 'jpsi_w': jpsi_width, + 'psi2s_m': psi2s_mass, + 'psi2s_s': psi2s_scale, + 'psi2s_p': psi2s_phase, + 'psi2s_w': psi2s_width, + 'p3770_m': p3770_mass, + 'p3770_s': p3770_scale, + 'p3770_p': p3770_phase, + 'p3770_w': p3770_width, + 'p4040_m': p4040_mass, + 'p4040_s': p4040_scale, + 'p4040_p': p4040_phase, + 'p4040_w': p4040_width, + 'p4160_m': p4160_mass, + 'p4160_s': p4160_scale, + 'p4160_p': p4160_phase, + 'p4160_w': p4160_width, + 'p4415_m': p4415_mass, + 'p4415_s': p4415_scale, + 'p4415_p': p4415_phase, + 'p4415_w': p4415_width, + 'rho_m': rho_mass, + 'rho_s': rho_scale, + 'rho_p': rho_phase, + 'rho_w': rho_width, + 'omega_m': omega_mass, + 'omega_s': omega_scale, + 'omega_p': omega_phase, + 'omega_w': omega_width, + 'phi_m': phi_mass, + 'phi_s': phi_scale, + 'phi_p': phi_phase, + 'phi_w': phi_width, + 'Dstar_m': Dstar_mass, + 'DDstar_s': 0.0, + 'DDstar_p': 0.0, + 'D_m': D_mass, + 'Dbar_m': Dbar_mass, + 'Dbar_s': 0.0, + 'Dbar_p': 0.0, + 'tau_m': pdg['tau_M'], + 'Ctt': 0.0, + 'b0_0': 0.292, + 'b0_1': 0.281, + 'b0_2': 0.150, + 'bplus_0': 0.466, + 'bplus_1': -0.885, + 'bplus_2': -0.213, + 'bT_0': 0.460, + 'bT_1': -1.089, + 'bT_2': -1.114} + + +def reset_param_values(variation = 0.05): + for param in total_f_fit.get_dependents(): + if param.floating: + param.set_value(param_values_dic[param.name] + random.uniform(-1, 1) * param_values_dic[param.name]* variation) +# print(param.name) +# for param in totalf.get_dependents(): +# param.set_value() + + +# # Analysis + +# In[ ]: + + +# # zfit.run.numeric_checks = False + +# fitting_range = 'cut' +# total_BR = 1.7e-10 + 4.9e-10 + 2.5e-9 + 6.02e-5 + 4.97e-6 + 1.38e-9 + 4.2e-10 + 2.6e-9 + 6.1e-10 + 4.37e-7 +# cut_BR = 1.0 - (6.02e-5 + 4.97e-6)/total_BR + +# Ctt_list = [] +# Ctt_error_list = [] + +# nr_of_toys = 1 +# if fitting_range == 'cut': +# nevents = int(pdg["number_of_decays"]*cut_BR) +# else: +# nevents = int(pdg["number_of_decays"]) +# # nevents = pdg["number_of_decays"] +# event_stack = 1000000 +# # nevents *= 41 +# # zfit.settings.set_verbosity(10) +# calls = int(nevents/event_stack + 1) + +# total_samp = [] + +# start = time.time() + +# sampler = total_f.create_sampler(n=event_stack) + +# for toy in range(nr_of_toys): + +# ### Generate data + +# # clear_output(wait=True) + +# print("Toy {}: Generating data...".format(toy)) + +# dirName = 'data/zfit_toys/toy_{0}'.format(toy) + +# if not os.path.exists(dirName): +# os.mkdir(dirName) +# print("Directory " , dirName , " Created ") + +# reset_param_values() + +# if fitting_range == 'cut': + +# sampler.resample(n=nevents) +# s = sampler.unstack_x() +# sam = zfit.run(s) +# calls = 0 +# c = 1 + +# else: +# for call in range(calls): + +# sampler.resample(n=event_stack) +# s = sampler.unstack_x() +# sam = zfit.run(s) + +# c = call + 1 + +# with open("data/zfit_toys/toy_{0}/{1}.pkl".format(toy, call), "wb") as f: +# pkl.dump(sam, f, pkl.HIGHEST_PROTOCOL) + +# print("Toy {}: Data generation finished".format(toy)) + +# ### Load data + +# print("Toy {}: Loading data...".format(toy)) + +# if fitting_range == 'cut': + +# total_samp = sam + +# else: + +# for call in range(calls): +# with open(r"data/zfit_toys/toy_0/{}.pkl".format(call), "rb") as input_file: +# sam = pkl.load(input_file) +# total_samp = np.append(total_samp, sam) + +# total_samp = total_samp.astype('float64') + +# if fitting_range == 'full': + +# data = zfit.data.Data.from_numpy(array=total_samp[:int(nevents)], obs=obs) + +# print("Toy {}: Loading data finished".format(toy)) + +# ### Fit data + +# print("Toy {}: Fitting pdf...".format(toy)) + +# for param in total_f.get_dependents(): +# param.randomize() + +# nll = zfit.loss.UnbinnedNLL(model=total_f, data=data, fit_range = (x_min, x_max), constraints = constraints) + +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) +# # minimizer._use_tfgrad = False +# result = minimizer.minimize(nll) + +# print("Toy {}: Fitting finished".format(toy)) + +# print("Function minimum:", result.fmin) +# print("Hesse errors:", result.hesse()) + +# params = result.params +# Ctt_list.append(params[Ctt]['value']) +# Ctt_error_list.append(params[Ctt]['minuit_hesse']['error']) + +# #plotting the result + +# plotdirName = 'data/plots'.format(toy) + +# if not os.path.exists(plotdirName): +# os.mkdir(plotdirName) +# # print("Directory " , dirName , " Created ") + +# probs = total_f.pdf(test_q, norm_range=False) +# calcs_test = zfit.run(probs) +# plt.clf() +# plt.plot(test_q, calcs_test, label = 'pdf') +# plt.legend() +# plt.ylim(0.0, 6e-6) +# plt.savefig(plotdirName + '/toy_fit_full_range{}.png'.format(toy)) + +# print("Toy {0}/{1}".format(toy+1, nr_of_toys)) +# print("Time taken: {}".format(display_time(int(time.time() - start)))) +# print("Projected time left: {}".format(display_time(int((time.time() - start)/(c+calls*(toy))*((nr_of_toys-toy)*calls-c))))) + +# if fitting_range == 'cut': + +# _1 = np.where((total_samp >= x_min) & (total_samp <= (jpsi_mass - 60.))) + +# tot_sam_1 = total_samp[_1] + +# _2 = np.where((total_samp >= (jpsi_mass + 70.)) & (total_samp <= (psi2s_mass - 50.))) + +# tot_sam_2 = total_samp[_2] + +# _3 = np.where((total_samp >= (psi2s_mass + 50.)) & (total_samp <= x_max)) + +# tot_sam_3 = total_samp[_3] + +# tot_sam = np.append(tot_sam_1, tot_sam_2) +# tot_sam = np.append(tot_sam, tot_sam_3) + +# data = zfit.data.Data.from_numpy(array=tot_sam[:int(nevents)], obs=obs_fit) + +# print("Toy {}: Loading data finished".format(toy)) + +# ### Fit data + +# print("Toy {}: Fitting pdf...".format(toy)) + +# for param in total_f_fit.get_dependents(): +# param.randomize() + +# nll = zfit.loss.UnbinnedNLL(model=total_f_fit, data=data, constraints = constraints) + +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) +# # minimizer._use_tfgrad = False +# result = minimizer.minimize(nll) + +# print("Function minimum:", result.fmin) +# print("Hesse errors:", result.hesse()) + +# params = result.params + +# if result.converged: +# Ctt_list.append(params[Ctt]['value']) +# Ctt_error_list.append(params[Ctt]['minuit_hesse']['error']) + +# #plotting the result + +# plotdirName = 'data/plots'.format(toy) + +# if not os.path.exists(plotdirName): +# os.mkdir(plotdirName) +# # print("Directory " , dirName , " Created ") + +# plt.clf() +# plt.hist(tot_sam, bins = int((x_max-x_min)/7.), label = 'toy data') +# plt.savefig(plotdirName + '/toy_histo_cut_region{}.png'.format(toy)) + + +# probs = total_f_fit.pdf(test_q, norm_range=False) +# calcs_test = zfit.run(probs) +# plt.clf() +# plt.plot(test_q, calcs_test, label = 'pdf') +# plt.axvline(x=jpsi_mass-60.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.axvline(x=jpsi_mass+70.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.axvline(x=psi2s_mass-50.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.axvline(x=psi2s_mass+50.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.legend() +# plt.ylim(0.0, 1.5e-6) +# plt.savefig(plotdirName + '/toy_fit_cut_region{}.png'.format(toy)) + +# print("Toy {0}/{1}".format(toy+1, nr_of_toys)) +# print("Time taken: {}".format(display_time(int(time.time() - start)))) +# print("Projected time left: {}".format(display_time(int((time.time() - start)/(toy+1))*((nr_of_toys-toy-1))))) + + + +# In[ ]: + + +# with open("data/results/Ctt_list.pkl", "wb") as f: +# pkl.dump(Ctt_list, f, pkl.HIGHEST_PROTOCOL) +# with open("data/results/Ctt_error_list.pkl", "wb") as f: +# pkl.dump(Ctt_error_list, f, pkl.HIGHEST_PROTOCOL) + + +# In[ ]: + + +# print('{0}/{1} fits converged'.format(len(Ctt_list), nr_of_toys)) +# print('Mean Ctt value = {}'.format(np.mean(Ctt_list))) +# print('Mean Ctt error = {}'.format(np.mean(Ctt_error_list))) +# print('95 Sensitivy = {}'.format(((2*np.mean(Ctt_error_list))**2)*4.2/1000)) + + +# In[ ]: + + +# plt.hist(tot_sam, bins = int((x_max-x_min)/7.)) + +# plt.show() + +# # _ = np.where((total_samp >= x_min) & (total_samp <= (jpsi_mass - 50.))) + +# tot_sam.shape + + +# In[ ]: + + +# Ctt.floating = False + + +# In[ ]: + + +# zfit.run(nll.value()) + + +# In[ ]: + + +# result.fmin + + +# In[ ]: + + +# BR_steps = np.linspace(0.0, 1e-3, 11) +pull_dic = {} + +mi = 1e-4 +ma = 3e-3 +ste = 20 + +for param in total_f_fit.get_dependents(): + if param.floating: + pull_dic[param.name] = [] + for step in range(2*ste): + pull_dic[param.name].append([]) + + + +def save_pulls(step): + for param in total_f_fit.get_dependents(): + if param.floating: + pull_dic[param.name][step].append((params[param]['value'] - param_values_dic[param.name])/params[param]['minuit_hesse']['error']) + + + +# for key in pull_dic.keys(): +# print(np.shape(pull_dic[key])) +# save_pulls(New_step=True) +# params[Ctt]['value'] + + +# In[ ]: + + +# for param in total_f_fit.get_dependents(): +# if param.floating: +# print(param.name) + +# print(params[Ctt]) + + +# # CLS Code + +# In[ ]: + + +# zfit.run.numeric_checks = False + +load = False + +bo = True + +D_contribs = True + +if not D_contribs: + Dbar_s.floating = False + Dbar_p.floating = False + DDstar_s.floating = False + DDstar_p.floating = False + +bo_set = 1 + +fitting_range = 'cut' +total_BR = 1.7e-10 + 4.9e-10 + 2.5e-9 + 6.02e-5 + 4.97e-6 + 1.38e-9 + 4.2e-10 + 2.6e-9 + 6.1e-10 + 4.37e-7 +cut_BR = 1.0 - (6.02e-5 + 4.97e-6)/total_BR + +Ctt_list = [] +Ctt_error_list = [] + +nr_of_toys = 1 +nevents = int(pdg["number_of_decays"]*cut_BR) +# nevents = pdg["number_of_decays"] +event_stack = 1000000 +# nevents *= 41 +# zfit.settings.set_verbosity(10) + +# mi = 1e-4 +# ma = 3e-3 +# ste = 13 + +BR_steps = np.linspace(mi, ma, ste) + +BR_steps[0] = 0.0 + +print(BR_steps) + +Ctt_steps = np.sqrt(BR_steps/4.2*1000) + +print(Ctt_steps) + +# total_samp = [] + +start = time.time() + +Nll_list = [] + +sampler = total_f.create_sampler(n=nevents, fixed_params = False) +sampler.set_data_range(obs_fit) + +__ = -1 + +#----------------------------------------------------- + +if not load: + for Ctt_step in Ctt_steps: + + __ += 1 + + for i in range(2): + Ctt_list.append([]) + Ctt_error_list.append([]) + Nll_list.append([]) + + for param in total_f_fit.get_dependents(): + if param.floating: + pull_dic[param.name].append([]) + + for toy in range(nr_of_toys): + + newset = True + + while newset: + + for floaty in [True, False]: + Ctt.floating = floaty + + for bo_step in range(bo_set): + + print('Step: {0}/{1}'.format(int(__), ste)) + print('Current Ctt: {0}'.format(Ctt_step)) + print('Ctt floating: {0}'.format(floaty)) + + reset_param_values(variation = 0.0) + + if floaty: + print('Toy {0}/{1} - Fit {2}/{3}'.format(toy, nr_of_toys, bo_step, bo_set)) + Ctt.set_value(Ctt_step) + + else: + Ctt.set_value(0.0) + print('Toy {0}/{1} - Fit {2}/{3}'.format(toy, nr_of_toys, bo_step, bo_set)) + + if newset: + sampler.resample(n=nevents) + data = sampler + newset = False + + ### Fit data + + if floaty: + #plt.clf() + #plt.title('Ctt value: {:.2f}'.format(Ctt_step)) + #plt.hist(zfit.run(data), bins = int((x_max-x_min)/7), range = (x_min, x_max)) + #plt.savefig('data/CLs/plots/set_histo{}.png'.format(__)) + _step = 2*__ + else: + _step = 2*__+1 + + nll = zfit.loss.UnbinnedNLL(model=total_f_fit, data=data, constraints = constraints) + + minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) + # minimizer._use_tfgrad = False + result = minimizer.minimize(nll) + + print("Function minimum:", result.fmin) + print("Hesse errors:", result.hesse()) + + params = result.params + + if result.converged: + + save_pulls(step = _step) + + if floaty: + Nll_list[-2].append(result.fmin) + Ctt_list[-2].append(params[Ctt]['value']) + Ctt_error_list[-2].append(params[Ctt]['minuit_hesse']['error']) + + else: + Nll_list[-1].append(result.fmin) + Ctt_list[-1].append(0.0) + Ctt_error_list[-1].append(0.0) + + + else: + for _ in [1,2]: + del Nll_list[-_][toy*bo_set:] +# print(np.shape(Nll_list[-_])) + del Ctt_list[-_][toy*bo_set:] + del Ctt_error_list[-_][toy*bo_set:] + for param in total_f_fit.get_dependents(): + if param.floating: + del pull_dic[param.name][_step+1-_][toy*bo_set:] + newset = True + break + + if not result.converged: + break + + print() + print('Time taken: {}'.format(display_time(int(time.time()-start)))) + print('Estimated time left: {}'.format(display_time(int((time.time()-start)/(__+(toy+1)/nr_of_toys)*(ste-__-(nr_of_toys-toy-1)/nr_of_toys))))) + + +# In[ ]: + + +if load: + + phase_combi = '--' + + if D_contribs: + D_dir = 'D-True' + else: + D_dir = 'D-False' + + _dir = 'data/CLs/finished/f1d1/{}/{}/'.format(phase_combi, D_dir) + + jobs = os.listdir(_dir) + + First = True + +# print(jobs) + + for job in jobs: + + dirName = _dir + str(job) + '/data/CLs' + + if not os.path.exists("{}/{}-{}_{}s{}b{}t--CLs_Nll_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys)): +# print(job) + continue + + with open(r"{}/variab.pkl".format(dirName), "rb") as input_file: + variab = pkl.load(input_file) +# print(variab) + + ### sanity check: + if variab['mi'] != mi or variab['ma'] != ma or variab['ste'] != ste or bo_set != bo_set: + print('Fitting parameters of data dont equal the ones given -- Job {} skipped!'.format(job)) + + with open(r"{}/{}-{}_{}s{}b{}t--CLs_Nll_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _Nll_list = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s{}b{}t--Ctt_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _Ctt_list = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s{}b{}t--Ctt_error_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _Ctt_error_list = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s{}b{}t--pull_dic.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _pull_dic = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s--CLs_list.pkl".format(dirName, mi,ma,ste), "rb") as input_file: + _CLs_list = pkl.load(input_file) + + + if First: + Nll_list = _Nll_list + Ctt_list = _Ctt_list + Ctt_error_list = _Ctt_error_list + pull_dic = _pull_dic +# print(_pull_dic) + CLs_list = _CLs_list + First = False + else: + for step in range(2*ste): +# print(Nll_list[step], step) + Nll_list[step].extend(_Nll_list[step]) + Ctt_list[step].extend(_Ctt_list[step]) + Ctt_error_list[step].extend(_Ctt_error_list[step]) + for key in pull_dic.keys(): +# print(key, np.shape(pull_dic[key])) + pull_dic[key][step].extend(_pull_dic[key][step]) + for step in range(ste): + CLs_list[step].extend(_CLs_list[step]) + +# print('----------------------') + + +# In[ ]: + + +dirName = 'data/CLs' + +# if bo and not load: +# for s in range(2*ste): +# Nll_list[s] = [np.min(Nll_list[s])] + + +if not load: + + if not os.path.exists(dirName): + os.mkdir(dirName) + print("Directory " , dirName , " Created ") + + with open("{}/{}-{}_{}s{}b{}t--CLs_Nll_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(Nll_list, f, pkl.HIGHEST_PROTOCOL) + + with open("{}/{}-{}_{}s{}b{}t--Ctt_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(Ctt_list, f, pkl.HIGHEST_PROTOCOL) + + with open("{}/{}-{}_{}s{}b{}t--Ctt_error_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(Ctt_error_list, f, pkl.HIGHEST_PROTOCOL) + + with open("{}/{}-{}_{}s{}b{}t--pull_dic.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(pull_dic, f, pkl.HIGHEST_PROTOCOL) + + variab = {'mi': mi, + 'ma': ma, + 'ste': ste, + 'bo_set': bo_set, + 'nr_of_toys': nr_of_toys} + + with open("{}/variab.pkl".format(dirName), "wb") as f: + pkl.dump(variab, f, pkl.HIGHEST_PROTOCOL) + + CLs_values = [] + + toy_size = bo_set + + print(np.shape(Nll_list)) + print(Nll_list[0:1]) + + for step in range(ste): + CLs_values.append([]) + for toy in range(nr_of_toys): + float_min = np.min(Nll_list[2*step][toy*bo_set:(toy+1)*bo_set]) + fix_min = np.min(Nll_list[2*step+1][toy*bo_set:(toy+1)*bo_set]) + CLs_values[step].append(float_min-fix_min) + + + print(np.shape(CLs_values)) + + with open("{}/{}-{}_{}s--CLs_list.pkl".format(dirName, mi,ma,ste), "wb") as f: + pkl.dump(CLs_values, f, pkl.HIGHEST_PROTOCOL) + + +# In[ ]: + + +# print(variab['mi'] != mi) + + +# ## Plot + +# In[ ]: + + +l = [] + + +if load: + CLs_values = -1*np.array(CLs_list) + +if not os.path.exists('data/CLs/plots'): + os.mkdir('data/CLs/plots') + print("Directory " , 'data/CLs/plots' , " Created ") + +print(np.shape(CLs_values)) + +for step in range(1,ste): + plt.clf() + plt.title('Ctt value: {:.2f}'.format(Ctt_steps[step])) + plt.hist(CLs_values[0], bins = 150, range = (-25, 50), label = 'Ctt fixed to 0') + plt.hist(CLs_values[step], bins = 150, range = (-25, 50), label = 'Ctt floating') + plt.axvline(x=np.mean(CLs_values[0]),color='red', linewidth=1.0, linestyle = 'dotted') + plt.legend() + plt.savefig('data/CLs/plots/CLs-BR({:.1E}).png'.format(BR_steps[step])) + + l.append(len(np.where(np.array(CLs_values[step]) < np.mean(CLs_values[0]))[0])) + +for step in range(2*ste): + if step%2 == 0: + floaty = True + else: + floaty = False + for key in pull_dic.keys(): + if not os.path.exists('data/CLs/plots/{}'.format(key)): + os.mkdir('data/CLs/plots/{}'.format(key)) + plt.clf() + plt.title('Pull {} - Ctt value {:.2f} - floating {}'.format(key, Ctt_steps[int(step/2)], floaty)) + plt.hist(pull_dic[key][step], bins = 50, range = (-5,5)) + plt.xlabel('Pull') + plt.savefig('data/CLs/plots/{}/{:.2f}Ctt{}s{}f.png'.format(key, Ctt_steps[int(step/2)], step, floaty)) + + +# In[ ]: + + +for s in range(len(l)): + print('BR: {:.4f}'.format(BR_steps[s+1])) + print(2*l[s]/len(CLs_values[s])) + print() + + +# In[ ]: + + +# for step in range(2*ste): +# for key in pull_dic.keys(): +# print(pull_dic[key][step]) + + +# In[ ]: + + +# for param in total_f_fit.get_dependents(): +# if param.floating: +# print(params[param]['value']) + + +# In[ ]: + + +print(display_time(int(time.time()-start))) + + +# In[ ]: + + +# variab['mi'] =! mi + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + diff --git a/data/CLs/finished/f1d1/-+/D-True/2288025/__pycache__/helperfunctions.cpython-37.pyc b/data/CLs/finished/f1d1/-+/D-True/2288025/__pycache__/helperfunctions.cpython-37.pyc new file mode 100644 index 0000000..507f75b --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288025/__pycache__/helperfunctions.cpython-37.pyc Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288025/__pycache__/pdg_const1.cpython-37.pyc b/data/CLs/finished/f1d1/-+/D-True/2288025/__pycache__/pdg_const1.cpython-37.pyc new file mode 100644 index 0000000..516800c --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288025/__pycache__/pdg_const1.cpython-37.pyc Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288025/data/CLs/0.0001-0.003_20s--CLs_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288025/data/CLs/0.0001-0.003_20s--CLs_list.pkl new file mode 100644 index 0000000..e93996c --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288025/data/CLs/0.0001-0.003_20s--CLs_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288025/data/CLs/0.0001-0.003_20s1b1t--CLs_Nll_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288025/data/CLs/0.0001-0.003_20s1b1t--CLs_Nll_list.pkl new file mode 100644 index 0000000..8cce50c --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288025/data/CLs/0.0001-0.003_20s1b1t--CLs_Nll_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288025/data/CLs/0.0001-0.003_20s1b1t--Ctt_error_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288025/data/CLs/0.0001-0.003_20s1b1t--Ctt_error_list.pkl new file mode 100644 index 0000000..b5debeb --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288025/data/CLs/0.0001-0.003_20s1b1t--Ctt_error_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288025/data/CLs/0.0001-0.003_20s1b1t--Ctt_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288025/data/CLs/0.0001-0.003_20s1b1t--Ctt_list.pkl new file mode 100644 index 0000000..5222e0e --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288025/data/CLs/0.0001-0.003_20s1b1t--Ctt_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288025/data/CLs/0.0001-0.003_20s1b1t--pull_dic.pkl b/data/CLs/finished/f1d1/-+/D-True/2288025/data/CLs/0.0001-0.003_20s1b1t--pull_dic.pkl new file mode 100644 index 0000000..b8197f5 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288025/data/CLs/0.0001-0.003_20s1b1t--pull_dic.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288025/data/CLs/variab.pkl b/data/CLs/finished/f1d1/-+/D-True/2288025/data/CLs/variab.pkl new file mode 100644 index 0000000..bb90dc0 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288025/data/CLs/variab.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288025/helperfunctions.py b/data/CLs/finished/f1d1/-+/D-True/2288025/helperfunctions.py new file mode 100644 index 0000000..88e120f --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288025/helperfunctions.py @@ -0,0 +1,33 @@ +# some helperfunctions + +import matplotlib +matplotlib.use("agg") +import matplotlib.pyplot as plt + +#Dislpay time (e.g. while generating points) + +display_intervals = ( + ('w', 604800), # 60 * 60 * 24 * 7 + ('d', 86400), # 60 * 60 * 24 + ('h', 3600), # 60 * 60 + ('min', 60), + ('s', 1), + ) + +def display_time(seconds, granularity=2): + result = [] + + for name, count in display_intervals: + value = seconds // count + if value: + seconds -= value * count + if value == 1: + name = name.rstrip('s') + result.append("{} {}".format(value, name)) + return ', '.join(result[:granularity]) + +def prepare_plot(title): + plt.title(title) + plt.grid() + plt.legend(loc = 'best') + plt.xlabel("q") diff --git a/data/CLs/finished/f1d1/-+/D-True/2288025/pdg_const1.py b/data/CLs/finished/f1d1/-+/D-True/2288025/pdg_const1.py new file mode 100644 index 0000000..70b3f30 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288025/pdg_const1.py @@ -0,0 +1,226 @@ +pdg = { + + + ###Particle masses### + + "mbstar" : 5415.4, + "mbstar0" : 5711.0, + "B0_M" : 5279.5, + "Bs_M" : 5366.7, + "Bplus_M" : 5279.3, + "Lb_M" : 5619.4, + "D0_M" : 1864.8, + "Dst_M" : 2010, + "pi_M" : 139.6, + "Jpsi_M" : 3096.9, + "Psi2s_M" : 3685.6, + "kaon_M" : 493.7, + "Ks_M" : 497.6, + "phi_M" : 1019.5, + "rho_M" : 775.26, + "rho_width" : 149.1, + "omega_M" : 782.65, + "omega_width" : 8.49, + + "muon_M" : 105.7, + "tau_M": 1776.86, + + "squark_M" : 95.0, + "bquark_M" : 4180.0, + "cquark_M" : 1275.0, + + "Bplus_tau" : 1.638e-12, + + ###Wilson coefficients### + + "C1" : -0.257, + "C2" : 1.009, + "C3" : -0.005, + "C4" : -0.078, + + "C7eff" : -0.306, + "C9eff" : 4.211, + "C10eff" : -4.103, + +# "C7eff": 0.0, +# "C9eff": 0.0, +# "C10eff": 0.0, + + ###Other constants + + "GF" : 1.1663787e-5, + "alpha_ew" : 1.0/137.0, + "Vts" : 0.0394, + "Vtb" : 1.019, + "number_of_decays": 5404696, + + #Formfactor z coefficients + + #"b0" : [0.285, 0.19, -0.17], + #"bplus" : [0.437, -1.41, -2.5], + #"bT" : [0.440, -1.47, -2.7] + + "b0" : [0.292, 0.281, 0.150], + "bplus" : [0.466, -0.885, -0.213], + "bT" : [0.460, -1.089, -1.114], + + "NR_BR": 4.37e-7, + "NR_auc": 0.00133, + + #Resonances format(mass, width, phase, scale) + + # pre scaling + +# "rho": (775.26, 149.0, -0.35, 1.0), + +# "omega": (782.7, 8.5, 0.26, 1.0), + +# "phi": (1019.46, 4.25, 0.5, 1.0), + +# "jpsi": (3096.0, 0.09, -1.5, 2e-2), +# "jpsi_auc": 0.2126825758464027, + +# "psi2s": (3686.0, 0.3, -1.5, 3.14e-3), +# "psi2s_auc": 2.802257483178487e-10, + +# "p3770": (3773.0, 27.2, -2.13, 1.0e-3), + +# "p4040": (4039.0, 80.0, -2.52, 2.0), + +# "p4160": (4191.0, 70.0, -1.9, 2.2), + +# "p4415": (4421.0, 62.0, -2.52, 1.0), + + + # after scaling (Phase combination --) + + # + # "rho": (743.2, 149.0, -0.22, 1.05), + # + # "omega": (782.7, 8.5, 0.38, 6.8), + # + # "phi": (1013.5, 4.25, 0.62, 19.2), + # + # "jpsi": (3096.1, 0.09, 1.63, 9897.0), + # "jpsi_auc": 0.2126825758464027, + # "jpsi_phase_unc": 0.05, + # + # "psi2s": (3686.0, 0.3, 1.8, 1396.0), + # "psi2s_auc": 0.0151332263, + # "psi2s_phase_unc": 0.1, + # + # "p3770": (3773.0, 27.2, -2.95, 2.5), + # + # "p4040": (4039.0, 80.0, -2.75, 1.01), + # + # "p4160": (4191.0, 70.0, -2.28, 2.2), + # + # "p4415": (4421.0, 62.0, -2.31, 1.24), + + # Phase combination of paper ++ + +# "rho": (743.2, 149.0, -0.35, 1.05), + +# "omega": (782.7, 8.5, 0.26, 6.8), + +# "phi": (1013.5, 4.25, 0.47, 19.2), + +# "jpsi": (3096.1, 0.09, -1.66, 9897.0), +# "jpsi_auc": 0.2126825758464027, +# "jpsi_phase_unc": 0.05, + +# "psi2s": (3686.0, 0.3, -1.93, 1396.0), +# "psi2s_auc": 0.0151332263, +# "psi2s_phase_unc": 0.1, + +# "p3770": (3773.0, 27.2, -2.13, 2.5), + +# "p4040": (4039.0, 80.0, -2.52, 1.01), + +# "p4160": (4191.0, 70.0, -1.90, 2.2), + +# "p4415": (4421.0, 62.0, -2.52, 1.24), + + # Phase combination of paper +- + +# "rho": (743.2, 149.0, -0.26, 1.05), + +# "omega": (782.7, 8.5, 0.35, 6.8), + +# "phi": (1013.5, 4.25, 0.58, 19.2), + +# "jpsi": (3096.1, 0.09, 1.47, 9897.0), +# "jpsi_auc": 0.2126825758464027, +# "jpsi_phase_unc": 0.05, + +# "psi2s": (3686.0, 0.3, -2.21, 1396.0), +# "psi2s_auc": 0.0151332263, +# "psi2s_phase_unc": 0.1, + +# "p3770": (3773.0, 27.2, -2.140, 2.5), + +# "p4040": (4039.0, 80.0, -2.64, 1.01), + +# "p4160": (4191.0, 70.0, -2.11, 2.2), + +# "p4415": (4421.0, 62.0, -2.42, 1.24), + + # Phase combination of paper -+ + + "rho": (743.2, 149.0, -0.30, 1.05), + + "omega": (782.7, 8.5, 0.30, 6.8), + + "phi": (1013.5, 4.25, 0.51, 19.2), + + "jpsi": (3096.1, 0.09, -1.5, 9897.0), + "jpsi_auc": 0.2126825758464027, + "jpsi_phase_unc": 0.05, + + "psi2s": (3686.0, 0.3, 2.08, 1396.0), + "psi2s_auc": 0.0151332263, + "psi2s_phase_unc": 0.1, + + "p3770": (3773.0, 27.2, -2.89, 2.5), + + "p4040": (4039.0, 80.0, -2.69, 1.01), + + "p4160": (4191.0, 70.0, -2.13, 2.2), + + "p4415": (4421.0, 62.0, -2.43, 1.24), + + + # zeroing resonances + +# "rho": (775.26, 149.0, -0.35, 0.0), +# "omega": (782.7, 8.5, 0.26, 0.0), +# "phi": (1019.46, 4.25, 0.5, 0.0), +# "jpsi": (3096.0, 0.09, -1.5, 0.0), +# "psi2s": (3686.0, 0.3, -1.5, 0.0), +# "p3770": (3773.0, 27.2, -2.13, 0.0), +# "p4040": (4039.0, 80.0, -2.52, 0.0), +# "p4160": (4147.0, 22.0, -1.9, 0.0), +# "p4415": (4421.0, 62.0, -2.52, 0.0), + + # 2P contributions format(mass, amp, phase) + +# "D_bar": ( + + #general + + "rho_BR": 1.7e-10, + "omega_BR": 4.9e-10, + "phi_BR": 2.5e-9, + "jpsi_BR": 6.02e-5, + "psi2s_BR": 4.97e-6, + "p3770_BR": 1.38e-9, + "p4040_BR": 4.2e-10, + "p4160_BR": 2.6e-9, + "p4415_BR": 6.1e-10, + +# Estimates + "Dbar_scale": 1.46, #with phase = pi + + "DDstar_scale": 2.41, #with phase = pi + + } diff --git a/data/CLs/finished/f1d1/-+/D-True/2288025/raremodel-nb.py b/data/CLs/finished/f1d1/-+/D-True/2288025/raremodel-nb.py new file mode 100644 index 0000000..c326c9c --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288025/raremodel-nb.py @@ -0,0 +1,2152 @@ +#!/usr/bin/env python +# coding: utf-8 + +# # Import + +# In[ ]: + + +import os + +# os.environ["CUDA_VISIBLE_DEVICES"] = "-1" +import random +import numpy as np +from pdg_const1 import pdg +import matplotlib +import matplotlib.pyplot as plt +import pickle as pkl +import sys +import time +from helperfunctions import display_time, prepare_plot +import cmath as c +import scipy.integrate as integrate +from scipy.optimize import fminbound +from array import array as arr +import collections +from itertools import compress +import tensorflow as tf +import zfit +from zfit import ztf +# from IPython.display import clear_output +import os +import tensorflow_probability as tfp +tfd = tfp.distributions + + +# In[ ]: + + +# chunksize = 10000 +# zfit.run.chunking.active = True +# zfit.run.chunking.max_n_points = chunksize + + +# # Build model and graphs +# ## Create graphs + +# In[ ]: + + + + + +# In[ ]: + + +def formfactor(q2, subscript, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2): #returns real value + #check if subscript is viable + + if subscript != "0" and subscript != "+" and subscript != "T": + raise ValueError('Wrong subscript entered, choose either 0, + or T') + + #get constants + + mK = ztf.constant(pdg['Ks_M']) + mbstar0 = ztf.constant(pdg["mbstar0"]) + mbstar = ztf.constant(pdg["mbstar"]) + + + mmu = ztf.constant(pdg['muon_M']) + mb = ztf.constant(pdg['bquark_M']) + ms = ztf.constant(pdg['squark_M']) + mB = ztf.constant(pdg['Bplus_M']) + + #N comes from derivation in paper + + N = 3 + + #some helperfunctions + + tpos = (mB - mK)**2 + tzero = (mB + mK)*(ztf.sqrt(mB)-ztf.sqrt(mK))**2 + + z_oben = ztf.sqrt(tpos - q2) - ztf.sqrt(tpos - tzero) + z_unten = ztf.sqrt(tpos - q2) + ztf.sqrt(tpos - tzero) + z = tf.divide(z_oben, z_unten) + + #calculate f0 + + if subscript == "0": + prefactor = 1/(1 - q2/(mbstar0**2)) + _sum = 0 + b0 = [b0_0, b0_1, b0_2] + + for i in range(N): + _sum += b0[i]*(tf.pow(z,i)) + + return ztf.to_complex(prefactor * _sum) + + #calculate f+ or fT + + else: + prefactor = 1/(1 - q2/(mbstar**2)) + _sum = 0 + + if subscript == "T": + bT = [bT_0, bT_1, bT_2] + for i in range(N): + _sum += bT[i] * (tf.pow(z, i) - ((-1)**(i-N)) * (i/N) * tf.pow(z, N)) + else: + bplus = [bplus_0, bplus_1, bplus_2] + for i in range(N): + _sum += bplus[i] * (tf.pow(z, i) - ((-1)**(i-N)) * (i/N) * tf.pow(z, N)) + + return ztf.to_complex(prefactor * _sum) + +def resonance(q, _mass, width, phase, scale): + + q2 = tf.pow(q, 2) + + mmu = ztf.constant(pdg['muon_M']) + + p = 0.5 * ztf.sqrt(q2 - 4*(mmu**2)) + + p0 = 0.5 * ztf.sqrt(_mass**2 - 4*mmu**2) + + gamma_j = tf.divide(p, q) * _mass * width / p0 + + #Calculate the resonance + + _top = tf.complex(_mass * width, ztf.constant(0.0)) + + _bottom = tf.complex(_mass**2 - q2, -_mass*gamma_j) + + com = _top/_bottom + + #Rotate by the phase + + r = ztf.to_complex(scale*tf.abs(com)) + + _phase = tf.angle(com) + + _phase += phase + + com = r * tf.exp(tf.complex(ztf.constant(0.0), _phase)) + + return com + + +def axiv_nonres(q, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2): + + GF = ztf.constant(pdg['GF']) + alpha_ew = ztf.constant(pdg['alpha_ew']) + Vtb = ztf.constant(pdg['Vtb']) + Vts = ztf.constant(pdg['Vts']) + C10eff = ztf.constant(pdg['C10eff']) + + mmu = ztf.constant(pdg['muon_M']) + mb = ztf.constant(pdg['bquark_M']) + ms = ztf.constant(pdg['squark_M']) + mK = ztf.constant(pdg['Ks_M']) + mB = ztf.constant(pdg['Bplus_M']) + + q2 = tf.pow(q, 2) + + #Some helperfunctions + + beta = 1. - 4. * mmu**2. / q2 + + kabs = ztf.sqrt(mB**2. + tf.pow(q2, 2)/mB**2. + mK**4./mB**2. - 2. * (mB**2. * mK**2. + mK**2. * q2 + mB**2. * q2) / mB**2.) + + #prefactor in front of whole bracket + + prefactor1 = GF**2. *alpha_ew**2. * (tf.abs(Vtb*Vts))**2. * kabs * beta / (128. * np.pi**5.) + + #left term in bracket + + bracket_left = 2./3. * tf.pow(kabs,2) * tf.pow(beta,2) * tf.pow(tf.abs(ztf.to_complex(C10eff)*formfactor(q2, "+", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2)),2) + + #middle term in bracket + + _top = 4. * mmu**2. * (mB**2. - mK**2.) * (mB**2. - mK**2.) + + _under = q2 * mB**2. + + bracket_middle = _top/_under *tf.pow(tf.abs(ztf.to_complex(C10eff) * formfactor(q2, "0", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2)), 2) + + #Note sqrt(q2) comes from derivation as we use q2 and plot q + + return prefactor1 * (bracket_left + bracket_middle) * 2 * q + +def vec(q, funcs, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2): + + q2 = tf.pow(q, 2) + + GF = ztf.constant(pdg['GF']) + alpha_ew = ztf.constant(pdg['alpha_ew']) + Vtb = ztf.constant(pdg['Vtb']) + Vts = ztf.constant(pdg['Vts']) + C7eff = ztf.constant(pdg['C7eff']) + + mmu = ztf.constant(pdg['muon_M']) + mb = ztf.constant(pdg['bquark_M']) + ms = ztf.constant(pdg['squark_M']) + mK = ztf.constant(pdg['Ks_M']) + mB = ztf.constant(pdg['Bplus_M']) + + #Some helperfunctions + + beta = 1. - 4. * mmu**2. / q2 + + kabs = ztf.sqrt(mB**2. + tf.pow(q2, 2)/mB**2. + mK**4./mB**2. - 2 * (mB**2 * mK**2 + mK**2 * q2 + mB**2 * q2) / mB**2) + + #prefactor in front of whole bracket + + prefactor1 = GF**2. *alpha_ew**2. * (tf.abs(Vtb*Vts))**2 * kabs * beta / (128. * np.pi**5.) + + #right term in bracket + + prefactor2 = tf.pow(kabs,2) * (1. - 1./3. * beta) + + abs_bracket = tf.pow(tf.abs(c9eff(q, funcs) * formfactor(q2, "+", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + ztf.to_complex(2.0 * C7eff * (mb + ms)/(mB + mK)) * formfactor(q2, "T", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2)),2) + + bracket_right = prefactor2 * abs_bracket + + #Note sqrt(q2) comes from derivation as we use q2 and plot q + + return prefactor1 * bracket_right * 2 * q + +def c9eff(q, funcs): + + C9eff_nr = ztf.to_complex(ztf.constant(pdg['C9eff'])) + + c9 = C9eff_nr + funcs + + return c9 + + +# In[ ]: + + +def G(y): + + def inner_rect_bracket(q): + return tf.log(ztf.to_complex((1+tf.sqrt(q))/(1-tf.sqrt(q)))-tf.complex(ztf.constant(0), -1*ztf.constant(np.pi))) + + def inner_right(q): + return ztf.to_complex(2 * tf.atan(1/tf.sqrt(tf.math.real(-q)))) + + big_bracket = tf.where(tf.math.real(y) > ztf.constant(0.0), inner_rect_bracket(y), inner_right(y)) + + return ztf.to_complex(tf.sqrt(tf.abs(y))) * big_bracket + +def h_S(m, q): + + return ztf.to_complex(2) - G(ztf.to_complex(1) - ztf.to_complex(4*tf.pow(m, 2)) / ztf.to_complex(tf.pow(q, 2))) + +def h_P(m, q): + + return ztf.to_complex(2/3) + (ztf.to_complex(1) - ztf.to_complex(4*tf.pow(m, 2)) / ztf.to_complex(tf.pow(q, 2))) * h_S(m,q) + +def two_p_ccbar(mD, m_D_bar, m_D_star, q): + + + #Load constants + nu_D_bar = ztf.to_complex(pdg["nu_D_bar"]) + nu_D = ztf.to_complex(pdg["nu_D"]) + nu_D_star = ztf.to_complex(pdg["nu_D_star"]) + + phase_D_bar = ztf.to_complex(pdg["phase_D_bar"]) + phase_D = ztf.to_complex(pdg["phase_D"]) + phase_D_star = ztf.to_complex(pdg["phase_D_star"]) + + #Calculation + left_part = nu_D_bar * tf.exp(tf.complex(ztf.constant(0.0), phase_D_bar)) * h_S(m_D_bar, q) + + right_part_D = nu_D * tf.exp(tf.complex(ztf.constant(0.0), phase_D)) * h_P(m_D, q) + + right_part_D_star = nu_D_star * tf.exp(tf.complex(ztf.constant(0.0), phase_D_star)) * h_P(m_D_star, q) + + return left_part + right_part_D + right_part_D_star + + +# ## Build pdf + +# In[ ]: + + +class total_pdf_cut(zfit.pdf.ZPDF): + _N_OBS = 1 # dimension, can be omitted + _PARAMS = ['b0_0', 'b0_1', 'b0_2', + 'bplus_0', 'bplus_1', 'bplus_2', + 'bT_0', 'bT_1', 'bT_2', + 'rho_mass', 'rho_scale', 'rho_phase', 'rho_width', + 'jpsi_mass', 'jpsi_scale', 'jpsi_phase', 'jpsi_width', + 'psi2s_mass', 'psi2s_scale', 'psi2s_phase', 'psi2s_width', + 'p3770_mass', 'p3770_scale', 'p3770_phase', 'p3770_width', + 'p4040_mass', 'p4040_scale', 'p4040_phase', 'p4040_width', + 'p4160_mass', 'p4160_scale', 'p4160_phase', 'p4160_width', + 'p4415_mass', 'p4415_scale', 'p4415_phase', 'p4415_width', + 'omega_mass', 'omega_scale', 'omega_phase', 'omega_width', + 'phi_mass', 'phi_scale', 'phi_phase', 'phi_width', + 'Dbar_mass', 'Dbar_scale', 'Dbar_phase', + 'Dstar_mass', 'DDstar_scale', 'DDstar_phase', 'D_mass', + 'tau_mass', 'C_tt'] +# the name of the parameters + + def _unnormalized_pdf(self, x): + + x = x.unstack_x() + + b0 = [self.params['b0_0'], self.params['b0_1'], self.params['b0_2']] + bplus = [self.params['bplus_0'], self.params['bplus_1'], self.params['bplus_2']] + bT = [self.params['bT_0'], self.params['bT_1'], self.params['bT_2']] + + def rho_res(q): + return resonance(q, _mass = self.params['rho_mass'], scale = self.params['rho_scale'], + phase = self.params['rho_phase'], width = self.params['rho_width']) + + def omega_res(q): + return resonance(q, _mass = self.params['omega_mass'], scale = self.params['omega_scale'], + phase = self.params['omega_phase'], width = self.params['omega_width']) + + def phi_res(q): + return resonance(q, _mass = self.params['phi_mass'], scale = self.params['phi_scale'], + phase = self.params['phi_phase'], width = self.params['phi_width']) + + def jpsi_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['jpsi_mass'], 2)) * resonance(q, _mass = self.params['jpsi_mass'], + scale = self.params['jpsi_scale'], + phase = self.params['jpsi_phase'], + width = self.params['jpsi_width']) + def psi2s_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['psi2s_mass'], 2)) * resonance(q, _mass = self.params['psi2s_mass'], + scale = self.params['psi2s_scale'], + phase = self.params['psi2s_phase'], + width = self.params['psi2s_width']) + def p3770_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p3770_mass'], 2)) * resonance(q, _mass = self.params['p3770_mass'], + scale = self.params['p3770_scale'], + phase = self.params['p3770_phase'], + width = self.params['p3770_width']) + + def p4040_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4040_mass'], 2)) * resonance(q, _mass = self.params['p4040_mass'], + scale = self.params['p4040_scale'], + phase = self.params['p4040_phase'], + width = self.params['p4040_width']) + + def p4160_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4160_mass'], 2)) * resonance(q, _mass = self.params['p4160_mass'], + scale = self.params['p4160_scale'], + phase = self.params['p4160_phase'], + width = self.params['p4160_width']) + + def p4415_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4415_mass'], 2)) * resonance(q, _mass = self.params['p4415_mass'], + scale = self.params['p4415_scale'], + phase = self.params['p4415_phase'], + width = self.params['p4415_width']) + + def P2_D(q): + Dbar_contrib = ztf.to_complex(self.params['Dbar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['Dbar_phase']))*ztf.to_complex(h_S(self.params['Dbar_mass'], q)) + DDstar_contrib = ztf.to_complex(self.params['DDstar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['DDstar_phase']))*(ztf.to_complex(h_P(self.params['Dstar_mass'], q)) + ztf.to_complex(h_P(self.params['D_mass'], q))) + return Dbar_contrib + DDstar_contrib + + def ttau_cusp(q): + return ztf.to_complex(self.params['C_tt'])*(ztf.to_complex((h_S(self.params['tau_mass'], q))) - ztf.to_complex(h_P(self.params['tau_mass'], q))) + + + funcs = rho_res(x) + omega_res(x) + phi_res(x) + jpsi_res(x) + psi2s_res(x) + p3770_res(x) + p4040_res(x)+ p4160_res(x) + p4415_res(x) + P2_D(x) + ttau_cusp(x) + + vec_f = vec(x, funcs, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + axiv_nr = axiv_nonres(x, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + tot = vec_f + axiv_nr + + #Cut out jpsi and psi2s + + tot = tf.where(tf.math.logical_or(x < ztf.constant(jpsi_mass-60.), x > ztf.constant(jpsi_mass+70.)), tot, 0.0*tot) + + tot = tf.where(tf.math.logical_or(x < ztf.constant(psi2s_mass-50.), x > ztf.constant(psi2s_mass+50.)), tot, 0.0*tot) + + return tot + +class total_pdf_full(zfit.pdf.ZPDF): + _N_OBS = 1 # dimension, can be omitted + _PARAMS = ['b0_0', 'b0_1', 'b0_2', + 'bplus_0', 'bplus_1', 'bplus_2', + 'bT_0', 'bT_1', 'bT_2', + 'rho_mass', 'rho_scale', 'rho_phase', 'rho_width', + 'jpsi_mass', 'jpsi_scale', 'jpsi_phase', 'jpsi_width', + 'psi2s_mass', 'psi2s_scale', 'psi2s_phase', 'psi2s_width', + 'p3770_mass', 'p3770_scale', 'p3770_phase', 'p3770_width', + 'p4040_mass', 'p4040_scale', 'p4040_phase', 'p4040_width', + 'p4160_mass', 'p4160_scale', 'p4160_phase', 'p4160_width', + 'p4415_mass', 'p4415_scale', 'p4415_phase', 'p4415_width', + 'omega_mass', 'omega_scale', 'omega_phase', 'omega_width', + 'phi_mass', 'phi_scale', 'phi_phase', 'phi_width', + 'Dbar_mass', 'Dbar_scale', 'Dbar_phase', + 'Dstar_mass', 'DDstar_scale', 'DDstar_phase', 'D_mass', + 'tau_mass', 'C_tt'] +# the name of the parameters + + def _unnormalized_pdf(self, x): + + x = x.unstack_x() + + b0 = [self.params['b0_0'], self.params['b0_1'], self.params['b0_2']] + bplus = [self.params['bplus_0'], self.params['bplus_1'], self.params['bplus_2']] + bT = [self.params['bT_0'], self.params['bT_1'], self.params['bT_2']] + + def rho_res(q): + return resonance(q, _mass = self.params['rho_mass'], scale = self.params['rho_scale'], + phase = self.params['rho_phase'], width = self.params['rho_width']) + + def omega_res(q): + return resonance(q, _mass = self.params['omega_mass'], scale = self.params['omega_scale'], + phase = self.params['omega_phase'], width = self.params['omega_width']) + + def phi_res(q): + return resonance(q, _mass = self.params['phi_mass'], scale = self.params['phi_scale'], + phase = self.params['phi_phase'], width = self.params['phi_width']) + + def jpsi_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['jpsi_mass'], 2)) * resonance(q, _mass = self.params['jpsi_mass'], + scale = self.params['jpsi_scale'], + phase = self.params['jpsi_phase'], + width = self.params['jpsi_width']) + def psi2s_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['psi2s_mass'], 2)) * resonance(q, _mass = self.params['psi2s_mass'], + scale = self.params['psi2s_scale'], + phase = self.params['psi2s_phase'], + width = self.params['psi2s_width']) + def p3770_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p3770_mass'], 2)) * resonance(q, _mass = self.params['p3770_mass'], + scale = self.params['p3770_scale'], + phase = self.params['p3770_phase'], + width = self.params['p3770_width']) + + def p4040_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4040_mass'], 2)) * resonance(q, _mass = self.params['p4040_mass'], + scale = self.params['p4040_scale'], + phase = self.params['p4040_phase'], + width = self.params['p4040_width']) + + def p4160_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4160_mass'], 2)) * resonance(q, _mass = self.params['p4160_mass'], + scale = self.params['p4160_scale'], + phase = self.params['p4160_phase'], + width = self.params['p4160_width']) + + def p4415_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4415_mass'], 2)) * resonance(q, _mass = self.params['p4415_mass'], + scale = self.params['p4415_scale'], + phase = self.params['p4415_phase'], + width = self.params['p4415_width']) + + def P2_D(q): + Dbar_contrib = ztf.to_complex(self.params['Dbar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['Dbar_phase']))*ztf.to_complex(h_S(self.params['Dbar_mass'], q)) + DDstar_contrib = ztf.to_complex(self.params['DDstar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['DDstar_phase']))*(ztf.to_complex(h_P(self.params['Dstar_mass'], q)) + ztf.to_complex(h_P(self.params['D_mass'], q))) + return Dbar_contrib + DDstar_contrib + + def ttau_cusp(q): + return ztf.to_complex(self.params['C_tt'])*(ztf.to_complex((h_S(self.params['tau_mass'], q))) - ztf.to_complex(h_P(self.params['tau_mass'], q))) + + + funcs = rho_res(x) + omega_res(x) + phi_res(x) + jpsi_res(x) + psi2s_res(x) + p3770_res(x) + p4040_res(x)+ p4160_res(x) + p4415_res(x) + P2_D(x) + ttau_cusp(x) + + vec_f = vec(x, funcs, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + axiv_nr = axiv_nonres(x, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + tot = vec_f + axiv_nr + + #Cut out jpsi and psi2s + +# tot = tf.where(tf.math.logical_or(x < ztf.constant(jpsi_mass-60.), x > ztf.constant(jpsi_mass+70.)), tot, 0.0*tot) + +# tot = tf.where(tf.math.logical_or(x < ztf.constant(psi2s_mass-50.), x > ztf.constant(psi2s_mass+50.)), tot, 0.0*tot) + + return tot + + +# ## Setup parameters + +# In[ ]: + + +# formfactors + +b0_0 = zfit.Parameter("b0_0", ztf.constant(0.292), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +b0_1 = zfit.Parameter("b0_1", ztf.constant(0.281), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +b0_2 = zfit.Parameter("b0_2", ztf.constant(0.150), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) + +bplus_0 = zfit.Parameter("bplus_0", ztf.constant(0.466), lower_limit = -2.0, upper_limit= 2.0) +bplus_1 = zfit.Parameter("bplus_1", ztf.constant(-0.885), lower_limit = -2.0, upper_limit= 2.0) +bplus_2 = zfit.Parameter("bplus_2", ztf.constant(-0.213), lower_limit = -2.0, upper_limit= 2.0) + +bT_0 = zfit.Parameter("bT_0", ztf.constant(0.460), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +bT_1 = zfit.Parameter("bT_1", ztf.constant(-1.089), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +bT_2 = zfit.Parameter("bT_2", ztf.constant(-1.114), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) + + +#rho + +rho_mass, rho_width, rho_phase, rho_scale = pdg["rho"] + +rho_m = zfit.Parameter("rho_m", ztf.constant(rho_mass), floating = False) #lower_limit = rho_mass - rho_width, upper_limit = rho_mass + rho_width) +rho_w = zfit.Parameter("rho_w", ztf.constant(rho_width), floating = False) +rho_p = zfit.Parameter("rho_p", ztf.constant(rho_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +rho_s = zfit.Parameter("rho_s", ztf.constant(rho_scale), lower_limit=rho_scale-np.sqrt(rho_scale), upper_limit=rho_scale+np.sqrt(rho_scale)) + +#omega + +omega_mass, omega_width, omega_phase, omega_scale = pdg["omega"] + +omega_m = zfit.Parameter("omega_m", ztf.constant(omega_mass), floating = False) +omega_w = zfit.Parameter("omega_w", ztf.constant(omega_width), floating = False) +omega_p = zfit.Parameter("omega_p", ztf.constant(omega_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +omega_s = zfit.Parameter("omega_s", ztf.constant(omega_scale), lower_limit=omega_scale-np.sqrt(omega_scale), upper_limit=omega_scale+np.sqrt(omega_scale)) + + +#phi + +phi_mass, phi_width, phi_phase, phi_scale = pdg["phi"] + +phi_m = zfit.Parameter("phi_m", ztf.constant(phi_mass), floating = False) +phi_w = zfit.Parameter("phi_w", ztf.constant(phi_width), floating = False) +phi_p = zfit.Parameter("phi_p", ztf.constant(phi_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +phi_s = zfit.Parameter("phi_s", ztf.constant(phi_scale), lower_limit=phi_scale-np.sqrt(phi_scale), upper_limit=phi_scale+np.sqrt(phi_scale)) + +#jpsi + +jpsi_mass, jpsi_width, jpsi_phase, jpsi_scale = pdg["jpsi"] + +jpsi_m = zfit.Parameter("jpsi_m", ztf.constant(jpsi_mass), floating = False) +jpsi_w = zfit.Parameter("jpsi_w", ztf.constant(jpsi_width), floating = False) +jpsi_p = zfit.Parameter("jpsi_p", ztf.constant(jpsi_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +jpsi_s = zfit.Parameter("jpsi_s", ztf.constant(jpsi_scale), floating = False) #, lower_limit=jpsi_scale-np.sqrt(jpsi_scale), upper_limit=jpsi_scale+np.sqrt(jpsi_scale)) + +#psi2s + +psi2s_mass, psi2s_width, psi2s_phase, psi2s_scale = pdg["psi2s"] + +psi2s_m = zfit.Parameter("psi2s_m", ztf.constant(psi2s_mass), floating = False) +psi2s_w = zfit.Parameter("psi2s_w", ztf.constant(psi2s_width), floating = False) +psi2s_p = zfit.Parameter("psi2s_p", ztf.constant(psi2s_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +psi2s_s = zfit.Parameter("psi2s_s", ztf.constant(psi2s_scale), floating = False) #, lower_limit=psi2s_scale-np.sqrt(psi2s_scale), upper_limit=psi2s_scale+np.sqrt(psi2s_scale)) + +#psi(3770) + +p3770_mass, p3770_width, p3770_phase, p3770_scale = pdg["p3770"] + +p3770_m = zfit.Parameter("p3770_m", ztf.constant(p3770_mass), floating = False) +p3770_w = zfit.Parameter("p3770_w", ztf.constant(p3770_width), floating = False) +p3770_p = zfit.Parameter("p3770_p", ztf.constant(p3770_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p3770_s = zfit.Parameter("p3770_s", ztf.constant(p3770_scale), lower_limit=p3770_scale-np.sqrt(p3770_scale), upper_limit=p3770_scale+np.sqrt(p3770_scale)) + +#psi(4040) + +p4040_mass, p4040_width, p4040_phase, p4040_scale = pdg["p4040"] + +p4040_m = zfit.Parameter("p4040_m", ztf.constant(p4040_mass), floating = False) +p4040_w = zfit.Parameter("p4040_w", ztf.constant(p4040_width), floating = False) +p4040_p = zfit.Parameter("p4040_p", ztf.constant(p4040_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p4040_s = zfit.Parameter("p4040_s", ztf.constant(p4040_scale), lower_limit=p4040_scale-np.sqrt(p4040_scale), upper_limit=p4040_scale+np.sqrt(p4040_scale)) + +#psi(4160) + +p4160_mass, p4160_width, p4160_phase, p4160_scale = pdg["p4160"] + +p4160_m = zfit.Parameter("p4160_m", ztf.constant(p4160_mass), floating = False) +p4160_w = zfit.Parameter("p4160_w", ztf.constant(p4160_width), floating = False) +p4160_p = zfit.Parameter("p4160_p", ztf.constant(p4160_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p4160_s = zfit.Parameter("p4160_s", ztf.constant(p4160_scale), lower_limit=p4160_scale-np.sqrt(p4160_scale), upper_limit=p4160_scale+np.sqrt(p4160_scale)) + +#psi(4415) + +p4415_mass, p4415_width, p4415_phase, p4415_scale = pdg["p4415"] + +p4415_m = zfit.Parameter("p4415_m", ztf.constant(p4415_mass), floating = False) +p4415_w = zfit.Parameter("p4415_w", ztf.constant(p4415_width), floating = False) +p4415_p = zfit.Parameter("p4415_p", ztf.constant(p4415_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p4415_s = zfit.Parameter("p4415_s", ztf.constant(p4415_scale), lower_limit=p4415_scale-np.sqrt(p4415_scale), upper_limit=p4415_scale+np.sqrt(p4415_scale)) + + +# ## Dynamic generation of 2 particle contribution + +# In[ ]: + + +m_c = 1300 + +Dbar_phase = 0.0 +DDstar_phase = 0.0 +Dstar_mass = pdg['Dst_M'] +Dbar_mass = pdg['D0_M'] +D_mass = pdg['D0_M'] + +Dbar_s = zfit.Parameter("Dbar_s", ztf.constant(0.0), lower_limit=-0.3, upper_limit=0.3) +Dbar_m = zfit.Parameter("Dbar_m", ztf.constant(Dbar_mass), floating = False) +Dbar_p = zfit.Parameter("Dbar_p", ztf.constant(Dbar_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi)#, floating = False) +DDstar_s = zfit.Parameter("DDstar_s", ztf.constant(0.0), lower_limit=-0.3, upper_limit=0.3)#, floating = False) +Dstar_m = zfit.Parameter("Dstar_m", ztf.constant(Dstar_mass), floating = False) +D_m = zfit.Parameter("D_m", ztf.constant(D_mass), floating = False) +DDstar_p = zfit.Parameter("DDstar_p", ztf.constant(DDstar_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi)#, floating = False) + + +# ## Tau parameters + +# In[ ]: + + +tau_m = zfit.Parameter("tau_m", ztf.constant(pdg['tau_M']), floating = False) +Ctt = zfit.Parameter("Ctt", ztf.constant(0.0), lower_limit=-2.5, upper_limit=2.5) + + +# ## Load data + +# In[ ]: + + +x_min = 2*pdg['muon_M'] +x_max = (pdg["Bplus_M"]-pdg["Ks_M"]-0.1) + +# # Full spectrum + +obs_toy = zfit.Space('q', limits = (x_min, x_max)) + +# Jpsi and Psi2s cut out + +obs1 = zfit.Space('q', limits = (x_min, jpsi_mass - 60.)) +obs2 = zfit.Space('q', limits = (jpsi_mass + 70., psi2s_mass - 50.)) +obs3 = zfit.Space('q', limits = (psi2s_mass + 50., x_max)) + +obs_fit = obs1 + obs2 + obs3 + +# with open(r"./data/slim_points/slim_points_toy_0_range({0}-{1}).pkl".format(int(x_min), int(x_max)), "rb") as input_file: +# part_set = pkl.load(input_file) + +# x_part = part_set['x_part'] + +# x_part = x_part.astype('float64') + +# data = zfit.data.Data.from_numpy(array=x_part, obs=obs) + + +# ## Setup pdf + +# In[ ]: + + +total_f = total_pdf_cut(obs=obs_toy, jpsi_mass = jpsi_m, jpsi_scale = jpsi_s, jpsi_phase = jpsi_p, jpsi_width = jpsi_w, + psi2s_mass = psi2s_m, psi2s_scale = psi2s_s, psi2s_phase = psi2s_p, psi2s_width = psi2s_w, + p3770_mass = p3770_m, p3770_scale = p3770_s, p3770_phase = p3770_p, p3770_width = p3770_w, + p4040_mass = p4040_m, p4040_scale = p4040_s, p4040_phase = p4040_p, p4040_width = p4040_w, + p4160_mass = p4160_m, p4160_scale = p4160_s, p4160_phase = p4160_p, p4160_width = p4160_w, + p4415_mass = p4415_m, p4415_scale = p4415_s, p4415_phase = p4415_p, p4415_width = p4415_w, + rho_mass = rho_m, rho_scale = rho_s, rho_phase = rho_p, rho_width = rho_w, + omega_mass = omega_m, omega_scale = omega_s, omega_phase = omega_p, omega_width = omega_w, + phi_mass = phi_m, phi_scale = phi_s, phi_phase = phi_p, phi_width = phi_w, + Dstar_mass = Dstar_m, DDstar_scale = DDstar_s, DDstar_phase = DDstar_p, D_mass = D_m, + Dbar_mass = Dbar_m, Dbar_scale = Dbar_s, Dbar_phase = Dbar_p, + tau_mass = tau_m, C_tt = Ctt, b0_0 = b0_0, b0_1 = b0_1, b0_2 = b0_2, + bplus_0 = bplus_0, bplus_1 = bplus_1, bplus_2 = bplus_2, + bT_0 = bT_0, bT_1 = bT_1, bT_2 = bT_2) + +total_f_fit = total_pdf_full(obs=obs_fit, jpsi_mass = jpsi_m, jpsi_scale = jpsi_s, jpsi_phase = jpsi_p, jpsi_width = jpsi_w, + psi2s_mass = psi2s_m, psi2s_scale = psi2s_s, psi2s_phase = psi2s_p, psi2s_width = psi2s_w, + p3770_mass = p3770_m, p3770_scale = p3770_s, p3770_phase = p3770_p, p3770_width = p3770_w, + p4040_mass = p4040_m, p4040_scale = p4040_s, p4040_phase = p4040_p, p4040_width = p4040_w, + p4160_mass = p4160_m, p4160_scale = p4160_s, p4160_phase = p4160_p, p4160_width = p4160_w, + p4415_mass = p4415_m, p4415_scale = p4415_s, p4415_phase = p4415_p, p4415_width = p4415_w, + rho_mass = rho_m, rho_scale = rho_s, rho_phase = rho_p, rho_width = rho_w, + omega_mass = omega_m, omega_scale = omega_s, omega_phase = omega_p, omega_width = omega_w, + phi_mass = phi_m, phi_scale = phi_s, phi_phase = phi_p, phi_width = phi_w, + Dstar_mass = Dstar_m, DDstar_scale = DDstar_s, DDstar_phase = DDstar_p, D_mass = D_m, + Dbar_mass = Dbar_m, Dbar_scale = Dbar_s, Dbar_phase = Dbar_p, + tau_mass = tau_m, C_tt = Ctt, b0_0 = b0_0, b0_1 = b0_1, b0_2 = b0_2, + bplus_0 = bplus_0, bplus_1 = bplus_1, bplus_2 = bplus_2, + bT_0 = bT_0, bT_1 = bT_1, bT_2 = bT_2) + +# print(total_pdf.obs) + +# print(calcs_test) + +# for param in total_f.get_dependents(): +# print(zfit.run(param)) + + +# In[ ]: + + +# total_f_fit.normalization(obs_fit) + + +# ## Test if graphs actually work and compute values + +# In[ ]: + + +# def total_test_tf(xq): + +# def jpsi_res(q): +# return resonance(q, jpsi_m, jpsi_s, jpsi_p, jpsi_w) + +# def psi2s_res(q): +# return resonance(q, psi2s_m, psi2s_s, psi2s_p, psi2s_w) + +# def cusp(q): +# return bifur_gauss(q, cusp_m, sig_L, sig_R, cusp_s) + +# funcs = jpsi_res(xq) + psi2s_res(xq) + cusp(xq) + +# vec_f = vec(xq, funcs) + +# axiv_nr = axiv_nonres(xq) + +# tot = vec_f + axiv_nr + +# return tot + +# def jpsi_res(q): +# return resonance(q, jpsi_m, jpsi_s, jpsi_p, jpsi_w) + +# calcs = zfit.run(total_test_tf(x_part)) + + + +test_q = np.linspace(x_min, x_max, int(2e6)) + +probs = total_f_fit.pdf(test_q, norm_range=False) + +calcs_test = zfit.run(probs) + +Ctt.set_value(0.5) + +calcs_test1 = zfit.run(probs) + +Ctt.set_value(0.0) + +Dbar_s.set_value(0.3) + +DDstar_s.set_value(0.3) + +calcs_test2 = zfit.run(probs) +# res_y = zfit.run(jpsi_res(test_q)) +# b0 = [b0_0, b0_1, b0_2] +# bplus = [bplus_0, bplus_1, bplus_2] +# bT = [bT_0, bT_1, bT_2] +# f0_y = zfit.run(tf.math.real(formfactor(test_q,"0", b0, bplus, bT))) +# fplus_y = zfit.run(tf.math.real(formfactor(test_q,"+", b0, bplus, bT))) +# fT_y = zfit.run(tf.math.real(formfactor(test_q,"T", b0, bplus, bT))) + + +# In[ ]: + + +plt.clf() +# plt.plot(x_part, calcs, '.') +plt.plot(test_q, calcs_test, label = 'pdf (Ctt = 0.0)') +plt.plot(test_q, calcs_test1, label = 'pdf (Ctt = 0.5)') +plt.plot(test_q, calcs_test2, label = 'pdf (D-contribs = 0.3)') +# plt.plot(test_q, f0_y, label = '0') +# plt.plot(test_q, fT_y, label = 'T') +# plt.plot(test_q, fplus_y, label = '+') +# plt.plot(test_q, res_y, label = 'res') +plt.legend() +plt.ylim(0.0, 1.5e-6) +# plt.yscale('log') +# plt.xlim(770, 785) +plt.savefig('test.png') +# print(jpsi_width) + + +# In[ ]: + + + + +# probs = mixture.prob(test_q) +# probs_np = zfit.run(probs) +# probs_np *= np.max(calcs_test) / np.max(probs_np) +# plt.figure() +# plt.semilogy(test_q, probs_np,label="importance sampling") +# plt.semilogy(test_q, calcs_test, label = 'pdf') + + +# In[ ]: + + +# 0.213/(0.00133+0.213+0.015) + + +# ## Adjust scaling of different parts + +# In[ ]: + + +total_f.update_integration_options(draws_per_dim=2000000, mc_sampler=None) +# inte = total_f.integrate(limits = (950., 1050.), norm_range=False) +# inte_fl = zfit.run(inte) +# print(inte_fl/4500) +# print(pdg["jpsi_BR"]/pdg["NR_BR"], inte_fl*pdg["psi2s_auc"]/pdg["NR_auc"]) + + +# In[ ]: + + +# # print("jpsi:", inte_fl) +# # print("Increase am by factor:", np.sqrt(pdg["jpsi_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) +# # print("New amp:", pdg["jpsi"][3]*np.sqrt(pdg["jpsi_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) + +# # print("psi2s:", inte_fl) +# # print("Increase am by factor:", np.sqrt(pdg["psi2s_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) +# # print("New amp:", pdg["psi2s"][3]*np.sqrt(pdg["psi2s_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) + +# name = "phi" + +# print(name+":", inte_fl) +# print("Increase am by factor:", np.sqrt(pdg[name+"_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) +# print("New amp:", pdg[name][0]*np.sqrt(pdg[name+"_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) + + +# print(x_min) +# print(x_max) +# # total_f.update_integration_options(draws_per_dim=2000000, mc_sampler=None) +# total_f.update_integration_options(mc_sampler=lambda dim, num_results, +# dtype: tf.random_uniform(maxval=1., shape=(num_results, dim), dtype=dtype), +# draws_per_dim=1000000) +# # _ = [] + +# # for i in range(10): + +# # inte = total_f.integrate(limits = (x_min, x_max)) +# # inte_fl = zfit.run(inte) +# # print(inte_fl) +# # _.append(inte_fl) + +# # print("mean:", np.mean(_)) + +# _ = time.time() + +# inte = total_f.integrate(limits = (x_min, x_max)) +# inte_fl = zfit.run(inte) +# print(inte_fl) +# print("Time taken: {}".format(display_time(int(time.time() - _)))) + +# print(pdg['NR_BR']/pdg['NR_auc']*inte_fl) +# print(0.25**2*4.2/1000) + + +# # Sampling +# ## Mixture distribution for sampling + +# In[ ]: + + + + +# print(list_of_borders[:9]) +# print(list_of_borders[-9:]) + + +class UniformSampleAndWeights(zfit.util.execution.SessionHolderMixin): + def __call__(self, limits, dtype, n_to_produce): + # n_to_produce = tf.cast(n_to_produce, dtype=tf.int32) + low, high = limits.limit1d + low = tf.cast(low, dtype=dtype) + high = tf.cast(high, dtype=dtype) +# uniform = tfd.Uniform(low=low, high=high) +# uniformjpsi = tfd.Uniform(low=tf.constant(3080, dtype=dtype), high=tf.constant(3112, dtype=dtype)) +# uniformpsi2s = tfd.Uniform(low=tf.constant(3670, dtype=dtype), high=tf.constant(3702, dtype=dtype)) + +# list_of_borders = [] +# _p = [] +# splits = 10 + +# _ = np.linspace(x_min, x_max, splits) + +# for i in range(splits): +# list_of_borders.append(tf.constant(_[i], dtype=dtype)) +# _p.append(tf.constant(1/splits, dtype=dtype)) + +# mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=_p[:(splits-1)]), +# components_distribution=tfd.Uniform(low=list_of_borders[:(splits-1)], +# high=list_of_borders[-(splits-1):])) + mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=[tf.constant(0.05, dtype=dtype), + tf.constant(0.93, dtype=dtype), + tf.constant(0.05, dtype=dtype), + tf.constant(0.065, dtype=dtype), + tf.constant(0.04, dtype=dtype), + tf.constant(0.05, dtype=dtype)]), + components_distribution=tfd.Uniform(low=[tf.constant(x_min, dtype=dtype), + tf.constant(3090, dtype=dtype), + tf.constant(3681, dtype=dtype), + tf.constant(3070, dtype=dtype), + tf.constant(1000, dtype=dtype), + tf.constant(3660, dtype=dtype)], + high=[tf.constant(x_max, dtype=dtype), + tf.constant(3102, dtype=dtype), + tf.constant(3691, dtype=dtype), + tf.constant(3110, dtype=dtype), + tf.constant(1040, dtype=dtype), + tf.constant(3710, dtype=dtype)])) +# dtype = tf.float64 +# mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=[tf.constant(0.04, dtype=dtype), +# tf.constant(0.90, dtype=dtype), +# tf.constant(0.02, dtype=dtype), +# tf.constant(0.07, dtype=dtype), +# tf.constant(0.02, dtype=dtype)]), +# components_distribution=tfd.Uniform(low=[tf.constant(x_min, dtype=dtype), +# tf.constant(3089, dtype=dtype), +# tf.constant(3103, dtype=dtype), +# tf.constant(3681, dtype=dtype), +# tf.constant(3691, dtype=dtype)], +# high=[tf.constant(3089, dtype=dtype), +# tf.constant(3103, dtype=dtype), +# tf.constant(3681, dtype=dtype), +# tf.constant(3691, dtype=dtype), +# tf.constant(x_max, dtype=dtype)])) +# mixture = tfd.Uniform(tf.constant(x_min, dtype=dtype), tf.constant(x_max, dtype=dtype)) +# sample = tf.random.uniform((n_to_produce, 1), dtype=dtype) + sample = mixture.sample((n_to_produce, 1)) +# sample = tf.random.uniform((n_to_produce, 1), dtype=dtype) + weights = mixture.prob(sample)[:,0] +# weights = tf.broadcast_to(tf.constant(1., dtype=dtype), shape=(n_to_produce,)) + # sample = tf.expand_dims(sample, axis=-1) +# print(sample, weights) + +# weights = tf.ones(shape=(n_to_produce,), dtype=dtype) + weights_max = None + thresholds = tf.random_uniform(shape=(n_to_produce,), dtype=dtype) + return sample, thresholds, weights, weights_max, n_to_produce + + +# In[ ]: + + +# total_f._sample_and_weights = UniformSampleAndWeights + + +# In[ ]: + + +# 0.00133/(0.00133+0.213+0.015)*(x_max-3750)/(x_max-x_min) + + +# In[ ]: + + +# zfit.settings.set_verbosity(10) + + +# In[ ]: + + +# # zfit.run.numeric_checks = False + +# nr_of_toys = 1 +# nevents = int(pdg["number_of_decays"]) +# nevents = pdg["number_of_decays"] +# event_stack = 1000000 +# # zfit.settings.set_verbosity(10) +# calls = int(nevents/event_stack + 1) + +# total_samp = [] + +# start = time.time() + +# sampler = total_f.create_sampler(n=event_stack) + +# for toy in range(nr_of_toys): + +# dirName = 'data/zfit_toys/toy_{0}'.format(toy) + +# if not os.path.exists(dirName): +# os.mkdir(dirName) +# print("Directory " , dirName , " Created ") + +# for call in range(calls): + +# sampler.resample(n=event_stack) +# s = sampler.unstack_x() +# sam = zfit.run(s) +# # clear_output(wait=True) + +# c = call + 1 + +# print("{0}/{1} of Toy {2}/{3}".format(c, calls, toy+1, nr_of_toys)) +# print("Time taken: {}".format(display_time(int(time.time() - start)))) +# print("Projected time left: {}".format(display_time(int((time.time() - start)/(c+calls*(toy))*((nr_of_toys-toy)*calls-c))))) + +# with open("data/zfit_toys/toy_{0}/{1}.pkl".format(toy, call), "wb") as f: +# pkl.dump(sam, f, pkl.HIGHEST_PROTOCOL) + + +# In[ ]: + + +# with open(r"data/zfit_toys/toy_0/0.pkl", "rb") as input_file: +# sam = pkl.load(input_file) +# print(sam[:10]) + +# with open(r"data/zfit_toys/toy_0/1.pkl", "rb") as input_file: +# sam2 = pkl.load(input_file) +# print(sam2[:10]) + +# print(np.sum(sam-sam2)) + + +# In[ ]: + + +# print("Time to generate full toy: {} s".format(int(time.time()-start))) + +# total_samp = [] + +# for call in range(calls): +# with open(r"data/zfit_toys/toy_0/{}.pkl".format(call), "rb") as input_file: +# sam = pkl.load(input_file) +# total_samp = np.append(total_samp, sam) + +# total_samp = total_samp.astype('float64') + +# data2 = zfit.data.Data.from_numpy(array=total_samp[:int(nevents)], obs=obs) + +# data3 = zfit.data.Data.from_numpy(array=total_samp, obs=obs) + +# print(total_samp[:nevents].shape) + + +# In[ ]: + + +# plt.clf() + +# bins = int((x_max-x_min)/7) + +# # calcs = zfit.run(total_test_tf(samp)) +# print(total_samp[:nevents].shape) + +# plt.hist(total_samp[:nevents], bins = bins, range = (x_min,x_max), label = 'data') +# # plt.plot(test_q, calcs_test*nevents , label = 'pdf') + +# # plt.plot(sam, calcs, '.') +# # plt.plot(test_q, calcs_test) +# # plt.yscale('log') +# plt.ylim(0, 200) +# # plt.xlim(3080, 3110) + +# plt.legend() + +# plt.savefig('test2.png') + + +# In[ ]: + + +# sampler = total_f.create_sampler(n=nevents) +# nll = zfit.loss.UnbinnedNLL(model=total_f, data=sampler, fit_range = (x_min, x_max)) + +# # for param in pdf.get_dependents(): +# # param.set_value(initial_value) + +# sampler.resample(n=nevents) + +# # Randomise initial values +# # for param in pdf.get_dependents(): +# # param.set_value(random value here) + +# # Minimise the NLL +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 10) +# minimum = minimizer.minimize(nll) + + +# In[ ]: + + +# jpsi_width + + +# In[ ]: + + +# plt.hist(sample, weights=1 / prob(sample)) + + +# # Fitting + +# In[ ]: + + +# start = time.time() + +# for param in total_f.get_dependents(): +# param.randomize() + +# # for param in total_f.get_dependents(): +# # print(zfit.run(param)) + +# nll = zfit.loss.UnbinnedNLL(model=total_f, data=data2, fit_range = (x_min, x_max)) + +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) +# # minimizer._use_tfgrad = False +# result = minimizer.minimize(nll) + +# # param_errors = result.error() + +# # for var, errors in param_errors.items(): +# # print('{}: ^{{+{}}}_{{{}}}'.format(var.name, errors['upper'], errors['lower'])) + +# print("Function minimum:", result.fmin) +# # print("Results:", result.params) +# print("Hesse errors:", result.hesse()) + + +# In[ ]: + + +# print("Time taken for fitting: {}".format(display_time(int(time.time()-start)))) + +# # probs = total_f.pdf(test_q) + +# calcs_test = zfit.run(probs) +# res_y = zfit.run(jpsi_res(test_q)) + + +# In[ ]: + + +# plt.clf() +# # plt.plot(x_part, calcs, '.') +# plt.plot(test_q, calcs_test, label = 'pdf') +# # plt.plot(test_q, res_y, label = 'res') +# plt.legend() +# plt.ylim(0.0, 10e-6) +# # plt.yscale('log') +# # plt.xlim(3080, 3110) +# plt.savefig('test3.png') +# # print(jpsi_width) + + +# In[ ]: + + +# _tot = 4.37e-7+6.02e-5+4.97e-6 +# _probs = [] +# _probs.append(6.02e-5/_tot) +# _probs.append(4.97e-6/_tot) +# _probs.append(4.37e-7/_tot) +# print(_probs) + + +# In[ ]: + + +# dtype = 'float64' +# # mixture = tfd.Uniform(tf.constant(x_min, dtype=dtype), tf.constant(x_max, dtype=dtype)) +# mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=[tf.constant(0.007, dtype=dtype), +# tf.constant(0.917, dtype=dtype), +# tf.constant(0.076, dtype=dtype)]), +# components_distribution=tfd.Uniform(low=[tf.constant(x_min, dtype=dtype), +# tf.constant(3080, dtype=dtype), +# tf.constant(3670, dtype=dtype)], +# high=[tf.constant(x_max, dtype=dtype), +# tf.constant(3112, dtype=dtype), +# tf.constant(3702, dtype=dtype)])) +# # for i in range(10): +# # print(zfit.run(mixture.prob(mixture.sample((10, 1))))) + + +# In[ ]: + + +# print((zfit.run(jpsi_p)%(2*np.pi))/np.pi) +# print((zfit.run(psi2s_p)%(2*np.pi))/np.pi) + + +# In[ ]: + + +# def jpsi_res(q): +# return resonance(q, _mass = jpsi_mass, scale = jpsi_scale, +# phase = jpsi_phase, width = jpsi_width) + +# def psi2s_res(q): +# return resonance(q, _mass = psi2s_mass, scale = psi2s_scale, +# phase = psi2s_phase, width = psi2s_width) + +# def p3770_res(q): +# return resonance(q, _mass = p3770_mass, scale = p3770_scale, +# phase = p3770_phase, width = p3770_width) + +# def p4040_res(q): +# return resonance(q, _mass = p4040_mass, scale = p4040_scale, +# phase = p4040_phase, width = p4040_width) + +# def p4160_res(q): +# return resonance(q, _mass = p4160_mass, scale = p4160_scale, +# phase = p4160_phase, width = p4160_width) + +# def p4415_res(q): +# return resonance(q, _mass = p4415_mass, scale = p4415_scale, +# phase = p4415_phase, width = p4415_width) + + +# In[ ]: + + +# 0.15**2*4.2/1000 +# result.hesse() + + +# ## Constraints + +# In[ ]: + + +# 1. Constraint - Real part of sum of Psi contrib and D contribs + +sum_list = [] + +sum_list.append(ztf.to_complex(jpsi_s) * tf.exp(tf.complex(ztf.constant(0.0), jpsi_p)) * ztf.to_complex(jpsi_w / (tf.pow(jpsi_m,3)))) +sum_list.append(ztf.to_complex(psi2s_s) * tf.exp(tf.complex(ztf.constant(0.0), psi2s_p)) * ztf.to_complex(psi2s_w / (tf.pow(psi2s_m,3)))) +sum_list.append(ztf.to_complex(p3770_s) * tf.exp(tf.complex(ztf.constant(0.0), p3770_p)) * ztf.to_complex(p3770_w / (tf.pow(p3770_m,3)))) +sum_list.append(ztf.to_complex(p4040_s) * tf.exp(tf.complex(ztf.constant(0.0), p4040_p)) * ztf.to_complex(p4040_w / (tf.pow(p4040_m,3)))) +sum_list.append(ztf.to_complex(p4160_s) * tf.exp(tf.complex(ztf.constant(0.0), p4160_p)) * ztf.to_complex(p4160_w / (tf.pow(p4160_m,3)))) +sum_list.append(ztf.to_complex(p4415_s) * tf.exp(tf.complex(ztf.constant(0.0), p4415_p)) * ztf.to_complex(p4415_w / (tf.pow(p4415_m,3)))) +sum_list.append(ztf.to_complex(DDstar_s) * tf.exp(tf.complex(ztf.constant(0.0), DDstar_p)) * (ztf.to_complex(1.0 / (10.0*tf.pow(Dstar_m,2)) + 1.0 / (10.0*tf.pow(D_m,2))))) +sum_list.append(ztf.to_complex(Dbar_s) * tf.exp(tf.complex(ztf.constant(0.0), Dbar_p)) * ztf.to_complex(1.0 / (6.0*tf.pow(Dbar_m,2)))) + +sum_ru_1 = ztf.to_complex(ztf.constant(0.0)) + +for part in sum_list: + sum_ru_1 += part + +sum_1 = tf.math.real(sum_ru_1) +# constraint1 = zfit.constraint.GaussianConstraint(params = sum_1, mu = ztf.constant(1.7*10**-8), +# sigma = ztf.constant(2.2*10**-8)) + +constraint1 = tf.pow((sum_1-ztf.constant(1.7*10**-8))/ztf.constant(2.2*10**-8),2)/ztf.constant(2.) + +# 2. Constraint - Abs. of sum of Psi contribs and D contribs + +sum_2 = tf.abs(sum_ru_1) +constraint2 = tf.cond(tf.greater_equal(sum_2, 5.0e-8), lambda: 100000., lambda: 0.) + +# 3. Constraint - Maximum eta of D contribs + +constraint3_0 = tf.cond(tf.greater_equal(tf.abs(Dbar_s), 0.2), lambda: 100000., lambda: 0.) + +constraint3_1 = tf.cond(tf.greater_equal(tf.abs(DDstar_s), 0.2), lambda: 100000., lambda: 0.) + +# 4. Constraint - Formfactor multivariant gaussian covariance fplus + +Cov_matrix = [[ztf.constant( 1.), ztf.constant( 0.45), ztf.constant( 0.19), ztf.constant(0.857), ztf.constant(0.598), ztf.constant(0.531), ztf.constant(0.752), ztf.constant(0.229), ztf.constant(0,117)], + [ztf.constant( 0.45), ztf.constant( 1.), ztf.constant(0.677), ztf.constant(0.708), ztf.constant(0.958), ztf.constant(0.927), ztf.constant(0.227), ztf.constant(0.443), ztf.constant(0.287)], + [ztf.constant( 0.19), ztf.constant(0.677), ztf.constant( 1.), ztf.constant(0.595), ztf.constant(0.770), ztf.constant(0.819),ztf.constant(-0.023), ztf.constant( 0.07), ztf.constant(0.196)], + [ztf.constant(0.857), ztf.constant(0.708), ztf.constant(0.595), ztf.constant( 1.), ztf.constant( 0.83), ztf.constant(0.766), ztf.constant(0.582), ztf.constant(0.237), ztf.constant(0.192)], + [ztf.constant(0.598), ztf.constant(0.958), ztf.constant(0.770), ztf.constant( 0.83), ztf.constant( 1.), ztf.constant(0.973), ztf.constant(0.324), ztf.constant(0.372), ztf.constant(0.272)], + [ztf.constant(0.531), ztf.constant(0.927), ztf.constant(0.819), ztf.constant(0.766), ztf.constant(0.973), ztf.constant( 1.), ztf.constant(0.268), ztf.constant(0.332), ztf.constant(0.269)], + [ztf.constant(0.752), ztf.constant(0.227),ztf.constant(-0.023), ztf.constant(0.582), ztf.constant(0.324), ztf.constant(0.268), ztf.constant( 1.), ztf.constant( 0.59), ztf.constant(0.515)], + [ztf.constant(0.229), ztf.constant(0.443), ztf.constant( 0.07), ztf.constant(0.237), ztf.constant(0.372), ztf.constant(0.332), ztf.constant( 0.59), ztf.constant( 1.), ztf.constant(0.897)], + [ztf.constant(0.117), ztf.constant(0.287), ztf.constant(0.196), ztf.constant(0.192), ztf.constant(0.272), ztf.constant(0.269), ztf.constant(0.515), ztf.constant(0.897), ztf.constant( 1.)]] + +def triGauss(val1,val2,val3,m = Cov_matrix): + + mean1 = ztf.constant(0.466) + mean2 = ztf.constant(-0.885) + mean3 = ztf.constant(-0.213) + sigma1 = ztf.constant(0.014) + sigma2 = ztf.constant(0.128) + sigma3 = ztf.constant(0.548) + x1 = (val1-mean1)/sigma1 + x2 = (val2-mean2)/sigma2 + x3 = (val3-mean3)/sigma3 + rho12 = m[0][1] + rho13 = m[0][2] + rho23 = m[1][2] + w = x1*x1*(rho23*rho23-1) + x2*x2*(rho13*rho13-1)+x3*x3*(rho12*rho12-1)+2*(x1*x2*(rho12-rho13*rho23)+x1*x3*(rho13-rho12*rho23)+x2*x3*(rho23-rho12*rho13)) + d = 2*(rho12*rho12+rho13*rho13+rho23*rho23-2*rho12*rho13*rho23-1) + + fcn = -w/d + chisq = -2*fcn + return chisq + +constraint4 = triGauss(bplus_0, bplus_1, bplus_2) + +# mean1 = ztf.constant(0.466) +# mean2 = ztf.constant(-0.885) +# mean3 = ztf.constant(-0.213) +# sigma1 = ztf.constant(0.014) +# sigma2 = ztf.constant(0.128) +# sigma3 = ztf.constant(0.548) +# constraint4_0 = tf.pow((bplus_0-mean1)/sigma1,2)/ztf.constant(2.) +# constraint4_1 = tf.pow((bplus_1-mean2)/sigma2,2)/ztf.constant(2.) +# constraint4_2 = tf.pow((bplus_2-mean3)/sigma3,2)/ztf.constant(2.) + +# 5. Constraint - Abs. of sum of light contribs + +sum_list_5 = [] + +sum_list_5.append(rho_s*rho_w/rho_m) +sum_list_5.append(omega_s*omega_w/omega_m) +sum_list_5.append(phi_s*phi_w/phi_m) + + +sum_ru_5 = ztf.constant(0.0) + +for part in sum_list_5: + sum_ru_5 += part + +constraint5 = tf.cond(tf.greater_equal(tf.abs(sum_ru_5), ztf.constant(0.02)), lambda: 100000., lambda: 0.) + +# 6. Constraint on phases of Jpsi and Psi2s for cut out fit + + +# constraint6_0 = zfit.constraint.GaussianConstraint(params = jpsi_p, mu = ztf.constant(pdg["jpsi_phase_unc"]), +# sigma = ztf.constant(jpsi_phase)) +# constraint6_1 = zfit.constraint.GaussianConstraint(params = psi2s_p, mu = ztf.constant(pdg["psi2s_phase_unc"]), +# sigma = ztf.constant(psi2s_phase)) + +constraint6_0 = tf.pow((jpsi_p-ztf.constant(jpsi_phase))/ztf.constant(pdg["jpsi_phase_unc"]),2)/ztf.constant(2.) +constraint6_1 = tf.pow((psi2s_p-ztf.constant(psi2s_phase))/ztf.constant(pdg["psi2s_phase_unc"]),2)/ztf.constant(2.) + +# 7. Constraint on Ctt with higher limits + +constraint7 = tf.cond(tf.greater_equal(Ctt*Ctt, 0.25), lambda: 100000., lambda: 0.) + +constraint7dtype = tf.float64 + +# zfit.run(constraint6_0) + +# ztf.convert_to_tensor(constraint6_0) + +#List of all constraints + +constraints = [constraint1, constraint2, constraint3_0, constraint3_1,# constraint4, #constraint4_0, constraint4_1, constraint4_2, + constraint6_0, constraint6_1]#, constraint7] + + +# ## Reset params + +# In[ ]: + + +param_values_dic = { + 'jpsi_m': jpsi_mass, + 'jpsi_s': jpsi_scale, + 'jpsi_p': jpsi_phase, + 'jpsi_w': jpsi_width, + 'psi2s_m': psi2s_mass, + 'psi2s_s': psi2s_scale, + 'psi2s_p': psi2s_phase, + 'psi2s_w': psi2s_width, + 'p3770_m': p3770_mass, + 'p3770_s': p3770_scale, + 'p3770_p': p3770_phase, + 'p3770_w': p3770_width, + 'p4040_m': p4040_mass, + 'p4040_s': p4040_scale, + 'p4040_p': p4040_phase, + 'p4040_w': p4040_width, + 'p4160_m': p4160_mass, + 'p4160_s': p4160_scale, + 'p4160_p': p4160_phase, + 'p4160_w': p4160_width, + 'p4415_m': p4415_mass, + 'p4415_s': p4415_scale, + 'p4415_p': p4415_phase, + 'p4415_w': p4415_width, + 'rho_m': rho_mass, + 'rho_s': rho_scale, + 'rho_p': rho_phase, + 'rho_w': rho_width, + 'omega_m': omega_mass, + 'omega_s': omega_scale, + 'omega_p': omega_phase, + 'omega_w': omega_width, + 'phi_m': phi_mass, + 'phi_s': phi_scale, + 'phi_p': phi_phase, + 'phi_w': phi_width, + 'Dstar_m': Dstar_mass, + 'DDstar_s': 0.0, + 'DDstar_p': 0.0, + 'D_m': D_mass, + 'Dbar_m': Dbar_mass, + 'Dbar_s': 0.0, + 'Dbar_p': 0.0, + 'tau_m': pdg['tau_M'], + 'Ctt': 0.0, + 'b0_0': 0.292, + 'b0_1': 0.281, + 'b0_2': 0.150, + 'bplus_0': 0.466, + 'bplus_1': -0.885, + 'bplus_2': -0.213, + 'bT_0': 0.460, + 'bT_1': -1.089, + 'bT_2': -1.114} + + +def reset_param_values(variation = 0.05): + for param in total_f_fit.get_dependents(): + if param.floating: + param.set_value(param_values_dic[param.name] + random.uniform(-1, 1) * param_values_dic[param.name]* variation) +# print(param.name) +# for param in totalf.get_dependents(): +# param.set_value() + + +# # Analysis + +# In[ ]: + + +# # zfit.run.numeric_checks = False + +# fitting_range = 'cut' +# total_BR = 1.7e-10 + 4.9e-10 + 2.5e-9 + 6.02e-5 + 4.97e-6 + 1.38e-9 + 4.2e-10 + 2.6e-9 + 6.1e-10 + 4.37e-7 +# cut_BR = 1.0 - (6.02e-5 + 4.97e-6)/total_BR + +# Ctt_list = [] +# Ctt_error_list = [] + +# nr_of_toys = 1 +# if fitting_range == 'cut': +# nevents = int(pdg["number_of_decays"]*cut_BR) +# else: +# nevents = int(pdg["number_of_decays"]) +# # nevents = pdg["number_of_decays"] +# event_stack = 1000000 +# # nevents *= 41 +# # zfit.settings.set_verbosity(10) +# calls = int(nevents/event_stack + 1) + +# total_samp = [] + +# start = time.time() + +# sampler = total_f.create_sampler(n=event_stack) + +# for toy in range(nr_of_toys): + +# ### Generate data + +# # clear_output(wait=True) + +# print("Toy {}: Generating data...".format(toy)) + +# dirName = 'data/zfit_toys/toy_{0}'.format(toy) + +# if not os.path.exists(dirName): +# os.mkdir(dirName) +# print("Directory " , dirName , " Created ") + +# reset_param_values() + +# if fitting_range == 'cut': + +# sampler.resample(n=nevents) +# s = sampler.unstack_x() +# sam = zfit.run(s) +# calls = 0 +# c = 1 + +# else: +# for call in range(calls): + +# sampler.resample(n=event_stack) +# s = sampler.unstack_x() +# sam = zfit.run(s) + +# c = call + 1 + +# with open("data/zfit_toys/toy_{0}/{1}.pkl".format(toy, call), "wb") as f: +# pkl.dump(sam, f, pkl.HIGHEST_PROTOCOL) + +# print("Toy {}: Data generation finished".format(toy)) + +# ### Load data + +# print("Toy {}: Loading data...".format(toy)) + +# if fitting_range == 'cut': + +# total_samp = sam + +# else: + +# for call in range(calls): +# with open(r"data/zfit_toys/toy_0/{}.pkl".format(call), "rb") as input_file: +# sam = pkl.load(input_file) +# total_samp = np.append(total_samp, sam) + +# total_samp = total_samp.astype('float64') + +# if fitting_range == 'full': + +# data = zfit.data.Data.from_numpy(array=total_samp[:int(nevents)], obs=obs) + +# print("Toy {}: Loading data finished".format(toy)) + +# ### Fit data + +# print("Toy {}: Fitting pdf...".format(toy)) + +# for param in total_f.get_dependents(): +# param.randomize() + +# nll = zfit.loss.UnbinnedNLL(model=total_f, data=data, fit_range = (x_min, x_max), constraints = constraints) + +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) +# # minimizer._use_tfgrad = False +# result = minimizer.minimize(nll) + +# print("Toy {}: Fitting finished".format(toy)) + +# print("Function minimum:", result.fmin) +# print("Hesse errors:", result.hesse()) + +# params = result.params +# Ctt_list.append(params[Ctt]['value']) +# Ctt_error_list.append(params[Ctt]['minuit_hesse']['error']) + +# #plotting the result + +# plotdirName = 'data/plots'.format(toy) + +# if not os.path.exists(plotdirName): +# os.mkdir(plotdirName) +# # print("Directory " , dirName , " Created ") + +# probs = total_f.pdf(test_q, norm_range=False) +# calcs_test = zfit.run(probs) +# plt.clf() +# plt.plot(test_q, calcs_test, label = 'pdf') +# plt.legend() +# plt.ylim(0.0, 6e-6) +# plt.savefig(plotdirName + '/toy_fit_full_range{}.png'.format(toy)) + +# print("Toy {0}/{1}".format(toy+1, nr_of_toys)) +# print("Time taken: {}".format(display_time(int(time.time() - start)))) +# print("Projected time left: {}".format(display_time(int((time.time() - start)/(c+calls*(toy))*((nr_of_toys-toy)*calls-c))))) + +# if fitting_range == 'cut': + +# _1 = np.where((total_samp >= x_min) & (total_samp <= (jpsi_mass - 60.))) + +# tot_sam_1 = total_samp[_1] + +# _2 = np.where((total_samp >= (jpsi_mass + 70.)) & (total_samp <= (psi2s_mass - 50.))) + +# tot_sam_2 = total_samp[_2] + +# _3 = np.where((total_samp >= (psi2s_mass + 50.)) & (total_samp <= x_max)) + +# tot_sam_3 = total_samp[_3] + +# tot_sam = np.append(tot_sam_1, tot_sam_2) +# tot_sam = np.append(tot_sam, tot_sam_3) + +# data = zfit.data.Data.from_numpy(array=tot_sam[:int(nevents)], obs=obs_fit) + +# print("Toy {}: Loading data finished".format(toy)) + +# ### Fit data + +# print("Toy {}: Fitting pdf...".format(toy)) + +# for param in total_f_fit.get_dependents(): +# param.randomize() + +# nll = zfit.loss.UnbinnedNLL(model=total_f_fit, data=data, constraints = constraints) + +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) +# # minimizer._use_tfgrad = False +# result = minimizer.minimize(nll) + +# print("Function minimum:", result.fmin) +# print("Hesse errors:", result.hesse()) + +# params = result.params + +# if result.converged: +# Ctt_list.append(params[Ctt]['value']) +# Ctt_error_list.append(params[Ctt]['minuit_hesse']['error']) + +# #plotting the result + +# plotdirName = 'data/plots'.format(toy) + +# if not os.path.exists(plotdirName): +# os.mkdir(plotdirName) +# # print("Directory " , dirName , " Created ") + +# plt.clf() +# plt.hist(tot_sam, bins = int((x_max-x_min)/7.), label = 'toy data') +# plt.savefig(plotdirName + '/toy_histo_cut_region{}.png'.format(toy)) + + +# probs = total_f_fit.pdf(test_q, norm_range=False) +# calcs_test = zfit.run(probs) +# plt.clf() +# plt.plot(test_q, calcs_test, label = 'pdf') +# plt.axvline(x=jpsi_mass-60.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.axvline(x=jpsi_mass+70.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.axvline(x=psi2s_mass-50.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.axvline(x=psi2s_mass+50.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.legend() +# plt.ylim(0.0, 1.5e-6) +# plt.savefig(plotdirName + '/toy_fit_cut_region{}.png'.format(toy)) + +# print("Toy {0}/{1}".format(toy+1, nr_of_toys)) +# print("Time taken: {}".format(display_time(int(time.time() - start)))) +# print("Projected time left: {}".format(display_time(int((time.time() - start)/(toy+1))*((nr_of_toys-toy-1))))) + + + +# In[ ]: + + +# with open("data/results/Ctt_list.pkl", "wb") as f: +# pkl.dump(Ctt_list, f, pkl.HIGHEST_PROTOCOL) +# with open("data/results/Ctt_error_list.pkl", "wb") as f: +# pkl.dump(Ctt_error_list, f, pkl.HIGHEST_PROTOCOL) + + +# In[ ]: + + +# print('{0}/{1} fits converged'.format(len(Ctt_list), nr_of_toys)) +# print('Mean Ctt value = {}'.format(np.mean(Ctt_list))) +# print('Mean Ctt error = {}'.format(np.mean(Ctt_error_list))) +# print('95 Sensitivy = {}'.format(((2*np.mean(Ctt_error_list))**2)*4.2/1000)) + + +# In[ ]: + + +# plt.hist(tot_sam, bins = int((x_max-x_min)/7.)) + +# plt.show() + +# # _ = np.where((total_samp >= x_min) & (total_samp <= (jpsi_mass - 50.))) + +# tot_sam.shape + + +# In[ ]: + + +# Ctt.floating = False + + +# In[ ]: + + +# zfit.run(nll.value()) + + +# In[ ]: + + +# result.fmin + + +# In[ ]: + + +# BR_steps = np.linspace(0.0, 1e-3, 11) +pull_dic = {} + +mi = 1e-4 +ma = 3e-3 +ste = 20 + +for param in total_f_fit.get_dependents(): + if param.floating: + pull_dic[param.name] = [] + for step in range(2*ste): + pull_dic[param.name].append([]) + + + +def save_pulls(step): + for param in total_f_fit.get_dependents(): + if param.floating: + pull_dic[param.name][step].append((params[param]['value'] - param_values_dic[param.name])/params[param]['minuit_hesse']['error']) + + + +# for key in pull_dic.keys(): +# print(np.shape(pull_dic[key])) +# save_pulls(New_step=True) +# params[Ctt]['value'] + + +# In[ ]: + + +# for param in total_f_fit.get_dependents(): +# if param.floating: +# print(param.name) + +# print(params[Ctt]) + + +# # CLS Code + +# In[ ]: + + +# zfit.run.numeric_checks = False + +load = False + +bo = True + +D_contribs = True + +if not D_contribs: + Dbar_s.floating = False + Dbar_p.floating = False + DDstar_s.floating = False + DDstar_p.floating = False + +bo_set = 1 + +fitting_range = 'cut' +total_BR = 1.7e-10 + 4.9e-10 + 2.5e-9 + 6.02e-5 + 4.97e-6 + 1.38e-9 + 4.2e-10 + 2.6e-9 + 6.1e-10 + 4.37e-7 +cut_BR = 1.0 - (6.02e-5 + 4.97e-6)/total_BR + +Ctt_list = [] +Ctt_error_list = [] + +nr_of_toys = 1 +nevents = int(pdg["number_of_decays"]*cut_BR) +# nevents = pdg["number_of_decays"] +event_stack = 1000000 +# nevents *= 41 +# zfit.settings.set_verbosity(10) + +# mi = 1e-4 +# ma = 3e-3 +# ste = 13 + +BR_steps = np.linspace(mi, ma, ste) + +BR_steps[0] = 0.0 + +print(BR_steps) + +Ctt_steps = np.sqrt(BR_steps/4.2*1000) + +print(Ctt_steps) + +# total_samp = [] + +start = time.time() + +Nll_list = [] + +sampler = total_f.create_sampler(n=nevents, fixed_params = False) +sampler.set_data_range(obs_fit) + +__ = -1 + +#----------------------------------------------------- + +if not load: + for Ctt_step in Ctt_steps: + + __ += 1 + + for i in range(2): + Ctt_list.append([]) + Ctt_error_list.append([]) + Nll_list.append([]) + + for param in total_f_fit.get_dependents(): + if param.floating: + pull_dic[param.name].append([]) + + for toy in range(nr_of_toys): + + newset = True + + while newset: + + for floaty in [True, False]: + Ctt.floating = floaty + + for bo_step in range(bo_set): + + print('Step: {0}/{1}'.format(int(__), ste)) + print('Current Ctt: {0}'.format(Ctt_step)) + print('Ctt floating: {0}'.format(floaty)) + + reset_param_values(variation = 0.0) + + if floaty: + print('Toy {0}/{1} - Fit {2}/{3}'.format(toy, nr_of_toys, bo_step, bo_set)) + Ctt.set_value(Ctt_step) + + else: + Ctt.set_value(0.0) + print('Toy {0}/{1} - Fit {2}/{3}'.format(toy, nr_of_toys, bo_step, bo_set)) + + if newset: + sampler.resample(n=nevents) + data = sampler + newset = False + + ### Fit data + + if floaty: + #plt.clf() + #plt.title('Ctt value: {:.2f}'.format(Ctt_step)) + #plt.hist(zfit.run(data), bins = int((x_max-x_min)/7), range = (x_min, x_max)) + #plt.savefig('data/CLs/plots/set_histo{}.png'.format(__)) + _step = 2*__ + else: + _step = 2*__+1 + + nll = zfit.loss.UnbinnedNLL(model=total_f_fit, data=data, constraints = constraints) + + minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) + # minimizer._use_tfgrad = False + result = minimizer.minimize(nll) + + print("Function minimum:", result.fmin) + print("Hesse errors:", result.hesse()) + + params = result.params + + if result.converged: + + save_pulls(step = _step) + + if floaty: + Nll_list[-2].append(result.fmin) + Ctt_list[-2].append(params[Ctt]['value']) + Ctt_error_list[-2].append(params[Ctt]['minuit_hesse']['error']) + + else: + Nll_list[-1].append(result.fmin) + Ctt_list[-1].append(0.0) + Ctt_error_list[-1].append(0.0) + + + else: + for _ in [1,2]: + del Nll_list[-_][toy*bo_set:] +# print(np.shape(Nll_list[-_])) + del Ctt_list[-_][toy*bo_set:] + del Ctt_error_list[-_][toy*bo_set:] + for param in total_f_fit.get_dependents(): + if param.floating: + del pull_dic[param.name][_step+1-_][toy*bo_set:] + newset = True + break + + if not result.converged: + break + + print() + print('Time taken: {}'.format(display_time(int(time.time()-start)))) + print('Estimated time left: {}'.format(display_time(int((time.time()-start)/(__+(toy+1)/nr_of_toys)*(ste-__-(nr_of_toys-toy-1)/nr_of_toys))))) + + +# In[ ]: + + +if load: + + phase_combi = '--' + + if D_contribs: + D_dir = 'D-True' + else: + D_dir = 'D-False' + + _dir = 'data/CLs/finished/f1d1/{}/{}/'.format(phase_combi, D_dir) + + jobs = os.listdir(_dir) + + First = True + +# print(jobs) + + for job in jobs: + + dirName = _dir + str(job) + '/data/CLs' + + if not os.path.exists("{}/{}-{}_{}s{}b{}t--CLs_Nll_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys)): +# print(job) + continue + + with open(r"{}/variab.pkl".format(dirName), "rb") as input_file: + variab = pkl.load(input_file) +# print(variab) + + ### sanity check: + if variab['mi'] != mi or variab['ma'] != ma or variab['ste'] != ste or bo_set != bo_set: + print('Fitting parameters of data dont equal the ones given -- Job {} skipped!'.format(job)) + + with open(r"{}/{}-{}_{}s{}b{}t--CLs_Nll_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _Nll_list = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s{}b{}t--Ctt_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _Ctt_list = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s{}b{}t--Ctt_error_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _Ctt_error_list = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s{}b{}t--pull_dic.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _pull_dic = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s--CLs_list.pkl".format(dirName, mi,ma,ste), "rb") as input_file: + _CLs_list = pkl.load(input_file) + + + if First: + Nll_list = _Nll_list + Ctt_list = _Ctt_list + Ctt_error_list = _Ctt_error_list + pull_dic = _pull_dic +# print(_pull_dic) + CLs_list = _CLs_list + First = False + else: + for step in range(2*ste): +# print(Nll_list[step], step) + Nll_list[step].extend(_Nll_list[step]) + Ctt_list[step].extend(_Ctt_list[step]) + Ctt_error_list[step].extend(_Ctt_error_list[step]) + for key in pull_dic.keys(): +# print(key, np.shape(pull_dic[key])) + pull_dic[key][step].extend(_pull_dic[key][step]) + for step in range(ste): + CLs_list[step].extend(_CLs_list[step]) + +# print('----------------------') + + +# In[ ]: + + +dirName = 'data/CLs' + +# if bo and not load: +# for s in range(2*ste): +# Nll_list[s] = [np.min(Nll_list[s])] + + +if not load: + + if not os.path.exists(dirName): + os.mkdir(dirName) + print("Directory " , dirName , " Created ") + + with open("{}/{}-{}_{}s{}b{}t--CLs_Nll_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(Nll_list, f, pkl.HIGHEST_PROTOCOL) + + with open("{}/{}-{}_{}s{}b{}t--Ctt_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(Ctt_list, f, pkl.HIGHEST_PROTOCOL) + + with open("{}/{}-{}_{}s{}b{}t--Ctt_error_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(Ctt_error_list, f, pkl.HIGHEST_PROTOCOL) + + with open("{}/{}-{}_{}s{}b{}t--pull_dic.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(pull_dic, f, pkl.HIGHEST_PROTOCOL) + + variab = {'mi': mi, + 'ma': ma, + 'ste': ste, + 'bo_set': bo_set, + 'nr_of_toys': nr_of_toys} + + with open("{}/variab.pkl".format(dirName), "wb") as f: + pkl.dump(variab, f, pkl.HIGHEST_PROTOCOL) + + CLs_values = [] + + toy_size = bo_set + + print(np.shape(Nll_list)) + print(Nll_list[0:1]) + + for step in range(ste): + CLs_values.append([]) + for toy in range(nr_of_toys): + float_min = np.min(Nll_list[2*step][toy*bo_set:(toy+1)*bo_set]) + fix_min = np.min(Nll_list[2*step+1][toy*bo_set:(toy+1)*bo_set]) + CLs_values[step].append(float_min-fix_min) + + + print(np.shape(CLs_values)) + + with open("{}/{}-{}_{}s--CLs_list.pkl".format(dirName, mi,ma,ste), "wb") as f: + pkl.dump(CLs_values, f, pkl.HIGHEST_PROTOCOL) + + +# In[ ]: + + +# print(variab['mi'] != mi) + + +# ## Plot + +# In[ ]: + + +l = [] + + +if load: + CLs_values = -1*np.array(CLs_list) + +if not os.path.exists('data/CLs/plots'): + os.mkdir('data/CLs/plots') + print("Directory " , 'data/CLs/plots' , " Created ") + +print(np.shape(CLs_values)) + +for step in range(1,ste): + plt.clf() + plt.title('Ctt value: {:.2f}'.format(Ctt_steps[step])) + plt.hist(CLs_values[0], bins = 150, range = (-25, 50), label = 'Ctt fixed to 0') + plt.hist(CLs_values[step], bins = 150, range = (-25, 50), label = 'Ctt floating') + plt.axvline(x=np.mean(CLs_values[0]),color='red', linewidth=1.0, linestyle = 'dotted') + plt.legend() + plt.savefig('data/CLs/plots/CLs-BR({:.1E}).png'.format(BR_steps[step])) + + l.append(len(np.where(np.array(CLs_values[step]) < np.mean(CLs_values[0]))[0])) + +for step in range(2*ste): + if step%2 == 0: + floaty = True + else: + floaty = False + for key in pull_dic.keys(): + if not os.path.exists('data/CLs/plots/{}'.format(key)): + os.mkdir('data/CLs/plots/{}'.format(key)) + plt.clf() + plt.title('Pull {} - Ctt value {:.2f} - floating {}'.format(key, Ctt_steps[int(step/2)], floaty)) + plt.hist(pull_dic[key][step], bins = 50, range = (-5,5)) + plt.xlabel('Pull') + plt.savefig('data/CLs/plots/{}/{:.2f}Ctt{}s{}f.png'.format(key, Ctt_steps[int(step/2)], step, floaty)) + + +# In[ ]: + + +for s in range(len(l)): + print('BR: {:.4f}'.format(BR_steps[s+1])) + print(2*l[s]/len(CLs_values[s])) + print() + + +# In[ ]: + + +# for step in range(2*ste): +# for key in pull_dic.keys(): +# print(pull_dic[key][step]) + + +# In[ ]: + + +# for param in total_f_fit.get_dependents(): +# if param.floating: +# print(params[param]['value']) + + +# In[ ]: + + +print(display_time(int(time.time()-start))) + + +# In[ ]: + + +# variab['mi'] =! mi + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + diff --git a/data/CLs/finished/f1d1/-+/D-True/2288026/__pycache__/helperfunctions.cpython-37.pyc b/data/CLs/finished/f1d1/-+/D-True/2288026/__pycache__/helperfunctions.cpython-37.pyc new file mode 100644 index 0000000..0b89df3 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288026/__pycache__/helperfunctions.cpython-37.pyc Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288026/__pycache__/pdg_const1.cpython-37.pyc b/data/CLs/finished/f1d1/-+/D-True/2288026/__pycache__/pdg_const1.cpython-37.pyc new file mode 100644 index 0000000..859c94a --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288026/__pycache__/pdg_const1.cpython-37.pyc Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288026/data/CLs/0.0001-0.003_20s--CLs_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288026/data/CLs/0.0001-0.003_20s--CLs_list.pkl new file mode 100644 index 0000000..9a25544 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288026/data/CLs/0.0001-0.003_20s--CLs_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288026/data/CLs/0.0001-0.003_20s1b1t--CLs_Nll_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288026/data/CLs/0.0001-0.003_20s1b1t--CLs_Nll_list.pkl new file mode 100644 index 0000000..4d2b7d9 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288026/data/CLs/0.0001-0.003_20s1b1t--CLs_Nll_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288026/data/CLs/0.0001-0.003_20s1b1t--Ctt_error_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288026/data/CLs/0.0001-0.003_20s1b1t--Ctt_error_list.pkl new file mode 100644 index 0000000..d82fa8d --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288026/data/CLs/0.0001-0.003_20s1b1t--Ctt_error_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288026/data/CLs/0.0001-0.003_20s1b1t--Ctt_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288026/data/CLs/0.0001-0.003_20s1b1t--Ctt_list.pkl new file mode 100644 index 0000000..906225c --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288026/data/CLs/0.0001-0.003_20s1b1t--Ctt_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288026/data/CLs/0.0001-0.003_20s1b1t--pull_dic.pkl b/data/CLs/finished/f1d1/-+/D-True/2288026/data/CLs/0.0001-0.003_20s1b1t--pull_dic.pkl new file mode 100644 index 0000000..b5b4eaf --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288026/data/CLs/0.0001-0.003_20s1b1t--pull_dic.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288026/data/CLs/variab.pkl b/data/CLs/finished/f1d1/-+/D-True/2288026/data/CLs/variab.pkl new file mode 100644 index 0000000..bb90dc0 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288026/data/CLs/variab.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288026/helperfunctions.py b/data/CLs/finished/f1d1/-+/D-True/2288026/helperfunctions.py new file mode 100644 index 0000000..88e120f --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288026/helperfunctions.py @@ -0,0 +1,33 @@ +# some helperfunctions + +import matplotlib +matplotlib.use("agg") +import matplotlib.pyplot as plt + +#Dislpay time (e.g. while generating points) + +display_intervals = ( + ('w', 604800), # 60 * 60 * 24 * 7 + ('d', 86400), # 60 * 60 * 24 + ('h', 3600), # 60 * 60 + ('min', 60), + ('s', 1), + ) + +def display_time(seconds, granularity=2): + result = [] + + for name, count in display_intervals: + value = seconds // count + if value: + seconds -= value * count + if value == 1: + name = name.rstrip('s') + result.append("{} {}".format(value, name)) + return ', '.join(result[:granularity]) + +def prepare_plot(title): + plt.title(title) + plt.grid() + plt.legend(loc = 'best') + plt.xlabel("q") diff --git a/data/CLs/finished/f1d1/-+/D-True/2288026/pdg_const1.py b/data/CLs/finished/f1d1/-+/D-True/2288026/pdg_const1.py new file mode 100644 index 0000000..70b3f30 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288026/pdg_const1.py @@ -0,0 +1,226 @@ +pdg = { + + + ###Particle masses### + + "mbstar" : 5415.4, + "mbstar0" : 5711.0, + "B0_M" : 5279.5, + "Bs_M" : 5366.7, + "Bplus_M" : 5279.3, + "Lb_M" : 5619.4, + "D0_M" : 1864.8, + "Dst_M" : 2010, + "pi_M" : 139.6, + "Jpsi_M" : 3096.9, + "Psi2s_M" : 3685.6, + "kaon_M" : 493.7, + "Ks_M" : 497.6, + "phi_M" : 1019.5, + "rho_M" : 775.26, + "rho_width" : 149.1, + "omega_M" : 782.65, + "omega_width" : 8.49, + + "muon_M" : 105.7, + "tau_M": 1776.86, + + "squark_M" : 95.0, + "bquark_M" : 4180.0, + "cquark_M" : 1275.0, + + "Bplus_tau" : 1.638e-12, + + ###Wilson coefficients### + + "C1" : -0.257, + "C2" : 1.009, + "C3" : -0.005, + "C4" : -0.078, + + "C7eff" : -0.306, + "C9eff" : 4.211, + "C10eff" : -4.103, + +# "C7eff": 0.0, +# "C9eff": 0.0, +# "C10eff": 0.0, + + ###Other constants + + "GF" : 1.1663787e-5, + "alpha_ew" : 1.0/137.0, + "Vts" : 0.0394, + "Vtb" : 1.019, + "number_of_decays": 5404696, + + #Formfactor z coefficients + + #"b0" : [0.285, 0.19, -0.17], + #"bplus" : [0.437, -1.41, -2.5], + #"bT" : [0.440, -1.47, -2.7] + + "b0" : [0.292, 0.281, 0.150], + "bplus" : [0.466, -0.885, -0.213], + "bT" : [0.460, -1.089, -1.114], + + "NR_BR": 4.37e-7, + "NR_auc": 0.00133, + + #Resonances format(mass, width, phase, scale) + + # pre scaling + +# "rho": (775.26, 149.0, -0.35, 1.0), + +# "omega": (782.7, 8.5, 0.26, 1.0), + +# "phi": (1019.46, 4.25, 0.5, 1.0), + +# "jpsi": (3096.0, 0.09, -1.5, 2e-2), +# "jpsi_auc": 0.2126825758464027, + +# "psi2s": (3686.0, 0.3, -1.5, 3.14e-3), +# "psi2s_auc": 2.802257483178487e-10, + +# "p3770": (3773.0, 27.2, -2.13, 1.0e-3), + +# "p4040": (4039.0, 80.0, -2.52, 2.0), + +# "p4160": (4191.0, 70.0, -1.9, 2.2), + +# "p4415": (4421.0, 62.0, -2.52, 1.0), + + + # after scaling (Phase combination --) + + # + # "rho": (743.2, 149.0, -0.22, 1.05), + # + # "omega": (782.7, 8.5, 0.38, 6.8), + # + # "phi": (1013.5, 4.25, 0.62, 19.2), + # + # "jpsi": (3096.1, 0.09, 1.63, 9897.0), + # "jpsi_auc": 0.2126825758464027, + # "jpsi_phase_unc": 0.05, + # + # "psi2s": (3686.0, 0.3, 1.8, 1396.0), + # "psi2s_auc": 0.0151332263, + # "psi2s_phase_unc": 0.1, + # + # "p3770": (3773.0, 27.2, -2.95, 2.5), + # + # "p4040": (4039.0, 80.0, -2.75, 1.01), + # + # "p4160": (4191.0, 70.0, -2.28, 2.2), + # + # "p4415": (4421.0, 62.0, -2.31, 1.24), + + # Phase combination of paper ++ + +# "rho": (743.2, 149.0, -0.35, 1.05), + +# "omega": (782.7, 8.5, 0.26, 6.8), + +# "phi": (1013.5, 4.25, 0.47, 19.2), + +# "jpsi": (3096.1, 0.09, -1.66, 9897.0), +# "jpsi_auc": 0.2126825758464027, +# "jpsi_phase_unc": 0.05, + +# "psi2s": (3686.0, 0.3, -1.93, 1396.0), +# "psi2s_auc": 0.0151332263, +# "psi2s_phase_unc": 0.1, + +# "p3770": (3773.0, 27.2, -2.13, 2.5), + +# "p4040": (4039.0, 80.0, -2.52, 1.01), + +# "p4160": (4191.0, 70.0, -1.90, 2.2), + +# "p4415": (4421.0, 62.0, -2.52, 1.24), + + # Phase combination of paper +- + +# "rho": (743.2, 149.0, -0.26, 1.05), + +# "omega": (782.7, 8.5, 0.35, 6.8), + +# "phi": (1013.5, 4.25, 0.58, 19.2), + +# "jpsi": (3096.1, 0.09, 1.47, 9897.0), +# "jpsi_auc": 0.2126825758464027, +# "jpsi_phase_unc": 0.05, + +# "psi2s": (3686.0, 0.3, -2.21, 1396.0), +# "psi2s_auc": 0.0151332263, +# "psi2s_phase_unc": 0.1, + +# "p3770": (3773.0, 27.2, -2.140, 2.5), + +# "p4040": (4039.0, 80.0, -2.64, 1.01), + +# "p4160": (4191.0, 70.0, -2.11, 2.2), + +# "p4415": (4421.0, 62.0, -2.42, 1.24), + + # Phase combination of paper -+ + + "rho": (743.2, 149.0, -0.30, 1.05), + + "omega": (782.7, 8.5, 0.30, 6.8), + + "phi": (1013.5, 4.25, 0.51, 19.2), + + "jpsi": (3096.1, 0.09, -1.5, 9897.0), + "jpsi_auc": 0.2126825758464027, + "jpsi_phase_unc": 0.05, + + "psi2s": (3686.0, 0.3, 2.08, 1396.0), + "psi2s_auc": 0.0151332263, + "psi2s_phase_unc": 0.1, + + "p3770": (3773.0, 27.2, -2.89, 2.5), + + "p4040": (4039.0, 80.0, -2.69, 1.01), + + "p4160": (4191.0, 70.0, -2.13, 2.2), + + "p4415": (4421.0, 62.0, -2.43, 1.24), + + + # zeroing resonances + +# "rho": (775.26, 149.0, -0.35, 0.0), +# "omega": (782.7, 8.5, 0.26, 0.0), +# "phi": (1019.46, 4.25, 0.5, 0.0), +# "jpsi": (3096.0, 0.09, -1.5, 0.0), +# "psi2s": (3686.0, 0.3, -1.5, 0.0), +# "p3770": (3773.0, 27.2, -2.13, 0.0), +# "p4040": (4039.0, 80.0, -2.52, 0.0), +# "p4160": (4147.0, 22.0, -1.9, 0.0), +# "p4415": (4421.0, 62.0, -2.52, 0.0), + + # 2P contributions format(mass, amp, phase) + +# "D_bar": ( + + #general + + "rho_BR": 1.7e-10, + "omega_BR": 4.9e-10, + "phi_BR": 2.5e-9, + "jpsi_BR": 6.02e-5, + "psi2s_BR": 4.97e-6, + "p3770_BR": 1.38e-9, + "p4040_BR": 4.2e-10, + "p4160_BR": 2.6e-9, + "p4415_BR": 6.1e-10, + +# Estimates + "Dbar_scale": 1.46, #with phase = pi + + "DDstar_scale": 2.41, #with phase = pi + + } diff --git a/data/CLs/finished/f1d1/-+/D-True/2288026/raremodel-nb.py b/data/CLs/finished/f1d1/-+/D-True/2288026/raremodel-nb.py new file mode 100644 index 0000000..c326c9c --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288026/raremodel-nb.py @@ -0,0 +1,2152 @@ +#!/usr/bin/env python +# coding: utf-8 + +# # Import + +# In[ ]: + + +import os + +# os.environ["CUDA_VISIBLE_DEVICES"] = "-1" +import random +import numpy as np +from pdg_const1 import pdg +import matplotlib +import matplotlib.pyplot as plt +import pickle as pkl +import sys +import time +from helperfunctions import display_time, prepare_plot +import cmath as c +import scipy.integrate as integrate +from scipy.optimize import fminbound +from array import array as arr +import collections +from itertools import compress +import tensorflow as tf +import zfit +from zfit import ztf +# from IPython.display import clear_output +import os +import tensorflow_probability as tfp +tfd = tfp.distributions + + +# In[ ]: + + +# chunksize = 10000 +# zfit.run.chunking.active = True +# zfit.run.chunking.max_n_points = chunksize + + +# # Build model and graphs +# ## Create graphs + +# In[ ]: + + + + + +# In[ ]: + + +def formfactor(q2, subscript, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2): #returns real value + #check if subscript is viable + + if subscript != "0" and subscript != "+" and subscript != "T": + raise ValueError('Wrong subscript entered, choose either 0, + or T') + + #get constants + + mK = ztf.constant(pdg['Ks_M']) + mbstar0 = ztf.constant(pdg["mbstar0"]) + mbstar = ztf.constant(pdg["mbstar"]) + + + mmu = ztf.constant(pdg['muon_M']) + mb = ztf.constant(pdg['bquark_M']) + ms = ztf.constant(pdg['squark_M']) + mB = ztf.constant(pdg['Bplus_M']) + + #N comes from derivation in paper + + N = 3 + + #some helperfunctions + + tpos = (mB - mK)**2 + tzero = (mB + mK)*(ztf.sqrt(mB)-ztf.sqrt(mK))**2 + + z_oben = ztf.sqrt(tpos - q2) - ztf.sqrt(tpos - tzero) + z_unten = ztf.sqrt(tpos - q2) + ztf.sqrt(tpos - tzero) + z = tf.divide(z_oben, z_unten) + + #calculate f0 + + if subscript == "0": + prefactor = 1/(1 - q2/(mbstar0**2)) + _sum = 0 + b0 = [b0_0, b0_1, b0_2] + + for i in range(N): + _sum += b0[i]*(tf.pow(z,i)) + + return ztf.to_complex(prefactor * _sum) + + #calculate f+ or fT + + else: + prefactor = 1/(1 - q2/(mbstar**2)) + _sum = 0 + + if subscript == "T": + bT = [bT_0, bT_1, bT_2] + for i in range(N): + _sum += bT[i] * (tf.pow(z, i) - ((-1)**(i-N)) * (i/N) * tf.pow(z, N)) + else: + bplus = [bplus_0, bplus_1, bplus_2] + for i in range(N): + _sum += bplus[i] * (tf.pow(z, i) - ((-1)**(i-N)) * (i/N) * tf.pow(z, N)) + + return ztf.to_complex(prefactor * _sum) + +def resonance(q, _mass, width, phase, scale): + + q2 = tf.pow(q, 2) + + mmu = ztf.constant(pdg['muon_M']) + + p = 0.5 * ztf.sqrt(q2 - 4*(mmu**2)) + + p0 = 0.5 * ztf.sqrt(_mass**2 - 4*mmu**2) + + gamma_j = tf.divide(p, q) * _mass * width / p0 + + #Calculate the resonance + + _top = tf.complex(_mass * width, ztf.constant(0.0)) + + _bottom = tf.complex(_mass**2 - q2, -_mass*gamma_j) + + com = _top/_bottom + + #Rotate by the phase + + r = ztf.to_complex(scale*tf.abs(com)) + + _phase = tf.angle(com) + + _phase += phase + + com = r * tf.exp(tf.complex(ztf.constant(0.0), _phase)) + + return com + + +def axiv_nonres(q, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2): + + GF = ztf.constant(pdg['GF']) + alpha_ew = ztf.constant(pdg['alpha_ew']) + Vtb = ztf.constant(pdg['Vtb']) + Vts = ztf.constant(pdg['Vts']) + C10eff = ztf.constant(pdg['C10eff']) + + mmu = ztf.constant(pdg['muon_M']) + mb = ztf.constant(pdg['bquark_M']) + ms = ztf.constant(pdg['squark_M']) + mK = ztf.constant(pdg['Ks_M']) + mB = ztf.constant(pdg['Bplus_M']) + + q2 = tf.pow(q, 2) + + #Some helperfunctions + + beta = 1. - 4. * mmu**2. / q2 + + kabs = ztf.sqrt(mB**2. + tf.pow(q2, 2)/mB**2. + mK**4./mB**2. - 2. * (mB**2. * mK**2. + mK**2. * q2 + mB**2. * q2) / mB**2.) + + #prefactor in front of whole bracket + + prefactor1 = GF**2. *alpha_ew**2. * (tf.abs(Vtb*Vts))**2. * kabs * beta / (128. * np.pi**5.) + + #left term in bracket + + bracket_left = 2./3. * tf.pow(kabs,2) * tf.pow(beta,2) * tf.pow(tf.abs(ztf.to_complex(C10eff)*formfactor(q2, "+", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2)),2) + + #middle term in bracket + + _top = 4. * mmu**2. * (mB**2. - mK**2.) * (mB**2. - mK**2.) + + _under = q2 * mB**2. + + bracket_middle = _top/_under *tf.pow(tf.abs(ztf.to_complex(C10eff) * formfactor(q2, "0", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2)), 2) + + #Note sqrt(q2) comes from derivation as we use q2 and plot q + + return prefactor1 * (bracket_left + bracket_middle) * 2 * q + +def vec(q, funcs, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2): + + q2 = tf.pow(q, 2) + + GF = ztf.constant(pdg['GF']) + alpha_ew = ztf.constant(pdg['alpha_ew']) + Vtb = ztf.constant(pdg['Vtb']) + Vts = ztf.constant(pdg['Vts']) + C7eff = ztf.constant(pdg['C7eff']) + + mmu = ztf.constant(pdg['muon_M']) + mb = ztf.constant(pdg['bquark_M']) + ms = ztf.constant(pdg['squark_M']) + mK = ztf.constant(pdg['Ks_M']) + mB = ztf.constant(pdg['Bplus_M']) + + #Some helperfunctions + + beta = 1. - 4. * mmu**2. / q2 + + kabs = ztf.sqrt(mB**2. + tf.pow(q2, 2)/mB**2. + mK**4./mB**2. - 2 * (mB**2 * mK**2 + mK**2 * q2 + mB**2 * q2) / mB**2) + + #prefactor in front of whole bracket + + prefactor1 = GF**2. *alpha_ew**2. * (tf.abs(Vtb*Vts))**2 * kabs * beta / (128. * np.pi**5.) + + #right term in bracket + + prefactor2 = tf.pow(kabs,2) * (1. - 1./3. * beta) + + abs_bracket = tf.pow(tf.abs(c9eff(q, funcs) * formfactor(q2, "+", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + ztf.to_complex(2.0 * C7eff * (mb + ms)/(mB + mK)) * formfactor(q2, "T", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2)),2) + + bracket_right = prefactor2 * abs_bracket + + #Note sqrt(q2) comes from derivation as we use q2 and plot q + + return prefactor1 * bracket_right * 2 * q + +def c9eff(q, funcs): + + C9eff_nr = ztf.to_complex(ztf.constant(pdg['C9eff'])) + + c9 = C9eff_nr + funcs + + return c9 + + +# In[ ]: + + +def G(y): + + def inner_rect_bracket(q): + return tf.log(ztf.to_complex((1+tf.sqrt(q))/(1-tf.sqrt(q)))-tf.complex(ztf.constant(0), -1*ztf.constant(np.pi))) + + def inner_right(q): + return ztf.to_complex(2 * tf.atan(1/tf.sqrt(tf.math.real(-q)))) + + big_bracket = tf.where(tf.math.real(y) > ztf.constant(0.0), inner_rect_bracket(y), inner_right(y)) + + return ztf.to_complex(tf.sqrt(tf.abs(y))) * big_bracket + +def h_S(m, q): + + return ztf.to_complex(2) - G(ztf.to_complex(1) - ztf.to_complex(4*tf.pow(m, 2)) / ztf.to_complex(tf.pow(q, 2))) + +def h_P(m, q): + + return ztf.to_complex(2/3) + (ztf.to_complex(1) - ztf.to_complex(4*tf.pow(m, 2)) / ztf.to_complex(tf.pow(q, 2))) * h_S(m,q) + +def two_p_ccbar(mD, m_D_bar, m_D_star, q): + + + #Load constants + nu_D_bar = ztf.to_complex(pdg["nu_D_bar"]) + nu_D = ztf.to_complex(pdg["nu_D"]) + nu_D_star = ztf.to_complex(pdg["nu_D_star"]) + + phase_D_bar = ztf.to_complex(pdg["phase_D_bar"]) + phase_D = ztf.to_complex(pdg["phase_D"]) + phase_D_star = ztf.to_complex(pdg["phase_D_star"]) + + #Calculation + left_part = nu_D_bar * tf.exp(tf.complex(ztf.constant(0.0), phase_D_bar)) * h_S(m_D_bar, q) + + right_part_D = nu_D * tf.exp(tf.complex(ztf.constant(0.0), phase_D)) * h_P(m_D, q) + + right_part_D_star = nu_D_star * tf.exp(tf.complex(ztf.constant(0.0), phase_D_star)) * h_P(m_D_star, q) + + return left_part + right_part_D + right_part_D_star + + +# ## Build pdf + +# In[ ]: + + +class total_pdf_cut(zfit.pdf.ZPDF): + _N_OBS = 1 # dimension, can be omitted + _PARAMS = ['b0_0', 'b0_1', 'b0_2', + 'bplus_0', 'bplus_1', 'bplus_2', + 'bT_0', 'bT_1', 'bT_2', + 'rho_mass', 'rho_scale', 'rho_phase', 'rho_width', + 'jpsi_mass', 'jpsi_scale', 'jpsi_phase', 'jpsi_width', + 'psi2s_mass', 'psi2s_scale', 'psi2s_phase', 'psi2s_width', + 'p3770_mass', 'p3770_scale', 'p3770_phase', 'p3770_width', + 'p4040_mass', 'p4040_scale', 'p4040_phase', 'p4040_width', + 'p4160_mass', 'p4160_scale', 'p4160_phase', 'p4160_width', + 'p4415_mass', 'p4415_scale', 'p4415_phase', 'p4415_width', + 'omega_mass', 'omega_scale', 'omega_phase', 'omega_width', + 'phi_mass', 'phi_scale', 'phi_phase', 'phi_width', + 'Dbar_mass', 'Dbar_scale', 'Dbar_phase', + 'Dstar_mass', 'DDstar_scale', 'DDstar_phase', 'D_mass', + 'tau_mass', 'C_tt'] +# the name of the parameters + + def _unnormalized_pdf(self, x): + + x = x.unstack_x() + + b0 = [self.params['b0_0'], self.params['b0_1'], self.params['b0_2']] + bplus = [self.params['bplus_0'], self.params['bplus_1'], self.params['bplus_2']] + bT = [self.params['bT_0'], self.params['bT_1'], self.params['bT_2']] + + def rho_res(q): + return resonance(q, _mass = self.params['rho_mass'], scale = self.params['rho_scale'], + phase = self.params['rho_phase'], width = self.params['rho_width']) + + def omega_res(q): + return resonance(q, _mass = self.params['omega_mass'], scale = self.params['omega_scale'], + phase = self.params['omega_phase'], width = self.params['omega_width']) + + def phi_res(q): + return resonance(q, _mass = self.params['phi_mass'], scale = self.params['phi_scale'], + phase = self.params['phi_phase'], width = self.params['phi_width']) + + def jpsi_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['jpsi_mass'], 2)) * resonance(q, _mass = self.params['jpsi_mass'], + scale = self.params['jpsi_scale'], + phase = self.params['jpsi_phase'], + width = self.params['jpsi_width']) + def psi2s_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['psi2s_mass'], 2)) * resonance(q, _mass = self.params['psi2s_mass'], + scale = self.params['psi2s_scale'], + phase = self.params['psi2s_phase'], + width = self.params['psi2s_width']) + def p3770_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p3770_mass'], 2)) * resonance(q, _mass = self.params['p3770_mass'], + scale = self.params['p3770_scale'], + phase = self.params['p3770_phase'], + width = self.params['p3770_width']) + + def p4040_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4040_mass'], 2)) * resonance(q, _mass = self.params['p4040_mass'], + scale = self.params['p4040_scale'], + phase = self.params['p4040_phase'], + width = self.params['p4040_width']) + + def p4160_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4160_mass'], 2)) * resonance(q, _mass = self.params['p4160_mass'], + scale = self.params['p4160_scale'], + phase = self.params['p4160_phase'], + width = self.params['p4160_width']) + + def p4415_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4415_mass'], 2)) * resonance(q, _mass = self.params['p4415_mass'], + scale = self.params['p4415_scale'], + phase = self.params['p4415_phase'], + width = self.params['p4415_width']) + + def P2_D(q): + Dbar_contrib = ztf.to_complex(self.params['Dbar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['Dbar_phase']))*ztf.to_complex(h_S(self.params['Dbar_mass'], q)) + DDstar_contrib = ztf.to_complex(self.params['DDstar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['DDstar_phase']))*(ztf.to_complex(h_P(self.params['Dstar_mass'], q)) + ztf.to_complex(h_P(self.params['D_mass'], q))) + return Dbar_contrib + DDstar_contrib + + def ttau_cusp(q): + return ztf.to_complex(self.params['C_tt'])*(ztf.to_complex((h_S(self.params['tau_mass'], q))) - ztf.to_complex(h_P(self.params['tau_mass'], q))) + + + funcs = rho_res(x) + omega_res(x) + phi_res(x) + jpsi_res(x) + psi2s_res(x) + p3770_res(x) + p4040_res(x)+ p4160_res(x) + p4415_res(x) + P2_D(x) + ttau_cusp(x) + + vec_f = vec(x, funcs, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + axiv_nr = axiv_nonres(x, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + tot = vec_f + axiv_nr + + #Cut out jpsi and psi2s + + tot = tf.where(tf.math.logical_or(x < ztf.constant(jpsi_mass-60.), x > ztf.constant(jpsi_mass+70.)), tot, 0.0*tot) + + tot = tf.where(tf.math.logical_or(x < ztf.constant(psi2s_mass-50.), x > ztf.constant(psi2s_mass+50.)), tot, 0.0*tot) + + return tot + +class total_pdf_full(zfit.pdf.ZPDF): + _N_OBS = 1 # dimension, can be omitted + _PARAMS = ['b0_0', 'b0_1', 'b0_2', + 'bplus_0', 'bplus_1', 'bplus_2', + 'bT_0', 'bT_1', 'bT_2', + 'rho_mass', 'rho_scale', 'rho_phase', 'rho_width', + 'jpsi_mass', 'jpsi_scale', 'jpsi_phase', 'jpsi_width', + 'psi2s_mass', 'psi2s_scale', 'psi2s_phase', 'psi2s_width', + 'p3770_mass', 'p3770_scale', 'p3770_phase', 'p3770_width', + 'p4040_mass', 'p4040_scale', 'p4040_phase', 'p4040_width', + 'p4160_mass', 'p4160_scale', 'p4160_phase', 'p4160_width', + 'p4415_mass', 'p4415_scale', 'p4415_phase', 'p4415_width', + 'omega_mass', 'omega_scale', 'omega_phase', 'omega_width', + 'phi_mass', 'phi_scale', 'phi_phase', 'phi_width', + 'Dbar_mass', 'Dbar_scale', 'Dbar_phase', + 'Dstar_mass', 'DDstar_scale', 'DDstar_phase', 'D_mass', + 'tau_mass', 'C_tt'] +# the name of the parameters + + def _unnormalized_pdf(self, x): + + x = x.unstack_x() + + b0 = [self.params['b0_0'], self.params['b0_1'], self.params['b0_2']] + bplus = [self.params['bplus_0'], self.params['bplus_1'], self.params['bplus_2']] + bT = [self.params['bT_0'], self.params['bT_1'], self.params['bT_2']] + + def rho_res(q): + return resonance(q, _mass = self.params['rho_mass'], scale = self.params['rho_scale'], + phase = self.params['rho_phase'], width = self.params['rho_width']) + + def omega_res(q): + return resonance(q, _mass = self.params['omega_mass'], scale = self.params['omega_scale'], + phase = self.params['omega_phase'], width = self.params['omega_width']) + + def phi_res(q): + return resonance(q, _mass = self.params['phi_mass'], scale = self.params['phi_scale'], + phase = self.params['phi_phase'], width = self.params['phi_width']) + + def jpsi_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['jpsi_mass'], 2)) * resonance(q, _mass = self.params['jpsi_mass'], + scale = self.params['jpsi_scale'], + phase = self.params['jpsi_phase'], + width = self.params['jpsi_width']) + def psi2s_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['psi2s_mass'], 2)) * resonance(q, _mass = self.params['psi2s_mass'], + scale = self.params['psi2s_scale'], + phase = self.params['psi2s_phase'], + width = self.params['psi2s_width']) + def p3770_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p3770_mass'], 2)) * resonance(q, _mass = self.params['p3770_mass'], + scale = self.params['p3770_scale'], + phase = self.params['p3770_phase'], + width = self.params['p3770_width']) + + def p4040_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4040_mass'], 2)) * resonance(q, _mass = self.params['p4040_mass'], + scale = self.params['p4040_scale'], + phase = self.params['p4040_phase'], + width = self.params['p4040_width']) + + def p4160_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4160_mass'], 2)) * resonance(q, _mass = self.params['p4160_mass'], + scale = self.params['p4160_scale'], + phase = self.params['p4160_phase'], + width = self.params['p4160_width']) + + def p4415_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4415_mass'], 2)) * resonance(q, _mass = self.params['p4415_mass'], + scale = self.params['p4415_scale'], + phase = self.params['p4415_phase'], + width = self.params['p4415_width']) + + def P2_D(q): + Dbar_contrib = ztf.to_complex(self.params['Dbar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['Dbar_phase']))*ztf.to_complex(h_S(self.params['Dbar_mass'], q)) + DDstar_contrib = ztf.to_complex(self.params['DDstar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['DDstar_phase']))*(ztf.to_complex(h_P(self.params['Dstar_mass'], q)) + ztf.to_complex(h_P(self.params['D_mass'], q))) + return Dbar_contrib + DDstar_contrib + + def ttau_cusp(q): + return ztf.to_complex(self.params['C_tt'])*(ztf.to_complex((h_S(self.params['tau_mass'], q))) - ztf.to_complex(h_P(self.params['tau_mass'], q))) + + + funcs = rho_res(x) + omega_res(x) + phi_res(x) + jpsi_res(x) + psi2s_res(x) + p3770_res(x) + p4040_res(x)+ p4160_res(x) + p4415_res(x) + P2_D(x) + ttau_cusp(x) + + vec_f = vec(x, funcs, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + axiv_nr = axiv_nonres(x, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + tot = vec_f + axiv_nr + + #Cut out jpsi and psi2s + +# tot = tf.where(tf.math.logical_or(x < ztf.constant(jpsi_mass-60.), x > ztf.constant(jpsi_mass+70.)), tot, 0.0*tot) + +# tot = tf.where(tf.math.logical_or(x < ztf.constant(psi2s_mass-50.), x > ztf.constant(psi2s_mass+50.)), tot, 0.0*tot) + + return tot + + +# ## Setup parameters + +# In[ ]: + + +# formfactors + +b0_0 = zfit.Parameter("b0_0", ztf.constant(0.292), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +b0_1 = zfit.Parameter("b0_1", ztf.constant(0.281), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +b0_2 = zfit.Parameter("b0_2", ztf.constant(0.150), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) + +bplus_0 = zfit.Parameter("bplus_0", ztf.constant(0.466), lower_limit = -2.0, upper_limit= 2.0) +bplus_1 = zfit.Parameter("bplus_1", ztf.constant(-0.885), lower_limit = -2.0, upper_limit= 2.0) +bplus_2 = zfit.Parameter("bplus_2", ztf.constant(-0.213), lower_limit = -2.0, upper_limit= 2.0) + +bT_0 = zfit.Parameter("bT_0", ztf.constant(0.460), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +bT_1 = zfit.Parameter("bT_1", ztf.constant(-1.089), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +bT_2 = zfit.Parameter("bT_2", ztf.constant(-1.114), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) + + +#rho + +rho_mass, rho_width, rho_phase, rho_scale = pdg["rho"] + +rho_m = zfit.Parameter("rho_m", ztf.constant(rho_mass), floating = False) #lower_limit = rho_mass - rho_width, upper_limit = rho_mass + rho_width) +rho_w = zfit.Parameter("rho_w", ztf.constant(rho_width), floating = False) +rho_p = zfit.Parameter("rho_p", ztf.constant(rho_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +rho_s = zfit.Parameter("rho_s", ztf.constant(rho_scale), lower_limit=rho_scale-np.sqrt(rho_scale), upper_limit=rho_scale+np.sqrt(rho_scale)) + +#omega + +omega_mass, omega_width, omega_phase, omega_scale = pdg["omega"] + +omega_m = zfit.Parameter("omega_m", ztf.constant(omega_mass), floating = False) +omega_w = zfit.Parameter("omega_w", ztf.constant(omega_width), floating = False) +omega_p = zfit.Parameter("omega_p", ztf.constant(omega_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +omega_s = zfit.Parameter("omega_s", ztf.constant(omega_scale), lower_limit=omega_scale-np.sqrt(omega_scale), upper_limit=omega_scale+np.sqrt(omega_scale)) + + +#phi + +phi_mass, phi_width, phi_phase, phi_scale = pdg["phi"] + +phi_m = zfit.Parameter("phi_m", ztf.constant(phi_mass), floating = False) +phi_w = zfit.Parameter("phi_w", ztf.constant(phi_width), floating = False) +phi_p = zfit.Parameter("phi_p", ztf.constant(phi_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +phi_s = zfit.Parameter("phi_s", ztf.constant(phi_scale), lower_limit=phi_scale-np.sqrt(phi_scale), upper_limit=phi_scale+np.sqrt(phi_scale)) + +#jpsi + +jpsi_mass, jpsi_width, jpsi_phase, jpsi_scale = pdg["jpsi"] + +jpsi_m = zfit.Parameter("jpsi_m", ztf.constant(jpsi_mass), floating = False) +jpsi_w = zfit.Parameter("jpsi_w", ztf.constant(jpsi_width), floating = False) +jpsi_p = zfit.Parameter("jpsi_p", ztf.constant(jpsi_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +jpsi_s = zfit.Parameter("jpsi_s", ztf.constant(jpsi_scale), floating = False) #, lower_limit=jpsi_scale-np.sqrt(jpsi_scale), upper_limit=jpsi_scale+np.sqrt(jpsi_scale)) + +#psi2s + +psi2s_mass, psi2s_width, psi2s_phase, psi2s_scale = pdg["psi2s"] + +psi2s_m = zfit.Parameter("psi2s_m", ztf.constant(psi2s_mass), floating = False) +psi2s_w = zfit.Parameter("psi2s_w", ztf.constant(psi2s_width), floating = False) +psi2s_p = zfit.Parameter("psi2s_p", ztf.constant(psi2s_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +psi2s_s = zfit.Parameter("psi2s_s", ztf.constant(psi2s_scale), floating = False) #, lower_limit=psi2s_scale-np.sqrt(psi2s_scale), upper_limit=psi2s_scale+np.sqrt(psi2s_scale)) + +#psi(3770) + +p3770_mass, p3770_width, p3770_phase, p3770_scale = pdg["p3770"] + +p3770_m = zfit.Parameter("p3770_m", ztf.constant(p3770_mass), floating = False) +p3770_w = zfit.Parameter("p3770_w", ztf.constant(p3770_width), floating = False) +p3770_p = zfit.Parameter("p3770_p", ztf.constant(p3770_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p3770_s = zfit.Parameter("p3770_s", ztf.constant(p3770_scale), lower_limit=p3770_scale-np.sqrt(p3770_scale), upper_limit=p3770_scale+np.sqrt(p3770_scale)) + +#psi(4040) + +p4040_mass, p4040_width, p4040_phase, p4040_scale = pdg["p4040"] + +p4040_m = zfit.Parameter("p4040_m", ztf.constant(p4040_mass), floating = False) +p4040_w = zfit.Parameter("p4040_w", ztf.constant(p4040_width), floating = False) +p4040_p = zfit.Parameter("p4040_p", ztf.constant(p4040_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p4040_s = zfit.Parameter("p4040_s", ztf.constant(p4040_scale), lower_limit=p4040_scale-np.sqrt(p4040_scale), upper_limit=p4040_scale+np.sqrt(p4040_scale)) + +#psi(4160) + +p4160_mass, p4160_width, p4160_phase, p4160_scale = pdg["p4160"] + +p4160_m = zfit.Parameter("p4160_m", ztf.constant(p4160_mass), floating = False) +p4160_w = zfit.Parameter("p4160_w", ztf.constant(p4160_width), floating = False) +p4160_p = zfit.Parameter("p4160_p", ztf.constant(p4160_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p4160_s = zfit.Parameter("p4160_s", ztf.constant(p4160_scale), lower_limit=p4160_scale-np.sqrt(p4160_scale), upper_limit=p4160_scale+np.sqrt(p4160_scale)) + +#psi(4415) + +p4415_mass, p4415_width, p4415_phase, p4415_scale = pdg["p4415"] + +p4415_m = zfit.Parameter("p4415_m", ztf.constant(p4415_mass), floating = False) +p4415_w = zfit.Parameter("p4415_w", ztf.constant(p4415_width), floating = False) +p4415_p = zfit.Parameter("p4415_p", ztf.constant(p4415_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p4415_s = zfit.Parameter("p4415_s", ztf.constant(p4415_scale), lower_limit=p4415_scale-np.sqrt(p4415_scale), upper_limit=p4415_scale+np.sqrt(p4415_scale)) + + +# ## Dynamic generation of 2 particle contribution + +# In[ ]: + + +m_c = 1300 + +Dbar_phase = 0.0 +DDstar_phase = 0.0 +Dstar_mass = pdg['Dst_M'] +Dbar_mass = pdg['D0_M'] +D_mass = pdg['D0_M'] + +Dbar_s = zfit.Parameter("Dbar_s", ztf.constant(0.0), lower_limit=-0.3, upper_limit=0.3) +Dbar_m = zfit.Parameter("Dbar_m", ztf.constant(Dbar_mass), floating = False) +Dbar_p = zfit.Parameter("Dbar_p", ztf.constant(Dbar_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi)#, floating = False) +DDstar_s = zfit.Parameter("DDstar_s", ztf.constant(0.0), lower_limit=-0.3, upper_limit=0.3)#, floating = False) +Dstar_m = zfit.Parameter("Dstar_m", ztf.constant(Dstar_mass), floating = False) +D_m = zfit.Parameter("D_m", ztf.constant(D_mass), floating = False) +DDstar_p = zfit.Parameter("DDstar_p", ztf.constant(DDstar_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi)#, floating = False) + + +# ## Tau parameters + +# In[ ]: + + +tau_m = zfit.Parameter("tau_m", ztf.constant(pdg['tau_M']), floating = False) +Ctt = zfit.Parameter("Ctt", ztf.constant(0.0), lower_limit=-2.5, upper_limit=2.5) + + +# ## Load data + +# In[ ]: + + +x_min = 2*pdg['muon_M'] +x_max = (pdg["Bplus_M"]-pdg["Ks_M"]-0.1) + +# # Full spectrum + +obs_toy = zfit.Space('q', limits = (x_min, x_max)) + +# Jpsi and Psi2s cut out + +obs1 = zfit.Space('q', limits = (x_min, jpsi_mass - 60.)) +obs2 = zfit.Space('q', limits = (jpsi_mass + 70., psi2s_mass - 50.)) +obs3 = zfit.Space('q', limits = (psi2s_mass + 50., x_max)) + +obs_fit = obs1 + obs2 + obs3 + +# with open(r"./data/slim_points/slim_points_toy_0_range({0}-{1}).pkl".format(int(x_min), int(x_max)), "rb") as input_file: +# part_set = pkl.load(input_file) + +# x_part = part_set['x_part'] + +# x_part = x_part.astype('float64') + +# data = zfit.data.Data.from_numpy(array=x_part, obs=obs) + + +# ## Setup pdf + +# In[ ]: + + +total_f = total_pdf_cut(obs=obs_toy, jpsi_mass = jpsi_m, jpsi_scale = jpsi_s, jpsi_phase = jpsi_p, jpsi_width = jpsi_w, + psi2s_mass = psi2s_m, psi2s_scale = psi2s_s, psi2s_phase = psi2s_p, psi2s_width = psi2s_w, + p3770_mass = p3770_m, p3770_scale = p3770_s, p3770_phase = p3770_p, p3770_width = p3770_w, + p4040_mass = p4040_m, p4040_scale = p4040_s, p4040_phase = p4040_p, p4040_width = p4040_w, + p4160_mass = p4160_m, p4160_scale = p4160_s, p4160_phase = p4160_p, p4160_width = p4160_w, + p4415_mass = p4415_m, p4415_scale = p4415_s, p4415_phase = p4415_p, p4415_width = p4415_w, + rho_mass = rho_m, rho_scale = rho_s, rho_phase = rho_p, rho_width = rho_w, + omega_mass = omega_m, omega_scale = omega_s, omega_phase = omega_p, omega_width = omega_w, + phi_mass = phi_m, phi_scale = phi_s, phi_phase = phi_p, phi_width = phi_w, + Dstar_mass = Dstar_m, DDstar_scale = DDstar_s, DDstar_phase = DDstar_p, D_mass = D_m, + Dbar_mass = Dbar_m, Dbar_scale = Dbar_s, Dbar_phase = Dbar_p, + tau_mass = tau_m, C_tt = Ctt, b0_0 = b0_0, b0_1 = b0_1, b0_2 = b0_2, + bplus_0 = bplus_0, bplus_1 = bplus_1, bplus_2 = bplus_2, + bT_0 = bT_0, bT_1 = bT_1, bT_2 = bT_2) + +total_f_fit = total_pdf_full(obs=obs_fit, jpsi_mass = jpsi_m, jpsi_scale = jpsi_s, jpsi_phase = jpsi_p, jpsi_width = jpsi_w, + psi2s_mass = psi2s_m, psi2s_scale = psi2s_s, psi2s_phase = psi2s_p, psi2s_width = psi2s_w, + p3770_mass = p3770_m, p3770_scale = p3770_s, p3770_phase = p3770_p, p3770_width = p3770_w, + p4040_mass = p4040_m, p4040_scale = p4040_s, p4040_phase = p4040_p, p4040_width = p4040_w, + p4160_mass = p4160_m, p4160_scale = p4160_s, p4160_phase = p4160_p, p4160_width = p4160_w, + p4415_mass = p4415_m, p4415_scale = p4415_s, p4415_phase = p4415_p, p4415_width = p4415_w, + rho_mass = rho_m, rho_scale = rho_s, rho_phase = rho_p, rho_width = rho_w, + omega_mass = omega_m, omega_scale = omega_s, omega_phase = omega_p, omega_width = omega_w, + phi_mass = phi_m, phi_scale = phi_s, phi_phase = phi_p, phi_width = phi_w, + Dstar_mass = Dstar_m, DDstar_scale = DDstar_s, DDstar_phase = DDstar_p, D_mass = D_m, + Dbar_mass = Dbar_m, Dbar_scale = Dbar_s, Dbar_phase = Dbar_p, + tau_mass = tau_m, C_tt = Ctt, b0_0 = b0_0, b0_1 = b0_1, b0_2 = b0_2, + bplus_0 = bplus_0, bplus_1 = bplus_1, bplus_2 = bplus_2, + bT_0 = bT_0, bT_1 = bT_1, bT_2 = bT_2) + +# print(total_pdf.obs) + +# print(calcs_test) + +# for param in total_f.get_dependents(): +# print(zfit.run(param)) + + +# In[ ]: + + +# total_f_fit.normalization(obs_fit) + + +# ## Test if graphs actually work and compute values + +# In[ ]: + + +# def total_test_tf(xq): + +# def jpsi_res(q): +# return resonance(q, jpsi_m, jpsi_s, jpsi_p, jpsi_w) + +# def psi2s_res(q): +# return resonance(q, psi2s_m, psi2s_s, psi2s_p, psi2s_w) + +# def cusp(q): +# return bifur_gauss(q, cusp_m, sig_L, sig_R, cusp_s) + +# funcs = jpsi_res(xq) + psi2s_res(xq) + cusp(xq) + +# vec_f = vec(xq, funcs) + +# axiv_nr = axiv_nonres(xq) + +# tot = vec_f + axiv_nr + +# return tot + +# def jpsi_res(q): +# return resonance(q, jpsi_m, jpsi_s, jpsi_p, jpsi_w) + +# calcs = zfit.run(total_test_tf(x_part)) + + + +test_q = np.linspace(x_min, x_max, int(2e6)) + +probs = total_f_fit.pdf(test_q, norm_range=False) + +calcs_test = zfit.run(probs) + +Ctt.set_value(0.5) + +calcs_test1 = zfit.run(probs) + +Ctt.set_value(0.0) + +Dbar_s.set_value(0.3) + +DDstar_s.set_value(0.3) + +calcs_test2 = zfit.run(probs) +# res_y = zfit.run(jpsi_res(test_q)) +# b0 = [b0_0, b0_1, b0_2] +# bplus = [bplus_0, bplus_1, bplus_2] +# bT = [bT_0, bT_1, bT_2] +# f0_y = zfit.run(tf.math.real(formfactor(test_q,"0", b0, bplus, bT))) +# fplus_y = zfit.run(tf.math.real(formfactor(test_q,"+", b0, bplus, bT))) +# fT_y = zfit.run(tf.math.real(formfactor(test_q,"T", b0, bplus, bT))) + + +# In[ ]: + + +plt.clf() +# plt.plot(x_part, calcs, '.') +plt.plot(test_q, calcs_test, label = 'pdf (Ctt = 0.0)') +plt.plot(test_q, calcs_test1, label = 'pdf (Ctt = 0.5)') +plt.plot(test_q, calcs_test2, label = 'pdf (D-contribs = 0.3)') +# plt.plot(test_q, f0_y, label = '0') +# plt.plot(test_q, fT_y, label = 'T') +# plt.plot(test_q, fplus_y, label = '+') +# plt.plot(test_q, res_y, label = 'res') +plt.legend() +plt.ylim(0.0, 1.5e-6) +# plt.yscale('log') +# plt.xlim(770, 785) +plt.savefig('test.png') +# print(jpsi_width) + + +# In[ ]: + + + + +# probs = mixture.prob(test_q) +# probs_np = zfit.run(probs) +# probs_np *= np.max(calcs_test) / np.max(probs_np) +# plt.figure() +# plt.semilogy(test_q, probs_np,label="importance sampling") +# plt.semilogy(test_q, calcs_test, label = 'pdf') + + +# In[ ]: + + +# 0.213/(0.00133+0.213+0.015) + + +# ## Adjust scaling of different parts + +# In[ ]: + + +total_f.update_integration_options(draws_per_dim=2000000, mc_sampler=None) +# inte = total_f.integrate(limits = (950., 1050.), norm_range=False) +# inte_fl = zfit.run(inte) +# print(inte_fl/4500) +# print(pdg["jpsi_BR"]/pdg["NR_BR"], inte_fl*pdg["psi2s_auc"]/pdg["NR_auc"]) + + +# In[ ]: + + +# # print("jpsi:", inte_fl) +# # print("Increase am by factor:", np.sqrt(pdg["jpsi_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) +# # print("New amp:", pdg["jpsi"][3]*np.sqrt(pdg["jpsi_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) + +# # print("psi2s:", inte_fl) +# # print("Increase am by factor:", np.sqrt(pdg["psi2s_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) +# # print("New amp:", pdg["psi2s"][3]*np.sqrt(pdg["psi2s_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) + +# name = "phi" + +# print(name+":", inte_fl) +# print("Increase am by factor:", np.sqrt(pdg[name+"_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) +# print("New amp:", pdg[name][0]*np.sqrt(pdg[name+"_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) + + +# print(x_min) +# print(x_max) +# # total_f.update_integration_options(draws_per_dim=2000000, mc_sampler=None) +# total_f.update_integration_options(mc_sampler=lambda dim, num_results, +# dtype: tf.random_uniform(maxval=1., shape=(num_results, dim), dtype=dtype), +# draws_per_dim=1000000) +# # _ = [] + +# # for i in range(10): + +# # inte = total_f.integrate(limits = (x_min, x_max)) +# # inte_fl = zfit.run(inte) +# # print(inte_fl) +# # _.append(inte_fl) + +# # print("mean:", np.mean(_)) + +# _ = time.time() + +# inte = total_f.integrate(limits = (x_min, x_max)) +# inte_fl = zfit.run(inte) +# print(inte_fl) +# print("Time taken: {}".format(display_time(int(time.time() - _)))) + +# print(pdg['NR_BR']/pdg['NR_auc']*inte_fl) +# print(0.25**2*4.2/1000) + + +# # Sampling +# ## Mixture distribution for sampling + +# In[ ]: + + + + +# print(list_of_borders[:9]) +# print(list_of_borders[-9:]) + + +class UniformSampleAndWeights(zfit.util.execution.SessionHolderMixin): + def __call__(self, limits, dtype, n_to_produce): + # n_to_produce = tf.cast(n_to_produce, dtype=tf.int32) + low, high = limits.limit1d + low = tf.cast(low, dtype=dtype) + high = tf.cast(high, dtype=dtype) +# uniform = tfd.Uniform(low=low, high=high) +# uniformjpsi = tfd.Uniform(low=tf.constant(3080, dtype=dtype), high=tf.constant(3112, dtype=dtype)) +# uniformpsi2s = tfd.Uniform(low=tf.constant(3670, dtype=dtype), high=tf.constant(3702, dtype=dtype)) + +# list_of_borders = [] +# _p = [] +# splits = 10 + +# _ = np.linspace(x_min, x_max, splits) + +# for i in range(splits): +# list_of_borders.append(tf.constant(_[i], dtype=dtype)) +# _p.append(tf.constant(1/splits, dtype=dtype)) + +# mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=_p[:(splits-1)]), +# components_distribution=tfd.Uniform(low=list_of_borders[:(splits-1)], +# high=list_of_borders[-(splits-1):])) + mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=[tf.constant(0.05, dtype=dtype), + tf.constant(0.93, dtype=dtype), + tf.constant(0.05, dtype=dtype), + tf.constant(0.065, dtype=dtype), + tf.constant(0.04, dtype=dtype), + tf.constant(0.05, dtype=dtype)]), + components_distribution=tfd.Uniform(low=[tf.constant(x_min, dtype=dtype), + tf.constant(3090, dtype=dtype), + tf.constant(3681, dtype=dtype), + tf.constant(3070, dtype=dtype), + tf.constant(1000, dtype=dtype), + tf.constant(3660, dtype=dtype)], + high=[tf.constant(x_max, dtype=dtype), + tf.constant(3102, dtype=dtype), + tf.constant(3691, dtype=dtype), + tf.constant(3110, dtype=dtype), + tf.constant(1040, dtype=dtype), + tf.constant(3710, dtype=dtype)])) +# dtype = tf.float64 +# mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=[tf.constant(0.04, dtype=dtype), +# tf.constant(0.90, dtype=dtype), +# tf.constant(0.02, dtype=dtype), +# tf.constant(0.07, dtype=dtype), +# tf.constant(0.02, dtype=dtype)]), +# components_distribution=tfd.Uniform(low=[tf.constant(x_min, dtype=dtype), +# tf.constant(3089, dtype=dtype), +# tf.constant(3103, dtype=dtype), +# tf.constant(3681, dtype=dtype), +# tf.constant(3691, dtype=dtype)], +# high=[tf.constant(3089, dtype=dtype), +# tf.constant(3103, dtype=dtype), +# tf.constant(3681, dtype=dtype), +# tf.constant(3691, dtype=dtype), +# tf.constant(x_max, dtype=dtype)])) +# mixture = tfd.Uniform(tf.constant(x_min, dtype=dtype), tf.constant(x_max, dtype=dtype)) +# sample = tf.random.uniform((n_to_produce, 1), dtype=dtype) + sample = mixture.sample((n_to_produce, 1)) +# sample = tf.random.uniform((n_to_produce, 1), dtype=dtype) + weights = mixture.prob(sample)[:,0] +# weights = tf.broadcast_to(tf.constant(1., dtype=dtype), shape=(n_to_produce,)) + # sample = tf.expand_dims(sample, axis=-1) +# print(sample, weights) + +# weights = tf.ones(shape=(n_to_produce,), dtype=dtype) + weights_max = None + thresholds = tf.random_uniform(shape=(n_to_produce,), dtype=dtype) + return sample, thresholds, weights, weights_max, n_to_produce + + +# In[ ]: + + +# total_f._sample_and_weights = UniformSampleAndWeights + + +# In[ ]: + + +# 0.00133/(0.00133+0.213+0.015)*(x_max-3750)/(x_max-x_min) + + +# In[ ]: + + +# zfit.settings.set_verbosity(10) + + +# In[ ]: + + +# # zfit.run.numeric_checks = False + +# nr_of_toys = 1 +# nevents = int(pdg["number_of_decays"]) +# nevents = pdg["number_of_decays"] +# event_stack = 1000000 +# # zfit.settings.set_verbosity(10) +# calls = int(nevents/event_stack + 1) + +# total_samp = [] + +# start = time.time() + +# sampler = total_f.create_sampler(n=event_stack) + +# for toy in range(nr_of_toys): + +# dirName = 'data/zfit_toys/toy_{0}'.format(toy) + +# if not os.path.exists(dirName): +# os.mkdir(dirName) +# print("Directory " , dirName , " Created ") + +# for call in range(calls): + +# sampler.resample(n=event_stack) +# s = sampler.unstack_x() +# sam = zfit.run(s) +# # clear_output(wait=True) + +# c = call + 1 + +# print("{0}/{1} of Toy {2}/{3}".format(c, calls, toy+1, nr_of_toys)) +# print("Time taken: {}".format(display_time(int(time.time() - start)))) +# print("Projected time left: {}".format(display_time(int((time.time() - start)/(c+calls*(toy))*((nr_of_toys-toy)*calls-c))))) + +# with open("data/zfit_toys/toy_{0}/{1}.pkl".format(toy, call), "wb") as f: +# pkl.dump(sam, f, pkl.HIGHEST_PROTOCOL) + + +# In[ ]: + + +# with open(r"data/zfit_toys/toy_0/0.pkl", "rb") as input_file: +# sam = pkl.load(input_file) +# print(sam[:10]) + +# with open(r"data/zfit_toys/toy_0/1.pkl", "rb") as input_file: +# sam2 = pkl.load(input_file) +# print(sam2[:10]) + +# print(np.sum(sam-sam2)) + + +# In[ ]: + + +# print("Time to generate full toy: {} s".format(int(time.time()-start))) + +# total_samp = [] + +# for call in range(calls): +# with open(r"data/zfit_toys/toy_0/{}.pkl".format(call), "rb") as input_file: +# sam = pkl.load(input_file) +# total_samp = np.append(total_samp, sam) + +# total_samp = total_samp.astype('float64') + +# data2 = zfit.data.Data.from_numpy(array=total_samp[:int(nevents)], obs=obs) + +# data3 = zfit.data.Data.from_numpy(array=total_samp, obs=obs) + +# print(total_samp[:nevents].shape) + + +# In[ ]: + + +# plt.clf() + +# bins = int((x_max-x_min)/7) + +# # calcs = zfit.run(total_test_tf(samp)) +# print(total_samp[:nevents].shape) + +# plt.hist(total_samp[:nevents], bins = bins, range = (x_min,x_max), label = 'data') +# # plt.plot(test_q, calcs_test*nevents , label = 'pdf') + +# # plt.plot(sam, calcs, '.') +# # plt.plot(test_q, calcs_test) +# # plt.yscale('log') +# plt.ylim(0, 200) +# # plt.xlim(3080, 3110) + +# plt.legend() + +# plt.savefig('test2.png') + + +# In[ ]: + + +# sampler = total_f.create_sampler(n=nevents) +# nll = zfit.loss.UnbinnedNLL(model=total_f, data=sampler, fit_range = (x_min, x_max)) + +# # for param in pdf.get_dependents(): +# # param.set_value(initial_value) + +# sampler.resample(n=nevents) + +# # Randomise initial values +# # for param in pdf.get_dependents(): +# # param.set_value(random value here) + +# # Minimise the NLL +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 10) +# minimum = minimizer.minimize(nll) + + +# In[ ]: + + +# jpsi_width + + +# In[ ]: + + +# plt.hist(sample, weights=1 / prob(sample)) + + +# # Fitting + +# In[ ]: + + +# start = time.time() + +# for param in total_f.get_dependents(): +# param.randomize() + +# # for param in total_f.get_dependents(): +# # print(zfit.run(param)) + +# nll = zfit.loss.UnbinnedNLL(model=total_f, data=data2, fit_range = (x_min, x_max)) + +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) +# # minimizer._use_tfgrad = False +# result = minimizer.minimize(nll) + +# # param_errors = result.error() + +# # for var, errors in param_errors.items(): +# # print('{}: ^{{+{}}}_{{{}}}'.format(var.name, errors['upper'], errors['lower'])) + +# print("Function minimum:", result.fmin) +# # print("Results:", result.params) +# print("Hesse errors:", result.hesse()) + + +# In[ ]: + + +# print("Time taken for fitting: {}".format(display_time(int(time.time()-start)))) + +# # probs = total_f.pdf(test_q) + +# calcs_test = zfit.run(probs) +# res_y = zfit.run(jpsi_res(test_q)) + + +# In[ ]: + + +# plt.clf() +# # plt.plot(x_part, calcs, '.') +# plt.plot(test_q, calcs_test, label = 'pdf') +# # plt.plot(test_q, res_y, label = 'res') +# plt.legend() +# plt.ylim(0.0, 10e-6) +# # plt.yscale('log') +# # plt.xlim(3080, 3110) +# plt.savefig('test3.png') +# # print(jpsi_width) + + +# In[ ]: + + +# _tot = 4.37e-7+6.02e-5+4.97e-6 +# _probs = [] +# _probs.append(6.02e-5/_tot) +# _probs.append(4.97e-6/_tot) +# _probs.append(4.37e-7/_tot) +# print(_probs) + + +# In[ ]: + + +# dtype = 'float64' +# # mixture = tfd.Uniform(tf.constant(x_min, dtype=dtype), tf.constant(x_max, dtype=dtype)) +# mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=[tf.constant(0.007, dtype=dtype), +# tf.constant(0.917, dtype=dtype), +# tf.constant(0.076, dtype=dtype)]), +# components_distribution=tfd.Uniform(low=[tf.constant(x_min, dtype=dtype), +# tf.constant(3080, dtype=dtype), +# tf.constant(3670, dtype=dtype)], +# high=[tf.constant(x_max, dtype=dtype), +# tf.constant(3112, dtype=dtype), +# tf.constant(3702, dtype=dtype)])) +# # for i in range(10): +# # print(zfit.run(mixture.prob(mixture.sample((10, 1))))) + + +# In[ ]: + + +# print((zfit.run(jpsi_p)%(2*np.pi))/np.pi) +# print((zfit.run(psi2s_p)%(2*np.pi))/np.pi) + + +# In[ ]: + + +# def jpsi_res(q): +# return resonance(q, _mass = jpsi_mass, scale = jpsi_scale, +# phase = jpsi_phase, width = jpsi_width) + +# def psi2s_res(q): +# return resonance(q, _mass = psi2s_mass, scale = psi2s_scale, +# phase = psi2s_phase, width = psi2s_width) + +# def p3770_res(q): +# return resonance(q, _mass = p3770_mass, scale = p3770_scale, +# phase = p3770_phase, width = p3770_width) + +# def p4040_res(q): +# return resonance(q, _mass = p4040_mass, scale = p4040_scale, +# phase = p4040_phase, width = p4040_width) + +# def p4160_res(q): +# return resonance(q, _mass = p4160_mass, scale = p4160_scale, +# phase = p4160_phase, width = p4160_width) + +# def p4415_res(q): +# return resonance(q, _mass = p4415_mass, scale = p4415_scale, +# phase = p4415_phase, width = p4415_width) + + +# In[ ]: + + +# 0.15**2*4.2/1000 +# result.hesse() + + +# ## Constraints + +# In[ ]: + + +# 1. Constraint - Real part of sum of Psi contrib and D contribs + +sum_list = [] + +sum_list.append(ztf.to_complex(jpsi_s) * tf.exp(tf.complex(ztf.constant(0.0), jpsi_p)) * ztf.to_complex(jpsi_w / (tf.pow(jpsi_m,3)))) +sum_list.append(ztf.to_complex(psi2s_s) * tf.exp(tf.complex(ztf.constant(0.0), psi2s_p)) * ztf.to_complex(psi2s_w / (tf.pow(psi2s_m,3)))) +sum_list.append(ztf.to_complex(p3770_s) * tf.exp(tf.complex(ztf.constant(0.0), p3770_p)) * ztf.to_complex(p3770_w / (tf.pow(p3770_m,3)))) +sum_list.append(ztf.to_complex(p4040_s) * tf.exp(tf.complex(ztf.constant(0.0), p4040_p)) * ztf.to_complex(p4040_w / (tf.pow(p4040_m,3)))) +sum_list.append(ztf.to_complex(p4160_s) * tf.exp(tf.complex(ztf.constant(0.0), p4160_p)) * ztf.to_complex(p4160_w / (tf.pow(p4160_m,3)))) +sum_list.append(ztf.to_complex(p4415_s) * tf.exp(tf.complex(ztf.constant(0.0), p4415_p)) * ztf.to_complex(p4415_w / (tf.pow(p4415_m,3)))) +sum_list.append(ztf.to_complex(DDstar_s) * tf.exp(tf.complex(ztf.constant(0.0), DDstar_p)) * (ztf.to_complex(1.0 / (10.0*tf.pow(Dstar_m,2)) + 1.0 / (10.0*tf.pow(D_m,2))))) +sum_list.append(ztf.to_complex(Dbar_s) * tf.exp(tf.complex(ztf.constant(0.0), Dbar_p)) * ztf.to_complex(1.0 / (6.0*tf.pow(Dbar_m,2)))) + +sum_ru_1 = ztf.to_complex(ztf.constant(0.0)) + +for part in sum_list: + sum_ru_1 += part + +sum_1 = tf.math.real(sum_ru_1) +# constraint1 = zfit.constraint.GaussianConstraint(params = sum_1, mu = ztf.constant(1.7*10**-8), +# sigma = ztf.constant(2.2*10**-8)) + +constraint1 = tf.pow((sum_1-ztf.constant(1.7*10**-8))/ztf.constant(2.2*10**-8),2)/ztf.constant(2.) + +# 2. Constraint - Abs. of sum of Psi contribs and D contribs + +sum_2 = tf.abs(sum_ru_1) +constraint2 = tf.cond(tf.greater_equal(sum_2, 5.0e-8), lambda: 100000., lambda: 0.) + +# 3. Constraint - Maximum eta of D contribs + +constraint3_0 = tf.cond(tf.greater_equal(tf.abs(Dbar_s), 0.2), lambda: 100000., lambda: 0.) + +constraint3_1 = tf.cond(tf.greater_equal(tf.abs(DDstar_s), 0.2), lambda: 100000., lambda: 0.) + +# 4. Constraint - Formfactor multivariant gaussian covariance fplus + +Cov_matrix = [[ztf.constant( 1.), ztf.constant( 0.45), ztf.constant( 0.19), ztf.constant(0.857), ztf.constant(0.598), ztf.constant(0.531), ztf.constant(0.752), ztf.constant(0.229), ztf.constant(0,117)], + [ztf.constant( 0.45), ztf.constant( 1.), ztf.constant(0.677), ztf.constant(0.708), ztf.constant(0.958), ztf.constant(0.927), ztf.constant(0.227), ztf.constant(0.443), ztf.constant(0.287)], + [ztf.constant( 0.19), ztf.constant(0.677), ztf.constant( 1.), ztf.constant(0.595), ztf.constant(0.770), ztf.constant(0.819),ztf.constant(-0.023), ztf.constant( 0.07), ztf.constant(0.196)], + [ztf.constant(0.857), ztf.constant(0.708), ztf.constant(0.595), ztf.constant( 1.), ztf.constant( 0.83), ztf.constant(0.766), ztf.constant(0.582), ztf.constant(0.237), ztf.constant(0.192)], + [ztf.constant(0.598), ztf.constant(0.958), ztf.constant(0.770), ztf.constant( 0.83), ztf.constant( 1.), ztf.constant(0.973), ztf.constant(0.324), ztf.constant(0.372), ztf.constant(0.272)], + [ztf.constant(0.531), ztf.constant(0.927), ztf.constant(0.819), ztf.constant(0.766), ztf.constant(0.973), ztf.constant( 1.), ztf.constant(0.268), ztf.constant(0.332), ztf.constant(0.269)], + [ztf.constant(0.752), ztf.constant(0.227),ztf.constant(-0.023), ztf.constant(0.582), ztf.constant(0.324), ztf.constant(0.268), ztf.constant( 1.), ztf.constant( 0.59), ztf.constant(0.515)], + [ztf.constant(0.229), ztf.constant(0.443), ztf.constant( 0.07), ztf.constant(0.237), ztf.constant(0.372), ztf.constant(0.332), ztf.constant( 0.59), ztf.constant( 1.), ztf.constant(0.897)], + [ztf.constant(0.117), ztf.constant(0.287), ztf.constant(0.196), ztf.constant(0.192), ztf.constant(0.272), ztf.constant(0.269), ztf.constant(0.515), ztf.constant(0.897), ztf.constant( 1.)]] + +def triGauss(val1,val2,val3,m = Cov_matrix): + + mean1 = ztf.constant(0.466) + mean2 = ztf.constant(-0.885) + mean3 = ztf.constant(-0.213) + sigma1 = ztf.constant(0.014) + sigma2 = ztf.constant(0.128) + sigma3 = ztf.constant(0.548) + x1 = (val1-mean1)/sigma1 + x2 = (val2-mean2)/sigma2 + x3 = (val3-mean3)/sigma3 + rho12 = m[0][1] + rho13 = m[0][2] + rho23 = m[1][2] + w = x1*x1*(rho23*rho23-1) + x2*x2*(rho13*rho13-1)+x3*x3*(rho12*rho12-1)+2*(x1*x2*(rho12-rho13*rho23)+x1*x3*(rho13-rho12*rho23)+x2*x3*(rho23-rho12*rho13)) + d = 2*(rho12*rho12+rho13*rho13+rho23*rho23-2*rho12*rho13*rho23-1) + + fcn = -w/d + chisq = -2*fcn + return chisq + +constraint4 = triGauss(bplus_0, bplus_1, bplus_2) + +# mean1 = ztf.constant(0.466) +# mean2 = ztf.constant(-0.885) +# mean3 = ztf.constant(-0.213) +# sigma1 = ztf.constant(0.014) +# sigma2 = ztf.constant(0.128) +# sigma3 = ztf.constant(0.548) +# constraint4_0 = tf.pow((bplus_0-mean1)/sigma1,2)/ztf.constant(2.) +# constraint4_1 = tf.pow((bplus_1-mean2)/sigma2,2)/ztf.constant(2.) +# constraint4_2 = tf.pow((bplus_2-mean3)/sigma3,2)/ztf.constant(2.) + +# 5. Constraint - Abs. of sum of light contribs + +sum_list_5 = [] + +sum_list_5.append(rho_s*rho_w/rho_m) +sum_list_5.append(omega_s*omega_w/omega_m) +sum_list_5.append(phi_s*phi_w/phi_m) + + +sum_ru_5 = ztf.constant(0.0) + +for part in sum_list_5: + sum_ru_5 += part + +constraint5 = tf.cond(tf.greater_equal(tf.abs(sum_ru_5), ztf.constant(0.02)), lambda: 100000., lambda: 0.) + +# 6. Constraint on phases of Jpsi and Psi2s for cut out fit + + +# constraint6_0 = zfit.constraint.GaussianConstraint(params = jpsi_p, mu = ztf.constant(pdg["jpsi_phase_unc"]), +# sigma = ztf.constant(jpsi_phase)) +# constraint6_1 = zfit.constraint.GaussianConstraint(params = psi2s_p, mu = ztf.constant(pdg["psi2s_phase_unc"]), +# sigma = ztf.constant(psi2s_phase)) + +constraint6_0 = tf.pow((jpsi_p-ztf.constant(jpsi_phase))/ztf.constant(pdg["jpsi_phase_unc"]),2)/ztf.constant(2.) +constraint6_1 = tf.pow((psi2s_p-ztf.constant(psi2s_phase))/ztf.constant(pdg["psi2s_phase_unc"]),2)/ztf.constant(2.) + +# 7. Constraint on Ctt with higher limits + +constraint7 = tf.cond(tf.greater_equal(Ctt*Ctt, 0.25), lambda: 100000., lambda: 0.) + +constraint7dtype = tf.float64 + +# zfit.run(constraint6_0) + +# ztf.convert_to_tensor(constraint6_0) + +#List of all constraints + +constraints = [constraint1, constraint2, constraint3_0, constraint3_1,# constraint4, #constraint4_0, constraint4_1, constraint4_2, + constraint6_0, constraint6_1]#, constraint7] + + +# ## Reset params + +# In[ ]: + + +param_values_dic = { + 'jpsi_m': jpsi_mass, + 'jpsi_s': jpsi_scale, + 'jpsi_p': jpsi_phase, + 'jpsi_w': jpsi_width, + 'psi2s_m': psi2s_mass, + 'psi2s_s': psi2s_scale, + 'psi2s_p': psi2s_phase, + 'psi2s_w': psi2s_width, + 'p3770_m': p3770_mass, + 'p3770_s': p3770_scale, + 'p3770_p': p3770_phase, + 'p3770_w': p3770_width, + 'p4040_m': p4040_mass, + 'p4040_s': p4040_scale, + 'p4040_p': p4040_phase, + 'p4040_w': p4040_width, + 'p4160_m': p4160_mass, + 'p4160_s': p4160_scale, + 'p4160_p': p4160_phase, + 'p4160_w': p4160_width, + 'p4415_m': p4415_mass, + 'p4415_s': p4415_scale, + 'p4415_p': p4415_phase, + 'p4415_w': p4415_width, + 'rho_m': rho_mass, + 'rho_s': rho_scale, + 'rho_p': rho_phase, + 'rho_w': rho_width, + 'omega_m': omega_mass, + 'omega_s': omega_scale, + 'omega_p': omega_phase, + 'omega_w': omega_width, + 'phi_m': phi_mass, + 'phi_s': phi_scale, + 'phi_p': phi_phase, + 'phi_w': phi_width, + 'Dstar_m': Dstar_mass, + 'DDstar_s': 0.0, + 'DDstar_p': 0.0, + 'D_m': D_mass, + 'Dbar_m': Dbar_mass, + 'Dbar_s': 0.0, + 'Dbar_p': 0.0, + 'tau_m': pdg['tau_M'], + 'Ctt': 0.0, + 'b0_0': 0.292, + 'b0_1': 0.281, + 'b0_2': 0.150, + 'bplus_0': 0.466, + 'bplus_1': -0.885, + 'bplus_2': -0.213, + 'bT_0': 0.460, + 'bT_1': -1.089, + 'bT_2': -1.114} + + +def reset_param_values(variation = 0.05): + for param in total_f_fit.get_dependents(): + if param.floating: + param.set_value(param_values_dic[param.name] + random.uniform(-1, 1) * param_values_dic[param.name]* variation) +# print(param.name) +# for param in totalf.get_dependents(): +# param.set_value() + + +# # Analysis + +# In[ ]: + + +# # zfit.run.numeric_checks = False + +# fitting_range = 'cut' +# total_BR = 1.7e-10 + 4.9e-10 + 2.5e-9 + 6.02e-5 + 4.97e-6 + 1.38e-9 + 4.2e-10 + 2.6e-9 + 6.1e-10 + 4.37e-7 +# cut_BR = 1.0 - (6.02e-5 + 4.97e-6)/total_BR + +# Ctt_list = [] +# Ctt_error_list = [] + +# nr_of_toys = 1 +# if fitting_range == 'cut': +# nevents = int(pdg["number_of_decays"]*cut_BR) +# else: +# nevents = int(pdg["number_of_decays"]) +# # nevents = pdg["number_of_decays"] +# event_stack = 1000000 +# # nevents *= 41 +# # zfit.settings.set_verbosity(10) +# calls = int(nevents/event_stack + 1) + +# total_samp = [] + +# start = time.time() + +# sampler = total_f.create_sampler(n=event_stack) + +# for toy in range(nr_of_toys): + +# ### Generate data + +# # clear_output(wait=True) + +# print("Toy {}: Generating data...".format(toy)) + +# dirName = 'data/zfit_toys/toy_{0}'.format(toy) + +# if not os.path.exists(dirName): +# os.mkdir(dirName) +# print("Directory " , dirName , " Created ") + +# reset_param_values() + +# if fitting_range == 'cut': + +# sampler.resample(n=nevents) +# s = sampler.unstack_x() +# sam = zfit.run(s) +# calls = 0 +# c = 1 + +# else: +# for call in range(calls): + +# sampler.resample(n=event_stack) +# s = sampler.unstack_x() +# sam = zfit.run(s) + +# c = call + 1 + +# with open("data/zfit_toys/toy_{0}/{1}.pkl".format(toy, call), "wb") as f: +# pkl.dump(sam, f, pkl.HIGHEST_PROTOCOL) + +# print("Toy {}: Data generation finished".format(toy)) + +# ### Load data + +# print("Toy {}: Loading data...".format(toy)) + +# if fitting_range == 'cut': + +# total_samp = sam + +# else: + +# for call in range(calls): +# with open(r"data/zfit_toys/toy_0/{}.pkl".format(call), "rb") as input_file: +# sam = pkl.load(input_file) +# total_samp = np.append(total_samp, sam) + +# total_samp = total_samp.astype('float64') + +# if fitting_range == 'full': + +# data = zfit.data.Data.from_numpy(array=total_samp[:int(nevents)], obs=obs) + +# print("Toy {}: Loading data finished".format(toy)) + +# ### Fit data + +# print("Toy {}: Fitting pdf...".format(toy)) + +# for param in total_f.get_dependents(): +# param.randomize() + +# nll = zfit.loss.UnbinnedNLL(model=total_f, data=data, fit_range = (x_min, x_max), constraints = constraints) + +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) +# # minimizer._use_tfgrad = False +# result = minimizer.minimize(nll) + +# print("Toy {}: Fitting finished".format(toy)) + +# print("Function minimum:", result.fmin) +# print("Hesse errors:", result.hesse()) + +# params = result.params +# Ctt_list.append(params[Ctt]['value']) +# Ctt_error_list.append(params[Ctt]['minuit_hesse']['error']) + +# #plotting the result + +# plotdirName = 'data/plots'.format(toy) + +# if not os.path.exists(plotdirName): +# os.mkdir(plotdirName) +# # print("Directory " , dirName , " Created ") + +# probs = total_f.pdf(test_q, norm_range=False) +# calcs_test = zfit.run(probs) +# plt.clf() +# plt.plot(test_q, calcs_test, label = 'pdf') +# plt.legend() +# plt.ylim(0.0, 6e-6) +# plt.savefig(plotdirName + '/toy_fit_full_range{}.png'.format(toy)) + +# print("Toy {0}/{1}".format(toy+1, nr_of_toys)) +# print("Time taken: {}".format(display_time(int(time.time() - start)))) +# print("Projected time left: {}".format(display_time(int((time.time() - start)/(c+calls*(toy))*((nr_of_toys-toy)*calls-c))))) + +# if fitting_range == 'cut': + +# _1 = np.where((total_samp >= x_min) & (total_samp <= (jpsi_mass - 60.))) + +# tot_sam_1 = total_samp[_1] + +# _2 = np.where((total_samp >= (jpsi_mass + 70.)) & (total_samp <= (psi2s_mass - 50.))) + +# tot_sam_2 = total_samp[_2] + +# _3 = np.where((total_samp >= (psi2s_mass + 50.)) & (total_samp <= x_max)) + +# tot_sam_3 = total_samp[_3] + +# tot_sam = np.append(tot_sam_1, tot_sam_2) +# tot_sam = np.append(tot_sam, tot_sam_3) + +# data = zfit.data.Data.from_numpy(array=tot_sam[:int(nevents)], obs=obs_fit) + +# print("Toy {}: Loading data finished".format(toy)) + +# ### Fit data + +# print("Toy {}: Fitting pdf...".format(toy)) + +# for param in total_f_fit.get_dependents(): +# param.randomize() + +# nll = zfit.loss.UnbinnedNLL(model=total_f_fit, data=data, constraints = constraints) + +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) +# # minimizer._use_tfgrad = False +# result = minimizer.minimize(nll) + +# print("Function minimum:", result.fmin) +# print("Hesse errors:", result.hesse()) + +# params = result.params + +# if result.converged: +# Ctt_list.append(params[Ctt]['value']) +# Ctt_error_list.append(params[Ctt]['minuit_hesse']['error']) + +# #plotting the result + +# plotdirName = 'data/plots'.format(toy) + +# if not os.path.exists(plotdirName): +# os.mkdir(plotdirName) +# # print("Directory " , dirName , " Created ") + +# plt.clf() +# plt.hist(tot_sam, bins = int((x_max-x_min)/7.), label = 'toy data') +# plt.savefig(plotdirName + '/toy_histo_cut_region{}.png'.format(toy)) + + +# probs = total_f_fit.pdf(test_q, norm_range=False) +# calcs_test = zfit.run(probs) +# plt.clf() +# plt.plot(test_q, calcs_test, label = 'pdf') +# plt.axvline(x=jpsi_mass-60.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.axvline(x=jpsi_mass+70.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.axvline(x=psi2s_mass-50.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.axvline(x=psi2s_mass+50.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.legend() +# plt.ylim(0.0, 1.5e-6) +# plt.savefig(plotdirName + '/toy_fit_cut_region{}.png'.format(toy)) + +# print("Toy {0}/{1}".format(toy+1, nr_of_toys)) +# print("Time taken: {}".format(display_time(int(time.time() - start)))) +# print("Projected time left: {}".format(display_time(int((time.time() - start)/(toy+1))*((nr_of_toys-toy-1))))) + + + +# In[ ]: + + +# with open("data/results/Ctt_list.pkl", "wb") as f: +# pkl.dump(Ctt_list, f, pkl.HIGHEST_PROTOCOL) +# with open("data/results/Ctt_error_list.pkl", "wb") as f: +# pkl.dump(Ctt_error_list, f, pkl.HIGHEST_PROTOCOL) + + +# In[ ]: + + +# print('{0}/{1} fits converged'.format(len(Ctt_list), nr_of_toys)) +# print('Mean Ctt value = {}'.format(np.mean(Ctt_list))) +# print('Mean Ctt error = {}'.format(np.mean(Ctt_error_list))) +# print('95 Sensitivy = {}'.format(((2*np.mean(Ctt_error_list))**2)*4.2/1000)) + + +# In[ ]: + + +# plt.hist(tot_sam, bins = int((x_max-x_min)/7.)) + +# plt.show() + +# # _ = np.where((total_samp >= x_min) & (total_samp <= (jpsi_mass - 50.))) + +# tot_sam.shape + + +# In[ ]: + + +# Ctt.floating = False + + +# In[ ]: + + +# zfit.run(nll.value()) + + +# In[ ]: + + +# result.fmin + + +# In[ ]: + + +# BR_steps = np.linspace(0.0, 1e-3, 11) +pull_dic = {} + +mi = 1e-4 +ma = 3e-3 +ste = 20 + +for param in total_f_fit.get_dependents(): + if param.floating: + pull_dic[param.name] = [] + for step in range(2*ste): + pull_dic[param.name].append([]) + + + +def save_pulls(step): + for param in total_f_fit.get_dependents(): + if param.floating: + pull_dic[param.name][step].append((params[param]['value'] - param_values_dic[param.name])/params[param]['minuit_hesse']['error']) + + + +# for key in pull_dic.keys(): +# print(np.shape(pull_dic[key])) +# save_pulls(New_step=True) +# params[Ctt]['value'] + + +# In[ ]: + + +# for param in total_f_fit.get_dependents(): +# if param.floating: +# print(param.name) + +# print(params[Ctt]) + + +# # CLS Code + +# In[ ]: + + +# zfit.run.numeric_checks = False + +load = False + +bo = True + +D_contribs = True + +if not D_contribs: + Dbar_s.floating = False + Dbar_p.floating = False + DDstar_s.floating = False + DDstar_p.floating = False + +bo_set = 1 + +fitting_range = 'cut' +total_BR = 1.7e-10 + 4.9e-10 + 2.5e-9 + 6.02e-5 + 4.97e-6 + 1.38e-9 + 4.2e-10 + 2.6e-9 + 6.1e-10 + 4.37e-7 +cut_BR = 1.0 - (6.02e-5 + 4.97e-6)/total_BR + +Ctt_list = [] +Ctt_error_list = [] + +nr_of_toys = 1 +nevents = int(pdg["number_of_decays"]*cut_BR) +# nevents = pdg["number_of_decays"] +event_stack = 1000000 +# nevents *= 41 +# zfit.settings.set_verbosity(10) + +# mi = 1e-4 +# ma = 3e-3 +# ste = 13 + +BR_steps = np.linspace(mi, ma, ste) + +BR_steps[0] = 0.0 + +print(BR_steps) + +Ctt_steps = np.sqrt(BR_steps/4.2*1000) + +print(Ctt_steps) + +# total_samp = [] + +start = time.time() + +Nll_list = [] + +sampler = total_f.create_sampler(n=nevents, fixed_params = False) +sampler.set_data_range(obs_fit) + +__ = -1 + +#----------------------------------------------------- + +if not load: + for Ctt_step in Ctt_steps: + + __ += 1 + + for i in range(2): + Ctt_list.append([]) + Ctt_error_list.append([]) + Nll_list.append([]) + + for param in total_f_fit.get_dependents(): + if param.floating: + pull_dic[param.name].append([]) + + for toy in range(nr_of_toys): + + newset = True + + while newset: + + for floaty in [True, False]: + Ctt.floating = floaty + + for bo_step in range(bo_set): + + print('Step: {0}/{1}'.format(int(__), ste)) + print('Current Ctt: {0}'.format(Ctt_step)) + print('Ctt floating: {0}'.format(floaty)) + + reset_param_values(variation = 0.0) + + if floaty: + print('Toy {0}/{1} - Fit {2}/{3}'.format(toy, nr_of_toys, bo_step, bo_set)) + Ctt.set_value(Ctt_step) + + else: + Ctt.set_value(0.0) + print('Toy {0}/{1} - Fit {2}/{3}'.format(toy, nr_of_toys, bo_step, bo_set)) + + if newset: + sampler.resample(n=nevents) + data = sampler + newset = False + + ### Fit data + + if floaty: + #plt.clf() + #plt.title('Ctt value: {:.2f}'.format(Ctt_step)) + #plt.hist(zfit.run(data), bins = int((x_max-x_min)/7), range = (x_min, x_max)) + #plt.savefig('data/CLs/plots/set_histo{}.png'.format(__)) + _step = 2*__ + else: + _step = 2*__+1 + + nll = zfit.loss.UnbinnedNLL(model=total_f_fit, data=data, constraints = constraints) + + minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) + # minimizer._use_tfgrad = False + result = minimizer.minimize(nll) + + print("Function minimum:", result.fmin) + print("Hesse errors:", result.hesse()) + + params = result.params + + if result.converged: + + save_pulls(step = _step) + + if floaty: + Nll_list[-2].append(result.fmin) + Ctt_list[-2].append(params[Ctt]['value']) + Ctt_error_list[-2].append(params[Ctt]['minuit_hesse']['error']) + + else: + Nll_list[-1].append(result.fmin) + Ctt_list[-1].append(0.0) + Ctt_error_list[-1].append(0.0) + + + else: + for _ in [1,2]: + del Nll_list[-_][toy*bo_set:] +# print(np.shape(Nll_list[-_])) + del Ctt_list[-_][toy*bo_set:] + del Ctt_error_list[-_][toy*bo_set:] + for param in total_f_fit.get_dependents(): + if param.floating: + del pull_dic[param.name][_step+1-_][toy*bo_set:] + newset = True + break + + if not result.converged: + break + + print() + print('Time taken: {}'.format(display_time(int(time.time()-start)))) + print('Estimated time left: {}'.format(display_time(int((time.time()-start)/(__+(toy+1)/nr_of_toys)*(ste-__-(nr_of_toys-toy-1)/nr_of_toys))))) + + +# In[ ]: + + +if load: + + phase_combi = '--' + + if D_contribs: + D_dir = 'D-True' + else: + D_dir = 'D-False' + + _dir = 'data/CLs/finished/f1d1/{}/{}/'.format(phase_combi, D_dir) + + jobs = os.listdir(_dir) + + First = True + +# print(jobs) + + for job in jobs: + + dirName = _dir + str(job) + '/data/CLs' + + if not os.path.exists("{}/{}-{}_{}s{}b{}t--CLs_Nll_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys)): +# print(job) + continue + + with open(r"{}/variab.pkl".format(dirName), "rb") as input_file: + variab = pkl.load(input_file) +# print(variab) + + ### sanity check: + if variab['mi'] != mi or variab['ma'] != ma or variab['ste'] != ste or bo_set != bo_set: + print('Fitting parameters of data dont equal the ones given -- Job {} skipped!'.format(job)) + + with open(r"{}/{}-{}_{}s{}b{}t--CLs_Nll_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _Nll_list = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s{}b{}t--Ctt_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _Ctt_list = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s{}b{}t--Ctt_error_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _Ctt_error_list = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s{}b{}t--pull_dic.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _pull_dic = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s--CLs_list.pkl".format(dirName, mi,ma,ste), "rb") as input_file: + _CLs_list = pkl.load(input_file) + + + if First: + Nll_list = _Nll_list + Ctt_list = _Ctt_list + Ctt_error_list = _Ctt_error_list + pull_dic = _pull_dic +# print(_pull_dic) + CLs_list = _CLs_list + First = False + else: + for step in range(2*ste): +# print(Nll_list[step], step) + Nll_list[step].extend(_Nll_list[step]) + Ctt_list[step].extend(_Ctt_list[step]) + Ctt_error_list[step].extend(_Ctt_error_list[step]) + for key in pull_dic.keys(): +# print(key, np.shape(pull_dic[key])) + pull_dic[key][step].extend(_pull_dic[key][step]) + for step in range(ste): + CLs_list[step].extend(_CLs_list[step]) + +# print('----------------------') + + +# In[ ]: + + +dirName = 'data/CLs' + +# if bo and not load: +# for s in range(2*ste): +# Nll_list[s] = [np.min(Nll_list[s])] + + +if not load: + + if not os.path.exists(dirName): + os.mkdir(dirName) + print("Directory " , dirName , " Created ") + + with open("{}/{}-{}_{}s{}b{}t--CLs_Nll_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(Nll_list, f, pkl.HIGHEST_PROTOCOL) + + with open("{}/{}-{}_{}s{}b{}t--Ctt_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(Ctt_list, f, pkl.HIGHEST_PROTOCOL) + + with open("{}/{}-{}_{}s{}b{}t--Ctt_error_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(Ctt_error_list, f, pkl.HIGHEST_PROTOCOL) + + with open("{}/{}-{}_{}s{}b{}t--pull_dic.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(pull_dic, f, pkl.HIGHEST_PROTOCOL) + + variab = {'mi': mi, + 'ma': ma, + 'ste': ste, + 'bo_set': bo_set, + 'nr_of_toys': nr_of_toys} + + with open("{}/variab.pkl".format(dirName), "wb") as f: + pkl.dump(variab, f, pkl.HIGHEST_PROTOCOL) + + CLs_values = [] + + toy_size = bo_set + + print(np.shape(Nll_list)) + print(Nll_list[0:1]) + + for step in range(ste): + CLs_values.append([]) + for toy in range(nr_of_toys): + float_min = np.min(Nll_list[2*step][toy*bo_set:(toy+1)*bo_set]) + fix_min = np.min(Nll_list[2*step+1][toy*bo_set:(toy+1)*bo_set]) + CLs_values[step].append(float_min-fix_min) + + + print(np.shape(CLs_values)) + + with open("{}/{}-{}_{}s--CLs_list.pkl".format(dirName, mi,ma,ste), "wb") as f: + pkl.dump(CLs_values, f, pkl.HIGHEST_PROTOCOL) + + +# In[ ]: + + +# print(variab['mi'] != mi) + + +# ## Plot + +# In[ ]: + + +l = [] + + +if load: + CLs_values = -1*np.array(CLs_list) + +if not os.path.exists('data/CLs/plots'): + os.mkdir('data/CLs/plots') + print("Directory " , 'data/CLs/plots' , " Created ") + +print(np.shape(CLs_values)) + +for step in range(1,ste): + plt.clf() + plt.title('Ctt value: {:.2f}'.format(Ctt_steps[step])) + plt.hist(CLs_values[0], bins = 150, range = (-25, 50), label = 'Ctt fixed to 0') + plt.hist(CLs_values[step], bins = 150, range = (-25, 50), label = 'Ctt floating') + plt.axvline(x=np.mean(CLs_values[0]),color='red', linewidth=1.0, linestyle = 'dotted') + plt.legend() + plt.savefig('data/CLs/plots/CLs-BR({:.1E}).png'.format(BR_steps[step])) + + l.append(len(np.where(np.array(CLs_values[step]) < np.mean(CLs_values[0]))[0])) + +for step in range(2*ste): + if step%2 == 0: + floaty = True + else: + floaty = False + for key in pull_dic.keys(): + if not os.path.exists('data/CLs/plots/{}'.format(key)): + os.mkdir('data/CLs/plots/{}'.format(key)) + plt.clf() + plt.title('Pull {} - Ctt value {:.2f} - floating {}'.format(key, Ctt_steps[int(step/2)], floaty)) + plt.hist(pull_dic[key][step], bins = 50, range = (-5,5)) + plt.xlabel('Pull') + plt.savefig('data/CLs/plots/{}/{:.2f}Ctt{}s{}f.png'.format(key, Ctt_steps[int(step/2)], step, floaty)) + + +# In[ ]: + + +for s in range(len(l)): + print('BR: {:.4f}'.format(BR_steps[s+1])) + print(2*l[s]/len(CLs_values[s])) + print() + + +# In[ ]: + + +# for step in range(2*ste): +# for key in pull_dic.keys(): +# print(pull_dic[key][step]) + + +# In[ ]: + + +# for param in total_f_fit.get_dependents(): +# if param.floating: +# print(params[param]['value']) + + +# In[ ]: + + +print(display_time(int(time.time()-start))) + + +# In[ ]: + + +# variab['mi'] =! mi + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + diff --git a/data/CLs/finished/f1d1/-+/D-True/2288027/__pycache__/helperfunctions.cpython-37.pyc b/data/CLs/finished/f1d1/-+/D-True/2288027/__pycache__/helperfunctions.cpython-37.pyc new file mode 100644 index 0000000..2ee71ca --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288027/__pycache__/helperfunctions.cpython-37.pyc Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288027/__pycache__/pdg_const1.cpython-37.pyc b/data/CLs/finished/f1d1/-+/D-True/2288027/__pycache__/pdg_const1.cpython-37.pyc new file mode 100644 index 0000000..8d0b03f --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288027/__pycache__/pdg_const1.cpython-37.pyc Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288027/data/CLs/0.0001-0.003_20s--CLs_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288027/data/CLs/0.0001-0.003_20s--CLs_list.pkl new file mode 100644 index 0000000..0953de6 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288027/data/CLs/0.0001-0.003_20s--CLs_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288027/data/CLs/0.0001-0.003_20s1b1t--CLs_Nll_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288027/data/CLs/0.0001-0.003_20s1b1t--CLs_Nll_list.pkl new file mode 100644 index 0000000..588501d --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288027/data/CLs/0.0001-0.003_20s1b1t--CLs_Nll_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288027/data/CLs/0.0001-0.003_20s1b1t--Ctt_error_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288027/data/CLs/0.0001-0.003_20s1b1t--Ctt_error_list.pkl new file mode 100644 index 0000000..71f869d --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288027/data/CLs/0.0001-0.003_20s1b1t--Ctt_error_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288027/data/CLs/0.0001-0.003_20s1b1t--Ctt_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288027/data/CLs/0.0001-0.003_20s1b1t--Ctt_list.pkl new file mode 100644 index 0000000..c183237 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288027/data/CLs/0.0001-0.003_20s1b1t--Ctt_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288027/data/CLs/0.0001-0.003_20s1b1t--pull_dic.pkl b/data/CLs/finished/f1d1/-+/D-True/2288027/data/CLs/0.0001-0.003_20s1b1t--pull_dic.pkl new file mode 100644 index 0000000..50c04e8 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288027/data/CLs/0.0001-0.003_20s1b1t--pull_dic.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288027/data/CLs/variab.pkl b/data/CLs/finished/f1d1/-+/D-True/2288027/data/CLs/variab.pkl new file mode 100644 index 0000000..bb90dc0 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288027/data/CLs/variab.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288027/helperfunctions.py b/data/CLs/finished/f1d1/-+/D-True/2288027/helperfunctions.py new file mode 100644 index 0000000..88e120f --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288027/helperfunctions.py @@ -0,0 +1,33 @@ +# some helperfunctions + +import matplotlib +matplotlib.use("agg") +import matplotlib.pyplot as plt + +#Dislpay time (e.g. while generating points) + +display_intervals = ( + ('w', 604800), # 60 * 60 * 24 * 7 + ('d', 86400), # 60 * 60 * 24 + ('h', 3600), # 60 * 60 + ('min', 60), + ('s', 1), + ) + +def display_time(seconds, granularity=2): + result = [] + + for name, count in display_intervals: + value = seconds // count + if value: + seconds -= value * count + if value == 1: + name = name.rstrip('s') + result.append("{} {}".format(value, name)) + return ', '.join(result[:granularity]) + +def prepare_plot(title): + plt.title(title) + plt.grid() + plt.legend(loc = 'best') + plt.xlabel("q") diff --git a/data/CLs/finished/f1d1/-+/D-True/2288027/pdg_const1.py b/data/CLs/finished/f1d1/-+/D-True/2288027/pdg_const1.py new file mode 100644 index 0000000..70b3f30 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288027/pdg_const1.py @@ -0,0 +1,226 @@ +pdg = { + + + ###Particle masses### + + "mbstar" : 5415.4, + "mbstar0" : 5711.0, + "B0_M" : 5279.5, + "Bs_M" : 5366.7, + "Bplus_M" : 5279.3, + "Lb_M" : 5619.4, + "D0_M" : 1864.8, + "Dst_M" : 2010, + "pi_M" : 139.6, + "Jpsi_M" : 3096.9, + "Psi2s_M" : 3685.6, + "kaon_M" : 493.7, + "Ks_M" : 497.6, + "phi_M" : 1019.5, + "rho_M" : 775.26, + "rho_width" : 149.1, + "omega_M" : 782.65, + "omega_width" : 8.49, + + "muon_M" : 105.7, + "tau_M": 1776.86, + + "squark_M" : 95.0, + "bquark_M" : 4180.0, + "cquark_M" : 1275.0, + + "Bplus_tau" : 1.638e-12, + + ###Wilson coefficients### + + "C1" : -0.257, + "C2" : 1.009, + "C3" : -0.005, + "C4" : -0.078, + + "C7eff" : -0.306, + "C9eff" : 4.211, + "C10eff" : -4.103, + +# "C7eff": 0.0, +# "C9eff": 0.0, +# "C10eff": 0.0, + + ###Other constants + + "GF" : 1.1663787e-5, + "alpha_ew" : 1.0/137.0, + "Vts" : 0.0394, + "Vtb" : 1.019, + "number_of_decays": 5404696, + + #Formfactor z coefficients + + #"b0" : [0.285, 0.19, -0.17], + #"bplus" : [0.437, -1.41, -2.5], + #"bT" : [0.440, -1.47, -2.7] + + "b0" : [0.292, 0.281, 0.150], + "bplus" : [0.466, -0.885, -0.213], + "bT" : [0.460, -1.089, -1.114], + + "NR_BR": 4.37e-7, + "NR_auc": 0.00133, + + #Resonances format(mass, width, phase, scale) + + # pre scaling + +# "rho": (775.26, 149.0, -0.35, 1.0), + +# "omega": (782.7, 8.5, 0.26, 1.0), + +# "phi": (1019.46, 4.25, 0.5, 1.0), + +# "jpsi": (3096.0, 0.09, -1.5, 2e-2), +# "jpsi_auc": 0.2126825758464027, + +# "psi2s": (3686.0, 0.3, -1.5, 3.14e-3), +# "psi2s_auc": 2.802257483178487e-10, + +# "p3770": (3773.0, 27.2, -2.13, 1.0e-3), + +# "p4040": (4039.0, 80.0, -2.52, 2.0), + +# "p4160": (4191.0, 70.0, -1.9, 2.2), + +# "p4415": (4421.0, 62.0, -2.52, 1.0), + + + # after scaling (Phase combination --) + + # + # "rho": (743.2, 149.0, -0.22, 1.05), + # + # "omega": (782.7, 8.5, 0.38, 6.8), + # + # "phi": (1013.5, 4.25, 0.62, 19.2), + # + # "jpsi": (3096.1, 0.09, 1.63, 9897.0), + # "jpsi_auc": 0.2126825758464027, + # "jpsi_phase_unc": 0.05, + # + # "psi2s": (3686.0, 0.3, 1.8, 1396.0), + # "psi2s_auc": 0.0151332263, + # "psi2s_phase_unc": 0.1, + # + # "p3770": (3773.0, 27.2, -2.95, 2.5), + # + # "p4040": (4039.0, 80.0, -2.75, 1.01), + # + # "p4160": (4191.0, 70.0, -2.28, 2.2), + # + # "p4415": (4421.0, 62.0, -2.31, 1.24), + + # Phase combination of paper ++ + +# "rho": (743.2, 149.0, -0.35, 1.05), + +# "omega": (782.7, 8.5, 0.26, 6.8), + +# "phi": (1013.5, 4.25, 0.47, 19.2), + +# "jpsi": (3096.1, 0.09, -1.66, 9897.0), +# "jpsi_auc": 0.2126825758464027, +# "jpsi_phase_unc": 0.05, + +# "psi2s": (3686.0, 0.3, -1.93, 1396.0), +# "psi2s_auc": 0.0151332263, +# "psi2s_phase_unc": 0.1, + +# "p3770": (3773.0, 27.2, -2.13, 2.5), + +# "p4040": (4039.0, 80.0, -2.52, 1.01), + +# "p4160": (4191.0, 70.0, -1.90, 2.2), + +# "p4415": (4421.0, 62.0, -2.52, 1.24), + + # Phase combination of paper +- + +# "rho": (743.2, 149.0, -0.26, 1.05), + +# "omega": (782.7, 8.5, 0.35, 6.8), + +# "phi": (1013.5, 4.25, 0.58, 19.2), + +# "jpsi": (3096.1, 0.09, 1.47, 9897.0), +# "jpsi_auc": 0.2126825758464027, +# "jpsi_phase_unc": 0.05, + +# "psi2s": (3686.0, 0.3, -2.21, 1396.0), +# "psi2s_auc": 0.0151332263, +# "psi2s_phase_unc": 0.1, + +# "p3770": (3773.0, 27.2, -2.140, 2.5), + +# "p4040": (4039.0, 80.0, -2.64, 1.01), + +# "p4160": (4191.0, 70.0, -2.11, 2.2), + +# "p4415": (4421.0, 62.0, -2.42, 1.24), + + # Phase combination of paper -+ + + "rho": (743.2, 149.0, -0.30, 1.05), + + "omega": (782.7, 8.5, 0.30, 6.8), + + "phi": (1013.5, 4.25, 0.51, 19.2), + + "jpsi": (3096.1, 0.09, -1.5, 9897.0), + "jpsi_auc": 0.2126825758464027, + "jpsi_phase_unc": 0.05, + + "psi2s": (3686.0, 0.3, 2.08, 1396.0), + "psi2s_auc": 0.0151332263, + "psi2s_phase_unc": 0.1, + + "p3770": (3773.0, 27.2, -2.89, 2.5), + + "p4040": (4039.0, 80.0, -2.69, 1.01), + + "p4160": (4191.0, 70.0, -2.13, 2.2), + + "p4415": (4421.0, 62.0, -2.43, 1.24), + + + # zeroing resonances + +# "rho": (775.26, 149.0, -0.35, 0.0), +# "omega": (782.7, 8.5, 0.26, 0.0), +# "phi": (1019.46, 4.25, 0.5, 0.0), +# "jpsi": (3096.0, 0.09, -1.5, 0.0), +# "psi2s": (3686.0, 0.3, -1.5, 0.0), +# "p3770": (3773.0, 27.2, -2.13, 0.0), +# "p4040": (4039.0, 80.0, -2.52, 0.0), +# "p4160": (4147.0, 22.0, -1.9, 0.0), +# "p4415": (4421.0, 62.0, -2.52, 0.0), + + # 2P contributions format(mass, amp, phase) + +# "D_bar": ( + + #general + + "rho_BR": 1.7e-10, + "omega_BR": 4.9e-10, + "phi_BR": 2.5e-9, + "jpsi_BR": 6.02e-5, + "psi2s_BR": 4.97e-6, + "p3770_BR": 1.38e-9, + "p4040_BR": 4.2e-10, + "p4160_BR": 2.6e-9, + "p4415_BR": 6.1e-10, + +# Estimates + "Dbar_scale": 1.46, #with phase = pi + + "DDstar_scale": 2.41, #with phase = pi + + } diff --git a/data/CLs/finished/f1d1/-+/D-True/2288027/raremodel-nb.py b/data/CLs/finished/f1d1/-+/D-True/2288027/raremodel-nb.py new file mode 100644 index 0000000..c326c9c --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288027/raremodel-nb.py @@ -0,0 +1,2152 @@ +#!/usr/bin/env python +# coding: utf-8 + +# # Import + +# In[ ]: + + +import os + +# os.environ["CUDA_VISIBLE_DEVICES"] = "-1" +import random +import numpy as np +from pdg_const1 import pdg +import matplotlib +import matplotlib.pyplot as plt +import pickle as pkl +import sys +import time +from helperfunctions import display_time, prepare_plot +import cmath as c +import scipy.integrate as integrate +from scipy.optimize import fminbound +from array import array as arr +import collections +from itertools import compress +import tensorflow as tf +import zfit +from zfit import ztf +# from IPython.display import clear_output +import os +import tensorflow_probability as tfp +tfd = tfp.distributions + + +# In[ ]: + + +# chunksize = 10000 +# zfit.run.chunking.active = True +# zfit.run.chunking.max_n_points = chunksize + + +# # Build model and graphs +# ## Create graphs + +# In[ ]: + + + + + +# In[ ]: + + +def formfactor(q2, subscript, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2): #returns real value + #check if subscript is viable + + if subscript != "0" and subscript != "+" and subscript != "T": + raise ValueError('Wrong subscript entered, choose either 0, + or T') + + #get constants + + mK = ztf.constant(pdg['Ks_M']) + mbstar0 = ztf.constant(pdg["mbstar0"]) + mbstar = ztf.constant(pdg["mbstar"]) + + + mmu = ztf.constant(pdg['muon_M']) + mb = ztf.constant(pdg['bquark_M']) + ms = ztf.constant(pdg['squark_M']) + mB = ztf.constant(pdg['Bplus_M']) + + #N comes from derivation in paper + + N = 3 + + #some helperfunctions + + tpos = (mB - mK)**2 + tzero = (mB + mK)*(ztf.sqrt(mB)-ztf.sqrt(mK))**2 + + z_oben = ztf.sqrt(tpos - q2) - ztf.sqrt(tpos - tzero) + z_unten = ztf.sqrt(tpos - q2) + ztf.sqrt(tpos - tzero) + z = tf.divide(z_oben, z_unten) + + #calculate f0 + + if subscript == "0": + prefactor = 1/(1 - q2/(mbstar0**2)) + _sum = 0 + b0 = [b0_0, b0_1, b0_2] + + for i in range(N): + _sum += b0[i]*(tf.pow(z,i)) + + return ztf.to_complex(prefactor * _sum) + + #calculate f+ or fT + + else: + prefactor = 1/(1 - q2/(mbstar**2)) + _sum = 0 + + if subscript == "T": + bT = [bT_0, bT_1, bT_2] + for i in range(N): + _sum += bT[i] * (tf.pow(z, i) - ((-1)**(i-N)) * (i/N) * tf.pow(z, N)) + else: + bplus = [bplus_0, bplus_1, bplus_2] + for i in range(N): + _sum += bplus[i] * (tf.pow(z, i) - ((-1)**(i-N)) * (i/N) * tf.pow(z, N)) + + return ztf.to_complex(prefactor * _sum) + +def resonance(q, _mass, width, phase, scale): + + q2 = tf.pow(q, 2) + + mmu = ztf.constant(pdg['muon_M']) + + p = 0.5 * ztf.sqrt(q2 - 4*(mmu**2)) + + p0 = 0.5 * ztf.sqrt(_mass**2 - 4*mmu**2) + + gamma_j = tf.divide(p, q) * _mass * width / p0 + + #Calculate the resonance + + _top = tf.complex(_mass * width, ztf.constant(0.0)) + + _bottom = tf.complex(_mass**2 - q2, -_mass*gamma_j) + + com = _top/_bottom + + #Rotate by the phase + + r = ztf.to_complex(scale*tf.abs(com)) + + _phase = tf.angle(com) + + _phase += phase + + com = r * tf.exp(tf.complex(ztf.constant(0.0), _phase)) + + return com + + +def axiv_nonres(q, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2): + + GF = ztf.constant(pdg['GF']) + alpha_ew = ztf.constant(pdg['alpha_ew']) + Vtb = ztf.constant(pdg['Vtb']) + Vts = ztf.constant(pdg['Vts']) + C10eff = ztf.constant(pdg['C10eff']) + + mmu = ztf.constant(pdg['muon_M']) + mb = ztf.constant(pdg['bquark_M']) + ms = ztf.constant(pdg['squark_M']) + mK = ztf.constant(pdg['Ks_M']) + mB = ztf.constant(pdg['Bplus_M']) + + q2 = tf.pow(q, 2) + + #Some helperfunctions + + beta = 1. - 4. * mmu**2. / q2 + + kabs = ztf.sqrt(mB**2. + tf.pow(q2, 2)/mB**2. + mK**4./mB**2. - 2. * (mB**2. * mK**2. + mK**2. * q2 + mB**2. * q2) / mB**2.) + + #prefactor in front of whole bracket + + prefactor1 = GF**2. *alpha_ew**2. * (tf.abs(Vtb*Vts))**2. * kabs * beta / (128. * np.pi**5.) + + #left term in bracket + + bracket_left = 2./3. * tf.pow(kabs,2) * tf.pow(beta,2) * tf.pow(tf.abs(ztf.to_complex(C10eff)*formfactor(q2, "+", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2)),2) + + #middle term in bracket + + _top = 4. * mmu**2. * (mB**2. - mK**2.) * (mB**2. - mK**2.) + + _under = q2 * mB**2. + + bracket_middle = _top/_under *tf.pow(tf.abs(ztf.to_complex(C10eff) * formfactor(q2, "0", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2)), 2) + + #Note sqrt(q2) comes from derivation as we use q2 and plot q + + return prefactor1 * (bracket_left + bracket_middle) * 2 * q + +def vec(q, funcs, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2): + + q2 = tf.pow(q, 2) + + GF = ztf.constant(pdg['GF']) + alpha_ew = ztf.constant(pdg['alpha_ew']) + Vtb = ztf.constant(pdg['Vtb']) + Vts = ztf.constant(pdg['Vts']) + C7eff = ztf.constant(pdg['C7eff']) + + mmu = ztf.constant(pdg['muon_M']) + mb = ztf.constant(pdg['bquark_M']) + ms = ztf.constant(pdg['squark_M']) + mK = ztf.constant(pdg['Ks_M']) + mB = ztf.constant(pdg['Bplus_M']) + + #Some helperfunctions + + beta = 1. - 4. * mmu**2. / q2 + + kabs = ztf.sqrt(mB**2. + tf.pow(q2, 2)/mB**2. + mK**4./mB**2. - 2 * (mB**2 * mK**2 + mK**2 * q2 + mB**2 * q2) / mB**2) + + #prefactor in front of whole bracket + + prefactor1 = GF**2. *alpha_ew**2. * (tf.abs(Vtb*Vts))**2 * kabs * beta / (128. * np.pi**5.) + + #right term in bracket + + prefactor2 = tf.pow(kabs,2) * (1. - 1./3. * beta) + + abs_bracket = tf.pow(tf.abs(c9eff(q, funcs) * formfactor(q2, "+", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + ztf.to_complex(2.0 * C7eff * (mb + ms)/(mB + mK)) * formfactor(q2, "T", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2)),2) + + bracket_right = prefactor2 * abs_bracket + + #Note sqrt(q2) comes from derivation as we use q2 and plot q + + return prefactor1 * bracket_right * 2 * q + +def c9eff(q, funcs): + + C9eff_nr = ztf.to_complex(ztf.constant(pdg['C9eff'])) + + c9 = C9eff_nr + funcs + + return c9 + + +# In[ ]: + + +def G(y): + + def inner_rect_bracket(q): + return tf.log(ztf.to_complex((1+tf.sqrt(q))/(1-tf.sqrt(q)))-tf.complex(ztf.constant(0), -1*ztf.constant(np.pi))) + + def inner_right(q): + return ztf.to_complex(2 * tf.atan(1/tf.sqrt(tf.math.real(-q)))) + + big_bracket = tf.where(tf.math.real(y) > ztf.constant(0.0), inner_rect_bracket(y), inner_right(y)) + + return ztf.to_complex(tf.sqrt(tf.abs(y))) * big_bracket + +def h_S(m, q): + + return ztf.to_complex(2) - G(ztf.to_complex(1) - ztf.to_complex(4*tf.pow(m, 2)) / ztf.to_complex(tf.pow(q, 2))) + +def h_P(m, q): + + return ztf.to_complex(2/3) + (ztf.to_complex(1) - ztf.to_complex(4*tf.pow(m, 2)) / ztf.to_complex(tf.pow(q, 2))) * h_S(m,q) + +def two_p_ccbar(mD, m_D_bar, m_D_star, q): + + + #Load constants + nu_D_bar = ztf.to_complex(pdg["nu_D_bar"]) + nu_D = ztf.to_complex(pdg["nu_D"]) + nu_D_star = ztf.to_complex(pdg["nu_D_star"]) + + phase_D_bar = ztf.to_complex(pdg["phase_D_bar"]) + phase_D = ztf.to_complex(pdg["phase_D"]) + phase_D_star = ztf.to_complex(pdg["phase_D_star"]) + + #Calculation + left_part = nu_D_bar * tf.exp(tf.complex(ztf.constant(0.0), phase_D_bar)) * h_S(m_D_bar, q) + + right_part_D = nu_D * tf.exp(tf.complex(ztf.constant(0.0), phase_D)) * h_P(m_D, q) + + right_part_D_star = nu_D_star * tf.exp(tf.complex(ztf.constant(0.0), phase_D_star)) * h_P(m_D_star, q) + + return left_part + right_part_D + right_part_D_star + + +# ## Build pdf + +# In[ ]: + + +class total_pdf_cut(zfit.pdf.ZPDF): + _N_OBS = 1 # dimension, can be omitted + _PARAMS = ['b0_0', 'b0_1', 'b0_2', + 'bplus_0', 'bplus_1', 'bplus_2', + 'bT_0', 'bT_1', 'bT_2', + 'rho_mass', 'rho_scale', 'rho_phase', 'rho_width', + 'jpsi_mass', 'jpsi_scale', 'jpsi_phase', 'jpsi_width', + 'psi2s_mass', 'psi2s_scale', 'psi2s_phase', 'psi2s_width', + 'p3770_mass', 'p3770_scale', 'p3770_phase', 'p3770_width', + 'p4040_mass', 'p4040_scale', 'p4040_phase', 'p4040_width', + 'p4160_mass', 'p4160_scale', 'p4160_phase', 'p4160_width', + 'p4415_mass', 'p4415_scale', 'p4415_phase', 'p4415_width', + 'omega_mass', 'omega_scale', 'omega_phase', 'omega_width', + 'phi_mass', 'phi_scale', 'phi_phase', 'phi_width', + 'Dbar_mass', 'Dbar_scale', 'Dbar_phase', + 'Dstar_mass', 'DDstar_scale', 'DDstar_phase', 'D_mass', + 'tau_mass', 'C_tt'] +# the name of the parameters + + def _unnormalized_pdf(self, x): + + x = x.unstack_x() + + b0 = [self.params['b0_0'], self.params['b0_1'], self.params['b0_2']] + bplus = [self.params['bplus_0'], self.params['bplus_1'], self.params['bplus_2']] + bT = [self.params['bT_0'], self.params['bT_1'], self.params['bT_2']] + + def rho_res(q): + return resonance(q, _mass = self.params['rho_mass'], scale = self.params['rho_scale'], + phase = self.params['rho_phase'], width = self.params['rho_width']) + + def omega_res(q): + return resonance(q, _mass = self.params['omega_mass'], scale = self.params['omega_scale'], + phase = self.params['omega_phase'], width = self.params['omega_width']) + + def phi_res(q): + return resonance(q, _mass = self.params['phi_mass'], scale = self.params['phi_scale'], + phase = self.params['phi_phase'], width = self.params['phi_width']) + + def jpsi_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['jpsi_mass'], 2)) * resonance(q, _mass = self.params['jpsi_mass'], + scale = self.params['jpsi_scale'], + phase = self.params['jpsi_phase'], + width = self.params['jpsi_width']) + def psi2s_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['psi2s_mass'], 2)) * resonance(q, _mass = self.params['psi2s_mass'], + scale = self.params['psi2s_scale'], + phase = self.params['psi2s_phase'], + width = self.params['psi2s_width']) + def p3770_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p3770_mass'], 2)) * resonance(q, _mass = self.params['p3770_mass'], + scale = self.params['p3770_scale'], + phase = self.params['p3770_phase'], + width = self.params['p3770_width']) + + def p4040_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4040_mass'], 2)) * resonance(q, _mass = self.params['p4040_mass'], + scale = self.params['p4040_scale'], + phase = self.params['p4040_phase'], + width = self.params['p4040_width']) + + def p4160_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4160_mass'], 2)) * resonance(q, _mass = self.params['p4160_mass'], + scale = self.params['p4160_scale'], + phase = self.params['p4160_phase'], + width = self.params['p4160_width']) + + def p4415_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4415_mass'], 2)) * resonance(q, _mass = self.params['p4415_mass'], + scale = self.params['p4415_scale'], + phase = self.params['p4415_phase'], + width = self.params['p4415_width']) + + def P2_D(q): + Dbar_contrib = ztf.to_complex(self.params['Dbar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['Dbar_phase']))*ztf.to_complex(h_S(self.params['Dbar_mass'], q)) + DDstar_contrib = ztf.to_complex(self.params['DDstar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['DDstar_phase']))*(ztf.to_complex(h_P(self.params['Dstar_mass'], q)) + ztf.to_complex(h_P(self.params['D_mass'], q))) + return Dbar_contrib + DDstar_contrib + + def ttau_cusp(q): + return ztf.to_complex(self.params['C_tt'])*(ztf.to_complex((h_S(self.params['tau_mass'], q))) - ztf.to_complex(h_P(self.params['tau_mass'], q))) + + + funcs = rho_res(x) + omega_res(x) + phi_res(x) + jpsi_res(x) + psi2s_res(x) + p3770_res(x) + p4040_res(x)+ p4160_res(x) + p4415_res(x) + P2_D(x) + ttau_cusp(x) + + vec_f = vec(x, funcs, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + axiv_nr = axiv_nonres(x, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + tot = vec_f + axiv_nr + + #Cut out jpsi and psi2s + + tot = tf.where(tf.math.logical_or(x < ztf.constant(jpsi_mass-60.), x > ztf.constant(jpsi_mass+70.)), tot, 0.0*tot) + + tot = tf.where(tf.math.logical_or(x < ztf.constant(psi2s_mass-50.), x > ztf.constant(psi2s_mass+50.)), tot, 0.0*tot) + + return tot + +class total_pdf_full(zfit.pdf.ZPDF): + _N_OBS = 1 # dimension, can be omitted + _PARAMS = ['b0_0', 'b0_1', 'b0_2', + 'bplus_0', 'bplus_1', 'bplus_2', + 'bT_0', 'bT_1', 'bT_2', + 'rho_mass', 'rho_scale', 'rho_phase', 'rho_width', + 'jpsi_mass', 'jpsi_scale', 'jpsi_phase', 'jpsi_width', + 'psi2s_mass', 'psi2s_scale', 'psi2s_phase', 'psi2s_width', + 'p3770_mass', 'p3770_scale', 'p3770_phase', 'p3770_width', + 'p4040_mass', 'p4040_scale', 'p4040_phase', 'p4040_width', + 'p4160_mass', 'p4160_scale', 'p4160_phase', 'p4160_width', + 'p4415_mass', 'p4415_scale', 'p4415_phase', 'p4415_width', + 'omega_mass', 'omega_scale', 'omega_phase', 'omega_width', + 'phi_mass', 'phi_scale', 'phi_phase', 'phi_width', + 'Dbar_mass', 'Dbar_scale', 'Dbar_phase', + 'Dstar_mass', 'DDstar_scale', 'DDstar_phase', 'D_mass', + 'tau_mass', 'C_tt'] +# the name of the parameters + + def _unnormalized_pdf(self, x): + + x = x.unstack_x() + + b0 = [self.params['b0_0'], self.params['b0_1'], self.params['b0_2']] + bplus = [self.params['bplus_0'], self.params['bplus_1'], self.params['bplus_2']] + bT = [self.params['bT_0'], self.params['bT_1'], self.params['bT_2']] + + def rho_res(q): + return resonance(q, _mass = self.params['rho_mass'], scale = self.params['rho_scale'], + phase = self.params['rho_phase'], width = self.params['rho_width']) + + def omega_res(q): + return resonance(q, _mass = self.params['omega_mass'], scale = self.params['omega_scale'], + phase = self.params['omega_phase'], width = self.params['omega_width']) + + def phi_res(q): + return resonance(q, _mass = self.params['phi_mass'], scale = self.params['phi_scale'], + phase = self.params['phi_phase'], width = self.params['phi_width']) + + def jpsi_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['jpsi_mass'], 2)) * resonance(q, _mass = self.params['jpsi_mass'], + scale = self.params['jpsi_scale'], + phase = self.params['jpsi_phase'], + width = self.params['jpsi_width']) + def psi2s_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['psi2s_mass'], 2)) * resonance(q, _mass = self.params['psi2s_mass'], + scale = self.params['psi2s_scale'], + phase = self.params['psi2s_phase'], + width = self.params['psi2s_width']) + def p3770_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p3770_mass'], 2)) * resonance(q, _mass = self.params['p3770_mass'], + scale = self.params['p3770_scale'], + phase = self.params['p3770_phase'], + width = self.params['p3770_width']) + + def p4040_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4040_mass'], 2)) * resonance(q, _mass = self.params['p4040_mass'], + scale = self.params['p4040_scale'], + phase = self.params['p4040_phase'], + width = self.params['p4040_width']) + + def p4160_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4160_mass'], 2)) * resonance(q, _mass = self.params['p4160_mass'], + scale = self.params['p4160_scale'], + phase = self.params['p4160_phase'], + width = self.params['p4160_width']) + + def p4415_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4415_mass'], 2)) * resonance(q, _mass = self.params['p4415_mass'], + scale = self.params['p4415_scale'], + phase = self.params['p4415_phase'], + width = self.params['p4415_width']) + + def P2_D(q): + Dbar_contrib = ztf.to_complex(self.params['Dbar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['Dbar_phase']))*ztf.to_complex(h_S(self.params['Dbar_mass'], q)) + DDstar_contrib = ztf.to_complex(self.params['DDstar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['DDstar_phase']))*(ztf.to_complex(h_P(self.params['Dstar_mass'], q)) + ztf.to_complex(h_P(self.params['D_mass'], q))) + return Dbar_contrib + DDstar_contrib + + def ttau_cusp(q): + return ztf.to_complex(self.params['C_tt'])*(ztf.to_complex((h_S(self.params['tau_mass'], q))) - ztf.to_complex(h_P(self.params['tau_mass'], q))) + + + funcs = rho_res(x) + omega_res(x) + phi_res(x) + jpsi_res(x) + psi2s_res(x) + p3770_res(x) + p4040_res(x)+ p4160_res(x) + p4415_res(x) + P2_D(x) + ttau_cusp(x) + + vec_f = vec(x, funcs, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + axiv_nr = axiv_nonres(x, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + tot = vec_f + axiv_nr + + #Cut out jpsi and psi2s + +# tot = tf.where(tf.math.logical_or(x < ztf.constant(jpsi_mass-60.), x > ztf.constant(jpsi_mass+70.)), tot, 0.0*tot) + +# tot = tf.where(tf.math.logical_or(x < ztf.constant(psi2s_mass-50.), x > ztf.constant(psi2s_mass+50.)), tot, 0.0*tot) + + return tot + + +# ## Setup parameters + +# In[ ]: + + +# formfactors + +b0_0 = zfit.Parameter("b0_0", ztf.constant(0.292), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +b0_1 = zfit.Parameter("b0_1", ztf.constant(0.281), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +b0_2 = zfit.Parameter("b0_2", ztf.constant(0.150), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) + +bplus_0 = zfit.Parameter("bplus_0", ztf.constant(0.466), lower_limit = -2.0, upper_limit= 2.0) +bplus_1 = zfit.Parameter("bplus_1", ztf.constant(-0.885), lower_limit = -2.0, upper_limit= 2.0) +bplus_2 = zfit.Parameter("bplus_2", ztf.constant(-0.213), lower_limit = -2.0, upper_limit= 2.0) + +bT_0 = zfit.Parameter("bT_0", ztf.constant(0.460), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +bT_1 = zfit.Parameter("bT_1", ztf.constant(-1.089), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +bT_2 = zfit.Parameter("bT_2", ztf.constant(-1.114), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) + + +#rho + +rho_mass, rho_width, rho_phase, rho_scale = pdg["rho"] + +rho_m = zfit.Parameter("rho_m", ztf.constant(rho_mass), floating = False) #lower_limit = rho_mass - rho_width, upper_limit = rho_mass + rho_width) +rho_w = zfit.Parameter("rho_w", ztf.constant(rho_width), floating = False) +rho_p = zfit.Parameter("rho_p", ztf.constant(rho_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +rho_s = zfit.Parameter("rho_s", ztf.constant(rho_scale), lower_limit=rho_scale-np.sqrt(rho_scale), upper_limit=rho_scale+np.sqrt(rho_scale)) + +#omega + +omega_mass, omega_width, omega_phase, omega_scale = pdg["omega"] + +omega_m = zfit.Parameter("omega_m", ztf.constant(omega_mass), floating = False) +omega_w = zfit.Parameter("omega_w", ztf.constant(omega_width), floating = False) +omega_p = zfit.Parameter("omega_p", ztf.constant(omega_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +omega_s = zfit.Parameter("omega_s", ztf.constant(omega_scale), lower_limit=omega_scale-np.sqrt(omega_scale), upper_limit=omega_scale+np.sqrt(omega_scale)) + + +#phi + +phi_mass, phi_width, phi_phase, phi_scale = pdg["phi"] + +phi_m = zfit.Parameter("phi_m", ztf.constant(phi_mass), floating = False) +phi_w = zfit.Parameter("phi_w", ztf.constant(phi_width), floating = False) +phi_p = zfit.Parameter("phi_p", ztf.constant(phi_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +phi_s = zfit.Parameter("phi_s", ztf.constant(phi_scale), lower_limit=phi_scale-np.sqrt(phi_scale), upper_limit=phi_scale+np.sqrt(phi_scale)) + +#jpsi + +jpsi_mass, jpsi_width, jpsi_phase, jpsi_scale = pdg["jpsi"] + +jpsi_m = zfit.Parameter("jpsi_m", ztf.constant(jpsi_mass), floating = False) +jpsi_w = zfit.Parameter("jpsi_w", ztf.constant(jpsi_width), floating = False) +jpsi_p = zfit.Parameter("jpsi_p", ztf.constant(jpsi_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +jpsi_s = zfit.Parameter("jpsi_s", ztf.constant(jpsi_scale), floating = False) #, lower_limit=jpsi_scale-np.sqrt(jpsi_scale), upper_limit=jpsi_scale+np.sqrt(jpsi_scale)) + +#psi2s + +psi2s_mass, psi2s_width, psi2s_phase, psi2s_scale = pdg["psi2s"] + +psi2s_m = zfit.Parameter("psi2s_m", ztf.constant(psi2s_mass), floating = False) +psi2s_w = zfit.Parameter("psi2s_w", ztf.constant(psi2s_width), floating = False) +psi2s_p = zfit.Parameter("psi2s_p", ztf.constant(psi2s_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +psi2s_s = zfit.Parameter("psi2s_s", ztf.constant(psi2s_scale), floating = False) #, lower_limit=psi2s_scale-np.sqrt(psi2s_scale), upper_limit=psi2s_scale+np.sqrt(psi2s_scale)) + +#psi(3770) + +p3770_mass, p3770_width, p3770_phase, p3770_scale = pdg["p3770"] + +p3770_m = zfit.Parameter("p3770_m", ztf.constant(p3770_mass), floating = False) +p3770_w = zfit.Parameter("p3770_w", ztf.constant(p3770_width), floating = False) +p3770_p = zfit.Parameter("p3770_p", ztf.constant(p3770_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p3770_s = zfit.Parameter("p3770_s", ztf.constant(p3770_scale), lower_limit=p3770_scale-np.sqrt(p3770_scale), upper_limit=p3770_scale+np.sqrt(p3770_scale)) + +#psi(4040) + +p4040_mass, p4040_width, p4040_phase, p4040_scale = pdg["p4040"] + +p4040_m = zfit.Parameter("p4040_m", ztf.constant(p4040_mass), floating = False) +p4040_w = zfit.Parameter("p4040_w", ztf.constant(p4040_width), floating = False) +p4040_p = zfit.Parameter("p4040_p", ztf.constant(p4040_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p4040_s = zfit.Parameter("p4040_s", ztf.constant(p4040_scale), lower_limit=p4040_scale-np.sqrt(p4040_scale), upper_limit=p4040_scale+np.sqrt(p4040_scale)) + +#psi(4160) + +p4160_mass, p4160_width, p4160_phase, p4160_scale = pdg["p4160"] + +p4160_m = zfit.Parameter("p4160_m", ztf.constant(p4160_mass), floating = False) +p4160_w = zfit.Parameter("p4160_w", ztf.constant(p4160_width), floating = False) +p4160_p = zfit.Parameter("p4160_p", ztf.constant(p4160_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p4160_s = zfit.Parameter("p4160_s", ztf.constant(p4160_scale), lower_limit=p4160_scale-np.sqrt(p4160_scale), upper_limit=p4160_scale+np.sqrt(p4160_scale)) + +#psi(4415) + +p4415_mass, p4415_width, p4415_phase, p4415_scale = pdg["p4415"] + +p4415_m = zfit.Parameter("p4415_m", ztf.constant(p4415_mass), floating = False) +p4415_w = zfit.Parameter("p4415_w", ztf.constant(p4415_width), floating = False) +p4415_p = zfit.Parameter("p4415_p", ztf.constant(p4415_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p4415_s = zfit.Parameter("p4415_s", ztf.constant(p4415_scale), lower_limit=p4415_scale-np.sqrt(p4415_scale), upper_limit=p4415_scale+np.sqrt(p4415_scale)) + + +# ## Dynamic generation of 2 particle contribution + +# In[ ]: + + +m_c = 1300 + +Dbar_phase = 0.0 +DDstar_phase = 0.0 +Dstar_mass = pdg['Dst_M'] +Dbar_mass = pdg['D0_M'] +D_mass = pdg['D0_M'] + +Dbar_s = zfit.Parameter("Dbar_s", ztf.constant(0.0), lower_limit=-0.3, upper_limit=0.3) +Dbar_m = zfit.Parameter("Dbar_m", ztf.constant(Dbar_mass), floating = False) +Dbar_p = zfit.Parameter("Dbar_p", ztf.constant(Dbar_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi)#, floating = False) +DDstar_s = zfit.Parameter("DDstar_s", ztf.constant(0.0), lower_limit=-0.3, upper_limit=0.3)#, floating = False) +Dstar_m = zfit.Parameter("Dstar_m", ztf.constant(Dstar_mass), floating = False) +D_m = zfit.Parameter("D_m", ztf.constant(D_mass), floating = False) +DDstar_p = zfit.Parameter("DDstar_p", ztf.constant(DDstar_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi)#, floating = False) + + +# ## Tau parameters + +# In[ ]: + + +tau_m = zfit.Parameter("tau_m", ztf.constant(pdg['tau_M']), floating = False) +Ctt = zfit.Parameter("Ctt", ztf.constant(0.0), lower_limit=-2.5, upper_limit=2.5) + + +# ## Load data + +# In[ ]: + + +x_min = 2*pdg['muon_M'] +x_max = (pdg["Bplus_M"]-pdg["Ks_M"]-0.1) + +# # Full spectrum + +obs_toy = zfit.Space('q', limits = (x_min, x_max)) + +# Jpsi and Psi2s cut out + +obs1 = zfit.Space('q', limits = (x_min, jpsi_mass - 60.)) +obs2 = zfit.Space('q', limits = (jpsi_mass + 70., psi2s_mass - 50.)) +obs3 = zfit.Space('q', limits = (psi2s_mass + 50., x_max)) + +obs_fit = obs1 + obs2 + obs3 + +# with open(r"./data/slim_points/slim_points_toy_0_range({0}-{1}).pkl".format(int(x_min), int(x_max)), "rb") as input_file: +# part_set = pkl.load(input_file) + +# x_part = part_set['x_part'] + +# x_part = x_part.astype('float64') + +# data = zfit.data.Data.from_numpy(array=x_part, obs=obs) + + +# ## Setup pdf + +# In[ ]: + + +total_f = total_pdf_cut(obs=obs_toy, jpsi_mass = jpsi_m, jpsi_scale = jpsi_s, jpsi_phase = jpsi_p, jpsi_width = jpsi_w, + psi2s_mass = psi2s_m, psi2s_scale = psi2s_s, psi2s_phase = psi2s_p, psi2s_width = psi2s_w, + p3770_mass = p3770_m, p3770_scale = p3770_s, p3770_phase = p3770_p, p3770_width = p3770_w, + p4040_mass = p4040_m, p4040_scale = p4040_s, p4040_phase = p4040_p, p4040_width = p4040_w, + p4160_mass = p4160_m, p4160_scale = p4160_s, p4160_phase = p4160_p, p4160_width = p4160_w, + p4415_mass = p4415_m, p4415_scale = p4415_s, p4415_phase = p4415_p, p4415_width = p4415_w, + rho_mass = rho_m, rho_scale = rho_s, rho_phase = rho_p, rho_width = rho_w, + omega_mass = omega_m, omega_scale = omega_s, omega_phase = omega_p, omega_width = omega_w, + phi_mass = phi_m, phi_scale = phi_s, phi_phase = phi_p, phi_width = phi_w, + Dstar_mass = Dstar_m, DDstar_scale = DDstar_s, DDstar_phase = DDstar_p, D_mass = D_m, + Dbar_mass = Dbar_m, Dbar_scale = Dbar_s, Dbar_phase = Dbar_p, + tau_mass = tau_m, C_tt = Ctt, b0_0 = b0_0, b0_1 = b0_1, b0_2 = b0_2, + bplus_0 = bplus_0, bplus_1 = bplus_1, bplus_2 = bplus_2, + bT_0 = bT_0, bT_1 = bT_1, bT_2 = bT_2) + +total_f_fit = total_pdf_full(obs=obs_fit, jpsi_mass = jpsi_m, jpsi_scale = jpsi_s, jpsi_phase = jpsi_p, jpsi_width = jpsi_w, + psi2s_mass = psi2s_m, psi2s_scale = psi2s_s, psi2s_phase = psi2s_p, psi2s_width = psi2s_w, + p3770_mass = p3770_m, p3770_scale = p3770_s, p3770_phase = p3770_p, p3770_width = p3770_w, + p4040_mass = p4040_m, p4040_scale = p4040_s, p4040_phase = p4040_p, p4040_width = p4040_w, + p4160_mass = p4160_m, p4160_scale = p4160_s, p4160_phase = p4160_p, p4160_width = p4160_w, + p4415_mass = p4415_m, p4415_scale = p4415_s, p4415_phase = p4415_p, p4415_width = p4415_w, + rho_mass = rho_m, rho_scale = rho_s, rho_phase = rho_p, rho_width = rho_w, + omega_mass = omega_m, omega_scale = omega_s, omega_phase = omega_p, omega_width = omega_w, + phi_mass = phi_m, phi_scale = phi_s, phi_phase = phi_p, phi_width = phi_w, + Dstar_mass = Dstar_m, DDstar_scale = DDstar_s, DDstar_phase = DDstar_p, D_mass = D_m, + Dbar_mass = Dbar_m, Dbar_scale = Dbar_s, Dbar_phase = Dbar_p, + tau_mass = tau_m, C_tt = Ctt, b0_0 = b0_0, b0_1 = b0_1, b0_2 = b0_2, + bplus_0 = bplus_0, bplus_1 = bplus_1, bplus_2 = bplus_2, + bT_0 = bT_0, bT_1 = bT_1, bT_2 = bT_2) + +# print(total_pdf.obs) + +# print(calcs_test) + +# for param in total_f.get_dependents(): +# print(zfit.run(param)) + + +# In[ ]: + + +# total_f_fit.normalization(obs_fit) + + +# ## Test if graphs actually work and compute values + +# In[ ]: + + +# def total_test_tf(xq): + +# def jpsi_res(q): +# return resonance(q, jpsi_m, jpsi_s, jpsi_p, jpsi_w) + +# def psi2s_res(q): +# return resonance(q, psi2s_m, psi2s_s, psi2s_p, psi2s_w) + +# def cusp(q): +# return bifur_gauss(q, cusp_m, sig_L, sig_R, cusp_s) + +# funcs = jpsi_res(xq) + psi2s_res(xq) + cusp(xq) + +# vec_f = vec(xq, funcs) + +# axiv_nr = axiv_nonres(xq) + +# tot = vec_f + axiv_nr + +# return tot + +# def jpsi_res(q): +# return resonance(q, jpsi_m, jpsi_s, jpsi_p, jpsi_w) + +# calcs = zfit.run(total_test_tf(x_part)) + + + +test_q = np.linspace(x_min, x_max, int(2e6)) + +probs = total_f_fit.pdf(test_q, norm_range=False) + +calcs_test = zfit.run(probs) + +Ctt.set_value(0.5) + +calcs_test1 = zfit.run(probs) + +Ctt.set_value(0.0) + +Dbar_s.set_value(0.3) + +DDstar_s.set_value(0.3) + +calcs_test2 = zfit.run(probs) +# res_y = zfit.run(jpsi_res(test_q)) +# b0 = [b0_0, b0_1, b0_2] +# bplus = [bplus_0, bplus_1, bplus_2] +# bT = [bT_0, bT_1, bT_2] +# f0_y = zfit.run(tf.math.real(formfactor(test_q,"0", b0, bplus, bT))) +# fplus_y = zfit.run(tf.math.real(formfactor(test_q,"+", b0, bplus, bT))) +# fT_y = zfit.run(tf.math.real(formfactor(test_q,"T", b0, bplus, bT))) + + +# In[ ]: + + +plt.clf() +# plt.plot(x_part, calcs, '.') +plt.plot(test_q, calcs_test, label = 'pdf (Ctt = 0.0)') +plt.plot(test_q, calcs_test1, label = 'pdf (Ctt = 0.5)') +plt.plot(test_q, calcs_test2, label = 'pdf (D-contribs = 0.3)') +# plt.plot(test_q, f0_y, label = '0') +# plt.plot(test_q, fT_y, label = 'T') +# plt.plot(test_q, fplus_y, label = '+') +# plt.plot(test_q, res_y, label = 'res') +plt.legend() +plt.ylim(0.0, 1.5e-6) +# plt.yscale('log') +# plt.xlim(770, 785) +plt.savefig('test.png') +# print(jpsi_width) + + +# In[ ]: + + + + +# probs = mixture.prob(test_q) +# probs_np = zfit.run(probs) +# probs_np *= np.max(calcs_test) / np.max(probs_np) +# plt.figure() +# plt.semilogy(test_q, probs_np,label="importance sampling") +# plt.semilogy(test_q, calcs_test, label = 'pdf') + + +# In[ ]: + + +# 0.213/(0.00133+0.213+0.015) + + +# ## Adjust scaling of different parts + +# In[ ]: + + +total_f.update_integration_options(draws_per_dim=2000000, mc_sampler=None) +# inte = total_f.integrate(limits = (950., 1050.), norm_range=False) +# inte_fl = zfit.run(inte) +# print(inte_fl/4500) +# print(pdg["jpsi_BR"]/pdg["NR_BR"], inte_fl*pdg["psi2s_auc"]/pdg["NR_auc"]) + + +# In[ ]: + + +# # print("jpsi:", inte_fl) +# # print("Increase am by factor:", np.sqrt(pdg["jpsi_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) +# # print("New amp:", pdg["jpsi"][3]*np.sqrt(pdg["jpsi_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) + +# # print("psi2s:", inte_fl) +# # print("Increase am by factor:", np.sqrt(pdg["psi2s_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) +# # print("New amp:", pdg["psi2s"][3]*np.sqrt(pdg["psi2s_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) + +# name = "phi" + +# print(name+":", inte_fl) +# print("Increase am by factor:", np.sqrt(pdg[name+"_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) +# print("New amp:", pdg[name][0]*np.sqrt(pdg[name+"_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) + + +# print(x_min) +# print(x_max) +# # total_f.update_integration_options(draws_per_dim=2000000, mc_sampler=None) +# total_f.update_integration_options(mc_sampler=lambda dim, num_results, +# dtype: tf.random_uniform(maxval=1., shape=(num_results, dim), dtype=dtype), +# draws_per_dim=1000000) +# # _ = [] + +# # for i in range(10): + +# # inte = total_f.integrate(limits = (x_min, x_max)) +# # inte_fl = zfit.run(inte) +# # print(inte_fl) +# # _.append(inte_fl) + +# # print("mean:", np.mean(_)) + +# _ = time.time() + +# inte = total_f.integrate(limits = (x_min, x_max)) +# inte_fl = zfit.run(inte) +# print(inte_fl) +# print("Time taken: {}".format(display_time(int(time.time() - _)))) + +# print(pdg['NR_BR']/pdg['NR_auc']*inte_fl) +# print(0.25**2*4.2/1000) + + +# # Sampling +# ## Mixture distribution for sampling + +# In[ ]: + + + + +# print(list_of_borders[:9]) +# print(list_of_borders[-9:]) + + +class UniformSampleAndWeights(zfit.util.execution.SessionHolderMixin): + def __call__(self, limits, dtype, n_to_produce): + # n_to_produce = tf.cast(n_to_produce, dtype=tf.int32) + low, high = limits.limit1d + low = tf.cast(low, dtype=dtype) + high = tf.cast(high, dtype=dtype) +# uniform = tfd.Uniform(low=low, high=high) +# uniformjpsi = tfd.Uniform(low=tf.constant(3080, dtype=dtype), high=tf.constant(3112, dtype=dtype)) +# uniformpsi2s = tfd.Uniform(low=tf.constant(3670, dtype=dtype), high=tf.constant(3702, dtype=dtype)) + +# list_of_borders = [] +# _p = [] +# splits = 10 + +# _ = np.linspace(x_min, x_max, splits) + +# for i in range(splits): +# list_of_borders.append(tf.constant(_[i], dtype=dtype)) +# _p.append(tf.constant(1/splits, dtype=dtype)) + +# mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=_p[:(splits-1)]), +# components_distribution=tfd.Uniform(low=list_of_borders[:(splits-1)], +# high=list_of_borders[-(splits-1):])) + mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=[tf.constant(0.05, dtype=dtype), + tf.constant(0.93, dtype=dtype), + tf.constant(0.05, dtype=dtype), + tf.constant(0.065, dtype=dtype), + tf.constant(0.04, dtype=dtype), + tf.constant(0.05, dtype=dtype)]), + components_distribution=tfd.Uniform(low=[tf.constant(x_min, dtype=dtype), + tf.constant(3090, dtype=dtype), + tf.constant(3681, dtype=dtype), + tf.constant(3070, dtype=dtype), + tf.constant(1000, dtype=dtype), + tf.constant(3660, dtype=dtype)], + high=[tf.constant(x_max, dtype=dtype), + tf.constant(3102, dtype=dtype), + tf.constant(3691, dtype=dtype), + tf.constant(3110, dtype=dtype), + tf.constant(1040, dtype=dtype), + tf.constant(3710, dtype=dtype)])) +# dtype = tf.float64 +# mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=[tf.constant(0.04, dtype=dtype), +# tf.constant(0.90, dtype=dtype), +# tf.constant(0.02, dtype=dtype), +# tf.constant(0.07, dtype=dtype), +# tf.constant(0.02, dtype=dtype)]), +# components_distribution=tfd.Uniform(low=[tf.constant(x_min, dtype=dtype), +# tf.constant(3089, dtype=dtype), +# tf.constant(3103, dtype=dtype), +# tf.constant(3681, dtype=dtype), +# tf.constant(3691, dtype=dtype)], +# high=[tf.constant(3089, dtype=dtype), +# tf.constant(3103, dtype=dtype), +# tf.constant(3681, dtype=dtype), +# tf.constant(3691, dtype=dtype), +# tf.constant(x_max, dtype=dtype)])) +# mixture = tfd.Uniform(tf.constant(x_min, dtype=dtype), tf.constant(x_max, dtype=dtype)) +# sample = tf.random.uniform((n_to_produce, 1), dtype=dtype) + sample = mixture.sample((n_to_produce, 1)) +# sample = tf.random.uniform((n_to_produce, 1), dtype=dtype) + weights = mixture.prob(sample)[:,0] +# weights = tf.broadcast_to(tf.constant(1., dtype=dtype), shape=(n_to_produce,)) + # sample = tf.expand_dims(sample, axis=-1) +# print(sample, weights) + +# weights = tf.ones(shape=(n_to_produce,), dtype=dtype) + weights_max = None + thresholds = tf.random_uniform(shape=(n_to_produce,), dtype=dtype) + return sample, thresholds, weights, weights_max, n_to_produce + + +# In[ ]: + + +# total_f._sample_and_weights = UniformSampleAndWeights + + +# In[ ]: + + +# 0.00133/(0.00133+0.213+0.015)*(x_max-3750)/(x_max-x_min) + + +# In[ ]: + + +# zfit.settings.set_verbosity(10) + + +# In[ ]: + + +# # zfit.run.numeric_checks = False + +# nr_of_toys = 1 +# nevents = int(pdg["number_of_decays"]) +# nevents = pdg["number_of_decays"] +# event_stack = 1000000 +# # zfit.settings.set_verbosity(10) +# calls = int(nevents/event_stack + 1) + +# total_samp = [] + +# start = time.time() + +# sampler = total_f.create_sampler(n=event_stack) + +# for toy in range(nr_of_toys): + +# dirName = 'data/zfit_toys/toy_{0}'.format(toy) + +# if not os.path.exists(dirName): +# os.mkdir(dirName) +# print("Directory " , dirName , " Created ") + +# for call in range(calls): + +# sampler.resample(n=event_stack) +# s = sampler.unstack_x() +# sam = zfit.run(s) +# # clear_output(wait=True) + +# c = call + 1 + +# print("{0}/{1} of Toy {2}/{3}".format(c, calls, toy+1, nr_of_toys)) +# print("Time taken: {}".format(display_time(int(time.time() - start)))) +# print("Projected time left: {}".format(display_time(int((time.time() - start)/(c+calls*(toy))*((nr_of_toys-toy)*calls-c))))) + +# with open("data/zfit_toys/toy_{0}/{1}.pkl".format(toy, call), "wb") as f: +# pkl.dump(sam, f, pkl.HIGHEST_PROTOCOL) + + +# In[ ]: + + +# with open(r"data/zfit_toys/toy_0/0.pkl", "rb") as input_file: +# sam = pkl.load(input_file) +# print(sam[:10]) + +# with open(r"data/zfit_toys/toy_0/1.pkl", "rb") as input_file: +# sam2 = pkl.load(input_file) +# print(sam2[:10]) + +# print(np.sum(sam-sam2)) + + +# In[ ]: + + +# print("Time to generate full toy: {} s".format(int(time.time()-start))) + +# total_samp = [] + +# for call in range(calls): +# with open(r"data/zfit_toys/toy_0/{}.pkl".format(call), "rb") as input_file: +# sam = pkl.load(input_file) +# total_samp = np.append(total_samp, sam) + +# total_samp = total_samp.astype('float64') + +# data2 = zfit.data.Data.from_numpy(array=total_samp[:int(nevents)], obs=obs) + +# data3 = zfit.data.Data.from_numpy(array=total_samp, obs=obs) + +# print(total_samp[:nevents].shape) + + +# In[ ]: + + +# plt.clf() + +# bins = int((x_max-x_min)/7) + +# # calcs = zfit.run(total_test_tf(samp)) +# print(total_samp[:nevents].shape) + +# plt.hist(total_samp[:nevents], bins = bins, range = (x_min,x_max), label = 'data') +# # plt.plot(test_q, calcs_test*nevents , label = 'pdf') + +# # plt.plot(sam, calcs, '.') +# # plt.plot(test_q, calcs_test) +# # plt.yscale('log') +# plt.ylim(0, 200) +# # plt.xlim(3080, 3110) + +# plt.legend() + +# plt.savefig('test2.png') + + +# In[ ]: + + +# sampler = total_f.create_sampler(n=nevents) +# nll = zfit.loss.UnbinnedNLL(model=total_f, data=sampler, fit_range = (x_min, x_max)) + +# # for param in pdf.get_dependents(): +# # param.set_value(initial_value) + +# sampler.resample(n=nevents) + +# # Randomise initial values +# # for param in pdf.get_dependents(): +# # param.set_value(random value here) + +# # Minimise the NLL +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 10) +# minimum = minimizer.minimize(nll) + + +# In[ ]: + + +# jpsi_width + + +# In[ ]: + + +# plt.hist(sample, weights=1 / prob(sample)) + + +# # Fitting + +# In[ ]: + + +# start = time.time() + +# for param in total_f.get_dependents(): +# param.randomize() + +# # for param in total_f.get_dependents(): +# # print(zfit.run(param)) + +# nll = zfit.loss.UnbinnedNLL(model=total_f, data=data2, fit_range = (x_min, x_max)) + +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) +# # minimizer._use_tfgrad = False +# result = minimizer.minimize(nll) + +# # param_errors = result.error() + +# # for var, errors in param_errors.items(): +# # print('{}: ^{{+{}}}_{{{}}}'.format(var.name, errors['upper'], errors['lower'])) + +# print("Function minimum:", result.fmin) +# # print("Results:", result.params) +# print("Hesse errors:", result.hesse()) + + +# In[ ]: + + +# print("Time taken for fitting: {}".format(display_time(int(time.time()-start)))) + +# # probs = total_f.pdf(test_q) + +# calcs_test = zfit.run(probs) +# res_y = zfit.run(jpsi_res(test_q)) + + +# In[ ]: + + +# plt.clf() +# # plt.plot(x_part, calcs, '.') +# plt.plot(test_q, calcs_test, label = 'pdf') +# # plt.plot(test_q, res_y, label = 'res') +# plt.legend() +# plt.ylim(0.0, 10e-6) +# # plt.yscale('log') +# # plt.xlim(3080, 3110) +# plt.savefig('test3.png') +# # print(jpsi_width) + + +# In[ ]: + + +# _tot = 4.37e-7+6.02e-5+4.97e-6 +# _probs = [] +# _probs.append(6.02e-5/_tot) +# _probs.append(4.97e-6/_tot) +# _probs.append(4.37e-7/_tot) +# print(_probs) + + +# In[ ]: + + +# dtype = 'float64' +# # mixture = tfd.Uniform(tf.constant(x_min, dtype=dtype), tf.constant(x_max, dtype=dtype)) +# mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=[tf.constant(0.007, dtype=dtype), +# tf.constant(0.917, dtype=dtype), +# tf.constant(0.076, dtype=dtype)]), +# components_distribution=tfd.Uniform(low=[tf.constant(x_min, dtype=dtype), +# tf.constant(3080, dtype=dtype), +# tf.constant(3670, dtype=dtype)], +# high=[tf.constant(x_max, dtype=dtype), +# tf.constant(3112, dtype=dtype), +# tf.constant(3702, dtype=dtype)])) +# # for i in range(10): +# # print(zfit.run(mixture.prob(mixture.sample((10, 1))))) + + +# In[ ]: + + +# print((zfit.run(jpsi_p)%(2*np.pi))/np.pi) +# print((zfit.run(psi2s_p)%(2*np.pi))/np.pi) + + +# In[ ]: + + +# def jpsi_res(q): +# return resonance(q, _mass = jpsi_mass, scale = jpsi_scale, +# phase = jpsi_phase, width = jpsi_width) + +# def psi2s_res(q): +# return resonance(q, _mass = psi2s_mass, scale = psi2s_scale, +# phase = psi2s_phase, width = psi2s_width) + +# def p3770_res(q): +# return resonance(q, _mass = p3770_mass, scale = p3770_scale, +# phase = p3770_phase, width = p3770_width) + +# def p4040_res(q): +# return resonance(q, _mass = p4040_mass, scale = p4040_scale, +# phase = p4040_phase, width = p4040_width) + +# def p4160_res(q): +# return resonance(q, _mass = p4160_mass, scale = p4160_scale, +# phase = p4160_phase, width = p4160_width) + +# def p4415_res(q): +# return resonance(q, _mass = p4415_mass, scale = p4415_scale, +# phase = p4415_phase, width = p4415_width) + + +# In[ ]: + + +# 0.15**2*4.2/1000 +# result.hesse() + + +# ## Constraints + +# In[ ]: + + +# 1. Constraint - Real part of sum of Psi contrib and D contribs + +sum_list = [] + +sum_list.append(ztf.to_complex(jpsi_s) * tf.exp(tf.complex(ztf.constant(0.0), jpsi_p)) * ztf.to_complex(jpsi_w / (tf.pow(jpsi_m,3)))) +sum_list.append(ztf.to_complex(psi2s_s) * tf.exp(tf.complex(ztf.constant(0.0), psi2s_p)) * ztf.to_complex(psi2s_w / (tf.pow(psi2s_m,3)))) +sum_list.append(ztf.to_complex(p3770_s) * tf.exp(tf.complex(ztf.constant(0.0), p3770_p)) * ztf.to_complex(p3770_w / (tf.pow(p3770_m,3)))) +sum_list.append(ztf.to_complex(p4040_s) * tf.exp(tf.complex(ztf.constant(0.0), p4040_p)) * ztf.to_complex(p4040_w / (tf.pow(p4040_m,3)))) +sum_list.append(ztf.to_complex(p4160_s) * tf.exp(tf.complex(ztf.constant(0.0), p4160_p)) * ztf.to_complex(p4160_w / (tf.pow(p4160_m,3)))) +sum_list.append(ztf.to_complex(p4415_s) * tf.exp(tf.complex(ztf.constant(0.0), p4415_p)) * ztf.to_complex(p4415_w / (tf.pow(p4415_m,3)))) +sum_list.append(ztf.to_complex(DDstar_s) * tf.exp(tf.complex(ztf.constant(0.0), DDstar_p)) * (ztf.to_complex(1.0 / (10.0*tf.pow(Dstar_m,2)) + 1.0 / (10.0*tf.pow(D_m,2))))) +sum_list.append(ztf.to_complex(Dbar_s) * tf.exp(tf.complex(ztf.constant(0.0), Dbar_p)) * ztf.to_complex(1.0 / (6.0*tf.pow(Dbar_m,2)))) + +sum_ru_1 = ztf.to_complex(ztf.constant(0.0)) + +for part in sum_list: + sum_ru_1 += part + +sum_1 = tf.math.real(sum_ru_1) +# constraint1 = zfit.constraint.GaussianConstraint(params = sum_1, mu = ztf.constant(1.7*10**-8), +# sigma = ztf.constant(2.2*10**-8)) + +constraint1 = tf.pow((sum_1-ztf.constant(1.7*10**-8))/ztf.constant(2.2*10**-8),2)/ztf.constant(2.) + +# 2. Constraint - Abs. of sum of Psi contribs and D contribs + +sum_2 = tf.abs(sum_ru_1) +constraint2 = tf.cond(tf.greater_equal(sum_2, 5.0e-8), lambda: 100000., lambda: 0.) + +# 3. Constraint - Maximum eta of D contribs + +constraint3_0 = tf.cond(tf.greater_equal(tf.abs(Dbar_s), 0.2), lambda: 100000., lambda: 0.) + +constraint3_1 = tf.cond(tf.greater_equal(tf.abs(DDstar_s), 0.2), lambda: 100000., lambda: 0.) + +# 4. Constraint - Formfactor multivariant gaussian covariance fplus + +Cov_matrix = [[ztf.constant( 1.), ztf.constant( 0.45), ztf.constant( 0.19), ztf.constant(0.857), ztf.constant(0.598), ztf.constant(0.531), ztf.constant(0.752), ztf.constant(0.229), ztf.constant(0,117)], + [ztf.constant( 0.45), ztf.constant( 1.), ztf.constant(0.677), ztf.constant(0.708), ztf.constant(0.958), ztf.constant(0.927), ztf.constant(0.227), ztf.constant(0.443), ztf.constant(0.287)], + [ztf.constant( 0.19), ztf.constant(0.677), ztf.constant( 1.), ztf.constant(0.595), ztf.constant(0.770), ztf.constant(0.819),ztf.constant(-0.023), ztf.constant( 0.07), ztf.constant(0.196)], + [ztf.constant(0.857), ztf.constant(0.708), ztf.constant(0.595), ztf.constant( 1.), ztf.constant( 0.83), ztf.constant(0.766), ztf.constant(0.582), ztf.constant(0.237), ztf.constant(0.192)], + [ztf.constant(0.598), ztf.constant(0.958), ztf.constant(0.770), ztf.constant( 0.83), ztf.constant( 1.), ztf.constant(0.973), ztf.constant(0.324), ztf.constant(0.372), ztf.constant(0.272)], + [ztf.constant(0.531), ztf.constant(0.927), ztf.constant(0.819), ztf.constant(0.766), ztf.constant(0.973), ztf.constant( 1.), ztf.constant(0.268), ztf.constant(0.332), ztf.constant(0.269)], + [ztf.constant(0.752), ztf.constant(0.227),ztf.constant(-0.023), ztf.constant(0.582), ztf.constant(0.324), ztf.constant(0.268), ztf.constant( 1.), ztf.constant( 0.59), ztf.constant(0.515)], + [ztf.constant(0.229), ztf.constant(0.443), ztf.constant( 0.07), ztf.constant(0.237), ztf.constant(0.372), ztf.constant(0.332), ztf.constant( 0.59), ztf.constant( 1.), ztf.constant(0.897)], + [ztf.constant(0.117), ztf.constant(0.287), ztf.constant(0.196), ztf.constant(0.192), ztf.constant(0.272), ztf.constant(0.269), ztf.constant(0.515), ztf.constant(0.897), ztf.constant( 1.)]] + +def triGauss(val1,val2,val3,m = Cov_matrix): + + mean1 = ztf.constant(0.466) + mean2 = ztf.constant(-0.885) + mean3 = ztf.constant(-0.213) + sigma1 = ztf.constant(0.014) + sigma2 = ztf.constant(0.128) + sigma3 = ztf.constant(0.548) + x1 = (val1-mean1)/sigma1 + x2 = (val2-mean2)/sigma2 + x3 = (val3-mean3)/sigma3 + rho12 = m[0][1] + rho13 = m[0][2] + rho23 = m[1][2] + w = x1*x1*(rho23*rho23-1) + x2*x2*(rho13*rho13-1)+x3*x3*(rho12*rho12-1)+2*(x1*x2*(rho12-rho13*rho23)+x1*x3*(rho13-rho12*rho23)+x2*x3*(rho23-rho12*rho13)) + d = 2*(rho12*rho12+rho13*rho13+rho23*rho23-2*rho12*rho13*rho23-1) + + fcn = -w/d + chisq = -2*fcn + return chisq + +constraint4 = triGauss(bplus_0, bplus_1, bplus_2) + +# mean1 = ztf.constant(0.466) +# mean2 = ztf.constant(-0.885) +# mean3 = ztf.constant(-0.213) +# sigma1 = ztf.constant(0.014) +# sigma2 = ztf.constant(0.128) +# sigma3 = ztf.constant(0.548) +# constraint4_0 = tf.pow((bplus_0-mean1)/sigma1,2)/ztf.constant(2.) +# constraint4_1 = tf.pow((bplus_1-mean2)/sigma2,2)/ztf.constant(2.) +# constraint4_2 = tf.pow((bplus_2-mean3)/sigma3,2)/ztf.constant(2.) + +# 5. Constraint - Abs. of sum of light contribs + +sum_list_5 = [] + +sum_list_5.append(rho_s*rho_w/rho_m) +sum_list_5.append(omega_s*omega_w/omega_m) +sum_list_5.append(phi_s*phi_w/phi_m) + + +sum_ru_5 = ztf.constant(0.0) + +for part in sum_list_5: + sum_ru_5 += part + +constraint5 = tf.cond(tf.greater_equal(tf.abs(sum_ru_5), ztf.constant(0.02)), lambda: 100000., lambda: 0.) + +# 6. Constraint on phases of Jpsi and Psi2s for cut out fit + + +# constraint6_0 = zfit.constraint.GaussianConstraint(params = jpsi_p, mu = ztf.constant(pdg["jpsi_phase_unc"]), +# sigma = ztf.constant(jpsi_phase)) +# constraint6_1 = zfit.constraint.GaussianConstraint(params = psi2s_p, mu = ztf.constant(pdg["psi2s_phase_unc"]), +# sigma = ztf.constant(psi2s_phase)) + +constraint6_0 = tf.pow((jpsi_p-ztf.constant(jpsi_phase))/ztf.constant(pdg["jpsi_phase_unc"]),2)/ztf.constant(2.) +constraint6_1 = tf.pow((psi2s_p-ztf.constant(psi2s_phase))/ztf.constant(pdg["psi2s_phase_unc"]),2)/ztf.constant(2.) + +# 7. Constraint on Ctt with higher limits + +constraint7 = tf.cond(tf.greater_equal(Ctt*Ctt, 0.25), lambda: 100000., lambda: 0.) + +constraint7dtype = tf.float64 + +# zfit.run(constraint6_0) + +# ztf.convert_to_tensor(constraint6_0) + +#List of all constraints + +constraints = [constraint1, constraint2, constraint3_0, constraint3_1,# constraint4, #constraint4_0, constraint4_1, constraint4_2, + constraint6_0, constraint6_1]#, constraint7] + + +# ## Reset params + +# In[ ]: + + +param_values_dic = { + 'jpsi_m': jpsi_mass, + 'jpsi_s': jpsi_scale, + 'jpsi_p': jpsi_phase, + 'jpsi_w': jpsi_width, + 'psi2s_m': psi2s_mass, + 'psi2s_s': psi2s_scale, + 'psi2s_p': psi2s_phase, + 'psi2s_w': psi2s_width, + 'p3770_m': p3770_mass, + 'p3770_s': p3770_scale, + 'p3770_p': p3770_phase, + 'p3770_w': p3770_width, + 'p4040_m': p4040_mass, + 'p4040_s': p4040_scale, + 'p4040_p': p4040_phase, + 'p4040_w': p4040_width, + 'p4160_m': p4160_mass, + 'p4160_s': p4160_scale, + 'p4160_p': p4160_phase, + 'p4160_w': p4160_width, + 'p4415_m': p4415_mass, + 'p4415_s': p4415_scale, + 'p4415_p': p4415_phase, + 'p4415_w': p4415_width, + 'rho_m': rho_mass, + 'rho_s': rho_scale, + 'rho_p': rho_phase, + 'rho_w': rho_width, + 'omega_m': omega_mass, + 'omega_s': omega_scale, + 'omega_p': omega_phase, + 'omega_w': omega_width, + 'phi_m': phi_mass, + 'phi_s': phi_scale, + 'phi_p': phi_phase, + 'phi_w': phi_width, + 'Dstar_m': Dstar_mass, + 'DDstar_s': 0.0, + 'DDstar_p': 0.0, + 'D_m': D_mass, + 'Dbar_m': Dbar_mass, + 'Dbar_s': 0.0, + 'Dbar_p': 0.0, + 'tau_m': pdg['tau_M'], + 'Ctt': 0.0, + 'b0_0': 0.292, + 'b0_1': 0.281, + 'b0_2': 0.150, + 'bplus_0': 0.466, + 'bplus_1': -0.885, + 'bplus_2': -0.213, + 'bT_0': 0.460, + 'bT_1': -1.089, + 'bT_2': -1.114} + + +def reset_param_values(variation = 0.05): + for param in total_f_fit.get_dependents(): + if param.floating: + param.set_value(param_values_dic[param.name] + random.uniform(-1, 1) * param_values_dic[param.name]* variation) +# print(param.name) +# for param in totalf.get_dependents(): +# param.set_value() + + +# # Analysis + +# In[ ]: + + +# # zfit.run.numeric_checks = False + +# fitting_range = 'cut' +# total_BR = 1.7e-10 + 4.9e-10 + 2.5e-9 + 6.02e-5 + 4.97e-6 + 1.38e-9 + 4.2e-10 + 2.6e-9 + 6.1e-10 + 4.37e-7 +# cut_BR = 1.0 - (6.02e-5 + 4.97e-6)/total_BR + +# Ctt_list = [] +# Ctt_error_list = [] + +# nr_of_toys = 1 +# if fitting_range == 'cut': +# nevents = int(pdg["number_of_decays"]*cut_BR) +# else: +# nevents = int(pdg["number_of_decays"]) +# # nevents = pdg["number_of_decays"] +# event_stack = 1000000 +# # nevents *= 41 +# # zfit.settings.set_verbosity(10) +# calls = int(nevents/event_stack + 1) + +# total_samp = [] + +# start = time.time() + +# sampler = total_f.create_sampler(n=event_stack) + +# for toy in range(nr_of_toys): + +# ### Generate data + +# # clear_output(wait=True) + +# print("Toy {}: Generating data...".format(toy)) + +# dirName = 'data/zfit_toys/toy_{0}'.format(toy) + +# if not os.path.exists(dirName): +# os.mkdir(dirName) +# print("Directory " , dirName , " Created ") + +# reset_param_values() + +# if fitting_range == 'cut': + +# sampler.resample(n=nevents) +# s = sampler.unstack_x() +# sam = zfit.run(s) +# calls = 0 +# c = 1 + +# else: +# for call in range(calls): + +# sampler.resample(n=event_stack) +# s = sampler.unstack_x() +# sam = zfit.run(s) + +# c = call + 1 + +# with open("data/zfit_toys/toy_{0}/{1}.pkl".format(toy, call), "wb") as f: +# pkl.dump(sam, f, pkl.HIGHEST_PROTOCOL) + +# print("Toy {}: Data generation finished".format(toy)) + +# ### Load data + +# print("Toy {}: Loading data...".format(toy)) + +# if fitting_range == 'cut': + +# total_samp = sam + +# else: + +# for call in range(calls): +# with open(r"data/zfit_toys/toy_0/{}.pkl".format(call), "rb") as input_file: +# sam = pkl.load(input_file) +# total_samp = np.append(total_samp, sam) + +# total_samp = total_samp.astype('float64') + +# if fitting_range == 'full': + +# data = zfit.data.Data.from_numpy(array=total_samp[:int(nevents)], obs=obs) + +# print("Toy {}: Loading data finished".format(toy)) + +# ### Fit data + +# print("Toy {}: Fitting pdf...".format(toy)) + +# for param in total_f.get_dependents(): +# param.randomize() + +# nll = zfit.loss.UnbinnedNLL(model=total_f, data=data, fit_range = (x_min, x_max), constraints = constraints) + +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) +# # minimizer._use_tfgrad = False +# result = minimizer.minimize(nll) + +# print("Toy {}: Fitting finished".format(toy)) + +# print("Function minimum:", result.fmin) +# print("Hesse errors:", result.hesse()) + +# params = result.params +# Ctt_list.append(params[Ctt]['value']) +# Ctt_error_list.append(params[Ctt]['minuit_hesse']['error']) + +# #plotting the result + +# plotdirName = 'data/plots'.format(toy) + +# if not os.path.exists(plotdirName): +# os.mkdir(plotdirName) +# # print("Directory " , dirName , " Created ") + +# probs = total_f.pdf(test_q, norm_range=False) +# calcs_test = zfit.run(probs) +# plt.clf() +# plt.plot(test_q, calcs_test, label = 'pdf') +# plt.legend() +# plt.ylim(0.0, 6e-6) +# plt.savefig(plotdirName + '/toy_fit_full_range{}.png'.format(toy)) + +# print("Toy {0}/{1}".format(toy+1, nr_of_toys)) +# print("Time taken: {}".format(display_time(int(time.time() - start)))) +# print("Projected time left: {}".format(display_time(int((time.time() - start)/(c+calls*(toy))*((nr_of_toys-toy)*calls-c))))) + +# if fitting_range == 'cut': + +# _1 = np.where((total_samp >= x_min) & (total_samp <= (jpsi_mass - 60.))) + +# tot_sam_1 = total_samp[_1] + +# _2 = np.where((total_samp >= (jpsi_mass + 70.)) & (total_samp <= (psi2s_mass - 50.))) + +# tot_sam_2 = total_samp[_2] + +# _3 = np.where((total_samp >= (psi2s_mass + 50.)) & (total_samp <= x_max)) + +# tot_sam_3 = total_samp[_3] + +# tot_sam = np.append(tot_sam_1, tot_sam_2) +# tot_sam = np.append(tot_sam, tot_sam_3) + +# data = zfit.data.Data.from_numpy(array=tot_sam[:int(nevents)], obs=obs_fit) + +# print("Toy {}: Loading data finished".format(toy)) + +# ### Fit data + +# print("Toy {}: Fitting pdf...".format(toy)) + +# for param in total_f_fit.get_dependents(): +# param.randomize() + +# nll = zfit.loss.UnbinnedNLL(model=total_f_fit, data=data, constraints = constraints) + +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) +# # minimizer._use_tfgrad = False +# result = minimizer.minimize(nll) + +# print("Function minimum:", result.fmin) +# print("Hesse errors:", result.hesse()) + +# params = result.params + +# if result.converged: +# Ctt_list.append(params[Ctt]['value']) +# Ctt_error_list.append(params[Ctt]['minuit_hesse']['error']) + +# #plotting the result + +# plotdirName = 'data/plots'.format(toy) + +# if not os.path.exists(plotdirName): +# os.mkdir(plotdirName) +# # print("Directory " , dirName , " Created ") + +# plt.clf() +# plt.hist(tot_sam, bins = int((x_max-x_min)/7.), label = 'toy data') +# plt.savefig(plotdirName + '/toy_histo_cut_region{}.png'.format(toy)) + + +# probs = total_f_fit.pdf(test_q, norm_range=False) +# calcs_test = zfit.run(probs) +# plt.clf() +# plt.plot(test_q, calcs_test, label = 'pdf') +# plt.axvline(x=jpsi_mass-60.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.axvline(x=jpsi_mass+70.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.axvline(x=psi2s_mass-50.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.axvline(x=psi2s_mass+50.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.legend() +# plt.ylim(0.0, 1.5e-6) +# plt.savefig(plotdirName + '/toy_fit_cut_region{}.png'.format(toy)) + +# print("Toy {0}/{1}".format(toy+1, nr_of_toys)) +# print("Time taken: {}".format(display_time(int(time.time() - start)))) +# print("Projected time left: {}".format(display_time(int((time.time() - start)/(toy+1))*((nr_of_toys-toy-1))))) + + + +# In[ ]: + + +# with open("data/results/Ctt_list.pkl", "wb") as f: +# pkl.dump(Ctt_list, f, pkl.HIGHEST_PROTOCOL) +# with open("data/results/Ctt_error_list.pkl", "wb") as f: +# pkl.dump(Ctt_error_list, f, pkl.HIGHEST_PROTOCOL) + + +# In[ ]: + + +# print('{0}/{1} fits converged'.format(len(Ctt_list), nr_of_toys)) +# print('Mean Ctt value = {}'.format(np.mean(Ctt_list))) +# print('Mean Ctt error = {}'.format(np.mean(Ctt_error_list))) +# print('95 Sensitivy = {}'.format(((2*np.mean(Ctt_error_list))**2)*4.2/1000)) + + +# In[ ]: + + +# plt.hist(tot_sam, bins = int((x_max-x_min)/7.)) + +# plt.show() + +# # _ = np.where((total_samp >= x_min) & (total_samp <= (jpsi_mass - 50.))) + +# tot_sam.shape + + +# In[ ]: + + +# Ctt.floating = False + + +# In[ ]: + + +# zfit.run(nll.value()) + + +# In[ ]: + + +# result.fmin + + +# In[ ]: + + +# BR_steps = np.linspace(0.0, 1e-3, 11) +pull_dic = {} + +mi = 1e-4 +ma = 3e-3 +ste = 20 + +for param in total_f_fit.get_dependents(): + if param.floating: + pull_dic[param.name] = [] + for step in range(2*ste): + pull_dic[param.name].append([]) + + + +def save_pulls(step): + for param in total_f_fit.get_dependents(): + if param.floating: + pull_dic[param.name][step].append((params[param]['value'] - param_values_dic[param.name])/params[param]['minuit_hesse']['error']) + + + +# for key in pull_dic.keys(): +# print(np.shape(pull_dic[key])) +# save_pulls(New_step=True) +# params[Ctt]['value'] + + +# In[ ]: + + +# for param in total_f_fit.get_dependents(): +# if param.floating: +# print(param.name) + +# print(params[Ctt]) + + +# # CLS Code + +# In[ ]: + + +# zfit.run.numeric_checks = False + +load = False + +bo = True + +D_contribs = True + +if not D_contribs: + Dbar_s.floating = False + Dbar_p.floating = False + DDstar_s.floating = False + DDstar_p.floating = False + +bo_set = 1 + +fitting_range = 'cut' +total_BR = 1.7e-10 + 4.9e-10 + 2.5e-9 + 6.02e-5 + 4.97e-6 + 1.38e-9 + 4.2e-10 + 2.6e-9 + 6.1e-10 + 4.37e-7 +cut_BR = 1.0 - (6.02e-5 + 4.97e-6)/total_BR + +Ctt_list = [] +Ctt_error_list = [] + +nr_of_toys = 1 +nevents = int(pdg["number_of_decays"]*cut_BR) +# nevents = pdg["number_of_decays"] +event_stack = 1000000 +# nevents *= 41 +# zfit.settings.set_verbosity(10) + +# mi = 1e-4 +# ma = 3e-3 +# ste = 13 + +BR_steps = np.linspace(mi, ma, ste) + +BR_steps[0] = 0.0 + +print(BR_steps) + +Ctt_steps = np.sqrt(BR_steps/4.2*1000) + +print(Ctt_steps) + +# total_samp = [] + +start = time.time() + +Nll_list = [] + +sampler = total_f.create_sampler(n=nevents, fixed_params = False) +sampler.set_data_range(obs_fit) + +__ = -1 + +#----------------------------------------------------- + +if not load: + for Ctt_step in Ctt_steps: + + __ += 1 + + for i in range(2): + Ctt_list.append([]) + Ctt_error_list.append([]) + Nll_list.append([]) + + for param in total_f_fit.get_dependents(): + if param.floating: + pull_dic[param.name].append([]) + + for toy in range(nr_of_toys): + + newset = True + + while newset: + + for floaty in [True, False]: + Ctt.floating = floaty + + for bo_step in range(bo_set): + + print('Step: {0}/{1}'.format(int(__), ste)) + print('Current Ctt: {0}'.format(Ctt_step)) + print('Ctt floating: {0}'.format(floaty)) + + reset_param_values(variation = 0.0) + + if floaty: + print('Toy {0}/{1} - Fit {2}/{3}'.format(toy, nr_of_toys, bo_step, bo_set)) + Ctt.set_value(Ctt_step) + + else: + Ctt.set_value(0.0) + print('Toy {0}/{1} - Fit {2}/{3}'.format(toy, nr_of_toys, bo_step, bo_set)) + + if newset: + sampler.resample(n=nevents) + data = sampler + newset = False + + ### Fit data + + if floaty: + #plt.clf() + #plt.title('Ctt value: {:.2f}'.format(Ctt_step)) + #plt.hist(zfit.run(data), bins = int((x_max-x_min)/7), range = (x_min, x_max)) + #plt.savefig('data/CLs/plots/set_histo{}.png'.format(__)) + _step = 2*__ + else: + _step = 2*__+1 + + nll = zfit.loss.UnbinnedNLL(model=total_f_fit, data=data, constraints = constraints) + + minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) + # minimizer._use_tfgrad = False + result = minimizer.minimize(nll) + + print("Function minimum:", result.fmin) + print("Hesse errors:", result.hesse()) + + params = result.params + + if result.converged: + + save_pulls(step = _step) + + if floaty: + Nll_list[-2].append(result.fmin) + Ctt_list[-2].append(params[Ctt]['value']) + Ctt_error_list[-2].append(params[Ctt]['minuit_hesse']['error']) + + else: + Nll_list[-1].append(result.fmin) + Ctt_list[-1].append(0.0) + Ctt_error_list[-1].append(0.0) + + + else: + for _ in [1,2]: + del Nll_list[-_][toy*bo_set:] +# print(np.shape(Nll_list[-_])) + del Ctt_list[-_][toy*bo_set:] + del Ctt_error_list[-_][toy*bo_set:] + for param in total_f_fit.get_dependents(): + if param.floating: + del pull_dic[param.name][_step+1-_][toy*bo_set:] + newset = True + break + + if not result.converged: + break + + print() + print('Time taken: {}'.format(display_time(int(time.time()-start)))) + print('Estimated time left: {}'.format(display_time(int((time.time()-start)/(__+(toy+1)/nr_of_toys)*(ste-__-(nr_of_toys-toy-1)/nr_of_toys))))) + + +# In[ ]: + + +if load: + + phase_combi = '--' + + if D_contribs: + D_dir = 'D-True' + else: + D_dir = 'D-False' + + _dir = 'data/CLs/finished/f1d1/{}/{}/'.format(phase_combi, D_dir) + + jobs = os.listdir(_dir) + + First = True + +# print(jobs) + + for job in jobs: + + dirName = _dir + str(job) + '/data/CLs' + + if not os.path.exists("{}/{}-{}_{}s{}b{}t--CLs_Nll_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys)): +# print(job) + continue + + with open(r"{}/variab.pkl".format(dirName), "rb") as input_file: + variab = pkl.load(input_file) +# print(variab) + + ### sanity check: + if variab['mi'] != mi or variab['ma'] != ma or variab['ste'] != ste or bo_set != bo_set: + print('Fitting parameters of data dont equal the ones given -- Job {} skipped!'.format(job)) + + with open(r"{}/{}-{}_{}s{}b{}t--CLs_Nll_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _Nll_list = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s{}b{}t--Ctt_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _Ctt_list = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s{}b{}t--Ctt_error_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _Ctt_error_list = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s{}b{}t--pull_dic.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _pull_dic = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s--CLs_list.pkl".format(dirName, mi,ma,ste), "rb") as input_file: + _CLs_list = pkl.load(input_file) + + + if First: + Nll_list = _Nll_list + Ctt_list = _Ctt_list + Ctt_error_list = _Ctt_error_list + pull_dic = _pull_dic +# print(_pull_dic) + CLs_list = _CLs_list + First = False + else: + for step in range(2*ste): +# print(Nll_list[step], step) + Nll_list[step].extend(_Nll_list[step]) + Ctt_list[step].extend(_Ctt_list[step]) + Ctt_error_list[step].extend(_Ctt_error_list[step]) + for key in pull_dic.keys(): +# print(key, np.shape(pull_dic[key])) + pull_dic[key][step].extend(_pull_dic[key][step]) + for step in range(ste): + CLs_list[step].extend(_CLs_list[step]) + +# print('----------------------') + + +# In[ ]: + + +dirName = 'data/CLs' + +# if bo and not load: +# for s in range(2*ste): +# Nll_list[s] = [np.min(Nll_list[s])] + + +if not load: + + if not os.path.exists(dirName): + os.mkdir(dirName) + print("Directory " , dirName , " Created ") + + with open("{}/{}-{}_{}s{}b{}t--CLs_Nll_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(Nll_list, f, pkl.HIGHEST_PROTOCOL) + + with open("{}/{}-{}_{}s{}b{}t--Ctt_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(Ctt_list, f, pkl.HIGHEST_PROTOCOL) + + with open("{}/{}-{}_{}s{}b{}t--Ctt_error_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(Ctt_error_list, f, pkl.HIGHEST_PROTOCOL) + + with open("{}/{}-{}_{}s{}b{}t--pull_dic.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(pull_dic, f, pkl.HIGHEST_PROTOCOL) + + variab = {'mi': mi, + 'ma': ma, + 'ste': ste, + 'bo_set': bo_set, + 'nr_of_toys': nr_of_toys} + + with open("{}/variab.pkl".format(dirName), "wb") as f: + pkl.dump(variab, f, pkl.HIGHEST_PROTOCOL) + + CLs_values = [] + + toy_size = bo_set + + print(np.shape(Nll_list)) + print(Nll_list[0:1]) + + for step in range(ste): + CLs_values.append([]) + for toy in range(nr_of_toys): + float_min = np.min(Nll_list[2*step][toy*bo_set:(toy+1)*bo_set]) + fix_min = np.min(Nll_list[2*step+1][toy*bo_set:(toy+1)*bo_set]) + CLs_values[step].append(float_min-fix_min) + + + print(np.shape(CLs_values)) + + with open("{}/{}-{}_{}s--CLs_list.pkl".format(dirName, mi,ma,ste), "wb") as f: + pkl.dump(CLs_values, f, pkl.HIGHEST_PROTOCOL) + + +# In[ ]: + + +# print(variab['mi'] != mi) + + +# ## Plot + +# In[ ]: + + +l = [] + + +if load: + CLs_values = -1*np.array(CLs_list) + +if not os.path.exists('data/CLs/plots'): + os.mkdir('data/CLs/plots') + print("Directory " , 'data/CLs/plots' , " Created ") + +print(np.shape(CLs_values)) + +for step in range(1,ste): + plt.clf() + plt.title('Ctt value: {:.2f}'.format(Ctt_steps[step])) + plt.hist(CLs_values[0], bins = 150, range = (-25, 50), label = 'Ctt fixed to 0') + plt.hist(CLs_values[step], bins = 150, range = (-25, 50), label = 'Ctt floating') + plt.axvline(x=np.mean(CLs_values[0]),color='red', linewidth=1.0, linestyle = 'dotted') + plt.legend() + plt.savefig('data/CLs/plots/CLs-BR({:.1E}).png'.format(BR_steps[step])) + + l.append(len(np.where(np.array(CLs_values[step]) < np.mean(CLs_values[0]))[0])) + +for step in range(2*ste): + if step%2 == 0: + floaty = True + else: + floaty = False + for key in pull_dic.keys(): + if not os.path.exists('data/CLs/plots/{}'.format(key)): + os.mkdir('data/CLs/plots/{}'.format(key)) + plt.clf() + plt.title('Pull {} - Ctt value {:.2f} - floating {}'.format(key, Ctt_steps[int(step/2)], floaty)) + plt.hist(pull_dic[key][step], bins = 50, range = (-5,5)) + plt.xlabel('Pull') + plt.savefig('data/CLs/plots/{}/{:.2f}Ctt{}s{}f.png'.format(key, Ctt_steps[int(step/2)], step, floaty)) + + +# In[ ]: + + +for s in range(len(l)): + print('BR: {:.4f}'.format(BR_steps[s+1])) + print(2*l[s]/len(CLs_values[s])) + print() + + +# In[ ]: + + +# for step in range(2*ste): +# for key in pull_dic.keys(): +# print(pull_dic[key][step]) + + +# In[ ]: + + +# for param in total_f_fit.get_dependents(): +# if param.floating: +# print(params[param]['value']) + + +# In[ ]: + + +print(display_time(int(time.time()-start))) + + +# In[ ]: + + +# variab['mi'] =! mi + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + diff --git a/data/CLs/finished/f1d1/-+/D-True/2288029/__pycache__/helperfunctions.cpython-37.pyc b/data/CLs/finished/f1d1/-+/D-True/2288029/__pycache__/helperfunctions.cpython-37.pyc new file mode 100644 index 0000000..cd1439f --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288029/__pycache__/helperfunctions.cpython-37.pyc Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288029/__pycache__/pdg_const1.cpython-37.pyc b/data/CLs/finished/f1d1/-+/D-True/2288029/__pycache__/pdg_const1.cpython-37.pyc new file mode 100644 index 0000000..88df3e1 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288029/__pycache__/pdg_const1.cpython-37.pyc Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288029/data/CLs/0.0001-0.003_20s--CLs_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288029/data/CLs/0.0001-0.003_20s--CLs_list.pkl new file mode 100644 index 0000000..e1cd7c6 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288029/data/CLs/0.0001-0.003_20s--CLs_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288029/data/CLs/0.0001-0.003_20s1b1t--CLs_Nll_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288029/data/CLs/0.0001-0.003_20s1b1t--CLs_Nll_list.pkl new file mode 100644 index 0000000..43cc6e3 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288029/data/CLs/0.0001-0.003_20s1b1t--CLs_Nll_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288029/data/CLs/0.0001-0.003_20s1b1t--Ctt_error_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288029/data/CLs/0.0001-0.003_20s1b1t--Ctt_error_list.pkl new file mode 100644 index 0000000..cadcaeb --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288029/data/CLs/0.0001-0.003_20s1b1t--Ctt_error_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288029/data/CLs/0.0001-0.003_20s1b1t--Ctt_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288029/data/CLs/0.0001-0.003_20s1b1t--Ctt_list.pkl new file mode 100644 index 0000000..c6bd4e5 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288029/data/CLs/0.0001-0.003_20s1b1t--Ctt_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288029/data/CLs/0.0001-0.003_20s1b1t--pull_dic.pkl b/data/CLs/finished/f1d1/-+/D-True/2288029/data/CLs/0.0001-0.003_20s1b1t--pull_dic.pkl new file mode 100644 index 0000000..4c091e7 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288029/data/CLs/0.0001-0.003_20s1b1t--pull_dic.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288029/data/CLs/variab.pkl b/data/CLs/finished/f1d1/-+/D-True/2288029/data/CLs/variab.pkl new file mode 100644 index 0000000..bb90dc0 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288029/data/CLs/variab.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288029/helperfunctions.py b/data/CLs/finished/f1d1/-+/D-True/2288029/helperfunctions.py new file mode 100644 index 0000000..88e120f --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288029/helperfunctions.py @@ -0,0 +1,33 @@ +# some helperfunctions + +import matplotlib +matplotlib.use("agg") +import matplotlib.pyplot as plt + +#Dislpay time (e.g. while generating points) + +display_intervals = ( + ('w', 604800), # 60 * 60 * 24 * 7 + ('d', 86400), # 60 * 60 * 24 + ('h', 3600), # 60 * 60 + ('min', 60), + ('s', 1), + ) + +def display_time(seconds, granularity=2): + result = [] + + for name, count in display_intervals: + value = seconds // count + if value: + seconds -= value * count + if value == 1: + name = name.rstrip('s') + result.append("{} {}".format(value, name)) + return ', '.join(result[:granularity]) + +def prepare_plot(title): + plt.title(title) + plt.grid() + plt.legend(loc = 'best') + plt.xlabel("q") diff --git a/data/CLs/finished/f1d1/-+/D-True/2288029/pdg_const1.py b/data/CLs/finished/f1d1/-+/D-True/2288029/pdg_const1.py new file mode 100644 index 0000000..70b3f30 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288029/pdg_const1.py @@ -0,0 +1,226 @@ +pdg = { + + + ###Particle masses### + + "mbstar" : 5415.4, + "mbstar0" : 5711.0, + "B0_M" : 5279.5, + "Bs_M" : 5366.7, + "Bplus_M" : 5279.3, + "Lb_M" : 5619.4, + "D0_M" : 1864.8, + "Dst_M" : 2010, + "pi_M" : 139.6, + "Jpsi_M" : 3096.9, + "Psi2s_M" : 3685.6, + "kaon_M" : 493.7, + "Ks_M" : 497.6, + "phi_M" : 1019.5, + "rho_M" : 775.26, + "rho_width" : 149.1, + "omega_M" : 782.65, + "omega_width" : 8.49, + + "muon_M" : 105.7, + "tau_M": 1776.86, + + "squark_M" : 95.0, + "bquark_M" : 4180.0, + "cquark_M" : 1275.0, + + "Bplus_tau" : 1.638e-12, + + ###Wilson coefficients### + + "C1" : -0.257, + "C2" : 1.009, + "C3" : -0.005, + "C4" : -0.078, + + "C7eff" : -0.306, + "C9eff" : 4.211, + "C10eff" : -4.103, + +# "C7eff": 0.0, +# "C9eff": 0.0, +# "C10eff": 0.0, + + ###Other constants + + "GF" : 1.1663787e-5, + "alpha_ew" : 1.0/137.0, + "Vts" : 0.0394, + "Vtb" : 1.019, + "number_of_decays": 5404696, + + #Formfactor z coefficients + + #"b0" : [0.285, 0.19, -0.17], + #"bplus" : [0.437, -1.41, -2.5], + #"bT" : [0.440, -1.47, -2.7] + + "b0" : [0.292, 0.281, 0.150], + "bplus" : [0.466, -0.885, -0.213], + "bT" : [0.460, -1.089, -1.114], + + "NR_BR": 4.37e-7, + "NR_auc": 0.00133, + + #Resonances format(mass, width, phase, scale) + + # pre scaling + +# "rho": (775.26, 149.0, -0.35, 1.0), + +# "omega": (782.7, 8.5, 0.26, 1.0), + +# "phi": (1019.46, 4.25, 0.5, 1.0), + +# "jpsi": (3096.0, 0.09, -1.5, 2e-2), +# "jpsi_auc": 0.2126825758464027, + +# "psi2s": (3686.0, 0.3, -1.5, 3.14e-3), +# "psi2s_auc": 2.802257483178487e-10, + +# "p3770": (3773.0, 27.2, -2.13, 1.0e-3), + +# "p4040": (4039.0, 80.0, -2.52, 2.0), + +# "p4160": (4191.0, 70.0, -1.9, 2.2), + +# "p4415": (4421.0, 62.0, -2.52, 1.0), + + + # after scaling (Phase combination --) + + # + # "rho": (743.2, 149.0, -0.22, 1.05), + # + # "omega": (782.7, 8.5, 0.38, 6.8), + # + # "phi": (1013.5, 4.25, 0.62, 19.2), + # + # "jpsi": (3096.1, 0.09, 1.63, 9897.0), + # "jpsi_auc": 0.2126825758464027, + # "jpsi_phase_unc": 0.05, + # + # "psi2s": (3686.0, 0.3, 1.8, 1396.0), + # "psi2s_auc": 0.0151332263, + # "psi2s_phase_unc": 0.1, + # + # "p3770": (3773.0, 27.2, -2.95, 2.5), + # + # "p4040": (4039.0, 80.0, -2.75, 1.01), + # + # "p4160": (4191.0, 70.0, -2.28, 2.2), + # + # "p4415": (4421.0, 62.0, -2.31, 1.24), + + # Phase combination of paper ++ + +# "rho": (743.2, 149.0, -0.35, 1.05), + +# "omega": (782.7, 8.5, 0.26, 6.8), + +# "phi": (1013.5, 4.25, 0.47, 19.2), + +# "jpsi": (3096.1, 0.09, -1.66, 9897.0), +# "jpsi_auc": 0.2126825758464027, +# "jpsi_phase_unc": 0.05, + +# "psi2s": (3686.0, 0.3, -1.93, 1396.0), +# "psi2s_auc": 0.0151332263, +# "psi2s_phase_unc": 0.1, + +# "p3770": (3773.0, 27.2, -2.13, 2.5), + +# "p4040": (4039.0, 80.0, -2.52, 1.01), + +# "p4160": (4191.0, 70.0, -1.90, 2.2), + +# "p4415": (4421.0, 62.0, -2.52, 1.24), + + # Phase combination of paper +- + +# "rho": (743.2, 149.0, -0.26, 1.05), + +# "omega": (782.7, 8.5, 0.35, 6.8), + +# "phi": (1013.5, 4.25, 0.58, 19.2), + +# "jpsi": (3096.1, 0.09, 1.47, 9897.0), +# "jpsi_auc": 0.2126825758464027, +# "jpsi_phase_unc": 0.05, + +# "psi2s": (3686.0, 0.3, -2.21, 1396.0), +# "psi2s_auc": 0.0151332263, +# "psi2s_phase_unc": 0.1, + +# "p3770": (3773.0, 27.2, -2.140, 2.5), + +# "p4040": (4039.0, 80.0, -2.64, 1.01), + +# "p4160": (4191.0, 70.0, -2.11, 2.2), + +# "p4415": (4421.0, 62.0, -2.42, 1.24), + + # Phase combination of paper -+ + + "rho": (743.2, 149.0, -0.30, 1.05), + + "omega": (782.7, 8.5, 0.30, 6.8), + + "phi": (1013.5, 4.25, 0.51, 19.2), + + "jpsi": (3096.1, 0.09, -1.5, 9897.0), + "jpsi_auc": 0.2126825758464027, + "jpsi_phase_unc": 0.05, + + "psi2s": (3686.0, 0.3, 2.08, 1396.0), + "psi2s_auc": 0.0151332263, + "psi2s_phase_unc": 0.1, + + "p3770": (3773.0, 27.2, -2.89, 2.5), + + "p4040": (4039.0, 80.0, -2.69, 1.01), + + "p4160": (4191.0, 70.0, -2.13, 2.2), + + "p4415": (4421.0, 62.0, -2.43, 1.24), + + + # zeroing resonances + +# "rho": (775.26, 149.0, -0.35, 0.0), +# "omega": (782.7, 8.5, 0.26, 0.0), +# "phi": (1019.46, 4.25, 0.5, 0.0), +# "jpsi": (3096.0, 0.09, -1.5, 0.0), +# "psi2s": (3686.0, 0.3, -1.5, 0.0), +# "p3770": (3773.0, 27.2, -2.13, 0.0), +# "p4040": (4039.0, 80.0, -2.52, 0.0), +# "p4160": (4147.0, 22.0, -1.9, 0.0), +# "p4415": (4421.0, 62.0, -2.52, 0.0), + + # 2P contributions format(mass, amp, phase) + +# "D_bar": ( + + #general + + "rho_BR": 1.7e-10, + "omega_BR": 4.9e-10, + "phi_BR": 2.5e-9, + "jpsi_BR": 6.02e-5, + "psi2s_BR": 4.97e-6, + "p3770_BR": 1.38e-9, + "p4040_BR": 4.2e-10, + "p4160_BR": 2.6e-9, + "p4415_BR": 6.1e-10, + +# Estimates + "Dbar_scale": 1.46, #with phase = pi + + "DDstar_scale": 2.41, #with phase = pi + + } diff --git a/data/CLs/finished/f1d1/-+/D-True/2288029/raremodel-nb.py b/data/CLs/finished/f1d1/-+/D-True/2288029/raremodel-nb.py new file mode 100644 index 0000000..c326c9c --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288029/raremodel-nb.py @@ -0,0 +1,2152 @@ +#!/usr/bin/env python +# coding: utf-8 + +# # Import + +# In[ ]: + + +import os + +# os.environ["CUDA_VISIBLE_DEVICES"] = "-1" +import random +import numpy as np +from pdg_const1 import pdg +import matplotlib +import matplotlib.pyplot as plt +import pickle as pkl +import sys +import time +from helperfunctions import display_time, prepare_plot +import cmath as c +import scipy.integrate as integrate +from scipy.optimize import fminbound +from array import array as arr +import collections +from itertools import compress +import tensorflow as tf +import zfit +from zfit import ztf +# from IPython.display import clear_output +import os +import tensorflow_probability as tfp +tfd = tfp.distributions + + +# In[ ]: + + +# chunksize = 10000 +# zfit.run.chunking.active = True +# zfit.run.chunking.max_n_points = chunksize + + +# # Build model and graphs +# ## Create graphs + +# In[ ]: + + + + + +# In[ ]: + + +def formfactor(q2, subscript, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2): #returns real value + #check if subscript is viable + + if subscript != "0" and subscript != "+" and subscript != "T": + raise ValueError('Wrong subscript entered, choose either 0, + or T') + + #get constants + + mK = ztf.constant(pdg['Ks_M']) + mbstar0 = ztf.constant(pdg["mbstar0"]) + mbstar = ztf.constant(pdg["mbstar"]) + + + mmu = ztf.constant(pdg['muon_M']) + mb = ztf.constant(pdg['bquark_M']) + ms = ztf.constant(pdg['squark_M']) + mB = ztf.constant(pdg['Bplus_M']) + + #N comes from derivation in paper + + N = 3 + + #some helperfunctions + + tpos = (mB - mK)**2 + tzero = (mB + mK)*(ztf.sqrt(mB)-ztf.sqrt(mK))**2 + + z_oben = ztf.sqrt(tpos - q2) - ztf.sqrt(tpos - tzero) + z_unten = ztf.sqrt(tpos - q2) + ztf.sqrt(tpos - tzero) + z = tf.divide(z_oben, z_unten) + + #calculate f0 + + if subscript == "0": + prefactor = 1/(1 - q2/(mbstar0**2)) + _sum = 0 + b0 = [b0_0, b0_1, b0_2] + + for i in range(N): + _sum += b0[i]*(tf.pow(z,i)) + + return ztf.to_complex(prefactor * _sum) + + #calculate f+ or fT + + else: + prefactor = 1/(1 - q2/(mbstar**2)) + _sum = 0 + + if subscript == "T": + bT = [bT_0, bT_1, bT_2] + for i in range(N): + _sum += bT[i] * (tf.pow(z, i) - ((-1)**(i-N)) * (i/N) * tf.pow(z, N)) + else: + bplus = [bplus_0, bplus_1, bplus_2] + for i in range(N): + _sum += bplus[i] * (tf.pow(z, i) - ((-1)**(i-N)) * (i/N) * tf.pow(z, N)) + + return ztf.to_complex(prefactor * _sum) + +def resonance(q, _mass, width, phase, scale): + + q2 = tf.pow(q, 2) + + mmu = ztf.constant(pdg['muon_M']) + + p = 0.5 * ztf.sqrt(q2 - 4*(mmu**2)) + + p0 = 0.5 * ztf.sqrt(_mass**2 - 4*mmu**2) + + gamma_j = tf.divide(p, q) * _mass * width / p0 + + #Calculate the resonance + + _top = tf.complex(_mass * width, ztf.constant(0.0)) + + _bottom = tf.complex(_mass**2 - q2, -_mass*gamma_j) + + com = _top/_bottom + + #Rotate by the phase + + r = ztf.to_complex(scale*tf.abs(com)) + + _phase = tf.angle(com) + + _phase += phase + + com = r * tf.exp(tf.complex(ztf.constant(0.0), _phase)) + + return com + + +def axiv_nonres(q, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2): + + GF = ztf.constant(pdg['GF']) + alpha_ew = ztf.constant(pdg['alpha_ew']) + Vtb = ztf.constant(pdg['Vtb']) + Vts = ztf.constant(pdg['Vts']) + C10eff = ztf.constant(pdg['C10eff']) + + mmu = ztf.constant(pdg['muon_M']) + mb = ztf.constant(pdg['bquark_M']) + ms = ztf.constant(pdg['squark_M']) + mK = ztf.constant(pdg['Ks_M']) + mB = ztf.constant(pdg['Bplus_M']) + + q2 = tf.pow(q, 2) + + #Some helperfunctions + + beta = 1. - 4. * mmu**2. / q2 + + kabs = ztf.sqrt(mB**2. + tf.pow(q2, 2)/mB**2. + mK**4./mB**2. - 2. * (mB**2. * mK**2. + mK**2. * q2 + mB**2. * q2) / mB**2.) + + #prefactor in front of whole bracket + + prefactor1 = GF**2. *alpha_ew**2. * (tf.abs(Vtb*Vts))**2. * kabs * beta / (128. * np.pi**5.) + + #left term in bracket + + bracket_left = 2./3. * tf.pow(kabs,2) * tf.pow(beta,2) * tf.pow(tf.abs(ztf.to_complex(C10eff)*formfactor(q2, "+", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2)),2) + + #middle term in bracket + + _top = 4. * mmu**2. * (mB**2. - mK**2.) * (mB**2. - mK**2.) + + _under = q2 * mB**2. + + bracket_middle = _top/_under *tf.pow(tf.abs(ztf.to_complex(C10eff) * formfactor(q2, "0", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2)), 2) + + #Note sqrt(q2) comes from derivation as we use q2 and plot q + + return prefactor1 * (bracket_left + bracket_middle) * 2 * q + +def vec(q, funcs, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2): + + q2 = tf.pow(q, 2) + + GF = ztf.constant(pdg['GF']) + alpha_ew = ztf.constant(pdg['alpha_ew']) + Vtb = ztf.constant(pdg['Vtb']) + Vts = ztf.constant(pdg['Vts']) + C7eff = ztf.constant(pdg['C7eff']) + + mmu = ztf.constant(pdg['muon_M']) + mb = ztf.constant(pdg['bquark_M']) + ms = ztf.constant(pdg['squark_M']) + mK = ztf.constant(pdg['Ks_M']) + mB = ztf.constant(pdg['Bplus_M']) + + #Some helperfunctions + + beta = 1. - 4. * mmu**2. / q2 + + kabs = ztf.sqrt(mB**2. + tf.pow(q2, 2)/mB**2. + mK**4./mB**2. - 2 * (mB**2 * mK**2 + mK**2 * q2 + mB**2 * q2) / mB**2) + + #prefactor in front of whole bracket + + prefactor1 = GF**2. *alpha_ew**2. * (tf.abs(Vtb*Vts))**2 * kabs * beta / (128. * np.pi**5.) + + #right term in bracket + + prefactor2 = tf.pow(kabs,2) * (1. - 1./3. * beta) + + abs_bracket = tf.pow(tf.abs(c9eff(q, funcs) * formfactor(q2, "+", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + ztf.to_complex(2.0 * C7eff * (mb + ms)/(mB + mK)) * formfactor(q2, "T", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2)),2) + + bracket_right = prefactor2 * abs_bracket + + #Note sqrt(q2) comes from derivation as we use q2 and plot q + + return prefactor1 * bracket_right * 2 * q + +def c9eff(q, funcs): + + C9eff_nr = ztf.to_complex(ztf.constant(pdg['C9eff'])) + + c9 = C9eff_nr + funcs + + return c9 + + +# In[ ]: + + +def G(y): + + def inner_rect_bracket(q): + return tf.log(ztf.to_complex((1+tf.sqrt(q))/(1-tf.sqrt(q)))-tf.complex(ztf.constant(0), -1*ztf.constant(np.pi))) + + def inner_right(q): + return ztf.to_complex(2 * tf.atan(1/tf.sqrt(tf.math.real(-q)))) + + big_bracket = tf.where(tf.math.real(y) > ztf.constant(0.0), inner_rect_bracket(y), inner_right(y)) + + return ztf.to_complex(tf.sqrt(tf.abs(y))) * big_bracket + +def h_S(m, q): + + return ztf.to_complex(2) - G(ztf.to_complex(1) - ztf.to_complex(4*tf.pow(m, 2)) / ztf.to_complex(tf.pow(q, 2))) + +def h_P(m, q): + + return ztf.to_complex(2/3) + (ztf.to_complex(1) - ztf.to_complex(4*tf.pow(m, 2)) / ztf.to_complex(tf.pow(q, 2))) * h_S(m,q) + +def two_p_ccbar(mD, m_D_bar, m_D_star, q): + + + #Load constants + nu_D_bar = ztf.to_complex(pdg["nu_D_bar"]) + nu_D = ztf.to_complex(pdg["nu_D"]) + nu_D_star = ztf.to_complex(pdg["nu_D_star"]) + + phase_D_bar = ztf.to_complex(pdg["phase_D_bar"]) + phase_D = ztf.to_complex(pdg["phase_D"]) + phase_D_star = ztf.to_complex(pdg["phase_D_star"]) + + #Calculation + left_part = nu_D_bar * tf.exp(tf.complex(ztf.constant(0.0), phase_D_bar)) * h_S(m_D_bar, q) + + right_part_D = nu_D * tf.exp(tf.complex(ztf.constant(0.0), phase_D)) * h_P(m_D, q) + + right_part_D_star = nu_D_star * tf.exp(tf.complex(ztf.constant(0.0), phase_D_star)) * h_P(m_D_star, q) + + return left_part + right_part_D + right_part_D_star + + +# ## Build pdf + +# In[ ]: + + +class total_pdf_cut(zfit.pdf.ZPDF): + _N_OBS = 1 # dimension, can be omitted + _PARAMS = ['b0_0', 'b0_1', 'b0_2', + 'bplus_0', 'bplus_1', 'bplus_2', + 'bT_0', 'bT_1', 'bT_2', + 'rho_mass', 'rho_scale', 'rho_phase', 'rho_width', + 'jpsi_mass', 'jpsi_scale', 'jpsi_phase', 'jpsi_width', + 'psi2s_mass', 'psi2s_scale', 'psi2s_phase', 'psi2s_width', + 'p3770_mass', 'p3770_scale', 'p3770_phase', 'p3770_width', + 'p4040_mass', 'p4040_scale', 'p4040_phase', 'p4040_width', + 'p4160_mass', 'p4160_scale', 'p4160_phase', 'p4160_width', + 'p4415_mass', 'p4415_scale', 'p4415_phase', 'p4415_width', + 'omega_mass', 'omega_scale', 'omega_phase', 'omega_width', + 'phi_mass', 'phi_scale', 'phi_phase', 'phi_width', + 'Dbar_mass', 'Dbar_scale', 'Dbar_phase', + 'Dstar_mass', 'DDstar_scale', 'DDstar_phase', 'D_mass', + 'tau_mass', 'C_tt'] +# the name of the parameters + + def _unnormalized_pdf(self, x): + + x = x.unstack_x() + + b0 = [self.params['b0_0'], self.params['b0_1'], self.params['b0_2']] + bplus = [self.params['bplus_0'], self.params['bplus_1'], self.params['bplus_2']] + bT = [self.params['bT_0'], self.params['bT_1'], self.params['bT_2']] + + def rho_res(q): + return resonance(q, _mass = self.params['rho_mass'], scale = self.params['rho_scale'], + phase = self.params['rho_phase'], width = self.params['rho_width']) + + def omega_res(q): + return resonance(q, _mass = self.params['omega_mass'], scale = self.params['omega_scale'], + phase = self.params['omega_phase'], width = self.params['omega_width']) + + def phi_res(q): + return resonance(q, _mass = self.params['phi_mass'], scale = self.params['phi_scale'], + phase = self.params['phi_phase'], width = self.params['phi_width']) + + def jpsi_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['jpsi_mass'], 2)) * resonance(q, _mass = self.params['jpsi_mass'], + scale = self.params['jpsi_scale'], + phase = self.params['jpsi_phase'], + width = self.params['jpsi_width']) + def psi2s_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['psi2s_mass'], 2)) * resonance(q, _mass = self.params['psi2s_mass'], + scale = self.params['psi2s_scale'], + phase = self.params['psi2s_phase'], + width = self.params['psi2s_width']) + def p3770_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p3770_mass'], 2)) * resonance(q, _mass = self.params['p3770_mass'], + scale = self.params['p3770_scale'], + phase = self.params['p3770_phase'], + width = self.params['p3770_width']) + + def p4040_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4040_mass'], 2)) * resonance(q, _mass = self.params['p4040_mass'], + scale = self.params['p4040_scale'], + phase = self.params['p4040_phase'], + width = self.params['p4040_width']) + + def p4160_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4160_mass'], 2)) * resonance(q, _mass = self.params['p4160_mass'], + scale = self.params['p4160_scale'], + phase = self.params['p4160_phase'], + width = self.params['p4160_width']) + + def p4415_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4415_mass'], 2)) * resonance(q, _mass = self.params['p4415_mass'], + scale = self.params['p4415_scale'], + phase = self.params['p4415_phase'], + width = self.params['p4415_width']) + + def P2_D(q): + Dbar_contrib = ztf.to_complex(self.params['Dbar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['Dbar_phase']))*ztf.to_complex(h_S(self.params['Dbar_mass'], q)) + DDstar_contrib = ztf.to_complex(self.params['DDstar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['DDstar_phase']))*(ztf.to_complex(h_P(self.params['Dstar_mass'], q)) + ztf.to_complex(h_P(self.params['D_mass'], q))) + return Dbar_contrib + DDstar_contrib + + def ttau_cusp(q): + return ztf.to_complex(self.params['C_tt'])*(ztf.to_complex((h_S(self.params['tau_mass'], q))) - ztf.to_complex(h_P(self.params['tau_mass'], q))) + + + funcs = rho_res(x) + omega_res(x) + phi_res(x) + jpsi_res(x) + psi2s_res(x) + p3770_res(x) + p4040_res(x)+ p4160_res(x) + p4415_res(x) + P2_D(x) + ttau_cusp(x) + + vec_f = vec(x, funcs, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + axiv_nr = axiv_nonres(x, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + tot = vec_f + axiv_nr + + #Cut out jpsi and psi2s + + tot = tf.where(tf.math.logical_or(x < ztf.constant(jpsi_mass-60.), x > ztf.constant(jpsi_mass+70.)), tot, 0.0*tot) + + tot = tf.where(tf.math.logical_or(x < ztf.constant(psi2s_mass-50.), x > ztf.constant(psi2s_mass+50.)), tot, 0.0*tot) + + return tot + +class total_pdf_full(zfit.pdf.ZPDF): + _N_OBS = 1 # dimension, can be omitted + _PARAMS = ['b0_0', 'b0_1', 'b0_2', + 'bplus_0', 'bplus_1', 'bplus_2', + 'bT_0', 'bT_1', 'bT_2', + 'rho_mass', 'rho_scale', 'rho_phase', 'rho_width', + 'jpsi_mass', 'jpsi_scale', 'jpsi_phase', 'jpsi_width', + 'psi2s_mass', 'psi2s_scale', 'psi2s_phase', 'psi2s_width', + 'p3770_mass', 'p3770_scale', 'p3770_phase', 'p3770_width', + 'p4040_mass', 'p4040_scale', 'p4040_phase', 'p4040_width', + 'p4160_mass', 'p4160_scale', 'p4160_phase', 'p4160_width', + 'p4415_mass', 'p4415_scale', 'p4415_phase', 'p4415_width', + 'omega_mass', 'omega_scale', 'omega_phase', 'omega_width', + 'phi_mass', 'phi_scale', 'phi_phase', 'phi_width', + 'Dbar_mass', 'Dbar_scale', 'Dbar_phase', + 'Dstar_mass', 'DDstar_scale', 'DDstar_phase', 'D_mass', + 'tau_mass', 'C_tt'] +# the name of the parameters + + def _unnormalized_pdf(self, x): + + x = x.unstack_x() + + b0 = [self.params['b0_0'], self.params['b0_1'], self.params['b0_2']] + bplus = [self.params['bplus_0'], self.params['bplus_1'], self.params['bplus_2']] + bT = [self.params['bT_0'], self.params['bT_1'], self.params['bT_2']] + + def rho_res(q): + return resonance(q, _mass = self.params['rho_mass'], scale = self.params['rho_scale'], + phase = self.params['rho_phase'], width = self.params['rho_width']) + + def omega_res(q): + return resonance(q, _mass = self.params['omega_mass'], scale = self.params['omega_scale'], + phase = self.params['omega_phase'], width = self.params['omega_width']) + + def phi_res(q): + return resonance(q, _mass = self.params['phi_mass'], scale = self.params['phi_scale'], + phase = self.params['phi_phase'], width = self.params['phi_width']) + + def jpsi_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['jpsi_mass'], 2)) * resonance(q, _mass = self.params['jpsi_mass'], + scale = self.params['jpsi_scale'], + phase = self.params['jpsi_phase'], + width = self.params['jpsi_width']) + def psi2s_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['psi2s_mass'], 2)) * resonance(q, _mass = self.params['psi2s_mass'], + scale = self.params['psi2s_scale'], + phase = self.params['psi2s_phase'], + width = self.params['psi2s_width']) + def p3770_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p3770_mass'], 2)) * resonance(q, _mass = self.params['p3770_mass'], + scale = self.params['p3770_scale'], + phase = self.params['p3770_phase'], + width = self.params['p3770_width']) + + def p4040_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4040_mass'], 2)) * resonance(q, _mass = self.params['p4040_mass'], + scale = self.params['p4040_scale'], + phase = self.params['p4040_phase'], + width = self.params['p4040_width']) + + def p4160_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4160_mass'], 2)) * resonance(q, _mass = self.params['p4160_mass'], + scale = self.params['p4160_scale'], + phase = self.params['p4160_phase'], + width = self.params['p4160_width']) + + def p4415_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4415_mass'], 2)) * resonance(q, _mass = self.params['p4415_mass'], + scale = self.params['p4415_scale'], + phase = self.params['p4415_phase'], + width = self.params['p4415_width']) + + def P2_D(q): + Dbar_contrib = ztf.to_complex(self.params['Dbar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['Dbar_phase']))*ztf.to_complex(h_S(self.params['Dbar_mass'], q)) + DDstar_contrib = ztf.to_complex(self.params['DDstar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['DDstar_phase']))*(ztf.to_complex(h_P(self.params['Dstar_mass'], q)) + ztf.to_complex(h_P(self.params['D_mass'], q))) + return Dbar_contrib + DDstar_contrib + + def ttau_cusp(q): + return ztf.to_complex(self.params['C_tt'])*(ztf.to_complex((h_S(self.params['tau_mass'], q))) - ztf.to_complex(h_P(self.params['tau_mass'], q))) + + + funcs = rho_res(x) + omega_res(x) + phi_res(x) + jpsi_res(x) + psi2s_res(x) + p3770_res(x) + p4040_res(x)+ p4160_res(x) + p4415_res(x) + P2_D(x) + ttau_cusp(x) + + vec_f = vec(x, funcs, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + axiv_nr = axiv_nonres(x, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + tot = vec_f + axiv_nr + + #Cut out jpsi and psi2s + +# tot = tf.where(tf.math.logical_or(x < ztf.constant(jpsi_mass-60.), x > ztf.constant(jpsi_mass+70.)), tot, 0.0*tot) + +# tot = tf.where(tf.math.logical_or(x < ztf.constant(psi2s_mass-50.), x > ztf.constant(psi2s_mass+50.)), tot, 0.0*tot) + + return tot + + +# ## Setup parameters + +# In[ ]: + + +# formfactors + +b0_0 = zfit.Parameter("b0_0", ztf.constant(0.292), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +b0_1 = zfit.Parameter("b0_1", ztf.constant(0.281), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +b0_2 = zfit.Parameter("b0_2", ztf.constant(0.150), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) + +bplus_0 = zfit.Parameter("bplus_0", ztf.constant(0.466), lower_limit = -2.0, upper_limit= 2.0) +bplus_1 = zfit.Parameter("bplus_1", ztf.constant(-0.885), lower_limit = -2.0, upper_limit= 2.0) +bplus_2 = zfit.Parameter("bplus_2", ztf.constant(-0.213), lower_limit = -2.0, upper_limit= 2.0) + +bT_0 = zfit.Parameter("bT_0", ztf.constant(0.460), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +bT_1 = zfit.Parameter("bT_1", ztf.constant(-1.089), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +bT_2 = zfit.Parameter("bT_2", ztf.constant(-1.114), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) + + +#rho + +rho_mass, rho_width, rho_phase, rho_scale = pdg["rho"] + +rho_m = zfit.Parameter("rho_m", ztf.constant(rho_mass), floating = False) #lower_limit = rho_mass - rho_width, upper_limit = rho_mass + rho_width) +rho_w = zfit.Parameter("rho_w", ztf.constant(rho_width), floating = False) +rho_p = zfit.Parameter("rho_p", ztf.constant(rho_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +rho_s = zfit.Parameter("rho_s", ztf.constant(rho_scale), lower_limit=rho_scale-np.sqrt(rho_scale), upper_limit=rho_scale+np.sqrt(rho_scale)) + +#omega + +omega_mass, omega_width, omega_phase, omega_scale = pdg["omega"] + +omega_m = zfit.Parameter("omega_m", ztf.constant(omega_mass), floating = False) +omega_w = zfit.Parameter("omega_w", ztf.constant(omega_width), floating = False) +omega_p = zfit.Parameter("omega_p", ztf.constant(omega_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +omega_s = zfit.Parameter("omega_s", ztf.constant(omega_scale), lower_limit=omega_scale-np.sqrt(omega_scale), upper_limit=omega_scale+np.sqrt(omega_scale)) + + +#phi + +phi_mass, phi_width, phi_phase, phi_scale = pdg["phi"] + +phi_m = zfit.Parameter("phi_m", ztf.constant(phi_mass), floating = False) +phi_w = zfit.Parameter("phi_w", ztf.constant(phi_width), floating = False) +phi_p = zfit.Parameter("phi_p", ztf.constant(phi_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +phi_s = zfit.Parameter("phi_s", ztf.constant(phi_scale), lower_limit=phi_scale-np.sqrt(phi_scale), upper_limit=phi_scale+np.sqrt(phi_scale)) + +#jpsi + +jpsi_mass, jpsi_width, jpsi_phase, jpsi_scale = pdg["jpsi"] + +jpsi_m = zfit.Parameter("jpsi_m", ztf.constant(jpsi_mass), floating = False) +jpsi_w = zfit.Parameter("jpsi_w", ztf.constant(jpsi_width), floating = False) +jpsi_p = zfit.Parameter("jpsi_p", ztf.constant(jpsi_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +jpsi_s = zfit.Parameter("jpsi_s", ztf.constant(jpsi_scale), floating = False) #, lower_limit=jpsi_scale-np.sqrt(jpsi_scale), upper_limit=jpsi_scale+np.sqrt(jpsi_scale)) + +#psi2s + +psi2s_mass, psi2s_width, psi2s_phase, psi2s_scale = pdg["psi2s"] + +psi2s_m = zfit.Parameter("psi2s_m", ztf.constant(psi2s_mass), floating = False) +psi2s_w = zfit.Parameter("psi2s_w", ztf.constant(psi2s_width), floating = False) +psi2s_p = zfit.Parameter("psi2s_p", ztf.constant(psi2s_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +psi2s_s = zfit.Parameter("psi2s_s", ztf.constant(psi2s_scale), floating = False) #, lower_limit=psi2s_scale-np.sqrt(psi2s_scale), upper_limit=psi2s_scale+np.sqrt(psi2s_scale)) + +#psi(3770) + +p3770_mass, p3770_width, p3770_phase, p3770_scale = pdg["p3770"] + +p3770_m = zfit.Parameter("p3770_m", ztf.constant(p3770_mass), floating = False) +p3770_w = zfit.Parameter("p3770_w", ztf.constant(p3770_width), floating = False) +p3770_p = zfit.Parameter("p3770_p", ztf.constant(p3770_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p3770_s = zfit.Parameter("p3770_s", ztf.constant(p3770_scale), lower_limit=p3770_scale-np.sqrt(p3770_scale), upper_limit=p3770_scale+np.sqrt(p3770_scale)) + +#psi(4040) + +p4040_mass, p4040_width, p4040_phase, p4040_scale = pdg["p4040"] + +p4040_m = zfit.Parameter("p4040_m", ztf.constant(p4040_mass), floating = False) +p4040_w = zfit.Parameter("p4040_w", ztf.constant(p4040_width), floating = False) +p4040_p = zfit.Parameter("p4040_p", ztf.constant(p4040_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p4040_s = zfit.Parameter("p4040_s", ztf.constant(p4040_scale), lower_limit=p4040_scale-np.sqrt(p4040_scale), upper_limit=p4040_scale+np.sqrt(p4040_scale)) + +#psi(4160) + +p4160_mass, p4160_width, p4160_phase, p4160_scale = pdg["p4160"] + +p4160_m = zfit.Parameter("p4160_m", ztf.constant(p4160_mass), floating = False) +p4160_w = zfit.Parameter("p4160_w", ztf.constant(p4160_width), floating = False) +p4160_p = zfit.Parameter("p4160_p", ztf.constant(p4160_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p4160_s = zfit.Parameter("p4160_s", ztf.constant(p4160_scale), lower_limit=p4160_scale-np.sqrt(p4160_scale), upper_limit=p4160_scale+np.sqrt(p4160_scale)) + +#psi(4415) + +p4415_mass, p4415_width, p4415_phase, p4415_scale = pdg["p4415"] + +p4415_m = zfit.Parameter("p4415_m", ztf.constant(p4415_mass), floating = False) +p4415_w = zfit.Parameter("p4415_w", ztf.constant(p4415_width), floating = False) +p4415_p = zfit.Parameter("p4415_p", ztf.constant(p4415_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p4415_s = zfit.Parameter("p4415_s", ztf.constant(p4415_scale), lower_limit=p4415_scale-np.sqrt(p4415_scale), upper_limit=p4415_scale+np.sqrt(p4415_scale)) + + +# ## Dynamic generation of 2 particle contribution + +# In[ ]: + + +m_c = 1300 + +Dbar_phase = 0.0 +DDstar_phase = 0.0 +Dstar_mass = pdg['Dst_M'] +Dbar_mass = pdg['D0_M'] +D_mass = pdg['D0_M'] + +Dbar_s = zfit.Parameter("Dbar_s", ztf.constant(0.0), lower_limit=-0.3, upper_limit=0.3) +Dbar_m = zfit.Parameter("Dbar_m", ztf.constant(Dbar_mass), floating = False) +Dbar_p = zfit.Parameter("Dbar_p", ztf.constant(Dbar_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi)#, floating = False) +DDstar_s = zfit.Parameter("DDstar_s", ztf.constant(0.0), lower_limit=-0.3, upper_limit=0.3)#, floating = False) +Dstar_m = zfit.Parameter("Dstar_m", ztf.constant(Dstar_mass), floating = False) +D_m = zfit.Parameter("D_m", ztf.constant(D_mass), floating = False) +DDstar_p = zfit.Parameter("DDstar_p", ztf.constant(DDstar_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi)#, floating = False) + + +# ## Tau parameters + +# In[ ]: + + +tau_m = zfit.Parameter("tau_m", ztf.constant(pdg['tau_M']), floating = False) +Ctt = zfit.Parameter("Ctt", ztf.constant(0.0), lower_limit=-2.5, upper_limit=2.5) + + +# ## Load data + +# In[ ]: + + +x_min = 2*pdg['muon_M'] +x_max = (pdg["Bplus_M"]-pdg["Ks_M"]-0.1) + +# # Full spectrum + +obs_toy = zfit.Space('q', limits = (x_min, x_max)) + +# Jpsi and Psi2s cut out + +obs1 = zfit.Space('q', limits = (x_min, jpsi_mass - 60.)) +obs2 = zfit.Space('q', limits = (jpsi_mass + 70., psi2s_mass - 50.)) +obs3 = zfit.Space('q', limits = (psi2s_mass + 50., x_max)) + +obs_fit = obs1 + obs2 + obs3 + +# with open(r"./data/slim_points/slim_points_toy_0_range({0}-{1}).pkl".format(int(x_min), int(x_max)), "rb") as input_file: +# part_set = pkl.load(input_file) + +# x_part = part_set['x_part'] + +# x_part = x_part.astype('float64') + +# data = zfit.data.Data.from_numpy(array=x_part, obs=obs) + + +# ## Setup pdf + +# In[ ]: + + +total_f = total_pdf_cut(obs=obs_toy, jpsi_mass = jpsi_m, jpsi_scale = jpsi_s, jpsi_phase = jpsi_p, jpsi_width = jpsi_w, + psi2s_mass = psi2s_m, psi2s_scale = psi2s_s, psi2s_phase = psi2s_p, psi2s_width = psi2s_w, + p3770_mass = p3770_m, p3770_scale = p3770_s, p3770_phase = p3770_p, p3770_width = p3770_w, + p4040_mass = p4040_m, p4040_scale = p4040_s, p4040_phase = p4040_p, p4040_width = p4040_w, + p4160_mass = p4160_m, p4160_scale = p4160_s, p4160_phase = p4160_p, p4160_width = p4160_w, + p4415_mass = p4415_m, p4415_scale = p4415_s, p4415_phase = p4415_p, p4415_width = p4415_w, + rho_mass = rho_m, rho_scale = rho_s, rho_phase = rho_p, rho_width = rho_w, + omega_mass = omega_m, omega_scale = omega_s, omega_phase = omega_p, omega_width = omega_w, + phi_mass = phi_m, phi_scale = phi_s, phi_phase = phi_p, phi_width = phi_w, + Dstar_mass = Dstar_m, DDstar_scale = DDstar_s, DDstar_phase = DDstar_p, D_mass = D_m, + Dbar_mass = Dbar_m, Dbar_scale = Dbar_s, Dbar_phase = Dbar_p, + tau_mass = tau_m, C_tt = Ctt, b0_0 = b0_0, b0_1 = b0_1, b0_2 = b0_2, + bplus_0 = bplus_0, bplus_1 = bplus_1, bplus_2 = bplus_2, + bT_0 = bT_0, bT_1 = bT_1, bT_2 = bT_2) + +total_f_fit = total_pdf_full(obs=obs_fit, jpsi_mass = jpsi_m, jpsi_scale = jpsi_s, jpsi_phase = jpsi_p, jpsi_width = jpsi_w, + psi2s_mass = psi2s_m, psi2s_scale = psi2s_s, psi2s_phase = psi2s_p, psi2s_width = psi2s_w, + p3770_mass = p3770_m, p3770_scale = p3770_s, p3770_phase = p3770_p, p3770_width = p3770_w, + p4040_mass = p4040_m, p4040_scale = p4040_s, p4040_phase = p4040_p, p4040_width = p4040_w, + p4160_mass = p4160_m, p4160_scale = p4160_s, p4160_phase = p4160_p, p4160_width = p4160_w, + p4415_mass = p4415_m, p4415_scale = p4415_s, p4415_phase = p4415_p, p4415_width = p4415_w, + rho_mass = rho_m, rho_scale = rho_s, rho_phase = rho_p, rho_width = rho_w, + omega_mass = omega_m, omega_scale = omega_s, omega_phase = omega_p, omega_width = omega_w, + phi_mass = phi_m, phi_scale = phi_s, phi_phase = phi_p, phi_width = phi_w, + Dstar_mass = Dstar_m, DDstar_scale = DDstar_s, DDstar_phase = DDstar_p, D_mass = D_m, + Dbar_mass = Dbar_m, Dbar_scale = Dbar_s, Dbar_phase = Dbar_p, + tau_mass = tau_m, C_tt = Ctt, b0_0 = b0_0, b0_1 = b0_1, b0_2 = b0_2, + bplus_0 = bplus_0, bplus_1 = bplus_1, bplus_2 = bplus_2, + bT_0 = bT_0, bT_1 = bT_1, bT_2 = bT_2) + +# print(total_pdf.obs) + +# print(calcs_test) + +# for param in total_f.get_dependents(): +# print(zfit.run(param)) + + +# In[ ]: + + +# total_f_fit.normalization(obs_fit) + + +# ## Test if graphs actually work and compute values + +# In[ ]: + + +# def total_test_tf(xq): + +# def jpsi_res(q): +# return resonance(q, jpsi_m, jpsi_s, jpsi_p, jpsi_w) + +# def psi2s_res(q): +# return resonance(q, psi2s_m, psi2s_s, psi2s_p, psi2s_w) + +# def cusp(q): +# return bifur_gauss(q, cusp_m, sig_L, sig_R, cusp_s) + +# funcs = jpsi_res(xq) + psi2s_res(xq) + cusp(xq) + +# vec_f = vec(xq, funcs) + +# axiv_nr = axiv_nonres(xq) + +# tot = vec_f + axiv_nr + +# return tot + +# def jpsi_res(q): +# return resonance(q, jpsi_m, jpsi_s, jpsi_p, jpsi_w) + +# calcs = zfit.run(total_test_tf(x_part)) + + + +test_q = np.linspace(x_min, x_max, int(2e6)) + +probs = total_f_fit.pdf(test_q, norm_range=False) + +calcs_test = zfit.run(probs) + +Ctt.set_value(0.5) + +calcs_test1 = zfit.run(probs) + +Ctt.set_value(0.0) + +Dbar_s.set_value(0.3) + +DDstar_s.set_value(0.3) + +calcs_test2 = zfit.run(probs) +# res_y = zfit.run(jpsi_res(test_q)) +# b0 = [b0_0, b0_1, b0_2] +# bplus = [bplus_0, bplus_1, bplus_2] +# bT = [bT_0, bT_1, bT_2] +# f0_y = zfit.run(tf.math.real(formfactor(test_q,"0", b0, bplus, bT))) +# fplus_y = zfit.run(tf.math.real(formfactor(test_q,"+", b0, bplus, bT))) +# fT_y = zfit.run(tf.math.real(formfactor(test_q,"T", b0, bplus, bT))) + + +# In[ ]: + + +plt.clf() +# plt.plot(x_part, calcs, '.') +plt.plot(test_q, calcs_test, label = 'pdf (Ctt = 0.0)') +plt.plot(test_q, calcs_test1, label = 'pdf (Ctt = 0.5)') +plt.plot(test_q, calcs_test2, label = 'pdf (D-contribs = 0.3)') +# plt.plot(test_q, f0_y, label = '0') +# plt.plot(test_q, fT_y, label = 'T') +# plt.plot(test_q, fplus_y, label = '+') +# plt.plot(test_q, res_y, label = 'res') +plt.legend() +plt.ylim(0.0, 1.5e-6) +# plt.yscale('log') +# plt.xlim(770, 785) +plt.savefig('test.png') +# print(jpsi_width) + + +# In[ ]: + + + + +# probs = mixture.prob(test_q) +# probs_np = zfit.run(probs) +# probs_np *= np.max(calcs_test) / np.max(probs_np) +# plt.figure() +# plt.semilogy(test_q, probs_np,label="importance sampling") +# plt.semilogy(test_q, calcs_test, label = 'pdf') + + +# In[ ]: + + +# 0.213/(0.00133+0.213+0.015) + + +# ## Adjust scaling of different parts + +# In[ ]: + + +total_f.update_integration_options(draws_per_dim=2000000, mc_sampler=None) +# inte = total_f.integrate(limits = (950., 1050.), norm_range=False) +# inte_fl = zfit.run(inte) +# print(inte_fl/4500) +# print(pdg["jpsi_BR"]/pdg["NR_BR"], inte_fl*pdg["psi2s_auc"]/pdg["NR_auc"]) + + +# In[ ]: + + +# # print("jpsi:", inte_fl) +# # print("Increase am by factor:", np.sqrt(pdg["jpsi_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) +# # print("New amp:", pdg["jpsi"][3]*np.sqrt(pdg["jpsi_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) + +# # print("psi2s:", inte_fl) +# # print("Increase am by factor:", np.sqrt(pdg["psi2s_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) +# # print("New amp:", pdg["psi2s"][3]*np.sqrt(pdg["psi2s_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) + +# name = "phi" + +# print(name+":", inte_fl) +# print("Increase am by factor:", np.sqrt(pdg[name+"_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) +# print("New amp:", pdg[name][0]*np.sqrt(pdg[name+"_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) + + +# print(x_min) +# print(x_max) +# # total_f.update_integration_options(draws_per_dim=2000000, mc_sampler=None) +# total_f.update_integration_options(mc_sampler=lambda dim, num_results, +# dtype: tf.random_uniform(maxval=1., shape=(num_results, dim), dtype=dtype), +# draws_per_dim=1000000) +# # _ = [] + +# # for i in range(10): + +# # inte = total_f.integrate(limits = (x_min, x_max)) +# # inte_fl = zfit.run(inte) +# # print(inte_fl) +# # _.append(inte_fl) + +# # print("mean:", np.mean(_)) + +# _ = time.time() + +# inte = total_f.integrate(limits = (x_min, x_max)) +# inte_fl = zfit.run(inte) +# print(inte_fl) +# print("Time taken: {}".format(display_time(int(time.time() - _)))) + +# print(pdg['NR_BR']/pdg['NR_auc']*inte_fl) +# print(0.25**2*4.2/1000) + + +# # Sampling +# ## Mixture distribution for sampling + +# In[ ]: + + + + +# print(list_of_borders[:9]) +# print(list_of_borders[-9:]) + + +class UniformSampleAndWeights(zfit.util.execution.SessionHolderMixin): + def __call__(self, limits, dtype, n_to_produce): + # n_to_produce = tf.cast(n_to_produce, dtype=tf.int32) + low, high = limits.limit1d + low = tf.cast(low, dtype=dtype) + high = tf.cast(high, dtype=dtype) +# uniform = tfd.Uniform(low=low, high=high) +# uniformjpsi = tfd.Uniform(low=tf.constant(3080, dtype=dtype), high=tf.constant(3112, dtype=dtype)) +# uniformpsi2s = tfd.Uniform(low=tf.constant(3670, dtype=dtype), high=tf.constant(3702, dtype=dtype)) + +# list_of_borders = [] +# _p = [] +# splits = 10 + +# _ = np.linspace(x_min, x_max, splits) + +# for i in range(splits): +# list_of_borders.append(tf.constant(_[i], dtype=dtype)) +# _p.append(tf.constant(1/splits, dtype=dtype)) + +# mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=_p[:(splits-1)]), +# components_distribution=tfd.Uniform(low=list_of_borders[:(splits-1)], +# high=list_of_borders[-(splits-1):])) + mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=[tf.constant(0.05, dtype=dtype), + tf.constant(0.93, dtype=dtype), + tf.constant(0.05, dtype=dtype), + tf.constant(0.065, dtype=dtype), + tf.constant(0.04, dtype=dtype), + tf.constant(0.05, dtype=dtype)]), + components_distribution=tfd.Uniform(low=[tf.constant(x_min, dtype=dtype), + tf.constant(3090, dtype=dtype), + tf.constant(3681, dtype=dtype), + tf.constant(3070, dtype=dtype), + tf.constant(1000, dtype=dtype), + tf.constant(3660, dtype=dtype)], + high=[tf.constant(x_max, dtype=dtype), + tf.constant(3102, dtype=dtype), + tf.constant(3691, dtype=dtype), + tf.constant(3110, dtype=dtype), + tf.constant(1040, dtype=dtype), + tf.constant(3710, dtype=dtype)])) +# dtype = tf.float64 +# mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=[tf.constant(0.04, dtype=dtype), +# tf.constant(0.90, dtype=dtype), +# tf.constant(0.02, dtype=dtype), +# tf.constant(0.07, dtype=dtype), +# tf.constant(0.02, dtype=dtype)]), +# components_distribution=tfd.Uniform(low=[tf.constant(x_min, dtype=dtype), +# tf.constant(3089, dtype=dtype), +# tf.constant(3103, dtype=dtype), +# tf.constant(3681, dtype=dtype), +# tf.constant(3691, dtype=dtype)], +# high=[tf.constant(3089, dtype=dtype), +# tf.constant(3103, dtype=dtype), +# tf.constant(3681, dtype=dtype), +# tf.constant(3691, dtype=dtype), +# tf.constant(x_max, dtype=dtype)])) +# mixture = tfd.Uniform(tf.constant(x_min, dtype=dtype), tf.constant(x_max, dtype=dtype)) +# sample = tf.random.uniform((n_to_produce, 1), dtype=dtype) + sample = mixture.sample((n_to_produce, 1)) +# sample = tf.random.uniform((n_to_produce, 1), dtype=dtype) + weights = mixture.prob(sample)[:,0] +# weights = tf.broadcast_to(tf.constant(1., dtype=dtype), shape=(n_to_produce,)) + # sample = tf.expand_dims(sample, axis=-1) +# print(sample, weights) + +# weights = tf.ones(shape=(n_to_produce,), dtype=dtype) + weights_max = None + thresholds = tf.random_uniform(shape=(n_to_produce,), dtype=dtype) + return sample, thresholds, weights, weights_max, n_to_produce + + +# In[ ]: + + +# total_f._sample_and_weights = UniformSampleAndWeights + + +# In[ ]: + + +# 0.00133/(0.00133+0.213+0.015)*(x_max-3750)/(x_max-x_min) + + +# In[ ]: + + +# zfit.settings.set_verbosity(10) + + +# In[ ]: + + +# # zfit.run.numeric_checks = False + +# nr_of_toys = 1 +# nevents = int(pdg["number_of_decays"]) +# nevents = pdg["number_of_decays"] +# event_stack = 1000000 +# # zfit.settings.set_verbosity(10) +# calls = int(nevents/event_stack + 1) + +# total_samp = [] + +# start = time.time() + +# sampler = total_f.create_sampler(n=event_stack) + +# for toy in range(nr_of_toys): + +# dirName = 'data/zfit_toys/toy_{0}'.format(toy) + +# if not os.path.exists(dirName): +# os.mkdir(dirName) +# print("Directory " , dirName , " Created ") + +# for call in range(calls): + +# sampler.resample(n=event_stack) +# s = sampler.unstack_x() +# sam = zfit.run(s) +# # clear_output(wait=True) + +# c = call + 1 + +# print("{0}/{1} of Toy {2}/{3}".format(c, calls, toy+1, nr_of_toys)) +# print("Time taken: {}".format(display_time(int(time.time() - start)))) +# print("Projected time left: {}".format(display_time(int((time.time() - start)/(c+calls*(toy))*((nr_of_toys-toy)*calls-c))))) + +# with open("data/zfit_toys/toy_{0}/{1}.pkl".format(toy, call), "wb") as f: +# pkl.dump(sam, f, pkl.HIGHEST_PROTOCOL) + + +# In[ ]: + + +# with open(r"data/zfit_toys/toy_0/0.pkl", "rb") as input_file: +# sam = pkl.load(input_file) +# print(sam[:10]) + +# with open(r"data/zfit_toys/toy_0/1.pkl", "rb") as input_file: +# sam2 = pkl.load(input_file) +# print(sam2[:10]) + +# print(np.sum(sam-sam2)) + + +# In[ ]: + + +# print("Time to generate full toy: {} s".format(int(time.time()-start))) + +# total_samp = [] + +# for call in range(calls): +# with open(r"data/zfit_toys/toy_0/{}.pkl".format(call), "rb") as input_file: +# sam = pkl.load(input_file) +# total_samp = np.append(total_samp, sam) + +# total_samp = total_samp.astype('float64') + +# data2 = zfit.data.Data.from_numpy(array=total_samp[:int(nevents)], obs=obs) + +# data3 = zfit.data.Data.from_numpy(array=total_samp, obs=obs) + +# print(total_samp[:nevents].shape) + + +# In[ ]: + + +# plt.clf() + +# bins = int((x_max-x_min)/7) + +# # calcs = zfit.run(total_test_tf(samp)) +# print(total_samp[:nevents].shape) + +# plt.hist(total_samp[:nevents], bins = bins, range = (x_min,x_max), label = 'data') +# # plt.plot(test_q, calcs_test*nevents , label = 'pdf') + +# # plt.plot(sam, calcs, '.') +# # plt.plot(test_q, calcs_test) +# # plt.yscale('log') +# plt.ylim(0, 200) +# # plt.xlim(3080, 3110) + +# plt.legend() + +# plt.savefig('test2.png') + + +# In[ ]: + + +# sampler = total_f.create_sampler(n=nevents) +# nll = zfit.loss.UnbinnedNLL(model=total_f, data=sampler, fit_range = (x_min, x_max)) + +# # for param in pdf.get_dependents(): +# # param.set_value(initial_value) + +# sampler.resample(n=nevents) + +# # Randomise initial values +# # for param in pdf.get_dependents(): +# # param.set_value(random value here) + +# # Minimise the NLL +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 10) +# minimum = minimizer.minimize(nll) + + +# In[ ]: + + +# jpsi_width + + +# In[ ]: + + +# plt.hist(sample, weights=1 / prob(sample)) + + +# # Fitting + +# In[ ]: + + +# start = time.time() + +# for param in total_f.get_dependents(): +# param.randomize() + +# # for param in total_f.get_dependents(): +# # print(zfit.run(param)) + +# nll = zfit.loss.UnbinnedNLL(model=total_f, data=data2, fit_range = (x_min, x_max)) + +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) +# # minimizer._use_tfgrad = False +# result = minimizer.minimize(nll) + +# # param_errors = result.error() + +# # for var, errors in param_errors.items(): +# # print('{}: ^{{+{}}}_{{{}}}'.format(var.name, errors['upper'], errors['lower'])) + +# print("Function minimum:", result.fmin) +# # print("Results:", result.params) +# print("Hesse errors:", result.hesse()) + + +# In[ ]: + + +# print("Time taken for fitting: {}".format(display_time(int(time.time()-start)))) + +# # probs = total_f.pdf(test_q) + +# calcs_test = zfit.run(probs) +# res_y = zfit.run(jpsi_res(test_q)) + + +# In[ ]: + + +# plt.clf() +# # plt.plot(x_part, calcs, '.') +# plt.plot(test_q, calcs_test, label = 'pdf') +# # plt.plot(test_q, res_y, label = 'res') +# plt.legend() +# plt.ylim(0.0, 10e-6) +# # plt.yscale('log') +# # plt.xlim(3080, 3110) +# plt.savefig('test3.png') +# # print(jpsi_width) + + +# In[ ]: + + +# _tot = 4.37e-7+6.02e-5+4.97e-6 +# _probs = [] +# _probs.append(6.02e-5/_tot) +# _probs.append(4.97e-6/_tot) +# _probs.append(4.37e-7/_tot) +# print(_probs) + + +# In[ ]: + + +# dtype = 'float64' +# # mixture = tfd.Uniform(tf.constant(x_min, dtype=dtype), tf.constant(x_max, dtype=dtype)) +# mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=[tf.constant(0.007, dtype=dtype), +# tf.constant(0.917, dtype=dtype), +# tf.constant(0.076, dtype=dtype)]), +# components_distribution=tfd.Uniform(low=[tf.constant(x_min, dtype=dtype), +# tf.constant(3080, dtype=dtype), +# tf.constant(3670, dtype=dtype)], +# high=[tf.constant(x_max, dtype=dtype), +# tf.constant(3112, dtype=dtype), +# tf.constant(3702, dtype=dtype)])) +# # for i in range(10): +# # print(zfit.run(mixture.prob(mixture.sample((10, 1))))) + + +# In[ ]: + + +# print((zfit.run(jpsi_p)%(2*np.pi))/np.pi) +# print((zfit.run(psi2s_p)%(2*np.pi))/np.pi) + + +# In[ ]: + + +# def jpsi_res(q): +# return resonance(q, _mass = jpsi_mass, scale = jpsi_scale, +# phase = jpsi_phase, width = jpsi_width) + +# def psi2s_res(q): +# return resonance(q, _mass = psi2s_mass, scale = psi2s_scale, +# phase = psi2s_phase, width = psi2s_width) + +# def p3770_res(q): +# return resonance(q, _mass = p3770_mass, scale = p3770_scale, +# phase = p3770_phase, width = p3770_width) + +# def p4040_res(q): +# return resonance(q, _mass = p4040_mass, scale = p4040_scale, +# phase = p4040_phase, width = p4040_width) + +# def p4160_res(q): +# return resonance(q, _mass = p4160_mass, scale = p4160_scale, +# phase = p4160_phase, width = p4160_width) + +# def p4415_res(q): +# return resonance(q, _mass = p4415_mass, scale = p4415_scale, +# phase = p4415_phase, width = p4415_width) + + +# In[ ]: + + +# 0.15**2*4.2/1000 +# result.hesse() + + +# ## Constraints + +# In[ ]: + + +# 1. Constraint - Real part of sum of Psi contrib and D contribs + +sum_list = [] + +sum_list.append(ztf.to_complex(jpsi_s) * tf.exp(tf.complex(ztf.constant(0.0), jpsi_p)) * ztf.to_complex(jpsi_w / (tf.pow(jpsi_m,3)))) +sum_list.append(ztf.to_complex(psi2s_s) * tf.exp(tf.complex(ztf.constant(0.0), psi2s_p)) * ztf.to_complex(psi2s_w / (tf.pow(psi2s_m,3)))) +sum_list.append(ztf.to_complex(p3770_s) * tf.exp(tf.complex(ztf.constant(0.0), p3770_p)) * ztf.to_complex(p3770_w / (tf.pow(p3770_m,3)))) +sum_list.append(ztf.to_complex(p4040_s) * tf.exp(tf.complex(ztf.constant(0.0), p4040_p)) * ztf.to_complex(p4040_w / (tf.pow(p4040_m,3)))) +sum_list.append(ztf.to_complex(p4160_s) * tf.exp(tf.complex(ztf.constant(0.0), p4160_p)) * ztf.to_complex(p4160_w / (tf.pow(p4160_m,3)))) +sum_list.append(ztf.to_complex(p4415_s) * tf.exp(tf.complex(ztf.constant(0.0), p4415_p)) * ztf.to_complex(p4415_w / (tf.pow(p4415_m,3)))) +sum_list.append(ztf.to_complex(DDstar_s) * tf.exp(tf.complex(ztf.constant(0.0), DDstar_p)) * (ztf.to_complex(1.0 / (10.0*tf.pow(Dstar_m,2)) + 1.0 / (10.0*tf.pow(D_m,2))))) +sum_list.append(ztf.to_complex(Dbar_s) * tf.exp(tf.complex(ztf.constant(0.0), Dbar_p)) * ztf.to_complex(1.0 / (6.0*tf.pow(Dbar_m,2)))) + +sum_ru_1 = ztf.to_complex(ztf.constant(0.0)) + +for part in sum_list: + sum_ru_1 += part + +sum_1 = tf.math.real(sum_ru_1) +# constraint1 = zfit.constraint.GaussianConstraint(params = sum_1, mu = ztf.constant(1.7*10**-8), +# sigma = ztf.constant(2.2*10**-8)) + +constraint1 = tf.pow((sum_1-ztf.constant(1.7*10**-8))/ztf.constant(2.2*10**-8),2)/ztf.constant(2.) + +# 2. Constraint - Abs. of sum of Psi contribs and D contribs + +sum_2 = tf.abs(sum_ru_1) +constraint2 = tf.cond(tf.greater_equal(sum_2, 5.0e-8), lambda: 100000., lambda: 0.) + +# 3. Constraint - Maximum eta of D contribs + +constraint3_0 = tf.cond(tf.greater_equal(tf.abs(Dbar_s), 0.2), lambda: 100000., lambda: 0.) + +constraint3_1 = tf.cond(tf.greater_equal(tf.abs(DDstar_s), 0.2), lambda: 100000., lambda: 0.) + +# 4. Constraint - Formfactor multivariant gaussian covariance fplus + +Cov_matrix = [[ztf.constant( 1.), ztf.constant( 0.45), ztf.constant( 0.19), ztf.constant(0.857), ztf.constant(0.598), ztf.constant(0.531), ztf.constant(0.752), ztf.constant(0.229), ztf.constant(0,117)], + [ztf.constant( 0.45), ztf.constant( 1.), ztf.constant(0.677), ztf.constant(0.708), ztf.constant(0.958), ztf.constant(0.927), ztf.constant(0.227), ztf.constant(0.443), ztf.constant(0.287)], + [ztf.constant( 0.19), ztf.constant(0.677), ztf.constant( 1.), ztf.constant(0.595), ztf.constant(0.770), ztf.constant(0.819),ztf.constant(-0.023), ztf.constant( 0.07), ztf.constant(0.196)], + [ztf.constant(0.857), ztf.constant(0.708), ztf.constant(0.595), ztf.constant( 1.), ztf.constant( 0.83), ztf.constant(0.766), ztf.constant(0.582), ztf.constant(0.237), ztf.constant(0.192)], + [ztf.constant(0.598), ztf.constant(0.958), ztf.constant(0.770), ztf.constant( 0.83), ztf.constant( 1.), ztf.constant(0.973), ztf.constant(0.324), ztf.constant(0.372), ztf.constant(0.272)], + [ztf.constant(0.531), ztf.constant(0.927), ztf.constant(0.819), ztf.constant(0.766), ztf.constant(0.973), ztf.constant( 1.), ztf.constant(0.268), ztf.constant(0.332), ztf.constant(0.269)], + [ztf.constant(0.752), ztf.constant(0.227),ztf.constant(-0.023), ztf.constant(0.582), ztf.constant(0.324), ztf.constant(0.268), ztf.constant( 1.), ztf.constant( 0.59), ztf.constant(0.515)], + [ztf.constant(0.229), ztf.constant(0.443), ztf.constant( 0.07), ztf.constant(0.237), ztf.constant(0.372), ztf.constant(0.332), ztf.constant( 0.59), ztf.constant( 1.), ztf.constant(0.897)], + [ztf.constant(0.117), ztf.constant(0.287), ztf.constant(0.196), ztf.constant(0.192), ztf.constant(0.272), ztf.constant(0.269), ztf.constant(0.515), ztf.constant(0.897), ztf.constant( 1.)]] + +def triGauss(val1,val2,val3,m = Cov_matrix): + + mean1 = ztf.constant(0.466) + mean2 = ztf.constant(-0.885) + mean3 = ztf.constant(-0.213) + sigma1 = ztf.constant(0.014) + sigma2 = ztf.constant(0.128) + sigma3 = ztf.constant(0.548) + x1 = (val1-mean1)/sigma1 + x2 = (val2-mean2)/sigma2 + x3 = (val3-mean3)/sigma3 + rho12 = m[0][1] + rho13 = m[0][2] + rho23 = m[1][2] + w = x1*x1*(rho23*rho23-1) + x2*x2*(rho13*rho13-1)+x3*x3*(rho12*rho12-1)+2*(x1*x2*(rho12-rho13*rho23)+x1*x3*(rho13-rho12*rho23)+x2*x3*(rho23-rho12*rho13)) + d = 2*(rho12*rho12+rho13*rho13+rho23*rho23-2*rho12*rho13*rho23-1) + + fcn = -w/d + chisq = -2*fcn + return chisq + +constraint4 = triGauss(bplus_0, bplus_1, bplus_2) + +# mean1 = ztf.constant(0.466) +# mean2 = ztf.constant(-0.885) +# mean3 = ztf.constant(-0.213) +# sigma1 = ztf.constant(0.014) +# sigma2 = ztf.constant(0.128) +# sigma3 = ztf.constant(0.548) +# constraint4_0 = tf.pow((bplus_0-mean1)/sigma1,2)/ztf.constant(2.) +# constraint4_1 = tf.pow((bplus_1-mean2)/sigma2,2)/ztf.constant(2.) +# constraint4_2 = tf.pow((bplus_2-mean3)/sigma3,2)/ztf.constant(2.) + +# 5. Constraint - Abs. of sum of light contribs + +sum_list_5 = [] + +sum_list_5.append(rho_s*rho_w/rho_m) +sum_list_5.append(omega_s*omega_w/omega_m) +sum_list_5.append(phi_s*phi_w/phi_m) + + +sum_ru_5 = ztf.constant(0.0) + +for part in sum_list_5: + sum_ru_5 += part + +constraint5 = tf.cond(tf.greater_equal(tf.abs(sum_ru_5), ztf.constant(0.02)), lambda: 100000., lambda: 0.) + +# 6. Constraint on phases of Jpsi and Psi2s for cut out fit + + +# constraint6_0 = zfit.constraint.GaussianConstraint(params = jpsi_p, mu = ztf.constant(pdg["jpsi_phase_unc"]), +# sigma = ztf.constant(jpsi_phase)) +# constraint6_1 = zfit.constraint.GaussianConstraint(params = psi2s_p, mu = ztf.constant(pdg["psi2s_phase_unc"]), +# sigma = ztf.constant(psi2s_phase)) + +constraint6_0 = tf.pow((jpsi_p-ztf.constant(jpsi_phase))/ztf.constant(pdg["jpsi_phase_unc"]),2)/ztf.constant(2.) +constraint6_1 = tf.pow((psi2s_p-ztf.constant(psi2s_phase))/ztf.constant(pdg["psi2s_phase_unc"]),2)/ztf.constant(2.) + +# 7. Constraint on Ctt with higher limits + +constraint7 = tf.cond(tf.greater_equal(Ctt*Ctt, 0.25), lambda: 100000., lambda: 0.) + +constraint7dtype = tf.float64 + +# zfit.run(constraint6_0) + +# ztf.convert_to_tensor(constraint6_0) + +#List of all constraints + +constraints = [constraint1, constraint2, constraint3_0, constraint3_1,# constraint4, #constraint4_0, constraint4_1, constraint4_2, + constraint6_0, constraint6_1]#, constraint7] + + +# ## Reset params + +# In[ ]: + + +param_values_dic = { + 'jpsi_m': jpsi_mass, + 'jpsi_s': jpsi_scale, + 'jpsi_p': jpsi_phase, + 'jpsi_w': jpsi_width, + 'psi2s_m': psi2s_mass, + 'psi2s_s': psi2s_scale, + 'psi2s_p': psi2s_phase, + 'psi2s_w': psi2s_width, + 'p3770_m': p3770_mass, + 'p3770_s': p3770_scale, + 'p3770_p': p3770_phase, + 'p3770_w': p3770_width, + 'p4040_m': p4040_mass, + 'p4040_s': p4040_scale, + 'p4040_p': p4040_phase, + 'p4040_w': p4040_width, + 'p4160_m': p4160_mass, + 'p4160_s': p4160_scale, + 'p4160_p': p4160_phase, + 'p4160_w': p4160_width, + 'p4415_m': p4415_mass, + 'p4415_s': p4415_scale, + 'p4415_p': p4415_phase, + 'p4415_w': p4415_width, + 'rho_m': rho_mass, + 'rho_s': rho_scale, + 'rho_p': rho_phase, + 'rho_w': rho_width, + 'omega_m': omega_mass, + 'omega_s': omega_scale, + 'omega_p': omega_phase, + 'omega_w': omega_width, + 'phi_m': phi_mass, + 'phi_s': phi_scale, + 'phi_p': phi_phase, + 'phi_w': phi_width, + 'Dstar_m': Dstar_mass, + 'DDstar_s': 0.0, + 'DDstar_p': 0.0, + 'D_m': D_mass, + 'Dbar_m': Dbar_mass, + 'Dbar_s': 0.0, + 'Dbar_p': 0.0, + 'tau_m': pdg['tau_M'], + 'Ctt': 0.0, + 'b0_0': 0.292, + 'b0_1': 0.281, + 'b0_2': 0.150, + 'bplus_0': 0.466, + 'bplus_1': -0.885, + 'bplus_2': -0.213, + 'bT_0': 0.460, + 'bT_1': -1.089, + 'bT_2': -1.114} + + +def reset_param_values(variation = 0.05): + for param in total_f_fit.get_dependents(): + if param.floating: + param.set_value(param_values_dic[param.name] + random.uniform(-1, 1) * param_values_dic[param.name]* variation) +# print(param.name) +# for param in totalf.get_dependents(): +# param.set_value() + + +# # Analysis + +# In[ ]: + + +# # zfit.run.numeric_checks = False + +# fitting_range = 'cut' +# total_BR = 1.7e-10 + 4.9e-10 + 2.5e-9 + 6.02e-5 + 4.97e-6 + 1.38e-9 + 4.2e-10 + 2.6e-9 + 6.1e-10 + 4.37e-7 +# cut_BR = 1.0 - (6.02e-5 + 4.97e-6)/total_BR + +# Ctt_list = [] +# Ctt_error_list = [] + +# nr_of_toys = 1 +# if fitting_range == 'cut': +# nevents = int(pdg["number_of_decays"]*cut_BR) +# else: +# nevents = int(pdg["number_of_decays"]) +# # nevents = pdg["number_of_decays"] +# event_stack = 1000000 +# # nevents *= 41 +# # zfit.settings.set_verbosity(10) +# calls = int(nevents/event_stack + 1) + +# total_samp = [] + +# start = time.time() + +# sampler = total_f.create_sampler(n=event_stack) + +# for toy in range(nr_of_toys): + +# ### Generate data + +# # clear_output(wait=True) + +# print("Toy {}: Generating data...".format(toy)) + +# dirName = 'data/zfit_toys/toy_{0}'.format(toy) + +# if not os.path.exists(dirName): +# os.mkdir(dirName) +# print("Directory " , dirName , " Created ") + +# reset_param_values() + +# if fitting_range == 'cut': + +# sampler.resample(n=nevents) +# s = sampler.unstack_x() +# sam = zfit.run(s) +# calls = 0 +# c = 1 + +# else: +# for call in range(calls): + +# sampler.resample(n=event_stack) +# s = sampler.unstack_x() +# sam = zfit.run(s) + +# c = call + 1 + +# with open("data/zfit_toys/toy_{0}/{1}.pkl".format(toy, call), "wb") as f: +# pkl.dump(sam, f, pkl.HIGHEST_PROTOCOL) + +# print("Toy {}: Data generation finished".format(toy)) + +# ### Load data + +# print("Toy {}: Loading data...".format(toy)) + +# if fitting_range == 'cut': + +# total_samp = sam + +# else: + +# for call in range(calls): +# with open(r"data/zfit_toys/toy_0/{}.pkl".format(call), "rb") as input_file: +# sam = pkl.load(input_file) +# total_samp = np.append(total_samp, sam) + +# total_samp = total_samp.astype('float64') + +# if fitting_range == 'full': + +# data = zfit.data.Data.from_numpy(array=total_samp[:int(nevents)], obs=obs) + +# print("Toy {}: Loading data finished".format(toy)) + +# ### Fit data + +# print("Toy {}: Fitting pdf...".format(toy)) + +# for param in total_f.get_dependents(): +# param.randomize() + +# nll = zfit.loss.UnbinnedNLL(model=total_f, data=data, fit_range = (x_min, x_max), constraints = constraints) + +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) +# # minimizer._use_tfgrad = False +# result = minimizer.minimize(nll) + +# print("Toy {}: Fitting finished".format(toy)) + +# print("Function minimum:", result.fmin) +# print("Hesse errors:", result.hesse()) + +# params = result.params +# Ctt_list.append(params[Ctt]['value']) +# Ctt_error_list.append(params[Ctt]['minuit_hesse']['error']) + +# #plotting the result + +# plotdirName = 'data/plots'.format(toy) + +# if not os.path.exists(plotdirName): +# os.mkdir(plotdirName) +# # print("Directory " , dirName , " Created ") + +# probs = total_f.pdf(test_q, norm_range=False) +# calcs_test = zfit.run(probs) +# plt.clf() +# plt.plot(test_q, calcs_test, label = 'pdf') +# plt.legend() +# plt.ylim(0.0, 6e-6) +# plt.savefig(plotdirName + '/toy_fit_full_range{}.png'.format(toy)) + +# print("Toy {0}/{1}".format(toy+1, nr_of_toys)) +# print("Time taken: {}".format(display_time(int(time.time() - start)))) +# print("Projected time left: {}".format(display_time(int((time.time() - start)/(c+calls*(toy))*((nr_of_toys-toy)*calls-c))))) + +# if fitting_range == 'cut': + +# _1 = np.where((total_samp >= x_min) & (total_samp <= (jpsi_mass - 60.))) + +# tot_sam_1 = total_samp[_1] + +# _2 = np.where((total_samp >= (jpsi_mass + 70.)) & (total_samp <= (psi2s_mass - 50.))) + +# tot_sam_2 = total_samp[_2] + +# _3 = np.where((total_samp >= (psi2s_mass + 50.)) & (total_samp <= x_max)) + +# tot_sam_3 = total_samp[_3] + +# tot_sam = np.append(tot_sam_1, tot_sam_2) +# tot_sam = np.append(tot_sam, tot_sam_3) + +# data = zfit.data.Data.from_numpy(array=tot_sam[:int(nevents)], obs=obs_fit) + +# print("Toy {}: Loading data finished".format(toy)) + +# ### Fit data + +# print("Toy {}: Fitting pdf...".format(toy)) + +# for param in total_f_fit.get_dependents(): +# param.randomize() + +# nll = zfit.loss.UnbinnedNLL(model=total_f_fit, data=data, constraints = constraints) + +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) +# # minimizer._use_tfgrad = False +# result = minimizer.minimize(nll) + +# print("Function minimum:", result.fmin) +# print("Hesse errors:", result.hesse()) + +# params = result.params + +# if result.converged: +# Ctt_list.append(params[Ctt]['value']) +# Ctt_error_list.append(params[Ctt]['minuit_hesse']['error']) + +# #plotting the result + +# plotdirName = 'data/plots'.format(toy) + +# if not os.path.exists(plotdirName): +# os.mkdir(plotdirName) +# # print("Directory " , dirName , " Created ") + +# plt.clf() +# plt.hist(tot_sam, bins = int((x_max-x_min)/7.), label = 'toy data') +# plt.savefig(plotdirName + '/toy_histo_cut_region{}.png'.format(toy)) + + +# probs = total_f_fit.pdf(test_q, norm_range=False) +# calcs_test = zfit.run(probs) +# plt.clf() +# plt.plot(test_q, calcs_test, label = 'pdf') +# plt.axvline(x=jpsi_mass-60.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.axvline(x=jpsi_mass+70.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.axvline(x=psi2s_mass-50.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.axvline(x=psi2s_mass+50.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.legend() +# plt.ylim(0.0, 1.5e-6) +# plt.savefig(plotdirName + '/toy_fit_cut_region{}.png'.format(toy)) + +# print("Toy {0}/{1}".format(toy+1, nr_of_toys)) +# print("Time taken: {}".format(display_time(int(time.time() - start)))) +# print("Projected time left: {}".format(display_time(int((time.time() - start)/(toy+1))*((nr_of_toys-toy-1))))) + + + +# In[ ]: + + +# with open("data/results/Ctt_list.pkl", "wb") as f: +# pkl.dump(Ctt_list, f, pkl.HIGHEST_PROTOCOL) +# with open("data/results/Ctt_error_list.pkl", "wb") as f: +# pkl.dump(Ctt_error_list, f, pkl.HIGHEST_PROTOCOL) + + +# In[ ]: + + +# print('{0}/{1} fits converged'.format(len(Ctt_list), nr_of_toys)) +# print('Mean Ctt value = {}'.format(np.mean(Ctt_list))) +# print('Mean Ctt error = {}'.format(np.mean(Ctt_error_list))) +# print('95 Sensitivy = {}'.format(((2*np.mean(Ctt_error_list))**2)*4.2/1000)) + + +# In[ ]: + + +# plt.hist(tot_sam, bins = int((x_max-x_min)/7.)) + +# plt.show() + +# # _ = np.where((total_samp >= x_min) & (total_samp <= (jpsi_mass - 50.))) + +# tot_sam.shape + + +# In[ ]: + + +# Ctt.floating = False + + +# In[ ]: + + +# zfit.run(nll.value()) + + +# In[ ]: + + +# result.fmin + + +# In[ ]: + + +# BR_steps = np.linspace(0.0, 1e-3, 11) +pull_dic = {} + +mi = 1e-4 +ma = 3e-3 +ste = 20 + +for param in total_f_fit.get_dependents(): + if param.floating: + pull_dic[param.name] = [] + for step in range(2*ste): + pull_dic[param.name].append([]) + + + +def save_pulls(step): + for param in total_f_fit.get_dependents(): + if param.floating: + pull_dic[param.name][step].append((params[param]['value'] - param_values_dic[param.name])/params[param]['minuit_hesse']['error']) + + + +# for key in pull_dic.keys(): +# print(np.shape(pull_dic[key])) +# save_pulls(New_step=True) +# params[Ctt]['value'] + + +# In[ ]: + + +# for param in total_f_fit.get_dependents(): +# if param.floating: +# print(param.name) + +# print(params[Ctt]) + + +# # CLS Code + +# In[ ]: + + +# zfit.run.numeric_checks = False + +load = False + +bo = True + +D_contribs = True + +if not D_contribs: + Dbar_s.floating = False + Dbar_p.floating = False + DDstar_s.floating = False + DDstar_p.floating = False + +bo_set = 1 + +fitting_range = 'cut' +total_BR = 1.7e-10 + 4.9e-10 + 2.5e-9 + 6.02e-5 + 4.97e-6 + 1.38e-9 + 4.2e-10 + 2.6e-9 + 6.1e-10 + 4.37e-7 +cut_BR = 1.0 - (6.02e-5 + 4.97e-6)/total_BR + +Ctt_list = [] +Ctt_error_list = [] + +nr_of_toys = 1 +nevents = int(pdg["number_of_decays"]*cut_BR) +# nevents = pdg["number_of_decays"] +event_stack = 1000000 +# nevents *= 41 +# zfit.settings.set_verbosity(10) + +# mi = 1e-4 +# ma = 3e-3 +# ste = 13 + +BR_steps = np.linspace(mi, ma, ste) + +BR_steps[0] = 0.0 + +print(BR_steps) + +Ctt_steps = np.sqrt(BR_steps/4.2*1000) + +print(Ctt_steps) + +# total_samp = [] + +start = time.time() + +Nll_list = [] + +sampler = total_f.create_sampler(n=nevents, fixed_params = False) +sampler.set_data_range(obs_fit) + +__ = -1 + +#----------------------------------------------------- + +if not load: + for Ctt_step in Ctt_steps: + + __ += 1 + + for i in range(2): + Ctt_list.append([]) + Ctt_error_list.append([]) + Nll_list.append([]) + + for param in total_f_fit.get_dependents(): + if param.floating: + pull_dic[param.name].append([]) + + for toy in range(nr_of_toys): + + newset = True + + while newset: + + for floaty in [True, False]: + Ctt.floating = floaty + + for bo_step in range(bo_set): + + print('Step: {0}/{1}'.format(int(__), ste)) + print('Current Ctt: {0}'.format(Ctt_step)) + print('Ctt floating: {0}'.format(floaty)) + + reset_param_values(variation = 0.0) + + if floaty: + print('Toy {0}/{1} - Fit {2}/{3}'.format(toy, nr_of_toys, bo_step, bo_set)) + Ctt.set_value(Ctt_step) + + else: + Ctt.set_value(0.0) + print('Toy {0}/{1} - Fit {2}/{3}'.format(toy, nr_of_toys, bo_step, bo_set)) + + if newset: + sampler.resample(n=nevents) + data = sampler + newset = False + + ### Fit data + + if floaty: + #plt.clf() + #plt.title('Ctt value: {:.2f}'.format(Ctt_step)) + #plt.hist(zfit.run(data), bins = int((x_max-x_min)/7), range = (x_min, x_max)) + #plt.savefig('data/CLs/plots/set_histo{}.png'.format(__)) + _step = 2*__ + else: + _step = 2*__+1 + + nll = zfit.loss.UnbinnedNLL(model=total_f_fit, data=data, constraints = constraints) + + minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) + # minimizer._use_tfgrad = False + result = minimizer.minimize(nll) + + print("Function minimum:", result.fmin) + print("Hesse errors:", result.hesse()) + + params = result.params + + if result.converged: + + save_pulls(step = _step) + + if floaty: + Nll_list[-2].append(result.fmin) + Ctt_list[-2].append(params[Ctt]['value']) + Ctt_error_list[-2].append(params[Ctt]['minuit_hesse']['error']) + + else: + Nll_list[-1].append(result.fmin) + Ctt_list[-1].append(0.0) + Ctt_error_list[-1].append(0.0) + + + else: + for _ in [1,2]: + del Nll_list[-_][toy*bo_set:] +# print(np.shape(Nll_list[-_])) + del Ctt_list[-_][toy*bo_set:] + del Ctt_error_list[-_][toy*bo_set:] + for param in total_f_fit.get_dependents(): + if param.floating: + del pull_dic[param.name][_step+1-_][toy*bo_set:] + newset = True + break + + if not result.converged: + break + + print() + print('Time taken: {}'.format(display_time(int(time.time()-start)))) + print('Estimated time left: {}'.format(display_time(int((time.time()-start)/(__+(toy+1)/nr_of_toys)*(ste-__-(nr_of_toys-toy-1)/nr_of_toys))))) + + +# In[ ]: + + +if load: + + phase_combi = '--' + + if D_contribs: + D_dir = 'D-True' + else: + D_dir = 'D-False' + + _dir = 'data/CLs/finished/f1d1/{}/{}/'.format(phase_combi, D_dir) + + jobs = os.listdir(_dir) + + First = True + +# print(jobs) + + for job in jobs: + + dirName = _dir + str(job) + '/data/CLs' + + if not os.path.exists("{}/{}-{}_{}s{}b{}t--CLs_Nll_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys)): +# print(job) + continue + + with open(r"{}/variab.pkl".format(dirName), "rb") as input_file: + variab = pkl.load(input_file) +# print(variab) + + ### sanity check: + if variab['mi'] != mi or variab['ma'] != ma or variab['ste'] != ste or bo_set != bo_set: + print('Fitting parameters of data dont equal the ones given -- Job {} skipped!'.format(job)) + + with open(r"{}/{}-{}_{}s{}b{}t--CLs_Nll_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _Nll_list = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s{}b{}t--Ctt_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _Ctt_list = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s{}b{}t--Ctt_error_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _Ctt_error_list = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s{}b{}t--pull_dic.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _pull_dic = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s--CLs_list.pkl".format(dirName, mi,ma,ste), "rb") as input_file: + _CLs_list = pkl.load(input_file) + + + if First: + Nll_list = _Nll_list + Ctt_list = _Ctt_list + Ctt_error_list = _Ctt_error_list + pull_dic = _pull_dic +# print(_pull_dic) + CLs_list = _CLs_list + First = False + else: + for step in range(2*ste): +# print(Nll_list[step], step) + Nll_list[step].extend(_Nll_list[step]) + Ctt_list[step].extend(_Ctt_list[step]) + Ctt_error_list[step].extend(_Ctt_error_list[step]) + for key in pull_dic.keys(): +# print(key, np.shape(pull_dic[key])) + pull_dic[key][step].extend(_pull_dic[key][step]) + for step in range(ste): + CLs_list[step].extend(_CLs_list[step]) + +# print('----------------------') + + +# In[ ]: + + +dirName = 'data/CLs' + +# if bo and not load: +# for s in range(2*ste): +# Nll_list[s] = [np.min(Nll_list[s])] + + +if not load: + + if not os.path.exists(dirName): + os.mkdir(dirName) + print("Directory " , dirName , " Created ") + + with open("{}/{}-{}_{}s{}b{}t--CLs_Nll_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(Nll_list, f, pkl.HIGHEST_PROTOCOL) + + with open("{}/{}-{}_{}s{}b{}t--Ctt_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(Ctt_list, f, pkl.HIGHEST_PROTOCOL) + + with open("{}/{}-{}_{}s{}b{}t--Ctt_error_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(Ctt_error_list, f, pkl.HIGHEST_PROTOCOL) + + with open("{}/{}-{}_{}s{}b{}t--pull_dic.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(pull_dic, f, pkl.HIGHEST_PROTOCOL) + + variab = {'mi': mi, + 'ma': ma, + 'ste': ste, + 'bo_set': bo_set, + 'nr_of_toys': nr_of_toys} + + with open("{}/variab.pkl".format(dirName), "wb") as f: + pkl.dump(variab, f, pkl.HIGHEST_PROTOCOL) + + CLs_values = [] + + toy_size = bo_set + + print(np.shape(Nll_list)) + print(Nll_list[0:1]) + + for step in range(ste): + CLs_values.append([]) + for toy in range(nr_of_toys): + float_min = np.min(Nll_list[2*step][toy*bo_set:(toy+1)*bo_set]) + fix_min = np.min(Nll_list[2*step+1][toy*bo_set:(toy+1)*bo_set]) + CLs_values[step].append(float_min-fix_min) + + + print(np.shape(CLs_values)) + + with open("{}/{}-{}_{}s--CLs_list.pkl".format(dirName, mi,ma,ste), "wb") as f: + pkl.dump(CLs_values, f, pkl.HIGHEST_PROTOCOL) + + +# In[ ]: + + +# print(variab['mi'] != mi) + + +# ## Plot + +# In[ ]: + + +l = [] + + +if load: + CLs_values = -1*np.array(CLs_list) + +if not os.path.exists('data/CLs/plots'): + os.mkdir('data/CLs/plots') + print("Directory " , 'data/CLs/plots' , " Created ") + +print(np.shape(CLs_values)) + +for step in range(1,ste): + plt.clf() + plt.title('Ctt value: {:.2f}'.format(Ctt_steps[step])) + plt.hist(CLs_values[0], bins = 150, range = (-25, 50), label = 'Ctt fixed to 0') + plt.hist(CLs_values[step], bins = 150, range = (-25, 50), label = 'Ctt floating') + plt.axvline(x=np.mean(CLs_values[0]),color='red', linewidth=1.0, linestyle = 'dotted') + plt.legend() + plt.savefig('data/CLs/plots/CLs-BR({:.1E}).png'.format(BR_steps[step])) + + l.append(len(np.where(np.array(CLs_values[step]) < np.mean(CLs_values[0]))[0])) + +for step in range(2*ste): + if step%2 == 0: + floaty = True + else: + floaty = False + for key in pull_dic.keys(): + if not os.path.exists('data/CLs/plots/{}'.format(key)): + os.mkdir('data/CLs/plots/{}'.format(key)) + plt.clf() + plt.title('Pull {} - Ctt value {:.2f} - floating {}'.format(key, Ctt_steps[int(step/2)], floaty)) + plt.hist(pull_dic[key][step], bins = 50, range = (-5,5)) + plt.xlabel('Pull') + plt.savefig('data/CLs/plots/{}/{:.2f}Ctt{}s{}f.png'.format(key, Ctt_steps[int(step/2)], step, floaty)) + + +# In[ ]: + + +for s in range(len(l)): + print('BR: {:.4f}'.format(BR_steps[s+1])) + print(2*l[s]/len(CLs_values[s])) + print() + + +# In[ ]: + + +# for step in range(2*ste): +# for key in pull_dic.keys(): +# print(pull_dic[key][step]) + + +# In[ ]: + + +# for param in total_f_fit.get_dependents(): +# if param.floating: +# print(params[param]['value']) + + +# In[ ]: + + +print(display_time(int(time.time()-start))) + + +# In[ ]: + + +# variab['mi'] =! mi + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + diff --git a/data/CLs/finished/f1d1/-+/D-True/2288030/__pycache__/helperfunctions.cpython-37.pyc b/data/CLs/finished/f1d1/-+/D-True/2288030/__pycache__/helperfunctions.cpython-37.pyc new file mode 100644 index 0000000..e255ec1 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288030/__pycache__/helperfunctions.cpython-37.pyc Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288030/__pycache__/pdg_const1.cpython-37.pyc b/data/CLs/finished/f1d1/-+/D-True/2288030/__pycache__/pdg_const1.cpython-37.pyc new file mode 100644 index 0000000..40f2871 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288030/__pycache__/pdg_const1.cpython-37.pyc Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288030/data/CLs/0.0001-0.003_20s--CLs_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288030/data/CLs/0.0001-0.003_20s--CLs_list.pkl new file mode 100644 index 0000000..19f426f --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288030/data/CLs/0.0001-0.003_20s--CLs_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288030/data/CLs/0.0001-0.003_20s1b1t--CLs_Nll_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288030/data/CLs/0.0001-0.003_20s1b1t--CLs_Nll_list.pkl new file mode 100644 index 0000000..6d191b8 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288030/data/CLs/0.0001-0.003_20s1b1t--CLs_Nll_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288030/data/CLs/0.0001-0.003_20s1b1t--Ctt_error_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288030/data/CLs/0.0001-0.003_20s1b1t--Ctt_error_list.pkl new file mode 100644 index 0000000..1ffa297 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288030/data/CLs/0.0001-0.003_20s1b1t--Ctt_error_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288030/data/CLs/0.0001-0.003_20s1b1t--Ctt_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288030/data/CLs/0.0001-0.003_20s1b1t--Ctt_list.pkl new file mode 100644 index 0000000..faad3fe --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288030/data/CLs/0.0001-0.003_20s1b1t--Ctt_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288030/data/CLs/0.0001-0.003_20s1b1t--pull_dic.pkl b/data/CLs/finished/f1d1/-+/D-True/2288030/data/CLs/0.0001-0.003_20s1b1t--pull_dic.pkl new file mode 100644 index 0000000..f8f9b9a --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288030/data/CLs/0.0001-0.003_20s1b1t--pull_dic.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288030/data/CLs/variab.pkl b/data/CLs/finished/f1d1/-+/D-True/2288030/data/CLs/variab.pkl new file mode 100644 index 0000000..bb90dc0 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288030/data/CLs/variab.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288030/helperfunctions.py b/data/CLs/finished/f1d1/-+/D-True/2288030/helperfunctions.py new file mode 100644 index 0000000..88e120f --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288030/helperfunctions.py @@ -0,0 +1,33 @@ +# some helperfunctions + +import matplotlib +matplotlib.use("agg") +import matplotlib.pyplot as plt + +#Dislpay time (e.g. while generating points) + +display_intervals = ( + ('w', 604800), # 60 * 60 * 24 * 7 + ('d', 86400), # 60 * 60 * 24 + ('h', 3600), # 60 * 60 + ('min', 60), + ('s', 1), + ) + +def display_time(seconds, granularity=2): + result = [] + + for name, count in display_intervals: + value = seconds // count + if value: + seconds -= value * count + if value == 1: + name = name.rstrip('s') + result.append("{} {}".format(value, name)) + return ', '.join(result[:granularity]) + +def prepare_plot(title): + plt.title(title) + plt.grid() + plt.legend(loc = 'best') + plt.xlabel("q") diff --git a/data/CLs/finished/f1d1/-+/D-True/2288030/pdg_const1.py b/data/CLs/finished/f1d1/-+/D-True/2288030/pdg_const1.py new file mode 100644 index 0000000..70b3f30 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288030/pdg_const1.py @@ -0,0 +1,226 @@ +pdg = { + + + ###Particle masses### + + "mbstar" : 5415.4, + "mbstar0" : 5711.0, + "B0_M" : 5279.5, + "Bs_M" : 5366.7, + "Bplus_M" : 5279.3, + "Lb_M" : 5619.4, + "D0_M" : 1864.8, + "Dst_M" : 2010, + "pi_M" : 139.6, + "Jpsi_M" : 3096.9, + "Psi2s_M" : 3685.6, + "kaon_M" : 493.7, + "Ks_M" : 497.6, + "phi_M" : 1019.5, + "rho_M" : 775.26, + "rho_width" : 149.1, + "omega_M" : 782.65, + "omega_width" : 8.49, + + "muon_M" : 105.7, + "tau_M": 1776.86, + + "squark_M" : 95.0, + "bquark_M" : 4180.0, + "cquark_M" : 1275.0, + + "Bplus_tau" : 1.638e-12, + + ###Wilson coefficients### + + "C1" : -0.257, + "C2" : 1.009, + "C3" : -0.005, + "C4" : -0.078, + + "C7eff" : -0.306, + "C9eff" : 4.211, + "C10eff" : -4.103, + +# "C7eff": 0.0, +# "C9eff": 0.0, +# "C10eff": 0.0, + + ###Other constants + + "GF" : 1.1663787e-5, + "alpha_ew" : 1.0/137.0, + "Vts" : 0.0394, + "Vtb" : 1.019, + "number_of_decays": 5404696, + + #Formfactor z coefficients + + #"b0" : [0.285, 0.19, -0.17], + #"bplus" : [0.437, -1.41, -2.5], + #"bT" : [0.440, -1.47, -2.7] + + "b0" : [0.292, 0.281, 0.150], + "bplus" : [0.466, -0.885, -0.213], + "bT" : [0.460, -1.089, -1.114], + + "NR_BR": 4.37e-7, + "NR_auc": 0.00133, + + #Resonances format(mass, width, phase, scale) + + # pre scaling + +# "rho": (775.26, 149.0, -0.35, 1.0), + +# "omega": (782.7, 8.5, 0.26, 1.0), + +# "phi": (1019.46, 4.25, 0.5, 1.0), + +# "jpsi": (3096.0, 0.09, -1.5, 2e-2), +# "jpsi_auc": 0.2126825758464027, + +# "psi2s": (3686.0, 0.3, -1.5, 3.14e-3), +# "psi2s_auc": 2.802257483178487e-10, + +# "p3770": (3773.0, 27.2, -2.13, 1.0e-3), + +# "p4040": (4039.0, 80.0, -2.52, 2.0), + +# "p4160": (4191.0, 70.0, -1.9, 2.2), + +# "p4415": (4421.0, 62.0, -2.52, 1.0), + + + # after scaling (Phase combination --) + + # + # "rho": (743.2, 149.0, -0.22, 1.05), + # + # "omega": (782.7, 8.5, 0.38, 6.8), + # + # "phi": (1013.5, 4.25, 0.62, 19.2), + # + # "jpsi": (3096.1, 0.09, 1.63, 9897.0), + # "jpsi_auc": 0.2126825758464027, + # "jpsi_phase_unc": 0.05, + # + # "psi2s": (3686.0, 0.3, 1.8, 1396.0), + # "psi2s_auc": 0.0151332263, + # "psi2s_phase_unc": 0.1, + # + # "p3770": (3773.0, 27.2, -2.95, 2.5), + # + # "p4040": (4039.0, 80.0, -2.75, 1.01), + # + # "p4160": (4191.0, 70.0, -2.28, 2.2), + # + # "p4415": (4421.0, 62.0, -2.31, 1.24), + + # Phase combination of paper ++ + +# "rho": (743.2, 149.0, -0.35, 1.05), + +# "omega": (782.7, 8.5, 0.26, 6.8), + +# "phi": (1013.5, 4.25, 0.47, 19.2), + +# "jpsi": (3096.1, 0.09, -1.66, 9897.0), +# "jpsi_auc": 0.2126825758464027, +# "jpsi_phase_unc": 0.05, + +# "psi2s": (3686.0, 0.3, -1.93, 1396.0), +# "psi2s_auc": 0.0151332263, +# "psi2s_phase_unc": 0.1, + +# "p3770": (3773.0, 27.2, -2.13, 2.5), + +# "p4040": (4039.0, 80.0, -2.52, 1.01), + +# "p4160": (4191.0, 70.0, -1.90, 2.2), + +# "p4415": (4421.0, 62.0, -2.52, 1.24), + + # Phase combination of paper +- + +# "rho": (743.2, 149.0, -0.26, 1.05), + +# "omega": (782.7, 8.5, 0.35, 6.8), + +# "phi": (1013.5, 4.25, 0.58, 19.2), + +# "jpsi": (3096.1, 0.09, 1.47, 9897.0), +# "jpsi_auc": 0.2126825758464027, +# "jpsi_phase_unc": 0.05, + +# "psi2s": (3686.0, 0.3, -2.21, 1396.0), +# "psi2s_auc": 0.0151332263, +# "psi2s_phase_unc": 0.1, + +# "p3770": (3773.0, 27.2, -2.140, 2.5), + +# "p4040": (4039.0, 80.0, -2.64, 1.01), + +# "p4160": (4191.0, 70.0, -2.11, 2.2), + +# "p4415": (4421.0, 62.0, -2.42, 1.24), + + # Phase combination of paper -+ + + "rho": (743.2, 149.0, -0.30, 1.05), + + "omega": (782.7, 8.5, 0.30, 6.8), + + "phi": (1013.5, 4.25, 0.51, 19.2), + + "jpsi": (3096.1, 0.09, -1.5, 9897.0), + "jpsi_auc": 0.2126825758464027, + "jpsi_phase_unc": 0.05, + + "psi2s": (3686.0, 0.3, 2.08, 1396.0), + "psi2s_auc": 0.0151332263, + "psi2s_phase_unc": 0.1, + + "p3770": (3773.0, 27.2, -2.89, 2.5), + + "p4040": (4039.0, 80.0, -2.69, 1.01), + + "p4160": (4191.0, 70.0, -2.13, 2.2), + + "p4415": (4421.0, 62.0, -2.43, 1.24), + + + # zeroing resonances + +# "rho": (775.26, 149.0, -0.35, 0.0), +# "omega": (782.7, 8.5, 0.26, 0.0), +# "phi": (1019.46, 4.25, 0.5, 0.0), +# "jpsi": (3096.0, 0.09, -1.5, 0.0), +# "psi2s": (3686.0, 0.3, -1.5, 0.0), +# "p3770": (3773.0, 27.2, -2.13, 0.0), +# "p4040": (4039.0, 80.0, -2.52, 0.0), +# "p4160": (4147.0, 22.0, -1.9, 0.0), +# "p4415": (4421.0, 62.0, -2.52, 0.0), + + # 2P contributions format(mass, amp, phase) + +# "D_bar": ( + + #general + + "rho_BR": 1.7e-10, + "omega_BR": 4.9e-10, + "phi_BR": 2.5e-9, + "jpsi_BR": 6.02e-5, + "psi2s_BR": 4.97e-6, + "p3770_BR": 1.38e-9, + "p4040_BR": 4.2e-10, + "p4160_BR": 2.6e-9, + "p4415_BR": 6.1e-10, + +# Estimates + "Dbar_scale": 1.46, #with phase = pi + + "DDstar_scale": 2.41, #with phase = pi + + } diff --git a/data/CLs/finished/f1d1/-+/D-True/2288030/raremodel-nb.py b/data/CLs/finished/f1d1/-+/D-True/2288030/raremodel-nb.py new file mode 100644 index 0000000..c326c9c --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288030/raremodel-nb.py @@ -0,0 +1,2152 @@ +#!/usr/bin/env python +# coding: utf-8 + +# # Import + +# In[ ]: + + +import os + +# os.environ["CUDA_VISIBLE_DEVICES"] = "-1" +import random +import numpy as np +from pdg_const1 import pdg +import matplotlib +import matplotlib.pyplot as plt +import pickle as pkl +import sys +import time +from helperfunctions import display_time, prepare_plot +import cmath as c +import scipy.integrate as integrate +from scipy.optimize import fminbound +from array import array as arr +import collections +from itertools import compress +import tensorflow as tf +import zfit +from zfit import ztf +# from IPython.display import clear_output +import os +import tensorflow_probability as tfp +tfd = tfp.distributions + + +# In[ ]: + + +# chunksize = 10000 +# zfit.run.chunking.active = True +# zfit.run.chunking.max_n_points = chunksize + + +# # Build model and graphs +# ## Create graphs + +# In[ ]: + + + + + +# In[ ]: + + +def formfactor(q2, subscript, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2): #returns real value + #check if subscript is viable + + if subscript != "0" and subscript != "+" and subscript != "T": + raise ValueError('Wrong subscript entered, choose either 0, + or T') + + #get constants + + mK = ztf.constant(pdg['Ks_M']) + mbstar0 = ztf.constant(pdg["mbstar0"]) + mbstar = ztf.constant(pdg["mbstar"]) + + + mmu = ztf.constant(pdg['muon_M']) + mb = ztf.constant(pdg['bquark_M']) + ms = ztf.constant(pdg['squark_M']) + mB = ztf.constant(pdg['Bplus_M']) + + #N comes from derivation in paper + + N = 3 + + #some helperfunctions + + tpos = (mB - mK)**2 + tzero = (mB + mK)*(ztf.sqrt(mB)-ztf.sqrt(mK))**2 + + z_oben = ztf.sqrt(tpos - q2) - ztf.sqrt(tpos - tzero) + z_unten = ztf.sqrt(tpos - q2) + ztf.sqrt(tpos - tzero) + z = tf.divide(z_oben, z_unten) + + #calculate f0 + + if subscript == "0": + prefactor = 1/(1 - q2/(mbstar0**2)) + _sum = 0 + b0 = [b0_0, b0_1, b0_2] + + for i in range(N): + _sum += b0[i]*(tf.pow(z,i)) + + return ztf.to_complex(prefactor * _sum) + + #calculate f+ or fT + + else: + prefactor = 1/(1 - q2/(mbstar**2)) + _sum = 0 + + if subscript == "T": + bT = [bT_0, bT_1, bT_2] + for i in range(N): + _sum += bT[i] * (tf.pow(z, i) - ((-1)**(i-N)) * (i/N) * tf.pow(z, N)) + else: + bplus = [bplus_0, bplus_1, bplus_2] + for i in range(N): + _sum += bplus[i] * (tf.pow(z, i) - ((-1)**(i-N)) * (i/N) * tf.pow(z, N)) + + return ztf.to_complex(prefactor * _sum) + +def resonance(q, _mass, width, phase, scale): + + q2 = tf.pow(q, 2) + + mmu = ztf.constant(pdg['muon_M']) + + p = 0.5 * ztf.sqrt(q2 - 4*(mmu**2)) + + p0 = 0.5 * ztf.sqrt(_mass**2 - 4*mmu**2) + + gamma_j = tf.divide(p, q) * _mass * width / p0 + + #Calculate the resonance + + _top = tf.complex(_mass * width, ztf.constant(0.0)) + + _bottom = tf.complex(_mass**2 - q2, -_mass*gamma_j) + + com = _top/_bottom + + #Rotate by the phase + + r = ztf.to_complex(scale*tf.abs(com)) + + _phase = tf.angle(com) + + _phase += phase + + com = r * tf.exp(tf.complex(ztf.constant(0.0), _phase)) + + return com + + +def axiv_nonres(q, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2): + + GF = ztf.constant(pdg['GF']) + alpha_ew = ztf.constant(pdg['alpha_ew']) + Vtb = ztf.constant(pdg['Vtb']) + Vts = ztf.constant(pdg['Vts']) + C10eff = ztf.constant(pdg['C10eff']) + + mmu = ztf.constant(pdg['muon_M']) + mb = ztf.constant(pdg['bquark_M']) + ms = ztf.constant(pdg['squark_M']) + mK = ztf.constant(pdg['Ks_M']) + mB = ztf.constant(pdg['Bplus_M']) + + q2 = tf.pow(q, 2) + + #Some helperfunctions + + beta = 1. - 4. * mmu**2. / q2 + + kabs = ztf.sqrt(mB**2. + tf.pow(q2, 2)/mB**2. + mK**4./mB**2. - 2. * (mB**2. * mK**2. + mK**2. * q2 + mB**2. * q2) / mB**2.) + + #prefactor in front of whole bracket + + prefactor1 = GF**2. *alpha_ew**2. * (tf.abs(Vtb*Vts))**2. * kabs * beta / (128. * np.pi**5.) + + #left term in bracket + + bracket_left = 2./3. * tf.pow(kabs,2) * tf.pow(beta,2) * tf.pow(tf.abs(ztf.to_complex(C10eff)*formfactor(q2, "+", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2)),2) + + #middle term in bracket + + _top = 4. * mmu**2. * (mB**2. - mK**2.) * (mB**2. - mK**2.) + + _under = q2 * mB**2. + + bracket_middle = _top/_under *tf.pow(tf.abs(ztf.to_complex(C10eff) * formfactor(q2, "0", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2)), 2) + + #Note sqrt(q2) comes from derivation as we use q2 and plot q + + return prefactor1 * (bracket_left + bracket_middle) * 2 * q + +def vec(q, funcs, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2): + + q2 = tf.pow(q, 2) + + GF = ztf.constant(pdg['GF']) + alpha_ew = ztf.constant(pdg['alpha_ew']) + Vtb = ztf.constant(pdg['Vtb']) + Vts = ztf.constant(pdg['Vts']) + C7eff = ztf.constant(pdg['C7eff']) + + mmu = ztf.constant(pdg['muon_M']) + mb = ztf.constant(pdg['bquark_M']) + ms = ztf.constant(pdg['squark_M']) + mK = ztf.constant(pdg['Ks_M']) + mB = ztf.constant(pdg['Bplus_M']) + + #Some helperfunctions + + beta = 1. - 4. * mmu**2. / q2 + + kabs = ztf.sqrt(mB**2. + tf.pow(q2, 2)/mB**2. + mK**4./mB**2. - 2 * (mB**2 * mK**2 + mK**2 * q2 + mB**2 * q2) / mB**2) + + #prefactor in front of whole bracket + + prefactor1 = GF**2. *alpha_ew**2. * (tf.abs(Vtb*Vts))**2 * kabs * beta / (128. * np.pi**5.) + + #right term in bracket + + prefactor2 = tf.pow(kabs,2) * (1. - 1./3. * beta) + + abs_bracket = tf.pow(tf.abs(c9eff(q, funcs) * formfactor(q2, "+", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + ztf.to_complex(2.0 * C7eff * (mb + ms)/(mB + mK)) * formfactor(q2, "T", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2)),2) + + bracket_right = prefactor2 * abs_bracket + + #Note sqrt(q2) comes from derivation as we use q2 and plot q + + return prefactor1 * bracket_right * 2 * q + +def c9eff(q, funcs): + + C9eff_nr = ztf.to_complex(ztf.constant(pdg['C9eff'])) + + c9 = C9eff_nr + funcs + + return c9 + + +# In[ ]: + + +def G(y): + + def inner_rect_bracket(q): + return tf.log(ztf.to_complex((1+tf.sqrt(q))/(1-tf.sqrt(q)))-tf.complex(ztf.constant(0), -1*ztf.constant(np.pi))) + + def inner_right(q): + return ztf.to_complex(2 * tf.atan(1/tf.sqrt(tf.math.real(-q)))) + + big_bracket = tf.where(tf.math.real(y) > ztf.constant(0.0), inner_rect_bracket(y), inner_right(y)) + + return ztf.to_complex(tf.sqrt(tf.abs(y))) * big_bracket + +def h_S(m, q): + + return ztf.to_complex(2) - G(ztf.to_complex(1) - ztf.to_complex(4*tf.pow(m, 2)) / ztf.to_complex(tf.pow(q, 2))) + +def h_P(m, q): + + return ztf.to_complex(2/3) + (ztf.to_complex(1) - ztf.to_complex(4*tf.pow(m, 2)) / ztf.to_complex(tf.pow(q, 2))) * h_S(m,q) + +def two_p_ccbar(mD, m_D_bar, m_D_star, q): + + + #Load constants + nu_D_bar = ztf.to_complex(pdg["nu_D_bar"]) + nu_D = ztf.to_complex(pdg["nu_D"]) + nu_D_star = ztf.to_complex(pdg["nu_D_star"]) + + phase_D_bar = ztf.to_complex(pdg["phase_D_bar"]) + phase_D = ztf.to_complex(pdg["phase_D"]) + phase_D_star = ztf.to_complex(pdg["phase_D_star"]) + + #Calculation + left_part = nu_D_bar * tf.exp(tf.complex(ztf.constant(0.0), phase_D_bar)) * h_S(m_D_bar, q) + + right_part_D = nu_D * tf.exp(tf.complex(ztf.constant(0.0), phase_D)) * h_P(m_D, q) + + right_part_D_star = nu_D_star * tf.exp(tf.complex(ztf.constant(0.0), phase_D_star)) * h_P(m_D_star, q) + + return left_part + right_part_D + right_part_D_star + + +# ## Build pdf + +# In[ ]: + + +class total_pdf_cut(zfit.pdf.ZPDF): + _N_OBS = 1 # dimension, can be omitted + _PARAMS = ['b0_0', 'b0_1', 'b0_2', + 'bplus_0', 'bplus_1', 'bplus_2', + 'bT_0', 'bT_1', 'bT_2', + 'rho_mass', 'rho_scale', 'rho_phase', 'rho_width', + 'jpsi_mass', 'jpsi_scale', 'jpsi_phase', 'jpsi_width', + 'psi2s_mass', 'psi2s_scale', 'psi2s_phase', 'psi2s_width', + 'p3770_mass', 'p3770_scale', 'p3770_phase', 'p3770_width', + 'p4040_mass', 'p4040_scale', 'p4040_phase', 'p4040_width', + 'p4160_mass', 'p4160_scale', 'p4160_phase', 'p4160_width', + 'p4415_mass', 'p4415_scale', 'p4415_phase', 'p4415_width', + 'omega_mass', 'omega_scale', 'omega_phase', 'omega_width', + 'phi_mass', 'phi_scale', 'phi_phase', 'phi_width', + 'Dbar_mass', 'Dbar_scale', 'Dbar_phase', + 'Dstar_mass', 'DDstar_scale', 'DDstar_phase', 'D_mass', + 'tau_mass', 'C_tt'] +# the name of the parameters + + def _unnormalized_pdf(self, x): + + x = x.unstack_x() + + b0 = [self.params['b0_0'], self.params['b0_1'], self.params['b0_2']] + bplus = [self.params['bplus_0'], self.params['bplus_1'], self.params['bplus_2']] + bT = [self.params['bT_0'], self.params['bT_1'], self.params['bT_2']] + + def rho_res(q): + return resonance(q, _mass = self.params['rho_mass'], scale = self.params['rho_scale'], + phase = self.params['rho_phase'], width = self.params['rho_width']) + + def omega_res(q): + return resonance(q, _mass = self.params['omega_mass'], scale = self.params['omega_scale'], + phase = self.params['omega_phase'], width = self.params['omega_width']) + + def phi_res(q): + return resonance(q, _mass = self.params['phi_mass'], scale = self.params['phi_scale'], + phase = self.params['phi_phase'], width = self.params['phi_width']) + + def jpsi_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['jpsi_mass'], 2)) * resonance(q, _mass = self.params['jpsi_mass'], + scale = self.params['jpsi_scale'], + phase = self.params['jpsi_phase'], + width = self.params['jpsi_width']) + def psi2s_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['psi2s_mass'], 2)) * resonance(q, _mass = self.params['psi2s_mass'], + scale = self.params['psi2s_scale'], + phase = self.params['psi2s_phase'], + width = self.params['psi2s_width']) + def p3770_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p3770_mass'], 2)) * resonance(q, _mass = self.params['p3770_mass'], + scale = self.params['p3770_scale'], + phase = self.params['p3770_phase'], + width = self.params['p3770_width']) + + def p4040_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4040_mass'], 2)) * resonance(q, _mass = self.params['p4040_mass'], + scale = self.params['p4040_scale'], + phase = self.params['p4040_phase'], + width = self.params['p4040_width']) + + def p4160_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4160_mass'], 2)) * resonance(q, _mass = self.params['p4160_mass'], + scale = self.params['p4160_scale'], + phase = self.params['p4160_phase'], + width = self.params['p4160_width']) + + def p4415_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4415_mass'], 2)) * resonance(q, _mass = self.params['p4415_mass'], + scale = self.params['p4415_scale'], + phase = self.params['p4415_phase'], + width = self.params['p4415_width']) + + def P2_D(q): + Dbar_contrib = ztf.to_complex(self.params['Dbar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['Dbar_phase']))*ztf.to_complex(h_S(self.params['Dbar_mass'], q)) + DDstar_contrib = ztf.to_complex(self.params['DDstar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['DDstar_phase']))*(ztf.to_complex(h_P(self.params['Dstar_mass'], q)) + ztf.to_complex(h_P(self.params['D_mass'], q))) + return Dbar_contrib + DDstar_contrib + + def ttau_cusp(q): + return ztf.to_complex(self.params['C_tt'])*(ztf.to_complex((h_S(self.params['tau_mass'], q))) - ztf.to_complex(h_P(self.params['tau_mass'], q))) + + + funcs = rho_res(x) + omega_res(x) + phi_res(x) + jpsi_res(x) + psi2s_res(x) + p3770_res(x) + p4040_res(x)+ p4160_res(x) + p4415_res(x) + P2_D(x) + ttau_cusp(x) + + vec_f = vec(x, funcs, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + axiv_nr = axiv_nonres(x, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + tot = vec_f + axiv_nr + + #Cut out jpsi and psi2s + + tot = tf.where(tf.math.logical_or(x < ztf.constant(jpsi_mass-60.), x > ztf.constant(jpsi_mass+70.)), tot, 0.0*tot) + + tot = tf.where(tf.math.logical_or(x < ztf.constant(psi2s_mass-50.), x > ztf.constant(psi2s_mass+50.)), tot, 0.0*tot) + + return tot + +class total_pdf_full(zfit.pdf.ZPDF): + _N_OBS = 1 # dimension, can be omitted + _PARAMS = ['b0_0', 'b0_1', 'b0_2', + 'bplus_0', 'bplus_1', 'bplus_2', + 'bT_0', 'bT_1', 'bT_2', + 'rho_mass', 'rho_scale', 'rho_phase', 'rho_width', + 'jpsi_mass', 'jpsi_scale', 'jpsi_phase', 'jpsi_width', + 'psi2s_mass', 'psi2s_scale', 'psi2s_phase', 'psi2s_width', + 'p3770_mass', 'p3770_scale', 'p3770_phase', 'p3770_width', + 'p4040_mass', 'p4040_scale', 'p4040_phase', 'p4040_width', + 'p4160_mass', 'p4160_scale', 'p4160_phase', 'p4160_width', + 'p4415_mass', 'p4415_scale', 'p4415_phase', 'p4415_width', + 'omega_mass', 'omega_scale', 'omega_phase', 'omega_width', + 'phi_mass', 'phi_scale', 'phi_phase', 'phi_width', + 'Dbar_mass', 'Dbar_scale', 'Dbar_phase', + 'Dstar_mass', 'DDstar_scale', 'DDstar_phase', 'D_mass', + 'tau_mass', 'C_tt'] +# the name of the parameters + + def _unnormalized_pdf(self, x): + + x = x.unstack_x() + + b0 = [self.params['b0_0'], self.params['b0_1'], self.params['b0_2']] + bplus = [self.params['bplus_0'], self.params['bplus_1'], self.params['bplus_2']] + bT = [self.params['bT_0'], self.params['bT_1'], self.params['bT_2']] + + def rho_res(q): + return resonance(q, _mass = self.params['rho_mass'], scale = self.params['rho_scale'], + phase = self.params['rho_phase'], width = self.params['rho_width']) + + def omega_res(q): + return resonance(q, _mass = self.params['omega_mass'], scale = self.params['omega_scale'], + phase = self.params['omega_phase'], width = self.params['omega_width']) + + def phi_res(q): + return resonance(q, _mass = self.params['phi_mass'], scale = self.params['phi_scale'], + phase = self.params['phi_phase'], width = self.params['phi_width']) + + def jpsi_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['jpsi_mass'], 2)) * resonance(q, _mass = self.params['jpsi_mass'], + scale = self.params['jpsi_scale'], + phase = self.params['jpsi_phase'], + width = self.params['jpsi_width']) + def psi2s_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['psi2s_mass'], 2)) * resonance(q, _mass = self.params['psi2s_mass'], + scale = self.params['psi2s_scale'], + phase = self.params['psi2s_phase'], + width = self.params['psi2s_width']) + def p3770_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p3770_mass'], 2)) * resonance(q, _mass = self.params['p3770_mass'], + scale = self.params['p3770_scale'], + phase = self.params['p3770_phase'], + width = self.params['p3770_width']) + + def p4040_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4040_mass'], 2)) * resonance(q, _mass = self.params['p4040_mass'], + scale = self.params['p4040_scale'], + phase = self.params['p4040_phase'], + width = self.params['p4040_width']) + + def p4160_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4160_mass'], 2)) * resonance(q, _mass = self.params['p4160_mass'], + scale = self.params['p4160_scale'], + phase = self.params['p4160_phase'], + width = self.params['p4160_width']) + + def p4415_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4415_mass'], 2)) * resonance(q, _mass = self.params['p4415_mass'], + scale = self.params['p4415_scale'], + phase = self.params['p4415_phase'], + width = self.params['p4415_width']) + + def P2_D(q): + Dbar_contrib = ztf.to_complex(self.params['Dbar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['Dbar_phase']))*ztf.to_complex(h_S(self.params['Dbar_mass'], q)) + DDstar_contrib = ztf.to_complex(self.params['DDstar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['DDstar_phase']))*(ztf.to_complex(h_P(self.params['Dstar_mass'], q)) + ztf.to_complex(h_P(self.params['D_mass'], q))) + return Dbar_contrib + DDstar_contrib + + def ttau_cusp(q): + return ztf.to_complex(self.params['C_tt'])*(ztf.to_complex((h_S(self.params['tau_mass'], q))) - ztf.to_complex(h_P(self.params['tau_mass'], q))) + + + funcs = rho_res(x) + omega_res(x) + phi_res(x) + jpsi_res(x) + psi2s_res(x) + p3770_res(x) + p4040_res(x)+ p4160_res(x) + p4415_res(x) + P2_D(x) + ttau_cusp(x) + + vec_f = vec(x, funcs, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + axiv_nr = axiv_nonres(x, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + tot = vec_f + axiv_nr + + #Cut out jpsi and psi2s + +# tot = tf.where(tf.math.logical_or(x < ztf.constant(jpsi_mass-60.), x > ztf.constant(jpsi_mass+70.)), tot, 0.0*tot) + +# tot = tf.where(tf.math.logical_or(x < ztf.constant(psi2s_mass-50.), x > ztf.constant(psi2s_mass+50.)), tot, 0.0*tot) + + return tot + + +# ## Setup parameters + +# In[ ]: + + +# formfactors + +b0_0 = zfit.Parameter("b0_0", ztf.constant(0.292), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +b0_1 = zfit.Parameter("b0_1", ztf.constant(0.281), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +b0_2 = zfit.Parameter("b0_2", ztf.constant(0.150), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) + +bplus_0 = zfit.Parameter("bplus_0", ztf.constant(0.466), lower_limit = -2.0, upper_limit= 2.0) +bplus_1 = zfit.Parameter("bplus_1", ztf.constant(-0.885), lower_limit = -2.0, upper_limit= 2.0) +bplus_2 = zfit.Parameter("bplus_2", ztf.constant(-0.213), lower_limit = -2.0, upper_limit= 2.0) + +bT_0 = zfit.Parameter("bT_0", ztf.constant(0.460), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +bT_1 = zfit.Parameter("bT_1", ztf.constant(-1.089), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +bT_2 = zfit.Parameter("bT_2", ztf.constant(-1.114), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) + + +#rho + +rho_mass, rho_width, rho_phase, rho_scale = pdg["rho"] + +rho_m = zfit.Parameter("rho_m", ztf.constant(rho_mass), floating = False) #lower_limit = rho_mass - rho_width, upper_limit = rho_mass + rho_width) +rho_w = zfit.Parameter("rho_w", ztf.constant(rho_width), floating = False) +rho_p = zfit.Parameter("rho_p", ztf.constant(rho_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +rho_s = zfit.Parameter("rho_s", ztf.constant(rho_scale), lower_limit=rho_scale-np.sqrt(rho_scale), upper_limit=rho_scale+np.sqrt(rho_scale)) + +#omega + +omega_mass, omega_width, omega_phase, omega_scale = pdg["omega"] + +omega_m = zfit.Parameter("omega_m", ztf.constant(omega_mass), floating = False) +omega_w = zfit.Parameter("omega_w", ztf.constant(omega_width), floating = False) +omega_p = zfit.Parameter("omega_p", ztf.constant(omega_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +omega_s = zfit.Parameter("omega_s", ztf.constant(omega_scale), lower_limit=omega_scale-np.sqrt(omega_scale), upper_limit=omega_scale+np.sqrt(omega_scale)) + + +#phi + +phi_mass, phi_width, phi_phase, phi_scale = pdg["phi"] + +phi_m = zfit.Parameter("phi_m", ztf.constant(phi_mass), floating = False) +phi_w = zfit.Parameter("phi_w", ztf.constant(phi_width), floating = False) +phi_p = zfit.Parameter("phi_p", ztf.constant(phi_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +phi_s = zfit.Parameter("phi_s", ztf.constant(phi_scale), lower_limit=phi_scale-np.sqrt(phi_scale), upper_limit=phi_scale+np.sqrt(phi_scale)) + +#jpsi + +jpsi_mass, jpsi_width, jpsi_phase, jpsi_scale = pdg["jpsi"] + +jpsi_m = zfit.Parameter("jpsi_m", ztf.constant(jpsi_mass), floating = False) +jpsi_w = zfit.Parameter("jpsi_w", ztf.constant(jpsi_width), floating = False) +jpsi_p = zfit.Parameter("jpsi_p", ztf.constant(jpsi_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +jpsi_s = zfit.Parameter("jpsi_s", ztf.constant(jpsi_scale), floating = False) #, lower_limit=jpsi_scale-np.sqrt(jpsi_scale), upper_limit=jpsi_scale+np.sqrt(jpsi_scale)) + +#psi2s + +psi2s_mass, psi2s_width, psi2s_phase, psi2s_scale = pdg["psi2s"] + +psi2s_m = zfit.Parameter("psi2s_m", ztf.constant(psi2s_mass), floating = False) +psi2s_w = zfit.Parameter("psi2s_w", ztf.constant(psi2s_width), floating = False) +psi2s_p = zfit.Parameter("psi2s_p", ztf.constant(psi2s_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +psi2s_s = zfit.Parameter("psi2s_s", ztf.constant(psi2s_scale), floating = False) #, lower_limit=psi2s_scale-np.sqrt(psi2s_scale), upper_limit=psi2s_scale+np.sqrt(psi2s_scale)) + +#psi(3770) + +p3770_mass, p3770_width, p3770_phase, p3770_scale = pdg["p3770"] + +p3770_m = zfit.Parameter("p3770_m", ztf.constant(p3770_mass), floating = False) +p3770_w = zfit.Parameter("p3770_w", ztf.constant(p3770_width), floating = False) +p3770_p = zfit.Parameter("p3770_p", ztf.constant(p3770_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p3770_s = zfit.Parameter("p3770_s", ztf.constant(p3770_scale), lower_limit=p3770_scale-np.sqrt(p3770_scale), upper_limit=p3770_scale+np.sqrt(p3770_scale)) + +#psi(4040) + +p4040_mass, p4040_width, p4040_phase, p4040_scale = pdg["p4040"] + +p4040_m = zfit.Parameter("p4040_m", ztf.constant(p4040_mass), floating = False) +p4040_w = zfit.Parameter("p4040_w", ztf.constant(p4040_width), floating = False) +p4040_p = zfit.Parameter("p4040_p", ztf.constant(p4040_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p4040_s = zfit.Parameter("p4040_s", ztf.constant(p4040_scale), lower_limit=p4040_scale-np.sqrt(p4040_scale), upper_limit=p4040_scale+np.sqrt(p4040_scale)) + +#psi(4160) + +p4160_mass, p4160_width, p4160_phase, p4160_scale = pdg["p4160"] + +p4160_m = zfit.Parameter("p4160_m", ztf.constant(p4160_mass), floating = False) +p4160_w = zfit.Parameter("p4160_w", ztf.constant(p4160_width), floating = False) +p4160_p = zfit.Parameter("p4160_p", ztf.constant(p4160_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p4160_s = zfit.Parameter("p4160_s", ztf.constant(p4160_scale), lower_limit=p4160_scale-np.sqrt(p4160_scale), upper_limit=p4160_scale+np.sqrt(p4160_scale)) + +#psi(4415) + +p4415_mass, p4415_width, p4415_phase, p4415_scale = pdg["p4415"] + +p4415_m = zfit.Parameter("p4415_m", ztf.constant(p4415_mass), floating = False) +p4415_w = zfit.Parameter("p4415_w", ztf.constant(p4415_width), floating = False) +p4415_p = zfit.Parameter("p4415_p", ztf.constant(p4415_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p4415_s = zfit.Parameter("p4415_s", ztf.constant(p4415_scale), lower_limit=p4415_scale-np.sqrt(p4415_scale), upper_limit=p4415_scale+np.sqrt(p4415_scale)) + + +# ## Dynamic generation of 2 particle contribution + +# In[ ]: + + +m_c = 1300 + +Dbar_phase = 0.0 +DDstar_phase = 0.0 +Dstar_mass = pdg['Dst_M'] +Dbar_mass = pdg['D0_M'] +D_mass = pdg['D0_M'] + +Dbar_s = zfit.Parameter("Dbar_s", ztf.constant(0.0), lower_limit=-0.3, upper_limit=0.3) +Dbar_m = zfit.Parameter("Dbar_m", ztf.constant(Dbar_mass), floating = False) +Dbar_p = zfit.Parameter("Dbar_p", ztf.constant(Dbar_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi)#, floating = False) +DDstar_s = zfit.Parameter("DDstar_s", ztf.constant(0.0), lower_limit=-0.3, upper_limit=0.3)#, floating = False) +Dstar_m = zfit.Parameter("Dstar_m", ztf.constant(Dstar_mass), floating = False) +D_m = zfit.Parameter("D_m", ztf.constant(D_mass), floating = False) +DDstar_p = zfit.Parameter("DDstar_p", ztf.constant(DDstar_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi)#, floating = False) + + +# ## Tau parameters + +# In[ ]: + + +tau_m = zfit.Parameter("tau_m", ztf.constant(pdg['tau_M']), floating = False) +Ctt = zfit.Parameter("Ctt", ztf.constant(0.0), lower_limit=-2.5, upper_limit=2.5) + + +# ## Load data + +# In[ ]: + + +x_min = 2*pdg['muon_M'] +x_max = (pdg["Bplus_M"]-pdg["Ks_M"]-0.1) + +# # Full spectrum + +obs_toy = zfit.Space('q', limits = (x_min, x_max)) + +# Jpsi and Psi2s cut out + +obs1 = zfit.Space('q', limits = (x_min, jpsi_mass - 60.)) +obs2 = zfit.Space('q', limits = (jpsi_mass + 70., psi2s_mass - 50.)) +obs3 = zfit.Space('q', limits = (psi2s_mass + 50., x_max)) + +obs_fit = obs1 + obs2 + obs3 + +# with open(r"./data/slim_points/slim_points_toy_0_range({0}-{1}).pkl".format(int(x_min), int(x_max)), "rb") as input_file: +# part_set = pkl.load(input_file) + +# x_part = part_set['x_part'] + +# x_part = x_part.astype('float64') + +# data = zfit.data.Data.from_numpy(array=x_part, obs=obs) + + +# ## Setup pdf + +# In[ ]: + + +total_f = total_pdf_cut(obs=obs_toy, jpsi_mass = jpsi_m, jpsi_scale = jpsi_s, jpsi_phase = jpsi_p, jpsi_width = jpsi_w, + psi2s_mass = psi2s_m, psi2s_scale = psi2s_s, psi2s_phase = psi2s_p, psi2s_width = psi2s_w, + p3770_mass = p3770_m, p3770_scale = p3770_s, p3770_phase = p3770_p, p3770_width = p3770_w, + p4040_mass = p4040_m, p4040_scale = p4040_s, p4040_phase = p4040_p, p4040_width = p4040_w, + p4160_mass = p4160_m, p4160_scale = p4160_s, p4160_phase = p4160_p, p4160_width = p4160_w, + p4415_mass = p4415_m, p4415_scale = p4415_s, p4415_phase = p4415_p, p4415_width = p4415_w, + rho_mass = rho_m, rho_scale = rho_s, rho_phase = rho_p, rho_width = rho_w, + omega_mass = omega_m, omega_scale = omega_s, omega_phase = omega_p, omega_width = omega_w, + phi_mass = phi_m, phi_scale = phi_s, phi_phase = phi_p, phi_width = phi_w, + Dstar_mass = Dstar_m, DDstar_scale = DDstar_s, DDstar_phase = DDstar_p, D_mass = D_m, + Dbar_mass = Dbar_m, Dbar_scale = Dbar_s, Dbar_phase = Dbar_p, + tau_mass = tau_m, C_tt = Ctt, b0_0 = b0_0, b0_1 = b0_1, b0_2 = b0_2, + bplus_0 = bplus_0, bplus_1 = bplus_1, bplus_2 = bplus_2, + bT_0 = bT_0, bT_1 = bT_1, bT_2 = bT_2) + +total_f_fit = total_pdf_full(obs=obs_fit, jpsi_mass = jpsi_m, jpsi_scale = jpsi_s, jpsi_phase = jpsi_p, jpsi_width = jpsi_w, + psi2s_mass = psi2s_m, psi2s_scale = psi2s_s, psi2s_phase = psi2s_p, psi2s_width = psi2s_w, + p3770_mass = p3770_m, p3770_scale = p3770_s, p3770_phase = p3770_p, p3770_width = p3770_w, + p4040_mass = p4040_m, p4040_scale = p4040_s, p4040_phase = p4040_p, p4040_width = p4040_w, + p4160_mass = p4160_m, p4160_scale = p4160_s, p4160_phase = p4160_p, p4160_width = p4160_w, + p4415_mass = p4415_m, p4415_scale = p4415_s, p4415_phase = p4415_p, p4415_width = p4415_w, + rho_mass = rho_m, rho_scale = rho_s, rho_phase = rho_p, rho_width = rho_w, + omega_mass = omega_m, omega_scale = omega_s, omega_phase = omega_p, omega_width = omega_w, + phi_mass = phi_m, phi_scale = phi_s, phi_phase = phi_p, phi_width = phi_w, + Dstar_mass = Dstar_m, DDstar_scale = DDstar_s, DDstar_phase = DDstar_p, D_mass = D_m, + Dbar_mass = Dbar_m, Dbar_scale = Dbar_s, Dbar_phase = Dbar_p, + tau_mass = tau_m, C_tt = Ctt, b0_0 = b0_0, b0_1 = b0_1, b0_2 = b0_2, + bplus_0 = bplus_0, bplus_1 = bplus_1, bplus_2 = bplus_2, + bT_0 = bT_0, bT_1 = bT_1, bT_2 = bT_2) + +# print(total_pdf.obs) + +# print(calcs_test) + +# for param in total_f.get_dependents(): +# print(zfit.run(param)) + + +# In[ ]: + + +# total_f_fit.normalization(obs_fit) + + +# ## Test if graphs actually work and compute values + +# In[ ]: + + +# def total_test_tf(xq): + +# def jpsi_res(q): +# return resonance(q, jpsi_m, jpsi_s, jpsi_p, jpsi_w) + +# def psi2s_res(q): +# return resonance(q, psi2s_m, psi2s_s, psi2s_p, psi2s_w) + +# def cusp(q): +# return bifur_gauss(q, cusp_m, sig_L, sig_R, cusp_s) + +# funcs = jpsi_res(xq) + psi2s_res(xq) + cusp(xq) + +# vec_f = vec(xq, funcs) + +# axiv_nr = axiv_nonres(xq) + +# tot = vec_f + axiv_nr + +# return tot + +# def jpsi_res(q): +# return resonance(q, jpsi_m, jpsi_s, jpsi_p, jpsi_w) + +# calcs = zfit.run(total_test_tf(x_part)) + + + +test_q = np.linspace(x_min, x_max, int(2e6)) + +probs = total_f_fit.pdf(test_q, norm_range=False) + +calcs_test = zfit.run(probs) + +Ctt.set_value(0.5) + +calcs_test1 = zfit.run(probs) + +Ctt.set_value(0.0) + +Dbar_s.set_value(0.3) + +DDstar_s.set_value(0.3) + +calcs_test2 = zfit.run(probs) +# res_y = zfit.run(jpsi_res(test_q)) +# b0 = [b0_0, b0_1, b0_2] +# bplus = [bplus_0, bplus_1, bplus_2] +# bT = [bT_0, bT_1, bT_2] +# f0_y = zfit.run(tf.math.real(formfactor(test_q,"0", b0, bplus, bT))) +# fplus_y = zfit.run(tf.math.real(formfactor(test_q,"+", b0, bplus, bT))) +# fT_y = zfit.run(tf.math.real(formfactor(test_q,"T", b0, bplus, bT))) + + +# In[ ]: + + +plt.clf() +# plt.plot(x_part, calcs, '.') +plt.plot(test_q, calcs_test, label = 'pdf (Ctt = 0.0)') +plt.plot(test_q, calcs_test1, label = 'pdf (Ctt = 0.5)') +plt.plot(test_q, calcs_test2, label = 'pdf (D-contribs = 0.3)') +# plt.plot(test_q, f0_y, label = '0') +# plt.plot(test_q, fT_y, label = 'T') +# plt.plot(test_q, fplus_y, label = '+') +# plt.plot(test_q, res_y, label = 'res') +plt.legend() +plt.ylim(0.0, 1.5e-6) +# plt.yscale('log') +# plt.xlim(770, 785) +plt.savefig('test.png') +# print(jpsi_width) + + +# In[ ]: + + + + +# probs = mixture.prob(test_q) +# probs_np = zfit.run(probs) +# probs_np *= np.max(calcs_test) / np.max(probs_np) +# plt.figure() +# plt.semilogy(test_q, probs_np,label="importance sampling") +# plt.semilogy(test_q, calcs_test, label = 'pdf') + + +# In[ ]: + + +# 0.213/(0.00133+0.213+0.015) + + +# ## Adjust scaling of different parts + +# In[ ]: + + +total_f.update_integration_options(draws_per_dim=2000000, mc_sampler=None) +# inte = total_f.integrate(limits = (950., 1050.), norm_range=False) +# inte_fl = zfit.run(inte) +# print(inte_fl/4500) +# print(pdg["jpsi_BR"]/pdg["NR_BR"], inte_fl*pdg["psi2s_auc"]/pdg["NR_auc"]) + + +# In[ ]: + + +# # print("jpsi:", inte_fl) +# # print("Increase am by factor:", np.sqrt(pdg["jpsi_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) +# # print("New amp:", pdg["jpsi"][3]*np.sqrt(pdg["jpsi_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) + +# # print("psi2s:", inte_fl) +# # print("Increase am by factor:", np.sqrt(pdg["psi2s_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) +# # print("New amp:", pdg["psi2s"][3]*np.sqrt(pdg["psi2s_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) + +# name = "phi" + +# print(name+":", inte_fl) +# print("Increase am by factor:", np.sqrt(pdg[name+"_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) +# print("New amp:", pdg[name][0]*np.sqrt(pdg[name+"_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) + + +# print(x_min) +# print(x_max) +# # total_f.update_integration_options(draws_per_dim=2000000, mc_sampler=None) +# total_f.update_integration_options(mc_sampler=lambda dim, num_results, +# dtype: tf.random_uniform(maxval=1., shape=(num_results, dim), dtype=dtype), +# draws_per_dim=1000000) +# # _ = [] + +# # for i in range(10): + +# # inte = total_f.integrate(limits = (x_min, x_max)) +# # inte_fl = zfit.run(inte) +# # print(inte_fl) +# # _.append(inte_fl) + +# # print("mean:", np.mean(_)) + +# _ = time.time() + +# inte = total_f.integrate(limits = (x_min, x_max)) +# inte_fl = zfit.run(inte) +# print(inte_fl) +# print("Time taken: {}".format(display_time(int(time.time() - _)))) + +# print(pdg['NR_BR']/pdg['NR_auc']*inte_fl) +# print(0.25**2*4.2/1000) + + +# # Sampling +# ## Mixture distribution for sampling + +# In[ ]: + + + + +# print(list_of_borders[:9]) +# print(list_of_borders[-9:]) + + +class UniformSampleAndWeights(zfit.util.execution.SessionHolderMixin): + def __call__(self, limits, dtype, n_to_produce): + # n_to_produce = tf.cast(n_to_produce, dtype=tf.int32) + low, high = limits.limit1d + low = tf.cast(low, dtype=dtype) + high = tf.cast(high, dtype=dtype) +# uniform = tfd.Uniform(low=low, high=high) +# uniformjpsi = tfd.Uniform(low=tf.constant(3080, dtype=dtype), high=tf.constant(3112, dtype=dtype)) +# uniformpsi2s = tfd.Uniform(low=tf.constant(3670, dtype=dtype), high=tf.constant(3702, dtype=dtype)) + +# list_of_borders = [] +# _p = [] +# splits = 10 + +# _ = np.linspace(x_min, x_max, splits) + +# for i in range(splits): +# list_of_borders.append(tf.constant(_[i], dtype=dtype)) +# _p.append(tf.constant(1/splits, dtype=dtype)) + +# mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=_p[:(splits-1)]), +# components_distribution=tfd.Uniform(low=list_of_borders[:(splits-1)], +# high=list_of_borders[-(splits-1):])) + mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=[tf.constant(0.05, dtype=dtype), + tf.constant(0.93, dtype=dtype), + tf.constant(0.05, dtype=dtype), + tf.constant(0.065, dtype=dtype), + tf.constant(0.04, dtype=dtype), + tf.constant(0.05, dtype=dtype)]), + components_distribution=tfd.Uniform(low=[tf.constant(x_min, dtype=dtype), + tf.constant(3090, dtype=dtype), + tf.constant(3681, dtype=dtype), + tf.constant(3070, dtype=dtype), + tf.constant(1000, dtype=dtype), + tf.constant(3660, dtype=dtype)], + high=[tf.constant(x_max, dtype=dtype), + tf.constant(3102, dtype=dtype), + tf.constant(3691, dtype=dtype), + tf.constant(3110, dtype=dtype), + tf.constant(1040, dtype=dtype), + tf.constant(3710, dtype=dtype)])) +# dtype = tf.float64 +# mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=[tf.constant(0.04, dtype=dtype), +# tf.constant(0.90, dtype=dtype), +# tf.constant(0.02, dtype=dtype), +# tf.constant(0.07, dtype=dtype), +# tf.constant(0.02, dtype=dtype)]), +# components_distribution=tfd.Uniform(low=[tf.constant(x_min, dtype=dtype), +# tf.constant(3089, dtype=dtype), +# tf.constant(3103, dtype=dtype), +# tf.constant(3681, dtype=dtype), +# tf.constant(3691, dtype=dtype)], +# high=[tf.constant(3089, dtype=dtype), +# tf.constant(3103, dtype=dtype), +# tf.constant(3681, dtype=dtype), +# tf.constant(3691, dtype=dtype), +# tf.constant(x_max, dtype=dtype)])) +# mixture = tfd.Uniform(tf.constant(x_min, dtype=dtype), tf.constant(x_max, dtype=dtype)) +# sample = tf.random.uniform((n_to_produce, 1), dtype=dtype) + sample = mixture.sample((n_to_produce, 1)) +# sample = tf.random.uniform((n_to_produce, 1), dtype=dtype) + weights = mixture.prob(sample)[:,0] +# weights = tf.broadcast_to(tf.constant(1., dtype=dtype), shape=(n_to_produce,)) + # sample = tf.expand_dims(sample, axis=-1) +# print(sample, weights) + +# weights = tf.ones(shape=(n_to_produce,), dtype=dtype) + weights_max = None + thresholds = tf.random_uniform(shape=(n_to_produce,), dtype=dtype) + return sample, thresholds, weights, weights_max, n_to_produce + + +# In[ ]: + + +# total_f._sample_and_weights = UniformSampleAndWeights + + +# In[ ]: + + +# 0.00133/(0.00133+0.213+0.015)*(x_max-3750)/(x_max-x_min) + + +# In[ ]: + + +# zfit.settings.set_verbosity(10) + + +# In[ ]: + + +# # zfit.run.numeric_checks = False + +# nr_of_toys = 1 +# nevents = int(pdg["number_of_decays"]) +# nevents = pdg["number_of_decays"] +# event_stack = 1000000 +# # zfit.settings.set_verbosity(10) +# calls = int(nevents/event_stack + 1) + +# total_samp = [] + +# start = time.time() + +# sampler = total_f.create_sampler(n=event_stack) + +# for toy in range(nr_of_toys): + +# dirName = 'data/zfit_toys/toy_{0}'.format(toy) + +# if not os.path.exists(dirName): +# os.mkdir(dirName) +# print("Directory " , dirName , " Created ") + +# for call in range(calls): + +# sampler.resample(n=event_stack) +# s = sampler.unstack_x() +# sam = zfit.run(s) +# # clear_output(wait=True) + +# c = call + 1 + +# print("{0}/{1} of Toy {2}/{3}".format(c, calls, toy+1, nr_of_toys)) +# print("Time taken: {}".format(display_time(int(time.time() - start)))) +# print("Projected time left: {}".format(display_time(int((time.time() - start)/(c+calls*(toy))*((nr_of_toys-toy)*calls-c))))) + +# with open("data/zfit_toys/toy_{0}/{1}.pkl".format(toy, call), "wb") as f: +# pkl.dump(sam, f, pkl.HIGHEST_PROTOCOL) + + +# In[ ]: + + +# with open(r"data/zfit_toys/toy_0/0.pkl", "rb") as input_file: +# sam = pkl.load(input_file) +# print(sam[:10]) + +# with open(r"data/zfit_toys/toy_0/1.pkl", "rb") as input_file: +# sam2 = pkl.load(input_file) +# print(sam2[:10]) + +# print(np.sum(sam-sam2)) + + +# In[ ]: + + +# print("Time to generate full toy: {} s".format(int(time.time()-start))) + +# total_samp = [] + +# for call in range(calls): +# with open(r"data/zfit_toys/toy_0/{}.pkl".format(call), "rb") as input_file: +# sam = pkl.load(input_file) +# total_samp = np.append(total_samp, sam) + +# total_samp = total_samp.astype('float64') + +# data2 = zfit.data.Data.from_numpy(array=total_samp[:int(nevents)], obs=obs) + +# data3 = zfit.data.Data.from_numpy(array=total_samp, obs=obs) + +# print(total_samp[:nevents].shape) + + +# In[ ]: + + +# plt.clf() + +# bins = int((x_max-x_min)/7) + +# # calcs = zfit.run(total_test_tf(samp)) +# print(total_samp[:nevents].shape) + +# plt.hist(total_samp[:nevents], bins = bins, range = (x_min,x_max), label = 'data') +# # plt.plot(test_q, calcs_test*nevents , label = 'pdf') + +# # plt.plot(sam, calcs, '.') +# # plt.plot(test_q, calcs_test) +# # plt.yscale('log') +# plt.ylim(0, 200) +# # plt.xlim(3080, 3110) + +# plt.legend() + +# plt.savefig('test2.png') + + +# In[ ]: + + +# sampler = total_f.create_sampler(n=nevents) +# nll = zfit.loss.UnbinnedNLL(model=total_f, data=sampler, fit_range = (x_min, x_max)) + +# # for param in pdf.get_dependents(): +# # param.set_value(initial_value) + +# sampler.resample(n=nevents) + +# # Randomise initial values +# # for param in pdf.get_dependents(): +# # param.set_value(random value here) + +# # Minimise the NLL +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 10) +# minimum = minimizer.minimize(nll) + + +# In[ ]: + + +# jpsi_width + + +# In[ ]: + + +# plt.hist(sample, weights=1 / prob(sample)) + + +# # Fitting + +# In[ ]: + + +# start = time.time() + +# for param in total_f.get_dependents(): +# param.randomize() + +# # for param in total_f.get_dependents(): +# # print(zfit.run(param)) + +# nll = zfit.loss.UnbinnedNLL(model=total_f, data=data2, fit_range = (x_min, x_max)) + +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) +# # minimizer._use_tfgrad = False +# result = minimizer.minimize(nll) + +# # param_errors = result.error() + +# # for var, errors in param_errors.items(): +# # print('{}: ^{{+{}}}_{{{}}}'.format(var.name, errors['upper'], errors['lower'])) + +# print("Function minimum:", result.fmin) +# # print("Results:", result.params) +# print("Hesse errors:", result.hesse()) + + +# In[ ]: + + +# print("Time taken for fitting: {}".format(display_time(int(time.time()-start)))) + +# # probs = total_f.pdf(test_q) + +# calcs_test = zfit.run(probs) +# res_y = zfit.run(jpsi_res(test_q)) + + +# In[ ]: + + +# plt.clf() +# # plt.plot(x_part, calcs, '.') +# plt.plot(test_q, calcs_test, label = 'pdf') +# # plt.plot(test_q, res_y, label = 'res') +# plt.legend() +# plt.ylim(0.0, 10e-6) +# # plt.yscale('log') +# # plt.xlim(3080, 3110) +# plt.savefig('test3.png') +# # print(jpsi_width) + + +# In[ ]: + + +# _tot = 4.37e-7+6.02e-5+4.97e-6 +# _probs = [] +# _probs.append(6.02e-5/_tot) +# _probs.append(4.97e-6/_tot) +# _probs.append(4.37e-7/_tot) +# print(_probs) + + +# In[ ]: + + +# dtype = 'float64' +# # mixture = tfd.Uniform(tf.constant(x_min, dtype=dtype), tf.constant(x_max, dtype=dtype)) +# mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=[tf.constant(0.007, dtype=dtype), +# tf.constant(0.917, dtype=dtype), +# tf.constant(0.076, dtype=dtype)]), +# components_distribution=tfd.Uniform(low=[tf.constant(x_min, dtype=dtype), +# tf.constant(3080, dtype=dtype), +# tf.constant(3670, dtype=dtype)], +# high=[tf.constant(x_max, dtype=dtype), +# tf.constant(3112, dtype=dtype), +# tf.constant(3702, dtype=dtype)])) +# # for i in range(10): +# # print(zfit.run(mixture.prob(mixture.sample((10, 1))))) + + +# In[ ]: + + +# print((zfit.run(jpsi_p)%(2*np.pi))/np.pi) +# print((zfit.run(psi2s_p)%(2*np.pi))/np.pi) + + +# In[ ]: + + +# def jpsi_res(q): +# return resonance(q, _mass = jpsi_mass, scale = jpsi_scale, +# phase = jpsi_phase, width = jpsi_width) + +# def psi2s_res(q): +# return resonance(q, _mass = psi2s_mass, scale = psi2s_scale, +# phase = psi2s_phase, width = psi2s_width) + +# def p3770_res(q): +# return resonance(q, _mass = p3770_mass, scale = p3770_scale, +# phase = p3770_phase, width = p3770_width) + +# def p4040_res(q): +# return resonance(q, _mass = p4040_mass, scale = p4040_scale, +# phase = p4040_phase, width = p4040_width) + +# def p4160_res(q): +# return resonance(q, _mass = p4160_mass, scale = p4160_scale, +# phase = p4160_phase, width = p4160_width) + +# def p4415_res(q): +# return resonance(q, _mass = p4415_mass, scale = p4415_scale, +# phase = p4415_phase, width = p4415_width) + + +# In[ ]: + + +# 0.15**2*4.2/1000 +# result.hesse() + + +# ## Constraints + +# In[ ]: + + +# 1. Constraint - Real part of sum of Psi contrib and D contribs + +sum_list = [] + +sum_list.append(ztf.to_complex(jpsi_s) * tf.exp(tf.complex(ztf.constant(0.0), jpsi_p)) * ztf.to_complex(jpsi_w / (tf.pow(jpsi_m,3)))) +sum_list.append(ztf.to_complex(psi2s_s) * tf.exp(tf.complex(ztf.constant(0.0), psi2s_p)) * ztf.to_complex(psi2s_w / (tf.pow(psi2s_m,3)))) +sum_list.append(ztf.to_complex(p3770_s) * tf.exp(tf.complex(ztf.constant(0.0), p3770_p)) * ztf.to_complex(p3770_w / (tf.pow(p3770_m,3)))) +sum_list.append(ztf.to_complex(p4040_s) * tf.exp(tf.complex(ztf.constant(0.0), p4040_p)) * ztf.to_complex(p4040_w / (tf.pow(p4040_m,3)))) +sum_list.append(ztf.to_complex(p4160_s) * tf.exp(tf.complex(ztf.constant(0.0), p4160_p)) * ztf.to_complex(p4160_w / (tf.pow(p4160_m,3)))) +sum_list.append(ztf.to_complex(p4415_s) * tf.exp(tf.complex(ztf.constant(0.0), p4415_p)) * ztf.to_complex(p4415_w / (tf.pow(p4415_m,3)))) +sum_list.append(ztf.to_complex(DDstar_s) * tf.exp(tf.complex(ztf.constant(0.0), DDstar_p)) * (ztf.to_complex(1.0 / (10.0*tf.pow(Dstar_m,2)) + 1.0 / (10.0*tf.pow(D_m,2))))) +sum_list.append(ztf.to_complex(Dbar_s) * tf.exp(tf.complex(ztf.constant(0.0), Dbar_p)) * ztf.to_complex(1.0 / (6.0*tf.pow(Dbar_m,2)))) + +sum_ru_1 = ztf.to_complex(ztf.constant(0.0)) + +for part in sum_list: + sum_ru_1 += part + +sum_1 = tf.math.real(sum_ru_1) +# constraint1 = zfit.constraint.GaussianConstraint(params = sum_1, mu = ztf.constant(1.7*10**-8), +# sigma = ztf.constant(2.2*10**-8)) + +constraint1 = tf.pow((sum_1-ztf.constant(1.7*10**-8))/ztf.constant(2.2*10**-8),2)/ztf.constant(2.) + +# 2. Constraint - Abs. of sum of Psi contribs and D contribs + +sum_2 = tf.abs(sum_ru_1) +constraint2 = tf.cond(tf.greater_equal(sum_2, 5.0e-8), lambda: 100000., lambda: 0.) + +# 3. Constraint - Maximum eta of D contribs + +constraint3_0 = tf.cond(tf.greater_equal(tf.abs(Dbar_s), 0.2), lambda: 100000., lambda: 0.) + +constraint3_1 = tf.cond(tf.greater_equal(tf.abs(DDstar_s), 0.2), lambda: 100000., lambda: 0.) + +# 4. Constraint - Formfactor multivariant gaussian covariance fplus + +Cov_matrix = [[ztf.constant( 1.), ztf.constant( 0.45), ztf.constant( 0.19), ztf.constant(0.857), ztf.constant(0.598), ztf.constant(0.531), ztf.constant(0.752), ztf.constant(0.229), ztf.constant(0,117)], + [ztf.constant( 0.45), ztf.constant( 1.), ztf.constant(0.677), ztf.constant(0.708), ztf.constant(0.958), ztf.constant(0.927), ztf.constant(0.227), ztf.constant(0.443), ztf.constant(0.287)], + [ztf.constant( 0.19), ztf.constant(0.677), ztf.constant( 1.), ztf.constant(0.595), ztf.constant(0.770), ztf.constant(0.819),ztf.constant(-0.023), ztf.constant( 0.07), ztf.constant(0.196)], + [ztf.constant(0.857), ztf.constant(0.708), ztf.constant(0.595), ztf.constant( 1.), ztf.constant( 0.83), ztf.constant(0.766), ztf.constant(0.582), ztf.constant(0.237), ztf.constant(0.192)], + [ztf.constant(0.598), ztf.constant(0.958), ztf.constant(0.770), ztf.constant( 0.83), ztf.constant( 1.), ztf.constant(0.973), ztf.constant(0.324), ztf.constant(0.372), ztf.constant(0.272)], + [ztf.constant(0.531), ztf.constant(0.927), ztf.constant(0.819), ztf.constant(0.766), ztf.constant(0.973), ztf.constant( 1.), ztf.constant(0.268), ztf.constant(0.332), ztf.constant(0.269)], + [ztf.constant(0.752), ztf.constant(0.227),ztf.constant(-0.023), ztf.constant(0.582), ztf.constant(0.324), ztf.constant(0.268), ztf.constant( 1.), ztf.constant( 0.59), ztf.constant(0.515)], + [ztf.constant(0.229), ztf.constant(0.443), ztf.constant( 0.07), ztf.constant(0.237), ztf.constant(0.372), ztf.constant(0.332), ztf.constant( 0.59), ztf.constant( 1.), ztf.constant(0.897)], + [ztf.constant(0.117), ztf.constant(0.287), ztf.constant(0.196), ztf.constant(0.192), ztf.constant(0.272), ztf.constant(0.269), ztf.constant(0.515), ztf.constant(0.897), ztf.constant( 1.)]] + +def triGauss(val1,val2,val3,m = Cov_matrix): + + mean1 = ztf.constant(0.466) + mean2 = ztf.constant(-0.885) + mean3 = ztf.constant(-0.213) + sigma1 = ztf.constant(0.014) + sigma2 = ztf.constant(0.128) + sigma3 = ztf.constant(0.548) + x1 = (val1-mean1)/sigma1 + x2 = (val2-mean2)/sigma2 + x3 = (val3-mean3)/sigma3 + rho12 = m[0][1] + rho13 = m[0][2] + rho23 = m[1][2] + w = x1*x1*(rho23*rho23-1) + x2*x2*(rho13*rho13-1)+x3*x3*(rho12*rho12-1)+2*(x1*x2*(rho12-rho13*rho23)+x1*x3*(rho13-rho12*rho23)+x2*x3*(rho23-rho12*rho13)) + d = 2*(rho12*rho12+rho13*rho13+rho23*rho23-2*rho12*rho13*rho23-1) + + fcn = -w/d + chisq = -2*fcn + return chisq + +constraint4 = triGauss(bplus_0, bplus_1, bplus_2) + +# mean1 = ztf.constant(0.466) +# mean2 = ztf.constant(-0.885) +# mean3 = ztf.constant(-0.213) +# sigma1 = ztf.constant(0.014) +# sigma2 = ztf.constant(0.128) +# sigma3 = ztf.constant(0.548) +# constraint4_0 = tf.pow((bplus_0-mean1)/sigma1,2)/ztf.constant(2.) +# constraint4_1 = tf.pow((bplus_1-mean2)/sigma2,2)/ztf.constant(2.) +# constraint4_2 = tf.pow((bplus_2-mean3)/sigma3,2)/ztf.constant(2.) + +# 5. Constraint - Abs. of sum of light contribs + +sum_list_5 = [] + +sum_list_5.append(rho_s*rho_w/rho_m) +sum_list_5.append(omega_s*omega_w/omega_m) +sum_list_5.append(phi_s*phi_w/phi_m) + + +sum_ru_5 = ztf.constant(0.0) + +for part in sum_list_5: + sum_ru_5 += part + +constraint5 = tf.cond(tf.greater_equal(tf.abs(sum_ru_5), ztf.constant(0.02)), lambda: 100000., lambda: 0.) + +# 6. Constraint on phases of Jpsi and Psi2s for cut out fit + + +# constraint6_0 = zfit.constraint.GaussianConstraint(params = jpsi_p, mu = ztf.constant(pdg["jpsi_phase_unc"]), +# sigma = ztf.constant(jpsi_phase)) +# constraint6_1 = zfit.constraint.GaussianConstraint(params = psi2s_p, mu = ztf.constant(pdg["psi2s_phase_unc"]), +# sigma = ztf.constant(psi2s_phase)) + +constraint6_0 = tf.pow((jpsi_p-ztf.constant(jpsi_phase))/ztf.constant(pdg["jpsi_phase_unc"]),2)/ztf.constant(2.) +constraint6_1 = tf.pow((psi2s_p-ztf.constant(psi2s_phase))/ztf.constant(pdg["psi2s_phase_unc"]),2)/ztf.constant(2.) + +# 7. Constraint on Ctt with higher limits + +constraint7 = tf.cond(tf.greater_equal(Ctt*Ctt, 0.25), lambda: 100000., lambda: 0.) + +constraint7dtype = tf.float64 + +# zfit.run(constraint6_0) + +# ztf.convert_to_tensor(constraint6_0) + +#List of all constraints + +constraints = [constraint1, constraint2, constraint3_0, constraint3_1,# constraint4, #constraint4_0, constraint4_1, constraint4_2, + constraint6_0, constraint6_1]#, constraint7] + + +# ## Reset params + +# In[ ]: + + +param_values_dic = { + 'jpsi_m': jpsi_mass, + 'jpsi_s': jpsi_scale, + 'jpsi_p': jpsi_phase, + 'jpsi_w': jpsi_width, + 'psi2s_m': psi2s_mass, + 'psi2s_s': psi2s_scale, + 'psi2s_p': psi2s_phase, + 'psi2s_w': psi2s_width, + 'p3770_m': p3770_mass, + 'p3770_s': p3770_scale, + 'p3770_p': p3770_phase, + 'p3770_w': p3770_width, + 'p4040_m': p4040_mass, + 'p4040_s': p4040_scale, + 'p4040_p': p4040_phase, + 'p4040_w': p4040_width, + 'p4160_m': p4160_mass, + 'p4160_s': p4160_scale, + 'p4160_p': p4160_phase, + 'p4160_w': p4160_width, + 'p4415_m': p4415_mass, + 'p4415_s': p4415_scale, + 'p4415_p': p4415_phase, + 'p4415_w': p4415_width, + 'rho_m': rho_mass, + 'rho_s': rho_scale, + 'rho_p': rho_phase, + 'rho_w': rho_width, + 'omega_m': omega_mass, + 'omega_s': omega_scale, + 'omega_p': omega_phase, + 'omega_w': omega_width, + 'phi_m': phi_mass, + 'phi_s': phi_scale, + 'phi_p': phi_phase, + 'phi_w': phi_width, + 'Dstar_m': Dstar_mass, + 'DDstar_s': 0.0, + 'DDstar_p': 0.0, + 'D_m': D_mass, + 'Dbar_m': Dbar_mass, + 'Dbar_s': 0.0, + 'Dbar_p': 0.0, + 'tau_m': pdg['tau_M'], + 'Ctt': 0.0, + 'b0_0': 0.292, + 'b0_1': 0.281, + 'b0_2': 0.150, + 'bplus_0': 0.466, + 'bplus_1': -0.885, + 'bplus_2': -0.213, + 'bT_0': 0.460, + 'bT_1': -1.089, + 'bT_2': -1.114} + + +def reset_param_values(variation = 0.05): + for param in total_f_fit.get_dependents(): + if param.floating: + param.set_value(param_values_dic[param.name] + random.uniform(-1, 1) * param_values_dic[param.name]* variation) +# print(param.name) +# for param in totalf.get_dependents(): +# param.set_value() + + +# # Analysis + +# In[ ]: + + +# # zfit.run.numeric_checks = False + +# fitting_range = 'cut' +# total_BR = 1.7e-10 + 4.9e-10 + 2.5e-9 + 6.02e-5 + 4.97e-6 + 1.38e-9 + 4.2e-10 + 2.6e-9 + 6.1e-10 + 4.37e-7 +# cut_BR = 1.0 - (6.02e-5 + 4.97e-6)/total_BR + +# Ctt_list = [] +# Ctt_error_list = [] + +# nr_of_toys = 1 +# if fitting_range == 'cut': +# nevents = int(pdg["number_of_decays"]*cut_BR) +# else: +# nevents = int(pdg["number_of_decays"]) +# # nevents = pdg["number_of_decays"] +# event_stack = 1000000 +# # nevents *= 41 +# # zfit.settings.set_verbosity(10) +# calls = int(nevents/event_stack + 1) + +# total_samp = [] + +# start = time.time() + +# sampler = total_f.create_sampler(n=event_stack) + +# for toy in range(nr_of_toys): + +# ### Generate data + +# # clear_output(wait=True) + +# print("Toy {}: Generating data...".format(toy)) + +# dirName = 'data/zfit_toys/toy_{0}'.format(toy) + +# if not os.path.exists(dirName): +# os.mkdir(dirName) +# print("Directory " , dirName , " Created ") + +# reset_param_values() + +# if fitting_range == 'cut': + +# sampler.resample(n=nevents) +# s = sampler.unstack_x() +# sam = zfit.run(s) +# calls = 0 +# c = 1 + +# else: +# for call in range(calls): + +# sampler.resample(n=event_stack) +# s = sampler.unstack_x() +# sam = zfit.run(s) + +# c = call + 1 + +# with open("data/zfit_toys/toy_{0}/{1}.pkl".format(toy, call), "wb") as f: +# pkl.dump(sam, f, pkl.HIGHEST_PROTOCOL) + +# print("Toy {}: Data generation finished".format(toy)) + +# ### Load data + +# print("Toy {}: Loading data...".format(toy)) + +# if fitting_range == 'cut': + +# total_samp = sam + +# else: + +# for call in range(calls): +# with open(r"data/zfit_toys/toy_0/{}.pkl".format(call), "rb") as input_file: +# sam = pkl.load(input_file) +# total_samp = np.append(total_samp, sam) + +# total_samp = total_samp.astype('float64') + +# if fitting_range == 'full': + +# data = zfit.data.Data.from_numpy(array=total_samp[:int(nevents)], obs=obs) + +# print("Toy {}: Loading data finished".format(toy)) + +# ### Fit data + +# print("Toy {}: Fitting pdf...".format(toy)) + +# for param in total_f.get_dependents(): +# param.randomize() + +# nll = zfit.loss.UnbinnedNLL(model=total_f, data=data, fit_range = (x_min, x_max), constraints = constraints) + +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) +# # minimizer._use_tfgrad = False +# result = minimizer.minimize(nll) + +# print("Toy {}: Fitting finished".format(toy)) + +# print("Function minimum:", result.fmin) +# print("Hesse errors:", result.hesse()) + +# params = result.params +# Ctt_list.append(params[Ctt]['value']) +# Ctt_error_list.append(params[Ctt]['minuit_hesse']['error']) + +# #plotting the result + +# plotdirName = 'data/plots'.format(toy) + +# if not os.path.exists(plotdirName): +# os.mkdir(plotdirName) +# # print("Directory " , dirName , " Created ") + +# probs = total_f.pdf(test_q, norm_range=False) +# calcs_test = zfit.run(probs) +# plt.clf() +# plt.plot(test_q, calcs_test, label = 'pdf') +# plt.legend() +# plt.ylim(0.0, 6e-6) +# plt.savefig(plotdirName + '/toy_fit_full_range{}.png'.format(toy)) + +# print("Toy {0}/{1}".format(toy+1, nr_of_toys)) +# print("Time taken: {}".format(display_time(int(time.time() - start)))) +# print("Projected time left: {}".format(display_time(int((time.time() - start)/(c+calls*(toy))*((nr_of_toys-toy)*calls-c))))) + +# if fitting_range == 'cut': + +# _1 = np.where((total_samp >= x_min) & (total_samp <= (jpsi_mass - 60.))) + +# tot_sam_1 = total_samp[_1] + +# _2 = np.where((total_samp >= (jpsi_mass + 70.)) & (total_samp <= (psi2s_mass - 50.))) + +# tot_sam_2 = total_samp[_2] + +# _3 = np.where((total_samp >= (psi2s_mass + 50.)) & (total_samp <= x_max)) + +# tot_sam_3 = total_samp[_3] + +# tot_sam = np.append(tot_sam_1, tot_sam_2) +# tot_sam = np.append(tot_sam, tot_sam_3) + +# data = zfit.data.Data.from_numpy(array=tot_sam[:int(nevents)], obs=obs_fit) + +# print("Toy {}: Loading data finished".format(toy)) + +# ### Fit data + +# print("Toy {}: Fitting pdf...".format(toy)) + +# for param in total_f_fit.get_dependents(): +# param.randomize() + +# nll = zfit.loss.UnbinnedNLL(model=total_f_fit, data=data, constraints = constraints) + +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) +# # minimizer._use_tfgrad = False +# result = minimizer.minimize(nll) + +# print("Function minimum:", result.fmin) +# print("Hesse errors:", result.hesse()) + +# params = result.params + +# if result.converged: +# Ctt_list.append(params[Ctt]['value']) +# Ctt_error_list.append(params[Ctt]['minuit_hesse']['error']) + +# #plotting the result + +# plotdirName = 'data/plots'.format(toy) + +# if not os.path.exists(plotdirName): +# os.mkdir(plotdirName) +# # print("Directory " , dirName , " Created ") + +# plt.clf() +# plt.hist(tot_sam, bins = int((x_max-x_min)/7.), label = 'toy data') +# plt.savefig(plotdirName + '/toy_histo_cut_region{}.png'.format(toy)) + + +# probs = total_f_fit.pdf(test_q, norm_range=False) +# calcs_test = zfit.run(probs) +# plt.clf() +# plt.plot(test_q, calcs_test, label = 'pdf') +# plt.axvline(x=jpsi_mass-60.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.axvline(x=jpsi_mass+70.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.axvline(x=psi2s_mass-50.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.axvline(x=psi2s_mass+50.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.legend() +# plt.ylim(0.0, 1.5e-6) +# plt.savefig(plotdirName + '/toy_fit_cut_region{}.png'.format(toy)) + +# print("Toy {0}/{1}".format(toy+1, nr_of_toys)) +# print("Time taken: {}".format(display_time(int(time.time() - start)))) +# print("Projected time left: {}".format(display_time(int((time.time() - start)/(toy+1))*((nr_of_toys-toy-1))))) + + + +# In[ ]: + + +# with open("data/results/Ctt_list.pkl", "wb") as f: +# pkl.dump(Ctt_list, f, pkl.HIGHEST_PROTOCOL) +# with open("data/results/Ctt_error_list.pkl", "wb") as f: +# pkl.dump(Ctt_error_list, f, pkl.HIGHEST_PROTOCOL) + + +# In[ ]: + + +# print('{0}/{1} fits converged'.format(len(Ctt_list), nr_of_toys)) +# print('Mean Ctt value = {}'.format(np.mean(Ctt_list))) +# print('Mean Ctt error = {}'.format(np.mean(Ctt_error_list))) +# print('95 Sensitivy = {}'.format(((2*np.mean(Ctt_error_list))**2)*4.2/1000)) + + +# In[ ]: + + +# plt.hist(tot_sam, bins = int((x_max-x_min)/7.)) + +# plt.show() + +# # _ = np.where((total_samp >= x_min) & (total_samp <= (jpsi_mass - 50.))) + +# tot_sam.shape + + +# In[ ]: + + +# Ctt.floating = False + + +# In[ ]: + + +# zfit.run(nll.value()) + + +# In[ ]: + + +# result.fmin + + +# In[ ]: + + +# BR_steps = np.linspace(0.0, 1e-3, 11) +pull_dic = {} + +mi = 1e-4 +ma = 3e-3 +ste = 20 + +for param in total_f_fit.get_dependents(): + if param.floating: + pull_dic[param.name] = [] + for step in range(2*ste): + pull_dic[param.name].append([]) + + + +def save_pulls(step): + for param in total_f_fit.get_dependents(): + if param.floating: + pull_dic[param.name][step].append((params[param]['value'] - param_values_dic[param.name])/params[param]['minuit_hesse']['error']) + + + +# for key in pull_dic.keys(): +# print(np.shape(pull_dic[key])) +# save_pulls(New_step=True) +# params[Ctt]['value'] + + +# In[ ]: + + +# for param in total_f_fit.get_dependents(): +# if param.floating: +# print(param.name) + +# print(params[Ctt]) + + +# # CLS Code + +# In[ ]: + + +# zfit.run.numeric_checks = False + +load = False + +bo = True + +D_contribs = True + +if not D_contribs: + Dbar_s.floating = False + Dbar_p.floating = False + DDstar_s.floating = False + DDstar_p.floating = False + +bo_set = 1 + +fitting_range = 'cut' +total_BR = 1.7e-10 + 4.9e-10 + 2.5e-9 + 6.02e-5 + 4.97e-6 + 1.38e-9 + 4.2e-10 + 2.6e-9 + 6.1e-10 + 4.37e-7 +cut_BR = 1.0 - (6.02e-5 + 4.97e-6)/total_BR + +Ctt_list = [] +Ctt_error_list = [] + +nr_of_toys = 1 +nevents = int(pdg["number_of_decays"]*cut_BR) +# nevents = pdg["number_of_decays"] +event_stack = 1000000 +# nevents *= 41 +# zfit.settings.set_verbosity(10) + +# mi = 1e-4 +# ma = 3e-3 +# ste = 13 + +BR_steps = np.linspace(mi, ma, ste) + +BR_steps[0] = 0.0 + +print(BR_steps) + +Ctt_steps = np.sqrt(BR_steps/4.2*1000) + +print(Ctt_steps) + +# total_samp = [] + +start = time.time() + +Nll_list = [] + +sampler = total_f.create_sampler(n=nevents, fixed_params = False) +sampler.set_data_range(obs_fit) + +__ = -1 + +#----------------------------------------------------- + +if not load: + for Ctt_step in Ctt_steps: + + __ += 1 + + for i in range(2): + Ctt_list.append([]) + Ctt_error_list.append([]) + Nll_list.append([]) + + for param in total_f_fit.get_dependents(): + if param.floating: + pull_dic[param.name].append([]) + + for toy in range(nr_of_toys): + + newset = True + + while newset: + + for floaty in [True, False]: + Ctt.floating = floaty + + for bo_step in range(bo_set): + + print('Step: {0}/{1}'.format(int(__), ste)) + print('Current Ctt: {0}'.format(Ctt_step)) + print('Ctt floating: {0}'.format(floaty)) + + reset_param_values(variation = 0.0) + + if floaty: + print('Toy {0}/{1} - Fit {2}/{3}'.format(toy, nr_of_toys, bo_step, bo_set)) + Ctt.set_value(Ctt_step) + + else: + Ctt.set_value(0.0) + print('Toy {0}/{1} - Fit {2}/{3}'.format(toy, nr_of_toys, bo_step, bo_set)) + + if newset: + sampler.resample(n=nevents) + data = sampler + newset = False + + ### Fit data + + if floaty: + #plt.clf() + #plt.title('Ctt value: {:.2f}'.format(Ctt_step)) + #plt.hist(zfit.run(data), bins = int((x_max-x_min)/7), range = (x_min, x_max)) + #plt.savefig('data/CLs/plots/set_histo{}.png'.format(__)) + _step = 2*__ + else: + _step = 2*__+1 + + nll = zfit.loss.UnbinnedNLL(model=total_f_fit, data=data, constraints = constraints) + + minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) + # minimizer._use_tfgrad = False + result = minimizer.minimize(nll) + + print("Function minimum:", result.fmin) + print("Hesse errors:", result.hesse()) + + params = result.params + + if result.converged: + + save_pulls(step = _step) + + if floaty: + Nll_list[-2].append(result.fmin) + Ctt_list[-2].append(params[Ctt]['value']) + Ctt_error_list[-2].append(params[Ctt]['minuit_hesse']['error']) + + else: + Nll_list[-1].append(result.fmin) + Ctt_list[-1].append(0.0) + Ctt_error_list[-1].append(0.0) + + + else: + for _ in [1,2]: + del Nll_list[-_][toy*bo_set:] +# print(np.shape(Nll_list[-_])) + del Ctt_list[-_][toy*bo_set:] + del Ctt_error_list[-_][toy*bo_set:] + for param in total_f_fit.get_dependents(): + if param.floating: + del pull_dic[param.name][_step+1-_][toy*bo_set:] + newset = True + break + + if not result.converged: + break + + print() + print('Time taken: {}'.format(display_time(int(time.time()-start)))) + print('Estimated time left: {}'.format(display_time(int((time.time()-start)/(__+(toy+1)/nr_of_toys)*(ste-__-(nr_of_toys-toy-1)/nr_of_toys))))) + + +# In[ ]: + + +if load: + + phase_combi = '--' + + if D_contribs: + D_dir = 'D-True' + else: + D_dir = 'D-False' + + _dir = 'data/CLs/finished/f1d1/{}/{}/'.format(phase_combi, D_dir) + + jobs = os.listdir(_dir) + + First = True + +# print(jobs) + + for job in jobs: + + dirName = _dir + str(job) + '/data/CLs' + + if not os.path.exists("{}/{}-{}_{}s{}b{}t--CLs_Nll_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys)): +# print(job) + continue + + with open(r"{}/variab.pkl".format(dirName), "rb") as input_file: + variab = pkl.load(input_file) +# print(variab) + + ### sanity check: + if variab['mi'] != mi or variab['ma'] != ma or variab['ste'] != ste or bo_set != bo_set: + print('Fitting parameters of data dont equal the ones given -- Job {} skipped!'.format(job)) + + with open(r"{}/{}-{}_{}s{}b{}t--CLs_Nll_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _Nll_list = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s{}b{}t--Ctt_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _Ctt_list = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s{}b{}t--Ctt_error_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _Ctt_error_list = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s{}b{}t--pull_dic.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _pull_dic = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s--CLs_list.pkl".format(dirName, mi,ma,ste), "rb") as input_file: + _CLs_list = pkl.load(input_file) + + + if First: + Nll_list = _Nll_list + Ctt_list = _Ctt_list + Ctt_error_list = _Ctt_error_list + pull_dic = _pull_dic +# print(_pull_dic) + CLs_list = _CLs_list + First = False + else: + for step in range(2*ste): +# print(Nll_list[step], step) + Nll_list[step].extend(_Nll_list[step]) + Ctt_list[step].extend(_Ctt_list[step]) + Ctt_error_list[step].extend(_Ctt_error_list[step]) + for key in pull_dic.keys(): +# print(key, np.shape(pull_dic[key])) + pull_dic[key][step].extend(_pull_dic[key][step]) + for step in range(ste): + CLs_list[step].extend(_CLs_list[step]) + +# print('----------------------') + + +# In[ ]: + + +dirName = 'data/CLs' + +# if bo and not load: +# for s in range(2*ste): +# Nll_list[s] = [np.min(Nll_list[s])] + + +if not load: + + if not os.path.exists(dirName): + os.mkdir(dirName) + print("Directory " , dirName , " Created ") + + with open("{}/{}-{}_{}s{}b{}t--CLs_Nll_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(Nll_list, f, pkl.HIGHEST_PROTOCOL) + + with open("{}/{}-{}_{}s{}b{}t--Ctt_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(Ctt_list, f, pkl.HIGHEST_PROTOCOL) + + with open("{}/{}-{}_{}s{}b{}t--Ctt_error_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(Ctt_error_list, f, pkl.HIGHEST_PROTOCOL) + + with open("{}/{}-{}_{}s{}b{}t--pull_dic.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(pull_dic, f, pkl.HIGHEST_PROTOCOL) + + variab = {'mi': mi, + 'ma': ma, + 'ste': ste, + 'bo_set': bo_set, + 'nr_of_toys': nr_of_toys} + + with open("{}/variab.pkl".format(dirName), "wb") as f: + pkl.dump(variab, f, pkl.HIGHEST_PROTOCOL) + + CLs_values = [] + + toy_size = bo_set + + print(np.shape(Nll_list)) + print(Nll_list[0:1]) + + for step in range(ste): + CLs_values.append([]) + for toy in range(nr_of_toys): + float_min = np.min(Nll_list[2*step][toy*bo_set:(toy+1)*bo_set]) + fix_min = np.min(Nll_list[2*step+1][toy*bo_set:(toy+1)*bo_set]) + CLs_values[step].append(float_min-fix_min) + + + print(np.shape(CLs_values)) + + with open("{}/{}-{}_{}s--CLs_list.pkl".format(dirName, mi,ma,ste), "wb") as f: + pkl.dump(CLs_values, f, pkl.HIGHEST_PROTOCOL) + + +# In[ ]: + + +# print(variab['mi'] != mi) + + +# ## Plot + +# In[ ]: + + +l = [] + + +if load: + CLs_values = -1*np.array(CLs_list) + +if not os.path.exists('data/CLs/plots'): + os.mkdir('data/CLs/plots') + print("Directory " , 'data/CLs/plots' , " Created ") + +print(np.shape(CLs_values)) + +for step in range(1,ste): + plt.clf() + plt.title('Ctt value: {:.2f}'.format(Ctt_steps[step])) + plt.hist(CLs_values[0], bins = 150, range = (-25, 50), label = 'Ctt fixed to 0') + plt.hist(CLs_values[step], bins = 150, range = (-25, 50), label = 'Ctt floating') + plt.axvline(x=np.mean(CLs_values[0]),color='red', linewidth=1.0, linestyle = 'dotted') + plt.legend() + plt.savefig('data/CLs/plots/CLs-BR({:.1E}).png'.format(BR_steps[step])) + + l.append(len(np.where(np.array(CLs_values[step]) < np.mean(CLs_values[0]))[0])) + +for step in range(2*ste): + if step%2 == 0: + floaty = True + else: + floaty = False + for key in pull_dic.keys(): + if not os.path.exists('data/CLs/plots/{}'.format(key)): + os.mkdir('data/CLs/plots/{}'.format(key)) + plt.clf() + plt.title('Pull {} - Ctt value {:.2f} - floating {}'.format(key, Ctt_steps[int(step/2)], floaty)) + plt.hist(pull_dic[key][step], bins = 50, range = (-5,5)) + plt.xlabel('Pull') + plt.savefig('data/CLs/plots/{}/{:.2f}Ctt{}s{}f.png'.format(key, Ctt_steps[int(step/2)], step, floaty)) + + +# In[ ]: + + +for s in range(len(l)): + print('BR: {:.4f}'.format(BR_steps[s+1])) + print(2*l[s]/len(CLs_values[s])) + print() + + +# In[ ]: + + +# for step in range(2*ste): +# for key in pull_dic.keys(): +# print(pull_dic[key][step]) + + +# In[ ]: + + +# for param in total_f_fit.get_dependents(): +# if param.floating: +# print(params[param]['value']) + + +# In[ ]: + + +print(display_time(int(time.time()-start))) + + +# In[ ]: + + +# variab['mi'] =! mi + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + diff --git a/data/CLs/finished/f1d1/-+/D-True/2288035/__pycache__/helperfunctions.cpython-37.pyc b/data/CLs/finished/f1d1/-+/D-True/2288035/__pycache__/helperfunctions.cpython-37.pyc new file mode 100644 index 0000000..b368103 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288035/__pycache__/helperfunctions.cpython-37.pyc Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288035/__pycache__/pdg_const1.cpython-37.pyc b/data/CLs/finished/f1d1/-+/D-True/2288035/__pycache__/pdg_const1.cpython-37.pyc new file mode 100644 index 0000000..0a942c8 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288035/__pycache__/pdg_const1.cpython-37.pyc Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288035/data/CLs/0.0001-0.003_20s--CLs_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288035/data/CLs/0.0001-0.003_20s--CLs_list.pkl new file mode 100644 index 0000000..5d60035 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288035/data/CLs/0.0001-0.003_20s--CLs_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288035/data/CLs/0.0001-0.003_20s1b1t--CLs_Nll_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288035/data/CLs/0.0001-0.003_20s1b1t--CLs_Nll_list.pkl new file mode 100644 index 0000000..db3bfe7 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288035/data/CLs/0.0001-0.003_20s1b1t--CLs_Nll_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288035/data/CLs/0.0001-0.003_20s1b1t--Ctt_error_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288035/data/CLs/0.0001-0.003_20s1b1t--Ctt_error_list.pkl new file mode 100644 index 0000000..7c2cdac --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288035/data/CLs/0.0001-0.003_20s1b1t--Ctt_error_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288035/data/CLs/0.0001-0.003_20s1b1t--Ctt_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288035/data/CLs/0.0001-0.003_20s1b1t--Ctt_list.pkl new file mode 100644 index 0000000..371719a --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288035/data/CLs/0.0001-0.003_20s1b1t--Ctt_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288035/data/CLs/0.0001-0.003_20s1b1t--pull_dic.pkl b/data/CLs/finished/f1d1/-+/D-True/2288035/data/CLs/0.0001-0.003_20s1b1t--pull_dic.pkl new file mode 100644 index 0000000..b09fdb7 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288035/data/CLs/0.0001-0.003_20s1b1t--pull_dic.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288035/data/CLs/variab.pkl b/data/CLs/finished/f1d1/-+/D-True/2288035/data/CLs/variab.pkl new file mode 100644 index 0000000..bb90dc0 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288035/data/CLs/variab.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288035/helperfunctions.py b/data/CLs/finished/f1d1/-+/D-True/2288035/helperfunctions.py new file mode 100644 index 0000000..88e120f --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288035/helperfunctions.py @@ -0,0 +1,33 @@ +# some helperfunctions + +import matplotlib +matplotlib.use("agg") +import matplotlib.pyplot as plt + +#Dislpay time (e.g. while generating points) + +display_intervals = ( + ('w', 604800), # 60 * 60 * 24 * 7 + ('d', 86400), # 60 * 60 * 24 + ('h', 3600), # 60 * 60 + ('min', 60), + ('s', 1), + ) + +def display_time(seconds, granularity=2): + result = [] + + for name, count in display_intervals: + value = seconds // count + if value: + seconds -= value * count + if value == 1: + name = name.rstrip('s') + result.append("{} {}".format(value, name)) + return ', '.join(result[:granularity]) + +def prepare_plot(title): + plt.title(title) + plt.grid() + plt.legend(loc = 'best') + plt.xlabel("q") diff --git a/data/CLs/finished/f1d1/-+/D-True/2288035/pdg_const1.py b/data/CLs/finished/f1d1/-+/D-True/2288035/pdg_const1.py new file mode 100644 index 0000000..70b3f30 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288035/pdg_const1.py @@ -0,0 +1,226 @@ +pdg = { + + + ###Particle masses### + + "mbstar" : 5415.4, + "mbstar0" : 5711.0, + "B0_M" : 5279.5, + "Bs_M" : 5366.7, + "Bplus_M" : 5279.3, + "Lb_M" : 5619.4, + "D0_M" : 1864.8, + "Dst_M" : 2010, + "pi_M" : 139.6, + "Jpsi_M" : 3096.9, + "Psi2s_M" : 3685.6, + "kaon_M" : 493.7, + "Ks_M" : 497.6, + "phi_M" : 1019.5, + "rho_M" : 775.26, + "rho_width" : 149.1, + "omega_M" : 782.65, + "omega_width" : 8.49, + + "muon_M" : 105.7, + "tau_M": 1776.86, + + "squark_M" : 95.0, + "bquark_M" : 4180.0, + "cquark_M" : 1275.0, + + "Bplus_tau" : 1.638e-12, + + ###Wilson coefficients### + + "C1" : -0.257, + "C2" : 1.009, + "C3" : -0.005, + "C4" : -0.078, + + "C7eff" : -0.306, + "C9eff" : 4.211, + "C10eff" : -4.103, + +# "C7eff": 0.0, +# "C9eff": 0.0, +# "C10eff": 0.0, + + ###Other constants + + "GF" : 1.1663787e-5, + "alpha_ew" : 1.0/137.0, + "Vts" : 0.0394, + "Vtb" : 1.019, + "number_of_decays": 5404696, + + #Formfactor z coefficients + + #"b0" : [0.285, 0.19, -0.17], + #"bplus" : [0.437, -1.41, -2.5], + #"bT" : [0.440, -1.47, -2.7] + + "b0" : [0.292, 0.281, 0.150], + "bplus" : [0.466, -0.885, -0.213], + "bT" : [0.460, -1.089, -1.114], + + "NR_BR": 4.37e-7, + "NR_auc": 0.00133, + + #Resonances format(mass, width, phase, scale) + + # pre scaling + +# "rho": (775.26, 149.0, -0.35, 1.0), + +# "omega": (782.7, 8.5, 0.26, 1.0), + +# "phi": (1019.46, 4.25, 0.5, 1.0), + +# "jpsi": (3096.0, 0.09, -1.5, 2e-2), +# "jpsi_auc": 0.2126825758464027, + +# "psi2s": (3686.0, 0.3, -1.5, 3.14e-3), +# "psi2s_auc": 2.802257483178487e-10, + +# "p3770": (3773.0, 27.2, -2.13, 1.0e-3), + +# "p4040": (4039.0, 80.0, -2.52, 2.0), + +# "p4160": (4191.0, 70.0, -1.9, 2.2), + +# "p4415": (4421.0, 62.0, -2.52, 1.0), + + + # after scaling (Phase combination --) + + # + # "rho": (743.2, 149.0, -0.22, 1.05), + # + # "omega": (782.7, 8.5, 0.38, 6.8), + # + # "phi": (1013.5, 4.25, 0.62, 19.2), + # + # "jpsi": (3096.1, 0.09, 1.63, 9897.0), + # "jpsi_auc": 0.2126825758464027, + # "jpsi_phase_unc": 0.05, + # + # "psi2s": (3686.0, 0.3, 1.8, 1396.0), + # "psi2s_auc": 0.0151332263, + # "psi2s_phase_unc": 0.1, + # + # "p3770": (3773.0, 27.2, -2.95, 2.5), + # + # "p4040": (4039.0, 80.0, -2.75, 1.01), + # + # "p4160": (4191.0, 70.0, -2.28, 2.2), + # + # "p4415": (4421.0, 62.0, -2.31, 1.24), + + # Phase combination of paper ++ + +# "rho": (743.2, 149.0, -0.35, 1.05), + +# "omega": (782.7, 8.5, 0.26, 6.8), + +# "phi": (1013.5, 4.25, 0.47, 19.2), + +# "jpsi": (3096.1, 0.09, -1.66, 9897.0), +# "jpsi_auc": 0.2126825758464027, +# "jpsi_phase_unc": 0.05, + +# "psi2s": (3686.0, 0.3, -1.93, 1396.0), +# "psi2s_auc": 0.0151332263, +# "psi2s_phase_unc": 0.1, + +# "p3770": (3773.0, 27.2, -2.13, 2.5), + +# "p4040": (4039.0, 80.0, -2.52, 1.01), + +# "p4160": (4191.0, 70.0, -1.90, 2.2), + +# "p4415": (4421.0, 62.0, -2.52, 1.24), + + # Phase combination of paper +- + +# "rho": (743.2, 149.0, -0.26, 1.05), + +# "omega": (782.7, 8.5, 0.35, 6.8), + +# "phi": (1013.5, 4.25, 0.58, 19.2), + +# "jpsi": (3096.1, 0.09, 1.47, 9897.0), +# "jpsi_auc": 0.2126825758464027, +# "jpsi_phase_unc": 0.05, + +# "psi2s": (3686.0, 0.3, -2.21, 1396.0), +# "psi2s_auc": 0.0151332263, +# "psi2s_phase_unc": 0.1, + +# "p3770": (3773.0, 27.2, -2.140, 2.5), + +# "p4040": (4039.0, 80.0, -2.64, 1.01), + +# "p4160": (4191.0, 70.0, -2.11, 2.2), + +# "p4415": (4421.0, 62.0, -2.42, 1.24), + + # Phase combination of paper -+ + + "rho": (743.2, 149.0, -0.30, 1.05), + + "omega": (782.7, 8.5, 0.30, 6.8), + + "phi": (1013.5, 4.25, 0.51, 19.2), + + "jpsi": (3096.1, 0.09, -1.5, 9897.0), + "jpsi_auc": 0.2126825758464027, + "jpsi_phase_unc": 0.05, + + "psi2s": (3686.0, 0.3, 2.08, 1396.0), + "psi2s_auc": 0.0151332263, + "psi2s_phase_unc": 0.1, + + "p3770": (3773.0, 27.2, -2.89, 2.5), + + "p4040": (4039.0, 80.0, -2.69, 1.01), + + "p4160": (4191.0, 70.0, -2.13, 2.2), + + "p4415": (4421.0, 62.0, -2.43, 1.24), + + + # zeroing resonances + +# "rho": (775.26, 149.0, -0.35, 0.0), +# "omega": (782.7, 8.5, 0.26, 0.0), +# "phi": (1019.46, 4.25, 0.5, 0.0), +# "jpsi": (3096.0, 0.09, -1.5, 0.0), +# "psi2s": (3686.0, 0.3, -1.5, 0.0), +# "p3770": (3773.0, 27.2, -2.13, 0.0), +# "p4040": (4039.0, 80.0, -2.52, 0.0), +# "p4160": (4147.0, 22.0, -1.9, 0.0), +# "p4415": (4421.0, 62.0, -2.52, 0.0), + + # 2P contributions format(mass, amp, phase) + +# "D_bar": ( + + #general + + "rho_BR": 1.7e-10, + "omega_BR": 4.9e-10, + "phi_BR": 2.5e-9, + "jpsi_BR": 6.02e-5, + "psi2s_BR": 4.97e-6, + "p3770_BR": 1.38e-9, + "p4040_BR": 4.2e-10, + "p4160_BR": 2.6e-9, + "p4415_BR": 6.1e-10, + +# Estimates + "Dbar_scale": 1.46, #with phase = pi + + "DDstar_scale": 2.41, #with phase = pi + + } diff --git a/data/CLs/finished/f1d1/-+/D-True/2288035/raremodel-nb.py b/data/CLs/finished/f1d1/-+/D-True/2288035/raremodel-nb.py new file mode 100644 index 0000000..c326c9c --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288035/raremodel-nb.py @@ -0,0 +1,2152 @@ +#!/usr/bin/env python +# coding: utf-8 + +# # Import + +# In[ ]: + + +import os + +# os.environ["CUDA_VISIBLE_DEVICES"] = "-1" +import random +import numpy as np +from pdg_const1 import pdg +import matplotlib +import matplotlib.pyplot as plt +import pickle as pkl +import sys +import time +from helperfunctions import display_time, prepare_plot +import cmath as c +import scipy.integrate as integrate +from scipy.optimize import fminbound +from array import array as arr +import collections +from itertools import compress +import tensorflow as tf +import zfit +from zfit import ztf +# from IPython.display import clear_output +import os +import tensorflow_probability as tfp +tfd = tfp.distributions + + +# In[ ]: + + +# chunksize = 10000 +# zfit.run.chunking.active = True +# zfit.run.chunking.max_n_points = chunksize + + +# # Build model and graphs +# ## Create graphs + +# In[ ]: + + + + + +# In[ ]: + + +def formfactor(q2, subscript, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2): #returns real value + #check if subscript is viable + + if subscript != "0" and subscript != "+" and subscript != "T": + raise ValueError('Wrong subscript entered, choose either 0, + or T') + + #get constants + + mK = ztf.constant(pdg['Ks_M']) + mbstar0 = ztf.constant(pdg["mbstar0"]) + mbstar = ztf.constant(pdg["mbstar"]) + + + mmu = ztf.constant(pdg['muon_M']) + mb = ztf.constant(pdg['bquark_M']) + ms = ztf.constant(pdg['squark_M']) + mB = ztf.constant(pdg['Bplus_M']) + + #N comes from derivation in paper + + N = 3 + + #some helperfunctions + + tpos = (mB - mK)**2 + tzero = (mB + mK)*(ztf.sqrt(mB)-ztf.sqrt(mK))**2 + + z_oben = ztf.sqrt(tpos - q2) - ztf.sqrt(tpos - tzero) + z_unten = ztf.sqrt(tpos - q2) + ztf.sqrt(tpos - tzero) + z = tf.divide(z_oben, z_unten) + + #calculate f0 + + if subscript == "0": + prefactor = 1/(1 - q2/(mbstar0**2)) + _sum = 0 + b0 = [b0_0, b0_1, b0_2] + + for i in range(N): + _sum += b0[i]*(tf.pow(z,i)) + + return ztf.to_complex(prefactor * _sum) + + #calculate f+ or fT + + else: + prefactor = 1/(1 - q2/(mbstar**2)) + _sum = 0 + + if subscript == "T": + bT = [bT_0, bT_1, bT_2] + for i in range(N): + _sum += bT[i] * (tf.pow(z, i) - ((-1)**(i-N)) * (i/N) * tf.pow(z, N)) + else: + bplus = [bplus_0, bplus_1, bplus_2] + for i in range(N): + _sum += bplus[i] * (tf.pow(z, i) - ((-1)**(i-N)) * (i/N) * tf.pow(z, N)) + + return ztf.to_complex(prefactor * _sum) + +def resonance(q, _mass, width, phase, scale): + + q2 = tf.pow(q, 2) + + mmu = ztf.constant(pdg['muon_M']) + + p = 0.5 * ztf.sqrt(q2 - 4*(mmu**2)) + + p0 = 0.5 * ztf.sqrt(_mass**2 - 4*mmu**2) + + gamma_j = tf.divide(p, q) * _mass * width / p0 + + #Calculate the resonance + + _top = tf.complex(_mass * width, ztf.constant(0.0)) + + _bottom = tf.complex(_mass**2 - q2, -_mass*gamma_j) + + com = _top/_bottom + + #Rotate by the phase + + r = ztf.to_complex(scale*tf.abs(com)) + + _phase = tf.angle(com) + + _phase += phase + + com = r * tf.exp(tf.complex(ztf.constant(0.0), _phase)) + + return com + + +def axiv_nonres(q, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2): + + GF = ztf.constant(pdg['GF']) + alpha_ew = ztf.constant(pdg['alpha_ew']) + Vtb = ztf.constant(pdg['Vtb']) + Vts = ztf.constant(pdg['Vts']) + C10eff = ztf.constant(pdg['C10eff']) + + mmu = ztf.constant(pdg['muon_M']) + mb = ztf.constant(pdg['bquark_M']) + ms = ztf.constant(pdg['squark_M']) + mK = ztf.constant(pdg['Ks_M']) + mB = ztf.constant(pdg['Bplus_M']) + + q2 = tf.pow(q, 2) + + #Some helperfunctions + + beta = 1. - 4. * mmu**2. / q2 + + kabs = ztf.sqrt(mB**2. + tf.pow(q2, 2)/mB**2. + mK**4./mB**2. - 2. * (mB**2. * mK**2. + mK**2. * q2 + mB**2. * q2) / mB**2.) + + #prefactor in front of whole bracket + + prefactor1 = GF**2. *alpha_ew**2. * (tf.abs(Vtb*Vts))**2. * kabs * beta / (128. * np.pi**5.) + + #left term in bracket + + bracket_left = 2./3. * tf.pow(kabs,2) * tf.pow(beta,2) * tf.pow(tf.abs(ztf.to_complex(C10eff)*formfactor(q2, "+", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2)),2) + + #middle term in bracket + + _top = 4. * mmu**2. * (mB**2. - mK**2.) * (mB**2. - mK**2.) + + _under = q2 * mB**2. + + bracket_middle = _top/_under *tf.pow(tf.abs(ztf.to_complex(C10eff) * formfactor(q2, "0", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2)), 2) + + #Note sqrt(q2) comes from derivation as we use q2 and plot q + + return prefactor1 * (bracket_left + bracket_middle) * 2 * q + +def vec(q, funcs, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2): + + q2 = tf.pow(q, 2) + + GF = ztf.constant(pdg['GF']) + alpha_ew = ztf.constant(pdg['alpha_ew']) + Vtb = ztf.constant(pdg['Vtb']) + Vts = ztf.constant(pdg['Vts']) + C7eff = ztf.constant(pdg['C7eff']) + + mmu = ztf.constant(pdg['muon_M']) + mb = ztf.constant(pdg['bquark_M']) + ms = ztf.constant(pdg['squark_M']) + mK = ztf.constant(pdg['Ks_M']) + mB = ztf.constant(pdg['Bplus_M']) + + #Some helperfunctions + + beta = 1. - 4. * mmu**2. / q2 + + kabs = ztf.sqrt(mB**2. + tf.pow(q2, 2)/mB**2. + mK**4./mB**2. - 2 * (mB**2 * mK**2 + mK**2 * q2 + mB**2 * q2) / mB**2) + + #prefactor in front of whole bracket + + prefactor1 = GF**2. *alpha_ew**2. * (tf.abs(Vtb*Vts))**2 * kabs * beta / (128. * np.pi**5.) + + #right term in bracket + + prefactor2 = tf.pow(kabs,2) * (1. - 1./3. * beta) + + abs_bracket = tf.pow(tf.abs(c9eff(q, funcs) * formfactor(q2, "+", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + ztf.to_complex(2.0 * C7eff * (mb + ms)/(mB + mK)) * formfactor(q2, "T", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2)),2) + + bracket_right = prefactor2 * abs_bracket + + #Note sqrt(q2) comes from derivation as we use q2 and plot q + + return prefactor1 * bracket_right * 2 * q + +def c9eff(q, funcs): + + C9eff_nr = ztf.to_complex(ztf.constant(pdg['C9eff'])) + + c9 = C9eff_nr + funcs + + return c9 + + +# In[ ]: + + +def G(y): + + def inner_rect_bracket(q): + return tf.log(ztf.to_complex((1+tf.sqrt(q))/(1-tf.sqrt(q)))-tf.complex(ztf.constant(0), -1*ztf.constant(np.pi))) + + def inner_right(q): + return ztf.to_complex(2 * tf.atan(1/tf.sqrt(tf.math.real(-q)))) + + big_bracket = tf.where(tf.math.real(y) > ztf.constant(0.0), inner_rect_bracket(y), inner_right(y)) + + return ztf.to_complex(tf.sqrt(tf.abs(y))) * big_bracket + +def h_S(m, q): + + return ztf.to_complex(2) - G(ztf.to_complex(1) - ztf.to_complex(4*tf.pow(m, 2)) / ztf.to_complex(tf.pow(q, 2))) + +def h_P(m, q): + + return ztf.to_complex(2/3) + (ztf.to_complex(1) - ztf.to_complex(4*tf.pow(m, 2)) / ztf.to_complex(tf.pow(q, 2))) * h_S(m,q) + +def two_p_ccbar(mD, m_D_bar, m_D_star, q): + + + #Load constants + nu_D_bar = ztf.to_complex(pdg["nu_D_bar"]) + nu_D = ztf.to_complex(pdg["nu_D"]) + nu_D_star = ztf.to_complex(pdg["nu_D_star"]) + + phase_D_bar = ztf.to_complex(pdg["phase_D_bar"]) + phase_D = ztf.to_complex(pdg["phase_D"]) + phase_D_star = ztf.to_complex(pdg["phase_D_star"]) + + #Calculation + left_part = nu_D_bar * tf.exp(tf.complex(ztf.constant(0.0), phase_D_bar)) * h_S(m_D_bar, q) + + right_part_D = nu_D * tf.exp(tf.complex(ztf.constant(0.0), phase_D)) * h_P(m_D, q) + + right_part_D_star = nu_D_star * tf.exp(tf.complex(ztf.constant(0.0), phase_D_star)) * h_P(m_D_star, q) + + return left_part + right_part_D + right_part_D_star + + +# ## Build pdf + +# In[ ]: + + +class total_pdf_cut(zfit.pdf.ZPDF): + _N_OBS = 1 # dimension, can be omitted + _PARAMS = ['b0_0', 'b0_1', 'b0_2', + 'bplus_0', 'bplus_1', 'bplus_2', + 'bT_0', 'bT_1', 'bT_2', + 'rho_mass', 'rho_scale', 'rho_phase', 'rho_width', + 'jpsi_mass', 'jpsi_scale', 'jpsi_phase', 'jpsi_width', + 'psi2s_mass', 'psi2s_scale', 'psi2s_phase', 'psi2s_width', + 'p3770_mass', 'p3770_scale', 'p3770_phase', 'p3770_width', + 'p4040_mass', 'p4040_scale', 'p4040_phase', 'p4040_width', + 'p4160_mass', 'p4160_scale', 'p4160_phase', 'p4160_width', + 'p4415_mass', 'p4415_scale', 'p4415_phase', 'p4415_width', + 'omega_mass', 'omega_scale', 'omega_phase', 'omega_width', + 'phi_mass', 'phi_scale', 'phi_phase', 'phi_width', + 'Dbar_mass', 'Dbar_scale', 'Dbar_phase', + 'Dstar_mass', 'DDstar_scale', 'DDstar_phase', 'D_mass', + 'tau_mass', 'C_tt'] +# the name of the parameters + + def _unnormalized_pdf(self, x): + + x = x.unstack_x() + + b0 = [self.params['b0_0'], self.params['b0_1'], self.params['b0_2']] + bplus = [self.params['bplus_0'], self.params['bplus_1'], self.params['bplus_2']] + bT = [self.params['bT_0'], self.params['bT_1'], self.params['bT_2']] + + def rho_res(q): + return resonance(q, _mass = self.params['rho_mass'], scale = self.params['rho_scale'], + phase = self.params['rho_phase'], width = self.params['rho_width']) + + def omega_res(q): + return resonance(q, _mass = self.params['omega_mass'], scale = self.params['omega_scale'], + phase = self.params['omega_phase'], width = self.params['omega_width']) + + def phi_res(q): + return resonance(q, _mass = self.params['phi_mass'], scale = self.params['phi_scale'], + phase = self.params['phi_phase'], width = self.params['phi_width']) + + def jpsi_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['jpsi_mass'], 2)) * resonance(q, _mass = self.params['jpsi_mass'], + scale = self.params['jpsi_scale'], + phase = self.params['jpsi_phase'], + width = self.params['jpsi_width']) + def psi2s_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['psi2s_mass'], 2)) * resonance(q, _mass = self.params['psi2s_mass'], + scale = self.params['psi2s_scale'], + phase = self.params['psi2s_phase'], + width = self.params['psi2s_width']) + def p3770_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p3770_mass'], 2)) * resonance(q, _mass = self.params['p3770_mass'], + scale = self.params['p3770_scale'], + phase = self.params['p3770_phase'], + width = self.params['p3770_width']) + + def p4040_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4040_mass'], 2)) * resonance(q, _mass = self.params['p4040_mass'], + scale = self.params['p4040_scale'], + phase = self.params['p4040_phase'], + width = self.params['p4040_width']) + + def p4160_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4160_mass'], 2)) * resonance(q, _mass = self.params['p4160_mass'], + scale = self.params['p4160_scale'], + phase = self.params['p4160_phase'], + width = self.params['p4160_width']) + + def p4415_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4415_mass'], 2)) * resonance(q, _mass = self.params['p4415_mass'], + scale = self.params['p4415_scale'], + phase = self.params['p4415_phase'], + width = self.params['p4415_width']) + + def P2_D(q): + Dbar_contrib = ztf.to_complex(self.params['Dbar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['Dbar_phase']))*ztf.to_complex(h_S(self.params['Dbar_mass'], q)) + DDstar_contrib = ztf.to_complex(self.params['DDstar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['DDstar_phase']))*(ztf.to_complex(h_P(self.params['Dstar_mass'], q)) + ztf.to_complex(h_P(self.params['D_mass'], q))) + return Dbar_contrib + DDstar_contrib + + def ttau_cusp(q): + return ztf.to_complex(self.params['C_tt'])*(ztf.to_complex((h_S(self.params['tau_mass'], q))) - ztf.to_complex(h_P(self.params['tau_mass'], q))) + + + funcs = rho_res(x) + omega_res(x) + phi_res(x) + jpsi_res(x) + psi2s_res(x) + p3770_res(x) + p4040_res(x)+ p4160_res(x) + p4415_res(x) + P2_D(x) + ttau_cusp(x) + + vec_f = vec(x, funcs, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + axiv_nr = axiv_nonres(x, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + tot = vec_f + axiv_nr + + #Cut out jpsi and psi2s + + tot = tf.where(tf.math.logical_or(x < ztf.constant(jpsi_mass-60.), x > ztf.constant(jpsi_mass+70.)), tot, 0.0*tot) + + tot = tf.where(tf.math.logical_or(x < ztf.constant(psi2s_mass-50.), x > ztf.constant(psi2s_mass+50.)), tot, 0.0*tot) + + return tot + +class total_pdf_full(zfit.pdf.ZPDF): + _N_OBS = 1 # dimension, can be omitted + _PARAMS = ['b0_0', 'b0_1', 'b0_2', + 'bplus_0', 'bplus_1', 'bplus_2', + 'bT_0', 'bT_1', 'bT_2', + 'rho_mass', 'rho_scale', 'rho_phase', 'rho_width', + 'jpsi_mass', 'jpsi_scale', 'jpsi_phase', 'jpsi_width', + 'psi2s_mass', 'psi2s_scale', 'psi2s_phase', 'psi2s_width', + 'p3770_mass', 'p3770_scale', 'p3770_phase', 'p3770_width', + 'p4040_mass', 'p4040_scale', 'p4040_phase', 'p4040_width', + 'p4160_mass', 'p4160_scale', 'p4160_phase', 'p4160_width', + 'p4415_mass', 'p4415_scale', 'p4415_phase', 'p4415_width', + 'omega_mass', 'omega_scale', 'omega_phase', 'omega_width', + 'phi_mass', 'phi_scale', 'phi_phase', 'phi_width', + 'Dbar_mass', 'Dbar_scale', 'Dbar_phase', + 'Dstar_mass', 'DDstar_scale', 'DDstar_phase', 'D_mass', + 'tau_mass', 'C_tt'] +# the name of the parameters + + def _unnormalized_pdf(self, x): + + x = x.unstack_x() + + b0 = [self.params['b0_0'], self.params['b0_1'], self.params['b0_2']] + bplus = [self.params['bplus_0'], self.params['bplus_1'], self.params['bplus_2']] + bT = [self.params['bT_0'], self.params['bT_1'], self.params['bT_2']] + + def rho_res(q): + return resonance(q, _mass = self.params['rho_mass'], scale = self.params['rho_scale'], + phase = self.params['rho_phase'], width = self.params['rho_width']) + + def omega_res(q): + return resonance(q, _mass = self.params['omega_mass'], scale = self.params['omega_scale'], + phase = self.params['omega_phase'], width = self.params['omega_width']) + + def phi_res(q): + return resonance(q, _mass = self.params['phi_mass'], scale = self.params['phi_scale'], + phase = self.params['phi_phase'], width = self.params['phi_width']) + + def jpsi_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['jpsi_mass'], 2)) * resonance(q, _mass = self.params['jpsi_mass'], + scale = self.params['jpsi_scale'], + phase = self.params['jpsi_phase'], + width = self.params['jpsi_width']) + def psi2s_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['psi2s_mass'], 2)) * resonance(q, _mass = self.params['psi2s_mass'], + scale = self.params['psi2s_scale'], + phase = self.params['psi2s_phase'], + width = self.params['psi2s_width']) + def p3770_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p3770_mass'], 2)) * resonance(q, _mass = self.params['p3770_mass'], + scale = self.params['p3770_scale'], + phase = self.params['p3770_phase'], + width = self.params['p3770_width']) + + def p4040_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4040_mass'], 2)) * resonance(q, _mass = self.params['p4040_mass'], + scale = self.params['p4040_scale'], + phase = self.params['p4040_phase'], + width = self.params['p4040_width']) + + def p4160_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4160_mass'], 2)) * resonance(q, _mass = self.params['p4160_mass'], + scale = self.params['p4160_scale'], + phase = self.params['p4160_phase'], + width = self.params['p4160_width']) + + def p4415_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4415_mass'], 2)) * resonance(q, _mass = self.params['p4415_mass'], + scale = self.params['p4415_scale'], + phase = self.params['p4415_phase'], + width = self.params['p4415_width']) + + def P2_D(q): + Dbar_contrib = ztf.to_complex(self.params['Dbar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['Dbar_phase']))*ztf.to_complex(h_S(self.params['Dbar_mass'], q)) + DDstar_contrib = ztf.to_complex(self.params['DDstar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['DDstar_phase']))*(ztf.to_complex(h_P(self.params['Dstar_mass'], q)) + ztf.to_complex(h_P(self.params['D_mass'], q))) + return Dbar_contrib + DDstar_contrib + + def ttau_cusp(q): + return ztf.to_complex(self.params['C_tt'])*(ztf.to_complex((h_S(self.params['tau_mass'], q))) - ztf.to_complex(h_P(self.params['tau_mass'], q))) + + + funcs = rho_res(x) + omega_res(x) + phi_res(x) + jpsi_res(x) + psi2s_res(x) + p3770_res(x) + p4040_res(x)+ p4160_res(x) + p4415_res(x) + P2_D(x) + ttau_cusp(x) + + vec_f = vec(x, funcs, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + axiv_nr = axiv_nonres(x, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + tot = vec_f + axiv_nr + + #Cut out jpsi and psi2s + +# tot = tf.where(tf.math.logical_or(x < ztf.constant(jpsi_mass-60.), x > ztf.constant(jpsi_mass+70.)), tot, 0.0*tot) + +# tot = tf.where(tf.math.logical_or(x < ztf.constant(psi2s_mass-50.), x > ztf.constant(psi2s_mass+50.)), tot, 0.0*tot) + + return tot + + +# ## Setup parameters + +# In[ ]: + + +# formfactors + +b0_0 = zfit.Parameter("b0_0", ztf.constant(0.292), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +b0_1 = zfit.Parameter("b0_1", ztf.constant(0.281), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +b0_2 = zfit.Parameter("b0_2", ztf.constant(0.150), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) + +bplus_0 = zfit.Parameter("bplus_0", ztf.constant(0.466), lower_limit = -2.0, upper_limit= 2.0) +bplus_1 = zfit.Parameter("bplus_1", ztf.constant(-0.885), lower_limit = -2.0, upper_limit= 2.0) +bplus_2 = zfit.Parameter("bplus_2", ztf.constant(-0.213), lower_limit = -2.0, upper_limit= 2.0) + +bT_0 = zfit.Parameter("bT_0", ztf.constant(0.460), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +bT_1 = zfit.Parameter("bT_1", ztf.constant(-1.089), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +bT_2 = zfit.Parameter("bT_2", ztf.constant(-1.114), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) + + +#rho + +rho_mass, rho_width, rho_phase, rho_scale = pdg["rho"] + +rho_m = zfit.Parameter("rho_m", ztf.constant(rho_mass), floating = False) #lower_limit = rho_mass - rho_width, upper_limit = rho_mass + rho_width) +rho_w = zfit.Parameter("rho_w", ztf.constant(rho_width), floating = False) +rho_p = zfit.Parameter("rho_p", ztf.constant(rho_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +rho_s = zfit.Parameter("rho_s", ztf.constant(rho_scale), lower_limit=rho_scale-np.sqrt(rho_scale), upper_limit=rho_scale+np.sqrt(rho_scale)) + +#omega + +omega_mass, omega_width, omega_phase, omega_scale = pdg["omega"] + +omega_m = zfit.Parameter("omega_m", ztf.constant(omega_mass), floating = False) +omega_w = zfit.Parameter("omega_w", ztf.constant(omega_width), floating = False) +omega_p = zfit.Parameter("omega_p", ztf.constant(omega_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +omega_s = zfit.Parameter("omega_s", ztf.constant(omega_scale), lower_limit=omega_scale-np.sqrt(omega_scale), upper_limit=omega_scale+np.sqrt(omega_scale)) + + +#phi + +phi_mass, phi_width, phi_phase, phi_scale = pdg["phi"] + +phi_m = zfit.Parameter("phi_m", ztf.constant(phi_mass), floating = False) +phi_w = zfit.Parameter("phi_w", ztf.constant(phi_width), floating = False) +phi_p = zfit.Parameter("phi_p", ztf.constant(phi_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +phi_s = zfit.Parameter("phi_s", ztf.constant(phi_scale), lower_limit=phi_scale-np.sqrt(phi_scale), upper_limit=phi_scale+np.sqrt(phi_scale)) + +#jpsi + +jpsi_mass, jpsi_width, jpsi_phase, jpsi_scale = pdg["jpsi"] + +jpsi_m = zfit.Parameter("jpsi_m", ztf.constant(jpsi_mass), floating = False) +jpsi_w = zfit.Parameter("jpsi_w", ztf.constant(jpsi_width), floating = False) +jpsi_p = zfit.Parameter("jpsi_p", ztf.constant(jpsi_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +jpsi_s = zfit.Parameter("jpsi_s", ztf.constant(jpsi_scale), floating = False) #, lower_limit=jpsi_scale-np.sqrt(jpsi_scale), upper_limit=jpsi_scale+np.sqrt(jpsi_scale)) + +#psi2s + +psi2s_mass, psi2s_width, psi2s_phase, psi2s_scale = pdg["psi2s"] + +psi2s_m = zfit.Parameter("psi2s_m", ztf.constant(psi2s_mass), floating = False) +psi2s_w = zfit.Parameter("psi2s_w", ztf.constant(psi2s_width), floating = False) +psi2s_p = zfit.Parameter("psi2s_p", ztf.constant(psi2s_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +psi2s_s = zfit.Parameter("psi2s_s", ztf.constant(psi2s_scale), floating = False) #, lower_limit=psi2s_scale-np.sqrt(psi2s_scale), upper_limit=psi2s_scale+np.sqrt(psi2s_scale)) + +#psi(3770) + +p3770_mass, p3770_width, p3770_phase, p3770_scale = pdg["p3770"] + +p3770_m = zfit.Parameter("p3770_m", ztf.constant(p3770_mass), floating = False) +p3770_w = zfit.Parameter("p3770_w", ztf.constant(p3770_width), floating = False) +p3770_p = zfit.Parameter("p3770_p", ztf.constant(p3770_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p3770_s = zfit.Parameter("p3770_s", ztf.constant(p3770_scale), lower_limit=p3770_scale-np.sqrt(p3770_scale), upper_limit=p3770_scale+np.sqrt(p3770_scale)) + +#psi(4040) + +p4040_mass, p4040_width, p4040_phase, p4040_scale = pdg["p4040"] + +p4040_m = zfit.Parameter("p4040_m", ztf.constant(p4040_mass), floating = False) +p4040_w = zfit.Parameter("p4040_w", ztf.constant(p4040_width), floating = False) +p4040_p = zfit.Parameter("p4040_p", ztf.constant(p4040_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p4040_s = zfit.Parameter("p4040_s", ztf.constant(p4040_scale), lower_limit=p4040_scale-np.sqrt(p4040_scale), upper_limit=p4040_scale+np.sqrt(p4040_scale)) + +#psi(4160) + +p4160_mass, p4160_width, p4160_phase, p4160_scale = pdg["p4160"] + +p4160_m = zfit.Parameter("p4160_m", ztf.constant(p4160_mass), floating = False) +p4160_w = zfit.Parameter("p4160_w", ztf.constant(p4160_width), floating = False) +p4160_p = zfit.Parameter("p4160_p", ztf.constant(p4160_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p4160_s = zfit.Parameter("p4160_s", ztf.constant(p4160_scale), lower_limit=p4160_scale-np.sqrt(p4160_scale), upper_limit=p4160_scale+np.sqrt(p4160_scale)) + +#psi(4415) + +p4415_mass, p4415_width, p4415_phase, p4415_scale = pdg["p4415"] + +p4415_m = zfit.Parameter("p4415_m", ztf.constant(p4415_mass), floating = False) +p4415_w = zfit.Parameter("p4415_w", ztf.constant(p4415_width), floating = False) +p4415_p = zfit.Parameter("p4415_p", ztf.constant(p4415_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p4415_s = zfit.Parameter("p4415_s", ztf.constant(p4415_scale), lower_limit=p4415_scale-np.sqrt(p4415_scale), upper_limit=p4415_scale+np.sqrt(p4415_scale)) + + +# ## Dynamic generation of 2 particle contribution + +# In[ ]: + + +m_c = 1300 + +Dbar_phase = 0.0 +DDstar_phase = 0.0 +Dstar_mass = pdg['Dst_M'] +Dbar_mass = pdg['D0_M'] +D_mass = pdg['D0_M'] + +Dbar_s = zfit.Parameter("Dbar_s", ztf.constant(0.0), lower_limit=-0.3, upper_limit=0.3) +Dbar_m = zfit.Parameter("Dbar_m", ztf.constant(Dbar_mass), floating = False) +Dbar_p = zfit.Parameter("Dbar_p", ztf.constant(Dbar_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi)#, floating = False) +DDstar_s = zfit.Parameter("DDstar_s", ztf.constant(0.0), lower_limit=-0.3, upper_limit=0.3)#, floating = False) +Dstar_m = zfit.Parameter("Dstar_m", ztf.constant(Dstar_mass), floating = False) +D_m = zfit.Parameter("D_m", ztf.constant(D_mass), floating = False) +DDstar_p = zfit.Parameter("DDstar_p", ztf.constant(DDstar_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi)#, floating = False) + + +# ## Tau parameters + +# In[ ]: + + +tau_m = zfit.Parameter("tau_m", ztf.constant(pdg['tau_M']), floating = False) +Ctt = zfit.Parameter("Ctt", ztf.constant(0.0), lower_limit=-2.5, upper_limit=2.5) + + +# ## Load data + +# In[ ]: + + +x_min = 2*pdg['muon_M'] +x_max = (pdg["Bplus_M"]-pdg["Ks_M"]-0.1) + +# # Full spectrum + +obs_toy = zfit.Space('q', limits = (x_min, x_max)) + +# Jpsi and Psi2s cut out + +obs1 = zfit.Space('q', limits = (x_min, jpsi_mass - 60.)) +obs2 = zfit.Space('q', limits = (jpsi_mass + 70., psi2s_mass - 50.)) +obs3 = zfit.Space('q', limits = (psi2s_mass + 50., x_max)) + +obs_fit = obs1 + obs2 + obs3 + +# with open(r"./data/slim_points/slim_points_toy_0_range({0}-{1}).pkl".format(int(x_min), int(x_max)), "rb") as input_file: +# part_set = pkl.load(input_file) + +# x_part = part_set['x_part'] + +# x_part = x_part.astype('float64') + +# data = zfit.data.Data.from_numpy(array=x_part, obs=obs) + + +# ## Setup pdf + +# In[ ]: + + +total_f = total_pdf_cut(obs=obs_toy, jpsi_mass = jpsi_m, jpsi_scale = jpsi_s, jpsi_phase = jpsi_p, jpsi_width = jpsi_w, + psi2s_mass = psi2s_m, psi2s_scale = psi2s_s, psi2s_phase = psi2s_p, psi2s_width = psi2s_w, + p3770_mass = p3770_m, p3770_scale = p3770_s, p3770_phase = p3770_p, p3770_width = p3770_w, + p4040_mass = p4040_m, p4040_scale = p4040_s, p4040_phase = p4040_p, p4040_width = p4040_w, + p4160_mass = p4160_m, p4160_scale = p4160_s, p4160_phase = p4160_p, p4160_width = p4160_w, + p4415_mass = p4415_m, p4415_scale = p4415_s, p4415_phase = p4415_p, p4415_width = p4415_w, + rho_mass = rho_m, rho_scale = rho_s, rho_phase = rho_p, rho_width = rho_w, + omega_mass = omega_m, omega_scale = omega_s, omega_phase = omega_p, omega_width = omega_w, + phi_mass = phi_m, phi_scale = phi_s, phi_phase = phi_p, phi_width = phi_w, + Dstar_mass = Dstar_m, DDstar_scale = DDstar_s, DDstar_phase = DDstar_p, D_mass = D_m, + Dbar_mass = Dbar_m, Dbar_scale = Dbar_s, Dbar_phase = Dbar_p, + tau_mass = tau_m, C_tt = Ctt, b0_0 = b0_0, b0_1 = b0_1, b0_2 = b0_2, + bplus_0 = bplus_0, bplus_1 = bplus_1, bplus_2 = bplus_2, + bT_0 = bT_0, bT_1 = bT_1, bT_2 = bT_2) + +total_f_fit = total_pdf_full(obs=obs_fit, jpsi_mass = jpsi_m, jpsi_scale = jpsi_s, jpsi_phase = jpsi_p, jpsi_width = jpsi_w, + psi2s_mass = psi2s_m, psi2s_scale = psi2s_s, psi2s_phase = psi2s_p, psi2s_width = psi2s_w, + p3770_mass = p3770_m, p3770_scale = p3770_s, p3770_phase = p3770_p, p3770_width = p3770_w, + p4040_mass = p4040_m, p4040_scale = p4040_s, p4040_phase = p4040_p, p4040_width = p4040_w, + p4160_mass = p4160_m, p4160_scale = p4160_s, p4160_phase = p4160_p, p4160_width = p4160_w, + p4415_mass = p4415_m, p4415_scale = p4415_s, p4415_phase = p4415_p, p4415_width = p4415_w, + rho_mass = rho_m, rho_scale = rho_s, rho_phase = rho_p, rho_width = rho_w, + omega_mass = omega_m, omega_scale = omega_s, omega_phase = omega_p, omega_width = omega_w, + phi_mass = phi_m, phi_scale = phi_s, phi_phase = phi_p, phi_width = phi_w, + Dstar_mass = Dstar_m, DDstar_scale = DDstar_s, DDstar_phase = DDstar_p, D_mass = D_m, + Dbar_mass = Dbar_m, Dbar_scale = Dbar_s, Dbar_phase = Dbar_p, + tau_mass = tau_m, C_tt = Ctt, b0_0 = b0_0, b0_1 = b0_1, b0_2 = b0_2, + bplus_0 = bplus_0, bplus_1 = bplus_1, bplus_2 = bplus_2, + bT_0 = bT_0, bT_1 = bT_1, bT_2 = bT_2) + +# print(total_pdf.obs) + +# print(calcs_test) + +# for param in total_f.get_dependents(): +# print(zfit.run(param)) + + +# In[ ]: + + +# total_f_fit.normalization(obs_fit) + + +# ## Test if graphs actually work and compute values + +# In[ ]: + + +# def total_test_tf(xq): + +# def jpsi_res(q): +# return resonance(q, jpsi_m, jpsi_s, jpsi_p, jpsi_w) + +# def psi2s_res(q): +# return resonance(q, psi2s_m, psi2s_s, psi2s_p, psi2s_w) + +# def cusp(q): +# return bifur_gauss(q, cusp_m, sig_L, sig_R, cusp_s) + +# funcs = jpsi_res(xq) + psi2s_res(xq) + cusp(xq) + +# vec_f = vec(xq, funcs) + +# axiv_nr = axiv_nonres(xq) + +# tot = vec_f + axiv_nr + +# return tot + +# def jpsi_res(q): +# return resonance(q, jpsi_m, jpsi_s, jpsi_p, jpsi_w) + +# calcs = zfit.run(total_test_tf(x_part)) + + + +test_q = np.linspace(x_min, x_max, int(2e6)) + +probs = total_f_fit.pdf(test_q, norm_range=False) + +calcs_test = zfit.run(probs) + +Ctt.set_value(0.5) + +calcs_test1 = zfit.run(probs) + +Ctt.set_value(0.0) + +Dbar_s.set_value(0.3) + +DDstar_s.set_value(0.3) + +calcs_test2 = zfit.run(probs) +# res_y = zfit.run(jpsi_res(test_q)) +# b0 = [b0_0, b0_1, b0_2] +# bplus = [bplus_0, bplus_1, bplus_2] +# bT = [bT_0, bT_1, bT_2] +# f0_y = zfit.run(tf.math.real(formfactor(test_q,"0", b0, bplus, bT))) +# fplus_y = zfit.run(tf.math.real(formfactor(test_q,"+", b0, bplus, bT))) +# fT_y = zfit.run(tf.math.real(formfactor(test_q,"T", b0, bplus, bT))) + + +# In[ ]: + + +plt.clf() +# plt.plot(x_part, calcs, '.') +plt.plot(test_q, calcs_test, label = 'pdf (Ctt = 0.0)') +plt.plot(test_q, calcs_test1, label = 'pdf (Ctt = 0.5)') +plt.plot(test_q, calcs_test2, label = 'pdf (D-contribs = 0.3)') +# plt.plot(test_q, f0_y, label = '0') +# plt.plot(test_q, fT_y, label = 'T') +# plt.plot(test_q, fplus_y, label = '+') +# plt.plot(test_q, res_y, label = 'res') +plt.legend() +plt.ylim(0.0, 1.5e-6) +# plt.yscale('log') +# plt.xlim(770, 785) +plt.savefig('test.png') +# print(jpsi_width) + + +# In[ ]: + + + + +# probs = mixture.prob(test_q) +# probs_np = zfit.run(probs) +# probs_np *= np.max(calcs_test) / np.max(probs_np) +# plt.figure() +# plt.semilogy(test_q, probs_np,label="importance sampling") +# plt.semilogy(test_q, calcs_test, label = 'pdf') + + +# In[ ]: + + +# 0.213/(0.00133+0.213+0.015) + + +# ## Adjust scaling of different parts + +# In[ ]: + + +total_f.update_integration_options(draws_per_dim=2000000, mc_sampler=None) +# inte = total_f.integrate(limits = (950., 1050.), norm_range=False) +# inte_fl = zfit.run(inte) +# print(inte_fl/4500) +# print(pdg["jpsi_BR"]/pdg["NR_BR"], inte_fl*pdg["psi2s_auc"]/pdg["NR_auc"]) + + +# In[ ]: + + +# # print("jpsi:", inte_fl) +# # print("Increase am by factor:", np.sqrt(pdg["jpsi_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) +# # print("New amp:", pdg["jpsi"][3]*np.sqrt(pdg["jpsi_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) + +# # print("psi2s:", inte_fl) +# # print("Increase am by factor:", np.sqrt(pdg["psi2s_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) +# # print("New amp:", pdg["psi2s"][3]*np.sqrt(pdg["psi2s_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) + +# name = "phi" + +# print(name+":", inte_fl) +# print("Increase am by factor:", np.sqrt(pdg[name+"_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) +# print("New amp:", pdg[name][0]*np.sqrt(pdg[name+"_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) + + +# print(x_min) +# print(x_max) +# # total_f.update_integration_options(draws_per_dim=2000000, mc_sampler=None) +# total_f.update_integration_options(mc_sampler=lambda dim, num_results, +# dtype: tf.random_uniform(maxval=1., shape=(num_results, dim), dtype=dtype), +# draws_per_dim=1000000) +# # _ = [] + +# # for i in range(10): + +# # inte = total_f.integrate(limits = (x_min, x_max)) +# # inte_fl = zfit.run(inte) +# # print(inte_fl) +# # _.append(inte_fl) + +# # print("mean:", np.mean(_)) + +# _ = time.time() + +# inte = total_f.integrate(limits = (x_min, x_max)) +# inte_fl = zfit.run(inte) +# print(inte_fl) +# print("Time taken: {}".format(display_time(int(time.time() - _)))) + +# print(pdg['NR_BR']/pdg['NR_auc']*inte_fl) +# print(0.25**2*4.2/1000) + + +# # Sampling +# ## Mixture distribution for sampling + +# In[ ]: + + + + +# print(list_of_borders[:9]) +# print(list_of_borders[-9:]) + + +class UniformSampleAndWeights(zfit.util.execution.SessionHolderMixin): + def __call__(self, limits, dtype, n_to_produce): + # n_to_produce = tf.cast(n_to_produce, dtype=tf.int32) + low, high = limits.limit1d + low = tf.cast(low, dtype=dtype) + high = tf.cast(high, dtype=dtype) +# uniform = tfd.Uniform(low=low, high=high) +# uniformjpsi = tfd.Uniform(low=tf.constant(3080, dtype=dtype), high=tf.constant(3112, dtype=dtype)) +# uniformpsi2s = tfd.Uniform(low=tf.constant(3670, dtype=dtype), high=tf.constant(3702, dtype=dtype)) + +# list_of_borders = [] +# _p = [] +# splits = 10 + +# _ = np.linspace(x_min, x_max, splits) + +# for i in range(splits): +# list_of_borders.append(tf.constant(_[i], dtype=dtype)) +# _p.append(tf.constant(1/splits, dtype=dtype)) + +# mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=_p[:(splits-1)]), +# components_distribution=tfd.Uniform(low=list_of_borders[:(splits-1)], +# high=list_of_borders[-(splits-1):])) + mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=[tf.constant(0.05, dtype=dtype), + tf.constant(0.93, dtype=dtype), + tf.constant(0.05, dtype=dtype), + tf.constant(0.065, dtype=dtype), + tf.constant(0.04, dtype=dtype), + tf.constant(0.05, dtype=dtype)]), + components_distribution=tfd.Uniform(low=[tf.constant(x_min, dtype=dtype), + tf.constant(3090, dtype=dtype), + tf.constant(3681, dtype=dtype), + tf.constant(3070, dtype=dtype), + tf.constant(1000, dtype=dtype), + tf.constant(3660, dtype=dtype)], + high=[tf.constant(x_max, dtype=dtype), + tf.constant(3102, dtype=dtype), + tf.constant(3691, dtype=dtype), + tf.constant(3110, dtype=dtype), + tf.constant(1040, dtype=dtype), + tf.constant(3710, dtype=dtype)])) +# dtype = tf.float64 +# mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=[tf.constant(0.04, dtype=dtype), +# tf.constant(0.90, dtype=dtype), +# tf.constant(0.02, dtype=dtype), +# tf.constant(0.07, dtype=dtype), +# tf.constant(0.02, dtype=dtype)]), +# components_distribution=tfd.Uniform(low=[tf.constant(x_min, dtype=dtype), +# tf.constant(3089, dtype=dtype), +# tf.constant(3103, dtype=dtype), +# tf.constant(3681, dtype=dtype), +# tf.constant(3691, dtype=dtype)], +# high=[tf.constant(3089, dtype=dtype), +# tf.constant(3103, dtype=dtype), +# tf.constant(3681, dtype=dtype), +# tf.constant(3691, dtype=dtype), +# tf.constant(x_max, dtype=dtype)])) +# mixture = tfd.Uniform(tf.constant(x_min, dtype=dtype), tf.constant(x_max, dtype=dtype)) +# sample = tf.random.uniform((n_to_produce, 1), dtype=dtype) + sample = mixture.sample((n_to_produce, 1)) +# sample = tf.random.uniform((n_to_produce, 1), dtype=dtype) + weights = mixture.prob(sample)[:,0] +# weights = tf.broadcast_to(tf.constant(1., dtype=dtype), shape=(n_to_produce,)) + # sample = tf.expand_dims(sample, axis=-1) +# print(sample, weights) + +# weights = tf.ones(shape=(n_to_produce,), dtype=dtype) + weights_max = None + thresholds = tf.random_uniform(shape=(n_to_produce,), dtype=dtype) + return sample, thresholds, weights, weights_max, n_to_produce + + +# In[ ]: + + +# total_f._sample_and_weights = UniformSampleAndWeights + + +# In[ ]: + + +# 0.00133/(0.00133+0.213+0.015)*(x_max-3750)/(x_max-x_min) + + +# In[ ]: + + +# zfit.settings.set_verbosity(10) + + +# In[ ]: + + +# # zfit.run.numeric_checks = False + +# nr_of_toys = 1 +# nevents = int(pdg["number_of_decays"]) +# nevents = pdg["number_of_decays"] +# event_stack = 1000000 +# # zfit.settings.set_verbosity(10) +# calls = int(nevents/event_stack + 1) + +# total_samp = [] + +# start = time.time() + +# sampler = total_f.create_sampler(n=event_stack) + +# for toy in range(nr_of_toys): + +# dirName = 'data/zfit_toys/toy_{0}'.format(toy) + +# if not os.path.exists(dirName): +# os.mkdir(dirName) +# print("Directory " , dirName , " Created ") + +# for call in range(calls): + +# sampler.resample(n=event_stack) +# s = sampler.unstack_x() +# sam = zfit.run(s) +# # clear_output(wait=True) + +# c = call + 1 + +# print("{0}/{1} of Toy {2}/{3}".format(c, calls, toy+1, nr_of_toys)) +# print("Time taken: {}".format(display_time(int(time.time() - start)))) +# print("Projected time left: {}".format(display_time(int((time.time() - start)/(c+calls*(toy))*((nr_of_toys-toy)*calls-c))))) + +# with open("data/zfit_toys/toy_{0}/{1}.pkl".format(toy, call), "wb") as f: +# pkl.dump(sam, f, pkl.HIGHEST_PROTOCOL) + + +# In[ ]: + + +# with open(r"data/zfit_toys/toy_0/0.pkl", "rb") as input_file: +# sam = pkl.load(input_file) +# print(sam[:10]) + +# with open(r"data/zfit_toys/toy_0/1.pkl", "rb") as input_file: +# sam2 = pkl.load(input_file) +# print(sam2[:10]) + +# print(np.sum(sam-sam2)) + + +# In[ ]: + + +# print("Time to generate full toy: {} s".format(int(time.time()-start))) + +# total_samp = [] + +# for call in range(calls): +# with open(r"data/zfit_toys/toy_0/{}.pkl".format(call), "rb") as input_file: +# sam = pkl.load(input_file) +# total_samp = np.append(total_samp, sam) + +# total_samp = total_samp.astype('float64') + +# data2 = zfit.data.Data.from_numpy(array=total_samp[:int(nevents)], obs=obs) + +# data3 = zfit.data.Data.from_numpy(array=total_samp, obs=obs) + +# print(total_samp[:nevents].shape) + + +# In[ ]: + + +# plt.clf() + +# bins = int((x_max-x_min)/7) + +# # calcs = zfit.run(total_test_tf(samp)) +# print(total_samp[:nevents].shape) + +# plt.hist(total_samp[:nevents], bins = bins, range = (x_min,x_max), label = 'data') +# # plt.plot(test_q, calcs_test*nevents , label = 'pdf') + +# # plt.plot(sam, calcs, '.') +# # plt.plot(test_q, calcs_test) +# # plt.yscale('log') +# plt.ylim(0, 200) +# # plt.xlim(3080, 3110) + +# plt.legend() + +# plt.savefig('test2.png') + + +# In[ ]: + + +# sampler = total_f.create_sampler(n=nevents) +# nll = zfit.loss.UnbinnedNLL(model=total_f, data=sampler, fit_range = (x_min, x_max)) + +# # for param in pdf.get_dependents(): +# # param.set_value(initial_value) + +# sampler.resample(n=nevents) + +# # Randomise initial values +# # for param in pdf.get_dependents(): +# # param.set_value(random value here) + +# # Minimise the NLL +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 10) +# minimum = minimizer.minimize(nll) + + +# In[ ]: + + +# jpsi_width + + +# In[ ]: + + +# plt.hist(sample, weights=1 / prob(sample)) + + +# # Fitting + +# In[ ]: + + +# start = time.time() + +# for param in total_f.get_dependents(): +# param.randomize() + +# # for param in total_f.get_dependents(): +# # print(zfit.run(param)) + +# nll = zfit.loss.UnbinnedNLL(model=total_f, data=data2, fit_range = (x_min, x_max)) + +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) +# # minimizer._use_tfgrad = False +# result = minimizer.minimize(nll) + +# # param_errors = result.error() + +# # for var, errors in param_errors.items(): +# # print('{}: ^{{+{}}}_{{{}}}'.format(var.name, errors['upper'], errors['lower'])) + +# print("Function minimum:", result.fmin) +# # print("Results:", result.params) +# print("Hesse errors:", result.hesse()) + + +# In[ ]: + + +# print("Time taken for fitting: {}".format(display_time(int(time.time()-start)))) + +# # probs = total_f.pdf(test_q) + +# calcs_test = zfit.run(probs) +# res_y = zfit.run(jpsi_res(test_q)) + + +# In[ ]: + + +# plt.clf() +# # plt.plot(x_part, calcs, '.') +# plt.plot(test_q, calcs_test, label = 'pdf') +# # plt.plot(test_q, res_y, label = 'res') +# plt.legend() +# plt.ylim(0.0, 10e-6) +# # plt.yscale('log') +# # plt.xlim(3080, 3110) +# plt.savefig('test3.png') +# # print(jpsi_width) + + +# In[ ]: + + +# _tot = 4.37e-7+6.02e-5+4.97e-6 +# _probs = [] +# _probs.append(6.02e-5/_tot) +# _probs.append(4.97e-6/_tot) +# _probs.append(4.37e-7/_tot) +# print(_probs) + + +# In[ ]: + + +# dtype = 'float64' +# # mixture = tfd.Uniform(tf.constant(x_min, dtype=dtype), tf.constant(x_max, dtype=dtype)) +# mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=[tf.constant(0.007, dtype=dtype), +# tf.constant(0.917, dtype=dtype), +# tf.constant(0.076, dtype=dtype)]), +# components_distribution=tfd.Uniform(low=[tf.constant(x_min, dtype=dtype), +# tf.constant(3080, dtype=dtype), +# tf.constant(3670, dtype=dtype)], +# high=[tf.constant(x_max, dtype=dtype), +# tf.constant(3112, dtype=dtype), +# tf.constant(3702, dtype=dtype)])) +# # for i in range(10): +# # print(zfit.run(mixture.prob(mixture.sample((10, 1))))) + + +# In[ ]: + + +# print((zfit.run(jpsi_p)%(2*np.pi))/np.pi) +# print((zfit.run(psi2s_p)%(2*np.pi))/np.pi) + + +# In[ ]: + + +# def jpsi_res(q): +# return resonance(q, _mass = jpsi_mass, scale = jpsi_scale, +# phase = jpsi_phase, width = jpsi_width) + +# def psi2s_res(q): +# return resonance(q, _mass = psi2s_mass, scale = psi2s_scale, +# phase = psi2s_phase, width = psi2s_width) + +# def p3770_res(q): +# return resonance(q, _mass = p3770_mass, scale = p3770_scale, +# phase = p3770_phase, width = p3770_width) + +# def p4040_res(q): +# return resonance(q, _mass = p4040_mass, scale = p4040_scale, +# phase = p4040_phase, width = p4040_width) + +# def p4160_res(q): +# return resonance(q, _mass = p4160_mass, scale = p4160_scale, +# phase = p4160_phase, width = p4160_width) + +# def p4415_res(q): +# return resonance(q, _mass = p4415_mass, scale = p4415_scale, +# phase = p4415_phase, width = p4415_width) + + +# In[ ]: + + +# 0.15**2*4.2/1000 +# result.hesse() + + +# ## Constraints + +# In[ ]: + + +# 1. Constraint - Real part of sum of Psi contrib and D contribs + +sum_list = [] + +sum_list.append(ztf.to_complex(jpsi_s) * tf.exp(tf.complex(ztf.constant(0.0), jpsi_p)) * ztf.to_complex(jpsi_w / (tf.pow(jpsi_m,3)))) +sum_list.append(ztf.to_complex(psi2s_s) * tf.exp(tf.complex(ztf.constant(0.0), psi2s_p)) * ztf.to_complex(psi2s_w / (tf.pow(psi2s_m,3)))) +sum_list.append(ztf.to_complex(p3770_s) * tf.exp(tf.complex(ztf.constant(0.0), p3770_p)) * ztf.to_complex(p3770_w / (tf.pow(p3770_m,3)))) +sum_list.append(ztf.to_complex(p4040_s) * tf.exp(tf.complex(ztf.constant(0.0), p4040_p)) * ztf.to_complex(p4040_w / (tf.pow(p4040_m,3)))) +sum_list.append(ztf.to_complex(p4160_s) * tf.exp(tf.complex(ztf.constant(0.0), p4160_p)) * ztf.to_complex(p4160_w / (tf.pow(p4160_m,3)))) +sum_list.append(ztf.to_complex(p4415_s) * tf.exp(tf.complex(ztf.constant(0.0), p4415_p)) * ztf.to_complex(p4415_w / (tf.pow(p4415_m,3)))) +sum_list.append(ztf.to_complex(DDstar_s) * tf.exp(tf.complex(ztf.constant(0.0), DDstar_p)) * (ztf.to_complex(1.0 / (10.0*tf.pow(Dstar_m,2)) + 1.0 / (10.0*tf.pow(D_m,2))))) +sum_list.append(ztf.to_complex(Dbar_s) * tf.exp(tf.complex(ztf.constant(0.0), Dbar_p)) * ztf.to_complex(1.0 / (6.0*tf.pow(Dbar_m,2)))) + +sum_ru_1 = ztf.to_complex(ztf.constant(0.0)) + +for part in sum_list: + sum_ru_1 += part + +sum_1 = tf.math.real(sum_ru_1) +# constraint1 = zfit.constraint.GaussianConstraint(params = sum_1, mu = ztf.constant(1.7*10**-8), +# sigma = ztf.constant(2.2*10**-8)) + +constraint1 = tf.pow((sum_1-ztf.constant(1.7*10**-8))/ztf.constant(2.2*10**-8),2)/ztf.constant(2.) + +# 2. Constraint - Abs. of sum of Psi contribs and D contribs + +sum_2 = tf.abs(sum_ru_1) +constraint2 = tf.cond(tf.greater_equal(sum_2, 5.0e-8), lambda: 100000., lambda: 0.) + +# 3. Constraint - Maximum eta of D contribs + +constraint3_0 = tf.cond(tf.greater_equal(tf.abs(Dbar_s), 0.2), lambda: 100000., lambda: 0.) + +constraint3_1 = tf.cond(tf.greater_equal(tf.abs(DDstar_s), 0.2), lambda: 100000., lambda: 0.) + +# 4. Constraint - Formfactor multivariant gaussian covariance fplus + +Cov_matrix = [[ztf.constant( 1.), ztf.constant( 0.45), ztf.constant( 0.19), ztf.constant(0.857), ztf.constant(0.598), ztf.constant(0.531), ztf.constant(0.752), ztf.constant(0.229), ztf.constant(0,117)], + [ztf.constant( 0.45), ztf.constant( 1.), ztf.constant(0.677), ztf.constant(0.708), ztf.constant(0.958), ztf.constant(0.927), ztf.constant(0.227), ztf.constant(0.443), ztf.constant(0.287)], + [ztf.constant( 0.19), ztf.constant(0.677), ztf.constant( 1.), ztf.constant(0.595), ztf.constant(0.770), ztf.constant(0.819),ztf.constant(-0.023), ztf.constant( 0.07), ztf.constant(0.196)], + [ztf.constant(0.857), ztf.constant(0.708), ztf.constant(0.595), ztf.constant( 1.), ztf.constant( 0.83), ztf.constant(0.766), ztf.constant(0.582), ztf.constant(0.237), ztf.constant(0.192)], + [ztf.constant(0.598), ztf.constant(0.958), ztf.constant(0.770), ztf.constant( 0.83), ztf.constant( 1.), ztf.constant(0.973), ztf.constant(0.324), ztf.constant(0.372), ztf.constant(0.272)], + [ztf.constant(0.531), ztf.constant(0.927), ztf.constant(0.819), ztf.constant(0.766), ztf.constant(0.973), ztf.constant( 1.), ztf.constant(0.268), ztf.constant(0.332), ztf.constant(0.269)], + [ztf.constant(0.752), ztf.constant(0.227),ztf.constant(-0.023), ztf.constant(0.582), ztf.constant(0.324), ztf.constant(0.268), ztf.constant( 1.), ztf.constant( 0.59), ztf.constant(0.515)], + [ztf.constant(0.229), ztf.constant(0.443), ztf.constant( 0.07), ztf.constant(0.237), ztf.constant(0.372), ztf.constant(0.332), ztf.constant( 0.59), ztf.constant( 1.), ztf.constant(0.897)], + [ztf.constant(0.117), ztf.constant(0.287), ztf.constant(0.196), ztf.constant(0.192), ztf.constant(0.272), ztf.constant(0.269), ztf.constant(0.515), ztf.constant(0.897), ztf.constant( 1.)]] + +def triGauss(val1,val2,val3,m = Cov_matrix): + + mean1 = ztf.constant(0.466) + mean2 = ztf.constant(-0.885) + mean3 = ztf.constant(-0.213) + sigma1 = ztf.constant(0.014) + sigma2 = ztf.constant(0.128) + sigma3 = ztf.constant(0.548) + x1 = (val1-mean1)/sigma1 + x2 = (val2-mean2)/sigma2 + x3 = (val3-mean3)/sigma3 + rho12 = m[0][1] + rho13 = m[0][2] + rho23 = m[1][2] + w = x1*x1*(rho23*rho23-1) + x2*x2*(rho13*rho13-1)+x3*x3*(rho12*rho12-1)+2*(x1*x2*(rho12-rho13*rho23)+x1*x3*(rho13-rho12*rho23)+x2*x3*(rho23-rho12*rho13)) + d = 2*(rho12*rho12+rho13*rho13+rho23*rho23-2*rho12*rho13*rho23-1) + + fcn = -w/d + chisq = -2*fcn + return chisq + +constraint4 = triGauss(bplus_0, bplus_1, bplus_2) + +# mean1 = ztf.constant(0.466) +# mean2 = ztf.constant(-0.885) +# mean3 = ztf.constant(-0.213) +# sigma1 = ztf.constant(0.014) +# sigma2 = ztf.constant(0.128) +# sigma3 = ztf.constant(0.548) +# constraint4_0 = tf.pow((bplus_0-mean1)/sigma1,2)/ztf.constant(2.) +# constraint4_1 = tf.pow((bplus_1-mean2)/sigma2,2)/ztf.constant(2.) +# constraint4_2 = tf.pow((bplus_2-mean3)/sigma3,2)/ztf.constant(2.) + +# 5. Constraint - Abs. of sum of light contribs + +sum_list_5 = [] + +sum_list_5.append(rho_s*rho_w/rho_m) +sum_list_5.append(omega_s*omega_w/omega_m) +sum_list_5.append(phi_s*phi_w/phi_m) + + +sum_ru_5 = ztf.constant(0.0) + +for part in sum_list_5: + sum_ru_5 += part + +constraint5 = tf.cond(tf.greater_equal(tf.abs(sum_ru_5), ztf.constant(0.02)), lambda: 100000., lambda: 0.) + +# 6. Constraint on phases of Jpsi and Psi2s for cut out fit + + +# constraint6_0 = zfit.constraint.GaussianConstraint(params = jpsi_p, mu = ztf.constant(pdg["jpsi_phase_unc"]), +# sigma = ztf.constant(jpsi_phase)) +# constraint6_1 = zfit.constraint.GaussianConstraint(params = psi2s_p, mu = ztf.constant(pdg["psi2s_phase_unc"]), +# sigma = ztf.constant(psi2s_phase)) + +constraint6_0 = tf.pow((jpsi_p-ztf.constant(jpsi_phase))/ztf.constant(pdg["jpsi_phase_unc"]),2)/ztf.constant(2.) +constraint6_1 = tf.pow((psi2s_p-ztf.constant(psi2s_phase))/ztf.constant(pdg["psi2s_phase_unc"]),2)/ztf.constant(2.) + +# 7. Constraint on Ctt with higher limits + +constraint7 = tf.cond(tf.greater_equal(Ctt*Ctt, 0.25), lambda: 100000., lambda: 0.) + +constraint7dtype = tf.float64 + +# zfit.run(constraint6_0) + +# ztf.convert_to_tensor(constraint6_0) + +#List of all constraints + +constraints = [constraint1, constraint2, constraint3_0, constraint3_1,# constraint4, #constraint4_0, constraint4_1, constraint4_2, + constraint6_0, constraint6_1]#, constraint7] + + +# ## Reset params + +# In[ ]: + + +param_values_dic = { + 'jpsi_m': jpsi_mass, + 'jpsi_s': jpsi_scale, + 'jpsi_p': jpsi_phase, + 'jpsi_w': jpsi_width, + 'psi2s_m': psi2s_mass, + 'psi2s_s': psi2s_scale, + 'psi2s_p': psi2s_phase, + 'psi2s_w': psi2s_width, + 'p3770_m': p3770_mass, + 'p3770_s': p3770_scale, + 'p3770_p': p3770_phase, + 'p3770_w': p3770_width, + 'p4040_m': p4040_mass, + 'p4040_s': p4040_scale, + 'p4040_p': p4040_phase, + 'p4040_w': p4040_width, + 'p4160_m': p4160_mass, + 'p4160_s': p4160_scale, + 'p4160_p': p4160_phase, + 'p4160_w': p4160_width, + 'p4415_m': p4415_mass, + 'p4415_s': p4415_scale, + 'p4415_p': p4415_phase, + 'p4415_w': p4415_width, + 'rho_m': rho_mass, + 'rho_s': rho_scale, + 'rho_p': rho_phase, + 'rho_w': rho_width, + 'omega_m': omega_mass, + 'omega_s': omega_scale, + 'omega_p': omega_phase, + 'omega_w': omega_width, + 'phi_m': phi_mass, + 'phi_s': phi_scale, + 'phi_p': phi_phase, + 'phi_w': phi_width, + 'Dstar_m': Dstar_mass, + 'DDstar_s': 0.0, + 'DDstar_p': 0.0, + 'D_m': D_mass, + 'Dbar_m': Dbar_mass, + 'Dbar_s': 0.0, + 'Dbar_p': 0.0, + 'tau_m': pdg['tau_M'], + 'Ctt': 0.0, + 'b0_0': 0.292, + 'b0_1': 0.281, + 'b0_2': 0.150, + 'bplus_0': 0.466, + 'bplus_1': -0.885, + 'bplus_2': -0.213, + 'bT_0': 0.460, + 'bT_1': -1.089, + 'bT_2': -1.114} + + +def reset_param_values(variation = 0.05): + for param in total_f_fit.get_dependents(): + if param.floating: + param.set_value(param_values_dic[param.name] + random.uniform(-1, 1) * param_values_dic[param.name]* variation) +# print(param.name) +# for param in totalf.get_dependents(): +# param.set_value() + + +# # Analysis + +# In[ ]: + + +# # zfit.run.numeric_checks = False + +# fitting_range = 'cut' +# total_BR = 1.7e-10 + 4.9e-10 + 2.5e-9 + 6.02e-5 + 4.97e-6 + 1.38e-9 + 4.2e-10 + 2.6e-9 + 6.1e-10 + 4.37e-7 +# cut_BR = 1.0 - (6.02e-5 + 4.97e-6)/total_BR + +# Ctt_list = [] +# Ctt_error_list = [] + +# nr_of_toys = 1 +# if fitting_range == 'cut': +# nevents = int(pdg["number_of_decays"]*cut_BR) +# else: +# nevents = int(pdg["number_of_decays"]) +# # nevents = pdg["number_of_decays"] +# event_stack = 1000000 +# # nevents *= 41 +# # zfit.settings.set_verbosity(10) +# calls = int(nevents/event_stack + 1) + +# total_samp = [] + +# start = time.time() + +# sampler = total_f.create_sampler(n=event_stack) + +# for toy in range(nr_of_toys): + +# ### Generate data + +# # clear_output(wait=True) + +# print("Toy {}: Generating data...".format(toy)) + +# dirName = 'data/zfit_toys/toy_{0}'.format(toy) + +# if not os.path.exists(dirName): +# os.mkdir(dirName) +# print("Directory " , dirName , " Created ") + +# reset_param_values() + +# if fitting_range == 'cut': + +# sampler.resample(n=nevents) +# s = sampler.unstack_x() +# sam = zfit.run(s) +# calls = 0 +# c = 1 + +# else: +# for call in range(calls): + +# sampler.resample(n=event_stack) +# s = sampler.unstack_x() +# sam = zfit.run(s) + +# c = call + 1 + +# with open("data/zfit_toys/toy_{0}/{1}.pkl".format(toy, call), "wb") as f: +# pkl.dump(sam, f, pkl.HIGHEST_PROTOCOL) + +# print("Toy {}: Data generation finished".format(toy)) + +# ### Load data + +# print("Toy {}: Loading data...".format(toy)) + +# if fitting_range == 'cut': + +# total_samp = sam + +# else: + +# for call in range(calls): +# with open(r"data/zfit_toys/toy_0/{}.pkl".format(call), "rb") as input_file: +# sam = pkl.load(input_file) +# total_samp = np.append(total_samp, sam) + +# total_samp = total_samp.astype('float64') + +# if fitting_range == 'full': + +# data = zfit.data.Data.from_numpy(array=total_samp[:int(nevents)], obs=obs) + +# print("Toy {}: Loading data finished".format(toy)) + +# ### Fit data + +# print("Toy {}: Fitting pdf...".format(toy)) + +# for param in total_f.get_dependents(): +# param.randomize() + +# nll = zfit.loss.UnbinnedNLL(model=total_f, data=data, fit_range = (x_min, x_max), constraints = constraints) + +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) +# # minimizer._use_tfgrad = False +# result = minimizer.minimize(nll) + +# print("Toy {}: Fitting finished".format(toy)) + +# print("Function minimum:", result.fmin) +# print("Hesse errors:", result.hesse()) + +# params = result.params +# Ctt_list.append(params[Ctt]['value']) +# Ctt_error_list.append(params[Ctt]['minuit_hesse']['error']) + +# #plotting the result + +# plotdirName = 'data/plots'.format(toy) + +# if not os.path.exists(plotdirName): +# os.mkdir(plotdirName) +# # print("Directory " , dirName , " Created ") + +# probs = total_f.pdf(test_q, norm_range=False) +# calcs_test = zfit.run(probs) +# plt.clf() +# plt.plot(test_q, calcs_test, label = 'pdf') +# plt.legend() +# plt.ylim(0.0, 6e-6) +# plt.savefig(plotdirName + '/toy_fit_full_range{}.png'.format(toy)) + +# print("Toy {0}/{1}".format(toy+1, nr_of_toys)) +# print("Time taken: {}".format(display_time(int(time.time() - start)))) +# print("Projected time left: {}".format(display_time(int((time.time() - start)/(c+calls*(toy))*((nr_of_toys-toy)*calls-c))))) + +# if fitting_range == 'cut': + +# _1 = np.where((total_samp >= x_min) & (total_samp <= (jpsi_mass - 60.))) + +# tot_sam_1 = total_samp[_1] + +# _2 = np.where((total_samp >= (jpsi_mass + 70.)) & (total_samp <= (psi2s_mass - 50.))) + +# tot_sam_2 = total_samp[_2] + +# _3 = np.where((total_samp >= (psi2s_mass + 50.)) & (total_samp <= x_max)) + +# tot_sam_3 = total_samp[_3] + +# tot_sam = np.append(tot_sam_1, tot_sam_2) +# tot_sam = np.append(tot_sam, tot_sam_3) + +# data = zfit.data.Data.from_numpy(array=tot_sam[:int(nevents)], obs=obs_fit) + +# print("Toy {}: Loading data finished".format(toy)) + +# ### Fit data + +# print("Toy {}: Fitting pdf...".format(toy)) + +# for param in total_f_fit.get_dependents(): +# param.randomize() + +# nll = zfit.loss.UnbinnedNLL(model=total_f_fit, data=data, constraints = constraints) + +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) +# # minimizer._use_tfgrad = False +# result = minimizer.minimize(nll) + +# print("Function minimum:", result.fmin) +# print("Hesse errors:", result.hesse()) + +# params = result.params + +# if result.converged: +# Ctt_list.append(params[Ctt]['value']) +# Ctt_error_list.append(params[Ctt]['minuit_hesse']['error']) + +# #plotting the result + +# plotdirName = 'data/plots'.format(toy) + +# if not os.path.exists(plotdirName): +# os.mkdir(plotdirName) +# # print("Directory " , dirName , " Created ") + +# plt.clf() +# plt.hist(tot_sam, bins = int((x_max-x_min)/7.), label = 'toy data') +# plt.savefig(plotdirName + '/toy_histo_cut_region{}.png'.format(toy)) + + +# probs = total_f_fit.pdf(test_q, norm_range=False) +# calcs_test = zfit.run(probs) +# plt.clf() +# plt.plot(test_q, calcs_test, label = 'pdf') +# plt.axvline(x=jpsi_mass-60.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.axvline(x=jpsi_mass+70.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.axvline(x=psi2s_mass-50.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.axvline(x=psi2s_mass+50.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.legend() +# plt.ylim(0.0, 1.5e-6) +# plt.savefig(plotdirName + '/toy_fit_cut_region{}.png'.format(toy)) + +# print("Toy {0}/{1}".format(toy+1, nr_of_toys)) +# print("Time taken: {}".format(display_time(int(time.time() - start)))) +# print("Projected time left: {}".format(display_time(int((time.time() - start)/(toy+1))*((nr_of_toys-toy-1))))) + + + +# In[ ]: + + +# with open("data/results/Ctt_list.pkl", "wb") as f: +# pkl.dump(Ctt_list, f, pkl.HIGHEST_PROTOCOL) +# with open("data/results/Ctt_error_list.pkl", "wb") as f: +# pkl.dump(Ctt_error_list, f, pkl.HIGHEST_PROTOCOL) + + +# In[ ]: + + +# print('{0}/{1} fits converged'.format(len(Ctt_list), nr_of_toys)) +# print('Mean Ctt value = {}'.format(np.mean(Ctt_list))) +# print('Mean Ctt error = {}'.format(np.mean(Ctt_error_list))) +# print('95 Sensitivy = {}'.format(((2*np.mean(Ctt_error_list))**2)*4.2/1000)) + + +# In[ ]: + + +# plt.hist(tot_sam, bins = int((x_max-x_min)/7.)) + +# plt.show() + +# # _ = np.where((total_samp >= x_min) & (total_samp <= (jpsi_mass - 50.))) + +# tot_sam.shape + + +# In[ ]: + + +# Ctt.floating = False + + +# In[ ]: + + +# zfit.run(nll.value()) + + +# In[ ]: + + +# result.fmin + + +# In[ ]: + + +# BR_steps = np.linspace(0.0, 1e-3, 11) +pull_dic = {} + +mi = 1e-4 +ma = 3e-3 +ste = 20 + +for param in total_f_fit.get_dependents(): + if param.floating: + pull_dic[param.name] = [] + for step in range(2*ste): + pull_dic[param.name].append([]) + + + +def save_pulls(step): + for param in total_f_fit.get_dependents(): + if param.floating: + pull_dic[param.name][step].append((params[param]['value'] - param_values_dic[param.name])/params[param]['minuit_hesse']['error']) + + + +# for key in pull_dic.keys(): +# print(np.shape(pull_dic[key])) +# save_pulls(New_step=True) +# params[Ctt]['value'] + + +# In[ ]: + + +# for param in total_f_fit.get_dependents(): +# if param.floating: +# print(param.name) + +# print(params[Ctt]) + + +# # CLS Code + +# In[ ]: + + +# zfit.run.numeric_checks = False + +load = False + +bo = True + +D_contribs = True + +if not D_contribs: + Dbar_s.floating = False + Dbar_p.floating = False + DDstar_s.floating = False + DDstar_p.floating = False + +bo_set = 1 + +fitting_range = 'cut' +total_BR = 1.7e-10 + 4.9e-10 + 2.5e-9 + 6.02e-5 + 4.97e-6 + 1.38e-9 + 4.2e-10 + 2.6e-9 + 6.1e-10 + 4.37e-7 +cut_BR = 1.0 - (6.02e-5 + 4.97e-6)/total_BR + +Ctt_list = [] +Ctt_error_list = [] + +nr_of_toys = 1 +nevents = int(pdg["number_of_decays"]*cut_BR) +# nevents = pdg["number_of_decays"] +event_stack = 1000000 +# nevents *= 41 +# zfit.settings.set_verbosity(10) + +# mi = 1e-4 +# ma = 3e-3 +# ste = 13 + +BR_steps = np.linspace(mi, ma, ste) + +BR_steps[0] = 0.0 + +print(BR_steps) + +Ctt_steps = np.sqrt(BR_steps/4.2*1000) + +print(Ctt_steps) + +# total_samp = [] + +start = time.time() + +Nll_list = [] + +sampler = total_f.create_sampler(n=nevents, fixed_params = False) +sampler.set_data_range(obs_fit) + +__ = -1 + +#----------------------------------------------------- + +if not load: + for Ctt_step in Ctt_steps: + + __ += 1 + + for i in range(2): + Ctt_list.append([]) + Ctt_error_list.append([]) + Nll_list.append([]) + + for param in total_f_fit.get_dependents(): + if param.floating: + pull_dic[param.name].append([]) + + for toy in range(nr_of_toys): + + newset = True + + while newset: + + for floaty in [True, False]: + Ctt.floating = floaty + + for bo_step in range(bo_set): + + print('Step: {0}/{1}'.format(int(__), ste)) + print('Current Ctt: {0}'.format(Ctt_step)) + print('Ctt floating: {0}'.format(floaty)) + + reset_param_values(variation = 0.0) + + if floaty: + print('Toy {0}/{1} - Fit {2}/{3}'.format(toy, nr_of_toys, bo_step, bo_set)) + Ctt.set_value(Ctt_step) + + else: + Ctt.set_value(0.0) + print('Toy {0}/{1} - Fit {2}/{3}'.format(toy, nr_of_toys, bo_step, bo_set)) + + if newset: + sampler.resample(n=nevents) + data = sampler + newset = False + + ### Fit data + + if floaty: + #plt.clf() + #plt.title('Ctt value: {:.2f}'.format(Ctt_step)) + #plt.hist(zfit.run(data), bins = int((x_max-x_min)/7), range = (x_min, x_max)) + #plt.savefig('data/CLs/plots/set_histo{}.png'.format(__)) + _step = 2*__ + else: + _step = 2*__+1 + + nll = zfit.loss.UnbinnedNLL(model=total_f_fit, data=data, constraints = constraints) + + minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) + # minimizer._use_tfgrad = False + result = minimizer.minimize(nll) + + print("Function minimum:", result.fmin) + print("Hesse errors:", result.hesse()) + + params = result.params + + if result.converged: + + save_pulls(step = _step) + + if floaty: + Nll_list[-2].append(result.fmin) + Ctt_list[-2].append(params[Ctt]['value']) + Ctt_error_list[-2].append(params[Ctt]['minuit_hesse']['error']) + + else: + Nll_list[-1].append(result.fmin) + Ctt_list[-1].append(0.0) + Ctt_error_list[-1].append(0.0) + + + else: + for _ in [1,2]: + del Nll_list[-_][toy*bo_set:] +# print(np.shape(Nll_list[-_])) + del Ctt_list[-_][toy*bo_set:] + del Ctt_error_list[-_][toy*bo_set:] + for param in total_f_fit.get_dependents(): + if param.floating: + del pull_dic[param.name][_step+1-_][toy*bo_set:] + newset = True + break + + if not result.converged: + break + + print() + print('Time taken: {}'.format(display_time(int(time.time()-start)))) + print('Estimated time left: {}'.format(display_time(int((time.time()-start)/(__+(toy+1)/nr_of_toys)*(ste-__-(nr_of_toys-toy-1)/nr_of_toys))))) + + +# In[ ]: + + +if load: + + phase_combi = '--' + + if D_contribs: + D_dir = 'D-True' + else: + D_dir = 'D-False' + + _dir = 'data/CLs/finished/f1d1/{}/{}/'.format(phase_combi, D_dir) + + jobs = os.listdir(_dir) + + First = True + +# print(jobs) + + for job in jobs: + + dirName = _dir + str(job) + '/data/CLs' + + if not os.path.exists("{}/{}-{}_{}s{}b{}t--CLs_Nll_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys)): +# print(job) + continue + + with open(r"{}/variab.pkl".format(dirName), "rb") as input_file: + variab = pkl.load(input_file) +# print(variab) + + ### sanity check: + if variab['mi'] != mi or variab['ma'] != ma or variab['ste'] != ste or bo_set != bo_set: + print('Fitting parameters of data dont equal the ones given -- Job {} skipped!'.format(job)) + + with open(r"{}/{}-{}_{}s{}b{}t--CLs_Nll_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _Nll_list = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s{}b{}t--Ctt_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _Ctt_list = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s{}b{}t--Ctt_error_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _Ctt_error_list = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s{}b{}t--pull_dic.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _pull_dic = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s--CLs_list.pkl".format(dirName, mi,ma,ste), "rb") as input_file: + _CLs_list = pkl.load(input_file) + + + if First: + Nll_list = _Nll_list + Ctt_list = _Ctt_list + Ctt_error_list = _Ctt_error_list + pull_dic = _pull_dic +# print(_pull_dic) + CLs_list = _CLs_list + First = False + else: + for step in range(2*ste): +# print(Nll_list[step], step) + Nll_list[step].extend(_Nll_list[step]) + Ctt_list[step].extend(_Ctt_list[step]) + Ctt_error_list[step].extend(_Ctt_error_list[step]) + for key in pull_dic.keys(): +# print(key, np.shape(pull_dic[key])) + pull_dic[key][step].extend(_pull_dic[key][step]) + for step in range(ste): + CLs_list[step].extend(_CLs_list[step]) + +# print('----------------------') + + +# In[ ]: + + +dirName = 'data/CLs' + +# if bo and not load: +# for s in range(2*ste): +# Nll_list[s] = [np.min(Nll_list[s])] + + +if not load: + + if not os.path.exists(dirName): + os.mkdir(dirName) + print("Directory " , dirName , " Created ") + + with open("{}/{}-{}_{}s{}b{}t--CLs_Nll_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(Nll_list, f, pkl.HIGHEST_PROTOCOL) + + with open("{}/{}-{}_{}s{}b{}t--Ctt_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(Ctt_list, f, pkl.HIGHEST_PROTOCOL) + + with open("{}/{}-{}_{}s{}b{}t--Ctt_error_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(Ctt_error_list, f, pkl.HIGHEST_PROTOCOL) + + with open("{}/{}-{}_{}s{}b{}t--pull_dic.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(pull_dic, f, pkl.HIGHEST_PROTOCOL) + + variab = {'mi': mi, + 'ma': ma, + 'ste': ste, + 'bo_set': bo_set, + 'nr_of_toys': nr_of_toys} + + with open("{}/variab.pkl".format(dirName), "wb") as f: + pkl.dump(variab, f, pkl.HIGHEST_PROTOCOL) + + CLs_values = [] + + toy_size = bo_set + + print(np.shape(Nll_list)) + print(Nll_list[0:1]) + + for step in range(ste): + CLs_values.append([]) + for toy in range(nr_of_toys): + float_min = np.min(Nll_list[2*step][toy*bo_set:(toy+1)*bo_set]) + fix_min = np.min(Nll_list[2*step+1][toy*bo_set:(toy+1)*bo_set]) + CLs_values[step].append(float_min-fix_min) + + + print(np.shape(CLs_values)) + + with open("{}/{}-{}_{}s--CLs_list.pkl".format(dirName, mi,ma,ste), "wb") as f: + pkl.dump(CLs_values, f, pkl.HIGHEST_PROTOCOL) + + +# In[ ]: + + +# print(variab['mi'] != mi) + + +# ## Plot + +# In[ ]: + + +l = [] + + +if load: + CLs_values = -1*np.array(CLs_list) + +if not os.path.exists('data/CLs/plots'): + os.mkdir('data/CLs/plots') + print("Directory " , 'data/CLs/plots' , " Created ") + +print(np.shape(CLs_values)) + +for step in range(1,ste): + plt.clf() + plt.title('Ctt value: {:.2f}'.format(Ctt_steps[step])) + plt.hist(CLs_values[0], bins = 150, range = (-25, 50), label = 'Ctt fixed to 0') + plt.hist(CLs_values[step], bins = 150, range = (-25, 50), label = 'Ctt floating') + plt.axvline(x=np.mean(CLs_values[0]),color='red', linewidth=1.0, linestyle = 'dotted') + plt.legend() + plt.savefig('data/CLs/plots/CLs-BR({:.1E}).png'.format(BR_steps[step])) + + l.append(len(np.where(np.array(CLs_values[step]) < np.mean(CLs_values[0]))[0])) + +for step in range(2*ste): + if step%2 == 0: + floaty = True + else: + floaty = False + for key in pull_dic.keys(): + if not os.path.exists('data/CLs/plots/{}'.format(key)): + os.mkdir('data/CLs/plots/{}'.format(key)) + plt.clf() + plt.title('Pull {} - Ctt value {:.2f} - floating {}'.format(key, Ctt_steps[int(step/2)], floaty)) + plt.hist(pull_dic[key][step], bins = 50, range = (-5,5)) + plt.xlabel('Pull') + plt.savefig('data/CLs/plots/{}/{:.2f}Ctt{}s{}f.png'.format(key, Ctt_steps[int(step/2)], step, floaty)) + + +# In[ ]: + + +for s in range(len(l)): + print('BR: {:.4f}'.format(BR_steps[s+1])) + print(2*l[s]/len(CLs_values[s])) + print() + + +# In[ ]: + + +# for step in range(2*ste): +# for key in pull_dic.keys(): +# print(pull_dic[key][step]) + + +# In[ ]: + + +# for param in total_f_fit.get_dependents(): +# if param.floating: +# print(params[param]['value']) + + +# In[ ]: + + +print(display_time(int(time.time()-start))) + + +# In[ ]: + + +# variab['mi'] =! mi + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + diff --git a/data/CLs/finished/f1d1/-+/D-True/2288037/__pycache__/helperfunctions.cpython-37.pyc b/data/CLs/finished/f1d1/-+/D-True/2288037/__pycache__/helperfunctions.cpython-37.pyc new file mode 100644 index 0000000..a7e8a34 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288037/__pycache__/helperfunctions.cpython-37.pyc Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288037/__pycache__/pdg_const1.cpython-37.pyc b/data/CLs/finished/f1d1/-+/D-True/2288037/__pycache__/pdg_const1.cpython-37.pyc new file mode 100644 index 0000000..85784d4 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288037/__pycache__/pdg_const1.cpython-37.pyc Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288037/data/CLs/0.0001-0.003_20s--CLs_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288037/data/CLs/0.0001-0.003_20s--CLs_list.pkl new file mode 100644 index 0000000..ba37845 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288037/data/CLs/0.0001-0.003_20s--CLs_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288037/data/CLs/0.0001-0.003_20s1b1t--CLs_Nll_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288037/data/CLs/0.0001-0.003_20s1b1t--CLs_Nll_list.pkl new file mode 100644 index 0000000..37560da --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288037/data/CLs/0.0001-0.003_20s1b1t--CLs_Nll_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288037/data/CLs/0.0001-0.003_20s1b1t--Ctt_error_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288037/data/CLs/0.0001-0.003_20s1b1t--Ctt_error_list.pkl new file mode 100644 index 0000000..435c3ad --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288037/data/CLs/0.0001-0.003_20s1b1t--Ctt_error_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288037/data/CLs/0.0001-0.003_20s1b1t--Ctt_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288037/data/CLs/0.0001-0.003_20s1b1t--Ctt_list.pkl new file mode 100644 index 0000000..a74a29b --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288037/data/CLs/0.0001-0.003_20s1b1t--Ctt_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288037/data/CLs/0.0001-0.003_20s1b1t--pull_dic.pkl b/data/CLs/finished/f1d1/-+/D-True/2288037/data/CLs/0.0001-0.003_20s1b1t--pull_dic.pkl new file mode 100644 index 0000000..f3c2083 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288037/data/CLs/0.0001-0.003_20s1b1t--pull_dic.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288037/data/CLs/variab.pkl b/data/CLs/finished/f1d1/-+/D-True/2288037/data/CLs/variab.pkl new file mode 100644 index 0000000..bb90dc0 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288037/data/CLs/variab.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288037/helperfunctions.py b/data/CLs/finished/f1d1/-+/D-True/2288037/helperfunctions.py new file mode 100644 index 0000000..88e120f --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288037/helperfunctions.py @@ -0,0 +1,33 @@ +# some helperfunctions + +import matplotlib +matplotlib.use("agg") +import matplotlib.pyplot as plt + +#Dislpay time (e.g. while generating points) + +display_intervals = ( + ('w', 604800), # 60 * 60 * 24 * 7 + ('d', 86400), # 60 * 60 * 24 + ('h', 3600), # 60 * 60 + ('min', 60), + ('s', 1), + ) + +def display_time(seconds, granularity=2): + result = [] + + for name, count in display_intervals: + value = seconds // count + if value: + seconds -= value * count + if value == 1: + name = name.rstrip('s') + result.append("{} {}".format(value, name)) + return ', '.join(result[:granularity]) + +def prepare_plot(title): + plt.title(title) + plt.grid() + plt.legend(loc = 'best') + plt.xlabel("q") diff --git a/data/CLs/finished/f1d1/-+/D-True/2288037/pdg_const1.py b/data/CLs/finished/f1d1/-+/D-True/2288037/pdg_const1.py new file mode 100644 index 0000000..70b3f30 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288037/pdg_const1.py @@ -0,0 +1,226 @@ +pdg = { + + + ###Particle masses### + + "mbstar" : 5415.4, + "mbstar0" : 5711.0, + "B0_M" : 5279.5, + "Bs_M" : 5366.7, + "Bplus_M" : 5279.3, + "Lb_M" : 5619.4, + "D0_M" : 1864.8, + "Dst_M" : 2010, + "pi_M" : 139.6, + "Jpsi_M" : 3096.9, + "Psi2s_M" : 3685.6, + "kaon_M" : 493.7, + "Ks_M" : 497.6, + "phi_M" : 1019.5, + "rho_M" : 775.26, + "rho_width" : 149.1, + "omega_M" : 782.65, + "omega_width" : 8.49, + + "muon_M" : 105.7, + "tau_M": 1776.86, + + "squark_M" : 95.0, + "bquark_M" : 4180.0, + "cquark_M" : 1275.0, + + "Bplus_tau" : 1.638e-12, + + ###Wilson coefficients### + + "C1" : -0.257, + "C2" : 1.009, + "C3" : -0.005, + "C4" : -0.078, + + "C7eff" : -0.306, + "C9eff" : 4.211, + "C10eff" : -4.103, + +# "C7eff": 0.0, +# "C9eff": 0.0, +# "C10eff": 0.0, + + ###Other constants + + "GF" : 1.1663787e-5, + "alpha_ew" : 1.0/137.0, + "Vts" : 0.0394, + "Vtb" : 1.019, + "number_of_decays": 5404696, + + #Formfactor z coefficients + + #"b0" : [0.285, 0.19, -0.17], + #"bplus" : [0.437, -1.41, -2.5], + #"bT" : [0.440, -1.47, -2.7] + + "b0" : [0.292, 0.281, 0.150], + "bplus" : [0.466, -0.885, -0.213], + "bT" : [0.460, -1.089, -1.114], + + "NR_BR": 4.37e-7, + "NR_auc": 0.00133, + + #Resonances format(mass, width, phase, scale) + + # pre scaling + +# "rho": (775.26, 149.0, -0.35, 1.0), + +# "omega": (782.7, 8.5, 0.26, 1.0), + +# "phi": (1019.46, 4.25, 0.5, 1.0), + +# "jpsi": (3096.0, 0.09, -1.5, 2e-2), +# "jpsi_auc": 0.2126825758464027, + +# "psi2s": (3686.0, 0.3, -1.5, 3.14e-3), +# "psi2s_auc": 2.802257483178487e-10, + +# "p3770": (3773.0, 27.2, -2.13, 1.0e-3), + +# "p4040": (4039.0, 80.0, -2.52, 2.0), + +# "p4160": (4191.0, 70.0, -1.9, 2.2), + +# "p4415": (4421.0, 62.0, -2.52, 1.0), + + + # after scaling (Phase combination --) + + # + # "rho": (743.2, 149.0, -0.22, 1.05), + # + # "omega": (782.7, 8.5, 0.38, 6.8), + # + # "phi": (1013.5, 4.25, 0.62, 19.2), + # + # "jpsi": (3096.1, 0.09, 1.63, 9897.0), + # "jpsi_auc": 0.2126825758464027, + # "jpsi_phase_unc": 0.05, + # + # "psi2s": (3686.0, 0.3, 1.8, 1396.0), + # "psi2s_auc": 0.0151332263, + # "psi2s_phase_unc": 0.1, + # + # "p3770": (3773.0, 27.2, -2.95, 2.5), + # + # "p4040": (4039.0, 80.0, -2.75, 1.01), + # + # "p4160": (4191.0, 70.0, -2.28, 2.2), + # + # "p4415": (4421.0, 62.0, -2.31, 1.24), + + # Phase combination of paper ++ + +# "rho": (743.2, 149.0, -0.35, 1.05), + +# "omega": (782.7, 8.5, 0.26, 6.8), + +# "phi": (1013.5, 4.25, 0.47, 19.2), + +# "jpsi": (3096.1, 0.09, -1.66, 9897.0), +# "jpsi_auc": 0.2126825758464027, +# "jpsi_phase_unc": 0.05, + +# "psi2s": (3686.0, 0.3, -1.93, 1396.0), +# "psi2s_auc": 0.0151332263, +# "psi2s_phase_unc": 0.1, + +# "p3770": (3773.0, 27.2, -2.13, 2.5), + +# "p4040": (4039.0, 80.0, -2.52, 1.01), + +# "p4160": (4191.0, 70.0, -1.90, 2.2), + +# "p4415": (4421.0, 62.0, -2.52, 1.24), + + # Phase combination of paper +- + +# "rho": (743.2, 149.0, -0.26, 1.05), + +# "omega": (782.7, 8.5, 0.35, 6.8), + +# "phi": (1013.5, 4.25, 0.58, 19.2), + +# "jpsi": (3096.1, 0.09, 1.47, 9897.0), +# "jpsi_auc": 0.2126825758464027, +# "jpsi_phase_unc": 0.05, + +# "psi2s": (3686.0, 0.3, -2.21, 1396.0), +# "psi2s_auc": 0.0151332263, +# "psi2s_phase_unc": 0.1, + +# "p3770": (3773.0, 27.2, -2.140, 2.5), + +# "p4040": (4039.0, 80.0, -2.64, 1.01), + +# "p4160": (4191.0, 70.0, -2.11, 2.2), + +# "p4415": (4421.0, 62.0, -2.42, 1.24), + + # Phase combination of paper -+ + + "rho": (743.2, 149.0, -0.30, 1.05), + + "omega": (782.7, 8.5, 0.30, 6.8), + + "phi": (1013.5, 4.25, 0.51, 19.2), + + "jpsi": (3096.1, 0.09, -1.5, 9897.0), + "jpsi_auc": 0.2126825758464027, + "jpsi_phase_unc": 0.05, + + "psi2s": (3686.0, 0.3, 2.08, 1396.0), + "psi2s_auc": 0.0151332263, + "psi2s_phase_unc": 0.1, + + "p3770": (3773.0, 27.2, -2.89, 2.5), + + "p4040": (4039.0, 80.0, -2.69, 1.01), + + "p4160": (4191.0, 70.0, -2.13, 2.2), + + "p4415": (4421.0, 62.0, -2.43, 1.24), + + + # zeroing resonances + +# "rho": (775.26, 149.0, -0.35, 0.0), +# "omega": (782.7, 8.5, 0.26, 0.0), +# "phi": (1019.46, 4.25, 0.5, 0.0), +# "jpsi": (3096.0, 0.09, -1.5, 0.0), +# "psi2s": (3686.0, 0.3, -1.5, 0.0), +# "p3770": (3773.0, 27.2, -2.13, 0.0), +# "p4040": (4039.0, 80.0, -2.52, 0.0), +# "p4160": (4147.0, 22.0, -1.9, 0.0), +# "p4415": (4421.0, 62.0, -2.52, 0.0), + + # 2P contributions format(mass, amp, phase) + +# "D_bar": ( + + #general + + "rho_BR": 1.7e-10, + "omega_BR": 4.9e-10, + "phi_BR": 2.5e-9, + "jpsi_BR": 6.02e-5, + "psi2s_BR": 4.97e-6, + "p3770_BR": 1.38e-9, + "p4040_BR": 4.2e-10, + "p4160_BR": 2.6e-9, + "p4415_BR": 6.1e-10, + +# Estimates + "Dbar_scale": 1.46, #with phase = pi + + "DDstar_scale": 2.41, #with phase = pi + + } diff --git a/data/CLs/finished/f1d1/-+/D-True/2288037/raremodel-nb.py b/data/CLs/finished/f1d1/-+/D-True/2288037/raremodel-nb.py new file mode 100644 index 0000000..c326c9c --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288037/raremodel-nb.py @@ -0,0 +1,2152 @@ +#!/usr/bin/env python +# coding: utf-8 + +# # Import + +# In[ ]: + + +import os + +# os.environ["CUDA_VISIBLE_DEVICES"] = "-1" +import random +import numpy as np +from pdg_const1 import pdg +import matplotlib +import matplotlib.pyplot as plt +import pickle as pkl +import sys +import time +from helperfunctions import display_time, prepare_plot +import cmath as c +import scipy.integrate as integrate +from scipy.optimize import fminbound +from array import array as arr +import collections +from itertools import compress +import tensorflow as tf +import zfit +from zfit import ztf +# from IPython.display import clear_output +import os +import tensorflow_probability as tfp +tfd = tfp.distributions + + +# In[ ]: + + +# chunksize = 10000 +# zfit.run.chunking.active = True +# zfit.run.chunking.max_n_points = chunksize + + +# # Build model and graphs +# ## Create graphs + +# In[ ]: + + + + + +# In[ ]: + + +def formfactor(q2, subscript, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2): #returns real value + #check if subscript is viable + + if subscript != "0" and subscript != "+" and subscript != "T": + raise ValueError('Wrong subscript entered, choose either 0, + or T') + + #get constants + + mK = ztf.constant(pdg['Ks_M']) + mbstar0 = ztf.constant(pdg["mbstar0"]) + mbstar = ztf.constant(pdg["mbstar"]) + + + mmu = ztf.constant(pdg['muon_M']) + mb = ztf.constant(pdg['bquark_M']) + ms = ztf.constant(pdg['squark_M']) + mB = ztf.constant(pdg['Bplus_M']) + + #N comes from derivation in paper + + N = 3 + + #some helperfunctions + + tpos = (mB - mK)**2 + tzero = (mB + mK)*(ztf.sqrt(mB)-ztf.sqrt(mK))**2 + + z_oben = ztf.sqrt(tpos - q2) - ztf.sqrt(tpos - tzero) + z_unten = ztf.sqrt(tpos - q2) + ztf.sqrt(tpos - tzero) + z = tf.divide(z_oben, z_unten) + + #calculate f0 + + if subscript == "0": + prefactor = 1/(1 - q2/(mbstar0**2)) + _sum = 0 + b0 = [b0_0, b0_1, b0_2] + + for i in range(N): + _sum += b0[i]*(tf.pow(z,i)) + + return ztf.to_complex(prefactor * _sum) + + #calculate f+ or fT + + else: + prefactor = 1/(1 - q2/(mbstar**2)) + _sum = 0 + + if subscript == "T": + bT = [bT_0, bT_1, bT_2] + for i in range(N): + _sum += bT[i] * (tf.pow(z, i) - ((-1)**(i-N)) * (i/N) * tf.pow(z, N)) + else: + bplus = [bplus_0, bplus_1, bplus_2] + for i in range(N): + _sum += bplus[i] * (tf.pow(z, i) - ((-1)**(i-N)) * (i/N) * tf.pow(z, N)) + + return ztf.to_complex(prefactor * _sum) + +def resonance(q, _mass, width, phase, scale): + + q2 = tf.pow(q, 2) + + mmu = ztf.constant(pdg['muon_M']) + + p = 0.5 * ztf.sqrt(q2 - 4*(mmu**2)) + + p0 = 0.5 * ztf.sqrt(_mass**2 - 4*mmu**2) + + gamma_j = tf.divide(p, q) * _mass * width / p0 + + #Calculate the resonance + + _top = tf.complex(_mass * width, ztf.constant(0.0)) + + _bottom = tf.complex(_mass**2 - q2, -_mass*gamma_j) + + com = _top/_bottom + + #Rotate by the phase + + r = ztf.to_complex(scale*tf.abs(com)) + + _phase = tf.angle(com) + + _phase += phase + + com = r * tf.exp(tf.complex(ztf.constant(0.0), _phase)) + + return com + + +def axiv_nonres(q, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2): + + GF = ztf.constant(pdg['GF']) + alpha_ew = ztf.constant(pdg['alpha_ew']) + Vtb = ztf.constant(pdg['Vtb']) + Vts = ztf.constant(pdg['Vts']) + C10eff = ztf.constant(pdg['C10eff']) + + mmu = ztf.constant(pdg['muon_M']) + mb = ztf.constant(pdg['bquark_M']) + ms = ztf.constant(pdg['squark_M']) + mK = ztf.constant(pdg['Ks_M']) + mB = ztf.constant(pdg['Bplus_M']) + + q2 = tf.pow(q, 2) + + #Some helperfunctions + + beta = 1. - 4. * mmu**2. / q2 + + kabs = ztf.sqrt(mB**2. + tf.pow(q2, 2)/mB**2. + mK**4./mB**2. - 2. * (mB**2. * mK**2. + mK**2. * q2 + mB**2. * q2) / mB**2.) + + #prefactor in front of whole bracket + + prefactor1 = GF**2. *alpha_ew**2. * (tf.abs(Vtb*Vts))**2. * kabs * beta / (128. * np.pi**5.) + + #left term in bracket + + bracket_left = 2./3. * tf.pow(kabs,2) * tf.pow(beta,2) * tf.pow(tf.abs(ztf.to_complex(C10eff)*formfactor(q2, "+", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2)),2) + + #middle term in bracket + + _top = 4. * mmu**2. * (mB**2. - mK**2.) * (mB**2. - mK**2.) + + _under = q2 * mB**2. + + bracket_middle = _top/_under *tf.pow(tf.abs(ztf.to_complex(C10eff) * formfactor(q2, "0", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2)), 2) + + #Note sqrt(q2) comes from derivation as we use q2 and plot q + + return prefactor1 * (bracket_left + bracket_middle) * 2 * q + +def vec(q, funcs, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2): + + q2 = tf.pow(q, 2) + + GF = ztf.constant(pdg['GF']) + alpha_ew = ztf.constant(pdg['alpha_ew']) + Vtb = ztf.constant(pdg['Vtb']) + Vts = ztf.constant(pdg['Vts']) + C7eff = ztf.constant(pdg['C7eff']) + + mmu = ztf.constant(pdg['muon_M']) + mb = ztf.constant(pdg['bquark_M']) + ms = ztf.constant(pdg['squark_M']) + mK = ztf.constant(pdg['Ks_M']) + mB = ztf.constant(pdg['Bplus_M']) + + #Some helperfunctions + + beta = 1. - 4. * mmu**2. / q2 + + kabs = ztf.sqrt(mB**2. + tf.pow(q2, 2)/mB**2. + mK**4./mB**2. - 2 * (mB**2 * mK**2 + mK**2 * q2 + mB**2 * q2) / mB**2) + + #prefactor in front of whole bracket + + prefactor1 = GF**2. *alpha_ew**2. * (tf.abs(Vtb*Vts))**2 * kabs * beta / (128. * np.pi**5.) + + #right term in bracket + + prefactor2 = tf.pow(kabs,2) * (1. - 1./3. * beta) + + abs_bracket = tf.pow(tf.abs(c9eff(q, funcs) * formfactor(q2, "+", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + ztf.to_complex(2.0 * C7eff * (mb + ms)/(mB + mK)) * formfactor(q2, "T", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2)),2) + + bracket_right = prefactor2 * abs_bracket + + #Note sqrt(q2) comes from derivation as we use q2 and plot q + + return prefactor1 * bracket_right * 2 * q + +def c9eff(q, funcs): + + C9eff_nr = ztf.to_complex(ztf.constant(pdg['C9eff'])) + + c9 = C9eff_nr + funcs + + return c9 + + +# In[ ]: + + +def G(y): + + def inner_rect_bracket(q): + return tf.log(ztf.to_complex((1+tf.sqrt(q))/(1-tf.sqrt(q)))-tf.complex(ztf.constant(0), -1*ztf.constant(np.pi))) + + def inner_right(q): + return ztf.to_complex(2 * tf.atan(1/tf.sqrt(tf.math.real(-q)))) + + big_bracket = tf.where(tf.math.real(y) > ztf.constant(0.0), inner_rect_bracket(y), inner_right(y)) + + return ztf.to_complex(tf.sqrt(tf.abs(y))) * big_bracket + +def h_S(m, q): + + return ztf.to_complex(2) - G(ztf.to_complex(1) - ztf.to_complex(4*tf.pow(m, 2)) / ztf.to_complex(tf.pow(q, 2))) + +def h_P(m, q): + + return ztf.to_complex(2/3) + (ztf.to_complex(1) - ztf.to_complex(4*tf.pow(m, 2)) / ztf.to_complex(tf.pow(q, 2))) * h_S(m,q) + +def two_p_ccbar(mD, m_D_bar, m_D_star, q): + + + #Load constants + nu_D_bar = ztf.to_complex(pdg["nu_D_bar"]) + nu_D = ztf.to_complex(pdg["nu_D"]) + nu_D_star = ztf.to_complex(pdg["nu_D_star"]) + + phase_D_bar = ztf.to_complex(pdg["phase_D_bar"]) + phase_D = ztf.to_complex(pdg["phase_D"]) + phase_D_star = ztf.to_complex(pdg["phase_D_star"]) + + #Calculation + left_part = nu_D_bar * tf.exp(tf.complex(ztf.constant(0.0), phase_D_bar)) * h_S(m_D_bar, q) + + right_part_D = nu_D * tf.exp(tf.complex(ztf.constant(0.0), phase_D)) * h_P(m_D, q) + + right_part_D_star = nu_D_star * tf.exp(tf.complex(ztf.constant(0.0), phase_D_star)) * h_P(m_D_star, q) + + return left_part + right_part_D + right_part_D_star + + +# ## Build pdf + +# In[ ]: + + +class total_pdf_cut(zfit.pdf.ZPDF): + _N_OBS = 1 # dimension, can be omitted + _PARAMS = ['b0_0', 'b0_1', 'b0_2', + 'bplus_0', 'bplus_1', 'bplus_2', + 'bT_0', 'bT_1', 'bT_2', + 'rho_mass', 'rho_scale', 'rho_phase', 'rho_width', + 'jpsi_mass', 'jpsi_scale', 'jpsi_phase', 'jpsi_width', + 'psi2s_mass', 'psi2s_scale', 'psi2s_phase', 'psi2s_width', + 'p3770_mass', 'p3770_scale', 'p3770_phase', 'p3770_width', + 'p4040_mass', 'p4040_scale', 'p4040_phase', 'p4040_width', + 'p4160_mass', 'p4160_scale', 'p4160_phase', 'p4160_width', + 'p4415_mass', 'p4415_scale', 'p4415_phase', 'p4415_width', + 'omega_mass', 'omega_scale', 'omega_phase', 'omega_width', + 'phi_mass', 'phi_scale', 'phi_phase', 'phi_width', + 'Dbar_mass', 'Dbar_scale', 'Dbar_phase', + 'Dstar_mass', 'DDstar_scale', 'DDstar_phase', 'D_mass', + 'tau_mass', 'C_tt'] +# the name of the parameters + + def _unnormalized_pdf(self, x): + + x = x.unstack_x() + + b0 = [self.params['b0_0'], self.params['b0_1'], self.params['b0_2']] + bplus = [self.params['bplus_0'], self.params['bplus_1'], self.params['bplus_2']] + bT = [self.params['bT_0'], self.params['bT_1'], self.params['bT_2']] + + def rho_res(q): + return resonance(q, _mass = self.params['rho_mass'], scale = self.params['rho_scale'], + phase = self.params['rho_phase'], width = self.params['rho_width']) + + def omega_res(q): + return resonance(q, _mass = self.params['omega_mass'], scale = self.params['omega_scale'], + phase = self.params['omega_phase'], width = self.params['omega_width']) + + def phi_res(q): + return resonance(q, _mass = self.params['phi_mass'], scale = self.params['phi_scale'], + phase = self.params['phi_phase'], width = self.params['phi_width']) + + def jpsi_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['jpsi_mass'], 2)) * resonance(q, _mass = self.params['jpsi_mass'], + scale = self.params['jpsi_scale'], + phase = self.params['jpsi_phase'], + width = self.params['jpsi_width']) + def psi2s_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['psi2s_mass'], 2)) * resonance(q, _mass = self.params['psi2s_mass'], + scale = self.params['psi2s_scale'], + phase = self.params['psi2s_phase'], + width = self.params['psi2s_width']) + def p3770_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p3770_mass'], 2)) * resonance(q, _mass = self.params['p3770_mass'], + scale = self.params['p3770_scale'], + phase = self.params['p3770_phase'], + width = self.params['p3770_width']) + + def p4040_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4040_mass'], 2)) * resonance(q, _mass = self.params['p4040_mass'], + scale = self.params['p4040_scale'], + phase = self.params['p4040_phase'], + width = self.params['p4040_width']) + + def p4160_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4160_mass'], 2)) * resonance(q, _mass = self.params['p4160_mass'], + scale = self.params['p4160_scale'], + phase = self.params['p4160_phase'], + width = self.params['p4160_width']) + + def p4415_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4415_mass'], 2)) * resonance(q, _mass = self.params['p4415_mass'], + scale = self.params['p4415_scale'], + phase = self.params['p4415_phase'], + width = self.params['p4415_width']) + + def P2_D(q): + Dbar_contrib = ztf.to_complex(self.params['Dbar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['Dbar_phase']))*ztf.to_complex(h_S(self.params['Dbar_mass'], q)) + DDstar_contrib = ztf.to_complex(self.params['DDstar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['DDstar_phase']))*(ztf.to_complex(h_P(self.params['Dstar_mass'], q)) + ztf.to_complex(h_P(self.params['D_mass'], q))) + return Dbar_contrib + DDstar_contrib + + def ttau_cusp(q): + return ztf.to_complex(self.params['C_tt'])*(ztf.to_complex((h_S(self.params['tau_mass'], q))) - ztf.to_complex(h_P(self.params['tau_mass'], q))) + + + funcs = rho_res(x) + omega_res(x) + phi_res(x) + jpsi_res(x) + psi2s_res(x) + p3770_res(x) + p4040_res(x)+ p4160_res(x) + p4415_res(x) + P2_D(x) + ttau_cusp(x) + + vec_f = vec(x, funcs, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + axiv_nr = axiv_nonres(x, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + tot = vec_f + axiv_nr + + #Cut out jpsi and psi2s + + tot = tf.where(tf.math.logical_or(x < ztf.constant(jpsi_mass-60.), x > ztf.constant(jpsi_mass+70.)), tot, 0.0*tot) + + tot = tf.where(tf.math.logical_or(x < ztf.constant(psi2s_mass-50.), x > ztf.constant(psi2s_mass+50.)), tot, 0.0*tot) + + return tot + +class total_pdf_full(zfit.pdf.ZPDF): + _N_OBS = 1 # dimension, can be omitted + _PARAMS = ['b0_0', 'b0_1', 'b0_2', + 'bplus_0', 'bplus_1', 'bplus_2', + 'bT_0', 'bT_1', 'bT_2', + 'rho_mass', 'rho_scale', 'rho_phase', 'rho_width', + 'jpsi_mass', 'jpsi_scale', 'jpsi_phase', 'jpsi_width', + 'psi2s_mass', 'psi2s_scale', 'psi2s_phase', 'psi2s_width', + 'p3770_mass', 'p3770_scale', 'p3770_phase', 'p3770_width', + 'p4040_mass', 'p4040_scale', 'p4040_phase', 'p4040_width', + 'p4160_mass', 'p4160_scale', 'p4160_phase', 'p4160_width', + 'p4415_mass', 'p4415_scale', 'p4415_phase', 'p4415_width', + 'omega_mass', 'omega_scale', 'omega_phase', 'omega_width', + 'phi_mass', 'phi_scale', 'phi_phase', 'phi_width', + 'Dbar_mass', 'Dbar_scale', 'Dbar_phase', + 'Dstar_mass', 'DDstar_scale', 'DDstar_phase', 'D_mass', + 'tau_mass', 'C_tt'] +# the name of the parameters + + def _unnormalized_pdf(self, x): + + x = x.unstack_x() + + b0 = [self.params['b0_0'], self.params['b0_1'], self.params['b0_2']] + bplus = [self.params['bplus_0'], self.params['bplus_1'], self.params['bplus_2']] + bT = [self.params['bT_0'], self.params['bT_1'], self.params['bT_2']] + + def rho_res(q): + return resonance(q, _mass = self.params['rho_mass'], scale = self.params['rho_scale'], + phase = self.params['rho_phase'], width = self.params['rho_width']) + + def omega_res(q): + return resonance(q, _mass = self.params['omega_mass'], scale = self.params['omega_scale'], + phase = self.params['omega_phase'], width = self.params['omega_width']) + + def phi_res(q): + return resonance(q, _mass = self.params['phi_mass'], scale = self.params['phi_scale'], + phase = self.params['phi_phase'], width = self.params['phi_width']) + + def jpsi_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['jpsi_mass'], 2)) * resonance(q, _mass = self.params['jpsi_mass'], + scale = self.params['jpsi_scale'], + phase = self.params['jpsi_phase'], + width = self.params['jpsi_width']) + def psi2s_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['psi2s_mass'], 2)) * resonance(q, _mass = self.params['psi2s_mass'], + scale = self.params['psi2s_scale'], + phase = self.params['psi2s_phase'], + width = self.params['psi2s_width']) + def p3770_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p3770_mass'], 2)) * resonance(q, _mass = self.params['p3770_mass'], + scale = self.params['p3770_scale'], + phase = self.params['p3770_phase'], + width = self.params['p3770_width']) + + def p4040_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4040_mass'], 2)) * resonance(q, _mass = self.params['p4040_mass'], + scale = self.params['p4040_scale'], + phase = self.params['p4040_phase'], + width = self.params['p4040_width']) + + def p4160_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4160_mass'], 2)) * resonance(q, _mass = self.params['p4160_mass'], + scale = self.params['p4160_scale'], + phase = self.params['p4160_phase'], + width = self.params['p4160_width']) + + def p4415_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4415_mass'], 2)) * resonance(q, _mass = self.params['p4415_mass'], + scale = self.params['p4415_scale'], + phase = self.params['p4415_phase'], + width = self.params['p4415_width']) + + def P2_D(q): + Dbar_contrib = ztf.to_complex(self.params['Dbar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['Dbar_phase']))*ztf.to_complex(h_S(self.params['Dbar_mass'], q)) + DDstar_contrib = ztf.to_complex(self.params['DDstar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['DDstar_phase']))*(ztf.to_complex(h_P(self.params['Dstar_mass'], q)) + ztf.to_complex(h_P(self.params['D_mass'], q))) + return Dbar_contrib + DDstar_contrib + + def ttau_cusp(q): + return ztf.to_complex(self.params['C_tt'])*(ztf.to_complex((h_S(self.params['tau_mass'], q))) - ztf.to_complex(h_P(self.params['tau_mass'], q))) + + + funcs = rho_res(x) + omega_res(x) + phi_res(x) + jpsi_res(x) + psi2s_res(x) + p3770_res(x) + p4040_res(x)+ p4160_res(x) + p4415_res(x) + P2_D(x) + ttau_cusp(x) + + vec_f = vec(x, funcs, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + axiv_nr = axiv_nonres(x, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + tot = vec_f + axiv_nr + + #Cut out jpsi and psi2s + +# tot = tf.where(tf.math.logical_or(x < ztf.constant(jpsi_mass-60.), x > ztf.constant(jpsi_mass+70.)), tot, 0.0*tot) + +# tot = tf.where(tf.math.logical_or(x < ztf.constant(psi2s_mass-50.), x > ztf.constant(psi2s_mass+50.)), tot, 0.0*tot) + + return tot + + +# ## Setup parameters + +# In[ ]: + + +# formfactors + +b0_0 = zfit.Parameter("b0_0", ztf.constant(0.292), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +b0_1 = zfit.Parameter("b0_1", ztf.constant(0.281), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +b0_2 = zfit.Parameter("b0_2", ztf.constant(0.150), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) + +bplus_0 = zfit.Parameter("bplus_0", ztf.constant(0.466), lower_limit = -2.0, upper_limit= 2.0) +bplus_1 = zfit.Parameter("bplus_1", ztf.constant(-0.885), lower_limit = -2.0, upper_limit= 2.0) +bplus_2 = zfit.Parameter("bplus_2", ztf.constant(-0.213), lower_limit = -2.0, upper_limit= 2.0) + +bT_0 = zfit.Parameter("bT_0", ztf.constant(0.460), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +bT_1 = zfit.Parameter("bT_1", ztf.constant(-1.089), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +bT_2 = zfit.Parameter("bT_2", ztf.constant(-1.114), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) + + +#rho + +rho_mass, rho_width, rho_phase, rho_scale = pdg["rho"] + +rho_m = zfit.Parameter("rho_m", ztf.constant(rho_mass), floating = False) #lower_limit = rho_mass - rho_width, upper_limit = rho_mass + rho_width) +rho_w = zfit.Parameter("rho_w", ztf.constant(rho_width), floating = False) +rho_p = zfit.Parameter("rho_p", ztf.constant(rho_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +rho_s = zfit.Parameter("rho_s", ztf.constant(rho_scale), lower_limit=rho_scale-np.sqrt(rho_scale), upper_limit=rho_scale+np.sqrt(rho_scale)) + +#omega + +omega_mass, omega_width, omega_phase, omega_scale = pdg["omega"] + +omega_m = zfit.Parameter("omega_m", ztf.constant(omega_mass), floating = False) +omega_w = zfit.Parameter("omega_w", ztf.constant(omega_width), floating = False) +omega_p = zfit.Parameter("omega_p", ztf.constant(omega_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +omega_s = zfit.Parameter("omega_s", ztf.constant(omega_scale), lower_limit=omega_scale-np.sqrt(omega_scale), upper_limit=omega_scale+np.sqrt(omega_scale)) + + +#phi + +phi_mass, phi_width, phi_phase, phi_scale = pdg["phi"] + +phi_m = zfit.Parameter("phi_m", ztf.constant(phi_mass), floating = False) +phi_w = zfit.Parameter("phi_w", ztf.constant(phi_width), floating = False) +phi_p = zfit.Parameter("phi_p", ztf.constant(phi_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +phi_s = zfit.Parameter("phi_s", ztf.constant(phi_scale), lower_limit=phi_scale-np.sqrt(phi_scale), upper_limit=phi_scale+np.sqrt(phi_scale)) + +#jpsi + +jpsi_mass, jpsi_width, jpsi_phase, jpsi_scale = pdg["jpsi"] + +jpsi_m = zfit.Parameter("jpsi_m", ztf.constant(jpsi_mass), floating = False) +jpsi_w = zfit.Parameter("jpsi_w", ztf.constant(jpsi_width), floating = False) +jpsi_p = zfit.Parameter("jpsi_p", ztf.constant(jpsi_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +jpsi_s = zfit.Parameter("jpsi_s", ztf.constant(jpsi_scale), floating = False) #, lower_limit=jpsi_scale-np.sqrt(jpsi_scale), upper_limit=jpsi_scale+np.sqrt(jpsi_scale)) + +#psi2s + +psi2s_mass, psi2s_width, psi2s_phase, psi2s_scale = pdg["psi2s"] + +psi2s_m = zfit.Parameter("psi2s_m", ztf.constant(psi2s_mass), floating = False) +psi2s_w = zfit.Parameter("psi2s_w", ztf.constant(psi2s_width), floating = False) +psi2s_p = zfit.Parameter("psi2s_p", ztf.constant(psi2s_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +psi2s_s = zfit.Parameter("psi2s_s", ztf.constant(psi2s_scale), floating = False) #, lower_limit=psi2s_scale-np.sqrt(psi2s_scale), upper_limit=psi2s_scale+np.sqrt(psi2s_scale)) + +#psi(3770) + +p3770_mass, p3770_width, p3770_phase, p3770_scale = pdg["p3770"] + +p3770_m = zfit.Parameter("p3770_m", ztf.constant(p3770_mass), floating = False) +p3770_w = zfit.Parameter("p3770_w", ztf.constant(p3770_width), floating = False) +p3770_p = zfit.Parameter("p3770_p", ztf.constant(p3770_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p3770_s = zfit.Parameter("p3770_s", ztf.constant(p3770_scale), lower_limit=p3770_scale-np.sqrt(p3770_scale), upper_limit=p3770_scale+np.sqrt(p3770_scale)) + +#psi(4040) + +p4040_mass, p4040_width, p4040_phase, p4040_scale = pdg["p4040"] + +p4040_m = zfit.Parameter("p4040_m", ztf.constant(p4040_mass), floating = False) +p4040_w = zfit.Parameter("p4040_w", ztf.constant(p4040_width), floating = False) +p4040_p = zfit.Parameter("p4040_p", ztf.constant(p4040_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p4040_s = zfit.Parameter("p4040_s", ztf.constant(p4040_scale), lower_limit=p4040_scale-np.sqrt(p4040_scale), upper_limit=p4040_scale+np.sqrt(p4040_scale)) + +#psi(4160) + +p4160_mass, p4160_width, p4160_phase, p4160_scale = pdg["p4160"] + +p4160_m = zfit.Parameter("p4160_m", ztf.constant(p4160_mass), floating = False) +p4160_w = zfit.Parameter("p4160_w", ztf.constant(p4160_width), floating = False) +p4160_p = zfit.Parameter("p4160_p", ztf.constant(p4160_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p4160_s = zfit.Parameter("p4160_s", ztf.constant(p4160_scale), lower_limit=p4160_scale-np.sqrt(p4160_scale), upper_limit=p4160_scale+np.sqrt(p4160_scale)) + +#psi(4415) + +p4415_mass, p4415_width, p4415_phase, p4415_scale = pdg["p4415"] + +p4415_m = zfit.Parameter("p4415_m", ztf.constant(p4415_mass), floating = False) +p4415_w = zfit.Parameter("p4415_w", ztf.constant(p4415_width), floating = False) +p4415_p = zfit.Parameter("p4415_p", ztf.constant(p4415_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p4415_s = zfit.Parameter("p4415_s", ztf.constant(p4415_scale), lower_limit=p4415_scale-np.sqrt(p4415_scale), upper_limit=p4415_scale+np.sqrt(p4415_scale)) + + +# ## Dynamic generation of 2 particle contribution + +# In[ ]: + + +m_c = 1300 + +Dbar_phase = 0.0 +DDstar_phase = 0.0 +Dstar_mass = pdg['Dst_M'] +Dbar_mass = pdg['D0_M'] +D_mass = pdg['D0_M'] + +Dbar_s = zfit.Parameter("Dbar_s", ztf.constant(0.0), lower_limit=-0.3, upper_limit=0.3) +Dbar_m = zfit.Parameter("Dbar_m", ztf.constant(Dbar_mass), floating = False) +Dbar_p = zfit.Parameter("Dbar_p", ztf.constant(Dbar_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi)#, floating = False) +DDstar_s = zfit.Parameter("DDstar_s", ztf.constant(0.0), lower_limit=-0.3, upper_limit=0.3)#, floating = False) +Dstar_m = zfit.Parameter("Dstar_m", ztf.constant(Dstar_mass), floating = False) +D_m = zfit.Parameter("D_m", ztf.constant(D_mass), floating = False) +DDstar_p = zfit.Parameter("DDstar_p", ztf.constant(DDstar_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi)#, floating = False) + + +# ## Tau parameters + +# In[ ]: + + +tau_m = zfit.Parameter("tau_m", ztf.constant(pdg['tau_M']), floating = False) +Ctt = zfit.Parameter("Ctt", ztf.constant(0.0), lower_limit=-2.5, upper_limit=2.5) + + +# ## Load data + +# In[ ]: + + +x_min = 2*pdg['muon_M'] +x_max = (pdg["Bplus_M"]-pdg["Ks_M"]-0.1) + +# # Full spectrum + +obs_toy = zfit.Space('q', limits = (x_min, x_max)) + +# Jpsi and Psi2s cut out + +obs1 = zfit.Space('q', limits = (x_min, jpsi_mass - 60.)) +obs2 = zfit.Space('q', limits = (jpsi_mass + 70., psi2s_mass - 50.)) +obs3 = zfit.Space('q', limits = (psi2s_mass + 50., x_max)) + +obs_fit = obs1 + obs2 + obs3 + +# with open(r"./data/slim_points/slim_points_toy_0_range({0}-{1}).pkl".format(int(x_min), int(x_max)), "rb") as input_file: +# part_set = pkl.load(input_file) + +# x_part = part_set['x_part'] + +# x_part = x_part.astype('float64') + +# data = zfit.data.Data.from_numpy(array=x_part, obs=obs) + + +# ## Setup pdf + +# In[ ]: + + +total_f = total_pdf_cut(obs=obs_toy, jpsi_mass = jpsi_m, jpsi_scale = jpsi_s, jpsi_phase = jpsi_p, jpsi_width = jpsi_w, + psi2s_mass = psi2s_m, psi2s_scale = psi2s_s, psi2s_phase = psi2s_p, psi2s_width = psi2s_w, + p3770_mass = p3770_m, p3770_scale = p3770_s, p3770_phase = p3770_p, p3770_width = p3770_w, + p4040_mass = p4040_m, p4040_scale = p4040_s, p4040_phase = p4040_p, p4040_width = p4040_w, + p4160_mass = p4160_m, p4160_scale = p4160_s, p4160_phase = p4160_p, p4160_width = p4160_w, + p4415_mass = p4415_m, p4415_scale = p4415_s, p4415_phase = p4415_p, p4415_width = p4415_w, + rho_mass = rho_m, rho_scale = rho_s, rho_phase = rho_p, rho_width = rho_w, + omega_mass = omega_m, omega_scale = omega_s, omega_phase = omega_p, omega_width = omega_w, + phi_mass = phi_m, phi_scale = phi_s, phi_phase = phi_p, phi_width = phi_w, + Dstar_mass = Dstar_m, DDstar_scale = DDstar_s, DDstar_phase = DDstar_p, D_mass = D_m, + Dbar_mass = Dbar_m, Dbar_scale = Dbar_s, Dbar_phase = Dbar_p, + tau_mass = tau_m, C_tt = Ctt, b0_0 = b0_0, b0_1 = b0_1, b0_2 = b0_2, + bplus_0 = bplus_0, bplus_1 = bplus_1, bplus_2 = bplus_2, + bT_0 = bT_0, bT_1 = bT_1, bT_2 = bT_2) + +total_f_fit = total_pdf_full(obs=obs_fit, jpsi_mass = jpsi_m, jpsi_scale = jpsi_s, jpsi_phase = jpsi_p, jpsi_width = jpsi_w, + psi2s_mass = psi2s_m, psi2s_scale = psi2s_s, psi2s_phase = psi2s_p, psi2s_width = psi2s_w, + p3770_mass = p3770_m, p3770_scale = p3770_s, p3770_phase = p3770_p, p3770_width = p3770_w, + p4040_mass = p4040_m, p4040_scale = p4040_s, p4040_phase = p4040_p, p4040_width = p4040_w, + p4160_mass = p4160_m, p4160_scale = p4160_s, p4160_phase = p4160_p, p4160_width = p4160_w, + p4415_mass = p4415_m, p4415_scale = p4415_s, p4415_phase = p4415_p, p4415_width = p4415_w, + rho_mass = rho_m, rho_scale = rho_s, rho_phase = rho_p, rho_width = rho_w, + omega_mass = omega_m, omega_scale = omega_s, omega_phase = omega_p, omega_width = omega_w, + phi_mass = phi_m, phi_scale = phi_s, phi_phase = phi_p, phi_width = phi_w, + Dstar_mass = Dstar_m, DDstar_scale = DDstar_s, DDstar_phase = DDstar_p, D_mass = D_m, + Dbar_mass = Dbar_m, Dbar_scale = Dbar_s, Dbar_phase = Dbar_p, + tau_mass = tau_m, C_tt = Ctt, b0_0 = b0_0, b0_1 = b0_1, b0_2 = b0_2, + bplus_0 = bplus_0, bplus_1 = bplus_1, bplus_2 = bplus_2, + bT_0 = bT_0, bT_1 = bT_1, bT_2 = bT_2) + +# print(total_pdf.obs) + +# print(calcs_test) + +# for param in total_f.get_dependents(): +# print(zfit.run(param)) + + +# In[ ]: + + +# total_f_fit.normalization(obs_fit) + + +# ## Test if graphs actually work and compute values + +# In[ ]: + + +# def total_test_tf(xq): + +# def jpsi_res(q): +# return resonance(q, jpsi_m, jpsi_s, jpsi_p, jpsi_w) + +# def psi2s_res(q): +# return resonance(q, psi2s_m, psi2s_s, psi2s_p, psi2s_w) + +# def cusp(q): +# return bifur_gauss(q, cusp_m, sig_L, sig_R, cusp_s) + +# funcs = jpsi_res(xq) + psi2s_res(xq) + cusp(xq) + +# vec_f = vec(xq, funcs) + +# axiv_nr = axiv_nonres(xq) + +# tot = vec_f + axiv_nr + +# return tot + +# def jpsi_res(q): +# return resonance(q, jpsi_m, jpsi_s, jpsi_p, jpsi_w) + +# calcs = zfit.run(total_test_tf(x_part)) + + + +test_q = np.linspace(x_min, x_max, int(2e6)) + +probs = total_f_fit.pdf(test_q, norm_range=False) + +calcs_test = zfit.run(probs) + +Ctt.set_value(0.5) + +calcs_test1 = zfit.run(probs) + +Ctt.set_value(0.0) + +Dbar_s.set_value(0.3) + +DDstar_s.set_value(0.3) + +calcs_test2 = zfit.run(probs) +# res_y = zfit.run(jpsi_res(test_q)) +# b0 = [b0_0, b0_1, b0_2] +# bplus = [bplus_0, bplus_1, bplus_2] +# bT = [bT_0, bT_1, bT_2] +# f0_y = zfit.run(tf.math.real(formfactor(test_q,"0", b0, bplus, bT))) +# fplus_y = zfit.run(tf.math.real(formfactor(test_q,"+", b0, bplus, bT))) +# fT_y = zfit.run(tf.math.real(formfactor(test_q,"T", b0, bplus, bT))) + + +# In[ ]: + + +plt.clf() +# plt.plot(x_part, calcs, '.') +plt.plot(test_q, calcs_test, label = 'pdf (Ctt = 0.0)') +plt.plot(test_q, calcs_test1, label = 'pdf (Ctt = 0.5)') +plt.plot(test_q, calcs_test2, label = 'pdf (D-contribs = 0.3)') +# plt.plot(test_q, f0_y, label = '0') +# plt.plot(test_q, fT_y, label = 'T') +# plt.plot(test_q, fplus_y, label = '+') +# plt.plot(test_q, res_y, label = 'res') +plt.legend() +plt.ylim(0.0, 1.5e-6) +# plt.yscale('log') +# plt.xlim(770, 785) +plt.savefig('test.png') +# print(jpsi_width) + + +# In[ ]: + + + + +# probs = mixture.prob(test_q) +# probs_np = zfit.run(probs) +# probs_np *= np.max(calcs_test) / np.max(probs_np) +# plt.figure() +# plt.semilogy(test_q, probs_np,label="importance sampling") +# plt.semilogy(test_q, calcs_test, label = 'pdf') + + +# In[ ]: + + +# 0.213/(0.00133+0.213+0.015) + + +# ## Adjust scaling of different parts + +# In[ ]: + + +total_f.update_integration_options(draws_per_dim=2000000, mc_sampler=None) +# inte = total_f.integrate(limits = (950., 1050.), norm_range=False) +# inte_fl = zfit.run(inte) +# print(inte_fl/4500) +# print(pdg["jpsi_BR"]/pdg["NR_BR"], inte_fl*pdg["psi2s_auc"]/pdg["NR_auc"]) + + +# In[ ]: + + +# # print("jpsi:", inte_fl) +# # print("Increase am by factor:", np.sqrt(pdg["jpsi_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) +# # print("New amp:", pdg["jpsi"][3]*np.sqrt(pdg["jpsi_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) + +# # print("psi2s:", inte_fl) +# # print("Increase am by factor:", np.sqrt(pdg["psi2s_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) +# # print("New amp:", pdg["psi2s"][3]*np.sqrt(pdg["psi2s_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) + +# name = "phi" + +# print(name+":", inte_fl) +# print("Increase am by factor:", np.sqrt(pdg[name+"_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) +# print("New amp:", pdg[name][0]*np.sqrt(pdg[name+"_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) + + +# print(x_min) +# print(x_max) +# # total_f.update_integration_options(draws_per_dim=2000000, mc_sampler=None) +# total_f.update_integration_options(mc_sampler=lambda dim, num_results, +# dtype: tf.random_uniform(maxval=1., shape=(num_results, dim), dtype=dtype), +# draws_per_dim=1000000) +# # _ = [] + +# # for i in range(10): + +# # inte = total_f.integrate(limits = (x_min, x_max)) +# # inte_fl = zfit.run(inte) +# # print(inte_fl) +# # _.append(inte_fl) + +# # print("mean:", np.mean(_)) + +# _ = time.time() + +# inte = total_f.integrate(limits = (x_min, x_max)) +# inte_fl = zfit.run(inte) +# print(inte_fl) +# print("Time taken: {}".format(display_time(int(time.time() - _)))) + +# print(pdg['NR_BR']/pdg['NR_auc']*inte_fl) +# print(0.25**2*4.2/1000) + + +# # Sampling +# ## Mixture distribution for sampling + +# In[ ]: + + + + +# print(list_of_borders[:9]) +# print(list_of_borders[-9:]) + + +class UniformSampleAndWeights(zfit.util.execution.SessionHolderMixin): + def __call__(self, limits, dtype, n_to_produce): + # n_to_produce = tf.cast(n_to_produce, dtype=tf.int32) + low, high = limits.limit1d + low = tf.cast(low, dtype=dtype) + high = tf.cast(high, dtype=dtype) +# uniform = tfd.Uniform(low=low, high=high) +# uniformjpsi = tfd.Uniform(low=tf.constant(3080, dtype=dtype), high=tf.constant(3112, dtype=dtype)) +# uniformpsi2s = tfd.Uniform(low=tf.constant(3670, dtype=dtype), high=tf.constant(3702, dtype=dtype)) + +# list_of_borders = [] +# _p = [] +# splits = 10 + +# _ = np.linspace(x_min, x_max, splits) + +# for i in range(splits): +# list_of_borders.append(tf.constant(_[i], dtype=dtype)) +# _p.append(tf.constant(1/splits, dtype=dtype)) + +# mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=_p[:(splits-1)]), +# components_distribution=tfd.Uniform(low=list_of_borders[:(splits-1)], +# high=list_of_borders[-(splits-1):])) + mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=[tf.constant(0.05, dtype=dtype), + tf.constant(0.93, dtype=dtype), + tf.constant(0.05, dtype=dtype), + tf.constant(0.065, dtype=dtype), + tf.constant(0.04, dtype=dtype), + tf.constant(0.05, dtype=dtype)]), + components_distribution=tfd.Uniform(low=[tf.constant(x_min, dtype=dtype), + tf.constant(3090, dtype=dtype), + tf.constant(3681, dtype=dtype), + tf.constant(3070, dtype=dtype), + tf.constant(1000, dtype=dtype), + tf.constant(3660, dtype=dtype)], + high=[tf.constant(x_max, dtype=dtype), + tf.constant(3102, dtype=dtype), + tf.constant(3691, dtype=dtype), + tf.constant(3110, dtype=dtype), + tf.constant(1040, dtype=dtype), + tf.constant(3710, dtype=dtype)])) +# dtype = tf.float64 +# mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=[tf.constant(0.04, dtype=dtype), +# tf.constant(0.90, dtype=dtype), +# tf.constant(0.02, dtype=dtype), +# tf.constant(0.07, dtype=dtype), +# tf.constant(0.02, dtype=dtype)]), +# components_distribution=tfd.Uniform(low=[tf.constant(x_min, dtype=dtype), +# tf.constant(3089, dtype=dtype), +# tf.constant(3103, dtype=dtype), +# tf.constant(3681, dtype=dtype), +# tf.constant(3691, dtype=dtype)], +# high=[tf.constant(3089, dtype=dtype), +# tf.constant(3103, dtype=dtype), +# tf.constant(3681, dtype=dtype), +# tf.constant(3691, dtype=dtype), +# tf.constant(x_max, dtype=dtype)])) +# mixture = tfd.Uniform(tf.constant(x_min, dtype=dtype), tf.constant(x_max, dtype=dtype)) +# sample = tf.random.uniform((n_to_produce, 1), dtype=dtype) + sample = mixture.sample((n_to_produce, 1)) +# sample = tf.random.uniform((n_to_produce, 1), dtype=dtype) + weights = mixture.prob(sample)[:,0] +# weights = tf.broadcast_to(tf.constant(1., dtype=dtype), shape=(n_to_produce,)) + # sample = tf.expand_dims(sample, axis=-1) +# print(sample, weights) + +# weights = tf.ones(shape=(n_to_produce,), dtype=dtype) + weights_max = None + thresholds = tf.random_uniform(shape=(n_to_produce,), dtype=dtype) + return sample, thresholds, weights, weights_max, n_to_produce + + +# In[ ]: + + +# total_f._sample_and_weights = UniformSampleAndWeights + + +# In[ ]: + + +# 0.00133/(0.00133+0.213+0.015)*(x_max-3750)/(x_max-x_min) + + +# In[ ]: + + +# zfit.settings.set_verbosity(10) + + +# In[ ]: + + +# # zfit.run.numeric_checks = False + +# nr_of_toys = 1 +# nevents = int(pdg["number_of_decays"]) +# nevents = pdg["number_of_decays"] +# event_stack = 1000000 +# # zfit.settings.set_verbosity(10) +# calls = int(nevents/event_stack + 1) + +# total_samp = [] + +# start = time.time() + +# sampler = total_f.create_sampler(n=event_stack) + +# for toy in range(nr_of_toys): + +# dirName = 'data/zfit_toys/toy_{0}'.format(toy) + +# if not os.path.exists(dirName): +# os.mkdir(dirName) +# print("Directory " , dirName , " Created ") + +# for call in range(calls): + +# sampler.resample(n=event_stack) +# s = sampler.unstack_x() +# sam = zfit.run(s) +# # clear_output(wait=True) + +# c = call + 1 + +# print("{0}/{1} of Toy {2}/{3}".format(c, calls, toy+1, nr_of_toys)) +# print("Time taken: {}".format(display_time(int(time.time() - start)))) +# print("Projected time left: {}".format(display_time(int((time.time() - start)/(c+calls*(toy))*((nr_of_toys-toy)*calls-c))))) + +# with open("data/zfit_toys/toy_{0}/{1}.pkl".format(toy, call), "wb") as f: +# pkl.dump(sam, f, pkl.HIGHEST_PROTOCOL) + + +# In[ ]: + + +# with open(r"data/zfit_toys/toy_0/0.pkl", "rb") as input_file: +# sam = pkl.load(input_file) +# print(sam[:10]) + +# with open(r"data/zfit_toys/toy_0/1.pkl", "rb") as input_file: +# sam2 = pkl.load(input_file) +# print(sam2[:10]) + +# print(np.sum(sam-sam2)) + + +# In[ ]: + + +# print("Time to generate full toy: {} s".format(int(time.time()-start))) + +# total_samp = [] + +# for call in range(calls): +# with open(r"data/zfit_toys/toy_0/{}.pkl".format(call), "rb") as input_file: +# sam = pkl.load(input_file) +# total_samp = np.append(total_samp, sam) + +# total_samp = total_samp.astype('float64') + +# data2 = zfit.data.Data.from_numpy(array=total_samp[:int(nevents)], obs=obs) + +# data3 = zfit.data.Data.from_numpy(array=total_samp, obs=obs) + +# print(total_samp[:nevents].shape) + + +# In[ ]: + + +# plt.clf() + +# bins = int((x_max-x_min)/7) + +# # calcs = zfit.run(total_test_tf(samp)) +# print(total_samp[:nevents].shape) + +# plt.hist(total_samp[:nevents], bins = bins, range = (x_min,x_max), label = 'data') +# # plt.plot(test_q, calcs_test*nevents , label = 'pdf') + +# # plt.plot(sam, calcs, '.') +# # plt.plot(test_q, calcs_test) +# # plt.yscale('log') +# plt.ylim(0, 200) +# # plt.xlim(3080, 3110) + +# plt.legend() + +# plt.savefig('test2.png') + + +# In[ ]: + + +# sampler = total_f.create_sampler(n=nevents) +# nll = zfit.loss.UnbinnedNLL(model=total_f, data=sampler, fit_range = (x_min, x_max)) + +# # for param in pdf.get_dependents(): +# # param.set_value(initial_value) + +# sampler.resample(n=nevents) + +# # Randomise initial values +# # for param in pdf.get_dependents(): +# # param.set_value(random value here) + +# # Minimise the NLL +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 10) +# minimum = minimizer.minimize(nll) + + +# In[ ]: + + +# jpsi_width + + +# In[ ]: + + +# plt.hist(sample, weights=1 / prob(sample)) + + +# # Fitting + +# In[ ]: + + +# start = time.time() + +# for param in total_f.get_dependents(): +# param.randomize() + +# # for param in total_f.get_dependents(): +# # print(zfit.run(param)) + +# nll = zfit.loss.UnbinnedNLL(model=total_f, data=data2, fit_range = (x_min, x_max)) + +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) +# # minimizer._use_tfgrad = False +# result = minimizer.minimize(nll) + +# # param_errors = result.error() + +# # for var, errors in param_errors.items(): +# # print('{}: ^{{+{}}}_{{{}}}'.format(var.name, errors['upper'], errors['lower'])) + +# print("Function minimum:", result.fmin) +# # print("Results:", result.params) +# print("Hesse errors:", result.hesse()) + + +# In[ ]: + + +# print("Time taken for fitting: {}".format(display_time(int(time.time()-start)))) + +# # probs = total_f.pdf(test_q) + +# calcs_test = zfit.run(probs) +# res_y = zfit.run(jpsi_res(test_q)) + + +# In[ ]: + + +# plt.clf() +# # plt.plot(x_part, calcs, '.') +# plt.plot(test_q, calcs_test, label = 'pdf') +# # plt.plot(test_q, res_y, label = 'res') +# plt.legend() +# plt.ylim(0.0, 10e-6) +# # plt.yscale('log') +# # plt.xlim(3080, 3110) +# plt.savefig('test3.png') +# # print(jpsi_width) + + +# In[ ]: + + +# _tot = 4.37e-7+6.02e-5+4.97e-6 +# _probs = [] +# _probs.append(6.02e-5/_tot) +# _probs.append(4.97e-6/_tot) +# _probs.append(4.37e-7/_tot) +# print(_probs) + + +# In[ ]: + + +# dtype = 'float64' +# # mixture = tfd.Uniform(tf.constant(x_min, dtype=dtype), tf.constant(x_max, dtype=dtype)) +# mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=[tf.constant(0.007, dtype=dtype), +# tf.constant(0.917, dtype=dtype), +# tf.constant(0.076, dtype=dtype)]), +# components_distribution=tfd.Uniform(low=[tf.constant(x_min, dtype=dtype), +# tf.constant(3080, dtype=dtype), +# tf.constant(3670, dtype=dtype)], +# high=[tf.constant(x_max, dtype=dtype), +# tf.constant(3112, dtype=dtype), +# tf.constant(3702, dtype=dtype)])) +# # for i in range(10): +# # print(zfit.run(mixture.prob(mixture.sample((10, 1))))) + + +# In[ ]: + + +# print((zfit.run(jpsi_p)%(2*np.pi))/np.pi) +# print((zfit.run(psi2s_p)%(2*np.pi))/np.pi) + + +# In[ ]: + + +# def jpsi_res(q): +# return resonance(q, _mass = jpsi_mass, scale = jpsi_scale, +# phase = jpsi_phase, width = jpsi_width) + +# def psi2s_res(q): +# return resonance(q, _mass = psi2s_mass, scale = psi2s_scale, +# phase = psi2s_phase, width = psi2s_width) + +# def p3770_res(q): +# return resonance(q, _mass = p3770_mass, scale = p3770_scale, +# phase = p3770_phase, width = p3770_width) + +# def p4040_res(q): +# return resonance(q, _mass = p4040_mass, scale = p4040_scale, +# phase = p4040_phase, width = p4040_width) + +# def p4160_res(q): +# return resonance(q, _mass = p4160_mass, scale = p4160_scale, +# phase = p4160_phase, width = p4160_width) + +# def p4415_res(q): +# return resonance(q, _mass = p4415_mass, scale = p4415_scale, +# phase = p4415_phase, width = p4415_width) + + +# In[ ]: + + +# 0.15**2*4.2/1000 +# result.hesse() + + +# ## Constraints + +# In[ ]: + + +# 1. Constraint - Real part of sum of Psi contrib and D contribs + +sum_list = [] + +sum_list.append(ztf.to_complex(jpsi_s) * tf.exp(tf.complex(ztf.constant(0.0), jpsi_p)) * ztf.to_complex(jpsi_w / (tf.pow(jpsi_m,3)))) +sum_list.append(ztf.to_complex(psi2s_s) * tf.exp(tf.complex(ztf.constant(0.0), psi2s_p)) * ztf.to_complex(psi2s_w / (tf.pow(psi2s_m,3)))) +sum_list.append(ztf.to_complex(p3770_s) * tf.exp(tf.complex(ztf.constant(0.0), p3770_p)) * ztf.to_complex(p3770_w / (tf.pow(p3770_m,3)))) +sum_list.append(ztf.to_complex(p4040_s) * tf.exp(tf.complex(ztf.constant(0.0), p4040_p)) * ztf.to_complex(p4040_w / (tf.pow(p4040_m,3)))) +sum_list.append(ztf.to_complex(p4160_s) * tf.exp(tf.complex(ztf.constant(0.0), p4160_p)) * ztf.to_complex(p4160_w / (tf.pow(p4160_m,3)))) +sum_list.append(ztf.to_complex(p4415_s) * tf.exp(tf.complex(ztf.constant(0.0), p4415_p)) * ztf.to_complex(p4415_w / (tf.pow(p4415_m,3)))) +sum_list.append(ztf.to_complex(DDstar_s) * tf.exp(tf.complex(ztf.constant(0.0), DDstar_p)) * (ztf.to_complex(1.0 / (10.0*tf.pow(Dstar_m,2)) + 1.0 / (10.0*tf.pow(D_m,2))))) +sum_list.append(ztf.to_complex(Dbar_s) * tf.exp(tf.complex(ztf.constant(0.0), Dbar_p)) * ztf.to_complex(1.0 / (6.0*tf.pow(Dbar_m,2)))) + +sum_ru_1 = ztf.to_complex(ztf.constant(0.0)) + +for part in sum_list: + sum_ru_1 += part + +sum_1 = tf.math.real(sum_ru_1) +# constraint1 = zfit.constraint.GaussianConstraint(params = sum_1, mu = ztf.constant(1.7*10**-8), +# sigma = ztf.constant(2.2*10**-8)) + +constraint1 = tf.pow((sum_1-ztf.constant(1.7*10**-8))/ztf.constant(2.2*10**-8),2)/ztf.constant(2.) + +# 2. Constraint - Abs. of sum of Psi contribs and D contribs + +sum_2 = tf.abs(sum_ru_1) +constraint2 = tf.cond(tf.greater_equal(sum_2, 5.0e-8), lambda: 100000., lambda: 0.) + +# 3. Constraint - Maximum eta of D contribs + +constraint3_0 = tf.cond(tf.greater_equal(tf.abs(Dbar_s), 0.2), lambda: 100000., lambda: 0.) + +constraint3_1 = tf.cond(tf.greater_equal(tf.abs(DDstar_s), 0.2), lambda: 100000., lambda: 0.) + +# 4. Constraint - Formfactor multivariant gaussian covariance fplus + +Cov_matrix = [[ztf.constant( 1.), ztf.constant( 0.45), ztf.constant( 0.19), ztf.constant(0.857), ztf.constant(0.598), ztf.constant(0.531), ztf.constant(0.752), ztf.constant(0.229), ztf.constant(0,117)], + [ztf.constant( 0.45), ztf.constant( 1.), ztf.constant(0.677), ztf.constant(0.708), ztf.constant(0.958), ztf.constant(0.927), ztf.constant(0.227), ztf.constant(0.443), ztf.constant(0.287)], + [ztf.constant( 0.19), ztf.constant(0.677), ztf.constant( 1.), ztf.constant(0.595), ztf.constant(0.770), ztf.constant(0.819),ztf.constant(-0.023), ztf.constant( 0.07), ztf.constant(0.196)], + [ztf.constant(0.857), ztf.constant(0.708), ztf.constant(0.595), ztf.constant( 1.), ztf.constant( 0.83), ztf.constant(0.766), ztf.constant(0.582), ztf.constant(0.237), ztf.constant(0.192)], + [ztf.constant(0.598), ztf.constant(0.958), ztf.constant(0.770), ztf.constant( 0.83), ztf.constant( 1.), ztf.constant(0.973), ztf.constant(0.324), ztf.constant(0.372), ztf.constant(0.272)], + [ztf.constant(0.531), ztf.constant(0.927), ztf.constant(0.819), ztf.constant(0.766), ztf.constant(0.973), ztf.constant( 1.), ztf.constant(0.268), ztf.constant(0.332), ztf.constant(0.269)], + [ztf.constant(0.752), ztf.constant(0.227),ztf.constant(-0.023), ztf.constant(0.582), ztf.constant(0.324), ztf.constant(0.268), ztf.constant( 1.), ztf.constant( 0.59), ztf.constant(0.515)], + [ztf.constant(0.229), ztf.constant(0.443), ztf.constant( 0.07), ztf.constant(0.237), ztf.constant(0.372), ztf.constant(0.332), ztf.constant( 0.59), ztf.constant( 1.), ztf.constant(0.897)], + [ztf.constant(0.117), ztf.constant(0.287), ztf.constant(0.196), ztf.constant(0.192), ztf.constant(0.272), ztf.constant(0.269), ztf.constant(0.515), ztf.constant(0.897), ztf.constant( 1.)]] + +def triGauss(val1,val2,val3,m = Cov_matrix): + + mean1 = ztf.constant(0.466) + mean2 = ztf.constant(-0.885) + mean3 = ztf.constant(-0.213) + sigma1 = ztf.constant(0.014) + sigma2 = ztf.constant(0.128) + sigma3 = ztf.constant(0.548) + x1 = (val1-mean1)/sigma1 + x2 = (val2-mean2)/sigma2 + x3 = (val3-mean3)/sigma3 + rho12 = m[0][1] + rho13 = m[0][2] + rho23 = m[1][2] + w = x1*x1*(rho23*rho23-1) + x2*x2*(rho13*rho13-1)+x3*x3*(rho12*rho12-1)+2*(x1*x2*(rho12-rho13*rho23)+x1*x3*(rho13-rho12*rho23)+x2*x3*(rho23-rho12*rho13)) + d = 2*(rho12*rho12+rho13*rho13+rho23*rho23-2*rho12*rho13*rho23-1) + + fcn = -w/d + chisq = -2*fcn + return chisq + +constraint4 = triGauss(bplus_0, bplus_1, bplus_2) + +# mean1 = ztf.constant(0.466) +# mean2 = ztf.constant(-0.885) +# mean3 = ztf.constant(-0.213) +# sigma1 = ztf.constant(0.014) +# sigma2 = ztf.constant(0.128) +# sigma3 = ztf.constant(0.548) +# constraint4_0 = tf.pow((bplus_0-mean1)/sigma1,2)/ztf.constant(2.) +# constraint4_1 = tf.pow((bplus_1-mean2)/sigma2,2)/ztf.constant(2.) +# constraint4_2 = tf.pow((bplus_2-mean3)/sigma3,2)/ztf.constant(2.) + +# 5. Constraint - Abs. of sum of light contribs + +sum_list_5 = [] + +sum_list_5.append(rho_s*rho_w/rho_m) +sum_list_5.append(omega_s*omega_w/omega_m) +sum_list_5.append(phi_s*phi_w/phi_m) + + +sum_ru_5 = ztf.constant(0.0) + +for part in sum_list_5: + sum_ru_5 += part + +constraint5 = tf.cond(tf.greater_equal(tf.abs(sum_ru_5), ztf.constant(0.02)), lambda: 100000., lambda: 0.) + +# 6. Constraint on phases of Jpsi and Psi2s for cut out fit + + +# constraint6_0 = zfit.constraint.GaussianConstraint(params = jpsi_p, mu = ztf.constant(pdg["jpsi_phase_unc"]), +# sigma = ztf.constant(jpsi_phase)) +# constraint6_1 = zfit.constraint.GaussianConstraint(params = psi2s_p, mu = ztf.constant(pdg["psi2s_phase_unc"]), +# sigma = ztf.constant(psi2s_phase)) + +constraint6_0 = tf.pow((jpsi_p-ztf.constant(jpsi_phase))/ztf.constant(pdg["jpsi_phase_unc"]),2)/ztf.constant(2.) +constraint6_1 = tf.pow((psi2s_p-ztf.constant(psi2s_phase))/ztf.constant(pdg["psi2s_phase_unc"]),2)/ztf.constant(2.) + +# 7. Constraint on Ctt with higher limits + +constraint7 = tf.cond(tf.greater_equal(Ctt*Ctt, 0.25), lambda: 100000., lambda: 0.) + +constraint7dtype = tf.float64 + +# zfit.run(constraint6_0) + +# ztf.convert_to_tensor(constraint6_0) + +#List of all constraints + +constraints = [constraint1, constraint2, constraint3_0, constraint3_1,# constraint4, #constraint4_0, constraint4_1, constraint4_2, + constraint6_0, constraint6_1]#, constraint7] + + +# ## Reset params + +# In[ ]: + + +param_values_dic = { + 'jpsi_m': jpsi_mass, + 'jpsi_s': jpsi_scale, + 'jpsi_p': jpsi_phase, + 'jpsi_w': jpsi_width, + 'psi2s_m': psi2s_mass, + 'psi2s_s': psi2s_scale, + 'psi2s_p': psi2s_phase, + 'psi2s_w': psi2s_width, + 'p3770_m': p3770_mass, + 'p3770_s': p3770_scale, + 'p3770_p': p3770_phase, + 'p3770_w': p3770_width, + 'p4040_m': p4040_mass, + 'p4040_s': p4040_scale, + 'p4040_p': p4040_phase, + 'p4040_w': p4040_width, + 'p4160_m': p4160_mass, + 'p4160_s': p4160_scale, + 'p4160_p': p4160_phase, + 'p4160_w': p4160_width, + 'p4415_m': p4415_mass, + 'p4415_s': p4415_scale, + 'p4415_p': p4415_phase, + 'p4415_w': p4415_width, + 'rho_m': rho_mass, + 'rho_s': rho_scale, + 'rho_p': rho_phase, + 'rho_w': rho_width, + 'omega_m': omega_mass, + 'omega_s': omega_scale, + 'omega_p': omega_phase, + 'omega_w': omega_width, + 'phi_m': phi_mass, + 'phi_s': phi_scale, + 'phi_p': phi_phase, + 'phi_w': phi_width, + 'Dstar_m': Dstar_mass, + 'DDstar_s': 0.0, + 'DDstar_p': 0.0, + 'D_m': D_mass, + 'Dbar_m': Dbar_mass, + 'Dbar_s': 0.0, + 'Dbar_p': 0.0, + 'tau_m': pdg['tau_M'], + 'Ctt': 0.0, + 'b0_0': 0.292, + 'b0_1': 0.281, + 'b0_2': 0.150, + 'bplus_0': 0.466, + 'bplus_1': -0.885, + 'bplus_2': -0.213, + 'bT_0': 0.460, + 'bT_1': -1.089, + 'bT_2': -1.114} + + +def reset_param_values(variation = 0.05): + for param in total_f_fit.get_dependents(): + if param.floating: + param.set_value(param_values_dic[param.name] + random.uniform(-1, 1) * param_values_dic[param.name]* variation) +# print(param.name) +# for param in totalf.get_dependents(): +# param.set_value() + + +# # Analysis + +# In[ ]: + + +# # zfit.run.numeric_checks = False + +# fitting_range = 'cut' +# total_BR = 1.7e-10 + 4.9e-10 + 2.5e-9 + 6.02e-5 + 4.97e-6 + 1.38e-9 + 4.2e-10 + 2.6e-9 + 6.1e-10 + 4.37e-7 +# cut_BR = 1.0 - (6.02e-5 + 4.97e-6)/total_BR + +# Ctt_list = [] +# Ctt_error_list = [] + +# nr_of_toys = 1 +# if fitting_range == 'cut': +# nevents = int(pdg["number_of_decays"]*cut_BR) +# else: +# nevents = int(pdg["number_of_decays"]) +# # nevents = pdg["number_of_decays"] +# event_stack = 1000000 +# # nevents *= 41 +# # zfit.settings.set_verbosity(10) +# calls = int(nevents/event_stack + 1) + +# total_samp = [] + +# start = time.time() + +# sampler = total_f.create_sampler(n=event_stack) + +# for toy in range(nr_of_toys): + +# ### Generate data + +# # clear_output(wait=True) + +# print("Toy {}: Generating data...".format(toy)) + +# dirName = 'data/zfit_toys/toy_{0}'.format(toy) + +# if not os.path.exists(dirName): +# os.mkdir(dirName) +# print("Directory " , dirName , " Created ") + +# reset_param_values() + +# if fitting_range == 'cut': + +# sampler.resample(n=nevents) +# s = sampler.unstack_x() +# sam = zfit.run(s) +# calls = 0 +# c = 1 + +# else: +# for call in range(calls): + +# sampler.resample(n=event_stack) +# s = sampler.unstack_x() +# sam = zfit.run(s) + +# c = call + 1 + +# with open("data/zfit_toys/toy_{0}/{1}.pkl".format(toy, call), "wb") as f: +# pkl.dump(sam, f, pkl.HIGHEST_PROTOCOL) + +# print("Toy {}: Data generation finished".format(toy)) + +# ### Load data + +# print("Toy {}: Loading data...".format(toy)) + +# if fitting_range == 'cut': + +# total_samp = sam + +# else: + +# for call in range(calls): +# with open(r"data/zfit_toys/toy_0/{}.pkl".format(call), "rb") as input_file: +# sam = pkl.load(input_file) +# total_samp = np.append(total_samp, sam) + +# total_samp = total_samp.astype('float64') + +# if fitting_range == 'full': + +# data = zfit.data.Data.from_numpy(array=total_samp[:int(nevents)], obs=obs) + +# print("Toy {}: Loading data finished".format(toy)) + +# ### Fit data + +# print("Toy {}: Fitting pdf...".format(toy)) + +# for param in total_f.get_dependents(): +# param.randomize() + +# nll = zfit.loss.UnbinnedNLL(model=total_f, data=data, fit_range = (x_min, x_max), constraints = constraints) + +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) +# # minimizer._use_tfgrad = False +# result = minimizer.minimize(nll) + +# print("Toy {}: Fitting finished".format(toy)) + +# print("Function minimum:", result.fmin) +# print("Hesse errors:", result.hesse()) + +# params = result.params +# Ctt_list.append(params[Ctt]['value']) +# Ctt_error_list.append(params[Ctt]['minuit_hesse']['error']) + +# #plotting the result + +# plotdirName = 'data/plots'.format(toy) + +# if not os.path.exists(plotdirName): +# os.mkdir(plotdirName) +# # print("Directory " , dirName , " Created ") + +# probs = total_f.pdf(test_q, norm_range=False) +# calcs_test = zfit.run(probs) +# plt.clf() +# plt.plot(test_q, calcs_test, label = 'pdf') +# plt.legend() +# plt.ylim(0.0, 6e-6) +# plt.savefig(plotdirName + '/toy_fit_full_range{}.png'.format(toy)) + +# print("Toy {0}/{1}".format(toy+1, nr_of_toys)) +# print("Time taken: {}".format(display_time(int(time.time() - start)))) +# print("Projected time left: {}".format(display_time(int((time.time() - start)/(c+calls*(toy))*((nr_of_toys-toy)*calls-c))))) + +# if fitting_range == 'cut': + +# _1 = np.where((total_samp >= x_min) & (total_samp <= (jpsi_mass - 60.))) + +# tot_sam_1 = total_samp[_1] + +# _2 = np.where((total_samp >= (jpsi_mass + 70.)) & (total_samp <= (psi2s_mass - 50.))) + +# tot_sam_2 = total_samp[_2] + +# _3 = np.where((total_samp >= (psi2s_mass + 50.)) & (total_samp <= x_max)) + +# tot_sam_3 = total_samp[_3] + +# tot_sam = np.append(tot_sam_1, tot_sam_2) +# tot_sam = np.append(tot_sam, tot_sam_3) + +# data = zfit.data.Data.from_numpy(array=tot_sam[:int(nevents)], obs=obs_fit) + +# print("Toy {}: Loading data finished".format(toy)) + +# ### Fit data + +# print("Toy {}: Fitting pdf...".format(toy)) + +# for param in total_f_fit.get_dependents(): +# param.randomize() + +# nll = zfit.loss.UnbinnedNLL(model=total_f_fit, data=data, constraints = constraints) + +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) +# # minimizer._use_tfgrad = False +# result = minimizer.minimize(nll) + +# print("Function minimum:", result.fmin) +# print("Hesse errors:", result.hesse()) + +# params = result.params + +# if result.converged: +# Ctt_list.append(params[Ctt]['value']) +# Ctt_error_list.append(params[Ctt]['minuit_hesse']['error']) + +# #plotting the result + +# plotdirName = 'data/plots'.format(toy) + +# if not os.path.exists(plotdirName): +# os.mkdir(plotdirName) +# # print("Directory " , dirName , " Created ") + +# plt.clf() +# plt.hist(tot_sam, bins = int((x_max-x_min)/7.), label = 'toy data') +# plt.savefig(plotdirName + '/toy_histo_cut_region{}.png'.format(toy)) + + +# probs = total_f_fit.pdf(test_q, norm_range=False) +# calcs_test = zfit.run(probs) +# plt.clf() +# plt.plot(test_q, calcs_test, label = 'pdf') +# plt.axvline(x=jpsi_mass-60.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.axvline(x=jpsi_mass+70.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.axvline(x=psi2s_mass-50.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.axvline(x=psi2s_mass+50.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.legend() +# plt.ylim(0.0, 1.5e-6) +# plt.savefig(plotdirName + '/toy_fit_cut_region{}.png'.format(toy)) + +# print("Toy {0}/{1}".format(toy+1, nr_of_toys)) +# print("Time taken: {}".format(display_time(int(time.time() - start)))) +# print("Projected time left: {}".format(display_time(int((time.time() - start)/(toy+1))*((nr_of_toys-toy-1))))) + + + +# In[ ]: + + +# with open("data/results/Ctt_list.pkl", "wb") as f: +# pkl.dump(Ctt_list, f, pkl.HIGHEST_PROTOCOL) +# with open("data/results/Ctt_error_list.pkl", "wb") as f: +# pkl.dump(Ctt_error_list, f, pkl.HIGHEST_PROTOCOL) + + +# In[ ]: + + +# print('{0}/{1} fits converged'.format(len(Ctt_list), nr_of_toys)) +# print('Mean Ctt value = {}'.format(np.mean(Ctt_list))) +# print('Mean Ctt error = {}'.format(np.mean(Ctt_error_list))) +# print('95 Sensitivy = {}'.format(((2*np.mean(Ctt_error_list))**2)*4.2/1000)) + + +# In[ ]: + + +# plt.hist(tot_sam, bins = int((x_max-x_min)/7.)) + +# plt.show() + +# # _ = np.where((total_samp >= x_min) & (total_samp <= (jpsi_mass - 50.))) + +# tot_sam.shape + + +# In[ ]: + + +# Ctt.floating = False + + +# In[ ]: + + +# zfit.run(nll.value()) + + +# In[ ]: + + +# result.fmin + + +# In[ ]: + + +# BR_steps = np.linspace(0.0, 1e-3, 11) +pull_dic = {} + +mi = 1e-4 +ma = 3e-3 +ste = 20 + +for param in total_f_fit.get_dependents(): + if param.floating: + pull_dic[param.name] = [] + for step in range(2*ste): + pull_dic[param.name].append([]) + + + +def save_pulls(step): + for param in total_f_fit.get_dependents(): + if param.floating: + pull_dic[param.name][step].append((params[param]['value'] - param_values_dic[param.name])/params[param]['minuit_hesse']['error']) + + + +# for key in pull_dic.keys(): +# print(np.shape(pull_dic[key])) +# save_pulls(New_step=True) +# params[Ctt]['value'] + + +# In[ ]: + + +# for param in total_f_fit.get_dependents(): +# if param.floating: +# print(param.name) + +# print(params[Ctt]) + + +# # CLS Code + +# In[ ]: + + +# zfit.run.numeric_checks = False + +load = False + +bo = True + +D_contribs = True + +if not D_contribs: + Dbar_s.floating = False + Dbar_p.floating = False + DDstar_s.floating = False + DDstar_p.floating = False + +bo_set = 1 + +fitting_range = 'cut' +total_BR = 1.7e-10 + 4.9e-10 + 2.5e-9 + 6.02e-5 + 4.97e-6 + 1.38e-9 + 4.2e-10 + 2.6e-9 + 6.1e-10 + 4.37e-7 +cut_BR = 1.0 - (6.02e-5 + 4.97e-6)/total_BR + +Ctt_list = [] +Ctt_error_list = [] + +nr_of_toys = 1 +nevents = int(pdg["number_of_decays"]*cut_BR) +# nevents = pdg["number_of_decays"] +event_stack = 1000000 +# nevents *= 41 +# zfit.settings.set_verbosity(10) + +# mi = 1e-4 +# ma = 3e-3 +# ste = 13 + +BR_steps = np.linspace(mi, ma, ste) + +BR_steps[0] = 0.0 + +print(BR_steps) + +Ctt_steps = np.sqrt(BR_steps/4.2*1000) + +print(Ctt_steps) + +# total_samp = [] + +start = time.time() + +Nll_list = [] + +sampler = total_f.create_sampler(n=nevents, fixed_params = False) +sampler.set_data_range(obs_fit) + +__ = -1 + +#----------------------------------------------------- + +if not load: + for Ctt_step in Ctt_steps: + + __ += 1 + + for i in range(2): + Ctt_list.append([]) + Ctt_error_list.append([]) + Nll_list.append([]) + + for param in total_f_fit.get_dependents(): + if param.floating: + pull_dic[param.name].append([]) + + for toy in range(nr_of_toys): + + newset = True + + while newset: + + for floaty in [True, False]: + Ctt.floating = floaty + + for bo_step in range(bo_set): + + print('Step: {0}/{1}'.format(int(__), ste)) + print('Current Ctt: {0}'.format(Ctt_step)) + print('Ctt floating: {0}'.format(floaty)) + + reset_param_values(variation = 0.0) + + if floaty: + print('Toy {0}/{1} - Fit {2}/{3}'.format(toy, nr_of_toys, bo_step, bo_set)) + Ctt.set_value(Ctt_step) + + else: + Ctt.set_value(0.0) + print('Toy {0}/{1} - Fit {2}/{3}'.format(toy, nr_of_toys, bo_step, bo_set)) + + if newset: + sampler.resample(n=nevents) + data = sampler + newset = False + + ### Fit data + + if floaty: + #plt.clf() + #plt.title('Ctt value: {:.2f}'.format(Ctt_step)) + #plt.hist(zfit.run(data), bins = int((x_max-x_min)/7), range = (x_min, x_max)) + #plt.savefig('data/CLs/plots/set_histo{}.png'.format(__)) + _step = 2*__ + else: + _step = 2*__+1 + + nll = zfit.loss.UnbinnedNLL(model=total_f_fit, data=data, constraints = constraints) + + minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) + # minimizer._use_tfgrad = False + result = minimizer.minimize(nll) + + print("Function minimum:", result.fmin) + print("Hesse errors:", result.hesse()) + + params = result.params + + if result.converged: + + save_pulls(step = _step) + + if floaty: + Nll_list[-2].append(result.fmin) + Ctt_list[-2].append(params[Ctt]['value']) + Ctt_error_list[-2].append(params[Ctt]['minuit_hesse']['error']) + + else: + Nll_list[-1].append(result.fmin) + Ctt_list[-1].append(0.0) + Ctt_error_list[-1].append(0.0) + + + else: + for _ in [1,2]: + del Nll_list[-_][toy*bo_set:] +# print(np.shape(Nll_list[-_])) + del Ctt_list[-_][toy*bo_set:] + del Ctt_error_list[-_][toy*bo_set:] + for param in total_f_fit.get_dependents(): + if param.floating: + del pull_dic[param.name][_step+1-_][toy*bo_set:] + newset = True + break + + if not result.converged: + break + + print() + print('Time taken: {}'.format(display_time(int(time.time()-start)))) + print('Estimated time left: {}'.format(display_time(int((time.time()-start)/(__+(toy+1)/nr_of_toys)*(ste-__-(nr_of_toys-toy-1)/nr_of_toys))))) + + +# In[ ]: + + +if load: + + phase_combi = '--' + + if D_contribs: + D_dir = 'D-True' + else: + D_dir = 'D-False' + + _dir = 'data/CLs/finished/f1d1/{}/{}/'.format(phase_combi, D_dir) + + jobs = os.listdir(_dir) + + First = True + +# print(jobs) + + for job in jobs: + + dirName = _dir + str(job) + '/data/CLs' + + if not os.path.exists("{}/{}-{}_{}s{}b{}t--CLs_Nll_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys)): +# print(job) + continue + + with open(r"{}/variab.pkl".format(dirName), "rb") as input_file: + variab = pkl.load(input_file) +# print(variab) + + ### sanity check: + if variab['mi'] != mi or variab['ma'] != ma or variab['ste'] != ste or bo_set != bo_set: + print('Fitting parameters of data dont equal the ones given -- Job {} skipped!'.format(job)) + + with open(r"{}/{}-{}_{}s{}b{}t--CLs_Nll_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _Nll_list = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s{}b{}t--Ctt_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _Ctt_list = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s{}b{}t--Ctt_error_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _Ctt_error_list = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s{}b{}t--pull_dic.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _pull_dic = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s--CLs_list.pkl".format(dirName, mi,ma,ste), "rb") as input_file: + _CLs_list = pkl.load(input_file) + + + if First: + Nll_list = _Nll_list + Ctt_list = _Ctt_list + Ctt_error_list = _Ctt_error_list + pull_dic = _pull_dic +# print(_pull_dic) + CLs_list = _CLs_list + First = False + else: + for step in range(2*ste): +# print(Nll_list[step], step) + Nll_list[step].extend(_Nll_list[step]) + Ctt_list[step].extend(_Ctt_list[step]) + Ctt_error_list[step].extend(_Ctt_error_list[step]) + for key in pull_dic.keys(): +# print(key, np.shape(pull_dic[key])) + pull_dic[key][step].extend(_pull_dic[key][step]) + for step in range(ste): + CLs_list[step].extend(_CLs_list[step]) + +# print('----------------------') + + +# In[ ]: + + +dirName = 'data/CLs' + +# if bo and not load: +# for s in range(2*ste): +# Nll_list[s] = [np.min(Nll_list[s])] + + +if not load: + + if not os.path.exists(dirName): + os.mkdir(dirName) + print("Directory " , dirName , " Created ") + + with open("{}/{}-{}_{}s{}b{}t--CLs_Nll_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(Nll_list, f, pkl.HIGHEST_PROTOCOL) + + with open("{}/{}-{}_{}s{}b{}t--Ctt_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(Ctt_list, f, pkl.HIGHEST_PROTOCOL) + + with open("{}/{}-{}_{}s{}b{}t--Ctt_error_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(Ctt_error_list, f, pkl.HIGHEST_PROTOCOL) + + with open("{}/{}-{}_{}s{}b{}t--pull_dic.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(pull_dic, f, pkl.HIGHEST_PROTOCOL) + + variab = {'mi': mi, + 'ma': ma, + 'ste': ste, + 'bo_set': bo_set, + 'nr_of_toys': nr_of_toys} + + with open("{}/variab.pkl".format(dirName), "wb") as f: + pkl.dump(variab, f, pkl.HIGHEST_PROTOCOL) + + CLs_values = [] + + toy_size = bo_set + + print(np.shape(Nll_list)) + print(Nll_list[0:1]) + + for step in range(ste): + CLs_values.append([]) + for toy in range(nr_of_toys): + float_min = np.min(Nll_list[2*step][toy*bo_set:(toy+1)*bo_set]) + fix_min = np.min(Nll_list[2*step+1][toy*bo_set:(toy+1)*bo_set]) + CLs_values[step].append(float_min-fix_min) + + + print(np.shape(CLs_values)) + + with open("{}/{}-{}_{}s--CLs_list.pkl".format(dirName, mi,ma,ste), "wb") as f: + pkl.dump(CLs_values, f, pkl.HIGHEST_PROTOCOL) + + +# In[ ]: + + +# print(variab['mi'] != mi) + + +# ## Plot + +# In[ ]: + + +l = [] + + +if load: + CLs_values = -1*np.array(CLs_list) + +if not os.path.exists('data/CLs/plots'): + os.mkdir('data/CLs/plots') + print("Directory " , 'data/CLs/plots' , " Created ") + +print(np.shape(CLs_values)) + +for step in range(1,ste): + plt.clf() + plt.title('Ctt value: {:.2f}'.format(Ctt_steps[step])) + plt.hist(CLs_values[0], bins = 150, range = (-25, 50), label = 'Ctt fixed to 0') + plt.hist(CLs_values[step], bins = 150, range = (-25, 50), label = 'Ctt floating') + plt.axvline(x=np.mean(CLs_values[0]),color='red', linewidth=1.0, linestyle = 'dotted') + plt.legend() + plt.savefig('data/CLs/plots/CLs-BR({:.1E}).png'.format(BR_steps[step])) + + l.append(len(np.where(np.array(CLs_values[step]) < np.mean(CLs_values[0]))[0])) + +for step in range(2*ste): + if step%2 == 0: + floaty = True + else: + floaty = False + for key in pull_dic.keys(): + if not os.path.exists('data/CLs/plots/{}'.format(key)): + os.mkdir('data/CLs/plots/{}'.format(key)) + plt.clf() + plt.title('Pull {} - Ctt value {:.2f} - floating {}'.format(key, Ctt_steps[int(step/2)], floaty)) + plt.hist(pull_dic[key][step], bins = 50, range = (-5,5)) + plt.xlabel('Pull') + plt.savefig('data/CLs/plots/{}/{:.2f}Ctt{}s{}f.png'.format(key, Ctt_steps[int(step/2)], step, floaty)) + + +# In[ ]: + + +for s in range(len(l)): + print('BR: {:.4f}'.format(BR_steps[s+1])) + print(2*l[s]/len(CLs_values[s])) + print() + + +# In[ ]: + + +# for step in range(2*ste): +# for key in pull_dic.keys(): +# print(pull_dic[key][step]) + + +# In[ ]: + + +# for param in total_f_fit.get_dependents(): +# if param.floating: +# print(params[param]['value']) + + +# In[ ]: + + +print(display_time(int(time.time()-start))) + + +# In[ ]: + + +# variab['mi'] =! mi + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + diff --git a/data/CLs/finished/f1d1/-+/D-True/2288039/__pycache__/helperfunctions.cpython-37.pyc b/data/CLs/finished/f1d1/-+/D-True/2288039/__pycache__/helperfunctions.cpython-37.pyc new file mode 100644 index 0000000..30c5cec --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288039/__pycache__/helperfunctions.cpython-37.pyc Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288039/__pycache__/pdg_const1.cpython-37.pyc b/data/CLs/finished/f1d1/-+/D-True/2288039/__pycache__/pdg_const1.cpython-37.pyc new file mode 100644 index 0000000..73e3e54 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288039/__pycache__/pdg_const1.cpython-37.pyc Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288039/data/CLs/0.0001-0.003_20s--CLs_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288039/data/CLs/0.0001-0.003_20s--CLs_list.pkl new file mode 100644 index 0000000..2b5f8ad --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288039/data/CLs/0.0001-0.003_20s--CLs_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288039/data/CLs/0.0001-0.003_20s1b1t--CLs_Nll_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288039/data/CLs/0.0001-0.003_20s1b1t--CLs_Nll_list.pkl new file mode 100644 index 0000000..75b0b8d --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288039/data/CLs/0.0001-0.003_20s1b1t--CLs_Nll_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288039/data/CLs/0.0001-0.003_20s1b1t--Ctt_error_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288039/data/CLs/0.0001-0.003_20s1b1t--Ctt_error_list.pkl new file mode 100644 index 0000000..59b0986 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288039/data/CLs/0.0001-0.003_20s1b1t--Ctt_error_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288039/data/CLs/0.0001-0.003_20s1b1t--Ctt_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288039/data/CLs/0.0001-0.003_20s1b1t--Ctt_list.pkl new file mode 100644 index 0000000..7181124 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288039/data/CLs/0.0001-0.003_20s1b1t--Ctt_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288039/data/CLs/0.0001-0.003_20s1b1t--pull_dic.pkl b/data/CLs/finished/f1d1/-+/D-True/2288039/data/CLs/0.0001-0.003_20s1b1t--pull_dic.pkl new file mode 100644 index 0000000..131fca0 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288039/data/CLs/0.0001-0.003_20s1b1t--pull_dic.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288039/data/CLs/variab.pkl b/data/CLs/finished/f1d1/-+/D-True/2288039/data/CLs/variab.pkl new file mode 100644 index 0000000..bb90dc0 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288039/data/CLs/variab.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288039/helperfunctions.py b/data/CLs/finished/f1d1/-+/D-True/2288039/helperfunctions.py new file mode 100644 index 0000000..88e120f --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288039/helperfunctions.py @@ -0,0 +1,33 @@ +# some helperfunctions + +import matplotlib +matplotlib.use("agg") +import matplotlib.pyplot as plt + +#Dislpay time (e.g. while generating points) + +display_intervals = ( + ('w', 604800), # 60 * 60 * 24 * 7 + ('d', 86400), # 60 * 60 * 24 + ('h', 3600), # 60 * 60 + ('min', 60), + ('s', 1), + ) + +def display_time(seconds, granularity=2): + result = [] + + for name, count in display_intervals: + value = seconds // count + if value: + seconds -= value * count + if value == 1: + name = name.rstrip('s') + result.append("{} {}".format(value, name)) + return ', '.join(result[:granularity]) + +def prepare_plot(title): + plt.title(title) + plt.grid() + plt.legend(loc = 'best') + plt.xlabel("q") diff --git a/data/CLs/finished/f1d1/-+/D-True/2288039/pdg_const1.py b/data/CLs/finished/f1d1/-+/D-True/2288039/pdg_const1.py new file mode 100644 index 0000000..70b3f30 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288039/pdg_const1.py @@ -0,0 +1,226 @@ +pdg = { + + + ###Particle masses### + + "mbstar" : 5415.4, + "mbstar0" : 5711.0, + "B0_M" : 5279.5, + "Bs_M" : 5366.7, + "Bplus_M" : 5279.3, + "Lb_M" : 5619.4, + "D0_M" : 1864.8, + "Dst_M" : 2010, + "pi_M" : 139.6, + "Jpsi_M" : 3096.9, + "Psi2s_M" : 3685.6, + "kaon_M" : 493.7, + "Ks_M" : 497.6, + "phi_M" : 1019.5, + "rho_M" : 775.26, + "rho_width" : 149.1, + "omega_M" : 782.65, + "omega_width" : 8.49, + + "muon_M" : 105.7, + "tau_M": 1776.86, + + "squark_M" : 95.0, + "bquark_M" : 4180.0, + "cquark_M" : 1275.0, + + "Bplus_tau" : 1.638e-12, + + ###Wilson coefficients### + + "C1" : -0.257, + "C2" : 1.009, + "C3" : -0.005, + "C4" : -0.078, + + "C7eff" : -0.306, + "C9eff" : 4.211, + "C10eff" : -4.103, + +# "C7eff": 0.0, +# "C9eff": 0.0, +# "C10eff": 0.0, + + ###Other constants + + "GF" : 1.1663787e-5, + "alpha_ew" : 1.0/137.0, + "Vts" : 0.0394, + "Vtb" : 1.019, + "number_of_decays": 5404696, + + #Formfactor z coefficients + + #"b0" : [0.285, 0.19, -0.17], + #"bplus" : [0.437, -1.41, -2.5], + #"bT" : [0.440, -1.47, -2.7] + + "b0" : [0.292, 0.281, 0.150], + "bplus" : [0.466, -0.885, -0.213], + "bT" : [0.460, -1.089, -1.114], + + "NR_BR": 4.37e-7, + "NR_auc": 0.00133, + + #Resonances format(mass, width, phase, scale) + + # pre scaling + +# "rho": (775.26, 149.0, -0.35, 1.0), + +# "omega": (782.7, 8.5, 0.26, 1.0), + +# "phi": (1019.46, 4.25, 0.5, 1.0), + +# "jpsi": (3096.0, 0.09, -1.5, 2e-2), +# "jpsi_auc": 0.2126825758464027, + +# "psi2s": (3686.0, 0.3, -1.5, 3.14e-3), +# "psi2s_auc": 2.802257483178487e-10, + +# "p3770": (3773.0, 27.2, -2.13, 1.0e-3), + +# "p4040": (4039.0, 80.0, -2.52, 2.0), + +# "p4160": (4191.0, 70.0, -1.9, 2.2), + +# "p4415": (4421.0, 62.0, -2.52, 1.0), + + + # after scaling (Phase combination --) + + # + # "rho": (743.2, 149.0, -0.22, 1.05), + # + # "omega": (782.7, 8.5, 0.38, 6.8), + # + # "phi": (1013.5, 4.25, 0.62, 19.2), + # + # "jpsi": (3096.1, 0.09, 1.63, 9897.0), + # "jpsi_auc": 0.2126825758464027, + # "jpsi_phase_unc": 0.05, + # + # "psi2s": (3686.0, 0.3, 1.8, 1396.0), + # "psi2s_auc": 0.0151332263, + # "psi2s_phase_unc": 0.1, + # + # "p3770": (3773.0, 27.2, -2.95, 2.5), + # + # "p4040": (4039.0, 80.0, -2.75, 1.01), + # + # "p4160": (4191.0, 70.0, -2.28, 2.2), + # + # "p4415": (4421.0, 62.0, -2.31, 1.24), + + # Phase combination of paper ++ + +# "rho": (743.2, 149.0, -0.35, 1.05), + +# "omega": (782.7, 8.5, 0.26, 6.8), + +# "phi": (1013.5, 4.25, 0.47, 19.2), + +# "jpsi": (3096.1, 0.09, -1.66, 9897.0), +# "jpsi_auc": 0.2126825758464027, +# "jpsi_phase_unc": 0.05, + +# "psi2s": (3686.0, 0.3, -1.93, 1396.0), +# "psi2s_auc": 0.0151332263, +# "psi2s_phase_unc": 0.1, + +# "p3770": (3773.0, 27.2, -2.13, 2.5), + +# "p4040": (4039.0, 80.0, -2.52, 1.01), + +# "p4160": (4191.0, 70.0, -1.90, 2.2), + +# "p4415": (4421.0, 62.0, -2.52, 1.24), + + # Phase combination of paper +- + +# "rho": (743.2, 149.0, -0.26, 1.05), + +# "omega": (782.7, 8.5, 0.35, 6.8), + +# "phi": (1013.5, 4.25, 0.58, 19.2), + +# "jpsi": (3096.1, 0.09, 1.47, 9897.0), +# "jpsi_auc": 0.2126825758464027, +# "jpsi_phase_unc": 0.05, + +# "psi2s": (3686.0, 0.3, -2.21, 1396.0), +# "psi2s_auc": 0.0151332263, +# "psi2s_phase_unc": 0.1, + +# "p3770": (3773.0, 27.2, -2.140, 2.5), + +# "p4040": (4039.0, 80.0, -2.64, 1.01), + +# "p4160": (4191.0, 70.0, -2.11, 2.2), + +# "p4415": (4421.0, 62.0, -2.42, 1.24), + + # Phase combination of paper -+ + + "rho": (743.2, 149.0, -0.30, 1.05), + + "omega": (782.7, 8.5, 0.30, 6.8), + + "phi": (1013.5, 4.25, 0.51, 19.2), + + "jpsi": (3096.1, 0.09, -1.5, 9897.0), + "jpsi_auc": 0.2126825758464027, + "jpsi_phase_unc": 0.05, + + "psi2s": (3686.0, 0.3, 2.08, 1396.0), + "psi2s_auc": 0.0151332263, + "psi2s_phase_unc": 0.1, + + "p3770": (3773.0, 27.2, -2.89, 2.5), + + "p4040": (4039.0, 80.0, -2.69, 1.01), + + "p4160": (4191.0, 70.0, -2.13, 2.2), + + "p4415": (4421.0, 62.0, -2.43, 1.24), + + + # zeroing resonances + +# "rho": (775.26, 149.0, -0.35, 0.0), +# "omega": (782.7, 8.5, 0.26, 0.0), +# "phi": (1019.46, 4.25, 0.5, 0.0), +# "jpsi": (3096.0, 0.09, -1.5, 0.0), +# "psi2s": (3686.0, 0.3, -1.5, 0.0), +# "p3770": (3773.0, 27.2, -2.13, 0.0), +# "p4040": (4039.0, 80.0, -2.52, 0.0), +# "p4160": (4147.0, 22.0, -1.9, 0.0), +# "p4415": (4421.0, 62.0, -2.52, 0.0), + + # 2P contributions format(mass, amp, phase) + +# "D_bar": ( + + #general + + "rho_BR": 1.7e-10, + "omega_BR": 4.9e-10, + "phi_BR": 2.5e-9, + "jpsi_BR": 6.02e-5, + "psi2s_BR": 4.97e-6, + "p3770_BR": 1.38e-9, + "p4040_BR": 4.2e-10, + "p4160_BR": 2.6e-9, + "p4415_BR": 6.1e-10, + +# Estimates + "Dbar_scale": 1.46, #with phase = pi + + "DDstar_scale": 2.41, #with phase = pi + + } diff --git a/data/CLs/finished/f1d1/-+/D-True/2288039/raremodel-nb.py b/data/CLs/finished/f1d1/-+/D-True/2288039/raremodel-nb.py new file mode 100644 index 0000000..c326c9c --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288039/raremodel-nb.py @@ -0,0 +1,2152 @@ +#!/usr/bin/env python +# coding: utf-8 + +# # Import + +# In[ ]: + + +import os + +# os.environ["CUDA_VISIBLE_DEVICES"] = "-1" +import random +import numpy as np +from pdg_const1 import pdg +import matplotlib +import matplotlib.pyplot as plt +import pickle as pkl +import sys +import time +from helperfunctions import display_time, prepare_plot +import cmath as c +import scipy.integrate as integrate +from scipy.optimize import fminbound +from array import array as arr +import collections +from itertools import compress +import tensorflow as tf +import zfit +from zfit import ztf +# from IPython.display import clear_output +import os +import tensorflow_probability as tfp +tfd = tfp.distributions + + +# In[ ]: + + +# chunksize = 10000 +# zfit.run.chunking.active = True +# zfit.run.chunking.max_n_points = chunksize + + +# # Build model and graphs +# ## Create graphs + +# In[ ]: + + + + + +# In[ ]: + + +def formfactor(q2, subscript, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2): #returns real value + #check if subscript is viable + + if subscript != "0" and subscript != "+" and subscript != "T": + raise ValueError('Wrong subscript entered, choose either 0, + or T') + + #get constants + + mK = ztf.constant(pdg['Ks_M']) + mbstar0 = ztf.constant(pdg["mbstar0"]) + mbstar = ztf.constant(pdg["mbstar"]) + + + mmu = ztf.constant(pdg['muon_M']) + mb = ztf.constant(pdg['bquark_M']) + ms = ztf.constant(pdg['squark_M']) + mB = ztf.constant(pdg['Bplus_M']) + + #N comes from derivation in paper + + N = 3 + + #some helperfunctions + + tpos = (mB - mK)**2 + tzero = (mB + mK)*(ztf.sqrt(mB)-ztf.sqrt(mK))**2 + + z_oben = ztf.sqrt(tpos - q2) - ztf.sqrt(tpos - tzero) + z_unten = ztf.sqrt(tpos - q2) + ztf.sqrt(tpos - tzero) + z = tf.divide(z_oben, z_unten) + + #calculate f0 + + if subscript == "0": + prefactor = 1/(1 - q2/(mbstar0**2)) + _sum = 0 + b0 = [b0_0, b0_1, b0_2] + + for i in range(N): + _sum += b0[i]*(tf.pow(z,i)) + + return ztf.to_complex(prefactor * _sum) + + #calculate f+ or fT + + else: + prefactor = 1/(1 - q2/(mbstar**2)) + _sum = 0 + + if subscript == "T": + bT = [bT_0, bT_1, bT_2] + for i in range(N): + _sum += bT[i] * (tf.pow(z, i) - ((-1)**(i-N)) * (i/N) * tf.pow(z, N)) + else: + bplus = [bplus_0, bplus_1, bplus_2] + for i in range(N): + _sum += bplus[i] * (tf.pow(z, i) - ((-1)**(i-N)) * (i/N) * tf.pow(z, N)) + + return ztf.to_complex(prefactor * _sum) + +def resonance(q, _mass, width, phase, scale): + + q2 = tf.pow(q, 2) + + mmu = ztf.constant(pdg['muon_M']) + + p = 0.5 * ztf.sqrt(q2 - 4*(mmu**2)) + + p0 = 0.5 * ztf.sqrt(_mass**2 - 4*mmu**2) + + gamma_j = tf.divide(p, q) * _mass * width / p0 + + #Calculate the resonance + + _top = tf.complex(_mass * width, ztf.constant(0.0)) + + _bottom = tf.complex(_mass**2 - q2, -_mass*gamma_j) + + com = _top/_bottom + + #Rotate by the phase + + r = ztf.to_complex(scale*tf.abs(com)) + + _phase = tf.angle(com) + + _phase += phase + + com = r * tf.exp(tf.complex(ztf.constant(0.0), _phase)) + + return com + + +def axiv_nonres(q, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2): + + GF = ztf.constant(pdg['GF']) + alpha_ew = ztf.constant(pdg['alpha_ew']) + Vtb = ztf.constant(pdg['Vtb']) + Vts = ztf.constant(pdg['Vts']) + C10eff = ztf.constant(pdg['C10eff']) + + mmu = ztf.constant(pdg['muon_M']) + mb = ztf.constant(pdg['bquark_M']) + ms = ztf.constant(pdg['squark_M']) + mK = ztf.constant(pdg['Ks_M']) + mB = ztf.constant(pdg['Bplus_M']) + + q2 = tf.pow(q, 2) + + #Some helperfunctions + + beta = 1. - 4. * mmu**2. / q2 + + kabs = ztf.sqrt(mB**2. + tf.pow(q2, 2)/mB**2. + mK**4./mB**2. - 2. * (mB**2. * mK**2. + mK**2. * q2 + mB**2. * q2) / mB**2.) + + #prefactor in front of whole bracket + + prefactor1 = GF**2. *alpha_ew**2. * (tf.abs(Vtb*Vts))**2. * kabs * beta / (128. * np.pi**5.) + + #left term in bracket + + bracket_left = 2./3. * tf.pow(kabs,2) * tf.pow(beta,2) * tf.pow(tf.abs(ztf.to_complex(C10eff)*formfactor(q2, "+", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2)),2) + + #middle term in bracket + + _top = 4. * mmu**2. * (mB**2. - mK**2.) * (mB**2. - mK**2.) + + _under = q2 * mB**2. + + bracket_middle = _top/_under *tf.pow(tf.abs(ztf.to_complex(C10eff) * formfactor(q2, "0", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2)), 2) + + #Note sqrt(q2) comes from derivation as we use q2 and plot q + + return prefactor1 * (bracket_left + bracket_middle) * 2 * q + +def vec(q, funcs, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2): + + q2 = tf.pow(q, 2) + + GF = ztf.constant(pdg['GF']) + alpha_ew = ztf.constant(pdg['alpha_ew']) + Vtb = ztf.constant(pdg['Vtb']) + Vts = ztf.constant(pdg['Vts']) + C7eff = ztf.constant(pdg['C7eff']) + + mmu = ztf.constant(pdg['muon_M']) + mb = ztf.constant(pdg['bquark_M']) + ms = ztf.constant(pdg['squark_M']) + mK = ztf.constant(pdg['Ks_M']) + mB = ztf.constant(pdg['Bplus_M']) + + #Some helperfunctions + + beta = 1. - 4. * mmu**2. / q2 + + kabs = ztf.sqrt(mB**2. + tf.pow(q2, 2)/mB**2. + mK**4./mB**2. - 2 * (mB**2 * mK**2 + mK**2 * q2 + mB**2 * q2) / mB**2) + + #prefactor in front of whole bracket + + prefactor1 = GF**2. *alpha_ew**2. * (tf.abs(Vtb*Vts))**2 * kabs * beta / (128. * np.pi**5.) + + #right term in bracket + + prefactor2 = tf.pow(kabs,2) * (1. - 1./3. * beta) + + abs_bracket = tf.pow(tf.abs(c9eff(q, funcs) * formfactor(q2, "+", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + ztf.to_complex(2.0 * C7eff * (mb + ms)/(mB + mK)) * formfactor(q2, "T", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2)),2) + + bracket_right = prefactor2 * abs_bracket + + #Note sqrt(q2) comes from derivation as we use q2 and plot q + + return prefactor1 * bracket_right * 2 * q + +def c9eff(q, funcs): + + C9eff_nr = ztf.to_complex(ztf.constant(pdg['C9eff'])) + + c9 = C9eff_nr + funcs + + return c9 + + +# In[ ]: + + +def G(y): + + def inner_rect_bracket(q): + return tf.log(ztf.to_complex((1+tf.sqrt(q))/(1-tf.sqrt(q)))-tf.complex(ztf.constant(0), -1*ztf.constant(np.pi))) + + def inner_right(q): + return ztf.to_complex(2 * tf.atan(1/tf.sqrt(tf.math.real(-q)))) + + big_bracket = tf.where(tf.math.real(y) > ztf.constant(0.0), inner_rect_bracket(y), inner_right(y)) + + return ztf.to_complex(tf.sqrt(tf.abs(y))) * big_bracket + +def h_S(m, q): + + return ztf.to_complex(2) - G(ztf.to_complex(1) - ztf.to_complex(4*tf.pow(m, 2)) / ztf.to_complex(tf.pow(q, 2))) + +def h_P(m, q): + + return ztf.to_complex(2/3) + (ztf.to_complex(1) - ztf.to_complex(4*tf.pow(m, 2)) / ztf.to_complex(tf.pow(q, 2))) * h_S(m,q) + +def two_p_ccbar(mD, m_D_bar, m_D_star, q): + + + #Load constants + nu_D_bar = ztf.to_complex(pdg["nu_D_bar"]) + nu_D = ztf.to_complex(pdg["nu_D"]) + nu_D_star = ztf.to_complex(pdg["nu_D_star"]) + + phase_D_bar = ztf.to_complex(pdg["phase_D_bar"]) + phase_D = ztf.to_complex(pdg["phase_D"]) + phase_D_star = ztf.to_complex(pdg["phase_D_star"]) + + #Calculation + left_part = nu_D_bar * tf.exp(tf.complex(ztf.constant(0.0), phase_D_bar)) * h_S(m_D_bar, q) + + right_part_D = nu_D * tf.exp(tf.complex(ztf.constant(0.0), phase_D)) * h_P(m_D, q) + + right_part_D_star = nu_D_star * tf.exp(tf.complex(ztf.constant(0.0), phase_D_star)) * h_P(m_D_star, q) + + return left_part + right_part_D + right_part_D_star + + +# ## Build pdf + +# In[ ]: + + +class total_pdf_cut(zfit.pdf.ZPDF): + _N_OBS = 1 # dimension, can be omitted + _PARAMS = ['b0_0', 'b0_1', 'b0_2', + 'bplus_0', 'bplus_1', 'bplus_2', + 'bT_0', 'bT_1', 'bT_2', + 'rho_mass', 'rho_scale', 'rho_phase', 'rho_width', + 'jpsi_mass', 'jpsi_scale', 'jpsi_phase', 'jpsi_width', + 'psi2s_mass', 'psi2s_scale', 'psi2s_phase', 'psi2s_width', + 'p3770_mass', 'p3770_scale', 'p3770_phase', 'p3770_width', + 'p4040_mass', 'p4040_scale', 'p4040_phase', 'p4040_width', + 'p4160_mass', 'p4160_scale', 'p4160_phase', 'p4160_width', + 'p4415_mass', 'p4415_scale', 'p4415_phase', 'p4415_width', + 'omega_mass', 'omega_scale', 'omega_phase', 'omega_width', + 'phi_mass', 'phi_scale', 'phi_phase', 'phi_width', + 'Dbar_mass', 'Dbar_scale', 'Dbar_phase', + 'Dstar_mass', 'DDstar_scale', 'DDstar_phase', 'D_mass', + 'tau_mass', 'C_tt'] +# the name of the parameters + + def _unnormalized_pdf(self, x): + + x = x.unstack_x() + + b0 = [self.params['b0_0'], self.params['b0_1'], self.params['b0_2']] + bplus = [self.params['bplus_0'], self.params['bplus_1'], self.params['bplus_2']] + bT = [self.params['bT_0'], self.params['bT_1'], self.params['bT_2']] + + def rho_res(q): + return resonance(q, _mass = self.params['rho_mass'], scale = self.params['rho_scale'], + phase = self.params['rho_phase'], width = self.params['rho_width']) + + def omega_res(q): + return resonance(q, _mass = self.params['omega_mass'], scale = self.params['omega_scale'], + phase = self.params['omega_phase'], width = self.params['omega_width']) + + def phi_res(q): + return resonance(q, _mass = self.params['phi_mass'], scale = self.params['phi_scale'], + phase = self.params['phi_phase'], width = self.params['phi_width']) + + def jpsi_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['jpsi_mass'], 2)) * resonance(q, _mass = self.params['jpsi_mass'], + scale = self.params['jpsi_scale'], + phase = self.params['jpsi_phase'], + width = self.params['jpsi_width']) + def psi2s_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['psi2s_mass'], 2)) * resonance(q, _mass = self.params['psi2s_mass'], + scale = self.params['psi2s_scale'], + phase = self.params['psi2s_phase'], + width = self.params['psi2s_width']) + def p3770_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p3770_mass'], 2)) * resonance(q, _mass = self.params['p3770_mass'], + scale = self.params['p3770_scale'], + phase = self.params['p3770_phase'], + width = self.params['p3770_width']) + + def p4040_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4040_mass'], 2)) * resonance(q, _mass = self.params['p4040_mass'], + scale = self.params['p4040_scale'], + phase = self.params['p4040_phase'], + width = self.params['p4040_width']) + + def p4160_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4160_mass'], 2)) * resonance(q, _mass = self.params['p4160_mass'], + scale = self.params['p4160_scale'], + phase = self.params['p4160_phase'], + width = self.params['p4160_width']) + + def p4415_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4415_mass'], 2)) * resonance(q, _mass = self.params['p4415_mass'], + scale = self.params['p4415_scale'], + phase = self.params['p4415_phase'], + width = self.params['p4415_width']) + + def P2_D(q): + Dbar_contrib = ztf.to_complex(self.params['Dbar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['Dbar_phase']))*ztf.to_complex(h_S(self.params['Dbar_mass'], q)) + DDstar_contrib = ztf.to_complex(self.params['DDstar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['DDstar_phase']))*(ztf.to_complex(h_P(self.params['Dstar_mass'], q)) + ztf.to_complex(h_P(self.params['D_mass'], q))) + return Dbar_contrib + DDstar_contrib + + def ttau_cusp(q): + return ztf.to_complex(self.params['C_tt'])*(ztf.to_complex((h_S(self.params['tau_mass'], q))) - ztf.to_complex(h_P(self.params['tau_mass'], q))) + + + funcs = rho_res(x) + omega_res(x) + phi_res(x) + jpsi_res(x) + psi2s_res(x) + p3770_res(x) + p4040_res(x)+ p4160_res(x) + p4415_res(x) + P2_D(x) + ttau_cusp(x) + + vec_f = vec(x, funcs, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + axiv_nr = axiv_nonres(x, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + tot = vec_f + axiv_nr + + #Cut out jpsi and psi2s + + tot = tf.where(tf.math.logical_or(x < ztf.constant(jpsi_mass-60.), x > ztf.constant(jpsi_mass+70.)), tot, 0.0*tot) + + tot = tf.where(tf.math.logical_or(x < ztf.constant(psi2s_mass-50.), x > ztf.constant(psi2s_mass+50.)), tot, 0.0*tot) + + return tot + +class total_pdf_full(zfit.pdf.ZPDF): + _N_OBS = 1 # dimension, can be omitted + _PARAMS = ['b0_0', 'b0_1', 'b0_2', + 'bplus_0', 'bplus_1', 'bplus_2', + 'bT_0', 'bT_1', 'bT_2', + 'rho_mass', 'rho_scale', 'rho_phase', 'rho_width', + 'jpsi_mass', 'jpsi_scale', 'jpsi_phase', 'jpsi_width', + 'psi2s_mass', 'psi2s_scale', 'psi2s_phase', 'psi2s_width', + 'p3770_mass', 'p3770_scale', 'p3770_phase', 'p3770_width', + 'p4040_mass', 'p4040_scale', 'p4040_phase', 'p4040_width', + 'p4160_mass', 'p4160_scale', 'p4160_phase', 'p4160_width', + 'p4415_mass', 'p4415_scale', 'p4415_phase', 'p4415_width', + 'omega_mass', 'omega_scale', 'omega_phase', 'omega_width', + 'phi_mass', 'phi_scale', 'phi_phase', 'phi_width', + 'Dbar_mass', 'Dbar_scale', 'Dbar_phase', + 'Dstar_mass', 'DDstar_scale', 'DDstar_phase', 'D_mass', + 'tau_mass', 'C_tt'] +# the name of the parameters + + def _unnormalized_pdf(self, x): + + x = x.unstack_x() + + b0 = [self.params['b0_0'], self.params['b0_1'], self.params['b0_2']] + bplus = [self.params['bplus_0'], self.params['bplus_1'], self.params['bplus_2']] + bT = [self.params['bT_0'], self.params['bT_1'], self.params['bT_2']] + + def rho_res(q): + return resonance(q, _mass = self.params['rho_mass'], scale = self.params['rho_scale'], + phase = self.params['rho_phase'], width = self.params['rho_width']) + + def omega_res(q): + return resonance(q, _mass = self.params['omega_mass'], scale = self.params['omega_scale'], + phase = self.params['omega_phase'], width = self.params['omega_width']) + + def phi_res(q): + return resonance(q, _mass = self.params['phi_mass'], scale = self.params['phi_scale'], + phase = self.params['phi_phase'], width = self.params['phi_width']) + + def jpsi_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['jpsi_mass'], 2)) * resonance(q, _mass = self.params['jpsi_mass'], + scale = self.params['jpsi_scale'], + phase = self.params['jpsi_phase'], + width = self.params['jpsi_width']) + def psi2s_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['psi2s_mass'], 2)) * resonance(q, _mass = self.params['psi2s_mass'], + scale = self.params['psi2s_scale'], + phase = self.params['psi2s_phase'], + width = self.params['psi2s_width']) + def p3770_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p3770_mass'], 2)) * resonance(q, _mass = self.params['p3770_mass'], + scale = self.params['p3770_scale'], + phase = self.params['p3770_phase'], + width = self.params['p3770_width']) + + def p4040_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4040_mass'], 2)) * resonance(q, _mass = self.params['p4040_mass'], + scale = self.params['p4040_scale'], + phase = self.params['p4040_phase'], + width = self.params['p4040_width']) + + def p4160_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4160_mass'], 2)) * resonance(q, _mass = self.params['p4160_mass'], + scale = self.params['p4160_scale'], + phase = self.params['p4160_phase'], + width = self.params['p4160_width']) + + def p4415_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4415_mass'], 2)) * resonance(q, _mass = self.params['p4415_mass'], + scale = self.params['p4415_scale'], + phase = self.params['p4415_phase'], + width = self.params['p4415_width']) + + def P2_D(q): + Dbar_contrib = ztf.to_complex(self.params['Dbar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['Dbar_phase']))*ztf.to_complex(h_S(self.params['Dbar_mass'], q)) + DDstar_contrib = ztf.to_complex(self.params['DDstar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['DDstar_phase']))*(ztf.to_complex(h_P(self.params['Dstar_mass'], q)) + ztf.to_complex(h_P(self.params['D_mass'], q))) + return Dbar_contrib + DDstar_contrib + + def ttau_cusp(q): + return ztf.to_complex(self.params['C_tt'])*(ztf.to_complex((h_S(self.params['tau_mass'], q))) - ztf.to_complex(h_P(self.params['tau_mass'], q))) + + + funcs = rho_res(x) + omega_res(x) + phi_res(x) + jpsi_res(x) + psi2s_res(x) + p3770_res(x) + p4040_res(x)+ p4160_res(x) + p4415_res(x) + P2_D(x) + ttau_cusp(x) + + vec_f = vec(x, funcs, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + axiv_nr = axiv_nonres(x, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + tot = vec_f + axiv_nr + + #Cut out jpsi and psi2s + +# tot = tf.where(tf.math.logical_or(x < ztf.constant(jpsi_mass-60.), x > ztf.constant(jpsi_mass+70.)), tot, 0.0*tot) + +# tot = tf.where(tf.math.logical_or(x < ztf.constant(psi2s_mass-50.), x > ztf.constant(psi2s_mass+50.)), tot, 0.0*tot) + + return tot + + +# ## Setup parameters + +# In[ ]: + + +# formfactors + +b0_0 = zfit.Parameter("b0_0", ztf.constant(0.292), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +b0_1 = zfit.Parameter("b0_1", ztf.constant(0.281), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +b0_2 = zfit.Parameter("b0_2", ztf.constant(0.150), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) + +bplus_0 = zfit.Parameter("bplus_0", ztf.constant(0.466), lower_limit = -2.0, upper_limit= 2.0) +bplus_1 = zfit.Parameter("bplus_1", ztf.constant(-0.885), lower_limit = -2.0, upper_limit= 2.0) +bplus_2 = zfit.Parameter("bplus_2", ztf.constant(-0.213), lower_limit = -2.0, upper_limit= 2.0) + +bT_0 = zfit.Parameter("bT_0", ztf.constant(0.460), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +bT_1 = zfit.Parameter("bT_1", ztf.constant(-1.089), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +bT_2 = zfit.Parameter("bT_2", ztf.constant(-1.114), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) + + +#rho + +rho_mass, rho_width, rho_phase, rho_scale = pdg["rho"] + +rho_m = zfit.Parameter("rho_m", ztf.constant(rho_mass), floating = False) #lower_limit = rho_mass - rho_width, upper_limit = rho_mass + rho_width) +rho_w = zfit.Parameter("rho_w", ztf.constant(rho_width), floating = False) +rho_p = zfit.Parameter("rho_p", ztf.constant(rho_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +rho_s = zfit.Parameter("rho_s", ztf.constant(rho_scale), lower_limit=rho_scale-np.sqrt(rho_scale), upper_limit=rho_scale+np.sqrt(rho_scale)) + +#omega + +omega_mass, omega_width, omega_phase, omega_scale = pdg["omega"] + +omega_m = zfit.Parameter("omega_m", ztf.constant(omega_mass), floating = False) +omega_w = zfit.Parameter("omega_w", ztf.constant(omega_width), floating = False) +omega_p = zfit.Parameter("omega_p", ztf.constant(omega_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +omega_s = zfit.Parameter("omega_s", ztf.constant(omega_scale), lower_limit=omega_scale-np.sqrt(omega_scale), upper_limit=omega_scale+np.sqrt(omega_scale)) + + +#phi + +phi_mass, phi_width, phi_phase, phi_scale = pdg["phi"] + +phi_m = zfit.Parameter("phi_m", ztf.constant(phi_mass), floating = False) +phi_w = zfit.Parameter("phi_w", ztf.constant(phi_width), floating = False) +phi_p = zfit.Parameter("phi_p", ztf.constant(phi_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +phi_s = zfit.Parameter("phi_s", ztf.constant(phi_scale), lower_limit=phi_scale-np.sqrt(phi_scale), upper_limit=phi_scale+np.sqrt(phi_scale)) + +#jpsi + +jpsi_mass, jpsi_width, jpsi_phase, jpsi_scale = pdg["jpsi"] + +jpsi_m = zfit.Parameter("jpsi_m", ztf.constant(jpsi_mass), floating = False) +jpsi_w = zfit.Parameter("jpsi_w", ztf.constant(jpsi_width), floating = False) +jpsi_p = zfit.Parameter("jpsi_p", ztf.constant(jpsi_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +jpsi_s = zfit.Parameter("jpsi_s", ztf.constant(jpsi_scale), floating = False) #, lower_limit=jpsi_scale-np.sqrt(jpsi_scale), upper_limit=jpsi_scale+np.sqrt(jpsi_scale)) + +#psi2s + +psi2s_mass, psi2s_width, psi2s_phase, psi2s_scale = pdg["psi2s"] + +psi2s_m = zfit.Parameter("psi2s_m", ztf.constant(psi2s_mass), floating = False) +psi2s_w = zfit.Parameter("psi2s_w", ztf.constant(psi2s_width), floating = False) +psi2s_p = zfit.Parameter("psi2s_p", ztf.constant(psi2s_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +psi2s_s = zfit.Parameter("psi2s_s", ztf.constant(psi2s_scale), floating = False) #, lower_limit=psi2s_scale-np.sqrt(psi2s_scale), upper_limit=psi2s_scale+np.sqrt(psi2s_scale)) + +#psi(3770) + +p3770_mass, p3770_width, p3770_phase, p3770_scale = pdg["p3770"] + +p3770_m = zfit.Parameter("p3770_m", ztf.constant(p3770_mass), floating = False) +p3770_w = zfit.Parameter("p3770_w", ztf.constant(p3770_width), floating = False) +p3770_p = zfit.Parameter("p3770_p", ztf.constant(p3770_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p3770_s = zfit.Parameter("p3770_s", ztf.constant(p3770_scale), lower_limit=p3770_scale-np.sqrt(p3770_scale), upper_limit=p3770_scale+np.sqrt(p3770_scale)) + +#psi(4040) + +p4040_mass, p4040_width, p4040_phase, p4040_scale = pdg["p4040"] + +p4040_m = zfit.Parameter("p4040_m", ztf.constant(p4040_mass), floating = False) +p4040_w = zfit.Parameter("p4040_w", ztf.constant(p4040_width), floating = False) +p4040_p = zfit.Parameter("p4040_p", ztf.constant(p4040_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p4040_s = zfit.Parameter("p4040_s", ztf.constant(p4040_scale), lower_limit=p4040_scale-np.sqrt(p4040_scale), upper_limit=p4040_scale+np.sqrt(p4040_scale)) + +#psi(4160) + +p4160_mass, p4160_width, p4160_phase, p4160_scale = pdg["p4160"] + +p4160_m = zfit.Parameter("p4160_m", ztf.constant(p4160_mass), floating = False) +p4160_w = zfit.Parameter("p4160_w", ztf.constant(p4160_width), floating = False) +p4160_p = zfit.Parameter("p4160_p", ztf.constant(p4160_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p4160_s = zfit.Parameter("p4160_s", ztf.constant(p4160_scale), lower_limit=p4160_scale-np.sqrt(p4160_scale), upper_limit=p4160_scale+np.sqrt(p4160_scale)) + +#psi(4415) + +p4415_mass, p4415_width, p4415_phase, p4415_scale = pdg["p4415"] + +p4415_m = zfit.Parameter("p4415_m", ztf.constant(p4415_mass), floating = False) +p4415_w = zfit.Parameter("p4415_w", ztf.constant(p4415_width), floating = False) +p4415_p = zfit.Parameter("p4415_p", ztf.constant(p4415_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p4415_s = zfit.Parameter("p4415_s", ztf.constant(p4415_scale), lower_limit=p4415_scale-np.sqrt(p4415_scale), upper_limit=p4415_scale+np.sqrt(p4415_scale)) + + +# ## Dynamic generation of 2 particle contribution + +# In[ ]: + + +m_c = 1300 + +Dbar_phase = 0.0 +DDstar_phase = 0.0 +Dstar_mass = pdg['Dst_M'] +Dbar_mass = pdg['D0_M'] +D_mass = pdg['D0_M'] + +Dbar_s = zfit.Parameter("Dbar_s", ztf.constant(0.0), lower_limit=-0.3, upper_limit=0.3) +Dbar_m = zfit.Parameter("Dbar_m", ztf.constant(Dbar_mass), floating = False) +Dbar_p = zfit.Parameter("Dbar_p", ztf.constant(Dbar_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi)#, floating = False) +DDstar_s = zfit.Parameter("DDstar_s", ztf.constant(0.0), lower_limit=-0.3, upper_limit=0.3)#, floating = False) +Dstar_m = zfit.Parameter("Dstar_m", ztf.constant(Dstar_mass), floating = False) +D_m = zfit.Parameter("D_m", ztf.constant(D_mass), floating = False) +DDstar_p = zfit.Parameter("DDstar_p", ztf.constant(DDstar_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi)#, floating = False) + + +# ## Tau parameters + +# In[ ]: + + +tau_m = zfit.Parameter("tau_m", ztf.constant(pdg['tau_M']), floating = False) +Ctt = zfit.Parameter("Ctt", ztf.constant(0.0), lower_limit=-2.5, upper_limit=2.5) + + +# ## Load data + +# In[ ]: + + +x_min = 2*pdg['muon_M'] +x_max = (pdg["Bplus_M"]-pdg["Ks_M"]-0.1) + +# # Full spectrum + +obs_toy = zfit.Space('q', limits = (x_min, x_max)) + +# Jpsi and Psi2s cut out + +obs1 = zfit.Space('q', limits = (x_min, jpsi_mass - 60.)) +obs2 = zfit.Space('q', limits = (jpsi_mass + 70., psi2s_mass - 50.)) +obs3 = zfit.Space('q', limits = (psi2s_mass + 50., x_max)) + +obs_fit = obs1 + obs2 + obs3 + +# with open(r"./data/slim_points/slim_points_toy_0_range({0}-{1}).pkl".format(int(x_min), int(x_max)), "rb") as input_file: +# part_set = pkl.load(input_file) + +# x_part = part_set['x_part'] + +# x_part = x_part.astype('float64') + +# data = zfit.data.Data.from_numpy(array=x_part, obs=obs) + + +# ## Setup pdf + +# In[ ]: + + +total_f = total_pdf_cut(obs=obs_toy, jpsi_mass = jpsi_m, jpsi_scale = jpsi_s, jpsi_phase = jpsi_p, jpsi_width = jpsi_w, + psi2s_mass = psi2s_m, psi2s_scale = psi2s_s, psi2s_phase = psi2s_p, psi2s_width = psi2s_w, + p3770_mass = p3770_m, p3770_scale = p3770_s, p3770_phase = p3770_p, p3770_width = p3770_w, + p4040_mass = p4040_m, p4040_scale = p4040_s, p4040_phase = p4040_p, p4040_width = p4040_w, + p4160_mass = p4160_m, p4160_scale = p4160_s, p4160_phase = p4160_p, p4160_width = p4160_w, + p4415_mass = p4415_m, p4415_scale = p4415_s, p4415_phase = p4415_p, p4415_width = p4415_w, + rho_mass = rho_m, rho_scale = rho_s, rho_phase = rho_p, rho_width = rho_w, + omega_mass = omega_m, omega_scale = omega_s, omega_phase = omega_p, omega_width = omega_w, + phi_mass = phi_m, phi_scale = phi_s, phi_phase = phi_p, phi_width = phi_w, + Dstar_mass = Dstar_m, DDstar_scale = DDstar_s, DDstar_phase = DDstar_p, D_mass = D_m, + Dbar_mass = Dbar_m, Dbar_scale = Dbar_s, Dbar_phase = Dbar_p, + tau_mass = tau_m, C_tt = Ctt, b0_0 = b0_0, b0_1 = b0_1, b0_2 = b0_2, + bplus_0 = bplus_0, bplus_1 = bplus_1, bplus_2 = bplus_2, + bT_0 = bT_0, bT_1 = bT_1, bT_2 = bT_2) + +total_f_fit = total_pdf_full(obs=obs_fit, jpsi_mass = jpsi_m, jpsi_scale = jpsi_s, jpsi_phase = jpsi_p, jpsi_width = jpsi_w, + psi2s_mass = psi2s_m, psi2s_scale = psi2s_s, psi2s_phase = psi2s_p, psi2s_width = psi2s_w, + p3770_mass = p3770_m, p3770_scale = p3770_s, p3770_phase = p3770_p, p3770_width = p3770_w, + p4040_mass = p4040_m, p4040_scale = p4040_s, p4040_phase = p4040_p, p4040_width = p4040_w, + p4160_mass = p4160_m, p4160_scale = p4160_s, p4160_phase = p4160_p, p4160_width = p4160_w, + p4415_mass = p4415_m, p4415_scale = p4415_s, p4415_phase = p4415_p, p4415_width = p4415_w, + rho_mass = rho_m, rho_scale = rho_s, rho_phase = rho_p, rho_width = rho_w, + omega_mass = omega_m, omega_scale = omega_s, omega_phase = omega_p, omega_width = omega_w, + phi_mass = phi_m, phi_scale = phi_s, phi_phase = phi_p, phi_width = phi_w, + Dstar_mass = Dstar_m, DDstar_scale = DDstar_s, DDstar_phase = DDstar_p, D_mass = D_m, + Dbar_mass = Dbar_m, Dbar_scale = Dbar_s, Dbar_phase = Dbar_p, + tau_mass = tau_m, C_tt = Ctt, b0_0 = b0_0, b0_1 = b0_1, b0_2 = b0_2, + bplus_0 = bplus_0, bplus_1 = bplus_1, bplus_2 = bplus_2, + bT_0 = bT_0, bT_1 = bT_1, bT_2 = bT_2) + +# print(total_pdf.obs) + +# print(calcs_test) + +# for param in total_f.get_dependents(): +# print(zfit.run(param)) + + +# In[ ]: + + +# total_f_fit.normalization(obs_fit) + + +# ## Test if graphs actually work and compute values + +# In[ ]: + + +# def total_test_tf(xq): + +# def jpsi_res(q): +# return resonance(q, jpsi_m, jpsi_s, jpsi_p, jpsi_w) + +# def psi2s_res(q): +# return resonance(q, psi2s_m, psi2s_s, psi2s_p, psi2s_w) + +# def cusp(q): +# return bifur_gauss(q, cusp_m, sig_L, sig_R, cusp_s) + +# funcs = jpsi_res(xq) + psi2s_res(xq) + cusp(xq) + +# vec_f = vec(xq, funcs) + +# axiv_nr = axiv_nonres(xq) + +# tot = vec_f + axiv_nr + +# return tot + +# def jpsi_res(q): +# return resonance(q, jpsi_m, jpsi_s, jpsi_p, jpsi_w) + +# calcs = zfit.run(total_test_tf(x_part)) + + + +test_q = np.linspace(x_min, x_max, int(2e6)) + +probs = total_f_fit.pdf(test_q, norm_range=False) + +calcs_test = zfit.run(probs) + +Ctt.set_value(0.5) + +calcs_test1 = zfit.run(probs) + +Ctt.set_value(0.0) + +Dbar_s.set_value(0.3) + +DDstar_s.set_value(0.3) + +calcs_test2 = zfit.run(probs) +# res_y = zfit.run(jpsi_res(test_q)) +# b0 = [b0_0, b0_1, b0_2] +# bplus = [bplus_0, bplus_1, bplus_2] +# bT = [bT_0, bT_1, bT_2] +# f0_y = zfit.run(tf.math.real(formfactor(test_q,"0", b0, bplus, bT))) +# fplus_y = zfit.run(tf.math.real(formfactor(test_q,"+", b0, bplus, bT))) +# fT_y = zfit.run(tf.math.real(formfactor(test_q,"T", b0, bplus, bT))) + + +# In[ ]: + + +plt.clf() +# plt.plot(x_part, calcs, '.') +plt.plot(test_q, calcs_test, label = 'pdf (Ctt = 0.0)') +plt.plot(test_q, calcs_test1, label = 'pdf (Ctt = 0.5)') +plt.plot(test_q, calcs_test2, label = 'pdf (D-contribs = 0.3)') +# plt.plot(test_q, f0_y, label = '0') +# plt.plot(test_q, fT_y, label = 'T') +# plt.plot(test_q, fplus_y, label = '+') +# plt.plot(test_q, res_y, label = 'res') +plt.legend() +plt.ylim(0.0, 1.5e-6) +# plt.yscale('log') +# plt.xlim(770, 785) +plt.savefig('test.png') +# print(jpsi_width) + + +# In[ ]: + + + + +# probs = mixture.prob(test_q) +# probs_np = zfit.run(probs) +# probs_np *= np.max(calcs_test) / np.max(probs_np) +# plt.figure() +# plt.semilogy(test_q, probs_np,label="importance sampling") +# plt.semilogy(test_q, calcs_test, label = 'pdf') + + +# In[ ]: + + +# 0.213/(0.00133+0.213+0.015) + + +# ## Adjust scaling of different parts + +# In[ ]: + + +total_f.update_integration_options(draws_per_dim=2000000, mc_sampler=None) +# inte = total_f.integrate(limits = (950., 1050.), norm_range=False) +# inte_fl = zfit.run(inte) +# print(inte_fl/4500) +# print(pdg["jpsi_BR"]/pdg["NR_BR"], inte_fl*pdg["psi2s_auc"]/pdg["NR_auc"]) + + +# In[ ]: + + +# # print("jpsi:", inte_fl) +# # print("Increase am by factor:", np.sqrt(pdg["jpsi_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) +# # print("New amp:", pdg["jpsi"][3]*np.sqrt(pdg["jpsi_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) + +# # print("psi2s:", inte_fl) +# # print("Increase am by factor:", np.sqrt(pdg["psi2s_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) +# # print("New amp:", pdg["psi2s"][3]*np.sqrt(pdg["psi2s_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) + +# name = "phi" + +# print(name+":", inte_fl) +# print("Increase am by factor:", np.sqrt(pdg[name+"_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) +# print("New amp:", pdg[name][0]*np.sqrt(pdg[name+"_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) + + +# print(x_min) +# print(x_max) +# # total_f.update_integration_options(draws_per_dim=2000000, mc_sampler=None) +# total_f.update_integration_options(mc_sampler=lambda dim, num_results, +# dtype: tf.random_uniform(maxval=1., shape=(num_results, dim), dtype=dtype), +# draws_per_dim=1000000) +# # _ = [] + +# # for i in range(10): + +# # inte = total_f.integrate(limits = (x_min, x_max)) +# # inte_fl = zfit.run(inte) +# # print(inte_fl) +# # _.append(inte_fl) + +# # print("mean:", np.mean(_)) + +# _ = time.time() + +# inte = total_f.integrate(limits = (x_min, x_max)) +# inte_fl = zfit.run(inte) +# print(inte_fl) +# print("Time taken: {}".format(display_time(int(time.time() - _)))) + +# print(pdg['NR_BR']/pdg['NR_auc']*inte_fl) +# print(0.25**2*4.2/1000) + + +# # Sampling +# ## Mixture distribution for sampling + +# In[ ]: + + + + +# print(list_of_borders[:9]) +# print(list_of_borders[-9:]) + + +class UniformSampleAndWeights(zfit.util.execution.SessionHolderMixin): + def __call__(self, limits, dtype, n_to_produce): + # n_to_produce = tf.cast(n_to_produce, dtype=tf.int32) + low, high = limits.limit1d + low = tf.cast(low, dtype=dtype) + high = tf.cast(high, dtype=dtype) +# uniform = tfd.Uniform(low=low, high=high) +# uniformjpsi = tfd.Uniform(low=tf.constant(3080, dtype=dtype), high=tf.constant(3112, dtype=dtype)) +# uniformpsi2s = tfd.Uniform(low=tf.constant(3670, dtype=dtype), high=tf.constant(3702, dtype=dtype)) + +# list_of_borders = [] +# _p = [] +# splits = 10 + +# _ = np.linspace(x_min, x_max, splits) + +# for i in range(splits): +# list_of_borders.append(tf.constant(_[i], dtype=dtype)) +# _p.append(tf.constant(1/splits, dtype=dtype)) + +# mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=_p[:(splits-1)]), +# components_distribution=tfd.Uniform(low=list_of_borders[:(splits-1)], +# high=list_of_borders[-(splits-1):])) + mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=[tf.constant(0.05, dtype=dtype), + tf.constant(0.93, dtype=dtype), + tf.constant(0.05, dtype=dtype), + tf.constant(0.065, dtype=dtype), + tf.constant(0.04, dtype=dtype), + tf.constant(0.05, dtype=dtype)]), + components_distribution=tfd.Uniform(low=[tf.constant(x_min, dtype=dtype), + tf.constant(3090, dtype=dtype), + tf.constant(3681, dtype=dtype), + tf.constant(3070, dtype=dtype), + tf.constant(1000, dtype=dtype), + tf.constant(3660, dtype=dtype)], + high=[tf.constant(x_max, dtype=dtype), + tf.constant(3102, dtype=dtype), + tf.constant(3691, dtype=dtype), + tf.constant(3110, dtype=dtype), + tf.constant(1040, dtype=dtype), + tf.constant(3710, dtype=dtype)])) +# dtype = tf.float64 +# mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=[tf.constant(0.04, dtype=dtype), +# tf.constant(0.90, dtype=dtype), +# tf.constant(0.02, dtype=dtype), +# tf.constant(0.07, dtype=dtype), +# tf.constant(0.02, dtype=dtype)]), +# components_distribution=tfd.Uniform(low=[tf.constant(x_min, dtype=dtype), +# tf.constant(3089, dtype=dtype), +# tf.constant(3103, dtype=dtype), +# tf.constant(3681, dtype=dtype), +# tf.constant(3691, dtype=dtype)], +# high=[tf.constant(3089, dtype=dtype), +# tf.constant(3103, dtype=dtype), +# tf.constant(3681, dtype=dtype), +# tf.constant(3691, dtype=dtype), +# tf.constant(x_max, dtype=dtype)])) +# mixture = tfd.Uniform(tf.constant(x_min, dtype=dtype), tf.constant(x_max, dtype=dtype)) +# sample = tf.random.uniform((n_to_produce, 1), dtype=dtype) + sample = mixture.sample((n_to_produce, 1)) +# sample = tf.random.uniform((n_to_produce, 1), dtype=dtype) + weights = mixture.prob(sample)[:,0] +# weights = tf.broadcast_to(tf.constant(1., dtype=dtype), shape=(n_to_produce,)) + # sample = tf.expand_dims(sample, axis=-1) +# print(sample, weights) + +# weights = tf.ones(shape=(n_to_produce,), dtype=dtype) + weights_max = None + thresholds = tf.random_uniform(shape=(n_to_produce,), dtype=dtype) + return sample, thresholds, weights, weights_max, n_to_produce + + +# In[ ]: + + +# total_f._sample_and_weights = UniformSampleAndWeights + + +# In[ ]: + + +# 0.00133/(0.00133+0.213+0.015)*(x_max-3750)/(x_max-x_min) + + +# In[ ]: + + +# zfit.settings.set_verbosity(10) + + +# In[ ]: + + +# # zfit.run.numeric_checks = False + +# nr_of_toys = 1 +# nevents = int(pdg["number_of_decays"]) +# nevents = pdg["number_of_decays"] +# event_stack = 1000000 +# # zfit.settings.set_verbosity(10) +# calls = int(nevents/event_stack + 1) + +# total_samp = [] + +# start = time.time() + +# sampler = total_f.create_sampler(n=event_stack) + +# for toy in range(nr_of_toys): + +# dirName = 'data/zfit_toys/toy_{0}'.format(toy) + +# if not os.path.exists(dirName): +# os.mkdir(dirName) +# print("Directory " , dirName , " Created ") + +# for call in range(calls): + +# sampler.resample(n=event_stack) +# s = sampler.unstack_x() +# sam = zfit.run(s) +# # clear_output(wait=True) + +# c = call + 1 + +# print("{0}/{1} of Toy {2}/{3}".format(c, calls, toy+1, nr_of_toys)) +# print("Time taken: {}".format(display_time(int(time.time() - start)))) +# print("Projected time left: {}".format(display_time(int((time.time() - start)/(c+calls*(toy))*((nr_of_toys-toy)*calls-c))))) + +# with open("data/zfit_toys/toy_{0}/{1}.pkl".format(toy, call), "wb") as f: +# pkl.dump(sam, f, pkl.HIGHEST_PROTOCOL) + + +# In[ ]: + + +# with open(r"data/zfit_toys/toy_0/0.pkl", "rb") as input_file: +# sam = pkl.load(input_file) +# print(sam[:10]) + +# with open(r"data/zfit_toys/toy_0/1.pkl", "rb") as input_file: +# sam2 = pkl.load(input_file) +# print(sam2[:10]) + +# print(np.sum(sam-sam2)) + + +# In[ ]: + + +# print("Time to generate full toy: {} s".format(int(time.time()-start))) + +# total_samp = [] + +# for call in range(calls): +# with open(r"data/zfit_toys/toy_0/{}.pkl".format(call), "rb") as input_file: +# sam = pkl.load(input_file) +# total_samp = np.append(total_samp, sam) + +# total_samp = total_samp.astype('float64') + +# data2 = zfit.data.Data.from_numpy(array=total_samp[:int(nevents)], obs=obs) + +# data3 = zfit.data.Data.from_numpy(array=total_samp, obs=obs) + +# print(total_samp[:nevents].shape) + + +# In[ ]: + + +# plt.clf() + +# bins = int((x_max-x_min)/7) + +# # calcs = zfit.run(total_test_tf(samp)) +# print(total_samp[:nevents].shape) + +# plt.hist(total_samp[:nevents], bins = bins, range = (x_min,x_max), label = 'data') +# # plt.plot(test_q, calcs_test*nevents , label = 'pdf') + +# # plt.plot(sam, calcs, '.') +# # plt.plot(test_q, calcs_test) +# # plt.yscale('log') +# plt.ylim(0, 200) +# # plt.xlim(3080, 3110) + +# plt.legend() + +# plt.savefig('test2.png') + + +# In[ ]: + + +# sampler = total_f.create_sampler(n=nevents) +# nll = zfit.loss.UnbinnedNLL(model=total_f, data=sampler, fit_range = (x_min, x_max)) + +# # for param in pdf.get_dependents(): +# # param.set_value(initial_value) + +# sampler.resample(n=nevents) + +# # Randomise initial values +# # for param in pdf.get_dependents(): +# # param.set_value(random value here) + +# # Minimise the NLL +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 10) +# minimum = minimizer.minimize(nll) + + +# In[ ]: + + +# jpsi_width + + +# In[ ]: + + +# plt.hist(sample, weights=1 / prob(sample)) + + +# # Fitting + +# In[ ]: + + +# start = time.time() + +# for param in total_f.get_dependents(): +# param.randomize() + +# # for param in total_f.get_dependents(): +# # print(zfit.run(param)) + +# nll = zfit.loss.UnbinnedNLL(model=total_f, data=data2, fit_range = (x_min, x_max)) + +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) +# # minimizer._use_tfgrad = False +# result = minimizer.minimize(nll) + +# # param_errors = result.error() + +# # for var, errors in param_errors.items(): +# # print('{}: ^{{+{}}}_{{{}}}'.format(var.name, errors['upper'], errors['lower'])) + +# print("Function minimum:", result.fmin) +# # print("Results:", result.params) +# print("Hesse errors:", result.hesse()) + + +# In[ ]: + + +# print("Time taken for fitting: {}".format(display_time(int(time.time()-start)))) + +# # probs = total_f.pdf(test_q) + +# calcs_test = zfit.run(probs) +# res_y = zfit.run(jpsi_res(test_q)) + + +# In[ ]: + + +# plt.clf() +# # plt.plot(x_part, calcs, '.') +# plt.plot(test_q, calcs_test, label = 'pdf') +# # plt.plot(test_q, res_y, label = 'res') +# plt.legend() +# plt.ylim(0.0, 10e-6) +# # plt.yscale('log') +# # plt.xlim(3080, 3110) +# plt.savefig('test3.png') +# # print(jpsi_width) + + +# In[ ]: + + +# _tot = 4.37e-7+6.02e-5+4.97e-6 +# _probs = [] +# _probs.append(6.02e-5/_tot) +# _probs.append(4.97e-6/_tot) +# _probs.append(4.37e-7/_tot) +# print(_probs) + + +# In[ ]: + + +# dtype = 'float64' +# # mixture = tfd.Uniform(tf.constant(x_min, dtype=dtype), tf.constant(x_max, dtype=dtype)) +# mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=[tf.constant(0.007, dtype=dtype), +# tf.constant(0.917, dtype=dtype), +# tf.constant(0.076, dtype=dtype)]), +# components_distribution=tfd.Uniform(low=[tf.constant(x_min, dtype=dtype), +# tf.constant(3080, dtype=dtype), +# tf.constant(3670, dtype=dtype)], +# high=[tf.constant(x_max, dtype=dtype), +# tf.constant(3112, dtype=dtype), +# tf.constant(3702, dtype=dtype)])) +# # for i in range(10): +# # print(zfit.run(mixture.prob(mixture.sample((10, 1))))) + + +# In[ ]: + + +# print((zfit.run(jpsi_p)%(2*np.pi))/np.pi) +# print((zfit.run(psi2s_p)%(2*np.pi))/np.pi) + + +# In[ ]: + + +# def jpsi_res(q): +# return resonance(q, _mass = jpsi_mass, scale = jpsi_scale, +# phase = jpsi_phase, width = jpsi_width) + +# def psi2s_res(q): +# return resonance(q, _mass = psi2s_mass, scale = psi2s_scale, +# phase = psi2s_phase, width = psi2s_width) + +# def p3770_res(q): +# return resonance(q, _mass = p3770_mass, scale = p3770_scale, +# phase = p3770_phase, width = p3770_width) + +# def p4040_res(q): +# return resonance(q, _mass = p4040_mass, scale = p4040_scale, +# phase = p4040_phase, width = p4040_width) + +# def p4160_res(q): +# return resonance(q, _mass = p4160_mass, scale = p4160_scale, +# phase = p4160_phase, width = p4160_width) + +# def p4415_res(q): +# return resonance(q, _mass = p4415_mass, scale = p4415_scale, +# phase = p4415_phase, width = p4415_width) + + +# In[ ]: + + +# 0.15**2*4.2/1000 +# result.hesse() + + +# ## Constraints + +# In[ ]: + + +# 1. Constraint - Real part of sum of Psi contrib and D contribs + +sum_list = [] + +sum_list.append(ztf.to_complex(jpsi_s) * tf.exp(tf.complex(ztf.constant(0.0), jpsi_p)) * ztf.to_complex(jpsi_w / (tf.pow(jpsi_m,3)))) +sum_list.append(ztf.to_complex(psi2s_s) * tf.exp(tf.complex(ztf.constant(0.0), psi2s_p)) * ztf.to_complex(psi2s_w / (tf.pow(psi2s_m,3)))) +sum_list.append(ztf.to_complex(p3770_s) * tf.exp(tf.complex(ztf.constant(0.0), p3770_p)) * ztf.to_complex(p3770_w / (tf.pow(p3770_m,3)))) +sum_list.append(ztf.to_complex(p4040_s) * tf.exp(tf.complex(ztf.constant(0.0), p4040_p)) * ztf.to_complex(p4040_w / (tf.pow(p4040_m,3)))) +sum_list.append(ztf.to_complex(p4160_s) * tf.exp(tf.complex(ztf.constant(0.0), p4160_p)) * ztf.to_complex(p4160_w / (tf.pow(p4160_m,3)))) +sum_list.append(ztf.to_complex(p4415_s) * tf.exp(tf.complex(ztf.constant(0.0), p4415_p)) * ztf.to_complex(p4415_w / (tf.pow(p4415_m,3)))) +sum_list.append(ztf.to_complex(DDstar_s) * tf.exp(tf.complex(ztf.constant(0.0), DDstar_p)) * (ztf.to_complex(1.0 / (10.0*tf.pow(Dstar_m,2)) + 1.0 / (10.0*tf.pow(D_m,2))))) +sum_list.append(ztf.to_complex(Dbar_s) * tf.exp(tf.complex(ztf.constant(0.0), Dbar_p)) * ztf.to_complex(1.0 / (6.0*tf.pow(Dbar_m,2)))) + +sum_ru_1 = ztf.to_complex(ztf.constant(0.0)) + +for part in sum_list: + sum_ru_1 += part + +sum_1 = tf.math.real(sum_ru_1) +# constraint1 = zfit.constraint.GaussianConstraint(params = sum_1, mu = ztf.constant(1.7*10**-8), +# sigma = ztf.constant(2.2*10**-8)) + +constraint1 = tf.pow((sum_1-ztf.constant(1.7*10**-8))/ztf.constant(2.2*10**-8),2)/ztf.constant(2.) + +# 2. Constraint - Abs. of sum of Psi contribs and D contribs + +sum_2 = tf.abs(sum_ru_1) +constraint2 = tf.cond(tf.greater_equal(sum_2, 5.0e-8), lambda: 100000., lambda: 0.) + +# 3. Constraint - Maximum eta of D contribs + +constraint3_0 = tf.cond(tf.greater_equal(tf.abs(Dbar_s), 0.2), lambda: 100000., lambda: 0.) + +constraint3_1 = tf.cond(tf.greater_equal(tf.abs(DDstar_s), 0.2), lambda: 100000., lambda: 0.) + +# 4. Constraint - Formfactor multivariant gaussian covariance fplus + +Cov_matrix = [[ztf.constant( 1.), ztf.constant( 0.45), ztf.constant( 0.19), ztf.constant(0.857), ztf.constant(0.598), ztf.constant(0.531), ztf.constant(0.752), ztf.constant(0.229), ztf.constant(0,117)], + [ztf.constant( 0.45), ztf.constant( 1.), ztf.constant(0.677), ztf.constant(0.708), ztf.constant(0.958), ztf.constant(0.927), ztf.constant(0.227), ztf.constant(0.443), ztf.constant(0.287)], + [ztf.constant( 0.19), ztf.constant(0.677), ztf.constant( 1.), ztf.constant(0.595), ztf.constant(0.770), ztf.constant(0.819),ztf.constant(-0.023), ztf.constant( 0.07), ztf.constant(0.196)], + [ztf.constant(0.857), ztf.constant(0.708), ztf.constant(0.595), ztf.constant( 1.), ztf.constant( 0.83), ztf.constant(0.766), ztf.constant(0.582), ztf.constant(0.237), ztf.constant(0.192)], + [ztf.constant(0.598), ztf.constant(0.958), ztf.constant(0.770), ztf.constant( 0.83), ztf.constant( 1.), ztf.constant(0.973), ztf.constant(0.324), ztf.constant(0.372), ztf.constant(0.272)], + [ztf.constant(0.531), ztf.constant(0.927), ztf.constant(0.819), ztf.constant(0.766), ztf.constant(0.973), ztf.constant( 1.), ztf.constant(0.268), ztf.constant(0.332), ztf.constant(0.269)], + [ztf.constant(0.752), ztf.constant(0.227),ztf.constant(-0.023), ztf.constant(0.582), ztf.constant(0.324), ztf.constant(0.268), ztf.constant( 1.), ztf.constant( 0.59), ztf.constant(0.515)], + [ztf.constant(0.229), ztf.constant(0.443), ztf.constant( 0.07), ztf.constant(0.237), ztf.constant(0.372), ztf.constant(0.332), ztf.constant( 0.59), ztf.constant( 1.), ztf.constant(0.897)], + [ztf.constant(0.117), ztf.constant(0.287), ztf.constant(0.196), ztf.constant(0.192), ztf.constant(0.272), ztf.constant(0.269), ztf.constant(0.515), ztf.constant(0.897), ztf.constant( 1.)]] + +def triGauss(val1,val2,val3,m = Cov_matrix): + + mean1 = ztf.constant(0.466) + mean2 = ztf.constant(-0.885) + mean3 = ztf.constant(-0.213) + sigma1 = ztf.constant(0.014) + sigma2 = ztf.constant(0.128) + sigma3 = ztf.constant(0.548) + x1 = (val1-mean1)/sigma1 + x2 = (val2-mean2)/sigma2 + x3 = (val3-mean3)/sigma3 + rho12 = m[0][1] + rho13 = m[0][2] + rho23 = m[1][2] + w = x1*x1*(rho23*rho23-1) + x2*x2*(rho13*rho13-1)+x3*x3*(rho12*rho12-1)+2*(x1*x2*(rho12-rho13*rho23)+x1*x3*(rho13-rho12*rho23)+x2*x3*(rho23-rho12*rho13)) + d = 2*(rho12*rho12+rho13*rho13+rho23*rho23-2*rho12*rho13*rho23-1) + + fcn = -w/d + chisq = -2*fcn + return chisq + +constraint4 = triGauss(bplus_0, bplus_1, bplus_2) + +# mean1 = ztf.constant(0.466) +# mean2 = ztf.constant(-0.885) +# mean3 = ztf.constant(-0.213) +# sigma1 = ztf.constant(0.014) +# sigma2 = ztf.constant(0.128) +# sigma3 = ztf.constant(0.548) +# constraint4_0 = tf.pow((bplus_0-mean1)/sigma1,2)/ztf.constant(2.) +# constraint4_1 = tf.pow((bplus_1-mean2)/sigma2,2)/ztf.constant(2.) +# constraint4_2 = tf.pow((bplus_2-mean3)/sigma3,2)/ztf.constant(2.) + +# 5. Constraint - Abs. of sum of light contribs + +sum_list_5 = [] + +sum_list_5.append(rho_s*rho_w/rho_m) +sum_list_5.append(omega_s*omega_w/omega_m) +sum_list_5.append(phi_s*phi_w/phi_m) + + +sum_ru_5 = ztf.constant(0.0) + +for part in sum_list_5: + sum_ru_5 += part + +constraint5 = tf.cond(tf.greater_equal(tf.abs(sum_ru_5), ztf.constant(0.02)), lambda: 100000., lambda: 0.) + +# 6. Constraint on phases of Jpsi and Psi2s for cut out fit + + +# constraint6_0 = zfit.constraint.GaussianConstraint(params = jpsi_p, mu = ztf.constant(pdg["jpsi_phase_unc"]), +# sigma = ztf.constant(jpsi_phase)) +# constraint6_1 = zfit.constraint.GaussianConstraint(params = psi2s_p, mu = ztf.constant(pdg["psi2s_phase_unc"]), +# sigma = ztf.constant(psi2s_phase)) + +constraint6_0 = tf.pow((jpsi_p-ztf.constant(jpsi_phase))/ztf.constant(pdg["jpsi_phase_unc"]),2)/ztf.constant(2.) +constraint6_1 = tf.pow((psi2s_p-ztf.constant(psi2s_phase))/ztf.constant(pdg["psi2s_phase_unc"]),2)/ztf.constant(2.) + +# 7. Constraint on Ctt with higher limits + +constraint7 = tf.cond(tf.greater_equal(Ctt*Ctt, 0.25), lambda: 100000., lambda: 0.) + +constraint7dtype = tf.float64 + +# zfit.run(constraint6_0) + +# ztf.convert_to_tensor(constraint6_0) + +#List of all constraints + +constraints = [constraint1, constraint2, constraint3_0, constraint3_1,# constraint4, #constraint4_0, constraint4_1, constraint4_2, + constraint6_0, constraint6_1]#, constraint7] + + +# ## Reset params + +# In[ ]: + + +param_values_dic = { + 'jpsi_m': jpsi_mass, + 'jpsi_s': jpsi_scale, + 'jpsi_p': jpsi_phase, + 'jpsi_w': jpsi_width, + 'psi2s_m': psi2s_mass, + 'psi2s_s': psi2s_scale, + 'psi2s_p': psi2s_phase, + 'psi2s_w': psi2s_width, + 'p3770_m': p3770_mass, + 'p3770_s': p3770_scale, + 'p3770_p': p3770_phase, + 'p3770_w': p3770_width, + 'p4040_m': p4040_mass, + 'p4040_s': p4040_scale, + 'p4040_p': p4040_phase, + 'p4040_w': p4040_width, + 'p4160_m': p4160_mass, + 'p4160_s': p4160_scale, + 'p4160_p': p4160_phase, + 'p4160_w': p4160_width, + 'p4415_m': p4415_mass, + 'p4415_s': p4415_scale, + 'p4415_p': p4415_phase, + 'p4415_w': p4415_width, + 'rho_m': rho_mass, + 'rho_s': rho_scale, + 'rho_p': rho_phase, + 'rho_w': rho_width, + 'omega_m': omega_mass, + 'omega_s': omega_scale, + 'omega_p': omega_phase, + 'omega_w': omega_width, + 'phi_m': phi_mass, + 'phi_s': phi_scale, + 'phi_p': phi_phase, + 'phi_w': phi_width, + 'Dstar_m': Dstar_mass, + 'DDstar_s': 0.0, + 'DDstar_p': 0.0, + 'D_m': D_mass, + 'Dbar_m': Dbar_mass, + 'Dbar_s': 0.0, + 'Dbar_p': 0.0, + 'tau_m': pdg['tau_M'], + 'Ctt': 0.0, + 'b0_0': 0.292, + 'b0_1': 0.281, + 'b0_2': 0.150, + 'bplus_0': 0.466, + 'bplus_1': -0.885, + 'bplus_2': -0.213, + 'bT_0': 0.460, + 'bT_1': -1.089, + 'bT_2': -1.114} + + +def reset_param_values(variation = 0.05): + for param in total_f_fit.get_dependents(): + if param.floating: + param.set_value(param_values_dic[param.name] + random.uniform(-1, 1) * param_values_dic[param.name]* variation) +# print(param.name) +# for param in totalf.get_dependents(): +# param.set_value() + + +# # Analysis + +# In[ ]: + + +# # zfit.run.numeric_checks = False + +# fitting_range = 'cut' +# total_BR = 1.7e-10 + 4.9e-10 + 2.5e-9 + 6.02e-5 + 4.97e-6 + 1.38e-9 + 4.2e-10 + 2.6e-9 + 6.1e-10 + 4.37e-7 +# cut_BR = 1.0 - (6.02e-5 + 4.97e-6)/total_BR + +# Ctt_list = [] +# Ctt_error_list = [] + +# nr_of_toys = 1 +# if fitting_range == 'cut': +# nevents = int(pdg["number_of_decays"]*cut_BR) +# else: +# nevents = int(pdg["number_of_decays"]) +# # nevents = pdg["number_of_decays"] +# event_stack = 1000000 +# # nevents *= 41 +# # zfit.settings.set_verbosity(10) +# calls = int(nevents/event_stack + 1) + +# total_samp = [] + +# start = time.time() + +# sampler = total_f.create_sampler(n=event_stack) + +# for toy in range(nr_of_toys): + +# ### Generate data + +# # clear_output(wait=True) + +# print("Toy {}: Generating data...".format(toy)) + +# dirName = 'data/zfit_toys/toy_{0}'.format(toy) + +# if not os.path.exists(dirName): +# os.mkdir(dirName) +# print("Directory " , dirName , " Created ") + +# reset_param_values() + +# if fitting_range == 'cut': + +# sampler.resample(n=nevents) +# s = sampler.unstack_x() +# sam = zfit.run(s) +# calls = 0 +# c = 1 + +# else: +# for call in range(calls): + +# sampler.resample(n=event_stack) +# s = sampler.unstack_x() +# sam = zfit.run(s) + +# c = call + 1 + +# with open("data/zfit_toys/toy_{0}/{1}.pkl".format(toy, call), "wb") as f: +# pkl.dump(sam, f, pkl.HIGHEST_PROTOCOL) + +# print("Toy {}: Data generation finished".format(toy)) + +# ### Load data + +# print("Toy {}: Loading data...".format(toy)) + +# if fitting_range == 'cut': + +# total_samp = sam + +# else: + +# for call in range(calls): +# with open(r"data/zfit_toys/toy_0/{}.pkl".format(call), "rb") as input_file: +# sam = pkl.load(input_file) +# total_samp = np.append(total_samp, sam) + +# total_samp = total_samp.astype('float64') + +# if fitting_range == 'full': + +# data = zfit.data.Data.from_numpy(array=total_samp[:int(nevents)], obs=obs) + +# print("Toy {}: Loading data finished".format(toy)) + +# ### Fit data + +# print("Toy {}: Fitting pdf...".format(toy)) + +# for param in total_f.get_dependents(): +# param.randomize() + +# nll = zfit.loss.UnbinnedNLL(model=total_f, data=data, fit_range = (x_min, x_max), constraints = constraints) + +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) +# # minimizer._use_tfgrad = False +# result = minimizer.minimize(nll) + +# print("Toy {}: Fitting finished".format(toy)) + +# print("Function minimum:", result.fmin) +# print("Hesse errors:", result.hesse()) + +# params = result.params +# Ctt_list.append(params[Ctt]['value']) +# Ctt_error_list.append(params[Ctt]['minuit_hesse']['error']) + +# #plotting the result + +# plotdirName = 'data/plots'.format(toy) + +# if not os.path.exists(plotdirName): +# os.mkdir(plotdirName) +# # print("Directory " , dirName , " Created ") + +# probs = total_f.pdf(test_q, norm_range=False) +# calcs_test = zfit.run(probs) +# plt.clf() +# plt.plot(test_q, calcs_test, label = 'pdf') +# plt.legend() +# plt.ylim(0.0, 6e-6) +# plt.savefig(plotdirName + '/toy_fit_full_range{}.png'.format(toy)) + +# print("Toy {0}/{1}".format(toy+1, nr_of_toys)) +# print("Time taken: {}".format(display_time(int(time.time() - start)))) +# print("Projected time left: {}".format(display_time(int((time.time() - start)/(c+calls*(toy))*((nr_of_toys-toy)*calls-c))))) + +# if fitting_range == 'cut': + +# _1 = np.where((total_samp >= x_min) & (total_samp <= (jpsi_mass - 60.))) + +# tot_sam_1 = total_samp[_1] + +# _2 = np.where((total_samp >= (jpsi_mass + 70.)) & (total_samp <= (psi2s_mass - 50.))) + +# tot_sam_2 = total_samp[_2] + +# _3 = np.where((total_samp >= (psi2s_mass + 50.)) & (total_samp <= x_max)) + +# tot_sam_3 = total_samp[_3] + +# tot_sam = np.append(tot_sam_1, tot_sam_2) +# tot_sam = np.append(tot_sam, tot_sam_3) + +# data = zfit.data.Data.from_numpy(array=tot_sam[:int(nevents)], obs=obs_fit) + +# print("Toy {}: Loading data finished".format(toy)) + +# ### Fit data + +# print("Toy {}: Fitting pdf...".format(toy)) + +# for param in total_f_fit.get_dependents(): +# param.randomize() + +# nll = zfit.loss.UnbinnedNLL(model=total_f_fit, data=data, constraints = constraints) + +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) +# # minimizer._use_tfgrad = False +# result = minimizer.minimize(nll) + +# print("Function minimum:", result.fmin) +# print("Hesse errors:", result.hesse()) + +# params = result.params + +# if result.converged: +# Ctt_list.append(params[Ctt]['value']) +# Ctt_error_list.append(params[Ctt]['minuit_hesse']['error']) + +# #plotting the result + +# plotdirName = 'data/plots'.format(toy) + +# if not os.path.exists(plotdirName): +# os.mkdir(plotdirName) +# # print("Directory " , dirName , " Created ") + +# plt.clf() +# plt.hist(tot_sam, bins = int((x_max-x_min)/7.), label = 'toy data') +# plt.savefig(plotdirName + '/toy_histo_cut_region{}.png'.format(toy)) + + +# probs = total_f_fit.pdf(test_q, norm_range=False) +# calcs_test = zfit.run(probs) +# plt.clf() +# plt.plot(test_q, calcs_test, label = 'pdf') +# plt.axvline(x=jpsi_mass-60.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.axvline(x=jpsi_mass+70.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.axvline(x=psi2s_mass-50.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.axvline(x=psi2s_mass+50.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.legend() +# plt.ylim(0.0, 1.5e-6) +# plt.savefig(plotdirName + '/toy_fit_cut_region{}.png'.format(toy)) + +# print("Toy {0}/{1}".format(toy+1, nr_of_toys)) +# print("Time taken: {}".format(display_time(int(time.time() - start)))) +# print("Projected time left: {}".format(display_time(int((time.time() - start)/(toy+1))*((nr_of_toys-toy-1))))) + + + +# In[ ]: + + +# with open("data/results/Ctt_list.pkl", "wb") as f: +# pkl.dump(Ctt_list, f, pkl.HIGHEST_PROTOCOL) +# with open("data/results/Ctt_error_list.pkl", "wb") as f: +# pkl.dump(Ctt_error_list, f, pkl.HIGHEST_PROTOCOL) + + +# In[ ]: + + +# print('{0}/{1} fits converged'.format(len(Ctt_list), nr_of_toys)) +# print('Mean Ctt value = {}'.format(np.mean(Ctt_list))) +# print('Mean Ctt error = {}'.format(np.mean(Ctt_error_list))) +# print('95 Sensitivy = {}'.format(((2*np.mean(Ctt_error_list))**2)*4.2/1000)) + + +# In[ ]: + + +# plt.hist(tot_sam, bins = int((x_max-x_min)/7.)) + +# plt.show() + +# # _ = np.where((total_samp >= x_min) & (total_samp <= (jpsi_mass - 50.))) + +# tot_sam.shape + + +# In[ ]: + + +# Ctt.floating = False + + +# In[ ]: + + +# zfit.run(nll.value()) + + +# In[ ]: + + +# result.fmin + + +# In[ ]: + + +# BR_steps = np.linspace(0.0, 1e-3, 11) +pull_dic = {} + +mi = 1e-4 +ma = 3e-3 +ste = 20 + +for param in total_f_fit.get_dependents(): + if param.floating: + pull_dic[param.name] = [] + for step in range(2*ste): + pull_dic[param.name].append([]) + + + +def save_pulls(step): + for param in total_f_fit.get_dependents(): + if param.floating: + pull_dic[param.name][step].append((params[param]['value'] - param_values_dic[param.name])/params[param]['minuit_hesse']['error']) + + + +# for key in pull_dic.keys(): +# print(np.shape(pull_dic[key])) +# save_pulls(New_step=True) +# params[Ctt]['value'] + + +# In[ ]: + + +# for param in total_f_fit.get_dependents(): +# if param.floating: +# print(param.name) + +# print(params[Ctt]) + + +# # CLS Code + +# In[ ]: + + +# zfit.run.numeric_checks = False + +load = False + +bo = True + +D_contribs = True + +if not D_contribs: + Dbar_s.floating = False + Dbar_p.floating = False + DDstar_s.floating = False + DDstar_p.floating = False + +bo_set = 1 + +fitting_range = 'cut' +total_BR = 1.7e-10 + 4.9e-10 + 2.5e-9 + 6.02e-5 + 4.97e-6 + 1.38e-9 + 4.2e-10 + 2.6e-9 + 6.1e-10 + 4.37e-7 +cut_BR = 1.0 - (6.02e-5 + 4.97e-6)/total_BR + +Ctt_list = [] +Ctt_error_list = [] + +nr_of_toys = 1 +nevents = int(pdg["number_of_decays"]*cut_BR) +# nevents = pdg["number_of_decays"] +event_stack = 1000000 +# nevents *= 41 +# zfit.settings.set_verbosity(10) + +# mi = 1e-4 +# ma = 3e-3 +# ste = 13 + +BR_steps = np.linspace(mi, ma, ste) + +BR_steps[0] = 0.0 + +print(BR_steps) + +Ctt_steps = np.sqrt(BR_steps/4.2*1000) + +print(Ctt_steps) + +# total_samp = [] + +start = time.time() + +Nll_list = [] + +sampler = total_f.create_sampler(n=nevents, fixed_params = False) +sampler.set_data_range(obs_fit) + +__ = -1 + +#----------------------------------------------------- + +if not load: + for Ctt_step in Ctt_steps: + + __ += 1 + + for i in range(2): + Ctt_list.append([]) + Ctt_error_list.append([]) + Nll_list.append([]) + + for param in total_f_fit.get_dependents(): + if param.floating: + pull_dic[param.name].append([]) + + for toy in range(nr_of_toys): + + newset = True + + while newset: + + for floaty in [True, False]: + Ctt.floating = floaty + + for bo_step in range(bo_set): + + print('Step: {0}/{1}'.format(int(__), ste)) + print('Current Ctt: {0}'.format(Ctt_step)) + print('Ctt floating: {0}'.format(floaty)) + + reset_param_values(variation = 0.0) + + if floaty: + print('Toy {0}/{1} - Fit {2}/{3}'.format(toy, nr_of_toys, bo_step, bo_set)) + Ctt.set_value(Ctt_step) + + else: + Ctt.set_value(0.0) + print('Toy {0}/{1} - Fit {2}/{3}'.format(toy, nr_of_toys, bo_step, bo_set)) + + if newset: + sampler.resample(n=nevents) + data = sampler + newset = False + + ### Fit data + + if floaty: + #plt.clf() + #plt.title('Ctt value: {:.2f}'.format(Ctt_step)) + #plt.hist(zfit.run(data), bins = int((x_max-x_min)/7), range = (x_min, x_max)) + #plt.savefig('data/CLs/plots/set_histo{}.png'.format(__)) + _step = 2*__ + else: + _step = 2*__+1 + + nll = zfit.loss.UnbinnedNLL(model=total_f_fit, data=data, constraints = constraints) + + minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) + # minimizer._use_tfgrad = False + result = minimizer.minimize(nll) + + print("Function minimum:", result.fmin) + print("Hesse errors:", result.hesse()) + + params = result.params + + if result.converged: + + save_pulls(step = _step) + + if floaty: + Nll_list[-2].append(result.fmin) + Ctt_list[-2].append(params[Ctt]['value']) + Ctt_error_list[-2].append(params[Ctt]['minuit_hesse']['error']) + + else: + Nll_list[-1].append(result.fmin) + Ctt_list[-1].append(0.0) + Ctt_error_list[-1].append(0.0) + + + else: + for _ in [1,2]: + del Nll_list[-_][toy*bo_set:] +# print(np.shape(Nll_list[-_])) + del Ctt_list[-_][toy*bo_set:] + del Ctt_error_list[-_][toy*bo_set:] + for param in total_f_fit.get_dependents(): + if param.floating: + del pull_dic[param.name][_step+1-_][toy*bo_set:] + newset = True + break + + if not result.converged: + break + + print() + print('Time taken: {}'.format(display_time(int(time.time()-start)))) + print('Estimated time left: {}'.format(display_time(int((time.time()-start)/(__+(toy+1)/nr_of_toys)*(ste-__-(nr_of_toys-toy-1)/nr_of_toys))))) + + +# In[ ]: + + +if load: + + phase_combi = '--' + + if D_contribs: + D_dir = 'D-True' + else: + D_dir = 'D-False' + + _dir = 'data/CLs/finished/f1d1/{}/{}/'.format(phase_combi, D_dir) + + jobs = os.listdir(_dir) + + First = True + +# print(jobs) + + for job in jobs: + + dirName = _dir + str(job) + '/data/CLs' + + if not os.path.exists("{}/{}-{}_{}s{}b{}t--CLs_Nll_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys)): +# print(job) + continue + + with open(r"{}/variab.pkl".format(dirName), "rb") as input_file: + variab = pkl.load(input_file) +# print(variab) + + ### sanity check: + if variab['mi'] != mi or variab['ma'] != ma or variab['ste'] != ste or bo_set != bo_set: + print('Fitting parameters of data dont equal the ones given -- Job {} skipped!'.format(job)) + + with open(r"{}/{}-{}_{}s{}b{}t--CLs_Nll_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _Nll_list = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s{}b{}t--Ctt_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _Ctt_list = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s{}b{}t--Ctt_error_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _Ctt_error_list = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s{}b{}t--pull_dic.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _pull_dic = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s--CLs_list.pkl".format(dirName, mi,ma,ste), "rb") as input_file: + _CLs_list = pkl.load(input_file) + + + if First: + Nll_list = _Nll_list + Ctt_list = _Ctt_list + Ctt_error_list = _Ctt_error_list + pull_dic = _pull_dic +# print(_pull_dic) + CLs_list = _CLs_list + First = False + else: + for step in range(2*ste): +# print(Nll_list[step], step) + Nll_list[step].extend(_Nll_list[step]) + Ctt_list[step].extend(_Ctt_list[step]) + Ctt_error_list[step].extend(_Ctt_error_list[step]) + for key in pull_dic.keys(): +# print(key, np.shape(pull_dic[key])) + pull_dic[key][step].extend(_pull_dic[key][step]) + for step in range(ste): + CLs_list[step].extend(_CLs_list[step]) + +# print('----------------------') + + +# In[ ]: + + +dirName = 'data/CLs' + +# if bo and not load: +# for s in range(2*ste): +# Nll_list[s] = [np.min(Nll_list[s])] + + +if not load: + + if not os.path.exists(dirName): + os.mkdir(dirName) + print("Directory " , dirName , " Created ") + + with open("{}/{}-{}_{}s{}b{}t--CLs_Nll_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(Nll_list, f, pkl.HIGHEST_PROTOCOL) + + with open("{}/{}-{}_{}s{}b{}t--Ctt_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(Ctt_list, f, pkl.HIGHEST_PROTOCOL) + + with open("{}/{}-{}_{}s{}b{}t--Ctt_error_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(Ctt_error_list, f, pkl.HIGHEST_PROTOCOL) + + with open("{}/{}-{}_{}s{}b{}t--pull_dic.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(pull_dic, f, pkl.HIGHEST_PROTOCOL) + + variab = {'mi': mi, + 'ma': ma, + 'ste': ste, + 'bo_set': bo_set, + 'nr_of_toys': nr_of_toys} + + with open("{}/variab.pkl".format(dirName), "wb") as f: + pkl.dump(variab, f, pkl.HIGHEST_PROTOCOL) + + CLs_values = [] + + toy_size = bo_set + + print(np.shape(Nll_list)) + print(Nll_list[0:1]) + + for step in range(ste): + CLs_values.append([]) + for toy in range(nr_of_toys): + float_min = np.min(Nll_list[2*step][toy*bo_set:(toy+1)*bo_set]) + fix_min = np.min(Nll_list[2*step+1][toy*bo_set:(toy+1)*bo_set]) + CLs_values[step].append(float_min-fix_min) + + + print(np.shape(CLs_values)) + + with open("{}/{}-{}_{}s--CLs_list.pkl".format(dirName, mi,ma,ste), "wb") as f: + pkl.dump(CLs_values, f, pkl.HIGHEST_PROTOCOL) + + +# In[ ]: + + +# print(variab['mi'] != mi) + + +# ## Plot + +# In[ ]: + + +l = [] + + +if load: + CLs_values = -1*np.array(CLs_list) + +if not os.path.exists('data/CLs/plots'): + os.mkdir('data/CLs/plots') + print("Directory " , 'data/CLs/plots' , " Created ") + +print(np.shape(CLs_values)) + +for step in range(1,ste): + plt.clf() + plt.title('Ctt value: {:.2f}'.format(Ctt_steps[step])) + plt.hist(CLs_values[0], bins = 150, range = (-25, 50), label = 'Ctt fixed to 0') + plt.hist(CLs_values[step], bins = 150, range = (-25, 50), label = 'Ctt floating') + plt.axvline(x=np.mean(CLs_values[0]),color='red', linewidth=1.0, linestyle = 'dotted') + plt.legend() + plt.savefig('data/CLs/plots/CLs-BR({:.1E}).png'.format(BR_steps[step])) + + l.append(len(np.where(np.array(CLs_values[step]) < np.mean(CLs_values[0]))[0])) + +for step in range(2*ste): + if step%2 == 0: + floaty = True + else: + floaty = False + for key in pull_dic.keys(): + if not os.path.exists('data/CLs/plots/{}'.format(key)): + os.mkdir('data/CLs/plots/{}'.format(key)) + plt.clf() + plt.title('Pull {} - Ctt value {:.2f} - floating {}'.format(key, Ctt_steps[int(step/2)], floaty)) + plt.hist(pull_dic[key][step], bins = 50, range = (-5,5)) + plt.xlabel('Pull') + plt.savefig('data/CLs/plots/{}/{:.2f}Ctt{}s{}f.png'.format(key, Ctt_steps[int(step/2)], step, floaty)) + + +# In[ ]: + + +for s in range(len(l)): + print('BR: {:.4f}'.format(BR_steps[s+1])) + print(2*l[s]/len(CLs_values[s])) + print() + + +# In[ ]: + + +# for step in range(2*ste): +# for key in pull_dic.keys(): +# print(pull_dic[key][step]) + + +# In[ ]: + + +# for param in total_f_fit.get_dependents(): +# if param.floating: +# print(params[param]['value']) + + +# In[ ]: + + +print(display_time(int(time.time()-start))) + + +# In[ ]: + + +# variab['mi'] =! mi + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + diff --git a/data/CLs/finished/f1d1/-+/D-True/2288040/__pycache__/helperfunctions.cpython-37.pyc b/data/CLs/finished/f1d1/-+/D-True/2288040/__pycache__/helperfunctions.cpython-37.pyc new file mode 100644 index 0000000..b02a9ab --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288040/__pycache__/helperfunctions.cpython-37.pyc Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288040/__pycache__/pdg_const1.cpython-37.pyc b/data/CLs/finished/f1d1/-+/D-True/2288040/__pycache__/pdg_const1.cpython-37.pyc new file mode 100644 index 0000000..6630214 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288040/__pycache__/pdg_const1.cpython-37.pyc Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288040/data/CLs/0.0001-0.003_20s--CLs_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288040/data/CLs/0.0001-0.003_20s--CLs_list.pkl new file mode 100644 index 0000000..db4e2d7 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288040/data/CLs/0.0001-0.003_20s--CLs_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288040/data/CLs/0.0001-0.003_20s1b1t--CLs_Nll_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288040/data/CLs/0.0001-0.003_20s1b1t--CLs_Nll_list.pkl new file mode 100644 index 0000000..6302f85 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288040/data/CLs/0.0001-0.003_20s1b1t--CLs_Nll_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288040/data/CLs/0.0001-0.003_20s1b1t--Ctt_error_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288040/data/CLs/0.0001-0.003_20s1b1t--Ctt_error_list.pkl new file mode 100644 index 0000000..9243f1f --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288040/data/CLs/0.0001-0.003_20s1b1t--Ctt_error_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288040/data/CLs/0.0001-0.003_20s1b1t--Ctt_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288040/data/CLs/0.0001-0.003_20s1b1t--Ctt_list.pkl new file mode 100644 index 0000000..930634d --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288040/data/CLs/0.0001-0.003_20s1b1t--Ctt_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288040/data/CLs/0.0001-0.003_20s1b1t--pull_dic.pkl b/data/CLs/finished/f1d1/-+/D-True/2288040/data/CLs/0.0001-0.003_20s1b1t--pull_dic.pkl new file mode 100644 index 0000000..e0979b5 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288040/data/CLs/0.0001-0.003_20s1b1t--pull_dic.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288040/data/CLs/variab.pkl b/data/CLs/finished/f1d1/-+/D-True/2288040/data/CLs/variab.pkl new file mode 100644 index 0000000..bb90dc0 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288040/data/CLs/variab.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288040/helperfunctions.py b/data/CLs/finished/f1d1/-+/D-True/2288040/helperfunctions.py new file mode 100644 index 0000000..88e120f --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288040/helperfunctions.py @@ -0,0 +1,33 @@ +# some helperfunctions + +import matplotlib +matplotlib.use("agg") +import matplotlib.pyplot as plt + +#Dislpay time (e.g. while generating points) + +display_intervals = ( + ('w', 604800), # 60 * 60 * 24 * 7 + ('d', 86400), # 60 * 60 * 24 + ('h', 3600), # 60 * 60 + ('min', 60), + ('s', 1), + ) + +def display_time(seconds, granularity=2): + result = [] + + for name, count in display_intervals: + value = seconds // count + if value: + seconds -= value * count + if value == 1: + name = name.rstrip('s') + result.append("{} {}".format(value, name)) + return ', '.join(result[:granularity]) + +def prepare_plot(title): + plt.title(title) + plt.grid() + plt.legend(loc = 'best') + plt.xlabel("q") diff --git a/data/CLs/finished/f1d1/-+/D-True/2288040/pdg_const1.py b/data/CLs/finished/f1d1/-+/D-True/2288040/pdg_const1.py new file mode 100644 index 0000000..70b3f30 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288040/pdg_const1.py @@ -0,0 +1,226 @@ +pdg = { + + + ###Particle masses### + + "mbstar" : 5415.4, + "mbstar0" : 5711.0, + "B0_M" : 5279.5, + "Bs_M" : 5366.7, + "Bplus_M" : 5279.3, + "Lb_M" : 5619.4, + "D0_M" : 1864.8, + "Dst_M" : 2010, + "pi_M" : 139.6, + "Jpsi_M" : 3096.9, + "Psi2s_M" : 3685.6, + "kaon_M" : 493.7, + "Ks_M" : 497.6, + "phi_M" : 1019.5, + "rho_M" : 775.26, + "rho_width" : 149.1, + "omega_M" : 782.65, + "omega_width" : 8.49, + + "muon_M" : 105.7, + "tau_M": 1776.86, + + "squark_M" : 95.0, + "bquark_M" : 4180.0, + "cquark_M" : 1275.0, + + "Bplus_tau" : 1.638e-12, + + ###Wilson coefficients### + + "C1" : -0.257, + "C2" : 1.009, + "C3" : -0.005, + "C4" : -0.078, + + "C7eff" : -0.306, + "C9eff" : 4.211, + "C10eff" : -4.103, + +# "C7eff": 0.0, +# "C9eff": 0.0, +# "C10eff": 0.0, + + ###Other constants + + "GF" : 1.1663787e-5, + "alpha_ew" : 1.0/137.0, + "Vts" : 0.0394, + "Vtb" : 1.019, + "number_of_decays": 5404696, + + #Formfactor z coefficients + + #"b0" : [0.285, 0.19, -0.17], + #"bplus" : [0.437, -1.41, -2.5], + #"bT" : [0.440, -1.47, -2.7] + + "b0" : [0.292, 0.281, 0.150], + "bplus" : [0.466, -0.885, -0.213], + "bT" : [0.460, -1.089, -1.114], + + "NR_BR": 4.37e-7, + "NR_auc": 0.00133, + + #Resonances format(mass, width, phase, scale) + + # pre scaling + +# "rho": (775.26, 149.0, -0.35, 1.0), + +# "omega": (782.7, 8.5, 0.26, 1.0), + +# "phi": (1019.46, 4.25, 0.5, 1.0), + +# "jpsi": (3096.0, 0.09, -1.5, 2e-2), +# "jpsi_auc": 0.2126825758464027, + +# "psi2s": (3686.0, 0.3, -1.5, 3.14e-3), +# "psi2s_auc": 2.802257483178487e-10, + +# "p3770": (3773.0, 27.2, -2.13, 1.0e-3), + +# "p4040": (4039.0, 80.0, -2.52, 2.0), + +# "p4160": (4191.0, 70.0, -1.9, 2.2), + +# "p4415": (4421.0, 62.0, -2.52, 1.0), + + + # after scaling (Phase combination --) + + # + # "rho": (743.2, 149.0, -0.22, 1.05), + # + # "omega": (782.7, 8.5, 0.38, 6.8), + # + # "phi": (1013.5, 4.25, 0.62, 19.2), + # + # "jpsi": (3096.1, 0.09, 1.63, 9897.0), + # "jpsi_auc": 0.2126825758464027, + # "jpsi_phase_unc": 0.05, + # + # "psi2s": (3686.0, 0.3, 1.8, 1396.0), + # "psi2s_auc": 0.0151332263, + # "psi2s_phase_unc": 0.1, + # + # "p3770": (3773.0, 27.2, -2.95, 2.5), + # + # "p4040": (4039.0, 80.0, -2.75, 1.01), + # + # "p4160": (4191.0, 70.0, -2.28, 2.2), + # + # "p4415": (4421.0, 62.0, -2.31, 1.24), + + # Phase combination of paper ++ + +# "rho": (743.2, 149.0, -0.35, 1.05), + +# "omega": (782.7, 8.5, 0.26, 6.8), + +# "phi": (1013.5, 4.25, 0.47, 19.2), + +# "jpsi": (3096.1, 0.09, -1.66, 9897.0), +# "jpsi_auc": 0.2126825758464027, +# "jpsi_phase_unc": 0.05, + +# "psi2s": (3686.0, 0.3, -1.93, 1396.0), +# "psi2s_auc": 0.0151332263, +# "psi2s_phase_unc": 0.1, + +# "p3770": (3773.0, 27.2, -2.13, 2.5), + +# "p4040": (4039.0, 80.0, -2.52, 1.01), + +# "p4160": (4191.0, 70.0, -1.90, 2.2), + +# "p4415": (4421.0, 62.0, -2.52, 1.24), + + # Phase combination of paper +- + +# "rho": (743.2, 149.0, -0.26, 1.05), + +# "omega": (782.7, 8.5, 0.35, 6.8), + +# "phi": (1013.5, 4.25, 0.58, 19.2), + +# "jpsi": (3096.1, 0.09, 1.47, 9897.0), +# "jpsi_auc": 0.2126825758464027, +# "jpsi_phase_unc": 0.05, + +# "psi2s": (3686.0, 0.3, -2.21, 1396.0), +# "psi2s_auc": 0.0151332263, +# "psi2s_phase_unc": 0.1, + +# "p3770": (3773.0, 27.2, -2.140, 2.5), + +# "p4040": (4039.0, 80.0, -2.64, 1.01), + +# "p4160": (4191.0, 70.0, -2.11, 2.2), + +# "p4415": (4421.0, 62.0, -2.42, 1.24), + + # Phase combination of paper -+ + + "rho": (743.2, 149.0, -0.30, 1.05), + + "omega": (782.7, 8.5, 0.30, 6.8), + + "phi": (1013.5, 4.25, 0.51, 19.2), + + "jpsi": (3096.1, 0.09, -1.5, 9897.0), + "jpsi_auc": 0.2126825758464027, + "jpsi_phase_unc": 0.05, + + "psi2s": (3686.0, 0.3, 2.08, 1396.0), + "psi2s_auc": 0.0151332263, + "psi2s_phase_unc": 0.1, + + "p3770": (3773.0, 27.2, -2.89, 2.5), + + "p4040": (4039.0, 80.0, -2.69, 1.01), + + "p4160": (4191.0, 70.0, -2.13, 2.2), + + "p4415": (4421.0, 62.0, -2.43, 1.24), + + + # zeroing resonances + +# "rho": (775.26, 149.0, -0.35, 0.0), +# "omega": (782.7, 8.5, 0.26, 0.0), +# "phi": (1019.46, 4.25, 0.5, 0.0), +# "jpsi": (3096.0, 0.09, -1.5, 0.0), +# "psi2s": (3686.0, 0.3, -1.5, 0.0), +# "p3770": (3773.0, 27.2, -2.13, 0.0), +# "p4040": (4039.0, 80.0, -2.52, 0.0), +# "p4160": (4147.0, 22.0, -1.9, 0.0), +# "p4415": (4421.0, 62.0, -2.52, 0.0), + + # 2P contributions format(mass, amp, phase) + +# "D_bar": ( + + #general + + "rho_BR": 1.7e-10, + "omega_BR": 4.9e-10, + "phi_BR": 2.5e-9, + "jpsi_BR": 6.02e-5, + "psi2s_BR": 4.97e-6, + "p3770_BR": 1.38e-9, + "p4040_BR": 4.2e-10, + "p4160_BR": 2.6e-9, + "p4415_BR": 6.1e-10, + +# Estimates + "Dbar_scale": 1.46, #with phase = pi + + "DDstar_scale": 2.41, #with phase = pi + + } diff --git a/data/CLs/finished/f1d1/-+/D-True/2288040/raremodel-nb.py b/data/CLs/finished/f1d1/-+/D-True/2288040/raremodel-nb.py new file mode 100644 index 0000000..c326c9c --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288040/raremodel-nb.py @@ -0,0 +1,2152 @@ +#!/usr/bin/env python +# coding: utf-8 + +# # Import + +# In[ ]: + + +import os + +# os.environ["CUDA_VISIBLE_DEVICES"] = "-1" +import random +import numpy as np +from pdg_const1 import pdg +import matplotlib +import matplotlib.pyplot as plt +import pickle as pkl +import sys +import time +from helperfunctions import display_time, prepare_plot +import cmath as c +import scipy.integrate as integrate +from scipy.optimize import fminbound +from array import array as arr +import collections +from itertools import compress +import tensorflow as tf +import zfit +from zfit import ztf +# from IPython.display import clear_output +import os +import tensorflow_probability as tfp +tfd = tfp.distributions + + +# In[ ]: + + +# chunksize = 10000 +# zfit.run.chunking.active = True +# zfit.run.chunking.max_n_points = chunksize + + +# # Build model and graphs +# ## Create graphs + +# In[ ]: + + + + + +# In[ ]: + + +def formfactor(q2, subscript, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2): #returns real value + #check if subscript is viable + + if subscript != "0" and subscript != "+" and subscript != "T": + raise ValueError('Wrong subscript entered, choose either 0, + or T') + + #get constants + + mK = ztf.constant(pdg['Ks_M']) + mbstar0 = ztf.constant(pdg["mbstar0"]) + mbstar = ztf.constant(pdg["mbstar"]) + + + mmu = ztf.constant(pdg['muon_M']) + mb = ztf.constant(pdg['bquark_M']) + ms = ztf.constant(pdg['squark_M']) + mB = ztf.constant(pdg['Bplus_M']) + + #N comes from derivation in paper + + N = 3 + + #some helperfunctions + + tpos = (mB - mK)**2 + tzero = (mB + mK)*(ztf.sqrt(mB)-ztf.sqrt(mK))**2 + + z_oben = ztf.sqrt(tpos - q2) - ztf.sqrt(tpos - tzero) + z_unten = ztf.sqrt(tpos - q2) + ztf.sqrt(tpos - tzero) + z = tf.divide(z_oben, z_unten) + + #calculate f0 + + if subscript == "0": + prefactor = 1/(1 - q2/(mbstar0**2)) + _sum = 0 + b0 = [b0_0, b0_1, b0_2] + + for i in range(N): + _sum += b0[i]*(tf.pow(z,i)) + + return ztf.to_complex(prefactor * _sum) + + #calculate f+ or fT + + else: + prefactor = 1/(1 - q2/(mbstar**2)) + _sum = 0 + + if subscript == "T": + bT = [bT_0, bT_1, bT_2] + for i in range(N): + _sum += bT[i] * (tf.pow(z, i) - ((-1)**(i-N)) * (i/N) * tf.pow(z, N)) + else: + bplus = [bplus_0, bplus_1, bplus_2] + for i in range(N): + _sum += bplus[i] * (tf.pow(z, i) - ((-1)**(i-N)) * (i/N) * tf.pow(z, N)) + + return ztf.to_complex(prefactor * _sum) + +def resonance(q, _mass, width, phase, scale): + + q2 = tf.pow(q, 2) + + mmu = ztf.constant(pdg['muon_M']) + + p = 0.5 * ztf.sqrt(q2 - 4*(mmu**2)) + + p0 = 0.5 * ztf.sqrt(_mass**2 - 4*mmu**2) + + gamma_j = tf.divide(p, q) * _mass * width / p0 + + #Calculate the resonance + + _top = tf.complex(_mass * width, ztf.constant(0.0)) + + _bottom = tf.complex(_mass**2 - q2, -_mass*gamma_j) + + com = _top/_bottom + + #Rotate by the phase + + r = ztf.to_complex(scale*tf.abs(com)) + + _phase = tf.angle(com) + + _phase += phase + + com = r * tf.exp(tf.complex(ztf.constant(0.0), _phase)) + + return com + + +def axiv_nonres(q, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2): + + GF = ztf.constant(pdg['GF']) + alpha_ew = ztf.constant(pdg['alpha_ew']) + Vtb = ztf.constant(pdg['Vtb']) + Vts = ztf.constant(pdg['Vts']) + C10eff = ztf.constant(pdg['C10eff']) + + mmu = ztf.constant(pdg['muon_M']) + mb = ztf.constant(pdg['bquark_M']) + ms = ztf.constant(pdg['squark_M']) + mK = ztf.constant(pdg['Ks_M']) + mB = ztf.constant(pdg['Bplus_M']) + + q2 = tf.pow(q, 2) + + #Some helperfunctions + + beta = 1. - 4. * mmu**2. / q2 + + kabs = ztf.sqrt(mB**2. + tf.pow(q2, 2)/mB**2. + mK**4./mB**2. - 2. * (mB**2. * mK**2. + mK**2. * q2 + mB**2. * q2) / mB**2.) + + #prefactor in front of whole bracket + + prefactor1 = GF**2. *alpha_ew**2. * (tf.abs(Vtb*Vts))**2. * kabs * beta / (128. * np.pi**5.) + + #left term in bracket + + bracket_left = 2./3. * tf.pow(kabs,2) * tf.pow(beta,2) * tf.pow(tf.abs(ztf.to_complex(C10eff)*formfactor(q2, "+", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2)),2) + + #middle term in bracket + + _top = 4. * mmu**2. * (mB**2. - mK**2.) * (mB**2. - mK**2.) + + _under = q2 * mB**2. + + bracket_middle = _top/_under *tf.pow(tf.abs(ztf.to_complex(C10eff) * formfactor(q2, "0", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2)), 2) + + #Note sqrt(q2) comes from derivation as we use q2 and plot q + + return prefactor1 * (bracket_left + bracket_middle) * 2 * q + +def vec(q, funcs, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2): + + q2 = tf.pow(q, 2) + + GF = ztf.constant(pdg['GF']) + alpha_ew = ztf.constant(pdg['alpha_ew']) + Vtb = ztf.constant(pdg['Vtb']) + Vts = ztf.constant(pdg['Vts']) + C7eff = ztf.constant(pdg['C7eff']) + + mmu = ztf.constant(pdg['muon_M']) + mb = ztf.constant(pdg['bquark_M']) + ms = ztf.constant(pdg['squark_M']) + mK = ztf.constant(pdg['Ks_M']) + mB = ztf.constant(pdg['Bplus_M']) + + #Some helperfunctions + + beta = 1. - 4. * mmu**2. / q2 + + kabs = ztf.sqrt(mB**2. + tf.pow(q2, 2)/mB**2. + mK**4./mB**2. - 2 * (mB**2 * mK**2 + mK**2 * q2 + mB**2 * q2) / mB**2) + + #prefactor in front of whole bracket + + prefactor1 = GF**2. *alpha_ew**2. * (tf.abs(Vtb*Vts))**2 * kabs * beta / (128. * np.pi**5.) + + #right term in bracket + + prefactor2 = tf.pow(kabs,2) * (1. - 1./3. * beta) + + abs_bracket = tf.pow(tf.abs(c9eff(q, funcs) * formfactor(q2, "+", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + ztf.to_complex(2.0 * C7eff * (mb + ms)/(mB + mK)) * formfactor(q2, "T", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2)),2) + + bracket_right = prefactor2 * abs_bracket + + #Note sqrt(q2) comes from derivation as we use q2 and plot q + + return prefactor1 * bracket_right * 2 * q + +def c9eff(q, funcs): + + C9eff_nr = ztf.to_complex(ztf.constant(pdg['C9eff'])) + + c9 = C9eff_nr + funcs + + return c9 + + +# In[ ]: + + +def G(y): + + def inner_rect_bracket(q): + return tf.log(ztf.to_complex((1+tf.sqrt(q))/(1-tf.sqrt(q)))-tf.complex(ztf.constant(0), -1*ztf.constant(np.pi))) + + def inner_right(q): + return ztf.to_complex(2 * tf.atan(1/tf.sqrt(tf.math.real(-q)))) + + big_bracket = tf.where(tf.math.real(y) > ztf.constant(0.0), inner_rect_bracket(y), inner_right(y)) + + return ztf.to_complex(tf.sqrt(tf.abs(y))) * big_bracket + +def h_S(m, q): + + return ztf.to_complex(2) - G(ztf.to_complex(1) - ztf.to_complex(4*tf.pow(m, 2)) / ztf.to_complex(tf.pow(q, 2))) + +def h_P(m, q): + + return ztf.to_complex(2/3) + (ztf.to_complex(1) - ztf.to_complex(4*tf.pow(m, 2)) / ztf.to_complex(tf.pow(q, 2))) * h_S(m,q) + +def two_p_ccbar(mD, m_D_bar, m_D_star, q): + + + #Load constants + nu_D_bar = ztf.to_complex(pdg["nu_D_bar"]) + nu_D = ztf.to_complex(pdg["nu_D"]) + nu_D_star = ztf.to_complex(pdg["nu_D_star"]) + + phase_D_bar = ztf.to_complex(pdg["phase_D_bar"]) + phase_D = ztf.to_complex(pdg["phase_D"]) + phase_D_star = ztf.to_complex(pdg["phase_D_star"]) + + #Calculation + left_part = nu_D_bar * tf.exp(tf.complex(ztf.constant(0.0), phase_D_bar)) * h_S(m_D_bar, q) + + right_part_D = nu_D * tf.exp(tf.complex(ztf.constant(0.0), phase_D)) * h_P(m_D, q) + + right_part_D_star = nu_D_star * tf.exp(tf.complex(ztf.constant(0.0), phase_D_star)) * h_P(m_D_star, q) + + return left_part + right_part_D + right_part_D_star + + +# ## Build pdf + +# In[ ]: + + +class total_pdf_cut(zfit.pdf.ZPDF): + _N_OBS = 1 # dimension, can be omitted + _PARAMS = ['b0_0', 'b0_1', 'b0_2', + 'bplus_0', 'bplus_1', 'bplus_2', + 'bT_0', 'bT_1', 'bT_2', + 'rho_mass', 'rho_scale', 'rho_phase', 'rho_width', + 'jpsi_mass', 'jpsi_scale', 'jpsi_phase', 'jpsi_width', + 'psi2s_mass', 'psi2s_scale', 'psi2s_phase', 'psi2s_width', + 'p3770_mass', 'p3770_scale', 'p3770_phase', 'p3770_width', + 'p4040_mass', 'p4040_scale', 'p4040_phase', 'p4040_width', + 'p4160_mass', 'p4160_scale', 'p4160_phase', 'p4160_width', + 'p4415_mass', 'p4415_scale', 'p4415_phase', 'p4415_width', + 'omega_mass', 'omega_scale', 'omega_phase', 'omega_width', + 'phi_mass', 'phi_scale', 'phi_phase', 'phi_width', + 'Dbar_mass', 'Dbar_scale', 'Dbar_phase', + 'Dstar_mass', 'DDstar_scale', 'DDstar_phase', 'D_mass', + 'tau_mass', 'C_tt'] +# the name of the parameters + + def _unnormalized_pdf(self, x): + + x = x.unstack_x() + + b0 = [self.params['b0_0'], self.params['b0_1'], self.params['b0_2']] + bplus = [self.params['bplus_0'], self.params['bplus_1'], self.params['bplus_2']] + bT = [self.params['bT_0'], self.params['bT_1'], self.params['bT_2']] + + def rho_res(q): + return resonance(q, _mass = self.params['rho_mass'], scale = self.params['rho_scale'], + phase = self.params['rho_phase'], width = self.params['rho_width']) + + def omega_res(q): + return resonance(q, _mass = self.params['omega_mass'], scale = self.params['omega_scale'], + phase = self.params['omega_phase'], width = self.params['omega_width']) + + def phi_res(q): + return resonance(q, _mass = self.params['phi_mass'], scale = self.params['phi_scale'], + phase = self.params['phi_phase'], width = self.params['phi_width']) + + def jpsi_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['jpsi_mass'], 2)) * resonance(q, _mass = self.params['jpsi_mass'], + scale = self.params['jpsi_scale'], + phase = self.params['jpsi_phase'], + width = self.params['jpsi_width']) + def psi2s_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['psi2s_mass'], 2)) * resonance(q, _mass = self.params['psi2s_mass'], + scale = self.params['psi2s_scale'], + phase = self.params['psi2s_phase'], + width = self.params['psi2s_width']) + def p3770_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p3770_mass'], 2)) * resonance(q, _mass = self.params['p3770_mass'], + scale = self.params['p3770_scale'], + phase = self.params['p3770_phase'], + width = self.params['p3770_width']) + + def p4040_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4040_mass'], 2)) * resonance(q, _mass = self.params['p4040_mass'], + scale = self.params['p4040_scale'], + phase = self.params['p4040_phase'], + width = self.params['p4040_width']) + + def p4160_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4160_mass'], 2)) * resonance(q, _mass = self.params['p4160_mass'], + scale = self.params['p4160_scale'], + phase = self.params['p4160_phase'], + width = self.params['p4160_width']) + + def p4415_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4415_mass'], 2)) * resonance(q, _mass = self.params['p4415_mass'], + scale = self.params['p4415_scale'], + phase = self.params['p4415_phase'], + width = self.params['p4415_width']) + + def P2_D(q): + Dbar_contrib = ztf.to_complex(self.params['Dbar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['Dbar_phase']))*ztf.to_complex(h_S(self.params['Dbar_mass'], q)) + DDstar_contrib = ztf.to_complex(self.params['DDstar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['DDstar_phase']))*(ztf.to_complex(h_P(self.params['Dstar_mass'], q)) + ztf.to_complex(h_P(self.params['D_mass'], q))) + return Dbar_contrib + DDstar_contrib + + def ttau_cusp(q): + return ztf.to_complex(self.params['C_tt'])*(ztf.to_complex((h_S(self.params['tau_mass'], q))) - ztf.to_complex(h_P(self.params['tau_mass'], q))) + + + funcs = rho_res(x) + omega_res(x) + phi_res(x) + jpsi_res(x) + psi2s_res(x) + p3770_res(x) + p4040_res(x)+ p4160_res(x) + p4415_res(x) + P2_D(x) + ttau_cusp(x) + + vec_f = vec(x, funcs, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + axiv_nr = axiv_nonres(x, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + tot = vec_f + axiv_nr + + #Cut out jpsi and psi2s + + tot = tf.where(tf.math.logical_or(x < ztf.constant(jpsi_mass-60.), x > ztf.constant(jpsi_mass+70.)), tot, 0.0*tot) + + tot = tf.where(tf.math.logical_or(x < ztf.constant(psi2s_mass-50.), x > ztf.constant(psi2s_mass+50.)), tot, 0.0*tot) + + return tot + +class total_pdf_full(zfit.pdf.ZPDF): + _N_OBS = 1 # dimension, can be omitted + _PARAMS = ['b0_0', 'b0_1', 'b0_2', + 'bplus_0', 'bplus_1', 'bplus_2', + 'bT_0', 'bT_1', 'bT_2', + 'rho_mass', 'rho_scale', 'rho_phase', 'rho_width', + 'jpsi_mass', 'jpsi_scale', 'jpsi_phase', 'jpsi_width', + 'psi2s_mass', 'psi2s_scale', 'psi2s_phase', 'psi2s_width', + 'p3770_mass', 'p3770_scale', 'p3770_phase', 'p3770_width', + 'p4040_mass', 'p4040_scale', 'p4040_phase', 'p4040_width', + 'p4160_mass', 'p4160_scale', 'p4160_phase', 'p4160_width', + 'p4415_mass', 'p4415_scale', 'p4415_phase', 'p4415_width', + 'omega_mass', 'omega_scale', 'omega_phase', 'omega_width', + 'phi_mass', 'phi_scale', 'phi_phase', 'phi_width', + 'Dbar_mass', 'Dbar_scale', 'Dbar_phase', + 'Dstar_mass', 'DDstar_scale', 'DDstar_phase', 'D_mass', + 'tau_mass', 'C_tt'] +# the name of the parameters + + def _unnormalized_pdf(self, x): + + x = x.unstack_x() + + b0 = [self.params['b0_0'], self.params['b0_1'], self.params['b0_2']] + bplus = [self.params['bplus_0'], self.params['bplus_1'], self.params['bplus_2']] + bT = [self.params['bT_0'], self.params['bT_1'], self.params['bT_2']] + + def rho_res(q): + return resonance(q, _mass = self.params['rho_mass'], scale = self.params['rho_scale'], + phase = self.params['rho_phase'], width = self.params['rho_width']) + + def omega_res(q): + return resonance(q, _mass = self.params['omega_mass'], scale = self.params['omega_scale'], + phase = self.params['omega_phase'], width = self.params['omega_width']) + + def phi_res(q): + return resonance(q, _mass = self.params['phi_mass'], scale = self.params['phi_scale'], + phase = self.params['phi_phase'], width = self.params['phi_width']) + + def jpsi_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['jpsi_mass'], 2)) * resonance(q, _mass = self.params['jpsi_mass'], + scale = self.params['jpsi_scale'], + phase = self.params['jpsi_phase'], + width = self.params['jpsi_width']) + def psi2s_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['psi2s_mass'], 2)) * resonance(q, _mass = self.params['psi2s_mass'], + scale = self.params['psi2s_scale'], + phase = self.params['psi2s_phase'], + width = self.params['psi2s_width']) + def p3770_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p3770_mass'], 2)) * resonance(q, _mass = self.params['p3770_mass'], + scale = self.params['p3770_scale'], + phase = self.params['p3770_phase'], + width = self.params['p3770_width']) + + def p4040_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4040_mass'], 2)) * resonance(q, _mass = self.params['p4040_mass'], + scale = self.params['p4040_scale'], + phase = self.params['p4040_phase'], + width = self.params['p4040_width']) + + def p4160_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4160_mass'], 2)) * resonance(q, _mass = self.params['p4160_mass'], + scale = self.params['p4160_scale'], + phase = self.params['p4160_phase'], + width = self.params['p4160_width']) + + def p4415_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4415_mass'], 2)) * resonance(q, _mass = self.params['p4415_mass'], + scale = self.params['p4415_scale'], + phase = self.params['p4415_phase'], + width = self.params['p4415_width']) + + def P2_D(q): + Dbar_contrib = ztf.to_complex(self.params['Dbar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['Dbar_phase']))*ztf.to_complex(h_S(self.params['Dbar_mass'], q)) + DDstar_contrib = ztf.to_complex(self.params['DDstar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['DDstar_phase']))*(ztf.to_complex(h_P(self.params['Dstar_mass'], q)) + ztf.to_complex(h_P(self.params['D_mass'], q))) + return Dbar_contrib + DDstar_contrib + + def ttau_cusp(q): + return ztf.to_complex(self.params['C_tt'])*(ztf.to_complex((h_S(self.params['tau_mass'], q))) - ztf.to_complex(h_P(self.params['tau_mass'], q))) + + + funcs = rho_res(x) + omega_res(x) + phi_res(x) + jpsi_res(x) + psi2s_res(x) + p3770_res(x) + p4040_res(x)+ p4160_res(x) + p4415_res(x) + P2_D(x) + ttau_cusp(x) + + vec_f = vec(x, funcs, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + axiv_nr = axiv_nonres(x, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + tot = vec_f + axiv_nr + + #Cut out jpsi and psi2s + +# tot = tf.where(tf.math.logical_or(x < ztf.constant(jpsi_mass-60.), x > ztf.constant(jpsi_mass+70.)), tot, 0.0*tot) + +# tot = tf.where(tf.math.logical_or(x < ztf.constant(psi2s_mass-50.), x > ztf.constant(psi2s_mass+50.)), tot, 0.0*tot) + + return tot + + +# ## Setup parameters + +# In[ ]: + + +# formfactors + +b0_0 = zfit.Parameter("b0_0", ztf.constant(0.292), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +b0_1 = zfit.Parameter("b0_1", ztf.constant(0.281), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +b0_2 = zfit.Parameter("b0_2", ztf.constant(0.150), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) + +bplus_0 = zfit.Parameter("bplus_0", ztf.constant(0.466), lower_limit = -2.0, upper_limit= 2.0) +bplus_1 = zfit.Parameter("bplus_1", ztf.constant(-0.885), lower_limit = -2.0, upper_limit= 2.0) +bplus_2 = zfit.Parameter("bplus_2", ztf.constant(-0.213), lower_limit = -2.0, upper_limit= 2.0) + +bT_0 = zfit.Parameter("bT_0", ztf.constant(0.460), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +bT_1 = zfit.Parameter("bT_1", ztf.constant(-1.089), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +bT_2 = zfit.Parameter("bT_2", ztf.constant(-1.114), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) + + +#rho + +rho_mass, rho_width, rho_phase, rho_scale = pdg["rho"] + +rho_m = zfit.Parameter("rho_m", ztf.constant(rho_mass), floating = False) #lower_limit = rho_mass - rho_width, upper_limit = rho_mass + rho_width) +rho_w = zfit.Parameter("rho_w", ztf.constant(rho_width), floating = False) +rho_p = zfit.Parameter("rho_p", ztf.constant(rho_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +rho_s = zfit.Parameter("rho_s", ztf.constant(rho_scale), lower_limit=rho_scale-np.sqrt(rho_scale), upper_limit=rho_scale+np.sqrt(rho_scale)) + +#omega + +omega_mass, omega_width, omega_phase, omega_scale = pdg["omega"] + +omega_m = zfit.Parameter("omega_m", ztf.constant(omega_mass), floating = False) +omega_w = zfit.Parameter("omega_w", ztf.constant(omega_width), floating = False) +omega_p = zfit.Parameter("omega_p", ztf.constant(omega_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +omega_s = zfit.Parameter("omega_s", ztf.constant(omega_scale), lower_limit=omega_scale-np.sqrt(omega_scale), upper_limit=omega_scale+np.sqrt(omega_scale)) + + +#phi + +phi_mass, phi_width, phi_phase, phi_scale = pdg["phi"] + +phi_m = zfit.Parameter("phi_m", ztf.constant(phi_mass), floating = False) +phi_w = zfit.Parameter("phi_w", ztf.constant(phi_width), floating = False) +phi_p = zfit.Parameter("phi_p", ztf.constant(phi_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +phi_s = zfit.Parameter("phi_s", ztf.constant(phi_scale), lower_limit=phi_scale-np.sqrt(phi_scale), upper_limit=phi_scale+np.sqrt(phi_scale)) + +#jpsi + +jpsi_mass, jpsi_width, jpsi_phase, jpsi_scale = pdg["jpsi"] + +jpsi_m = zfit.Parameter("jpsi_m", ztf.constant(jpsi_mass), floating = False) +jpsi_w = zfit.Parameter("jpsi_w", ztf.constant(jpsi_width), floating = False) +jpsi_p = zfit.Parameter("jpsi_p", ztf.constant(jpsi_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +jpsi_s = zfit.Parameter("jpsi_s", ztf.constant(jpsi_scale), floating = False) #, lower_limit=jpsi_scale-np.sqrt(jpsi_scale), upper_limit=jpsi_scale+np.sqrt(jpsi_scale)) + +#psi2s + +psi2s_mass, psi2s_width, psi2s_phase, psi2s_scale = pdg["psi2s"] + +psi2s_m = zfit.Parameter("psi2s_m", ztf.constant(psi2s_mass), floating = False) +psi2s_w = zfit.Parameter("psi2s_w", ztf.constant(psi2s_width), floating = False) +psi2s_p = zfit.Parameter("psi2s_p", ztf.constant(psi2s_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +psi2s_s = zfit.Parameter("psi2s_s", ztf.constant(psi2s_scale), floating = False) #, lower_limit=psi2s_scale-np.sqrt(psi2s_scale), upper_limit=psi2s_scale+np.sqrt(psi2s_scale)) + +#psi(3770) + +p3770_mass, p3770_width, p3770_phase, p3770_scale = pdg["p3770"] + +p3770_m = zfit.Parameter("p3770_m", ztf.constant(p3770_mass), floating = False) +p3770_w = zfit.Parameter("p3770_w", ztf.constant(p3770_width), floating = False) +p3770_p = zfit.Parameter("p3770_p", ztf.constant(p3770_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p3770_s = zfit.Parameter("p3770_s", ztf.constant(p3770_scale), lower_limit=p3770_scale-np.sqrt(p3770_scale), upper_limit=p3770_scale+np.sqrt(p3770_scale)) + +#psi(4040) + +p4040_mass, p4040_width, p4040_phase, p4040_scale = pdg["p4040"] + +p4040_m = zfit.Parameter("p4040_m", ztf.constant(p4040_mass), floating = False) +p4040_w = zfit.Parameter("p4040_w", ztf.constant(p4040_width), floating = False) +p4040_p = zfit.Parameter("p4040_p", ztf.constant(p4040_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p4040_s = zfit.Parameter("p4040_s", ztf.constant(p4040_scale), lower_limit=p4040_scale-np.sqrt(p4040_scale), upper_limit=p4040_scale+np.sqrt(p4040_scale)) + +#psi(4160) + +p4160_mass, p4160_width, p4160_phase, p4160_scale = pdg["p4160"] + +p4160_m = zfit.Parameter("p4160_m", ztf.constant(p4160_mass), floating = False) +p4160_w = zfit.Parameter("p4160_w", ztf.constant(p4160_width), floating = False) +p4160_p = zfit.Parameter("p4160_p", ztf.constant(p4160_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p4160_s = zfit.Parameter("p4160_s", ztf.constant(p4160_scale), lower_limit=p4160_scale-np.sqrt(p4160_scale), upper_limit=p4160_scale+np.sqrt(p4160_scale)) + +#psi(4415) + +p4415_mass, p4415_width, p4415_phase, p4415_scale = pdg["p4415"] + +p4415_m = zfit.Parameter("p4415_m", ztf.constant(p4415_mass), floating = False) +p4415_w = zfit.Parameter("p4415_w", ztf.constant(p4415_width), floating = False) +p4415_p = zfit.Parameter("p4415_p", ztf.constant(p4415_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p4415_s = zfit.Parameter("p4415_s", ztf.constant(p4415_scale), lower_limit=p4415_scale-np.sqrt(p4415_scale), upper_limit=p4415_scale+np.sqrt(p4415_scale)) + + +# ## Dynamic generation of 2 particle contribution + +# In[ ]: + + +m_c = 1300 + +Dbar_phase = 0.0 +DDstar_phase = 0.0 +Dstar_mass = pdg['Dst_M'] +Dbar_mass = pdg['D0_M'] +D_mass = pdg['D0_M'] + +Dbar_s = zfit.Parameter("Dbar_s", ztf.constant(0.0), lower_limit=-0.3, upper_limit=0.3) +Dbar_m = zfit.Parameter("Dbar_m", ztf.constant(Dbar_mass), floating = False) +Dbar_p = zfit.Parameter("Dbar_p", ztf.constant(Dbar_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi)#, floating = False) +DDstar_s = zfit.Parameter("DDstar_s", ztf.constant(0.0), lower_limit=-0.3, upper_limit=0.3)#, floating = False) +Dstar_m = zfit.Parameter("Dstar_m", ztf.constant(Dstar_mass), floating = False) +D_m = zfit.Parameter("D_m", ztf.constant(D_mass), floating = False) +DDstar_p = zfit.Parameter("DDstar_p", ztf.constant(DDstar_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi)#, floating = False) + + +# ## Tau parameters + +# In[ ]: + + +tau_m = zfit.Parameter("tau_m", ztf.constant(pdg['tau_M']), floating = False) +Ctt = zfit.Parameter("Ctt", ztf.constant(0.0), lower_limit=-2.5, upper_limit=2.5) + + +# ## Load data + +# In[ ]: + + +x_min = 2*pdg['muon_M'] +x_max = (pdg["Bplus_M"]-pdg["Ks_M"]-0.1) + +# # Full spectrum + +obs_toy = zfit.Space('q', limits = (x_min, x_max)) + +# Jpsi and Psi2s cut out + +obs1 = zfit.Space('q', limits = (x_min, jpsi_mass - 60.)) +obs2 = zfit.Space('q', limits = (jpsi_mass + 70., psi2s_mass - 50.)) +obs3 = zfit.Space('q', limits = (psi2s_mass + 50., x_max)) + +obs_fit = obs1 + obs2 + obs3 + +# with open(r"./data/slim_points/slim_points_toy_0_range({0}-{1}).pkl".format(int(x_min), int(x_max)), "rb") as input_file: +# part_set = pkl.load(input_file) + +# x_part = part_set['x_part'] + +# x_part = x_part.astype('float64') + +# data = zfit.data.Data.from_numpy(array=x_part, obs=obs) + + +# ## Setup pdf + +# In[ ]: + + +total_f = total_pdf_cut(obs=obs_toy, jpsi_mass = jpsi_m, jpsi_scale = jpsi_s, jpsi_phase = jpsi_p, jpsi_width = jpsi_w, + psi2s_mass = psi2s_m, psi2s_scale = psi2s_s, psi2s_phase = psi2s_p, psi2s_width = psi2s_w, + p3770_mass = p3770_m, p3770_scale = p3770_s, p3770_phase = p3770_p, p3770_width = p3770_w, + p4040_mass = p4040_m, p4040_scale = p4040_s, p4040_phase = p4040_p, p4040_width = p4040_w, + p4160_mass = p4160_m, p4160_scale = p4160_s, p4160_phase = p4160_p, p4160_width = p4160_w, + p4415_mass = p4415_m, p4415_scale = p4415_s, p4415_phase = p4415_p, p4415_width = p4415_w, + rho_mass = rho_m, rho_scale = rho_s, rho_phase = rho_p, rho_width = rho_w, + omega_mass = omega_m, omega_scale = omega_s, omega_phase = omega_p, omega_width = omega_w, + phi_mass = phi_m, phi_scale = phi_s, phi_phase = phi_p, phi_width = phi_w, + Dstar_mass = Dstar_m, DDstar_scale = DDstar_s, DDstar_phase = DDstar_p, D_mass = D_m, + Dbar_mass = Dbar_m, Dbar_scale = Dbar_s, Dbar_phase = Dbar_p, + tau_mass = tau_m, C_tt = Ctt, b0_0 = b0_0, b0_1 = b0_1, b0_2 = b0_2, + bplus_0 = bplus_0, bplus_1 = bplus_1, bplus_2 = bplus_2, + bT_0 = bT_0, bT_1 = bT_1, bT_2 = bT_2) + +total_f_fit = total_pdf_full(obs=obs_fit, jpsi_mass = jpsi_m, jpsi_scale = jpsi_s, jpsi_phase = jpsi_p, jpsi_width = jpsi_w, + psi2s_mass = psi2s_m, psi2s_scale = psi2s_s, psi2s_phase = psi2s_p, psi2s_width = psi2s_w, + p3770_mass = p3770_m, p3770_scale = p3770_s, p3770_phase = p3770_p, p3770_width = p3770_w, + p4040_mass = p4040_m, p4040_scale = p4040_s, p4040_phase = p4040_p, p4040_width = p4040_w, + p4160_mass = p4160_m, p4160_scale = p4160_s, p4160_phase = p4160_p, p4160_width = p4160_w, + p4415_mass = p4415_m, p4415_scale = p4415_s, p4415_phase = p4415_p, p4415_width = p4415_w, + rho_mass = rho_m, rho_scale = rho_s, rho_phase = rho_p, rho_width = rho_w, + omega_mass = omega_m, omega_scale = omega_s, omega_phase = omega_p, omega_width = omega_w, + phi_mass = phi_m, phi_scale = phi_s, phi_phase = phi_p, phi_width = phi_w, + Dstar_mass = Dstar_m, DDstar_scale = DDstar_s, DDstar_phase = DDstar_p, D_mass = D_m, + Dbar_mass = Dbar_m, Dbar_scale = Dbar_s, Dbar_phase = Dbar_p, + tau_mass = tau_m, C_tt = Ctt, b0_0 = b0_0, b0_1 = b0_1, b0_2 = b0_2, + bplus_0 = bplus_0, bplus_1 = bplus_1, bplus_2 = bplus_2, + bT_0 = bT_0, bT_1 = bT_1, bT_2 = bT_2) + +# print(total_pdf.obs) + +# print(calcs_test) + +# for param in total_f.get_dependents(): +# print(zfit.run(param)) + + +# In[ ]: + + +# total_f_fit.normalization(obs_fit) + + +# ## Test if graphs actually work and compute values + +# In[ ]: + + +# def total_test_tf(xq): + +# def jpsi_res(q): +# return resonance(q, jpsi_m, jpsi_s, jpsi_p, jpsi_w) + +# def psi2s_res(q): +# return resonance(q, psi2s_m, psi2s_s, psi2s_p, psi2s_w) + +# def cusp(q): +# return bifur_gauss(q, cusp_m, sig_L, sig_R, cusp_s) + +# funcs = jpsi_res(xq) + psi2s_res(xq) + cusp(xq) + +# vec_f = vec(xq, funcs) + +# axiv_nr = axiv_nonres(xq) + +# tot = vec_f + axiv_nr + +# return tot + +# def jpsi_res(q): +# return resonance(q, jpsi_m, jpsi_s, jpsi_p, jpsi_w) + +# calcs = zfit.run(total_test_tf(x_part)) + + + +test_q = np.linspace(x_min, x_max, int(2e6)) + +probs = total_f_fit.pdf(test_q, norm_range=False) + +calcs_test = zfit.run(probs) + +Ctt.set_value(0.5) + +calcs_test1 = zfit.run(probs) + +Ctt.set_value(0.0) + +Dbar_s.set_value(0.3) + +DDstar_s.set_value(0.3) + +calcs_test2 = zfit.run(probs) +# res_y = zfit.run(jpsi_res(test_q)) +# b0 = [b0_0, b0_1, b0_2] +# bplus = [bplus_0, bplus_1, bplus_2] +# bT = [bT_0, bT_1, bT_2] +# f0_y = zfit.run(tf.math.real(formfactor(test_q,"0", b0, bplus, bT))) +# fplus_y = zfit.run(tf.math.real(formfactor(test_q,"+", b0, bplus, bT))) +# fT_y = zfit.run(tf.math.real(formfactor(test_q,"T", b0, bplus, bT))) + + +# In[ ]: + + +plt.clf() +# plt.plot(x_part, calcs, '.') +plt.plot(test_q, calcs_test, label = 'pdf (Ctt = 0.0)') +plt.plot(test_q, calcs_test1, label = 'pdf (Ctt = 0.5)') +plt.plot(test_q, calcs_test2, label = 'pdf (D-contribs = 0.3)') +# plt.plot(test_q, f0_y, label = '0') +# plt.plot(test_q, fT_y, label = 'T') +# plt.plot(test_q, fplus_y, label = '+') +# plt.plot(test_q, res_y, label = 'res') +plt.legend() +plt.ylim(0.0, 1.5e-6) +# plt.yscale('log') +# plt.xlim(770, 785) +plt.savefig('test.png') +# print(jpsi_width) + + +# In[ ]: + + + + +# probs = mixture.prob(test_q) +# probs_np = zfit.run(probs) +# probs_np *= np.max(calcs_test) / np.max(probs_np) +# plt.figure() +# plt.semilogy(test_q, probs_np,label="importance sampling") +# plt.semilogy(test_q, calcs_test, label = 'pdf') + + +# In[ ]: + + +# 0.213/(0.00133+0.213+0.015) + + +# ## Adjust scaling of different parts + +# In[ ]: + + +total_f.update_integration_options(draws_per_dim=2000000, mc_sampler=None) +# inte = total_f.integrate(limits = (950., 1050.), norm_range=False) +# inte_fl = zfit.run(inte) +# print(inte_fl/4500) +# print(pdg["jpsi_BR"]/pdg["NR_BR"], inte_fl*pdg["psi2s_auc"]/pdg["NR_auc"]) + + +# In[ ]: + + +# # print("jpsi:", inte_fl) +# # print("Increase am by factor:", np.sqrt(pdg["jpsi_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) +# # print("New amp:", pdg["jpsi"][3]*np.sqrt(pdg["jpsi_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) + +# # print("psi2s:", inte_fl) +# # print("Increase am by factor:", np.sqrt(pdg["psi2s_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) +# # print("New amp:", pdg["psi2s"][3]*np.sqrt(pdg["psi2s_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) + +# name = "phi" + +# print(name+":", inte_fl) +# print("Increase am by factor:", np.sqrt(pdg[name+"_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) +# print("New amp:", pdg[name][0]*np.sqrt(pdg[name+"_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) + + +# print(x_min) +# print(x_max) +# # total_f.update_integration_options(draws_per_dim=2000000, mc_sampler=None) +# total_f.update_integration_options(mc_sampler=lambda dim, num_results, +# dtype: tf.random_uniform(maxval=1., shape=(num_results, dim), dtype=dtype), +# draws_per_dim=1000000) +# # _ = [] + +# # for i in range(10): + +# # inte = total_f.integrate(limits = (x_min, x_max)) +# # inte_fl = zfit.run(inte) +# # print(inte_fl) +# # _.append(inte_fl) + +# # print("mean:", np.mean(_)) + +# _ = time.time() + +# inte = total_f.integrate(limits = (x_min, x_max)) +# inte_fl = zfit.run(inte) +# print(inte_fl) +# print("Time taken: {}".format(display_time(int(time.time() - _)))) + +# print(pdg['NR_BR']/pdg['NR_auc']*inte_fl) +# print(0.25**2*4.2/1000) + + +# # Sampling +# ## Mixture distribution for sampling + +# In[ ]: + + + + +# print(list_of_borders[:9]) +# print(list_of_borders[-9:]) + + +class UniformSampleAndWeights(zfit.util.execution.SessionHolderMixin): + def __call__(self, limits, dtype, n_to_produce): + # n_to_produce = tf.cast(n_to_produce, dtype=tf.int32) + low, high = limits.limit1d + low = tf.cast(low, dtype=dtype) + high = tf.cast(high, dtype=dtype) +# uniform = tfd.Uniform(low=low, high=high) +# uniformjpsi = tfd.Uniform(low=tf.constant(3080, dtype=dtype), high=tf.constant(3112, dtype=dtype)) +# uniformpsi2s = tfd.Uniform(low=tf.constant(3670, dtype=dtype), high=tf.constant(3702, dtype=dtype)) + +# list_of_borders = [] +# _p = [] +# splits = 10 + +# _ = np.linspace(x_min, x_max, splits) + +# for i in range(splits): +# list_of_borders.append(tf.constant(_[i], dtype=dtype)) +# _p.append(tf.constant(1/splits, dtype=dtype)) + +# mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=_p[:(splits-1)]), +# components_distribution=tfd.Uniform(low=list_of_borders[:(splits-1)], +# high=list_of_borders[-(splits-1):])) + mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=[tf.constant(0.05, dtype=dtype), + tf.constant(0.93, dtype=dtype), + tf.constant(0.05, dtype=dtype), + tf.constant(0.065, dtype=dtype), + tf.constant(0.04, dtype=dtype), + tf.constant(0.05, dtype=dtype)]), + components_distribution=tfd.Uniform(low=[tf.constant(x_min, dtype=dtype), + tf.constant(3090, dtype=dtype), + tf.constant(3681, dtype=dtype), + tf.constant(3070, dtype=dtype), + tf.constant(1000, dtype=dtype), + tf.constant(3660, dtype=dtype)], + high=[tf.constant(x_max, dtype=dtype), + tf.constant(3102, dtype=dtype), + tf.constant(3691, dtype=dtype), + tf.constant(3110, dtype=dtype), + tf.constant(1040, dtype=dtype), + tf.constant(3710, dtype=dtype)])) +# dtype = tf.float64 +# mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=[tf.constant(0.04, dtype=dtype), +# tf.constant(0.90, dtype=dtype), +# tf.constant(0.02, dtype=dtype), +# tf.constant(0.07, dtype=dtype), +# tf.constant(0.02, dtype=dtype)]), +# components_distribution=tfd.Uniform(low=[tf.constant(x_min, dtype=dtype), +# tf.constant(3089, dtype=dtype), +# tf.constant(3103, dtype=dtype), +# tf.constant(3681, dtype=dtype), +# tf.constant(3691, dtype=dtype)], +# high=[tf.constant(3089, dtype=dtype), +# tf.constant(3103, dtype=dtype), +# tf.constant(3681, dtype=dtype), +# tf.constant(3691, dtype=dtype), +# tf.constant(x_max, dtype=dtype)])) +# mixture = tfd.Uniform(tf.constant(x_min, dtype=dtype), tf.constant(x_max, dtype=dtype)) +# sample = tf.random.uniform((n_to_produce, 1), dtype=dtype) + sample = mixture.sample((n_to_produce, 1)) +# sample = tf.random.uniform((n_to_produce, 1), dtype=dtype) + weights = mixture.prob(sample)[:,0] +# weights = tf.broadcast_to(tf.constant(1., dtype=dtype), shape=(n_to_produce,)) + # sample = tf.expand_dims(sample, axis=-1) +# print(sample, weights) + +# weights = tf.ones(shape=(n_to_produce,), dtype=dtype) + weights_max = None + thresholds = tf.random_uniform(shape=(n_to_produce,), dtype=dtype) + return sample, thresholds, weights, weights_max, n_to_produce + + +# In[ ]: + + +# total_f._sample_and_weights = UniformSampleAndWeights + + +# In[ ]: + + +# 0.00133/(0.00133+0.213+0.015)*(x_max-3750)/(x_max-x_min) + + +# In[ ]: + + +# zfit.settings.set_verbosity(10) + + +# In[ ]: + + +# # zfit.run.numeric_checks = False + +# nr_of_toys = 1 +# nevents = int(pdg["number_of_decays"]) +# nevents = pdg["number_of_decays"] +# event_stack = 1000000 +# # zfit.settings.set_verbosity(10) +# calls = int(nevents/event_stack + 1) + +# total_samp = [] + +# start = time.time() + +# sampler = total_f.create_sampler(n=event_stack) + +# for toy in range(nr_of_toys): + +# dirName = 'data/zfit_toys/toy_{0}'.format(toy) + +# if not os.path.exists(dirName): +# os.mkdir(dirName) +# print("Directory " , dirName , " Created ") + +# for call in range(calls): + +# sampler.resample(n=event_stack) +# s = sampler.unstack_x() +# sam = zfit.run(s) +# # clear_output(wait=True) + +# c = call + 1 + +# print("{0}/{1} of Toy {2}/{3}".format(c, calls, toy+1, nr_of_toys)) +# print("Time taken: {}".format(display_time(int(time.time() - start)))) +# print("Projected time left: {}".format(display_time(int((time.time() - start)/(c+calls*(toy))*((nr_of_toys-toy)*calls-c))))) + +# with open("data/zfit_toys/toy_{0}/{1}.pkl".format(toy, call), "wb") as f: +# pkl.dump(sam, f, pkl.HIGHEST_PROTOCOL) + + +# In[ ]: + + +# with open(r"data/zfit_toys/toy_0/0.pkl", "rb") as input_file: +# sam = pkl.load(input_file) +# print(sam[:10]) + +# with open(r"data/zfit_toys/toy_0/1.pkl", "rb") as input_file: +# sam2 = pkl.load(input_file) +# print(sam2[:10]) + +# print(np.sum(sam-sam2)) + + +# In[ ]: + + +# print("Time to generate full toy: {} s".format(int(time.time()-start))) + +# total_samp = [] + +# for call in range(calls): +# with open(r"data/zfit_toys/toy_0/{}.pkl".format(call), "rb") as input_file: +# sam = pkl.load(input_file) +# total_samp = np.append(total_samp, sam) + +# total_samp = total_samp.astype('float64') + +# data2 = zfit.data.Data.from_numpy(array=total_samp[:int(nevents)], obs=obs) + +# data3 = zfit.data.Data.from_numpy(array=total_samp, obs=obs) + +# print(total_samp[:nevents].shape) + + +# In[ ]: + + +# plt.clf() + +# bins = int((x_max-x_min)/7) + +# # calcs = zfit.run(total_test_tf(samp)) +# print(total_samp[:nevents].shape) + +# plt.hist(total_samp[:nevents], bins = bins, range = (x_min,x_max), label = 'data') +# # plt.plot(test_q, calcs_test*nevents , label = 'pdf') + +# # plt.plot(sam, calcs, '.') +# # plt.plot(test_q, calcs_test) +# # plt.yscale('log') +# plt.ylim(0, 200) +# # plt.xlim(3080, 3110) + +# plt.legend() + +# plt.savefig('test2.png') + + +# In[ ]: + + +# sampler = total_f.create_sampler(n=nevents) +# nll = zfit.loss.UnbinnedNLL(model=total_f, data=sampler, fit_range = (x_min, x_max)) + +# # for param in pdf.get_dependents(): +# # param.set_value(initial_value) + +# sampler.resample(n=nevents) + +# # Randomise initial values +# # for param in pdf.get_dependents(): +# # param.set_value(random value here) + +# # Minimise the NLL +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 10) +# minimum = minimizer.minimize(nll) + + +# In[ ]: + + +# jpsi_width + + +# In[ ]: + + +# plt.hist(sample, weights=1 / prob(sample)) + + +# # Fitting + +# In[ ]: + + +# start = time.time() + +# for param in total_f.get_dependents(): +# param.randomize() + +# # for param in total_f.get_dependents(): +# # print(zfit.run(param)) + +# nll = zfit.loss.UnbinnedNLL(model=total_f, data=data2, fit_range = (x_min, x_max)) + +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) +# # minimizer._use_tfgrad = False +# result = minimizer.minimize(nll) + +# # param_errors = result.error() + +# # for var, errors in param_errors.items(): +# # print('{}: ^{{+{}}}_{{{}}}'.format(var.name, errors['upper'], errors['lower'])) + +# print("Function minimum:", result.fmin) +# # print("Results:", result.params) +# print("Hesse errors:", result.hesse()) + + +# In[ ]: + + +# print("Time taken for fitting: {}".format(display_time(int(time.time()-start)))) + +# # probs = total_f.pdf(test_q) + +# calcs_test = zfit.run(probs) +# res_y = zfit.run(jpsi_res(test_q)) + + +# In[ ]: + + +# plt.clf() +# # plt.plot(x_part, calcs, '.') +# plt.plot(test_q, calcs_test, label = 'pdf') +# # plt.plot(test_q, res_y, label = 'res') +# plt.legend() +# plt.ylim(0.0, 10e-6) +# # plt.yscale('log') +# # plt.xlim(3080, 3110) +# plt.savefig('test3.png') +# # print(jpsi_width) + + +# In[ ]: + + +# _tot = 4.37e-7+6.02e-5+4.97e-6 +# _probs = [] +# _probs.append(6.02e-5/_tot) +# _probs.append(4.97e-6/_tot) +# _probs.append(4.37e-7/_tot) +# print(_probs) + + +# In[ ]: + + +# dtype = 'float64' +# # mixture = tfd.Uniform(tf.constant(x_min, dtype=dtype), tf.constant(x_max, dtype=dtype)) +# mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=[tf.constant(0.007, dtype=dtype), +# tf.constant(0.917, dtype=dtype), +# tf.constant(0.076, dtype=dtype)]), +# components_distribution=tfd.Uniform(low=[tf.constant(x_min, dtype=dtype), +# tf.constant(3080, dtype=dtype), +# tf.constant(3670, dtype=dtype)], +# high=[tf.constant(x_max, dtype=dtype), +# tf.constant(3112, dtype=dtype), +# tf.constant(3702, dtype=dtype)])) +# # for i in range(10): +# # print(zfit.run(mixture.prob(mixture.sample((10, 1))))) + + +# In[ ]: + + +# print((zfit.run(jpsi_p)%(2*np.pi))/np.pi) +# print((zfit.run(psi2s_p)%(2*np.pi))/np.pi) + + +# In[ ]: + + +# def jpsi_res(q): +# return resonance(q, _mass = jpsi_mass, scale = jpsi_scale, +# phase = jpsi_phase, width = jpsi_width) + +# def psi2s_res(q): +# return resonance(q, _mass = psi2s_mass, scale = psi2s_scale, +# phase = psi2s_phase, width = psi2s_width) + +# def p3770_res(q): +# return resonance(q, _mass = p3770_mass, scale = p3770_scale, +# phase = p3770_phase, width = p3770_width) + +# def p4040_res(q): +# return resonance(q, _mass = p4040_mass, scale = p4040_scale, +# phase = p4040_phase, width = p4040_width) + +# def p4160_res(q): +# return resonance(q, _mass = p4160_mass, scale = p4160_scale, +# phase = p4160_phase, width = p4160_width) + +# def p4415_res(q): +# return resonance(q, _mass = p4415_mass, scale = p4415_scale, +# phase = p4415_phase, width = p4415_width) + + +# In[ ]: + + +# 0.15**2*4.2/1000 +# result.hesse() + + +# ## Constraints + +# In[ ]: + + +# 1. Constraint - Real part of sum of Psi contrib and D contribs + +sum_list = [] + +sum_list.append(ztf.to_complex(jpsi_s) * tf.exp(tf.complex(ztf.constant(0.0), jpsi_p)) * ztf.to_complex(jpsi_w / (tf.pow(jpsi_m,3)))) +sum_list.append(ztf.to_complex(psi2s_s) * tf.exp(tf.complex(ztf.constant(0.0), psi2s_p)) * ztf.to_complex(psi2s_w / (tf.pow(psi2s_m,3)))) +sum_list.append(ztf.to_complex(p3770_s) * tf.exp(tf.complex(ztf.constant(0.0), p3770_p)) * ztf.to_complex(p3770_w / (tf.pow(p3770_m,3)))) +sum_list.append(ztf.to_complex(p4040_s) * tf.exp(tf.complex(ztf.constant(0.0), p4040_p)) * ztf.to_complex(p4040_w / (tf.pow(p4040_m,3)))) +sum_list.append(ztf.to_complex(p4160_s) * tf.exp(tf.complex(ztf.constant(0.0), p4160_p)) * ztf.to_complex(p4160_w / (tf.pow(p4160_m,3)))) +sum_list.append(ztf.to_complex(p4415_s) * tf.exp(tf.complex(ztf.constant(0.0), p4415_p)) * ztf.to_complex(p4415_w / (tf.pow(p4415_m,3)))) +sum_list.append(ztf.to_complex(DDstar_s) * tf.exp(tf.complex(ztf.constant(0.0), DDstar_p)) * (ztf.to_complex(1.0 / (10.0*tf.pow(Dstar_m,2)) + 1.0 / (10.0*tf.pow(D_m,2))))) +sum_list.append(ztf.to_complex(Dbar_s) * tf.exp(tf.complex(ztf.constant(0.0), Dbar_p)) * ztf.to_complex(1.0 / (6.0*tf.pow(Dbar_m,2)))) + +sum_ru_1 = ztf.to_complex(ztf.constant(0.0)) + +for part in sum_list: + sum_ru_1 += part + +sum_1 = tf.math.real(sum_ru_1) +# constraint1 = zfit.constraint.GaussianConstraint(params = sum_1, mu = ztf.constant(1.7*10**-8), +# sigma = ztf.constant(2.2*10**-8)) + +constraint1 = tf.pow((sum_1-ztf.constant(1.7*10**-8))/ztf.constant(2.2*10**-8),2)/ztf.constant(2.) + +# 2. Constraint - Abs. of sum of Psi contribs and D contribs + +sum_2 = tf.abs(sum_ru_1) +constraint2 = tf.cond(tf.greater_equal(sum_2, 5.0e-8), lambda: 100000., lambda: 0.) + +# 3. Constraint - Maximum eta of D contribs + +constraint3_0 = tf.cond(tf.greater_equal(tf.abs(Dbar_s), 0.2), lambda: 100000., lambda: 0.) + +constraint3_1 = tf.cond(tf.greater_equal(tf.abs(DDstar_s), 0.2), lambda: 100000., lambda: 0.) + +# 4. Constraint - Formfactor multivariant gaussian covariance fplus + +Cov_matrix = [[ztf.constant( 1.), ztf.constant( 0.45), ztf.constant( 0.19), ztf.constant(0.857), ztf.constant(0.598), ztf.constant(0.531), ztf.constant(0.752), ztf.constant(0.229), ztf.constant(0,117)], + [ztf.constant( 0.45), ztf.constant( 1.), ztf.constant(0.677), ztf.constant(0.708), ztf.constant(0.958), ztf.constant(0.927), ztf.constant(0.227), ztf.constant(0.443), ztf.constant(0.287)], + [ztf.constant( 0.19), ztf.constant(0.677), ztf.constant( 1.), ztf.constant(0.595), ztf.constant(0.770), ztf.constant(0.819),ztf.constant(-0.023), ztf.constant( 0.07), ztf.constant(0.196)], + [ztf.constant(0.857), ztf.constant(0.708), ztf.constant(0.595), ztf.constant( 1.), ztf.constant( 0.83), ztf.constant(0.766), ztf.constant(0.582), ztf.constant(0.237), ztf.constant(0.192)], + [ztf.constant(0.598), ztf.constant(0.958), ztf.constant(0.770), ztf.constant( 0.83), ztf.constant( 1.), ztf.constant(0.973), ztf.constant(0.324), ztf.constant(0.372), ztf.constant(0.272)], + [ztf.constant(0.531), ztf.constant(0.927), ztf.constant(0.819), ztf.constant(0.766), ztf.constant(0.973), ztf.constant( 1.), ztf.constant(0.268), ztf.constant(0.332), ztf.constant(0.269)], + [ztf.constant(0.752), ztf.constant(0.227),ztf.constant(-0.023), ztf.constant(0.582), ztf.constant(0.324), ztf.constant(0.268), ztf.constant( 1.), ztf.constant( 0.59), ztf.constant(0.515)], + [ztf.constant(0.229), ztf.constant(0.443), ztf.constant( 0.07), ztf.constant(0.237), ztf.constant(0.372), ztf.constant(0.332), ztf.constant( 0.59), ztf.constant( 1.), ztf.constant(0.897)], + [ztf.constant(0.117), ztf.constant(0.287), ztf.constant(0.196), ztf.constant(0.192), ztf.constant(0.272), ztf.constant(0.269), ztf.constant(0.515), ztf.constant(0.897), ztf.constant( 1.)]] + +def triGauss(val1,val2,val3,m = Cov_matrix): + + mean1 = ztf.constant(0.466) + mean2 = ztf.constant(-0.885) + mean3 = ztf.constant(-0.213) + sigma1 = ztf.constant(0.014) + sigma2 = ztf.constant(0.128) + sigma3 = ztf.constant(0.548) + x1 = (val1-mean1)/sigma1 + x2 = (val2-mean2)/sigma2 + x3 = (val3-mean3)/sigma3 + rho12 = m[0][1] + rho13 = m[0][2] + rho23 = m[1][2] + w = x1*x1*(rho23*rho23-1) + x2*x2*(rho13*rho13-1)+x3*x3*(rho12*rho12-1)+2*(x1*x2*(rho12-rho13*rho23)+x1*x3*(rho13-rho12*rho23)+x2*x3*(rho23-rho12*rho13)) + d = 2*(rho12*rho12+rho13*rho13+rho23*rho23-2*rho12*rho13*rho23-1) + + fcn = -w/d + chisq = -2*fcn + return chisq + +constraint4 = triGauss(bplus_0, bplus_1, bplus_2) + +# mean1 = ztf.constant(0.466) +# mean2 = ztf.constant(-0.885) +# mean3 = ztf.constant(-0.213) +# sigma1 = ztf.constant(0.014) +# sigma2 = ztf.constant(0.128) +# sigma3 = ztf.constant(0.548) +# constraint4_0 = tf.pow((bplus_0-mean1)/sigma1,2)/ztf.constant(2.) +# constraint4_1 = tf.pow((bplus_1-mean2)/sigma2,2)/ztf.constant(2.) +# constraint4_2 = tf.pow((bplus_2-mean3)/sigma3,2)/ztf.constant(2.) + +# 5. Constraint - Abs. of sum of light contribs + +sum_list_5 = [] + +sum_list_5.append(rho_s*rho_w/rho_m) +sum_list_5.append(omega_s*omega_w/omega_m) +sum_list_5.append(phi_s*phi_w/phi_m) + + +sum_ru_5 = ztf.constant(0.0) + +for part in sum_list_5: + sum_ru_5 += part + +constraint5 = tf.cond(tf.greater_equal(tf.abs(sum_ru_5), ztf.constant(0.02)), lambda: 100000., lambda: 0.) + +# 6. Constraint on phases of Jpsi and Psi2s for cut out fit + + +# constraint6_0 = zfit.constraint.GaussianConstraint(params = jpsi_p, mu = ztf.constant(pdg["jpsi_phase_unc"]), +# sigma = ztf.constant(jpsi_phase)) +# constraint6_1 = zfit.constraint.GaussianConstraint(params = psi2s_p, mu = ztf.constant(pdg["psi2s_phase_unc"]), +# sigma = ztf.constant(psi2s_phase)) + +constraint6_0 = tf.pow((jpsi_p-ztf.constant(jpsi_phase))/ztf.constant(pdg["jpsi_phase_unc"]),2)/ztf.constant(2.) +constraint6_1 = tf.pow((psi2s_p-ztf.constant(psi2s_phase))/ztf.constant(pdg["psi2s_phase_unc"]),2)/ztf.constant(2.) + +# 7. Constraint on Ctt with higher limits + +constraint7 = tf.cond(tf.greater_equal(Ctt*Ctt, 0.25), lambda: 100000., lambda: 0.) + +constraint7dtype = tf.float64 + +# zfit.run(constraint6_0) + +# ztf.convert_to_tensor(constraint6_0) + +#List of all constraints + +constraints = [constraint1, constraint2, constraint3_0, constraint3_1,# constraint4, #constraint4_0, constraint4_1, constraint4_2, + constraint6_0, constraint6_1]#, constraint7] + + +# ## Reset params + +# In[ ]: + + +param_values_dic = { + 'jpsi_m': jpsi_mass, + 'jpsi_s': jpsi_scale, + 'jpsi_p': jpsi_phase, + 'jpsi_w': jpsi_width, + 'psi2s_m': psi2s_mass, + 'psi2s_s': psi2s_scale, + 'psi2s_p': psi2s_phase, + 'psi2s_w': psi2s_width, + 'p3770_m': p3770_mass, + 'p3770_s': p3770_scale, + 'p3770_p': p3770_phase, + 'p3770_w': p3770_width, + 'p4040_m': p4040_mass, + 'p4040_s': p4040_scale, + 'p4040_p': p4040_phase, + 'p4040_w': p4040_width, + 'p4160_m': p4160_mass, + 'p4160_s': p4160_scale, + 'p4160_p': p4160_phase, + 'p4160_w': p4160_width, + 'p4415_m': p4415_mass, + 'p4415_s': p4415_scale, + 'p4415_p': p4415_phase, + 'p4415_w': p4415_width, + 'rho_m': rho_mass, + 'rho_s': rho_scale, + 'rho_p': rho_phase, + 'rho_w': rho_width, + 'omega_m': omega_mass, + 'omega_s': omega_scale, + 'omega_p': omega_phase, + 'omega_w': omega_width, + 'phi_m': phi_mass, + 'phi_s': phi_scale, + 'phi_p': phi_phase, + 'phi_w': phi_width, + 'Dstar_m': Dstar_mass, + 'DDstar_s': 0.0, + 'DDstar_p': 0.0, + 'D_m': D_mass, + 'Dbar_m': Dbar_mass, + 'Dbar_s': 0.0, + 'Dbar_p': 0.0, + 'tau_m': pdg['tau_M'], + 'Ctt': 0.0, + 'b0_0': 0.292, + 'b0_1': 0.281, + 'b0_2': 0.150, + 'bplus_0': 0.466, + 'bplus_1': -0.885, + 'bplus_2': -0.213, + 'bT_0': 0.460, + 'bT_1': -1.089, + 'bT_2': -1.114} + + +def reset_param_values(variation = 0.05): + for param in total_f_fit.get_dependents(): + if param.floating: + param.set_value(param_values_dic[param.name] + random.uniform(-1, 1) * param_values_dic[param.name]* variation) +# print(param.name) +# for param in totalf.get_dependents(): +# param.set_value() + + +# # Analysis + +# In[ ]: + + +# # zfit.run.numeric_checks = False + +# fitting_range = 'cut' +# total_BR = 1.7e-10 + 4.9e-10 + 2.5e-9 + 6.02e-5 + 4.97e-6 + 1.38e-9 + 4.2e-10 + 2.6e-9 + 6.1e-10 + 4.37e-7 +# cut_BR = 1.0 - (6.02e-5 + 4.97e-6)/total_BR + +# Ctt_list = [] +# Ctt_error_list = [] + +# nr_of_toys = 1 +# if fitting_range == 'cut': +# nevents = int(pdg["number_of_decays"]*cut_BR) +# else: +# nevents = int(pdg["number_of_decays"]) +# # nevents = pdg["number_of_decays"] +# event_stack = 1000000 +# # nevents *= 41 +# # zfit.settings.set_verbosity(10) +# calls = int(nevents/event_stack + 1) + +# total_samp = [] + +# start = time.time() + +# sampler = total_f.create_sampler(n=event_stack) + +# for toy in range(nr_of_toys): + +# ### Generate data + +# # clear_output(wait=True) + +# print("Toy {}: Generating data...".format(toy)) + +# dirName = 'data/zfit_toys/toy_{0}'.format(toy) + +# if not os.path.exists(dirName): +# os.mkdir(dirName) +# print("Directory " , dirName , " Created ") + +# reset_param_values() + +# if fitting_range == 'cut': + +# sampler.resample(n=nevents) +# s = sampler.unstack_x() +# sam = zfit.run(s) +# calls = 0 +# c = 1 + +# else: +# for call in range(calls): + +# sampler.resample(n=event_stack) +# s = sampler.unstack_x() +# sam = zfit.run(s) + +# c = call + 1 + +# with open("data/zfit_toys/toy_{0}/{1}.pkl".format(toy, call), "wb") as f: +# pkl.dump(sam, f, pkl.HIGHEST_PROTOCOL) + +# print("Toy {}: Data generation finished".format(toy)) + +# ### Load data + +# print("Toy {}: Loading data...".format(toy)) + +# if fitting_range == 'cut': + +# total_samp = sam + +# else: + +# for call in range(calls): +# with open(r"data/zfit_toys/toy_0/{}.pkl".format(call), "rb") as input_file: +# sam = pkl.load(input_file) +# total_samp = np.append(total_samp, sam) + +# total_samp = total_samp.astype('float64') + +# if fitting_range == 'full': + +# data = zfit.data.Data.from_numpy(array=total_samp[:int(nevents)], obs=obs) + +# print("Toy {}: Loading data finished".format(toy)) + +# ### Fit data + +# print("Toy {}: Fitting pdf...".format(toy)) + +# for param in total_f.get_dependents(): +# param.randomize() + +# nll = zfit.loss.UnbinnedNLL(model=total_f, data=data, fit_range = (x_min, x_max), constraints = constraints) + +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) +# # minimizer._use_tfgrad = False +# result = minimizer.minimize(nll) + +# print("Toy {}: Fitting finished".format(toy)) + +# print("Function minimum:", result.fmin) +# print("Hesse errors:", result.hesse()) + +# params = result.params +# Ctt_list.append(params[Ctt]['value']) +# Ctt_error_list.append(params[Ctt]['minuit_hesse']['error']) + +# #plotting the result + +# plotdirName = 'data/plots'.format(toy) + +# if not os.path.exists(plotdirName): +# os.mkdir(plotdirName) +# # print("Directory " , dirName , " Created ") + +# probs = total_f.pdf(test_q, norm_range=False) +# calcs_test = zfit.run(probs) +# plt.clf() +# plt.plot(test_q, calcs_test, label = 'pdf') +# plt.legend() +# plt.ylim(0.0, 6e-6) +# plt.savefig(plotdirName + '/toy_fit_full_range{}.png'.format(toy)) + +# print("Toy {0}/{1}".format(toy+1, nr_of_toys)) +# print("Time taken: {}".format(display_time(int(time.time() - start)))) +# print("Projected time left: {}".format(display_time(int((time.time() - start)/(c+calls*(toy))*((nr_of_toys-toy)*calls-c))))) + +# if fitting_range == 'cut': + +# _1 = np.where((total_samp >= x_min) & (total_samp <= (jpsi_mass - 60.))) + +# tot_sam_1 = total_samp[_1] + +# _2 = np.where((total_samp >= (jpsi_mass + 70.)) & (total_samp <= (psi2s_mass - 50.))) + +# tot_sam_2 = total_samp[_2] + +# _3 = np.where((total_samp >= (psi2s_mass + 50.)) & (total_samp <= x_max)) + +# tot_sam_3 = total_samp[_3] + +# tot_sam = np.append(tot_sam_1, tot_sam_2) +# tot_sam = np.append(tot_sam, tot_sam_3) + +# data = zfit.data.Data.from_numpy(array=tot_sam[:int(nevents)], obs=obs_fit) + +# print("Toy {}: Loading data finished".format(toy)) + +# ### Fit data + +# print("Toy {}: Fitting pdf...".format(toy)) + +# for param in total_f_fit.get_dependents(): +# param.randomize() + +# nll = zfit.loss.UnbinnedNLL(model=total_f_fit, data=data, constraints = constraints) + +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) +# # minimizer._use_tfgrad = False +# result = minimizer.minimize(nll) + +# print("Function minimum:", result.fmin) +# print("Hesse errors:", result.hesse()) + +# params = result.params + +# if result.converged: +# Ctt_list.append(params[Ctt]['value']) +# Ctt_error_list.append(params[Ctt]['minuit_hesse']['error']) + +# #plotting the result + +# plotdirName = 'data/plots'.format(toy) + +# if not os.path.exists(plotdirName): +# os.mkdir(plotdirName) +# # print("Directory " , dirName , " Created ") + +# plt.clf() +# plt.hist(tot_sam, bins = int((x_max-x_min)/7.), label = 'toy data') +# plt.savefig(plotdirName + '/toy_histo_cut_region{}.png'.format(toy)) + + +# probs = total_f_fit.pdf(test_q, norm_range=False) +# calcs_test = zfit.run(probs) +# plt.clf() +# plt.plot(test_q, calcs_test, label = 'pdf') +# plt.axvline(x=jpsi_mass-60.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.axvline(x=jpsi_mass+70.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.axvline(x=psi2s_mass-50.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.axvline(x=psi2s_mass+50.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.legend() +# plt.ylim(0.0, 1.5e-6) +# plt.savefig(plotdirName + '/toy_fit_cut_region{}.png'.format(toy)) + +# print("Toy {0}/{1}".format(toy+1, nr_of_toys)) +# print("Time taken: {}".format(display_time(int(time.time() - start)))) +# print("Projected time left: {}".format(display_time(int((time.time() - start)/(toy+1))*((nr_of_toys-toy-1))))) + + + +# In[ ]: + + +# with open("data/results/Ctt_list.pkl", "wb") as f: +# pkl.dump(Ctt_list, f, pkl.HIGHEST_PROTOCOL) +# with open("data/results/Ctt_error_list.pkl", "wb") as f: +# pkl.dump(Ctt_error_list, f, pkl.HIGHEST_PROTOCOL) + + +# In[ ]: + + +# print('{0}/{1} fits converged'.format(len(Ctt_list), nr_of_toys)) +# print('Mean Ctt value = {}'.format(np.mean(Ctt_list))) +# print('Mean Ctt error = {}'.format(np.mean(Ctt_error_list))) +# print('95 Sensitivy = {}'.format(((2*np.mean(Ctt_error_list))**2)*4.2/1000)) + + +# In[ ]: + + +# plt.hist(tot_sam, bins = int((x_max-x_min)/7.)) + +# plt.show() + +# # _ = np.where((total_samp >= x_min) & (total_samp <= (jpsi_mass - 50.))) + +# tot_sam.shape + + +# In[ ]: + + +# Ctt.floating = False + + +# In[ ]: + + +# zfit.run(nll.value()) + + +# In[ ]: + + +# result.fmin + + +# In[ ]: + + +# BR_steps = np.linspace(0.0, 1e-3, 11) +pull_dic = {} + +mi = 1e-4 +ma = 3e-3 +ste = 20 + +for param in total_f_fit.get_dependents(): + if param.floating: + pull_dic[param.name] = [] + for step in range(2*ste): + pull_dic[param.name].append([]) + + + +def save_pulls(step): + for param in total_f_fit.get_dependents(): + if param.floating: + pull_dic[param.name][step].append((params[param]['value'] - param_values_dic[param.name])/params[param]['minuit_hesse']['error']) + + + +# for key in pull_dic.keys(): +# print(np.shape(pull_dic[key])) +# save_pulls(New_step=True) +# params[Ctt]['value'] + + +# In[ ]: + + +# for param in total_f_fit.get_dependents(): +# if param.floating: +# print(param.name) + +# print(params[Ctt]) + + +# # CLS Code + +# In[ ]: + + +# zfit.run.numeric_checks = False + +load = False + +bo = True + +D_contribs = True + +if not D_contribs: + Dbar_s.floating = False + Dbar_p.floating = False + DDstar_s.floating = False + DDstar_p.floating = False + +bo_set = 1 + +fitting_range = 'cut' +total_BR = 1.7e-10 + 4.9e-10 + 2.5e-9 + 6.02e-5 + 4.97e-6 + 1.38e-9 + 4.2e-10 + 2.6e-9 + 6.1e-10 + 4.37e-7 +cut_BR = 1.0 - (6.02e-5 + 4.97e-6)/total_BR + +Ctt_list = [] +Ctt_error_list = [] + +nr_of_toys = 1 +nevents = int(pdg["number_of_decays"]*cut_BR) +# nevents = pdg["number_of_decays"] +event_stack = 1000000 +# nevents *= 41 +# zfit.settings.set_verbosity(10) + +# mi = 1e-4 +# ma = 3e-3 +# ste = 13 + +BR_steps = np.linspace(mi, ma, ste) + +BR_steps[0] = 0.0 + +print(BR_steps) + +Ctt_steps = np.sqrt(BR_steps/4.2*1000) + +print(Ctt_steps) + +# total_samp = [] + +start = time.time() + +Nll_list = [] + +sampler = total_f.create_sampler(n=nevents, fixed_params = False) +sampler.set_data_range(obs_fit) + +__ = -1 + +#----------------------------------------------------- + +if not load: + for Ctt_step in Ctt_steps: + + __ += 1 + + for i in range(2): + Ctt_list.append([]) + Ctt_error_list.append([]) + Nll_list.append([]) + + for param in total_f_fit.get_dependents(): + if param.floating: + pull_dic[param.name].append([]) + + for toy in range(nr_of_toys): + + newset = True + + while newset: + + for floaty in [True, False]: + Ctt.floating = floaty + + for bo_step in range(bo_set): + + print('Step: {0}/{1}'.format(int(__), ste)) + print('Current Ctt: {0}'.format(Ctt_step)) + print('Ctt floating: {0}'.format(floaty)) + + reset_param_values(variation = 0.0) + + if floaty: + print('Toy {0}/{1} - Fit {2}/{3}'.format(toy, nr_of_toys, bo_step, bo_set)) + Ctt.set_value(Ctt_step) + + else: + Ctt.set_value(0.0) + print('Toy {0}/{1} - Fit {2}/{3}'.format(toy, nr_of_toys, bo_step, bo_set)) + + if newset: + sampler.resample(n=nevents) + data = sampler + newset = False + + ### Fit data + + if floaty: + #plt.clf() + #plt.title('Ctt value: {:.2f}'.format(Ctt_step)) + #plt.hist(zfit.run(data), bins = int((x_max-x_min)/7), range = (x_min, x_max)) + #plt.savefig('data/CLs/plots/set_histo{}.png'.format(__)) + _step = 2*__ + else: + _step = 2*__+1 + + nll = zfit.loss.UnbinnedNLL(model=total_f_fit, data=data, constraints = constraints) + + minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) + # minimizer._use_tfgrad = False + result = minimizer.minimize(nll) + + print("Function minimum:", result.fmin) + print("Hesse errors:", result.hesse()) + + params = result.params + + if result.converged: + + save_pulls(step = _step) + + if floaty: + Nll_list[-2].append(result.fmin) + Ctt_list[-2].append(params[Ctt]['value']) + Ctt_error_list[-2].append(params[Ctt]['minuit_hesse']['error']) + + else: + Nll_list[-1].append(result.fmin) + Ctt_list[-1].append(0.0) + Ctt_error_list[-1].append(0.0) + + + else: + for _ in [1,2]: + del Nll_list[-_][toy*bo_set:] +# print(np.shape(Nll_list[-_])) + del Ctt_list[-_][toy*bo_set:] + del Ctt_error_list[-_][toy*bo_set:] + for param in total_f_fit.get_dependents(): + if param.floating: + del pull_dic[param.name][_step+1-_][toy*bo_set:] + newset = True + break + + if not result.converged: + break + + print() + print('Time taken: {}'.format(display_time(int(time.time()-start)))) + print('Estimated time left: {}'.format(display_time(int((time.time()-start)/(__+(toy+1)/nr_of_toys)*(ste-__-(nr_of_toys-toy-1)/nr_of_toys))))) + + +# In[ ]: + + +if load: + + phase_combi = '--' + + if D_contribs: + D_dir = 'D-True' + else: + D_dir = 'D-False' + + _dir = 'data/CLs/finished/f1d1/{}/{}/'.format(phase_combi, D_dir) + + jobs = os.listdir(_dir) + + First = True + +# print(jobs) + + for job in jobs: + + dirName = _dir + str(job) + '/data/CLs' + + if not os.path.exists("{}/{}-{}_{}s{}b{}t--CLs_Nll_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys)): +# print(job) + continue + + with open(r"{}/variab.pkl".format(dirName), "rb") as input_file: + variab = pkl.load(input_file) +# print(variab) + + ### sanity check: + if variab['mi'] != mi or variab['ma'] != ma or variab['ste'] != ste or bo_set != bo_set: + print('Fitting parameters of data dont equal the ones given -- Job {} skipped!'.format(job)) + + with open(r"{}/{}-{}_{}s{}b{}t--CLs_Nll_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _Nll_list = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s{}b{}t--Ctt_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _Ctt_list = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s{}b{}t--Ctt_error_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _Ctt_error_list = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s{}b{}t--pull_dic.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _pull_dic = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s--CLs_list.pkl".format(dirName, mi,ma,ste), "rb") as input_file: + _CLs_list = pkl.load(input_file) + + + if First: + Nll_list = _Nll_list + Ctt_list = _Ctt_list + Ctt_error_list = _Ctt_error_list + pull_dic = _pull_dic +# print(_pull_dic) + CLs_list = _CLs_list + First = False + else: + for step in range(2*ste): +# print(Nll_list[step], step) + Nll_list[step].extend(_Nll_list[step]) + Ctt_list[step].extend(_Ctt_list[step]) + Ctt_error_list[step].extend(_Ctt_error_list[step]) + for key in pull_dic.keys(): +# print(key, np.shape(pull_dic[key])) + pull_dic[key][step].extend(_pull_dic[key][step]) + for step in range(ste): + CLs_list[step].extend(_CLs_list[step]) + +# print('----------------------') + + +# In[ ]: + + +dirName = 'data/CLs' + +# if bo and not load: +# for s in range(2*ste): +# Nll_list[s] = [np.min(Nll_list[s])] + + +if not load: + + if not os.path.exists(dirName): + os.mkdir(dirName) + print("Directory " , dirName , " Created ") + + with open("{}/{}-{}_{}s{}b{}t--CLs_Nll_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(Nll_list, f, pkl.HIGHEST_PROTOCOL) + + with open("{}/{}-{}_{}s{}b{}t--Ctt_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(Ctt_list, f, pkl.HIGHEST_PROTOCOL) + + with open("{}/{}-{}_{}s{}b{}t--Ctt_error_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(Ctt_error_list, f, pkl.HIGHEST_PROTOCOL) + + with open("{}/{}-{}_{}s{}b{}t--pull_dic.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(pull_dic, f, pkl.HIGHEST_PROTOCOL) + + variab = {'mi': mi, + 'ma': ma, + 'ste': ste, + 'bo_set': bo_set, + 'nr_of_toys': nr_of_toys} + + with open("{}/variab.pkl".format(dirName), "wb") as f: + pkl.dump(variab, f, pkl.HIGHEST_PROTOCOL) + + CLs_values = [] + + toy_size = bo_set + + print(np.shape(Nll_list)) + print(Nll_list[0:1]) + + for step in range(ste): + CLs_values.append([]) + for toy in range(nr_of_toys): + float_min = np.min(Nll_list[2*step][toy*bo_set:(toy+1)*bo_set]) + fix_min = np.min(Nll_list[2*step+1][toy*bo_set:(toy+1)*bo_set]) + CLs_values[step].append(float_min-fix_min) + + + print(np.shape(CLs_values)) + + with open("{}/{}-{}_{}s--CLs_list.pkl".format(dirName, mi,ma,ste), "wb") as f: + pkl.dump(CLs_values, f, pkl.HIGHEST_PROTOCOL) + + +# In[ ]: + + +# print(variab['mi'] != mi) + + +# ## Plot + +# In[ ]: + + +l = [] + + +if load: + CLs_values = -1*np.array(CLs_list) + +if not os.path.exists('data/CLs/plots'): + os.mkdir('data/CLs/plots') + print("Directory " , 'data/CLs/plots' , " Created ") + +print(np.shape(CLs_values)) + +for step in range(1,ste): + plt.clf() + plt.title('Ctt value: {:.2f}'.format(Ctt_steps[step])) + plt.hist(CLs_values[0], bins = 150, range = (-25, 50), label = 'Ctt fixed to 0') + plt.hist(CLs_values[step], bins = 150, range = (-25, 50), label = 'Ctt floating') + plt.axvline(x=np.mean(CLs_values[0]),color='red', linewidth=1.0, linestyle = 'dotted') + plt.legend() + plt.savefig('data/CLs/plots/CLs-BR({:.1E}).png'.format(BR_steps[step])) + + l.append(len(np.where(np.array(CLs_values[step]) < np.mean(CLs_values[0]))[0])) + +for step in range(2*ste): + if step%2 == 0: + floaty = True + else: + floaty = False + for key in pull_dic.keys(): + if not os.path.exists('data/CLs/plots/{}'.format(key)): + os.mkdir('data/CLs/plots/{}'.format(key)) + plt.clf() + plt.title('Pull {} - Ctt value {:.2f} - floating {}'.format(key, Ctt_steps[int(step/2)], floaty)) + plt.hist(pull_dic[key][step], bins = 50, range = (-5,5)) + plt.xlabel('Pull') + plt.savefig('data/CLs/plots/{}/{:.2f}Ctt{}s{}f.png'.format(key, Ctt_steps[int(step/2)], step, floaty)) + + +# In[ ]: + + +for s in range(len(l)): + print('BR: {:.4f}'.format(BR_steps[s+1])) + print(2*l[s]/len(CLs_values[s])) + print() + + +# In[ ]: + + +# for step in range(2*ste): +# for key in pull_dic.keys(): +# print(pull_dic[key][step]) + + +# In[ ]: + + +# for param in total_f_fit.get_dependents(): +# if param.floating: +# print(params[param]['value']) + + +# In[ ]: + + +print(display_time(int(time.time()-start))) + + +# In[ ]: + + +# variab['mi'] =! mi + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + diff --git a/data/CLs/finished/f1d1/-+/D-True/2288041/__pycache__/helperfunctions.cpython-37.pyc b/data/CLs/finished/f1d1/-+/D-True/2288041/__pycache__/helperfunctions.cpython-37.pyc new file mode 100644 index 0000000..b6b46b5 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288041/__pycache__/helperfunctions.cpython-37.pyc Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288041/__pycache__/pdg_const1.cpython-37.pyc b/data/CLs/finished/f1d1/-+/D-True/2288041/__pycache__/pdg_const1.cpython-37.pyc new file mode 100644 index 0000000..9befd1f --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288041/__pycache__/pdg_const1.cpython-37.pyc Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288041/data/CLs/0.0001-0.003_20s--CLs_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288041/data/CLs/0.0001-0.003_20s--CLs_list.pkl new file mode 100644 index 0000000..90eb54f --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288041/data/CLs/0.0001-0.003_20s--CLs_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288041/data/CLs/0.0001-0.003_20s1b1t--CLs_Nll_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288041/data/CLs/0.0001-0.003_20s1b1t--CLs_Nll_list.pkl new file mode 100644 index 0000000..6192543 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288041/data/CLs/0.0001-0.003_20s1b1t--CLs_Nll_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288041/data/CLs/0.0001-0.003_20s1b1t--Ctt_error_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288041/data/CLs/0.0001-0.003_20s1b1t--Ctt_error_list.pkl new file mode 100644 index 0000000..3d12f15 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288041/data/CLs/0.0001-0.003_20s1b1t--Ctt_error_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288041/data/CLs/0.0001-0.003_20s1b1t--Ctt_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288041/data/CLs/0.0001-0.003_20s1b1t--Ctt_list.pkl new file mode 100644 index 0000000..3f689c3 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288041/data/CLs/0.0001-0.003_20s1b1t--Ctt_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288041/data/CLs/0.0001-0.003_20s1b1t--pull_dic.pkl b/data/CLs/finished/f1d1/-+/D-True/2288041/data/CLs/0.0001-0.003_20s1b1t--pull_dic.pkl new file mode 100644 index 0000000..0a5b10c --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288041/data/CLs/0.0001-0.003_20s1b1t--pull_dic.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288041/data/CLs/variab.pkl b/data/CLs/finished/f1d1/-+/D-True/2288041/data/CLs/variab.pkl new file mode 100644 index 0000000..bb90dc0 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288041/data/CLs/variab.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288041/helperfunctions.py b/data/CLs/finished/f1d1/-+/D-True/2288041/helperfunctions.py new file mode 100644 index 0000000..88e120f --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288041/helperfunctions.py @@ -0,0 +1,33 @@ +# some helperfunctions + +import matplotlib +matplotlib.use("agg") +import matplotlib.pyplot as plt + +#Dislpay time (e.g. while generating points) + +display_intervals = ( + ('w', 604800), # 60 * 60 * 24 * 7 + ('d', 86400), # 60 * 60 * 24 + ('h', 3600), # 60 * 60 + ('min', 60), + ('s', 1), + ) + +def display_time(seconds, granularity=2): + result = [] + + for name, count in display_intervals: + value = seconds // count + if value: + seconds -= value * count + if value == 1: + name = name.rstrip('s') + result.append("{} {}".format(value, name)) + return ', '.join(result[:granularity]) + +def prepare_plot(title): + plt.title(title) + plt.grid() + plt.legend(loc = 'best') + plt.xlabel("q") diff --git a/data/CLs/finished/f1d1/-+/D-True/2288041/pdg_const1.py b/data/CLs/finished/f1d1/-+/D-True/2288041/pdg_const1.py new file mode 100644 index 0000000..70b3f30 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288041/pdg_const1.py @@ -0,0 +1,226 @@ +pdg = { + + + ###Particle masses### + + "mbstar" : 5415.4, + "mbstar0" : 5711.0, + "B0_M" : 5279.5, + "Bs_M" : 5366.7, + "Bplus_M" : 5279.3, + "Lb_M" : 5619.4, + "D0_M" : 1864.8, + "Dst_M" : 2010, + "pi_M" : 139.6, + "Jpsi_M" : 3096.9, + "Psi2s_M" : 3685.6, + "kaon_M" : 493.7, + "Ks_M" : 497.6, + "phi_M" : 1019.5, + "rho_M" : 775.26, + "rho_width" : 149.1, + "omega_M" : 782.65, + "omega_width" : 8.49, + + "muon_M" : 105.7, + "tau_M": 1776.86, + + "squark_M" : 95.0, + "bquark_M" : 4180.0, + "cquark_M" : 1275.0, + + "Bplus_tau" : 1.638e-12, + + ###Wilson coefficients### + + "C1" : -0.257, + "C2" : 1.009, + "C3" : -0.005, + "C4" : -0.078, + + "C7eff" : -0.306, + "C9eff" : 4.211, + "C10eff" : -4.103, + +# "C7eff": 0.0, +# "C9eff": 0.0, +# "C10eff": 0.0, + + ###Other constants + + "GF" : 1.1663787e-5, + "alpha_ew" : 1.0/137.0, + "Vts" : 0.0394, + "Vtb" : 1.019, + "number_of_decays": 5404696, + + #Formfactor z coefficients + + #"b0" : [0.285, 0.19, -0.17], + #"bplus" : [0.437, -1.41, -2.5], + #"bT" : [0.440, -1.47, -2.7] + + "b0" : [0.292, 0.281, 0.150], + "bplus" : [0.466, -0.885, -0.213], + "bT" : [0.460, -1.089, -1.114], + + "NR_BR": 4.37e-7, + "NR_auc": 0.00133, + + #Resonances format(mass, width, phase, scale) + + # pre scaling + +# "rho": (775.26, 149.0, -0.35, 1.0), + +# "omega": (782.7, 8.5, 0.26, 1.0), + +# "phi": (1019.46, 4.25, 0.5, 1.0), + +# "jpsi": (3096.0, 0.09, -1.5, 2e-2), +# "jpsi_auc": 0.2126825758464027, + +# "psi2s": (3686.0, 0.3, -1.5, 3.14e-3), +# "psi2s_auc": 2.802257483178487e-10, + +# "p3770": (3773.0, 27.2, -2.13, 1.0e-3), + +# "p4040": (4039.0, 80.0, -2.52, 2.0), + +# "p4160": (4191.0, 70.0, -1.9, 2.2), + +# "p4415": (4421.0, 62.0, -2.52, 1.0), + + + # after scaling (Phase combination --) + + # + # "rho": (743.2, 149.0, -0.22, 1.05), + # + # "omega": (782.7, 8.5, 0.38, 6.8), + # + # "phi": (1013.5, 4.25, 0.62, 19.2), + # + # "jpsi": (3096.1, 0.09, 1.63, 9897.0), + # "jpsi_auc": 0.2126825758464027, + # "jpsi_phase_unc": 0.05, + # + # "psi2s": (3686.0, 0.3, 1.8, 1396.0), + # "psi2s_auc": 0.0151332263, + # "psi2s_phase_unc": 0.1, + # + # "p3770": (3773.0, 27.2, -2.95, 2.5), + # + # "p4040": (4039.0, 80.0, -2.75, 1.01), + # + # "p4160": (4191.0, 70.0, -2.28, 2.2), + # + # "p4415": (4421.0, 62.0, -2.31, 1.24), + + # Phase combination of paper ++ + +# "rho": (743.2, 149.0, -0.35, 1.05), + +# "omega": (782.7, 8.5, 0.26, 6.8), + +# "phi": (1013.5, 4.25, 0.47, 19.2), + +# "jpsi": (3096.1, 0.09, -1.66, 9897.0), +# "jpsi_auc": 0.2126825758464027, +# "jpsi_phase_unc": 0.05, + +# "psi2s": (3686.0, 0.3, -1.93, 1396.0), +# "psi2s_auc": 0.0151332263, +# "psi2s_phase_unc": 0.1, + +# "p3770": (3773.0, 27.2, -2.13, 2.5), + +# "p4040": (4039.0, 80.0, -2.52, 1.01), + +# "p4160": (4191.0, 70.0, -1.90, 2.2), + +# "p4415": (4421.0, 62.0, -2.52, 1.24), + + # Phase combination of paper +- + +# "rho": (743.2, 149.0, -0.26, 1.05), + +# "omega": (782.7, 8.5, 0.35, 6.8), + +# "phi": (1013.5, 4.25, 0.58, 19.2), + +# "jpsi": (3096.1, 0.09, 1.47, 9897.0), +# "jpsi_auc": 0.2126825758464027, +# "jpsi_phase_unc": 0.05, + +# "psi2s": (3686.0, 0.3, -2.21, 1396.0), +# "psi2s_auc": 0.0151332263, +# "psi2s_phase_unc": 0.1, + +# "p3770": (3773.0, 27.2, -2.140, 2.5), + +# "p4040": (4039.0, 80.0, -2.64, 1.01), + +# "p4160": (4191.0, 70.0, -2.11, 2.2), + +# "p4415": (4421.0, 62.0, -2.42, 1.24), + + # Phase combination of paper -+ + + "rho": (743.2, 149.0, -0.30, 1.05), + + "omega": (782.7, 8.5, 0.30, 6.8), + + "phi": (1013.5, 4.25, 0.51, 19.2), + + "jpsi": (3096.1, 0.09, -1.5, 9897.0), + "jpsi_auc": 0.2126825758464027, + "jpsi_phase_unc": 0.05, + + "psi2s": (3686.0, 0.3, 2.08, 1396.0), + "psi2s_auc": 0.0151332263, + "psi2s_phase_unc": 0.1, + + "p3770": (3773.0, 27.2, -2.89, 2.5), + + "p4040": (4039.0, 80.0, -2.69, 1.01), + + "p4160": (4191.0, 70.0, -2.13, 2.2), + + "p4415": (4421.0, 62.0, -2.43, 1.24), + + + # zeroing resonances + +# "rho": (775.26, 149.0, -0.35, 0.0), +# "omega": (782.7, 8.5, 0.26, 0.0), +# "phi": (1019.46, 4.25, 0.5, 0.0), +# "jpsi": (3096.0, 0.09, -1.5, 0.0), +# "psi2s": (3686.0, 0.3, -1.5, 0.0), +# "p3770": (3773.0, 27.2, -2.13, 0.0), +# "p4040": (4039.0, 80.0, -2.52, 0.0), +# "p4160": (4147.0, 22.0, -1.9, 0.0), +# "p4415": (4421.0, 62.0, -2.52, 0.0), + + # 2P contributions format(mass, amp, phase) + +# "D_bar": ( + + #general + + "rho_BR": 1.7e-10, + "omega_BR": 4.9e-10, + "phi_BR": 2.5e-9, + "jpsi_BR": 6.02e-5, + "psi2s_BR": 4.97e-6, + "p3770_BR": 1.38e-9, + "p4040_BR": 4.2e-10, + "p4160_BR": 2.6e-9, + "p4415_BR": 6.1e-10, + +# Estimates + "Dbar_scale": 1.46, #with phase = pi + + "DDstar_scale": 2.41, #with phase = pi + + } diff --git a/data/CLs/finished/f1d1/-+/D-True/2288041/raremodel-nb.py b/data/CLs/finished/f1d1/-+/D-True/2288041/raremodel-nb.py new file mode 100644 index 0000000..c326c9c --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288041/raremodel-nb.py @@ -0,0 +1,2152 @@ +#!/usr/bin/env python +# coding: utf-8 + +# # Import + +# In[ ]: + + +import os + +# os.environ["CUDA_VISIBLE_DEVICES"] = "-1" +import random +import numpy as np +from pdg_const1 import pdg +import matplotlib +import matplotlib.pyplot as plt +import pickle as pkl +import sys +import time +from helperfunctions import display_time, prepare_plot +import cmath as c +import scipy.integrate as integrate +from scipy.optimize import fminbound +from array import array as arr +import collections +from itertools import compress +import tensorflow as tf +import zfit +from zfit import ztf +# from IPython.display import clear_output +import os +import tensorflow_probability as tfp +tfd = tfp.distributions + + +# In[ ]: + + +# chunksize = 10000 +# zfit.run.chunking.active = True +# zfit.run.chunking.max_n_points = chunksize + + +# # Build model and graphs +# ## Create graphs + +# In[ ]: + + + + + +# In[ ]: + + +def formfactor(q2, subscript, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2): #returns real value + #check if subscript is viable + + if subscript != "0" and subscript != "+" and subscript != "T": + raise ValueError('Wrong subscript entered, choose either 0, + or T') + + #get constants + + mK = ztf.constant(pdg['Ks_M']) + mbstar0 = ztf.constant(pdg["mbstar0"]) + mbstar = ztf.constant(pdg["mbstar"]) + + + mmu = ztf.constant(pdg['muon_M']) + mb = ztf.constant(pdg['bquark_M']) + ms = ztf.constant(pdg['squark_M']) + mB = ztf.constant(pdg['Bplus_M']) + + #N comes from derivation in paper + + N = 3 + + #some helperfunctions + + tpos = (mB - mK)**2 + tzero = (mB + mK)*(ztf.sqrt(mB)-ztf.sqrt(mK))**2 + + z_oben = ztf.sqrt(tpos - q2) - ztf.sqrt(tpos - tzero) + z_unten = ztf.sqrt(tpos - q2) + ztf.sqrt(tpos - tzero) + z = tf.divide(z_oben, z_unten) + + #calculate f0 + + if subscript == "0": + prefactor = 1/(1 - q2/(mbstar0**2)) + _sum = 0 + b0 = [b0_0, b0_1, b0_2] + + for i in range(N): + _sum += b0[i]*(tf.pow(z,i)) + + return ztf.to_complex(prefactor * _sum) + + #calculate f+ or fT + + else: + prefactor = 1/(1 - q2/(mbstar**2)) + _sum = 0 + + if subscript == "T": + bT = [bT_0, bT_1, bT_2] + for i in range(N): + _sum += bT[i] * (tf.pow(z, i) - ((-1)**(i-N)) * (i/N) * tf.pow(z, N)) + else: + bplus = [bplus_0, bplus_1, bplus_2] + for i in range(N): + _sum += bplus[i] * (tf.pow(z, i) - ((-1)**(i-N)) * (i/N) * tf.pow(z, N)) + + return ztf.to_complex(prefactor * _sum) + +def resonance(q, _mass, width, phase, scale): + + q2 = tf.pow(q, 2) + + mmu = ztf.constant(pdg['muon_M']) + + p = 0.5 * ztf.sqrt(q2 - 4*(mmu**2)) + + p0 = 0.5 * ztf.sqrt(_mass**2 - 4*mmu**2) + + gamma_j = tf.divide(p, q) * _mass * width / p0 + + #Calculate the resonance + + _top = tf.complex(_mass * width, ztf.constant(0.0)) + + _bottom = tf.complex(_mass**2 - q2, -_mass*gamma_j) + + com = _top/_bottom + + #Rotate by the phase + + r = ztf.to_complex(scale*tf.abs(com)) + + _phase = tf.angle(com) + + _phase += phase + + com = r * tf.exp(tf.complex(ztf.constant(0.0), _phase)) + + return com + + +def axiv_nonres(q, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2): + + GF = ztf.constant(pdg['GF']) + alpha_ew = ztf.constant(pdg['alpha_ew']) + Vtb = ztf.constant(pdg['Vtb']) + Vts = ztf.constant(pdg['Vts']) + C10eff = ztf.constant(pdg['C10eff']) + + mmu = ztf.constant(pdg['muon_M']) + mb = ztf.constant(pdg['bquark_M']) + ms = ztf.constant(pdg['squark_M']) + mK = ztf.constant(pdg['Ks_M']) + mB = ztf.constant(pdg['Bplus_M']) + + q2 = tf.pow(q, 2) + + #Some helperfunctions + + beta = 1. - 4. * mmu**2. / q2 + + kabs = ztf.sqrt(mB**2. + tf.pow(q2, 2)/mB**2. + mK**4./mB**2. - 2. * (mB**2. * mK**2. + mK**2. * q2 + mB**2. * q2) / mB**2.) + + #prefactor in front of whole bracket + + prefactor1 = GF**2. *alpha_ew**2. * (tf.abs(Vtb*Vts))**2. * kabs * beta / (128. * np.pi**5.) + + #left term in bracket + + bracket_left = 2./3. * tf.pow(kabs,2) * tf.pow(beta,2) * tf.pow(tf.abs(ztf.to_complex(C10eff)*formfactor(q2, "+", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2)),2) + + #middle term in bracket + + _top = 4. * mmu**2. * (mB**2. - mK**2.) * (mB**2. - mK**2.) + + _under = q2 * mB**2. + + bracket_middle = _top/_under *tf.pow(tf.abs(ztf.to_complex(C10eff) * formfactor(q2, "0", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2)), 2) + + #Note sqrt(q2) comes from derivation as we use q2 and plot q + + return prefactor1 * (bracket_left + bracket_middle) * 2 * q + +def vec(q, funcs, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2): + + q2 = tf.pow(q, 2) + + GF = ztf.constant(pdg['GF']) + alpha_ew = ztf.constant(pdg['alpha_ew']) + Vtb = ztf.constant(pdg['Vtb']) + Vts = ztf.constant(pdg['Vts']) + C7eff = ztf.constant(pdg['C7eff']) + + mmu = ztf.constant(pdg['muon_M']) + mb = ztf.constant(pdg['bquark_M']) + ms = ztf.constant(pdg['squark_M']) + mK = ztf.constant(pdg['Ks_M']) + mB = ztf.constant(pdg['Bplus_M']) + + #Some helperfunctions + + beta = 1. - 4. * mmu**2. / q2 + + kabs = ztf.sqrt(mB**2. + tf.pow(q2, 2)/mB**2. + mK**4./mB**2. - 2 * (mB**2 * mK**2 + mK**2 * q2 + mB**2 * q2) / mB**2) + + #prefactor in front of whole bracket + + prefactor1 = GF**2. *alpha_ew**2. * (tf.abs(Vtb*Vts))**2 * kabs * beta / (128. * np.pi**5.) + + #right term in bracket + + prefactor2 = tf.pow(kabs,2) * (1. - 1./3. * beta) + + abs_bracket = tf.pow(tf.abs(c9eff(q, funcs) * formfactor(q2, "+", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + ztf.to_complex(2.0 * C7eff * (mb + ms)/(mB + mK)) * formfactor(q2, "T", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2)),2) + + bracket_right = prefactor2 * abs_bracket + + #Note sqrt(q2) comes from derivation as we use q2 and plot q + + return prefactor1 * bracket_right * 2 * q + +def c9eff(q, funcs): + + C9eff_nr = ztf.to_complex(ztf.constant(pdg['C9eff'])) + + c9 = C9eff_nr + funcs + + return c9 + + +# In[ ]: + + +def G(y): + + def inner_rect_bracket(q): + return tf.log(ztf.to_complex((1+tf.sqrt(q))/(1-tf.sqrt(q)))-tf.complex(ztf.constant(0), -1*ztf.constant(np.pi))) + + def inner_right(q): + return ztf.to_complex(2 * tf.atan(1/tf.sqrt(tf.math.real(-q)))) + + big_bracket = tf.where(tf.math.real(y) > ztf.constant(0.0), inner_rect_bracket(y), inner_right(y)) + + return ztf.to_complex(tf.sqrt(tf.abs(y))) * big_bracket + +def h_S(m, q): + + return ztf.to_complex(2) - G(ztf.to_complex(1) - ztf.to_complex(4*tf.pow(m, 2)) / ztf.to_complex(tf.pow(q, 2))) + +def h_P(m, q): + + return ztf.to_complex(2/3) + (ztf.to_complex(1) - ztf.to_complex(4*tf.pow(m, 2)) / ztf.to_complex(tf.pow(q, 2))) * h_S(m,q) + +def two_p_ccbar(mD, m_D_bar, m_D_star, q): + + + #Load constants + nu_D_bar = ztf.to_complex(pdg["nu_D_bar"]) + nu_D = ztf.to_complex(pdg["nu_D"]) + nu_D_star = ztf.to_complex(pdg["nu_D_star"]) + + phase_D_bar = ztf.to_complex(pdg["phase_D_bar"]) + phase_D = ztf.to_complex(pdg["phase_D"]) + phase_D_star = ztf.to_complex(pdg["phase_D_star"]) + + #Calculation + left_part = nu_D_bar * tf.exp(tf.complex(ztf.constant(0.0), phase_D_bar)) * h_S(m_D_bar, q) + + right_part_D = nu_D * tf.exp(tf.complex(ztf.constant(0.0), phase_D)) * h_P(m_D, q) + + right_part_D_star = nu_D_star * tf.exp(tf.complex(ztf.constant(0.0), phase_D_star)) * h_P(m_D_star, q) + + return left_part + right_part_D + right_part_D_star + + +# ## Build pdf + +# In[ ]: + + +class total_pdf_cut(zfit.pdf.ZPDF): + _N_OBS = 1 # dimension, can be omitted + _PARAMS = ['b0_0', 'b0_1', 'b0_2', + 'bplus_0', 'bplus_1', 'bplus_2', + 'bT_0', 'bT_1', 'bT_2', + 'rho_mass', 'rho_scale', 'rho_phase', 'rho_width', + 'jpsi_mass', 'jpsi_scale', 'jpsi_phase', 'jpsi_width', + 'psi2s_mass', 'psi2s_scale', 'psi2s_phase', 'psi2s_width', + 'p3770_mass', 'p3770_scale', 'p3770_phase', 'p3770_width', + 'p4040_mass', 'p4040_scale', 'p4040_phase', 'p4040_width', + 'p4160_mass', 'p4160_scale', 'p4160_phase', 'p4160_width', + 'p4415_mass', 'p4415_scale', 'p4415_phase', 'p4415_width', + 'omega_mass', 'omega_scale', 'omega_phase', 'omega_width', + 'phi_mass', 'phi_scale', 'phi_phase', 'phi_width', + 'Dbar_mass', 'Dbar_scale', 'Dbar_phase', + 'Dstar_mass', 'DDstar_scale', 'DDstar_phase', 'D_mass', + 'tau_mass', 'C_tt'] +# the name of the parameters + + def _unnormalized_pdf(self, x): + + x = x.unstack_x() + + b0 = [self.params['b0_0'], self.params['b0_1'], self.params['b0_2']] + bplus = [self.params['bplus_0'], self.params['bplus_1'], self.params['bplus_2']] + bT = [self.params['bT_0'], self.params['bT_1'], self.params['bT_2']] + + def rho_res(q): + return resonance(q, _mass = self.params['rho_mass'], scale = self.params['rho_scale'], + phase = self.params['rho_phase'], width = self.params['rho_width']) + + def omega_res(q): + return resonance(q, _mass = self.params['omega_mass'], scale = self.params['omega_scale'], + phase = self.params['omega_phase'], width = self.params['omega_width']) + + def phi_res(q): + return resonance(q, _mass = self.params['phi_mass'], scale = self.params['phi_scale'], + phase = self.params['phi_phase'], width = self.params['phi_width']) + + def jpsi_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['jpsi_mass'], 2)) * resonance(q, _mass = self.params['jpsi_mass'], + scale = self.params['jpsi_scale'], + phase = self.params['jpsi_phase'], + width = self.params['jpsi_width']) + def psi2s_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['psi2s_mass'], 2)) * resonance(q, _mass = self.params['psi2s_mass'], + scale = self.params['psi2s_scale'], + phase = self.params['psi2s_phase'], + width = self.params['psi2s_width']) + def p3770_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p3770_mass'], 2)) * resonance(q, _mass = self.params['p3770_mass'], + scale = self.params['p3770_scale'], + phase = self.params['p3770_phase'], + width = self.params['p3770_width']) + + def p4040_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4040_mass'], 2)) * resonance(q, _mass = self.params['p4040_mass'], + scale = self.params['p4040_scale'], + phase = self.params['p4040_phase'], + width = self.params['p4040_width']) + + def p4160_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4160_mass'], 2)) * resonance(q, _mass = self.params['p4160_mass'], + scale = self.params['p4160_scale'], + phase = self.params['p4160_phase'], + width = self.params['p4160_width']) + + def p4415_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4415_mass'], 2)) * resonance(q, _mass = self.params['p4415_mass'], + scale = self.params['p4415_scale'], + phase = self.params['p4415_phase'], + width = self.params['p4415_width']) + + def P2_D(q): + Dbar_contrib = ztf.to_complex(self.params['Dbar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['Dbar_phase']))*ztf.to_complex(h_S(self.params['Dbar_mass'], q)) + DDstar_contrib = ztf.to_complex(self.params['DDstar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['DDstar_phase']))*(ztf.to_complex(h_P(self.params['Dstar_mass'], q)) + ztf.to_complex(h_P(self.params['D_mass'], q))) + return Dbar_contrib + DDstar_contrib + + def ttau_cusp(q): + return ztf.to_complex(self.params['C_tt'])*(ztf.to_complex((h_S(self.params['tau_mass'], q))) - ztf.to_complex(h_P(self.params['tau_mass'], q))) + + + funcs = rho_res(x) + omega_res(x) + phi_res(x) + jpsi_res(x) + psi2s_res(x) + p3770_res(x) + p4040_res(x)+ p4160_res(x) + p4415_res(x) + P2_D(x) + ttau_cusp(x) + + vec_f = vec(x, funcs, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + axiv_nr = axiv_nonres(x, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + tot = vec_f + axiv_nr + + #Cut out jpsi and psi2s + + tot = tf.where(tf.math.logical_or(x < ztf.constant(jpsi_mass-60.), x > ztf.constant(jpsi_mass+70.)), tot, 0.0*tot) + + tot = tf.where(tf.math.logical_or(x < ztf.constant(psi2s_mass-50.), x > ztf.constant(psi2s_mass+50.)), tot, 0.0*tot) + + return tot + +class total_pdf_full(zfit.pdf.ZPDF): + _N_OBS = 1 # dimension, can be omitted + _PARAMS = ['b0_0', 'b0_1', 'b0_2', + 'bplus_0', 'bplus_1', 'bplus_2', + 'bT_0', 'bT_1', 'bT_2', + 'rho_mass', 'rho_scale', 'rho_phase', 'rho_width', + 'jpsi_mass', 'jpsi_scale', 'jpsi_phase', 'jpsi_width', + 'psi2s_mass', 'psi2s_scale', 'psi2s_phase', 'psi2s_width', + 'p3770_mass', 'p3770_scale', 'p3770_phase', 'p3770_width', + 'p4040_mass', 'p4040_scale', 'p4040_phase', 'p4040_width', + 'p4160_mass', 'p4160_scale', 'p4160_phase', 'p4160_width', + 'p4415_mass', 'p4415_scale', 'p4415_phase', 'p4415_width', + 'omega_mass', 'omega_scale', 'omega_phase', 'omega_width', + 'phi_mass', 'phi_scale', 'phi_phase', 'phi_width', + 'Dbar_mass', 'Dbar_scale', 'Dbar_phase', + 'Dstar_mass', 'DDstar_scale', 'DDstar_phase', 'D_mass', + 'tau_mass', 'C_tt'] +# the name of the parameters + + def _unnormalized_pdf(self, x): + + x = x.unstack_x() + + b0 = [self.params['b0_0'], self.params['b0_1'], self.params['b0_2']] + bplus = [self.params['bplus_0'], self.params['bplus_1'], self.params['bplus_2']] + bT = [self.params['bT_0'], self.params['bT_1'], self.params['bT_2']] + + def rho_res(q): + return resonance(q, _mass = self.params['rho_mass'], scale = self.params['rho_scale'], + phase = self.params['rho_phase'], width = self.params['rho_width']) + + def omega_res(q): + return resonance(q, _mass = self.params['omega_mass'], scale = self.params['omega_scale'], + phase = self.params['omega_phase'], width = self.params['omega_width']) + + def phi_res(q): + return resonance(q, _mass = self.params['phi_mass'], scale = self.params['phi_scale'], + phase = self.params['phi_phase'], width = self.params['phi_width']) + + def jpsi_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['jpsi_mass'], 2)) * resonance(q, _mass = self.params['jpsi_mass'], + scale = self.params['jpsi_scale'], + phase = self.params['jpsi_phase'], + width = self.params['jpsi_width']) + def psi2s_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['psi2s_mass'], 2)) * resonance(q, _mass = self.params['psi2s_mass'], + scale = self.params['psi2s_scale'], + phase = self.params['psi2s_phase'], + width = self.params['psi2s_width']) + def p3770_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p3770_mass'], 2)) * resonance(q, _mass = self.params['p3770_mass'], + scale = self.params['p3770_scale'], + phase = self.params['p3770_phase'], + width = self.params['p3770_width']) + + def p4040_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4040_mass'], 2)) * resonance(q, _mass = self.params['p4040_mass'], + scale = self.params['p4040_scale'], + phase = self.params['p4040_phase'], + width = self.params['p4040_width']) + + def p4160_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4160_mass'], 2)) * resonance(q, _mass = self.params['p4160_mass'], + scale = self.params['p4160_scale'], + phase = self.params['p4160_phase'], + width = self.params['p4160_width']) + + def p4415_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4415_mass'], 2)) * resonance(q, _mass = self.params['p4415_mass'], + scale = self.params['p4415_scale'], + phase = self.params['p4415_phase'], + width = self.params['p4415_width']) + + def P2_D(q): + Dbar_contrib = ztf.to_complex(self.params['Dbar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['Dbar_phase']))*ztf.to_complex(h_S(self.params['Dbar_mass'], q)) + DDstar_contrib = ztf.to_complex(self.params['DDstar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['DDstar_phase']))*(ztf.to_complex(h_P(self.params['Dstar_mass'], q)) + ztf.to_complex(h_P(self.params['D_mass'], q))) + return Dbar_contrib + DDstar_contrib + + def ttau_cusp(q): + return ztf.to_complex(self.params['C_tt'])*(ztf.to_complex((h_S(self.params['tau_mass'], q))) - ztf.to_complex(h_P(self.params['tau_mass'], q))) + + + funcs = rho_res(x) + omega_res(x) + phi_res(x) + jpsi_res(x) + psi2s_res(x) + p3770_res(x) + p4040_res(x)+ p4160_res(x) + p4415_res(x) + P2_D(x) + ttau_cusp(x) + + vec_f = vec(x, funcs, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + axiv_nr = axiv_nonres(x, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + tot = vec_f + axiv_nr + + #Cut out jpsi and psi2s + +# tot = tf.where(tf.math.logical_or(x < ztf.constant(jpsi_mass-60.), x > ztf.constant(jpsi_mass+70.)), tot, 0.0*tot) + +# tot = tf.where(tf.math.logical_or(x < ztf.constant(psi2s_mass-50.), x > ztf.constant(psi2s_mass+50.)), tot, 0.0*tot) + + return tot + + +# ## Setup parameters + +# In[ ]: + + +# formfactors + +b0_0 = zfit.Parameter("b0_0", ztf.constant(0.292), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +b0_1 = zfit.Parameter("b0_1", ztf.constant(0.281), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +b0_2 = zfit.Parameter("b0_2", ztf.constant(0.150), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) + +bplus_0 = zfit.Parameter("bplus_0", ztf.constant(0.466), lower_limit = -2.0, upper_limit= 2.0) +bplus_1 = zfit.Parameter("bplus_1", ztf.constant(-0.885), lower_limit = -2.0, upper_limit= 2.0) +bplus_2 = zfit.Parameter("bplus_2", ztf.constant(-0.213), lower_limit = -2.0, upper_limit= 2.0) + +bT_0 = zfit.Parameter("bT_0", ztf.constant(0.460), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +bT_1 = zfit.Parameter("bT_1", ztf.constant(-1.089), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +bT_2 = zfit.Parameter("bT_2", ztf.constant(-1.114), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) + + +#rho + +rho_mass, rho_width, rho_phase, rho_scale = pdg["rho"] + +rho_m = zfit.Parameter("rho_m", ztf.constant(rho_mass), floating = False) #lower_limit = rho_mass - rho_width, upper_limit = rho_mass + rho_width) +rho_w = zfit.Parameter("rho_w", ztf.constant(rho_width), floating = False) +rho_p = zfit.Parameter("rho_p", ztf.constant(rho_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +rho_s = zfit.Parameter("rho_s", ztf.constant(rho_scale), lower_limit=rho_scale-np.sqrt(rho_scale), upper_limit=rho_scale+np.sqrt(rho_scale)) + +#omega + +omega_mass, omega_width, omega_phase, omega_scale = pdg["omega"] + +omega_m = zfit.Parameter("omega_m", ztf.constant(omega_mass), floating = False) +omega_w = zfit.Parameter("omega_w", ztf.constant(omega_width), floating = False) +omega_p = zfit.Parameter("omega_p", ztf.constant(omega_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +omega_s = zfit.Parameter("omega_s", ztf.constant(omega_scale), lower_limit=omega_scale-np.sqrt(omega_scale), upper_limit=omega_scale+np.sqrt(omega_scale)) + + +#phi + +phi_mass, phi_width, phi_phase, phi_scale = pdg["phi"] + +phi_m = zfit.Parameter("phi_m", ztf.constant(phi_mass), floating = False) +phi_w = zfit.Parameter("phi_w", ztf.constant(phi_width), floating = False) +phi_p = zfit.Parameter("phi_p", ztf.constant(phi_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +phi_s = zfit.Parameter("phi_s", ztf.constant(phi_scale), lower_limit=phi_scale-np.sqrt(phi_scale), upper_limit=phi_scale+np.sqrt(phi_scale)) + +#jpsi + +jpsi_mass, jpsi_width, jpsi_phase, jpsi_scale = pdg["jpsi"] + +jpsi_m = zfit.Parameter("jpsi_m", ztf.constant(jpsi_mass), floating = False) +jpsi_w = zfit.Parameter("jpsi_w", ztf.constant(jpsi_width), floating = False) +jpsi_p = zfit.Parameter("jpsi_p", ztf.constant(jpsi_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +jpsi_s = zfit.Parameter("jpsi_s", ztf.constant(jpsi_scale), floating = False) #, lower_limit=jpsi_scale-np.sqrt(jpsi_scale), upper_limit=jpsi_scale+np.sqrt(jpsi_scale)) + +#psi2s + +psi2s_mass, psi2s_width, psi2s_phase, psi2s_scale = pdg["psi2s"] + +psi2s_m = zfit.Parameter("psi2s_m", ztf.constant(psi2s_mass), floating = False) +psi2s_w = zfit.Parameter("psi2s_w", ztf.constant(psi2s_width), floating = False) +psi2s_p = zfit.Parameter("psi2s_p", ztf.constant(psi2s_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +psi2s_s = zfit.Parameter("psi2s_s", ztf.constant(psi2s_scale), floating = False) #, lower_limit=psi2s_scale-np.sqrt(psi2s_scale), upper_limit=psi2s_scale+np.sqrt(psi2s_scale)) + +#psi(3770) + +p3770_mass, p3770_width, p3770_phase, p3770_scale = pdg["p3770"] + +p3770_m = zfit.Parameter("p3770_m", ztf.constant(p3770_mass), floating = False) +p3770_w = zfit.Parameter("p3770_w", ztf.constant(p3770_width), floating = False) +p3770_p = zfit.Parameter("p3770_p", ztf.constant(p3770_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p3770_s = zfit.Parameter("p3770_s", ztf.constant(p3770_scale), lower_limit=p3770_scale-np.sqrt(p3770_scale), upper_limit=p3770_scale+np.sqrt(p3770_scale)) + +#psi(4040) + +p4040_mass, p4040_width, p4040_phase, p4040_scale = pdg["p4040"] + +p4040_m = zfit.Parameter("p4040_m", ztf.constant(p4040_mass), floating = False) +p4040_w = zfit.Parameter("p4040_w", ztf.constant(p4040_width), floating = False) +p4040_p = zfit.Parameter("p4040_p", ztf.constant(p4040_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p4040_s = zfit.Parameter("p4040_s", ztf.constant(p4040_scale), lower_limit=p4040_scale-np.sqrt(p4040_scale), upper_limit=p4040_scale+np.sqrt(p4040_scale)) + +#psi(4160) + +p4160_mass, p4160_width, p4160_phase, p4160_scale = pdg["p4160"] + +p4160_m = zfit.Parameter("p4160_m", ztf.constant(p4160_mass), floating = False) +p4160_w = zfit.Parameter("p4160_w", ztf.constant(p4160_width), floating = False) +p4160_p = zfit.Parameter("p4160_p", ztf.constant(p4160_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p4160_s = zfit.Parameter("p4160_s", ztf.constant(p4160_scale), lower_limit=p4160_scale-np.sqrt(p4160_scale), upper_limit=p4160_scale+np.sqrt(p4160_scale)) + +#psi(4415) + +p4415_mass, p4415_width, p4415_phase, p4415_scale = pdg["p4415"] + +p4415_m = zfit.Parameter("p4415_m", ztf.constant(p4415_mass), floating = False) +p4415_w = zfit.Parameter("p4415_w", ztf.constant(p4415_width), floating = False) +p4415_p = zfit.Parameter("p4415_p", ztf.constant(p4415_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p4415_s = zfit.Parameter("p4415_s", ztf.constant(p4415_scale), lower_limit=p4415_scale-np.sqrt(p4415_scale), upper_limit=p4415_scale+np.sqrt(p4415_scale)) + + +# ## Dynamic generation of 2 particle contribution + +# In[ ]: + + +m_c = 1300 + +Dbar_phase = 0.0 +DDstar_phase = 0.0 +Dstar_mass = pdg['Dst_M'] +Dbar_mass = pdg['D0_M'] +D_mass = pdg['D0_M'] + +Dbar_s = zfit.Parameter("Dbar_s", ztf.constant(0.0), lower_limit=-0.3, upper_limit=0.3) +Dbar_m = zfit.Parameter("Dbar_m", ztf.constant(Dbar_mass), floating = False) +Dbar_p = zfit.Parameter("Dbar_p", ztf.constant(Dbar_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi)#, floating = False) +DDstar_s = zfit.Parameter("DDstar_s", ztf.constant(0.0), lower_limit=-0.3, upper_limit=0.3)#, floating = False) +Dstar_m = zfit.Parameter("Dstar_m", ztf.constant(Dstar_mass), floating = False) +D_m = zfit.Parameter("D_m", ztf.constant(D_mass), floating = False) +DDstar_p = zfit.Parameter("DDstar_p", ztf.constant(DDstar_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi)#, floating = False) + + +# ## Tau parameters + +# In[ ]: + + +tau_m = zfit.Parameter("tau_m", ztf.constant(pdg['tau_M']), floating = False) +Ctt = zfit.Parameter("Ctt", ztf.constant(0.0), lower_limit=-2.5, upper_limit=2.5) + + +# ## Load data + +# In[ ]: + + +x_min = 2*pdg['muon_M'] +x_max = (pdg["Bplus_M"]-pdg["Ks_M"]-0.1) + +# # Full spectrum + +obs_toy = zfit.Space('q', limits = (x_min, x_max)) + +# Jpsi and Psi2s cut out + +obs1 = zfit.Space('q', limits = (x_min, jpsi_mass - 60.)) +obs2 = zfit.Space('q', limits = (jpsi_mass + 70., psi2s_mass - 50.)) +obs3 = zfit.Space('q', limits = (psi2s_mass + 50., x_max)) + +obs_fit = obs1 + obs2 + obs3 + +# with open(r"./data/slim_points/slim_points_toy_0_range({0}-{1}).pkl".format(int(x_min), int(x_max)), "rb") as input_file: +# part_set = pkl.load(input_file) + +# x_part = part_set['x_part'] + +# x_part = x_part.astype('float64') + +# data = zfit.data.Data.from_numpy(array=x_part, obs=obs) + + +# ## Setup pdf + +# In[ ]: + + +total_f = total_pdf_cut(obs=obs_toy, jpsi_mass = jpsi_m, jpsi_scale = jpsi_s, jpsi_phase = jpsi_p, jpsi_width = jpsi_w, + psi2s_mass = psi2s_m, psi2s_scale = psi2s_s, psi2s_phase = psi2s_p, psi2s_width = psi2s_w, + p3770_mass = p3770_m, p3770_scale = p3770_s, p3770_phase = p3770_p, p3770_width = p3770_w, + p4040_mass = p4040_m, p4040_scale = p4040_s, p4040_phase = p4040_p, p4040_width = p4040_w, + p4160_mass = p4160_m, p4160_scale = p4160_s, p4160_phase = p4160_p, p4160_width = p4160_w, + p4415_mass = p4415_m, p4415_scale = p4415_s, p4415_phase = p4415_p, p4415_width = p4415_w, + rho_mass = rho_m, rho_scale = rho_s, rho_phase = rho_p, rho_width = rho_w, + omega_mass = omega_m, omega_scale = omega_s, omega_phase = omega_p, omega_width = omega_w, + phi_mass = phi_m, phi_scale = phi_s, phi_phase = phi_p, phi_width = phi_w, + Dstar_mass = Dstar_m, DDstar_scale = DDstar_s, DDstar_phase = DDstar_p, D_mass = D_m, + Dbar_mass = Dbar_m, Dbar_scale = Dbar_s, Dbar_phase = Dbar_p, + tau_mass = tau_m, C_tt = Ctt, b0_0 = b0_0, b0_1 = b0_1, b0_2 = b0_2, + bplus_0 = bplus_0, bplus_1 = bplus_1, bplus_2 = bplus_2, + bT_0 = bT_0, bT_1 = bT_1, bT_2 = bT_2) + +total_f_fit = total_pdf_full(obs=obs_fit, jpsi_mass = jpsi_m, jpsi_scale = jpsi_s, jpsi_phase = jpsi_p, jpsi_width = jpsi_w, + psi2s_mass = psi2s_m, psi2s_scale = psi2s_s, psi2s_phase = psi2s_p, psi2s_width = psi2s_w, + p3770_mass = p3770_m, p3770_scale = p3770_s, p3770_phase = p3770_p, p3770_width = p3770_w, + p4040_mass = p4040_m, p4040_scale = p4040_s, p4040_phase = p4040_p, p4040_width = p4040_w, + p4160_mass = p4160_m, p4160_scale = p4160_s, p4160_phase = p4160_p, p4160_width = p4160_w, + p4415_mass = p4415_m, p4415_scale = p4415_s, p4415_phase = p4415_p, p4415_width = p4415_w, + rho_mass = rho_m, rho_scale = rho_s, rho_phase = rho_p, rho_width = rho_w, + omega_mass = omega_m, omega_scale = omega_s, omega_phase = omega_p, omega_width = omega_w, + phi_mass = phi_m, phi_scale = phi_s, phi_phase = phi_p, phi_width = phi_w, + Dstar_mass = Dstar_m, DDstar_scale = DDstar_s, DDstar_phase = DDstar_p, D_mass = D_m, + Dbar_mass = Dbar_m, Dbar_scale = Dbar_s, Dbar_phase = Dbar_p, + tau_mass = tau_m, C_tt = Ctt, b0_0 = b0_0, b0_1 = b0_1, b0_2 = b0_2, + bplus_0 = bplus_0, bplus_1 = bplus_1, bplus_2 = bplus_2, + bT_0 = bT_0, bT_1 = bT_1, bT_2 = bT_2) + +# print(total_pdf.obs) + +# print(calcs_test) + +# for param in total_f.get_dependents(): +# print(zfit.run(param)) + + +# In[ ]: + + +# total_f_fit.normalization(obs_fit) + + +# ## Test if graphs actually work and compute values + +# In[ ]: + + +# def total_test_tf(xq): + +# def jpsi_res(q): +# return resonance(q, jpsi_m, jpsi_s, jpsi_p, jpsi_w) + +# def psi2s_res(q): +# return resonance(q, psi2s_m, psi2s_s, psi2s_p, psi2s_w) + +# def cusp(q): +# return bifur_gauss(q, cusp_m, sig_L, sig_R, cusp_s) + +# funcs = jpsi_res(xq) + psi2s_res(xq) + cusp(xq) + +# vec_f = vec(xq, funcs) + +# axiv_nr = axiv_nonres(xq) + +# tot = vec_f + axiv_nr + +# return tot + +# def jpsi_res(q): +# return resonance(q, jpsi_m, jpsi_s, jpsi_p, jpsi_w) + +# calcs = zfit.run(total_test_tf(x_part)) + + + +test_q = np.linspace(x_min, x_max, int(2e6)) + +probs = total_f_fit.pdf(test_q, norm_range=False) + +calcs_test = zfit.run(probs) + +Ctt.set_value(0.5) + +calcs_test1 = zfit.run(probs) + +Ctt.set_value(0.0) + +Dbar_s.set_value(0.3) + +DDstar_s.set_value(0.3) + +calcs_test2 = zfit.run(probs) +# res_y = zfit.run(jpsi_res(test_q)) +# b0 = [b0_0, b0_1, b0_2] +# bplus = [bplus_0, bplus_1, bplus_2] +# bT = [bT_0, bT_1, bT_2] +# f0_y = zfit.run(tf.math.real(formfactor(test_q,"0", b0, bplus, bT))) +# fplus_y = zfit.run(tf.math.real(formfactor(test_q,"+", b0, bplus, bT))) +# fT_y = zfit.run(tf.math.real(formfactor(test_q,"T", b0, bplus, bT))) + + +# In[ ]: + + +plt.clf() +# plt.plot(x_part, calcs, '.') +plt.plot(test_q, calcs_test, label = 'pdf (Ctt = 0.0)') +plt.plot(test_q, calcs_test1, label = 'pdf (Ctt = 0.5)') +plt.plot(test_q, calcs_test2, label = 'pdf (D-contribs = 0.3)') +# plt.plot(test_q, f0_y, label = '0') +# plt.plot(test_q, fT_y, label = 'T') +# plt.plot(test_q, fplus_y, label = '+') +# plt.plot(test_q, res_y, label = 'res') +plt.legend() +plt.ylim(0.0, 1.5e-6) +# plt.yscale('log') +# plt.xlim(770, 785) +plt.savefig('test.png') +# print(jpsi_width) + + +# In[ ]: + + + + +# probs = mixture.prob(test_q) +# probs_np = zfit.run(probs) +# probs_np *= np.max(calcs_test) / np.max(probs_np) +# plt.figure() +# plt.semilogy(test_q, probs_np,label="importance sampling") +# plt.semilogy(test_q, calcs_test, label = 'pdf') + + +# In[ ]: + + +# 0.213/(0.00133+0.213+0.015) + + +# ## Adjust scaling of different parts + +# In[ ]: + + +total_f.update_integration_options(draws_per_dim=2000000, mc_sampler=None) +# inte = total_f.integrate(limits = (950., 1050.), norm_range=False) +# inte_fl = zfit.run(inte) +# print(inte_fl/4500) +# print(pdg["jpsi_BR"]/pdg["NR_BR"], inte_fl*pdg["psi2s_auc"]/pdg["NR_auc"]) + + +# In[ ]: + + +# # print("jpsi:", inte_fl) +# # print("Increase am by factor:", np.sqrt(pdg["jpsi_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) +# # print("New amp:", pdg["jpsi"][3]*np.sqrt(pdg["jpsi_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) + +# # print("psi2s:", inte_fl) +# # print("Increase am by factor:", np.sqrt(pdg["psi2s_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) +# # print("New amp:", pdg["psi2s"][3]*np.sqrt(pdg["psi2s_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) + +# name = "phi" + +# print(name+":", inte_fl) +# print("Increase am by factor:", np.sqrt(pdg[name+"_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) +# print("New amp:", pdg[name][0]*np.sqrt(pdg[name+"_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) + + +# print(x_min) +# print(x_max) +# # total_f.update_integration_options(draws_per_dim=2000000, mc_sampler=None) +# total_f.update_integration_options(mc_sampler=lambda dim, num_results, +# dtype: tf.random_uniform(maxval=1., shape=(num_results, dim), dtype=dtype), +# draws_per_dim=1000000) +# # _ = [] + +# # for i in range(10): + +# # inte = total_f.integrate(limits = (x_min, x_max)) +# # inte_fl = zfit.run(inte) +# # print(inte_fl) +# # _.append(inte_fl) + +# # print("mean:", np.mean(_)) + +# _ = time.time() + +# inte = total_f.integrate(limits = (x_min, x_max)) +# inte_fl = zfit.run(inte) +# print(inte_fl) +# print("Time taken: {}".format(display_time(int(time.time() - _)))) + +# print(pdg['NR_BR']/pdg['NR_auc']*inte_fl) +# print(0.25**2*4.2/1000) + + +# # Sampling +# ## Mixture distribution for sampling + +# In[ ]: + + + + +# print(list_of_borders[:9]) +# print(list_of_borders[-9:]) + + +class UniformSampleAndWeights(zfit.util.execution.SessionHolderMixin): + def __call__(self, limits, dtype, n_to_produce): + # n_to_produce = tf.cast(n_to_produce, dtype=tf.int32) + low, high = limits.limit1d + low = tf.cast(low, dtype=dtype) + high = tf.cast(high, dtype=dtype) +# uniform = tfd.Uniform(low=low, high=high) +# uniformjpsi = tfd.Uniform(low=tf.constant(3080, dtype=dtype), high=tf.constant(3112, dtype=dtype)) +# uniformpsi2s = tfd.Uniform(low=tf.constant(3670, dtype=dtype), high=tf.constant(3702, dtype=dtype)) + +# list_of_borders = [] +# _p = [] +# splits = 10 + +# _ = np.linspace(x_min, x_max, splits) + +# for i in range(splits): +# list_of_borders.append(tf.constant(_[i], dtype=dtype)) +# _p.append(tf.constant(1/splits, dtype=dtype)) + +# mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=_p[:(splits-1)]), +# components_distribution=tfd.Uniform(low=list_of_borders[:(splits-1)], +# high=list_of_borders[-(splits-1):])) + mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=[tf.constant(0.05, dtype=dtype), + tf.constant(0.93, dtype=dtype), + tf.constant(0.05, dtype=dtype), + tf.constant(0.065, dtype=dtype), + tf.constant(0.04, dtype=dtype), + tf.constant(0.05, dtype=dtype)]), + components_distribution=tfd.Uniform(low=[tf.constant(x_min, dtype=dtype), + tf.constant(3090, dtype=dtype), + tf.constant(3681, dtype=dtype), + tf.constant(3070, dtype=dtype), + tf.constant(1000, dtype=dtype), + tf.constant(3660, dtype=dtype)], + high=[tf.constant(x_max, dtype=dtype), + tf.constant(3102, dtype=dtype), + tf.constant(3691, dtype=dtype), + tf.constant(3110, dtype=dtype), + tf.constant(1040, dtype=dtype), + tf.constant(3710, dtype=dtype)])) +# dtype = tf.float64 +# mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=[tf.constant(0.04, dtype=dtype), +# tf.constant(0.90, dtype=dtype), +# tf.constant(0.02, dtype=dtype), +# tf.constant(0.07, dtype=dtype), +# tf.constant(0.02, dtype=dtype)]), +# components_distribution=tfd.Uniform(low=[tf.constant(x_min, dtype=dtype), +# tf.constant(3089, dtype=dtype), +# tf.constant(3103, dtype=dtype), +# tf.constant(3681, dtype=dtype), +# tf.constant(3691, dtype=dtype)], +# high=[tf.constant(3089, dtype=dtype), +# tf.constant(3103, dtype=dtype), +# tf.constant(3681, dtype=dtype), +# tf.constant(3691, dtype=dtype), +# tf.constant(x_max, dtype=dtype)])) +# mixture = tfd.Uniform(tf.constant(x_min, dtype=dtype), tf.constant(x_max, dtype=dtype)) +# sample = tf.random.uniform((n_to_produce, 1), dtype=dtype) + sample = mixture.sample((n_to_produce, 1)) +# sample = tf.random.uniform((n_to_produce, 1), dtype=dtype) + weights = mixture.prob(sample)[:,0] +# weights = tf.broadcast_to(tf.constant(1., dtype=dtype), shape=(n_to_produce,)) + # sample = tf.expand_dims(sample, axis=-1) +# print(sample, weights) + +# weights = tf.ones(shape=(n_to_produce,), dtype=dtype) + weights_max = None + thresholds = tf.random_uniform(shape=(n_to_produce,), dtype=dtype) + return sample, thresholds, weights, weights_max, n_to_produce + + +# In[ ]: + + +# total_f._sample_and_weights = UniformSampleAndWeights + + +# In[ ]: + + +# 0.00133/(0.00133+0.213+0.015)*(x_max-3750)/(x_max-x_min) + + +# In[ ]: + + +# zfit.settings.set_verbosity(10) + + +# In[ ]: + + +# # zfit.run.numeric_checks = False + +# nr_of_toys = 1 +# nevents = int(pdg["number_of_decays"]) +# nevents = pdg["number_of_decays"] +# event_stack = 1000000 +# # zfit.settings.set_verbosity(10) +# calls = int(nevents/event_stack + 1) + +# total_samp = [] + +# start = time.time() + +# sampler = total_f.create_sampler(n=event_stack) + +# for toy in range(nr_of_toys): + +# dirName = 'data/zfit_toys/toy_{0}'.format(toy) + +# if not os.path.exists(dirName): +# os.mkdir(dirName) +# print("Directory " , dirName , " Created ") + +# for call in range(calls): + +# sampler.resample(n=event_stack) +# s = sampler.unstack_x() +# sam = zfit.run(s) +# # clear_output(wait=True) + +# c = call + 1 + +# print("{0}/{1} of Toy {2}/{3}".format(c, calls, toy+1, nr_of_toys)) +# print("Time taken: {}".format(display_time(int(time.time() - start)))) +# print("Projected time left: {}".format(display_time(int((time.time() - start)/(c+calls*(toy))*((nr_of_toys-toy)*calls-c))))) + +# with open("data/zfit_toys/toy_{0}/{1}.pkl".format(toy, call), "wb") as f: +# pkl.dump(sam, f, pkl.HIGHEST_PROTOCOL) + + +# In[ ]: + + +# with open(r"data/zfit_toys/toy_0/0.pkl", "rb") as input_file: +# sam = pkl.load(input_file) +# print(sam[:10]) + +# with open(r"data/zfit_toys/toy_0/1.pkl", "rb") as input_file: +# sam2 = pkl.load(input_file) +# print(sam2[:10]) + +# print(np.sum(sam-sam2)) + + +# In[ ]: + + +# print("Time to generate full toy: {} s".format(int(time.time()-start))) + +# total_samp = [] + +# for call in range(calls): +# with open(r"data/zfit_toys/toy_0/{}.pkl".format(call), "rb") as input_file: +# sam = pkl.load(input_file) +# total_samp = np.append(total_samp, sam) + +# total_samp = total_samp.astype('float64') + +# data2 = zfit.data.Data.from_numpy(array=total_samp[:int(nevents)], obs=obs) + +# data3 = zfit.data.Data.from_numpy(array=total_samp, obs=obs) + +# print(total_samp[:nevents].shape) + + +# In[ ]: + + +# plt.clf() + +# bins = int((x_max-x_min)/7) + +# # calcs = zfit.run(total_test_tf(samp)) +# print(total_samp[:nevents].shape) + +# plt.hist(total_samp[:nevents], bins = bins, range = (x_min,x_max), label = 'data') +# # plt.plot(test_q, calcs_test*nevents , label = 'pdf') + +# # plt.plot(sam, calcs, '.') +# # plt.plot(test_q, calcs_test) +# # plt.yscale('log') +# plt.ylim(0, 200) +# # plt.xlim(3080, 3110) + +# plt.legend() + +# plt.savefig('test2.png') + + +# In[ ]: + + +# sampler = total_f.create_sampler(n=nevents) +# nll = zfit.loss.UnbinnedNLL(model=total_f, data=sampler, fit_range = (x_min, x_max)) + +# # for param in pdf.get_dependents(): +# # param.set_value(initial_value) + +# sampler.resample(n=nevents) + +# # Randomise initial values +# # for param in pdf.get_dependents(): +# # param.set_value(random value here) + +# # Minimise the NLL +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 10) +# minimum = minimizer.minimize(nll) + + +# In[ ]: + + +# jpsi_width + + +# In[ ]: + + +# plt.hist(sample, weights=1 / prob(sample)) + + +# # Fitting + +# In[ ]: + + +# start = time.time() + +# for param in total_f.get_dependents(): +# param.randomize() + +# # for param in total_f.get_dependents(): +# # print(zfit.run(param)) + +# nll = zfit.loss.UnbinnedNLL(model=total_f, data=data2, fit_range = (x_min, x_max)) + +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) +# # minimizer._use_tfgrad = False +# result = minimizer.minimize(nll) + +# # param_errors = result.error() + +# # for var, errors in param_errors.items(): +# # print('{}: ^{{+{}}}_{{{}}}'.format(var.name, errors['upper'], errors['lower'])) + +# print("Function minimum:", result.fmin) +# # print("Results:", result.params) +# print("Hesse errors:", result.hesse()) + + +# In[ ]: + + +# print("Time taken for fitting: {}".format(display_time(int(time.time()-start)))) + +# # probs = total_f.pdf(test_q) + +# calcs_test = zfit.run(probs) +# res_y = zfit.run(jpsi_res(test_q)) + + +# In[ ]: + + +# plt.clf() +# # plt.plot(x_part, calcs, '.') +# plt.plot(test_q, calcs_test, label = 'pdf') +# # plt.plot(test_q, res_y, label = 'res') +# plt.legend() +# plt.ylim(0.0, 10e-6) +# # plt.yscale('log') +# # plt.xlim(3080, 3110) +# plt.savefig('test3.png') +# # print(jpsi_width) + + +# In[ ]: + + +# _tot = 4.37e-7+6.02e-5+4.97e-6 +# _probs = [] +# _probs.append(6.02e-5/_tot) +# _probs.append(4.97e-6/_tot) +# _probs.append(4.37e-7/_tot) +# print(_probs) + + +# In[ ]: + + +# dtype = 'float64' +# # mixture = tfd.Uniform(tf.constant(x_min, dtype=dtype), tf.constant(x_max, dtype=dtype)) +# mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=[tf.constant(0.007, dtype=dtype), +# tf.constant(0.917, dtype=dtype), +# tf.constant(0.076, dtype=dtype)]), +# components_distribution=tfd.Uniform(low=[tf.constant(x_min, dtype=dtype), +# tf.constant(3080, dtype=dtype), +# tf.constant(3670, dtype=dtype)], +# high=[tf.constant(x_max, dtype=dtype), +# tf.constant(3112, dtype=dtype), +# tf.constant(3702, dtype=dtype)])) +# # for i in range(10): +# # print(zfit.run(mixture.prob(mixture.sample((10, 1))))) + + +# In[ ]: + + +# print((zfit.run(jpsi_p)%(2*np.pi))/np.pi) +# print((zfit.run(psi2s_p)%(2*np.pi))/np.pi) + + +# In[ ]: + + +# def jpsi_res(q): +# return resonance(q, _mass = jpsi_mass, scale = jpsi_scale, +# phase = jpsi_phase, width = jpsi_width) + +# def psi2s_res(q): +# return resonance(q, _mass = psi2s_mass, scale = psi2s_scale, +# phase = psi2s_phase, width = psi2s_width) + +# def p3770_res(q): +# return resonance(q, _mass = p3770_mass, scale = p3770_scale, +# phase = p3770_phase, width = p3770_width) + +# def p4040_res(q): +# return resonance(q, _mass = p4040_mass, scale = p4040_scale, +# phase = p4040_phase, width = p4040_width) + +# def p4160_res(q): +# return resonance(q, _mass = p4160_mass, scale = p4160_scale, +# phase = p4160_phase, width = p4160_width) + +# def p4415_res(q): +# return resonance(q, _mass = p4415_mass, scale = p4415_scale, +# phase = p4415_phase, width = p4415_width) + + +# In[ ]: + + +# 0.15**2*4.2/1000 +# result.hesse() + + +# ## Constraints + +# In[ ]: + + +# 1. Constraint - Real part of sum of Psi contrib and D contribs + +sum_list = [] + +sum_list.append(ztf.to_complex(jpsi_s) * tf.exp(tf.complex(ztf.constant(0.0), jpsi_p)) * ztf.to_complex(jpsi_w / (tf.pow(jpsi_m,3)))) +sum_list.append(ztf.to_complex(psi2s_s) * tf.exp(tf.complex(ztf.constant(0.0), psi2s_p)) * ztf.to_complex(psi2s_w / (tf.pow(psi2s_m,3)))) +sum_list.append(ztf.to_complex(p3770_s) * tf.exp(tf.complex(ztf.constant(0.0), p3770_p)) * ztf.to_complex(p3770_w / (tf.pow(p3770_m,3)))) +sum_list.append(ztf.to_complex(p4040_s) * tf.exp(tf.complex(ztf.constant(0.0), p4040_p)) * ztf.to_complex(p4040_w / (tf.pow(p4040_m,3)))) +sum_list.append(ztf.to_complex(p4160_s) * tf.exp(tf.complex(ztf.constant(0.0), p4160_p)) * ztf.to_complex(p4160_w / (tf.pow(p4160_m,3)))) +sum_list.append(ztf.to_complex(p4415_s) * tf.exp(tf.complex(ztf.constant(0.0), p4415_p)) * ztf.to_complex(p4415_w / (tf.pow(p4415_m,3)))) +sum_list.append(ztf.to_complex(DDstar_s) * tf.exp(tf.complex(ztf.constant(0.0), DDstar_p)) * (ztf.to_complex(1.0 / (10.0*tf.pow(Dstar_m,2)) + 1.0 / (10.0*tf.pow(D_m,2))))) +sum_list.append(ztf.to_complex(Dbar_s) * tf.exp(tf.complex(ztf.constant(0.0), Dbar_p)) * ztf.to_complex(1.0 / (6.0*tf.pow(Dbar_m,2)))) + +sum_ru_1 = ztf.to_complex(ztf.constant(0.0)) + +for part in sum_list: + sum_ru_1 += part + +sum_1 = tf.math.real(sum_ru_1) +# constraint1 = zfit.constraint.GaussianConstraint(params = sum_1, mu = ztf.constant(1.7*10**-8), +# sigma = ztf.constant(2.2*10**-8)) + +constraint1 = tf.pow((sum_1-ztf.constant(1.7*10**-8))/ztf.constant(2.2*10**-8),2)/ztf.constant(2.) + +# 2. Constraint - Abs. of sum of Psi contribs and D contribs + +sum_2 = tf.abs(sum_ru_1) +constraint2 = tf.cond(tf.greater_equal(sum_2, 5.0e-8), lambda: 100000., lambda: 0.) + +# 3. Constraint - Maximum eta of D contribs + +constraint3_0 = tf.cond(tf.greater_equal(tf.abs(Dbar_s), 0.2), lambda: 100000., lambda: 0.) + +constraint3_1 = tf.cond(tf.greater_equal(tf.abs(DDstar_s), 0.2), lambda: 100000., lambda: 0.) + +# 4. Constraint - Formfactor multivariant gaussian covariance fplus + +Cov_matrix = [[ztf.constant( 1.), ztf.constant( 0.45), ztf.constant( 0.19), ztf.constant(0.857), ztf.constant(0.598), ztf.constant(0.531), ztf.constant(0.752), ztf.constant(0.229), ztf.constant(0,117)], + [ztf.constant( 0.45), ztf.constant( 1.), ztf.constant(0.677), ztf.constant(0.708), ztf.constant(0.958), ztf.constant(0.927), ztf.constant(0.227), ztf.constant(0.443), ztf.constant(0.287)], + [ztf.constant( 0.19), ztf.constant(0.677), ztf.constant( 1.), ztf.constant(0.595), ztf.constant(0.770), ztf.constant(0.819),ztf.constant(-0.023), ztf.constant( 0.07), ztf.constant(0.196)], + [ztf.constant(0.857), ztf.constant(0.708), ztf.constant(0.595), ztf.constant( 1.), ztf.constant( 0.83), ztf.constant(0.766), ztf.constant(0.582), ztf.constant(0.237), ztf.constant(0.192)], + [ztf.constant(0.598), ztf.constant(0.958), ztf.constant(0.770), ztf.constant( 0.83), ztf.constant( 1.), ztf.constant(0.973), ztf.constant(0.324), ztf.constant(0.372), ztf.constant(0.272)], + [ztf.constant(0.531), ztf.constant(0.927), ztf.constant(0.819), ztf.constant(0.766), ztf.constant(0.973), ztf.constant( 1.), ztf.constant(0.268), ztf.constant(0.332), ztf.constant(0.269)], + [ztf.constant(0.752), ztf.constant(0.227),ztf.constant(-0.023), ztf.constant(0.582), ztf.constant(0.324), ztf.constant(0.268), ztf.constant( 1.), ztf.constant( 0.59), ztf.constant(0.515)], + [ztf.constant(0.229), ztf.constant(0.443), ztf.constant( 0.07), ztf.constant(0.237), ztf.constant(0.372), ztf.constant(0.332), ztf.constant( 0.59), ztf.constant( 1.), ztf.constant(0.897)], + [ztf.constant(0.117), ztf.constant(0.287), ztf.constant(0.196), ztf.constant(0.192), ztf.constant(0.272), ztf.constant(0.269), ztf.constant(0.515), ztf.constant(0.897), ztf.constant( 1.)]] + +def triGauss(val1,val2,val3,m = Cov_matrix): + + mean1 = ztf.constant(0.466) + mean2 = ztf.constant(-0.885) + mean3 = ztf.constant(-0.213) + sigma1 = ztf.constant(0.014) + sigma2 = ztf.constant(0.128) + sigma3 = ztf.constant(0.548) + x1 = (val1-mean1)/sigma1 + x2 = (val2-mean2)/sigma2 + x3 = (val3-mean3)/sigma3 + rho12 = m[0][1] + rho13 = m[0][2] + rho23 = m[1][2] + w = x1*x1*(rho23*rho23-1) + x2*x2*(rho13*rho13-1)+x3*x3*(rho12*rho12-1)+2*(x1*x2*(rho12-rho13*rho23)+x1*x3*(rho13-rho12*rho23)+x2*x3*(rho23-rho12*rho13)) + d = 2*(rho12*rho12+rho13*rho13+rho23*rho23-2*rho12*rho13*rho23-1) + + fcn = -w/d + chisq = -2*fcn + return chisq + +constraint4 = triGauss(bplus_0, bplus_1, bplus_2) + +# mean1 = ztf.constant(0.466) +# mean2 = ztf.constant(-0.885) +# mean3 = ztf.constant(-0.213) +# sigma1 = ztf.constant(0.014) +# sigma2 = ztf.constant(0.128) +# sigma3 = ztf.constant(0.548) +# constraint4_0 = tf.pow((bplus_0-mean1)/sigma1,2)/ztf.constant(2.) +# constraint4_1 = tf.pow((bplus_1-mean2)/sigma2,2)/ztf.constant(2.) +# constraint4_2 = tf.pow((bplus_2-mean3)/sigma3,2)/ztf.constant(2.) + +# 5. Constraint - Abs. of sum of light contribs + +sum_list_5 = [] + +sum_list_5.append(rho_s*rho_w/rho_m) +sum_list_5.append(omega_s*omega_w/omega_m) +sum_list_5.append(phi_s*phi_w/phi_m) + + +sum_ru_5 = ztf.constant(0.0) + +for part in sum_list_5: + sum_ru_5 += part + +constraint5 = tf.cond(tf.greater_equal(tf.abs(sum_ru_5), ztf.constant(0.02)), lambda: 100000., lambda: 0.) + +# 6. Constraint on phases of Jpsi and Psi2s for cut out fit + + +# constraint6_0 = zfit.constraint.GaussianConstraint(params = jpsi_p, mu = ztf.constant(pdg["jpsi_phase_unc"]), +# sigma = ztf.constant(jpsi_phase)) +# constraint6_1 = zfit.constraint.GaussianConstraint(params = psi2s_p, mu = ztf.constant(pdg["psi2s_phase_unc"]), +# sigma = ztf.constant(psi2s_phase)) + +constraint6_0 = tf.pow((jpsi_p-ztf.constant(jpsi_phase))/ztf.constant(pdg["jpsi_phase_unc"]),2)/ztf.constant(2.) +constraint6_1 = tf.pow((psi2s_p-ztf.constant(psi2s_phase))/ztf.constant(pdg["psi2s_phase_unc"]),2)/ztf.constant(2.) + +# 7. Constraint on Ctt with higher limits + +constraint7 = tf.cond(tf.greater_equal(Ctt*Ctt, 0.25), lambda: 100000., lambda: 0.) + +constraint7dtype = tf.float64 + +# zfit.run(constraint6_0) + +# ztf.convert_to_tensor(constraint6_0) + +#List of all constraints + +constraints = [constraint1, constraint2, constraint3_0, constraint3_1,# constraint4, #constraint4_0, constraint4_1, constraint4_2, + constraint6_0, constraint6_1]#, constraint7] + + +# ## Reset params + +# In[ ]: + + +param_values_dic = { + 'jpsi_m': jpsi_mass, + 'jpsi_s': jpsi_scale, + 'jpsi_p': jpsi_phase, + 'jpsi_w': jpsi_width, + 'psi2s_m': psi2s_mass, + 'psi2s_s': psi2s_scale, + 'psi2s_p': psi2s_phase, + 'psi2s_w': psi2s_width, + 'p3770_m': p3770_mass, + 'p3770_s': p3770_scale, + 'p3770_p': p3770_phase, + 'p3770_w': p3770_width, + 'p4040_m': p4040_mass, + 'p4040_s': p4040_scale, + 'p4040_p': p4040_phase, + 'p4040_w': p4040_width, + 'p4160_m': p4160_mass, + 'p4160_s': p4160_scale, + 'p4160_p': p4160_phase, + 'p4160_w': p4160_width, + 'p4415_m': p4415_mass, + 'p4415_s': p4415_scale, + 'p4415_p': p4415_phase, + 'p4415_w': p4415_width, + 'rho_m': rho_mass, + 'rho_s': rho_scale, + 'rho_p': rho_phase, + 'rho_w': rho_width, + 'omega_m': omega_mass, + 'omega_s': omega_scale, + 'omega_p': omega_phase, + 'omega_w': omega_width, + 'phi_m': phi_mass, + 'phi_s': phi_scale, + 'phi_p': phi_phase, + 'phi_w': phi_width, + 'Dstar_m': Dstar_mass, + 'DDstar_s': 0.0, + 'DDstar_p': 0.0, + 'D_m': D_mass, + 'Dbar_m': Dbar_mass, + 'Dbar_s': 0.0, + 'Dbar_p': 0.0, + 'tau_m': pdg['tau_M'], + 'Ctt': 0.0, + 'b0_0': 0.292, + 'b0_1': 0.281, + 'b0_2': 0.150, + 'bplus_0': 0.466, + 'bplus_1': -0.885, + 'bplus_2': -0.213, + 'bT_0': 0.460, + 'bT_1': -1.089, + 'bT_2': -1.114} + + +def reset_param_values(variation = 0.05): + for param in total_f_fit.get_dependents(): + if param.floating: + param.set_value(param_values_dic[param.name] + random.uniform(-1, 1) * param_values_dic[param.name]* variation) +# print(param.name) +# for param in totalf.get_dependents(): +# param.set_value() + + +# # Analysis + +# In[ ]: + + +# # zfit.run.numeric_checks = False + +# fitting_range = 'cut' +# total_BR = 1.7e-10 + 4.9e-10 + 2.5e-9 + 6.02e-5 + 4.97e-6 + 1.38e-9 + 4.2e-10 + 2.6e-9 + 6.1e-10 + 4.37e-7 +# cut_BR = 1.0 - (6.02e-5 + 4.97e-6)/total_BR + +# Ctt_list = [] +# Ctt_error_list = [] + +# nr_of_toys = 1 +# if fitting_range == 'cut': +# nevents = int(pdg["number_of_decays"]*cut_BR) +# else: +# nevents = int(pdg["number_of_decays"]) +# # nevents = pdg["number_of_decays"] +# event_stack = 1000000 +# # nevents *= 41 +# # zfit.settings.set_verbosity(10) +# calls = int(nevents/event_stack + 1) + +# total_samp = [] + +# start = time.time() + +# sampler = total_f.create_sampler(n=event_stack) + +# for toy in range(nr_of_toys): + +# ### Generate data + +# # clear_output(wait=True) + +# print("Toy {}: Generating data...".format(toy)) + +# dirName = 'data/zfit_toys/toy_{0}'.format(toy) + +# if not os.path.exists(dirName): +# os.mkdir(dirName) +# print("Directory " , dirName , " Created ") + +# reset_param_values() + +# if fitting_range == 'cut': + +# sampler.resample(n=nevents) +# s = sampler.unstack_x() +# sam = zfit.run(s) +# calls = 0 +# c = 1 + +# else: +# for call in range(calls): + +# sampler.resample(n=event_stack) +# s = sampler.unstack_x() +# sam = zfit.run(s) + +# c = call + 1 + +# with open("data/zfit_toys/toy_{0}/{1}.pkl".format(toy, call), "wb") as f: +# pkl.dump(sam, f, pkl.HIGHEST_PROTOCOL) + +# print("Toy {}: Data generation finished".format(toy)) + +# ### Load data + +# print("Toy {}: Loading data...".format(toy)) + +# if fitting_range == 'cut': + +# total_samp = sam + +# else: + +# for call in range(calls): +# with open(r"data/zfit_toys/toy_0/{}.pkl".format(call), "rb") as input_file: +# sam = pkl.load(input_file) +# total_samp = np.append(total_samp, sam) + +# total_samp = total_samp.astype('float64') + +# if fitting_range == 'full': + +# data = zfit.data.Data.from_numpy(array=total_samp[:int(nevents)], obs=obs) + +# print("Toy {}: Loading data finished".format(toy)) + +# ### Fit data + +# print("Toy {}: Fitting pdf...".format(toy)) + +# for param in total_f.get_dependents(): +# param.randomize() + +# nll = zfit.loss.UnbinnedNLL(model=total_f, data=data, fit_range = (x_min, x_max), constraints = constraints) + +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) +# # minimizer._use_tfgrad = False +# result = minimizer.minimize(nll) + +# print("Toy {}: Fitting finished".format(toy)) + +# print("Function minimum:", result.fmin) +# print("Hesse errors:", result.hesse()) + +# params = result.params +# Ctt_list.append(params[Ctt]['value']) +# Ctt_error_list.append(params[Ctt]['minuit_hesse']['error']) + +# #plotting the result + +# plotdirName = 'data/plots'.format(toy) + +# if not os.path.exists(plotdirName): +# os.mkdir(plotdirName) +# # print("Directory " , dirName , " Created ") + +# probs = total_f.pdf(test_q, norm_range=False) +# calcs_test = zfit.run(probs) +# plt.clf() +# plt.plot(test_q, calcs_test, label = 'pdf') +# plt.legend() +# plt.ylim(0.0, 6e-6) +# plt.savefig(plotdirName + '/toy_fit_full_range{}.png'.format(toy)) + +# print("Toy {0}/{1}".format(toy+1, nr_of_toys)) +# print("Time taken: {}".format(display_time(int(time.time() - start)))) +# print("Projected time left: {}".format(display_time(int((time.time() - start)/(c+calls*(toy))*((nr_of_toys-toy)*calls-c))))) + +# if fitting_range == 'cut': + +# _1 = np.where((total_samp >= x_min) & (total_samp <= (jpsi_mass - 60.))) + +# tot_sam_1 = total_samp[_1] + +# _2 = np.where((total_samp >= (jpsi_mass + 70.)) & (total_samp <= (psi2s_mass - 50.))) + +# tot_sam_2 = total_samp[_2] + +# _3 = np.where((total_samp >= (psi2s_mass + 50.)) & (total_samp <= x_max)) + +# tot_sam_3 = total_samp[_3] + +# tot_sam = np.append(tot_sam_1, tot_sam_2) +# tot_sam = np.append(tot_sam, tot_sam_3) + +# data = zfit.data.Data.from_numpy(array=tot_sam[:int(nevents)], obs=obs_fit) + +# print("Toy {}: Loading data finished".format(toy)) + +# ### Fit data + +# print("Toy {}: Fitting pdf...".format(toy)) + +# for param in total_f_fit.get_dependents(): +# param.randomize() + +# nll = zfit.loss.UnbinnedNLL(model=total_f_fit, data=data, constraints = constraints) + +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) +# # minimizer._use_tfgrad = False +# result = minimizer.minimize(nll) + +# print("Function minimum:", result.fmin) +# print("Hesse errors:", result.hesse()) + +# params = result.params + +# if result.converged: +# Ctt_list.append(params[Ctt]['value']) +# Ctt_error_list.append(params[Ctt]['minuit_hesse']['error']) + +# #plotting the result + +# plotdirName = 'data/plots'.format(toy) + +# if not os.path.exists(plotdirName): +# os.mkdir(plotdirName) +# # print("Directory " , dirName , " Created ") + +# plt.clf() +# plt.hist(tot_sam, bins = int((x_max-x_min)/7.), label = 'toy data') +# plt.savefig(plotdirName + '/toy_histo_cut_region{}.png'.format(toy)) + + +# probs = total_f_fit.pdf(test_q, norm_range=False) +# calcs_test = zfit.run(probs) +# plt.clf() +# plt.plot(test_q, calcs_test, label = 'pdf') +# plt.axvline(x=jpsi_mass-60.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.axvline(x=jpsi_mass+70.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.axvline(x=psi2s_mass-50.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.axvline(x=psi2s_mass+50.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.legend() +# plt.ylim(0.0, 1.5e-6) +# plt.savefig(plotdirName + '/toy_fit_cut_region{}.png'.format(toy)) + +# print("Toy {0}/{1}".format(toy+1, nr_of_toys)) +# print("Time taken: {}".format(display_time(int(time.time() - start)))) +# print("Projected time left: {}".format(display_time(int((time.time() - start)/(toy+1))*((nr_of_toys-toy-1))))) + + + +# In[ ]: + + +# with open("data/results/Ctt_list.pkl", "wb") as f: +# pkl.dump(Ctt_list, f, pkl.HIGHEST_PROTOCOL) +# with open("data/results/Ctt_error_list.pkl", "wb") as f: +# pkl.dump(Ctt_error_list, f, pkl.HIGHEST_PROTOCOL) + + +# In[ ]: + + +# print('{0}/{1} fits converged'.format(len(Ctt_list), nr_of_toys)) +# print('Mean Ctt value = {}'.format(np.mean(Ctt_list))) +# print('Mean Ctt error = {}'.format(np.mean(Ctt_error_list))) +# print('95 Sensitivy = {}'.format(((2*np.mean(Ctt_error_list))**2)*4.2/1000)) + + +# In[ ]: + + +# plt.hist(tot_sam, bins = int((x_max-x_min)/7.)) + +# plt.show() + +# # _ = np.where((total_samp >= x_min) & (total_samp <= (jpsi_mass - 50.))) + +# tot_sam.shape + + +# In[ ]: + + +# Ctt.floating = False + + +# In[ ]: + + +# zfit.run(nll.value()) + + +# In[ ]: + + +# result.fmin + + +# In[ ]: + + +# BR_steps = np.linspace(0.0, 1e-3, 11) +pull_dic = {} + +mi = 1e-4 +ma = 3e-3 +ste = 20 + +for param in total_f_fit.get_dependents(): + if param.floating: + pull_dic[param.name] = [] + for step in range(2*ste): + pull_dic[param.name].append([]) + + + +def save_pulls(step): + for param in total_f_fit.get_dependents(): + if param.floating: + pull_dic[param.name][step].append((params[param]['value'] - param_values_dic[param.name])/params[param]['minuit_hesse']['error']) + + + +# for key in pull_dic.keys(): +# print(np.shape(pull_dic[key])) +# save_pulls(New_step=True) +# params[Ctt]['value'] + + +# In[ ]: + + +# for param in total_f_fit.get_dependents(): +# if param.floating: +# print(param.name) + +# print(params[Ctt]) + + +# # CLS Code + +# In[ ]: + + +# zfit.run.numeric_checks = False + +load = False + +bo = True + +D_contribs = True + +if not D_contribs: + Dbar_s.floating = False + Dbar_p.floating = False + DDstar_s.floating = False + DDstar_p.floating = False + +bo_set = 1 + +fitting_range = 'cut' +total_BR = 1.7e-10 + 4.9e-10 + 2.5e-9 + 6.02e-5 + 4.97e-6 + 1.38e-9 + 4.2e-10 + 2.6e-9 + 6.1e-10 + 4.37e-7 +cut_BR = 1.0 - (6.02e-5 + 4.97e-6)/total_BR + +Ctt_list = [] +Ctt_error_list = [] + +nr_of_toys = 1 +nevents = int(pdg["number_of_decays"]*cut_BR) +# nevents = pdg["number_of_decays"] +event_stack = 1000000 +# nevents *= 41 +# zfit.settings.set_verbosity(10) + +# mi = 1e-4 +# ma = 3e-3 +# ste = 13 + +BR_steps = np.linspace(mi, ma, ste) + +BR_steps[0] = 0.0 + +print(BR_steps) + +Ctt_steps = np.sqrt(BR_steps/4.2*1000) + +print(Ctt_steps) + +# total_samp = [] + +start = time.time() + +Nll_list = [] + +sampler = total_f.create_sampler(n=nevents, fixed_params = False) +sampler.set_data_range(obs_fit) + +__ = -1 + +#----------------------------------------------------- + +if not load: + for Ctt_step in Ctt_steps: + + __ += 1 + + for i in range(2): + Ctt_list.append([]) + Ctt_error_list.append([]) + Nll_list.append([]) + + for param in total_f_fit.get_dependents(): + if param.floating: + pull_dic[param.name].append([]) + + for toy in range(nr_of_toys): + + newset = True + + while newset: + + for floaty in [True, False]: + Ctt.floating = floaty + + for bo_step in range(bo_set): + + print('Step: {0}/{1}'.format(int(__), ste)) + print('Current Ctt: {0}'.format(Ctt_step)) + print('Ctt floating: {0}'.format(floaty)) + + reset_param_values(variation = 0.0) + + if floaty: + print('Toy {0}/{1} - Fit {2}/{3}'.format(toy, nr_of_toys, bo_step, bo_set)) + Ctt.set_value(Ctt_step) + + else: + Ctt.set_value(0.0) + print('Toy {0}/{1} - Fit {2}/{3}'.format(toy, nr_of_toys, bo_step, bo_set)) + + if newset: + sampler.resample(n=nevents) + data = sampler + newset = False + + ### Fit data + + if floaty: + #plt.clf() + #plt.title('Ctt value: {:.2f}'.format(Ctt_step)) + #plt.hist(zfit.run(data), bins = int((x_max-x_min)/7), range = (x_min, x_max)) + #plt.savefig('data/CLs/plots/set_histo{}.png'.format(__)) + _step = 2*__ + else: + _step = 2*__+1 + + nll = zfit.loss.UnbinnedNLL(model=total_f_fit, data=data, constraints = constraints) + + minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) + # minimizer._use_tfgrad = False + result = minimizer.minimize(nll) + + print("Function minimum:", result.fmin) + print("Hesse errors:", result.hesse()) + + params = result.params + + if result.converged: + + save_pulls(step = _step) + + if floaty: + Nll_list[-2].append(result.fmin) + Ctt_list[-2].append(params[Ctt]['value']) + Ctt_error_list[-2].append(params[Ctt]['minuit_hesse']['error']) + + else: + Nll_list[-1].append(result.fmin) + Ctt_list[-1].append(0.0) + Ctt_error_list[-1].append(0.0) + + + else: + for _ in [1,2]: + del Nll_list[-_][toy*bo_set:] +# print(np.shape(Nll_list[-_])) + del Ctt_list[-_][toy*bo_set:] + del Ctt_error_list[-_][toy*bo_set:] + for param in total_f_fit.get_dependents(): + if param.floating: + del pull_dic[param.name][_step+1-_][toy*bo_set:] + newset = True + break + + if not result.converged: + break + + print() + print('Time taken: {}'.format(display_time(int(time.time()-start)))) + print('Estimated time left: {}'.format(display_time(int((time.time()-start)/(__+(toy+1)/nr_of_toys)*(ste-__-(nr_of_toys-toy-1)/nr_of_toys))))) + + +# In[ ]: + + +if load: + + phase_combi = '--' + + if D_contribs: + D_dir = 'D-True' + else: + D_dir = 'D-False' + + _dir = 'data/CLs/finished/f1d1/{}/{}/'.format(phase_combi, D_dir) + + jobs = os.listdir(_dir) + + First = True + +# print(jobs) + + for job in jobs: + + dirName = _dir + str(job) + '/data/CLs' + + if not os.path.exists("{}/{}-{}_{}s{}b{}t--CLs_Nll_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys)): +# print(job) + continue + + with open(r"{}/variab.pkl".format(dirName), "rb") as input_file: + variab = pkl.load(input_file) +# print(variab) + + ### sanity check: + if variab['mi'] != mi or variab['ma'] != ma or variab['ste'] != ste or bo_set != bo_set: + print('Fitting parameters of data dont equal the ones given -- Job {} skipped!'.format(job)) + + with open(r"{}/{}-{}_{}s{}b{}t--CLs_Nll_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _Nll_list = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s{}b{}t--Ctt_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _Ctt_list = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s{}b{}t--Ctt_error_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _Ctt_error_list = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s{}b{}t--pull_dic.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _pull_dic = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s--CLs_list.pkl".format(dirName, mi,ma,ste), "rb") as input_file: + _CLs_list = pkl.load(input_file) + + + if First: + Nll_list = _Nll_list + Ctt_list = _Ctt_list + Ctt_error_list = _Ctt_error_list + pull_dic = _pull_dic +# print(_pull_dic) + CLs_list = _CLs_list + First = False + else: + for step in range(2*ste): +# print(Nll_list[step], step) + Nll_list[step].extend(_Nll_list[step]) + Ctt_list[step].extend(_Ctt_list[step]) + Ctt_error_list[step].extend(_Ctt_error_list[step]) + for key in pull_dic.keys(): +# print(key, np.shape(pull_dic[key])) + pull_dic[key][step].extend(_pull_dic[key][step]) + for step in range(ste): + CLs_list[step].extend(_CLs_list[step]) + +# print('----------------------') + + +# In[ ]: + + +dirName = 'data/CLs' + +# if bo and not load: +# for s in range(2*ste): +# Nll_list[s] = [np.min(Nll_list[s])] + + +if not load: + + if not os.path.exists(dirName): + os.mkdir(dirName) + print("Directory " , dirName , " Created ") + + with open("{}/{}-{}_{}s{}b{}t--CLs_Nll_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(Nll_list, f, pkl.HIGHEST_PROTOCOL) + + with open("{}/{}-{}_{}s{}b{}t--Ctt_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(Ctt_list, f, pkl.HIGHEST_PROTOCOL) + + with open("{}/{}-{}_{}s{}b{}t--Ctt_error_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(Ctt_error_list, f, pkl.HIGHEST_PROTOCOL) + + with open("{}/{}-{}_{}s{}b{}t--pull_dic.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(pull_dic, f, pkl.HIGHEST_PROTOCOL) + + variab = {'mi': mi, + 'ma': ma, + 'ste': ste, + 'bo_set': bo_set, + 'nr_of_toys': nr_of_toys} + + with open("{}/variab.pkl".format(dirName), "wb") as f: + pkl.dump(variab, f, pkl.HIGHEST_PROTOCOL) + + CLs_values = [] + + toy_size = bo_set + + print(np.shape(Nll_list)) + print(Nll_list[0:1]) + + for step in range(ste): + CLs_values.append([]) + for toy in range(nr_of_toys): + float_min = np.min(Nll_list[2*step][toy*bo_set:(toy+1)*bo_set]) + fix_min = np.min(Nll_list[2*step+1][toy*bo_set:(toy+1)*bo_set]) + CLs_values[step].append(float_min-fix_min) + + + print(np.shape(CLs_values)) + + with open("{}/{}-{}_{}s--CLs_list.pkl".format(dirName, mi,ma,ste), "wb") as f: + pkl.dump(CLs_values, f, pkl.HIGHEST_PROTOCOL) + + +# In[ ]: + + +# print(variab['mi'] != mi) + + +# ## Plot + +# In[ ]: + + +l = [] + + +if load: + CLs_values = -1*np.array(CLs_list) + +if not os.path.exists('data/CLs/plots'): + os.mkdir('data/CLs/plots') + print("Directory " , 'data/CLs/plots' , " Created ") + +print(np.shape(CLs_values)) + +for step in range(1,ste): + plt.clf() + plt.title('Ctt value: {:.2f}'.format(Ctt_steps[step])) + plt.hist(CLs_values[0], bins = 150, range = (-25, 50), label = 'Ctt fixed to 0') + plt.hist(CLs_values[step], bins = 150, range = (-25, 50), label = 'Ctt floating') + plt.axvline(x=np.mean(CLs_values[0]),color='red', linewidth=1.0, linestyle = 'dotted') + plt.legend() + plt.savefig('data/CLs/plots/CLs-BR({:.1E}).png'.format(BR_steps[step])) + + l.append(len(np.where(np.array(CLs_values[step]) < np.mean(CLs_values[0]))[0])) + +for step in range(2*ste): + if step%2 == 0: + floaty = True + else: + floaty = False + for key in pull_dic.keys(): + if not os.path.exists('data/CLs/plots/{}'.format(key)): + os.mkdir('data/CLs/plots/{}'.format(key)) + plt.clf() + plt.title('Pull {} - Ctt value {:.2f} - floating {}'.format(key, Ctt_steps[int(step/2)], floaty)) + plt.hist(pull_dic[key][step], bins = 50, range = (-5,5)) + plt.xlabel('Pull') + plt.savefig('data/CLs/plots/{}/{:.2f}Ctt{}s{}f.png'.format(key, Ctt_steps[int(step/2)], step, floaty)) + + +# In[ ]: + + +for s in range(len(l)): + print('BR: {:.4f}'.format(BR_steps[s+1])) + print(2*l[s]/len(CLs_values[s])) + print() + + +# In[ ]: + + +# for step in range(2*ste): +# for key in pull_dic.keys(): +# print(pull_dic[key][step]) + + +# In[ ]: + + +# for param in total_f_fit.get_dependents(): +# if param.floating: +# print(params[param]['value']) + + +# In[ ]: + + +print(display_time(int(time.time()-start))) + + +# In[ ]: + + +# variab['mi'] =! mi + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + diff --git a/data/CLs/finished/f1d1/-+/D-True/2288043/__pycache__/helperfunctions.cpython-37.pyc b/data/CLs/finished/f1d1/-+/D-True/2288043/__pycache__/helperfunctions.cpython-37.pyc new file mode 100644 index 0000000..9c3a4f0 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288043/__pycache__/helperfunctions.cpython-37.pyc Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288043/__pycache__/pdg_const1.cpython-37.pyc b/data/CLs/finished/f1d1/-+/D-True/2288043/__pycache__/pdg_const1.cpython-37.pyc new file mode 100644 index 0000000..d8ae734 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288043/__pycache__/pdg_const1.cpython-37.pyc Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288043/data/CLs/0.0001-0.003_20s--CLs_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288043/data/CLs/0.0001-0.003_20s--CLs_list.pkl new file mode 100644 index 0000000..932c98c --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288043/data/CLs/0.0001-0.003_20s--CLs_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288043/data/CLs/0.0001-0.003_20s1b1t--CLs_Nll_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288043/data/CLs/0.0001-0.003_20s1b1t--CLs_Nll_list.pkl new file mode 100644 index 0000000..2ee73c3 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288043/data/CLs/0.0001-0.003_20s1b1t--CLs_Nll_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288043/data/CLs/0.0001-0.003_20s1b1t--Ctt_error_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288043/data/CLs/0.0001-0.003_20s1b1t--Ctt_error_list.pkl new file mode 100644 index 0000000..86f4477 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288043/data/CLs/0.0001-0.003_20s1b1t--Ctt_error_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288043/data/CLs/0.0001-0.003_20s1b1t--Ctt_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288043/data/CLs/0.0001-0.003_20s1b1t--Ctt_list.pkl new file mode 100644 index 0000000..c1b4a6f --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288043/data/CLs/0.0001-0.003_20s1b1t--Ctt_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288043/data/CLs/0.0001-0.003_20s1b1t--pull_dic.pkl b/data/CLs/finished/f1d1/-+/D-True/2288043/data/CLs/0.0001-0.003_20s1b1t--pull_dic.pkl new file mode 100644 index 0000000..a6c375b --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288043/data/CLs/0.0001-0.003_20s1b1t--pull_dic.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288043/data/CLs/variab.pkl b/data/CLs/finished/f1d1/-+/D-True/2288043/data/CLs/variab.pkl new file mode 100644 index 0000000..bb90dc0 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288043/data/CLs/variab.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288043/helperfunctions.py b/data/CLs/finished/f1d1/-+/D-True/2288043/helperfunctions.py new file mode 100644 index 0000000..88e120f --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288043/helperfunctions.py @@ -0,0 +1,33 @@ +# some helperfunctions + +import matplotlib +matplotlib.use("agg") +import matplotlib.pyplot as plt + +#Dislpay time (e.g. while generating points) + +display_intervals = ( + ('w', 604800), # 60 * 60 * 24 * 7 + ('d', 86400), # 60 * 60 * 24 + ('h', 3600), # 60 * 60 + ('min', 60), + ('s', 1), + ) + +def display_time(seconds, granularity=2): + result = [] + + for name, count in display_intervals: + value = seconds // count + if value: + seconds -= value * count + if value == 1: + name = name.rstrip('s') + result.append("{} {}".format(value, name)) + return ', '.join(result[:granularity]) + +def prepare_plot(title): + plt.title(title) + plt.grid() + plt.legend(loc = 'best') + plt.xlabel("q") diff --git a/data/CLs/finished/f1d1/-+/D-True/2288043/pdg_const1.py b/data/CLs/finished/f1d1/-+/D-True/2288043/pdg_const1.py new file mode 100644 index 0000000..70b3f30 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288043/pdg_const1.py @@ -0,0 +1,226 @@ +pdg = { + + + ###Particle masses### + + "mbstar" : 5415.4, + "mbstar0" : 5711.0, + "B0_M" : 5279.5, + "Bs_M" : 5366.7, + "Bplus_M" : 5279.3, + "Lb_M" : 5619.4, + "D0_M" : 1864.8, + "Dst_M" : 2010, + "pi_M" : 139.6, + "Jpsi_M" : 3096.9, + "Psi2s_M" : 3685.6, + "kaon_M" : 493.7, + "Ks_M" : 497.6, + "phi_M" : 1019.5, + "rho_M" : 775.26, + "rho_width" : 149.1, + "omega_M" : 782.65, + "omega_width" : 8.49, + + "muon_M" : 105.7, + "tau_M": 1776.86, + + "squark_M" : 95.0, + "bquark_M" : 4180.0, + "cquark_M" : 1275.0, + + "Bplus_tau" : 1.638e-12, + + ###Wilson coefficients### + + "C1" : -0.257, + "C2" : 1.009, + "C3" : -0.005, + "C4" : -0.078, + + "C7eff" : -0.306, + "C9eff" : 4.211, + "C10eff" : -4.103, + +# "C7eff": 0.0, +# "C9eff": 0.0, +# "C10eff": 0.0, + + ###Other constants + + "GF" : 1.1663787e-5, + "alpha_ew" : 1.0/137.0, + "Vts" : 0.0394, + "Vtb" : 1.019, + "number_of_decays": 5404696, + + #Formfactor z coefficients + + #"b0" : [0.285, 0.19, -0.17], + #"bplus" : [0.437, -1.41, -2.5], + #"bT" : [0.440, -1.47, -2.7] + + "b0" : [0.292, 0.281, 0.150], + "bplus" : [0.466, -0.885, -0.213], + "bT" : [0.460, -1.089, -1.114], + + "NR_BR": 4.37e-7, + "NR_auc": 0.00133, + + #Resonances format(mass, width, phase, scale) + + # pre scaling + +# "rho": (775.26, 149.0, -0.35, 1.0), + +# "omega": (782.7, 8.5, 0.26, 1.0), + +# "phi": (1019.46, 4.25, 0.5, 1.0), + +# "jpsi": (3096.0, 0.09, -1.5, 2e-2), +# "jpsi_auc": 0.2126825758464027, + +# "psi2s": (3686.0, 0.3, -1.5, 3.14e-3), +# "psi2s_auc": 2.802257483178487e-10, + +# "p3770": (3773.0, 27.2, -2.13, 1.0e-3), + +# "p4040": (4039.0, 80.0, -2.52, 2.0), + +# "p4160": (4191.0, 70.0, -1.9, 2.2), + +# "p4415": (4421.0, 62.0, -2.52, 1.0), + + + # after scaling (Phase combination --) + + # + # "rho": (743.2, 149.0, -0.22, 1.05), + # + # "omega": (782.7, 8.5, 0.38, 6.8), + # + # "phi": (1013.5, 4.25, 0.62, 19.2), + # + # "jpsi": (3096.1, 0.09, 1.63, 9897.0), + # "jpsi_auc": 0.2126825758464027, + # "jpsi_phase_unc": 0.05, + # + # "psi2s": (3686.0, 0.3, 1.8, 1396.0), + # "psi2s_auc": 0.0151332263, + # "psi2s_phase_unc": 0.1, + # + # "p3770": (3773.0, 27.2, -2.95, 2.5), + # + # "p4040": (4039.0, 80.0, -2.75, 1.01), + # + # "p4160": (4191.0, 70.0, -2.28, 2.2), + # + # "p4415": (4421.0, 62.0, -2.31, 1.24), + + # Phase combination of paper ++ + +# "rho": (743.2, 149.0, -0.35, 1.05), + +# "omega": (782.7, 8.5, 0.26, 6.8), + +# "phi": (1013.5, 4.25, 0.47, 19.2), + +# "jpsi": (3096.1, 0.09, -1.66, 9897.0), +# "jpsi_auc": 0.2126825758464027, +# "jpsi_phase_unc": 0.05, + +# "psi2s": (3686.0, 0.3, -1.93, 1396.0), +# "psi2s_auc": 0.0151332263, +# "psi2s_phase_unc": 0.1, + +# "p3770": (3773.0, 27.2, -2.13, 2.5), + +# "p4040": (4039.0, 80.0, -2.52, 1.01), + +# "p4160": (4191.0, 70.0, -1.90, 2.2), + +# "p4415": (4421.0, 62.0, -2.52, 1.24), + + # Phase combination of paper +- + +# "rho": (743.2, 149.0, -0.26, 1.05), + +# "omega": (782.7, 8.5, 0.35, 6.8), + +# "phi": (1013.5, 4.25, 0.58, 19.2), + +# "jpsi": (3096.1, 0.09, 1.47, 9897.0), +# "jpsi_auc": 0.2126825758464027, +# "jpsi_phase_unc": 0.05, + +# "psi2s": (3686.0, 0.3, -2.21, 1396.0), +# "psi2s_auc": 0.0151332263, +# "psi2s_phase_unc": 0.1, + +# "p3770": (3773.0, 27.2, -2.140, 2.5), + +# "p4040": (4039.0, 80.0, -2.64, 1.01), + +# "p4160": (4191.0, 70.0, -2.11, 2.2), + +# "p4415": (4421.0, 62.0, -2.42, 1.24), + + # Phase combination of paper -+ + + "rho": (743.2, 149.0, -0.30, 1.05), + + "omega": (782.7, 8.5, 0.30, 6.8), + + "phi": (1013.5, 4.25, 0.51, 19.2), + + "jpsi": (3096.1, 0.09, -1.5, 9897.0), + "jpsi_auc": 0.2126825758464027, + "jpsi_phase_unc": 0.05, + + "psi2s": (3686.0, 0.3, 2.08, 1396.0), + "psi2s_auc": 0.0151332263, + "psi2s_phase_unc": 0.1, + + "p3770": (3773.0, 27.2, -2.89, 2.5), + + "p4040": (4039.0, 80.0, -2.69, 1.01), + + "p4160": (4191.0, 70.0, -2.13, 2.2), + + "p4415": (4421.0, 62.0, -2.43, 1.24), + + + # zeroing resonances + +# "rho": (775.26, 149.0, -0.35, 0.0), +# "omega": (782.7, 8.5, 0.26, 0.0), +# "phi": (1019.46, 4.25, 0.5, 0.0), +# "jpsi": (3096.0, 0.09, -1.5, 0.0), +# "psi2s": (3686.0, 0.3, -1.5, 0.0), +# "p3770": (3773.0, 27.2, -2.13, 0.0), +# "p4040": (4039.0, 80.0, -2.52, 0.0), +# "p4160": (4147.0, 22.0, -1.9, 0.0), +# "p4415": (4421.0, 62.0, -2.52, 0.0), + + # 2P contributions format(mass, amp, phase) + +# "D_bar": ( + + #general + + "rho_BR": 1.7e-10, + "omega_BR": 4.9e-10, + "phi_BR": 2.5e-9, + "jpsi_BR": 6.02e-5, + "psi2s_BR": 4.97e-6, + "p3770_BR": 1.38e-9, + "p4040_BR": 4.2e-10, + "p4160_BR": 2.6e-9, + "p4415_BR": 6.1e-10, + +# Estimates + "Dbar_scale": 1.46, #with phase = pi + + "DDstar_scale": 2.41, #with phase = pi + + } diff --git a/data/CLs/finished/f1d1/-+/D-True/2288043/raremodel-nb.py b/data/CLs/finished/f1d1/-+/D-True/2288043/raremodel-nb.py new file mode 100644 index 0000000..c326c9c --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288043/raremodel-nb.py @@ -0,0 +1,2152 @@ +#!/usr/bin/env python +# coding: utf-8 + +# # Import + +# In[ ]: + + +import os + +# os.environ["CUDA_VISIBLE_DEVICES"] = "-1" +import random +import numpy as np +from pdg_const1 import pdg +import matplotlib +import matplotlib.pyplot as plt +import pickle as pkl +import sys +import time +from helperfunctions import display_time, prepare_plot +import cmath as c +import scipy.integrate as integrate +from scipy.optimize import fminbound +from array import array as arr +import collections +from itertools import compress +import tensorflow as tf +import zfit +from zfit import ztf +# from IPython.display import clear_output +import os +import tensorflow_probability as tfp +tfd = tfp.distributions + + +# In[ ]: + + +# chunksize = 10000 +# zfit.run.chunking.active = True +# zfit.run.chunking.max_n_points = chunksize + + +# # Build model and graphs +# ## Create graphs + +# In[ ]: + + + + + +# In[ ]: + + +def formfactor(q2, subscript, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2): #returns real value + #check if subscript is viable + + if subscript != "0" and subscript != "+" and subscript != "T": + raise ValueError('Wrong subscript entered, choose either 0, + or T') + + #get constants + + mK = ztf.constant(pdg['Ks_M']) + mbstar0 = ztf.constant(pdg["mbstar0"]) + mbstar = ztf.constant(pdg["mbstar"]) + + + mmu = ztf.constant(pdg['muon_M']) + mb = ztf.constant(pdg['bquark_M']) + ms = ztf.constant(pdg['squark_M']) + mB = ztf.constant(pdg['Bplus_M']) + + #N comes from derivation in paper + + N = 3 + + #some helperfunctions + + tpos = (mB - mK)**2 + tzero = (mB + mK)*(ztf.sqrt(mB)-ztf.sqrt(mK))**2 + + z_oben = ztf.sqrt(tpos - q2) - ztf.sqrt(tpos - tzero) + z_unten = ztf.sqrt(tpos - q2) + ztf.sqrt(tpos - tzero) + z = tf.divide(z_oben, z_unten) + + #calculate f0 + + if subscript == "0": + prefactor = 1/(1 - q2/(mbstar0**2)) + _sum = 0 + b0 = [b0_0, b0_1, b0_2] + + for i in range(N): + _sum += b0[i]*(tf.pow(z,i)) + + return ztf.to_complex(prefactor * _sum) + + #calculate f+ or fT + + else: + prefactor = 1/(1 - q2/(mbstar**2)) + _sum = 0 + + if subscript == "T": + bT = [bT_0, bT_1, bT_2] + for i in range(N): + _sum += bT[i] * (tf.pow(z, i) - ((-1)**(i-N)) * (i/N) * tf.pow(z, N)) + else: + bplus = [bplus_0, bplus_1, bplus_2] + for i in range(N): + _sum += bplus[i] * (tf.pow(z, i) - ((-1)**(i-N)) * (i/N) * tf.pow(z, N)) + + return ztf.to_complex(prefactor * _sum) + +def resonance(q, _mass, width, phase, scale): + + q2 = tf.pow(q, 2) + + mmu = ztf.constant(pdg['muon_M']) + + p = 0.5 * ztf.sqrt(q2 - 4*(mmu**2)) + + p0 = 0.5 * ztf.sqrt(_mass**2 - 4*mmu**2) + + gamma_j = tf.divide(p, q) * _mass * width / p0 + + #Calculate the resonance + + _top = tf.complex(_mass * width, ztf.constant(0.0)) + + _bottom = tf.complex(_mass**2 - q2, -_mass*gamma_j) + + com = _top/_bottom + + #Rotate by the phase + + r = ztf.to_complex(scale*tf.abs(com)) + + _phase = tf.angle(com) + + _phase += phase + + com = r * tf.exp(tf.complex(ztf.constant(0.0), _phase)) + + return com + + +def axiv_nonres(q, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2): + + GF = ztf.constant(pdg['GF']) + alpha_ew = ztf.constant(pdg['alpha_ew']) + Vtb = ztf.constant(pdg['Vtb']) + Vts = ztf.constant(pdg['Vts']) + C10eff = ztf.constant(pdg['C10eff']) + + mmu = ztf.constant(pdg['muon_M']) + mb = ztf.constant(pdg['bquark_M']) + ms = ztf.constant(pdg['squark_M']) + mK = ztf.constant(pdg['Ks_M']) + mB = ztf.constant(pdg['Bplus_M']) + + q2 = tf.pow(q, 2) + + #Some helperfunctions + + beta = 1. - 4. * mmu**2. / q2 + + kabs = ztf.sqrt(mB**2. + tf.pow(q2, 2)/mB**2. + mK**4./mB**2. - 2. * (mB**2. * mK**2. + mK**2. * q2 + mB**2. * q2) / mB**2.) + + #prefactor in front of whole bracket + + prefactor1 = GF**2. *alpha_ew**2. * (tf.abs(Vtb*Vts))**2. * kabs * beta / (128. * np.pi**5.) + + #left term in bracket + + bracket_left = 2./3. * tf.pow(kabs,2) * tf.pow(beta,2) * tf.pow(tf.abs(ztf.to_complex(C10eff)*formfactor(q2, "+", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2)),2) + + #middle term in bracket + + _top = 4. * mmu**2. * (mB**2. - mK**2.) * (mB**2. - mK**2.) + + _under = q2 * mB**2. + + bracket_middle = _top/_under *tf.pow(tf.abs(ztf.to_complex(C10eff) * formfactor(q2, "0", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2)), 2) + + #Note sqrt(q2) comes from derivation as we use q2 and plot q + + return prefactor1 * (bracket_left + bracket_middle) * 2 * q + +def vec(q, funcs, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2): + + q2 = tf.pow(q, 2) + + GF = ztf.constant(pdg['GF']) + alpha_ew = ztf.constant(pdg['alpha_ew']) + Vtb = ztf.constant(pdg['Vtb']) + Vts = ztf.constant(pdg['Vts']) + C7eff = ztf.constant(pdg['C7eff']) + + mmu = ztf.constant(pdg['muon_M']) + mb = ztf.constant(pdg['bquark_M']) + ms = ztf.constant(pdg['squark_M']) + mK = ztf.constant(pdg['Ks_M']) + mB = ztf.constant(pdg['Bplus_M']) + + #Some helperfunctions + + beta = 1. - 4. * mmu**2. / q2 + + kabs = ztf.sqrt(mB**2. + tf.pow(q2, 2)/mB**2. + mK**4./mB**2. - 2 * (mB**2 * mK**2 + mK**2 * q2 + mB**2 * q2) / mB**2) + + #prefactor in front of whole bracket + + prefactor1 = GF**2. *alpha_ew**2. * (tf.abs(Vtb*Vts))**2 * kabs * beta / (128. * np.pi**5.) + + #right term in bracket + + prefactor2 = tf.pow(kabs,2) * (1. - 1./3. * beta) + + abs_bracket = tf.pow(tf.abs(c9eff(q, funcs) * formfactor(q2, "+", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + ztf.to_complex(2.0 * C7eff * (mb + ms)/(mB + mK)) * formfactor(q2, "T", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2)),2) + + bracket_right = prefactor2 * abs_bracket + + #Note sqrt(q2) comes from derivation as we use q2 and plot q + + return prefactor1 * bracket_right * 2 * q + +def c9eff(q, funcs): + + C9eff_nr = ztf.to_complex(ztf.constant(pdg['C9eff'])) + + c9 = C9eff_nr + funcs + + return c9 + + +# In[ ]: + + +def G(y): + + def inner_rect_bracket(q): + return tf.log(ztf.to_complex((1+tf.sqrt(q))/(1-tf.sqrt(q)))-tf.complex(ztf.constant(0), -1*ztf.constant(np.pi))) + + def inner_right(q): + return ztf.to_complex(2 * tf.atan(1/tf.sqrt(tf.math.real(-q)))) + + big_bracket = tf.where(tf.math.real(y) > ztf.constant(0.0), inner_rect_bracket(y), inner_right(y)) + + return ztf.to_complex(tf.sqrt(tf.abs(y))) * big_bracket + +def h_S(m, q): + + return ztf.to_complex(2) - G(ztf.to_complex(1) - ztf.to_complex(4*tf.pow(m, 2)) / ztf.to_complex(tf.pow(q, 2))) + +def h_P(m, q): + + return ztf.to_complex(2/3) + (ztf.to_complex(1) - ztf.to_complex(4*tf.pow(m, 2)) / ztf.to_complex(tf.pow(q, 2))) * h_S(m,q) + +def two_p_ccbar(mD, m_D_bar, m_D_star, q): + + + #Load constants + nu_D_bar = ztf.to_complex(pdg["nu_D_bar"]) + nu_D = ztf.to_complex(pdg["nu_D"]) + nu_D_star = ztf.to_complex(pdg["nu_D_star"]) + + phase_D_bar = ztf.to_complex(pdg["phase_D_bar"]) + phase_D = ztf.to_complex(pdg["phase_D"]) + phase_D_star = ztf.to_complex(pdg["phase_D_star"]) + + #Calculation + left_part = nu_D_bar * tf.exp(tf.complex(ztf.constant(0.0), phase_D_bar)) * h_S(m_D_bar, q) + + right_part_D = nu_D * tf.exp(tf.complex(ztf.constant(0.0), phase_D)) * h_P(m_D, q) + + right_part_D_star = nu_D_star * tf.exp(tf.complex(ztf.constant(0.0), phase_D_star)) * h_P(m_D_star, q) + + return left_part + right_part_D + right_part_D_star + + +# ## Build pdf + +# In[ ]: + + +class total_pdf_cut(zfit.pdf.ZPDF): + _N_OBS = 1 # dimension, can be omitted + _PARAMS = ['b0_0', 'b0_1', 'b0_2', + 'bplus_0', 'bplus_1', 'bplus_2', + 'bT_0', 'bT_1', 'bT_2', + 'rho_mass', 'rho_scale', 'rho_phase', 'rho_width', + 'jpsi_mass', 'jpsi_scale', 'jpsi_phase', 'jpsi_width', + 'psi2s_mass', 'psi2s_scale', 'psi2s_phase', 'psi2s_width', + 'p3770_mass', 'p3770_scale', 'p3770_phase', 'p3770_width', + 'p4040_mass', 'p4040_scale', 'p4040_phase', 'p4040_width', + 'p4160_mass', 'p4160_scale', 'p4160_phase', 'p4160_width', + 'p4415_mass', 'p4415_scale', 'p4415_phase', 'p4415_width', + 'omega_mass', 'omega_scale', 'omega_phase', 'omega_width', + 'phi_mass', 'phi_scale', 'phi_phase', 'phi_width', + 'Dbar_mass', 'Dbar_scale', 'Dbar_phase', + 'Dstar_mass', 'DDstar_scale', 'DDstar_phase', 'D_mass', + 'tau_mass', 'C_tt'] +# the name of the parameters + + def _unnormalized_pdf(self, x): + + x = x.unstack_x() + + b0 = [self.params['b0_0'], self.params['b0_1'], self.params['b0_2']] + bplus = [self.params['bplus_0'], self.params['bplus_1'], self.params['bplus_2']] + bT = [self.params['bT_0'], self.params['bT_1'], self.params['bT_2']] + + def rho_res(q): + return resonance(q, _mass = self.params['rho_mass'], scale = self.params['rho_scale'], + phase = self.params['rho_phase'], width = self.params['rho_width']) + + def omega_res(q): + return resonance(q, _mass = self.params['omega_mass'], scale = self.params['omega_scale'], + phase = self.params['omega_phase'], width = self.params['omega_width']) + + def phi_res(q): + return resonance(q, _mass = self.params['phi_mass'], scale = self.params['phi_scale'], + phase = self.params['phi_phase'], width = self.params['phi_width']) + + def jpsi_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['jpsi_mass'], 2)) * resonance(q, _mass = self.params['jpsi_mass'], + scale = self.params['jpsi_scale'], + phase = self.params['jpsi_phase'], + width = self.params['jpsi_width']) + def psi2s_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['psi2s_mass'], 2)) * resonance(q, _mass = self.params['psi2s_mass'], + scale = self.params['psi2s_scale'], + phase = self.params['psi2s_phase'], + width = self.params['psi2s_width']) + def p3770_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p3770_mass'], 2)) * resonance(q, _mass = self.params['p3770_mass'], + scale = self.params['p3770_scale'], + phase = self.params['p3770_phase'], + width = self.params['p3770_width']) + + def p4040_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4040_mass'], 2)) * resonance(q, _mass = self.params['p4040_mass'], + scale = self.params['p4040_scale'], + phase = self.params['p4040_phase'], + width = self.params['p4040_width']) + + def p4160_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4160_mass'], 2)) * resonance(q, _mass = self.params['p4160_mass'], + scale = self.params['p4160_scale'], + phase = self.params['p4160_phase'], + width = self.params['p4160_width']) + + def p4415_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4415_mass'], 2)) * resonance(q, _mass = self.params['p4415_mass'], + scale = self.params['p4415_scale'], + phase = self.params['p4415_phase'], + width = self.params['p4415_width']) + + def P2_D(q): + Dbar_contrib = ztf.to_complex(self.params['Dbar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['Dbar_phase']))*ztf.to_complex(h_S(self.params['Dbar_mass'], q)) + DDstar_contrib = ztf.to_complex(self.params['DDstar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['DDstar_phase']))*(ztf.to_complex(h_P(self.params['Dstar_mass'], q)) + ztf.to_complex(h_P(self.params['D_mass'], q))) + return Dbar_contrib + DDstar_contrib + + def ttau_cusp(q): + return ztf.to_complex(self.params['C_tt'])*(ztf.to_complex((h_S(self.params['tau_mass'], q))) - ztf.to_complex(h_P(self.params['tau_mass'], q))) + + + funcs = rho_res(x) + omega_res(x) + phi_res(x) + jpsi_res(x) + psi2s_res(x) + p3770_res(x) + p4040_res(x)+ p4160_res(x) + p4415_res(x) + P2_D(x) + ttau_cusp(x) + + vec_f = vec(x, funcs, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + axiv_nr = axiv_nonres(x, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + tot = vec_f + axiv_nr + + #Cut out jpsi and psi2s + + tot = tf.where(tf.math.logical_or(x < ztf.constant(jpsi_mass-60.), x > ztf.constant(jpsi_mass+70.)), tot, 0.0*tot) + + tot = tf.where(tf.math.logical_or(x < ztf.constant(psi2s_mass-50.), x > ztf.constant(psi2s_mass+50.)), tot, 0.0*tot) + + return tot + +class total_pdf_full(zfit.pdf.ZPDF): + _N_OBS = 1 # dimension, can be omitted + _PARAMS = ['b0_0', 'b0_1', 'b0_2', + 'bplus_0', 'bplus_1', 'bplus_2', + 'bT_0', 'bT_1', 'bT_2', + 'rho_mass', 'rho_scale', 'rho_phase', 'rho_width', + 'jpsi_mass', 'jpsi_scale', 'jpsi_phase', 'jpsi_width', + 'psi2s_mass', 'psi2s_scale', 'psi2s_phase', 'psi2s_width', + 'p3770_mass', 'p3770_scale', 'p3770_phase', 'p3770_width', + 'p4040_mass', 'p4040_scale', 'p4040_phase', 'p4040_width', + 'p4160_mass', 'p4160_scale', 'p4160_phase', 'p4160_width', + 'p4415_mass', 'p4415_scale', 'p4415_phase', 'p4415_width', + 'omega_mass', 'omega_scale', 'omega_phase', 'omega_width', + 'phi_mass', 'phi_scale', 'phi_phase', 'phi_width', + 'Dbar_mass', 'Dbar_scale', 'Dbar_phase', + 'Dstar_mass', 'DDstar_scale', 'DDstar_phase', 'D_mass', + 'tau_mass', 'C_tt'] +# the name of the parameters + + def _unnormalized_pdf(self, x): + + x = x.unstack_x() + + b0 = [self.params['b0_0'], self.params['b0_1'], self.params['b0_2']] + bplus = [self.params['bplus_0'], self.params['bplus_1'], self.params['bplus_2']] + bT = [self.params['bT_0'], self.params['bT_1'], self.params['bT_2']] + + def rho_res(q): + return resonance(q, _mass = self.params['rho_mass'], scale = self.params['rho_scale'], + phase = self.params['rho_phase'], width = self.params['rho_width']) + + def omega_res(q): + return resonance(q, _mass = self.params['omega_mass'], scale = self.params['omega_scale'], + phase = self.params['omega_phase'], width = self.params['omega_width']) + + def phi_res(q): + return resonance(q, _mass = self.params['phi_mass'], scale = self.params['phi_scale'], + phase = self.params['phi_phase'], width = self.params['phi_width']) + + def jpsi_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['jpsi_mass'], 2)) * resonance(q, _mass = self.params['jpsi_mass'], + scale = self.params['jpsi_scale'], + phase = self.params['jpsi_phase'], + width = self.params['jpsi_width']) + def psi2s_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['psi2s_mass'], 2)) * resonance(q, _mass = self.params['psi2s_mass'], + scale = self.params['psi2s_scale'], + phase = self.params['psi2s_phase'], + width = self.params['psi2s_width']) + def p3770_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p3770_mass'], 2)) * resonance(q, _mass = self.params['p3770_mass'], + scale = self.params['p3770_scale'], + phase = self.params['p3770_phase'], + width = self.params['p3770_width']) + + def p4040_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4040_mass'], 2)) * resonance(q, _mass = self.params['p4040_mass'], + scale = self.params['p4040_scale'], + phase = self.params['p4040_phase'], + width = self.params['p4040_width']) + + def p4160_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4160_mass'], 2)) * resonance(q, _mass = self.params['p4160_mass'], + scale = self.params['p4160_scale'], + phase = self.params['p4160_phase'], + width = self.params['p4160_width']) + + def p4415_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4415_mass'], 2)) * resonance(q, _mass = self.params['p4415_mass'], + scale = self.params['p4415_scale'], + phase = self.params['p4415_phase'], + width = self.params['p4415_width']) + + def P2_D(q): + Dbar_contrib = ztf.to_complex(self.params['Dbar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['Dbar_phase']))*ztf.to_complex(h_S(self.params['Dbar_mass'], q)) + DDstar_contrib = ztf.to_complex(self.params['DDstar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['DDstar_phase']))*(ztf.to_complex(h_P(self.params['Dstar_mass'], q)) + ztf.to_complex(h_P(self.params['D_mass'], q))) + return Dbar_contrib + DDstar_contrib + + def ttau_cusp(q): + return ztf.to_complex(self.params['C_tt'])*(ztf.to_complex((h_S(self.params['tau_mass'], q))) - ztf.to_complex(h_P(self.params['tau_mass'], q))) + + + funcs = rho_res(x) + omega_res(x) + phi_res(x) + jpsi_res(x) + psi2s_res(x) + p3770_res(x) + p4040_res(x)+ p4160_res(x) + p4415_res(x) + P2_D(x) + ttau_cusp(x) + + vec_f = vec(x, funcs, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + axiv_nr = axiv_nonres(x, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + tot = vec_f + axiv_nr + + #Cut out jpsi and psi2s + +# tot = tf.where(tf.math.logical_or(x < ztf.constant(jpsi_mass-60.), x > ztf.constant(jpsi_mass+70.)), tot, 0.0*tot) + +# tot = tf.where(tf.math.logical_or(x < ztf.constant(psi2s_mass-50.), x > ztf.constant(psi2s_mass+50.)), tot, 0.0*tot) + + return tot + + +# ## Setup parameters + +# In[ ]: + + +# formfactors + +b0_0 = zfit.Parameter("b0_0", ztf.constant(0.292), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +b0_1 = zfit.Parameter("b0_1", ztf.constant(0.281), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +b0_2 = zfit.Parameter("b0_2", ztf.constant(0.150), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) + +bplus_0 = zfit.Parameter("bplus_0", ztf.constant(0.466), lower_limit = -2.0, upper_limit= 2.0) +bplus_1 = zfit.Parameter("bplus_1", ztf.constant(-0.885), lower_limit = -2.0, upper_limit= 2.0) +bplus_2 = zfit.Parameter("bplus_2", ztf.constant(-0.213), lower_limit = -2.0, upper_limit= 2.0) + +bT_0 = zfit.Parameter("bT_0", ztf.constant(0.460), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +bT_1 = zfit.Parameter("bT_1", ztf.constant(-1.089), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +bT_2 = zfit.Parameter("bT_2", ztf.constant(-1.114), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) + + +#rho + +rho_mass, rho_width, rho_phase, rho_scale = pdg["rho"] + +rho_m = zfit.Parameter("rho_m", ztf.constant(rho_mass), floating = False) #lower_limit = rho_mass - rho_width, upper_limit = rho_mass + rho_width) +rho_w = zfit.Parameter("rho_w", ztf.constant(rho_width), floating = False) +rho_p = zfit.Parameter("rho_p", ztf.constant(rho_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +rho_s = zfit.Parameter("rho_s", ztf.constant(rho_scale), lower_limit=rho_scale-np.sqrt(rho_scale), upper_limit=rho_scale+np.sqrt(rho_scale)) + +#omega + +omega_mass, omega_width, omega_phase, omega_scale = pdg["omega"] + +omega_m = zfit.Parameter("omega_m", ztf.constant(omega_mass), floating = False) +omega_w = zfit.Parameter("omega_w", ztf.constant(omega_width), floating = False) +omega_p = zfit.Parameter("omega_p", ztf.constant(omega_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +omega_s = zfit.Parameter("omega_s", ztf.constant(omega_scale), lower_limit=omega_scale-np.sqrt(omega_scale), upper_limit=omega_scale+np.sqrt(omega_scale)) + + +#phi + +phi_mass, phi_width, phi_phase, phi_scale = pdg["phi"] + +phi_m = zfit.Parameter("phi_m", ztf.constant(phi_mass), floating = False) +phi_w = zfit.Parameter("phi_w", ztf.constant(phi_width), floating = False) +phi_p = zfit.Parameter("phi_p", ztf.constant(phi_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +phi_s = zfit.Parameter("phi_s", ztf.constant(phi_scale), lower_limit=phi_scale-np.sqrt(phi_scale), upper_limit=phi_scale+np.sqrt(phi_scale)) + +#jpsi + +jpsi_mass, jpsi_width, jpsi_phase, jpsi_scale = pdg["jpsi"] + +jpsi_m = zfit.Parameter("jpsi_m", ztf.constant(jpsi_mass), floating = False) +jpsi_w = zfit.Parameter("jpsi_w", ztf.constant(jpsi_width), floating = False) +jpsi_p = zfit.Parameter("jpsi_p", ztf.constant(jpsi_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +jpsi_s = zfit.Parameter("jpsi_s", ztf.constant(jpsi_scale), floating = False) #, lower_limit=jpsi_scale-np.sqrt(jpsi_scale), upper_limit=jpsi_scale+np.sqrt(jpsi_scale)) + +#psi2s + +psi2s_mass, psi2s_width, psi2s_phase, psi2s_scale = pdg["psi2s"] + +psi2s_m = zfit.Parameter("psi2s_m", ztf.constant(psi2s_mass), floating = False) +psi2s_w = zfit.Parameter("psi2s_w", ztf.constant(psi2s_width), floating = False) +psi2s_p = zfit.Parameter("psi2s_p", ztf.constant(psi2s_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +psi2s_s = zfit.Parameter("psi2s_s", ztf.constant(psi2s_scale), floating = False) #, lower_limit=psi2s_scale-np.sqrt(psi2s_scale), upper_limit=psi2s_scale+np.sqrt(psi2s_scale)) + +#psi(3770) + +p3770_mass, p3770_width, p3770_phase, p3770_scale = pdg["p3770"] + +p3770_m = zfit.Parameter("p3770_m", ztf.constant(p3770_mass), floating = False) +p3770_w = zfit.Parameter("p3770_w", ztf.constant(p3770_width), floating = False) +p3770_p = zfit.Parameter("p3770_p", ztf.constant(p3770_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p3770_s = zfit.Parameter("p3770_s", ztf.constant(p3770_scale), lower_limit=p3770_scale-np.sqrt(p3770_scale), upper_limit=p3770_scale+np.sqrt(p3770_scale)) + +#psi(4040) + +p4040_mass, p4040_width, p4040_phase, p4040_scale = pdg["p4040"] + +p4040_m = zfit.Parameter("p4040_m", ztf.constant(p4040_mass), floating = False) +p4040_w = zfit.Parameter("p4040_w", ztf.constant(p4040_width), floating = False) +p4040_p = zfit.Parameter("p4040_p", ztf.constant(p4040_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p4040_s = zfit.Parameter("p4040_s", ztf.constant(p4040_scale), lower_limit=p4040_scale-np.sqrt(p4040_scale), upper_limit=p4040_scale+np.sqrt(p4040_scale)) + +#psi(4160) + +p4160_mass, p4160_width, p4160_phase, p4160_scale = pdg["p4160"] + +p4160_m = zfit.Parameter("p4160_m", ztf.constant(p4160_mass), floating = False) +p4160_w = zfit.Parameter("p4160_w", ztf.constant(p4160_width), floating = False) +p4160_p = zfit.Parameter("p4160_p", ztf.constant(p4160_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p4160_s = zfit.Parameter("p4160_s", ztf.constant(p4160_scale), lower_limit=p4160_scale-np.sqrt(p4160_scale), upper_limit=p4160_scale+np.sqrt(p4160_scale)) + +#psi(4415) + +p4415_mass, p4415_width, p4415_phase, p4415_scale = pdg["p4415"] + +p4415_m = zfit.Parameter("p4415_m", ztf.constant(p4415_mass), floating = False) +p4415_w = zfit.Parameter("p4415_w", ztf.constant(p4415_width), floating = False) +p4415_p = zfit.Parameter("p4415_p", ztf.constant(p4415_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p4415_s = zfit.Parameter("p4415_s", ztf.constant(p4415_scale), lower_limit=p4415_scale-np.sqrt(p4415_scale), upper_limit=p4415_scale+np.sqrt(p4415_scale)) + + +# ## Dynamic generation of 2 particle contribution + +# In[ ]: + + +m_c = 1300 + +Dbar_phase = 0.0 +DDstar_phase = 0.0 +Dstar_mass = pdg['Dst_M'] +Dbar_mass = pdg['D0_M'] +D_mass = pdg['D0_M'] + +Dbar_s = zfit.Parameter("Dbar_s", ztf.constant(0.0), lower_limit=-0.3, upper_limit=0.3) +Dbar_m = zfit.Parameter("Dbar_m", ztf.constant(Dbar_mass), floating = False) +Dbar_p = zfit.Parameter("Dbar_p", ztf.constant(Dbar_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi)#, floating = False) +DDstar_s = zfit.Parameter("DDstar_s", ztf.constant(0.0), lower_limit=-0.3, upper_limit=0.3)#, floating = False) +Dstar_m = zfit.Parameter("Dstar_m", ztf.constant(Dstar_mass), floating = False) +D_m = zfit.Parameter("D_m", ztf.constant(D_mass), floating = False) +DDstar_p = zfit.Parameter("DDstar_p", ztf.constant(DDstar_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi)#, floating = False) + + +# ## Tau parameters + +# In[ ]: + + +tau_m = zfit.Parameter("tau_m", ztf.constant(pdg['tau_M']), floating = False) +Ctt = zfit.Parameter("Ctt", ztf.constant(0.0), lower_limit=-2.5, upper_limit=2.5) + + +# ## Load data + +# In[ ]: + + +x_min = 2*pdg['muon_M'] +x_max = (pdg["Bplus_M"]-pdg["Ks_M"]-0.1) + +# # Full spectrum + +obs_toy = zfit.Space('q', limits = (x_min, x_max)) + +# Jpsi and Psi2s cut out + +obs1 = zfit.Space('q', limits = (x_min, jpsi_mass - 60.)) +obs2 = zfit.Space('q', limits = (jpsi_mass + 70., psi2s_mass - 50.)) +obs3 = zfit.Space('q', limits = (psi2s_mass + 50., x_max)) + +obs_fit = obs1 + obs2 + obs3 + +# with open(r"./data/slim_points/slim_points_toy_0_range({0}-{1}).pkl".format(int(x_min), int(x_max)), "rb") as input_file: +# part_set = pkl.load(input_file) + +# x_part = part_set['x_part'] + +# x_part = x_part.astype('float64') + +# data = zfit.data.Data.from_numpy(array=x_part, obs=obs) + + +# ## Setup pdf + +# In[ ]: + + +total_f = total_pdf_cut(obs=obs_toy, jpsi_mass = jpsi_m, jpsi_scale = jpsi_s, jpsi_phase = jpsi_p, jpsi_width = jpsi_w, + psi2s_mass = psi2s_m, psi2s_scale = psi2s_s, psi2s_phase = psi2s_p, psi2s_width = psi2s_w, + p3770_mass = p3770_m, p3770_scale = p3770_s, p3770_phase = p3770_p, p3770_width = p3770_w, + p4040_mass = p4040_m, p4040_scale = p4040_s, p4040_phase = p4040_p, p4040_width = p4040_w, + p4160_mass = p4160_m, p4160_scale = p4160_s, p4160_phase = p4160_p, p4160_width = p4160_w, + p4415_mass = p4415_m, p4415_scale = p4415_s, p4415_phase = p4415_p, p4415_width = p4415_w, + rho_mass = rho_m, rho_scale = rho_s, rho_phase = rho_p, rho_width = rho_w, + omega_mass = omega_m, omega_scale = omega_s, omega_phase = omega_p, omega_width = omega_w, + phi_mass = phi_m, phi_scale = phi_s, phi_phase = phi_p, phi_width = phi_w, + Dstar_mass = Dstar_m, DDstar_scale = DDstar_s, DDstar_phase = DDstar_p, D_mass = D_m, + Dbar_mass = Dbar_m, Dbar_scale = Dbar_s, Dbar_phase = Dbar_p, + tau_mass = tau_m, C_tt = Ctt, b0_0 = b0_0, b0_1 = b0_1, b0_2 = b0_2, + bplus_0 = bplus_0, bplus_1 = bplus_1, bplus_2 = bplus_2, + bT_0 = bT_0, bT_1 = bT_1, bT_2 = bT_2) + +total_f_fit = total_pdf_full(obs=obs_fit, jpsi_mass = jpsi_m, jpsi_scale = jpsi_s, jpsi_phase = jpsi_p, jpsi_width = jpsi_w, + psi2s_mass = psi2s_m, psi2s_scale = psi2s_s, psi2s_phase = psi2s_p, psi2s_width = psi2s_w, + p3770_mass = p3770_m, p3770_scale = p3770_s, p3770_phase = p3770_p, p3770_width = p3770_w, + p4040_mass = p4040_m, p4040_scale = p4040_s, p4040_phase = p4040_p, p4040_width = p4040_w, + p4160_mass = p4160_m, p4160_scale = p4160_s, p4160_phase = p4160_p, p4160_width = p4160_w, + p4415_mass = p4415_m, p4415_scale = p4415_s, p4415_phase = p4415_p, p4415_width = p4415_w, + rho_mass = rho_m, rho_scale = rho_s, rho_phase = rho_p, rho_width = rho_w, + omega_mass = omega_m, omega_scale = omega_s, omega_phase = omega_p, omega_width = omega_w, + phi_mass = phi_m, phi_scale = phi_s, phi_phase = phi_p, phi_width = phi_w, + Dstar_mass = Dstar_m, DDstar_scale = DDstar_s, DDstar_phase = DDstar_p, D_mass = D_m, + Dbar_mass = Dbar_m, Dbar_scale = Dbar_s, Dbar_phase = Dbar_p, + tau_mass = tau_m, C_tt = Ctt, b0_0 = b0_0, b0_1 = b0_1, b0_2 = b0_2, + bplus_0 = bplus_0, bplus_1 = bplus_1, bplus_2 = bplus_2, + bT_0 = bT_0, bT_1 = bT_1, bT_2 = bT_2) + +# print(total_pdf.obs) + +# print(calcs_test) + +# for param in total_f.get_dependents(): +# print(zfit.run(param)) + + +# In[ ]: + + +# total_f_fit.normalization(obs_fit) + + +# ## Test if graphs actually work and compute values + +# In[ ]: + + +# def total_test_tf(xq): + +# def jpsi_res(q): +# return resonance(q, jpsi_m, jpsi_s, jpsi_p, jpsi_w) + +# def psi2s_res(q): +# return resonance(q, psi2s_m, psi2s_s, psi2s_p, psi2s_w) + +# def cusp(q): +# return bifur_gauss(q, cusp_m, sig_L, sig_R, cusp_s) + +# funcs = jpsi_res(xq) + psi2s_res(xq) + cusp(xq) + +# vec_f = vec(xq, funcs) + +# axiv_nr = axiv_nonres(xq) + +# tot = vec_f + axiv_nr + +# return tot + +# def jpsi_res(q): +# return resonance(q, jpsi_m, jpsi_s, jpsi_p, jpsi_w) + +# calcs = zfit.run(total_test_tf(x_part)) + + + +test_q = np.linspace(x_min, x_max, int(2e6)) + +probs = total_f_fit.pdf(test_q, norm_range=False) + +calcs_test = zfit.run(probs) + +Ctt.set_value(0.5) + +calcs_test1 = zfit.run(probs) + +Ctt.set_value(0.0) + +Dbar_s.set_value(0.3) + +DDstar_s.set_value(0.3) + +calcs_test2 = zfit.run(probs) +# res_y = zfit.run(jpsi_res(test_q)) +# b0 = [b0_0, b0_1, b0_2] +# bplus = [bplus_0, bplus_1, bplus_2] +# bT = [bT_0, bT_1, bT_2] +# f0_y = zfit.run(tf.math.real(formfactor(test_q,"0", b0, bplus, bT))) +# fplus_y = zfit.run(tf.math.real(formfactor(test_q,"+", b0, bplus, bT))) +# fT_y = zfit.run(tf.math.real(formfactor(test_q,"T", b0, bplus, bT))) + + +# In[ ]: + + +plt.clf() +# plt.plot(x_part, calcs, '.') +plt.plot(test_q, calcs_test, label = 'pdf (Ctt = 0.0)') +plt.plot(test_q, calcs_test1, label = 'pdf (Ctt = 0.5)') +plt.plot(test_q, calcs_test2, label = 'pdf (D-contribs = 0.3)') +# plt.plot(test_q, f0_y, label = '0') +# plt.plot(test_q, fT_y, label = 'T') +# plt.plot(test_q, fplus_y, label = '+') +# plt.plot(test_q, res_y, label = 'res') +plt.legend() +plt.ylim(0.0, 1.5e-6) +# plt.yscale('log') +# plt.xlim(770, 785) +plt.savefig('test.png') +# print(jpsi_width) + + +# In[ ]: + + + + +# probs = mixture.prob(test_q) +# probs_np = zfit.run(probs) +# probs_np *= np.max(calcs_test) / np.max(probs_np) +# plt.figure() +# plt.semilogy(test_q, probs_np,label="importance sampling") +# plt.semilogy(test_q, calcs_test, label = 'pdf') + + +# In[ ]: + + +# 0.213/(0.00133+0.213+0.015) + + +# ## Adjust scaling of different parts + +# In[ ]: + + +total_f.update_integration_options(draws_per_dim=2000000, mc_sampler=None) +# inte = total_f.integrate(limits = (950., 1050.), norm_range=False) +# inte_fl = zfit.run(inte) +# print(inte_fl/4500) +# print(pdg["jpsi_BR"]/pdg["NR_BR"], inte_fl*pdg["psi2s_auc"]/pdg["NR_auc"]) + + +# In[ ]: + + +# # print("jpsi:", inte_fl) +# # print("Increase am by factor:", np.sqrt(pdg["jpsi_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) +# # print("New amp:", pdg["jpsi"][3]*np.sqrt(pdg["jpsi_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) + +# # print("psi2s:", inte_fl) +# # print("Increase am by factor:", np.sqrt(pdg["psi2s_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) +# # print("New amp:", pdg["psi2s"][3]*np.sqrt(pdg["psi2s_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) + +# name = "phi" + +# print(name+":", inte_fl) +# print("Increase am by factor:", np.sqrt(pdg[name+"_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) +# print("New amp:", pdg[name][0]*np.sqrt(pdg[name+"_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) + + +# print(x_min) +# print(x_max) +# # total_f.update_integration_options(draws_per_dim=2000000, mc_sampler=None) +# total_f.update_integration_options(mc_sampler=lambda dim, num_results, +# dtype: tf.random_uniform(maxval=1., shape=(num_results, dim), dtype=dtype), +# draws_per_dim=1000000) +# # _ = [] + +# # for i in range(10): + +# # inte = total_f.integrate(limits = (x_min, x_max)) +# # inte_fl = zfit.run(inte) +# # print(inte_fl) +# # _.append(inte_fl) + +# # print("mean:", np.mean(_)) + +# _ = time.time() + +# inte = total_f.integrate(limits = (x_min, x_max)) +# inte_fl = zfit.run(inte) +# print(inte_fl) +# print("Time taken: {}".format(display_time(int(time.time() - _)))) + +# print(pdg['NR_BR']/pdg['NR_auc']*inte_fl) +# print(0.25**2*4.2/1000) + + +# # Sampling +# ## Mixture distribution for sampling + +# In[ ]: + + + + +# print(list_of_borders[:9]) +# print(list_of_borders[-9:]) + + +class UniformSampleAndWeights(zfit.util.execution.SessionHolderMixin): + def __call__(self, limits, dtype, n_to_produce): + # n_to_produce = tf.cast(n_to_produce, dtype=tf.int32) + low, high = limits.limit1d + low = tf.cast(low, dtype=dtype) + high = tf.cast(high, dtype=dtype) +# uniform = tfd.Uniform(low=low, high=high) +# uniformjpsi = tfd.Uniform(low=tf.constant(3080, dtype=dtype), high=tf.constant(3112, dtype=dtype)) +# uniformpsi2s = tfd.Uniform(low=tf.constant(3670, dtype=dtype), high=tf.constant(3702, dtype=dtype)) + +# list_of_borders = [] +# _p = [] +# splits = 10 + +# _ = np.linspace(x_min, x_max, splits) + +# for i in range(splits): +# list_of_borders.append(tf.constant(_[i], dtype=dtype)) +# _p.append(tf.constant(1/splits, dtype=dtype)) + +# mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=_p[:(splits-1)]), +# components_distribution=tfd.Uniform(low=list_of_borders[:(splits-1)], +# high=list_of_borders[-(splits-1):])) + mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=[tf.constant(0.05, dtype=dtype), + tf.constant(0.93, dtype=dtype), + tf.constant(0.05, dtype=dtype), + tf.constant(0.065, dtype=dtype), + tf.constant(0.04, dtype=dtype), + tf.constant(0.05, dtype=dtype)]), + components_distribution=tfd.Uniform(low=[tf.constant(x_min, dtype=dtype), + tf.constant(3090, dtype=dtype), + tf.constant(3681, dtype=dtype), + tf.constant(3070, dtype=dtype), + tf.constant(1000, dtype=dtype), + tf.constant(3660, dtype=dtype)], + high=[tf.constant(x_max, dtype=dtype), + tf.constant(3102, dtype=dtype), + tf.constant(3691, dtype=dtype), + tf.constant(3110, dtype=dtype), + tf.constant(1040, dtype=dtype), + tf.constant(3710, dtype=dtype)])) +# dtype = tf.float64 +# mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=[tf.constant(0.04, dtype=dtype), +# tf.constant(0.90, dtype=dtype), +# tf.constant(0.02, dtype=dtype), +# tf.constant(0.07, dtype=dtype), +# tf.constant(0.02, dtype=dtype)]), +# components_distribution=tfd.Uniform(low=[tf.constant(x_min, dtype=dtype), +# tf.constant(3089, dtype=dtype), +# tf.constant(3103, dtype=dtype), +# tf.constant(3681, dtype=dtype), +# tf.constant(3691, dtype=dtype)], +# high=[tf.constant(3089, dtype=dtype), +# tf.constant(3103, dtype=dtype), +# tf.constant(3681, dtype=dtype), +# tf.constant(3691, dtype=dtype), +# tf.constant(x_max, dtype=dtype)])) +# mixture = tfd.Uniform(tf.constant(x_min, dtype=dtype), tf.constant(x_max, dtype=dtype)) +# sample = tf.random.uniform((n_to_produce, 1), dtype=dtype) + sample = mixture.sample((n_to_produce, 1)) +# sample = tf.random.uniform((n_to_produce, 1), dtype=dtype) + weights = mixture.prob(sample)[:,0] +# weights = tf.broadcast_to(tf.constant(1., dtype=dtype), shape=(n_to_produce,)) + # sample = tf.expand_dims(sample, axis=-1) +# print(sample, weights) + +# weights = tf.ones(shape=(n_to_produce,), dtype=dtype) + weights_max = None + thresholds = tf.random_uniform(shape=(n_to_produce,), dtype=dtype) + return sample, thresholds, weights, weights_max, n_to_produce + + +# In[ ]: + + +# total_f._sample_and_weights = UniformSampleAndWeights + + +# In[ ]: + + +# 0.00133/(0.00133+0.213+0.015)*(x_max-3750)/(x_max-x_min) + + +# In[ ]: + + +# zfit.settings.set_verbosity(10) + + +# In[ ]: + + +# # zfit.run.numeric_checks = False + +# nr_of_toys = 1 +# nevents = int(pdg["number_of_decays"]) +# nevents = pdg["number_of_decays"] +# event_stack = 1000000 +# # zfit.settings.set_verbosity(10) +# calls = int(nevents/event_stack + 1) + +# total_samp = [] + +# start = time.time() + +# sampler = total_f.create_sampler(n=event_stack) + +# for toy in range(nr_of_toys): + +# dirName = 'data/zfit_toys/toy_{0}'.format(toy) + +# if not os.path.exists(dirName): +# os.mkdir(dirName) +# print("Directory " , dirName , " Created ") + +# for call in range(calls): + +# sampler.resample(n=event_stack) +# s = sampler.unstack_x() +# sam = zfit.run(s) +# # clear_output(wait=True) + +# c = call + 1 + +# print("{0}/{1} of Toy {2}/{3}".format(c, calls, toy+1, nr_of_toys)) +# print("Time taken: {}".format(display_time(int(time.time() - start)))) +# print("Projected time left: {}".format(display_time(int((time.time() - start)/(c+calls*(toy))*((nr_of_toys-toy)*calls-c))))) + +# with open("data/zfit_toys/toy_{0}/{1}.pkl".format(toy, call), "wb") as f: +# pkl.dump(sam, f, pkl.HIGHEST_PROTOCOL) + + +# In[ ]: + + +# with open(r"data/zfit_toys/toy_0/0.pkl", "rb") as input_file: +# sam = pkl.load(input_file) +# print(sam[:10]) + +# with open(r"data/zfit_toys/toy_0/1.pkl", "rb") as input_file: +# sam2 = pkl.load(input_file) +# print(sam2[:10]) + +# print(np.sum(sam-sam2)) + + +# In[ ]: + + +# print("Time to generate full toy: {} s".format(int(time.time()-start))) + +# total_samp = [] + +# for call in range(calls): +# with open(r"data/zfit_toys/toy_0/{}.pkl".format(call), "rb") as input_file: +# sam = pkl.load(input_file) +# total_samp = np.append(total_samp, sam) + +# total_samp = total_samp.astype('float64') + +# data2 = zfit.data.Data.from_numpy(array=total_samp[:int(nevents)], obs=obs) + +# data3 = zfit.data.Data.from_numpy(array=total_samp, obs=obs) + +# print(total_samp[:nevents].shape) + + +# In[ ]: + + +# plt.clf() + +# bins = int((x_max-x_min)/7) + +# # calcs = zfit.run(total_test_tf(samp)) +# print(total_samp[:nevents].shape) + +# plt.hist(total_samp[:nevents], bins = bins, range = (x_min,x_max), label = 'data') +# # plt.plot(test_q, calcs_test*nevents , label = 'pdf') + +# # plt.plot(sam, calcs, '.') +# # plt.plot(test_q, calcs_test) +# # plt.yscale('log') +# plt.ylim(0, 200) +# # plt.xlim(3080, 3110) + +# plt.legend() + +# plt.savefig('test2.png') + + +# In[ ]: + + +# sampler = total_f.create_sampler(n=nevents) +# nll = zfit.loss.UnbinnedNLL(model=total_f, data=sampler, fit_range = (x_min, x_max)) + +# # for param in pdf.get_dependents(): +# # param.set_value(initial_value) + +# sampler.resample(n=nevents) + +# # Randomise initial values +# # for param in pdf.get_dependents(): +# # param.set_value(random value here) + +# # Minimise the NLL +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 10) +# minimum = minimizer.minimize(nll) + + +# In[ ]: + + +# jpsi_width + + +# In[ ]: + + +# plt.hist(sample, weights=1 / prob(sample)) + + +# # Fitting + +# In[ ]: + + +# start = time.time() + +# for param in total_f.get_dependents(): +# param.randomize() + +# # for param in total_f.get_dependents(): +# # print(zfit.run(param)) + +# nll = zfit.loss.UnbinnedNLL(model=total_f, data=data2, fit_range = (x_min, x_max)) + +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) +# # minimizer._use_tfgrad = False +# result = minimizer.minimize(nll) + +# # param_errors = result.error() + +# # for var, errors in param_errors.items(): +# # print('{}: ^{{+{}}}_{{{}}}'.format(var.name, errors['upper'], errors['lower'])) + +# print("Function minimum:", result.fmin) +# # print("Results:", result.params) +# print("Hesse errors:", result.hesse()) + + +# In[ ]: + + +# print("Time taken for fitting: {}".format(display_time(int(time.time()-start)))) + +# # probs = total_f.pdf(test_q) + +# calcs_test = zfit.run(probs) +# res_y = zfit.run(jpsi_res(test_q)) + + +# In[ ]: + + +# plt.clf() +# # plt.plot(x_part, calcs, '.') +# plt.plot(test_q, calcs_test, label = 'pdf') +# # plt.plot(test_q, res_y, label = 'res') +# plt.legend() +# plt.ylim(0.0, 10e-6) +# # plt.yscale('log') +# # plt.xlim(3080, 3110) +# plt.savefig('test3.png') +# # print(jpsi_width) + + +# In[ ]: + + +# _tot = 4.37e-7+6.02e-5+4.97e-6 +# _probs = [] +# _probs.append(6.02e-5/_tot) +# _probs.append(4.97e-6/_tot) +# _probs.append(4.37e-7/_tot) +# print(_probs) + + +# In[ ]: + + +# dtype = 'float64' +# # mixture = tfd.Uniform(tf.constant(x_min, dtype=dtype), tf.constant(x_max, dtype=dtype)) +# mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=[tf.constant(0.007, dtype=dtype), +# tf.constant(0.917, dtype=dtype), +# tf.constant(0.076, dtype=dtype)]), +# components_distribution=tfd.Uniform(low=[tf.constant(x_min, dtype=dtype), +# tf.constant(3080, dtype=dtype), +# tf.constant(3670, dtype=dtype)], +# high=[tf.constant(x_max, dtype=dtype), +# tf.constant(3112, dtype=dtype), +# tf.constant(3702, dtype=dtype)])) +# # for i in range(10): +# # print(zfit.run(mixture.prob(mixture.sample((10, 1))))) + + +# In[ ]: + + +# print((zfit.run(jpsi_p)%(2*np.pi))/np.pi) +# print((zfit.run(psi2s_p)%(2*np.pi))/np.pi) + + +# In[ ]: + + +# def jpsi_res(q): +# return resonance(q, _mass = jpsi_mass, scale = jpsi_scale, +# phase = jpsi_phase, width = jpsi_width) + +# def psi2s_res(q): +# return resonance(q, _mass = psi2s_mass, scale = psi2s_scale, +# phase = psi2s_phase, width = psi2s_width) + +# def p3770_res(q): +# return resonance(q, _mass = p3770_mass, scale = p3770_scale, +# phase = p3770_phase, width = p3770_width) + +# def p4040_res(q): +# return resonance(q, _mass = p4040_mass, scale = p4040_scale, +# phase = p4040_phase, width = p4040_width) + +# def p4160_res(q): +# return resonance(q, _mass = p4160_mass, scale = p4160_scale, +# phase = p4160_phase, width = p4160_width) + +# def p4415_res(q): +# return resonance(q, _mass = p4415_mass, scale = p4415_scale, +# phase = p4415_phase, width = p4415_width) + + +# In[ ]: + + +# 0.15**2*4.2/1000 +# result.hesse() + + +# ## Constraints + +# In[ ]: + + +# 1. Constraint - Real part of sum of Psi contrib and D contribs + +sum_list = [] + +sum_list.append(ztf.to_complex(jpsi_s) * tf.exp(tf.complex(ztf.constant(0.0), jpsi_p)) * ztf.to_complex(jpsi_w / (tf.pow(jpsi_m,3)))) +sum_list.append(ztf.to_complex(psi2s_s) * tf.exp(tf.complex(ztf.constant(0.0), psi2s_p)) * ztf.to_complex(psi2s_w / (tf.pow(psi2s_m,3)))) +sum_list.append(ztf.to_complex(p3770_s) * tf.exp(tf.complex(ztf.constant(0.0), p3770_p)) * ztf.to_complex(p3770_w / (tf.pow(p3770_m,3)))) +sum_list.append(ztf.to_complex(p4040_s) * tf.exp(tf.complex(ztf.constant(0.0), p4040_p)) * ztf.to_complex(p4040_w / (tf.pow(p4040_m,3)))) +sum_list.append(ztf.to_complex(p4160_s) * tf.exp(tf.complex(ztf.constant(0.0), p4160_p)) * ztf.to_complex(p4160_w / (tf.pow(p4160_m,3)))) +sum_list.append(ztf.to_complex(p4415_s) * tf.exp(tf.complex(ztf.constant(0.0), p4415_p)) * ztf.to_complex(p4415_w / (tf.pow(p4415_m,3)))) +sum_list.append(ztf.to_complex(DDstar_s) * tf.exp(tf.complex(ztf.constant(0.0), DDstar_p)) * (ztf.to_complex(1.0 / (10.0*tf.pow(Dstar_m,2)) + 1.0 / (10.0*tf.pow(D_m,2))))) +sum_list.append(ztf.to_complex(Dbar_s) * tf.exp(tf.complex(ztf.constant(0.0), Dbar_p)) * ztf.to_complex(1.0 / (6.0*tf.pow(Dbar_m,2)))) + +sum_ru_1 = ztf.to_complex(ztf.constant(0.0)) + +for part in sum_list: + sum_ru_1 += part + +sum_1 = tf.math.real(sum_ru_1) +# constraint1 = zfit.constraint.GaussianConstraint(params = sum_1, mu = ztf.constant(1.7*10**-8), +# sigma = ztf.constant(2.2*10**-8)) + +constraint1 = tf.pow((sum_1-ztf.constant(1.7*10**-8))/ztf.constant(2.2*10**-8),2)/ztf.constant(2.) + +# 2. Constraint - Abs. of sum of Psi contribs and D contribs + +sum_2 = tf.abs(sum_ru_1) +constraint2 = tf.cond(tf.greater_equal(sum_2, 5.0e-8), lambda: 100000., lambda: 0.) + +# 3. Constraint - Maximum eta of D contribs + +constraint3_0 = tf.cond(tf.greater_equal(tf.abs(Dbar_s), 0.2), lambda: 100000., lambda: 0.) + +constraint3_1 = tf.cond(tf.greater_equal(tf.abs(DDstar_s), 0.2), lambda: 100000., lambda: 0.) + +# 4. Constraint - Formfactor multivariant gaussian covariance fplus + +Cov_matrix = [[ztf.constant( 1.), ztf.constant( 0.45), ztf.constant( 0.19), ztf.constant(0.857), ztf.constant(0.598), ztf.constant(0.531), ztf.constant(0.752), ztf.constant(0.229), ztf.constant(0,117)], + [ztf.constant( 0.45), ztf.constant( 1.), ztf.constant(0.677), ztf.constant(0.708), ztf.constant(0.958), ztf.constant(0.927), ztf.constant(0.227), ztf.constant(0.443), ztf.constant(0.287)], + [ztf.constant( 0.19), ztf.constant(0.677), ztf.constant( 1.), ztf.constant(0.595), ztf.constant(0.770), ztf.constant(0.819),ztf.constant(-0.023), ztf.constant( 0.07), ztf.constant(0.196)], + [ztf.constant(0.857), ztf.constant(0.708), ztf.constant(0.595), ztf.constant( 1.), ztf.constant( 0.83), ztf.constant(0.766), ztf.constant(0.582), ztf.constant(0.237), ztf.constant(0.192)], + [ztf.constant(0.598), ztf.constant(0.958), ztf.constant(0.770), ztf.constant( 0.83), ztf.constant( 1.), ztf.constant(0.973), ztf.constant(0.324), ztf.constant(0.372), ztf.constant(0.272)], + [ztf.constant(0.531), ztf.constant(0.927), ztf.constant(0.819), ztf.constant(0.766), ztf.constant(0.973), ztf.constant( 1.), ztf.constant(0.268), ztf.constant(0.332), ztf.constant(0.269)], + [ztf.constant(0.752), ztf.constant(0.227),ztf.constant(-0.023), ztf.constant(0.582), ztf.constant(0.324), ztf.constant(0.268), ztf.constant( 1.), ztf.constant( 0.59), ztf.constant(0.515)], + [ztf.constant(0.229), ztf.constant(0.443), ztf.constant( 0.07), ztf.constant(0.237), ztf.constant(0.372), ztf.constant(0.332), ztf.constant( 0.59), ztf.constant( 1.), ztf.constant(0.897)], + [ztf.constant(0.117), ztf.constant(0.287), ztf.constant(0.196), ztf.constant(0.192), ztf.constant(0.272), ztf.constant(0.269), ztf.constant(0.515), ztf.constant(0.897), ztf.constant( 1.)]] + +def triGauss(val1,val2,val3,m = Cov_matrix): + + mean1 = ztf.constant(0.466) + mean2 = ztf.constant(-0.885) + mean3 = ztf.constant(-0.213) + sigma1 = ztf.constant(0.014) + sigma2 = ztf.constant(0.128) + sigma3 = ztf.constant(0.548) + x1 = (val1-mean1)/sigma1 + x2 = (val2-mean2)/sigma2 + x3 = (val3-mean3)/sigma3 + rho12 = m[0][1] + rho13 = m[0][2] + rho23 = m[1][2] + w = x1*x1*(rho23*rho23-1) + x2*x2*(rho13*rho13-1)+x3*x3*(rho12*rho12-1)+2*(x1*x2*(rho12-rho13*rho23)+x1*x3*(rho13-rho12*rho23)+x2*x3*(rho23-rho12*rho13)) + d = 2*(rho12*rho12+rho13*rho13+rho23*rho23-2*rho12*rho13*rho23-1) + + fcn = -w/d + chisq = -2*fcn + return chisq + +constraint4 = triGauss(bplus_0, bplus_1, bplus_2) + +# mean1 = ztf.constant(0.466) +# mean2 = ztf.constant(-0.885) +# mean3 = ztf.constant(-0.213) +# sigma1 = ztf.constant(0.014) +# sigma2 = ztf.constant(0.128) +# sigma3 = ztf.constant(0.548) +# constraint4_0 = tf.pow((bplus_0-mean1)/sigma1,2)/ztf.constant(2.) +# constraint4_1 = tf.pow((bplus_1-mean2)/sigma2,2)/ztf.constant(2.) +# constraint4_2 = tf.pow((bplus_2-mean3)/sigma3,2)/ztf.constant(2.) + +# 5. Constraint - Abs. of sum of light contribs + +sum_list_5 = [] + +sum_list_5.append(rho_s*rho_w/rho_m) +sum_list_5.append(omega_s*omega_w/omega_m) +sum_list_5.append(phi_s*phi_w/phi_m) + + +sum_ru_5 = ztf.constant(0.0) + +for part in sum_list_5: + sum_ru_5 += part + +constraint5 = tf.cond(tf.greater_equal(tf.abs(sum_ru_5), ztf.constant(0.02)), lambda: 100000., lambda: 0.) + +# 6. Constraint on phases of Jpsi and Psi2s for cut out fit + + +# constraint6_0 = zfit.constraint.GaussianConstraint(params = jpsi_p, mu = ztf.constant(pdg["jpsi_phase_unc"]), +# sigma = ztf.constant(jpsi_phase)) +# constraint6_1 = zfit.constraint.GaussianConstraint(params = psi2s_p, mu = ztf.constant(pdg["psi2s_phase_unc"]), +# sigma = ztf.constant(psi2s_phase)) + +constraint6_0 = tf.pow((jpsi_p-ztf.constant(jpsi_phase))/ztf.constant(pdg["jpsi_phase_unc"]),2)/ztf.constant(2.) +constraint6_1 = tf.pow((psi2s_p-ztf.constant(psi2s_phase))/ztf.constant(pdg["psi2s_phase_unc"]),2)/ztf.constant(2.) + +# 7. Constraint on Ctt with higher limits + +constraint7 = tf.cond(tf.greater_equal(Ctt*Ctt, 0.25), lambda: 100000., lambda: 0.) + +constraint7dtype = tf.float64 + +# zfit.run(constraint6_0) + +# ztf.convert_to_tensor(constraint6_0) + +#List of all constraints + +constraints = [constraint1, constraint2, constraint3_0, constraint3_1,# constraint4, #constraint4_0, constraint4_1, constraint4_2, + constraint6_0, constraint6_1]#, constraint7] + + +# ## Reset params + +# In[ ]: + + +param_values_dic = { + 'jpsi_m': jpsi_mass, + 'jpsi_s': jpsi_scale, + 'jpsi_p': jpsi_phase, + 'jpsi_w': jpsi_width, + 'psi2s_m': psi2s_mass, + 'psi2s_s': psi2s_scale, + 'psi2s_p': psi2s_phase, + 'psi2s_w': psi2s_width, + 'p3770_m': p3770_mass, + 'p3770_s': p3770_scale, + 'p3770_p': p3770_phase, + 'p3770_w': p3770_width, + 'p4040_m': p4040_mass, + 'p4040_s': p4040_scale, + 'p4040_p': p4040_phase, + 'p4040_w': p4040_width, + 'p4160_m': p4160_mass, + 'p4160_s': p4160_scale, + 'p4160_p': p4160_phase, + 'p4160_w': p4160_width, + 'p4415_m': p4415_mass, + 'p4415_s': p4415_scale, + 'p4415_p': p4415_phase, + 'p4415_w': p4415_width, + 'rho_m': rho_mass, + 'rho_s': rho_scale, + 'rho_p': rho_phase, + 'rho_w': rho_width, + 'omega_m': omega_mass, + 'omega_s': omega_scale, + 'omega_p': omega_phase, + 'omega_w': omega_width, + 'phi_m': phi_mass, + 'phi_s': phi_scale, + 'phi_p': phi_phase, + 'phi_w': phi_width, + 'Dstar_m': Dstar_mass, + 'DDstar_s': 0.0, + 'DDstar_p': 0.0, + 'D_m': D_mass, + 'Dbar_m': Dbar_mass, + 'Dbar_s': 0.0, + 'Dbar_p': 0.0, + 'tau_m': pdg['tau_M'], + 'Ctt': 0.0, + 'b0_0': 0.292, + 'b0_1': 0.281, + 'b0_2': 0.150, + 'bplus_0': 0.466, + 'bplus_1': -0.885, + 'bplus_2': -0.213, + 'bT_0': 0.460, + 'bT_1': -1.089, + 'bT_2': -1.114} + + +def reset_param_values(variation = 0.05): + for param in total_f_fit.get_dependents(): + if param.floating: + param.set_value(param_values_dic[param.name] + random.uniform(-1, 1) * param_values_dic[param.name]* variation) +# print(param.name) +# for param in totalf.get_dependents(): +# param.set_value() + + +# # Analysis + +# In[ ]: + + +# # zfit.run.numeric_checks = False + +# fitting_range = 'cut' +# total_BR = 1.7e-10 + 4.9e-10 + 2.5e-9 + 6.02e-5 + 4.97e-6 + 1.38e-9 + 4.2e-10 + 2.6e-9 + 6.1e-10 + 4.37e-7 +# cut_BR = 1.0 - (6.02e-5 + 4.97e-6)/total_BR + +# Ctt_list = [] +# Ctt_error_list = [] + +# nr_of_toys = 1 +# if fitting_range == 'cut': +# nevents = int(pdg["number_of_decays"]*cut_BR) +# else: +# nevents = int(pdg["number_of_decays"]) +# # nevents = pdg["number_of_decays"] +# event_stack = 1000000 +# # nevents *= 41 +# # zfit.settings.set_verbosity(10) +# calls = int(nevents/event_stack + 1) + +# total_samp = [] + +# start = time.time() + +# sampler = total_f.create_sampler(n=event_stack) + +# for toy in range(nr_of_toys): + +# ### Generate data + +# # clear_output(wait=True) + +# print("Toy {}: Generating data...".format(toy)) + +# dirName = 'data/zfit_toys/toy_{0}'.format(toy) + +# if not os.path.exists(dirName): +# os.mkdir(dirName) +# print("Directory " , dirName , " Created ") + +# reset_param_values() + +# if fitting_range == 'cut': + +# sampler.resample(n=nevents) +# s = sampler.unstack_x() +# sam = zfit.run(s) +# calls = 0 +# c = 1 + +# else: +# for call in range(calls): + +# sampler.resample(n=event_stack) +# s = sampler.unstack_x() +# sam = zfit.run(s) + +# c = call + 1 + +# with open("data/zfit_toys/toy_{0}/{1}.pkl".format(toy, call), "wb") as f: +# pkl.dump(sam, f, pkl.HIGHEST_PROTOCOL) + +# print("Toy {}: Data generation finished".format(toy)) + +# ### Load data + +# print("Toy {}: Loading data...".format(toy)) + +# if fitting_range == 'cut': + +# total_samp = sam + +# else: + +# for call in range(calls): +# with open(r"data/zfit_toys/toy_0/{}.pkl".format(call), "rb") as input_file: +# sam = pkl.load(input_file) +# total_samp = np.append(total_samp, sam) + +# total_samp = total_samp.astype('float64') + +# if fitting_range == 'full': + +# data = zfit.data.Data.from_numpy(array=total_samp[:int(nevents)], obs=obs) + +# print("Toy {}: Loading data finished".format(toy)) + +# ### Fit data + +# print("Toy {}: Fitting pdf...".format(toy)) + +# for param in total_f.get_dependents(): +# param.randomize() + +# nll = zfit.loss.UnbinnedNLL(model=total_f, data=data, fit_range = (x_min, x_max), constraints = constraints) + +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) +# # minimizer._use_tfgrad = False +# result = minimizer.minimize(nll) + +# print("Toy {}: Fitting finished".format(toy)) + +# print("Function minimum:", result.fmin) +# print("Hesse errors:", result.hesse()) + +# params = result.params +# Ctt_list.append(params[Ctt]['value']) +# Ctt_error_list.append(params[Ctt]['minuit_hesse']['error']) + +# #plotting the result + +# plotdirName = 'data/plots'.format(toy) + +# if not os.path.exists(plotdirName): +# os.mkdir(plotdirName) +# # print("Directory " , dirName , " Created ") + +# probs = total_f.pdf(test_q, norm_range=False) +# calcs_test = zfit.run(probs) +# plt.clf() +# plt.plot(test_q, calcs_test, label = 'pdf') +# plt.legend() +# plt.ylim(0.0, 6e-6) +# plt.savefig(plotdirName + '/toy_fit_full_range{}.png'.format(toy)) + +# print("Toy {0}/{1}".format(toy+1, nr_of_toys)) +# print("Time taken: {}".format(display_time(int(time.time() - start)))) +# print("Projected time left: {}".format(display_time(int((time.time() - start)/(c+calls*(toy))*((nr_of_toys-toy)*calls-c))))) + +# if fitting_range == 'cut': + +# _1 = np.where((total_samp >= x_min) & (total_samp <= (jpsi_mass - 60.))) + +# tot_sam_1 = total_samp[_1] + +# _2 = np.where((total_samp >= (jpsi_mass + 70.)) & (total_samp <= (psi2s_mass - 50.))) + +# tot_sam_2 = total_samp[_2] + +# _3 = np.where((total_samp >= (psi2s_mass + 50.)) & (total_samp <= x_max)) + +# tot_sam_3 = total_samp[_3] + +# tot_sam = np.append(tot_sam_1, tot_sam_2) +# tot_sam = np.append(tot_sam, tot_sam_3) + +# data = zfit.data.Data.from_numpy(array=tot_sam[:int(nevents)], obs=obs_fit) + +# print("Toy {}: Loading data finished".format(toy)) + +# ### Fit data + +# print("Toy {}: Fitting pdf...".format(toy)) + +# for param in total_f_fit.get_dependents(): +# param.randomize() + +# nll = zfit.loss.UnbinnedNLL(model=total_f_fit, data=data, constraints = constraints) + +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) +# # minimizer._use_tfgrad = False +# result = minimizer.minimize(nll) + +# print("Function minimum:", result.fmin) +# print("Hesse errors:", result.hesse()) + +# params = result.params + +# if result.converged: +# Ctt_list.append(params[Ctt]['value']) +# Ctt_error_list.append(params[Ctt]['minuit_hesse']['error']) + +# #plotting the result + +# plotdirName = 'data/plots'.format(toy) + +# if not os.path.exists(plotdirName): +# os.mkdir(plotdirName) +# # print("Directory " , dirName , " Created ") + +# plt.clf() +# plt.hist(tot_sam, bins = int((x_max-x_min)/7.), label = 'toy data') +# plt.savefig(plotdirName + '/toy_histo_cut_region{}.png'.format(toy)) + + +# probs = total_f_fit.pdf(test_q, norm_range=False) +# calcs_test = zfit.run(probs) +# plt.clf() +# plt.plot(test_q, calcs_test, label = 'pdf') +# plt.axvline(x=jpsi_mass-60.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.axvline(x=jpsi_mass+70.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.axvline(x=psi2s_mass-50.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.axvline(x=psi2s_mass+50.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.legend() +# plt.ylim(0.0, 1.5e-6) +# plt.savefig(plotdirName + '/toy_fit_cut_region{}.png'.format(toy)) + +# print("Toy {0}/{1}".format(toy+1, nr_of_toys)) +# print("Time taken: {}".format(display_time(int(time.time() - start)))) +# print("Projected time left: {}".format(display_time(int((time.time() - start)/(toy+1))*((nr_of_toys-toy-1))))) + + + +# In[ ]: + + +# with open("data/results/Ctt_list.pkl", "wb") as f: +# pkl.dump(Ctt_list, f, pkl.HIGHEST_PROTOCOL) +# with open("data/results/Ctt_error_list.pkl", "wb") as f: +# pkl.dump(Ctt_error_list, f, pkl.HIGHEST_PROTOCOL) + + +# In[ ]: + + +# print('{0}/{1} fits converged'.format(len(Ctt_list), nr_of_toys)) +# print('Mean Ctt value = {}'.format(np.mean(Ctt_list))) +# print('Mean Ctt error = {}'.format(np.mean(Ctt_error_list))) +# print('95 Sensitivy = {}'.format(((2*np.mean(Ctt_error_list))**2)*4.2/1000)) + + +# In[ ]: + + +# plt.hist(tot_sam, bins = int((x_max-x_min)/7.)) + +# plt.show() + +# # _ = np.where((total_samp >= x_min) & (total_samp <= (jpsi_mass - 50.))) + +# tot_sam.shape + + +# In[ ]: + + +# Ctt.floating = False + + +# In[ ]: + + +# zfit.run(nll.value()) + + +# In[ ]: + + +# result.fmin + + +# In[ ]: + + +# BR_steps = np.linspace(0.0, 1e-3, 11) +pull_dic = {} + +mi = 1e-4 +ma = 3e-3 +ste = 20 + +for param in total_f_fit.get_dependents(): + if param.floating: + pull_dic[param.name] = [] + for step in range(2*ste): + pull_dic[param.name].append([]) + + + +def save_pulls(step): + for param in total_f_fit.get_dependents(): + if param.floating: + pull_dic[param.name][step].append((params[param]['value'] - param_values_dic[param.name])/params[param]['minuit_hesse']['error']) + + + +# for key in pull_dic.keys(): +# print(np.shape(pull_dic[key])) +# save_pulls(New_step=True) +# params[Ctt]['value'] + + +# In[ ]: + + +# for param in total_f_fit.get_dependents(): +# if param.floating: +# print(param.name) + +# print(params[Ctt]) + + +# # CLS Code + +# In[ ]: + + +# zfit.run.numeric_checks = False + +load = False + +bo = True + +D_contribs = True + +if not D_contribs: + Dbar_s.floating = False + Dbar_p.floating = False + DDstar_s.floating = False + DDstar_p.floating = False + +bo_set = 1 + +fitting_range = 'cut' +total_BR = 1.7e-10 + 4.9e-10 + 2.5e-9 + 6.02e-5 + 4.97e-6 + 1.38e-9 + 4.2e-10 + 2.6e-9 + 6.1e-10 + 4.37e-7 +cut_BR = 1.0 - (6.02e-5 + 4.97e-6)/total_BR + +Ctt_list = [] +Ctt_error_list = [] + +nr_of_toys = 1 +nevents = int(pdg["number_of_decays"]*cut_BR) +# nevents = pdg["number_of_decays"] +event_stack = 1000000 +# nevents *= 41 +# zfit.settings.set_verbosity(10) + +# mi = 1e-4 +# ma = 3e-3 +# ste = 13 + +BR_steps = np.linspace(mi, ma, ste) + +BR_steps[0] = 0.0 + +print(BR_steps) + +Ctt_steps = np.sqrt(BR_steps/4.2*1000) + +print(Ctt_steps) + +# total_samp = [] + +start = time.time() + +Nll_list = [] + +sampler = total_f.create_sampler(n=nevents, fixed_params = False) +sampler.set_data_range(obs_fit) + +__ = -1 + +#----------------------------------------------------- + +if not load: + for Ctt_step in Ctt_steps: + + __ += 1 + + for i in range(2): + Ctt_list.append([]) + Ctt_error_list.append([]) + Nll_list.append([]) + + for param in total_f_fit.get_dependents(): + if param.floating: + pull_dic[param.name].append([]) + + for toy in range(nr_of_toys): + + newset = True + + while newset: + + for floaty in [True, False]: + Ctt.floating = floaty + + for bo_step in range(bo_set): + + print('Step: {0}/{1}'.format(int(__), ste)) + print('Current Ctt: {0}'.format(Ctt_step)) + print('Ctt floating: {0}'.format(floaty)) + + reset_param_values(variation = 0.0) + + if floaty: + print('Toy {0}/{1} - Fit {2}/{3}'.format(toy, nr_of_toys, bo_step, bo_set)) + Ctt.set_value(Ctt_step) + + else: + Ctt.set_value(0.0) + print('Toy {0}/{1} - Fit {2}/{3}'.format(toy, nr_of_toys, bo_step, bo_set)) + + if newset: + sampler.resample(n=nevents) + data = sampler + newset = False + + ### Fit data + + if floaty: + #plt.clf() + #plt.title('Ctt value: {:.2f}'.format(Ctt_step)) + #plt.hist(zfit.run(data), bins = int((x_max-x_min)/7), range = (x_min, x_max)) + #plt.savefig('data/CLs/plots/set_histo{}.png'.format(__)) + _step = 2*__ + else: + _step = 2*__+1 + + nll = zfit.loss.UnbinnedNLL(model=total_f_fit, data=data, constraints = constraints) + + minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) + # minimizer._use_tfgrad = False + result = minimizer.minimize(nll) + + print("Function minimum:", result.fmin) + print("Hesse errors:", result.hesse()) + + params = result.params + + if result.converged: + + save_pulls(step = _step) + + if floaty: + Nll_list[-2].append(result.fmin) + Ctt_list[-2].append(params[Ctt]['value']) + Ctt_error_list[-2].append(params[Ctt]['minuit_hesse']['error']) + + else: + Nll_list[-1].append(result.fmin) + Ctt_list[-1].append(0.0) + Ctt_error_list[-1].append(0.0) + + + else: + for _ in [1,2]: + del Nll_list[-_][toy*bo_set:] +# print(np.shape(Nll_list[-_])) + del Ctt_list[-_][toy*bo_set:] + del Ctt_error_list[-_][toy*bo_set:] + for param in total_f_fit.get_dependents(): + if param.floating: + del pull_dic[param.name][_step+1-_][toy*bo_set:] + newset = True + break + + if not result.converged: + break + + print() + print('Time taken: {}'.format(display_time(int(time.time()-start)))) + print('Estimated time left: {}'.format(display_time(int((time.time()-start)/(__+(toy+1)/nr_of_toys)*(ste-__-(nr_of_toys-toy-1)/nr_of_toys))))) + + +# In[ ]: + + +if load: + + phase_combi = '--' + + if D_contribs: + D_dir = 'D-True' + else: + D_dir = 'D-False' + + _dir = 'data/CLs/finished/f1d1/{}/{}/'.format(phase_combi, D_dir) + + jobs = os.listdir(_dir) + + First = True + +# print(jobs) + + for job in jobs: + + dirName = _dir + str(job) + '/data/CLs' + + if not os.path.exists("{}/{}-{}_{}s{}b{}t--CLs_Nll_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys)): +# print(job) + continue + + with open(r"{}/variab.pkl".format(dirName), "rb") as input_file: + variab = pkl.load(input_file) +# print(variab) + + ### sanity check: + if variab['mi'] != mi or variab['ma'] != ma or variab['ste'] != ste or bo_set != bo_set: + print('Fitting parameters of data dont equal the ones given -- Job {} skipped!'.format(job)) + + with open(r"{}/{}-{}_{}s{}b{}t--CLs_Nll_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _Nll_list = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s{}b{}t--Ctt_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _Ctt_list = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s{}b{}t--Ctt_error_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _Ctt_error_list = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s{}b{}t--pull_dic.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _pull_dic = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s--CLs_list.pkl".format(dirName, mi,ma,ste), "rb") as input_file: + _CLs_list = pkl.load(input_file) + + + if First: + Nll_list = _Nll_list + Ctt_list = _Ctt_list + Ctt_error_list = _Ctt_error_list + pull_dic = _pull_dic +# print(_pull_dic) + CLs_list = _CLs_list + First = False + else: + for step in range(2*ste): +# print(Nll_list[step], step) + Nll_list[step].extend(_Nll_list[step]) + Ctt_list[step].extend(_Ctt_list[step]) + Ctt_error_list[step].extend(_Ctt_error_list[step]) + for key in pull_dic.keys(): +# print(key, np.shape(pull_dic[key])) + pull_dic[key][step].extend(_pull_dic[key][step]) + for step in range(ste): + CLs_list[step].extend(_CLs_list[step]) + +# print('----------------------') + + +# In[ ]: + + +dirName = 'data/CLs' + +# if bo and not load: +# for s in range(2*ste): +# Nll_list[s] = [np.min(Nll_list[s])] + + +if not load: + + if not os.path.exists(dirName): + os.mkdir(dirName) + print("Directory " , dirName , " Created ") + + with open("{}/{}-{}_{}s{}b{}t--CLs_Nll_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(Nll_list, f, pkl.HIGHEST_PROTOCOL) + + with open("{}/{}-{}_{}s{}b{}t--Ctt_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(Ctt_list, f, pkl.HIGHEST_PROTOCOL) + + with open("{}/{}-{}_{}s{}b{}t--Ctt_error_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(Ctt_error_list, f, pkl.HIGHEST_PROTOCOL) + + with open("{}/{}-{}_{}s{}b{}t--pull_dic.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(pull_dic, f, pkl.HIGHEST_PROTOCOL) + + variab = {'mi': mi, + 'ma': ma, + 'ste': ste, + 'bo_set': bo_set, + 'nr_of_toys': nr_of_toys} + + with open("{}/variab.pkl".format(dirName), "wb") as f: + pkl.dump(variab, f, pkl.HIGHEST_PROTOCOL) + + CLs_values = [] + + toy_size = bo_set + + print(np.shape(Nll_list)) + print(Nll_list[0:1]) + + for step in range(ste): + CLs_values.append([]) + for toy in range(nr_of_toys): + float_min = np.min(Nll_list[2*step][toy*bo_set:(toy+1)*bo_set]) + fix_min = np.min(Nll_list[2*step+1][toy*bo_set:(toy+1)*bo_set]) + CLs_values[step].append(float_min-fix_min) + + + print(np.shape(CLs_values)) + + with open("{}/{}-{}_{}s--CLs_list.pkl".format(dirName, mi,ma,ste), "wb") as f: + pkl.dump(CLs_values, f, pkl.HIGHEST_PROTOCOL) + + +# In[ ]: + + +# print(variab['mi'] != mi) + + +# ## Plot + +# In[ ]: + + +l = [] + + +if load: + CLs_values = -1*np.array(CLs_list) + +if not os.path.exists('data/CLs/plots'): + os.mkdir('data/CLs/plots') + print("Directory " , 'data/CLs/plots' , " Created ") + +print(np.shape(CLs_values)) + +for step in range(1,ste): + plt.clf() + plt.title('Ctt value: {:.2f}'.format(Ctt_steps[step])) + plt.hist(CLs_values[0], bins = 150, range = (-25, 50), label = 'Ctt fixed to 0') + plt.hist(CLs_values[step], bins = 150, range = (-25, 50), label = 'Ctt floating') + plt.axvline(x=np.mean(CLs_values[0]),color='red', linewidth=1.0, linestyle = 'dotted') + plt.legend() + plt.savefig('data/CLs/plots/CLs-BR({:.1E}).png'.format(BR_steps[step])) + + l.append(len(np.where(np.array(CLs_values[step]) < np.mean(CLs_values[0]))[0])) + +for step in range(2*ste): + if step%2 == 0: + floaty = True + else: + floaty = False + for key in pull_dic.keys(): + if not os.path.exists('data/CLs/plots/{}'.format(key)): + os.mkdir('data/CLs/plots/{}'.format(key)) + plt.clf() + plt.title('Pull {} - Ctt value {:.2f} - floating {}'.format(key, Ctt_steps[int(step/2)], floaty)) + plt.hist(pull_dic[key][step], bins = 50, range = (-5,5)) + plt.xlabel('Pull') + plt.savefig('data/CLs/plots/{}/{:.2f}Ctt{}s{}f.png'.format(key, Ctt_steps[int(step/2)], step, floaty)) + + +# In[ ]: + + +for s in range(len(l)): + print('BR: {:.4f}'.format(BR_steps[s+1])) + print(2*l[s]/len(CLs_values[s])) + print() + + +# In[ ]: + + +# for step in range(2*ste): +# for key in pull_dic.keys(): +# print(pull_dic[key][step]) + + +# In[ ]: + + +# for param in total_f_fit.get_dependents(): +# if param.floating: +# print(params[param]['value']) + + +# In[ ]: + + +print(display_time(int(time.time()-start))) + + +# In[ ]: + + +# variab['mi'] =! mi + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + diff --git a/data/CLs/finished/f1d1/-+/D-True/2288046/__pycache__/helperfunctions.cpython-37.pyc b/data/CLs/finished/f1d1/-+/D-True/2288046/__pycache__/helperfunctions.cpython-37.pyc new file mode 100644 index 0000000..00f9bfd --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288046/__pycache__/helperfunctions.cpython-37.pyc Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288046/__pycache__/pdg_const1.cpython-37.pyc b/data/CLs/finished/f1d1/-+/D-True/2288046/__pycache__/pdg_const1.cpython-37.pyc new file mode 100644 index 0000000..4d67e90 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288046/__pycache__/pdg_const1.cpython-37.pyc Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288046/data/CLs/0.0001-0.003_20s--CLs_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288046/data/CLs/0.0001-0.003_20s--CLs_list.pkl new file mode 100644 index 0000000..fd93b00 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288046/data/CLs/0.0001-0.003_20s--CLs_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288046/data/CLs/0.0001-0.003_20s1b1t--CLs_Nll_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288046/data/CLs/0.0001-0.003_20s1b1t--CLs_Nll_list.pkl new file mode 100644 index 0000000..1f5c8de --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288046/data/CLs/0.0001-0.003_20s1b1t--CLs_Nll_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288046/data/CLs/0.0001-0.003_20s1b1t--Ctt_error_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288046/data/CLs/0.0001-0.003_20s1b1t--Ctt_error_list.pkl new file mode 100644 index 0000000..97e028b --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288046/data/CLs/0.0001-0.003_20s1b1t--Ctt_error_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288046/data/CLs/0.0001-0.003_20s1b1t--Ctt_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288046/data/CLs/0.0001-0.003_20s1b1t--Ctt_list.pkl new file mode 100644 index 0000000..99cb58e --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288046/data/CLs/0.0001-0.003_20s1b1t--Ctt_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288046/data/CLs/0.0001-0.003_20s1b1t--pull_dic.pkl b/data/CLs/finished/f1d1/-+/D-True/2288046/data/CLs/0.0001-0.003_20s1b1t--pull_dic.pkl new file mode 100644 index 0000000..343e61b --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288046/data/CLs/0.0001-0.003_20s1b1t--pull_dic.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288046/data/CLs/variab.pkl b/data/CLs/finished/f1d1/-+/D-True/2288046/data/CLs/variab.pkl new file mode 100644 index 0000000..bb90dc0 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288046/data/CLs/variab.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288046/helperfunctions.py b/data/CLs/finished/f1d1/-+/D-True/2288046/helperfunctions.py new file mode 100644 index 0000000..88e120f --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288046/helperfunctions.py @@ -0,0 +1,33 @@ +# some helperfunctions + +import matplotlib +matplotlib.use("agg") +import matplotlib.pyplot as plt + +#Dislpay time (e.g. while generating points) + +display_intervals = ( + ('w', 604800), # 60 * 60 * 24 * 7 + ('d', 86400), # 60 * 60 * 24 + ('h', 3600), # 60 * 60 + ('min', 60), + ('s', 1), + ) + +def display_time(seconds, granularity=2): + result = [] + + for name, count in display_intervals: + value = seconds // count + if value: + seconds -= value * count + if value == 1: + name = name.rstrip('s') + result.append("{} {}".format(value, name)) + return ', '.join(result[:granularity]) + +def prepare_plot(title): + plt.title(title) + plt.grid() + plt.legend(loc = 'best') + plt.xlabel("q") diff --git a/data/CLs/finished/f1d1/-+/D-True/2288046/pdg_const1.py b/data/CLs/finished/f1d1/-+/D-True/2288046/pdg_const1.py new file mode 100644 index 0000000..70b3f30 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288046/pdg_const1.py @@ -0,0 +1,226 @@ +pdg = { + + + ###Particle masses### + + "mbstar" : 5415.4, + "mbstar0" : 5711.0, + "B0_M" : 5279.5, + "Bs_M" : 5366.7, + "Bplus_M" : 5279.3, + "Lb_M" : 5619.4, + "D0_M" : 1864.8, + "Dst_M" : 2010, + "pi_M" : 139.6, + "Jpsi_M" : 3096.9, + "Psi2s_M" : 3685.6, + "kaon_M" : 493.7, + "Ks_M" : 497.6, + "phi_M" : 1019.5, + "rho_M" : 775.26, + "rho_width" : 149.1, + "omega_M" : 782.65, + "omega_width" : 8.49, + + "muon_M" : 105.7, + "tau_M": 1776.86, + + "squark_M" : 95.0, + "bquark_M" : 4180.0, + "cquark_M" : 1275.0, + + "Bplus_tau" : 1.638e-12, + + ###Wilson coefficients### + + "C1" : -0.257, + "C2" : 1.009, + "C3" : -0.005, + "C4" : -0.078, + + "C7eff" : -0.306, + "C9eff" : 4.211, + "C10eff" : -4.103, + +# "C7eff": 0.0, +# "C9eff": 0.0, +# "C10eff": 0.0, + + ###Other constants + + "GF" : 1.1663787e-5, + "alpha_ew" : 1.0/137.0, + "Vts" : 0.0394, + "Vtb" : 1.019, + "number_of_decays": 5404696, + + #Formfactor z coefficients + + #"b0" : [0.285, 0.19, -0.17], + #"bplus" : [0.437, -1.41, -2.5], + #"bT" : [0.440, -1.47, -2.7] + + "b0" : [0.292, 0.281, 0.150], + "bplus" : [0.466, -0.885, -0.213], + "bT" : [0.460, -1.089, -1.114], + + "NR_BR": 4.37e-7, + "NR_auc": 0.00133, + + #Resonances format(mass, width, phase, scale) + + # pre scaling + +# "rho": (775.26, 149.0, -0.35, 1.0), + +# "omega": (782.7, 8.5, 0.26, 1.0), + +# "phi": (1019.46, 4.25, 0.5, 1.0), + +# "jpsi": (3096.0, 0.09, -1.5, 2e-2), +# "jpsi_auc": 0.2126825758464027, + +# "psi2s": (3686.0, 0.3, -1.5, 3.14e-3), +# "psi2s_auc": 2.802257483178487e-10, + +# "p3770": (3773.0, 27.2, -2.13, 1.0e-3), + +# "p4040": (4039.0, 80.0, -2.52, 2.0), + +# "p4160": (4191.0, 70.0, -1.9, 2.2), + +# "p4415": (4421.0, 62.0, -2.52, 1.0), + + + # after scaling (Phase combination --) + + # + # "rho": (743.2, 149.0, -0.22, 1.05), + # + # "omega": (782.7, 8.5, 0.38, 6.8), + # + # "phi": (1013.5, 4.25, 0.62, 19.2), + # + # "jpsi": (3096.1, 0.09, 1.63, 9897.0), + # "jpsi_auc": 0.2126825758464027, + # "jpsi_phase_unc": 0.05, + # + # "psi2s": (3686.0, 0.3, 1.8, 1396.0), + # "psi2s_auc": 0.0151332263, + # "psi2s_phase_unc": 0.1, + # + # "p3770": (3773.0, 27.2, -2.95, 2.5), + # + # "p4040": (4039.0, 80.0, -2.75, 1.01), + # + # "p4160": (4191.0, 70.0, -2.28, 2.2), + # + # "p4415": (4421.0, 62.0, -2.31, 1.24), + + # Phase combination of paper ++ + +# "rho": (743.2, 149.0, -0.35, 1.05), + +# "omega": (782.7, 8.5, 0.26, 6.8), + +# "phi": (1013.5, 4.25, 0.47, 19.2), + +# "jpsi": (3096.1, 0.09, -1.66, 9897.0), +# "jpsi_auc": 0.2126825758464027, +# "jpsi_phase_unc": 0.05, + +# "psi2s": (3686.0, 0.3, -1.93, 1396.0), +# "psi2s_auc": 0.0151332263, +# "psi2s_phase_unc": 0.1, + +# "p3770": (3773.0, 27.2, -2.13, 2.5), + +# "p4040": (4039.0, 80.0, -2.52, 1.01), + +# "p4160": (4191.0, 70.0, -1.90, 2.2), + +# "p4415": (4421.0, 62.0, -2.52, 1.24), + + # Phase combination of paper +- + +# "rho": (743.2, 149.0, -0.26, 1.05), + +# "omega": (782.7, 8.5, 0.35, 6.8), + +# "phi": (1013.5, 4.25, 0.58, 19.2), + +# "jpsi": (3096.1, 0.09, 1.47, 9897.0), +# "jpsi_auc": 0.2126825758464027, +# "jpsi_phase_unc": 0.05, + +# "psi2s": (3686.0, 0.3, -2.21, 1396.0), +# "psi2s_auc": 0.0151332263, +# "psi2s_phase_unc": 0.1, + +# "p3770": (3773.0, 27.2, -2.140, 2.5), + +# "p4040": (4039.0, 80.0, -2.64, 1.01), + +# "p4160": (4191.0, 70.0, -2.11, 2.2), + +# "p4415": (4421.0, 62.0, -2.42, 1.24), + + # Phase combination of paper -+ + + "rho": (743.2, 149.0, -0.30, 1.05), + + "omega": (782.7, 8.5, 0.30, 6.8), + + "phi": (1013.5, 4.25, 0.51, 19.2), + + "jpsi": (3096.1, 0.09, -1.5, 9897.0), + "jpsi_auc": 0.2126825758464027, + "jpsi_phase_unc": 0.05, + + "psi2s": (3686.0, 0.3, 2.08, 1396.0), + "psi2s_auc": 0.0151332263, + "psi2s_phase_unc": 0.1, + + "p3770": (3773.0, 27.2, -2.89, 2.5), + + "p4040": (4039.0, 80.0, -2.69, 1.01), + + "p4160": (4191.0, 70.0, -2.13, 2.2), + + "p4415": (4421.0, 62.0, -2.43, 1.24), + + + # zeroing resonances + +# "rho": (775.26, 149.0, -0.35, 0.0), +# "omega": (782.7, 8.5, 0.26, 0.0), +# "phi": (1019.46, 4.25, 0.5, 0.0), +# "jpsi": (3096.0, 0.09, -1.5, 0.0), +# "psi2s": (3686.0, 0.3, -1.5, 0.0), +# "p3770": (3773.0, 27.2, -2.13, 0.0), +# "p4040": (4039.0, 80.0, -2.52, 0.0), +# "p4160": (4147.0, 22.0, -1.9, 0.0), +# "p4415": (4421.0, 62.0, -2.52, 0.0), + + # 2P contributions format(mass, amp, phase) + +# "D_bar": ( + + #general + + "rho_BR": 1.7e-10, + "omega_BR": 4.9e-10, + "phi_BR": 2.5e-9, + "jpsi_BR": 6.02e-5, + "psi2s_BR": 4.97e-6, + "p3770_BR": 1.38e-9, + "p4040_BR": 4.2e-10, + "p4160_BR": 2.6e-9, + "p4415_BR": 6.1e-10, + +# Estimates + "Dbar_scale": 1.46, #with phase = pi + + "DDstar_scale": 2.41, #with phase = pi + + } diff --git a/data/CLs/finished/f1d1/-+/D-True/2288046/raremodel-nb.py b/data/CLs/finished/f1d1/-+/D-True/2288046/raremodel-nb.py new file mode 100644 index 0000000..c326c9c --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288046/raremodel-nb.py @@ -0,0 +1,2152 @@ +#!/usr/bin/env python +# coding: utf-8 + +# # Import + +# In[ ]: + + +import os + +# os.environ["CUDA_VISIBLE_DEVICES"] = "-1" +import random +import numpy as np +from pdg_const1 import pdg +import matplotlib +import matplotlib.pyplot as plt +import pickle as pkl +import sys +import time +from helperfunctions import display_time, prepare_plot +import cmath as c +import scipy.integrate as integrate +from scipy.optimize import fminbound +from array import array as arr +import collections +from itertools import compress +import tensorflow as tf +import zfit +from zfit import ztf +# from IPython.display import clear_output +import os +import tensorflow_probability as tfp +tfd = tfp.distributions + + +# In[ ]: + + +# chunksize = 10000 +# zfit.run.chunking.active = True +# zfit.run.chunking.max_n_points = chunksize + + +# # Build model and graphs +# ## Create graphs + +# In[ ]: + + + + + +# In[ ]: + + +def formfactor(q2, subscript, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2): #returns real value + #check if subscript is viable + + if subscript != "0" and subscript != "+" and subscript != "T": + raise ValueError('Wrong subscript entered, choose either 0, + or T') + + #get constants + + mK = ztf.constant(pdg['Ks_M']) + mbstar0 = ztf.constant(pdg["mbstar0"]) + mbstar = ztf.constant(pdg["mbstar"]) + + + mmu = ztf.constant(pdg['muon_M']) + mb = ztf.constant(pdg['bquark_M']) + ms = ztf.constant(pdg['squark_M']) + mB = ztf.constant(pdg['Bplus_M']) + + #N comes from derivation in paper + + N = 3 + + #some helperfunctions + + tpos = (mB - mK)**2 + tzero = (mB + mK)*(ztf.sqrt(mB)-ztf.sqrt(mK))**2 + + z_oben = ztf.sqrt(tpos - q2) - ztf.sqrt(tpos - tzero) + z_unten = ztf.sqrt(tpos - q2) + ztf.sqrt(tpos - tzero) + z = tf.divide(z_oben, z_unten) + + #calculate f0 + + if subscript == "0": + prefactor = 1/(1 - q2/(mbstar0**2)) + _sum = 0 + b0 = [b0_0, b0_1, b0_2] + + for i in range(N): + _sum += b0[i]*(tf.pow(z,i)) + + return ztf.to_complex(prefactor * _sum) + + #calculate f+ or fT + + else: + prefactor = 1/(1 - q2/(mbstar**2)) + _sum = 0 + + if subscript == "T": + bT = [bT_0, bT_1, bT_2] + for i in range(N): + _sum += bT[i] * (tf.pow(z, i) - ((-1)**(i-N)) * (i/N) * tf.pow(z, N)) + else: + bplus = [bplus_0, bplus_1, bplus_2] + for i in range(N): + _sum += bplus[i] * (tf.pow(z, i) - ((-1)**(i-N)) * (i/N) * tf.pow(z, N)) + + return ztf.to_complex(prefactor * _sum) + +def resonance(q, _mass, width, phase, scale): + + q2 = tf.pow(q, 2) + + mmu = ztf.constant(pdg['muon_M']) + + p = 0.5 * ztf.sqrt(q2 - 4*(mmu**2)) + + p0 = 0.5 * ztf.sqrt(_mass**2 - 4*mmu**2) + + gamma_j = tf.divide(p, q) * _mass * width / p0 + + #Calculate the resonance + + _top = tf.complex(_mass * width, ztf.constant(0.0)) + + _bottom = tf.complex(_mass**2 - q2, -_mass*gamma_j) + + com = _top/_bottom + + #Rotate by the phase + + r = ztf.to_complex(scale*tf.abs(com)) + + _phase = tf.angle(com) + + _phase += phase + + com = r * tf.exp(tf.complex(ztf.constant(0.0), _phase)) + + return com + + +def axiv_nonres(q, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2): + + GF = ztf.constant(pdg['GF']) + alpha_ew = ztf.constant(pdg['alpha_ew']) + Vtb = ztf.constant(pdg['Vtb']) + Vts = ztf.constant(pdg['Vts']) + C10eff = ztf.constant(pdg['C10eff']) + + mmu = ztf.constant(pdg['muon_M']) + mb = ztf.constant(pdg['bquark_M']) + ms = ztf.constant(pdg['squark_M']) + mK = ztf.constant(pdg['Ks_M']) + mB = ztf.constant(pdg['Bplus_M']) + + q2 = tf.pow(q, 2) + + #Some helperfunctions + + beta = 1. - 4. * mmu**2. / q2 + + kabs = ztf.sqrt(mB**2. + tf.pow(q2, 2)/mB**2. + mK**4./mB**2. - 2. * (mB**2. * mK**2. + mK**2. * q2 + mB**2. * q2) / mB**2.) + + #prefactor in front of whole bracket + + prefactor1 = GF**2. *alpha_ew**2. * (tf.abs(Vtb*Vts))**2. * kabs * beta / (128. * np.pi**5.) + + #left term in bracket + + bracket_left = 2./3. * tf.pow(kabs,2) * tf.pow(beta,2) * tf.pow(tf.abs(ztf.to_complex(C10eff)*formfactor(q2, "+", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2)),2) + + #middle term in bracket + + _top = 4. * mmu**2. * (mB**2. - mK**2.) * (mB**2. - mK**2.) + + _under = q2 * mB**2. + + bracket_middle = _top/_under *tf.pow(tf.abs(ztf.to_complex(C10eff) * formfactor(q2, "0", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2)), 2) + + #Note sqrt(q2) comes from derivation as we use q2 and plot q + + return prefactor1 * (bracket_left + bracket_middle) * 2 * q + +def vec(q, funcs, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2): + + q2 = tf.pow(q, 2) + + GF = ztf.constant(pdg['GF']) + alpha_ew = ztf.constant(pdg['alpha_ew']) + Vtb = ztf.constant(pdg['Vtb']) + Vts = ztf.constant(pdg['Vts']) + C7eff = ztf.constant(pdg['C7eff']) + + mmu = ztf.constant(pdg['muon_M']) + mb = ztf.constant(pdg['bquark_M']) + ms = ztf.constant(pdg['squark_M']) + mK = ztf.constant(pdg['Ks_M']) + mB = ztf.constant(pdg['Bplus_M']) + + #Some helperfunctions + + beta = 1. - 4. * mmu**2. / q2 + + kabs = ztf.sqrt(mB**2. + tf.pow(q2, 2)/mB**2. + mK**4./mB**2. - 2 * (mB**2 * mK**2 + mK**2 * q2 + mB**2 * q2) / mB**2) + + #prefactor in front of whole bracket + + prefactor1 = GF**2. *alpha_ew**2. * (tf.abs(Vtb*Vts))**2 * kabs * beta / (128. * np.pi**5.) + + #right term in bracket + + prefactor2 = tf.pow(kabs,2) * (1. - 1./3. * beta) + + abs_bracket = tf.pow(tf.abs(c9eff(q, funcs) * formfactor(q2, "+", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + ztf.to_complex(2.0 * C7eff * (mb + ms)/(mB + mK)) * formfactor(q2, "T", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2)),2) + + bracket_right = prefactor2 * abs_bracket + + #Note sqrt(q2) comes from derivation as we use q2 and plot q + + return prefactor1 * bracket_right * 2 * q + +def c9eff(q, funcs): + + C9eff_nr = ztf.to_complex(ztf.constant(pdg['C9eff'])) + + c9 = C9eff_nr + funcs + + return c9 + + +# In[ ]: + + +def G(y): + + def inner_rect_bracket(q): + return tf.log(ztf.to_complex((1+tf.sqrt(q))/(1-tf.sqrt(q)))-tf.complex(ztf.constant(0), -1*ztf.constant(np.pi))) + + def inner_right(q): + return ztf.to_complex(2 * tf.atan(1/tf.sqrt(tf.math.real(-q)))) + + big_bracket = tf.where(tf.math.real(y) > ztf.constant(0.0), inner_rect_bracket(y), inner_right(y)) + + return ztf.to_complex(tf.sqrt(tf.abs(y))) * big_bracket + +def h_S(m, q): + + return ztf.to_complex(2) - G(ztf.to_complex(1) - ztf.to_complex(4*tf.pow(m, 2)) / ztf.to_complex(tf.pow(q, 2))) + +def h_P(m, q): + + return ztf.to_complex(2/3) + (ztf.to_complex(1) - ztf.to_complex(4*tf.pow(m, 2)) / ztf.to_complex(tf.pow(q, 2))) * h_S(m,q) + +def two_p_ccbar(mD, m_D_bar, m_D_star, q): + + + #Load constants + nu_D_bar = ztf.to_complex(pdg["nu_D_bar"]) + nu_D = ztf.to_complex(pdg["nu_D"]) + nu_D_star = ztf.to_complex(pdg["nu_D_star"]) + + phase_D_bar = ztf.to_complex(pdg["phase_D_bar"]) + phase_D = ztf.to_complex(pdg["phase_D"]) + phase_D_star = ztf.to_complex(pdg["phase_D_star"]) + + #Calculation + left_part = nu_D_bar * tf.exp(tf.complex(ztf.constant(0.0), phase_D_bar)) * h_S(m_D_bar, q) + + right_part_D = nu_D * tf.exp(tf.complex(ztf.constant(0.0), phase_D)) * h_P(m_D, q) + + right_part_D_star = nu_D_star * tf.exp(tf.complex(ztf.constant(0.0), phase_D_star)) * h_P(m_D_star, q) + + return left_part + right_part_D + right_part_D_star + + +# ## Build pdf + +# In[ ]: + + +class total_pdf_cut(zfit.pdf.ZPDF): + _N_OBS = 1 # dimension, can be omitted + _PARAMS = ['b0_0', 'b0_1', 'b0_2', + 'bplus_0', 'bplus_1', 'bplus_2', + 'bT_0', 'bT_1', 'bT_2', + 'rho_mass', 'rho_scale', 'rho_phase', 'rho_width', + 'jpsi_mass', 'jpsi_scale', 'jpsi_phase', 'jpsi_width', + 'psi2s_mass', 'psi2s_scale', 'psi2s_phase', 'psi2s_width', + 'p3770_mass', 'p3770_scale', 'p3770_phase', 'p3770_width', + 'p4040_mass', 'p4040_scale', 'p4040_phase', 'p4040_width', + 'p4160_mass', 'p4160_scale', 'p4160_phase', 'p4160_width', + 'p4415_mass', 'p4415_scale', 'p4415_phase', 'p4415_width', + 'omega_mass', 'omega_scale', 'omega_phase', 'omega_width', + 'phi_mass', 'phi_scale', 'phi_phase', 'phi_width', + 'Dbar_mass', 'Dbar_scale', 'Dbar_phase', + 'Dstar_mass', 'DDstar_scale', 'DDstar_phase', 'D_mass', + 'tau_mass', 'C_tt'] +# the name of the parameters + + def _unnormalized_pdf(self, x): + + x = x.unstack_x() + + b0 = [self.params['b0_0'], self.params['b0_1'], self.params['b0_2']] + bplus = [self.params['bplus_0'], self.params['bplus_1'], self.params['bplus_2']] + bT = [self.params['bT_0'], self.params['bT_1'], self.params['bT_2']] + + def rho_res(q): + return resonance(q, _mass = self.params['rho_mass'], scale = self.params['rho_scale'], + phase = self.params['rho_phase'], width = self.params['rho_width']) + + def omega_res(q): + return resonance(q, _mass = self.params['omega_mass'], scale = self.params['omega_scale'], + phase = self.params['omega_phase'], width = self.params['omega_width']) + + def phi_res(q): + return resonance(q, _mass = self.params['phi_mass'], scale = self.params['phi_scale'], + phase = self.params['phi_phase'], width = self.params['phi_width']) + + def jpsi_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['jpsi_mass'], 2)) * resonance(q, _mass = self.params['jpsi_mass'], + scale = self.params['jpsi_scale'], + phase = self.params['jpsi_phase'], + width = self.params['jpsi_width']) + def psi2s_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['psi2s_mass'], 2)) * resonance(q, _mass = self.params['psi2s_mass'], + scale = self.params['psi2s_scale'], + phase = self.params['psi2s_phase'], + width = self.params['psi2s_width']) + def p3770_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p3770_mass'], 2)) * resonance(q, _mass = self.params['p3770_mass'], + scale = self.params['p3770_scale'], + phase = self.params['p3770_phase'], + width = self.params['p3770_width']) + + def p4040_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4040_mass'], 2)) * resonance(q, _mass = self.params['p4040_mass'], + scale = self.params['p4040_scale'], + phase = self.params['p4040_phase'], + width = self.params['p4040_width']) + + def p4160_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4160_mass'], 2)) * resonance(q, _mass = self.params['p4160_mass'], + scale = self.params['p4160_scale'], + phase = self.params['p4160_phase'], + width = self.params['p4160_width']) + + def p4415_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4415_mass'], 2)) * resonance(q, _mass = self.params['p4415_mass'], + scale = self.params['p4415_scale'], + phase = self.params['p4415_phase'], + width = self.params['p4415_width']) + + def P2_D(q): + Dbar_contrib = ztf.to_complex(self.params['Dbar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['Dbar_phase']))*ztf.to_complex(h_S(self.params['Dbar_mass'], q)) + DDstar_contrib = ztf.to_complex(self.params['DDstar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['DDstar_phase']))*(ztf.to_complex(h_P(self.params['Dstar_mass'], q)) + ztf.to_complex(h_P(self.params['D_mass'], q))) + return Dbar_contrib + DDstar_contrib + + def ttau_cusp(q): + return ztf.to_complex(self.params['C_tt'])*(ztf.to_complex((h_S(self.params['tau_mass'], q))) - ztf.to_complex(h_P(self.params['tau_mass'], q))) + + + funcs = rho_res(x) + omega_res(x) + phi_res(x) + jpsi_res(x) + psi2s_res(x) + p3770_res(x) + p4040_res(x)+ p4160_res(x) + p4415_res(x) + P2_D(x) + ttau_cusp(x) + + vec_f = vec(x, funcs, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + axiv_nr = axiv_nonres(x, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + tot = vec_f + axiv_nr + + #Cut out jpsi and psi2s + + tot = tf.where(tf.math.logical_or(x < ztf.constant(jpsi_mass-60.), x > ztf.constant(jpsi_mass+70.)), tot, 0.0*tot) + + tot = tf.where(tf.math.logical_or(x < ztf.constant(psi2s_mass-50.), x > ztf.constant(psi2s_mass+50.)), tot, 0.0*tot) + + return tot + +class total_pdf_full(zfit.pdf.ZPDF): + _N_OBS = 1 # dimension, can be omitted + _PARAMS = ['b0_0', 'b0_1', 'b0_2', + 'bplus_0', 'bplus_1', 'bplus_2', + 'bT_0', 'bT_1', 'bT_2', + 'rho_mass', 'rho_scale', 'rho_phase', 'rho_width', + 'jpsi_mass', 'jpsi_scale', 'jpsi_phase', 'jpsi_width', + 'psi2s_mass', 'psi2s_scale', 'psi2s_phase', 'psi2s_width', + 'p3770_mass', 'p3770_scale', 'p3770_phase', 'p3770_width', + 'p4040_mass', 'p4040_scale', 'p4040_phase', 'p4040_width', + 'p4160_mass', 'p4160_scale', 'p4160_phase', 'p4160_width', + 'p4415_mass', 'p4415_scale', 'p4415_phase', 'p4415_width', + 'omega_mass', 'omega_scale', 'omega_phase', 'omega_width', + 'phi_mass', 'phi_scale', 'phi_phase', 'phi_width', + 'Dbar_mass', 'Dbar_scale', 'Dbar_phase', + 'Dstar_mass', 'DDstar_scale', 'DDstar_phase', 'D_mass', + 'tau_mass', 'C_tt'] +# the name of the parameters + + def _unnormalized_pdf(self, x): + + x = x.unstack_x() + + b0 = [self.params['b0_0'], self.params['b0_1'], self.params['b0_2']] + bplus = [self.params['bplus_0'], self.params['bplus_1'], self.params['bplus_2']] + bT = [self.params['bT_0'], self.params['bT_1'], self.params['bT_2']] + + def rho_res(q): + return resonance(q, _mass = self.params['rho_mass'], scale = self.params['rho_scale'], + phase = self.params['rho_phase'], width = self.params['rho_width']) + + def omega_res(q): + return resonance(q, _mass = self.params['omega_mass'], scale = self.params['omega_scale'], + phase = self.params['omega_phase'], width = self.params['omega_width']) + + def phi_res(q): + return resonance(q, _mass = self.params['phi_mass'], scale = self.params['phi_scale'], + phase = self.params['phi_phase'], width = self.params['phi_width']) + + def jpsi_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['jpsi_mass'], 2)) * resonance(q, _mass = self.params['jpsi_mass'], + scale = self.params['jpsi_scale'], + phase = self.params['jpsi_phase'], + width = self.params['jpsi_width']) + def psi2s_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['psi2s_mass'], 2)) * resonance(q, _mass = self.params['psi2s_mass'], + scale = self.params['psi2s_scale'], + phase = self.params['psi2s_phase'], + width = self.params['psi2s_width']) + def p3770_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p3770_mass'], 2)) * resonance(q, _mass = self.params['p3770_mass'], + scale = self.params['p3770_scale'], + phase = self.params['p3770_phase'], + width = self.params['p3770_width']) + + def p4040_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4040_mass'], 2)) * resonance(q, _mass = self.params['p4040_mass'], + scale = self.params['p4040_scale'], + phase = self.params['p4040_phase'], + width = self.params['p4040_width']) + + def p4160_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4160_mass'], 2)) * resonance(q, _mass = self.params['p4160_mass'], + scale = self.params['p4160_scale'], + phase = self.params['p4160_phase'], + width = self.params['p4160_width']) + + def p4415_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4415_mass'], 2)) * resonance(q, _mass = self.params['p4415_mass'], + scale = self.params['p4415_scale'], + phase = self.params['p4415_phase'], + width = self.params['p4415_width']) + + def P2_D(q): + Dbar_contrib = ztf.to_complex(self.params['Dbar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['Dbar_phase']))*ztf.to_complex(h_S(self.params['Dbar_mass'], q)) + DDstar_contrib = ztf.to_complex(self.params['DDstar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['DDstar_phase']))*(ztf.to_complex(h_P(self.params['Dstar_mass'], q)) + ztf.to_complex(h_P(self.params['D_mass'], q))) + return Dbar_contrib + DDstar_contrib + + def ttau_cusp(q): + return ztf.to_complex(self.params['C_tt'])*(ztf.to_complex((h_S(self.params['tau_mass'], q))) - ztf.to_complex(h_P(self.params['tau_mass'], q))) + + + funcs = rho_res(x) + omega_res(x) + phi_res(x) + jpsi_res(x) + psi2s_res(x) + p3770_res(x) + p4040_res(x)+ p4160_res(x) + p4415_res(x) + P2_D(x) + ttau_cusp(x) + + vec_f = vec(x, funcs, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + axiv_nr = axiv_nonres(x, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + tot = vec_f + axiv_nr + + #Cut out jpsi and psi2s + +# tot = tf.where(tf.math.logical_or(x < ztf.constant(jpsi_mass-60.), x > ztf.constant(jpsi_mass+70.)), tot, 0.0*tot) + +# tot = tf.where(tf.math.logical_or(x < ztf.constant(psi2s_mass-50.), x > ztf.constant(psi2s_mass+50.)), tot, 0.0*tot) + + return tot + + +# ## Setup parameters + +# In[ ]: + + +# formfactors + +b0_0 = zfit.Parameter("b0_0", ztf.constant(0.292), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +b0_1 = zfit.Parameter("b0_1", ztf.constant(0.281), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +b0_2 = zfit.Parameter("b0_2", ztf.constant(0.150), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) + +bplus_0 = zfit.Parameter("bplus_0", ztf.constant(0.466), lower_limit = -2.0, upper_limit= 2.0) +bplus_1 = zfit.Parameter("bplus_1", ztf.constant(-0.885), lower_limit = -2.0, upper_limit= 2.0) +bplus_2 = zfit.Parameter("bplus_2", ztf.constant(-0.213), lower_limit = -2.0, upper_limit= 2.0) + +bT_0 = zfit.Parameter("bT_0", ztf.constant(0.460), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +bT_1 = zfit.Parameter("bT_1", ztf.constant(-1.089), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +bT_2 = zfit.Parameter("bT_2", ztf.constant(-1.114), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) + + +#rho + +rho_mass, rho_width, rho_phase, rho_scale = pdg["rho"] + +rho_m = zfit.Parameter("rho_m", ztf.constant(rho_mass), floating = False) #lower_limit = rho_mass - rho_width, upper_limit = rho_mass + rho_width) +rho_w = zfit.Parameter("rho_w", ztf.constant(rho_width), floating = False) +rho_p = zfit.Parameter("rho_p", ztf.constant(rho_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +rho_s = zfit.Parameter("rho_s", ztf.constant(rho_scale), lower_limit=rho_scale-np.sqrt(rho_scale), upper_limit=rho_scale+np.sqrt(rho_scale)) + +#omega + +omega_mass, omega_width, omega_phase, omega_scale = pdg["omega"] + +omega_m = zfit.Parameter("omega_m", ztf.constant(omega_mass), floating = False) +omega_w = zfit.Parameter("omega_w", ztf.constant(omega_width), floating = False) +omega_p = zfit.Parameter("omega_p", ztf.constant(omega_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +omega_s = zfit.Parameter("omega_s", ztf.constant(omega_scale), lower_limit=omega_scale-np.sqrt(omega_scale), upper_limit=omega_scale+np.sqrt(omega_scale)) + + +#phi + +phi_mass, phi_width, phi_phase, phi_scale = pdg["phi"] + +phi_m = zfit.Parameter("phi_m", ztf.constant(phi_mass), floating = False) +phi_w = zfit.Parameter("phi_w", ztf.constant(phi_width), floating = False) +phi_p = zfit.Parameter("phi_p", ztf.constant(phi_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +phi_s = zfit.Parameter("phi_s", ztf.constant(phi_scale), lower_limit=phi_scale-np.sqrt(phi_scale), upper_limit=phi_scale+np.sqrt(phi_scale)) + +#jpsi + +jpsi_mass, jpsi_width, jpsi_phase, jpsi_scale = pdg["jpsi"] + +jpsi_m = zfit.Parameter("jpsi_m", ztf.constant(jpsi_mass), floating = False) +jpsi_w = zfit.Parameter("jpsi_w", ztf.constant(jpsi_width), floating = False) +jpsi_p = zfit.Parameter("jpsi_p", ztf.constant(jpsi_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +jpsi_s = zfit.Parameter("jpsi_s", ztf.constant(jpsi_scale), floating = False) #, lower_limit=jpsi_scale-np.sqrt(jpsi_scale), upper_limit=jpsi_scale+np.sqrt(jpsi_scale)) + +#psi2s + +psi2s_mass, psi2s_width, psi2s_phase, psi2s_scale = pdg["psi2s"] + +psi2s_m = zfit.Parameter("psi2s_m", ztf.constant(psi2s_mass), floating = False) +psi2s_w = zfit.Parameter("psi2s_w", ztf.constant(psi2s_width), floating = False) +psi2s_p = zfit.Parameter("psi2s_p", ztf.constant(psi2s_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +psi2s_s = zfit.Parameter("psi2s_s", ztf.constant(psi2s_scale), floating = False) #, lower_limit=psi2s_scale-np.sqrt(psi2s_scale), upper_limit=psi2s_scale+np.sqrt(psi2s_scale)) + +#psi(3770) + +p3770_mass, p3770_width, p3770_phase, p3770_scale = pdg["p3770"] + +p3770_m = zfit.Parameter("p3770_m", ztf.constant(p3770_mass), floating = False) +p3770_w = zfit.Parameter("p3770_w", ztf.constant(p3770_width), floating = False) +p3770_p = zfit.Parameter("p3770_p", ztf.constant(p3770_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p3770_s = zfit.Parameter("p3770_s", ztf.constant(p3770_scale), lower_limit=p3770_scale-np.sqrt(p3770_scale), upper_limit=p3770_scale+np.sqrt(p3770_scale)) + +#psi(4040) + +p4040_mass, p4040_width, p4040_phase, p4040_scale = pdg["p4040"] + +p4040_m = zfit.Parameter("p4040_m", ztf.constant(p4040_mass), floating = False) +p4040_w = zfit.Parameter("p4040_w", ztf.constant(p4040_width), floating = False) +p4040_p = zfit.Parameter("p4040_p", ztf.constant(p4040_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p4040_s = zfit.Parameter("p4040_s", ztf.constant(p4040_scale), lower_limit=p4040_scale-np.sqrt(p4040_scale), upper_limit=p4040_scale+np.sqrt(p4040_scale)) + +#psi(4160) + +p4160_mass, p4160_width, p4160_phase, p4160_scale = pdg["p4160"] + +p4160_m = zfit.Parameter("p4160_m", ztf.constant(p4160_mass), floating = False) +p4160_w = zfit.Parameter("p4160_w", ztf.constant(p4160_width), floating = False) +p4160_p = zfit.Parameter("p4160_p", ztf.constant(p4160_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p4160_s = zfit.Parameter("p4160_s", ztf.constant(p4160_scale), lower_limit=p4160_scale-np.sqrt(p4160_scale), upper_limit=p4160_scale+np.sqrt(p4160_scale)) + +#psi(4415) + +p4415_mass, p4415_width, p4415_phase, p4415_scale = pdg["p4415"] + +p4415_m = zfit.Parameter("p4415_m", ztf.constant(p4415_mass), floating = False) +p4415_w = zfit.Parameter("p4415_w", ztf.constant(p4415_width), floating = False) +p4415_p = zfit.Parameter("p4415_p", ztf.constant(p4415_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p4415_s = zfit.Parameter("p4415_s", ztf.constant(p4415_scale), lower_limit=p4415_scale-np.sqrt(p4415_scale), upper_limit=p4415_scale+np.sqrt(p4415_scale)) + + +# ## Dynamic generation of 2 particle contribution + +# In[ ]: + + +m_c = 1300 + +Dbar_phase = 0.0 +DDstar_phase = 0.0 +Dstar_mass = pdg['Dst_M'] +Dbar_mass = pdg['D0_M'] +D_mass = pdg['D0_M'] + +Dbar_s = zfit.Parameter("Dbar_s", ztf.constant(0.0), lower_limit=-0.3, upper_limit=0.3) +Dbar_m = zfit.Parameter("Dbar_m", ztf.constant(Dbar_mass), floating = False) +Dbar_p = zfit.Parameter("Dbar_p", ztf.constant(Dbar_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi)#, floating = False) +DDstar_s = zfit.Parameter("DDstar_s", ztf.constant(0.0), lower_limit=-0.3, upper_limit=0.3)#, floating = False) +Dstar_m = zfit.Parameter("Dstar_m", ztf.constant(Dstar_mass), floating = False) +D_m = zfit.Parameter("D_m", ztf.constant(D_mass), floating = False) +DDstar_p = zfit.Parameter("DDstar_p", ztf.constant(DDstar_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi)#, floating = False) + + +# ## Tau parameters + +# In[ ]: + + +tau_m = zfit.Parameter("tau_m", ztf.constant(pdg['tau_M']), floating = False) +Ctt = zfit.Parameter("Ctt", ztf.constant(0.0), lower_limit=-2.5, upper_limit=2.5) + + +# ## Load data + +# In[ ]: + + +x_min = 2*pdg['muon_M'] +x_max = (pdg["Bplus_M"]-pdg["Ks_M"]-0.1) + +# # Full spectrum + +obs_toy = zfit.Space('q', limits = (x_min, x_max)) + +# Jpsi and Psi2s cut out + +obs1 = zfit.Space('q', limits = (x_min, jpsi_mass - 60.)) +obs2 = zfit.Space('q', limits = (jpsi_mass + 70., psi2s_mass - 50.)) +obs3 = zfit.Space('q', limits = (psi2s_mass + 50., x_max)) + +obs_fit = obs1 + obs2 + obs3 + +# with open(r"./data/slim_points/slim_points_toy_0_range({0}-{1}).pkl".format(int(x_min), int(x_max)), "rb") as input_file: +# part_set = pkl.load(input_file) + +# x_part = part_set['x_part'] + +# x_part = x_part.astype('float64') + +# data = zfit.data.Data.from_numpy(array=x_part, obs=obs) + + +# ## Setup pdf + +# In[ ]: + + +total_f = total_pdf_cut(obs=obs_toy, jpsi_mass = jpsi_m, jpsi_scale = jpsi_s, jpsi_phase = jpsi_p, jpsi_width = jpsi_w, + psi2s_mass = psi2s_m, psi2s_scale = psi2s_s, psi2s_phase = psi2s_p, psi2s_width = psi2s_w, + p3770_mass = p3770_m, p3770_scale = p3770_s, p3770_phase = p3770_p, p3770_width = p3770_w, + p4040_mass = p4040_m, p4040_scale = p4040_s, p4040_phase = p4040_p, p4040_width = p4040_w, + p4160_mass = p4160_m, p4160_scale = p4160_s, p4160_phase = p4160_p, p4160_width = p4160_w, + p4415_mass = p4415_m, p4415_scale = p4415_s, p4415_phase = p4415_p, p4415_width = p4415_w, + rho_mass = rho_m, rho_scale = rho_s, rho_phase = rho_p, rho_width = rho_w, + omega_mass = omega_m, omega_scale = omega_s, omega_phase = omega_p, omega_width = omega_w, + phi_mass = phi_m, phi_scale = phi_s, phi_phase = phi_p, phi_width = phi_w, + Dstar_mass = Dstar_m, DDstar_scale = DDstar_s, DDstar_phase = DDstar_p, D_mass = D_m, + Dbar_mass = Dbar_m, Dbar_scale = Dbar_s, Dbar_phase = Dbar_p, + tau_mass = tau_m, C_tt = Ctt, b0_0 = b0_0, b0_1 = b0_1, b0_2 = b0_2, + bplus_0 = bplus_0, bplus_1 = bplus_1, bplus_2 = bplus_2, + bT_0 = bT_0, bT_1 = bT_1, bT_2 = bT_2) + +total_f_fit = total_pdf_full(obs=obs_fit, jpsi_mass = jpsi_m, jpsi_scale = jpsi_s, jpsi_phase = jpsi_p, jpsi_width = jpsi_w, + psi2s_mass = psi2s_m, psi2s_scale = psi2s_s, psi2s_phase = psi2s_p, psi2s_width = psi2s_w, + p3770_mass = p3770_m, p3770_scale = p3770_s, p3770_phase = p3770_p, p3770_width = p3770_w, + p4040_mass = p4040_m, p4040_scale = p4040_s, p4040_phase = p4040_p, p4040_width = p4040_w, + p4160_mass = p4160_m, p4160_scale = p4160_s, p4160_phase = p4160_p, p4160_width = p4160_w, + p4415_mass = p4415_m, p4415_scale = p4415_s, p4415_phase = p4415_p, p4415_width = p4415_w, + rho_mass = rho_m, rho_scale = rho_s, rho_phase = rho_p, rho_width = rho_w, + omega_mass = omega_m, omega_scale = omega_s, omega_phase = omega_p, omega_width = omega_w, + phi_mass = phi_m, phi_scale = phi_s, phi_phase = phi_p, phi_width = phi_w, + Dstar_mass = Dstar_m, DDstar_scale = DDstar_s, DDstar_phase = DDstar_p, D_mass = D_m, + Dbar_mass = Dbar_m, Dbar_scale = Dbar_s, Dbar_phase = Dbar_p, + tau_mass = tau_m, C_tt = Ctt, b0_0 = b0_0, b0_1 = b0_1, b0_2 = b0_2, + bplus_0 = bplus_0, bplus_1 = bplus_1, bplus_2 = bplus_2, + bT_0 = bT_0, bT_1 = bT_1, bT_2 = bT_2) + +# print(total_pdf.obs) + +# print(calcs_test) + +# for param in total_f.get_dependents(): +# print(zfit.run(param)) + + +# In[ ]: + + +# total_f_fit.normalization(obs_fit) + + +# ## Test if graphs actually work and compute values + +# In[ ]: + + +# def total_test_tf(xq): + +# def jpsi_res(q): +# return resonance(q, jpsi_m, jpsi_s, jpsi_p, jpsi_w) + +# def psi2s_res(q): +# return resonance(q, psi2s_m, psi2s_s, psi2s_p, psi2s_w) + +# def cusp(q): +# return bifur_gauss(q, cusp_m, sig_L, sig_R, cusp_s) + +# funcs = jpsi_res(xq) + psi2s_res(xq) + cusp(xq) + +# vec_f = vec(xq, funcs) + +# axiv_nr = axiv_nonres(xq) + +# tot = vec_f + axiv_nr + +# return tot + +# def jpsi_res(q): +# return resonance(q, jpsi_m, jpsi_s, jpsi_p, jpsi_w) + +# calcs = zfit.run(total_test_tf(x_part)) + + + +test_q = np.linspace(x_min, x_max, int(2e6)) + +probs = total_f_fit.pdf(test_q, norm_range=False) + +calcs_test = zfit.run(probs) + +Ctt.set_value(0.5) + +calcs_test1 = zfit.run(probs) + +Ctt.set_value(0.0) + +Dbar_s.set_value(0.3) + +DDstar_s.set_value(0.3) + +calcs_test2 = zfit.run(probs) +# res_y = zfit.run(jpsi_res(test_q)) +# b0 = [b0_0, b0_1, b0_2] +# bplus = [bplus_0, bplus_1, bplus_2] +# bT = [bT_0, bT_1, bT_2] +# f0_y = zfit.run(tf.math.real(formfactor(test_q,"0", b0, bplus, bT))) +# fplus_y = zfit.run(tf.math.real(formfactor(test_q,"+", b0, bplus, bT))) +# fT_y = zfit.run(tf.math.real(formfactor(test_q,"T", b0, bplus, bT))) + + +# In[ ]: + + +plt.clf() +# plt.plot(x_part, calcs, '.') +plt.plot(test_q, calcs_test, label = 'pdf (Ctt = 0.0)') +plt.plot(test_q, calcs_test1, label = 'pdf (Ctt = 0.5)') +plt.plot(test_q, calcs_test2, label = 'pdf (D-contribs = 0.3)') +# plt.plot(test_q, f0_y, label = '0') +# plt.plot(test_q, fT_y, label = 'T') +# plt.plot(test_q, fplus_y, label = '+') +# plt.plot(test_q, res_y, label = 'res') +plt.legend() +plt.ylim(0.0, 1.5e-6) +# plt.yscale('log') +# plt.xlim(770, 785) +plt.savefig('test.png') +# print(jpsi_width) + + +# In[ ]: + + + + +# probs = mixture.prob(test_q) +# probs_np = zfit.run(probs) +# probs_np *= np.max(calcs_test) / np.max(probs_np) +# plt.figure() +# plt.semilogy(test_q, probs_np,label="importance sampling") +# plt.semilogy(test_q, calcs_test, label = 'pdf') + + +# In[ ]: + + +# 0.213/(0.00133+0.213+0.015) + + +# ## Adjust scaling of different parts + +# In[ ]: + + +total_f.update_integration_options(draws_per_dim=2000000, mc_sampler=None) +# inte = total_f.integrate(limits = (950., 1050.), norm_range=False) +# inte_fl = zfit.run(inte) +# print(inte_fl/4500) +# print(pdg["jpsi_BR"]/pdg["NR_BR"], inte_fl*pdg["psi2s_auc"]/pdg["NR_auc"]) + + +# In[ ]: + + +# # print("jpsi:", inte_fl) +# # print("Increase am by factor:", np.sqrt(pdg["jpsi_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) +# # print("New amp:", pdg["jpsi"][3]*np.sqrt(pdg["jpsi_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) + +# # print("psi2s:", inte_fl) +# # print("Increase am by factor:", np.sqrt(pdg["psi2s_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) +# # print("New amp:", pdg["psi2s"][3]*np.sqrt(pdg["psi2s_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) + +# name = "phi" + +# print(name+":", inte_fl) +# print("Increase am by factor:", np.sqrt(pdg[name+"_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) +# print("New amp:", pdg[name][0]*np.sqrt(pdg[name+"_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) + + +# print(x_min) +# print(x_max) +# # total_f.update_integration_options(draws_per_dim=2000000, mc_sampler=None) +# total_f.update_integration_options(mc_sampler=lambda dim, num_results, +# dtype: tf.random_uniform(maxval=1., shape=(num_results, dim), dtype=dtype), +# draws_per_dim=1000000) +# # _ = [] + +# # for i in range(10): + +# # inte = total_f.integrate(limits = (x_min, x_max)) +# # inte_fl = zfit.run(inte) +# # print(inte_fl) +# # _.append(inte_fl) + +# # print("mean:", np.mean(_)) + +# _ = time.time() + +# inte = total_f.integrate(limits = (x_min, x_max)) +# inte_fl = zfit.run(inte) +# print(inte_fl) +# print("Time taken: {}".format(display_time(int(time.time() - _)))) + +# print(pdg['NR_BR']/pdg['NR_auc']*inte_fl) +# print(0.25**2*4.2/1000) + + +# # Sampling +# ## Mixture distribution for sampling + +# In[ ]: + + + + +# print(list_of_borders[:9]) +# print(list_of_borders[-9:]) + + +class UniformSampleAndWeights(zfit.util.execution.SessionHolderMixin): + def __call__(self, limits, dtype, n_to_produce): + # n_to_produce = tf.cast(n_to_produce, dtype=tf.int32) + low, high = limits.limit1d + low = tf.cast(low, dtype=dtype) + high = tf.cast(high, dtype=dtype) +# uniform = tfd.Uniform(low=low, high=high) +# uniformjpsi = tfd.Uniform(low=tf.constant(3080, dtype=dtype), high=tf.constant(3112, dtype=dtype)) +# uniformpsi2s = tfd.Uniform(low=tf.constant(3670, dtype=dtype), high=tf.constant(3702, dtype=dtype)) + +# list_of_borders = [] +# _p = [] +# splits = 10 + +# _ = np.linspace(x_min, x_max, splits) + +# for i in range(splits): +# list_of_borders.append(tf.constant(_[i], dtype=dtype)) +# _p.append(tf.constant(1/splits, dtype=dtype)) + +# mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=_p[:(splits-1)]), +# components_distribution=tfd.Uniform(low=list_of_borders[:(splits-1)], +# high=list_of_borders[-(splits-1):])) + mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=[tf.constant(0.05, dtype=dtype), + tf.constant(0.93, dtype=dtype), + tf.constant(0.05, dtype=dtype), + tf.constant(0.065, dtype=dtype), + tf.constant(0.04, dtype=dtype), + tf.constant(0.05, dtype=dtype)]), + components_distribution=tfd.Uniform(low=[tf.constant(x_min, dtype=dtype), + tf.constant(3090, dtype=dtype), + tf.constant(3681, dtype=dtype), + tf.constant(3070, dtype=dtype), + tf.constant(1000, dtype=dtype), + tf.constant(3660, dtype=dtype)], + high=[tf.constant(x_max, dtype=dtype), + tf.constant(3102, dtype=dtype), + tf.constant(3691, dtype=dtype), + tf.constant(3110, dtype=dtype), + tf.constant(1040, dtype=dtype), + tf.constant(3710, dtype=dtype)])) +# dtype = tf.float64 +# mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=[tf.constant(0.04, dtype=dtype), +# tf.constant(0.90, dtype=dtype), +# tf.constant(0.02, dtype=dtype), +# tf.constant(0.07, dtype=dtype), +# tf.constant(0.02, dtype=dtype)]), +# components_distribution=tfd.Uniform(low=[tf.constant(x_min, dtype=dtype), +# tf.constant(3089, dtype=dtype), +# tf.constant(3103, dtype=dtype), +# tf.constant(3681, dtype=dtype), +# tf.constant(3691, dtype=dtype)], +# high=[tf.constant(3089, dtype=dtype), +# tf.constant(3103, dtype=dtype), +# tf.constant(3681, dtype=dtype), +# tf.constant(3691, dtype=dtype), +# tf.constant(x_max, dtype=dtype)])) +# mixture = tfd.Uniform(tf.constant(x_min, dtype=dtype), tf.constant(x_max, dtype=dtype)) +# sample = tf.random.uniform((n_to_produce, 1), dtype=dtype) + sample = mixture.sample((n_to_produce, 1)) +# sample = tf.random.uniform((n_to_produce, 1), dtype=dtype) + weights = mixture.prob(sample)[:,0] +# weights = tf.broadcast_to(tf.constant(1., dtype=dtype), shape=(n_to_produce,)) + # sample = tf.expand_dims(sample, axis=-1) +# print(sample, weights) + +# weights = tf.ones(shape=(n_to_produce,), dtype=dtype) + weights_max = None + thresholds = tf.random_uniform(shape=(n_to_produce,), dtype=dtype) + return sample, thresholds, weights, weights_max, n_to_produce + + +# In[ ]: + + +# total_f._sample_and_weights = UniformSampleAndWeights + + +# In[ ]: + + +# 0.00133/(0.00133+0.213+0.015)*(x_max-3750)/(x_max-x_min) + + +# In[ ]: + + +# zfit.settings.set_verbosity(10) + + +# In[ ]: + + +# # zfit.run.numeric_checks = False + +# nr_of_toys = 1 +# nevents = int(pdg["number_of_decays"]) +# nevents = pdg["number_of_decays"] +# event_stack = 1000000 +# # zfit.settings.set_verbosity(10) +# calls = int(nevents/event_stack + 1) + +# total_samp = [] + +# start = time.time() + +# sampler = total_f.create_sampler(n=event_stack) + +# for toy in range(nr_of_toys): + +# dirName = 'data/zfit_toys/toy_{0}'.format(toy) + +# if not os.path.exists(dirName): +# os.mkdir(dirName) +# print("Directory " , dirName , " Created ") + +# for call in range(calls): + +# sampler.resample(n=event_stack) +# s = sampler.unstack_x() +# sam = zfit.run(s) +# # clear_output(wait=True) + +# c = call + 1 + +# print("{0}/{1} of Toy {2}/{3}".format(c, calls, toy+1, nr_of_toys)) +# print("Time taken: {}".format(display_time(int(time.time() - start)))) +# print("Projected time left: {}".format(display_time(int((time.time() - start)/(c+calls*(toy))*((nr_of_toys-toy)*calls-c))))) + +# with open("data/zfit_toys/toy_{0}/{1}.pkl".format(toy, call), "wb") as f: +# pkl.dump(sam, f, pkl.HIGHEST_PROTOCOL) + + +# In[ ]: + + +# with open(r"data/zfit_toys/toy_0/0.pkl", "rb") as input_file: +# sam = pkl.load(input_file) +# print(sam[:10]) + +# with open(r"data/zfit_toys/toy_0/1.pkl", "rb") as input_file: +# sam2 = pkl.load(input_file) +# print(sam2[:10]) + +# print(np.sum(sam-sam2)) + + +# In[ ]: + + +# print("Time to generate full toy: {} s".format(int(time.time()-start))) + +# total_samp = [] + +# for call in range(calls): +# with open(r"data/zfit_toys/toy_0/{}.pkl".format(call), "rb") as input_file: +# sam = pkl.load(input_file) +# total_samp = np.append(total_samp, sam) + +# total_samp = total_samp.astype('float64') + +# data2 = zfit.data.Data.from_numpy(array=total_samp[:int(nevents)], obs=obs) + +# data3 = zfit.data.Data.from_numpy(array=total_samp, obs=obs) + +# print(total_samp[:nevents].shape) + + +# In[ ]: + + +# plt.clf() + +# bins = int((x_max-x_min)/7) + +# # calcs = zfit.run(total_test_tf(samp)) +# print(total_samp[:nevents].shape) + +# plt.hist(total_samp[:nevents], bins = bins, range = (x_min,x_max), label = 'data') +# # plt.plot(test_q, calcs_test*nevents , label = 'pdf') + +# # plt.plot(sam, calcs, '.') +# # plt.plot(test_q, calcs_test) +# # plt.yscale('log') +# plt.ylim(0, 200) +# # plt.xlim(3080, 3110) + +# plt.legend() + +# plt.savefig('test2.png') + + +# In[ ]: + + +# sampler = total_f.create_sampler(n=nevents) +# nll = zfit.loss.UnbinnedNLL(model=total_f, data=sampler, fit_range = (x_min, x_max)) + +# # for param in pdf.get_dependents(): +# # param.set_value(initial_value) + +# sampler.resample(n=nevents) + +# # Randomise initial values +# # for param in pdf.get_dependents(): +# # param.set_value(random value here) + +# # Minimise the NLL +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 10) +# minimum = minimizer.minimize(nll) + + +# In[ ]: + + +# jpsi_width + + +# In[ ]: + + +# plt.hist(sample, weights=1 / prob(sample)) + + +# # Fitting + +# In[ ]: + + +# start = time.time() + +# for param in total_f.get_dependents(): +# param.randomize() + +# # for param in total_f.get_dependents(): +# # print(zfit.run(param)) + +# nll = zfit.loss.UnbinnedNLL(model=total_f, data=data2, fit_range = (x_min, x_max)) + +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) +# # minimizer._use_tfgrad = False +# result = minimizer.minimize(nll) + +# # param_errors = result.error() + +# # for var, errors in param_errors.items(): +# # print('{}: ^{{+{}}}_{{{}}}'.format(var.name, errors['upper'], errors['lower'])) + +# print("Function minimum:", result.fmin) +# # print("Results:", result.params) +# print("Hesse errors:", result.hesse()) + + +# In[ ]: + + +# print("Time taken for fitting: {}".format(display_time(int(time.time()-start)))) + +# # probs = total_f.pdf(test_q) + +# calcs_test = zfit.run(probs) +# res_y = zfit.run(jpsi_res(test_q)) + + +# In[ ]: + + +# plt.clf() +# # plt.plot(x_part, calcs, '.') +# plt.plot(test_q, calcs_test, label = 'pdf') +# # plt.plot(test_q, res_y, label = 'res') +# plt.legend() +# plt.ylim(0.0, 10e-6) +# # plt.yscale('log') +# # plt.xlim(3080, 3110) +# plt.savefig('test3.png') +# # print(jpsi_width) + + +# In[ ]: + + +# _tot = 4.37e-7+6.02e-5+4.97e-6 +# _probs = [] +# _probs.append(6.02e-5/_tot) +# _probs.append(4.97e-6/_tot) +# _probs.append(4.37e-7/_tot) +# print(_probs) + + +# In[ ]: + + +# dtype = 'float64' +# # mixture = tfd.Uniform(tf.constant(x_min, dtype=dtype), tf.constant(x_max, dtype=dtype)) +# mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=[tf.constant(0.007, dtype=dtype), +# tf.constant(0.917, dtype=dtype), +# tf.constant(0.076, dtype=dtype)]), +# components_distribution=tfd.Uniform(low=[tf.constant(x_min, dtype=dtype), +# tf.constant(3080, dtype=dtype), +# tf.constant(3670, dtype=dtype)], +# high=[tf.constant(x_max, dtype=dtype), +# tf.constant(3112, dtype=dtype), +# tf.constant(3702, dtype=dtype)])) +# # for i in range(10): +# # print(zfit.run(mixture.prob(mixture.sample((10, 1))))) + + +# In[ ]: + + +# print((zfit.run(jpsi_p)%(2*np.pi))/np.pi) +# print((zfit.run(psi2s_p)%(2*np.pi))/np.pi) + + +# In[ ]: + + +# def jpsi_res(q): +# return resonance(q, _mass = jpsi_mass, scale = jpsi_scale, +# phase = jpsi_phase, width = jpsi_width) + +# def psi2s_res(q): +# return resonance(q, _mass = psi2s_mass, scale = psi2s_scale, +# phase = psi2s_phase, width = psi2s_width) + +# def p3770_res(q): +# return resonance(q, _mass = p3770_mass, scale = p3770_scale, +# phase = p3770_phase, width = p3770_width) + +# def p4040_res(q): +# return resonance(q, _mass = p4040_mass, scale = p4040_scale, +# phase = p4040_phase, width = p4040_width) + +# def p4160_res(q): +# return resonance(q, _mass = p4160_mass, scale = p4160_scale, +# phase = p4160_phase, width = p4160_width) + +# def p4415_res(q): +# return resonance(q, _mass = p4415_mass, scale = p4415_scale, +# phase = p4415_phase, width = p4415_width) + + +# In[ ]: + + +# 0.15**2*4.2/1000 +# result.hesse() + + +# ## Constraints + +# In[ ]: + + +# 1. Constraint - Real part of sum of Psi contrib and D contribs + +sum_list = [] + +sum_list.append(ztf.to_complex(jpsi_s) * tf.exp(tf.complex(ztf.constant(0.0), jpsi_p)) * ztf.to_complex(jpsi_w / (tf.pow(jpsi_m,3)))) +sum_list.append(ztf.to_complex(psi2s_s) * tf.exp(tf.complex(ztf.constant(0.0), psi2s_p)) * ztf.to_complex(psi2s_w / (tf.pow(psi2s_m,3)))) +sum_list.append(ztf.to_complex(p3770_s) * tf.exp(tf.complex(ztf.constant(0.0), p3770_p)) * ztf.to_complex(p3770_w / (tf.pow(p3770_m,3)))) +sum_list.append(ztf.to_complex(p4040_s) * tf.exp(tf.complex(ztf.constant(0.0), p4040_p)) * ztf.to_complex(p4040_w / (tf.pow(p4040_m,3)))) +sum_list.append(ztf.to_complex(p4160_s) * tf.exp(tf.complex(ztf.constant(0.0), p4160_p)) * ztf.to_complex(p4160_w / (tf.pow(p4160_m,3)))) +sum_list.append(ztf.to_complex(p4415_s) * tf.exp(tf.complex(ztf.constant(0.0), p4415_p)) * ztf.to_complex(p4415_w / (tf.pow(p4415_m,3)))) +sum_list.append(ztf.to_complex(DDstar_s) * tf.exp(tf.complex(ztf.constant(0.0), DDstar_p)) * (ztf.to_complex(1.0 / (10.0*tf.pow(Dstar_m,2)) + 1.0 / (10.0*tf.pow(D_m,2))))) +sum_list.append(ztf.to_complex(Dbar_s) * tf.exp(tf.complex(ztf.constant(0.0), Dbar_p)) * ztf.to_complex(1.0 / (6.0*tf.pow(Dbar_m,2)))) + +sum_ru_1 = ztf.to_complex(ztf.constant(0.0)) + +for part in sum_list: + sum_ru_1 += part + +sum_1 = tf.math.real(sum_ru_1) +# constraint1 = zfit.constraint.GaussianConstraint(params = sum_1, mu = ztf.constant(1.7*10**-8), +# sigma = ztf.constant(2.2*10**-8)) + +constraint1 = tf.pow((sum_1-ztf.constant(1.7*10**-8))/ztf.constant(2.2*10**-8),2)/ztf.constant(2.) + +# 2. Constraint - Abs. of sum of Psi contribs and D contribs + +sum_2 = tf.abs(sum_ru_1) +constraint2 = tf.cond(tf.greater_equal(sum_2, 5.0e-8), lambda: 100000., lambda: 0.) + +# 3. Constraint - Maximum eta of D contribs + +constraint3_0 = tf.cond(tf.greater_equal(tf.abs(Dbar_s), 0.2), lambda: 100000., lambda: 0.) + +constraint3_1 = tf.cond(tf.greater_equal(tf.abs(DDstar_s), 0.2), lambda: 100000., lambda: 0.) + +# 4. Constraint - Formfactor multivariant gaussian covariance fplus + +Cov_matrix = [[ztf.constant( 1.), ztf.constant( 0.45), ztf.constant( 0.19), ztf.constant(0.857), ztf.constant(0.598), ztf.constant(0.531), ztf.constant(0.752), ztf.constant(0.229), ztf.constant(0,117)], + [ztf.constant( 0.45), ztf.constant( 1.), ztf.constant(0.677), ztf.constant(0.708), ztf.constant(0.958), ztf.constant(0.927), ztf.constant(0.227), ztf.constant(0.443), ztf.constant(0.287)], + [ztf.constant( 0.19), ztf.constant(0.677), ztf.constant( 1.), ztf.constant(0.595), ztf.constant(0.770), ztf.constant(0.819),ztf.constant(-0.023), ztf.constant( 0.07), ztf.constant(0.196)], + [ztf.constant(0.857), ztf.constant(0.708), ztf.constant(0.595), ztf.constant( 1.), ztf.constant( 0.83), ztf.constant(0.766), ztf.constant(0.582), ztf.constant(0.237), ztf.constant(0.192)], + [ztf.constant(0.598), ztf.constant(0.958), ztf.constant(0.770), ztf.constant( 0.83), ztf.constant( 1.), ztf.constant(0.973), ztf.constant(0.324), ztf.constant(0.372), ztf.constant(0.272)], + [ztf.constant(0.531), ztf.constant(0.927), ztf.constant(0.819), ztf.constant(0.766), ztf.constant(0.973), ztf.constant( 1.), ztf.constant(0.268), ztf.constant(0.332), ztf.constant(0.269)], + [ztf.constant(0.752), ztf.constant(0.227),ztf.constant(-0.023), ztf.constant(0.582), ztf.constant(0.324), ztf.constant(0.268), ztf.constant( 1.), ztf.constant( 0.59), ztf.constant(0.515)], + [ztf.constant(0.229), ztf.constant(0.443), ztf.constant( 0.07), ztf.constant(0.237), ztf.constant(0.372), ztf.constant(0.332), ztf.constant( 0.59), ztf.constant( 1.), ztf.constant(0.897)], + [ztf.constant(0.117), ztf.constant(0.287), ztf.constant(0.196), ztf.constant(0.192), ztf.constant(0.272), ztf.constant(0.269), ztf.constant(0.515), ztf.constant(0.897), ztf.constant( 1.)]] + +def triGauss(val1,val2,val3,m = Cov_matrix): + + mean1 = ztf.constant(0.466) + mean2 = ztf.constant(-0.885) + mean3 = ztf.constant(-0.213) + sigma1 = ztf.constant(0.014) + sigma2 = ztf.constant(0.128) + sigma3 = ztf.constant(0.548) + x1 = (val1-mean1)/sigma1 + x2 = (val2-mean2)/sigma2 + x3 = (val3-mean3)/sigma3 + rho12 = m[0][1] + rho13 = m[0][2] + rho23 = m[1][2] + w = x1*x1*(rho23*rho23-1) + x2*x2*(rho13*rho13-1)+x3*x3*(rho12*rho12-1)+2*(x1*x2*(rho12-rho13*rho23)+x1*x3*(rho13-rho12*rho23)+x2*x3*(rho23-rho12*rho13)) + d = 2*(rho12*rho12+rho13*rho13+rho23*rho23-2*rho12*rho13*rho23-1) + + fcn = -w/d + chisq = -2*fcn + return chisq + +constraint4 = triGauss(bplus_0, bplus_1, bplus_2) + +# mean1 = ztf.constant(0.466) +# mean2 = ztf.constant(-0.885) +# mean3 = ztf.constant(-0.213) +# sigma1 = ztf.constant(0.014) +# sigma2 = ztf.constant(0.128) +# sigma3 = ztf.constant(0.548) +# constraint4_0 = tf.pow((bplus_0-mean1)/sigma1,2)/ztf.constant(2.) +# constraint4_1 = tf.pow((bplus_1-mean2)/sigma2,2)/ztf.constant(2.) +# constraint4_2 = tf.pow((bplus_2-mean3)/sigma3,2)/ztf.constant(2.) + +# 5. Constraint - Abs. of sum of light contribs + +sum_list_5 = [] + +sum_list_5.append(rho_s*rho_w/rho_m) +sum_list_5.append(omega_s*omega_w/omega_m) +sum_list_5.append(phi_s*phi_w/phi_m) + + +sum_ru_5 = ztf.constant(0.0) + +for part in sum_list_5: + sum_ru_5 += part + +constraint5 = tf.cond(tf.greater_equal(tf.abs(sum_ru_5), ztf.constant(0.02)), lambda: 100000., lambda: 0.) + +# 6. Constraint on phases of Jpsi and Psi2s for cut out fit + + +# constraint6_0 = zfit.constraint.GaussianConstraint(params = jpsi_p, mu = ztf.constant(pdg["jpsi_phase_unc"]), +# sigma = ztf.constant(jpsi_phase)) +# constraint6_1 = zfit.constraint.GaussianConstraint(params = psi2s_p, mu = ztf.constant(pdg["psi2s_phase_unc"]), +# sigma = ztf.constant(psi2s_phase)) + +constraint6_0 = tf.pow((jpsi_p-ztf.constant(jpsi_phase))/ztf.constant(pdg["jpsi_phase_unc"]),2)/ztf.constant(2.) +constraint6_1 = tf.pow((psi2s_p-ztf.constant(psi2s_phase))/ztf.constant(pdg["psi2s_phase_unc"]),2)/ztf.constant(2.) + +# 7. Constraint on Ctt with higher limits + +constraint7 = tf.cond(tf.greater_equal(Ctt*Ctt, 0.25), lambda: 100000., lambda: 0.) + +constraint7dtype = tf.float64 + +# zfit.run(constraint6_0) + +# ztf.convert_to_tensor(constraint6_0) + +#List of all constraints + +constraints = [constraint1, constraint2, constraint3_0, constraint3_1,# constraint4, #constraint4_0, constraint4_1, constraint4_2, + constraint6_0, constraint6_1]#, constraint7] + + +# ## Reset params + +# In[ ]: + + +param_values_dic = { + 'jpsi_m': jpsi_mass, + 'jpsi_s': jpsi_scale, + 'jpsi_p': jpsi_phase, + 'jpsi_w': jpsi_width, + 'psi2s_m': psi2s_mass, + 'psi2s_s': psi2s_scale, + 'psi2s_p': psi2s_phase, + 'psi2s_w': psi2s_width, + 'p3770_m': p3770_mass, + 'p3770_s': p3770_scale, + 'p3770_p': p3770_phase, + 'p3770_w': p3770_width, + 'p4040_m': p4040_mass, + 'p4040_s': p4040_scale, + 'p4040_p': p4040_phase, + 'p4040_w': p4040_width, + 'p4160_m': p4160_mass, + 'p4160_s': p4160_scale, + 'p4160_p': p4160_phase, + 'p4160_w': p4160_width, + 'p4415_m': p4415_mass, + 'p4415_s': p4415_scale, + 'p4415_p': p4415_phase, + 'p4415_w': p4415_width, + 'rho_m': rho_mass, + 'rho_s': rho_scale, + 'rho_p': rho_phase, + 'rho_w': rho_width, + 'omega_m': omega_mass, + 'omega_s': omega_scale, + 'omega_p': omega_phase, + 'omega_w': omega_width, + 'phi_m': phi_mass, + 'phi_s': phi_scale, + 'phi_p': phi_phase, + 'phi_w': phi_width, + 'Dstar_m': Dstar_mass, + 'DDstar_s': 0.0, + 'DDstar_p': 0.0, + 'D_m': D_mass, + 'Dbar_m': Dbar_mass, + 'Dbar_s': 0.0, + 'Dbar_p': 0.0, + 'tau_m': pdg['tau_M'], + 'Ctt': 0.0, + 'b0_0': 0.292, + 'b0_1': 0.281, + 'b0_2': 0.150, + 'bplus_0': 0.466, + 'bplus_1': -0.885, + 'bplus_2': -0.213, + 'bT_0': 0.460, + 'bT_1': -1.089, + 'bT_2': -1.114} + + +def reset_param_values(variation = 0.05): + for param in total_f_fit.get_dependents(): + if param.floating: + param.set_value(param_values_dic[param.name] + random.uniform(-1, 1) * param_values_dic[param.name]* variation) +# print(param.name) +# for param in totalf.get_dependents(): +# param.set_value() + + +# # Analysis + +# In[ ]: + + +# # zfit.run.numeric_checks = False + +# fitting_range = 'cut' +# total_BR = 1.7e-10 + 4.9e-10 + 2.5e-9 + 6.02e-5 + 4.97e-6 + 1.38e-9 + 4.2e-10 + 2.6e-9 + 6.1e-10 + 4.37e-7 +# cut_BR = 1.0 - (6.02e-5 + 4.97e-6)/total_BR + +# Ctt_list = [] +# Ctt_error_list = [] + +# nr_of_toys = 1 +# if fitting_range == 'cut': +# nevents = int(pdg["number_of_decays"]*cut_BR) +# else: +# nevents = int(pdg["number_of_decays"]) +# # nevents = pdg["number_of_decays"] +# event_stack = 1000000 +# # nevents *= 41 +# # zfit.settings.set_verbosity(10) +# calls = int(nevents/event_stack + 1) + +# total_samp = [] + +# start = time.time() + +# sampler = total_f.create_sampler(n=event_stack) + +# for toy in range(nr_of_toys): + +# ### Generate data + +# # clear_output(wait=True) + +# print("Toy {}: Generating data...".format(toy)) + +# dirName = 'data/zfit_toys/toy_{0}'.format(toy) + +# if not os.path.exists(dirName): +# os.mkdir(dirName) +# print("Directory " , dirName , " Created ") + +# reset_param_values() + +# if fitting_range == 'cut': + +# sampler.resample(n=nevents) +# s = sampler.unstack_x() +# sam = zfit.run(s) +# calls = 0 +# c = 1 + +# else: +# for call in range(calls): + +# sampler.resample(n=event_stack) +# s = sampler.unstack_x() +# sam = zfit.run(s) + +# c = call + 1 + +# with open("data/zfit_toys/toy_{0}/{1}.pkl".format(toy, call), "wb") as f: +# pkl.dump(sam, f, pkl.HIGHEST_PROTOCOL) + +# print("Toy {}: Data generation finished".format(toy)) + +# ### Load data + +# print("Toy {}: Loading data...".format(toy)) + +# if fitting_range == 'cut': + +# total_samp = sam + +# else: + +# for call in range(calls): +# with open(r"data/zfit_toys/toy_0/{}.pkl".format(call), "rb") as input_file: +# sam = pkl.load(input_file) +# total_samp = np.append(total_samp, sam) + +# total_samp = total_samp.astype('float64') + +# if fitting_range == 'full': + +# data = zfit.data.Data.from_numpy(array=total_samp[:int(nevents)], obs=obs) + +# print("Toy {}: Loading data finished".format(toy)) + +# ### Fit data + +# print("Toy {}: Fitting pdf...".format(toy)) + +# for param in total_f.get_dependents(): +# param.randomize() + +# nll = zfit.loss.UnbinnedNLL(model=total_f, data=data, fit_range = (x_min, x_max), constraints = constraints) + +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) +# # minimizer._use_tfgrad = False +# result = minimizer.minimize(nll) + +# print("Toy {}: Fitting finished".format(toy)) + +# print("Function minimum:", result.fmin) +# print("Hesse errors:", result.hesse()) + +# params = result.params +# Ctt_list.append(params[Ctt]['value']) +# Ctt_error_list.append(params[Ctt]['minuit_hesse']['error']) + +# #plotting the result + +# plotdirName = 'data/plots'.format(toy) + +# if not os.path.exists(plotdirName): +# os.mkdir(plotdirName) +# # print("Directory " , dirName , " Created ") + +# probs = total_f.pdf(test_q, norm_range=False) +# calcs_test = zfit.run(probs) +# plt.clf() +# plt.plot(test_q, calcs_test, label = 'pdf') +# plt.legend() +# plt.ylim(0.0, 6e-6) +# plt.savefig(plotdirName + '/toy_fit_full_range{}.png'.format(toy)) + +# print("Toy {0}/{1}".format(toy+1, nr_of_toys)) +# print("Time taken: {}".format(display_time(int(time.time() - start)))) +# print("Projected time left: {}".format(display_time(int((time.time() - start)/(c+calls*(toy))*((nr_of_toys-toy)*calls-c))))) + +# if fitting_range == 'cut': + +# _1 = np.where((total_samp >= x_min) & (total_samp <= (jpsi_mass - 60.))) + +# tot_sam_1 = total_samp[_1] + +# _2 = np.where((total_samp >= (jpsi_mass + 70.)) & (total_samp <= (psi2s_mass - 50.))) + +# tot_sam_2 = total_samp[_2] + +# _3 = np.where((total_samp >= (psi2s_mass + 50.)) & (total_samp <= x_max)) + +# tot_sam_3 = total_samp[_3] + +# tot_sam = np.append(tot_sam_1, tot_sam_2) +# tot_sam = np.append(tot_sam, tot_sam_3) + +# data = zfit.data.Data.from_numpy(array=tot_sam[:int(nevents)], obs=obs_fit) + +# print("Toy {}: Loading data finished".format(toy)) + +# ### Fit data + +# print("Toy {}: Fitting pdf...".format(toy)) + +# for param in total_f_fit.get_dependents(): +# param.randomize() + +# nll = zfit.loss.UnbinnedNLL(model=total_f_fit, data=data, constraints = constraints) + +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) +# # minimizer._use_tfgrad = False +# result = minimizer.minimize(nll) + +# print("Function minimum:", result.fmin) +# print("Hesse errors:", result.hesse()) + +# params = result.params + +# if result.converged: +# Ctt_list.append(params[Ctt]['value']) +# Ctt_error_list.append(params[Ctt]['minuit_hesse']['error']) + +# #plotting the result + +# plotdirName = 'data/plots'.format(toy) + +# if not os.path.exists(plotdirName): +# os.mkdir(plotdirName) +# # print("Directory " , dirName , " Created ") + +# plt.clf() +# plt.hist(tot_sam, bins = int((x_max-x_min)/7.), label = 'toy data') +# plt.savefig(plotdirName + '/toy_histo_cut_region{}.png'.format(toy)) + + +# probs = total_f_fit.pdf(test_q, norm_range=False) +# calcs_test = zfit.run(probs) +# plt.clf() +# plt.plot(test_q, calcs_test, label = 'pdf') +# plt.axvline(x=jpsi_mass-60.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.axvline(x=jpsi_mass+70.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.axvline(x=psi2s_mass-50.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.axvline(x=psi2s_mass+50.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.legend() +# plt.ylim(0.0, 1.5e-6) +# plt.savefig(plotdirName + '/toy_fit_cut_region{}.png'.format(toy)) + +# print("Toy {0}/{1}".format(toy+1, nr_of_toys)) +# print("Time taken: {}".format(display_time(int(time.time() - start)))) +# print("Projected time left: {}".format(display_time(int((time.time() - start)/(toy+1))*((nr_of_toys-toy-1))))) + + + +# In[ ]: + + +# with open("data/results/Ctt_list.pkl", "wb") as f: +# pkl.dump(Ctt_list, f, pkl.HIGHEST_PROTOCOL) +# with open("data/results/Ctt_error_list.pkl", "wb") as f: +# pkl.dump(Ctt_error_list, f, pkl.HIGHEST_PROTOCOL) + + +# In[ ]: + + +# print('{0}/{1} fits converged'.format(len(Ctt_list), nr_of_toys)) +# print('Mean Ctt value = {}'.format(np.mean(Ctt_list))) +# print('Mean Ctt error = {}'.format(np.mean(Ctt_error_list))) +# print('95 Sensitivy = {}'.format(((2*np.mean(Ctt_error_list))**2)*4.2/1000)) + + +# In[ ]: + + +# plt.hist(tot_sam, bins = int((x_max-x_min)/7.)) + +# plt.show() + +# # _ = np.where((total_samp >= x_min) & (total_samp <= (jpsi_mass - 50.))) + +# tot_sam.shape + + +# In[ ]: + + +# Ctt.floating = False + + +# In[ ]: + + +# zfit.run(nll.value()) + + +# In[ ]: + + +# result.fmin + + +# In[ ]: + + +# BR_steps = np.linspace(0.0, 1e-3, 11) +pull_dic = {} + +mi = 1e-4 +ma = 3e-3 +ste = 20 + +for param in total_f_fit.get_dependents(): + if param.floating: + pull_dic[param.name] = [] + for step in range(2*ste): + pull_dic[param.name].append([]) + + + +def save_pulls(step): + for param in total_f_fit.get_dependents(): + if param.floating: + pull_dic[param.name][step].append((params[param]['value'] - param_values_dic[param.name])/params[param]['minuit_hesse']['error']) + + + +# for key in pull_dic.keys(): +# print(np.shape(pull_dic[key])) +# save_pulls(New_step=True) +# params[Ctt]['value'] + + +# In[ ]: + + +# for param in total_f_fit.get_dependents(): +# if param.floating: +# print(param.name) + +# print(params[Ctt]) + + +# # CLS Code + +# In[ ]: + + +# zfit.run.numeric_checks = False + +load = False + +bo = True + +D_contribs = True + +if not D_contribs: + Dbar_s.floating = False + Dbar_p.floating = False + DDstar_s.floating = False + DDstar_p.floating = False + +bo_set = 1 + +fitting_range = 'cut' +total_BR = 1.7e-10 + 4.9e-10 + 2.5e-9 + 6.02e-5 + 4.97e-6 + 1.38e-9 + 4.2e-10 + 2.6e-9 + 6.1e-10 + 4.37e-7 +cut_BR = 1.0 - (6.02e-5 + 4.97e-6)/total_BR + +Ctt_list = [] +Ctt_error_list = [] + +nr_of_toys = 1 +nevents = int(pdg["number_of_decays"]*cut_BR) +# nevents = pdg["number_of_decays"] +event_stack = 1000000 +# nevents *= 41 +# zfit.settings.set_verbosity(10) + +# mi = 1e-4 +# ma = 3e-3 +# ste = 13 + +BR_steps = np.linspace(mi, ma, ste) + +BR_steps[0] = 0.0 + +print(BR_steps) + +Ctt_steps = np.sqrt(BR_steps/4.2*1000) + +print(Ctt_steps) + +# total_samp = [] + +start = time.time() + +Nll_list = [] + +sampler = total_f.create_sampler(n=nevents, fixed_params = False) +sampler.set_data_range(obs_fit) + +__ = -1 + +#----------------------------------------------------- + +if not load: + for Ctt_step in Ctt_steps: + + __ += 1 + + for i in range(2): + Ctt_list.append([]) + Ctt_error_list.append([]) + Nll_list.append([]) + + for param in total_f_fit.get_dependents(): + if param.floating: + pull_dic[param.name].append([]) + + for toy in range(nr_of_toys): + + newset = True + + while newset: + + for floaty in [True, False]: + Ctt.floating = floaty + + for bo_step in range(bo_set): + + print('Step: {0}/{1}'.format(int(__), ste)) + print('Current Ctt: {0}'.format(Ctt_step)) + print('Ctt floating: {0}'.format(floaty)) + + reset_param_values(variation = 0.0) + + if floaty: + print('Toy {0}/{1} - Fit {2}/{3}'.format(toy, nr_of_toys, bo_step, bo_set)) + Ctt.set_value(Ctt_step) + + else: + Ctt.set_value(0.0) + print('Toy {0}/{1} - Fit {2}/{3}'.format(toy, nr_of_toys, bo_step, bo_set)) + + if newset: + sampler.resample(n=nevents) + data = sampler + newset = False + + ### Fit data + + if floaty: + #plt.clf() + #plt.title('Ctt value: {:.2f}'.format(Ctt_step)) + #plt.hist(zfit.run(data), bins = int((x_max-x_min)/7), range = (x_min, x_max)) + #plt.savefig('data/CLs/plots/set_histo{}.png'.format(__)) + _step = 2*__ + else: + _step = 2*__+1 + + nll = zfit.loss.UnbinnedNLL(model=total_f_fit, data=data, constraints = constraints) + + minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) + # minimizer._use_tfgrad = False + result = minimizer.minimize(nll) + + print("Function minimum:", result.fmin) + print("Hesse errors:", result.hesse()) + + params = result.params + + if result.converged: + + save_pulls(step = _step) + + if floaty: + Nll_list[-2].append(result.fmin) + Ctt_list[-2].append(params[Ctt]['value']) + Ctt_error_list[-2].append(params[Ctt]['minuit_hesse']['error']) + + else: + Nll_list[-1].append(result.fmin) + Ctt_list[-1].append(0.0) + Ctt_error_list[-1].append(0.0) + + + else: + for _ in [1,2]: + del Nll_list[-_][toy*bo_set:] +# print(np.shape(Nll_list[-_])) + del Ctt_list[-_][toy*bo_set:] + del Ctt_error_list[-_][toy*bo_set:] + for param in total_f_fit.get_dependents(): + if param.floating: + del pull_dic[param.name][_step+1-_][toy*bo_set:] + newset = True + break + + if not result.converged: + break + + print() + print('Time taken: {}'.format(display_time(int(time.time()-start)))) + print('Estimated time left: {}'.format(display_time(int((time.time()-start)/(__+(toy+1)/nr_of_toys)*(ste-__-(nr_of_toys-toy-1)/nr_of_toys))))) + + +# In[ ]: + + +if load: + + phase_combi = '--' + + if D_contribs: + D_dir = 'D-True' + else: + D_dir = 'D-False' + + _dir = 'data/CLs/finished/f1d1/{}/{}/'.format(phase_combi, D_dir) + + jobs = os.listdir(_dir) + + First = True + +# print(jobs) + + for job in jobs: + + dirName = _dir + str(job) + '/data/CLs' + + if not os.path.exists("{}/{}-{}_{}s{}b{}t--CLs_Nll_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys)): +# print(job) + continue + + with open(r"{}/variab.pkl".format(dirName), "rb") as input_file: + variab = pkl.load(input_file) +# print(variab) + + ### sanity check: + if variab['mi'] != mi or variab['ma'] != ma or variab['ste'] != ste or bo_set != bo_set: + print('Fitting parameters of data dont equal the ones given -- Job {} skipped!'.format(job)) + + with open(r"{}/{}-{}_{}s{}b{}t--CLs_Nll_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _Nll_list = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s{}b{}t--Ctt_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _Ctt_list = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s{}b{}t--Ctt_error_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _Ctt_error_list = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s{}b{}t--pull_dic.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _pull_dic = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s--CLs_list.pkl".format(dirName, mi,ma,ste), "rb") as input_file: + _CLs_list = pkl.load(input_file) + + + if First: + Nll_list = _Nll_list + Ctt_list = _Ctt_list + Ctt_error_list = _Ctt_error_list + pull_dic = _pull_dic +# print(_pull_dic) + CLs_list = _CLs_list + First = False + else: + for step in range(2*ste): +# print(Nll_list[step], step) + Nll_list[step].extend(_Nll_list[step]) + Ctt_list[step].extend(_Ctt_list[step]) + Ctt_error_list[step].extend(_Ctt_error_list[step]) + for key in pull_dic.keys(): +# print(key, np.shape(pull_dic[key])) + pull_dic[key][step].extend(_pull_dic[key][step]) + for step in range(ste): + CLs_list[step].extend(_CLs_list[step]) + +# print('----------------------') + + +# In[ ]: + + +dirName = 'data/CLs' + +# if bo and not load: +# for s in range(2*ste): +# Nll_list[s] = [np.min(Nll_list[s])] + + +if not load: + + if not os.path.exists(dirName): + os.mkdir(dirName) + print("Directory " , dirName , " Created ") + + with open("{}/{}-{}_{}s{}b{}t--CLs_Nll_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(Nll_list, f, pkl.HIGHEST_PROTOCOL) + + with open("{}/{}-{}_{}s{}b{}t--Ctt_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(Ctt_list, f, pkl.HIGHEST_PROTOCOL) + + with open("{}/{}-{}_{}s{}b{}t--Ctt_error_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(Ctt_error_list, f, pkl.HIGHEST_PROTOCOL) + + with open("{}/{}-{}_{}s{}b{}t--pull_dic.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(pull_dic, f, pkl.HIGHEST_PROTOCOL) + + variab = {'mi': mi, + 'ma': ma, + 'ste': ste, + 'bo_set': bo_set, + 'nr_of_toys': nr_of_toys} + + with open("{}/variab.pkl".format(dirName), "wb") as f: + pkl.dump(variab, f, pkl.HIGHEST_PROTOCOL) + + CLs_values = [] + + toy_size = bo_set + + print(np.shape(Nll_list)) + print(Nll_list[0:1]) + + for step in range(ste): + CLs_values.append([]) + for toy in range(nr_of_toys): + float_min = np.min(Nll_list[2*step][toy*bo_set:(toy+1)*bo_set]) + fix_min = np.min(Nll_list[2*step+1][toy*bo_set:(toy+1)*bo_set]) + CLs_values[step].append(float_min-fix_min) + + + print(np.shape(CLs_values)) + + with open("{}/{}-{}_{}s--CLs_list.pkl".format(dirName, mi,ma,ste), "wb") as f: + pkl.dump(CLs_values, f, pkl.HIGHEST_PROTOCOL) + + +# In[ ]: + + +# print(variab['mi'] != mi) + + +# ## Plot + +# In[ ]: + + +l = [] + + +if load: + CLs_values = -1*np.array(CLs_list) + +if not os.path.exists('data/CLs/plots'): + os.mkdir('data/CLs/plots') + print("Directory " , 'data/CLs/plots' , " Created ") + +print(np.shape(CLs_values)) + +for step in range(1,ste): + plt.clf() + plt.title('Ctt value: {:.2f}'.format(Ctt_steps[step])) + plt.hist(CLs_values[0], bins = 150, range = (-25, 50), label = 'Ctt fixed to 0') + plt.hist(CLs_values[step], bins = 150, range = (-25, 50), label = 'Ctt floating') + plt.axvline(x=np.mean(CLs_values[0]),color='red', linewidth=1.0, linestyle = 'dotted') + plt.legend() + plt.savefig('data/CLs/plots/CLs-BR({:.1E}).png'.format(BR_steps[step])) + + l.append(len(np.where(np.array(CLs_values[step]) < np.mean(CLs_values[0]))[0])) + +for step in range(2*ste): + if step%2 == 0: + floaty = True + else: + floaty = False + for key in pull_dic.keys(): + if not os.path.exists('data/CLs/plots/{}'.format(key)): + os.mkdir('data/CLs/plots/{}'.format(key)) + plt.clf() + plt.title('Pull {} - Ctt value {:.2f} - floating {}'.format(key, Ctt_steps[int(step/2)], floaty)) + plt.hist(pull_dic[key][step], bins = 50, range = (-5,5)) + plt.xlabel('Pull') + plt.savefig('data/CLs/plots/{}/{:.2f}Ctt{}s{}f.png'.format(key, Ctt_steps[int(step/2)], step, floaty)) + + +# In[ ]: + + +for s in range(len(l)): + print('BR: {:.4f}'.format(BR_steps[s+1])) + print(2*l[s]/len(CLs_values[s])) + print() + + +# In[ ]: + + +# for step in range(2*ste): +# for key in pull_dic.keys(): +# print(pull_dic[key][step]) + + +# In[ ]: + + +# for param in total_f_fit.get_dependents(): +# if param.floating: +# print(params[param]['value']) + + +# In[ ]: + + +print(display_time(int(time.time()-start))) + + +# In[ ]: + + +# variab['mi'] =! mi + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + diff --git a/data/CLs/finished/f1d1/-+/D-True/2288047/__pycache__/helperfunctions.cpython-37.pyc b/data/CLs/finished/f1d1/-+/D-True/2288047/__pycache__/helperfunctions.cpython-37.pyc new file mode 100644 index 0000000..bb87af9 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288047/__pycache__/helperfunctions.cpython-37.pyc Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288047/__pycache__/pdg_const1.cpython-37.pyc b/data/CLs/finished/f1d1/-+/D-True/2288047/__pycache__/pdg_const1.cpython-37.pyc new file mode 100644 index 0000000..22926c8 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288047/__pycache__/pdg_const1.cpython-37.pyc Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288047/data/CLs/0.0001-0.003_20s--CLs_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288047/data/CLs/0.0001-0.003_20s--CLs_list.pkl new file mode 100644 index 0000000..817ce8d --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288047/data/CLs/0.0001-0.003_20s--CLs_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288047/data/CLs/0.0001-0.003_20s1b1t--CLs_Nll_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288047/data/CLs/0.0001-0.003_20s1b1t--CLs_Nll_list.pkl new file mode 100644 index 0000000..4479427 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288047/data/CLs/0.0001-0.003_20s1b1t--CLs_Nll_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288047/data/CLs/0.0001-0.003_20s1b1t--Ctt_error_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288047/data/CLs/0.0001-0.003_20s1b1t--Ctt_error_list.pkl new file mode 100644 index 0000000..0fe32ff --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288047/data/CLs/0.0001-0.003_20s1b1t--Ctt_error_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288047/data/CLs/0.0001-0.003_20s1b1t--Ctt_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288047/data/CLs/0.0001-0.003_20s1b1t--Ctt_list.pkl new file mode 100644 index 0000000..42cc7ff --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288047/data/CLs/0.0001-0.003_20s1b1t--Ctt_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288047/data/CLs/0.0001-0.003_20s1b1t--pull_dic.pkl b/data/CLs/finished/f1d1/-+/D-True/2288047/data/CLs/0.0001-0.003_20s1b1t--pull_dic.pkl new file mode 100644 index 0000000..4fb34c7 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288047/data/CLs/0.0001-0.003_20s1b1t--pull_dic.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288047/data/CLs/variab.pkl b/data/CLs/finished/f1d1/-+/D-True/2288047/data/CLs/variab.pkl new file mode 100644 index 0000000..bb90dc0 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288047/data/CLs/variab.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288047/helperfunctions.py b/data/CLs/finished/f1d1/-+/D-True/2288047/helperfunctions.py new file mode 100644 index 0000000..88e120f --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288047/helperfunctions.py @@ -0,0 +1,33 @@ +# some helperfunctions + +import matplotlib +matplotlib.use("agg") +import matplotlib.pyplot as plt + +#Dislpay time (e.g. while generating points) + +display_intervals = ( + ('w', 604800), # 60 * 60 * 24 * 7 + ('d', 86400), # 60 * 60 * 24 + ('h', 3600), # 60 * 60 + ('min', 60), + ('s', 1), + ) + +def display_time(seconds, granularity=2): + result = [] + + for name, count in display_intervals: + value = seconds // count + if value: + seconds -= value * count + if value == 1: + name = name.rstrip('s') + result.append("{} {}".format(value, name)) + return ', '.join(result[:granularity]) + +def prepare_plot(title): + plt.title(title) + plt.grid() + plt.legend(loc = 'best') + plt.xlabel("q") diff --git a/data/CLs/finished/f1d1/-+/D-True/2288047/pdg_const1.py b/data/CLs/finished/f1d1/-+/D-True/2288047/pdg_const1.py new file mode 100644 index 0000000..70b3f30 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288047/pdg_const1.py @@ -0,0 +1,226 @@ +pdg = { + + + ###Particle masses### + + "mbstar" : 5415.4, + "mbstar0" : 5711.0, + "B0_M" : 5279.5, + "Bs_M" : 5366.7, + "Bplus_M" : 5279.3, + "Lb_M" : 5619.4, + "D0_M" : 1864.8, + "Dst_M" : 2010, + "pi_M" : 139.6, + "Jpsi_M" : 3096.9, + "Psi2s_M" : 3685.6, + "kaon_M" : 493.7, + "Ks_M" : 497.6, + "phi_M" : 1019.5, + "rho_M" : 775.26, + "rho_width" : 149.1, + "omega_M" : 782.65, + "omega_width" : 8.49, + + "muon_M" : 105.7, + "tau_M": 1776.86, + + "squark_M" : 95.0, + "bquark_M" : 4180.0, + "cquark_M" : 1275.0, + + "Bplus_tau" : 1.638e-12, + + ###Wilson coefficients### + + "C1" : -0.257, + "C2" : 1.009, + "C3" : -0.005, + "C4" : -0.078, + + "C7eff" : -0.306, + "C9eff" : 4.211, + "C10eff" : -4.103, + +# "C7eff": 0.0, +# "C9eff": 0.0, +# "C10eff": 0.0, + + ###Other constants + + "GF" : 1.1663787e-5, + "alpha_ew" : 1.0/137.0, + "Vts" : 0.0394, + "Vtb" : 1.019, + "number_of_decays": 5404696, + + #Formfactor z coefficients + + #"b0" : [0.285, 0.19, -0.17], + #"bplus" : [0.437, -1.41, -2.5], + #"bT" : [0.440, -1.47, -2.7] + + "b0" : [0.292, 0.281, 0.150], + "bplus" : [0.466, -0.885, -0.213], + "bT" : [0.460, -1.089, -1.114], + + "NR_BR": 4.37e-7, + "NR_auc": 0.00133, + + #Resonances format(mass, width, phase, scale) + + # pre scaling + +# "rho": (775.26, 149.0, -0.35, 1.0), + +# "omega": (782.7, 8.5, 0.26, 1.0), + +# "phi": (1019.46, 4.25, 0.5, 1.0), + +# "jpsi": (3096.0, 0.09, -1.5, 2e-2), +# "jpsi_auc": 0.2126825758464027, + +# "psi2s": (3686.0, 0.3, -1.5, 3.14e-3), +# "psi2s_auc": 2.802257483178487e-10, + +# "p3770": (3773.0, 27.2, -2.13, 1.0e-3), + +# "p4040": (4039.0, 80.0, -2.52, 2.0), + +# "p4160": (4191.0, 70.0, -1.9, 2.2), + +# "p4415": (4421.0, 62.0, -2.52, 1.0), + + + # after scaling (Phase combination --) + + # + # "rho": (743.2, 149.0, -0.22, 1.05), + # + # "omega": (782.7, 8.5, 0.38, 6.8), + # + # "phi": (1013.5, 4.25, 0.62, 19.2), + # + # "jpsi": (3096.1, 0.09, 1.63, 9897.0), + # "jpsi_auc": 0.2126825758464027, + # "jpsi_phase_unc": 0.05, + # + # "psi2s": (3686.0, 0.3, 1.8, 1396.0), + # "psi2s_auc": 0.0151332263, + # "psi2s_phase_unc": 0.1, + # + # "p3770": (3773.0, 27.2, -2.95, 2.5), + # + # "p4040": (4039.0, 80.0, -2.75, 1.01), + # + # "p4160": (4191.0, 70.0, -2.28, 2.2), + # + # "p4415": (4421.0, 62.0, -2.31, 1.24), + + # Phase combination of paper ++ + +# "rho": (743.2, 149.0, -0.35, 1.05), + +# "omega": (782.7, 8.5, 0.26, 6.8), + +# "phi": (1013.5, 4.25, 0.47, 19.2), + +# "jpsi": (3096.1, 0.09, -1.66, 9897.0), +# "jpsi_auc": 0.2126825758464027, +# "jpsi_phase_unc": 0.05, + +# "psi2s": (3686.0, 0.3, -1.93, 1396.0), +# "psi2s_auc": 0.0151332263, +# "psi2s_phase_unc": 0.1, + +# "p3770": (3773.0, 27.2, -2.13, 2.5), + +# "p4040": (4039.0, 80.0, -2.52, 1.01), + +# "p4160": (4191.0, 70.0, -1.90, 2.2), + +# "p4415": (4421.0, 62.0, -2.52, 1.24), + + # Phase combination of paper +- + +# "rho": (743.2, 149.0, -0.26, 1.05), + +# "omega": (782.7, 8.5, 0.35, 6.8), + +# "phi": (1013.5, 4.25, 0.58, 19.2), + +# "jpsi": (3096.1, 0.09, 1.47, 9897.0), +# "jpsi_auc": 0.2126825758464027, +# "jpsi_phase_unc": 0.05, + +# "psi2s": (3686.0, 0.3, -2.21, 1396.0), +# "psi2s_auc": 0.0151332263, +# "psi2s_phase_unc": 0.1, + +# "p3770": (3773.0, 27.2, -2.140, 2.5), + +# "p4040": (4039.0, 80.0, -2.64, 1.01), + +# "p4160": (4191.0, 70.0, -2.11, 2.2), + +# "p4415": (4421.0, 62.0, -2.42, 1.24), + + # Phase combination of paper -+ + + "rho": (743.2, 149.0, -0.30, 1.05), + + "omega": (782.7, 8.5, 0.30, 6.8), + + "phi": (1013.5, 4.25, 0.51, 19.2), + + "jpsi": (3096.1, 0.09, -1.5, 9897.0), + "jpsi_auc": 0.2126825758464027, + "jpsi_phase_unc": 0.05, + + "psi2s": (3686.0, 0.3, 2.08, 1396.0), + "psi2s_auc": 0.0151332263, + "psi2s_phase_unc": 0.1, + + "p3770": (3773.0, 27.2, -2.89, 2.5), + + "p4040": (4039.0, 80.0, -2.69, 1.01), + + "p4160": (4191.0, 70.0, -2.13, 2.2), + + "p4415": (4421.0, 62.0, -2.43, 1.24), + + + # zeroing resonances + +# "rho": (775.26, 149.0, -0.35, 0.0), +# "omega": (782.7, 8.5, 0.26, 0.0), +# "phi": (1019.46, 4.25, 0.5, 0.0), +# "jpsi": (3096.0, 0.09, -1.5, 0.0), +# "psi2s": (3686.0, 0.3, -1.5, 0.0), +# "p3770": (3773.0, 27.2, -2.13, 0.0), +# "p4040": (4039.0, 80.0, -2.52, 0.0), +# "p4160": (4147.0, 22.0, -1.9, 0.0), +# "p4415": (4421.0, 62.0, -2.52, 0.0), + + # 2P contributions format(mass, amp, phase) + +# "D_bar": ( + + #general + + "rho_BR": 1.7e-10, + "omega_BR": 4.9e-10, + "phi_BR": 2.5e-9, + "jpsi_BR": 6.02e-5, + "psi2s_BR": 4.97e-6, + "p3770_BR": 1.38e-9, + "p4040_BR": 4.2e-10, + "p4160_BR": 2.6e-9, + "p4415_BR": 6.1e-10, + +# Estimates + "Dbar_scale": 1.46, #with phase = pi + + "DDstar_scale": 2.41, #with phase = pi + + } diff --git a/data/CLs/finished/f1d1/-+/D-True/2288047/raremodel-nb.py b/data/CLs/finished/f1d1/-+/D-True/2288047/raremodel-nb.py new file mode 100644 index 0000000..c326c9c --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288047/raremodel-nb.py @@ -0,0 +1,2152 @@ +#!/usr/bin/env python +# coding: utf-8 + +# # Import + +# In[ ]: + + +import os + +# os.environ["CUDA_VISIBLE_DEVICES"] = "-1" +import random +import numpy as np +from pdg_const1 import pdg +import matplotlib +import matplotlib.pyplot as plt +import pickle as pkl +import sys +import time +from helperfunctions import display_time, prepare_plot +import cmath as c +import scipy.integrate as integrate +from scipy.optimize import fminbound +from array import array as arr +import collections +from itertools import compress +import tensorflow as tf +import zfit +from zfit import ztf +# from IPython.display import clear_output +import os +import tensorflow_probability as tfp +tfd = tfp.distributions + + +# In[ ]: + + +# chunksize = 10000 +# zfit.run.chunking.active = True +# zfit.run.chunking.max_n_points = chunksize + + +# # Build model and graphs +# ## Create graphs + +# In[ ]: + + + + + +# In[ ]: + + +def formfactor(q2, subscript, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2): #returns real value + #check if subscript is viable + + if subscript != "0" and subscript != "+" and subscript != "T": + raise ValueError('Wrong subscript entered, choose either 0, + or T') + + #get constants + + mK = ztf.constant(pdg['Ks_M']) + mbstar0 = ztf.constant(pdg["mbstar0"]) + mbstar = ztf.constant(pdg["mbstar"]) + + + mmu = ztf.constant(pdg['muon_M']) + mb = ztf.constant(pdg['bquark_M']) + ms = ztf.constant(pdg['squark_M']) + mB = ztf.constant(pdg['Bplus_M']) + + #N comes from derivation in paper + + N = 3 + + #some helperfunctions + + tpos = (mB - mK)**2 + tzero = (mB + mK)*(ztf.sqrt(mB)-ztf.sqrt(mK))**2 + + z_oben = ztf.sqrt(tpos - q2) - ztf.sqrt(tpos - tzero) + z_unten = ztf.sqrt(tpos - q2) + ztf.sqrt(tpos - tzero) + z = tf.divide(z_oben, z_unten) + + #calculate f0 + + if subscript == "0": + prefactor = 1/(1 - q2/(mbstar0**2)) + _sum = 0 + b0 = [b0_0, b0_1, b0_2] + + for i in range(N): + _sum += b0[i]*(tf.pow(z,i)) + + return ztf.to_complex(prefactor * _sum) + + #calculate f+ or fT + + else: + prefactor = 1/(1 - q2/(mbstar**2)) + _sum = 0 + + if subscript == "T": + bT = [bT_0, bT_1, bT_2] + for i in range(N): + _sum += bT[i] * (tf.pow(z, i) - ((-1)**(i-N)) * (i/N) * tf.pow(z, N)) + else: + bplus = [bplus_0, bplus_1, bplus_2] + for i in range(N): + _sum += bplus[i] * (tf.pow(z, i) - ((-1)**(i-N)) * (i/N) * tf.pow(z, N)) + + return ztf.to_complex(prefactor * _sum) + +def resonance(q, _mass, width, phase, scale): + + q2 = tf.pow(q, 2) + + mmu = ztf.constant(pdg['muon_M']) + + p = 0.5 * ztf.sqrt(q2 - 4*(mmu**2)) + + p0 = 0.5 * ztf.sqrt(_mass**2 - 4*mmu**2) + + gamma_j = tf.divide(p, q) * _mass * width / p0 + + #Calculate the resonance + + _top = tf.complex(_mass * width, ztf.constant(0.0)) + + _bottom = tf.complex(_mass**2 - q2, -_mass*gamma_j) + + com = _top/_bottom + + #Rotate by the phase + + r = ztf.to_complex(scale*tf.abs(com)) + + _phase = tf.angle(com) + + _phase += phase + + com = r * tf.exp(tf.complex(ztf.constant(0.0), _phase)) + + return com + + +def axiv_nonres(q, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2): + + GF = ztf.constant(pdg['GF']) + alpha_ew = ztf.constant(pdg['alpha_ew']) + Vtb = ztf.constant(pdg['Vtb']) + Vts = ztf.constant(pdg['Vts']) + C10eff = ztf.constant(pdg['C10eff']) + + mmu = ztf.constant(pdg['muon_M']) + mb = ztf.constant(pdg['bquark_M']) + ms = ztf.constant(pdg['squark_M']) + mK = ztf.constant(pdg['Ks_M']) + mB = ztf.constant(pdg['Bplus_M']) + + q2 = tf.pow(q, 2) + + #Some helperfunctions + + beta = 1. - 4. * mmu**2. / q2 + + kabs = ztf.sqrt(mB**2. + tf.pow(q2, 2)/mB**2. + mK**4./mB**2. - 2. * (mB**2. * mK**2. + mK**2. * q2 + mB**2. * q2) / mB**2.) + + #prefactor in front of whole bracket + + prefactor1 = GF**2. *alpha_ew**2. * (tf.abs(Vtb*Vts))**2. * kabs * beta / (128. * np.pi**5.) + + #left term in bracket + + bracket_left = 2./3. * tf.pow(kabs,2) * tf.pow(beta,2) * tf.pow(tf.abs(ztf.to_complex(C10eff)*formfactor(q2, "+", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2)),2) + + #middle term in bracket + + _top = 4. * mmu**2. * (mB**2. - mK**2.) * (mB**2. - mK**2.) + + _under = q2 * mB**2. + + bracket_middle = _top/_under *tf.pow(tf.abs(ztf.to_complex(C10eff) * formfactor(q2, "0", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2)), 2) + + #Note sqrt(q2) comes from derivation as we use q2 and plot q + + return prefactor1 * (bracket_left + bracket_middle) * 2 * q + +def vec(q, funcs, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2): + + q2 = tf.pow(q, 2) + + GF = ztf.constant(pdg['GF']) + alpha_ew = ztf.constant(pdg['alpha_ew']) + Vtb = ztf.constant(pdg['Vtb']) + Vts = ztf.constant(pdg['Vts']) + C7eff = ztf.constant(pdg['C7eff']) + + mmu = ztf.constant(pdg['muon_M']) + mb = ztf.constant(pdg['bquark_M']) + ms = ztf.constant(pdg['squark_M']) + mK = ztf.constant(pdg['Ks_M']) + mB = ztf.constant(pdg['Bplus_M']) + + #Some helperfunctions + + beta = 1. - 4. * mmu**2. / q2 + + kabs = ztf.sqrt(mB**2. + tf.pow(q2, 2)/mB**2. + mK**4./mB**2. - 2 * (mB**2 * mK**2 + mK**2 * q2 + mB**2 * q2) / mB**2) + + #prefactor in front of whole bracket + + prefactor1 = GF**2. *alpha_ew**2. * (tf.abs(Vtb*Vts))**2 * kabs * beta / (128. * np.pi**5.) + + #right term in bracket + + prefactor2 = tf.pow(kabs,2) * (1. - 1./3. * beta) + + abs_bracket = tf.pow(tf.abs(c9eff(q, funcs) * formfactor(q2, "+", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + ztf.to_complex(2.0 * C7eff * (mb + ms)/(mB + mK)) * formfactor(q2, "T", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2)),2) + + bracket_right = prefactor2 * abs_bracket + + #Note sqrt(q2) comes from derivation as we use q2 and plot q + + return prefactor1 * bracket_right * 2 * q + +def c9eff(q, funcs): + + C9eff_nr = ztf.to_complex(ztf.constant(pdg['C9eff'])) + + c9 = C9eff_nr + funcs + + return c9 + + +# In[ ]: + + +def G(y): + + def inner_rect_bracket(q): + return tf.log(ztf.to_complex((1+tf.sqrt(q))/(1-tf.sqrt(q)))-tf.complex(ztf.constant(0), -1*ztf.constant(np.pi))) + + def inner_right(q): + return ztf.to_complex(2 * tf.atan(1/tf.sqrt(tf.math.real(-q)))) + + big_bracket = tf.where(tf.math.real(y) > ztf.constant(0.0), inner_rect_bracket(y), inner_right(y)) + + return ztf.to_complex(tf.sqrt(tf.abs(y))) * big_bracket + +def h_S(m, q): + + return ztf.to_complex(2) - G(ztf.to_complex(1) - ztf.to_complex(4*tf.pow(m, 2)) / ztf.to_complex(tf.pow(q, 2))) + +def h_P(m, q): + + return ztf.to_complex(2/3) + (ztf.to_complex(1) - ztf.to_complex(4*tf.pow(m, 2)) / ztf.to_complex(tf.pow(q, 2))) * h_S(m,q) + +def two_p_ccbar(mD, m_D_bar, m_D_star, q): + + + #Load constants + nu_D_bar = ztf.to_complex(pdg["nu_D_bar"]) + nu_D = ztf.to_complex(pdg["nu_D"]) + nu_D_star = ztf.to_complex(pdg["nu_D_star"]) + + phase_D_bar = ztf.to_complex(pdg["phase_D_bar"]) + phase_D = ztf.to_complex(pdg["phase_D"]) + phase_D_star = ztf.to_complex(pdg["phase_D_star"]) + + #Calculation + left_part = nu_D_bar * tf.exp(tf.complex(ztf.constant(0.0), phase_D_bar)) * h_S(m_D_bar, q) + + right_part_D = nu_D * tf.exp(tf.complex(ztf.constant(0.0), phase_D)) * h_P(m_D, q) + + right_part_D_star = nu_D_star * tf.exp(tf.complex(ztf.constant(0.0), phase_D_star)) * h_P(m_D_star, q) + + return left_part + right_part_D + right_part_D_star + + +# ## Build pdf + +# In[ ]: + + +class total_pdf_cut(zfit.pdf.ZPDF): + _N_OBS = 1 # dimension, can be omitted + _PARAMS = ['b0_0', 'b0_1', 'b0_2', + 'bplus_0', 'bplus_1', 'bplus_2', + 'bT_0', 'bT_1', 'bT_2', + 'rho_mass', 'rho_scale', 'rho_phase', 'rho_width', + 'jpsi_mass', 'jpsi_scale', 'jpsi_phase', 'jpsi_width', + 'psi2s_mass', 'psi2s_scale', 'psi2s_phase', 'psi2s_width', + 'p3770_mass', 'p3770_scale', 'p3770_phase', 'p3770_width', + 'p4040_mass', 'p4040_scale', 'p4040_phase', 'p4040_width', + 'p4160_mass', 'p4160_scale', 'p4160_phase', 'p4160_width', + 'p4415_mass', 'p4415_scale', 'p4415_phase', 'p4415_width', + 'omega_mass', 'omega_scale', 'omega_phase', 'omega_width', + 'phi_mass', 'phi_scale', 'phi_phase', 'phi_width', + 'Dbar_mass', 'Dbar_scale', 'Dbar_phase', + 'Dstar_mass', 'DDstar_scale', 'DDstar_phase', 'D_mass', + 'tau_mass', 'C_tt'] +# the name of the parameters + + def _unnormalized_pdf(self, x): + + x = x.unstack_x() + + b0 = [self.params['b0_0'], self.params['b0_1'], self.params['b0_2']] + bplus = [self.params['bplus_0'], self.params['bplus_1'], self.params['bplus_2']] + bT = [self.params['bT_0'], self.params['bT_1'], self.params['bT_2']] + + def rho_res(q): + return resonance(q, _mass = self.params['rho_mass'], scale = self.params['rho_scale'], + phase = self.params['rho_phase'], width = self.params['rho_width']) + + def omega_res(q): + return resonance(q, _mass = self.params['omega_mass'], scale = self.params['omega_scale'], + phase = self.params['omega_phase'], width = self.params['omega_width']) + + def phi_res(q): + return resonance(q, _mass = self.params['phi_mass'], scale = self.params['phi_scale'], + phase = self.params['phi_phase'], width = self.params['phi_width']) + + def jpsi_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['jpsi_mass'], 2)) * resonance(q, _mass = self.params['jpsi_mass'], + scale = self.params['jpsi_scale'], + phase = self.params['jpsi_phase'], + width = self.params['jpsi_width']) + def psi2s_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['psi2s_mass'], 2)) * resonance(q, _mass = self.params['psi2s_mass'], + scale = self.params['psi2s_scale'], + phase = self.params['psi2s_phase'], + width = self.params['psi2s_width']) + def p3770_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p3770_mass'], 2)) * resonance(q, _mass = self.params['p3770_mass'], + scale = self.params['p3770_scale'], + phase = self.params['p3770_phase'], + width = self.params['p3770_width']) + + def p4040_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4040_mass'], 2)) * resonance(q, _mass = self.params['p4040_mass'], + scale = self.params['p4040_scale'], + phase = self.params['p4040_phase'], + width = self.params['p4040_width']) + + def p4160_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4160_mass'], 2)) * resonance(q, _mass = self.params['p4160_mass'], + scale = self.params['p4160_scale'], + phase = self.params['p4160_phase'], + width = self.params['p4160_width']) + + def p4415_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4415_mass'], 2)) * resonance(q, _mass = self.params['p4415_mass'], + scale = self.params['p4415_scale'], + phase = self.params['p4415_phase'], + width = self.params['p4415_width']) + + def P2_D(q): + Dbar_contrib = ztf.to_complex(self.params['Dbar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['Dbar_phase']))*ztf.to_complex(h_S(self.params['Dbar_mass'], q)) + DDstar_contrib = ztf.to_complex(self.params['DDstar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['DDstar_phase']))*(ztf.to_complex(h_P(self.params['Dstar_mass'], q)) + ztf.to_complex(h_P(self.params['D_mass'], q))) + return Dbar_contrib + DDstar_contrib + + def ttau_cusp(q): + return ztf.to_complex(self.params['C_tt'])*(ztf.to_complex((h_S(self.params['tau_mass'], q))) - ztf.to_complex(h_P(self.params['tau_mass'], q))) + + + funcs = rho_res(x) + omega_res(x) + phi_res(x) + jpsi_res(x) + psi2s_res(x) + p3770_res(x) + p4040_res(x)+ p4160_res(x) + p4415_res(x) + P2_D(x) + ttau_cusp(x) + + vec_f = vec(x, funcs, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + axiv_nr = axiv_nonres(x, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + tot = vec_f + axiv_nr + + #Cut out jpsi and psi2s + + tot = tf.where(tf.math.logical_or(x < ztf.constant(jpsi_mass-60.), x > ztf.constant(jpsi_mass+70.)), tot, 0.0*tot) + + tot = tf.where(tf.math.logical_or(x < ztf.constant(psi2s_mass-50.), x > ztf.constant(psi2s_mass+50.)), tot, 0.0*tot) + + return tot + +class total_pdf_full(zfit.pdf.ZPDF): + _N_OBS = 1 # dimension, can be omitted + _PARAMS = ['b0_0', 'b0_1', 'b0_2', + 'bplus_0', 'bplus_1', 'bplus_2', + 'bT_0', 'bT_1', 'bT_2', + 'rho_mass', 'rho_scale', 'rho_phase', 'rho_width', + 'jpsi_mass', 'jpsi_scale', 'jpsi_phase', 'jpsi_width', + 'psi2s_mass', 'psi2s_scale', 'psi2s_phase', 'psi2s_width', + 'p3770_mass', 'p3770_scale', 'p3770_phase', 'p3770_width', + 'p4040_mass', 'p4040_scale', 'p4040_phase', 'p4040_width', + 'p4160_mass', 'p4160_scale', 'p4160_phase', 'p4160_width', + 'p4415_mass', 'p4415_scale', 'p4415_phase', 'p4415_width', + 'omega_mass', 'omega_scale', 'omega_phase', 'omega_width', + 'phi_mass', 'phi_scale', 'phi_phase', 'phi_width', + 'Dbar_mass', 'Dbar_scale', 'Dbar_phase', + 'Dstar_mass', 'DDstar_scale', 'DDstar_phase', 'D_mass', + 'tau_mass', 'C_tt'] +# the name of the parameters + + def _unnormalized_pdf(self, x): + + x = x.unstack_x() + + b0 = [self.params['b0_0'], self.params['b0_1'], self.params['b0_2']] + bplus = [self.params['bplus_0'], self.params['bplus_1'], self.params['bplus_2']] + bT = [self.params['bT_0'], self.params['bT_1'], self.params['bT_2']] + + def rho_res(q): + return resonance(q, _mass = self.params['rho_mass'], scale = self.params['rho_scale'], + phase = self.params['rho_phase'], width = self.params['rho_width']) + + def omega_res(q): + return resonance(q, _mass = self.params['omega_mass'], scale = self.params['omega_scale'], + phase = self.params['omega_phase'], width = self.params['omega_width']) + + def phi_res(q): + return resonance(q, _mass = self.params['phi_mass'], scale = self.params['phi_scale'], + phase = self.params['phi_phase'], width = self.params['phi_width']) + + def jpsi_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['jpsi_mass'], 2)) * resonance(q, _mass = self.params['jpsi_mass'], + scale = self.params['jpsi_scale'], + phase = self.params['jpsi_phase'], + width = self.params['jpsi_width']) + def psi2s_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['psi2s_mass'], 2)) * resonance(q, _mass = self.params['psi2s_mass'], + scale = self.params['psi2s_scale'], + phase = self.params['psi2s_phase'], + width = self.params['psi2s_width']) + def p3770_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p3770_mass'], 2)) * resonance(q, _mass = self.params['p3770_mass'], + scale = self.params['p3770_scale'], + phase = self.params['p3770_phase'], + width = self.params['p3770_width']) + + def p4040_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4040_mass'], 2)) * resonance(q, _mass = self.params['p4040_mass'], + scale = self.params['p4040_scale'], + phase = self.params['p4040_phase'], + width = self.params['p4040_width']) + + def p4160_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4160_mass'], 2)) * resonance(q, _mass = self.params['p4160_mass'], + scale = self.params['p4160_scale'], + phase = self.params['p4160_phase'], + width = self.params['p4160_width']) + + def p4415_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4415_mass'], 2)) * resonance(q, _mass = self.params['p4415_mass'], + scale = self.params['p4415_scale'], + phase = self.params['p4415_phase'], + width = self.params['p4415_width']) + + def P2_D(q): + Dbar_contrib = ztf.to_complex(self.params['Dbar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['Dbar_phase']))*ztf.to_complex(h_S(self.params['Dbar_mass'], q)) + DDstar_contrib = ztf.to_complex(self.params['DDstar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['DDstar_phase']))*(ztf.to_complex(h_P(self.params['Dstar_mass'], q)) + ztf.to_complex(h_P(self.params['D_mass'], q))) + return Dbar_contrib + DDstar_contrib + + def ttau_cusp(q): + return ztf.to_complex(self.params['C_tt'])*(ztf.to_complex((h_S(self.params['tau_mass'], q))) - ztf.to_complex(h_P(self.params['tau_mass'], q))) + + + funcs = rho_res(x) + omega_res(x) + phi_res(x) + jpsi_res(x) + psi2s_res(x) + p3770_res(x) + p4040_res(x)+ p4160_res(x) + p4415_res(x) + P2_D(x) + ttau_cusp(x) + + vec_f = vec(x, funcs, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + axiv_nr = axiv_nonres(x, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + tot = vec_f + axiv_nr + + #Cut out jpsi and psi2s + +# tot = tf.where(tf.math.logical_or(x < ztf.constant(jpsi_mass-60.), x > ztf.constant(jpsi_mass+70.)), tot, 0.0*tot) + +# tot = tf.where(tf.math.logical_or(x < ztf.constant(psi2s_mass-50.), x > ztf.constant(psi2s_mass+50.)), tot, 0.0*tot) + + return tot + + +# ## Setup parameters + +# In[ ]: + + +# formfactors + +b0_0 = zfit.Parameter("b0_0", ztf.constant(0.292), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +b0_1 = zfit.Parameter("b0_1", ztf.constant(0.281), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +b0_2 = zfit.Parameter("b0_2", ztf.constant(0.150), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) + +bplus_0 = zfit.Parameter("bplus_0", ztf.constant(0.466), lower_limit = -2.0, upper_limit= 2.0) +bplus_1 = zfit.Parameter("bplus_1", ztf.constant(-0.885), lower_limit = -2.0, upper_limit= 2.0) +bplus_2 = zfit.Parameter("bplus_2", ztf.constant(-0.213), lower_limit = -2.0, upper_limit= 2.0) + +bT_0 = zfit.Parameter("bT_0", ztf.constant(0.460), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +bT_1 = zfit.Parameter("bT_1", ztf.constant(-1.089), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +bT_2 = zfit.Parameter("bT_2", ztf.constant(-1.114), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) + + +#rho + +rho_mass, rho_width, rho_phase, rho_scale = pdg["rho"] + +rho_m = zfit.Parameter("rho_m", ztf.constant(rho_mass), floating = False) #lower_limit = rho_mass - rho_width, upper_limit = rho_mass + rho_width) +rho_w = zfit.Parameter("rho_w", ztf.constant(rho_width), floating = False) +rho_p = zfit.Parameter("rho_p", ztf.constant(rho_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +rho_s = zfit.Parameter("rho_s", ztf.constant(rho_scale), lower_limit=rho_scale-np.sqrt(rho_scale), upper_limit=rho_scale+np.sqrt(rho_scale)) + +#omega + +omega_mass, omega_width, omega_phase, omega_scale = pdg["omega"] + +omega_m = zfit.Parameter("omega_m", ztf.constant(omega_mass), floating = False) +omega_w = zfit.Parameter("omega_w", ztf.constant(omega_width), floating = False) +omega_p = zfit.Parameter("omega_p", ztf.constant(omega_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +omega_s = zfit.Parameter("omega_s", ztf.constant(omega_scale), lower_limit=omega_scale-np.sqrt(omega_scale), upper_limit=omega_scale+np.sqrt(omega_scale)) + + +#phi + +phi_mass, phi_width, phi_phase, phi_scale = pdg["phi"] + +phi_m = zfit.Parameter("phi_m", ztf.constant(phi_mass), floating = False) +phi_w = zfit.Parameter("phi_w", ztf.constant(phi_width), floating = False) +phi_p = zfit.Parameter("phi_p", ztf.constant(phi_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +phi_s = zfit.Parameter("phi_s", ztf.constant(phi_scale), lower_limit=phi_scale-np.sqrt(phi_scale), upper_limit=phi_scale+np.sqrt(phi_scale)) + +#jpsi + +jpsi_mass, jpsi_width, jpsi_phase, jpsi_scale = pdg["jpsi"] + +jpsi_m = zfit.Parameter("jpsi_m", ztf.constant(jpsi_mass), floating = False) +jpsi_w = zfit.Parameter("jpsi_w", ztf.constant(jpsi_width), floating = False) +jpsi_p = zfit.Parameter("jpsi_p", ztf.constant(jpsi_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +jpsi_s = zfit.Parameter("jpsi_s", ztf.constant(jpsi_scale), floating = False) #, lower_limit=jpsi_scale-np.sqrt(jpsi_scale), upper_limit=jpsi_scale+np.sqrt(jpsi_scale)) + +#psi2s + +psi2s_mass, psi2s_width, psi2s_phase, psi2s_scale = pdg["psi2s"] + +psi2s_m = zfit.Parameter("psi2s_m", ztf.constant(psi2s_mass), floating = False) +psi2s_w = zfit.Parameter("psi2s_w", ztf.constant(psi2s_width), floating = False) +psi2s_p = zfit.Parameter("psi2s_p", ztf.constant(psi2s_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +psi2s_s = zfit.Parameter("psi2s_s", ztf.constant(psi2s_scale), floating = False) #, lower_limit=psi2s_scale-np.sqrt(psi2s_scale), upper_limit=psi2s_scale+np.sqrt(psi2s_scale)) + +#psi(3770) + +p3770_mass, p3770_width, p3770_phase, p3770_scale = pdg["p3770"] + +p3770_m = zfit.Parameter("p3770_m", ztf.constant(p3770_mass), floating = False) +p3770_w = zfit.Parameter("p3770_w", ztf.constant(p3770_width), floating = False) +p3770_p = zfit.Parameter("p3770_p", ztf.constant(p3770_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p3770_s = zfit.Parameter("p3770_s", ztf.constant(p3770_scale), lower_limit=p3770_scale-np.sqrt(p3770_scale), upper_limit=p3770_scale+np.sqrt(p3770_scale)) + +#psi(4040) + +p4040_mass, p4040_width, p4040_phase, p4040_scale = pdg["p4040"] + +p4040_m = zfit.Parameter("p4040_m", ztf.constant(p4040_mass), floating = False) +p4040_w = zfit.Parameter("p4040_w", ztf.constant(p4040_width), floating = False) +p4040_p = zfit.Parameter("p4040_p", ztf.constant(p4040_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p4040_s = zfit.Parameter("p4040_s", ztf.constant(p4040_scale), lower_limit=p4040_scale-np.sqrt(p4040_scale), upper_limit=p4040_scale+np.sqrt(p4040_scale)) + +#psi(4160) + +p4160_mass, p4160_width, p4160_phase, p4160_scale = pdg["p4160"] + +p4160_m = zfit.Parameter("p4160_m", ztf.constant(p4160_mass), floating = False) +p4160_w = zfit.Parameter("p4160_w", ztf.constant(p4160_width), floating = False) +p4160_p = zfit.Parameter("p4160_p", ztf.constant(p4160_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p4160_s = zfit.Parameter("p4160_s", ztf.constant(p4160_scale), lower_limit=p4160_scale-np.sqrt(p4160_scale), upper_limit=p4160_scale+np.sqrt(p4160_scale)) + +#psi(4415) + +p4415_mass, p4415_width, p4415_phase, p4415_scale = pdg["p4415"] + +p4415_m = zfit.Parameter("p4415_m", ztf.constant(p4415_mass), floating = False) +p4415_w = zfit.Parameter("p4415_w", ztf.constant(p4415_width), floating = False) +p4415_p = zfit.Parameter("p4415_p", ztf.constant(p4415_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p4415_s = zfit.Parameter("p4415_s", ztf.constant(p4415_scale), lower_limit=p4415_scale-np.sqrt(p4415_scale), upper_limit=p4415_scale+np.sqrt(p4415_scale)) + + +# ## Dynamic generation of 2 particle contribution + +# In[ ]: + + +m_c = 1300 + +Dbar_phase = 0.0 +DDstar_phase = 0.0 +Dstar_mass = pdg['Dst_M'] +Dbar_mass = pdg['D0_M'] +D_mass = pdg['D0_M'] + +Dbar_s = zfit.Parameter("Dbar_s", ztf.constant(0.0), lower_limit=-0.3, upper_limit=0.3) +Dbar_m = zfit.Parameter("Dbar_m", ztf.constant(Dbar_mass), floating = False) +Dbar_p = zfit.Parameter("Dbar_p", ztf.constant(Dbar_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi)#, floating = False) +DDstar_s = zfit.Parameter("DDstar_s", ztf.constant(0.0), lower_limit=-0.3, upper_limit=0.3)#, floating = False) +Dstar_m = zfit.Parameter("Dstar_m", ztf.constant(Dstar_mass), floating = False) +D_m = zfit.Parameter("D_m", ztf.constant(D_mass), floating = False) +DDstar_p = zfit.Parameter("DDstar_p", ztf.constant(DDstar_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi)#, floating = False) + + +# ## Tau parameters + +# In[ ]: + + +tau_m = zfit.Parameter("tau_m", ztf.constant(pdg['tau_M']), floating = False) +Ctt = zfit.Parameter("Ctt", ztf.constant(0.0), lower_limit=-2.5, upper_limit=2.5) + + +# ## Load data + +# In[ ]: + + +x_min = 2*pdg['muon_M'] +x_max = (pdg["Bplus_M"]-pdg["Ks_M"]-0.1) + +# # Full spectrum + +obs_toy = zfit.Space('q', limits = (x_min, x_max)) + +# Jpsi and Psi2s cut out + +obs1 = zfit.Space('q', limits = (x_min, jpsi_mass - 60.)) +obs2 = zfit.Space('q', limits = (jpsi_mass + 70., psi2s_mass - 50.)) +obs3 = zfit.Space('q', limits = (psi2s_mass + 50., x_max)) + +obs_fit = obs1 + obs2 + obs3 + +# with open(r"./data/slim_points/slim_points_toy_0_range({0}-{1}).pkl".format(int(x_min), int(x_max)), "rb") as input_file: +# part_set = pkl.load(input_file) + +# x_part = part_set['x_part'] + +# x_part = x_part.astype('float64') + +# data = zfit.data.Data.from_numpy(array=x_part, obs=obs) + + +# ## Setup pdf + +# In[ ]: + + +total_f = total_pdf_cut(obs=obs_toy, jpsi_mass = jpsi_m, jpsi_scale = jpsi_s, jpsi_phase = jpsi_p, jpsi_width = jpsi_w, + psi2s_mass = psi2s_m, psi2s_scale = psi2s_s, psi2s_phase = psi2s_p, psi2s_width = psi2s_w, + p3770_mass = p3770_m, p3770_scale = p3770_s, p3770_phase = p3770_p, p3770_width = p3770_w, + p4040_mass = p4040_m, p4040_scale = p4040_s, p4040_phase = p4040_p, p4040_width = p4040_w, + p4160_mass = p4160_m, p4160_scale = p4160_s, p4160_phase = p4160_p, p4160_width = p4160_w, + p4415_mass = p4415_m, p4415_scale = p4415_s, p4415_phase = p4415_p, p4415_width = p4415_w, + rho_mass = rho_m, rho_scale = rho_s, rho_phase = rho_p, rho_width = rho_w, + omega_mass = omega_m, omega_scale = omega_s, omega_phase = omega_p, omega_width = omega_w, + phi_mass = phi_m, phi_scale = phi_s, phi_phase = phi_p, phi_width = phi_w, + Dstar_mass = Dstar_m, DDstar_scale = DDstar_s, DDstar_phase = DDstar_p, D_mass = D_m, + Dbar_mass = Dbar_m, Dbar_scale = Dbar_s, Dbar_phase = Dbar_p, + tau_mass = tau_m, C_tt = Ctt, b0_0 = b0_0, b0_1 = b0_1, b0_2 = b0_2, + bplus_0 = bplus_0, bplus_1 = bplus_1, bplus_2 = bplus_2, + bT_0 = bT_0, bT_1 = bT_1, bT_2 = bT_2) + +total_f_fit = total_pdf_full(obs=obs_fit, jpsi_mass = jpsi_m, jpsi_scale = jpsi_s, jpsi_phase = jpsi_p, jpsi_width = jpsi_w, + psi2s_mass = psi2s_m, psi2s_scale = psi2s_s, psi2s_phase = psi2s_p, psi2s_width = psi2s_w, + p3770_mass = p3770_m, p3770_scale = p3770_s, p3770_phase = p3770_p, p3770_width = p3770_w, + p4040_mass = p4040_m, p4040_scale = p4040_s, p4040_phase = p4040_p, p4040_width = p4040_w, + p4160_mass = p4160_m, p4160_scale = p4160_s, p4160_phase = p4160_p, p4160_width = p4160_w, + p4415_mass = p4415_m, p4415_scale = p4415_s, p4415_phase = p4415_p, p4415_width = p4415_w, + rho_mass = rho_m, rho_scale = rho_s, rho_phase = rho_p, rho_width = rho_w, + omega_mass = omega_m, omega_scale = omega_s, omega_phase = omega_p, omega_width = omega_w, + phi_mass = phi_m, phi_scale = phi_s, phi_phase = phi_p, phi_width = phi_w, + Dstar_mass = Dstar_m, DDstar_scale = DDstar_s, DDstar_phase = DDstar_p, D_mass = D_m, + Dbar_mass = Dbar_m, Dbar_scale = Dbar_s, Dbar_phase = Dbar_p, + tau_mass = tau_m, C_tt = Ctt, b0_0 = b0_0, b0_1 = b0_1, b0_2 = b0_2, + bplus_0 = bplus_0, bplus_1 = bplus_1, bplus_2 = bplus_2, + bT_0 = bT_0, bT_1 = bT_1, bT_2 = bT_2) + +# print(total_pdf.obs) + +# print(calcs_test) + +# for param in total_f.get_dependents(): +# print(zfit.run(param)) + + +# In[ ]: + + +# total_f_fit.normalization(obs_fit) + + +# ## Test if graphs actually work and compute values + +# In[ ]: + + +# def total_test_tf(xq): + +# def jpsi_res(q): +# return resonance(q, jpsi_m, jpsi_s, jpsi_p, jpsi_w) + +# def psi2s_res(q): +# return resonance(q, psi2s_m, psi2s_s, psi2s_p, psi2s_w) + +# def cusp(q): +# return bifur_gauss(q, cusp_m, sig_L, sig_R, cusp_s) + +# funcs = jpsi_res(xq) + psi2s_res(xq) + cusp(xq) + +# vec_f = vec(xq, funcs) + +# axiv_nr = axiv_nonres(xq) + +# tot = vec_f + axiv_nr + +# return tot + +# def jpsi_res(q): +# return resonance(q, jpsi_m, jpsi_s, jpsi_p, jpsi_w) + +# calcs = zfit.run(total_test_tf(x_part)) + + + +test_q = np.linspace(x_min, x_max, int(2e6)) + +probs = total_f_fit.pdf(test_q, norm_range=False) + +calcs_test = zfit.run(probs) + +Ctt.set_value(0.5) + +calcs_test1 = zfit.run(probs) + +Ctt.set_value(0.0) + +Dbar_s.set_value(0.3) + +DDstar_s.set_value(0.3) + +calcs_test2 = zfit.run(probs) +# res_y = zfit.run(jpsi_res(test_q)) +# b0 = [b0_0, b0_1, b0_2] +# bplus = [bplus_0, bplus_1, bplus_2] +# bT = [bT_0, bT_1, bT_2] +# f0_y = zfit.run(tf.math.real(formfactor(test_q,"0", b0, bplus, bT))) +# fplus_y = zfit.run(tf.math.real(formfactor(test_q,"+", b0, bplus, bT))) +# fT_y = zfit.run(tf.math.real(formfactor(test_q,"T", b0, bplus, bT))) + + +# In[ ]: + + +plt.clf() +# plt.plot(x_part, calcs, '.') +plt.plot(test_q, calcs_test, label = 'pdf (Ctt = 0.0)') +plt.plot(test_q, calcs_test1, label = 'pdf (Ctt = 0.5)') +plt.plot(test_q, calcs_test2, label = 'pdf (D-contribs = 0.3)') +# plt.plot(test_q, f0_y, label = '0') +# plt.plot(test_q, fT_y, label = 'T') +# plt.plot(test_q, fplus_y, label = '+') +# plt.plot(test_q, res_y, label = 'res') +plt.legend() +plt.ylim(0.0, 1.5e-6) +# plt.yscale('log') +# plt.xlim(770, 785) +plt.savefig('test.png') +# print(jpsi_width) + + +# In[ ]: + + + + +# probs = mixture.prob(test_q) +# probs_np = zfit.run(probs) +# probs_np *= np.max(calcs_test) / np.max(probs_np) +# plt.figure() +# plt.semilogy(test_q, probs_np,label="importance sampling") +# plt.semilogy(test_q, calcs_test, label = 'pdf') + + +# In[ ]: + + +# 0.213/(0.00133+0.213+0.015) + + +# ## Adjust scaling of different parts + +# In[ ]: + + +total_f.update_integration_options(draws_per_dim=2000000, mc_sampler=None) +# inte = total_f.integrate(limits = (950., 1050.), norm_range=False) +# inte_fl = zfit.run(inte) +# print(inte_fl/4500) +# print(pdg["jpsi_BR"]/pdg["NR_BR"], inte_fl*pdg["psi2s_auc"]/pdg["NR_auc"]) + + +# In[ ]: + + +# # print("jpsi:", inte_fl) +# # print("Increase am by factor:", np.sqrt(pdg["jpsi_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) +# # print("New amp:", pdg["jpsi"][3]*np.sqrt(pdg["jpsi_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) + +# # print("psi2s:", inte_fl) +# # print("Increase am by factor:", np.sqrt(pdg["psi2s_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) +# # print("New amp:", pdg["psi2s"][3]*np.sqrt(pdg["psi2s_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) + +# name = "phi" + +# print(name+":", inte_fl) +# print("Increase am by factor:", np.sqrt(pdg[name+"_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) +# print("New amp:", pdg[name][0]*np.sqrt(pdg[name+"_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) + + +# print(x_min) +# print(x_max) +# # total_f.update_integration_options(draws_per_dim=2000000, mc_sampler=None) +# total_f.update_integration_options(mc_sampler=lambda dim, num_results, +# dtype: tf.random_uniform(maxval=1., shape=(num_results, dim), dtype=dtype), +# draws_per_dim=1000000) +# # _ = [] + +# # for i in range(10): + +# # inte = total_f.integrate(limits = (x_min, x_max)) +# # inte_fl = zfit.run(inte) +# # print(inte_fl) +# # _.append(inte_fl) + +# # print("mean:", np.mean(_)) + +# _ = time.time() + +# inte = total_f.integrate(limits = (x_min, x_max)) +# inte_fl = zfit.run(inte) +# print(inte_fl) +# print("Time taken: {}".format(display_time(int(time.time() - _)))) + +# print(pdg['NR_BR']/pdg['NR_auc']*inte_fl) +# print(0.25**2*4.2/1000) + + +# # Sampling +# ## Mixture distribution for sampling + +# In[ ]: + + + + +# print(list_of_borders[:9]) +# print(list_of_borders[-9:]) + + +class UniformSampleAndWeights(zfit.util.execution.SessionHolderMixin): + def __call__(self, limits, dtype, n_to_produce): + # n_to_produce = tf.cast(n_to_produce, dtype=tf.int32) + low, high = limits.limit1d + low = tf.cast(low, dtype=dtype) + high = tf.cast(high, dtype=dtype) +# uniform = tfd.Uniform(low=low, high=high) +# uniformjpsi = tfd.Uniform(low=tf.constant(3080, dtype=dtype), high=tf.constant(3112, dtype=dtype)) +# uniformpsi2s = tfd.Uniform(low=tf.constant(3670, dtype=dtype), high=tf.constant(3702, dtype=dtype)) + +# list_of_borders = [] +# _p = [] +# splits = 10 + +# _ = np.linspace(x_min, x_max, splits) + +# for i in range(splits): +# list_of_borders.append(tf.constant(_[i], dtype=dtype)) +# _p.append(tf.constant(1/splits, dtype=dtype)) + +# mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=_p[:(splits-1)]), +# components_distribution=tfd.Uniform(low=list_of_borders[:(splits-1)], +# high=list_of_borders[-(splits-1):])) + mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=[tf.constant(0.05, dtype=dtype), + tf.constant(0.93, dtype=dtype), + tf.constant(0.05, dtype=dtype), + tf.constant(0.065, dtype=dtype), + tf.constant(0.04, dtype=dtype), + tf.constant(0.05, dtype=dtype)]), + components_distribution=tfd.Uniform(low=[tf.constant(x_min, dtype=dtype), + tf.constant(3090, dtype=dtype), + tf.constant(3681, dtype=dtype), + tf.constant(3070, dtype=dtype), + tf.constant(1000, dtype=dtype), + tf.constant(3660, dtype=dtype)], + high=[tf.constant(x_max, dtype=dtype), + tf.constant(3102, dtype=dtype), + tf.constant(3691, dtype=dtype), + tf.constant(3110, dtype=dtype), + tf.constant(1040, dtype=dtype), + tf.constant(3710, dtype=dtype)])) +# dtype = tf.float64 +# mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=[tf.constant(0.04, dtype=dtype), +# tf.constant(0.90, dtype=dtype), +# tf.constant(0.02, dtype=dtype), +# tf.constant(0.07, dtype=dtype), +# tf.constant(0.02, dtype=dtype)]), +# components_distribution=tfd.Uniform(low=[tf.constant(x_min, dtype=dtype), +# tf.constant(3089, dtype=dtype), +# tf.constant(3103, dtype=dtype), +# tf.constant(3681, dtype=dtype), +# tf.constant(3691, dtype=dtype)], +# high=[tf.constant(3089, dtype=dtype), +# tf.constant(3103, dtype=dtype), +# tf.constant(3681, dtype=dtype), +# tf.constant(3691, dtype=dtype), +# tf.constant(x_max, dtype=dtype)])) +# mixture = tfd.Uniform(tf.constant(x_min, dtype=dtype), tf.constant(x_max, dtype=dtype)) +# sample = tf.random.uniform((n_to_produce, 1), dtype=dtype) + sample = mixture.sample((n_to_produce, 1)) +# sample = tf.random.uniform((n_to_produce, 1), dtype=dtype) + weights = mixture.prob(sample)[:,0] +# weights = tf.broadcast_to(tf.constant(1., dtype=dtype), shape=(n_to_produce,)) + # sample = tf.expand_dims(sample, axis=-1) +# print(sample, weights) + +# weights = tf.ones(shape=(n_to_produce,), dtype=dtype) + weights_max = None + thresholds = tf.random_uniform(shape=(n_to_produce,), dtype=dtype) + return sample, thresholds, weights, weights_max, n_to_produce + + +# In[ ]: + + +# total_f._sample_and_weights = UniformSampleAndWeights + + +# In[ ]: + + +# 0.00133/(0.00133+0.213+0.015)*(x_max-3750)/(x_max-x_min) + + +# In[ ]: + + +# zfit.settings.set_verbosity(10) + + +# In[ ]: + + +# # zfit.run.numeric_checks = False + +# nr_of_toys = 1 +# nevents = int(pdg["number_of_decays"]) +# nevents = pdg["number_of_decays"] +# event_stack = 1000000 +# # zfit.settings.set_verbosity(10) +# calls = int(nevents/event_stack + 1) + +# total_samp = [] + +# start = time.time() + +# sampler = total_f.create_sampler(n=event_stack) + +# for toy in range(nr_of_toys): + +# dirName = 'data/zfit_toys/toy_{0}'.format(toy) + +# if not os.path.exists(dirName): +# os.mkdir(dirName) +# print("Directory " , dirName , " Created ") + +# for call in range(calls): + +# sampler.resample(n=event_stack) +# s = sampler.unstack_x() +# sam = zfit.run(s) +# # clear_output(wait=True) + +# c = call + 1 + +# print("{0}/{1} of Toy {2}/{3}".format(c, calls, toy+1, nr_of_toys)) +# print("Time taken: {}".format(display_time(int(time.time() - start)))) +# print("Projected time left: {}".format(display_time(int((time.time() - start)/(c+calls*(toy))*((nr_of_toys-toy)*calls-c))))) + +# with open("data/zfit_toys/toy_{0}/{1}.pkl".format(toy, call), "wb") as f: +# pkl.dump(sam, f, pkl.HIGHEST_PROTOCOL) + + +# In[ ]: + + +# with open(r"data/zfit_toys/toy_0/0.pkl", "rb") as input_file: +# sam = pkl.load(input_file) +# print(sam[:10]) + +# with open(r"data/zfit_toys/toy_0/1.pkl", "rb") as input_file: +# sam2 = pkl.load(input_file) +# print(sam2[:10]) + +# print(np.sum(sam-sam2)) + + +# In[ ]: + + +# print("Time to generate full toy: {} s".format(int(time.time()-start))) + +# total_samp = [] + +# for call in range(calls): +# with open(r"data/zfit_toys/toy_0/{}.pkl".format(call), "rb") as input_file: +# sam = pkl.load(input_file) +# total_samp = np.append(total_samp, sam) + +# total_samp = total_samp.astype('float64') + +# data2 = zfit.data.Data.from_numpy(array=total_samp[:int(nevents)], obs=obs) + +# data3 = zfit.data.Data.from_numpy(array=total_samp, obs=obs) + +# print(total_samp[:nevents].shape) + + +# In[ ]: + + +# plt.clf() + +# bins = int((x_max-x_min)/7) + +# # calcs = zfit.run(total_test_tf(samp)) +# print(total_samp[:nevents].shape) + +# plt.hist(total_samp[:nevents], bins = bins, range = (x_min,x_max), label = 'data') +# # plt.plot(test_q, calcs_test*nevents , label = 'pdf') + +# # plt.plot(sam, calcs, '.') +# # plt.plot(test_q, calcs_test) +# # plt.yscale('log') +# plt.ylim(0, 200) +# # plt.xlim(3080, 3110) + +# plt.legend() + +# plt.savefig('test2.png') + + +# In[ ]: + + +# sampler = total_f.create_sampler(n=nevents) +# nll = zfit.loss.UnbinnedNLL(model=total_f, data=sampler, fit_range = (x_min, x_max)) + +# # for param in pdf.get_dependents(): +# # param.set_value(initial_value) + +# sampler.resample(n=nevents) + +# # Randomise initial values +# # for param in pdf.get_dependents(): +# # param.set_value(random value here) + +# # Minimise the NLL +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 10) +# minimum = minimizer.minimize(nll) + + +# In[ ]: + + +# jpsi_width + + +# In[ ]: + + +# plt.hist(sample, weights=1 / prob(sample)) + + +# # Fitting + +# In[ ]: + + +# start = time.time() + +# for param in total_f.get_dependents(): +# param.randomize() + +# # for param in total_f.get_dependents(): +# # print(zfit.run(param)) + +# nll = zfit.loss.UnbinnedNLL(model=total_f, data=data2, fit_range = (x_min, x_max)) + +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) +# # minimizer._use_tfgrad = False +# result = minimizer.minimize(nll) + +# # param_errors = result.error() + +# # for var, errors in param_errors.items(): +# # print('{}: ^{{+{}}}_{{{}}}'.format(var.name, errors['upper'], errors['lower'])) + +# print("Function minimum:", result.fmin) +# # print("Results:", result.params) +# print("Hesse errors:", result.hesse()) + + +# In[ ]: + + +# print("Time taken for fitting: {}".format(display_time(int(time.time()-start)))) + +# # probs = total_f.pdf(test_q) + +# calcs_test = zfit.run(probs) +# res_y = zfit.run(jpsi_res(test_q)) + + +# In[ ]: + + +# plt.clf() +# # plt.plot(x_part, calcs, '.') +# plt.plot(test_q, calcs_test, label = 'pdf') +# # plt.plot(test_q, res_y, label = 'res') +# plt.legend() +# plt.ylim(0.0, 10e-6) +# # plt.yscale('log') +# # plt.xlim(3080, 3110) +# plt.savefig('test3.png') +# # print(jpsi_width) + + +# In[ ]: + + +# _tot = 4.37e-7+6.02e-5+4.97e-6 +# _probs = [] +# _probs.append(6.02e-5/_tot) +# _probs.append(4.97e-6/_tot) +# _probs.append(4.37e-7/_tot) +# print(_probs) + + +# In[ ]: + + +# dtype = 'float64' +# # mixture = tfd.Uniform(tf.constant(x_min, dtype=dtype), tf.constant(x_max, dtype=dtype)) +# mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=[tf.constant(0.007, dtype=dtype), +# tf.constant(0.917, dtype=dtype), +# tf.constant(0.076, dtype=dtype)]), +# components_distribution=tfd.Uniform(low=[tf.constant(x_min, dtype=dtype), +# tf.constant(3080, dtype=dtype), +# tf.constant(3670, dtype=dtype)], +# high=[tf.constant(x_max, dtype=dtype), +# tf.constant(3112, dtype=dtype), +# tf.constant(3702, dtype=dtype)])) +# # for i in range(10): +# # print(zfit.run(mixture.prob(mixture.sample((10, 1))))) + + +# In[ ]: + + +# print((zfit.run(jpsi_p)%(2*np.pi))/np.pi) +# print((zfit.run(psi2s_p)%(2*np.pi))/np.pi) + + +# In[ ]: + + +# def jpsi_res(q): +# return resonance(q, _mass = jpsi_mass, scale = jpsi_scale, +# phase = jpsi_phase, width = jpsi_width) + +# def psi2s_res(q): +# return resonance(q, _mass = psi2s_mass, scale = psi2s_scale, +# phase = psi2s_phase, width = psi2s_width) + +# def p3770_res(q): +# return resonance(q, _mass = p3770_mass, scale = p3770_scale, +# phase = p3770_phase, width = p3770_width) + +# def p4040_res(q): +# return resonance(q, _mass = p4040_mass, scale = p4040_scale, +# phase = p4040_phase, width = p4040_width) + +# def p4160_res(q): +# return resonance(q, _mass = p4160_mass, scale = p4160_scale, +# phase = p4160_phase, width = p4160_width) + +# def p4415_res(q): +# return resonance(q, _mass = p4415_mass, scale = p4415_scale, +# phase = p4415_phase, width = p4415_width) + + +# In[ ]: + + +# 0.15**2*4.2/1000 +# result.hesse() + + +# ## Constraints + +# In[ ]: + + +# 1. Constraint - Real part of sum of Psi contrib and D contribs + +sum_list = [] + +sum_list.append(ztf.to_complex(jpsi_s) * tf.exp(tf.complex(ztf.constant(0.0), jpsi_p)) * ztf.to_complex(jpsi_w / (tf.pow(jpsi_m,3)))) +sum_list.append(ztf.to_complex(psi2s_s) * tf.exp(tf.complex(ztf.constant(0.0), psi2s_p)) * ztf.to_complex(psi2s_w / (tf.pow(psi2s_m,3)))) +sum_list.append(ztf.to_complex(p3770_s) * tf.exp(tf.complex(ztf.constant(0.0), p3770_p)) * ztf.to_complex(p3770_w / (tf.pow(p3770_m,3)))) +sum_list.append(ztf.to_complex(p4040_s) * tf.exp(tf.complex(ztf.constant(0.0), p4040_p)) * ztf.to_complex(p4040_w / (tf.pow(p4040_m,3)))) +sum_list.append(ztf.to_complex(p4160_s) * tf.exp(tf.complex(ztf.constant(0.0), p4160_p)) * ztf.to_complex(p4160_w / (tf.pow(p4160_m,3)))) +sum_list.append(ztf.to_complex(p4415_s) * tf.exp(tf.complex(ztf.constant(0.0), p4415_p)) * ztf.to_complex(p4415_w / (tf.pow(p4415_m,3)))) +sum_list.append(ztf.to_complex(DDstar_s) * tf.exp(tf.complex(ztf.constant(0.0), DDstar_p)) * (ztf.to_complex(1.0 / (10.0*tf.pow(Dstar_m,2)) + 1.0 / (10.0*tf.pow(D_m,2))))) +sum_list.append(ztf.to_complex(Dbar_s) * tf.exp(tf.complex(ztf.constant(0.0), Dbar_p)) * ztf.to_complex(1.0 / (6.0*tf.pow(Dbar_m,2)))) + +sum_ru_1 = ztf.to_complex(ztf.constant(0.0)) + +for part in sum_list: + sum_ru_1 += part + +sum_1 = tf.math.real(sum_ru_1) +# constraint1 = zfit.constraint.GaussianConstraint(params = sum_1, mu = ztf.constant(1.7*10**-8), +# sigma = ztf.constant(2.2*10**-8)) + +constraint1 = tf.pow((sum_1-ztf.constant(1.7*10**-8))/ztf.constant(2.2*10**-8),2)/ztf.constant(2.) + +# 2. Constraint - Abs. of sum of Psi contribs and D contribs + +sum_2 = tf.abs(sum_ru_1) +constraint2 = tf.cond(tf.greater_equal(sum_2, 5.0e-8), lambda: 100000., lambda: 0.) + +# 3. Constraint - Maximum eta of D contribs + +constraint3_0 = tf.cond(tf.greater_equal(tf.abs(Dbar_s), 0.2), lambda: 100000., lambda: 0.) + +constraint3_1 = tf.cond(tf.greater_equal(tf.abs(DDstar_s), 0.2), lambda: 100000., lambda: 0.) + +# 4. Constraint - Formfactor multivariant gaussian covariance fplus + +Cov_matrix = [[ztf.constant( 1.), ztf.constant( 0.45), ztf.constant( 0.19), ztf.constant(0.857), ztf.constant(0.598), ztf.constant(0.531), ztf.constant(0.752), ztf.constant(0.229), ztf.constant(0,117)], + [ztf.constant( 0.45), ztf.constant( 1.), ztf.constant(0.677), ztf.constant(0.708), ztf.constant(0.958), ztf.constant(0.927), ztf.constant(0.227), ztf.constant(0.443), ztf.constant(0.287)], + [ztf.constant( 0.19), ztf.constant(0.677), ztf.constant( 1.), ztf.constant(0.595), ztf.constant(0.770), ztf.constant(0.819),ztf.constant(-0.023), ztf.constant( 0.07), ztf.constant(0.196)], + [ztf.constant(0.857), ztf.constant(0.708), ztf.constant(0.595), ztf.constant( 1.), ztf.constant( 0.83), ztf.constant(0.766), ztf.constant(0.582), ztf.constant(0.237), ztf.constant(0.192)], + [ztf.constant(0.598), ztf.constant(0.958), ztf.constant(0.770), ztf.constant( 0.83), ztf.constant( 1.), ztf.constant(0.973), ztf.constant(0.324), ztf.constant(0.372), ztf.constant(0.272)], + [ztf.constant(0.531), ztf.constant(0.927), ztf.constant(0.819), ztf.constant(0.766), ztf.constant(0.973), ztf.constant( 1.), ztf.constant(0.268), ztf.constant(0.332), ztf.constant(0.269)], + [ztf.constant(0.752), ztf.constant(0.227),ztf.constant(-0.023), ztf.constant(0.582), ztf.constant(0.324), ztf.constant(0.268), ztf.constant( 1.), ztf.constant( 0.59), ztf.constant(0.515)], + [ztf.constant(0.229), ztf.constant(0.443), ztf.constant( 0.07), ztf.constant(0.237), ztf.constant(0.372), ztf.constant(0.332), ztf.constant( 0.59), ztf.constant( 1.), ztf.constant(0.897)], + [ztf.constant(0.117), ztf.constant(0.287), ztf.constant(0.196), ztf.constant(0.192), ztf.constant(0.272), ztf.constant(0.269), ztf.constant(0.515), ztf.constant(0.897), ztf.constant( 1.)]] + +def triGauss(val1,val2,val3,m = Cov_matrix): + + mean1 = ztf.constant(0.466) + mean2 = ztf.constant(-0.885) + mean3 = ztf.constant(-0.213) + sigma1 = ztf.constant(0.014) + sigma2 = ztf.constant(0.128) + sigma3 = ztf.constant(0.548) + x1 = (val1-mean1)/sigma1 + x2 = (val2-mean2)/sigma2 + x3 = (val3-mean3)/sigma3 + rho12 = m[0][1] + rho13 = m[0][2] + rho23 = m[1][2] + w = x1*x1*(rho23*rho23-1) + x2*x2*(rho13*rho13-1)+x3*x3*(rho12*rho12-1)+2*(x1*x2*(rho12-rho13*rho23)+x1*x3*(rho13-rho12*rho23)+x2*x3*(rho23-rho12*rho13)) + d = 2*(rho12*rho12+rho13*rho13+rho23*rho23-2*rho12*rho13*rho23-1) + + fcn = -w/d + chisq = -2*fcn + return chisq + +constraint4 = triGauss(bplus_0, bplus_1, bplus_2) + +# mean1 = ztf.constant(0.466) +# mean2 = ztf.constant(-0.885) +# mean3 = ztf.constant(-0.213) +# sigma1 = ztf.constant(0.014) +# sigma2 = ztf.constant(0.128) +# sigma3 = ztf.constant(0.548) +# constraint4_0 = tf.pow((bplus_0-mean1)/sigma1,2)/ztf.constant(2.) +# constraint4_1 = tf.pow((bplus_1-mean2)/sigma2,2)/ztf.constant(2.) +# constraint4_2 = tf.pow((bplus_2-mean3)/sigma3,2)/ztf.constant(2.) + +# 5. Constraint - Abs. of sum of light contribs + +sum_list_5 = [] + +sum_list_5.append(rho_s*rho_w/rho_m) +sum_list_5.append(omega_s*omega_w/omega_m) +sum_list_5.append(phi_s*phi_w/phi_m) + + +sum_ru_5 = ztf.constant(0.0) + +for part in sum_list_5: + sum_ru_5 += part + +constraint5 = tf.cond(tf.greater_equal(tf.abs(sum_ru_5), ztf.constant(0.02)), lambda: 100000., lambda: 0.) + +# 6. Constraint on phases of Jpsi and Psi2s for cut out fit + + +# constraint6_0 = zfit.constraint.GaussianConstraint(params = jpsi_p, mu = ztf.constant(pdg["jpsi_phase_unc"]), +# sigma = ztf.constant(jpsi_phase)) +# constraint6_1 = zfit.constraint.GaussianConstraint(params = psi2s_p, mu = ztf.constant(pdg["psi2s_phase_unc"]), +# sigma = ztf.constant(psi2s_phase)) + +constraint6_0 = tf.pow((jpsi_p-ztf.constant(jpsi_phase))/ztf.constant(pdg["jpsi_phase_unc"]),2)/ztf.constant(2.) +constraint6_1 = tf.pow((psi2s_p-ztf.constant(psi2s_phase))/ztf.constant(pdg["psi2s_phase_unc"]),2)/ztf.constant(2.) + +# 7. Constraint on Ctt with higher limits + +constraint7 = tf.cond(tf.greater_equal(Ctt*Ctt, 0.25), lambda: 100000., lambda: 0.) + +constraint7dtype = tf.float64 + +# zfit.run(constraint6_0) + +# ztf.convert_to_tensor(constraint6_0) + +#List of all constraints + +constraints = [constraint1, constraint2, constraint3_0, constraint3_1,# constraint4, #constraint4_0, constraint4_1, constraint4_2, + constraint6_0, constraint6_1]#, constraint7] + + +# ## Reset params + +# In[ ]: + + +param_values_dic = { + 'jpsi_m': jpsi_mass, + 'jpsi_s': jpsi_scale, + 'jpsi_p': jpsi_phase, + 'jpsi_w': jpsi_width, + 'psi2s_m': psi2s_mass, + 'psi2s_s': psi2s_scale, + 'psi2s_p': psi2s_phase, + 'psi2s_w': psi2s_width, + 'p3770_m': p3770_mass, + 'p3770_s': p3770_scale, + 'p3770_p': p3770_phase, + 'p3770_w': p3770_width, + 'p4040_m': p4040_mass, + 'p4040_s': p4040_scale, + 'p4040_p': p4040_phase, + 'p4040_w': p4040_width, + 'p4160_m': p4160_mass, + 'p4160_s': p4160_scale, + 'p4160_p': p4160_phase, + 'p4160_w': p4160_width, + 'p4415_m': p4415_mass, + 'p4415_s': p4415_scale, + 'p4415_p': p4415_phase, + 'p4415_w': p4415_width, + 'rho_m': rho_mass, + 'rho_s': rho_scale, + 'rho_p': rho_phase, + 'rho_w': rho_width, + 'omega_m': omega_mass, + 'omega_s': omega_scale, + 'omega_p': omega_phase, + 'omega_w': omega_width, + 'phi_m': phi_mass, + 'phi_s': phi_scale, + 'phi_p': phi_phase, + 'phi_w': phi_width, + 'Dstar_m': Dstar_mass, + 'DDstar_s': 0.0, + 'DDstar_p': 0.0, + 'D_m': D_mass, + 'Dbar_m': Dbar_mass, + 'Dbar_s': 0.0, + 'Dbar_p': 0.0, + 'tau_m': pdg['tau_M'], + 'Ctt': 0.0, + 'b0_0': 0.292, + 'b0_1': 0.281, + 'b0_2': 0.150, + 'bplus_0': 0.466, + 'bplus_1': -0.885, + 'bplus_2': -0.213, + 'bT_0': 0.460, + 'bT_1': -1.089, + 'bT_2': -1.114} + + +def reset_param_values(variation = 0.05): + for param in total_f_fit.get_dependents(): + if param.floating: + param.set_value(param_values_dic[param.name] + random.uniform(-1, 1) * param_values_dic[param.name]* variation) +# print(param.name) +# for param in totalf.get_dependents(): +# param.set_value() + + +# # Analysis + +# In[ ]: + + +# # zfit.run.numeric_checks = False + +# fitting_range = 'cut' +# total_BR = 1.7e-10 + 4.9e-10 + 2.5e-9 + 6.02e-5 + 4.97e-6 + 1.38e-9 + 4.2e-10 + 2.6e-9 + 6.1e-10 + 4.37e-7 +# cut_BR = 1.0 - (6.02e-5 + 4.97e-6)/total_BR + +# Ctt_list = [] +# Ctt_error_list = [] + +# nr_of_toys = 1 +# if fitting_range == 'cut': +# nevents = int(pdg["number_of_decays"]*cut_BR) +# else: +# nevents = int(pdg["number_of_decays"]) +# # nevents = pdg["number_of_decays"] +# event_stack = 1000000 +# # nevents *= 41 +# # zfit.settings.set_verbosity(10) +# calls = int(nevents/event_stack + 1) + +# total_samp = [] + +# start = time.time() + +# sampler = total_f.create_sampler(n=event_stack) + +# for toy in range(nr_of_toys): + +# ### Generate data + +# # clear_output(wait=True) + +# print("Toy {}: Generating data...".format(toy)) + +# dirName = 'data/zfit_toys/toy_{0}'.format(toy) + +# if not os.path.exists(dirName): +# os.mkdir(dirName) +# print("Directory " , dirName , " Created ") + +# reset_param_values() + +# if fitting_range == 'cut': + +# sampler.resample(n=nevents) +# s = sampler.unstack_x() +# sam = zfit.run(s) +# calls = 0 +# c = 1 + +# else: +# for call in range(calls): + +# sampler.resample(n=event_stack) +# s = sampler.unstack_x() +# sam = zfit.run(s) + +# c = call + 1 + +# with open("data/zfit_toys/toy_{0}/{1}.pkl".format(toy, call), "wb") as f: +# pkl.dump(sam, f, pkl.HIGHEST_PROTOCOL) + +# print("Toy {}: Data generation finished".format(toy)) + +# ### Load data + +# print("Toy {}: Loading data...".format(toy)) + +# if fitting_range == 'cut': + +# total_samp = sam + +# else: + +# for call in range(calls): +# with open(r"data/zfit_toys/toy_0/{}.pkl".format(call), "rb") as input_file: +# sam = pkl.load(input_file) +# total_samp = np.append(total_samp, sam) + +# total_samp = total_samp.astype('float64') + +# if fitting_range == 'full': + +# data = zfit.data.Data.from_numpy(array=total_samp[:int(nevents)], obs=obs) + +# print("Toy {}: Loading data finished".format(toy)) + +# ### Fit data + +# print("Toy {}: Fitting pdf...".format(toy)) + +# for param in total_f.get_dependents(): +# param.randomize() + +# nll = zfit.loss.UnbinnedNLL(model=total_f, data=data, fit_range = (x_min, x_max), constraints = constraints) + +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) +# # minimizer._use_tfgrad = False +# result = minimizer.minimize(nll) + +# print("Toy {}: Fitting finished".format(toy)) + +# print("Function minimum:", result.fmin) +# print("Hesse errors:", result.hesse()) + +# params = result.params +# Ctt_list.append(params[Ctt]['value']) +# Ctt_error_list.append(params[Ctt]['minuit_hesse']['error']) + +# #plotting the result + +# plotdirName = 'data/plots'.format(toy) + +# if not os.path.exists(plotdirName): +# os.mkdir(plotdirName) +# # print("Directory " , dirName , " Created ") + +# probs = total_f.pdf(test_q, norm_range=False) +# calcs_test = zfit.run(probs) +# plt.clf() +# plt.plot(test_q, calcs_test, label = 'pdf') +# plt.legend() +# plt.ylim(0.0, 6e-6) +# plt.savefig(plotdirName + '/toy_fit_full_range{}.png'.format(toy)) + +# print("Toy {0}/{1}".format(toy+1, nr_of_toys)) +# print("Time taken: {}".format(display_time(int(time.time() - start)))) +# print("Projected time left: {}".format(display_time(int((time.time() - start)/(c+calls*(toy))*((nr_of_toys-toy)*calls-c))))) + +# if fitting_range == 'cut': + +# _1 = np.where((total_samp >= x_min) & (total_samp <= (jpsi_mass - 60.))) + +# tot_sam_1 = total_samp[_1] + +# _2 = np.where((total_samp >= (jpsi_mass + 70.)) & (total_samp <= (psi2s_mass - 50.))) + +# tot_sam_2 = total_samp[_2] + +# _3 = np.where((total_samp >= (psi2s_mass + 50.)) & (total_samp <= x_max)) + +# tot_sam_3 = total_samp[_3] + +# tot_sam = np.append(tot_sam_1, tot_sam_2) +# tot_sam = np.append(tot_sam, tot_sam_3) + +# data = zfit.data.Data.from_numpy(array=tot_sam[:int(nevents)], obs=obs_fit) + +# print("Toy {}: Loading data finished".format(toy)) + +# ### Fit data + +# print("Toy {}: Fitting pdf...".format(toy)) + +# for param in total_f_fit.get_dependents(): +# param.randomize() + +# nll = zfit.loss.UnbinnedNLL(model=total_f_fit, data=data, constraints = constraints) + +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) +# # minimizer._use_tfgrad = False +# result = minimizer.minimize(nll) + +# print("Function minimum:", result.fmin) +# print("Hesse errors:", result.hesse()) + +# params = result.params + +# if result.converged: +# Ctt_list.append(params[Ctt]['value']) +# Ctt_error_list.append(params[Ctt]['minuit_hesse']['error']) + +# #plotting the result + +# plotdirName = 'data/plots'.format(toy) + +# if not os.path.exists(plotdirName): +# os.mkdir(plotdirName) +# # print("Directory " , dirName , " Created ") + +# plt.clf() +# plt.hist(tot_sam, bins = int((x_max-x_min)/7.), label = 'toy data') +# plt.savefig(plotdirName + '/toy_histo_cut_region{}.png'.format(toy)) + + +# probs = total_f_fit.pdf(test_q, norm_range=False) +# calcs_test = zfit.run(probs) +# plt.clf() +# plt.plot(test_q, calcs_test, label = 'pdf') +# plt.axvline(x=jpsi_mass-60.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.axvline(x=jpsi_mass+70.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.axvline(x=psi2s_mass-50.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.axvline(x=psi2s_mass+50.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.legend() +# plt.ylim(0.0, 1.5e-6) +# plt.savefig(plotdirName + '/toy_fit_cut_region{}.png'.format(toy)) + +# print("Toy {0}/{1}".format(toy+1, nr_of_toys)) +# print("Time taken: {}".format(display_time(int(time.time() - start)))) +# print("Projected time left: {}".format(display_time(int((time.time() - start)/(toy+1))*((nr_of_toys-toy-1))))) + + + +# In[ ]: + + +# with open("data/results/Ctt_list.pkl", "wb") as f: +# pkl.dump(Ctt_list, f, pkl.HIGHEST_PROTOCOL) +# with open("data/results/Ctt_error_list.pkl", "wb") as f: +# pkl.dump(Ctt_error_list, f, pkl.HIGHEST_PROTOCOL) + + +# In[ ]: + + +# print('{0}/{1} fits converged'.format(len(Ctt_list), nr_of_toys)) +# print('Mean Ctt value = {}'.format(np.mean(Ctt_list))) +# print('Mean Ctt error = {}'.format(np.mean(Ctt_error_list))) +# print('95 Sensitivy = {}'.format(((2*np.mean(Ctt_error_list))**2)*4.2/1000)) + + +# In[ ]: + + +# plt.hist(tot_sam, bins = int((x_max-x_min)/7.)) + +# plt.show() + +# # _ = np.where((total_samp >= x_min) & (total_samp <= (jpsi_mass - 50.))) + +# tot_sam.shape + + +# In[ ]: + + +# Ctt.floating = False + + +# In[ ]: + + +# zfit.run(nll.value()) + + +# In[ ]: + + +# result.fmin + + +# In[ ]: + + +# BR_steps = np.linspace(0.0, 1e-3, 11) +pull_dic = {} + +mi = 1e-4 +ma = 3e-3 +ste = 20 + +for param in total_f_fit.get_dependents(): + if param.floating: + pull_dic[param.name] = [] + for step in range(2*ste): + pull_dic[param.name].append([]) + + + +def save_pulls(step): + for param in total_f_fit.get_dependents(): + if param.floating: + pull_dic[param.name][step].append((params[param]['value'] - param_values_dic[param.name])/params[param]['minuit_hesse']['error']) + + + +# for key in pull_dic.keys(): +# print(np.shape(pull_dic[key])) +# save_pulls(New_step=True) +# params[Ctt]['value'] + + +# In[ ]: + + +# for param in total_f_fit.get_dependents(): +# if param.floating: +# print(param.name) + +# print(params[Ctt]) + + +# # CLS Code + +# In[ ]: + + +# zfit.run.numeric_checks = False + +load = False + +bo = True + +D_contribs = True + +if not D_contribs: + Dbar_s.floating = False + Dbar_p.floating = False + DDstar_s.floating = False + DDstar_p.floating = False + +bo_set = 1 + +fitting_range = 'cut' +total_BR = 1.7e-10 + 4.9e-10 + 2.5e-9 + 6.02e-5 + 4.97e-6 + 1.38e-9 + 4.2e-10 + 2.6e-9 + 6.1e-10 + 4.37e-7 +cut_BR = 1.0 - (6.02e-5 + 4.97e-6)/total_BR + +Ctt_list = [] +Ctt_error_list = [] + +nr_of_toys = 1 +nevents = int(pdg["number_of_decays"]*cut_BR) +# nevents = pdg["number_of_decays"] +event_stack = 1000000 +# nevents *= 41 +# zfit.settings.set_verbosity(10) + +# mi = 1e-4 +# ma = 3e-3 +# ste = 13 + +BR_steps = np.linspace(mi, ma, ste) + +BR_steps[0] = 0.0 + +print(BR_steps) + +Ctt_steps = np.sqrt(BR_steps/4.2*1000) + +print(Ctt_steps) + +# total_samp = [] + +start = time.time() + +Nll_list = [] + +sampler = total_f.create_sampler(n=nevents, fixed_params = False) +sampler.set_data_range(obs_fit) + +__ = -1 + +#----------------------------------------------------- + +if not load: + for Ctt_step in Ctt_steps: + + __ += 1 + + for i in range(2): + Ctt_list.append([]) + Ctt_error_list.append([]) + Nll_list.append([]) + + for param in total_f_fit.get_dependents(): + if param.floating: + pull_dic[param.name].append([]) + + for toy in range(nr_of_toys): + + newset = True + + while newset: + + for floaty in [True, False]: + Ctt.floating = floaty + + for bo_step in range(bo_set): + + print('Step: {0}/{1}'.format(int(__), ste)) + print('Current Ctt: {0}'.format(Ctt_step)) + print('Ctt floating: {0}'.format(floaty)) + + reset_param_values(variation = 0.0) + + if floaty: + print('Toy {0}/{1} - Fit {2}/{3}'.format(toy, nr_of_toys, bo_step, bo_set)) + Ctt.set_value(Ctt_step) + + else: + Ctt.set_value(0.0) + print('Toy {0}/{1} - Fit {2}/{3}'.format(toy, nr_of_toys, bo_step, bo_set)) + + if newset: + sampler.resample(n=nevents) + data = sampler + newset = False + + ### Fit data + + if floaty: + #plt.clf() + #plt.title('Ctt value: {:.2f}'.format(Ctt_step)) + #plt.hist(zfit.run(data), bins = int((x_max-x_min)/7), range = (x_min, x_max)) + #plt.savefig('data/CLs/plots/set_histo{}.png'.format(__)) + _step = 2*__ + else: + _step = 2*__+1 + + nll = zfit.loss.UnbinnedNLL(model=total_f_fit, data=data, constraints = constraints) + + minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) + # minimizer._use_tfgrad = False + result = minimizer.minimize(nll) + + print("Function minimum:", result.fmin) + print("Hesse errors:", result.hesse()) + + params = result.params + + if result.converged: + + save_pulls(step = _step) + + if floaty: + Nll_list[-2].append(result.fmin) + Ctt_list[-2].append(params[Ctt]['value']) + Ctt_error_list[-2].append(params[Ctt]['minuit_hesse']['error']) + + else: + Nll_list[-1].append(result.fmin) + Ctt_list[-1].append(0.0) + Ctt_error_list[-1].append(0.0) + + + else: + for _ in [1,2]: + del Nll_list[-_][toy*bo_set:] +# print(np.shape(Nll_list[-_])) + del Ctt_list[-_][toy*bo_set:] + del Ctt_error_list[-_][toy*bo_set:] + for param in total_f_fit.get_dependents(): + if param.floating: + del pull_dic[param.name][_step+1-_][toy*bo_set:] + newset = True + break + + if not result.converged: + break + + print() + print('Time taken: {}'.format(display_time(int(time.time()-start)))) + print('Estimated time left: {}'.format(display_time(int((time.time()-start)/(__+(toy+1)/nr_of_toys)*(ste-__-(nr_of_toys-toy-1)/nr_of_toys))))) + + +# In[ ]: + + +if load: + + phase_combi = '--' + + if D_contribs: + D_dir = 'D-True' + else: + D_dir = 'D-False' + + _dir = 'data/CLs/finished/f1d1/{}/{}/'.format(phase_combi, D_dir) + + jobs = os.listdir(_dir) + + First = True + +# print(jobs) + + for job in jobs: + + dirName = _dir + str(job) + '/data/CLs' + + if not os.path.exists("{}/{}-{}_{}s{}b{}t--CLs_Nll_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys)): +# print(job) + continue + + with open(r"{}/variab.pkl".format(dirName), "rb") as input_file: + variab = pkl.load(input_file) +# print(variab) + + ### sanity check: + if variab['mi'] != mi or variab['ma'] != ma or variab['ste'] != ste or bo_set != bo_set: + print('Fitting parameters of data dont equal the ones given -- Job {} skipped!'.format(job)) + + with open(r"{}/{}-{}_{}s{}b{}t--CLs_Nll_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _Nll_list = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s{}b{}t--Ctt_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _Ctt_list = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s{}b{}t--Ctt_error_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _Ctt_error_list = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s{}b{}t--pull_dic.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _pull_dic = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s--CLs_list.pkl".format(dirName, mi,ma,ste), "rb") as input_file: + _CLs_list = pkl.load(input_file) + + + if First: + Nll_list = _Nll_list + Ctt_list = _Ctt_list + Ctt_error_list = _Ctt_error_list + pull_dic = _pull_dic +# print(_pull_dic) + CLs_list = _CLs_list + First = False + else: + for step in range(2*ste): +# print(Nll_list[step], step) + Nll_list[step].extend(_Nll_list[step]) + Ctt_list[step].extend(_Ctt_list[step]) + Ctt_error_list[step].extend(_Ctt_error_list[step]) + for key in pull_dic.keys(): +# print(key, np.shape(pull_dic[key])) + pull_dic[key][step].extend(_pull_dic[key][step]) + for step in range(ste): + CLs_list[step].extend(_CLs_list[step]) + +# print('----------------------') + + +# In[ ]: + + +dirName = 'data/CLs' + +# if bo and not load: +# for s in range(2*ste): +# Nll_list[s] = [np.min(Nll_list[s])] + + +if not load: + + if not os.path.exists(dirName): + os.mkdir(dirName) + print("Directory " , dirName , " Created ") + + with open("{}/{}-{}_{}s{}b{}t--CLs_Nll_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(Nll_list, f, pkl.HIGHEST_PROTOCOL) + + with open("{}/{}-{}_{}s{}b{}t--Ctt_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(Ctt_list, f, pkl.HIGHEST_PROTOCOL) + + with open("{}/{}-{}_{}s{}b{}t--Ctt_error_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(Ctt_error_list, f, pkl.HIGHEST_PROTOCOL) + + with open("{}/{}-{}_{}s{}b{}t--pull_dic.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(pull_dic, f, pkl.HIGHEST_PROTOCOL) + + variab = {'mi': mi, + 'ma': ma, + 'ste': ste, + 'bo_set': bo_set, + 'nr_of_toys': nr_of_toys} + + with open("{}/variab.pkl".format(dirName), "wb") as f: + pkl.dump(variab, f, pkl.HIGHEST_PROTOCOL) + + CLs_values = [] + + toy_size = bo_set + + print(np.shape(Nll_list)) + print(Nll_list[0:1]) + + for step in range(ste): + CLs_values.append([]) + for toy in range(nr_of_toys): + float_min = np.min(Nll_list[2*step][toy*bo_set:(toy+1)*bo_set]) + fix_min = np.min(Nll_list[2*step+1][toy*bo_set:(toy+1)*bo_set]) + CLs_values[step].append(float_min-fix_min) + + + print(np.shape(CLs_values)) + + with open("{}/{}-{}_{}s--CLs_list.pkl".format(dirName, mi,ma,ste), "wb") as f: + pkl.dump(CLs_values, f, pkl.HIGHEST_PROTOCOL) + + +# In[ ]: + + +# print(variab['mi'] != mi) + + +# ## Plot + +# In[ ]: + + +l = [] + + +if load: + CLs_values = -1*np.array(CLs_list) + +if not os.path.exists('data/CLs/plots'): + os.mkdir('data/CLs/plots') + print("Directory " , 'data/CLs/plots' , " Created ") + +print(np.shape(CLs_values)) + +for step in range(1,ste): + plt.clf() + plt.title('Ctt value: {:.2f}'.format(Ctt_steps[step])) + plt.hist(CLs_values[0], bins = 150, range = (-25, 50), label = 'Ctt fixed to 0') + plt.hist(CLs_values[step], bins = 150, range = (-25, 50), label = 'Ctt floating') + plt.axvline(x=np.mean(CLs_values[0]),color='red', linewidth=1.0, linestyle = 'dotted') + plt.legend() + plt.savefig('data/CLs/plots/CLs-BR({:.1E}).png'.format(BR_steps[step])) + + l.append(len(np.where(np.array(CLs_values[step]) < np.mean(CLs_values[0]))[0])) + +for step in range(2*ste): + if step%2 == 0: + floaty = True + else: + floaty = False + for key in pull_dic.keys(): + if not os.path.exists('data/CLs/plots/{}'.format(key)): + os.mkdir('data/CLs/plots/{}'.format(key)) + plt.clf() + plt.title('Pull {} - Ctt value {:.2f} - floating {}'.format(key, Ctt_steps[int(step/2)], floaty)) + plt.hist(pull_dic[key][step], bins = 50, range = (-5,5)) + plt.xlabel('Pull') + plt.savefig('data/CLs/plots/{}/{:.2f}Ctt{}s{}f.png'.format(key, Ctt_steps[int(step/2)], step, floaty)) + + +# In[ ]: + + +for s in range(len(l)): + print('BR: {:.4f}'.format(BR_steps[s+1])) + print(2*l[s]/len(CLs_values[s])) + print() + + +# In[ ]: + + +# for step in range(2*ste): +# for key in pull_dic.keys(): +# print(pull_dic[key][step]) + + +# In[ ]: + + +# for param in total_f_fit.get_dependents(): +# if param.floating: +# print(params[param]['value']) + + +# In[ ]: + + +print(display_time(int(time.time()-start))) + + +# In[ ]: + + +# variab['mi'] =! mi + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + diff --git a/data/CLs/finished/f1d1/-+/D-True/2288048/__pycache__/helperfunctions.cpython-37.pyc b/data/CLs/finished/f1d1/-+/D-True/2288048/__pycache__/helperfunctions.cpython-37.pyc new file mode 100644 index 0000000..ef0f198 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288048/__pycache__/helperfunctions.cpython-37.pyc Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288048/__pycache__/pdg_const1.cpython-37.pyc b/data/CLs/finished/f1d1/-+/D-True/2288048/__pycache__/pdg_const1.cpython-37.pyc new file mode 100644 index 0000000..965fc33 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288048/__pycache__/pdg_const1.cpython-37.pyc Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288048/data/CLs/0.0001-0.003_20s--CLs_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288048/data/CLs/0.0001-0.003_20s--CLs_list.pkl new file mode 100644 index 0000000..086c737 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288048/data/CLs/0.0001-0.003_20s--CLs_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288048/data/CLs/0.0001-0.003_20s1b1t--CLs_Nll_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288048/data/CLs/0.0001-0.003_20s1b1t--CLs_Nll_list.pkl new file mode 100644 index 0000000..350fefc --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288048/data/CLs/0.0001-0.003_20s1b1t--CLs_Nll_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288048/data/CLs/0.0001-0.003_20s1b1t--Ctt_error_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288048/data/CLs/0.0001-0.003_20s1b1t--Ctt_error_list.pkl new file mode 100644 index 0000000..644563e --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288048/data/CLs/0.0001-0.003_20s1b1t--Ctt_error_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288048/data/CLs/0.0001-0.003_20s1b1t--Ctt_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288048/data/CLs/0.0001-0.003_20s1b1t--Ctt_list.pkl new file mode 100644 index 0000000..def0863 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288048/data/CLs/0.0001-0.003_20s1b1t--Ctt_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288048/data/CLs/0.0001-0.003_20s1b1t--pull_dic.pkl b/data/CLs/finished/f1d1/-+/D-True/2288048/data/CLs/0.0001-0.003_20s1b1t--pull_dic.pkl new file mode 100644 index 0000000..fd369f5 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288048/data/CLs/0.0001-0.003_20s1b1t--pull_dic.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288048/data/CLs/variab.pkl b/data/CLs/finished/f1d1/-+/D-True/2288048/data/CLs/variab.pkl new file mode 100644 index 0000000..bb90dc0 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288048/data/CLs/variab.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288048/helperfunctions.py b/data/CLs/finished/f1d1/-+/D-True/2288048/helperfunctions.py new file mode 100644 index 0000000..88e120f --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288048/helperfunctions.py @@ -0,0 +1,33 @@ +# some helperfunctions + +import matplotlib +matplotlib.use("agg") +import matplotlib.pyplot as plt + +#Dislpay time (e.g. while generating points) + +display_intervals = ( + ('w', 604800), # 60 * 60 * 24 * 7 + ('d', 86400), # 60 * 60 * 24 + ('h', 3600), # 60 * 60 + ('min', 60), + ('s', 1), + ) + +def display_time(seconds, granularity=2): + result = [] + + for name, count in display_intervals: + value = seconds // count + if value: + seconds -= value * count + if value == 1: + name = name.rstrip('s') + result.append("{} {}".format(value, name)) + return ', '.join(result[:granularity]) + +def prepare_plot(title): + plt.title(title) + plt.grid() + plt.legend(loc = 'best') + plt.xlabel("q") diff --git a/data/CLs/finished/f1d1/-+/D-True/2288048/pdg_const1.py b/data/CLs/finished/f1d1/-+/D-True/2288048/pdg_const1.py new file mode 100644 index 0000000..70b3f30 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288048/pdg_const1.py @@ -0,0 +1,226 @@ +pdg = { + + + ###Particle masses### + + "mbstar" : 5415.4, + "mbstar0" : 5711.0, + "B0_M" : 5279.5, + "Bs_M" : 5366.7, + "Bplus_M" : 5279.3, + "Lb_M" : 5619.4, + "D0_M" : 1864.8, + "Dst_M" : 2010, + "pi_M" : 139.6, + "Jpsi_M" : 3096.9, + "Psi2s_M" : 3685.6, + "kaon_M" : 493.7, + "Ks_M" : 497.6, + "phi_M" : 1019.5, + "rho_M" : 775.26, + "rho_width" : 149.1, + "omega_M" : 782.65, + "omega_width" : 8.49, + + "muon_M" : 105.7, + "tau_M": 1776.86, + + "squark_M" : 95.0, + "bquark_M" : 4180.0, + "cquark_M" : 1275.0, + + "Bplus_tau" : 1.638e-12, + + ###Wilson coefficients### + + "C1" : -0.257, + "C2" : 1.009, + "C3" : -0.005, + "C4" : -0.078, + + "C7eff" : -0.306, + "C9eff" : 4.211, + "C10eff" : -4.103, + +# "C7eff": 0.0, +# "C9eff": 0.0, +# "C10eff": 0.0, + + ###Other constants + + "GF" : 1.1663787e-5, + "alpha_ew" : 1.0/137.0, + "Vts" : 0.0394, + "Vtb" : 1.019, + "number_of_decays": 5404696, + + #Formfactor z coefficients + + #"b0" : [0.285, 0.19, -0.17], + #"bplus" : [0.437, -1.41, -2.5], + #"bT" : [0.440, -1.47, -2.7] + + "b0" : [0.292, 0.281, 0.150], + "bplus" : [0.466, -0.885, -0.213], + "bT" : [0.460, -1.089, -1.114], + + "NR_BR": 4.37e-7, + "NR_auc": 0.00133, + + #Resonances format(mass, width, phase, scale) + + # pre scaling + +# "rho": (775.26, 149.0, -0.35, 1.0), + +# "omega": (782.7, 8.5, 0.26, 1.0), + +# "phi": (1019.46, 4.25, 0.5, 1.0), + +# "jpsi": (3096.0, 0.09, -1.5, 2e-2), +# "jpsi_auc": 0.2126825758464027, + +# "psi2s": (3686.0, 0.3, -1.5, 3.14e-3), +# "psi2s_auc": 2.802257483178487e-10, + +# "p3770": (3773.0, 27.2, -2.13, 1.0e-3), + +# "p4040": (4039.0, 80.0, -2.52, 2.0), + +# "p4160": (4191.0, 70.0, -1.9, 2.2), + +# "p4415": (4421.0, 62.0, -2.52, 1.0), + + + # after scaling (Phase combination --) + + # + # "rho": (743.2, 149.0, -0.22, 1.05), + # + # "omega": (782.7, 8.5, 0.38, 6.8), + # + # "phi": (1013.5, 4.25, 0.62, 19.2), + # + # "jpsi": (3096.1, 0.09, 1.63, 9897.0), + # "jpsi_auc": 0.2126825758464027, + # "jpsi_phase_unc": 0.05, + # + # "psi2s": (3686.0, 0.3, 1.8, 1396.0), + # "psi2s_auc": 0.0151332263, + # "psi2s_phase_unc": 0.1, + # + # "p3770": (3773.0, 27.2, -2.95, 2.5), + # + # "p4040": (4039.0, 80.0, -2.75, 1.01), + # + # "p4160": (4191.0, 70.0, -2.28, 2.2), + # + # "p4415": (4421.0, 62.0, -2.31, 1.24), + + # Phase combination of paper ++ + +# "rho": (743.2, 149.0, -0.35, 1.05), + +# "omega": (782.7, 8.5, 0.26, 6.8), + +# "phi": (1013.5, 4.25, 0.47, 19.2), + +# "jpsi": (3096.1, 0.09, -1.66, 9897.0), +# "jpsi_auc": 0.2126825758464027, +# "jpsi_phase_unc": 0.05, + +# "psi2s": (3686.0, 0.3, -1.93, 1396.0), +# "psi2s_auc": 0.0151332263, +# "psi2s_phase_unc": 0.1, + +# "p3770": (3773.0, 27.2, -2.13, 2.5), + +# "p4040": (4039.0, 80.0, -2.52, 1.01), + +# "p4160": (4191.0, 70.0, -1.90, 2.2), + +# "p4415": (4421.0, 62.0, -2.52, 1.24), + + # Phase combination of paper +- + +# "rho": (743.2, 149.0, -0.26, 1.05), + +# "omega": (782.7, 8.5, 0.35, 6.8), + +# "phi": (1013.5, 4.25, 0.58, 19.2), + +# "jpsi": (3096.1, 0.09, 1.47, 9897.0), +# "jpsi_auc": 0.2126825758464027, +# "jpsi_phase_unc": 0.05, + +# "psi2s": (3686.0, 0.3, -2.21, 1396.0), +# "psi2s_auc": 0.0151332263, +# "psi2s_phase_unc": 0.1, + +# "p3770": (3773.0, 27.2, -2.140, 2.5), + +# "p4040": (4039.0, 80.0, -2.64, 1.01), + +# "p4160": (4191.0, 70.0, -2.11, 2.2), + +# "p4415": (4421.0, 62.0, -2.42, 1.24), + + # Phase combination of paper -+ + + "rho": (743.2, 149.0, -0.30, 1.05), + + "omega": (782.7, 8.5, 0.30, 6.8), + + "phi": (1013.5, 4.25, 0.51, 19.2), + + "jpsi": (3096.1, 0.09, -1.5, 9897.0), + "jpsi_auc": 0.2126825758464027, + "jpsi_phase_unc": 0.05, + + "psi2s": (3686.0, 0.3, 2.08, 1396.0), + "psi2s_auc": 0.0151332263, + "psi2s_phase_unc": 0.1, + + "p3770": (3773.0, 27.2, -2.89, 2.5), + + "p4040": (4039.0, 80.0, -2.69, 1.01), + + "p4160": (4191.0, 70.0, -2.13, 2.2), + + "p4415": (4421.0, 62.0, -2.43, 1.24), + + + # zeroing resonances + +# "rho": (775.26, 149.0, -0.35, 0.0), +# "omega": (782.7, 8.5, 0.26, 0.0), +# "phi": (1019.46, 4.25, 0.5, 0.0), +# "jpsi": (3096.0, 0.09, -1.5, 0.0), +# "psi2s": (3686.0, 0.3, -1.5, 0.0), +# "p3770": (3773.0, 27.2, -2.13, 0.0), +# "p4040": (4039.0, 80.0, -2.52, 0.0), +# "p4160": (4147.0, 22.0, -1.9, 0.0), +# "p4415": (4421.0, 62.0, -2.52, 0.0), + + # 2P contributions format(mass, amp, phase) + +# "D_bar": ( + + #general + + "rho_BR": 1.7e-10, + "omega_BR": 4.9e-10, + "phi_BR": 2.5e-9, + "jpsi_BR": 6.02e-5, + "psi2s_BR": 4.97e-6, + "p3770_BR": 1.38e-9, + "p4040_BR": 4.2e-10, + "p4160_BR": 2.6e-9, + "p4415_BR": 6.1e-10, + +# Estimates + "Dbar_scale": 1.46, #with phase = pi + + "DDstar_scale": 2.41, #with phase = pi + + } diff --git a/data/CLs/finished/f1d1/-+/D-True/2288048/raremodel-nb.py b/data/CLs/finished/f1d1/-+/D-True/2288048/raremodel-nb.py new file mode 100644 index 0000000..c326c9c --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288048/raremodel-nb.py @@ -0,0 +1,2152 @@ +#!/usr/bin/env python +# coding: utf-8 + +# # Import + +# In[ ]: + + +import os + +# os.environ["CUDA_VISIBLE_DEVICES"] = "-1" +import random +import numpy as np +from pdg_const1 import pdg +import matplotlib +import matplotlib.pyplot as plt +import pickle as pkl +import sys +import time +from helperfunctions import display_time, prepare_plot +import cmath as c +import scipy.integrate as integrate +from scipy.optimize import fminbound +from array import array as arr +import collections +from itertools import compress +import tensorflow as tf +import zfit +from zfit import ztf +# from IPython.display import clear_output +import os +import tensorflow_probability as tfp +tfd = tfp.distributions + + +# In[ ]: + + +# chunksize = 10000 +# zfit.run.chunking.active = True +# zfit.run.chunking.max_n_points = chunksize + + +# # Build model and graphs +# ## Create graphs + +# In[ ]: + + + + + +# In[ ]: + + +def formfactor(q2, subscript, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2): #returns real value + #check if subscript is viable + + if subscript != "0" and subscript != "+" and subscript != "T": + raise ValueError('Wrong subscript entered, choose either 0, + or T') + + #get constants + + mK = ztf.constant(pdg['Ks_M']) + mbstar0 = ztf.constant(pdg["mbstar0"]) + mbstar = ztf.constant(pdg["mbstar"]) + + + mmu = ztf.constant(pdg['muon_M']) + mb = ztf.constant(pdg['bquark_M']) + ms = ztf.constant(pdg['squark_M']) + mB = ztf.constant(pdg['Bplus_M']) + + #N comes from derivation in paper + + N = 3 + + #some helperfunctions + + tpos = (mB - mK)**2 + tzero = (mB + mK)*(ztf.sqrt(mB)-ztf.sqrt(mK))**2 + + z_oben = ztf.sqrt(tpos - q2) - ztf.sqrt(tpos - tzero) + z_unten = ztf.sqrt(tpos - q2) + ztf.sqrt(tpos - tzero) + z = tf.divide(z_oben, z_unten) + + #calculate f0 + + if subscript == "0": + prefactor = 1/(1 - q2/(mbstar0**2)) + _sum = 0 + b0 = [b0_0, b0_1, b0_2] + + for i in range(N): + _sum += b0[i]*(tf.pow(z,i)) + + return ztf.to_complex(prefactor * _sum) + + #calculate f+ or fT + + else: + prefactor = 1/(1 - q2/(mbstar**2)) + _sum = 0 + + if subscript == "T": + bT = [bT_0, bT_1, bT_2] + for i in range(N): + _sum += bT[i] * (tf.pow(z, i) - ((-1)**(i-N)) * (i/N) * tf.pow(z, N)) + else: + bplus = [bplus_0, bplus_1, bplus_2] + for i in range(N): + _sum += bplus[i] * (tf.pow(z, i) - ((-1)**(i-N)) * (i/N) * tf.pow(z, N)) + + return ztf.to_complex(prefactor * _sum) + +def resonance(q, _mass, width, phase, scale): + + q2 = tf.pow(q, 2) + + mmu = ztf.constant(pdg['muon_M']) + + p = 0.5 * ztf.sqrt(q2 - 4*(mmu**2)) + + p0 = 0.5 * ztf.sqrt(_mass**2 - 4*mmu**2) + + gamma_j = tf.divide(p, q) * _mass * width / p0 + + #Calculate the resonance + + _top = tf.complex(_mass * width, ztf.constant(0.0)) + + _bottom = tf.complex(_mass**2 - q2, -_mass*gamma_j) + + com = _top/_bottom + + #Rotate by the phase + + r = ztf.to_complex(scale*tf.abs(com)) + + _phase = tf.angle(com) + + _phase += phase + + com = r * tf.exp(tf.complex(ztf.constant(0.0), _phase)) + + return com + + +def axiv_nonres(q, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2): + + GF = ztf.constant(pdg['GF']) + alpha_ew = ztf.constant(pdg['alpha_ew']) + Vtb = ztf.constant(pdg['Vtb']) + Vts = ztf.constant(pdg['Vts']) + C10eff = ztf.constant(pdg['C10eff']) + + mmu = ztf.constant(pdg['muon_M']) + mb = ztf.constant(pdg['bquark_M']) + ms = ztf.constant(pdg['squark_M']) + mK = ztf.constant(pdg['Ks_M']) + mB = ztf.constant(pdg['Bplus_M']) + + q2 = tf.pow(q, 2) + + #Some helperfunctions + + beta = 1. - 4. * mmu**2. / q2 + + kabs = ztf.sqrt(mB**2. + tf.pow(q2, 2)/mB**2. + mK**4./mB**2. - 2. * (mB**2. * mK**2. + mK**2. * q2 + mB**2. * q2) / mB**2.) + + #prefactor in front of whole bracket + + prefactor1 = GF**2. *alpha_ew**2. * (tf.abs(Vtb*Vts))**2. * kabs * beta / (128. * np.pi**5.) + + #left term in bracket + + bracket_left = 2./3. * tf.pow(kabs,2) * tf.pow(beta,2) * tf.pow(tf.abs(ztf.to_complex(C10eff)*formfactor(q2, "+", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2)),2) + + #middle term in bracket + + _top = 4. * mmu**2. * (mB**2. - mK**2.) * (mB**2. - mK**2.) + + _under = q2 * mB**2. + + bracket_middle = _top/_under *tf.pow(tf.abs(ztf.to_complex(C10eff) * formfactor(q2, "0", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2)), 2) + + #Note sqrt(q2) comes from derivation as we use q2 and plot q + + return prefactor1 * (bracket_left + bracket_middle) * 2 * q + +def vec(q, funcs, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2): + + q2 = tf.pow(q, 2) + + GF = ztf.constant(pdg['GF']) + alpha_ew = ztf.constant(pdg['alpha_ew']) + Vtb = ztf.constant(pdg['Vtb']) + Vts = ztf.constant(pdg['Vts']) + C7eff = ztf.constant(pdg['C7eff']) + + mmu = ztf.constant(pdg['muon_M']) + mb = ztf.constant(pdg['bquark_M']) + ms = ztf.constant(pdg['squark_M']) + mK = ztf.constant(pdg['Ks_M']) + mB = ztf.constant(pdg['Bplus_M']) + + #Some helperfunctions + + beta = 1. - 4. * mmu**2. / q2 + + kabs = ztf.sqrt(mB**2. + tf.pow(q2, 2)/mB**2. + mK**4./mB**2. - 2 * (mB**2 * mK**2 + mK**2 * q2 + mB**2 * q2) / mB**2) + + #prefactor in front of whole bracket + + prefactor1 = GF**2. *alpha_ew**2. * (tf.abs(Vtb*Vts))**2 * kabs * beta / (128. * np.pi**5.) + + #right term in bracket + + prefactor2 = tf.pow(kabs,2) * (1. - 1./3. * beta) + + abs_bracket = tf.pow(tf.abs(c9eff(q, funcs) * formfactor(q2, "+", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + ztf.to_complex(2.0 * C7eff * (mb + ms)/(mB + mK)) * formfactor(q2, "T", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2)),2) + + bracket_right = prefactor2 * abs_bracket + + #Note sqrt(q2) comes from derivation as we use q2 and plot q + + return prefactor1 * bracket_right * 2 * q + +def c9eff(q, funcs): + + C9eff_nr = ztf.to_complex(ztf.constant(pdg['C9eff'])) + + c9 = C9eff_nr + funcs + + return c9 + + +# In[ ]: + + +def G(y): + + def inner_rect_bracket(q): + return tf.log(ztf.to_complex((1+tf.sqrt(q))/(1-tf.sqrt(q)))-tf.complex(ztf.constant(0), -1*ztf.constant(np.pi))) + + def inner_right(q): + return ztf.to_complex(2 * tf.atan(1/tf.sqrt(tf.math.real(-q)))) + + big_bracket = tf.where(tf.math.real(y) > ztf.constant(0.0), inner_rect_bracket(y), inner_right(y)) + + return ztf.to_complex(tf.sqrt(tf.abs(y))) * big_bracket + +def h_S(m, q): + + return ztf.to_complex(2) - G(ztf.to_complex(1) - ztf.to_complex(4*tf.pow(m, 2)) / ztf.to_complex(tf.pow(q, 2))) + +def h_P(m, q): + + return ztf.to_complex(2/3) + (ztf.to_complex(1) - ztf.to_complex(4*tf.pow(m, 2)) / ztf.to_complex(tf.pow(q, 2))) * h_S(m,q) + +def two_p_ccbar(mD, m_D_bar, m_D_star, q): + + + #Load constants + nu_D_bar = ztf.to_complex(pdg["nu_D_bar"]) + nu_D = ztf.to_complex(pdg["nu_D"]) + nu_D_star = ztf.to_complex(pdg["nu_D_star"]) + + phase_D_bar = ztf.to_complex(pdg["phase_D_bar"]) + phase_D = ztf.to_complex(pdg["phase_D"]) + phase_D_star = ztf.to_complex(pdg["phase_D_star"]) + + #Calculation + left_part = nu_D_bar * tf.exp(tf.complex(ztf.constant(0.0), phase_D_bar)) * h_S(m_D_bar, q) + + right_part_D = nu_D * tf.exp(tf.complex(ztf.constant(0.0), phase_D)) * h_P(m_D, q) + + right_part_D_star = nu_D_star * tf.exp(tf.complex(ztf.constant(0.0), phase_D_star)) * h_P(m_D_star, q) + + return left_part + right_part_D + right_part_D_star + + +# ## Build pdf + +# In[ ]: + + +class total_pdf_cut(zfit.pdf.ZPDF): + _N_OBS = 1 # dimension, can be omitted + _PARAMS = ['b0_0', 'b0_1', 'b0_2', + 'bplus_0', 'bplus_1', 'bplus_2', + 'bT_0', 'bT_1', 'bT_2', + 'rho_mass', 'rho_scale', 'rho_phase', 'rho_width', + 'jpsi_mass', 'jpsi_scale', 'jpsi_phase', 'jpsi_width', + 'psi2s_mass', 'psi2s_scale', 'psi2s_phase', 'psi2s_width', + 'p3770_mass', 'p3770_scale', 'p3770_phase', 'p3770_width', + 'p4040_mass', 'p4040_scale', 'p4040_phase', 'p4040_width', + 'p4160_mass', 'p4160_scale', 'p4160_phase', 'p4160_width', + 'p4415_mass', 'p4415_scale', 'p4415_phase', 'p4415_width', + 'omega_mass', 'omega_scale', 'omega_phase', 'omega_width', + 'phi_mass', 'phi_scale', 'phi_phase', 'phi_width', + 'Dbar_mass', 'Dbar_scale', 'Dbar_phase', + 'Dstar_mass', 'DDstar_scale', 'DDstar_phase', 'D_mass', + 'tau_mass', 'C_tt'] +# the name of the parameters + + def _unnormalized_pdf(self, x): + + x = x.unstack_x() + + b0 = [self.params['b0_0'], self.params['b0_1'], self.params['b0_2']] + bplus = [self.params['bplus_0'], self.params['bplus_1'], self.params['bplus_2']] + bT = [self.params['bT_0'], self.params['bT_1'], self.params['bT_2']] + + def rho_res(q): + return resonance(q, _mass = self.params['rho_mass'], scale = self.params['rho_scale'], + phase = self.params['rho_phase'], width = self.params['rho_width']) + + def omega_res(q): + return resonance(q, _mass = self.params['omega_mass'], scale = self.params['omega_scale'], + phase = self.params['omega_phase'], width = self.params['omega_width']) + + def phi_res(q): + return resonance(q, _mass = self.params['phi_mass'], scale = self.params['phi_scale'], + phase = self.params['phi_phase'], width = self.params['phi_width']) + + def jpsi_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['jpsi_mass'], 2)) * resonance(q, _mass = self.params['jpsi_mass'], + scale = self.params['jpsi_scale'], + phase = self.params['jpsi_phase'], + width = self.params['jpsi_width']) + def psi2s_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['psi2s_mass'], 2)) * resonance(q, _mass = self.params['psi2s_mass'], + scale = self.params['psi2s_scale'], + phase = self.params['psi2s_phase'], + width = self.params['psi2s_width']) + def p3770_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p3770_mass'], 2)) * resonance(q, _mass = self.params['p3770_mass'], + scale = self.params['p3770_scale'], + phase = self.params['p3770_phase'], + width = self.params['p3770_width']) + + def p4040_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4040_mass'], 2)) * resonance(q, _mass = self.params['p4040_mass'], + scale = self.params['p4040_scale'], + phase = self.params['p4040_phase'], + width = self.params['p4040_width']) + + def p4160_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4160_mass'], 2)) * resonance(q, _mass = self.params['p4160_mass'], + scale = self.params['p4160_scale'], + phase = self.params['p4160_phase'], + width = self.params['p4160_width']) + + def p4415_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4415_mass'], 2)) * resonance(q, _mass = self.params['p4415_mass'], + scale = self.params['p4415_scale'], + phase = self.params['p4415_phase'], + width = self.params['p4415_width']) + + def P2_D(q): + Dbar_contrib = ztf.to_complex(self.params['Dbar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['Dbar_phase']))*ztf.to_complex(h_S(self.params['Dbar_mass'], q)) + DDstar_contrib = ztf.to_complex(self.params['DDstar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['DDstar_phase']))*(ztf.to_complex(h_P(self.params['Dstar_mass'], q)) + ztf.to_complex(h_P(self.params['D_mass'], q))) + return Dbar_contrib + DDstar_contrib + + def ttau_cusp(q): + return ztf.to_complex(self.params['C_tt'])*(ztf.to_complex((h_S(self.params['tau_mass'], q))) - ztf.to_complex(h_P(self.params['tau_mass'], q))) + + + funcs = rho_res(x) + omega_res(x) + phi_res(x) + jpsi_res(x) + psi2s_res(x) + p3770_res(x) + p4040_res(x)+ p4160_res(x) + p4415_res(x) + P2_D(x) + ttau_cusp(x) + + vec_f = vec(x, funcs, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + axiv_nr = axiv_nonres(x, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + tot = vec_f + axiv_nr + + #Cut out jpsi and psi2s + + tot = tf.where(tf.math.logical_or(x < ztf.constant(jpsi_mass-60.), x > ztf.constant(jpsi_mass+70.)), tot, 0.0*tot) + + tot = tf.where(tf.math.logical_or(x < ztf.constant(psi2s_mass-50.), x > ztf.constant(psi2s_mass+50.)), tot, 0.0*tot) + + return tot + +class total_pdf_full(zfit.pdf.ZPDF): + _N_OBS = 1 # dimension, can be omitted + _PARAMS = ['b0_0', 'b0_1', 'b0_2', + 'bplus_0', 'bplus_1', 'bplus_2', + 'bT_0', 'bT_1', 'bT_2', + 'rho_mass', 'rho_scale', 'rho_phase', 'rho_width', + 'jpsi_mass', 'jpsi_scale', 'jpsi_phase', 'jpsi_width', + 'psi2s_mass', 'psi2s_scale', 'psi2s_phase', 'psi2s_width', + 'p3770_mass', 'p3770_scale', 'p3770_phase', 'p3770_width', + 'p4040_mass', 'p4040_scale', 'p4040_phase', 'p4040_width', + 'p4160_mass', 'p4160_scale', 'p4160_phase', 'p4160_width', + 'p4415_mass', 'p4415_scale', 'p4415_phase', 'p4415_width', + 'omega_mass', 'omega_scale', 'omega_phase', 'omega_width', + 'phi_mass', 'phi_scale', 'phi_phase', 'phi_width', + 'Dbar_mass', 'Dbar_scale', 'Dbar_phase', + 'Dstar_mass', 'DDstar_scale', 'DDstar_phase', 'D_mass', + 'tau_mass', 'C_tt'] +# the name of the parameters + + def _unnormalized_pdf(self, x): + + x = x.unstack_x() + + b0 = [self.params['b0_0'], self.params['b0_1'], self.params['b0_2']] + bplus = [self.params['bplus_0'], self.params['bplus_1'], self.params['bplus_2']] + bT = [self.params['bT_0'], self.params['bT_1'], self.params['bT_2']] + + def rho_res(q): + return resonance(q, _mass = self.params['rho_mass'], scale = self.params['rho_scale'], + phase = self.params['rho_phase'], width = self.params['rho_width']) + + def omega_res(q): + return resonance(q, _mass = self.params['omega_mass'], scale = self.params['omega_scale'], + phase = self.params['omega_phase'], width = self.params['omega_width']) + + def phi_res(q): + return resonance(q, _mass = self.params['phi_mass'], scale = self.params['phi_scale'], + phase = self.params['phi_phase'], width = self.params['phi_width']) + + def jpsi_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['jpsi_mass'], 2)) * resonance(q, _mass = self.params['jpsi_mass'], + scale = self.params['jpsi_scale'], + phase = self.params['jpsi_phase'], + width = self.params['jpsi_width']) + def psi2s_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['psi2s_mass'], 2)) * resonance(q, _mass = self.params['psi2s_mass'], + scale = self.params['psi2s_scale'], + phase = self.params['psi2s_phase'], + width = self.params['psi2s_width']) + def p3770_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p3770_mass'], 2)) * resonance(q, _mass = self.params['p3770_mass'], + scale = self.params['p3770_scale'], + phase = self.params['p3770_phase'], + width = self.params['p3770_width']) + + def p4040_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4040_mass'], 2)) * resonance(q, _mass = self.params['p4040_mass'], + scale = self.params['p4040_scale'], + phase = self.params['p4040_phase'], + width = self.params['p4040_width']) + + def p4160_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4160_mass'], 2)) * resonance(q, _mass = self.params['p4160_mass'], + scale = self.params['p4160_scale'], + phase = self.params['p4160_phase'], + width = self.params['p4160_width']) + + def p4415_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4415_mass'], 2)) * resonance(q, _mass = self.params['p4415_mass'], + scale = self.params['p4415_scale'], + phase = self.params['p4415_phase'], + width = self.params['p4415_width']) + + def P2_D(q): + Dbar_contrib = ztf.to_complex(self.params['Dbar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['Dbar_phase']))*ztf.to_complex(h_S(self.params['Dbar_mass'], q)) + DDstar_contrib = ztf.to_complex(self.params['DDstar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['DDstar_phase']))*(ztf.to_complex(h_P(self.params['Dstar_mass'], q)) + ztf.to_complex(h_P(self.params['D_mass'], q))) + return Dbar_contrib + DDstar_contrib + + def ttau_cusp(q): + return ztf.to_complex(self.params['C_tt'])*(ztf.to_complex((h_S(self.params['tau_mass'], q))) - ztf.to_complex(h_P(self.params['tau_mass'], q))) + + + funcs = rho_res(x) + omega_res(x) + phi_res(x) + jpsi_res(x) + psi2s_res(x) + p3770_res(x) + p4040_res(x)+ p4160_res(x) + p4415_res(x) + P2_D(x) + ttau_cusp(x) + + vec_f = vec(x, funcs, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + axiv_nr = axiv_nonres(x, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + tot = vec_f + axiv_nr + + #Cut out jpsi and psi2s + +# tot = tf.where(tf.math.logical_or(x < ztf.constant(jpsi_mass-60.), x > ztf.constant(jpsi_mass+70.)), tot, 0.0*tot) + +# tot = tf.where(tf.math.logical_or(x < ztf.constant(psi2s_mass-50.), x > ztf.constant(psi2s_mass+50.)), tot, 0.0*tot) + + return tot + + +# ## Setup parameters + +# In[ ]: + + +# formfactors + +b0_0 = zfit.Parameter("b0_0", ztf.constant(0.292), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +b0_1 = zfit.Parameter("b0_1", ztf.constant(0.281), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +b0_2 = zfit.Parameter("b0_2", ztf.constant(0.150), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) + +bplus_0 = zfit.Parameter("bplus_0", ztf.constant(0.466), lower_limit = -2.0, upper_limit= 2.0) +bplus_1 = zfit.Parameter("bplus_1", ztf.constant(-0.885), lower_limit = -2.0, upper_limit= 2.0) +bplus_2 = zfit.Parameter("bplus_2", ztf.constant(-0.213), lower_limit = -2.0, upper_limit= 2.0) + +bT_0 = zfit.Parameter("bT_0", ztf.constant(0.460), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +bT_1 = zfit.Parameter("bT_1", ztf.constant(-1.089), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +bT_2 = zfit.Parameter("bT_2", ztf.constant(-1.114), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) + + +#rho + +rho_mass, rho_width, rho_phase, rho_scale = pdg["rho"] + +rho_m = zfit.Parameter("rho_m", ztf.constant(rho_mass), floating = False) #lower_limit = rho_mass - rho_width, upper_limit = rho_mass + rho_width) +rho_w = zfit.Parameter("rho_w", ztf.constant(rho_width), floating = False) +rho_p = zfit.Parameter("rho_p", ztf.constant(rho_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +rho_s = zfit.Parameter("rho_s", ztf.constant(rho_scale), lower_limit=rho_scale-np.sqrt(rho_scale), upper_limit=rho_scale+np.sqrt(rho_scale)) + +#omega + +omega_mass, omega_width, omega_phase, omega_scale = pdg["omega"] + +omega_m = zfit.Parameter("omega_m", ztf.constant(omega_mass), floating = False) +omega_w = zfit.Parameter("omega_w", ztf.constant(omega_width), floating = False) +omega_p = zfit.Parameter("omega_p", ztf.constant(omega_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +omega_s = zfit.Parameter("omega_s", ztf.constant(omega_scale), lower_limit=omega_scale-np.sqrt(omega_scale), upper_limit=omega_scale+np.sqrt(omega_scale)) + + +#phi + +phi_mass, phi_width, phi_phase, phi_scale = pdg["phi"] + +phi_m = zfit.Parameter("phi_m", ztf.constant(phi_mass), floating = False) +phi_w = zfit.Parameter("phi_w", ztf.constant(phi_width), floating = False) +phi_p = zfit.Parameter("phi_p", ztf.constant(phi_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +phi_s = zfit.Parameter("phi_s", ztf.constant(phi_scale), lower_limit=phi_scale-np.sqrt(phi_scale), upper_limit=phi_scale+np.sqrt(phi_scale)) + +#jpsi + +jpsi_mass, jpsi_width, jpsi_phase, jpsi_scale = pdg["jpsi"] + +jpsi_m = zfit.Parameter("jpsi_m", ztf.constant(jpsi_mass), floating = False) +jpsi_w = zfit.Parameter("jpsi_w", ztf.constant(jpsi_width), floating = False) +jpsi_p = zfit.Parameter("jpsi_p", ztf.constant(jpsi_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +jpsi_s = zfit.Parameter("jpsi_s", ztf.constant(jpsi_scale), floating = False) #, lower_limit=jpsi_scale-np.sqrt(jpsi_scale), upper_limit=jpsi_scale+np.sqrt(jpsi_scale)) + +#psi2s + +psi2s_mass, psi2s_width, psi2s_phase, psi2s_scale = pdg["psi2s"] + +psi2s_m = zfit.Parameter("psi2s_m", ztf.constant(psi2s_mass), floating = False) +psi2s_w = zfit.Parameter("psi2s_w", ztf.constant(psi2s_width), floating = False) +psi2s_p = zfit.Parameter("psi2s_p", ztf.constant(psi2s_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +psi2s_s = zfit.Parameter("psi2s_s", ztf.constant(psi2s_scale), floating = False) #, lower_limit=psi2s_scale-np.sqrt(psi2s_scale), upper_limit=psi2s_scale+np.sqrt(psi2s_scale)) + +#psi(3770) + +p3770_mass, p3770_width, p3770_phase, p3770_scale = pdg["p3770"] + +p3770_m = zfit.Parameter("p3770_m", ztf.constant(p3770_mass), floating = False) +p3770_w = zfit.Parameter("p3770_w", ztf.constant(p3770_width), floating = False) +p3770_p = zfit.Parameter("p3770_p", ztf.constant(p3770_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p3770_s = zfit.Parameter("p3770_s", ztf.constant(p3770_scale), lower_limit=p3770_scale-np.sqrt(p3770_scale), upper_limit=p3770_scale+np.sqrt(p3770_scale)) + +#psi(4040) + +p4040_mass, p4040_width, p4040_phase, p4040_scale = pdg["p4040"] + +p4040_m = zfit.Parameter("p4040_m", ztf.constant(p4040_mass), floating = False) +p4040_w = zfit.Parameter("p4040_w", ztf.constant(p4040_width), floating = False) +p4040_p = zfit.Parameter("p4040_p", ztf.constant(p4040_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p4040_s = zfit.Parameter("p4040_s", ztf.constant(p4040_scale), lower_limit=p4040_scale-np.sqrt(p4040_scale), upper_limit=p4040_scale+np.sqrt(p4040_scale)) + +#psi(4160) + +p4160_mass, p4160_width, p4160_phase, p4160_scale = pdg["p4160"] + +p4160_m = zfit.Parameter("p4160_m", ztf.constant(p4160_mass), floating = False) +p4160_w = zfit.Parameter("p4160_w", ztf.constant(p4160_width), floating = False) +p4160_p = zfit.Parameter("p4160_p", ztf.constant(p4160_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p4160_s = zfit.Parameter("p4160_s", ztf.constant(p4160_scale), lower_limit=p4160_scale-np.sqrt(p4160_scale), upper_limit=p4160_scale+np.sqrt(p4160_scale)) + +#psi(4415) + +p4415_mass, p4415_width, p4415_phase, p4415_scale = pdg["p4415"] + +p4415_m = zfit.Parameter("p4415_m", ztf.constant(p4415_mass), floating = False) +p4415_w = zfit.Parameter("p4415_w", ztf.constant(p4415_width), floating = False) +p4415_p = zfit.Parameter("p4415_p", ztf.constant(p4415_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p4415_s = zfit.Parameter("p4415_s", ztf.constant(p4415_scale), lower_limit=p4415_scale-np.sqrt(p4415_scale), upper_limit=p4415_scale+np.sqrt(p4415_scale)) + + +# ## Dynamic generation of 2 particle contribution + +# In[ ]: + + +m_c = 1300 + +Dbar_phase = 0.0 +DDstar_phase = 0.0 +Dstar_mass = pdg['Dst_M'] +Dbar_mass = pdg['D0_M'] +D_mass = pdg['D0_M'] + +Dbar_s = zfit.Parameter("Dbar_s", ztf.constant(0.0), lower_limit=-0.3, upper_limit=0.3) +Dbar_m = zfit.Parameter("Dbar_m", ztf.constant(Dbar_mass), floating = False) +Dbar_p = zfit.Parameter("Dbar_p", ztf.constant(Dbar_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi)#, floating = False) +DDstar_s = zfit.Parameter("DDstar_s", ztf.constant(0.0), lower_limit=-0.3, upper_limit=0.3)#, floating = False) +Dstar_m = zfit.Parameter("Dstar_m", ztf.constant(Dstar_mass), floating = False) +D_m = zfit.Parameter("D_m", ztf.constant(D_mass), floating = False) +DDstar_p = zfit.Parameter("DDstar_p", ztf.constant(DDstar_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi)#, floating = False) + + +# ## Tau parameters + +# In[ ]: + + +tau_m = zfit.Parameter("tau_m", ztf.constant(pdg['tau_M']), floating = False) +Ctt = zfit.Parameter("Ctt", ztf.constant(0.0), lower_limit=-2.5, upper_limit=2.5) + + +# ## Load data + +# In[ ]: + + +x_min = 2*pdg['muon_M'] +x_max = (pdg["Bplus_M"]-pdg["Ks_M"]-0.1) + +# # Full spectrum + +obs_toy = zfit.Space('q', limits = (x_min, x_max)) + +# Jpsi and Psi2s cut out + +obs1 = zfit.Space('q', limits = (x_min, jpsi_mass - 60.)) +obs2 = zfit.Space('q', limits = (jpsi_mass + 70., psi2s_mass - 50.)) +obs3 = zfit.Space('q', limits = (psi2s_mass + 50., x_max)) + +obs_fit = obs1 + obs2 + obs3 + +# with open(r"./data/slim_points/slim_points_toy_0_range({0}-{1}).pkl".format(int(x_min), int(x_max)), "rb") as input_file: +# part_set = pkl.load(input_file) + +# x_part = part_set['x_part'] + +# x_part = x_part.astype('float64') + +# data = zfit.data.Data.from_numpy(array=x_part, obs=obs) + + +# ## Setup pdf + +# In[ ]: + + +total_f = total_pdf_cut(obs=obs_toy, jpsi_mass = jpsi_m, jpsi_scale = jpsi_s, jpsi_phase = jpsi_p, jpsi_width = jpsi_w, + psi2s_mass = psi2s_m, psi2s_scale = psi2s_s, psi2s_phase = psi2s_p, psi2s_width = psi2s_w, + p3770_mass = p3770_m, p3770_scale = p3770_s, p3770_phase = p3770_p, p3770_width = p3770_w, + p4040_mass = p4040_m, p4040_scale = p4040_s, p4040_phase = p4040_p, p4040_width = p4040_w, + p4160_mass = p4160_m, p4160_scale = p4160_s, p4160_phase = p4160_p, p4160_width = p4160_w, + p4415_mass = p4415_m, p4415_scale = p4415_s, p4415_phase = p4415_p, p4415_width = p4415_w, + rho_mass = rho_m, rho_scale = rho_s, rho_phase = rho_p, rho_width = rho_w, + omega_mass = omega_m, omega_scale = omega_s, omega_phase = omega_p, omega_width = omega_w, + phi_mass = phi_m, phi_scale = phi_s, phi_phase = phi_p, phi_width = phi_w, + Dstar_mass = Dstar_m, DDstar_scale = DDstar_s, DDstar_phase = DDstar_p, D_mass = D_m, + Dbar_mass = Dbar_m, Dbar_scale = Dbar_s, Dbar_phase = Dbar_p, + tau_mass = tau_m, C_tt = Ctt, b0_0 = b0_0, b0_1 = b0_1, b0_2 = b0_2, + bplus_0 = bplus_0, bplus_1 = bplus_1, bplus_2 = bplus_2, + bT_0 = bT_0, bT_1 = bT_1, bT_2 = bT_2) + +total_f_fit = total_pdf_full(obs=obs_fit, jpsi_mass = jpsi_m, jpsi_scale = jpsi_s, jpsi_phase = jpsi_p, jpsi_width = jpsi_w, + psi2s_mass = psi2s_m, psi2s_scale = psi2s_s, psi2s_phase = psi2s_p, psi2s_width = psi2s_w, + p3770_mass = p3770_m, p3770_scale = p3770_s, p3770_phase = p3770_p, p3770_width = p3770_w, + p4040_mass = p4040_m, p4040_scale = p4040_s, p4040_phase = p4040_p, p4040_width = p4040_w, + p4160_mass = p4160_m, p4160_scale = p4160_s, p4160_phase = p4160_p, p4160_width = p4160_w, + p4415_mass = p4415_m, p4415_scale = p4415_s, p4415_phase = p4415_p, p4415_width = p4415_w, + rho_mass = rho_m, rho_scale = rho_s, rho_phase = rho_p, rho_width = rho_w, + omega_mass = omega_m, omega_scale = omega_s, omega_phase = omega_p, omega_width = omega_w, + phi_mass = phi_m, phi_scale = phi_s, phi_phase = phi_p, phi_width = phi_w, + Dstar_mass = Dstar_m, DDstar_scale = DDstar_s, DDstar_phase = DDstar_p, D_mass = D_m, + Dbar_mass = Dbar_m, Dbar_scale = Dbar_s, Dbar_phase = Dbar_p, + tau_mass = tau_m, C_tt = Ctt, b0_0 = b0_0, b0_1 = b0_1, b0_2 = b0_2, + bplus_0 = bplus_0, bplus_1 = bplus_1, bplus_2 = bplus_2, + bT_0 = bT_0, bT_1 = bT_1, bT_2 = bT_2) + +# print(total_pdf.obs) + +# print(calcs_test) + +# for param in total_f.get_dependents(): +# print(zfit.run(param)) + + +# In[ ]: + + +# total_f_fit.normalization(obs_fit) + + +# ## Test if graphs actually work and compute values + +# In[ ]: + + +# def total_test_tf(xq): + +# def jpsi_res(q): +# return resonance(q, jpsi_m, jpsi_s, jpsi_p, jpsi_w) + +# def psi2s_res(q): +# return resonance(q, psi2s_m, psi2s_s, psi2s_p, psi2s_w) + +# def cusp(q): +# return bifur_gauss(q, cusp_m, sig_L, sig_R, cusp_s) + +# funcs = jpsi_res(xq) + psi2s_res(xq) + cusp(xq) + +# vec_f = vec(xq, funcs) + +# axiv_nr = axiv_nonres(xq) + +# tot = vec_f + axiv_nr + +# return tot + +# def jpsi_res(q): +# return resonance(q, jpsi_m, jpsi_s, jpsi_p, jpsi_w) + +# calcs = zfit.run(total_test_tf(x_part)) + + + +test_q = np.linspace(x_min, x_max, int(2e6)) + +probs = total_f_fit.pdf(test_q, norm_range=False) + +calcs_test = zfit.run(probs) + +Ctt.set_value(0.5) + +calcs_test1 = zfit.run(probs) + +Ctt.set_value(0.0) + +Dbar_s.set_value(0.3) + +DDstar_s.set_value(0.3) + +calcs_test2 = zfit.run(probs) +# res_y = zfit.run(jpsi_res(test_q)) +# b0 = [b0_0, b0_1, b0_2] +# bplus = [bplus_0, bplus_1, bplus_2] +# bT = [bT_0, bT_1, bT_2] +# f0_y = zfit.run(tf.math.real(formfactor(test_q,"0", b0, bplus, bT))) +# fplus_y = zfit.run(tf.math.real(formfactor(test_q,"+", b0, bplus, bT))) +# fT_y = zfit.run(tf.math.real(formfactor(test_q,"T", b0, bplus, bT))) + + +# In[ ]: + + +plt.clf() +# plt.plot(x_part, calcs, '.') +plt.plot(test_q, calcs_test, label = 'pdf (Ctt = 0.0)') +plt.plot(test_q, calcs_test1, label = 'pdf (Ctt = 0.5)') +plt.plot(test_q, calcs_test2, label = 'pdf (D-contribs = 0.3)') +# plt.plot(test_q, f0_y, label = '0') +# plt.plot(test_q, fT_y, label = 'T') +# plt.plot(test_q, fplus_y, label = '+') +# plt.plot(test_q, res_y, label = 'res') +plt.legend() +plt.ylim(0.0, 1.5e-6) +# plt.yscale('log') +# plt.xlim(770, 785) +plt.savefig('test.png') +# print(jpsi_width) + + +# In[ ]: + + + + +# probs = mixture.prob(test_q) +# probs_np = zfit.run(probs) +# probs_np *= np.max(calcs_test) / np.max(probs_np) +# plt.figure() +# plt.semilogy(test_q, probs_np,label="importance sampling") +# plt.semilogy(test_q, calcs_test, label = 'pdf') + + +# In[ ]: + + +# 0.213/(0.00133+0.213+0.015) + + +# ## Adjust scaling of different parts + +# In[ ]: + + +total_f.update_integration_options(draws_per_dim=2000000, mc_sampler=None) +# inte = total_f.integrate(limits = (950., 1050.), norm_range=False) +# inte_fl = zfit.run(inte) +# print(inte_fl/4500) +# print(pdg["jpsi_BR"]/pdg["NR_BR"], inte_fl*pdg["psi2s_auc"]/pdg["NR_auc"]) + + +# In[ ]: + + +# # print("jpsi:", inte_fl) +# # print("Increase am by factor:", np.sqrt(pdg["jpsi_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) +# # print("New amp:", pdg["jpsi"][3]*np.sqrt(pdg["jpsi_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) + +# # print("psi2s:", inte_fl) +# # print("Increase am by factor:", np.sqrt(pdg["psi2s_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) +# # print("New amp:", pdg["psi2s"][3]*np.sqrt(pdg["psi2s_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) + +# name = "phi" + +# print(name+":", inte_fl) +# print("Increase am by factor:", np.sqrt(pdg[name+"_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) +# print("New amp:", pdg[name][0]*np.sqrt(pdg[name+"_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) + + +# print(x_min) +# print(x_max) +# # total_f.update_integration_options(draws_per_dim=2000000, mc_sampler=None) +# total_f.update_integration_options(mc_sampler=lambda dim, num_results, +# dtype: tf.random_uniform(maxval=1., shape=(num_results, dim), dtype=dtype), +# draws_per_dim=1000000) +# # _ = [] + +# # for i in range(10): + +# # inte = total_f.integrate(limits = (x_min, x_max)) +# # inte_fl = zfit.run(inte) +# # print(inte_fl) +# # _.append(inte_fl) + +# # print("mean:", np.mean(_)) + +# _ = time.time() + +# inte = total_f.integrate(limits = (x_min, x_max)) +# inte_fl = zfit.run(inte) +# print(inte_fl) +# print("Time taken: {}".format(display_time(int(time.time() - _)))) + +# print(pdg['NR_BR']/pdg['NR_auc']*inte_fl) +# print(0.25**2*4.2/1000) + + +# # Sampling +# ## Mixture distribution for sampling + +# In[ ]: + + + + +# print(list_of_borders[:9]) +# print(list_of_borders[-9:]) + + +class UniformSampleAndWeights(zfit.util.execution.SessionHolderMixin): + def __call__(self, limits, dtype, n_to_produce): + # n_to_produce = tf.cast(n_to_produce, dtype=tf.int32) + low, high = limits.limit1d + low = tf.cast(low, dtype=dtype) + high = tf.cast(high, dtype=dtype) +# uniform = tfd.Uniform(low=low, high=high) +# uniformjpsi = tfd.Uniform(low=tf.constant(3080, dtype=dtype), high=tf.constant(3112, dtype=dtype)) +# uniformpsi2s = tfd.Uniform(low=tf.constant(3670, dtype=dtype), high=tf.constant(3702, dtype=dtype)) + +# list_of_borders = [] +# _p = [] +# splits = 10 + +# _ = np.linspace(x_min, x_max, splits) + +# for i in range(splits): +# list_of_borders.append(tf.constant(_[i], dtype=dtype)) +# _p.append(tf.constant(1/splits, dtype=dtype)) + +# mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=_p[:(splits-1)]), +# components_distribution=tfd.Uniform(low=list_of_borders[:(splits-1)], +# high=list_of_borders[-(splits-1):])) + mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=[tf.constant(0.05, dtype=dtype), + tf.constant(0.93, dtype=dtype), + tf.constant(0.05, dtype=dtype), + tf.constant(0.065, dtype=dtype), + tf.constant(0.04, dtype=dtype), + tf.constant(0.05, dtype=dtype)]), + components_distribution=tfd.Uniform(low=[tf.constant(x_min, dtype=dtype), + tf.constant(3090, dtype=dtype), + tf.constant(3681, dtype=dtype), + tf.constant(3070, dtype=dtype), + tf.constant(1000, dtype=dtype), + tf.constant(3660, dtype=dtype)], + high=[tf.constant(x_max, dtype=dtype), + tf.constant(3102, dtype=dtype), + tf.constant(3691, dtype=dtype), + tf.constant(3110, dtype=dtype), + tf.constant(1040, dtype=dtype), + tf.constant(3710, dtype=dtype)])) +# dtype = tf.float64 +# mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=[tf.constant(0.04, dtype=dtype), +# tf.constant(0.90, dtype=dtype), +# tf.constant(0.02, dtype=dtype), +# tf.constant(0.07, dtype=dtype), +# tf.constant(0.02, dtype=dtype)]), +# components_distribution=tfd.Uniform(low=[tf.constant(x_min, dtype=dtype), +# tf.constant(3089, dtype=dtype), +# tf.constant(3103, dtype=dtype), +# tf.constant(3681, dtype=dtype), +# tf.constant(3691, dtype=dtype)], +# high=[tf.constant(3089, dtype=dtype), +# tf.constant(3103, dtype=dtype), +# tf.constant(3681, dtype=dtype), +# tf.constant(3691, dtype=dtype), +# tf.constant(x_max, dtype=dtype)])) +# mixture = tfd.Uniform(tf.constant(x_min, dtype=dtype), tf.constant(x_max, dtype=dtype)) +# sample = tf.random.uniform((n_to_produce, 1), dtype=dtype) + sample = mixture.sample((n_to_produce, 1)) +# sample = tf.random.uniform((n_to_produce, 1), dtype=dtype) + weights = mixture.prob(sample)[:,0] +# weights = tf.broadcast_to(tf.constant(1., dtype=dtype), shape=(n_to_produce,)) + # sample = tf.expand_dims(sample, axis=-1) +# print(sample, weights) + +# weights = tf.ones(shape=(n_to_produce,), dtype=dtype) + weights_max = None + thresholds = tf.random_uniform(shape=(n_to_produce,), dtype=dtype) + return sample, thresholds, weights, weights_max, n_to_produce + + +# In[ ]: + + +# total_f._sample_and_weights = UniformSampleAndWeights + + +# In[ ]: + + +# 0.00133/(0.00133+0.213+0.015)*(x_max-3750)/(x_max-x_min) + + +# In[ ]: + + +# zfit.settings.set_verbosity(10) + + +# In[ ]: + + +# # zfit.run.numeric_checks = False + +# nr_of_toys = 1 +# nevents = int(pdg["number_of_decays"]) +# nevents = pdg["number_of_decays"] +# event_stack = 1000000 +# # zfit.settings.set_verbosity(10) +# calls = int(nevents/event_stack + 1) + +# total_samp = [] + +# start = time.time() + +# sampler = total_f.create_sampler(n=event_stack) + +# for toy in range(nr_of_toys): + +# dirName = 'data/zfit_toys/toy_{0}'.format(toy) + +# if not os.path.exists(dirName): +# os.mkdir(dirName) +# print("Directory " , dirName , " Created ") + +# for call in range(calls): + +# sampler.resample(n=event_stack) +# s = sampler.unstack_x() +# sam = zfit.run(s) +# # clear_output(wait=True) + +# c = call + 1 + +# print("{0}/{1} of Toy {2}/{3}".format(c, calls, toy+1, nr_of_toys)) +# print("Time taken: {}".format(display_time(int(time.time() - start)))) +# print("Projected time left: {}".format(display_time(int((time.time() - start)/(c+calls*(toy))*((nr_of_toys-toy)*calls-c))))) + +# with open("data/zfit_toys/toy_{0}/{1}.pkl".format(toy, call), "wb") as f: +# pkl.dump(sam, f, pkl.HIGHEST_PROTOCOL) + + +# In[ ]: + + +# with open(r"data/zfit_toys/toy_0/0.pkl", "rb") as input_file: +# sam = pkl.load(input_file) +# print(sam[:10]) + +# with open(r"data/zfit_toys/toy_0/1.pkl", "rb") as input_file: +# sam2 = pkl.load(input_file) +# print(sam2[:10]) + +# print(np.sum(sam-sam2)) + + +# In[ ]: + + +# print("Time to generate full toy: {} s".format(int(time.time()-start))) + +# total_samp = [] + +# for call in range(calls): +# with open(r"data/zfit_toys/toy_0/{}.pkl".format(call), "rb") as input_file: +# sam = pkl.load(input_file) +# total_samp = np.append(total_samp, sam) + +# total_samp = total_samp.astype('float64') + +# data2 = zfit.data.Data.from_numpy(array=total_samp[:int(nevents)], obs=obs) + +# data3 = zfit.data.Data.from_numpy(array=total_samp, obs=obs) + +# print(total_samp[:nevents].shape) + + +# In[ ]: + + +# plt.clf() + +# bins = int((x_max-x_min)/7) + +# # calcs = zfit.run(total_test_tf(samp)) +# print(total_samp[:nevents].shape) + +# plt.hist(total_samp[:nevents], bins = bins, range = (x_min,x_max), label = 'data') +# # plt.plot(test_q, calcs_test*nevents , label = 'pdf') + +# # plt.plot(sam, calcs, '.') +# # plt.plot(test_q, calcs_test) +# # plt.yscale('log') +# plt.ylim(0, 200) +# # plt.xlim(3080, 3110) + +# plt.legend() + +# plt.savefig('test2.png') + + +# In[ ]: + + +# sampler = total_f.create_sampler(n=nevents) +# nll = zfit.loss.UnbinnedNLL(model=total_f, data=sampler, fit_range = (x_min, x_max)) + +# # for param in pdf.get_dependents(): +# # param.set_value(initial_value) + +# sampler.resample(n=nevents) + +# # Randomise initial values +# # for param in pdf.get_dependents(): +# # param.set_value(random value here) + +# # Minimise the NLL +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 10) +# minimum = minimizer.minimize(nll) + + +# In[ ]: + + +# jpsi_width + + +# In[ ]: + + +# plt.hist(sample, weights=1 / prob(sample)) + + +# # Fitting + +# In[ ]: + + +# start = time.time() + +# for param in total_f.get_dependents(): +# param.randomize() + +# # for param in total_f.get_dependents(): +# # print(zfit.run(param)) + +# nll = zfit.loss.UnbinnedNLL(model=total_f, data=data2, fit_range = (x_min, x_max)) + +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) +# # minimizer._use_tfgrad = False +# result = minimizer.minimize(nll) + +# # param_errors = result.error() + +# # for var, errors in param_errors.items(): +# # print('{}: ^{{+{}}}_{{{}}}'.format(var.name, errors['upper'], errors['lower'])) + +# print("Function minimum:", result.fmin) +# # print("Results:", result.params) +# print("Hesse errors:", result.hesse()) + + +# In[ ]: + + +# print("Time taken for fitting: {}".format(display_time(int(time.time()-start)))) + +# # probs = total_f.pdf(test_q) + +# calcs_test = zfit.run(probs) +# res_y = zfit.run(jpsi_res(test_q)) + + +# In[ ]: + + +# plt.clf() +# # plt.plot(x_part, calcs, '.') +# plt.plot(test_q, calcs_test, label = 'pdf') +# # plt.plot(test_q, res_y, label = 'res') +# plt.legend() +# plt.ylim(0.0, 10e-6) +# # plt.yscale('log') +# # plt.xlim(3080, 3110) +# plt.savefig('test3.png') +# # print(jpsi_width) + + +# In[ ]: + + +# _tot = 4.37e-7+6.02e-5+4.97e-6 +# _probs = [] +# _probs.append(6.02e-5/_tot) +# _probs.append(4.97e-6/_tot) +# _probs.append(4.37e-7/_tot) +# print(_probs) + + +# In[ ]: + + +# dtype = 'float64' +# # mixture = tfd.Uniform(tf.constant(x_min, dtype=dtype), tf.constant(x_max, dtype=dtype)) +# mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=[tf.constant(0.007, dtype=dtype), +# tf.constant(0.917, dtype=dtype), +# tf.constant(0.076, dtype=dtype)]), +# components_distribution=tfd.Uniform(low=[tf.constant(x_min, dtype=dtype), +# tf.constant(3080, dtype=dtype), +# tf.constant(3670, dtype=dtype)], +# high=[tf.constant(x_max, dtype=dtype), +# tf.constant(3112, dtype=dtype), +# tf.constant(3702, dtype=dtype)])) +# # for i in range(10): +# # print(zfit.run(mixture.prob(mixture.sample((10, 1))))) + + +# In[ ]: + + +# print((zfit.run(jpsi_p)%(2*np.pi))/np.pi) +# print((zfit.run(psi2s_p)%(2*np.pi))/np.pi) + + +# In[ ]: + + +# def jpsi_res(q): +# return resonance(q, _mass = jpsi_mass, scale = jpsi_scale, +# phase = jpsi_phase, width = jpsi_width) + +# def psi2s_res(q): +# return resonance(q, _mass = psi2s_mass, scale = psi2s_scale, +# phase = psi2s_phase, width = psi2s_width) + +# def p3770_res(q): +# return resonance(q, _mass = p3770_mass, scale = p3770_scale, +# phase = p3770_phase, width = p3770_width) + +# def p4040_res(q): +# return resonance(q, _mass = p4040_mass, scale = p4040_scale, +# phase = p4040_phase, width = p4040_width) + +# def p4160_res(q): +# return resonance(q, _mass = p4160_mass, scale = p4160_scale, +# phase = p4160_phase, width = p4160_width) + +# def p4415_res(q): +# return resonance(q, _mass = p4415_mass, scale = p4415_scale, +# phase = p4415_phase, width = p4415_width) + + +# In[ ]: + + +# 0.15**2*4.2/1000 +# result.hesse() + + +# ## Constraints + +# In[ ]: + + +# 1. Constraint - Real part of sum of Psi contrib and D contribs + +sum_list = [] + +sum_list.append(ztf.to_complex(jpsi_s) * tf.exp(tf.complex(ztf.constant(0.0), jpsi_p)) * ztf.to_complex(jpsi_w / (tf.pow(jpsi_m,3)))) +sum_list.append(ztf.to_complex(psi2s_s) * tf.exp(tf.complex(ztf.constant(0.0), psi2s_p)) * ztf.to_complex(psi2s_w / (tf.pow(psi2s_m,3)))) +sum_list.append(ztf.to_complex(p3770_s) * tf.exp(tf.complex(ztf.constant(0.0), p3770_p)) * ztf.to_complex(p3770_w / (tf.pow(p3770_m,3)))) +sum_list.append(ztf.to_complex(p4040_s) * tf.exp(tf.complex(ztf.constant(0.0), p4040_p)) * ztf.to_complex(p4040_w / (tf.pow(p4040_m,3)))) +sum_list.append(ztf.to_complex(p4160_s) * tf.exp(tf.complex(ztf.constant(0.0), p4160_p)) * ztf.to_complex(p4160_w / (tf.pow(p4160_m,3)))) +sum_list.append(ztf.to_complex(p4415_s) * tf.exp(tf.complex(ztf.constant(0.0), p4415_p)) * ztf.to_complex(p4415_w / (tf.pow(p4415_m,3)))) +sum_list.append(ztf.to_complex(DDstar_s) * tf.exp(tf.complex(ztf.constant(0.0), DDstar_p)) * (ztf.to_complex(1.0 / (10.0*tf.pow(Dstar_m,2)) + 1.0 / (10.0*tf.pow(D_m,2))))) +sum_list.append(ztf.to_complex(Dbar_s) * tf.exp(tf.complex(ztf.constant(0.0), Dbar_p)) * ztf.to_complex(1.0 / (6.0*tf.pow(Dbar_m,2)))) + +sum_ru_1 = ztf.to_complex(ztf.constant(0.0)) + +for part in sum_list: + sum_ru_1 += part + +sum_1 = tf.math.real(sum_ru_1) +# constraint1 = zfit.constraint.GaussianConstraint(params = sum_1, mu = ztf.constant(1.7*10**-8), +# sigma = ztf.constant(2.2*10**-8)) + +constraint1 = tf.pow((sum_1-ztf.constant(1.7*10**-8))/ztf.constant(2.2*10**-8),2)/ztf.constant(2.) + +# 2. Constraint - Abs. of sum of Psi contribs and D contribs + +sum_2 = tf.abs(sum_ru_1) +constraint2 = tf.cond(tf.greater_equal(sum_2, 5.0e-8), lambda: 100000., lambda: 0.) + +# 3. Constraint - Maximum eta of D contribs + +constraint3_0 = tf.cond(tf.greater_equal(tf.abs(Dbar_s), 0.2), lambda: 100000., lambda: 0.) + +constraint3_1 = tf.cond(tf.greater_equal(tf.abs(DDstar_s), 0.2), lambda: 100000., lambda: 0.) + +# 4. Constraint - Formfactor multivariant gaussian covariance fplus + +Cov_matrix = [[ztf.constant( 1.), ztf.constant( 0.45), ztf.constant( 0.19), ztf.constant(0.857), ztf.constant(0.598), ztf.constant(0.531), ztf.constant(0.752), ztf.constant(0.229), ztf.constant(0,117)], + [ztf.constant( 0.45), ztf.constant( 1.), ztf.constant(0.677), ztf.constant(0.708), ztf.constant(0.958), ztf.constant(0.927), ztf.constant(0.227), ztf.constant(0.443), ztf.constant(0.287)], + [ztf.constant( 0.19), ztf.constant(0.677), ztf.constant( 1.), ztf.constant(0.595), ztf.constant(0.770), ztf.constant(0.819),ztf.constant(-0.023), ztf.constant( 0.07), ztf.constant(0.196)], + [ztf.constant(0.857), ztf.constant(0.708), ztf.constant(0.595), ztf.constant( 1.), ztf.constant( 0.83), ztf.constant(0.766), ztf.constant(0.582), ztf.constant(0.237), ztf.constant(0.192)], + [ztf.constant(0.598), ztf.constant(0.958), ztf.constant(0.770), ztf.constant( 0.83), ztf.constant( 1.), ztf.constant(0.973), ztf.constant(0.324), ztf.constant(0.372), ztf.constant(0.272)], + [ztf.constant(0.531), ztf.constant(0.927), ztf.constant(0.819), ztf.constant(0.766), ztf.constant(0.973), ztf.constant( 1.), ztf.constant(0.268), ztf.constant(0.332), ztf.constant(0.269)], + [ztf.constant(0.752), ztf.constant(0.227),ztf.constant(-0.023), ztf.constant(0.582), ztf.constant(0.324), ztf.constant(0.268), ztf.constant( 1.), ztf.constant( 0.59), ztf.constant(0.515)], + [ztf.constant(0.229), ztf.constant(0.443), ztf.constant( 0.07), ztf.constant(0.237), ztf.constant(0.372), ztf.constant(0.332), ztf.constant( 0.59), ztf.constant( 1.), ztf.constant(0.897)], + [ztf.constant(0.117), ztf.constant(0.287), ztf.constant(0.196), ztf.constant(0.192), ztf.constant(0.272), ztf.constant(0.269), ztf.constant(0.515), ztf.constant(0.897), ztf.constant( 1.)]] + +def triGauss(val1,val2,val3,m = Cov_matrix): + + mean1 = ztf.constant(0.466) + mean2 = ztf.constant(-0.885) + mean3 = ztf.constant(-0.213) + sigma1 = ztf.constant(0.014) + sigma2 = ztf.constant(0.128) + sigma3 = ztf.constant(0.548) + x1 = (val1-mean1)/sigma1 + x2 = (val2-mean2)/sigma2 + x3 = (val3-mean3)/sigma3 + rho12 = m[0][1] + rho13 = m[0][2] + rho23 = m[1][2] + w = x1*x1*(rho23*rho23-1) + x2*x2*(rho13*rho13-1)+x3*x3*(rho12*rho12-1)+2*(x1*x2*(rho12-rho13*rho23)+x1*x3*(rho13-rho12*rho23)+x2*x3*(rho23-rho12*rho13)) + d = 2*(rho12*rho12+rho13*rho13+rho23*rho23-2*rho12*rho13*rho23-1) + + fcn = -w/d + chisq = -2*fcn + return chisq + +constraint4 = triGauss(bplus_0, bplus_1, bplus_2) + +# mean1 = ztf.constant(0.466) +# mean2 = ztf.constant(-0.885) +# mean3 = ztf.constant(-0.213) +# sigma1 = ztf.constant(0.014) +# sigma2 = ztf.constant(0.128) +# sigma3 = ztf.constant(0.548) +# constraint4_0 = tf.pow((bplus_0-mean1)/sigma1,2)/ztf.constant(2.) +# constraint4_1 = tf.pow((bplus_1-mean2)/sigma2,2)/ztf.constant(2.) +# constraint4_2 = tf.pow((bplus_2-mean3)/sigma3,2)/ztf.constant(2.) + +# 5. Constraint - Abs. of sum of light contribs + +sum_list_5 = [] + +sum_list_5.append(rho_s*rho_w/rho_m) +sum_list_5.append(omega_s*omega_w/omega_m) +sum_list_5.append(phi_s*phi_w/phi_m) + + +sum_ru_5 = ztf.constant(0.0) + +for part in sum_list_5: + sum_ru_5 += part + +constraint5 = tf.cond(tf.greater_equal(tf.abs(sum_ru_5), ztf.constant(0.02)), lambda: 100000., lambda: 0.) + +# 6. Constraint on phases of Jpsi and Psi2s for cut out fit + + +# constraint6_0 = zfit.constraint.GaussianConstraint(params = jpsi_p, mu = ztf.constant(pdg["jpsi_phase_unc"]), +# sigma = ztf.constant(jpsi_phase)) +# constraint6_1 = zfit.constraint.GaussianConstraint(params = psi2s_p, mu = ztf.constant(pdg["psi2s_phase_unc"]), +# sigma = ztf.constant(psi2s_phase)) + +constraint6_0 = tf.pow((jpsi_p-ztf.constant(jpsi_phase))/ztf.constant(pdg["jpsi_phase_unc"]),2)/ztf.constant(2.) +constraint6_1 = tf.pow((psi2s_p-ztf.constant(psi2s_phase))/ztf.constant(pdg["psi2s_phase_unc"]),2)/ztf.constant(2.) + +# 7. Constraint on Ctt with higher limits + +constraint7 = tf.cond(tf.greater_equal(Ctt*Ctt, 0.25), lambda: 100000., lambda: 0.) + +constraint7dtype = tf.float64 + +# zfit.run(constraint6_0) + +# ztf.convert_to_tensor(constraint6_0) + +#List of all constraints + +constraints = [constraint1, constraint2, constraint3_0, constraint3_1,# constraint4, #constraint4_0, constraint4_1, constraint4_2, + constraint6_0, constraint6_1]#, constraint7] + + +# ## Reset params + +# In[ ]: + + +param_values_dic = { + 'jpsi_m': jpsi_mass, + 'jpsi_s': jpsi_scale, + 'jpsi_p': jpsi_phase, + 'jpsi_w': jpsi_width, + 'psi2s_m': psi2s_mass, + 'psi2s_s': psi2s_scale, + 'psi2s_p': psi2s_phase, + 'psi2s_w': psi2s_width, + 'p3770_m': p3770_mass, + 'p3770_s': p3770_scale, + 'p3770_p': p3770_phase, + 'p3770_w': p3770_width, + 'p4040_m': p4040_mass, + 'p4040_s': p4040_scale, + 'p4040_p': p4040_phase, + 'p4040_w': p4040_width, + 'p4160_m': p4160_mass, + 'p4160_s': p4160_scale, + 'p4160_p': p4160_phase, + 'p4160_w': p4160_width, + 'p4415_m': p4415_mass, + 'p4415_s': p4415_scale, + 'p4415_p': p4415_phase, + 'p4415_w': p4415_width, + 'rho_m': rho_mass, + 'rho_s': rho_scale, + 'rho_p': rho_phase, + 'rho_w': rho_width, + 'omega_m': omega_mass, + 'omega_s': omega_scale, + 'omega_p': omega_phase, + 'omega_w': omega_width, + 'phi_m': phi_mass, + 'phi_s': phi_scale, + 'phi_p': phi_phase, + 'phi_w': phi_width, + 'Dstar_m': Dstar_mass, + 'DDstar_s': 0.0, + 'DDstar_p': 0.0, + 'D_m': D_mass, + 'Dbar_m': Dbar_mass, + 'Dbar_s': 0.0, + 'Dbar_p': 0.0, + 'tau_m': pdg['tau_M'], + 'Ctt': 0.0, + 'b0_0': 0.292, + 'b0_1': 0.281, + 'b0_2': 0.150, + 'bplus_0': 0.466, + 'bplus_1': -0.885, + 'bplus_2': -0.213, + 'bT_0': 0.460, + 'bT_1': -1.089, + 'bT_2': -1.114} + + +def reset_param_values(variation = 0.05): + for param in total_f_fit.get_dependents(): + if param.floating: + param.set_value(param_values_dic[param.name] + random.uniform(-1, 1) * param_values_dic[param.name]* variation) +# print(param.name) +# for param in totalf.get_dependents(): +# param.set_value() + + +# # Analysis + +# In[ ]: + + +# # zfit.run.numeric_checks = False + +# fitting_range = 'cut' +# total_BR = 1.7e-10 + 4.9e-10 + 2.5e-9 + 6.02e-5 + 4.97e-6 + 1.38e-9 + 4.2e-10 + 2.6e-9 + 6.1e-10 + 4.37e-7 +# cut_BR = 1.0 - (6.02e-5 + 4.97e-6)/total_BR + +# Ctt_list = [] +# Ctt_error_list = [] + +# nr_of_toys = 1 +# if fitting_range == 'cut': +# nevents = int(pdg["number_of_decays"]*cut_BR) +# else: +# nevents = int(pdg["number_of_decays"]) +# # nevents = pdg["number_of_decays"] +# event_stack = 1000000 +# # nevents *= 41 +# # zfit.settings.set_verbosity(10) +# calls = int(nevents/event_stack + 1) + +# total_samp = [] + +# start = time.time() + +# sampler = total_f.create_sampler(n=event_stack) + +# for toy in range(nr_of_toys): + +# ### Generate data + +# # clear_output(wait=True) + +# print("Toy {}: Generating data...".format(toy)) + +# dirName = 'data/zfit_toys/toy_{0}'.format(toy) + +# if not os.path.exists(dirName): +# os.mkdir(dirName) +# print("Directory " , dirName , " Created ") + +# reset_param_values() + +# if fitting_range == 'cut': + +# sampler.resample(n=nevents) +# s = sampler.unstack_x() +# sam = zfit.run(s) +# calls = 0 +# c = 1 + +# else: +# for call in range(calls): + +# sampler.resample(n=event_stack) +# s = sampler.unstack_x() +# sam = zfit.run(s) + +# c = call + 1 + +# with open("data/zfit_toys/toy_{0}/{1}.pkl".format(toy, call), "wb") as f: +# pkl.dump(sam, f, pkl.HIGHEST_PROTOCOL) + +# print("Toy {}: Data generation finished".format(toy)) + +# ### Load data + +# print("Toy {}: Loading data...".format(toy)) + +# if fitting_range == 'cut': + +# total_samp = sam + +# else: + +# for call in range(calls): +# with open(r"data/zfit_toys/toy_0/{}.pkl".format(call), "rb") as input_file: +# sam = pkl.load(input_file) +# total_samp = np.append(total_samp, sam) + +# total_samp = total_samp.astype('float64') + +# if fitting_range == 'full': + +# data = zfit.data.Data.from_numpy(array=total_samp[:int(nevents)], obs=obs) + +# print("Toy {}: Loading data finished".format(toy)) + +# ### Fit data + +# print("Toy {}: Fitting pdf...".format(toy)) + +# for param in total_f.get_dependents(): +# param.randomize() + +# nll = zfit.loss.UnbinnedNLL(model=total_f, data=data, fit_range = (x_min, x_max), constraints = constraints) + +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) +# # minimizer._use_tfgrad = False +# result = minimizer.minimize(nll) + +# print("Toy {}: Fitting finished".format(toy)) + +# print("Function minimum:", result.fmin) +# print("Hesse errors:", result.hesse()) + +# params = result.params +# Ctt_list.append(params[Ctt]['value']) +# Ctt_error_list.append(params[Ctt]['minuit_hesse']['error']) + +# #plotting the result + +# plotdirName = 'data/plots'.format(toy) + +# if not os.path.exists(plotdirName): +# os.mkdir(plotdirName) +# # print("Directory " , dirName , " Created ") + +# probs = total_f.pdf(test_q, norm_range=False) +# calcs_test = zfit.run(probs) +# plt.clf() +# plt.plot(test_q, calcs_test, label = 'pdf') +# plt.legend() +# plt.ylim(0.0, 6e-6) +# plt.savefig(plotdirName + '/toy_fit_full_range{}.png'.format(toy)) + +# print("Toy {0}/{1}".format(toy+1, nr_of_toys)) +# print("Time taken: {}".format(display_time(int(time.time() - start)))) +# print("Projected time left: {}".format(display_time(int((time.time() - start)/(c+calls*(toy))*((nr_of_toys-toy)*calls-c))))) + +# if fitting_range == 'cut': + +# _1 = np.where((total_samp >= x_min) & (total_samp <= (jpsi_mass - 60.))) + +# tot_sam_1 = total_samp[_1] + +# _2 = np.where((total_samp >= (jpsi_mass + 70.)) & (total_samp <= (psi2s_mass - 50.))) + +# tot_sam_2 = total_samp[_2] + +# _3 = np.where((total_samp >= (psi2s_mass + 50.)) & (total_samp <= x_max)) + +# tot_sam_3 = total_samp[_3] + +# tot_sam = np.append(tot_sam_1, tot_sam_2) +# tot_sam = np.append(tot_sam, tot_sam_3) + +# data = zfit.data.Data.from_numpy(array=tot_sam[:int(nevents)], obs=obs_fit) + +# print("Toy {}: Loading data finished".format(toy)) + +# ### Fit data + +# print("Toy {}: Fitting pdf...".format(toy)) + +# for param in total_f_fit.get_dependents(): +# param.randomize() + +# nll = zfit.loss.UnbinnedNLL(model=total_f_fit, data=data, constraints = constraints) + +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) +# # minimizer._use_tfgrad = False +# result = minimizer.minimize(nll) + +# print("Function minimum:", result.fmin) +# print("Hesse errors:", result.hesse()) + +# params = result.params + +# if result.converged: +# Ctt_list.append(params[Ctt]['value']) +# Ctt_error_list.append(params[Ctt]['minuit_hesse']['error']) + +# #plotting the result + +# plotdirName = 'data/plots'.format(toy) + +# if not os.path.exists(plotdirName): +# os.mkdir(plotdirName) +# # print("Directory " , dirName , " Created ") + +# plt.clf() +# plt.hist(tot_sam, bins = int((x_max-x_min)/7.), label = 'toy data') +# plt.savefig(plotdirName + '/toy_histo_cut_region{}.png'.format(toy)) + + +# probs = total_f_fit.pdf(test_q, norm_range=False) +# calcs_test = zfit.run(probs) +# plt.clf() +# plt.plot(test_q, calcs_test, label = 'pdf') +# plt.axvline(x=jpsi_mass-60.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.axvline(x=jpsi_mass+70.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.axvline(x=psi2s_mass-50.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.axvline(x=psi2s_mass+50.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.legend() +# plt.ylim(0.0, 1.5e-6) +# plt.savefig(plotdirName + '/toy_fit_cut_region{}.png'.format(toy)) + +# print("Toy {0}/{1}".format(toy+1, nr_of_toys)) +# print("Time taken: {}".format(display_time(int(time.time() - start)))) +# print("Projected time left: {}".format(display_time(int((time.time() - start)/(toy+1))*((nr_of_toys-toy-1))))) + + + +# In[ ]: + + +# with open("data/results/Ctt_list.pkl", "wb") as f: +# pkl.dump(Ctt_list, f, pkl.HIGHEST_PROTOCOL) +# with open("data/results/Ctt_error_list.pkl", "wb") as f: +# pkl.dump(Ctt_error_list, f, pkl.HIGHEST_PROTOCOL) + + +# In[ ]: + + +# print('{0}/{1} fits converged'.format(len(Ctt_list), nr_of_toys)) +# print('Mean Ctt value = {}'.format(np.mean(Ctt_list))) +# print('Mean Ctt error = {}'.format(np.mean(Ctt_error_list))) +# print('95 Sensitivy = {}'.format(((2*np.mean(Ctt_error_list))**2)*4.2/1000)) + + +# In[ ]: + + +# plt.hist(tot_sam, bins = int((x_max-x_min)/7.)) + +# plt.show() + +# # _ = np.where((total_samp >= x_min) & (total_samp <= (jpsi_mass - 50.))) + +# tot_sam.shape + + +# In[ ]: + + +# Ctt.floating = False + + +# In[ ]: + + +# zfit.run(nll.value()) + + +# In[ ]: + + +# result.fmin + + +# In[ ]: + + +# BR_steps = np.linspace(0.0, 1e-3, 11) +pull_dic = {} + +mi = 1e-4 +ma = 3e-3 +ste = 20 + +for param in total_f_fit.get_dependents(): + if param.floating: + pull_dic[param.name] = [] + for step in range(2*ste): + pull_dic[param.name].append([]) + + + +def save_pulls(step): + for param in total_f_fit.get_dependents(): + if param.floating: + pull_dic[param.name][step].append((params[param]['value'] - param_values_dic[param.name])/params[param]['minuit_hesse']['error']) + + + +# for key in pull_dic.keys(): +# print(np.shape(pull_dic[key])) +# save_pulls(New_step=True) +# params[Ctt]['value'] + + +# In[ ]: + + +# for param in total_f_fit.get_dependents(): +# if param.floating: +# print(param.name) + +# print(params[Ctt]) + + +# # CLS Code + +# In[ ]: + + +# zfit.run.numeric_checks = False + +load = False + +bo = True + +D_contribs = True + +if not D_contribs: + Dbar_s.floating = False + Dbar_p.floating = False + DDstar_s.floating = False + DDstar_p.floating = False + +bo_set = 1 + +fitting_range = 'cut' +total_BR = 1.7e-10 + 4.9e-10 + 2.5e-9 + 6.02e-5 + 4.97e-6 + 1.38e-9 + 4.2e-10 + 2.6e-9 + 6.1e-10 + 4.37e-7 +cut_BR = 1.0 - (6.02e-5 + 4.97e-6)/total_BR + +Ctt_list = [] +Ctt_error_list = [] + +nr_of_toys = 1 +nevents = int(pdg["number_of_decays"]*cut_BR) +# nevents = pdg["number_of_decays"] +event_stack = 1000000 +# nevents *= 41 +# zfit.settings.set_verbosity(10) + +# mi = 1e-4 +# ma = 3e-3 +# ste = 13 + +BR_steps = np.linspace(mi, ma, ste) + +BR_steps[0] = 0.0 + +print(BR_steps) + +Ctt_steps = np.sqrt(BR_steps/4.2*1000) + +print(Ctt_steps) + +# total_samp = [] + +start = time.time() + +Nll_list = [] + +sampler = total_f.create_sampler(n=nevents, fixed_params = False) +sampler.set_data_range(obs_fit) + +__ = -1 + +#----------------------------------------------------- + +if not load: + for Ctt_step in Ctt_steps: + + __ += 1 + + for i in range(2): + Ctt_list.append([]) + Ctt_error_list.append([]) + Nll_list.append([]) + + for param in total_f_fit.get_dependents(): + if param.floating: + pull_dic[param.name].append([]) + + for toy in range(nr_of_toys): + + newset = True + + while newset: + + for floaty in [True, False]: + Ctt.floating = floaty + + for bo_step in range(bo_set): + + print('Step: {0}/{1}'.format(int(__), ste)) + print('Current Ctt: {0}'.format(Ctt_step)) + print('Ctt floating: {0}'.format(floaty)) + + reset_param_values(variation = 0.0) + + if floaty: + print('Toy {0}/{1} - Fit {2}/{3}'.format(toy, nr_of_toys, bo_step, bo_set)) + Ctt.set_value(Ctt_step) + + else: + Ctt.set_value(0.0) + print('Toy {0}/{1} - Fit {2}/{3}'.format(toy, nr_of_toys, bo_step, bo_set)) + + if newset: + sampler.resample(n=nevents) + data = sampler + newset = False + + ### Fit data + + if floaty: + #plt.clf() + #plt.title('Ctt value: {:.2f}'.format(Ctt_step)) + #plt.hist(zfit.run(data), bins = int((x_max-x_min)/7), range = (x_min, x_max)) + #plt.savefig('data/CLs/plots/set_histo{}.png'.format(__)) + _step = 2*__ + else: + _step = 2*__+1 + + nll = zfit.loss.UnbinnedNLL(model=total_f_fit, data=data, constraints = constraints) + + minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) + # minimizer._use_tfgrad = False + result = minimizer.minimize(nll) + + print("Function minimum:", result.fmin) + print("Hesse errors:", result.hesse()) + + params = result.params + + if result.converged: + + save_pulls(step = _step) + + if floaty: + Nll_list[-2].append(result.fmin) + Ctt_list[-2].append(params[Ctt]['value']) + Ctt_error_list[-2].append(params[Ctt]['minuit_hesse']['error']) + + else: + Nll_list[-1].append(result.fmin) + Ctt_list[-1].append(0.0) + Ctt_error_list[-1].append(0.0) + + + else: + for _ in [1,2]: + del Nll_list[-_][toy*bo_set:] +# print(np.shape(Nll_list[-_])) + del Ctt_list[-_][toy*bo_set:] + del Ctt_error_list[-_][toy*bo_set:] + for param in total_f_fit.get_dependents(): + if param.floating: + del pull_dic[param.name][_step+1-_][toy*bo_set:] + newset = True + break + + if not result.converged: + break + + print() + print('Time taken: {}'.format(display_time(int(time.time()-start)))) + print('Estimated time left: {}'.format(display_time(int((time.time()-start)/(__+(toy+1)/nr_of_toys)*(ste-__-(nr_of_toys-toy-1)/nr_of_toys))))) + + +# In[ ]: + + +if load: + + phase_combi = '--' + + if D_contribs: + D_dir = 'D-True' + else: + D_dir = 'D-False' + + _dir = 'data/CLs/finished/f1d1/{}/{}/'.format(phase_combi, D_dir) + + jobs = os.listdir(_dir) + + First = True + +# print(jobs) + + for job in jobs: + + dirName = _dir + str(job) + '/data/CLs' + + if not os.path.exists("{}/{}-{}_{}s{}b{}t--CLs_Nll_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys)): +# print(job) + continue + + with open(r"{}/variab.pkl".format(dirName), "rb") as input_file: + variab = pkl.load(input_file) +# print(variab) + + ### sanity check: + if variab['mi'] != mi or variab['ma'] != ma or variab['ste'] != ste or bo_set != bo_set: + print('Fitting parameters of data dont equal the ones given -- Job {} skipped!'.format(job)) + + with open(r"{}/{}-{}_{}s{}b{}t--CLs_Nll_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _Nll_list = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s{}b{}t--Ctt_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _Ctt_list = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s{}b{}t--Ctt_error_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _Ctt_error_list = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s{}b{}t--pull_dic.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _pull_dic = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s--CLs_list.pkl".format(dirName, mi,ma,ste), "rb") as input_file: + _CLs_list = pkl.load(input_file) + + + if First: + Nll_list = _Nll_list + Ctt_list = _Ctt_list + Ctt_error_list = _Ctt_error_list + pull_dic = _pull_dic +# print(_pull_dic) + CLs_list = _CLs_list + First = False + else: + for step in range(2*ste): +# print(Nll_list[step], step) + Nll_list[step].extend(_Nll_list[step]) + Ctt_list[step].extend(_Ctt_list[step]) + Ctt_error_list[step].extend(_Ctt_error_list[step]) + for key in pull_dic.keys(): +# print(key, np.shape(pull_dic[key])) + pull_dic[key][step].extend(_pull_dic[key][step]) + for step in range(ste): + CLs_list[step].extend(_CLs_list[step]) + +# print('----------------------') + + +# In[ ]: + + +dirName = 'data/CLs' + +# if bo and not load: +# for s in range(2*ste): +# Nll_list[s] = [np.min(Nll_list[s])] + + +if not load: + + if not os.path.exists(dirName): + os.mkdir(dirName) + print("Directory " , dirName , " Created ") + + with open("{}/{}-{}_{}s{}b{}t--CLs_Nll_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(Nll_list, f, pkl.HIGHEST_PROTOCOL) + + with open("{}/{}-{}_{}s{}b{}t--Ctt_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(Ctt_list, f, pkl.HIGHEST_PROTOCOL) + + with open("{}/{}-{}_{}s{}b{}t--Ctt_error_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(Ctt_error_list, f, pkl.HIGHEST_PROTOCOL) + + with open("{}/{}-{}_{}s{}b{}t--pull_dic.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(pull_dic, f, pkl.HIGHEST_PROTOCOL) + + variab = {'mi': mi, + 'ma': ma, + 'ste': ste, + 'bo_set': bo_set, + 'nr_of_toys': nr_of_toys} + + with open("{}/variab.pkl".format(dirName), "wb") as f: + pkl.dump(variab, f, pkl.HIGHEST_PROTOCOL) + + CLs_values = [] + + toy_size = bo_set + + print(np.shape(Nll_list)) + print(Nll_list[0:1]) + + for step in range(ste): + CLs_values.append([]) + for toy in range(nr_of_toys): + float_min = np.min(Nll_list[2*step][toy*bo_set:(toy+1)*bo_set]) + fix_min = np.min(Nll_list[2*step+1][toy*bo_set:(toy+1)*bo_set]) + CLs_values[step].append(float_min-fix_min) + + + print(np.shape(CLs_values)) + + with open("{}/{}-{}_{}s--CLs_list.pkl".format(dirName, mi,ma,ste), "wb") as f: + pkl.dump(CLs_values, f, pkl.HIGHEST_PROTOCOL) + + +# In[ ]: + + +# print(variab['mi'] != mi) + + +# ## Plot + +# In[ ]: + + +l = [] + + +if load: + CLs_values = -1*np.array(CLs_list) + +if not os.path.exists('data/CLs/plots'): + os.mkdir('data/CLs/plots') + print("Directory " , 'data/CLs/plots' , " Created ") + +print(np.shape(CLs_values)) + +for step in range(1,ste): + plt.clf() + plt.title('Ctt value: {:.2f}'.format(Ctt_steps[step])) + plt.hist(CLs_values[0], bins = 150, range = (-25, 50), label = 'Ctt fixed to 0') + plt.hist(CLs_values[step], bins = 150, range = (-25, 50), label = 'Ctt floating') + plt.axvline(x=np.mean(CLs_values[0]),color='red', linewidth=1.0, linestyle = 'dotted') + plt.legend() + plt.savefig('data/CLs/plots/CLs-BR({:.1E}).png'.format(BR_steps[step])) + + l.append(len(np.where(np.array(CLs_values[step]) < np.mean(CLs_values[0]))[0])) + +for step in range(2*ste): + if step%2 == 0: + floaty = True + else: + floaty = False + for key in pull_dic.keys(): + if not os.path.exists('data/CLs/plots/{}'.format(key)): + os.mkdir('data/CLs/plots/{}'.format(key)) + plt.clf() + plt.title('Pull {} - Ctt value {:.2f} - floating {}'.format(key, Ctt_steps[int(step/2)], floaty)) + plt.hist(pull_dic[key][step], bins = 50, range = (-5,5)) + plt.xlabel('Pull') + plt.savefig('data/CLs/plots/{}/{:.2f}Ctt{}s{}f.png'.format(key, Ctt_steps[int(step/2)], step, floaty)) + + +# In[ ]: + + +for s in range(len(l)): + print('BR: {:.4f}'.format(BR_steps[s+1])) + print(2*l[s]/len(CLs_values[s])) + print() + + +# In[ ]: + + +# for step in range(2*ste): +# for key in pull_dic.keys(): +# print(pull_dic[key][step]) + + +# In[ ]: + + +# for param in total_f_fit.get_dependents(): +# if param.floating: +# print(params[param]['value']) + + +# In[ ]: + + +print(display_time(int(time.time()-start))) + + +# In[ ]: + + +# variab['mi'] =! mi + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + diff --git a/data/CLs/finished/f1d1/-+/D-True/2288051/__pycache__/helperfunctions.cpython-37.pyc b/data/CLs/finished/f1d1/-+/D-True/2288051/__pycache__/helperfunctions.cpython-37.pyc new file mode 100644 index 0000000..2cf689c --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288051/__pycache__/helperfunctions.cpython-37.pyc Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288051/__pycache__/pdg_const1.cpython-37.pyc b/data/CLs/finished/f1d1/-+/D-True/2288051/__pycache__/pdg_const1.cpython-37.pyc new file mode 100644 index 0000000..6c50efd --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288051/__pycache__/pdg_const1.cpython-37.pyc Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288051/data/CLs/0.0001-0.003_20s--CLs_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288051/data/CLs/0.0001-0.003_20s--CLs_list.pkl new file mode 100644 index 0000000..cb49312 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288051/data/CLs/0.0001-0.003_20s--CLs_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288051/data/CLs/0.0001-0.003_20s1b1t--CLs_Nll_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288051/data/CLs/0.0001-0.003_20s1b1t--CLs_Nll_list.pkl new file mode 100644 index 0000000..ed1beea --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288051/data/CLs/0.0001-0.003_20s1b1t--CLs_Nll_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288051/data/CLs/0.0001-0.003_20s1b1t--Ctt_error_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288051/data/CLs/0.0001-0.003_20s1b1t--Ctt_error_list.pkl new file mode 100644 index 0000000..67e740d --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288051/data/CLs/0.0001-0.003_20s1b1t--Ctt_error_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288051/data/CLs/0.0001-0.003_20s1b1t--Ctt_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288051/data/CLs/0.0001-0.003_20s1b1t--Ctt_list.pkl new file mode 100644 index 0000000..cb87b22 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288051/data/CLs/0.0001-0.003_20s1b1t--Ctt_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288051/data/CLs/0.0001-0.003_20s1b1t--pull_dic.pkl b/data/CLs/finished/f1d1/-+/D-True/2288051/data/CLs/0.0001-0.003_20s1b1t--pull_dic.pkl new file mode 100644 index 0000000..784c085 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288051/data/CLs/0.0001-0.003_20s1b1t--pull_dic.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288051/data/CLs/variab.pkl b/data/CLs/finished/f1d1/-+/D-True/2288051/data/CLs/variab.pkl new file mode 100644 index 0000000..bb90dc0 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288051/data/CLs/variab.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288051/helperfunctions.py b/data/CLs/finished/f1d1/-+/D-True/2288051/helperfunctions.py new file mode 100644 index 0000000..88e120f --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288051/helperfunctions.py @@ -0,0 +1,33 @@ +# some helperfunctions + +import matplotlib +matplotlib.use("agg") +import matplotlib.pyplot as plt + +#Dislpay time (e.g. while generating points) + +display_intervals = ( + ('w', 604800), # 60 * 60 * 24 * 7 + ('d', 86400), # 60 * 60 * 24 + ('h', 3600), # 60 * 60 + ('min', 60), + ('s', 1), + ) + +def display_time(seconds, granularity=2): + result = [] + + for name, count in display_intervals: + value = seconds // count + if value: + seconds -= value * count + if value == 1: + name = name.rstrip('s') + result.append("{} {}".format(value, name)) + return ', '.join(result[:granularity]) + +def prepare_plot(title): + plt.title(title) + plt.grid() + plt.legend(loc = 'best') + plt.xlabel("q") diff --git a/data/CLs/finished/f1d1/-+/D-True/2288051/pdg_const1.py b/data/CLs/finished/f1d1/-+/D-True/2288051/pdg_const1.py new file mode 100644 index 0000000..70b3f30 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288051/pdg_const1.py @@ -0,0 +1,226 @@ +pdg = { + + + ###Particle masses### + + "mbstar" : 5415.4, + "mbstar0" : 5711.0, + "B0_M" : 5279.5, + "Bs_M" : 5366.7, + "Bplus_M" : 5279.3, + "Lb_M" : 5619.4, + "D0_M" : 1864.8, + "Dst_M" : 2010, + "pi_M" : 139.6, + "Jpsi_M" : 3096.9, + "Psi2s_M" : 3685.6, + "kaon_M" : 493.7, + "Ks_M" : 497.6, + "phi_M" : 1019.5, + "rho_M" : 775.26, + "rho_width" : 149.1, + "omega_M" : 782.65, + "omega_width" : 8.49, + + "muon_M" : 105.7, + "tau_M": 1776.86, + + "squark_M" : 95.0, + "bquark_M" : 4180.0, + "cquark_M" : 1275.0, + + "Bplus_tau" : 1.638e-12, + + ###Wilson coefficients### + + "C1" : -0.257, + "C2" : 1.009, + "C3" : -0.005, + "C4" : -0.078, + + "C7eff" : -0.306, + "C9eff" : 4.211, + "C10eff" : -4.103, + +# "C7eff": 0.0, +# "C9eff": 0.0, +# "C10eff": 0.0, + + ###Other constants + + "GF" : 1.1663787e-5, + "alpha_ew" : 1.0/137.0, + "Vts" : 0.0394, + "Vtb" : 1.019, + "number_of_decays": 5404696, + + #Formfactor z coefficients + + #"b0" : [0.285, 0.19, -0.17], + #"bplus" : [0.437, -1.41, -2.5], + #"bT" : [0.440, -1.47, -2.7] + + "b0" : [0.292, 0.281, 0.150], + "bplus" : [0.466, -0.885, -0.213], + "bT" : [0.460, -1.089, -1.114], + + "NR_BR": 4.37e-7, + "NR_auc": 0.00133, + + #Resonances format(mass, width, phase, scale) + + # pre scaling + +# "rho": (775.26, 149.0, -0.35, 1.0), + +# "omega": (782.7, 8.5, 0.26, 1.0), + +# "phi": (1019.46, 4.25, 0.5, 1.0), + +# "jpsi": (3096.0, 0.09, -1.5, 2e-2), +# "jpsi_auc": 0.2126825758464027, + +# "psi2s": (3686.0, 0.3, -1.5, 3.14e-3), +# "psi2s_auc": 2.802257483178487e-10, + +# "p3770": (3773.0, 27.2, -2.13, 1.0e-3), + +# "p4040": (4039.0, 80.0, -2.52, 2.0), + +# "p4160": (4191.0, 70.0, -1.9, 2.2), + +# "p4415": (4421.0, 62.0, -2.52, 1.0), + + + # after scaling (Phase combination --) + + # + # "rho": (743.2, 149.0, -0.22, 1.05), + # + # "omega": (782.7, 8.5, 0.38, 6.8), + # + # "phi": (1013.5, 4.25, 0.62, 19.2), + # + # "jpsi": (3096.1, 0.09, 1.63, 9897.0), + # "jpsi_auc": 0.2126825758464027, + # "jpsi_phase_unc": 0.05, + # + # "psi2s": (3686.0, 0.3, 1.8, 1396.0), + # "psi2s_auc": 0.0151332263, + # "psi2s_phase_unc": 0.1, + # + # "p3770": (3773.0, 27.2, -2.95, 2.5), + # + # "p4040": (4039.0, 80.0, -2.75, 1.01), + # + # "p4160": (4191.0, 70.0, -2.28, 2.2), + # + # "p4415": (4421.0, 62.0, -2.31, 1.24), + + # Phase combination of paper ++ + +# "rho": (743.2, 149.0, -0.35, 1.05), + +# "omega": (782.7, 8.5, 0.26, 6.8), + +# "phi": (1013.5, 4.25, 0.47, 19.2), + +# "jpsi": (3096.1, 0.09, -1.66, 9897.0), +# "jpsi_auc": 0.2126825758464027, +# "jpsi_phase_unc": 0.05, + +# "psi2s": (3686.0, 0.3, -1.93, 1396.0), +# "psi2s_auc": 0.0151332263, +# "psi2s_phase_unc": 0.1, + +# "p3770": (3773.0, 27.2, -2.13, 2.5), + +# "p4040": (4039.0, 80.0, -2.52, 1.01), + +# "p4160": (4191.0, 70.0, -1.90, 2.2), + +# "p4415": (4421.0, 62.0, -2.52, 1.24), + + # Phase combination of paper +- + +# "rho": (743.2, 149.0, -0.26, 1.05), + +# "omega": (782.7, 8.5, 0.35, 6.8), + +# "phi": (1013.5, 4.25, 0.58, 19.2), + +# "jpsi": (3096.1, 0.09, 1.47, 9897.0), +# "jpsi_auc": 0.2126825758464027, +# "jpsi_phase_unc": 0.05, + +# "psi2s": (3686.0, 0.3, -2.21, 1396.0), +# "psi2s_auc": 0.0151332263, +# "psi2s_phase_unc": 0.1, + +# "p3770": (3773.0, 27.2, -2.140, 2.5), + +# "p4040": (4039.0, 80.0, -2.64, 1.01), + +# "p4160": (4191.0, 70.0, -2.11, 2.2), + +# "p4415": (4421.0, 62.0, -2.42, 1.24), + + # Phase combination of paper -+ + + "rho": (743.2, 149.0, -0.30, 1.05), + + "omega": (782.7, 8.5, 0.30, 6.8), + + "phi": (1013.5, 4.25, 0.51, 19.2), + + "jpsi": (3096.1, 0.09, -1.5, 9897.0), + "jpsi_auc": 0.2126825758464027, + "jpsi_phase_unc": 0.05, + + "psi2s": (3686.0, 0.3, 2.08, 1396.0), + "psi2s_auc": 0.0151332263, + "psi2s_phase_unc": 0.1, + + "p3770": (3773.0, 27.2, -2.89, 2.5), + + "p4040": (4039.0, 80.0, -2.69, 1.01), + + "p4160": (4191.0, 70.0, -2.13, 2.2), + + "p4415": (4421.0, 62.0, -2.43, 1.24), + + + # zeroing resonances + +# "rho": (775.26, 149.0, -0.35, 0.0), +# "omega": (782.7, 8.5, 0.26, 0.0), +# "phi": (1019.46, 4.25, 0.5, 0.0), +# "jpsi": (3096.0, 0.09, -1.5, 0.0), +# "psi2s": (3686.0, 0.3, -1.5, 0.0), +# "p3770": (3773.0, 27.2, -2.13, 0.0), +# "p4040": (4039.0, 80.0, -2.52, 0.0), +# "p4160": (4147.0, 22.0, -1.9, 0.0), +# "p4415": (4421.0, 62.0, -2.52, 0.0), + + # 2P contributions format(mass, amp, phase) + +# "D_bar": ( + + #general + + "rho_BR": 1.7e-10, + "omega_BR": 4.9e-10, + "phi_BR": 2.5e-9, + "jpsi_BR": 6.02e-5, + "psi2s_BR": 4.97e-6, + "p3770_BR": 1.38e-9, + "p4040_BR": 4.2e-10, + "p4160_BR": 2.6e-9, + "p4415_BR": 6.1e-10, + +# Estimates + "Dbar_scale": 1.46, #with phase = pi + + "DDstar_scale": 2.41, #with phase = pi + + } diff --git a/data/CLs/finished/f1d1/-+/D-True/2288051/raremodel-nb.py b/data/CLs/finished/f1d1/-+/D-True/2288051/raremodel-nb.py new file mode 100644 index 0000000..c326c9c --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288051/raremodel-nb.py @@ -0,0 +1,2152 @@ +#!/usr/bin/env python +# coding: utf-8 + +# # Import + +# In[ ]: + + +import os + +# os.environ["CUDA_VISIBLE_DEVICES"] = "-1" +import random +import numpy as np +from pdg_const1 import pdg +import matplotlib +import matplotlib.pyplot as plt +import pickle as pkl +import sys +import time +from helperfunctions import display_time, prepare_plot +import cmath as c +import scipy.integrate as integrate +from scipy.optimize import fminbound +from array import array as arr +import collections +from itertools import compress +import tensorflow as tf +import zfit +from zfit import ztf +# from IPython.display import clear_output +import os +import tensorflow_probability as tfp +tfd = tfp.distributions + + +# In[ ]: + + +# chunksize = 10000 +# zfit.run.chunking.active = True +# zfit.run.chunking.max_n_points = chunksize + + +# # Build model and graphs +# ## Create graphs + +# In[ ]: + + + + + +# In[ ]: + + +def formfactor(q2, subscript, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2): #returns real value + #check if subscript is viable + + if subscript != "0" and subscript != "+" and subscript != "T": + raise ValueError('Wrong subscript entered, choose either 0, + or T') + + #get constants + + mK = ztf.constant(pdg['Ks_M']) + mbstar0 = ztf.constant(pdg["mbstar0"]) + mbstar = ztf.constant(pdg["mbstar"]) + + + mmu = ztf.constant(pdg['muon_M']) + mb = ztf.constant(pdg['bquark_M']) + ms = ztf.constant(pdg['squark_M']) + mB = ztf.constant(pdg['Bplus_M']) + + #N comes from derivation in paper + + N = 3 + + #some helperfunctions + + tpos = (mB - mK)**2 + tzero = (mB + mK)*(ztf.sqrt(mB)-ztf.sqrt(mK))**2 + + z_oben = ztf.sqrt(tpos - q2) - ztf.sqrt(tpos - tzero) + z_unten = ztf.sqrt(tpos - q2) + ztf.sqrt(tpos - tzero) + z = tf.divide(z_oben, z_unten) + + #calculate f0 + + if subscript == "0": + prefactor = 1/(1 - q2/(mbstar0**2)) + _sum = 0 + b0 = [b0_0, b0_1, b0_2] + + for i in range(N): + _sum += b0[i]*(tf.pow(z,i)) + + return ztf.to_complex(prefactor * _sum) + + #calculate f+ or fT + + else: + prefactor = 1/(1 - q2/(mbstar**2)) + _sum = 0 + + if subscript == "T": + bT = [bT_0, bT_1, bT_2] + for i in range(N): + _sum += bT[i] * (tf.pow(z, i) - ((-1)**(i-N)) * (i/N) * tf.pow(z, N)) + else: + bplus = [bplus_0, bplus_1, bplus_2] + for i in range(N): + _sum += bplus[i] * (tf.pow(z, i) - ((-1)**(i-N)) * (i/N) * tf.pow(z, N)) + + return ztf.to_complex(prefactor * _sum) + +def resonance(q, _mass, width, phase, scale): + + q2 = tf.pow(q, 2) + + mmu = ztf.constant(pdg['muon_M']) + + p = 0.5 * ztf.sqrt(q2 - 4*(mmu**2)) + + p0 = 0.5 * ztf.sqrt(_mass**2 - 4*mmu**2) + + gamma_j = tf.divide(p, q) * _mass * width / p0 + + #Calculate the resonance + + _top = tf.complex(_mass * width, ztf.constant(0.0)) + + _bottom = tf.complex(_mass**2 - q2, -_mass*gamma_j) + + com = _top/_bottom + + #Rotate by the phase + + r = ztf.to_complex(scale*tf.abs(com)) + + _phase = tf.angle(com) + + _phase += phase + + com = r * tf.exp(tf.complex(ztf.constant(0.0), _phase)) + + return com + + +def axiv_nonres(q, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2): + + GF = ztf.constant(pdg['GF']) + alpha_ew = ztf.constant(pdg['alpha_ew']) + Vtb = ztf.constant(pdg['Vtb']) + Vts = ztf.constant(pdg['Vts']) + C10eff = ztf.constant(pdg['C10eff']) + + mmu = ztf.constant(pdg['muon_M']) + mb = ztf.constant(pdg['bquark_M']) + ms = ztf.constant(pdg['squark_M']) + mK = ztf.constant(pdg['Ks_M']) + mB = ztf.constant(pdg['Bplus_M']) + + q2 = tf.pow(q, 2) + + #Some helperfunctions + + beta = 1. - 4. * mmu**2. / q2 + + kabs = ztf.sqrt(mB**2. + tf.pow(q2, 2)/mB**2. + mK**4./mB**2. - 2. * (mB**2. * mK**2. + mK**2. * q2 + mB**2. * q2) / mB**2.) + + #prefactor in front of whole bracket + + prefactor1 = GF**2. *alpha_ew**2. * (tf.abs(Vtb*Vts))**2. * kabs * beta / (128. * np.pi**5.) + + #left term in bracket + + bracket_left = 2./3. * tf.pow(kabs,2) * tf.pow(beta,2) * tf.pow(tf.abs(ztf.to_complex(C10eff)*formfactor(q2, "+", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2)),2) + + #middle term in bracket + + _top = 4. * mmu**2. * (mB**2. - mK**2.) * (mB**2. - mK**2.) + + _under = q2 * mB**2. + + bracket_middle = _top/_under *tf.pow(tf.abs(ztf.to_complex(C10eff) * formfactor(q2, "0", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2)), 2) + + #Note sqrt(q2) comes from derivation as we use q2 and plot q + + return prefactor1 * (bracket_left + bracket_middle) * 2 * q + +def vec(q, funcs, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2): + + q2 = tf.pow(q, 2) + + GF = ztf.constant(pdg['GF']) + alpha_ew = ztf.constant(pdg['alpha_ew']) + Vtb = ztf.constant(pdg['Vtb']) + Vts = ztf.constant(pdg['Vts']) + C7eff = ztf.constant(pdg['C7eff']) + + mmu = ztf.constant(pdg['muon_M']) + mb = ztf.constant(pdg['bquark_M']) + ms = ztf.constant(pdg['squark_M']) + mK = ztf.constant(pdg['Ks_M']) + mB = ztf.constant(pdg['Bplus_M']) + + #Some helperfunctions + + beta = 1. - 4. * mmu**2. / q2 + + kabs = ztf.sqrt(mB**2. + tf.pow(q2, 2)/mB**2. + mK**4./mB**2. - 2 * (mB**2 * mK**2 + mK**2 * q2 + mB**2 * q2) / mB**2) + + #prefactor in front of whole bracket + + prefactor1 = GF**2. *alpha_ew**2. * (tf.abs(Vtb*Vts))**2 * kabs * beta / (128. * np.pi**5.) + + #right term in bracket + + prefactor2 = tf.pow(kabs,2) * (1. - 1./3. * beta) + + abs_bracket = tf.pow(tf.abs(c9eff(q, funcs) * formfactor(q2, "+", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + ztf.to_complex(2.0 * C7eff * (mb + ms)/(mB + mK)) * formfactor(q2, "T", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2)),2) + + bracket_right = prefactor2 * abs_bracket + + #Note sqrt(q2) comes from derivation as we use q2 and plot q + + return prefactor1 * bracket_right * 2 * q + +def c9eff(q, funcs): + + C9eff_nr = ztf.to_complex(ztf.constant(pdg['C9eff'])) + + c9 = C9eff_nr + funcs + + return c9 + + +# In[ ]: + + +def G(y): + + def inner_rect_bracket(q): + return tf.log(ztf.to_complex((1+tf.sqrt(q))/(1-tf.sqrt(q)))-tf.complex(ztf.constant(0), -1*ztf.constant(np.pi))) + + def inner_right(q): + return ztf.to_complex(2 * tf.atan(1/tf.sqrt(tf.math.real(-q)))) + + big_bracket = tf.where(tf.math.real(y) > ztf.constant(0.0), inner_rect_bracket(y), inner_right(y)) + + return ztf.to_complex(tf.sqrt(tf.abs(y))) * big_bracket + +def h_S(m, q): + + return ztf.to_complex(2) - G(ztf.to_complex(1) - ztf.to_complex(4*tf.pow(m, 2)) / ztf.to_complex(tf.pow(q, 2))) + +def h_P(m, q): + + return ztf.to_complex(2/3) + (ztf.to_complex(1) - ztf.to_complex(4*tf.pow(m, 2)) / ztf.to_complex(tf.pow(q, 2))) * h_S(m,q) + +def two_p_ccbar(mD, m_D_bar, m_D_star, q): + + + #Load constants + nu_D_bar = ztf.to_complex(pdg["nu_D_bar"]) + nu_D = ztf.to_complex(pdg["nu_D"]) + nu_D_star = ztf.to_complex(pdg["nu_D_star"]) + + phase_D_bar = ztf.to_complex(pdg["phase_D_bar"]) + phase_D = ztf.to_complex(pdg["phase_D"]) + phase_D_star = ztf.to_complex(pdg["phase_D_star"]) + + #Calculation + left_part = nu_D_bar * tf.exp(tf.complex(ztf.constant(0.0), phase_D_bar)) * h_S(m_D_bar, q) + + right_part_D = nu_D * tf.exp(tf.complex(ztf.constant(0.0), phase_D)) * h_P(m_D, q) + + right_part_D_star = nu_D_star * tf.exp(tf.complex(ztf.constant(0.0), phase_D_star)) * h_P(m_D_star, q) + + return left_part + right_part_D + right_part_D_star + + +# ## Build pdf + +# In[ ]: + + +class total_pdf_cut(zfit.pdf.ZPDF): + _N_OBS = 1 # dimension, can be omitted + _PARAMS = ['b0_0', 'b0_1', 'b0_2', + 'bplus_0', 'bplus_1', 'bplus_2', + 'bT_0', 'bT_1', 'bT_2', + 'rho_mass', 'rho_scale', 'rho_phase', 'rho_width', + 'jpsi_mass', 'jpsi_scale', 'jpsi_phase', 'jpsi_width', + 'psi2s_mass', 'psi2s_scale', 'psi2s_phase', 'psi2s_width', + 'p3770_mass', 'p3770_scale', 'p3770_phase', 'p3770_width', + 'p4040_mass', 'p4040_scale', 'p4040_phase', 'p4040_width', + 'p4160_mass', 'p4160_scale', 'p4160_phase', 'p4160_width', + 'p4415_mass', 'p4415_scale', 'p4415_phase', 'p4415_width', + 'omega_mass', 'omega_scale', 'omega_phase', 'omega_width', + 'phi_mass', 'phi_scale', 'phi_phase', 'phi_width', + 'Dbar_mass', 'Dbar_scale', 'Dbar_phase', + 'Dstar_mass', 'DDstar_scale', 'DDstar_phase', 'D_mass', + 'tau_mass', 'C_tt'] +# the name of the parameters + + def _unnormalized_pdf(self, x): + + x = x.unstack_x() + + b0 = [self.params['b0_0'], self.params['b0_1'], self.params['b0_2']] + bplus = [self.params['bplus_0'], self.params['bplus_1'], self.params['bplus_2']] + bT = [self.params['bT_0'], self.params['bT_1'], self.params['bT_2']] + + def rho_res(q): + return resonance(q, _mass = self.params['rho_mass'], scale = self.params['rho_scale'], + phase = self.params['rho_phase'], width = self.params['rho_width']) + + def omega_res(q): + return resonance(q, _mass = self.params['omega_mass'], scale = self.params['omega_scale'], + phase = self.params['omega_phase'], width = self.params['omega_width']) + + def phi_res(q): + return resonance(q, _mass = self.params['phi_mass'], scale = self.params['phi_scale'], + phase = self.params['phi_phase'], width = self.params['phi_width']) + + def jpsi_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['jpsi_mass'], 2)) * resonance(q, _mass = self.params['jpsi_mass'], + scale = self.params['jpsi_scale'], + phase = self.params['jpsi_phase'], + width = self.params['jpsi_width']) + def psi2s_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['psi2s_mass'], 2)) * resonance(q, _mass = self.params['psi2s_mass'], + scale = self.params['psi2s_scale'], + phase = self.params['psi2s_phase'], + width = self.params['psi2s_width']) + def p3770_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p3770_mass'], 2)) * resonance(q, _mass = self.params['p3770_mass'], + scale = self.params['p3770_scale'], + phase = self.params['p3770_phase'], + width = self.params['p3770_width']) + + def p4040_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4040_mass'], 2)) * resonance(q, _mass = self.params['p4040_mass'], + scale = self.params['p4040_scale'], + phase = self.params['p4040_phase'], + width = self.params['p4040_width']) + + def p4160_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4160_mass'], 2)) * resonance(q, _mass = self.params['p4160_mass'], + scale = self.params['p4160_scale'], + phase = self.params['p4160_phase'], + width = self.params['p4160_width']) + + def p4415_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4415_mass'], 2)) * resonance(q, _mass = self.params['p4415_mass'], + scale = self.params['p4415_scale'], + phase = self.params['p4415_phase'], + width = self.params['p4415_width']) + + def P2_D(q): + Dbar_contrib = ztf.to_complex(self.params['Dbar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['Dbar_phase']))*ztf.to_complex(h_S(self.params['Dbar_mass'], q)) + DDstar_contrib = ztf.to_complex(self.params['DDstar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['DDstar_phase']))*(ztf.to_complex(h_P(self.params['Dstar_mass'], q)) + ztf.to_complex(h_P(self.params['D_mass'], q))) + return Dbar_contrib + DDstar_contrib + + def ttau_cusp(q): + return ztf.to_complex(self.params['C_tt'])*(ztf.to_complex((h_S(self.params['tau_mass'], q))) - ztf.to_complex(h_P(self.params['tau_mass'], q))) + + + funcs = rho_res(x) + omega_res(x) + phi_res(x) + jpsi_res(x) + psi2s_res(x) + p3770_res(x) + p4040_res(x)+ p4160_res(x) + p4415_res(x) + P2_D(x) + ttau_cusp(x) + + vec_f = vec(x, funcs, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + axiv_nr = axiv_nonres(x, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + tot = vec_f + axiv_nr + + #Cut out jpsi and psi2s + + tot = tf.where(tf.math.logical_or(x < ztf.constant(jpsi_mass-60.), x > ztf.constant(jpsi_mass+70.)), tot, 0.0*tot) + + tot = tf.where(tf.math.logical_or(x < ztf.constant(psi2s_mass-50.), x > ztf.constant(psi2s_mass+50.)), tot, 0.0*tot) + + return tot + +class total_pdf_full(zfit.pdf.ZPDF): + _N_OBS = 1 # dimension, can be omitted + _PARAMS = ['b0_0', 'b0_1', 'b0_2', + 'bplus_0', 'bplus_1', 'bplus_2', + 'bT_0', 'bT_1', 'bT_2', + 'rho_mass', 'rho_scale', 'rho_phase', 'rho_width', + 'jpsi_mass', 'jpsi_scale', 'jpsi_phase', 'jpsi_width', + 'psi2s_mass', 'psi2s_scale', 'psi2s_phase', 'psi2s_width', + 'p3770_mass', 'p3770_scale', 'p3770_phase', 'p3770_width', + 'p4040_mass', 'p4040_scale', 'p4040_phase', 'p4040_width', + 'p4160_mass', 'p4160_scale', 'p4160_phase', 'p4160_width', + 'p4415_mass', 'p4415_scale', 'p4415_phase', 'p4415_width', + 'omega_mass', 'omega_scale', 'omega_phase', 'omega_width', + 'phi_mass', 'phi_scale', 'phi_phase', 'phi_width', + 'Dbar_mass', 'Dbar_scale', 'Dbar_phase', + 'Dstar_mass', 'DDstar_scale', 'DDstar_phase', 'D_mass', + 'tau_mass', 'C_tt'] +# the name of the parameters + + def _unnormalized_pdf(self, x): + + x = x.unstack_x() + + b0 = [self.params['b0_0'], self.params['b0_1'], self.params['b0_2']] + bplus = [self.params['bplus_0'], self.params['bplus_1'], self.params['bplus_2']] + bT = [self.params['bT_0'], self.params['bT_1'], self.params['bT_2']] + + def rho_res(q): + return resonance(q, _mass = self.params['rho_mass'], scale = self.params['rho_scale'], + phase = self.params['rho_phase'], width = self.params['rho_width']) + + def omega_res(q): + return resonance(q, _mass = self.params['omega_mass'], scale = self.params['omega_scale'], + phase = self.params['omega_phase'], width = self.params['omega_width']) + + def phi_res(q): + return resonance(q, _mass = self.params['phi_mass'], scale = self.params['phi_scale'], + phase = self.params['phi_phase'], width = self.params['phi_width']) + + def jpsi_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['jpsi_mass'], 2)) * resonance(q, _mass = self.params['jpsi_mass'], + scale = self.params['jpsi_scale'], + phase = self.params['jpsi_phase'], + width = self.params['jpsi_width']) + def psi2s_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['psi2s_mass'], 2)) * resonance(q, _mass = self.params['psi2s_mass'], + scale = self.params['psi2s_scale'], + phase = self.params['psi2s_phase'], + width = self.params['psi2s_width']) + def p3770_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p3770_mass'], 2)) * resonance(q, _mass = self.params['p3770_mass'], + scale = self.params['p3770_scale'], + phase = self.params['p3770_phase'], + width = self.params['p3770_width']) + + def p4040_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4040_mass'], 2)) * resonance(q, _mass = self.params['p4040_mass'], + scale = self.params['p4040_scale'], + phase = self.params['p4040_phase'], + width = self.params['p4040_width']) + + def p4160_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4160_mass'], 2)) * resonance(q, _mass = self.params['p4160_mass'], + scale = self.params['p4160_scale'], + phase = self.params['p4160_phase'], + width = self.params['p4160_width']) + + def p4415_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4415_mass'], 2)) * resonance(q, _mass = self.params['p4415_mass'], + scale = self.params['p4415_scale'], + phase = self.params['p4415_phase'], + width = self.params['p4415_width']) + + def P2_D(q): + Dbar_contrib = ztf.to_complex(self.params['Dbar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['Dbar_phase']))*ztf.to_complex(h_S(self.params['Dbar_mass'], q)) + DDstar_contrib = ztf.to_complex(self.params['DDstar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['DDstar_phase']))*(ztf.to_complex(h_P(self.params['Dstar_mass'], q)) + ztf.to_complex(h_P(self.params['D_mass'], q))) + return Dbar_contrib + DDstar_contrib + + def ttau_cusp(q): + return ztf.to_complex(self.params['C_tt'])*(ztf.to_complex((h_S(self.params['tau_mass'], q))) - ztf.to_complex(h_P(self.params['tau_mass'], q))) + + + funcs = rho_res(x) + omega_res(x) + phi_res(x) + jpsi_res(x) + psi2s_res(x) + p3770_res(x) + p4040_res(x)+ p4160_res(x) + p4415_res(x) + P2_D(x) + ttau_cusp(x) + + vec_f = vec(x, funcs, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + axiv_nr = axiv_nonres(x, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + tot = vec_f + axiv_nr + + #Cut out jpsi and psi2s + +# tot = tf.where(tf.math.logical_or(x < ztf.constant(jpsi_mass-60.), x > ztf.constant(jpsi_mass+70.)), tot, 0.0*tot) + +# tot = tf.where(tf.math.logical_or(x < ztf.constant(psi2s_mass-50.), x > ztf.constant(psi2s_mass+50.)), tot, 0.0*tot) + + return tot + + +# ## Setup parameters + +# In[ ]: + + +# formfactors + +b0_0 = zfit.Parameter("b0_0", ztf.constant(0.292), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +b0_1 = zfit.Parameter("b0_1", ztf.constant(0.281), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +b0_2 = zfit.Parameter("b0_2", ztf.constant(0.150), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) + +bplus_0 = zfit.Parameter("bplus_0", ztf.constant(0.466), lower_limit = -2.0, upper_limit= 2.0) +bplus_1 = zfit.Parameter("bplus_1", ztf.constant(-0.885), lower_limit = -2.0, upper_limit= 2.0) +bplus_2 = zfit.Parameter("bplus_2", ztf.constant(-0.213), lower_limit = -2.0, upper_limit= 2.0) + +bT_0 = zfit.Parameter("bT_0", ztf.constant(0.460), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +bT_1 = zfit.Parameter("bT_1", ztf.constant(-1.089), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +bT_2 = zfit.Parameter("bT_2", ztf.constant(-1.114), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) + + +#rho + +rho_mass, rho_width, rho_phase, rho_scale = pdg["rho"] + +rho_m = zfit.Parameter("rho_m", ztf.constant(rho_mass), floating = False) #lower_limit = rho_mass - rho_width, upper_limit = rho_mass + rho_width) +rho_w = zfit.Parameter("rho_w", ztf.constant(rho_width), floating = False) +rho_p = zfit.Parameter("rho_p", ztf.constant(rho_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +rho_s = zfit.Parameter("rho_s", ztf.constant(rho_scale), lower_limit=rho_scale-np.sqrt(rho_scale), upper_limit=rho_scale+np.sqrt(rho_scale)) + +#omega + +omega_mass, omega_width, omega_phase, omega_scale = pdg["omega"] + +omega_m = zfit.Parameter("omega_m", ztf.constant(omega_mass), floating = False) +omega_w = zfit.Parameter("omega_w", ztf.constant(omega_width), floating = False) +omega_p = zfit.Parameter("omega_p", ztf.constant(omega_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +omega_s = zfit.Parameter("omega_s", ztf.constant(omega_scale), lower_limit=omega_scale-np.sqrt(omega_scale), upper_limit=omega_scale+np.sqrt(omega_scale)) + + +#phi + +phi_mass, phi_width, phi_phase, phi_scale = pdg["phi"] + +phi_m = zfit.Parameter("phi_m", ztf.constant(phi_mass), floating = False) +phi_w = zfit.Parameter("phi_w", ztf.constant(phi_width), floating = False) +phi_p = zfit.Parameter("phi_p", ztf.constant(phi_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +phi_s = zfit.Parameter("phi_s", ztf.constant(phi_scale), lower_limit=phi_scale-np.sqrt(phi_scale), upper_limit=phi_scale+np.sqrt(phi_scale)) + +#jpsi + +jpsi_mass, jpsi_width, jpsi_phase, jpsi_scale = pdg["jpsi"] + +jpsi_m = zfit.Parameter("jpsi_m", ztf.constant(jpsi_mass), floating = False) +jpsi_w = zfit.Parameter("jpsi_w", ztf.constant(jpsi_width), floating = False) +jpsi_p = zfit.Parameter("jpsi_p", ztf.constant(jpsi_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +jpsi_s = zfit.Parameter("jpsi_s", ztf.constant(jpsi_scale), floating = False) #, lower_limit=jpsi_scale-np.sqrt(jpsi_scale), upper_limit=jpsi_scale+np.sqrt(jpsi_scale)) + +#psi2s + +psi2s_mass, psi2s_width, psi2s_phase, psi2s_scale = pdg["psi2s"] + +psi2s_m = zfit.Parameter("psi2s_m", ztf.constant(psi2s_mass), floating = False) +psi2s_w = zfit.Parameter("psi2s_w", ztf.constant(psi2s_width), floating = False) +psi2s_p = zfit.Parameter("psi2s_p", ztf.constant(psi2s_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +psi2s_s = zfit.Parameter("psi2s_s", ztf.constant(psi2s_scale), floating = False) #, lower_limit=psi2s_scale-np.sqrt(psi2s_scale), upper_limit=psi2s_scale+np.sqrt(psi2s_scale)) + +#psi(3770) + +p3770_mass, p3770_width, p3770_phase, p3770_scale = pdg["p3770"] + +p3770_m = zfit.Parameter("p3770_m", ztf.constant(p3770_mass), floating = False) +p3770_w = zfit.Parameter("p3770_w", ztf.constant(p3770_width), floating = False) +p3770_p = zfit.Parameter("p3770_p", ztf.constant(p3770_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p3770_s = zfit.Parameter("p3770_s", ztf.constant(p3770_scale), lower_limit=p3770_scale-np.sqrt(p3770_scale), upper_limit=p3770_scale+np.sqrt(p3770_scale)) + +#psi(4040) + +p4040_mass, p4040_width, p4040_phase, p4040_scale = pdg["p4040"] + +p4040_m = zfit.Parameter("p4040_m", ztf.constant(p4040_mass), floating = False) +p4040_w = zfit.Parameter("p4040_w", ztf.constant(p4040_width), floating = False) +p4040_p = zfit.Parameter("p4040_p", ztf.constant(p4040_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p4040_s = zfit.Parameter("p4040_s", ztf.constant(p4040_scale), lower_limit=p4040_scale-np.sqrt(p4040_scale), upper_limit=p4040_scale+np.sqrt(p4040_scale)) + +#psi(4160) + +p4160_mass, p4160_width, p4160_phase, p4160_scale = pdg["p4160"] + +p4160_m = zfit.Parameter("p4160_m", ztf.constant(p4160_mass), floating = False) +p4160_w = zfit.Parameter("p4160_w", ztf.constant(p4160_width), floating = False) +p4160_p = zfit.Parameter("p4160_p", ztf.constant(p4160_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p4160_s = zfit.Parameter("p4160_s", ztf.constant(p4160_scale), lower_limit=p4160_scale-np.sqrt(p4160_scale), upper_limit=p4160_scale+np.sqrt(p4160_scale)) + +#psi(4415) + +p4415_mass, p4415_width, p4415_phase, p4415_scale = pdg["p4415"] + +p4415_m = zfit.Parameter("p4415_m", ztf.constant(p4415_mass), floating = False) +p4415_w = zfit.Parameter("p4415_w", ztf.constant(p4415_width), floating = False) +p4415_p = zfit.Parameter("p4415_p", ztf.constant(p4415_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p4415_s = zfit.Parameter("p4415_s", ztf.constant(p4415_scale), lower_limit=p4415_scale-np.sqrt(p4415_scale), upper_limit=p4415_scale+np.sqrt(p4415_scale)) + + +# ## Dynamic generation of 2 particle contribution + +# In[ ]: + + +m_c = 1300 + +Dbar_phase = 0.0 +DDstar_phase = 0.0 +Dstar_mass = pdg['Dst_M'] +Dbar_mass = pdg['D0_M'] +D_mass = pdg['D0_M'] + +Dbar_s = zfit.Parameter("Dbar_s", ztf.constant(0.0), lower_limit=-0.3, upper_limit=0.3) +Dbar_m = zfit.Parameter("Dbar_m", ztf.constant(Dbar_mass), floating = False) +Dbar_p = zfit.Parameter("Dbar_p", ztf.constant(Dbar_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi)#, floating = False) +DDstar_s = zfit.Parameter("DDstar_s", ztf.constant(0.0), lower_limit=-0.3, upper_limit=0.3)#, floating = False) +Dstar_m = zfit.Parameter("Dstar_m", ztf.constant(Dstar_mass), floating = False) +D_m = zfit.Parameter("D_m", ztf.constant(D_mass), floating = False) +DDstar_p = zfit.Parameter("DDstar_p", ztf.constant(DDstar_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi)#, floating = False) + + +# ## Tau parameters + +# In[ ]: + + +tau_m = zfit.Parameter("tau_m", ztf.constant(pdg['tau_M']), floating = False) +Ctt = zfit.Parameter("Ctt", ztf.constant(0.0), lower_limit=-2.5, upper_limit=2.5) + + +# ## Load data + +# In[ ]: + + +x_min = 2*pdg['muon_M'] +x_max = (pdg["Bplus_M"]-pdg["Ks_M"]-0.1) + +# # Full spectrum + +obs_toy = zfit.Space('q', limits = (x_min, x_max)) + +# Jpsi and Psi2s cut out + +obs1 = zfit.Space('q', limits = (x_min, jpsi_mass - 60.)) +obs2 = zfit.Space('q', limits = (jpsi_mass + 70., psi2s_mass - 50.)) +obs3 = zfit.Space('q', limits = (psi2s_mass + 50., x_max)) + +obs_fit = obs1 + obs2 + obs3 + +# with open(r"./data/slim_points/slim_points_toy_0_range({0}-{1}).pkl".format(int(x_min), int(x_max)), "rb") as input_file: +# part_set = pkl.load(input_file) + +# x_part = part_set['x_part'] + +# x_part = x_part.astype('float64') + +# data = zfit.data.Data.from_numpy(array=x_part, obs=obs) + + +# ## Setup pdf + +# In[ ]: + + +total_f = total_pdf_cut(obs=obs_toy, jpsi_mass = jpsi_m, jpsi_scale = jpsi_s, jpsi_phase = jpsi_p, jpsi_width = jpsi_w, + psi2s_mass = psi2s_m, psi2s_scale = psi2s_s, psi2s_phase = psi2s_p, psi2s_width = psi2s_w, + p3770_mass = p3770_m, p3770_scale = p3770_s, p3770_phase = p3770_p, p3770_width = p3770_w, + p4040_mass = p4040_m, p4040_scale = p4040_s, p4040_phase = p4040_p, p4040_width = p4040_w, + p4160_mass = p4160_m, p4160_scale = p4160_s, p4160_phase = p4160_p, p4160_width = p4160_w, + p4415_mass = p4415_m, p4415_scale = p4415_s, p4415_phase = p4415_p, p4415_width = p4415_w, + rho_mass = rho_m, rho_scale = rho_s, rho_phase = rho_p, rho_width = rho_w, + omega_mass = omega_m, omega_scale = omega_s, omega_phase = omega_p, omega_width = omega_w, + phi_mass = phi_m, phi_scale = phi_s, phi_phase = phi_p, phi_width = phi_w, + Dstar_mass = Dstar_m, DDstar_scale = DDstar_s, DDstar_phase = DDstar_p, D_mass = D_m, + Dbar_mass = Dbar_m, Dbar_scale = Dbar_s, Dbar_phase = Dbar_p, + tau_mass = tau_m, C_tt = Ctt, b0_0 = b0_0, b0_1 = b0_1, b0_2 = b0_2, + bplus_0 = bplus_0, bplus_1 = bplus_1, bplus_2 = bplus_2, + bT_0 = bT_0, bT_1 = bT_1, bT_2 = bT_2) + +total_f_fit = total_pdf_full(obs=obs_fit, jpsi_mass = jpsi_m, jpsi_scale = jpsi_s, jpsi_phase = jpsi_p, jpsi_width = jpsi_w, + psi2s_mass = psi2s_m, psi2s_scale = psi2s_s, psi2s_phase = psi2s_p, psi2s_width = psi2s_w, + p3770_mass = p3770_m, p3770_scale = p3770_s, p3770_phase = p3770_p, p3770_width = p3770_w, + p4040_mass = p4040_m, p4040_scale = p4040_s, p4040_phase = p4040_p, p4040_width = p4040_w, + p4160_mass = p4160_m, p4160_scale = p4160_s, p4160_phase = p4160_p, p4160_width = p4160_w, + p4415_mass = p4415_m, p4415_scale = p4415_s, p4415_phase = p4415_p, p4415_width = p4415_w, + rho_mass = rho_m, rho_scale = rho_s, rho_phase = rho_p, rho_width = rho_w, + omega_mass = omega_m, omega_scale = omega_s, omega_phase = omega_p, omega_width = omega_w, + phi_mass = phi_m, phi_scale = phi_s, phi_phase = phi_p, phi_width = phi_w, + Dstar_mass = Dstar_m, DDstar_scale = DDstar_s, DDstar_phase = DDstar_p, D_mass = D_m, + Dbar_mass = Dbar_m, Dbar_scale = Dbar_s, Dbar_phase = Dbar_p, + tau_mass = tau_m, C_tt = Ctt, b0_0 = b0_0, b0_1 = b0_1, b0_2 = b0_2, + bplus_0 = bplus_0, bplus_1 = bplus_1, bplus_2 = bplus_2, + bT_0 = bT_0, bT_1 = bT_1, bT_2 = bT_2) + +# print(total_pdf.obs) + +# print(calcs_test) + +# for param in total_f.get_dependents(): +# print(zfit.run(param)) + + +# In[ ]: + + +# total_f_fit.normalization(obs_fit) + + +# ## Test if graphs actually work and compute values + +# In[ ]: + + +# def total_test_tf(xq): + +# def jpsi_res(q): +# return resonance(q, jpsi_m, jpsi_s, jpsi_p, jpsi_w) + +# def psi2s_res(q): +# return resonance(q, psi2s_m, psi2s_s, psi2s_p, psi2s_w) + +# def cusp(q): +# return bifur_gauss(q, cusp_m, sig_L, sig_R, cusp_s) + +# funcs = jpsi_res(xq) + psi2s_res(xq) + cusp(xq) + +# vec_f = vec(xq, funcs) + +# axiv_nr = axiv_nonres(xq) + +# tot = vec_f + axiv_nr + +# return tot + +# def jpsi_res(q): +# return resonance(q, jpsi_m, jpsi_s, jpsi_p, jpsi_w) + +# calcs = zfit.run(total_test_tf(x_part)) + + + +test_q = np.linspace(x_min, x_max, int(2e6)) + +probs = total_f_fit.pdf(test_q, norm_range=False) + +calcs_test = zfit.run(probs) + +Ctt.set_value(0.5) + +calcs_test1 = zfit.run(probs) + +Ctt.set_value(0.0) + +Dbar_s.set_value(0.3) + +DDstar_s.set_value(0.3) + +calcs_test2 = zfit.run(probs) +# res_y = zfit.run(jpsi_res(test_q)) +# b0 = [b0_0, b0_1, b0_2] +# bplus = [bplus_0, bplus_1, bplus_2] +# bT = [bT_0, bT_1, bT_2] +# f0_y = zfit.run(tf.math.real(formfactor(test_q,"0", b0, bplus, bT))) +# fplus_y = zfit.run(tf.math.real(formfactor(test_q,"+", b0, bplus, bT))) +# fT_y = zfit.run(tf.math.real(formfactor(test_q,"T", b0, bplus, bT))) + + +# In[ ]: + + +plt.clf() +# plt.plot(x_part, calcs, '.') +plt.plot(test_q, calcs_test, label = 'pdf (Ctt = 0.0)') +plt.plot(test_q, calcs_test1, label = 'pdf (Ctt = 0.5)') +plt.plot(test_q, calcs_test2, label = 'pdf (D-contribs = 0.3)') +# plt.plot(test_q, f0_y, label = '0') +# plt.plot(test_q, fT_y, label = 'T') +# plt.plot(test_q, fplus_y, label = '+') +# plt.plot(test_q, res_y, label = 'res') +plt.legend() +plt.ylim(0.0, 1.5e-6) +# plt.yscale('log') +# plt.xlim(770, 785) +plt.savefig('test.png') +# print(jpsi_width) + + +# In[ ]: + + + + +# probs = mixture.prob(test_q) +# probs_np = zfit.run(probs) +# probs_np *= np.max(calcs_test) / np.max(probs_np) +# plt.figure() +# plt.semilogy(test_q, probs_np,label="importance sampling") +# plt.semilogy(test_q, calcs_test, label = 'pdf') + + +# In[ ]: + + +# 0.213/(0.00133+0.213+0.015) + + +# ## Adjust scaling of different parts + +# In[ ]: + + +total_f.update_integration_options(draws_per_dim=2000000, mc_sampler=None) +# inte = total_f.integrate(limits = (950., 1050.), norm_range=False) +# inte_fl = zfit.run(inte) +# print(inte_fl/4500) +# print(pdg["jpsi_BR"]/pdg["NR_BR"], inte_fl*pdg["psi2s_auc"]/pdg["NR_auc"]) + + +# In[ ]: + + +# # print("jpsi:", inte_fl) +# # print("Increase am by factor:", np.sqrt(pdg["jpsi_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) +# # print("New amp:", pdg["jpsi"][3]*np.sqrt(pdg["jpsi_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) + +# # print("psi2s:", inte_fl) +# # print("Increase am by factor:", np.sqrt(pdg["psi2s_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) +# # print("New amp:", pdg["psi2s"][3]*np.sqrt(pdg["psi2s_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) + +# name = "phi" + +# print(name+":", inte_fl) +# print("Increase am by factor:", np.sqrt(pdg[name+"_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) +# print("New amp:", pdg[name][0]*np.sqrt(pdg[name+"_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) + + +# print(x_min) +# print(x_max) +# # total_f.update_integration_options(draws_per_dim=2000000, mc_sampler=None) +# total_f.update_integration_options(mc_sampler=lambda dim, num_results, +# dtype: tf.random_uniform(maxval=1., shape=(num_results, dim), dtype=dtype), +# draws_per_dim=1000000) +# # _ = [] + +# # for i in range(10): + +# # inte = total_f.integrate(limits = (x_min, x_max)) +# # inte_fl = zfit.run(inte) +# # print(inte_fl) +# # _.append(inte_fl) + +# # print("mean:", np.mean(_)) + +# _ = time.time() + +# inte = total_f.integrate(limits = (x_min, x_max)) +# inte_fl = zfit.run(inte) +# print(inte_fl) +# print("Time taken: {}".format(display_time(int(time.time() - _)))) + +# print(pdg['NR_BR']/pdg['NR_auc']*inte_fl) +# print(0.25**2*4.2/1000) + + +# # Sampling +# ## Mixture distribution for sampling + +# In[ ]: + + + + +# print(list_of_borders[:9]) +# print(list_of_borders[-9:]) + + +class UniformSampleAndWeights(zfit.util.execution.SessionHolderMixin): + def __call__(self, limits, dtype, n_to_produce): + # n_to_produce = tf.cast(n_to_produce, dtype=tf.int32) + low, high = limits.limit1d + low = tf.cast(low, dtype=dtype) + high = tf.cast(high, dtype=dtype) +# uniform = tfd.Uniform(low=low, high=high) +# uniformjpsi = tfd.Uniform(low=tf.constant(3080, dtype=dtype), high=tf.constant(3112, dtype=dtype)) +# uniformpsi2s = tfd.Uniform(low=tf.constant(3670, dtype=dtype), high=tf.constant(3702, dtype=dtype)) + +# list_of_borders = [] +# _p = [] +# splits = 10 + +# _ = np.linspace(x_min, x_max, splits) + +# for i in range(splits): +# list_of_borders.append(tf.constant(_[i], dtype=dtype)) +# _p.append(tf.constant(1/splits, dtype=dtype)) + +# mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=_p[:(splits-1)]), +# components_distribution=tfd.Uniform(low=list_of_borders[:(splits-1)], +# high=list_of_borders[-(splits-1):])) + mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=[tf.constant(0.05, dtype=dtype), + tf.constant(0.93, dtype=dtype), + tf.constant(0.05, dtype=dtype), + tf.constant(0.065, dtype=dtype), + tf.constant(0.04, dtype=dtype), + tf.constant(0.05, dtype=dtype)]), + components_distribution=tfd.Uniform(low=[tf.constant(x_min, dtype=dtype), + tf.constant(3090, dtype=dtype), + tf.constant(3681, dtype=dtype), + tf.constant(3070, dtype=dtype), + tf.constant(1000, dtype=dtype), + tf.constant(3660, dtype=dtype)], + high=[tf.constant(x_max, dtype=dtype), + tf.constant(3102, dtype=dtype), + tf.constant(3691, dtype=dtype), + tf.constant(3110, dtype=dtype), + tf.constant(1040, dtype=dtype), + tf.constant(3710, dtype=dtype)])) +# dtype = tf.float64 +# mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=[tf.constant(0.04, dtype=dtype), +# tf.constant(0.90, dtype=dtype), +# tf.constant(0.02, dtype=dtype), +# tf.constant(0.07, dtype=dtype), +# tf.constant(0.02, dtype=dtype)]), +# components_distribution=tfd.Uniform(low=[tf.constant(x_min, dtype=dtype), +# tf.constant(3089, dtype=dtype), +# tf.constant(3103, dtype=dtype), +# tf.constant(3681, dtype=dtype), +# tf.constant(3691, dtype=dtype)], +# high=[tf.constant(3089, dtype=dtype), +# tf.constant(3103, dtype=dtype), +# tf.constant(3681, dtype=dtype), +# tf.constant(3691, dtype=dtype), +# tf.constant(x_max, dtype=dtype)])) +# mixture = tfd.Uniform(tf.constant(x_min, dtype=dtype), tf.constant(x_max, dtype=dtype)) +# sample = tf.random.uniform((n_to_produce, 1), dtype=dtype) + sample = mixture.sample((n_to_produce, 1)) +# sample = tf.random.uniform((n_to_produce, 1), dtype=dtype) + weights = mixture.prob(sample)[:,0] +# weights = tf.broadcast_to(tf.constant(1., dtype=dtype), shape=(n_to_produce,)) + # sample = tf.expand_dims(sample, axis=-1) +# print(sample, weights) + +# weights = tf.ones(shape=(n_to_produce,), dtype=dtype) + weights_max = None + thresholds = tf.random_uniform(shape=(n_to_produce,), dtype=dtype) + return sample, thresholds, weights, weights_max, n_to_produce + + +# In[ ]: + + +# total_f._sample_and_weights = UniformSampleAndWeights + + +# In[ ]: + + +# 0.00133/(0.00133+0.213+0.015)*(x_max-3750)/(x_max-x_min) + + +# In[ ]: + + +# zfit.settings.set_verbosity(10) + + +# In[ ]: + + +# # zfit.run.numeric_checks = False + +# nr_of_toys = 1 +# nevents = int(pdg["number_of_decays"]) +# nevents = pdg["number_of_decays"] +# event_stack = 1000000 +# # zfit.settings.set_verbosity(10) +# calls = int(nevents/event_stack + 1) + +# total_samp = [] + +# start = time.time() + +# sampler = total_f.create_sampler(n=event_stack) + +# for toy in range(nr_of_toys): + +# dirName = 'data/zfit_toys/toy_{0}'.format(toy) + +# if not os.path.exists(dirName): +# os.mkdir(dirName) +# print("Directory " , dirName , " Created ") + +# for call in range(calls): + +# sampler.resample(n=event_stack) +# s = sampler.unstack_x() +# sam = zfit.run(s) +# # clear_output(wait=True) + +# c = call + 1 + +# print("{0}/{1} of Toy {2}/{3}".format(c, calls, toy+1, nr_of_toys)) +# print("Time taken: {}".format(display_time(int(time.time() - start)))) +# print("Projected time left: {}".format(display_time(int((time.time() - start)/(c+calls*(toy))*((nr_of_toys-toy)*calls-c))))) + +# with open("data/zfit_toys/toy_{0}/{1}.pkl".format(toy, call), "wb") as f: +# pkl.dump(sam, f, pkl.HIGHEST_PROTOCOL) + + +# In[ ]: + + +# with open(r"data/zfit_toys/toy_0/0.pkl", "rb") as input_file: +# sam = pkl.load(input_file) +# print(sam[:10]) + +# with open(r"data/zfit_toys/toy_0/1.pkl", "rb") as input_file: +# sam2 = pkl.load(input_file) +# print(sam2[:10]) + +# print(np.sum(sam-sam2)) + + +# In[ ]: + + +# print("Time to generate full toy: {} s".format(int(time.time()-start))) + +# total_samp = [] + +# for call in range(calls): +# with open(r"data/zfit_toys/toy_0/{}.pkl".format(call), "rb") as input_file: +# sam = pkl.load(input_file) +# total_samp = np.append(total_samp, sam) + +# total_samp = total_samp.astype('float64') + +# data2 = zfit.data.Data.from_numpy(array=total_samp[:int(nevents)], obs=obs) + +# data3 = zfit.data.Data.from_numpy(array=total_samp, obs=obs) + +# print(total_samp[:nevents].shape) + + +# In[ ]: + + +# plt.clf() + +# bins = int((x_max-x_min)/7) + +# # calcs = zfit.run(total_test_tf(samp)) +# print(total_samp[:nevents].shape) + +# plt.hist(total_samp[:nevents], bins = bins, range = (x_min,x_max), label = 'data') +# # plt.plot(test_q, calcs_test*nevents , label = 'pdf') + +# # plt.plot(sam, calcs, '.') +# # plt.plot(test_q, calcs_test) +# # plt.yscale('log') +# plt.ylim(0, 200) +# # plt.xlim(3080, 3110) + +# plt.legend() + +# plt.savefig('test2.png') + + +# In[ ]: + + +# sampler = total_f.create_sampler(n=nevents) +# nll = zfit.loss.UnbinnedNLL(model=total_f, data=sampler, fit_range = (x_min, x_max)) + +# # for param in pdf.get_dependents(): +# # param.set_value(initial_value) + +# sampler.resample(n=nevents) + +# # Randomise initial values +# # for param in pdf.get_dependents(): +# # param.set_value(random value here) + +# # Minimise the NLL +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 10) +# minimum = minimizer.minimize(nll) + + +# In[ ]: + + +# jpsi_width + + +# In[ ]: + + +# plt.hist(sample, weights=1 / prob(sample)) + + +# # Fitting + +# In[ ]: + + +# start = time.time() + +# for param in total_f.get_dependents(): +# param.randomize() + +# # for param in total_f.get_dependents(): +# # print(zfit.run(param)) + +# nll = zfit.loss.UnbinnedNLL(model=total_f, data=data2, fit_range = (x_min, x_max)) + +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) +# # minimizer._use_tfgrad = False +# result = minimizer.minimize(nll) + +# # param_errors = result.error() + +# # for var, errors in param_errors.items(): +# # print('{}: ^{{+{}}}_{{{}}}'.format(var.name, errors['upper'], errors['lower'])) + +# print("Function minimum:", result.fmin) +# # print("Results:", result.params) +# print("Hesse errors:", result.hesse()) + + +# In[ ]: + + +# print("Time taken for fitting: {}".format(display_time(int(time.time()-start)))) + +# # probs = total_f.pdf(test_q) + +# calcs_test = zfit.run(probs) +# res_y = zfit.run(jpsi_res(test_q)) + + +# In[ ]: + + +# plt.clf() +# # plt.plot(x_part, calcs, '.') +# plt.plot(test_q, calcs_test, label = 'pdf') +# # plt.plot(test_q, res_y, label = 'res') +# plt.legend() +# plt.ylim(0.0, 10e-6) +# # plt.yscale('log') +# # plt.xlim(3080, 3110) +# plt.savefig('test3.png') +# # print(jpsi_width) + + +# In[ ]: + + +# _tot = 4.37e-7+6.02e-5+4.97e-6 +# _probs = [] +# _probs.append(6.02e-5/_tot) +# _probs.append(4.97e-6/_tot) +# _probs.append(4.37e-7/_tot) +# print(_probs) + + +# In[ ]: + + +# dtype = 'float64' +# # mixture = tfd.Uniform(tf.constant(x_min, dtype=dtype), tf.constant(x_max, dtype=dtype)) +# mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=[tf.constant(0.007, dtype=dtype), +# tf.constant(0.917, dtype=dtype), +# tf.constant(0.076, dtype=dtype)]), +# components_distribution=tfd.Uniform(low=[tf.constant(x_min, dtype=dtype), +# tf.constant(3080, dtype=dtype), +# tf.constant(3670, dtype=dtype)], +# high=[tf.constant(x_max, dtype=dtype), +# tf.constant(3112, dtype=dtype), +# tf.constant(3702, dtype=dtype)])) +# # for i in range(10): +# # print(zfit.run(mixture.prob(mixture.sample((10, 1))))) + + +# In[ ]: + + +# print((zfit.run(jpsi_p)%(2*np.pi))/np.pi) +# print((zfit.run(psi2s_p)%(2*np.pi))/np.pi) + + +# In[ ]: + + +# def jpsi_res(q): +# return resonance(q, _mass = jpsi_mass, scale = jpsi_scale, +# phase = jpsi_phase, width = jpsi_width) + +# def psi2s_res(q): +# return resonance(q, _mass = psi2s_mass, scale = psi2s_scale, +# phase = psi2s_phase, width = psi2s_width) + +# def p3770_res(q): +# return resonance(q, _mass = p3770_mass, scale = p3770_scale, +# phase = p3770_phase, width = p3770_width) + +# def p4040_res(q): +# return resonance(q, _mass = p4040_mass, scale = p4040_scale, +# phase = p4040_phase, width = p4040_width) + +# def p4160_res(q): +# return resonance(q, _mass = p4160_mass, scale = p4160_scale, +# phase = p4160_phase, width = p4160_width) + +# def p4415_res(q): +# return resonance(q, _mass = p4415_mass, scale = p4415_scale, +# phase = p4415_phase, width = p4415_width) + + +# In[ ]: + + +# 0.15**2*4.2/1000 +# result.hesse() + + +# ## Constraints + +# In[ ]: + + +# 1. Constraint - Real part of sum of Psi contrib and D contribs + +sum_list = [] + +sum_list.append(ztf.to_complex(jpsi_s) * tf.exp(tf.complex(ztf.constant(0.0), jpsi_p)) * ztf.to_complex(jpsi_w / (tf.pow(jpsi_m,3)))) +sum_list.append(ztf.to_complex(psi2s_s) * tf.exp(tf.complex(ztf.constant(0.0), psi2s_p)) * ztf.to_complex(psi2s_w / (tf.pow(psi2s_m,3)))) +sum_list.append(ztf.to_complex(p3770_s) * tf.exp(tf.complex(ztf.constant(0.0), p3770_p)) * ztf.to_complex(p3770_w / (tf.pow(p3770_m,3)))) +sum_list.append(ztf.to_complex(p4040_s) * tf.exp(tf.complex(ztf.constant(0.0), p4040_p)) * ztf.to_complex(p4040_w / (tf.pow(p4040_m,3)))) +sum_list.append(ztf.to_complex(p4160_s) * tf.exp(tf.complex(ztf.constant(0.0), p4160_p)) * ztf.to_complex(p4160_w / (tf.pow(p4160_m,3)))) +sum_list.append(ztf.to_complex(p4415_s) * tf.exp(tf.complex(ztf.constant(0.0), p4415_p)) * ztf.to_complex(p4415_w / (tf.pow(p4415_m,3)))) +sum_list.append(ztf.to_complex(DDstar_s) * tf.exp(tf.complex(ztf.constant(0.0), DDstar_p)) * (ztf.to_complex(1.0 / (10.0*tf.pow(Dstar_m,2)) + 1.0 / (10.0*tf.pow(D_m,2))))) +sum_list.append(ztf.to_complex(Dbar_s) * tf.exp(tf.complex(ztf.constant(0.0), Dbar_p)) * ztf.to_complex(1.0 / (6.0*tf.pow(Dbar_m,2)))) + +sum_ru_1 = ztf.to_complex(ztf.constant(0.0)) + +for part in sum_list: + sum_ru_1 += part + +sum_1 = tf.math.real(sum_ru_1) +# constraint1 = zfit.constraint.GaussianConstraint(params = sum_1, mu = ztf.constant(1.7*10**-8), +# sigma = ztf.constant(2.2*10**-8)) + +constraint1 = tf.pow((sum_1-ztf.constant(1.7*10**-8))/ztf.constant(2.2*10**-8),2)/ztf.constant(2.) + +# 2. Constraint - Abs. of sum of Psi contribs and D contribs + +sum_2 = tf.abs(sum_ru_1) +constraint2 = tf.cond(tf.greater_equal(sum_2, 5.0e-8), lambda: 100000., lambda: 0.) + +# 3. Constraint - Maximum eta of D contribs + +constraint3_0 = tf.cond(tf.greater_equal(tf.abs(Dbar_s), 0.2), lambda: 100000., lambda: 0.) + +constraint3_1 = tf.cond(tf.greater_equal(tf.abs(DDstar_s), 0.2), lambda: 100000., lambda: 0.) + +# 4. Constraint - Formfactor multivariant gaussian covariance fplus + +Cov_matrix = [[ztf.constant( 1.), ztf.constant( 0.45), ztf.constant( 0.19), ztf.constant(0.857), ztf.constant(0.598), ztf.constant(0.531), ztf.constant(0.752), ztf.constant(0.229), ztf.constant(0,117)], + [ztf.constant( 0.45), ztf.constant( 1.), ztf.constant(0.677), ztf.constant(0.708), ztf.constant(0.958), ztf.constant(0.927), ztf.constant(0.227), ztf.constant(0.443), ztf.constant(0.287)], + [ztf.constant( 0.19), ztf.constant(0.677), ztf.constant( 1.), ztf.constant(0.595), ztf.constant(0.770), ztf.constant(0.819),ztf.constant(-0.023), ztf.constant( 0.07), ztf.constant(0.196)], + [ztf.constant(0.857), ztf.constant(0.708), ztf.constant(0.595), ztf.constant( 1.), ztf.constant( 0.83), ztf.constant(0.766), ztf.constant(0.582), ztf.constant(0.237), ztf.constant(0.192)], + [ztf.constant(0.598), ztf.constant(0.958), ztf.constant(0.770), ztf.constant( 0.83), ztf.constant( 1.), ztf.constant(0.973), ztf.constant(0.324), ztf.constant(0.372), ztf.constant(0.272)], + [ztf.constant(0.531), ztf.constant(0.927), ztf.constant(0.819), ztf.constant(0.766), ztf.constant(0.973), ztf.constant( 1.), ztf.constant(0.268), ztf.constant(0.332), ztf.constant(0.269)], + [ztf.constant(0.752), ztf.constant(0.227),ztf.constant(-0.023), ztf.constant(0.582), ztf.constant(0.324), ztf.constant(0.268), ztf.constant( 1.), ztf.constant( 0.59), ztf.constant(0.515)], + [ztf.constant(0.229), ztf.constant(0.443), ztf.constant( 0.07), ztf.constant(0.237), ztf.constant(0.372), ztf.constant(0.332), ztf.constant( 0.59), ztf.constant( 1.), ztf.constant(0.897)], + [ztf.constant(0.117), ztf.constant(0.287), ztf.constant(0.196), ztf.constant(0.192), ztf.constant(0.272), ztf.constant(0.269), ztf.constant(0.515), ztf.constant(0.897), ztf.constant( 1.)]] + +def triGauss(val1,val2,val3,m = Cov_matrix): + + mean1 = ztf.constant(0.466) + mean2 = ztf.constant(-0.885) + mean3 = ztf.constant(-0.213) + sigma1 = ztf.constant(0.014) + sigma2 = ztf.constant(0.128) + sigma3 = ztf.constant(0.548) + x1 = (val1-mean1)/sigma1 + x2 = (val2-mean2)/sigma2 + x3 = (val3-mean3)/sigma3 + rho12 = m[0][1] + rho13 = m[0][2] + rho23 = m[1][2] + w = x1*x1*(rho23*rho23-1) + x2*x2*(rho13*rho13-1)+x3*x3*(rho12*rho12-1)+2*(x1*x2*(rho12-rho13*rho23)+x1*x3*(rho13-rho12*rho23)+x2*x3*(rho23-rho12*rho13)) + d = 2*(rho12*rho12+rho13*rho13+rho23*rho23-2*rho12*rho13*rho23-1) + + fcn = -w/d + chisq = -2*fcn + return chisq + +constraint4 = triGauss(bplus_0, bplus_1, bplus_2) + +# mean1 = ztf.constant(0.466) +# mean2 = ztf.constant(-0.885) +# mean3 = ztf.constant(-0.213) +# sigma1 = ztf.constant(0.014) +# sigma2 = ztf.constant(0.128) +# sigma3 = ztf.constant(0.548) +# constraint4_0 = tf.pow((bplus_0-mean1)/sigma1,2)/ztf.constant(2.) +# constraint4_1 = tf.pow((bplus_1-mean2)/sigma2,2)/ztf.constant(2.) +# constraint4_2 = tf.pow((bplus_2-mean3)/sigma3,2)/ztf.constant(2.) + +# 5. Constraint - Abs. of sum of light contribs + +sum_list_5 = [] + +sum_list_5.append(rho_s*rho_w/rho_m) +sum_list_5.append(omega_s*omega_w/omega_m) +sum_list_5.append(phi_s*phi_w/phi_m) + + +sum_ru_5 = ztf.constant(0.0) + +for part in sum_list_5: + sum_ru_5 += part + +constraint5 = tf.cond(tf.greater_equal(tf.abs(sum_ru_5), ztf.constant(0.02)), lambda: 100000., lambda: 0.) + +# 6. Constraint on phases of Jpsi and Psi2s for cut out fit + + +# constraint6_0 = zfit.constraint.GaussianConstraint(params = jpsi_p, mu = ztf.constant(pdg["jpsi_phase_unc"]), +# sigma = ztf.constant(jpsi_phase)) +# constraint6_1 = zfit.constraint.GaussianConstraint(params = psi2s_p, mu = ztf.constant(pdg["psi2s_phase_unc"]), +# sigma = ztf.constant(psi2s_phase)) + +constraint6_0 = tf.pow((jpsi_p-ztf.constant(jpsi_phase))/ztf.constant(pdg["jpsi_phase_unc"]),2)/ztf.constant(2.) +constraint6_1 = tf.pow((psi2s_p-ztf.constant(psi2s_phase))/ztf.constant(pdg["psi2s_phase_unc"]),2)/ztf.constant(2.) + +# 7. Constraint on Ctt with higher limits + +constraint7 = tf.cond(tf.greater_equal(Ctt*Ctt, 0.25), lambda: 100000., lambda: 0.) + +constraint7dtype = tf.float64 + +# zfit.run(constraint6_0) + +# ztf.convert_to_tensor(constraint6_0) + +#List of all constraints + +constraints = [constraint1, constraint2, constraint3_0, constraint3_1,# constraint4, #constraint4_0, constraint4_1, constraint4_2, + constraint6_0, constraint6_1]#, constraint7] + + +# ## Reset params + +# In[ ]: + + +param_values_dic = { + 'jpsi_m': jpsi_mass, + 'jpsi_s': jpsi_scale, + 'jpsi_p': jpsi_phase, + 'jpsi_w': jpsi_width, + 'psi2s_m': psi2s_mass, + 'psi2s_s': psi2s_scale, + 'psi2s_p': psi2s_phase, + 'psi2s_w': psi2s_width, + 'p3770_m': p3770_mass, + 'p3770_s': p3770_scale, + 'p3770_p': p3770_phase, + 'p3770_w': p3770_width, + 'p4040_m': p4040_mass, + 'p4040_s': p4040_scale, + 'p4040_p': p4040_phase, + 'p4040_w': p4040_width, + 'p4160_m': p4160_mass, + 'p4160_s': p4160_scale, + 'p4160_p': p4160_phase, + 'p4160_w': p4160_width, + 'p4415_m': p4415_mass, + 'p4415_s': p4415_scale, + 'p4415_p': p4415_phase, + 'p4415_w': p4415_width, + 'rho_m': rho_mass, + 'rho_s': rho_scale, + 'rho_p': rho_phase, + 'rho_w': rho_width, + 'omega_m': omega_mass, + 'omega_s': omega_scale, + 'omega_p': omega_phase, + 'omega_w': omega_width, + 'phi_m': phi_mass, + 'phi_s': phi_scale, + 'phi_p': phi_phase, + 'phi_w': phi_width, + 'Dstar_m': Dstar_mass, + 'DDstar_s': 0.0, + 'DDstar_p': 0.0, + 'D_m': D_mass, + 'Dbar_m': Dbar_mass, + 'Dbar_s': 0.0, + 'Dbar_p': 0.0, + 'tau_m': pdg['tau_M'], + 'Ctt': 0.0, + 'b0_0': 0.292, + 'b0_1': 0.281, + 'b0_2': 0.150, + 'bplus_0': 0.466, + 'bplus_1': -0.885, + 'bplus_2': -0.213, + 'bT_0': 0.460, + 'bT_1': -1.089, + 'bT_2': -1.114} + + +def reset_param_values(variation = 0.05): + for param in total_f_fit.get_dependents(): + if param.floating: + param.set_value(param_values_dic[param.name] + random.uniform(-1, 1) * param_values_dic[param.name]* variation) +# print(param.name) +# for param in totalf.get_dependents(): +# param.set_value() + + +# # Analysis + +# In[ ]: + + +# # zfit.run.numeric_checks = False + +# fitting_range = 'cut' +# total_BR = 1.7e-10 + 4.9e-10 + 2.5e-9 + 6.02e-5 + 4.97e-6 + 1.38e-9 + 4.2e-10 + 2.6e-9 + 6.1e-10 + 4.37e-7 +# cut_BR = 1.0 - (6.02e-5 + 4.97e-6)/total_BR + +# Ctt_list = [] +# Ctt_error_list = [] + +# nr_of_toys = 1 +# if fitting_range == 'cut': +# nevents = int(pdg["number_of_decays"]*cut_BR) +# else: +# nevents = int(pdg["number_of_decays"]) +# # nevents = pdg["number_of_decays"] +# event_stack = 1000000 +# # nevents *= 41 +# # zfit.settings.set_verbosity(10) +# calls = int(nevents/event_stack + 1) + +# total_samp = [] + +# start = time.time() + +# sampler = total_f.create_sampler(n=event_stack) + +# for toy in range(nr_of_toys): + +# ### Generate data + +# # clear_output(wait=True) + +# print("Toy {}: Generating data...".format(toy)) + +# dirName = 'data/zfit_toys/toy_{0}'.format(toy) + +# if not os.path.exists(dirName): +# os.mkdir(dirName) +# print("Directory " , dirName , " Created ") + +# reset_param_values() + +# if fitting_range == 'cut': + +# sampler.resample(n=nevents) +# s = sampler.unstack_x() +# sam = zfit.run(s) +# calls = 0 +# c = 1 + +# else: +# for call in range(calls): + +# sampler.resample(n=event_stack) +# s = sampler.unstack_x() +# sam = zfit.run(s) + +# c = call + 1 + +# with open("data/zfit_toys/toy_{0}/{1}.pkl".format(toy, call), "wb") as f: +# pkl.dump(sam, f, pkl.HIGHEST_PROTOCOL) + +# print("Toy {}: Data generation finished".format(toy)) + +# ### Load data + +# print("Toy {}: Loading data...".format(toy)) + +# if fitting_range == 'cut': + +# total_samp = sam + +# else: + +# for call in range(calls): +# with open(r"data/zfit_toys/toy_0/{}.pkl".format(call), "rb") as input_file: +# sam = pkl.load(input_file) +# total_samp = np.append(total_samp, sam) + +# total_samp = total_samp.astype('float64') + +# if fitting_range == 'full': + +# data = zfit.data.Data.from_numpy(array=total_samp[:int(nevents)], obs=obs) + +# print("Toy {}: Loading data finished".format(toy)) + +# ### Fit data + +# print("Toy {}: Fitting pdf...".format(toy)) + +# for param in total_f.get_dependents(): +# param.randomize() + +# nll = zfit.loss.UnbinnedNLL(model=total_f, data=data, fit_range = (x_min, x_max), constraints = constraints) + +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) +# # minimizer._use_tfgrad = False +# result = minimizer.minimize(nll) + +# print("Toy {}: Fitting finished".format(toy)) + +# print("Function minimum:", result.fmin) +# print("Hesse errors:", result.hesse()) + +# params = result.params +# Ctt_list.append(params[Ctt]['value']) +# Ctt_error_list.append(params[Ctt]['minuit_hesse']['error']) + +# #plotting the result + +# plotdirName = 'data/plots'.format(toy) + +# if not os.path.exists(plotdirName): +# os.mkdir(plotdirName) +# # print("Directory " , dirName , " Created ") + +# probs = total_f.pdf(test_q, norm_range=False) +# calcs_test = zfit.run(probs) +# plt.clf() +# plt.plot(test_q, calcs_test, label = 'pdf') +# plt.legend() +# plt.ylim(0.0, 6e-6) +# plt.savefig(plotdirName + '/toy_fit_full_range{}.png'.format(toy)) + +# print("Toy {0}/{1}".format(toy+1, nr_of_toys)) +# print("Time taken: {}".format(display_time(int(time.time() - start)))) +# print("Projected time left: {}".format(display_time(int((time.time() - start)/(c+calls*(toy))*((nr_of_toys-toy)*calls-c))))) + +# if fitting_range == 'cut': + +# _1 = np.where((total_samp >= x_min) & (total_samp <= (jpsi_mass - 60.))) + +# tot_sam_1 = total_samp[_1] + +# _2 = np.where((total_samp >= (jpsi_mass + 70.)) & (total_samp <= (psi2s_mass - 50.))) + +# tot_sam_2 = total_samp[_2] + +# _3 = np.where((total_samp >= (psi2s_mass + 50.)) & (total_samp <= x_max)) + +# tot_sam_3 = total_samp[_3] + +# tot_sam = np.append(tot_sam_1, tot_sam_2) +# tot_sam = np.append(tot_sam, tot_sam_3) + +# data = zfit.data.Data.from_numpy(array=tot_sam[:int(nevents)], obs=obs_fit) + +# print("Toy {}: Loading data finished".format(toy)) + +# ### Fit data + +# print("Toy {}: Fitting pdf...".format(toy)) + +# for param in total_f_fit.get_dependents(): +# param.randomize() + +# nll = zfit.loss.UnbinnedNLL(model=total_f_fit, data=data, constraints = constraints) + +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) +# # minimizer._use_tfgrad = False +# result = minimizer.minimize(nll) + +# print("Function minimum:", result.fmin) +# print("Hesse errors:", result.hesse()) + +# params = result.params + +# if result.converged: +# Ctt_list.append(params[Ctt]['value']) +# Ctt_error_list.append(params[Ctt]['minuit_hesse']['error']) + +# #plotting the result + +# plotdirName = 'data/plots'.format(toy) + +# if not os.path.exists(plotdirName): +# os.mkdir(plotdirName) +# # print("Directory " , dirName , " Created ") + +# plt.clf() +# plt.hist(tot_sam, bins = int((x_max-x_min)/7.), label = 'toy data') +# plt.savefig(plotdirName + '/toy_histo_cut_region{}.png'.format(toy)) + + +# probs = total_f_fit.pdf(test_q, norm_range=False) +# calcs_test = zfit.run(probs) +# plt.clf() +# plt.plot(test_q, calcs_test, label = 'pdf') +# plt.axvline(x=jpsi_mass-60.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.axvline(x=jpsi_mass+70.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.axvline(x=psi2s_mass-50.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.axvline(x=psi2s_mass+50.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.legend() +# plt.ylim(0.0, 1.5e-6) +# plt.savefig(plotdirName + '/toy_fit_cut_region{}.png'.format(toy)) + +# print("Toy {0}/{1}".format(toy+1, nr_of_toys)) +# print("Time taken: {}".format(display_time(int(time.time() - start)))) +# print("Projected time left: {}".format(display_time(int((time.time() - start)/(toy+1))*((nr_of_toys-toy-1))))) + + + +# In[ ]: + + +# with open("data/results/Ctt_list.pkl", "wb") as f: +# pkl.dump(Ctt_list, f, pkl.HIGHEST_PROTOCOL) +# with open("data/results/Ctt_error_list.pkl", "wb") as f: +# pkl.dump(Ctt_error_list, f, pkl.HIGHEST_PROTOCOL) + + +# In[ ]: + + +# print('{0}/{1} fits converged'.format(len(Ctt_list), nr_of_toys)) +# print('Mean Ctt value = {}'.format(np.mean(Ctt_list))) +# print('Mean Ctt error = {}'.format(np.mean(Ctt_error_list))) +# print('95 Sensitivy = {}'.format(((2*np.mean(Ctt_error_list))**2)*4.2/1000)) + + +# In[ ]: + + +# plt.hist(tot_sam, bins = int((x_max-x_min)/7.)) + +# plt.show() + +# # _ = np.where((total_samp >= x_min) & (total_samp <= (jpsi_mass - 50.))) + +# tot_sam.shape + + +# In[ ]: + + +# Ctt.floating = False + + +# In[ ]: + + +# zfit.run(nll.value()) + + +# In[ ]: + + +# result.fmin + + +# In[ ]: + + +# BR_steps = np.linspace(0.0, 1e-3, 11) +pull_dic = {} + +mi = 1e-4 +ma = 3e-3 +ste = 20 + +for param in total_f_fit.get_dependents(): + if param.floating: + pull_dic[param.name] = [] + for step in range(2*ste): + pull_dic[param.name].append([]) + + + +def save_pulls(step): + for param in total_f_fit.get_dependents(): + if param.floating: + pull_dic[param.name][step].append((params[param]['value'] - param_values_dic[param.name])/params[param]['minuit_hesse']['error']) + + + +# for key in pull_dic.keys(): +# print(np.shape(pull_dic[key])) +# save_pulls(New_step=True) +# params[Ctt]['value'] + + +# In[ ]: + + +# for param in total_f_fit.get_dependents(): +# if param.floating: +# print(param.name) + +# print(params[Ctt]) + + +# # CLS Code + +# In[ ]: + + +# zfit.run.numeric_checks = False + +load = False + +bo = True + +D_contribs = True + +if not D_contribs: + Dbar_s.floating = False + Dbar_p.floating = False + DDstar_s.floating = False + DDstar_p.floating = False + +bo_set = 1 + +fitting_range = 'cut' +total_BR = 1.7e-10 + 4.9e-10 + 2.5e-9 + 6.02e-5 + 4.97e-6 + 1.38e-9 + 4.2e-10 + 2.6e-9 + 6.1e-10 + 4.37e-7 +cut_BR = 1.0 - (6.02e-5 + 4.97e-6)/total_BR + +Ctt_list = [] +Ctt_error_list = [] + +nr_of_toys = 1 +nevents = int(pdg["number_of_decays"]*cut_BR) +# nevents = pdg["number_of_decays"] +event_stack = 1000000 +# nevents *= 41 +# zfit.settings.set_verbosity(10) + +# mi = 1e-4 +# ma = 3e-3 +# ste = 13 + +BR_steps = np.linspace(mi, ma, ste) + +BR_steps[0] = 0.0 + +print(BR_steps) + +Ctt_steps = np.sqrt(BR_steps/4.2*1000) + +print(Ctt_steps) + +# total_samp = [] + +start = time.time() + +Nll_list = [] + +sampler = total_f.create_sampler(n=nevents, fixed_params = False) +sampler.set_data_range(obs_fit) + +__ = -1 + +#----------------------------------------------------- + +if not load: + for Ctt_step in Ctt_steps: + + __ += 1 + + for i in range(2): + Ctt_list.append([]) + Ctt_error_list.append([]) + Nll_list.append([]) + + for param in total_f_fit.get_dependents(): + if param.floating: + pull_dic[param.name].append([]) + + for toy in range(nr_of_toys): + + newset = True + + while newset: + + for floaty in [True, False]: + Ctt.floating = floaty + + for bo_step in range(bo_set): + + print('Step: {0}/{1}'.format(int(__), ste)) + print('Current Ctt: {0}'.format(Ctt_step)) + print('Ctt floating: {0}'.format(floaty)) + + reset_param_values(variation = 0.0) + + if floaty: + print('Toy {0}/{1} - Fit {2}/{3}'.format(toy, nr_of_toys, bo_step, bo_set)) + Ctt.set_value(Ctt_step) + + else: + Ctt.set_value(0.0) + print('Toy {0}/{1} - Fit {2}/{3}'.format(toy, nr_of_toys, bo_step, bo_set)) + + if newset: + sampler.resample(n=nevents) + data = sampler + newset = False + + ### Fit data + + if floaty: + #plt.clf() + #plt.title('Ctt value: {:.2f}'.format(Ctt_step)) + #plt.hist(zfit.run(data), bins = int((x_max-x_min)/7), range = (x_min, x_max)) + #plt.savefig('data/CLs/plots/set_histo{}.png'.format(__)) + _step = 2*__ + else: + _step = 2*__+1 + + nll = zfit.loss.UnbinnedNLL(model=total_f_fit, data=data, constraints = constraints) + + minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) + # minimizer._use_tfgrad = False + result = minimizer.minimize(nll) + + print("Function minimum:", result.fmin) + print("Hesse errors:", result.hesse()) + + params = result.params + + if result.converged: + + save_pulls(step = _step) + + if floaty: + Nll_list[-2].append(result.fmin) + Ctt_list[-2].append(params[Ctt]['value']) + Ctt_error_list[-2].append(params[Ctt]['minuit_hesse']['error']) + + else: + Nll_list[-1].append(result.fmin) + Ctt_list[-1].append(0.0) + Ctt_error_list[-1].append(0.0) + + + else: + for _ in [1,2]: + del Nll_list[-_][toy*bo_set:] +# print(np.shape(Nll_list[-_])) + del Ctt_list[-_][toy*bo_set:] + del Ctt_error_list[-_][toy*bo_set:] + for param in total_f_fit.get_dependents(): + if param.floating: + del pull_dic[param.name][_step+1-_][toy*bo_set:] + newset = True + break + + if not result.converged: + break + + print() + print('Time taken: {}'.format(display_time(int(time.time()-start)))) + print('Estimated time left: {}'.format(display_time(int((time.time()-start)/(__+(toy+1)/nr_of_toys)*(ste-__-(nr_of_toys-toy-1)/nr_of_toys))))) + + +# In[ ]: + + +if load: + + phase_combi = '--' + + if D_contribs: + D_dir = 'D-True' + else: + D_dir = 'D-False' + + _dir = 'data/CLs/finished/f1d1/{}/{}/'.format(phase_combi, D_dir) + + jobs = os.listdir(_dir) + + First = True + +# print(jobs) + + for job in jobs: + + dirName = _dir + str(job) + '/data/CLs' + + if not os.path.exists("{}/{}-{}_{}s{}b{}t--CLs_Nll_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys)): +# print(job) + continue + + with open(r"{}/variab.pkl".format(dirName), "rb") as input_file: + variab = pkl.load(input_file) +# print(variab) + + ### sanity check: + if variab['mi'] != mi or variab['ma'] != ma or variab['ste'] != ste or bo_set != bo_set: + print('Fitting parameters of data dont equal the ones given -- Job {} skipped!'.format(job)) + + with open(r"{}/{}-{}_{}s{}b{}t--CLs_Nll_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _Nll_list = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s{}b{}t--Ctt_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _Ctt_list = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s{}b{}t--Ctt_error_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _Ctt_error_list = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s{}b{}t--pull_dic.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _pull_dic = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s--CLs_list.pkl".format(dirName, mi,ma,ste), "rb") as input_file: + _CLs_list = pkl.load(input_file) + + + if First: + Nll_list = _Nll_list + Ctt_list = _Ctt_list + Ctt_error_list = _Ctt_error_list + pull_dic = _pull_dic +# print(_pull_dic) + CLs_list = _CLs_list + First = False + else: + for step in range(2*ste): +# print(Nll_list[step], step) + Nll_list[step].extend(_Nll_list[step]) + Ctt_list[step].extend(_Ctt_list[step]) + Ctt_error_list[step].extend(_Ctt_error_list[step]) + for key in pull_dic.keys(): +# print(key, np.shape(pull_dic[key])) + pull_dic[key][step].extend(_pull_dic[key][step]) + for step in range(ste): + CLs_list[step].extend(_CLs_list[step]) + +# print('----------------------') + + +# In[ ]: + + +dirName = 'data/CLs' + +# if bo and not load: +# for s in range(2*ste): +# Nll_list[s] = [np.min(Nll_list[s])] + + +if not load: + + if not os.path.exists(dirName): + os.mkdir(dirName) + print("Directory " , dirName , " Created ") + + with open("{}/{}-{}_{}s{}b{}t--CLs_Nll_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(Nll_list, f, pkl.HIGHEST_PROTOCOL) + + with open("{}/{}-{}_{}s{}b{}t--Ctt_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(Ctt_list, f, pkl.HIGHEST_PROTOCOL) + + with open("{}/{}-{}_{}s{}b{}t--Ctt_error_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(Ctt_error_list, f, pkl.HIGHEST_PROTOCOL) + + with open("{}/{}-{}_{}s{}b{}t--pull_dic.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(pull_dic, f, pkl.HIGHEST_PROTOCOL) + + variab = {'mi': mi, + 'ma': ma, + 'ste': ste, + 'bo_set': bo_set, + 'nr_of_toys': nr_of_toys} + + with open("{}/variab.pkl".format(dirName), "wb") as f: + pkl.dump(variab, f, pkl.HIGHEST_PROTOCOL) + + CLs_values = [] + + toy_size = bo_set + + print(np.shape(Nll_list)) + print(Nll_list[0:1]) + + for step in range(ste): + CLs_values.append([]) + for toy in range(nr_of_toys): + float_min = np.min(Nll_list[2*step][toy*bo_set:(toy+1)*bo_set]) + fix_min = np.min(Nll_list[2*step+1][toy*bo_set:(toy+1)*bo_set]) + CLs_values[step].append(float_min-fix_min) + + + print(np.shape(CLs_values)) + + with open("{}/{}-{}_{}s--CLs_list.pkl".format(dirName, mi,ma,ste), "wb") as f: + pkl.dump(CLs_values, f, pkl.HIGHEST_PROTOCOL) + + +# In[ ]: + + +# print(variab['mi'] != mi) + + +# ## Plot + +# In[ ]: + + +l = [] + + +if load: + CLs_values = -1*np.array(CLs_list) + +if not os.path.exists('data/CLs/plots'): + os.mkdir('data/CLs/plots') + print("Directory " , 'data/CLs/plots' , " Created ") + +print(np.shape(CLs_values)) + +for step in range(1,ste): + plt.clf() + plt.title('Ctt value: {:.2f}'.format(Ctt_steps[step])) + plt.hist(CLs_values[0], bins = 150, range = (-25, 50), label = 'Ctt fixed to 0') + plt.hist(CLs_values[step], bins = 150, range = (-25, 50), label = 'Ctt floating') + plt.axvline(x=np.mean(CLs_values[0]),color='red', linewidth=1.0, linestyle = 'dotted') + plt.legend() + plt.savefig('data/CLs/plots/CLs-BR({:.1E}).png'.format(BR_steps[step])) + + l.append(len(np.where(np.array(CLs_values[step]) < np.mean(CLs_values[0]))[0])) + +for step in range(2*ste): + if step%2 == 0: + floaty = True + else: + floaty = False + for key in pull_dic.keys(): + if not os.path.exists('data/CLs/plots/{}'.format(key)): + os.mkdir('data/CLs/plots/{}'.format(key)) + plt.clf() + plt.title('Pull {} - Ctt value {:.2f} - floating {}'.format(key, Ctt_steps[int(step/2)], floaty)) + plt.hist(pull_dic[key][step], bins = 50, range = (-5,5)) + plt.xlabel('Pull') + plt.savefig('data/CLs/plots/{}/{:.2f}Ctt{}s{}f.png'.format(key, Ctt_steps[int(step/2)], step, floaty)) + + +# In[ ]: + + +for s in range(len(l)): + print('BR: {:.4f}'.format(BR_steps[s+1])) + print(2*l[s]/len(CLs_values[s])) + print() + + +# In[ ]: + + +# for step in range(2*ste): +# for key in pull_dic.keys(): +# print(pull_dic[key][step]) + + +# In[ ]: + + +# for param in total_f_fit.get_dependents(): +# if param.floating: +# print(params[param]['value']) + + +# In[ ]: + + +print(display_time(int(time.time()-start))) + + +# In[ ]: + + +# variab['mi'] =! mi + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + diff --git a/data/CLs/finished/f1d1/-+/D-True/2288052/__pycache__/helperfunctions.cpython-37.pyc b/data/CLs/finished/f1d1/-+/D-True/2288052/__pycache__/helperfunctions.cpython-37.pyc new file mode 100644 index 0000000..6af0ee7 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288052/__pycache__/helperfunctions.cpython-37.pyc Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288052/__pycache__/pdg_const1.cpython-37.pyc b/data/CLs/finished/f1d1/-+/D-True/2288052/__pycache__/pdg_const1.cpython-37.pyc new file mode 100644 index 0000000..26f7f3e --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288052/__pycache__/pdg_const1.cpython-37.pyc Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288052/data/CLs/0.0001-0.003_20s--CLs_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288052/data/CLs/0.0001-0.003_20s--CLs_list.pkl new file mode 100644 index 0000000..81cde13 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288052/data/CLs/0.0001-0.003_20s--CLs_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288052/data/CLs/0.0001-0.003_20s1b1t--CLs_Nll_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288052/data/CLs/0.0001-0.003_20s1b1t--CLs_Nll_list.pkl new file mode 100644 index 0000000..d75075d --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288052/data/CLs/0.0001-0.003_20s1b1t--CLs_Nll_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288052/data/CLs/0.0001-0.003_20s1b1t--Ctt_error_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288052/data/CLs/0.0001-0.003_20s1b1t--Ctt_error_list.pkl new file mode 100644 index 0000000..7e1f6a5 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288052/data/CLs/0.0001-0.003_20s1b1t--Ctt_error_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288052/data/CLs/0.0001-0.003_20s1b1t--Ctt_list.pkl b/data/CLs/finished/f1d1/-+/D-True/2288052/data/CLs/0.0001-0.003_20s1b1t--Ctt_list.pkl new file mode 100644 index 0000000..cf4a9ae --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288052/data/CLs/0.0001-0.003_20s1b1t--Ctt_list.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288052/data/CLs/0.0001-0.003_20s1b1t--pull_dic.pkl b/data/CLs/finished/f1d1/-+/D-True/2288052/data/CLs/0.0001-0.003_20s1b1t--pull_dic.pkl new file mode 100644 index 0000000..1263dc4 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288052/data/CLs/0.0001-0.003_20s1b1t--pull_dic.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288052/data/CLs/variab.pkl b/data/CLs/finished/f1d1/-+/D-True/2288052/data/CLs/variab.pkl new file mode 100644 index 0000000..bb90dc0 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288052/data/CLs/variab.pkl Binary files differ diff --git a/data/CLs/finished/f1d1/-+/D-True/2288052/helperfunctions.py b/data/CLs/finished/f1d1/-+/D-True/2288052/helperfunctions.py new file mode 100644 index 0000000..88e120f --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288052/helperfunctions.py @@ -0,0 +1,33 @@ +# some helperfunctions + +import matplotlib +matplotlib.use("agg") +import matplotlib.pyplot as plt + +#Dislpay time (e.g. while generating points) + +display_intervals = ( + ('w', 604800), # 60 * 60 * 24 * 7 + ('d', 86400), # 60 * 60 * 24 + ('h', 3600), # 60 * 60 + ('min', 60), + ('s', 1), + ) + +def display_time(seconds, granularity=2): + result = [] + + for name, count in display_intervals: + value = seconds // count + if value: + seconds -= value * count + if value == 1: + name = name.rstrip('s') + result.append("{} {}".format(value, name)) + return ', '.join(result[:granularity]) + +def prepare_plot(title): + plt.title(title) + plt.grid() + plt.legend(loc = 'best') + plt.xlabel("q") diff --git a/data/CLs/finished/f1d1/-+/D-True/2288052/pdg_const1.py b/data/CLs/finished/f1d1/-+/D-True/2288052/pdg_const1.py new file mode 100644 index 0000000..70b3f30 --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288052/pdg_const1.py @@ -0,0 +1,226 @@ +pdg = { + + + ###Particle masses### + + "mbstar" : 5415.4, + "mbstar0" : 5711.0, + "B0_M" : 5279.5, + "Bs_M" : 5366.7, + "Bplus_M" : 5279.3, + "Lb_M" : 5619.4, + "D0_M" : 1864.8, + "Dst_M" : 2010, + "pi_M" : 139.6, + "Jpsi_M" : 3096.9, + "Psi2s_M" : 3685.6, + "kaon_M" : 493.7, + "Ks_M" : 497.6, + "phi_M" : 1019.5, + "rho_M" : 775.26, + "rho_width" : 149.1, + "omega_M" : 782.65, + "omega_width" : 8.49, + + "muon_M" : 105.7, + "tau_M": 1776.86, + + "squark_M" : 95.0, + "bquark_M" : 4180.0, + "cquark_M" : 1275.0, + + "Bplus_tau" : 1.638e-12, + + ###Wilson coefficients### + + "C1" : -0.257, + "C2" : 1.009, + "C3" : -0.005, + "C4" : -0.078, + + "C7eff" : -0.306, + "C9eff" : 4.211, + "C10eff" : -4.103, + +# "C7eff": 0.0, +# "C9eff": 0.0, +# "C10eff": 0.0, + + ###Other constants + + "GF" : 1.1663787e-5, + "alpha_ew" : 1.0/137.0, + "Vts" : 0.0394, + "Vtb" : 1.019, + "number_of_decays": 5404696, + + #Formfactor z coefficients + + #"b0" : [0.285, 0.19, -0.17], + #"bplus" : [0.437, -1.41, -2.5], + #"bT" : [0.440, -1.47, -2.7] + + "b0" : [0.292, 0.281, 0.150], + "bplus" : [0.466, -0.885, -0.213], + "bT" : [0.460, -1.089, -1.114], + + "NR_BR": 4.37e-7, + "NR_auc": 0.00133, + + #Resonances format(mass, width, phase, scale) + + # pre scaling + +# "rho": (775.26, 149.0, -0.35, 1.0), + +# "omega": (782.7, 8.5, 0.26, 1.0), + +# "phi": (1019.46, 4.25, 0.5, 1.0), + +# "jpsi": (3096.0, 0.09, -1.5, 2e-2), +# "jpsi_auc": 0.2126825758464027, + +# "psi2s": (3686.0, 0.3, -1.5, 3.14e-3), +# "psi2s_auc": 2.802257483178487e-10, + +# "p3770": (3773.0, 27.2, -2.13, 1.0e-3), + +# "p4040": (4039.0, 80.0, -2.52, 2.0), + +# "p4160": (4191.0, 70.0, -1.9, 2.2), + +# "p4415": (4421.0, 62.0, -2.52, 1.0), + + + # after scaling (Phase combination --) + + # + # "rho": (743.2, 149.0, -0.22, 1.05), + # + # "omega": (782.7, 8.5, 0.38, 6.8), + # + # "phi": (1013.5, 4.25, 0.62, 19.2), + # + # "jpsi": (3096.1, 0.09, 1.63, 9897.0), + # "jpsi_auc": 0.2126825758464027, + # "jpsi_phase_unc": 0.05, + # + # "psi2s": (3686.0, 0.3, 1.8, 1396.0), + # "psi2s_auc": 0.0151332263, + # "psi2s_phase_unc": 0.1, + # + # "p3770": (3773.0, 27.2, -2.95, 2.5), + # + # "p4040": (4039.0, 80.0, -2.75, 1.01), + # + # "p4160": (4191.0, 70.0, -2.28, 2.2), + # + # "p4415": (4421.0, 62.0, -2.31, 1.24), + + # Phase combination of paper ++ + +# "rho": (743.2, 149.0, -0.35, 1.05), + +# "omega": (782.7, 8.5, 0.26, 6.8), + +# "phi": (1013.5, 4.25, 0.47, 19.2), + +# "jpsi": (3096.1, 0.09, -1.66, 9897.0), +# "jpsi_auc": 0.2126825758464027, +# "jpsi_phase_unc": 0.05, + +# "psi2s": (3686.0, 0.3, -1.93, 1396.0), +# "psi2s_auc": 0.0151332263, +# "psi2s_phase_unc": 0.1, + +# "p3770": (3773.0, 27.2, -2.13, 2.5), + +# "p4040": (4039.0, 80.0, -2.52, 1.01), + +# "p4160": (4191.0, 70.0, -1.90, 2.2), + +# "p4415": (4421.0, 62.0, -2.52, 1.24), + + # Phase combination of paper +- + +# "rho": (743.2, 149.0, -0.26, 1.05), + +# "omega": (782.7, 8.5, 0.35, 6.8), + +# "phi": (1013.5, 4.25, 0.58, 19.2), + +# "jpsi": (3096.1, 0.09, 1.47, 9897.0), +# "jpsi_auc": 0.2126825758464027, +# "jpsi_phase_unc": 0.05, + +# "psi2s": (3686.0, 0.3, -2.21, 1396.0), +# "psi2s_auc": 0.0151332263, +# "psi2s_phase_unc": 0.1, + +# "p3770": (3773.0, 27.2, -2.140, 2.5), + +# "p4040": (4039.0, 80.0, -2.64, 1.01), + +# "p4160": (4191.0, 70.0, -2.11, 2.2), + +# "p4415": (4421.0, 62.0, -2.42, 1.24), + + # Phase combination of paper -+ + + "rho": (743.2, 149.0, -0.30, 1.05), + + "omega": (782.7, 8.5, 0.30, 6.8), + + "phi": (1013.5, 4.25, 0.51, 19.2), + + "jpsi": (3096.1, 0.09, -1.5, 9897.0), + "jpsi_auc": 0.2126825758464027, + "jpsi_phase_unc": 0.05, + + "psi2s": (3686.0, 0.3, 2.08, 1396.0), + "psi2s_auc": 0.0151332263, + "psi2s_phase_unc": 0.1, + + "p3770": (3773.0, 27.2, -2.89, 2.5), + + "p4040": (4039.0, 80.0, -2.69, 1.01), + + "p4160": (4191.0, 70.0, -2.13, 2.2), + + "p4415": (4421.0, 62.0, -2.43, 1.24), + + + # zeroing resonances + +# "rho": (775.26, 149.0, -0.35, 0.0), +# "omega": (782.7, 8.5, 0.26, 0.0), +# "phi": (1019.46, 4.25, 0.5, 0.0), +# "jpsi": (3096.0, 0.09, -1.5, 0.0), +# "psi2s": (3686.0, 0.3, -1.5, 0.0), +# "p3770": (3773.0, 27.2, -2.13, 0.0), +# "p4040": (4039.0, 80.0, -2.52, 0.0), +# "p4160": (4147.0, 22.0, -1.9, 0.0), +# "p4415": (4421.0, 62.0, -2.52, 0.0), + + # 2P contributions format(mass, amp, phase) + +# "D_bar": ( + + #general + + "rho_BR": 1.7e-10, + "omega_BR": 4.9e-10, + "phi_BR": 2.5e-9, + "jpsi_BR": 6.02e-5, + "psi2s_BR": 4.97e-6, + "p3770_BR": 1.38e-9, + "p4040_BR": 4.2e-10, + "p4160_BR": 2.6e-9, + "p4415_BR": 6.1e-10, + +# Estimates + "Dbar_scale": 1.46, #with phase = pi + + "DDstar_scale": 2.41, #with phase = pi + + } diff --git a/data/CLs/finished/f1d1/-+/D-True/2288052/raremodel-nb.py b/data/CLs/finished/f1d1/-+/D-True/2288052/raremodel-nb.py new file mode 100644 index 0000000..c326c9c --- /dev/null +++ b/data/CLs/finished/f1d1/-+/D-True/2288052/raremodel-nb.py @@ -0,0 +1,2152 @@ +#!/usr/bin/env python +# coding: utf-8 + +# # Import + +# In[ ]: + + +import os + +# os.environ["CUDA_VISIBLE_DEVICES"] = "-1" +import random +import numpy as np +from pdg_const1 import pdg +import matplotlib +import matplotlib.pyplot as plt +import pickle as pkl +import sys +import time +from helperfunctions import display_time, prepare_plot +import cmath as c +import scipy.integrate as integrate +from scipy.optimize import fminbound +from array import array as arr +import collections +from itertools import compress +import tensorflow as tf +import zfit +from zfit import ztf +# from IPython.display import clear_output +import os +import tensorflow_probability as tfp +tfd = tfp.distributions + + +# In[ ]: + + +# chunksize = 10000 +# zfit.run.chunking.active = True +# zfit.run.chunking.max_n_points = chunksize + + +# # Build model and graphs +# ## Create graphs + +# In[ ]: + + + + + +# In[ ]: + + +def formfactor(q2, subscript, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2): #returns real value + #check if subscript is viable + + if subscript != "0" and subscript != "+" and subscript != "T": + raise ValueError('Wrong subscript entered, choose either 0, + or T') + + #get constants + + mK = ztf.constant(pdg['Ks_M']) + mbstar0 = ztf.constant(pdg["mbstar0"]) + mbstar = ztf.constant(pdg["mbstar"]) + + + mmu = ztf.constant(pdg['muon_M']) + mb = ztf.constant(pdg['bquark_M']) + ms = ztf.constant(pdg['squark_M']) + mB = ztf.constant(pdg['Bplus_M']) + + #N comes from derivation in paper + + N = 3 + + #some helperfunctions + + tpos = (mB - mK)**2 + tzero = (mB + mK)*(ztf.sqrt(mB)-ztf.sqrt(mK))**2 + + z_oben = ztf.sqrt(tpos - q2) - ztf.sqrt(tpos - tzero) + z_unten = ztf.sqrt(tpos - q2) + ztf.sqrt(tpos - tzero) + z = tf.divide(z_oben, z_unten) + + #calculate f0 + + if subscript == "0": + prefactor = 1/(1 - q2/(mbstar0**2)) + _sum = 0 + b0 = [b0_0, b0_1, b0_2] + + for i in range(N): + _sum += b0[i]*(tf.pow(z,i)) + + return ztf.to_complex(prefactor * _sum) + + #calculate f+ or fT + + else: + prefactor = 1/(1 - q2/(mbstar**2)) + _sum = 0 + + if subscript == "T": + bT = [bT_0, bT_1, bT_2] + for i in range(N): + _sum += bT[i] * (tf.pow(z, i) - ((-1)**(i-N)) * (i/N) * tf.pow(z, N)) + else: + bplus = [bplus_0, bplus_1, bplus_2] + for i in range(N): + _sum += bplus[i] * (tf.pow(z, i) - ((-1)**(i-N)) * (i/N) * tf.pow(z, N)) + + return ztf.to_complex(prefactor * _sum) + +def resonance(q, _mass, width, phase, scale): + + q2 = tf.pow(q, 2) + + mmu = ztf.constant(pdg['muon_M']) + + p = 0.5 * ztf.sqrt(q2 - 4*(mmu**2)) + + p0 = 0.5 * ztf.sqrt(_mass**2 - 4*mmu**2) + + gamma_j = tf.divide(p, q) * _mass * width / p0 + + #Calculate the resonance + + _top = tf.complex(_mass * width, ztf.constant(0.0)) + + _bottom = tf.complex(_mass**2 - q2, -_mass*gamma_j) + + com = _top/_bottom + + #Rotate by the phase + + r = ztf.to_complex(scale*tf.abs(com)) + + _phase = tf.angle(com) + + _phase += phase + + com = r * tf.exp(tf.complex(ztf.constant(0.0), _phase)) + + return com + + +def axiv_nonres(q, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2): + + GF = ztf.constant(pdg['GF']) + alpha_ew = ztf.constant(pdg['alpha_ew']) + Vtb = ztf.constant(pdg['Vtb']) + Vts = ztf.constant(pdg['Vts']) + C10eff = ztf.constant(pdg['C10eff']) + + mmu = ztf.constant(pdg['muon_M']) + mb = ztf.constant(pdg['bquark_M']) + ms = ztf.constant(pdg['squark_M']) + mK = ztf.constant(pdg['Ks_M']) + mB = ztf.constant(pdg['Bplus_M']) + + q2 = tf.pow(q, 2) + + #Some helperfunctions + + beta = 1. - 4. * mmu**2. / q2 + + kabs = ztf.sqrt(mB**2. + tf.pow(q2, 2)/mB**2. + mK**4./mB**2. - 2. * (mB**2. * mK**2. + mK**2. * q2 + mB**2. * q2) / mB**2.) + + #prefactor in front of whole bracket + + prefactor1 = GF**2. *alpha_ew**2. * (tf.abs(Vtb*Vts))**2. * kabs * beta / (128. * np.pi**5.) + + #left term in bracket + + bracket_left = 2./3. * tf.pow(kabs,2) * tf.pow(beta,2) * tf.pow(tf.abs(ztf.to_complex(C10eff)*formfactor(q2, "+", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2)),2) + + #middle term in bracket + + _top = 4. * mmu**2. * (mB**2. - mK**2.) * (mB**2. - mK**2.) + + _under = q2 * mB**2. + + bracket_middle = _top/_under *tf.pow(tf.abs(ztf.to_complex(C10eff) * formfactor(q2, "0", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2)), 2) + + #Note sqrt(q2) comes from derivation as we use q2 and plot q + + return prefactor1 * (bracket_left + bracket_middle) * 2 * q + +def vec(q, funcs, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2): + + q2 = tf.pow(q, 2) + + GF = ztf.constant(pdg['GF']) + alpha_ew = ztf.constant(pdg['alpha_ew']) + Vtb = ztf.constant(pdg['Vtb']) + Vts = ztf.constant(pdg['Vts']) + C7eff = ztf.constant(pdg['C7eff']) + + mmu = ztf.constant(pdg['muon_M']) + mb = ztf.constant(pdg['bquark_M']) + ms = ztf.constant(pdg['squark_M']) + mK = ztf.constant(pdg['Ks_M']) + mB = ztf.constant(pdg['Bplus_M']) + + #Some helperfunctions + + beta = 1. - 4. * mmu**2. / q2 + + kabs = ztf.sqrt(mB**2. + tf.pow(q2, 2)/mB**2. + mK**4./mB**2. - 2 * (mB**2 * mK**2 + mK**2 * q2 + mB**2 * q2) / mB**2) + + #prefactor in front of whole bracket + + prefactor1 = GF**2. *alpha_ew**2. * (tf.abs(Vtb*Vts))**2 * kabs * beta / (128. * np.pi**5.) + + #right term in bracket + + prefactor2 = tf.pow(kabs,2) * (1. - 1./3. * beta) + + abs_bracket = tf.pow(tf.abs(c9eff(q, funcs) * formfactor(q2, "+", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + ztf.to_complex(2.0 * C7eff * (mb + ms)/(mB + mK)) * formfactor(q2, "T", b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2)),2) + + bracket_right = prefactor2 * abs_bracket + + #Note sqrt(q2) comes from derivation as we use q2 and plot q + + return prefactor1 * bracket_right * 2 * q + +def c9eff(q, funcs): + + C9eff_nr = ztf.to_complex(ztf.constant(pdg['C9eff'])) + + c9 = C9eff_nr + funcs + + return c9 + + +# In[ ]: + + +def G(y): + + def inner_rect_bracket(q): + return tf.log(ztf.to_complex((1+tf.sqrt(q))/(1-tf.sqrt(q)))-tf.complex(ztf.constant(0), -1*ztf.constant(np.pi))) + + def inner_right(q): + return ztf.to_complex(2 * tf.atan(1/tf.sqrt(tf.math.real(-q)))) + + big_bracket = tf.where(tf.math.real(y) > ztf.constant(0.0), inner_rect_bracket(y), inner_right(y)) + + return ztf.to_complex(tf.sqrt(tf.abs(y))) * big_bracket + +def h_S(m, q): + + return ztf.to_complex(2) - G(ztf.to_complex(1) - ztf.to_complex(4*tf.pow(m, 2)) / ztf.to_complex(tf.pow(q, 2))) + +def h_P(m, q): + + return ztf.to_complex(2/3) + (ztf.to_complex(1) - ztf.to_complex(4*tf.pow(m, 2)) / ztf.to_complex(tf.pow(q, 2))) * h_S(m,q) + +def two_p_ccbar(mD, m_D_bar, m_D_star, q): + + + #Load constants + nu_D_bar = ztf.to_complex(pdg["nu_D_bar"]) + nu_D = ztf.to_complex(pdg["nu_D"]) + nu_D_star = ztf.to_complex(pdg["nu_D_star"]) + + phase_D_bar = ztf.to_complex(pdg["phase_D_bar"]) + phase_D = ztf.to_complex(pdg["phase_D"]) + phase_D_star = ztf.to_complex(pdg["phase_D_star"]) + + #Calculation + left_part = nu_D_bar * tf.exp(tf.complex(ztf.constant(0.0), phase_D_bar)) * h_S(m_D_bar, q) + + right_part_D = nu_D * tf.exp(tf.complex(ztf.constant(0.0), phase_D)) * h_P(m_D, q) + + right_part_D_star = nu_D_star * tf.exp(tf.complex(ztf.constant(0.0), phase_D_star)) * h_P(m_D_star, q) + + return left_part + right_part_D + right_part_D_star + + +# ## Build pdf + +# In[ ]: + + +class total_pdf_cut(zfit.pdf.ZPDF): + _N_OBS = 1 # dimension, can be omitted + _PARAMS = ['b0_0', 'b0_1', 'b0_2', + 'bplus_0', 'bplus_1', 'bplus_2', + 'bT_0', 'bT_1', 'bT_2', + 'rho_mass', 'rho_scale', 'rho_phase', 'rho_width', + 'jpsi_mass', 'jpsi_scale', 'jpsi_phase', 'jpsi_width', + 'psi2s_mass', 'psi2s_scale', 'psi2s_phase', 'psi2s_width', + 'p3770_mass', 'p3770_scale', 'p3770_phase', 'p3770_width', + 'p4040_mass', 'p4040_scale', 'p4040_phase', 'p4040_width', + 'p4160_mass', 'p4160_scale', 'p4160_phase', 'p4160_width', + 'p4415_mass', 'p4415_scale', 'p4415_phase', 'p4415_width', + 'omega_mass', 'omega_scale', 'omega_phase', 'omega_width', + 'phi_mass', 'phi_scale', 'phi_phase', 'phi_width', + 'Dbar_mass', 'Dbar_scale', 'Dbar_phase', + 'Dstar_mass', 'DDstar_scale', 'DDstar_phase', 'D_mass', + 'tau_mass', 'C_tt'] +# the name of the parameters + + def _unnormalized_pdf(self, x): + + x = x.unstack_x() + + b0 = [self.params['b0_0'], self.params['b0_1'], self.params['b0_2']] + bplus = [self.params['bplus_0'], self.params['bplus_1'], self.params['bplus_2']] + bT = [self.params['bT_0'], self.params['bT_1'], self.params['bT_2']] + + def rho_res(q): + return resonance(q, _mass = self.params['rho_mass'], scale = self.params['rho_scale'], + phase = self.params['rho_phase'], width = self.params['rho_width']) + + def omega_res(q): + return resonance(q, _mass = self.params['omega_mass'], scale = self.params['omega_scale'], + phase = self.params['omega_phase'], width = self.params['omega_width']) + + def phi_res(q): + return resonance(q, _mass = self.params['phi_mass'], scale = self.params['phi_scale'], + phase = self.params['phi_phase'], width = self.params['phi_width']) + + def jpsi_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['jpsi_mass'], 2)) * resonance(q, _mass = self.params['jpsi_mass'], + scale = self.params['jpsi_scale'], + phase = self.params['jpsi_phase'], + width = self.params['jpsi_width']) + def psi2s_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['psi2s_mass'], 2)) * resonance(q, _mass = self.params['psi2s_mass'], + scale = self.params['psi2s_scale'], + phase = self.params['psi2s_phase'], + width = self.params['psi2s_width']) + def p3770_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p3770_mass'], 2)) * resonance(q, _mass = self.params['p3770_mass'], + scale = self.params['p3770_scale'], + phase = self.params['p3770_phase'], + width = self.params['p3770_width']) + + def p4040_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4040_mass'], 2)) * resonance(q, _mass = self.params['p4040_mass'], + scale = self.params['p4040_scale'], + phase = self.params['p4040_phase'], + width = self.params['p4040_width']) + + def p4160_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4160_mass'], 2)) * resonance(q, _mass = self.params['p4160_mass'], + scale = self.params['p4160_scale'], + phase = self.params['p4160_phase'], + width = self.params['p4160_width']) + + def p4415_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4415_mass'], 2)) * resonance(q, _mass = self.params['p4415_mass'], + scale = self.params['p4415_scale'], + phase = self.params['p4415_phase'], + width = self.params['p4415_width']) + + def P2_D(q): + Dbar_contrib = ztf.to_complex(self.params['Dbar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['Dbar_phase']))*ztf.to_complex(h_S(self.params['Dbar_mass'], q)) + DDstar_contrib = ztf.to_complex(self.params['DDstar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['DDstar_phase']))*(ztf.to_complex(h_P(self.params['Dstar_mass'], q)) + ztf.to_complex(h_P(self.params['D_mass'], q))) + return Dbar_contrib + DDstar_contrib + + def ttau_cusp(q): + return ztf.to_complex(self.params['C_tt'])*(ztf.to_complex((h_S(self.params['tau_mass'], q))) - ztf.to_complex(h_P(self.params['tau_mass'], q))) + + + funcs = rho_res(x) + omega_res(x) + phi_res(x) + jpsi_res(x) + psi2s_res(x) + p3770_res(x) + p4040_res(x)+ p4160_res(x) + p4415_res(x) + P2_D(x) + ttau_cusp(x) + + vec_f = vec(x, funcs, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + axiv_nr = axiv_nonres(x, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + tot = vec_f + axiv_nr + + #Cut out jpsi and psi2s + + tot = tf.where(tf.math.logical_or(x < ztf.constant(jpsi_mass-60.), x > ztf.constant(jpsi_mass+70.)), tot, 0.0*tot) + + tot = tf.where(tf.math.logical_or(x < ztf.constant(psi2s_mass-50.), x > ztf.constant(psi2s_mass+50.)), tot, 0.0*tot) + + return tot + +class total_pdf_full(zfit.pdf.ZPDF): + _N_OBS = 1 # dimension, can be omitted + _PARAMS = ['b0_0', 'b0_1', 'b0_2', + 'bplus_0', 'bplus_1', 'bplus_2', + 'bT_0', 'bT_1', 'bT_2', + 'rho_mass', 'rho_scale', 'rho_phase', 'rho_width', + 'jpsi_mass', 'jpsi_scale', 'jpsi_phase', 'jpsi_width', + 'psi2s_mass', 'psi2s_scale', 'psi2s_phase', 'psi2s_width', + 'p3770_mass', 'p3770_scale', 'p3770_phase', 'p3770_width', + 'p4040_mass', 'p4040_scale', 'p4040_phase', 'p4040_width', + 'p4160_mass', 'p4160_scale', 'p4160_phase', 'p4160_width', + 'p4415_mass', 'p4415_scale', 'p4415_phase', 'p4415_width', + 'omega_mass', 'omega_scale', 'omega_phase', 'omega_width', + 'phi_mass', 'phi_scale', 'phi_phase', 'phi_width', + 'Dbar_mass', 'Dbar_scale', 'Dbar_phase', + 'Dstar_mass', 'DDstar_scale', 'DDstar_phase', 'D_mass', + 'tau_mass', 'C_tt'] +# the name of the parameters + + def _unnormalized_pdf(self, x): + + x = x.unstack_x() + + b0 = [self.params['b0_0'], self.params['b0_1'], self.params['b0_2']] + bplus = [self.params['bplus_0'], self.params['bplus_1'], self.params['bplus_2']] + bT = [self.params['bT_0'], self.params['bT_1'], self.params['bT_2']] + + def rho_res(q): + return resonance(q, _mass = self.params['rho_mass'], scale = self.params['rho_scale'], + phase = self.params['rho_phase'], width = self.params['rho_width']) + + def omega_res(q): + return resonance(q, _mass = self.params['omega_mass'], scale = self.params['omega_scale'], + phase = self.params['omega_phase'], width = self.params['omega_width']) + + def phi_res(q): + return resonance(q, _mass = self.params['phi_mass'], scale = self.params['phi_scale'], + phase = self.params['phi_phase'], width = self.params['phi_width']) + + def jpsi_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['jpsi_mass'], 2)) * resonance(q, _mass = self.params['jpsi_mass'], + scale = self.params['jpsi_scale'], + phase = self.params['jpsi_phase'], + width = self.params['jpsi_width']) + def psi2s_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['psi2s_mass'], 2)) * resonance(q, _mass = self.params['psi2s_mass'], + scale = self.params['psi2s_scale'], + phase = self.params['psi2s_phase'], + width = self.params['psi2s_width']) + def p3770_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p3770_mass'], 2)) * resonance(q, _mass = self.params['p3770_mass'], + scale = self.params['p3770_scale'], + phase = self.params['p3770_phase'], + width = self.params['p3770_width']) + + def p4040_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4040_mass'], 2)) * resonance(q, _mass = self.params['p4040_mass'], + scale = self.params['p4040_scale'], + phase = self.params['p4040_phase'], + width = self.params['p4040_width']) + + def p4160_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4160_mass'], 2)) * resonance(q, _mass = self.params['p4160_mass'], + scale = self.params['p4160_scale'], + phase = self.params['p4160_phase'], + width = self.params['p4160_width']) + + def p4415_res(q): + return ztf.to_complex(tf.pow(q, 2) / tf.pow(self.params['p4415_mass'], 2)) * resonance(q, _mass = self.params['p4415_mass'], + scale = self.params['p4415_scale'], + phase = self.params['p4415_phase'], + width = self.params['p4415_width']) + + def P2_D(q): + Dbar_contrib = ztf.to_complex(self.params['Dbar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['Dbar_phase']))*ztf.to_complex(h_S(self.params['Dbar_mass'], q)) + DDstar_contrib = ztf.to_complex(self.params['DDstar_scale'])*tf.exp(tf.complex(ztf.constant(0.0), self.params['DDstar_phase']))*(ztf.to_complex(h_P(self.params['Dstar_mass'], q)) + ztf.to_complex(h_P(self.params['D_mass'], q))) + return Dbar_contrib + DDstar_contrib + + def ttau_cusp(q): + return ztf.to_complex(self.params['C_tt'])*(ztf.to_complex((h_S(self.params['tau_mass'], q))) - ztf.to_complex(h_P(self.params['tau_mass'], q))) + + + funcs = rho_res(x) + omega_res(x) + phi_res(x) + jpsi_res(x) + psi2s_res(x) + p3770_res(x) + p4040_res(x)+ p4160_res(x) + p4415_res(x) + P2_D(x) + ttau_cusp(x) + + vec_f = vec(x, funcs, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + axiv_nr = axiv_nonres(x, b0_0, b0_1, b0_2, bplus_0, bplus_1, bplus_2, bT_0, bT_1, bT_2) + + tot = vec_f + axiv_nr + + #Cut out jpsi and psi2s + +# tot = tf.where(tf.math.logical_or(x < ztf.constant(jpsi_mass-60.), x > ztf.constant(jpsi_mass+70.)), tot, 0.0*tot) + +# tot = tf.where(tf.math.logical_or(x < ztf.constant(psi2s_mass-50.), x > ztf.constant(psi2s_mass+50.)), tot, 0.0*tot) + + return tot + + +# ## Setup parameters + +# In[ ]: + + +# formfactors + +b0_0 = zfit.Parameter("b0_0", ztf.constant(0.292), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +b0_1 = zfit.Parameter("b0_1", ztf.constant(0.281), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +b0_2 = zfit.Parameter("b0_2", ztf.constant(0.150), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) + +bplus_0 = zfit.Parameter("bplus_0", ztf.constant(0.466), lower_limit = -2.0, upper_limit= 2.0) +bplus_1 = zfit.Parameter("bplus_1", ztf.constant(-0.885), lower_limit = -2.0, upper_limit= 2.0) +bplus_2 = zfit.Parameter("bplus_2", ztf.constant(-0.213), lower_limit = -2.0, upper_limit= 2.0) + +bT_0 = zfit.Parameter("bT_0", ztf.constant(0.460), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +bT_1 = zfit.Parameter("bT_1", ztf.constant(-1.089), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) +bT_2 = zfit.Parameter("bT_2", ztf.constant(-1.114), floating = False) #, lower_limit = -2.0, upper_limit= 2.0) + + +#rho + +rho_mass, rho_width, rho_phase, rho_scale = pdg["rho"] + +rho_m = zfit.Parameter("rho_m", ztf.constant(rho_mass), floating = False) #lower_limit = rho_mass - rho_width, upper_limit = rho_mass + rho_width) +rho_w = zfit.Parameter("rho_w", ztf.constant(rho_width), floating = False) +rho_p = zfit.Parameter("rho_p", ztf.constant(rho_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +rho_s = zfit.Parameter("rho_s", ztf.constant(rho_scale), lower_limit=rho_scale-np.sqrt(rho_scale), upper_limit=rho_scale+np.sqrt(rho_scale)) + +#omega + +omega_mass, omega_width, omega_phase, omega_scale = pdg["omega"] + +omega_m = zfit.Parameter("omega_m", ztf.constant(omega_mass), floating = False) +omega_w = zfit.Parameter("omega_w", ztf.constant(omega_width), floating = False) +omega_p = zfit.Parameter("omega_p", ztf.constant(omega_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +omega_s = zfit.Parameter("omega_s", ztf.constant(omega_scale), lower_limit=omega_scale-np.sqrt(omega_scale), upper_limit=omega_scale+np.sqrt(omega_scale)) + + +#phi + +phi_mass, phi_width, phi_phase, phi_scale = pdg["phi"] + +phi_m = zfit.Parameter("phi_m", ztf.constant(phi_mass), floating = False) +phi_w = zfit.Parameter("phi_w", ztf.constant(phi_width), floating = False) +phi_p = zfit.Parameter("phi_p", ztf.constant(phi_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +phi_s = zfit.Parameter("phi_s", ztf.constant(phi_scale), lower_limit=phi_scale-np.sqrt(phi_scale), upper_limit=phi_scale+np.sqrt(phi_scale)) + +#jpsi + +jpsi_mass, jpsi_width, jpsi_phase, jpsi_scale = pdg["jpsi"] + +jpsi_m = zfit.Parameter("jpsi_m", ztf.constant(jpsi_mass), floating = False) +jpsi_w = zfit.Parameter("jpsi_w", ztf.constant(jpsi_width), floating = False) +jpsi_p = zfit.Parameter("jpsi_p", ztf.constant(jpsi_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +jpsi_s = zfit.Parameter("jpsi_s", ztf.constant(jpsi_scale), floating = False) #, lower_limit=jpsi_scale-np.sqrt(jpsi_scale), upper_limit=jpsi_scale+np.sqrt(jpsi_scale)) + +#psi2s + +psi2s_mass, psi2s_width, psi2s_phase, psi2s_scale = pdg["psi2s"] + +psi2s_m = zfit.Parameter("psi2s_m", ztf.constant(psi2s_mass), floating = False) +psi2s_w = zfit.Parameter("psi2s_w", ztf.constant(psi2s_width), floating = False) +psi2s_p = zfit.Parameter("psi2s_p", ztf.constant(psi2s_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +psi2s_s = zfit.Parameter("psi2s_s", ztf.constant(psi2s_scale), floating = False) #, lower_limit=psi2s_scale-np.sqrt(psi2s_scale), upper_limit=psi2s_scale+np.sqrt(psi2s_scale)) + +#psi(3770) + +p3770_mass, p3770_width, p3770_phase, p3770_scale = pdg["p3770"] + +p3770_m = zfit.Parameter("p3770_m", ztf.constant(p3770_mass), floating = False) +p3770_w = zfit.Parameter("p3770_w", ztf.constant(p3770_width), floating = False) +p3770_p = zfit.Parameter("p3770_p", ztf.constant(p3770_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p3770_s = zfit.Parameter("p3770_s", ztf.constant(p3770_scale), lower_limit=p3770_scale-np.sqrt(p3770_scale), upper_limit=p3770_scale+np.sqrt(p3770_scale)) + +#psi(4040) + +p4040_mass, p4040_width, p4040_phase, p4040_scale = pdg["p4040"] + +p4040_m = zfit.Parameter("p4040_m", ztf.constant(p4040_mass), floating = False) +p4040_w = zfit.Parameter("p4040_w", ztf.constant(p4040_width), floating = False) +p4040_p = zfit.Parameter("p4040_p", ztf.constant(p4040_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p4040_s = zfit.Parameter("p4040_s", ztf.constant(p4040_scale), lower_limit=p4040_scale-np.sqrt(p4040_scale), upper_limit=p4040_scale+np.sqrt(p4040_scale)) + +#psi(4160) + +p4160_mass, p4160_width, p4160_phase, p4160_scale = pdg["p4160"] + +p4160_m = zfit.Parameter("p4160_m", ztf.constant(p4160_mass), floating = False) +p4160_w = zfit.Parameter("p4160_w", ztf.constant(p4160_width), floating = False) +p4160_p = zfit.Parameter("p4160_p", ztf.constant(p4160_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p4160_s = zfit.Parameter("p4160_s", ztf.constant(p4160_scale), lower_limit=p4160_scale-np.sqrt(p4160_scale), upper_limit=p4160_scale+np.sqrt(p4160_scale)) + +#psi(4415) + +p4415_mass, p4415_width, p4415_phase, p4415_scale = pdg["p4415"] + +p4415_m = zfit.Parameter("p4415_m", ztf.constant(p4415_mass), floating = False) +p4415_w = zfit.Parameter("p4415_w", ztf.constant(p4415_width), floating = False) +p4415_p = zfit.Parameter("p4415_p", ztf.constant(p4415_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi) +p4415_s = zfit.Parameter("p4415_s", ztf.constant(p4415_scale), lower_limit=p4415_scale-np.sqrt(p4415_scale), upper_limit=p4415_scale+np.sqrt(p4415_scale)) + + +# ## Dynamic generation of 2 particle contribution + +# In[ ]: + + +m_c = 1300 + +Dbar_phase = 0.0 +DDstar_phase = 0.0 +Dstar_mass = pdg['Dst_M'] +Dbar_mass = pdg['D0_M'] +D_mass = pdg['D0_M'] + +Dbar_s = zfit.Parameter("Dbar_s", ztf.constant(0.0), lower_limit=-0.3, upper_limit=0.3) +Dbar_m = zfit.Parameter("Dbar_m", ztf.constant(Dbar_mass), floating = False) +Dbar_p = zfit.Parameter("Dbar_p", ztf.constant(Dbar_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi)#, floating = False) +DDstar_s = zfit.Parameter("DDstar_s", ztf.constant(0.0), lower_limit=-0.3, upper_limit=0.3)#, floating = False) +Dstar_m = zfit.Parameter("Dstar_m", ztf.constant(Dstar_mass), floating = False) +D_m = zfit.Parameter("D_m", ztf.constant(D_mass), floating = False) +DDstar_p = zfit.Parameter("DDstar_p", ztf.constant(DDstar_phase), lower_limit=-2*np.pi, upper_limit=2*np.pi)#, floating = False) + + +# ## Tau parameters + +# In[ ]: + + +tau_m = zfit.Parameter("tau_m", ztf.constant(pdg['tau_M']), floating = False) +Ctt = zfit.Parameter("Ctt", ztf.constant(0.0), lower_limit=-2.5, upper_limit=2.5) + + +# ## Load data + +# In[ ]: + + +x_min = 2*pdg['muon_M'] +x_max = (pdg["Bplus_M"]-pdg["Ks_M"]-0.1) + +# # Full spectrum + +obs_toy = zfit.Space('q', limits = (x_min, x_max)) + +# Jpsi and Psi2s cut out + +obs1 = zfit.Space('q', limits = (x_min, jpsi_mass - 60.)) +obs2 = zfit.Space('q', limits = (jpsi_mass + 70., psi2s_mass - 50.)) +obs3 = zfit.Space('q', limits = (psi2s_mass + 50., x_max)) + +obs_fit = obs1 + obs2 + obs3 + +# with open(r"./data/slim_points/slim_points_toy_0_range({0}-{1}).pkl".format(int(x_min), int(x_max)), "rb") as input_file: +# part_set = pkl.load(input_file) + +# x_part = part_set['x_part'] + +# x_part = x_part.astype('float64') + +# data = zfit.data.Data.from_numpy(array=x_part, obs=obs) + + +# ## Setup pdf + +# In[ ]: + + +total_f = total_pdf_cut(obs=obs_toy, jpsi_mass = jpsi_m, jpsi_scale = jpsi_s, jpsi_phase = jpsi_p, jpsi_width = jpsi_w, + psi2s_mass = psi2s_m, psi2s_scale = psi2s_s, psi2s_phase = psi2s_p, psi2s_width = psi2s_w, + p3770_mass = p3770_m, p3770_scale = p3770_s, p3770_phase = p3770_p, p3770_width = p3770_w, + p4040_mass = p4040_m, p4040_scale = p4040_s, p4040_phase = p4040_p, p4040_width = p4040_w, + p4160_mass = p4160_m, p4160_scale = p4160_s, p4160_phase = p4160_p, p4160_width = p4160_w, + p4415_mass = p4415_m, p4415_scale = p4415_s, p4415_phase = p4415_p, p4415_width = p4415_w, + rho_mass = rho_m, rho_scale = rho_s, rho_phase = rho_p, rho_width = rho_w, + omega_mass = omega_m, omega_scale = omega_s, omega_phase = omega_p, omega_width = omega_w, + phi_mass = phi_m, phi_scale = phi_s, phi_phase = phi_p, phi_width = phi_w, + Dstar_mass = Dstar_m, DDstar_scale = DDstar_s, DDstar_phase = DDstar_p, D_mass = D_m, + Dbar_mass = Dbar_m, Dbar_scale = Dbar_s, Dbar_phase = Dbar_p, + tau_mass = tau_m, C_tt = Ctt, b0_0 = b0_0, b0_1 = b0_1, b0_2 = b0_2, + bplus_0 = bplus_0, bplus_1 = bplus_1, bplus_2 = bplus_2, + bT_0 = bT_0, bT_1 = bT_1, bT_2 = bT_2) + +total_f_fit = total_pdf_full(obs=obs_fit, jpsi_mass = jpsi_m, jpsi_scale = jpsi_s, jpsi_phase = jpsi_p, jpsi_width = jpsi_w, + psi2s_mass = psi2s_m, psi2s_scale = psi2s_s, psi2s_phase = psi2s_p, psi2s_width = psi2s_w, + p3770_mass = p3770_m, p3770_scale = p3770_s, p3770_phase = p3770_p, p3770_width = p3770_w, + p4040_mass = p4040_m, p4040_scale = p4040_s, p4040_phase = p4040_p, p4040_width = p4040_w, + p4160_mass = p4160_m, p4160_scale = p4160_s, p4160_phase = p4160_p, p4160_width = p4160_w, + p4415_mass = p4415_m, p4415_scale = p4415_s, p4415_phase = p4415_p, p4415_width = p4415_w, + rho_mass = rho_m, rho_scale = rho_s, rho_phase = rho_p, rho_width = rho_w, + omega_mass = omega_m, omega_scale = omega_s, omega_phase = omega_p, omega_width = omega_w, + phi_mass = phi_m, phi_scale = phi_s, phi_phase = phi_p, phi_width = phi_w, + Dstar_mass = Dstar_m, DDstar_scale = DDstar_s, DDstar_phase = DDstar_p, D_mass = D_m, + Dbar_mass = Dbar_m, Dbar_scale = Dbar_s, Dbar_phase = Dbar_p, + tau_mass = tau_m, C_tt = Ctt, b0_0 = b0_0, b0_1 = b0_1, b0_2 = b0_2, + bplus_0 = bplus_0, bplus_1 = bplus_1, bplus_2 = bplus_2, + bT_0 = bT_0, bT_1 = bT_1, bT_2 = bT_2) + +# print(total_pdf.obs) + +# print(calcs_test) + +# for param in total_f.get_dependents(): +# print(zfit.run(param)) + + +# In[ ]: + + +# total_f_fit.normalization(obs_fit) + + +# ## Test if graphs actually work and compute values + +# In[ ]: + + +# def total_test_tf(xq): + +# def jpsi_res(q): +# return resonance(q, jpsi_m, jpsi_s, jpsi_p, jpsi_w) + +# def psi2s_res(q): +# return resonance(q, psi2s_m, psi2s_s, psi2s_p, psi2s_w) + +# def cusp(q): +# return bifur_gauss(q, cusp_m, sig_L, sig_R, cusp_s) + +# funcs = jpsi_res(xq) + psi2s_res(xq) + cusp(xq) + +# vec_f = vec(xq, funcs) + +# axiv_nr = axiv_nonres(xq) + +# tot = vec_f + axiv_nr + +# return tot + +# def jpsi_res(q): +# return resonance(q, jpsi_m, jpsi_s, jpsi_p, jpsi_w) + +# calcs = zfit.run(total_test_tf(x_part)) + + + +test_q = np.linspace(x_min, x_max, int(2e6)) + +probs = total_f_fit.pdf(test_q, norm_range=False) + +calcs_test = zfit.run(probs) + +Ctt.set_value(0.5) + +calcs_test1 = zfit.run(probs) + +Ctt.set_value(0.0) + +Dbar_s.set_value(0.3) + +DDstar_s.set_value(0.3) + +calcs_test2 = zfit.run(probs) +# res_y = zfit.run(jpsi_res(test_q)) +# b0 = [b0_0, b0_1, b0_2] +# bplus = [bplus_0, bplus_1, bplus_2] +# bT = [bT_0, bT_1, bT_2] +# f0_y = zfit.run(tf.math.real(formfactor(test_q,"0", b0, bplus, bT))) +# fplus_y = zfit.run(tf.math.real(formfactor(test_q,"+", b0, bplus, bT))) +# fT_y = zfit.run(tf.math.real(formfactor(test_q,"T", b0, bplus, bT))) + + +# In[ ]: + + +plt.clf() +# plt.plot(x_part, calcs, '.') +plt.plot(test_q, calcs_test, label = 'pdf (Ctt = 0.0)') +plt.plot(test_q, calcs_test1, label = 'pdf (Ctt = 0.5)') +plt.plot(test_q, calcs_test2, label = 'pdf (D-contribs = 0.3)') +# plt.plot(test_q, f0_y, label = '0') +# plt.plot(test_q, fT_y, label = 'T') +# plt.plot(test_q, fplus_y, label = '+') +# plt.plot(test_q, res_y, label = 'res') +plt.legend() +plt.ylim(0.0, 1.5e-6) +# plt.yscale('log') +# plt.xlim(770, 785) +plt.savefig('test.png') +# print(jpsi_width) + + +# In[ ]: + + + + +# probs = mixture.prob(test_q) +# probs_np = zfit.run(probs) +# probs_np *= np.max(calcs_test) / np.max(probs_np) +# plt.figure() +# plt.semilogy(test_q, probs_np,label="importance sampling") +# plt.semilogy(test_q, calcs_test, label = 'pdf') + + +# In[ ]: + + +# 0.213/(0.00133+0.213+0.015) + + +# ## Adjust scaling of different parts + +# In[ ]: + + +total_f.update_integration_options(draws_per_dim=2000000, mc_sampler=None) +# inte = total_f.integrate(limits = (950., 1050.), norm_range=False) +# inte_fl = zfit.run(inte) +# print(inte_fl/4500) +# print(pdg["jpsi_BR"]/pdg["NR_BR"], inte_fl*pdg["psi2s_auc"]/pdg["NR_auc"]) + + +# In[ ]: + + +# # print("jpsi:", inte_fl) +# # print("Increase am by factor:", np.sqrt(pdg["jpsi_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) +# # print("New amp:", pdg["jpsi"][3]*np.sqrt(pdg["jpsi_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) + +# # print("psi2s:", inte_fl) +# # print("Increase am by factor:", np.sqrt(pdg["psi2s_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) +# # print("New amp:", pdg["psi2s"][3]*np.sqrt(pdg["psi2s_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) + +# name = "phi" + +# print(name+":", inte_fl) +# print("Increase am by factor:", np.sqrt(pdg[name+"_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) +# print("New amp:", pdg[name][0]*np.sqrt(pdg[name+"_BR"]/pdg["NR_BR"]*pdg["NR_auc"]/inte_fl)) + + +# print(x_min) +# print(x_max) +# # total_f.update_integration_options(draws_per_dim=2000000, mc_sampler=None) +# total_f.update_integration_options(mc_sampler=lambda dim, num_results, +# dtype: tf.random_uniform(maxval=1., shape=(num_results, dim), dtype=dtype), +# draws_per_dim=1000000) +# # _ = [] + +# # for i in range(10): + +# # inte = total_f.integrate(limits = (x_min, x_max)) +# # inte_fl = zfit.run(inte) +# # print(inte_fl) +# # _.append(inte_fl) + +# # print("mean:", np.mean(_)) + +# _ = time.time() + +# inte = total_f.integrate(limits = (x_min, x_max)) +# inte_fl = zfit.run(inte) +# print(inte_fl) +# print("Time taken: {}".format(display_time(int(time.time() - _)))) + +# print(pdg['NR_BR']/pdg['NR_auc']*inte_fl) +# print(0.25**2*4.2/1000) + + +# # Sampling +# ## Mixture distribution for sampling + +# In[ ]: + + + + +# print(list_of_borders[:9]) +# print(list_of_borders[-9:]) + + +class UniformSampleAndWeights(zfit.util.execution.SessionHolderMixin): + def __call__(self, limits, dtype, n_to_produce): + # n_to_produce = tf.cast(n_to_produce, dtype=tf.int32) + low, high = limits.limit1d + low = tf.cast(low, dtype=dtype) + high = tf.cast(high, dtype=dtype) +# uniform = tfd.Uniform(low=low, high=high) +# uniformjpsi = tfd.Uniform(low=tf.constant(3080, dtype=dtype), high=tf.constant(3112, dtype=dtype)) +# uniformpsi2s = tfd.Uniform(low=tf.constant(3670, dtype=dtype), high=tf.constant(3702, dtype=dtype)) + +# list_of_borders = [] +# _p = [] +# splits = 10 + +# _ = np.linspace(x_min, x_max, splits) + +# for i in range(splits): +# list_of_borders.append(tf.constant(_[i], dtype=dtype)) +# _p.append(tf.constant(1/splits, dtype=dtype)) + +# mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=_p[:(splits-1)]), +# components_distribution=tfd.Uniform(low=list_of_borders[:(splits-1)], +# high=list_of_borders[-(splits-1):])) + mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=[tf.constant(0.05, dtype=dtype), + tf.constant(0.93, dtype=dtype), + tf.constant(0.05, dtype=dtype), + tf.constant(0.065, dtype=dtype), + tf.constant(0.04, dtype=dtype), + tf.constant(0.05, dtype=dtype)]), + components_distribution=tfd.Uniform(low=[tf.constant(x_min, dtype=dtype), + tf.constant(3090, dtype=dtype), + tf.constant(3681, dtype=dtype), + tf.constant(3070, dtype=dtype), + tf.constant(1000, dtype=dtype), + tf.constant(3660, dtype=dtype)], + high=[tf.constant(x_max, dtype=dtype), + tf.constant(3102, dtype=dtype), + tf.constant(3691, dtype=dtype), + tf.constant(3110, dtype=dtype), + tf.constant(1040, dtype=dtype), + tf.constant(3710, dtype=dtype)])) +# dtype = tf.float64 +# mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=[tf.constant(0.04, dtype=dtype), +# tf.constant(0.90, dtype=dtype), +# tf.constant(0.02, dtype=dtype), +# tf.constant(0.07, dtype=dtype), +# tf.constant(0.02, dtype=dtype)]), +# components_distribution=tfd.Uniform(low=[tf.constant(x_min, dtype=dtype), +# tf.constant(3089, dtype=dtype), +# tf.constant(3103, dtype=dtype), +# tf.constant(3681, dtype=dtype), +# tf.constant(3691, dtype=dtype)], +# high=[tf.constant(3089, dtype=dtype), +# tf.constant(3103, dtype=dtype), +# tf.constant(3681, dtype=dtype), +# tf.constant(3691, dtype=dtype), +# tf.constant(x_max, dtype=dtype)])) +# mixture = tfd.Uniform(tf.constant(x_min, dtype=dtype), tf.constant(x_max, dtype=dtype)) +# sample = tf.random.uniform((n_to_produce, 1), dtype=dtype) + sample = mixture.sample((n_to_produce, 1)) +# sample = tf.random.uniform((n_to_produce, 1), dtype=dtype) + weights = mixture.prob(sample)[:,0] +# weights = tf.broadcast_to(tf.constant(1., dtype=dtype), shape=(n_to_produce,)) + # sample = tf.expand_dims(sample, axis=-1) +# print(sample, weights) + +# weights = tf.ones(shape=(n_to_produce,), dtype=dtype) + weights_max = None + thresholds = tf.random_uniform(shape=(n_to_produce,), dtype=dtype) + return sample, thresholds, weights, weights_max, n_to_produce + + +# In[ ]: + + +# total_f._sample_and_weights = UniformSampleAndWeights + + +# In[ ]: + + +# 0.00133/(0.00133+0.213+0.015)*(x_max-3750)/(x_max-x_min) + + +# In[ ]: + + +# zfit.settings.set_verbosity(10) + + +# In[ ]: + + +# # zfit.run.numeric_checks = False + +# nr_of_toys = 1 +# nevents = int(pdg["number_of_decays"]) +# nevents = pdg["number_of_decays"] +# event_stack = 1000000 +# # zfit.settings.set_verbosity(10) +# calls = int(nevents/event_stack + 1) + +# total_samp = [] + +# start = time.time() + +# sampler = total_f.create_sampler(n=event_stack) + +# for toy in range(nr_of_toys): + +# dirName = 'data/zfit_toys/toy_{0}'.format(toy) + +# if not os.path.exists(dirName): +# os.mkdir(dirName) +# print("Directory " , dirName , " Created ") + +# for call in range(calls): + +# sampler.resample(n=event_stack) +# s = sampler.unstack_x() +# sam = zfit.run(s) +# # clear_output(wait=True) + +# c = call + 1 + +# print("{0}/{1} of Toy {2}/{3}".format(c, calls, toy+1, nr_of_toys)) +# print("Time taken: {}".format(display_time(int(time.time() - start)))) +# print("Projected time left: {}".format(display_time(int((time.time() - start)/(c+calls*(toy))*((nr_of_toys-toy)*calls-c))))) + +# with open("data/zfit_toys/toy_{0}/{1}.pkl".format(toy, call), "wb") as f: +# pkl.dump(sam, f, pkl.HIGHEST_PROTOCOL) + + +# In[ ]: + + +# with open(r"data/zfit_toys/toy_0/0.pkl", "rb") as input_file: +# sam = pkl.load(input_file) +# print(sam[:10]) + +# with open(r"data/zfit_toys/toy_0/1.pkl", "rb") as input_file: +# sam2 = pkl.load(input_file) +# print(sam2[:10]) + +# print(np.sum(sam-sam2)) + + +# In[ ]: + + +# print("Time to generate full toy: {} s".format(int(time.time()-start))) + +# total_samp = [] + +# for call in range(calls): +# with open(r"data/zfit_toys/toy_0/{}.pkl".format(call), "rb") as input_file: +# sam = pkl.load(input_file) +# total_samp = np.append(total_samp, sam) + +# total_samp = total_samp.astype('float64') + +# data2 = zfit.data.Data.from_numpy(array=total_samp[:int(nevents)], obs=obs) + +# data3 = zfit.data.Data.from_numpy(array=total_samp, obs=obs) + +# print(total_samp[:nevents].shape) + + +# In[ ]: + + +# plt.clf() + +# bins = int((x_max-x_min)/7) + +# # calcs = zfit.run(total_test_tf(samp)) +# print(total_samp[:nevents].shape) + +# plt.hist(total_samp[:nevents], bins = bins, range = (x_min,x_max), label = 'data') +# # plt.plot(test_q, calcs_test*nevents , label = 'pdf') + +# # plt.plot(sam, calcs, '.') +# # plt.plot(test_q, calcs_test) +# # plt.yscale('log') +# plt.ylim(0, 200) +# # plt.xlim(3080, 3110) + +# plt.legend() + +# plt.savefig('test2.png') + + +# In[ ]: + + +# sampler = total_f.create_sampler(n=nevents) +# nll = zfit.loss.UnbinnedNLL(model=total_f, data=sampler, fit_range = (x_min, x_max)) + +# # for param in pdf.get_dependents(): +# # param.set_value(initial_value) + +# sampler.resample(n=nevents) + +# # Randomise initial values +# # for param in pdf.get_dependents(): +# # param.set_value(random value here) + +# # Minimise the NLL +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 10) +# minimum = minimizer.minimize(nll) + + +# In[ ]: + + +# jpsi_width + + +# In[ ]: + + +# plt.hist(sample, weights=1 / prob(sample)) + + +# # Fitting + +# In[ ]: + + +# start = time.time() + +# for param in total_f.get_dependents(): +# param.randomize() + +# # for param in total_f.get_dependents(): +# # print(zfit.run(param)) + +# nll = zfit.loss.UnbinnedNLL(model=total_f, data=data2, fit_range = (x_min, x_max)) + +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) +# # minimizer._use_tfgrad = False +# result = minimizer.minimize(nll) + +# # param_errors = result.error() + +# # for var, errors in param_errors.items(): +# # print('{}: ^{{+{}}}_{{{}}}'.format(var.name, errors['upper'], errors['lower'])) + +# print("Function minimum:", result.fmin) +# # print("Results:", result.params) +# print("Hesse errors:", result.hesse()) + + +# In[ ]: + + +# print("Time taken for fitting: {}".format(display_time(int(time.time()-start)))) + +# # probs = total_f.pdf(test_q) + +# calcs_test = zfit.run(probs) +# res_y = zfit.run(jpsi_res(test_q)) + + +# In[ ]: + + +# plt.clf() +# # plt.plot(x_part, calcs, '.') +# plt.plot(test_q, calcs_test, label = 'pdf') +# # plt.plot(test_q, res_y, label = 'res') +# plt.legend() +# plt.ylim(0.0, 10e-6) +# # plt.yscale('log') +# # plt.xlim(3080, 3110) +# plt.savefig('test3.png') +# # print(jpsi_width) + + +# In[ ]: + + +# _tot = 4.37e-7+6.02e-5+4.97e-6 +# _probs = [] +# _probs.append(6.02e-5/_tot) +# _probs.append(4.97e-6/_tot) +# _probs.append(4.37e-7/_tot) +# print(_probs) + + +# In[ ]: + + +# dtype = 'float64' +# # mixture = tfd.Uniform(tf.constant(x_min, dtype=dtype), tf.constant(x_max, dtype=dtype)) +# mixture = tfd.MixtureSameFamily(mixture_distribution=tfd.Categorical(probs=[tf.constant(0.007, dtype=dtype), +# tf.constant(0.917, dtype=dtype), +# tf.constant(0.076, dtype=dtype)]), +# components_distribution=tfd.Uniform(low=[tf.constant(x_min, dtype=dtype), +# tf.constant(3080, dtype=dtype), +# tf.constant(3670, dtype=dtype)], +# high=[tf.constant(x_max, dtype=dtype), +# tf.constant(3112, dtype=dtype), +# tf.constant(3702, dtype=dtype)])) +# # for i in range(10): +# # print(zfit.run(mixture.prob(mixture.sample((10, 1))))) + + +# In[ ]: + + +# print((zfit.run(jpsi_p)%(2*np.pi))/np.pi) +# print((zfit.run(psi2s_p)%(2*np.pi))/np.pi) + + +# In[ ]: + + +# def jpsi_res(q): +# return resonance(q, _mass = jpsi_mass, scale = jpsi_scale, +# phase = jpsi_phase, width = jpsi_width) + +# def psi2s_res(q): +# return resonance(q, _mass = psi2s_mass, scale = psi2s_scale, +# phase = psi2s_phase, width = psi2s_width) + +# def p3770_res(q): +# return resonance(q, _mass = p3770_mass, scale = p3770_scale, +# phase = p3770_phase, width = p3770_width) + +# def p4040_res(q): +# return resonance(q, _mass = p4040_mass, scale = p4040_scale, +# phase = p4040_phase, width = p4040_width) + +# def p4160_res(q): +# return resonance(q, _mass = p4160_mass, scale = p4160_scale, +# phase = p4160_phase, width = p4160_width) + +# def p4415_res(q): +# return resonance(q, _mass = p4415_mass, scale = p4415_scale, +# phase = p4415_phase, width = p4415_width) + + +# In[ ]: + + +# 0.15**2*4.2/1000 +# result.hesse() + + +# ## Constraints + +# In[ ]: + + +# 1. Constraint - Real part of sum of Psi contrib and D contribs + +sum_list = [] + +sum_list.append(ztf.to_complex(jpsi_s) * tf.exp(tf.complex(ztf.constant(0.0), jpsi_p)) * ztf.to_complex(jpsi_w / (tf.pow(jpsi_m,3)))) +sum_list.append(ztf.to_complex(psi2s_s) * tf.exp(tf.complex(ztf.constant(0.0), psi2s_p)) * ztf.to_complex(psi2s_w / (tf.pow(psi2s_m,3)))) +sum_list.append(ztf.to_complex(p3770_s) * tf.exp(tf.complex(ztf.constant(0.0), p3770_p)) * ztf.to_complex(p3770_w / (tf.pow(p3770_m,3)))) +sum_list.append(ztf.to_complex(p4040_s) * tf.exp(tf.complex(ztf.constant(0.0), p4040_p)) * ztf.to_complex(p4040_w / (tf.pow(p4040_m,3)))) +sum_list.append(ztf.to_complex(p4160_s) * tf.exp(tf.complex(ztf.constant(0.0), p4160_p)) * ztf.to_complex(p4160_w / (tf.pow(p4160_m,3)))) +sum_list.append(ztf.to_complex(p4415_s) * tf.exp(tf.complex(ztf.constant(0.0), p4415_p)) * ztf.to_complex(p4415_w / (tf.pow(p4415_m,3)))) +sum_list.append(ztf.to_complex(DDstar_s) * tf.exp(tf.complex(ztf.constant(0.0), DDstar_p)) * (ztf.to_complex(1.0 / (10.0*tf.pow(Dstar_m,2)) + 1.0 / (10.0*tf.pow(D_m,2))))) +sum_list.append(ztf.to_complex(Dbar_s) * tf.exp(tf.complex(ztf.constant(0.0), Dbar_p)) * ztf.to_complex(1.0 / (6.0*tf.pow(Dbar_m,2)))) + +sum_ru_1 = ztf.to_complex(ztf.constant(0.0)) + +for part in sum_list: + sum_ru_1 += part + +sum_1 = tf.math.real(sum_ru_1) +# constraint1 = zfit.constraint.GaussianConstraint(params = sum_1, mu = ztf.constant(1.7*10**-8), +# sigma = ztf.constant(2.2*10**-8)) + +constraint1 = tf.pow((sum_1-ztf.constant(1.7*10**-8))/ztf.constant(2.2*10**-8),2)/ztf.constant(2.) + +# 2. Constraint - Abs. of sum of Psi contribs and D contribs + +sum_2 = tf.abs(sum_ru_1) +constraint2 = tf.cond(tf.greater_equal(sum_2, 5.0e-8), lambda: 100000., lambda: 0.) + +# 3. Constraint - Maximum eta of D contribs + +constraint3_0 = tf.cond(tf.greater_equal(tf.abs(Dbar_s), 0.2), lambda: 100000., lambda: 0.) + +constraint3_1 = tf.cond(tf.greater_equal(tf.abs(DDstar_s), 0.2), lambda: 100000., lambda: 0.) + +# 4. Constraint - Formfactor multivariant gaussian covariance fplus + +Cov_matrix = [[ztf.constant( 1.), ztf.constant( 0.45), ztf.constant( 0.19), ztf.constant(0.857), ztf.constant(0.598), ztf.constant(0.531), ztf.constant(0.752), ztf.constant(0.229), ztf.constant(0,117)], + [ztf.constant( 0.45), ztf.constant( 1.), ztf.constant(0.677), ztf.constant(0.708), ztf.constant(0.958), ztf.constant(0.927), ztf.constant(0.227), ztf.constant(0.443), ztf.constant(0.287)], + [ztf.constant( 0.19), ztf.constant(0.677), ztf.constant( 1.), ztf.constant(0.595), ztf.constant(0.770), ztf.constant(0.819),ztf.constant(-0.023), ztf.constant( 0.07), ztf.constant(0.196)], + [ztf.constant(0.857), ztf.constant(0.708), ztf.constant(0.595), ztf.constant( 1.), ztf.constant( 0.83), ztf.constant(0.766), ztf.constant(0.582), ztf.constant(0.237), ztf.constant(0.192)], + [ztf.constant(0.598), ztf.constant(0.958), ztf.constant(0.770), ztf.constant( 0.83), ztf.constant( 1.), ztf.constant(0.973), ztf.constant(0.324), ztf.constant(0.372), ztf.constant(0.272)], + [ztf.constant(0.531), ztf.constant(0.927), ztf.constant(0.819), ztf.constant(0.766), ztf.constant(0.973), ztf.constant( 1.), ztf.constant(0.268), ztf.constant(0.332), ztf.constant(0.269)], + [ztf.constant(0.752), ztf.constant(0.227),ztf.constant(-0.023), ztf.constant(0.582), ztf.constant(0.324), ztf.constant(0.268), ztf.constant( 1.), ztf.constant( 0.59), ztf.constant(0.515)], + [ztf.constant(0.229), ztf.constant(0.443), ztf.constant( 0.07), ztf.constant(0.237), ztf.constant(0.372), ztf.constant(0.332), ztf.constant( 0.59), ztf.constant( 1.), ztf.constant(0.897)], + [ztf.constant(0.117), ztf.constant(0.287), ztf.constant(0.196), ztf.constant(0.192), ztf.constant(0.272), ztf.constant(0.269), ztf.constant(0.515), ztf.constant(0.897), ztf.constant( 1.)]] + +def triGauss(val1,val2,val3,m = Cov_matrix): + + mean1 = ztf.constant(0.466) + mean2 = ztf.constant(-0.885) + mean3 = ztf.constant(-0.213) + sigma1 = ztf.constant(0.014) + sigma2 = ztf.constant(0.128) + sigma3 = ztf.constant(0.548) + x1 = (val1-mean1)/sigma1 + x2 = (val2-mean2)/sigma2 + x3 = (val3-mean3)/sigma3 + rho12 = m[0][1] + rho13 = m[0][2] + rho23 = m[1][2] + w = x1*x1*(rho23*rho23-1) + x2*x2*(rho13*rho13-1)+x3*x3*(rho12*rho12-1)+2*(x1*x2*(rho12-rho13*rho23)+x1*x3*(rho13-rho12*rho23)+x2*x3*(rho23-rho12*rho13)) + d = 2*(rho12*rho12+rho13*rho13+rho23*rho23-2*rho12*rho13*rho23-1) + + fcn = -w/d + chisq = -2*fcn + return chisq + +constraint4 = triGauss(bplus_0, bplus_1, bplus_2) + +# mean1 = ztf.constant(0.466) +# mean2 = ztf.constant(-0.885) +# mean3 = ztf.constant(-0.213) +# sigma1 = ztf.constant(0.014) +# sigma2 = ztf.constant(0.128) +# sigma3 = ztf.constant(0.548) +# constraint4_0 = tf.pow((bplus_0-mean1)/sigma1,2)/ztf.constant(2.) +# constraint4_1 = tf.pow((bplus_1-mean2)/sigma2,2)/ztf.constant(2.) +# constraint4_2 = tf.pow((bplus_2-mean3)/sigma3,2)/ztf.constant(2.) + +# 5. Constraint - Abs. of sum of light contribs + +sum_list_5 = [] + +sum_list_5.append(rho_s*rho_w/rho_m) +sum_list_5.append(omega_s*omega_w/omega_m) +sum_list_5.append(phi_s*phi_w/phi_m) + + +sum_ru_5 = ztf.constant(0.0) + +for part in sum_list_5: + sum_ru_5 += part + +constraint5 = tf.cond(tf.greater_equal(tf.abs(sum_ru_5), ztf.constant(0.02)), lambda: 100000., lambda: 0.) + +# 6. Constraint on phases of Jpsi and Psi2s for cut out fit + + +# constraint6_0 = zfit.constraint.GaussianConstraint(params = jpsi_p, mu = ztf.constant(pdg["jpsi_phase_unc"]), +# sigma = ztf.constant(jpsi_phase)) +# constraint6_1 = zfit.constraint.GaussianConstraint(params = psi2s_p, mu = ztf.constant(pdg["psi2s_phase_unc"]), +# sigma = ztf.constant(psi2s_phase)) + +constraint6_0 = tf.pow((jpsi_p-ztf.constant(jpsi_phase))/ztf.constant(pdg["jpsi_phase_unc"]),2)/ztf.constant(2.) +constraint6_1 = tf.pow((psi2s_p-ztf.constant(psi2s_phase))/ztf.constant(pdg["psi2s_phase_unc"]),2)/ztf.constant(2.) + +# 7. Constraint on Ctt with higher limits + +constraint7 = tf.cond(tf.greater_equal(Ctt*Ctt, 0.25), lambda: 100000., lambda: 0.) + +constraint7dtype = tf.float64 + +# zfit.run(constraint6_0) + +# ztf.convert_to_tensor(constraint6_0) + +#List of all constraints + +constraints = [constraint1, constraint2, constraint3_0, constraint3_1,# constraint4, #constraint4_0, constraint4_1, constraint4_2, + constraint6_0, constraint6_1]#, constraint7] + + +# ## Reset params + +# In[ ]: + + +param_values_dic = { + 'jpsi_m': jpsi_mass, + 'jpsi_s': jpsi_scale, + 'jpsi_p': jpsi_phase, + 'jpsi_w': jpsi_width, + 'psi2s_m': psi2s_mass, + 'psi2s_s': psi2s_scale, + 'psi2s_p': psi2s_phase, + 'psi2s_w': psi2s_width, + 'p3770_m': p3770_mass, + 'p3770_s': p3770_scale, + 'p3770_p': p3770_phase, + 'p3770_w': p3770_width, + 'p4040_m': p4040_mass, + 'p4040_s': p4040_scale, + 'p4040_p': p4040_phase, + 'p4040_w': p4040_width, + 'p4160_m': p4160_mass, + 'p4160_s': p4160_scale, + 'p4160_p': p4160_phase, + 'p4160_w': p4160_width, + 'p4415_m': p4415_mass, + 'p4415_s': p4415_scale, + 'p4415_p': p4415_phase, + 'p4415_w': p4415_width, + 'rho_m': rho_mass, + 'rho_s': rho_scale, + 'rho_p': rho_phase, + 'rho_w': rho_width, + 'omega_m': omega_mass, + 'omega_s': omega_scale, + 'omega_p': omega_phase, + 'omega_w': omega_width, + 'phi_m': phi_mass, + 'phi_s': phi_scale, + 'phi_p': phi_phase, + 'phi_w': phi_width, + 'Dstar_m': Dstar_mass, + 'DDstar_s': 0.0, + 'DDstar_p': 0.0, + 'D_m': D_mass, + 'Dbar_m': Dbar_mass, + 'Dbar_s': 0.0, + 'Dbar_p': 0.0, + 'tau_m': pdg['tau_M'], + 'Ctt': 0.0, + 'b0_0': 0.292, + 'b0_1': 0.281, + 'b0_2': 0.150, + 'bplus_0': 0.466, + 'bplus_1': -0.885, + 'bplus_2': -0.213, + 'bT_0': 0.460, + 'bT_1': -1.089, + 'bT_2': -1.114} + + +def reset_param_values(variation = 0.05): + for param in total_f_fit.get_dependents(): + if param.floating: + param.set_value(param_values_dic[param.name] + random.uniform(-1, 1) * param_values_dic[param.name]* variation) +# print(param.name) +# for param in totalf.get_dependents(): +# param.set_value() + + +# # Analysis + +# In[ ]: + + +# # zfit.run.numeric_checks = False + +# fitting_range = 'cut' +# total_BR = 1.7e-10 + 4.9e-10 + 2.5e-9 + 6.02e-5 + 4.97e-6 + 1.38e-9 + 4.2e-10 + 2.6e-9 + 6.1e-10 + 4.37e-7 +# cut_BR = 1.0 - (6.02e-5 + 4.97e-6)/total_BR + +# Ctt_list = [] +# Ctt_error_list = [] + +# nr_of_toys = 1 +# if fitting_range == 'cut': +# nevents = int(pdg["number_of_decays"]*cut_BR) +# else: +# nevents = int(pdg["number_of_decays"]) +# # nevents = pdg["number_of_decays"] +# event_stack = 1000000 +# # nevents *= 41 +# # zfit.settings.set_verbosity(10) +# calls = int(nevents/event_stack + 1) + +# total_samp = [] + +# start = time.time() + +# sampler = total_f.create_sampler(n=event_stack) + +# for toy in range(nr_of_toys): + +# ### Generate data + +# # clear_output(wait=True) + +# print("Toy {}: Generating data...".format(toy)) + +# dirName = 'data/zfit_toys/toy_{0}'.format(toy) + +# if not os.path.exists(dirName): +# os.mkdir(dirName) +# print("Directory " , dirName , " Created ") + +# reset_param_values() + +# if fitting_range == 'cut': + +# sampler.resample(n=nevents) +# s = sampler.unstack_x() +# sam = zfit.run(s) +# calls = 0 +# c = 1 + +# else: +# for call in range(calls): + +# sampler.resample(n=event_stack) +# s = sampler.unstack_x() +# sam = zfit.run(s) + +# c = call + 1 + +# with open("data/zfit_toys/toy_{0}/{1}.pkl".format(toy, call), "wb") as f: +# pkl.dump(sam, f, pkl.HIGHEST_PROTOCOL) + +# print("Toy {}: Data generation finished".format(toy)) + +# ### Load data + +# print("Toy {}: Loading data...".format(toy)) + +# if fitting_range == 'cut': + +# total_samp = sam + +# else: + +# for call in range(calls): +# with open(r"data/zfit_toys/toy_0/{}.pkl".format(call), "rb") as input_file: +# sam = pkl.load(input_file) +# total_samp = np.append(total_samp, sam) + +# total_samp = total_samp.astype('float64') + +# if fitting_range == 'full': + +# data = zfit.data.Data.from_numpy(array=total_samp[:int(nevents)], obs=obs) + +# print("Toy {}: Loading data finished".format(toy)) + +# ### Fit data + +# print("Toy {}: Fitting pdf...".format(toy)) + +# for param in total_f.get_dependents(): +# param.randomize() + +# nll = zfit.loss.UnbinnedNLL(model=total_f, data=data, fit_range = (x_min, x_max), constraints = constraints) + +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) +# # minimizer._use_tfgrad = False +# result = minimizer.minimize(nll) + +# print("Toy {}: Fitting finished".format(toy)) + +# print("Function minimum:", result.fmin) +# print("Hesse errors:", result.hesse()) + +# params = result.params +# Ctt_list.append(params[Ctt]['value']) +# Ctt_error_list.append(params[Ctt]['minuit_hesse']['error']) + +# #plotting the result + +# plotdirName = 'data/plots'.format(toy) + +# if not os.path.exists(plotdirName): +# os.mkdir(plotdirName) +# # print("Directory " , dirName , " Created ") + +# probs = total_f.pdf(test_q, norm_range=False) +# calcs_test = zfit.run(probs) +# plt.clf() +# plt.plot(test_q, calcs_test, label = 'pdf') +# plt.legend() +# plt.ylim(0.0, 6e-6) +# plt.savefig(plotdirName + '/toy_fit_full_range{}.png'.format(toy)) + +# print("Toy {0}/{1}".format(toy+1, nr_of_toys)) +# print("Time taken: {}".format(display_time(int(time.time() - start)))) +# print("Projected time left: {}".format(display_time(int((time.time() - start)/(c+calls*(toy))*((nr_of_toys-toy)*calls-c))))) + +# if fitting_range == 'cut': + +# _1 = np.where((total_samp >= x_min) & (total_samp <= (jpsi_mass - 60.))) + +# tot_sam_1 = total_samp[_1] + +# _2 = np.where((total_samp >= (jpsi_mass + 70.)) & (total_samp <= (psi2s_mass - 50.))) + +# tot_sam_2 = total_samp[_2] + +# _3 = np.where((total_samp >= (psi2s_mass + 50.)) & (total_samp <= x_max)) + +# tot_sam_3 = total_samp[_3] + +# tot_sam = np.append(tot_sam_1, tot_sam_2) +# tot_sam = np.append(tot_sam, tot_sam_3) + +# data = zfit.data.Data.from_numpy(array=tot_sam[:int(nevents)], obs=obs_fit) + +# print("Toy {}: Loading data finished".format(toy)) + +# ### Fit data + +# print("Toy {}: Fitting pdf...".format(toy)) + +# for param in total_f_fit.get_dependents(): +# param.randomize() + +# nll = zfit.loss.UnbinnedNLL(model=total_f_fit, data=data, constraints = constraints) + +# minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) +# # minimizer._use_tfgrad = False +# result = minimizer.minimize(nll) + +# print("Function minimum:", result.fmin) +# print("Hesse errors:", result.hesse()) + +# params = result.params + +# if result.converged: +# Ctt_list.append(params[Ctt]['value']) +# Ctt_error_list.append(params[Ctt]['minuit_hesse']['error']) + +# #plotting the result + +# plotdirName = 'data/plots'.format(toy) + +# if not os.path.exists(plotdirName): +# os.mkdir(plotdirName) +# # print("Directory " , dirName , " Created ") + +# plt.clf() +# plt.hist(tot_sam, bins = int((x_max-x_min)/7.), label = 'toy data') +# plt.savefig(plotdirName + '/toy_histo_cut_region{}.png'.format(toy)) + + +# probs = total_f_fit.pdf(test_q, norm_range=False) +# calcs_test = zfit.run(probs) +# plt.clf() +# plt.plot(test_q, calcs_test, label = 'pdf') +# plt.axvline(x=jpsi_mass-60.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.axvline(x=jpsi_mass+70.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.axvline(x=psi2s_mass-50.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.axvline(x=psi2s_mass+50.,color='red', linewidth=0.7, linestyle = 'dotted') +# plt.legend() +# plt.ylim(0.0, 1.5e-6) +# plt.savefig(plotdirName + '/toy_fit_cut_region{}.png'.format(toy)) + +# print("Toy {0}/{1}".format(toy+1, nr_of_toys)) +# print("Time taken: {}".format(display_time(int(time.time() - start)))) +# print("Projected time left: {}".format(display_time(int((time.time() - start)/(toy+1))*((nr_of_toys-toy-1))))) + + + +# In[ ]: + + +# with open("data/results/Ctt_list.pkl", "wb") as f: +# pkl.dump(Ctt_list, f, pkl.HIGHEST_PROTOCOL) +# with open("data/results/Ctt_error_list.pkl", "wb") as f: +# pkl.dump(Ctt_error_list, f, pkl.HIGHEST_PROTOCOL) + + +# In[ ]: + + +# print('{0}/{1} fits converged'.format(len(Ctt_list), nr_of_toys)) +# print('Mean Ctt value = {}'.format(np.mean(Ctt_list))) +# print('Mean Ctt error = {}'.format(np.mean(Ctt_error_list))) +# print('95 Sensitivy = {}'.format(((2*np.mean(Ctt_error_list))**2)*4.2/1000)) + + +# In[ ]: + + +# plt.hist(tot_sam, bins = int((x_max-x_min)/7.)) + +# plt.show() + +# # _ = np.where((total_samp >= x_min) & (total_samp <= (jpsi_mass - 50.))) + +# tot_sam.shape + + +# In[ ]: + + +# Ctt.floating = False + + +# In[ ]: + + +# zfit.run(nll.value()) + + +# In[ ]: + + +# result.fmin + + +# In[ ]: + + +# BR_steps = np.linspace(0.0, 1e-3, 11) +pull_dic = {} + +mi = 1e-4 +ma = 3e-3 +ste = 20 + +for param in total_f_fit.get_dependents(): + if param.floating: + pull_dic[param.name] = [] + for step in range(2*ste): + pull_dic[param.name].append([]) + + + +def save_pulls(step): + for param in total_f_fit.get_dependents(): + if param.floating: + pull_dic[param.name][step].append((params[param]['value'] - param_values_dic[param.name])/params[param]['minuit_hesse']['error']) + + + +# for key in pull_dic.keys(): +# print(np.shape(pull_dic[key])) +# save_pulls(New_step=True) +# params[Ctt]['value'] + + +# In[ ]: + + +# for param in total_f_fit.get_dependents(): +# if param.floating: +# print(param.name) + +# print(params[Ctt]) + + +# # CLS Code + +# In[ ]: + + +# zfit.run.numeric_checks = False + +load = False + +bo = True + +D_contribs = True + +if not D_contribs: + Dbar_s.floating = False + Dbar_p.floating = False + DDstar_s.floating = False + DDstar_p.floating = False + +bo_set = 1 + +fitting_range = 'cut' +total_BR = 1.7e-10 + 4.9e-10 + 2.5e-9 + 6.02e-5 + 4.97e-6 + 1.38e-9 + 4.2e-10 + 2.6e-9 + 6.1e-10 + 4.37e-7 +cut_BR = 1.0 - (6.02e-5 + 4.97e-6)/total_BR + +Ctt_list = [] +Ctt_error_list = [] + +nr_of_toys = 1 +nevents = int(pdg["number_of_decays"]*cut_BR) +# nevents = pdg["number_of_decays"] +event_stack = 1000000 +# nevents *= 41 +# zfit.settings.set_verbosity(10) + +# mi = 1e-4 +# ma = 3e-3 +# ste = 13 + +BR_steps = np.linspace(mi, ma, ste) + +BR_steps[0] = 0.0 + +print(BR_steps) + +Ctt_steps = np.sqrt(BR_steps/4.2*1000) + +print(Ctt_steps) + +# total_samp = [] + +start = time.time() + +Nll_list = [] + +sampler = total_f.create_sampler(n=nevents, fixed_params = False) +sampler.set_data_range(obs_fit) + +__ = -1 + +#----------------------------------------------------- + +if not load: + for Ctt_step in Ctt_steps: + + __ += 1 + + for i in range(2): + Ctt_list.append([]) + Ctt_error_list.append([]) + Nll_list.append([]) + + for param in total_f_fit.get_dependents(): + if param.floating: + pull_dic[param.name].append([]) + + for toy in range(nr_of_toys): + + newset = True + + while newset: + + for floaty in [True, False]: + Ctt.floating = floaty + + for bo_step in range(bo_set): + + print('Step: {0}/{1}'.format(int(__), ste)) + print('Current Ctt: {0}'.format(Ctt_step)) + print('Ctt floating: {0}'.format(floaty)) + + reset_param_values(variation = 0.0) + + if floaty: + print('Toy {0}/{1} - Fit {2}/{3}'.format(toy, nr_of_toys, bo_step, bo_set)) + Ctt.set_value(Ctt_step) + + else: + Ctt.set_value(0.0) + print('Toy {0}/{1} - Fit {2}/{3}'.format(toy, nr_of_toys, bo_step, bo_set)) + + if newset: + sampler.resample(n=nevents) + data = sampler + newset = False + + ### Fit data + + if floaty: + #plt.clf() + #plt.title('Ctt value: {:.2f}'.format(Ctt_step)) + #plt.hist(zfit.run(data), bins = int((x_max-x_min)/7), range = (x_min, x_max)) + #plt.savefig('data/CLs/plots/set_histo{}.png'.format(__)) + _step = 2*__ + else: + _step = 2*__+1 + + nll = zfit.loss.UnbinnedNLL(model=total_f_fit, data=data, constraints = constraints) + + minimizer = zfit.minimize.MinuitMinimizer(verbosity = 5) + # minimizer._use_tfgrad = False + result = minimizer.minimize(nll) + + print("Function minimum:", result.fmin) + print("Hesse errors:", result.hesse()) + + params = result.params + + if result.converged: + + save_pulls(step = _step) + + if floaty: + Nll_list[-2].append(result.fmin) + Ctt_list[-2].append(params[Ctt]['value']) + Ctt_error_list[-2].append(params[Ctt]['minuit_hesse']['error']) + + else: + Nll_list[-1].append(result.fmin) + Ctt_list[-1].append(0.0) + Ctt_error_list[-1].append(0.0) + + + else: + for _ in [1,2]: + del Nll_list[-_][toy*bo_set:] +# print(np.shape(Nll_list[-_])) + del Ctt_list[-_][toy*bo_set:] + del Ctt_error_list[-_][toy*bo_set:] + for param in total_f_fit.get_dependents(): + if param.floating: + del pull_dic[param.name][_step+1-_][toy*bo_set:] + newset = True + break + + if not result.converged: + break + + print() + print('Time taken: {}'.format(display_time(int(time.time()-start)))) + print('Estimated time left: {}'.format(display_time(int((time.time()-start)/(__+(toy+1)/nr_of_toys)*(ste-__-(nr_of_toys-toy-1)/nr_of_toys))))) + + +# In[ ]: + + +if load: + + phase_combi = '--' + + if D_contribs: + D_dir = 'D-True' + else: + D_dir = 'D-False' + + _dir = 'data/CLs/finished/f1d1/{}/{}/'.format(phase_combi, D_dir) + + jobs = os.listdir(_dir) + + First = True + +# print(jobs) + + for job in jobs: + + dirName = _dir + str(job) + '/data/CLs' + + if not os.path.exists("{}/{}-{}_{}s{}b{}t--CLs_Nll_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys)): +# print(job) + continue + + with open(r"{}/variab.pkl".format(dirName), "rb") as input_file: + variab = pkl.load(input_file) +# print(variab) + + ### sanity check: + if variab['mi'] != mi or variab['ma'] != ma or variab['ste'] != ste or bo_set != bo_set: + print('Fitting parameters of data dont equal the ones given -- Job {} skipped!'.format(job)) + + with open(r"{}/{}-{}_{}s{}b{}t--CLs_Nll_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _Nll_list = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s{}b{}t--Ctt_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _Ctt_list = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s{}b{}t--Ctt_error_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _Ctt_error_list = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s{}b{}t--pull_dic.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "rb") as input_file: + _pull_dic = pkl.load(input_file) + + with open(r"{}/{}-{}_{}s--CLs_list.pkl".format(dirName, mi,ma,ste), "rb") as input_file: + _CLs_list = pkl.load(input_file) + + + if First: + Nll_list = _Nll_list + Ctt_list = _Ctt_list + Ctt_error_list = _Ctt_error_list + pull_dic = _pull_dic +# print(_pull_dic) + CLs_list = _CLs_list + First = False + else: + for step in range(2*ste): +# print(Nll_list[step], step) + Nll_list[step].extend(_Nll_list[step]) + Ctt_list[step].extend(_Ctt_list[step]) + Ctt_error_list[step].extend(_Ctt_error_list[step]) + for key in pull_dic.keys(): +# print(key, np.shape(pull_dic[key])) + pull_dic[key][step].extend(_pull_dic[key][step]) + for step in range(ste): + CLs_list[step].extend(_CLs_list[step]) + +# print('----------------------') + + +# In[ ]: + + +dirName = 'data/CLs' + +# if bo and not load: +# for s in range(2*ste): +# Nll_list[s] = [np.min(Nll_list[s])] + + +if not load: + + if not os.path.exists(dirName): + os.mkdir(dirName) + print("Directory " , dirName , " Created ") + + with open("{}/{}-{}_{}s{}b{}t--CLs_Nll_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(Nll_list, f, pkl.HIGHEST_PROTOCOL) + + with open("{}/{}-{}_{}s{}b{}t--Ctt_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(Ctt_list, f, pkl.HIGHEST_PROTOCOL) + + with open("{}/{}-{}_{}s{}b{}t--Ctt_error_list.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(Ctt_error_list, f, pkl.HIGHEST_PROTOCOL) + + with open("{}/{}-{}_{}s{}b{}t--pull_dic.pkl".format(dirName, mi,ma,ste,bo_set,nr_of_toys), "wb") as f: + pkl.dump(pull_dic, f, pkl.HIGHEST_PROTOCOL) + + variab = {'mi': mi, + 'ma': ma, + 'ste': ste, + 'bo_set': bo_set, + 'nr_of_toys': nr_of_toys} + + with open("{}/variab.pkl".format(dirName), "wb") as f: + pkl.dump(variab, f, pkl.HIGHEST_PROTOCOL) + + CLs_values = [] + + toy_size = bo_set + + print(np.shape(Nll_list)) + print(Nll_list[0:1]) + + for step in range(ste): + CLs_values.append([]) + for toy in range(nr_of_toys): + float_min = np.min(Nll_list[2*step][toy*bo_set:(toy+1)*bo_set]) + fix_min = np.min(Nll_list[2*step+1][toy*bo_set:(toy+1)*bo_set]) + CLs_values[step].append(float_min-fix_min) + + + print(np.shape(CLs_values)) + + with open("{}/{}-{}_{}s--CLs_list.pkl".format(dirName, mi,ma,ste), "wb") as f: + pkl.dump(CLs_values, f, pkl.HIGHEST_PROTOCOL) + + +# In[ ]: + + +# print(variab['mi'] != mi) + + +# ## Plot + +# In[ ]: + + +l = [] + + +if load: + CLs_values = -1*np.array(CLs_list) + +if not os.path.exists('data/CLs/plots'): + os.mkdir('data/CLs/plots') + print("Directory " , 'data/CLs/plots' , " Created ") + +print(np.shape(CLs_values)) + +for step in range(1,ste): + plt.clf() + plt.title('Ctt value: {:.2f}'.format(Ctt_steps[step])) + plt.hist(CLs_values[0], bins = 150, range = (-25, 50), label = 'Ctt fixed to 0') + plt.hist(CLs_values[step], bins = 150, range = (-25, 50), label = 'Ctt floating') + plt.axvline(x=np.mean(CLs_values[0]),color='red', linewidth=1.0, linestyle = 'dotted') + plt.legend() + plt.savefig('data/CLs/plots/CLs-BR({:.1E}).png'.format(BR_steps[step])) + + l.append(len(np.where(np.array(CLs_values[step]) < np.mean(CLs_values[0]))[0])) + +for step in range(2*ste): + if step%2 == 0: + floaty = True + else: + floaty = False + for key in pull_dic.keys(): + if not os.path.exists('data/CLs/plots/{}'.format(key)): + os.mkdir('data/CLs/plots/{}'.format(key)) + plt.clf() + plt.title('Pull {} - Ctt value {:.2f} - floating {}'.format(key, Ctt_steps[int(step/2)], floaty)) + plt.hist(pull_dic[key][step], bins = 50, range = (-5,5)) + plt.xlabel('Pull') + plt.savefig('data/CLs/plots/{}/{:.2f}Ctt{}s{}f.png'.format(key, Ctt_steps[int(step/2)], step, floaty)) + + +# In[ ]: + + +for s in range(len(l)): + print('BR: {:.4f}'.format(BR_steps[s+1])) + print(2*l[s]/len(CLs_values[s])) + print() + + +# In[ ]: + + +# for step in range(2*ste): +# for key in pull_dic.keys(): +# print(pull_dic[key][step]) + + +# In[ ]: + + +# for param in total_f_fit.get_dependents(): +# if param.floating: +# print(params[param]['value']) + + +# In[ ]: + + +print(display_time(int(time.time()-start))) + + +# In[ ]: + + +# variab['mi'] =! mi + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + diff --git "a/data/CLs/plots/CLs-BR\0501.0E-03\051.png" "b/data/CLs/plots/CLs-BR\0501.0E-03\051.png" index ee5a4d8..a06ca16 100644 --- "a/data/CLs/plots/CLs-BR\0501.0E-03\051.png" +++ "b/data/CLs/plots/CLs-BR\0501.0E-03\051.png" Binary files differ diff --git "a/data/CLs/plots/CLs-BR\0501.2E-03\051.png" "b/data/CLs/plots/CLs-BR\0501.2E-03\051.png" index 5bb18c2..fce2040 100644 --- "a/data/CLs/plots/CLs-BR\0501.2E-03\051.png" +++ "b/data/CLs/plots/CLs-BR\0501.2E-03\051.png" Binary files differ diff --git "a/data/CLs/plots/CLs-BR\0501.3E-03\051.png" "b/data/CLs/plots/CLs-BR\0501.3E-03\051.png" index 25cb92a..ef5becb 100644 --- "a/data/CLs/plots/CLs-BR\0501.3E-03\051.png" +++ "b/data/CLs/plots/CLs-BR\0501.3E-03\051.png" Binary files differ diff --git "a/data/CLs/plots/CLs-BR\0501.5E-03\051.png" "b/data/CLs/plots/CLs-BR\0501.5E-03\051.png" index 2de16e1..dab19bd 100644 --- "a/data/CLs/plots/CLs-BR\0501.5E-03\051.png" +++ "b/data/CLs/plots/CLs-BR\0501.5E-03\051.png" Binary files differ diff --git "a/data/CLs/plots/CLs-BR\0501.6E-03\051.png" "b/data/CLs/plots/CLs-BR\0501.6E-03\051.png" index 985e918..cbc07e6 100644 --- "a/data/CLs/plots/CLs-BR\0501.6E-03\051.png" +++ "b/data/CLs/plots/CLs-BR\0501.6E-03\051.png" Binary files differ diff --git "a/data/CLs/plots/CLs-BR\0501.8E-03\051.png" "b/data/CLs/plots/CLs-BR\0501.8E-03\051.png" index 339b5e8..8b58240 100644 --- "a/data/CLs/plots/CLs-BR\0501.8E-03\051.png" +++ "b/data/CLs/plots/CLs-BR\0501.8E-03\051.png" Binary files differ diff --git "a/data/CLs/plots/CLs-BR\0501.9E-03\051.png" "b/data/CLs/plots/CLs-BR\0501.9E-03\051.png" index 0e969b2..c282195 100644 --- "a/data/CLs/plots/CLs-BR\0501.9E-03\051.png" +++ "b/data/CLs/plots/CLs-BR\0501.9E-03\051.png" Binary files differ diff --git "a/data/CLs/plots/CLs-BR\0502.1E-03\051.png" "b/data/CLs/plots/CLs-BR\0502.1E-03\051.png" index 2f0f5dd..3258bb7 100644 --- "a/data/CLs/plots/CLs-BR\0502.1E-03\051.png" +++ "b/data/CLs/plots/CLs-BR\0502.1E-03\051.png" Binary files differ diff --git "a/data/CLs/plots/CLs-BR\0502.2E-03\051.png" "b/data/CLs/plots/CLs-BR\0502.2E-03\051.png" index a2ae117..cb97833 100644 --- "a/data/CLs/plots/CLs-BR\0502.2E-03\051.png" +++ "b/data/CLs/plots/CLs-BR\0502.2E-03\051.png" Binary files differ diff --git "a/data/CLs/plots/CLs-BR\0502.4E-03\051.png" "b/data/CLs/plots/CLs-BR\0502.4E-03\051.png" index 57ed2d9..d4bad32 100644 --- "a/data/CLs/plots/CLs-BR\0502.4E-03\051.png" +++ "b/data/CLs/plots/CLs-BR\0502.4E-03\051.png" Binary files differ diff --git "a/data/CLs/plots/CLs-BR\0502.5E-03\051.png" "b/data/CLs/plots/CLs-BR\0502.5E-03\051.png" index 2e685e9..e88a238 100644 --- "a/data/CLs/plots/CLs-BR\0502.5E-03\051.png" +++ "b/data/CLs/plots/CLs-BR\0502.5E-03\051.png" Binary files differ diff --git "a/data/CLs/plots/CLs-BR\0502.5E-04\051.png" "b/data/CLs/plots/CLs-BR\0502.5E-04\051.png" index d839626..c928542 100644 --- "a/data/CLs/plots/CLs-BR\0502.5E-04\051.png" +++ "b/data/CLs/plots/CLs-BR\0502.5E-04\051.png" Binary files differ diff --git "a/data/CLs/plots/CLs-BR\0502.7E-03\051.png" "b/data/CLs/plots/CLs-BR\0502.7E-03\051.png" index 844e80e..6930a32 100644 --- "a/data/CLs/plots/CLs-BR\0502.7E-03\051.png" +++ "b/data/CLs/plots/CLs-BR\0502.7E-03\051.png" Binary files differ diff --git "a/data/CLs/plots/CLs-BR\0502.8E-03\051.png" "b/data/CLs/plots/CLs-BR\0502.8E-03\051.png" index 421a8f4..4994d9d 100644 --- "a/data/CLs/plots/CLs-BR\0502.8E-03\051.png" +++ "b/data/CLs/plots/CLs-BR\0502.8E-03\051.png" Binary files differ diff --git "a/data/CLs/plots/CLs-BR\0503.0E-03\051.png" "b/data/CLs/plots/CLs-BR\0503.0E-03\051.png" index e393539..47cae2d 100644 --- "a/data/CLs/plots/CLs-BR\0503.0E-03\051.png" +++ "b/data/CLs/plots/CLs-BR\0503.0E-03\051.png" Binary files differ diff --git "a/data/CLs/plots/CLs-BR\0504.1E-04\051.png" "b/data/CLs/plots/CLs-BR\0504.1E-04\051.png" index f6b736f..b5ddc12 100644 --- "a/data/CLs/plots/CLs-BR\0504.1E-04\051.png" +++ "b/data/CLs/plots/CLs-BR\0504.1E-04\051.png" Binary files differ diff --git "a/data/CLs/plots/CLs-BR\0505.6E-04\051.png" "b/data/CLs/plots/CLs-BR\0505.6E-04\051.png" index adcf6c7..a0ff26a 100644 --- "a/data/CLs/plots/CLs-BR\0505.6E-04\051.png" +++ "b/data/CLs/plots/CLs-BR\0505.6E-04\051.png" Binary files differ diff --git "a/data/CLs/plots/CLs-BR\0507.1E-04\051.png" "b/data/CLs/plots/CLs-BR\0507.1E-04\051.png" index e73f4fd..da27d13 100644 --- "a/data/CLs/plots/CLs-BR\0507.1E-04\051.png" +++ "b/data/CLs/plots/CLs-BR\0507.1E-04\051.png" Binary files differ diff --git "a/data/CLs/plots/CLs-BR\0508.6E-04\051.png" "b/data/CLs/plots/CLs-BR\0508.6E-04\051.png" index c4bae10..a35bfd7 100644 --- "a/data/CLs/plots/CLs-BR\0508.6E-04\051.png" +++ "b/data/CLs/plots/CLs-BR\0508.6E-04\051.png" Binary files differ diff --git a/data/CLs/plots/Ctt/0.00Ctt0sTruef.png b/data/CLs/plots/Ctt/0.00Ctt0sTruef.png index 409b6e7..738d92e 100644 --- a/data/CLs/plots/Ctt/0.00Ctt0sTruef.png +++ b/data/CLs/plots/Ctt/0.00Ctt0sTruef.png Binary files differ diff --git a/data/CLs/plots/Ctt/0.25Ctt2sTruef.png b/data/CLs/plots/Ctt/0.25Ctt2sTruef.png index 43e8610..5d01511 100644 --- a/data/CLs/plots/Ctt/0.25Ctt2sTruef.png +++ b/data/CLs/plots/Ctt/0.25Ctt2sTruef.png Binary files differ diff --git a/data/CLs/plots/Ctt/0.31Ctt4sTruef.png b/data/CLs/plots/Ctt/0.31Ctt4sTruef.png index 5a7832f..462ab14 100644 --- a/data/CLs/plots/Ctt/0.31Ctt4sTruef.png +++ b/data/CLs/plots/Ctt/0.31Ctt4sTruef.png Binary files differ diff --git a/data/CLs/plots/Ctt/0.36Ctt6sTruef.png b/data/CLs/plots/Ctt/0.36Ctt6sTruef.png index d5dbc45..c4ef4fa 100644 --- a/data/CLs/plots/Ctt/0.36Ctt6sTruef.png +++ b/data/CLs/plots/Ctt/0.36Ctt6sTruef.png Binary files differ diff --git a/data/CLs/plots/Ctt/0.41Ctt8sTruef.png b/data/CLs/plots/Ctt/0.41Ctt8sTruef.png index efbf69e..769b2b4 100644 --- a/data/CLs/plots/Ctt/0.41Ctt8sTruef.png +++ b/data/CLs/plots/Ctt/0.41Ctt8sTruef.png Binary files differ diff --git a/data/CLs/plots/Ctt/0.45Ctt10sTruef.png b/data/CLs/plots/Ctt/0.45Ctt10sTruef.png index 589652c..d22857c 100644 --- a/data/CLs/plots/Ctt/0.45Ctt10sTruef.png +++ b/data/CLs/plots/Ctt/0.45Ctt10sTruef.png Binary files differ diff --git a/data/CLs/plots/Ctt/0.49Ctt12sTruef.png b/data/CLs/plots/Ctt/0.49Ctt12sTruef.png index d7427aa..1d3410f 100644 --- a/data/CLs/plots/Ctt/0.49Ctt12sTruef.png +++ b/data/CLs/plots/Ctt/0.49Ctt12sTruef.png Binary files differ diff --git a/data/CLs/plots/Ctt/0.53Ctt14sTruef.png b/data/CLs/plots/Ctt/0.53Ctt14sTruef.png index a5dd581..85c517a 100644 --- a/data/CLs/plots/Ctt/0.53Ctt14sTruef.png +++ b/data/CLs/plots/Ctt/0.53Ctt14sTruef.png Binary files differ diff --git a/data/CLs/plots/Ctt/0.56Ctt16sTruef.png b/data/CLs/plots/Ctt/0.56Ctt16sTruef.png index 3cc21d5..b954b51 100644 --- a/data/CLs/plots/Ctt/0.56Ctt16sTruef.png +++ b/data/CLs/plots/Ctt/0.56Ctt16sTruef.png Binary files differ diff --git a/data/CLs/plots/Ctt/0.59Ctt18sTruef.png b/data/CLs/plots/Ctt/0.59Ctt18sTruef.png index 2bc6810..d756acf 100644 --- a/data/CLs/plots/Ctt/0.59Ctt18sTruef.png +++ b/data/CLs/plots/Ctt/0.59Ctt18sTruef.png Binary files differ diff --git a/data/CLs/plots/Ctt/0.62Ctt20sTruef.png b/data/CLs/plots/Ctt/0.62Ctt20sTruef.png index 43423f1..748b875 100644 --- a/data/CLs/plots/Ctt/0.62Ctt20sTruef.png +++ b/data/CLs/plots/Ctt/0.62Ctt20sTruef.png Binary files differ diff --git a/data/CLs/plots/Ctt/0.65Ctt22sTruef.png b/data/CLs/plots/Ctt/0.65Ctt22sTruef.png index c8ddc70..d3af084 100644 --- a/data/CLs/plots/Ctt/0.65Ctt22sTruef.png +++ b/data/CLs/plots/Ctt/0.65Ctt22sTruef.png Binary files differ diff --git a/data/CLs/plots/Ctt/0.68Ctt24sTruef.png b/data/CLs/plots/Ctt/0.68Ctt24sTruef.png index 52acdfb..e5b3018 100644 --- a/data/CLs/plots/Ctt/0.68Ctt24sTruef.png +++ b/data/CLs/plots/Ctt/0.68Ctt24sTruef.png Binary files differ diff --git a/data/CLs/plots/Ctt/0.70Ctt26sTruef.png b/data/CLs/plots/Ctt/0.70Ctt26sTruef.png index 6d6af5e..72a8982 100644 --- a/data/CLs/plots/Ctt/0.70Ctt26sTruef.png +++ b/data/CLs/plots/Ctt/0.70Ctt26sTruef.png Binary files differ diff --git a/data/CLs/plots/Ctt/0.73Ctt28sTruef.png b/data/CLs/plots/Ctt/0.73Ctt28sTruef.png index f243796..11ba3ce 100644 --- a/data/CLs/plots/Ctt/0.73Ctt28sTruef.png +++ b/data/CLs/plots/Ctt/0.73Ctt28sTruef.png Binary files differ diff --git a/data/CLs/plots/Ctt/0.75Ctt30sTruef.png b/data/CLs/plots/Ctt/0.75Ctt30sTruef.png index cc8ccc0..135ff5d 100644 --- a/data/CLs/plots/Ctt/0.75Ctt30sTruef.png +++ b/data/CLs/plots/Ctt/0.75Ctt30sTruef.png Binary files differ diff --git a/data/CLs/plots/Ctt/0.78Ctt32sTruef.png b/data/CLs/plots/Ctt/0.78Ctt32sTruef.png index bb05a13..fbbc47d 100644 --- a/data/CLs/plots/Ctt/0.78Ctt32sTruef.png +++ b/data/CLs/plots/Ctt/0.78Ctt32sTruef.png Binary files differ diff --git a/data/CLs/plots/Ctt/0.80Ctt34sTruef.png b/data/CLs/plots/Ctt/0.80Ctt34sTruef.png index 3419221..2884532 100644 --- a/data/CLs/plots/Ctt/0.80Ctt34sTruef.png +++ b/data/CLs/plots/Ctt/0.80Ctt34sTruef.png Binary files differ diff --git a/data/CLs/plots/Ctt/0.82Ctt36sTruef.png b/data/CLs/plots/Ctt/0.82Ctt36sTruef.png index e13448b..20e3a87 100644 --- a/data/CLs/plots/Ctt/0.82Ctt36sTruef.png +++ b/data/CLs/plots/Ctt/0.82Ctt36sTruef.png Binary files differ diff --git a/data/CLs/plots/Ctt/0.85Ctt38sTruef.png b/data/CLs/plots/Ctt/0.85Ctt38sTruef.png index 399f4b7..476428e 100644 --- a/data/CLs/plots/Ctt/0.85Ctt38sTruef.png +++ b/data/CLs/plots/Ctt/0.85Ctt38sTruef.png Binary files differ diff --git a/data/CLs/plots/DDstar_p/0.00Ctt0sTruef.png b/data/CLs/plots/DDstar_p/0.00Ctt0sTruef.png index 82940fe..cce7bfe 100644 --- a/data/CLs/plots/DDstar_p/0.00Ctt0sTruef.png +++ b/data/CLs/plots/DDstar_p/0.00Ctt0sTruef.png Binary files differ diff --git a/data/CLs/plots/DDstar_p/0.00Ctt1sFalsef.png b/data/CLs/plots/DDstar_p/0.00Ctt1sFalsef.png index 2f8ef28..4d03885 100644 --- a/data/CLs/plots/DDstar_p/0.00Ctt1sFalsef.png +++ b/data/CLs/plots/DDstar_p/0.00Ctt1sFalsef.png Binary files differ diff --git a/data/CLs/plots/DDstar_p/0.25Ctt2sTruef.png b/data/CLs/plots/DDstar_p/0.25Ctt2sTruef.png index 916c8f5..38f0a10 100644 --- a/data/CLs/plots/DDstar_p/0.25Ctt2sTruef.png +++ b/data/CLs/plots/DDstar_p/0.25Ctt2sTruef.png Binary files differ diff --git a/data/CLs/plots/DDstar_p/0.25Ctt3sFalsef.png b/data/CLs/plots/DDstar_p/0.25Ctt3sFalsef.png index ad051de..42c28d9 100644 --- a/data/CLs/plots/DDstar_p/0.25Ctt3sFalsef.png +++ b/data/CLs/plots/DDstar_p/0.25Ctt3sFalsef.png Binary files differ diff --git a/data/CLs/plots/DDstar_p/0.31Ctt4sTruef.png b/data/CLs/plots/DDstar_p/0.31Ctt4sTruef.png index 7cb416b..0795368 100644 --- a/data/CLs/plots/DDstar_p/0.31Ctt4sTruef.png +++ b/data/CLs/plots/DDstar_p/0.31Ctt4sTruef.png Binary files differ diff --git a/data/CLs/plots/DDstar_p/0.31Ctt5sFalsef.png b/data/CLs/plots/DDstar_p/0.31Ctt5sFalsef.png index 14f4c72..57fc35b 100644 --- a/data/CLs/plots/DDstar_p/0.31Ctt5sFalsef.png +++ b/data/CLs/plots/DDstar_p/0.31Ctt5sFalsef.png Binary files differ diff --git a/data/CLs/plots/DDstar_p/0.36Ctt6sTruef.png b/data/CLs/plots/DDstar_p/0.36Ctt6sTruef.png index d25b5e5..fb0d4f9 100644 --- a/data/CLs/plots/DDstar_p/0.36Ctt6sTruef.png +++ b/data/CLs/plots/DDstar_p/0.36Ctt6sTruef.png Binary files differ diff --git a/data/CLs/plots/DDstar_p/0.36Ctt7sFalsef.png b/data/CLs/plots/DDstar_p/0.36Ctt7sFalsef.png index ee1ebde..c9c827e 100644 --- a/data/CLs/plots/DDstar_p/0.36Ctt7sFalsef.png +++ b/data/CLs/plots/DDstar_p/0.36Ctt7sFalsef.png Binary files differ diff --git a/data/CLs/plots/DDstar_p/0.41Ctt8sTruef.png b/data/CLs/plots/DDstar_p/0.41Ctt8sTruef.png index c1212fc..af8d419 100644 --- a/data/CLs/plots/DDstar_p/0.41Ctt8sTruef.png +++ b/data/CLs/plots/DDstar_p/0.41Ctt8sTruef.png Binary files differ diff --git a/data/CLs/plots/DDstar_p/0.41Ctt9sFalsef.png b/data/CLs/plots/DDstar_p/0.41Ctt9sFalsef.png index 33fb17b..844b85f 100644 --- a/data/CLs/plots/DDstar_p/0.41Ctt9sFalsef.png +++ b/data/CLs/plots/DDstar_p/0.41Ctt9sFalsef.png Binary files differ diff --git a/data/CLs/plots/DDstar_p/0.45Ctt10sTruef.png b/data/CLs/plots/DDstar_p/0.45Ctt10sTruef.png index f13bc15..b0888b5 100644 --- a/data/CLs/plots/DDstar_p/0.45Ctt10sTruef.png +++ b/data/CLs/plots/DDstar_p/0.45Ctt10sTruef.png Binary files differ diff --git a/data/CLs/plots/DDstar_p/0.45Ctt11sFalsef.png b/data/CLs/plots/DDstar_p/0.45Ctt11sFalsef.png index b1aa467..0d8dc92 100644 --- a/data/CLs/plots/DDstar_p/0.45Ctt11sFalsef.png +++ b/data/CLs/plots/DDstar_p/0.45Ctt11sFalsef.png Binary files differ diff --git a/data/CLs/plots/DDstar_p/0.49Ctt12sTruef.png b/data/CLs/plots/DDstar_p/0.49Ctt12sTruef.png index a81677f..340bc7f 100644 --- a/data/CLs/plots/DDstar_p/0.49Ctt12sTruef.png +++ b/data/CLs/plots/DDstar_p/0.49Ctt12sTruef.png Binary files differ diff --git a/data/CLs/plots/DDstar_p/0.49Ctt13sFalsef.png b/data/CLs/plots/DDstar_p/0.49Ctt13sFalsef.png index ae8e0f4..f0bb54e 100644 --- a/data/CLs/plots/DDstar_p/0.49Ctt13sFalsef.png +++ b/data/CLs/plots/DDstar_p/0.49Ctt13sFalsef.png Binary files differ diff --git a/data/CLs/plots/DDstar_p/0.53Ctt14sTruef.png b/data/CLs/plots/DDstar_p/0.53Ctt14sTruef.png index 5fbbe73..751985f 100644 --- a/data/CLs/plots/DDstar_p/0.53Ctt14sTruef.png +++ b/data/CLs/plots/DDstar_p/0.53Ctt14sTruef.png Binary files differ diff --git a/data/CLs/plots/DDstar_p/0.53Ctt15sFalsef.png b/data/CLs/plots/DDstar_p/0.53Ctt15sFalsef.png index f804271..9dabe2c 100644 --- a/data/CLs/plots/DDstar_p/0.53Ctt15sFalsef.png +++ b/data/CLs/plots/DDstar_p/0.53Ctt15sFalsef.png Binary files differ diff --git a/data/CLs/plots/DDstar_p/0.56Ctt16sTruef.png b/data/CLs/plots/DDstar_p/0.56Ctt16sTruef.png index be3a3fd..156981a 100644 --- a/data/CLs/plots/DDstar_p/0.56Ctt16sTruef.png +++ b/data/CLs/plots/DDstar_p/0.56Ctt16sTruef.png Binary files differ diff --git a/data/CLs/plots/DDstar_p/0.56Ctt17sFalsef.png b/data/CLs/plots/DDstar_p/0.56Ctt17sFalsef.png index 42fbda3..7da7dc0 100644 --- a/data/CLs/plots/DDstar_p/0.56Ctt17sFalsef.png +++ b/data/CLs/plots/DDstar_p/0.56Ctt17sFalsef.png Binary files differ diff --git a/data/CLs/plots/DDstar_p/0.59Ctt18sTruef.png b/data/CLs/plots/DDstar_p/0.59Ctt18sTruef.png index 6454575..cc1c54f 100644 --- a/data/CLs/plots/DDstar_p/0.59Ctt18sTruef.png +++ b/data/CLs/plots/DDstar_p/0.59Ctt18sTruef.png Binary files differ diff --git a/data/CLs/plots/DDstar_p/0.59Ctt19sFalsef.png b/data/CLs/plots/DDstar_p/0.59Ctt19sFalsef.png index 2705209..150f0e0 100644 --- a/data/CLs/plots/DDstar_p/0.59Ctt19sFalsef.png +++ b/data/CLs/plots/DDstar_p/0.59Ctt19sFalsef.png Binary files differ diff --git a/data/CLs/plots/DDstar_p/0.62Ctt20sTruef.png b/data/CLs/plots/DDstar_p/0.62Ctt20sTruef.png index 7fd738c..882c977 100644 --- a/data/CLs/plots/DDstar_p/0.62Ctt20sTruef.png +++ b/data/CLs/plots/DDstar_p/0.62Ctt20sTruef.png Binary files differ diff --git a/data/CLs/plots/DDstar_p/0.62Ctt21sFalsef.png b/data/CLs/plots/DDstar_p/0.62Ctt21sFalsef.png index f97c8ee..90a6288 100644 --- a/data/CLs/plots/DDstar_p/0.62Ctt21sFalsef.png +++ b/data/CLs/plots/DDstar_p/0.62Ctt21sFalsef.png Binary files differ diff --git a/data/CLs/plots/DDstar_p/0.65Ctt22sTruef.png b/data/CLs/plots/DDstar_p/0.65Ctt22sTruef.png index e195388..05b3068 100644 --- a/data/CLs/plots/DDstar_p/0.65Ctt22sTruef.png +++ b/data/CLs/plots/DDstar_p/0.65Ctt22sTruef.png Binary files differ diff --git a/data/CLs/plots/DDstar_p/0.65Ctt23sFalsef.png b/data/CLs/plots/DDstar_p/0.65Ctt23sFalsef.png index c982eee..0c7acb9 100644 --- a/data/CLs/plots/DDstar_p/0.65Ctt23sFalsef.png +++ b/data/CLs/plots/DDstar_p/0.65Ctt23sFalsef.png Binary files differ diff --git a/data/CLs/plots/DDstar_p/0.68Ctt24sTruef.png b/data/CLs/plots/DDstar_p/0.68Ctt24sTruef.png index 14cb9b9..78787fc 100644 --- a/data/CLs/plots/DDstar_p/0.68Ctt24sTruef.png +++ b/data/CLs/plots/DDstar_p/0.68Ctt24sTruef.png Binary files differ diff --git a/data/CLs/plots/DDstar_p/0.68Ctt25sFalsef.png b/data/CLs/plots/DDstar_p/0.68Ctt25sFalsef.png index 400e09b..113ccd1 100644 --- a/data/CLs/plots/DDstar_p/0.68Ctt25sFalsef.png +++ b/data/CLs/plots/DDstar_p/0.68Ctt25sFalsef.png Binary files differ diff --git a/data/CLs/plots/DDstar_p/0.70Ctt26sTruef.png b/data/CLs/plots/DDstar_p/0.70Ctt26sTruef.png index b4e5f0b..5dbba4a 100644 --- a/data/CLs/plots/DDstar_p/0.70Ctt26sTruef.png +++ b/data/CLs/plots/DDstar_p/0.70Ctt26sTruef.png Binary files differ diff --git a/data/CLs/plots/DDstar_p/0.70Ctt27sFalsef.png b/data/CLs/plots/DDstar_p/0.70Ctt27sFalsef.png index d2125d8..78a9806 100644 --- a/data/CLs/plots/DDstar_p/0.70Ctt27sFalsef.png +++ b/data/CLs/plots/DDstar_p/0.70Ctt27sFalsef.png Binary files differ diff --git a/data/CLs/plots/DDstar_p/0.73Ctt28sTruef.png b/data/CLs/plots/DDstar_p/0.73Ctt28sTruef.png index 88a83c0..ec6900d 100644 --- a/data/CLs/plots/DDstar_p/0.73Ctt28sTruef.png +++ b/data/CLs/plots/DDstar_p/0.73Ctt28sTruef.png Binary files differ diff --git a/data/CLs/plots/DDstar_p/0.73Ctt29sFalsef.png b/data/CLs/plots/DDstar_p/0.73Ctt29sFalsef.png index 84ada9e..81155c5 100644 --- a/data/CLs/plots/DDstar_p/0.73Ctt29sFalsef.png +++ b/data/CLs/plots/DDstar_p/0.73Ctt29sFalsef.png Binary files differ diff --git a/data/CLs/plots/DDstar_p/0.75Ctt30sTruef.png b/data/CLs/plots/DDstar_p/0.75Ctt30sTruef.png index a8a4eb0..45dcd0e 100644 --- a/data/CLs/plots/DDstar_p/0.75Ctt30sTruef.png +++ b/data/CLs/plots/DDstar_p/0.75Ctt30sTruef.png Binary files differ diff --git a/data/CLs/plots/DDstar_p/0.75Ctt31sFalsef.png b/data/CLs/plots/DDstar_p/0.75Ctt31sFalsef.png index 804168d..b8704a3 100644 --- a/data/CLs/plots/DDstar_p/0.75Ctt31sFalsef.png +++ b/data/CLs/plots/DDstar_p/0.75Ctt31sFalsef.png Binary files differ diff --git a/data/CLs/plots/DDstar_p/0.78Ctt32sTruef.png b/data/CLs/plots/DDstar_p/0.78Ctt32sTruef.png index ff10c42..a36d981 100644 --- a/data/CLs/plots/DDstar_p/0.78Ctt32sTruef.png +++ b/data/CLs/plots/DDstar_p/0.78Ctt32sTruef.png Binary files differ diff --git a/data/CLs/plots/DDstar_p/0.78Ctt33sFalsef.png b/data/CLs/plots/DDstar_p/0.78Ctt33sFalsef.png index de1ab41..988f104 100644 --- a/data/CLs/plots/DDstar_p/0.78Ctt33sFalsef.png +++ b/data/CLs/plots/DDstar_p/0.78Ctt33sFalsef.png Binary files differ diff --git a/data/CLs/plots/DDstar_p/0.80Ctt34sTruef.png b/data/CLs/plots/DDstar_p/0.80Ctt34sTruef.png index cae7e60..35a208d 100644 --- a/data/CLs/plots/DDstar_p/0.80Ctt34sTruef.png +++ b/data/CLs/plots/DDstar_p/0.80Ctt34sTruef.png Binary files differ diff --git a/data/CLs/plots/DDstar_p/0.80Ctt35sFalsef.png b/data/CLs/plots/DDstar_p/0.80Ctt35sFalsef.png index 6b5b3bc..ebacc97 100644 --- a/data/CLs/plots/DDstar_p/0.80Ctt35sFalsef.png +++ b/data/CLs/plots/DDstar_p/0.80Ctt35sFalsef.png Binary files differ diff --git a/data/CLs/plots/DDstar_p/0.82Ctt36sTruef.png b/data/CLs/plots/DDstar_p/0.82Ctt36sTruef.png index 66152d7..8c0523b 100644 --- a/data/CLs/plots/DDstar_p/0.82Ctt36sTruef.png +++ b/data/CLs/plots/DDstar_p/0.82Ctt36sTruef.png Binary files differ diff --git a/data/CLs/plots/DDstar_p/0.82Ctt37sFalsef.png b/data/CLs/plots/DDstar_p/0.82Ctt37sFalsef.png index adb293f..696f8d1 100644 --- a/data/CLs/plots/DDstar_p/0.82Ctt37sFalsef.png +++ b/data/CLs/plots/DDstar_p/0.82Ctt37sFalsef.png Binary files differ diff --git a/data/CLs/plots/DDstar_p/0.85Ctt38sTruef.png b/data/CLs/plots/DDstar_p/0.85Ctt38sTruef.png index c202dd6..8da9e30 100644 --- a/data/CLs/plots/DDstar_p/0.85Ctt38sTruef.png +++ b/data/CLs/plots/DDstar_p/0.85Ctt38sTruef.png Binary files differ diff --git a/data/CLs/plots/DDstar_p/0.85Ctt39sFalsef.png b/data/CLs/plots/DDstar_p/0.85Ctt39sFalsef.png index d9ed53d..9a233a1 100644 --- a/data/CLs/plots/DDstar_p/0.85Ctt39sFalsef.png +++ b/data/CLs/plots/DDstar_p/0.85Ctt39sFalsef.png Binary files differ diff --git a/data/CLs/plots/DDstar_s/0.00Ctt0sTruef.png b/data/CLs/plots/DDstar_s/0.00Ctt0sTruef.png index 48a36f8..36895ec 100644 --- a/data/CLs/plots/DDstar_s/0.00Ctt0sTruef.png +++ b/data/CLs/plots/DDstar_s/0.00Ctt0sTruef.png Binary files differ diff --git a/data/CLs/plots/DDstar_s/0.00Ctt1sFalsef.png b/data/CLs/plots/DDstar_s/0.00Ctt1sFalsef.png index 5867756..2b4310c 100644 --- a/data/CLs/plots/DDstar_s/0.00Ctt1sFalsef.png +++ b/data/CLs/plots/DDstar_s/0.00Ctt1sFalsef.png Binary files differ diff --git a/data/CLs/plots/DDstar_s/0.25Ctt2sTruef.png b/data/CLs/plots/DDstar_s/0.25Ctt2sTruef.png index 3a98ee9..a4ded66 100644 --- a/data/CLs/plots/DDstar_s/0.25Ctt2sTruef.png +++ b/data/CLs/plots/DDstar_s/0.25Ctt2sTruef.png Binary files differ diff --git a/data/CLs/plots/DDstar_s/0.25Ctt3sFalsef.png b/data/CLs/plots/DDstar_s/0.25Ctt3sFalsef.png index 3fe6f2d..486a02c 100644 --- a/data/CLs/plots/DDstar_s/0.25Ctt3sFalsef.png +++ b/data/CLs/plots/DDstar_s/0.25Ctt3sFalsef.png Binary files differ diff --git a/data/CLs/plots/DDstar_s/0.31Ctt4sTruef.png b/data/CLs/plots/DDstar_s/0.31Ctt4sTruef.png index 5f2fce0..72a071e 100644 --- a/data/CLs/plots/DDstar_s/0.31Ctt4sTruef.png +++ b/data/CLs/plots/DDstar_s/0.31Ctt4sTruef.png Binary files differ diff --git a/data/CLs/plots/DDstar_s/0.31Ctt5sFalsef.png b/data/CLs/plots/DDstar_s/0.31Ctt5sFalsef.png index 50c4014..701e54d 100644 --- a/data/CLs/plots/DDstar_s/0.31Ctt5sFalsef.png +++ b/data/CLs/plots/DDstar_s/0.31Ctt5sFalsef.png Binary files differ diff --git a/data/CLs/plots/DDstar_s/0.36Ctt6sTruef.png b/data/CLs/plots/DDstar_s/0.36Ctt6sTruef.png index 3ee5247..888f7af 100644 --- a/data/CLs/plots/DDstar_s/0.36Ctt6sTruef.png +++ b/data/CLs/plots/DDstar_s/0.36Ctt6sTruef.png Binary files differ diff --git a/data/CLs/plots/DDstar_s/0.36Ctt7sFalsef.png b/data/CLs/plots/DDstar_s/0.36Ctt7sFalsef.png index 18097c0..3a6a4fc 100644 --- a/data/CLs/plots/DDstar_s/0.36Ctt7sFalsef.png +++ b/data/CLs/plots/DDstar_s/0.36Ctt7sFalsef.png Binary files differ diff --git a/data/CLs/plots/DDstar_s/0.41Ctt8sTruef.png b/data/CLs/plots/DDstar_s/0.41Ctt8sTruef.png index 64d86af..866639e 100644 --- a/data/CLs/plots/DDstar_s/0.41Ctt8sTruef.png +++ b/data/CLs/plots/DDstar_s/0.41Ctt8sTruef.png Binary files differ diff --git a/data/CLs/plots/DDstar_s/0.41Ctt9sFalsef.png b/data/CLs/plots/DDstar_s/0.41Ctt9sFalsef.png index cca9da9..f07678d 100644 --- a/data/CLs/plots/DDstar_s/0.41Ctt9sFalsef.png +++ b/data/CLs/plots/DDstar_s/0.41Ctt9sFalsef.png Binary files differ diff --git a/data/CLs/plots/DDstar_s/0.45Ctt10sTruef.png b/data/CLs/plots/DDstar_s/0.45Ctt10sTruef.png index fcabe62..6b42ef2 100644 --- a/data/CLs/plots/DDstar_s/0.45Ctt10sTruef.png +++ b/data/CLs/plots/DDstar_s/0.45Ctt10sTruef.png Binary files differ diff --git a/data/CLs/plots/DDstar_s/0.45Ctt11sFalsef.png b/data/CLs/plots/DDstar_s/0.45Ctt11sFalsef.png index 047ac4a..046091d 100644 --- a/data/CLs/plots/DDstar_s/0.45Ctt11sFalsef.png +++ b/data/CLs/plots/DDstar_s/0.45Ctt11sFalsef.png Binary files differ diff --git a/data/CLs/plots/DDstar_s/0.49Ctt12sTruef.png b/data/CLs/plots/DDstar_s/0.49Ctt12sTruef.png index 1fb5f9f..64e9cbc 100644 --- a/data/CLs/plots/DDstar_s/0.49Ctt12sTruef.png +++ b/data/CLs/plots/DDstar_s/0.49Ctt12sTruef.png Binary files differ diff --git a/data/CLs/plots/DDstar_s/0.49Ctt13sFalsef.png b/data/CLs/plots/DDstar_s/0.49Ctt13sFalsef.png index e9fde64..5ee7d12 100644 --- a/data/CLs/plots/DDstar_s/0.49Ctt13sFalsef.png +++ b/data/CLs/plots/DDstar_s/0.49Ctt13sFalsef.png Binary files differ diff --git a/data/CLs/plots/DDstar_s/0.53Ctt14sTruef.png b/data/CLs/plots/DDstar_s/0.53Ctt14sTruef.png index 84649a2..3ad4fb8 100644 --- a/data/CLs/plots/DDstar_s/0.53Ctt14sTruef.png +++ b/data/CLs/plots/DDstar_s/0.53Ctt14sTruef.png Binary files differ diff --git a/data/CLs/plots/DDstar_s/0.53Ctt15sFalsef.png b/data/CLs/plots/DDstar_s/0.53Ctt15sFalsef.png index 0e250b6..6ad3bd3 100644 --- a/data/CLs/plots/DDstar_s/0.53Ctt15sFalsef.png +++ b/data/CLs/plots/DDstar_s/0.53Ctt15sFalsef.png Binary files differ diff --git a/data/CLs/plots/DDstar_s/0.56Ctt16sTruef.png b/data/CLs/plots/DDstar_s/0.56Ctt16sTruef.png index d861490..9acaeaa 100644 --- a/data/CLs/plots/DDstar_s/0.56Ctt16sTruef.png +++ b/data/CLs/plots/DDstar_s/0.56Ctt16sTruef.png Binary files differ diff --git a/data/CLs/plots/DDstar_s/0.56Ctt17sFalsef.png b/data/CLs/plots/DDstar_s/0.56Ctt17sFalsef.png index 5291d82..f832ac8 100644 --- a/data/CLs/plots/DDstar_s/0.56Ctt17sFalsef.png +++ b/data/CLs/plots/DDstar_s/0.56Ctt17sFalsef.png Binary files differ diff --git a/data/CLs/plots/DDstar_s/0.59Ctt18sTruef.png b/data/CLs/plots/DDstar_s/0.59Ctt18sTruef.png index bfa87c3..36f392e 100644 --- a/data/CLs/plots/DDstar_s/0.59Ctt18sTruef.png +++ b/data/CLs/plots/DDstar_s/0.59Ctt18sTruef.png Binary files differ diff --git a/data/CLs/plots/DDstar_s/0.59Ctt19sFalsef.png b/data/CLs/plots/DDstar_s/0.59Ctt19sFalsef.png index 0f52d45..53bac37 100644 --- a/data/CLs/plots/DDstar_s/0.59Ctt19sFalsef.png +++ b/data/CLs/plots/DDstar_s/0.59Ctt19sFalsef.png Binary files differ diff --git a/data/CLs/plots/DDstar_s/0.62Ctt20sTruef.png b/data/CLs/plots/DDstar_s/0.62Ctt20sTruef.png index 6c8805b..3a495a8 100644 --- a/data/CLs/plots/DDstar_s/0.62Ctt20sTruef.png +++ b/data/CLs/plots/DDstar_s/0.62Ctt20sTruef.png Binary files differ diff --git a/data/CLs/plots/DDstar_s/0.62Ctt21sFalsef.png b/data/CLs/plots/DDstar_s/0.62Ctt21sFalsef.png index 0ac0ccb..c872d33 100644 --- a/data/CLs/plots/DDstar_s/0.62Ctt21sFalsef.png +++ b/data/CLs/plots/DDstar_s/0.62Ctt21sFalsef.png Binary files differ diff --git a/data/CLs/plots/DDstar_s/0.65Ctt22sTruef.png b/data/CLs/plots/DDstar_s/0.65Ctt22sTruef.png index b1fbb29..9d5ba2c 100644 --- a/data/CLs/plots/DDstar_s/0.65Ctt22sTruef.png +++ b/data/CLs/plots/DDstar_s/0.65Ctt22sTruef.png Binary files differ diff --git a/data/CLs/plots/DDstar_s/0.65Ctt23sFalsef.png b/data/CLs/plots/DDstar_s/0.65Ctt23sFalsef.png index 039a90d..ddd7683 100644 --- a/data/CLs/plots/DDstar_s/0.65Ctt23sFalsef.png +++ b/data/CLs/plots/DDstar_s/0.65Ctt23sFalsef.png Binary files differ diff --git a/data/CLs/plots/DDstar_s/0.68Ctt24sTruef.png b/data/CLs/plots/DDstar_s/0.68Ctt24sTruef.png index e7e9365..eea99b9 100644 --- a/data/CLs/plots/DDstar_s/0.68Ctt24sTruef.png +++ b/data/CLs/plots/DDstar_s/0.68Ctt24sTruef.png Binary files differ diff --git a/data/CLs/plots/DDstar_s/0.68Ctt25sFalsef.png b/data/CLs/plots/DDstar_s/0.68Ctt25sFalsef.png index e8a571c..4eca50b 100644 --- a/data/CLs/plots/DDstar_s/0.68Ctt25sFalsef.png +++ b/data/CLs/plots/DDstar_s/0.68Ctt25sFalsef.png Binary files differ diff --git a/data/CLs/plots/DDstar_s/0.70Ctt26sTruef.png b/data/CLs/plots/DDstar_s/0.70Ctt26sTruef.png index 08efa5b..d67d8bd 100644 --- a/data/CLs/plots/DDstar_s/0.70Ctt26sTruef.png +++ b/data/CLs/plots/DDstar_s/0.70Ctt26sTruef.png Binary files differ diff --git a/data/CLs/plots/DDstar_s/0.70Ctt27sFalsef.png b/data/CLs/plots/DDstar_s/0.70Ctt27sFalsef.png index 53de7fb..bc9af5d 100644 --- a/data/CLs/plots/DDstar_s/0.70Ctt27sFalsef.png +++ b/data/CLs/plots/DDstar_s/0.70Ctt27sFalsef.png Binary files differ diff --git a/data/CLs/plots/DDstar_s/0.73Ctt28sTruef.png b/data/CLs/plots/DDstar_s/0.73Ctt28sTruef.png index ec4b04a..9f7da8a 100644 --- a/data/CLs/plots/DDstar_s/0.73Ctt28sTruef.png +++ b/data/CLs/plots/DDstar_s/0.73Ctt28sTruef.png Binary files differ diff --git a/data/CLs/plots/DDstar_s/0.73Ctt29sFalsef.png b/data/CLs/plots/DDstar_s/0.73Ctt29sFalsef.png index cc06610..539d843 100644 --- a/data/CLs/plots/DDstar_s/0.73Ctt29sFalsef.png +++ b/data/CLs/plots/DDstar_s/0.73Ctt29sFalsef.png Binary files differ diff --git a/data/CLs/plots/DDstar_s/0.75Ctt30sTruef.png b/data/CLs/plots/DDstar_s/0.75Ctt30sTruef.png index 3baef3f..44cd0e5 100644 --- a/data/CLs/plots/DDstar_s/0.75Ctt30sTruef.png +++ b/data/CLs/plots/DDstar_s/0.75Ctt30sTruef.png Binary files differ diff --git a/data/CLs/plots/DDstar_s/0.75Ctt31sFalsef.png b/data/CLs/plots/DDstar_s/0.75Ctt31sFalsef.png index cb884af..d0606bd 100644 --- a/data/CLs/plots/DDstar_s/0.75Ctt31sFalsef.png +++ b/data/CLs/plots/DDstar_s/0.75Ctt31sFalsef.png Binary files differ diff --git a/data/CLs/plots/DDstar_s/0.78Ctt32sTruef.png b/data/CLs/plots/DDstar_s/0.78Ctt32sTruef.png index 7764b66..1259bb5 100644 --- a/data/CLs/plots/DDstar_s/0.78Ctt32sTruef.png +++ b/data/CLs/plots/DDstar_s/0.78Ctt32sTruef.png Binary files differ diff --git a/data/CLs/plots/DDstar_s/0.78Ctt33sFalsef.png b/data/CLs/plots/DDstar_s/0.78Ctt33sFalsef.png index ec90998..1d864a4 100644 --- a/data/CLs/plots/DDstar_s/0.78Ctt33sFalsef.png +++ b/data/CLs/plots/DDstar_s/0.78Ctt33sFalsef.png Binary files differ diff --git a/data/CLs/plots/DDstar_s/0.80Ctt34sTruef.png b/data/CLs/plots/DDstar_s/0.80Ctt34sTruef.png index c8b3bb2..e5e5a4f 100644 --- a/data/CLs/plots/DDstar_s/0.80Ctt34sTruef.png +++ b/data/CLs/plots/DDstar_s/0.80Ctt34sTruef.png Binary files differ diff --git a/data/CLs/plots/DDstar_s/0.80Ctt35sFalsef.png b/data/CLs/plots/DDstar_s/0.80Ctt35sFalsef.png index d95adeb..68bbc76 100644 --- a/data/CLs/plots/DDstar_s/0.80Ctt35sFalsef.png +++ b/data/CLs/plots/DDstar_s/0.80Ctt35sFalsef.png Binary files differ diff --git a/data/CLs/plots/DDstar_s/0.82Ctt36sTruef.png b/data/CLs/plots/DDstar_s/0.82Ctt36sTruef.png index 9279feb..c9d162b 100644 --- a/data/CLs/plots/DDstar_s/0.82Ctt36sTruef.png +++ b/data/CLs/plots/DDstar_s/0.82Ctt36sTruef.png Binary files differ diff --git a/data/CLs/plots/DDstar_s/0.82Ctt37sFalsef.png b/data/CLs/plots/DDstar_s/0.82Ctt37sFalsef.png index f885fbd..72dac67 100644 --- a/data/CLs/plots/DDstar_s/0.82Ctt37sFalsef.png +++ b/data/CLs/plots/DDstar_s/0.82Ctt37sFalsef.png Binary files differ diff --git a/data/CLs/plots/DDstar_s/0.85Ctt38sTruef.png b/data/CLs/plots/DDstar_s/0.85Ctt38sTruef.png index b00ae0a..16c1d6c 100644 --- a/data/CLs/plots/DDstar_s/0.85Ctt38sTruef.png +++ b/data/CLs/plots/DDstar_s/0.85Ctt38sTruef.png Binary files differ diff --git a/data/CLs/plots/DDstar_s/0.85Ctt39sFalsef.png b/data/CLs/plots/DDstar_s/0.85Ctt39sFalsef.png index da5b21b..f226515 100644 --- a/data/CLs/plots/DDstar_s/0.85Ctt39sFalsef.png +++ b/data/CLs/plots/DDstar_s/0.85Ctt39sFalsef.png Binary files differ diff --git a/data/CLs/plots/Dbar_p/0.00Ctt0sTruef.png b/data/CLs/plots/Dbar_p/0.00Ctt0sTruef.png index cc292d0..4484fa5 100644 --- a/data/CLs/plots/Dbar_p/0.00Ctt0sTruef.png +++ b/data/CLs/plots/Dbar_p/0.00Ctt0sTruef.png Binary files differ diff --git a/data/CLs/plots/Dbar_p/0.00Ctt1sFalsef.png b/data/CLs/plots/Dbar_p/0.00Ctt1sFalsef.png index 0b6a123..b141b46 100644 --- a/data/CLs/plots/Dbar_p/0.00Ctt1sFalsef.png +++ b/data/CLs/plots/Dbar_p/0.00Ctt1sFalsef.png Binary files differ diff --git a/data/CLs/plots/Dbar_p/0.25Ctt2sTruef.png b/data/CLs/plots/Dbar_p/0.25Ctt2sTruef.png index 09a6d7d..4d934a4 100644 --- a/data/CLs/plots/Dbar_p/0.25Ctt2sTruef.png +++ b/data/CLs/plots/Dbar_p/0.25Ctt2sTruef.png Binary files differ diff --git a/data/CLs/plots/Dbar_p/0.25Ctt3sFalsef.png b/data/CLs/plots/Dbar_p/0.25Ctt3sFalsef.png index 375633e..0a4955e 100644 --- a/data/CLs/plots/Dbar_p/0.25Ctt3sFalsef.png +++ b/data/CLs/plots/Dbar_p/0.25Ctt3sFalsef.png Binary files differ diff --git a/data/CLs/plots/Dbar_p/0.31Ctt4sTruef.png b/data/CLs/plots/Dbar_p/0.31Ctt4sTruef.png index 3b23adb..e05606e 100644 --- a/data/CLs/plots/Dbar_p/0.31Ctt4sTruef.png +++ b/data/CLs/plots/Dbar_p/0.31Ctt4sTruef.png Binary files differ diff --git a/data/CLs/plots/Dbar_p/0.31Ctt5sFalsef.png b/data/CLs/plots/Dbar_p/0.31Ctt5sFalsef.png index e6ed0d8..6ccbf62 100644 --- a/data/CLs/plots/Dbar_p/0.31Ctt5sFalsef.png +++ b/data/CLs/plots/Dbar_p/0.31Ctt5sFalsef.png Binary files differ diff --git a/data/CLs/plots/Dbar_p/0.36Ctt6sTruef.png b/data/CLs/plots/Dbar_p/0.36Ctt6sTruef.png index b16c21f..8982d3a 100644 --- a/data/CLs/plots/Dbar_p/0.36Ctt6sTruef.png +++ b/data/CLs/plots/Dbar_p/0.36Ctt6sTruef.png Binary files differ diff --git a/data/CLs/plots/Dbar_p/0.36Ctt7sFalsef.png b/data/CLs/plots/Dbar_p/0.36Ctt7sFalsef.png index c845bff..e328d85 100644 --- a/data/CLs/plots/Dbar_p/0.36Ctt7sFalsef.png +++ b/data/CLs/plots/Dbar_p/0.36Ctt7sFalsef.png Binary files differ diff --git a/data/CLs/plots/Dbar_p/0.41Ctt8sTruef.png b/data/CLs/plots/Dbar_p/0.41Ctt8sTruef.png index 4c124db..fbb528b 100644 --- a/data/CLs/plots/Dbar_p/0.41Ctt8sTruef.png +++ b/data/CLs/plots/Dbar_p/0.41Ctt8sTruef.png Binary files differ diff --git a/data/CLs/plots/Dbar_p/0.41Ctt9sFalsef.png b/data/CLs/plots/Dbar_p/0.41Ctt9sFalsef.png index f6e21ac..cdb6847 100644 --- a/data/CLs/plots/Dbar_p/0.41Ctt9sFalsef.png +++ b/data/CLs/plots/Dbar_p/0.41Ctt9sFalsef.png Binary files differ diff --git a/data/CLs/plots/Dbar_p/0.45Ctt10sTruef.png b/data/CLs/plots/Dbar_p/0.45Ctt10sTruef.png index 4c9c575..3b10472 100644 --- a/data/CLs/plots/Dbar_p/0.45Ctt10sTruef.png +++ b/data/CLs/plots/Dbar_p/0.45Ctt10sTruef.png Binary files differ diff --git a/data/CLs/plots/Dbar_p/0.45Ctt11sFalsef.png b/data/CLs/plots/Dbar_p/0.45Ctt11sFalsef.png index 10b7181..7e64ad2 100644 --- a/data/CLs/plots/Dbar_p/0.45Ctt11sFalsef.png +++ b/data/CLs/plots/Dbar_p/0.45Ctt11sFalsef.png Binary files differ diff --git a/data/CLs/plots/Dbar_p/0.49Ctt12sTruef.png b/data/CLs/plots/Dbar_p/0.49Ctt12sTruef.png index 4a9229b..7a684c1 100644 --- a/data/CLs/plots/Dbar_p/0.49Ctt12sTruef.png +++ b/data/CLs/plots/Dbar_p/0.49Ctt12sTruef.png Binary files differ diff --git a/data/CLs/plots/Dbar_p/0.49Ctt13sFalsef.png b/data/CLs/plots/Dbar_p/0.49Ctt13sFalsef.png index 58398fd..c6b2bcc 100644 --- a/data/CLs/plots/Dbar_p/0.49Ctt13sFalsef.png +++ b/data/CLs/plots/Dbar_p/0.49Ctt13sFalsef.png Binary files differ diff --git a/data/CLs/plots/Dbar_p/0.53Ctt14sTruef.png b/data/CLs/plots/Dbar_p/0.53Ctt14sTruef.png index 59faa78..2b60b99 100644 --- a/data/CLs/plots/Dbar_p/0.53Ctt14sTruef.png +++ b/data/CLs/plots/Dbar_p/0.53Ctt14sTruef.png Binary files differ diff --git a/data/CLs/plots/Dbar_p/0.53Ctt15sFalsef.png b/data/CLs/plots/Dbar_p/0.53Ctt15sFalsef.png index 642d4b0..72b837e 100644 --- a/data/CLs/plots/Dbar_p/0.53Ctt15sFalsef.png +++ b/data/CLs/plots/Dbar_p/0.53Ctt15sFalsef.png Binary files differ diff --git a/data/CLs/plots/Dbar_p/0.56Ctt16sTruef.png b/data/CLs/plots/Dbar_p/0.56Ctt16sTruef.png index 9c66d7c..097b27b 100644 --- a/data/CLs/plots/Dbar_p/0.56Ctt16sTruef.png +++ b/data/CLs/plots/Dbar_p/0.56Ctt16sTruef.png Binary files differ diff --git a/data/CLs/plots/Dbar_p/0.56Ctt17sFalsef.png b/data/CLs/plots/Dbar_p/0.56Ctt17sFalsef.png index a871a31..fadd042 100644 --- a/data/CLs/plots/Dbar_p/0.56Ctt17sFalsef.png +++ b/data/CLs/plots/Dbar_p/0.56Ctt17sFalsef.png Binary files differ diff --git a/data/CLs/plots/Dbar_p/0.59Ctt18sTruef.png b/data/CLs/plots/Dbar_p/0.59Ctt18sTruef.png index 19d0c35..eb542f7 100644 --- a/data/CLs/plots/Dbar_p/0.59Ctt18sTruef.png +++ b/data/CLs/plots/Dbar_p/0.59Ctt18sTruef.png Binary files differ diff --git a/data/CLs/plots/Dbar_p/0.59Ctt19sFalsef.png b/data/CLs/plots/Dbar_p/0.59Ctt19sFalsef.png index 47ec5f3..ccbb5fb 100644 --- a/data/CLs/plots/Dbar_p/0.59Ctt19sFalsef.png +++ b/data/CLs/plots/Dbar_p/0.59Ctt19sFalsef.png Binary files differ diff --git a/data/CLs/plots/Dbar_p/0.62Ctt20sTruef.png b/data/CLs/plots/Dbar_p/0.62Ctt20sTruef.png index e0efb8b..1b01f69 100644 --- a/data/CLs/plots/Dbar_p/0.62Ctt20sTruef.png +++ b/data/CLs/plots/Dbar_p/0.62Ctt20sTruef.png Binary files differ diff --git a/data/CLs/plots/Dbar_p/0.62Ctt21sFalsef.png b/data/CLs/plots/Dbar_p/0.62Ctt21sFalsef.png index dd1fd27..11f7562 100644 --- a/data/CLs/plots/Dbar_p/0.62Ctt21sFalsef.png +++ b/data/CLs/plots/Dbar_p/0.62Ctt21sFalsef.png Binary files differ diff --git a/data/CLs/plots/Dbar_p/0.65Ctt22sTruef.png b/data/CLs/plots/Dbar_p/0.65Ctt22sTruef.png index e485322..073d5b2 100644 --- a/data/CLs/plots/Dbar_p/0.65Ctt22sTruef.png +++ b/data/CLs/plots/Dbar_p/0.65Ctt22sTruef.png Binary files differ diff --git a/data/CLs/plots/Dbar_p/0.65Ctt23sFalsef.png b/data/CLs/plots/Dbar_p/0.65Ctt23sFalsef.png index 8006475..f34b915 100644 --- a/data/CLs/plots/Dbar_p/0.65Ctt23sFalsef.png +++ b/data/CLs/plots/Dbar_p/0.65Ctt23sFalsef.png Binary files differ diff --git a/data/CLs/plots/Dbar_p/0.68Ctt24sTruef.png b/data/CLs/plots/Dbar_p/0.68Ctt24sTruef.png index 70ce660..a765d03 100644 --- a/data/CLs/plots/Dbar_p/0.68Ctt24sTruef.png +++ b/data/CLs/plots/Dbar_p/0.68Ctt24sTruef.png Binary files differ diff --git a/data/CLs/plots/Dbar_p/0.68Ctt25sFalsef.png b/data/CLs/plots/Dbar_p/0.68Ctt25sFalsef.png index 0e3d4c4..f8a89cb 100644 --- a/data/CLs/plots/Dbar_p/0.68Ctt25sFalsef.png +++ b/data/CLs/plots/Dbar_p/0.68Ctt25sFalsef.png Binary files differ diff --git a/data/CLs/plots/Dbar_p/0.70Ctt26sTruef.png b/data/CLs/plots/Dbar_p/0.70Ctt26sTruef.png index 2c7dd3b..e2dca68 100644 --- a/data/CLs/plots/Dbar_p/0.70Ctt26sTruef.png +++ b/data/CLs/plots/Dbar_p/0.70Ctt26sTruef.png Binary files differ diff --git a/data/CLs/plots/Dbar_p/0.70Ctt27sFalsef.png b/data/CLs/plots/Dbar_p/0.70Ctt27sFalsef.png index f393b86..e6009be 100644 --- a/data/CLs/plots/Dbar_p/0.70Ctt27sFalsef.png +++ b/data/CLs/plots/Dbar_p/0.70Ctt27sFalsef.png Binary files differ diff --git a/data/CLs/plots/Dbar_p/0.73Ctt28sTruef.png b/data/CLs/plots/Dbar_p/0.73Ctt28sTruef.png index e48a0a7..91ae31f 100644 --- a/data/CLs/plots/Dbar_p/0.73Ctt28sTruef.png +++ b/data/CLs/plots/Dbar_p/0.73Ctt28sTruef.png Binary files differ diff --git a/data/CLs/plots/Dbar_p/0.73Ctt29sFalsef.png b/data/CLs/plots/Dbar_p/0.73Ctt29sFalsef.png index 5bf9a4f..4238cb3 100644 --- a/data/CLs/plots/Dbar_p/0.73Ctt29sFalsef.png +++ b/data/CLs/plots/Dbar_p/0.73Ctt29sFalsef.png Binary files differ diff --git a/data/CLs/plots/Dbar_p/0.75Ctt30sTruef.png b/data/CLs/plots/Dbar_p/0.75Ctt30sTruef.png index 8bb0af3..1502e66 100644 --- a/data/CLs/plots/Dbar_p/0.75Ctt30sTruef.png +++ b/data/CLs/plots/Dbar_p/0.75Ctt30sTruef.png Binary files differ diff --git a/data/CLs/plots/Dbar_p/0.75Ctt31sFalsef.png b/data/CLs/plots/Dbar_p/0.75Ctt31sFalsef.png index b39119b..fd3b9a0 100644 --- a/data/CLs/plots/Dbar_p/0.75Ctt31sFalsef.png +++ b/data/CLs/plots/Dbar_p/0.75Ctt31sFalsef.png Binary files differ diff --git a/data/CLs/plots/Dbar_p/0.78Ctt32sTruef.png b/data/CLs/plots/Dbar_p/0.78Ctt32sTruef.png index e73453b..6c471df 100644 --- a/data/CLs/plots/Dbar_p/0.78Ctt32sTruef.png +++ b/data/CLs/plots/Dbar_p/0.78Ctt32sTruef.png Binary files differ diff --git a/data/CLs/plots/Dbar_p/0.78Ctt33sFalsef.png b/data/CLs/plots/Dbar_p/0.78Ctt33sFalsef.png index 465bc1c..c17952b 100644 --- a/data/CLs/plots/Dbar_p/0.78Ctt33sFalsef.png +++ b/data/CLs/plots/Dbar_p/0.78Ctt33sFalsef.png Binary files differ diff --git a/data/CLs/plots/Dbar_p/0.80Ctt34sTruef.png b/data/CLs/plots/Dbar_p/0.80Ctt34sTruef.png index 5f3bc65..2be670c 100644 --- a/data/CLs/plots/Dbar_p/0.80Ctt34sTruef.png +++ b/data/CLs/plots/Dbar_p/0.80Ctt34sTruef.png Binary files differ diff --git a/data/CLs/plots/Dbar_p/0.80Ctt35sFalsef.png b/data/CLs/plots/Dbar_p/0.80Ctt35sFalsef.png index 0b935ac..b834e4f 100644 --- a/data/CLs/plots/Dbar_p/0.80Ctt35sFalsef.png +++ b/data/CLs/plots/Dbar_p/0.80Ctt35sFalsef.png Binary files differ diff --git a/data/CLs/plots/Dbar_p/0.82Ctt36sTruef.png b/data/CLs/plots/Dbar_p/0.82Ctt36sTruef.png index 45967ae..97197a1 100644 --- a/data/CLs/plots/Dbar_p/0.82Ctt36sTruef.png +++ b/data/CLs/plots/Dbar_p/0.82Ctt36sTruef.png Binary files differ diff --git a/data/CLs/plots/Dbar_p/0.82Ctt37sFalsef.png b/data/CLs/plots/Dbar_p/0.82Ctt37sFalsef.png index 990fc33..a64f31a 100644 --- a/data/CLs/plots/Dbar_p/0.82Ctt37sFalsef.png +++ b/data/CLs/plots/Dbar_p/0.82Ctt37sFalsef.png Binary files differ diff --git a/data/CLs/plots/Dbar_p/0.85Ctt38sTruef.png b/data/CLs/plots/Dbar_p/0.85Ctt38sTruef.png index cc93e63..52da211 100644 --- a/data/CLs/plots/Dbar_p/0.85Ctt38sTruef.png +++ b/data/CLs/plots/Dbar_p/0.85Ctt38sTruef.png Binary files differ diff --git a/data/CLs/plots/Dbar_p/0.85Ctt39sFalsef.png b/data/CLs/plots/Dbar_p/0.85Ctt39sFalsef.png index c0fbc4e..4465187 100644 --- a/data/CLs/plots/Dbar_p/0.85Ctt39sFalsef.png +++ b/data/CLs/plots/Dbar_p/0.85Ctt39sFalsef.png Binary files differ diff --git a/data/CLs/plots/Dbar_s/0.00Ctt0sTruef.png b/data/CLs/plots/Dbar_s/0.00Ctt0sTruef.png index 625fde0..1a65523 100644 --- a/data/CLs/plots/Dbar_s/0.00Ctt0sTruef.png +++ b/data/CLs/plots/Dbar_s/0.00Ctt0sTruef.png Binary files differ diff --git a/data/CLs/plots/Dbar_s/0.00Ctt1sFalsef.png b/data/CLs/plots/Dbar_s/0.00Ctt1sFalsef.png index b72a045..0afbc2f 100644 --- a/data/CLs/plots/Dbar_s/0.00Ctt1sFalsef.png +++ b/data/CLs/plots/Dbar_s/0.00Ctt1sFalsef.png Binary files differ diff --git a/data/CLs/plots/Dbar_s/0.25Ctt2sTruef.png b/data/CLs/plots/Dbar_s/0.25Ctt2sTruef.png index da24101..3082b3c 100644 --- a/data/CLs/plots/Dbar_s/0.25Ctt2sTruef.png +++ b/data/CLs/plots/Dbar_s/0.25Ctt2sTruef.png Binary files differ diff --git a/data/CLs/plots/Dbar_s/0.25Ctt3sFalsef.png b/data/CLs/plots/Dbar_s/0.25Ctt3sFalsef.png index 4c158d6..bddac0b 100644 --- a/data/CLs/plots/Dbar_s/0.25Ctt3sFalsef.png +++ b/data/CLs/plots/Dbar_s/0.25Ctt3sFalsef.png Binary files differ diff --git a/data/CLs/plots/Dbar_s/0.31Ctt4sTruef.png b/data/CLs/plots/Dbar_s/0.31Ctt4sTruef.png index 1c14429..b118c8b 100644 --- a/data/CLs/plots/Dbar_s/0.31Ctt4sTruef.png +++ b/data/CLs/plots/Dbar_s/0.31Ctt4sTruef.png Binary files differ diff --git a/data/CLs/plots/Dbar_s/0.31Ctt5sFalsef.png b/data/CLs/plots/Dbar_s/0.31Ctt5sFalsef.png index 30d1d2d..805b8e0 100644 --- a/data/CLs/plots/Dbar_s/0.31Ctt5sFalsef.png +++ b/data/CLs/plots/Dbar_s/0.31Ctt5sFalsef.png Binary files differ diff --git a/data/CLs/plots/Dbar_s/0.36Ctt6sTruef.png b/data/CLs/plots/Dbar_s/0.36Ctt6sTruef.png index 4da8e0f..f400b9d 100644 --- a/data/CLs/plots/Dbar_s/0.36Ctt6sTruef.png +++ b/data/CLs/plots/Dbar_s/0.36Ctt6sTruef.png Binary files differ diff --git a/data/CLs/plots/Dbar_s/0.36Ctt7sFalsef.png b/data/CLs/plots/Dbar_s/0.36Ctt7sFalsef.png index 590f75c..b43315d 100644 --- a/data/CLs/plots/Dbar_s/0.36Ctt7sFalsef.png +++ b/data/CLs/plots/Dbar_s/0.36Ctt7sFalsef.png Binary files differ diff --git a/data/CLs/plots/Dbar_s/0.41Ctt8sTruef.png b/data/CLs/plots/Dbar_s/0.41Ctt8sTruef.png index 4518183..d662c53 100644 --- a/data/CLs/plots/Dbar_s/0.41Ctt8sTruef.png +++ b/data/CLs/plots/Dbar_s/0.41Ctt8sTruef.png Binary files differ diff --git a/data/CLs/plots/Dbar_s/0.41Ctt9sFalsef.png b/data/CLs/plots/Dbar_s/0.41Ctt9sFalsef.png index 99c5d0a..e6aa3f5 100644 --- a/data/CLs/plots/Dbar_s/0.41Ctt9sFalsef.png +++ b/data/CLs/plots/Dbar_s/0.41Ctt9sFalsef.png Binary files differ diff --git a/data/CLs/plots/Dbar_s/0.45Ctt10sTruef.png b/data/CLs/plots/Dbar_s/0.45Ctt10sTruef.png index e0434a0..7933a67 100644 --- a/data/CLs/plots/Dbar_s/0.45Ctt10sTruef.png +++ b/data/CLs/plots/Dbar_s/0.45Ctt10sTruef.png Binary files differ diff --git a/data/CLs/plots/Dbar_s/0.45Ctt11sFalsef.png b/data/CLs/plots/Dbar_s/0.45Ctt11sFalsef.png index 5207ded..5f670ea 100644 --- a/data/CLs/plots/Dbar_s/0.45Ctt11sFalsef.png +++ b/data/CLs/plots/Dbar_s/0.45Ctt11sFalsef.png Binary files differ diff --git a/data/CLs/plots/Dbar_s/0.49Ctt12sTruef.png b/data/CLs/plots/Dbar_s/0.49Ctt12sTruef.png index 36ac990..a9b4db9 100644 --- a/data/CLs/plots/Dbar_s/0.49Ctt12sTruef.png +++ b/data/CLs/plots/Dbar_s/0.49Ctt12sTruef.png Binary files differ diff --git a/data/CLs/plots/Dbar_s/0.49Ctt13sFalsef.png b/data/CLs/plots/Dbar_s/0.49Ctt13sFalsef.png index 6f113e6..4f2ef3c 100644 --- a/data/CLs/plots/Dbar_s/0.49Ctt13sFalsef.png +++ b/data/CLs/plots/Dbar_s/0.49Ctt13sFalsef.png Binary files differ diff --git a/data/CLs/plots/Dbar_s/0.53Ctt14sTruef.png b/data/CLs/plots/Dbar_s/0.53Ctt14sTruef.png index 9cc35fa..4cb84a2 100644 --- a/data/CLs/plots/Dbar_s/0.53Ctt14sTruef.png +++ b/data/CLs/plots/Dbar_s/0.53Ctt14sTruef.png Binary files differ diff --git a/data/CLs/plots/Dbar_s/0.53Ctt15sFalsef.png b/data/CLs/plots/Dbar_s/0.53Ctt15sFalsef.png index 43f7802..8cbe7a2 100644 --- a/data/CLs/plots/Dbar_s/0.53Ctt15sFalsef.png +++ b/data/CLs/plots/Dbar_s/0.53Ctt15sFalsef.png Binary files differ diff --git a/data/CLs/plots/Dbar_s/0.56Ctt16sTruef.png b/data/CLs/plots/Dbar_s/0.56Ctt16sTruef.png index b5b9853..44288aa 100644 --- a/data/CLs/plots/Dbar_s/0.56Ctt16sTruef.png +++ b/data/CLs/plots/Dbar_s/0.56Ctt16sTruef.png Binary files differ diff --git a/data/CLs/plots/Dbar_s/0.56Ctt17sFalsef.png b/data/CLs/plots/Dbar_s/0.56Ctt17sFalsef.png index c7fc6a4..ea75abc 100644 --- a/data/CLs/plots/Dbar_s/0.56Ctt17sFalsef.png +++ b/data/CLs/plots/Dbar_s/0.56Ctt17sFalsef.png Binary files differ diff --git a/data/CLs/plots/Dbar_s/0.59Ctt18sTruef.png b/data/CLs/plots/Dbar_s/0.59Ctt18sTruef.png index 462a65b..269b900 100644 --- a/data/CLs/plots/Dbar_s/0.59Ctt18sTruef.png +++ b/data/CLs/plots/Dbar_s/0.59Ctt18sTruef.png Binary files differ diff --git a/data/CLs/plots/Dbar_s/0.59Ctt19sFalsef.png b/data/CLs/plots/Dbar_s/0.59Ctt19sFalsef.png index e6694be..03286d5 100644 --- a/data/CLs/plots/Dbar_s/0.59Ctt19sFalsef.png +++ b/data/CLs/plots/Dbar_s/0.59Ctt19sFalsef.png Binary files differ diff --git a/data/CLs/plots/Dbar_s/0.62Ctt20sTruef.png b/data/CLs/plots/Dbar_s/0.62Ctt20sTruef.png index bc31d92..6e39dbd 100644 --- a/data/CLs/plots/Dbar_s/0.62Ctt20sTruef.png +++ b/data/CLs/plots/Dbar_s/0.62Ctt20sTruef.png Binary files differ diff --git a/data/CLs/plots/Dbar_s/0.62Ctt21sFalsef.png b/data/CLs/plots/Dbar_s/0.62Ctt21sFalsef.png index a66db00..98ce056 100644 --- a/data/CLs/plots/Dbar_s/0.62Ctt21sFalsef.png +++ b/data/CLs/plots/Dbar_s/0.62Ctt21sFalsef.png Binary files differ diff --git a/data/CLs/plots/Dbar_s/0.65Ctt22sTruef.png b/data/CLs/plots/Dbar_s/0.65Ctt22sTruef.png index 0e98165..79dd366 100644 --- a/data/CLs/plots/Dbar_s/0.65Ctt22sTruef.png +++ b/data/CLs/plots/Dbar_s/0.65Ctt22sTruef.png Binary files differ diff --git a/data/CLs/plots/Dbar_s/0.65Ctt23sFalsef.png b/data/CLs/plots/Dbar_s/0.65Ctt23sFalsef.png index 400007e..3fe5510 100644 --- a/data/CLs/plots/Dbar_s/0.65Ctt23sFalsef.png +++ b/data/CLs/plots/Dbar_s/0.65Ctt23sFalsef.png Binary files differ diff --git a/data/CLs/plots/Dbar_s/0.68Ctt24sTruef.png b/data/CLs/plots/Dbar_s/0.68Ctt24sTruef.png index e719c95..685da18 100644 --- a/data/CLs/plots/Dbar_s/0.68Ctt24sTruef.png +++ b/data/CLs/plots/Dbar_s/0.68Ctt24sTruef.png Binary files differ diff --git a/data/CLs/plots/Dbar_s/0.68Ctt25sFalsef.png b/data/CLs/plots/Dbar_s/0.68Ctt25sFalsef.png index e2c6efe..8161f4a 100644 --- a/data/CLs/plots/Dbar_s/0.68Ctt25sFalsef.png +++ b/data/CLs/plots/Dbar_s/0.68Ctt25sFalsef.png Binary files differ diff --git a/data/CLs/plots/Dbar_s/0.70Ctt26sTruef.png b/data/CLs/plots/Dbar_s/0.70Ctt26sTruef.png index 243dec8..78ba467 100644 --- a/data/CLs/plots/Dbar_s/0.70Ctt26sTruef.png +++ b/data/CLs/plots/Dbar_s/0.70Ctt26sTruef.png Binary files differ diff --git a/data/CLs/plots/Dbar_s/0.70Ctt27sFalsef.png b/data/CLs/plots/Dbar_s/0.70Ctt27sFalsef.png index 434f990..459343c 100644 --- a/data/CLs/plots/Dbar_s/0.70Ctt27sFalsef.png +++ b/data/CLs/plots/Dbar_s/0.70Ctt27sFalsef.png Binary files differ diff --git a/data/CLs/plots/Dbar_s/0.73Ctt28sTruef.png b/data/CLs/plots/Dbar_s/0.73Ctt28sTruef.png index 06f5ec6..e6f2c43 100644 --- a/data/CLs/plots/Dbar_s/0.73Ctt28sTruef.png +++ b/data/CLs/plots/Dbar_s/0.73Ctt28sTruef.png Binary files differ diff --git a/data/CLs/plots/Dbar_s/0.73Ctt29sFalsef.png b/data/CLs/plots/Dbar_s/0.73Ctt29sFalsef.png index 99e50fe..1552317 100644 --- a/data/CLs/plots/Dbar_s/0.73Ctt29sFalsef.png +++ b/data/CLs/plots/Dbar_s/0.73Ctt29sFalsef.png Binary files differ diff --git a/data/CLs/plots/Dbar_s/0.75Ctt30sTruef.png b/data/CLs/plots/Dbar_s/0.75Ctt30sTruef.png index c2a322f..74c185e 100644 --- a/data/CLs/plots/Dbar_s/0.75Ctt30sTruef.png +++ b/data/CLs/plots/Dbar_s/0.75Ctt30sTruef.png Binary files differ diff --git a/data/CLs/plots/Dbar_s/0.75Ctt31sFalsef.png b/data/CLs/plots/Dbar_s/0.75Ctt31sFalsef.png index 18930e5..1796843 100644 --- a/data/CLs/plots/Dbar_s/0.75Ctt31sFalsef.png +++ b/data/CLs/plots/Dbar_s/0.75Ctt31sFalsef.png Binary files differ diff --git a/data/CLs/plots/Dbar_s/0.78Ctt32sTruef.png b/data/CLs/plots/Dbar_s/0.78Ctt32sTruef.png index 3eec711..2a3d46f 100644 --- a/data/CLs/plots/Dbar_s/0.78Ctt32sTruef.png +++ b/data/CLs/plots/Dbar_s/0.78Ctt32sTruef.png Binary files differ diff --git a/data/CLs/plots/Dbar_s/0.78Ctt33sFalsef.png b/data/CLs/plots/Dbar_s/0.78Ctt33sFalsef.png index 54210f1..ba87924 100644 --- a/data/CLs/plots/Dbar_s/0.78Ctt33sFalsef.png +++ b/data/CLs/plots/Dbar_s/0.78Ctt33sFalsef.png Binary files differ diff --git a/data/CLs/plots/Dbar_s/0.80Ctt34sTruef.png b/data/CLs/plots/Dbar_s/0.80Ctt34sTruef.png index ca79f3a..ff7f3d4 100644 --- a/data/CLs/plots/Dbar_s/0.80Ctt34sTruef.png +++ b/data/CLs/plots/Dbar_s/0.80Ctt34sTruef.png Binary files differ diff --git a/data/CLs/plots/Dbar_s/0.80Ctt35sFalsef.png b/data/CLs/plots/Dbar_s/0.80Ctt35sFalsef.png index e3d1667..a4fb829 100644 --- a/data/CLs/plots/Dbar_s/0.80Ctt35sFalsef.png +++ b/data/CLs/plots/Dbar_s/0.80Ctt35sFalsef.png Binary files differ diff --git a/data/CLs/plots/Dbar_s/0.82Ctt36sTruef.png b/data/CLs/plots/Dbar_s/0.82Ctt36sTruef.png index 9e35c4c..bbda4be 100644 --- a/data/CLs/plots/Dbar_s/0.82Ctt36sTruef.png +++ b/data/CLs/plots/Dbar_s/0.82Ctt36sTruef.png Binary files differ diff --git a/data/CLs/plots/Dbar_s/0.82Ctt37sFalsef.png b/data/CLs/plots/Dbar_s/0.82Ctt37sFalsef.png index 4209020..c0acbd9 100644 --- a/data/CLs/plots/Dbar_s/0.82Ctt37sFalsef.png +++ b/data/CLs/plots/Dbar_s/0.82Ctt37sFalsef.png Binary files differ diff --git a/data/CLs/plots/Dbar_s/0.85Ctt38sTruef.png b/data/CLs/plots/Dbar_s/0.85Ctt38sTruef.png index a6aae93..6fdc38e 100644 --- a/data/CLs/plots/Dbar_s/0.85Ctt38sTruef.png +++ b/data/CLs/plots/Dbar_s/0.85Ctt38sTruef.png Binary files differ diff --git a/data/CLs/plots/Dbar_s/0.85Ctt39sFalsef.png b/data/CLs/plots/Dbar_s/0.85Ctt39sFalsef.png index fdc3ba0..44d5145 100644 --- a/data/CLs/plots/Dbar_s/0.85Ctt39sFalsef.png +++ b/data/CLs/plots/Dbar_s/0.85Ctt39sFalsef.png Binary files differ diff --git a/data/CLs/plots/bplus_0/0.00Ctt0sTruef.png b/data/CLs/plots/bplus_0/0.00Ctt0sTruef.png index 471123c..4d88845 100644 --- a/data/CLs/plots/bplus_0/0.00Ctt0sTruef.png +++ b/data/CLs/plots/bplus_0/0.00Ctt0sTruef.png Binary files differ diff --git a/data/CLs/plots/bplus_0/0.00Ctt1sFalsef.png b/data/CLs/plots/bplus_0/0.00Ctt1sFalsef.png index 60166aa..77512ab 100644 --- a/data/CLs/plots/bplus_0/0.00Ctt1sFalsef.png +++ b/data/CLs/plots/bplus_0/0.00Ctt1sFalsef.png Binary files differ diff --git a/data/CLs/plots/bplus_0/0.25Ctt2sTruef.png b/data/CLs/plots/bplus_0/0.25Ctt2sTruef.png index e31b3c6..3f0fb8c 100644 --- a/data/CLs/plots/bplus_0/0.25Ctt2sTruef.png +++ b/data/CLs/plots/bplus_0/0.25Ctt2sTruef.png Binary files differ diff --git a/data/CLs/plots/bplus_0/0.25Ctt3sFalsef.png b/data/CLs/plots/bplus_0/0.25Ctt3sFalsef.png index b3d9a29..2983537 100644 --- a/data/CLs/plots/bplus_0/0.25Ctt3sFalsef.png +++ b/data/CLs/plots/bplus_0/0.25Ctt3sFalsef.png Binary files differ diff --git a/data/CLs/plots/bplus_0/0.31Ctt4sTruef.png b/data/CLs/plots/bplus_0/0.31Ctt4sTruef.png index 45ce32e..350639a 100644 --- a/data/CLs/plots/bplus_0/0.31Ctt4sTruef.png +++ b/data/CLs/plots/bplus_0/0.31Ctt4sTruef.png Binary files differ diff --git a/data/CLs/plots/bplus_0/0.31Ctt5sFalsef.png b/data/CLs/plots/bplus_0/0.31Ctt5sFalsef.png index 9e4f641..3f24822 100644 --- a/data/CLs/plots/bplus_0/0.31Ctt5sFalsef.png +++ b/data/CLs/plots/bplus_0/0.31Ctt5sFalsef.png Binary files differ diff --git a/data/CLs/plots/bplus_0/0.36Ctt6sTruef.png b/data/CLs/plots/bplus_0/0.36Ctt6sTruef.png index 308aa60..fb4cc62 100644 --- a/data/CLs/plots/bplus_0/0.36Ctt6sTruef.png +++ b/data/CLs/plots/bplus_0/0.36Ctt6sTruef.png Binary files differ diff --git a/data/CLs/plots/bplus_0/0.36Ctt7sFalsef.png b/data/CLs/plots/bplus_0/0.36Ctt7sFalsef.png index 3c507a8..6a91612 100644 --- a/data/CLs/plots/bplus_0/0.36Ctt7sFalsef.png +++ b/data/CLs/plots/bplus_0/0.36Ctt7sFalsef.png Binary files differ diff --git a/data/CLs/plots/bplus_0/0.41Ctt8sTruef.png b/data/CLs/plots/bplus_0/0.41Ctt8sTruef.png index 49767d9..ecedb5b 100644 --- a/data/CLs/plots/bplus_0/0.41Ctt8sTruef.png +++ b/data/CLs/plots/bplus_0/0.41Ctt8sTruef.png Binary files differ diff --git a/data/CLs/plots/bplus_0/0.41Ctt9sFalsef.png b/data/CLs/plots/bplus_0/0.41Ctt9sFalsef.png index cfcdc5a..bb2a3f4 100644 --- a/data/CLs/plots/bplus_0/0.41Ctt9sFalsef.png +++ b/data/CLs/plots/bplus_0/0.41Ctt9sFalsef.png Binary files differ diff --git a/data/CLs/plots/bplus_0/0.45Ctt10sTruef.png b/data/CLs/plots/bplus_0/0.45Ctt10sTruef.png index 6a11257..6c79a6a 100644 --- a/data/CLs/plots/bplus_0/0.45Ctt10sTruef.png +++ b/data/CLs/plots/bplus_0/0.45Ctt10sTruef.png Binary files differ diff --git a/data/CLs/plots/bplus_0/0.45Ctt11sFalsef.png b/data/CLs/plots/bplus_0/0.45Ctt11sFalsef.png index ba8be65..aebf7f1 100644 --- a/data/CLs/plots/bplus_0/0.45Ctt11sFalsef.png +++ b/data/CLs/plots/bplus_0/0.45Ctt11sFalsef.png Binary files differ diff --git a/data/CLs/plots/bplus_0/0.49Ctt12sTruef.png b/data/CLs/plots/bplus_0/0.49Ctt12sTruef.png index b887d11..5501f11 100644 --- a/data/CLs/plots/bplus_0/0.49Ctt12sTruef.png +++ b/data/CLs/plots/bplus_0/0.49Ctt12sTruef.png Binary files differ diff --git a/data/CLs/plots/bplus_0/0.49Ctt13sFalsef.png b/data/CLs/plots/bplus_0/0.49Ctt13sFalsef.png index 4ba46ad..89dce00 100644 --- a/data/CLs/plots/bplus_0/0.49Ctt13sFalsef.png +++ b/data/CLs/plots/bplus_0/0.49Ctt13sFalsef.png Binary files differ diff --git a/data/CLs/plots/bplus_0/0.53Ctt14sTruef.png b/data/CLs/plots/bplus_0/0.53Ctt14sTruef.png index 292da34..40e2eda 100644 --- a/data/CLs/plots/bplus_0/0.53Ctt14sTruef.png +++ b/data/CLs/plots/bplus_0/0.53Ctt14sTruef.png Binary files differ diff --git a/data/CLs/plots/bplus_0/0.53Ctt15sFalsef.png b/data/CLs/plots/bplus_0/0.53Ctt15sFalsef.png index a9c2ec2..16f47ec 100644 --- a/data/CLs/plots/bplus_0/0.53Ctt15sFalsef.png +++ b/data/CLs/plots/bplus_0/0.53Ctt15sFalsef.png Binary files differ diff --git a/data/CLs/plots/bplus_0/0.56Ctt16sTruef.png b/data/CLs/plots/bplus_0/0.56Ctt16sTruef.png index c49d40b..47f29fb 100644 --- a/data/CLs/plots/bplus_0/0.56Ctt16sTruef.png +++ b/data/CLs/plots/bplus_0/0.56Ctt16sTruef.png Binary files differ diff --git a/data/CLs/plots/bplus_0/0.56Ctt17sFalsef.png b/data/CLs/plots/bplus_0/0.56Ctt17sFalsef.png index f07d053..f99ec0e 100644 --- a/data/CLs/plots/bplus_0/0.56Ctt17sFalsef.png +++ b/data/CLs/plots/bplus_0/0.56Ctt17sFalsef.png Binary files differ diff --git a/data/CLs/plots/bplus_0/0.59Ctt18sTruef.png b/data/CLs/plots/bplus_0/0.59Ctt18sTruef.png index 7d42ddb..f3bada9 100644 --- a/data/CLs/plots/bplus_0/0.59Ctt18sTruef.png +++ b/data/CLs/plots/bplus_0/0.59Ctt18sTruef.png Binary files differ diff --git a/data/CLs/plots/bplus_0/0.59Ctt19sFalsef.png b/data/CLs/plots/bplus_0/0.59Ctt19sFalsef.png index 012e2db..ae569a1 100644 --- a/data/CLs/plots/bplus_0/0.59Ctt19sFalsef.png +++ b/data/CLs/plots/bplus_0/0.59Ctt19sFalsef.png Binary files differ diff --git a/data/CLs/plots/bplus_0/0.62Ctt20sTruef.png b/data/CLs/plots/bplus_0/0.62Ctt20sTruef.png index bea15ca..18e5175 100644 --- a/data/CLs/plots/bplus_0/0.62Ctt20sTruef.png +++ b/data/CLs/plots/bplus_0/0.62Ctt20sTruef.png Binary files differ diff --git a/data/CLs/plots/bplus_0/0.62Ctt21sFalsef.png b/data/CLs/plots/bplus_0/0.62Ctt21sFalsef.png index 38ea6fa..c5a4b38 100644 --- a/data/CLs/plots/bplus_0/0.62Ctt21sFalsef.png +++ b/data/CLs/plots/bplus_0/0.62Ctt21sFalsef.png Binary files differ diff --git a/data/CLs/plots/bplus_0/0.65Ctt22sTruef.png b/data/CLs/plots/bplus_0/0.65Ctt22sTruef.png index 8b4a14f..6100437 100644 --- a/data/CLs/plots/bplus_0/0.65Ctt22sTruef.png +++ b/data/CLs/plots/bplus_0/0.65Ctt22sTruef.png Binary files differ diff --git a/data/CLs/plots/bplus_0/0.65Ctt23sFalsef.png b/data/CLs/plots/bplus_0/0.65Ctt23sFalsef.png index ac77e6d..564fe87 100644 --- a/data/CLs/plots/bplus_0/0.65Ctt23sFalsef.png +++ b/data/CLs/plots/bplus_0/0.65Ctt23sFalsef.png Binary files differ diff --git a/data/CLs/plots/bplus_0/0.68Ctt24sTruef.png b/data/CLs/plots/bplus_0/0.68Ctt24sTruef.png index 3ca2d65..11b5fbb 100644 --- a/data/CLs/plots/bplus_0/0.68Ctt24sTruef.png +++ b/data/CLs/plots/bplus_0/0.68Ctt24sTruef.png Binary files differ diff --git a/data/CLs/plots/bplus_0/0.68Ctt25sFalsef.png b/data/CLs/plots/bplus_0/0.68Ctt25sFalsef.png index d673043..eb80c41 100644 --- a/data/CLs/plots/bplus_0/0.68Ctt25sFalsef.png +++ b/data/CLs/plots/bplus_0/0.68Ctt25sFalsef.png Binary files differ diff --git a/data/CLs/plots/bplus_0/0.70Ctt26sTruef.png b/data/CLs/plots/bplus_0/0.70Ctt26sTruef.png index a18538c..5d80cf7 100644 --- a/data/CLs/plots/bplus_0/0.70Ctt26sTruef.png +++ b/data/CLs/plots/bplus_0/0.70Ctt26sTruef.png Binary files differ diff --git a/data/CLs/plots/bplus_0/0.70Ctt27sFalsef.png b/data/CLs/plots/bplus_0/0.70Ctt27sFalsef.png index 1d1d300..79fc0a1 100644 --- a/data/CLs/plots/bplus_0/0.70Ctt27sFalsef.png +++ b/data/CLs/plots/bplus_0/0.70Ctt27sFalsef.png Binary files differ diff --git a/data/CLs/plots/bplus_0/0.73Ctt28sTruef.png b/data/CLs/plots/bplus_0/0.73Ctt28sTruef.png index f499593..f2058b0 100644 --- a/data/CLs/plots/bplus_0/0.73Ctt28sTruef.png +++ b/data/CLs/plots/bplus_0/0.73Ctt28sTruef.png Binary files differ diff --git a/data/CLs/plots/bplus_0/0.73Ctt29sFalsef.png b/data/CLs/plots/bplus_0/0.73Ctt29sFalsef.png index a4df870..1d74e3d 100644 --- a/data/CLs/plots/bplus_0/0.73Ctt29sFalsef.png +++ b/data/CLs/plots/bplus_0/0.73Ctt29sFalsef.png Binary files differ diff --git a/data/CLs/plots/bplus_0/0.75Ctt30sTruef.png b/data/CLs/plots/bplus_0/0.75Ctt30sTruef.png index a4bb35b..3a6b4d8 100644 --- a/data/CLs/plots/bplus_0/0.75Ctt30sTruef.png +++ b/data/CLs/plots/bplus_0/0.75Ctt30sTruef.png Binary files differ diff --git a/data/CLs/plots/bplus_0/0.75Ctt31sFalsef.png b/data/CLs/plots/bplus_0/0.75Ctt31sFalsef.png index 769f077..be791b6 100644 --- a/data/CLs/plots/bplus_0/0.75Ctt31sFalsef.png +++ b/data/CLs/plots/bplus_0/0.75Ctt31sFalsef.png Binary files differ diff --git a/data/CLs/plots/bplus_0/0.78Ctt32sTruef.png b/data/CLs/plots/bplus_0/0.78Ctt32sTruef.png index e32715f..1791c91 100644 --- a/data/CLs/plots/bplus_0/0.78Ctt32sTruef.png +++ b/data/CLs/plots/bplus_0/0.78Ctt32sTruef.png Binary files differ diff --git a/data/CLs/plots/bplus_0/0.78Ctt33sFalsef.png b/data/CLs/plots/bplus_0/0.78Ctt33sFalsef.png index 3bbe429..da3d9fa 100644 --- a/data/CLs/plots/bplus_0/0.78Ctt33sFalsef.png +++ b/data/CLs/plots/bplus_0/0.78Ctt33sFalsef.png Binary files differ diff --git a/data/CLs/plots/bplus_0/0.80Ctt34sTruef.png b/data/CLs/plots/bplus_0/0.80Ctt34sTruef.png index 540ca69..01e21ef 100644 --- a/data/CLs/plots/bplus_0/0.80Ctt34sTruef.png +++ b/data/CLs/plots/bplus_0/0.80Ctt34sTruef.png Binary files differ diff --git a/data/CLs/plots/bplus_0/0.80Ctt35sFalsef.png b/data/CLs/plots/bplus_0/0.80Ctt35sFalsef.png index f1a9e04..bb4f714 100644 --- a/data/CLs/plots/bplus_0/0.80Ctt35sFalsef.png +++ b/data/CLs/plots/bplus_0/0.80Ctt35sFalsef.png Binary files differ diff --git a/data/CLs/plots/bplus_0/0.82Ctt36sTruef.png b/data/CLs/plots/bplus_0/0.82Ctt36sTruef.png index fc04e11..c3316aa 100644 --- a/data/CLs/plots/bplus_0/0.82Ctt36sTruef.png +++ b/data/CLs/plots/bplus_0/0.82Ctt36sTruef.png Binary files differ diff --git a/data/CLs/plots/bplus_0/0.82Ctt37sFalsef.png b/data/CLs/plots/bplus_0/0.82Ctt37sFalsef.png index 76516dd..4f4e26f 100644 --- a/data/CLs/plots/bplus_0/0.82Ctt37sFalsef.png +++ b/data/CLs/plots/bplus_0/0.82Ctt37sFalsef.png Binary files differ diff --git a/data/CLs/plots/bplus_0/0.85Ctt38sTruef.png b/data/CLs/plots/bplus_0/0.85Ctt38sTruef.png index 8db3027..1f8d8a1 100644 --- a/data/CLs/plots/bplus_0/0.85Ctt38sTruef.png +++ b/data/CLs/plots/bplus_0/0.85Ctt38sTruef.png Binary files differ diff --git a/data/CLs/plots/bplus_0/0.85Ctt39sFalsef.png b/data/CLs/plots/bplus_0/0.85Ctt39sFalsef.png index 884429d..15f936a 100644 --- a/data/CLs/plots/bplus_0/0.85Ctt39sFalsef.png +++ b/data/CLs/plots/bplus_0/0.85Ctt39sFalsef.png Binary files differ diff --git a/data/CLs/plots/bplus_1/0.00Ctt0sTruef.png b/data/CLs/plots/bplus_1/0.00Ctt0sTruef.png index 8e09df4..2a22bbb 100644 --- a/data/CLs/plots/bplus_1/0.00Ctt0sTruef.png +++ b/data/CLs/plots/bplus_1/0.00Ctt0sTruef.png Binary files differ diff --git a/data/CLs/plots/bplus_1/0.00Ctt1sFalsef.png b/data/CLs/plots/bplus_1/0.00Ctt1sFalsef.png index bc45edd..8b20ffd 100644 --- a/data/CLs/plots/bplus_1/0.00Ctt1sFalsef.png +++ b/data/CLs/plots/bplus_1/0.00Ctt1sFalsef.png Binary files differ diff --git a/data/CLs/plots/bplus_1/0.25Ctt2sTruef.png b/data/CLs/plots/bplus_1/0.25Ctt2sTruef.png index 60b456b..f21c5f5 100644 --- a/data/CLs/plots/bplus_1/0.25Ctt2sTruef.png +++ b/data/CLs/plots/bplus_1/0.25Ctt2sTruef.png Binary files differ diff --git a/data/CLs/plots/bplus_1/0.25Ctt3sFalsef.png b/data/CLs/plots/bplus_1/0.25Ctt3sFalsef.png index 91df78c..6153dd3 100644 --- a/data/CLs/plots/bplus_1/0.25Ctt3sFalsef.png +++ b/data/CLs/plots/bplus_1/0.25Ctt3sFalsef.png Binary files differ diff --git a/data/CLs/plots/bplus_1/0.31Ctt4sTruef.png b/data/CLs/plots/bplus_1/0.31Ctt4sTruef.png index 9e49d57..fb8c713 100644 --- a/data/CLs/plots/bplus_1/0.31Ctt4sTruef.png +++ b/data/CLs/plots/bplus_1/0.31Ctt4sTruef.png Binary files differ diff --git a/data/CLs/plots/bplus_1/0.31Ctt5sFalsef.png b/data/CLs/plots/bplus_1/0.31Ctt5sFalsef.png index 087fe2d..9715df6 100644 --- a/data/CLs/plots/bplus_1/0.31Ctt5sFalsef.png +++ b/data/CLs/plots/bplus_1/0.31Ctt5sFalsef.png Binary files differ diff --git a/data/CLs/plots/bplus_1/0.36Ctt6sTruef.png b/data/CLs/plots/bplus_1/0.36Ctt6sTruef.png index 2098f1e..fa0a211 100644 --- a/data/CLs/plots/bplus_1/0.36Ctt6sTruef.png +++ b/data/CLs/plots/bplus_1/0.36Ctt6sTruef.png Binary files differ diff --git a/data/CLs/plots/bplus_1/0.36Ctt7sFalsef.png b/data/CLs/plots/bplus_1/0.36Ctt7sFalsef.png index 86bba20..ff06770 100644 --- a/data/CLs/plots/bplus_1/0.36Ctt7sFalsef.png +++ b/data/CLs/plots/bplus_1/0.36Ctt7sFalsef.png Binary files differ diff --git a/data/CLs/plots/bplus_1/0.41Ctt8sTruef.png b/data/CLs/plots/bplus_1/0.41Ctt8sTruef.png index a66a1c2..dffc9a1 100644 --- a/data/CLs/plots/bplus_1/0.41Ctt8sTruef.png +++ b/data/CLs/plots/bplus_1/0.41Ctt8sTruef.png Binary files differ diff --git a/data/CLs/plots/bplus_1/0.41Ctt9sFalsef.png b/data/CLs/plots/bplus_1/0.41Ctt9sFalsef.png index 8c5a991..26fae7e 100644 --- a/data/CLs/plots/bplus_1/0.41Ctt9sFalsef.png +++ b/data/CLs/plots/bplus_1/0.41Ctt9sFalsef.png Binary files differ diff --git a/data/CLs/plots/bplus_1/0.45Ctt10sTruef.png b/data/CLs/plots/bplus_1/0.45Ctt10sTruef.png index 6d37a6e..2a15108 100644 --- a/data/CLs/plots/bplus_1/0.45Ctt10sTruef.png +++ b/data/CLs/plots/bplus_1/0.45Ctt10sTruef.png Binary files differ diff --git a/data/CLs/plots/bplus_1/0.45Ctt11sFalsef.png b/data/CLs/plots/bplus_1/0.45Ctt11sFalsef.png index 3f2d272..d3e9beb 100644 --- a/data/CLs/plots/bplus_1/0.45Ctt11sFalsef.png +++ b/data/CLs/plots/bplus_1/0.45Ctt11sFalsef.png Binary files differ diff --git a/data/CLs/plots/bplus_1/0.49Ctt12sTruef.png b/data/CLs/plots/bplus_1/0.49Ctt12sTruef.png index 48ae9eb..11f9948 100644 --- a/data/CLs/plots/bplus_1/0.49Ctt12sTruef.png +++ b/data/CLs/plots/bplus_1/0.49Ctt12sTruef.png Binary files differ diff --git a/data/CLs/plots/bplus_1/0.49Ctt13sFalsef.png b/data/CLs/plots/bplus_1/0.49Ctt13sFalsef.png index 939faff..82e48ff 100644 --- a/data/CLs/plots/bplus_1/0.49Ctt13sFalsef.png +++ b/data/CLs/plots/bplus_1/0.49Ctt13sFalsef.png Binary files differ diff --git a/data/CLs/plots/bplus_1/0.53Ctt14sTruef.png b/data/CLs/plots/bplus_1/0.53Ctt14sTruef.png index aedbf78..8546455 100644 --- a/data/CLs/plots/bplus_1/0.53Ctt14sTruef.png +++ b/data/CLs/plots/bplus_1/0.53Ctt14sTruef.png Binary files differ diff --git a/data/CLs/plots/bplus_1/0.53Ctt15sFalsef.png b/data/CLs/plots/bplus_1/0.53Ctt15sFalsef.png index f18065c..1e6fec0 100644 --- a/data/CLs/plots/bplus_1/0.53Ctt15sFalsef.png +++ b/data/CLs/plots/bplus_1/0.53Ctt15sFalsef.png Binary files differ diff --git a/data/CLs/plots/bplus_1/0.56Ctt16sTruef.png b/data/CLs/plots/bplus_1/0.56Ctt16sTruef.png index f0f08ec..48dd735 100644 --- a/data/CLs/plots/bplus_1/0.56Ctt16sTruef.png +++ b/data/CLs/plots/bplus_1/0.56Ctt16sTruef.png Binary files differ diff --git a/data/CLs/plots/bplus_1/0.56Ctt17sFalsef.png b/data/CLs/plots/bplus_1/0.56Ctt17sFalsef.png index 01c9e72..33bc1ab 100644 --- a/data/CLs/plots/bplus_1/0.56Ctt17sFalsef.png +++ b/data/CLs/plots/bplus_1/0.56Ctt17sFalsef.png Binary files differ diff --git a/data/CLs/plots/bplus_1/0.59Ctt18sTruef.png b/data/CLs/plots/bplus_1/0.59Ctt18sTruef.png index bc91463..4661598 100644 --- a/data/CLs/plots/bplus_1/0.59Ctt18sTruef.png +++ b/data/CLs/plots/bplus_1/0.59Ctt18sTruef.png Binary files differ diff --git a/data/CLs/plots/bplus_1/0.59Ctt19sFalsef.png b/data/CLs/plots/bplus_1/0.59Ctt19sFalsef.png index 6f889b9..fbdba13 100644 --- a/data/CLs/plots/bplus_1/0.59Ctt19sFalsef.png +++ b/data/CLs/plots/bplus_1/0.59Ctt19sFalsef.png Binary files differ diff --git a/data/CLs/plots/bplus_1/0.62Ctt20sTruef.png b/data/CLs/plots/bplus_1/0.62Ctt20sTruef.png index b2fcc09..8364ccc 100644 --- a/data/CLs/plots/bplus_1/0.62Ctt20sTruef.png +++ b/data/CLs/plots/bplus_1/0.62Ctt20sTruef.png Binary files differ diff --git a/data/CLs/plots/bplus_1/0.62Ctt21sFalsef.png b/data/CLs/plots/bplus_1/0.62Ctt21sFalsef.png index ec0f862..798b7f7 100644 --- a/data/CLs/plots/bplus_1/0.62Ctt21sFalsef.png +++ b/data/CLs/plots/bplus_1/0.62Ctt21sFalsef.png Binary files differ diff --git a/data/CLs/plots/bplus_1/0.65Ctt22sTruef.png b/data/CLs/plots/bplus_1/0.65Ctt22sTruef.png index 12fcb10..8bb1ebf 100644 --- a/data/CLs/plots/bplus_1/0.65Ctt22sTruef.png +++ b/data/CLs/plots/bplus_1/0.65Ctt22sTruef.png Binary files differ diff --git a/data/CLs/plots/bplus_1/0.65Ctt23sFalsef.png b/data/CLs/plots/bplus_1/0.65Ctt23sFalsef.png index a1e4fb5..943d82f 100644 --- a/data/CLs/plots/bplus_1/0.65Ctt23sFalsef.png +++ b/data/CLs/plots/bplus_1/0.65Ctt23sFalsef.png Binary files differ diff --git a/data/CLs/plots/bplus_1/0.68Ctt24sTruef.png b/data/CLs/plots/bplus_1/0.68Ctt24sTruef.png index 2df0b41..6bb7077 100644 --- a/data/CLs/plots/bplus_1/0.68Ctt24sTruef.png +++ b/data/CLs/plots/bplus_1/0.68Ctt24sTruef.png Binary files differ diff --git a/data/CLs/plots/bplus_1/0.68Ctt25sFalsef.png b/data/CLs/plots/bplus_1/0.68Ctt25sFalsef.png index 69f03fd..ae04687 100644 --- a/data/CLs/plots/bplus_1/0.68Ctt25sFalsef.png +++ b/data/CLs/plots/bplus_1/0.68Ctt25sFalsef.png Binary files differ diff --git a/data/CLs/plots/bplus_1/0.70Ctt26sTruef.png b/data/CLs/plots/bplus_1/0.70Ctt26sTruef.png index 80faaec..dab55f1 100644 --- a/data/CLs/plots/bplus_1/0.70Ctt26sTruef.png +++ b/data/CLs/plots/bplus_1/0.70Ctt26sTruef.png Binary files differ diff --git a/data/CLs/plots/bplus_1/0.70Ctt27sFalsef.png b/data/CLs/plots/bplus_1/0.70Ctt27sFalsef.png index e84d22b..3705699 100644 --- a/data/CLs/plots/bplus_1/0.70Ctt27sFalsef.png +++ b/data/CLs/plots/bplus_1/0.70Ctt27sFalsef.png Binary files differ diff --git a/data/CLs/plots/bplus_1/0.73Ctt28sTruef.png b/data/CLs/plots/bplus_1/0.73Ctt28sTruef.png index a8b44ac..f5a673b 100644 --- a/data/CLs/plots/bplus_1/0.73Ctt28sTruef.png +++ b/data/CLs/plots/bplus_1/0.73Ctt28sTruef.png Binary files differ diff --git a/data/CLs/plots/bplus_1/0.73Ctt29sFalsef.png b/data/CLs/plots/bplus_1/0.73Ctt29sFalsef.png index df64dfd..2e2d763 100644 --- a/data/CLs/plots/bplus_1/0.73Ctt29sFalsef.png +++ b/data/CLs/plots/bplus_1/0.73Ctt29sFalsef.png Binary files differ diff --git a/data/CLs/plots/bplus_1/0.75Ctt30sTruef.png b/data/CLs/plots/bplus_1/0.75Ctt30sTruef.png index fb1380d..aec5765 100644 --- a/data/CLs/plots/bplus_1/0.75Ctt30sTruef.png +++ b/data/CLs/plots/bplus_1/0.75Ctt30sTruef.png Binary files differ diff --git a/data/CLs/plots/bplus_1/0.75Ctt31sFalsef.png b/data/CLs/plots/bplus_1/0.75Ctt31sFalsef.png index e7bae97..1f9007b 100644 --- a/data/CLs/plots/bplus_1/0.75Ctt31sFalsef.png +++ b/data/CLs/plots/bplus_1/0.75Ctt31sFalsef.png Binary files differ diff --git a/data/CLs/plots/bplus_1/0.78Ctt32sTruef.png b/data/CLs/plots/bplus_1/0.78Ctt32sTruef.png index 9d5cdd9..8749fa1 100644 --- a/data/CLs/plots/bplus_1/0.78Ctt32sTruef.png +++ b/data/CLs/plots/bplus_1/0.78Ctt32sTruef.png Binary files differ diff --git a/data/CLs/plots/bplus_1/0.78Ctt33sFalsef.png b/data/CLs/plots/bplus_1/0.78Ctt33sFalsef.png index e17e6df..4e59795 100644 --- a/data/CLs/plots/bplus_1/0.78Ctt33sFalsef.png +++ b/data/CLs/plots/bplus_1/0.78Ctt33sFalsef.png Binary files differ diff --git a/data/CLs/plots/bplus_1/0.80Ctt34sTruef.png b/data/CLs/plots/bplus_1/0.80Ctt34sTruef.png index 2a7dae4..30ca31a 100644 --- a/data/CLs/plots/bplus_1/0.80Ctt34sTruef.png +++ b/data/CLs/plots/bplus_1/0.80Ctt34sTruef.png Binary files differ diff --git a/data/CLs/plots/bplus_1/0.80Ctt35sFalsef.png b/data/CLs/plots/bplus_1/0.80Ctt35sFalsef.png index 401f642..87d4546 100644 --- a/data/CLs/plots/bplus_1/0.80Ctt35sFalsef.png +++ b/data/CLs/plots/bplus_1/0.80Ctt35sFalsef.png Binary files differ diff --git a/data/CLs/plots/bplus_1/0.82Ctt36sTruef.png b/data/CLs/plots/bplus_1/0.82Ctt36sTruef.png index 5524dfc..b205e3d 100644 --- a/data/CLs/plots/bplus_1/0.82Ctt36sTruef.png +++ b/data/CLs/plots/bplus_1/0.82Ctt36sTruef.png Binary files differ diff --git a/data/CLs/plots/bplus_1/0.82Ctt37sFalsef.png b/data/CLs/plots/bplus_1/0.82Ctt37sFalsef.png index 78493ad..d409d7e 100644 --- a/data/CLs/plots/bplus_1/0.82Ctt37sFalsef.png +++ b/data/CLs/plots/bplus_1/0.82Ctt37sFalsef.png Binary files differ diff --git a/data/CLs/plots/bplus_1/0.85Ctt38sTruef.png b/data/CLs/plots/bplus_1/0.85Ctt38sTruef.png index 5bce28e..2013255 100644 --- a/data/CLs/plots/bplus_1/0.85Ctt38sTruef.png +++ b/data/CLs/plots/bplus_1/0.85Ctt38sTruef.png Binary files differ diff --git a/data/CLs/plots/bplus_1/0.85Ctt39sFalsef.png b/data/CLs/plots/bplus_1/0.85Ctt39sFalsef.png index e95a725..2dcb84e 100644 --- a/data/CLs/plots/bplus_1/0.85Ctt39sFalsef.png +++ b/data/CLs/plots/bplus_1/0.85Ctt39sFalsef.png Binary files differ diff --git a/data/CLs/plots/bplus_2/0.00Ctt0sTruef.png b/data/CLs/plots/bplus_2/0.00Ctt0sTruef.png index 278cfb0..7a778e8 100644 --- a/data/CLs/plots/bplus_2/0.00Ctt0sTruef.png +++ b/data/CLs/plots/bplus_2/0.00Ctt0sTruef.png Binary files differ diff --git a/data/CLs/plots/bplus_2/0.00Ctt1sFalsef.png b/data/CLs/plots/bplus_2/0.00Ctt1sFalsef.png index b49afc5..9acbd34 100644 --- a/data/CLs/plots/bplus_2/0.00Ctt1sFalsef.png +++ b/data/CLs/plots/bplus_2/0.00Ctt1sFalsef.png Binary files differ diff --git a/data/CLs/plots/bplus_2/0.25Ctt2sTruef.png b/data/CLs/plots/bplus_2/0.25Ctt2sTruef.png index 406d379..204a6cd 100644 --- a/data/CLs/plots/bplus_2/0.25Ctt2sTruef.png +++ b/data/CLs/plots/bplus_2/0.25Ctt2sTruef.png Binary files differ diff --git a/data/CLs/plots/bplus_2/0.25Ctt3sFalsef.png b/data/CLs/plots/bplus_2/0.25Ctt3sFalsef.png index 1af8878..3feabe0 100644 --- a/data/CLs/plots/bplus_2/0.25Ctt3sFalsef.png +++ b/data/CLs/plots/bplus_2/0.25Ctt3sFalsef.png Binary files differ diff --git a/data/CLs/plots/bplus_2/0.31Ctt4sTruef.png b/data/CLs/plots/bplus_2/0.31Ctt4sTruef.png index 7f90daa..bcfb075 100644 --- a/data/CLs/plots/bplus_2/0.31Ctt4sTruef.png +++ b/data/CLs/plots/bplus_2/0.31Ctt4sTruef.png Binary files differ diff --git a/data/CLs/plots/bplus_2/0.31Ctt5sFalsef.png b/data/CLs/plots/bplus_2/0.31Ctt5sFalsef.png index 656b93f..4135f06 100644 --- a/data/CLs/plots/bplus_2/0.31Ctt5sFalsef.png +++ b/data/CLs/plots/bplus_2/0.31Ctt5sFalsef.png Binary files differ diff --git a/data/CLs/plots/bplus_2/0.36Ctt6sTruef.png b/data/CLs/plots/bplus_2/0.36Ctt6sTruef.png index 9af9bde..717883d 100644 --- a/data/CLs/plots/bplus_2/0.36Ctt6sTruef.png +++ b/data/CLs/plots/bplus_2/0.36Ctt6sTruef.png Binary files differ diff --git a/data/CLs/plots/bplus_2/0.36Ctt7sFalsef.png b/data/CLs/plots/bplus_2/0.36Ctt7sFalsef.png index d91091d..6cd0036 100644 --- a/data/CLs/plots/bplus_2/0.36Ctt7sFalsef.png +++ b/data/CLs/plots/bplus_2/0.36Ctt7sFalsef.png Binary files differ diff --git a/data/CLs/plots/bplus_2/0.41Ctt8sTruef.png b/data/CLs/plots/bplus_2/0.41Ctt8sTruef.png index f7b77a2..9581e8d 100644 --- a/data/CLs/plots/bplus_2/0.41Ctt8sTruef.png +++ b/data/CLs/plots/bplus_2/0.41Ctt8sTruef.png Binary files differ diff --git a/data/CLs/plots/bplus_2/0.41Ctt9sFalsef.png b/data/CLs/plots/bplus_2/0.41Ctt9sFalsef.png index de32898..d9627c0 100644 --- a/data/CLs/plots/bplus_2/0.41Ctt9sFalsef.png +++ b/data/CLs/plots/bplus_2/0.41Ctt9sFalsef.png Binary files differ diff --git a/data/CLs/plots/bplus_2/0.45Ctt10sTruef.png b/data/CLs/plots/bplus_2/0.45Ctt10sTruef.png index b01301a..5f9e29c 100644 --- a/data/CLs/plots/bplus_2/0.45Ctt10sTruef.png +++ b/data/CLs/plots/bplus_2/0.45Ctt10sTruef.png Binary files differ diff --git a/data/CLs/plots/bplus_2/0.45Ctt11sFalsef.png b/data/CLs/plots/bplus_2/0.45Ctt11sFalsef.png index 04ae1da..53b0703 100644 --- a/data/CLs/plots/bplus_2/0.45Ctt11sFalsef.png +++ b/data/CLs/plots/bplus_2/0.45Ctt11sFalsef.png Binary files differ diff --git a/data/CLs/plots/bplus_2/0.49Ctt12sTruef.png b/data/CLs/plots/bplus_2/0.49Ctt12sTruef.png index 597753e..f50d1db 100644 --- a/data/CLs/plots/bplus_2/0.49Ctt12sTruef.png +++ b/data/CLs/plots/bplus_2/0.49Ctt12sTruef.png Binary files differ diff --git a/data/CLs/plots/bplus_2/0.49Ctt13sFalsef.png b/data/CLs/plots/bplus_2/0.49Ctt13sFalsef.png index 5cf25a5..3515f7d 100644 --- a/data/CLs/plots/bplus_2/0.49Ctt13sFalsef.png +++ b/data/CLs/plots/bplus_2/0.49Ctt13sFalsef.png Binary files differ diff --git a/data/CLs/plots/bplus_2/0.53Ctt14sTruef.png b/data/CLs/plots/bplus_2/0.53Ctt14sTruef.png index bf2260e..49cb21e 100644 --- a/data/CLs/plots/bplus_2/0.53Ctt14sTruef.png +++ b/data/CLs/plots/bplus_2/0.53Ctt14sTruef.png Binary files differ diff --git a/data/CLs/plots/bplus_2/0.53Ctt15sFalsef.png b/data/CLs/plots/bplus_2/0.53Ctt15sFalsef.png index db2ed9b..2c9d044 100644 --- a/data/CLs/plots/bplus_2/0.53Ctt15sFalsef.png +++ b/data/CLs/plots/bplus_2/0.53Ctt15sFalsef.png Binary files differ diff --git a/data/CLs/plots/bplus_2/0.56Ctt16sTruef.png b/data/CLs/plots/bplus_2/0.56Ctt16sTruef.png index 882e620..51fbd3d 100644 --- a/data/CLs/plots/bplus_2/0.56Ctt16sTruef.png +++ b/data/CLs/plots/bplus_2/0.56Ctt16sTruef.png Binary files differ diff --git a/data/CLs/plots/bplus_2/0.56Ctt17sFalsef.png b/data/CLs/plots/bplus_2/0.56Ctt17sFalsef.png index 17492e9..792b5e4 100644 --- a/data/CLs/plots/bplus_2/0.56Ctt17sFalsef.png +++ b/data/CLs/plots/bplus_2/0.56Ctt17sFalsef.png Binary files differ diff --git a/data/CLs/plots/bplus_2/0.59Ctt18sTruef.png b/data/CLs/plots/bplus_2/0.59Ctt18sTruef.png index fcd0bd6..4f10b70 100644 --- a/data/CLs/plots/bplus_2/0.59Ctt18sTruef.png +++ b/data/CLs/plots/bplus_2/0.59Ctt18sTruef.png Binary files differ diff --git a/data/CLs/plots/bplus_2/0.59Ctt19sFalsef.png b/data/CLs/plots/bplus_2/0.59Ctt19sFalsef.png index 76ee7b8..7f6ce58 100644 --- a/data/CLs/plots/bplus_2/0.59Ctt19sFalsef.png +++ b/data/CLs/plots/bplus_2/0.59Ctt19sFalsef.png Binary files differ diff --git a/data/CLs/plots/bplus_2/0.62Ctt20sTruef.png b/data/CLs/plots/bplus_2/0.62Ctt20sTruef.png index a17d075..abc6373 100644 --- a/data/CLs/plots/bplus_2/0.62Ctt20sTruef.png +++ b/data/CLs/plots/bplus_2/0.62Ctt20sTruef.png Binary files differ diff --git a/data/CLs/plots/bplus_2/0.62Ctt21sFalsef.png b/data/CLs/plots/bplus_2/0.62Ctt21sFalsef.png index ee7a610..d50c73f 100644 --- a/data/CLs/plots/bplus_2/0.62Ctt21sFalsef.png +++ b/data/CLs/plots/bplus_2/0.62Ctt21sFalsef.png Binary files differ diff --git a/data/CLs/plots/bplus_2/0.65Ctt22sTruef.png b/data/CLs/plots/bplus_2/0.65Ctt22sTruef.png index 71d30ba..3877df9 100644 --- a/data/CLs/plots/bplus_2/0.65Ctt22sTruef.png +++ b/data/CLs/plots/bplus_2/0.65Ctt22sTruef.png Binary files differ diff --git a/data/CLs/plots/bplus_2/0.65Ctt23sFalsef.png b/data/CLs/plots/bplus_2/0.65Ctt23sFalsef.png index a8f8bbc..453079a 100644 --- a/data/CLs/plots/bplus_2/0.65Ctt23sFalsef.png +++ b/data/CLs/plots/bplus_2/0.65Ctt23sFalsef.png Binary files differ diff --git a/data/CLs/plots/bplus_2/0.68Ctt24sTruef.png b/data/CLs/plots/bplus_2/0.68Ctt24sTruef.png index 59d47a7..7c86ff8 100644 --- a/data/CLs/plots/bplus_2/0.68Ctt24sTruef.png +++ b/data/CLs/plots/bplus_2/0.68Ctt24sTruef.png Binary files differ diff --git a/data/CLs/plots/bplus_2/0.68Ctt25sFalsef.png b/data/CLs/plots/bplus_2/0.68Ctt25sFalsef.png index 92e6752..cd42662 100644 --- a/data/CLs/plots/bplus_2/0.68Ctt25sFalsef.png +++ b/data/CLs/plots/bplus_2/0.68Ctt25sFalsef.png Binary files differ diff --git a/data/CLs/plots/bplus_2/0.70Ctt26sTruef.png b/data/CLs/plots/bplus_2/0.70Ctt26sTruef.png index 378ddbf..d1816e3 100644 --- a/data/CLs/plots/bplus_2/0.70Ctt26sTruef.png +++ b/data/CLs/plots/bplus_2/0.70Ctt26sTruef.png Binary files differ diff --git a/data/CLs/plots/bplus_2/0.70Ctt27sFalsef.png b/data/CLs/plots/bplus_2/0.70Ctt27sFalsef.png index c78db41..c13b501 100644 --- a/data/CLs/plots/bplus_2/0.70Ctt27sFalsef.png +++ b/data/CLs/plots/bplus_2/0.70Ctt27sFalsef.png Binary files differ diff --git a/data/CLs/plots/bplus_2/0.73Ctt28sTruef.png b/data/CLs/plots/bplus_2/0.73Ctt28sTruef.png index c9d5c84..6529165 100644 --- a/data/CLs/plots/bplus_2/0.73Ctt28sTruef.png +++ b/data/CLs/plots/bplus_2/0.73Ctt28sTruef.png Binary files differ diff --git a/data/CLs/plots/bplus_2/0.73Ctt29sFalsef.png b/data/CLs/plots/bplus_2/0.73Ctt29sFalsef.png index d36dd77..ae3a9d2 100644 --- a/data/CLs/plots/bplus_2/0.73Ctt29sFalsef.png +++ b/data/CLs/plots/bplus_2/0.73Ctt29sFalsef.png Binary files differ diff --git a/data/CLs/plots/bplus_2/0.75Ctt30sTruef.png b/data/CLs/plots/bplus_2/0.75Ctt30sTruef.png index 31c90c4..e0a9433 100644 --- a/data/CLs/plots/bplus_2/0.75Ctt30sTruef.png +++ b/data/CLs/plots/bplus_2/0.75Ctt30sTruef.png Binary files differ diff --git a/data/CLs/plots/bplus_2/0.75Ctt31sFalsef.png b/data/CLs/plots/bplus_2/0.75Ctt31sFalsef.png index e7900ce..8ff4549 100644 --- a/data/CLs/plots/bplus_2/0.75Ctt31sFalsef.png +++ b/data/CLs/plots/bplus_2/0.75Ctt31sFalsef.png Binary files differ diff --git a/data/CLs/plots/bplus_2/0.78Ctt32sTruef.png b/data/CLs/plots/bplus_2/0.78Ctt32sTruef.png index 73fc9c9..d704519 100644 --- a/data/CLs/plots/bplus_2/0.78Ctt32sTruef.png +++ b/data/CLs/plots/bplus_2/0.78Ctt32sTruef.png Binary files differ diff --git a/data/CLs/plots/bplus_2/0.78Ctt33sFalsef.png b/data/CLs/plots/bplus_2/0.78Ctt33sFalsef.png index 7b385d9..b53d620 100644 --- a/data/CLs/plots/bplus_2/0.78Ctt33sFalsef.png +++ b/data/CLs/plots/bplus_2/0.78Ctt33sFalsef.png Binary files differ diff --git a/data/CLs/plots/bplus_2/0.80Ctt34sTruef.png b/data/CLs/plots/bplus_2/0.80Ctt34sTruef.png index 96c5c2c..72efbcb 100644 --- a/data/CLs/plots/bplus_2/0.80Ctt34sTruef.png +++ b/data/CLs/plots/bplus_2/0.80Ctt34sTruef.png Binary files differ diff --git a/data/CLs/plots/bplus_2/0.80Ctt35sFalsef.png b/data/CLs/plots/bplus_2/0.80Ctt35sFalsef.png index 9c6eb8c..29f5a51 100644 --- a/data/CLs/plots/bplus_2/0.80Ctt35sFalsef.png +++ b/data/CLs/plots/bplus_2/0.80Ctt35sFalsef.png Binary files differ diff --git a/data/CLs/plots/bplus_2/0.82Ctt36sTruef.png b/data/CLs/plots/bplus_2/0.82Ctt36sTruef.png index 18c0367..e279a47 100644 --- a/data/CLs/plots/bplus_2/0.82Ctt36sTruef.png +++ b/data/CLs/plots/bplus_2/0.82Ctt36sTruef.png Binary files differ diff --git a/data/CLs/plots/bplus_2/0.82Ctt37sFalsef.png b/data/CLs/plots/bplus_2/0.82Ctt37sFalsef.png index 1cdfd66..d821d2a 100644 --- a/data/CLs/plots/bplus_2/0.82Ctt37sFalsef.png +++ b/data/CLs/plots/bplus_2/0.82Ctt37sFalsef.png Binary files differ diff --git a/data/CLs/plots/bplus_2/0.85Ctt38sTruef.png b/data/CLs/plots/bplus_2/0.85Ctt38sTruef.png index 97c4034..9c08578 100644 --- a/data/CLs/plots/bplus_2/0.85Ctt38sTruef.png +++ b/data/CLs/plots/bplus_2/0.85Ctt38sTruef.png Binary files differ diff --git a/data/CLs/plots/bplus_2/0.85Ctt39sFalsef.png b/data/CLs/plots/bplus_2/0.85Ctt39sFalsef.png index 4ebebd4..1ebff22 100644 --- a/data/CLs/plots/bplus_2/0.85Ctt39sFalsef.png +++ b/data/CLs/plots/bplus_2/0.85Ctt39sFalsef.png Binary files differ diff --git a/data/CLs/plots/jpsi_p/0.00Ctt0sTruef.png b/data/CLs/plots/jpsi_p/0.00Ctt0sTruef.png index 3790925..f778951 100644 --- a/data/CLs/plots/jpsi_p/0.00Ctt0sTruef.png +++ b/data/CLs/plots/jpsi_p/0.00Ctt0sTruef.png Binary files differ diff --git a/data/CLs/plots/jpsi_p/0.00Ctt1sFalsef.png b/data/CLs/plots/jpsi_p/0.00Ctt1sFalsef.png index 43ef5bb..5aa45bd 100644 --- a/data/CLs/plots/jpsi_p/0.00Ctt1sFalsef.png +++ b/data/CLs/plots/jpsi_p/0.00Ctt1sFalsef.png Binary files differ diff --git a/data/CLs/plots/jpsi_p/0.25Ctt2sTruef.png b/data/CLs/plots/jpsi_p/0.25Ctt2sTruef.png index c5b93a5..77829cc 100644 --- a/data/CLs/plots/jpsi_p/0.25Ctt2sTruef.png +++ b/data/CLs/plots/jpsi_p/0.25Ctt2sTruef.png Binary files differ diff --git a/data/CLs/plots/jpsi_p/0.25Ctt3sFalsef.png b/data/CLs/plots/jpsi_p/0.25Ctt3sFalsef.png index 30f32e8..2a3fec4 100644 --- a/data/CLs/plots/jpsi_p/0.25Ctt3sFalsef.png +++ b/data/CLs/plots/jpsi_p/0.25Ctt3sFalsef.png Binary files differ diff --git a/data/CLs/plots/jpsi_p/0.31Ctt4sTruef.png b/data/CLs/plots/jpsi_p/0.31Ctt4sTruef.png index c893b40..7128e7a 100644 --- a/data/CLs/plots/jpsi_p/0.31Ctt4sTruef.png +++ b/data/CLs/plots/jpsi_p/0.31Ctt4sTruef.png Binary files differ diff --git a/data/CLs/plots/jpsi_p/0.31Ctt5sFalsef.png b/data/CLs/plots/jpsi_p/0.31Ctt5sFalsef.png index 555f2fa..19b7da4 100644 --- a/data/CLs/plots/jpsi_p/0.31Ctt5sFalsef.png +++ b/data/CLs/plots/jpsi_p/0.31Ctt5sFalsef.png Binary files differ diff --git a/data/CLs/plots/jpsi_p/0.36Ctt6sTruef.png b/data/CLs/plots/jpsi_p/0.36Ctt6sTruef.png index 313eebe..9a5257b 100644 --- a/data/CLs/plots/jpsi_p/0.36Ctt6sTruef.png +++ b/data/CLs/plots/jpsi_p/0.36Ctt6sTruef.png Binary files differ diff --git a/data/CLs/plots/jpsi_p/0.36Ctt7sFalsef.png b/data/CLs/plots/jpsi_p/0.36Ctt7sFalsef.png index 0934a1e..3d44d65 100644 --- a/data/CLs/plots/jpsi_p/0.36Ctt7sFalsef.png +++ b/data/CLs/plots/jpsi_p/0.36Ctt7sFalsef.png Binary files differ diff --git a/data/CLs/plots/jpsi_p/0.41Ctt8sTruef.png b/data/CLs/plots/jpsi_p/0.41Ctt8sTruef.png index 12fc243..d4bf155 100644 --- a/data/CLs/plots/jpsi_p/0.41Ctt8sTruef.png +++ b/data/CLs/plots/jpsi_p/0.41Ctt8sTruef.png Binary files differ diff --git a/data/CLs/plots/jpsi_p/0.41Ctt9sFalsef.png b/data/CLs/plots/jpsi_p/0.41Ctt9sFalsef.png index ac9e456..a15b4fe 100644 --- a/data/CLs/plots/jpsi_p/0.41Ctt9sFalsef.png +++ b/data/CLs/plots/jpsi_p/0.41Ctt9sFalsef.png Binary files differ diff --git a/data/CLs/plots/jpsi_p/0.45Ctt10sTruef.png b/data/CLs/plots/jpsi_p/0.45Ctt10sTruef.png index a87fa3d..2affd4b 100644 --- a/data/CLs/plots/jpsi_p/0.45Ctt10sTruef.png +++ b/data/CLs/plots/jpsi_p/0.45Ctt10sTruef.png Binary files differ diff --git a/data/CLs/plots/jpsi_p/0.45Ctt11sFalsef.png b/data/CLs/plots/jpsi_p/0.45Ctt11sFalsef.png index d3734fe..1ac4c98 100644 --- a/data/CLs/plots/jpsi_p/0.45Ctt11sFalsef.png +++ b/data/CLs/plots/jpsi_p/0.45Ctt11sFalsef.png Binary files differ diff --git a/data/CLs/plots/jpsi_p/0.49Ctt12sTruef.png b/data/CLs/plots/jpsi_p/0.49Ctt12sTruef.png index 83e2ae2..ad3cf5d 100644 --- a/data/CLs/plots/jpsi_p/0.49Ctt12sTruef.png +++ b/data/CLs/plots/jpsi_p/0.49Ctt12sTruef.png Binary files differ diff --git a/data/CLs/plots/jpsi_p/0.49Ctt13sFalsef.png b/data/CLs/plots/jpsi_p/0.49Ctt13sFalsef.png index 5675dc2..7bf7a58 100644 --- a/data/CLs/plots/jpsi_p/0.49Ctt13sFalsef.png +++ b/data/CLs/plots/jpsi_p/0.49Ctt13sFalsef.png Binary files differ diff --git a/data/CLs/plots/jpsi_p/0.53Ctt14sTruef.png b/data/CLs/plots/jpsi_p/0.53Ctt14sTruef.png index 79b1c92..4f48185 100644 --- a/data/CLs/plots/jpsi_p/0.53Ctt14sTruef.png +++ b/data/CLs/plots/jpsi_p/0.53Ctt14sTruef.png Binary files differ diff --git a/data/CLs/plots/jpsi_p/0.53Ctt15sFalsef.png b/data/CLs/plots/jpsi_p/0.53Ctt15sFalsef.png index bdd87e7..c03313a 100644 --- a/data/CLs/plots/jpsi_p/0.53Ctt15sFalsef.png +++ b/data/CLs/plots/jpsi_p/0.53Ctt15sFalsef.png Binary files differ diff --git a/data/CLs/plots/jpsi_p/0.56Ctt16sTruef.png b/data/CLs/plots/jpsi_p/0.56Ctt16sTruef.png index b9ecfa0..3bcca08 100644 --- a/data/CLs/plots/jpsi_p/0.56Ctt16sTruef.png +++ b/data/CLs/plots/jpsi_p/0.56Ctt16sTruef.png Binary files differ diff --git a/data/CLs/plots/jpsi_p/0.56Ctt17sFalsef.png b/data/CLs/plots/jpsi_p/0.56Ctt17sFalsef.png index c5ae14f..0382797 100644 --- a/data/CLs/plots/jpsi_p/0.56Ctt17sFalsef.png +++ b/data/CLs/plots/jpsi_p/0.56Ctt17sFalsef.png Binary files differ diff --git a/data/CLs/plots/jpsi_p/0.59Ctt18sTruef.png b/data/CLs/plots/jpsi_p/0.59Ctt18sTruef.png index 03384a1..393f6ef 100644 --- a/data/CLs/plots/jpsi_p/0.59Ctt18sTruef.png +++ b/data/CLs/plots/jpsi_p/0.59Ctt18sTruef.png Binary files differ diff --git a/data/CLs/plots/jpsi_p/0.59Ctt19sFalsef.png b/data/CLs/plots/jpsi_p/0.59Ctt19sFalsef.png index ae29af3..8bdd51a 100644 --- a/data/CLs/plots/jpsi_p/0.59Ctt19sFalsef.png +++ b/data/CLs/plots/jpsi_p/0.59Ctt19sFalsef.png Binary files differ diff --git a/data/CLs/plots/jpsi_p/0.62Ctt20sTruef.png b/data/CLs/plots/jpsi_p/0.62Ctt20sTruef.png index 9514d2c..66d857a 100644 --- a/data/CLs/plots/jpsi_p/0.62Ctt20sTruef.png +++ b/data/CLs/plots/jpsi_p/0.62Ctt20sTruef.png Binary files differ diff --git a/data/CLs/plots/jpsi_p/0.62Ctt21sFalsef.png b/data/CLs/plots/jpsi_p/0.62Ctt21sFalsef.png index 6319fd7..188e1be 100644 --- a/data/CLs/plots/jpsi_p/0.62Ctt21sFalsef.png +++ b/data/CLs/plots/jpsi_p/0.62Ctt21sFalsef.png Binary files differ diff --git a/data/CLs/plots/jpsi_p/0.65Ctt22sTruef.png b/data/CLs/plots/jpsi_p/0.65Ctt22sTruef.png index f363ad2..f5b4459 100644 --- a/data/CLs/plots/jpsi_p/0.65Ctt22sTruef.png +++ b/data/CLs/plots/jpsi_p/0.65Ctt22sTruef.png Binary files differ diff --git a/data/CLs/plots/jpsi_p/0.65Ctt23sFalsef.png b/data/CLs/plots/jpsi_p/0.65Ctt23sFalsef.png index 4ccce32..3f280d5 100644 --- a/data/CLs/plots/jpsi_p/0.65Ctt23sFalsef.png +++ b/data/CLs/plots/jpsi_p/0.65Ctt23sFalsef.png Binary files differ diff --git a/data/CLs/plots/jpsi_p/0.68Ctt24sTruef.png b/data/CLs/plots/jpsi_p/0.68Ctt24sTruef.png index cf7ed39..1645165 100644 --- a/data/CLs/plots/jpsi_p/0.68Ctt24sTruef.png +++ b/data/CLs/plots/jpsi_p/0.68Ctt24sTruef.png Binary files differ diff --git a/data/CLs/plots/jpsi_p/0.68Ctt25sFalsef.png b/data/CLs/plots/jpsi_p/0.68Ctt25sFalsef.png index b3222ed..5b625e7 100644 --- a/data/CLs/plots/jpsi_p/0.68Ctt25sFalsef.png +++ b/data/CLs/plots/jpsi_p/0.68Ctt25sFalsef.png Binary files differ diff --git a/data/CLs/plots/jpsi_p/0.70Ctt26sTruef.png b/data/CLs/plots/jpsi_p/0.70Ctt26sTruef.png index 9cd0873..5d5886e 100644 --- a/data/CLs/plots/jpsi_p/0.70Ctt26sTruef.png +++ b/data/CLs/plots/jpsi_p/0.70Ctt26sTruef.png Binary files differ diff --git a/data/CLs/plots/jpsi_p/0.70Ctt27sFalsef.png b/data/CLs/plots/jpsi_p/0.70Ctt27sFalsef.png index 61c1c28..005531a 100644 --- a/data/CLs/plots/jpsi_p/0.70Ctt27sFalsef.png +++ b/data/CLs/plots/jpsi_p/0.70Ctt27sFalsef.png Binary files differ diff --git a/data/CLs/plots/jpsi_p/0.73Ctt28sTruef.png b/data/CLs/plots/jpsi_p/0.73Ctt28sTruef.png index aacbaf6..edb6b26 100644 --- a/data/CLs/plots/jpsi_p/0.73Ctt28sTruef.png +++ b/data/CLs/plots/jpsi_p/0.73Ctt28sTruef.png Binary files differ diff --git a/data/CLs/plots/jpsi_p/0.73Ctt29sFalsef.png b/data/CLs/plots/jpsi_p/0.73Ctt29sFalsef.png index e965839..08dbc2a 100644 --- a/data/CLs/plots/jpsi_p/0.73Ctt29sFalsef.png +++ b/data/CLs/plots/jpsi_p/0.73Ctt29sFalsef.png Binary files differ diff --git a/data/CLs/plots/jpsi_p/0.75Ctt30sTruef.png b/data/CLs/plots/jpsi_p/0.75Ctt30sTruef.png index b19d596..ba35510 100644 --- a/data/CLs/plots/jpsi_p/0.75Ctt30sTruef.png +++ b/data/CLs/plots/jpsi_p/0.75Ctt30sTruef.png Binary files differ diff --git a/data/CLs/plots/jpsi_p/0.75Ctt31sFalsef.png b/data/CLs/plots/jpsi_p/0.75Ctt31sFalsef.png index 345d54f..df51c00 100644 --- a/data/CLs/plots/jpsi_p/0.75Ctt31sFalsef.png +++ b/data/CLs/plots/jpsi_p/0.75Ctt31sFalsef.png Binary files differ diff --git a/data/CLs/plots/jpsi_p/0.78Ctt32sTruef.png b/data/CLs/plots/jpsi_p/0.78Ctt32sTruef.png index c7a897c..3e82c54 100644 --- a/data/CLs/plots/jpsi_p/0.78Ctt32sTruef.png +++ b/data/CLs/plots/jpsi_p/0.78Ctt32sTruef.png Binary files differ diff --git a/data/CLs/plots/jpsi_p/0.78Ctt33sFalsef.png b/data/CLs/plots/jpsi_p/0.78Ctt33sFalsef.png index 4778a0a..e2ec68c 100644 --- a/data/CLs/plots/jpsi_p/0.78Ctt33sFalsef.png +++ b/data/CLs/plots/jpsi_p/0.78Ctt33sFalsef.png Binary files differ diff --git a/data/CLs/plots/jpsi_p/0.80Ctt34sTruef.png b/data/CLs/plots/jpsi_p/0.80Ctt34sTruef.png index 3fad64a..08aafae 100644 --- a/data/CLs/plots/jpsi_p/0.80Ctt34sTruef.png +++ b/data/CLs/plots/jpsi_p/0.80Ctt34sTruef.png Binary files differ diff --git a/data/CLs/plots/jpsi_p/0.80Ctt35sFalsef.png b/data/CLs/plots/jpsi_p/0.80Ctt35sFalsef.png index 92f36cf..aa62366 100644 --- a/data/CLs/plots/jpsi_p/0.80Ctt35sFalsef.png +++ b/data/CLs/plots/jpsi_p/0.80Ctt35sFalsef.png Binary files differ diff --git a/data/CLs/plots/jpsi_p/0.82Ctt36sTruef.png b/data/CLs/plots/jpsi_p/0.82Ctt36sTruef.png index 2880ff8..f9ce061 100644 --- a/data/CLs/plots/jpsi_p/0.82Ctt36sTruef.png +++ b/data/CLs/plots/jpsi_p/0.82Ctt36sTruef.png Binary files differ diff --git a/data/CLs/plots/jpsi_p/0.82Ctt37sFalsef.png b/data/CLs/plots/jpsi_p/0.82Ctt37sFalsef.png index b969aec..f56f9ff 100644 --- a/data/CLs/plots/jpsi_p/0.82Ctt37sFalsef.png +++ b/data/CLs/plots/jpsi_p/0.82Ctt37sFalsef.png Binary files differ diff --git a/data/CLs/plots/jpsi_p/0.85Ctt38sTruef.png b/data/CLs/plots/jpsi_p/0.85Ctt38sTruef.png index dd3c777..e4a2a8c 100644 --- a/data/CLs/plots/jpsi_p/0.85Ctt38sTruef.png +++ b/data/CLs/plots/jpsi_p/0.85Ctt38sTruef.png Binary files differ diff --git a/data/CLs/plots/jpsi_p/0.85Ctt39sFalsef.png b/data/CLs/plots/jpsi_p/0.85Ctt39sFalsef.png index 85e3d4c..6115780 100644 --- a/data/CLs/plots/jpsi_p/0.85Ctt39sFalsef.png +++ b/data/CLs/plots/jpsi_p/0.85Ctt39sFalsef.png Binary files differ diff --git a/data/CLs/plots/omega_p/0.00Ctt0sTruef.png b/data/CLs/plots/omega_p/0.00Ctt0sTruef.png index 712a33e..473e985 100644 --- a/data/CLs/plots/omega_p/0.00Ctt0sTruef.png +++ b/data/CLs/plots/omega_p/0.00Ctt0sTruef.png Binary files differ diff --git a/data/CLs/plots/omega_p/0.00Ctt1sFalsef.png b/data/CLs/plots/omega_p/0.00Ctt1sFalsef.png index 657535a..a115517 100644 --- a/data/CLs/plots/omega_p/0.00Ctt1sFalsef.png +++ b/data/CLs/plots/omega_p/0.00Ctt1sFalsef.png Binary files differ diff --git a/data/CLs/plots/omega_p/0.25Ctt2sTruef.png b/data/CLs/plots/omega_p/0.25Ctt2sTruef.png index 9e9f894..eb325be 100644 --- a/data/CLs/plots/omega_p/0.25Ctt2sTruef.png +++ b/data/CLs/plots/omega_p/0.25Ctt2sTruef.png Binary files differ diff --git a/data/CLs/plots/omega_p/0.25Ctt3sFalsef.png b/data/CLs/plots/omega_p/0.25Ctt3sFalsef.png index a336adb..54861a2 100644 --- a/data/CLs/plots/omega_p/0.25Ctt3sFalsef.png +++ b/data/CLs/plots/omega_p/0.25Ctt3sFalsef.png Binary files differ diff --git a/data/CLs/plots/omega_p/0.31Ctt4sTruef.png b/data/CLs/plots/omega_p/0.31Ctt4sTruef.png index 8aab86a..b1bc71f 100644 --- a/data/CLs/plots/omega_p/0.31Ctt4sTruef.png +++ b/data/CLs/plots/omega_p/0.31Ctt4sTruef.png Binary files differ diff --git a/data/CLs/plots/omega_p/0.31Ctt5sFalsef.png b/data/CLs/plots/omega_p/0.31Ctt5sFalsef.png index 0d41ba2..bec95c6 100644 --- a/data/CLs/plots/omega_p/0.31Ctt5sFalsef.png +++ b/data/CLs/plots/omega_p/0.31Ctt5sFalsef.png Binary files differ diff --git a/data/CLs/plots/omega_p/0.36Ctt6sTruef.png b/data/CLs/plots/omega_p/0.36Ctt6sTruef.png index 2e87b11..ca1e405 100644 --- a/data/CLs/plots/omega_p/0.36Ctt6sTruef.png +++ b/data/CLs/plots/omega_p/0.36Ctt6sTruef.png Binary files differ diff --git a/data/CLs/plots/omega_p/0.36Ctt7sFalsef.png b/data/CLs/plots/omega_p/0.36Ctt7sFalsef.png index ac2664c..9353b66 100644 --- a/data/CLs/plots/omega_p/0.36Ctt7sFalsef.png +++ b/data/CLs/plots/omega_p/0.36Ctt7sFalsef.png Binary files differ diff --git a/data/CLs/plots/omega_p/0.41Ctt8sTruef.png b/data/CLs/plots/omega_p/0.41Ctt8sTruef.png index d854692..23f54ef 100644 --- a/data/CLs/plots/omega_p/0.41Ctt8sTruef.png +++ b/data/CLs/plots/omega_p/0.41Ctt8sTruef.png Binary files differ diff --git a/data/CLs/plots/omega_p/0.41Ctt9sFalsef.png b/data/CLs/plots/omega_p/0.41Ctt9sFalsef.png index c006153..0b40b17 100644 --- a/data/CLs/plots/omega_p/0.41Ctt9sFalsef.png +++ b/data/CLs/plots/omega_p/0.41Ctt9sFalsef.png Binary files differ diff --git a/data/CLs/plots/omega_p/0.45Ctt10sTruef.png b/data/CLs/plots/omega_p/0.45Ctt10sTruef.png index 1daab35..ee8a914 100644 --- a/data/CLs/plots/omega_p/0.45Ctt10sTruef.png +++ b/data/CLs/plots/omega_p/0.45Ctt10sTruef.png Binary files differ diff --git a/data/CLs/plots/omega_p/0.45Ctt11sFalsef.png b/data/CLs/plots/omega_p/0.45Ctt11sFalsef.png index 6c886b1..f453d77 100644 --- a/data/CLs/plots/omega_p/0.45Ctt11sFalsef.png +++ b/data/CLs/plots/omega_p/0.45Ctt11sFalsef.png Binary files differ diff --git a/data/CLs/plots/omega_p/0.49Ctt12sTruef.png b/data/CLs/plots/omega_p/0.49Ctt12sTruef.png index 834eec8..c67ecf3 100644 --- a/data/CLs/plots/omega_p/0.49Ctt12sTruef.png +++ b/data/CLs/plots/omega_p/0.49Ctt12sTruef.png Binary files differ diff --git a/data/CLs/plots/omega_p/0.49Ctt13sFalsef.png b/data/CLs/plots/omega_p/0.49Ctt13sFalsef.png index 489632c..cfe9235 100644 --- a/data/CLs/plots/omega_p/0.49Ctt13sFalsef.png +++ b/data/CLs/plots/omega_p/0.49Ctt13sFalsef.png Binary files differ diff --git a/data/CLs/plots/omega_p/0.53Ctt14sTruef.png b/data/CLs/plots/omega_p/0.53Ctt14sTruef.png index a6670cb..228356d 100644 --- a/data/CLs/plots/omega_p/0.53Ctt14sTruef.png +++ b/data/CLs/plots/omega_p/0.53Ctt14sTruef.png Binary files differ diff --git a/data/CLs/plots/omega_p/0.53Ctt15sFalsef.png b/data/CLs/plots/omega_p/0.53Ctt15sFalsef.png index bd512d4..0397a46 100644 --- a/data/CLs/plots/omega_p/0.53Ctt15sFalsef.png +++ b/data/CLs/plots/omega_p/0.53Ctt15sFalsef.png Binary files differ diff --git a/data/CLs/plots/omega_p/0.56Ctt16sTruef.png b/data/CLs/plots/omega_p/0.56Ctt16sTruef.png index d6e7887..eb0ceea 100644 --- a/data/CLs/plots/omega_p/0.56Ctt16sTruef.png +++ b/data/CLs/plots/omega_p/0.56Ctt16sTruef.png Binary files differ diff --git a/data/CLs/plots/omega_p/0.56Ctt17sFalsef.png b/data/CLs/plots/omega_p/0.56Ctt17sFalsef.png index 1008e2c..d7a1a33 100644 --- a/data/CLs/plots/omega_p/0.56Ctt17sFalsef.png +++ b/data/CLs/plots/omega_p/0.56Ctt17sFalsef.png Binary files differ diff --git a/data/CLs/plots/omega_p/0.59Ctt18sTruef.png b/data/CLs/plots/omega_p/0.59Ctt18sTruef.png index a02b501..e7f61a4 100644 --- a/data/CLs/plots/omega_p/0.59Ctt18sTruef.png +++ b/data/CLs/plots/omega_p/0.59Ctt18sTruef.png Binary files differ diff --git a/data/CLs/plots/omega_p/0.59Ctt19sFalsef.png b/data/CLs/plots/omega_p/0.59Ctt19sFalsef.png index 7ee4d0d..277f326 100644 --- a/data/CLs/plots/omega_p/0.59Ctt19sFalsef.png +++ b/data/CLs/plots/omega_p/0.59Ctt19sFalsef.png Binary files differ diff --git a/data/CLs/plots/omega_p/0.62Ctt20sTruef.png b/data/CLs/plots/omega_p/0.62Ctt20sTruef.png index 48ef8e0..e128891 100644 --- a/data/CLs/plots/omega_p/0.62Ctt20sTruef.png +++ b/data/CLs/plots/omega_p/0.62Ctt20sTruef.png Binary files differ diff --git a/data/CLs/plots/omega_p/0.62Ctt21sFalsef.png b/data/CLs/plots/omega_p/0.62Ctt21sFalsef.png index 3b5bb73..fa41e54 100644 --- a/data/CLs/plots/omega_p/0.62Ctt21sFalsef.png +++ b/data/CLs/plots/omega_p/0.62Ctt21sFalsef.png Binary files differ diff --git a/data/CLs/plots/omega_p/0.65Ctt22sTruef.png b/data/CLs/plots/omega_p/0.65Ctt22sTruef.png index 4f87b45..410d7c7 100644 --- a/data/CLs/plots/omega_p/0.65Ctt22sTruef.png +++ b/data/CLs/plots/omega_p/0.65Ctt22sTruef.png Binary files differ diff --git a/data/CLs/plots/omega_p/0.65Ctt23sFalsef.png b/data/CLs/plots/omega_p/0.65Ctt23sFalsef.png index 159b68c..1b87cfc 100644 --- a/data/CLs/plots/omega_p/0.65Ctt23sFalsef.png +++ b/data/CLs/plots/omega_p/0.65Ctt23sFalsef.png Binary files differ diff --git a/data/CLs/plots/omega_p/0.68Ctt24sTruef.png b/data/CLs/plots/omega_p/0.68Ctt24sTruef.png index 8dea28f..15581b0 100644 --- a/data/CLs/plots/omega_p/0.68Ctt24sTruef.png +++ b/data/CLs/plots/omega_p/0.68Ctt24sTruef.png Binary files differ diff --git a/data/CLs/plots/omega_p/0.68Ctt25sFalsef.png b/data/CLs/plots/omega_p/0.68Ctt25sFalsef.png index 6ac57ac..437d987 100644 --- a/data/CLs/plots/omega_p/0.68Ctt25sFalsef.png +++ b/data/CLs/plots/omega_p/0.68Ctt25sFalsef.png Binary files differ diff --git a/data/CLs/plots/omega_p/0.70Ctt26sTruef.png b/data/CLs/plots/omega_p/0.70Ctt26sTruef.png index 3da07a3..8d0961b 100644 --- a/data/CLs/plots/omega_p/0.70Ctt26sTruef.png +++ b/data/CLs/plots/omega_p/0.70Ctt26sTruef.png Binary files differ diff --git a/data/CLs/plots/omega_p/0.70Ctt27sFalsef.png b/data/CLs/plots/omega_p/0.70Ctt27sFalsef.png index 041ef75..ce5bd9d 100644 --- a/data/CLs/plots/omega_p/0.70Ctt27sFalsef.png +++ b/data/CLs/plots/omega_p/0.70Ctt27sFalsef.png Binary files differ diff --git a/data/CLs/plots/omega_p/0.73Ctt28sTruef.png b/data/CLs/plots/omega_p/0.73Ctt28sTruef.png index 83c395c..a85cb5e 100644 --- a/data/CLs/plots/omega_p/0.73Ctt28sTruef.png +++ b/data/CLs/plots/omega_p/0.73Ctt28sTruef.png Binary files differ diff --git a/data/CLs/plots/omega_p/0.73Ctt29sFalsef.png b/data/CLs/plots/omega_p/0.73Ctt29sFalsef.png index ff664dd..75a1eaa 100644 --- a/data/CLs/plots/omega_p/0.73Ctt29sFalsef.png +++ b/data/CLs/plots/omega_p/0.73Ctt29sFalsef.png Binary files differ diff --git a/data/CLs/plots/omega_p/0.75Ctt30sTruef.png b/data/CLs/plots/omega_p/0.75Ctt30sTruef.png index b122c1e..5887102 100644 --- a/data/CLs/plots/omega_p/0.75Ctt30sTruef.png +++ b/data/CLs/plots/omega_p/0.75Ctt30sTruef.png Binary files differ diff --git a/data/CLs/plots/omega_p/0.75Ctt31sFalsef.png b/data/CLs/plots/omega_p/0.75Ctt31sFalsef.png index f51202e..033df75 100644 --- a/data/CLs/plots/omega_p/0.75Ctt31sFalsef.png +++ b/data/CLs/plots/omega_p/0.75Ctt31sFalsef.png Binary files differ diff --git a/data/CLs/plots/omega_p/0.78Ctt32sTruef.png b/data/CLs/plots/omega_p/0.78Ctt32sTruef.png index 06325a2..4a485b4 100644 --- a/data/CLs/plots/omega_p/0.78Ctt32sTruef.png +++ b/data/CLs/plots/omega_p/0.78Ctt32sTruef.png Binary files differ diff --git a/data/CLs/plots/omega_p/0.78Ctt33sFalsef.png b/data/CLs/plots/omega_p/0.78Ctt33sFalsef.png index 2304fcf..666f73c 100644 --- a/data/CLs/plots/omega_p/0.78Ctt33sFalsef.png +++ b/data/CLs/plots/omega_p/0.78Ctt33sFalsef.png Binary files differ diff --git a/data/CLs/plots/omega_p/0.80Ctt34sTruef.png b/data/CLs/plots/omega_p/0.80Ctt34sTruef.png index 6233681..a875f84 100644 --- a/data/CLs/plots/omega_p/0.80Ctt34sTruef.png +++ b/data/CLs/plots/omega_p/0.80Ctt34sTruef.png Binary files differ diff --git a/data/CLs/plots/omega_p/0.80Ctt35sFalsef.png b/data/CLs/plots/omega_p/0.80Ctt35sFalsef.png index b3c3e34..3e355d4 100644 --- a/data/CLs/plots/omega_p/0.80Ctt35sFalsef.png +++ b/data/CLs/plots/omega_p/0.80Ctt35sFalsef.png Binary files differ diff --git a/data/CLs/plots/omega_p/0.82Ctt36sTruef.png b/data/CLs/plots/omega_p/0.82Ctt36sTruef.png index 2f41d9f..58dfa92 100644 --- a/data/CLs/plots/omega_p/0.82Ctt36sTruef.png +++ b/data/CLs/plots/omega_p/0.82Ctt36sTruef.png Binary files differ diff --git a/data/CLs/plots/omega_p/0.82Ctt37sFalsef.png b/data/CLs/plots/omega_p/0.82Ctt37sFalsef.png index c13032a..4dd75fd 100644 --- a/data/CLs/plots/omega_p/0.82Ctt37sFalsef.png +++ b/data/CLs/plots/omega_p/0.82Ctt37sFalsef.png Binary files differ diff --git a/data/CLs/plots/omega_p/0.85Ctt38sTruef.png b/data/CLs/plots/omega_p/0.85Ctt38sTruef.png index f3c7274..a873ddf 100644 --- a/data/CLs/plots/omega_p/0.85Ctt38sTruef.png +++ b/data/CLs/plots/omega_p/0.85Ctt38sTruef.png Binary files differ diff --git a/data/CLs/plots/omega_p/0.85Ctt39sFalsef.png b/data/CLs/plots/omega_p/0.85Ctt39sFalsef.png index dad476a..0ac2d93 100644 --- a/data/CLs/plots/omega_p/0.85Ctt39sFalsef.png +++ b/data/CLs/plots/omega_p/0.85Ctt39sFalsef.png Binary files differ diff --git a/data/CLs/plots/omega_s/0.00Ctt0sTruef.png b/data/CLs/plots/omega_s/0.00Ctt0sTruef.png index a84c4ae..678b82e 100644 --- a/data/CLs/plots/omega_s/0.00Ctt0sTruef.png +++ b/data/CLs/plots/omega_s/0.00Ctt0sTruef.png Binary files differ diff --git a/data/CLs/plots/omega_s/0.00Ctt1sFalsef.png b/data/CLs/plots/omega_s/0.00Ctt1sFalsef.png index 596a6c2..a4c411e 100644 --- a/data/CLs/plots/omega_s/0.00Ctt1sFalsef.png +++ b/data/CLs/plots/omega_s/0.00Ctt1sFalsef.png Binary files differ diff --git a/data/CLs/plots/omega_s/0.25Ctt2sTruef.png b/data/CLs/plots/omega_s/0.25Ctt2sTruef.png index a14316b..4bf26f4 100644 --- a/data/CLs/plots/omega_s/0.25Ctt2sTruef.png +++ b/data/CLs/plots/omega_s/0.25Ctt2sTruef.png Binary files differ diff --git a/data/CLs/plots/omega_s/0.25Ctt3sFalsef.png b/data/CLs/plots/omega_s/0.25Ctt3sFalsef.png index 486ecb2..1c10c8e 100644 --- a/data/CLs/plots/omega_s/0.25Ctt3sFalsef.png +++ b/data/CLs/plots/omega_s/0.25Ctt3sFalsef.png Binary files differ diff --git a/data/CLs/plots/omega_s/0.31Ctt4sTruef.png b/data/CLs/plots/omega_s/0.31Ctt4sTruef.png index 153bcb6..022328f 100644 --- a/data/CLs/plots/omega_s/0.31Ctt4sTruef.png +++ b/data/CLs/plots/omega_s/0.31Ctt4sTruef.png Binary files differ diff --git a/data/CLs/plots/omega_s/0.31Ctt5sFalsef.png b/data/CLs/plots/omega_s/0.31Ctt5sFalsef.png index 84627af..31cb30e 100644 --- a/data/CLs/plots/omega_s/0.31Ctt5sFalsef.png +++ b/data/CLs/plots/omega_s/0.31Ctt5sFalsef.png Binary files differ diff --git a/data/CLs/plots/omega_s/0.36Ctt6sTruef.png b/data/CLs/plots/omega_s/0.36Ctt6sTruef.png index 908d152..ec3d9d0 100644 --- a/data/CLs/plots/omega_s/0.36Ctt6sTruef.png +++ b/data/CLs/plots/omega_s/0.36Ctt6sTruef.png Binary files differ diff --git a/data/CLs/plots/omega_s/0.36Ctt7sFalsef.png b/data/CLs/plots/omega_s/0.36Ctt7sFalsef.png index bc5a7b6..c24125f 100644 --- a/data/CLs/plots/omega_s/0.36Ctt7sFalsef.png +++ b/data/CLs/plots/omega_s/0.36Ctt7sFalsef.png Binary files differ diff --git a/data/CLs/plots/omega_s/0.41Ctt8sTruef.png b/data/CLs/plots/omega_s/0.41Ctt8sTruef.png index de854c5..ad8c117 100644 --- a/data/CLs/plots/omega_s/0.41Ctt8sTruef.png +++ b/data/CLs/plots/omega_s/0.41Ctt8sTruef.png Binary files differ diff --git a/data/CLs/plots/omega_s/0.41Ctt9sFalsef.png b/data/CLs/plots/omega_s/0.41Ctt9sFalsef.png index 7a43bc5..c9b7684 100644 --- a/data/CLs/plots/omega_s/0.41Ctt9sFalsef.png +++ b/data/CLs/plots/omega_s/0.41Ctt9sFalsef.png Binary files differ diff --git a/data/CLs/plots/omega_s/0.45Ctt10sTruef.png b/data/CLs/plots/omega_s/0.45Ctt10sTruef.png index 36a1866..fe317ca 100644 --- a/data/CLs/plots/omega_s/0.45Ctt10sTruef.png +++ b/data/CLs/plots/omega_s/0.45Ctt10sTruef.png Binary files differ diff --git a/data/CLs/plots/omega_s/0.45Ctt11sFalsef.png b/data/CLs/plots/omega_s/0.45Ctt11sFalsef.png index c5e76e5..369461f 100644 --- a/data/CLs/plots/omega_s/0.45Ctt11sFalsef.png +++ b/data/CLs/plots/omega_s/0.45Ctt11sFalsef.png Binary files differ diff --git a/data/CLs/plots/omega_s/0.49Ctt12sTruef.png b/data/CLs/plots/omega_s/0.49Ctt12sTruef.png index 4f88411..c500cd8 100644 --- a/data/CLs/plots/omega_s/0.49Ctt12sTruef.png +++ b/data/CLs/plots/omega_s/0.49Ctt12sTruef.png Binary files differ diff --git a/data/CLs/plots/omega_s/0.49Ctt13sFalsef.png b/data/CLs/plots/omega_s/0.49Ctt13sFalsef.png index 3081bec..99a6264 100644 --- a/data/CLs/plots/omega_s/0.49Ctt13sFalsef.png +++ b/data/CLs/plots/omega_s/0.49Ctt13sFalsef.png Binary files differ diff --git a/data/CLs/plots/omega_s/0.53Ctt14sTruef.png b/data/CLs/plots/omega_s/0.53Ctt14sTruef.png index 11b319f..9b8e7be 100644 --- a/data/CLs/plots/omega_s/0.53Ctt14sTruef.png +++ b/data/CLs/plots/omega_s/0.53Ctt14sTruef.png Binary files differ diff --git a/data/CLs/plots/omega_s/0.53Ctt15sFalsef.png b/data/CLs/plots/omega_s/0.53Ctt15sFalsef.png index 573f4f5..a752930 100644 --- a/data/CLs/plots/omega_s/0.53Ctt15sFalsef.png +++ b/data/CLs/plots/omega_s/0.53Ctt15sFalsef.png Binary files differ diff --git a/data/CLs/plots/omega_s/0.56Ctt16sTruef.png b/data/CLs/plots/omega_s/0.56Ctt16sTruef.png index c5c0a32..d542872 100644 --- a/data/CLs/plots/omega_s/0.56Ctt16sTruef.png +++ b/data/CLs/plots/omega_s/0.56Ctt16sTruef.png Binary files differ diff --git a/data/CLs/plots/omega_s/0.56Ctt17sFalsef.png b/data/CLs/plots/omega_s/0.56Ctt17sFalsef.png index 27bd5c8..aae94e6 100644 --- a/data/CLs/plots/omega_s/0.56Ctt17sFalsef.png +++ b/data/CLs/plots/omega_s/0.56Ctt17sFalsef.png Binary files differ diff --git a/data/CLs/plots/omega_s/0.59Ctt18sTruef.png b/data/CLs/plots/omega_s/0.59Ctt18sTruef.png index 8e4c93c..4ff7818 100644 --- a/data/CLs/plots/omega_s/0.59Ctt18sTruef.png +++ b/data/CLs/plots/omega_s/0.59Ctt18sTruef.png Binary files differ diff --git a/data/CLs/plots/omega_s/0.59Ctt19sFalsef.png b/data/CLs/plots/omega_s/0.59Ctt19sFalsef.png index 657f2bc..1930507 100644 --- a/data/CLs/plots/omega_s/0.59Ctt19sFalsef.png +++ b/data/CLs/plots/omega_s/0.59Ctt19sFalsef.png Binary files differ diff --git a/data/CLs/plots/omega_s/0.62Ctt20sTruef.png b/data/CLs/plots/omega_s/0.62Ctt20sTruef.png index c470c49..71116e5 100644 --- a/data/CLs/plots/omega_s/0.62Ctt20sTruef.png +++ b/data/CLs/plots/omega_s/0.62Ctt20sTruef.png Binary files differ diff --git a/data/CLs/plots/omega_s/0.62Ctt21sFalsef.png b/data/CLs/plots/omega_s/0.62Ctt21sFalsef.png index 052f63f..3805132 100644 --- a/data/CLs/plots/omega_s/0.62Ctt21sFalsef.png +++ b/data/CLs/plots/omega_s/0.62Ctt21sFalsef.png Binary files differ diff --git a/data/CLs/plots/omega_s/0.65Ctt22sTruef.png b/data/CLs/plots/omega_s/0.65Ctt22sTruef.png index 9ff288f..68fcaa0 100644 --- a/data/CLs/plots/omega_s/0.65Ctt22sTruef.png +++ b/data/CLs/plots/omega_s/0.65Ctt22sTruef.png Binary files differ diff --git a/data/CLs/plots/omega_s/0.65Ctt23sFalsef.png b/data/CLs/plots/omega_s/0.65Ctt23sFalsef.png index bfe4054..ea71a75 100644 --- a/data/CLs/plots/omega_s/0.65Ctt23sFalsef.png +++ b/data/CLs/plots/omega_s/0.65Ctt23sFalsef.png Binary files differ diff --git a/data/CLs/plots/omega_s/0.68Ctt24sTruef.png b/data/CLs/plots/omega_s/0.68Ctt24sTruef.png index d1e0d88..84a76e7 100644 --- a/data/CLs/plots/omega_s/0.68Ctt24sTruef.png +++ b/data/CLs/plots/omega_s/0.68Ctt24sTruef.png Binary files differ diff --git a/data/CLs/plots/omega_s/0.68Ctt25sFalsef.png b/data/CLs/plots/omega_s/0.68Ctt25sFalsef.png index 8fddd25..9910a2a 100644 --- a/data/CLs/plots/omega_s/0.68Ctt25sFalsef.png +++ b/data/CLs/plots/omega_s/0.68Ctt25sFalsef.png Binary files differ diff --git a/data/CLs/plots/omega_s/0.70Ctt26sTruef.png b/data/CLs/plots/omega_s/0.70Ctt26sTruef.png index 6302281..1c6b919 100644 --- a/data/CLs/plots/omega_s/0.70Ctt26sTruef.png +++ b/data/CLs/plots/omega_s/0.70Ctt26sTruef.png Binary files differ diff --git a/data/CLs/plots/omega_s/0.70Ctt27sFalsef.png b/data/CLs/plots/omega_s/0.70Ctt27sFalsef.png index 7b38407..4ce03d3 100644 --- a/data/CLs/plots/omega_s/0.70Ctt27sFalsef.png +++ b/data/CLs/plots/omega_s/0.70Ctt27sFalsef.png Binary files differ diff --git a/data/CLs/plots/omega_s/0.73Ctt28sTruef.png b/data/CLs/plots/omega_s/0.73Ctt28sTruef.png index 0a93232..5999624 100644 --- a/data/CLs/plots/omega_s/0.73Ctt28sTruef.png +++ b/data/CLs/plots/omega_s/0.73Ctt28sTruef.png Binary files differ diff --git a/data/CLs/plots/omega_s/0.73Ctt29sFalsef.png b/data/CLs/plots/omega_s/0.73Ctt29sFalsef.png index 995b9e5..f642f72 100644 --- a/data/CLs/plots/omega_s/0.73Ctt29sFalsef.png +++ b/data/CLs/plots/omega_s/0.73Ctt29sFalsef.png Binary files differ diff --git a/data/CLs/plots/omega_s/0.75Ctt30sTruef.png b/data/CLs/plots/omega_s/0.75Ctt30sTruef.png index a2003b3..56cc998 100644 --- a/data/CLs/plots/omega_s/0.75Ctt30sTruef.png +++ b/data/CLs/plots/omega_s/0.75Ctt30sTruef.png Binary files differ diff --git a/data/CLs/plots/omega_s/0.75Ctt31sFalsef.png b/data/CLs/plots/omega_s/0.75Ctt31sFalsef.png index 16b8686..88d2795 100644 --- a/data/CLs/plots/omega_s/0.75Ctt31sFalsef.png +++ b/data/CLs/plots/omega_s/0.75Ctt31sFalsef.png Binary files differ diff --git a/data/CLs/plots/omega_s/0.78Ctt32sTruef.png b/data/CLs/plots/omega_s/0.78Ctt32sTruef.png index 692a93a..f94a762 100644 --- a/data/CLs/plots/omega_s/0.78Ctt32sTruef.png +++ b/data/CLs/plots/omega_s/0.78Ctt32sTruef.png Binary files differ diff --git a/data/CLs/plots/omega_s/0.78Ctt33sFalsef.png b/data/CLs/plots/omega_s/0.78Ctt33sFalsef.png index d06d9d6..da4ceb6 100644 --- a/data/CLs/plots/omega_s/0.78Ctt33sFalsef.png +++ b/data/CLs/plots/omega_s/0.78Ctt33sFalsef.png Binary files differ diff --git a/data/CLs/plots/omega_s/0.80Ctt34sTruef.png b/data/CLs/plots/omega_s/0.80Ctt34sTruef.png index 56e8e32..fd78e66 100644 --- a/data/CLs/plots/omega_s/0.80Ctt34sTruef.png +++ b/data/CLs/plots/omega_s/0.80Ctt34sTruef.png Binary files differ diff --git a/data/CLs/plots/omega_s/0.80Ctt35sFalsef.png b/data/CLs/plots/omega_s/0.80Ctt35sFalsef.png index 59223bb..8ba37cc 100644 --- a/data/CLs/plots/omega_s/0.80Ctt35sFalsef.png +++ b/data/CLs/plots/omega_s/0.80Ctt35sFalsef.png Binary files differ diff --git a/data/CLs/plots/omega_s/0.82Ctt36sTruef.png b/data/CLs/plots/omega_s/0.82Ctt36sTruef.png index 3675538..57adc31 100644 --- a/data/CLs/plots/omega_s/0.82Ctt36sTruef.png +++ b/data/CLs/plots/omega_s/0.82Ctt36sTruef.png Binary files differ diff --git a/data/CLs/plots/omega_s/0.82Ctt37sFalsef.png b/data/CLs/plots/omega_s/0.82Ctt37sFalsef.png index 7f9b5a5..03689a6 100644 --- a/data/CLs/plots/omega_s/0.82Ctt37sFalsef.png +++ b/data/CLs/plots/omega_s/0.82Ctt37sFalsef.png Binary files differ diff --git a/data/CLs/plots/omega_s/0.85Ctt38sTruef.png b/data/CLs/plots/omega_s/0.85Ctt38sTruef.png index cff83a9..e810488 100644 --- a/data/CLs/plots/omega_s/0.85Ctt38sTruef.png +++ b/data/CLs/plots/omega_s/0.85Ctt38sTruef.png Binary files differ diff --git a/data/CLs/plots/omega_s/0.85Ctt39sFalsef.png b/data/CLs/plots/omega_s/0.85Ctt39sFalsef.png index af0ae54..779b8b3 100644 --- a/data/CLs/plots/omega_s/0.85Ctt39sFalsef.png +++ b/data/CLs/plots/omega_s/0.85Ctt39sFalsef.png Binary files differ diff --git a/data/CLs/plots/p3770_p/0.00Ctt0sTruef.png b/data/CLs/plots/p3770_p/0.00Ctt0sTruef.png index 045c686..992980f 100644 --- a/data/CLs/plots/p3770_p/0.00Ctt0sTruef.png +++ b/data/CLs/plots/p3770_p/0.00Ctt0sTruef.png Binary files differ diff --git a/data/CLs/plots/p3770_p/0.00Ctt1sFalsef.png b/data/CLs/plots/p3770_p/0.00Ctt1sFalsef.png index bee6c15..b382027 100644 --- a/data/CLs/plots/p3770_p/0.00Ctt1sFalsef.png +++ b/data/CLs/plots/p3770_p/0.00Ctt1sFalsef.png Binary files differ diff --git a/data/CLs/plots/p3770_p/0.25Ctt2sTruef.png b/data/CLs/plots/p3770_p/0.25Ctt2sTruef.png index a224de5..6c01d15 100644 --- a/data/CLs/plots/p3770_p/0.25Ctt2sTruef.png +++ b/data/CLs/plots/p3770_p/0.25Ctt2sTruef.png Binary files differ diff --git a/data/CLs/plots/p3770_p/0.25Ctt3sFalsef.png b/data/CLs/plots/p3770_p/0.25Ctt3sFalsef.png index bfc301e..ead5cb8 100644 --- a/data/CLs/plots/p3770_p/0.25Ctt3sFalsef.png +++ b/data/CLs/plots/p3770_p/0.25Ctt3sFalsef.png Binary files differ diff --git a/data/CLs/plots/p3770_p/0.31Ctt4sTruef.png b/data/CLs/plots/p3770_p/0.31Ctt4sTruef.png index 7acad05..b884ce8 100644 --- a/data/CLs/plots/p3770_p/0.31Ctt4sTruef.png +++ b/data/CLs/plots/p3770_p/0.31Ctt4sTruef.png Binary files differ diff --git a/data/CLs/plots/p3770_p/0.31Ctt5sFalsef.png b/data/CLs/plots/p3770_p/0.31Ctt5sFalsef.png index 1217de5..0d60b89 100644 --- a/data/CLs/plots/p3770_p/0.31Ctt5sFalsef.png +++ b/data/CLs/plots/p3770_p/0.31Ctt5sFalsef.png Binary files differ diff --git a/data/CLs/plots/p3770_p/0.36Ctt6sTruef.png b/data/CLs/plots/p3770_p/0.36Ctt6sTruef.png index 4d99736..257f5ab 100644 --- a/data/CLs/plots/p3770_p/0.36Ctt6sTruef.png +++ b/data/CLs/plots/p3770_p/0.36Ctt6sTruef.png Binary files differ diff --git a/data/CLs/plots/p3770_p/0.36Ctt7sFalsef.png b/data/CLs/plots/p3770_p/0.36Ctt7sFalsef.png index 2905105..4512c83 100644 --- a/data/CLs/plots/p3770_p/0.36Ctt7sFalsef.png +++ b/data/CLs/plots/p3770_p/0.36Ctt7sFalsef.png Binary files differ diff --git a/data/CLs/plots/p3770_p/0.41Ctt8sTruef.png b/data/CLs/plots/p3770_p/0.41Ctt8sTruef.png index 5d0b908..f93222f 100644 --- a/data/CLs/plots/p3770_p/0.41Ctt8sTruef.png +++ b/data/CLs/plots/p3770_p/0.41Ctt8sTruef.png Binary files differ diff --git a/data/CLs/plots/p3770_p/0.41Ctt9sFalsef.png b/data/CLs/plots/p3770_p/0.41Ctt9sFalsef.png index 41389ce..3a4485a 100644 --- a/data/CLs/plots/p3770_p/0.41Ctt9sFalsef.png +++ b/data/CLs/plots/p3770_p/0.41Ctt9sFalsef.png Binary files differ diff --git a/data/CLs/plots/p3770_p/0.45Ctt10sTruef.png b/data/CLs/plots/p3770_p/0.45Ctt10sTruef.png index a5b3958..a2f13c8 100644 --- a/data/CLs/plots/p3770_p/0.45Ctt10sTruef.png +++ b/data/CLs/plots/p3770_p/0.45Ctt10sTruef.png Binary files differ diff --git a/data/CLs/plots/p3770_p/0.45Ctt11sFalsef.png b/data/CLs/plots/p3770_p/0.45Ctt11sFalsef.png index bdaeb17..422f56d 100644 --- a/data/CLs/plots/p3770_p/0.45Ctt11sFalsef.png +++ b/data/CLs/plots/p3770_p/0.45Ctt11sFalsef.png Binary files differ diff --git a/data/CLs/plots/p3770_p/0.49Ctt12sTruef.png b/data/CLs/plots/p3770_p/0.49Ctt12sTruef.png index fcd3251..8cde867 100644 --- a/data/CLs/plots/p3770_p/0.49Ctt12sTruef.png +++ b/data/CLs/plots/p3770_p/0.49Ctt12sTruef.png Binary files differ diff --git a/data/CLs/plots/p3770_p/0.49Ctt13sFalsef.png b/data/CLs/plots/p3770_p/0.49Ctt13sFalsef.png index a0ad197..cebec47 100644 --- a/data/CLs/plots/p3770_p/0.49Ctt13sFalsef.png +++ b/data/CLs/plots/p3770_p/0.49Ctt13sFalsef.png Binary files differ diff --git a/data/CLs/plots/p3770_p/0.53Ctt14sTruef.png b/data/CLs/plots/p3770_p/0.53Ctt14sTruef.png index 9fd5985..32dff88 100644 --- a/data/CLs/plots/p3770_p/0.53Ctt14sTruef.png +++ b/data/CLs/plots/p3770_p/0.53Ctt14sTruef.png Binary files differ diff --git a/data/CLs/plots/p3770_p/0.53Ctt15sFalsef.png b/data/CLs/plots/p3770_p/0.53Ctt15sFalsef.png index 3ff89b7..f4b27e4 100644 --- a/data/CLs/plots/p3770_p/0.53Ctt15sFalsef.png +++ b/data/CLs/plots/p3770_p/0.53Ctt15sFalsef.png Binary files differ diff --git a/data/CLs/plots/p3770_p/0.56Ctt16sTruef.png b/data/CLs/plots/p3770_p/0.56Ctt16sTruef.png index d7f014d..715c9bf 100644 --- a/data/CLs/plots/p3770_p/0.56Ctt16sTruef.png +++ b/data/CLs/plots/p3770_p/0.56Ctt16sTruef.png Binary files differ diff --git a/data/CLs/plots/p3770_p/0.56Ctt17sFalsef.png b/data/CLs/plots/p3770_p/0.56Ctt17sFalsef.png index b80c13f..bdb519b 100644 --- a/data/CLs/plots/p3770_p/0.56Ctt17sFalsef.png +++ b/data/CLs/plots/p3770_p/0.56Ctt17sFalsef.png Binary files differ diff --git a/data/CLs/plots/p3770_p/0.59Ctt18sTruef.png b/data/CLs/plots/p3770_p/0.59Ctt18sTruef.png index 33f2e92..bec52e9 100644 --- a/data/CLs/plots/p3770_p/0.59Ctt18sTruef.png +++ b/data/CLs/plots/p3770_p/0.59Ctt18sTruef.png Binary files differ diff --git a/data/CLs/plots/p3770_p/0.59Ctt19sFalsef.png b/data/CLs/plots/p3770_p/0.59Ctt19sFalsef.png index d4fb52d..eea7c29 100644 --- a/data/CLs/plots/p3770_p/0.59Ctt19sFalsef.png +++ b/data/CLs/plots/p3770_p/0.59Ctt19sFalsef.png Binary files differ diff --git a/data/CLs/plots/p3770_p/0.62Ctt20sTruef.png b/data/CLs/plots/p3770_p/0.62Ctt20sTruef.png index 338354f..c01ab91 100644 --- a/data/CLs/plots/p3770_p/0.62Ctt20sTruef.png +++ b/data/CLs/plots/p3770_p/0.62Ctt20sTruef.png Binary files differ diff --git a/data/CLs/plots/p3770_p/0.62Ctt21sFalsef.png b/data/CLs/plots/p3770_p/0.62Ctt21sFalsef.png index 1fc5aa3..d5be283 100644 --- a/data/CLs/plots/p3770_p/0.62Ctt21sFalsef.png +++ b/data/CLs/plots/p3770_p/0.62Ctt21sFalsef.png Binary files differ diff --git a/data/CLs/plots/p3770_p/0.65Ctt22sTruef.png b/data/CLs/plots/p3770_p/0.65Ctt22sTruef.png index 2650b02..4e0f1b4 100644 --- a/data/CLs/plots/p3770_p/0.65Ctt22sTruef.png +++ b/data/CLs/plots/p3770_p/0.65Ctt22sTruef.png Binary files differ diff --git a/data/CLs/plots/p3770_p/0.65Ctt23sFalsef.png b/data/CLs/plots/p3770_p/0.65Ctt23sFalsef.png index b9dec6f..7717354 100644 --- a/data/CLs/plots/p3770_p/0.65Ctt23sFalsef.png +++ b/data/CLs/plots/p3770_p/0.65Ctt23sFalsef.png Binary files differ diff --git a/data/CLs/plots/p3770_p/0.68Ctt24sTruef.png b/data/CLs/plots/p3770_p/0.68Ctt24sTruef.png index 374184b..9d2486d 100644 --- a/data/CLs/plots/p3770_p/0.68Ctt24sTruef.png +++ b/data/CLs/plots/p3770_p/0.68Ctt24sTruef.png Binary files differ diff --git a/data/CLs/plots/p3770_p/0.68Ctt25sFalsef.png b/data/CLs/plots/p3770_p/0.68Ctt25sFalsef.png index 3b3b825..c3aa928 100644 --- a/data/CLs/plots/p3770_p/0.68Ctt25sFalsef.png +++ b/data/CLs/plots/p3770_p/0.68Ctt25sFalsef.png Binary files differ diff --git a/data/CLs/plots/p3770_p/0.70Ctt26sTruef.png b/data/CLs/plots/p3770_p/0.70Ctt26sTruef.png index fc47f19..82a9803 100644 --- a/data/CLs/plots/p3770_p/0.70Ctt26sTruef.png +++ b/data/CLs/plots/p3770_p/0.70Ctt26sTruef.png Binary files differ diff --git a/data/CLs/plots/p3770_p/0.70Ctt27sFalsef.png b/data/CLs/plots/p3770_p/0.70Ctt27sFalsef.png index 7d7bd72..5f132c2 100644 --- a/data/CLs/plots/p3770_p/0.70Ctt27sFalsef.png +++ b/data/CLs/plots/p3770_p/0.70Ctt27sFalsef.png Binary files differ diff --git a/data/CLs/plots/p3770_p/0.73Ctt28sTruef.png b/data/CLs/plots/p3770_p/0.73Ctt28sTruef.png index c264894..4c5dd64 100644 --- a/data/CLs/plots/p3770_p/0.73Ctt28sTruef.png +++ b/data/CLs/plots/p3770_p/0.73Ctt28sTruef.png Binary files differ diff --git a/data/CLs/plots/p3770_p/0.73Ctt29sFalsef.png b/data/CLs/plots/p3770_p/0.73Ctt29sFalsef.png index 5a186b7..6f14d33 100644 --- a/data/CLs/plots/p3770_p/0.73Ctt29sFalsef.png +++ b/data/CLs/plots/p3770_p/0.73Ctt29sFalsef.png Binary files differ diff --git a/data/CLs/plots/p3770_p/0.75Ctt30sTruef.png b/data/CLs/plots/p3770_p/0.75Ctt30sTruef.png index 25fe292..ec3a0c4 100644 --- a/data/CLs/plots/p3770_p/0.75Ctt30sTruef.png +++ b/data/CLs/plots/p3770_p/0.75Ctt30sTruef.png Binary files differ diff --git a/data/CLs/plots/p3770_p/0.75Ctt31sFalsef.png b/data/CLs/plots/p3770_p/0.75Ctt31sFalsef.png index 8cfd96a..51c8da2 100644 --- a/data/CLs/plots/p3770_p/0.75Ctt31sFalsef.png +++ b/data/CLs/plots/p3770_p/0.75Ctt31sFalsef.png Binary files differ diff --git a/data/CLs/plots/p3770_p/0.78Ctt32sTruef.png b/data/CLs/plots/p3770_p/0.78Ctt32sTruef.png index 3f87861..0c69dd5 100644 --- a/data/CLs/plots/p3770_p/0.78Ctt32sTruef.png +++ b/data/CLs/plots/p3770_p/0.78Ctt32sTruef.png Binary files differ diff --git a/data/CLs/plots/p3770_p/0.78Ctt33sFalsef.png b/data/CLs/plots/p3770_p/0.78Ctt33sFalsef.png index 3877d8c..6402ef2 100644 --- a/data/CLs/plots/p3770_p/0.78Ctt33sFalsef.png +++ b/data/CLs/plots/p3770_p/0.78Ctt33sFalsef.png Binary files differ diff --git a/data/CLs/plots/p3770_p/0.80Ctt34sTruef.png b/data/CLs/plots/p3770_p/0.80Ctt34sTruef.png index 13a85fd..42065d9 100644 --- a/data/CLs/plots/p3770_p/0.80Ctt34sTruef.png +++ b/data/CLs/plots/p3770_p/0.80Ctt34sTruef.png Binary files differ diff --git a/data/CLs/plots/p3770_p/0.80Ctt35sFalsef.png b/data/CLs/plots/p3770_p/0.80Ctt35sFalsef.png index 5d98543..d4e21ad 100644 --- a/data/CLs/plots/p3770_p/0.80Ctt35sFalsef.png +++ b/data/CLs/plots/p3770_p/0.80Ctt35sFalsef.png Binary files differ diff --git a/data/CLs/plots/p3770_p/0.82Ctt36sTruef.png b/data/CLs/plots/p3770_p/0.82Ctt36sTruef.png index 65e302a..89421df 100644 --- a/data/CLs/plots/p3770_p/0.82Ctt36sTruef.png +++ b/data/CLs/plots/p3770_p/0.82Ctt36sTruef.png Binary files differ diff --git a/data/CLs/plots/p3770_p/0.82Ctt37sFalsef.png b/data/CLs/plots/p3770_p/0.82Ctt37sFalsef.png index befdede..93ff368 100644 --- a/data/CLs/plots/p3770_p/0.82Ctt37sFalsef.png +++ b/data/CLs/plots/p3770_p/0.82Ctt37sFalsef.png Binary files differ diff --git a/data/CLs/plots/p3770_p/0.85Ctt38sTruef.png b/data/CLs/plots/p3770_p/0.85Ctt38sTruef.png index 037519d..7abf07c 100644 --- a/data/CLs/plots/p3770_p/0.85Ctt38sTruef.png +++ b/data/CLs/plots/p3770_p/0.85Ctt38sTruef.png Binary files differ diff --git a/data/CLs/plots/p3770_p/0.85Ctt39sFalsef.png b/data/CLs/plots/p3770_p/0.85Ctt39sFalsef.png index a73517e..3bb8993 100644 --- a/data/CLs/plots/p3770_p/0.85Ctt39sFalsef.png +++ b/data/CLs/plots/p3770_p/0.85Ctt39sFalsef.png Binary files differ diff --git a/data/CLs/plots/p3770_s/0.00Ctt0sTruef.png b/data/CLs/plots/p3770_s/0.00Ctt0sTruef.png index 3c5e937..68b7614 100644 --- a/data/CLs/plots/p3770_s/0.00Ctt0sTruef.png +++ b/data/CLs/plots/p3770_s/0.00Ctt0sTruef.png Binary files differ diff --git a/data/CLs/plots/p3770_s/0.00Ctt1sFalsef.png b/data/CLs/plots/p3770_s/0.00Ctt1sFalsef.png index cdfbda3..ee662df 100644 --- a/data/CLs/plots/p3770_s/0.00Ctt1sFalsef.png +++ b/data/CLs/plots/p3770_s/0.00Ctt1sFalsef.png Binary files differ diff --git a/data/CLs/plots/p3770_s/0.25Ctt2sTruef.png b/data/CLs/plots/p3770_s/0.25Ctt2sTruef.png index fb0c091..a2b3547 100644 --- a/data/CLs/plots/p3770_s/0.25Ctt2sTruef.png +++ b/data/CLs/plots/p3770_s/0.25Ctt2sTruef.png Binary files differ diff --git a/data/CLs/plots/p3770_s/0.25Ctt3sFalsef.png b/data/CLs/plots/p3770_s/0.25Ctt3sFalsef.png index f7abafe..1a3b291 100644 --- a/data/CLs/plots/p3770_s/0.25Ctt3sFalsef.png +++ b/data/CLs/plots/p3770_s/0.25Ctt3sFalsef.png Binary files differ diff --git a/data/CLs/plots/p3770_s/0.31Ctt4sTruef.png b/data/CLs/plots/p3770_s/0.31Ctt4sTruef.png index 214f0d3..cca9398 100644 --- a/data/CLs/plots/p3770_s/0.31Ctt4sTruef.png +++ b/data/CLs/plots/p3770_s/0.31Ctt4sTruef.png Binary files differ diff --git a/data/CLs/plots/p3770_s/0.31Ctt5sFalsef.png b/data/CLs/plots/p3770_s/0.31Ctt5sFalsef.png index 7719af2..fb43725 100644 --- a/data/CLs/plots/p3770_s/0.31Ctt5sFalsef.png +++ b/data/CLs/plots/p3770_s/0.31Ctt5sFalsef.png Binary files differ diff --git a/data/CLs/plots/p3770_s/0.36Ctt6sTruef.png b/data/CLs/plots/p3770_s/0.36Ctt6sTruef.png index 061cb4c..c37b1d0 100644 --- a/data/CLs/plots/p3770_s/0.36Ctt6sTruef.png +++ b/data/CLs/plots/p3770_s/0.36Ctt6sTruef.png Binary files differ diff --git a/data/CLs/plots/p3770_s/0.36Ctt7sFalsef.png b/data/CLs/plots/p3770_s/0.36Ctt7sFalsef.png index fb5651f..46b37d0 100644 --- a/data/CLs/plots/p3770_s/0.36Ctt7sFalsef.png +++ b/data/CLs/plots/p3770_s/0.36Ctt7sFalsef.png Binary files differ diff --git a/data/CLs/plots/p3770_s/0.41Ctt8sTruef.png b/data/CLs/plots/p3770_s/0.41Ctt8sTruef.png index 1c783e3..9967d20 100644 --- a/data/CLs/plots/p3770_s/0.41Ctt8sTruef.png +++ b/data/CLs/plots/p3770_s/0.41Ctt8sTruef.png Binary files differ diff --git a/data/CLs/plots/p3770_s/0.41Ctt9sFalsef.png b/data/CLs/plots/p3770_s/0.41Ctt9sFalsef.png index 88de499..74994b2 100644 --- a/data/CLs/plots/p3770_s/0.41Ctt9sFalsef.png +++ b/data/CLs/plots/p3770_s/0.41Ctt9sFalsef.png Binary files differ diff --git a/data/CLs/plots/p3770_s/0.45Ctt10sTruef.png b/data/CLs/plots/p3770_s/0.45Ctt10sTruef.png index 065c7b1..fb62c23 100644 --- a/data/CLs/plots/p3770_s/0.45Ctt10sTruef.png +++ b/data/CLs/plots/p3770_s/0.45Ctt10sTruef.png Binary files differ diff --git a/data/CLs/plots/p3770_s/0.45Ctt11sFalsef.png b/data/CLs/plots/p3770_s/0.45Ctt11sFalsef.png index 5dfa248..e290a31 100644 --- a/data/CLs/plots/p3770_s/0.45Ctt11sFalsef.png +++ b/data/CLs/plots/p3770_s/0.45Ctt11sFalsef.png Binary files differ diff --git a/data/CLs/plots/p3770_s/0.49Ctt12sTruef.png b/data/CLs/plots/p3770_s/0.49Ctt12sTruef.png index b7e675c..8c47167 100644 --- a/data/CLs/plots/p3770_s/0.49Ctt12sTruef.png +++ b/data/CLs/plots/p3770_s/0.49Ctt12sTruef.png Binary files differ diff --git a/data/CLs/plots/p3770_s/0.49Ctt13sFalsef.png b/data/CLs/plots/p3770_s/0.49Ctt13sFalsef.png index d0e1ab6..70404a4 100644 --- a/data/CLs/plots/p3770_s/0.49Ctt13sFalsef.png +++ b/data/CLs/plots/p3770_s/0.49Ctt13sFalsef.png Binary files differ diff --git a/data/CLs/plots/p3770_s/0.53Ctt14sTruef.png b/data/CLs/plots/p3770_s/0.53Ctt14sTruef.png index 60e0826..10736ba 100644 --- a/data/CLs/plots/p3770_s/0.53Ctt14sTruef.png +++ b/data/CLs/plots/p3770_s/0.53Ctt14sTruef.png Binary files differ diff --git a/data/CLs/plots/p3770_s/0.53Ctt15sFalsef.png b/data/CLs/plots/p3770_s/0.53Ctt15sFalsef.png index b46f562..39f7e52 100644 --- a/data/CLs/plots/p3770_s/0.53Ctt15sFalsef.png +++ b/data/CLs/plots/p3770_s/0.53Ctt15sFalsef.png Binary files differ diff --git a/data/CLs/plots/p3770_s/0.56Ctt16sTruef.png b/data/CLs/plots/p3770_s/0.56Ctt16sTruef.png index 07cc47f..b34ba03 100644 --- a/data/CLs/plots/p3770_s/0.56Ctt16sTruef.png +++ b/data/CLs/plots/p3770_s/0.56Ctt16sTruef.png Binary files differ diff --git a/data/CLs/plots/p3770_s/0.56Ctt17sFalsef.png b/data/CLs/plots/p3770_s/0.56Ctt17sFalsef.png index 0b75671..14b6008 100644 --- a/data/CLs/plots/p3770_s/0.56Ctt17sFalsef.png +++ b/data/CLs/plots/p3770_s/0.56Ctt17sFalsef.png Binary files differ diff --git a/data/CLs/plots/p3770_s/0.59Ctt18sTruef.png b/data/CLs/plots/p3770_s/0.59Ctt18sTruef.png index 0868968..bd665f0 100644 --- a/data/CLs/plots/p3770_s/0.59Ctt18sTruef.png +++ b/data/CLs/plots/p3770_s/0.59Ctt18sTruef.png Binary files differ diff --git a/data/CLs/plots/p3770_s/0.59Ctt19sFalsef.png b/data/CLs/plots/p3770_s/0.59Ctt19sFalsef.png index 8a5fe16..c4083bb 100644 --- a/data/CLs/plots/p3770_s/0.59Ctt19sFalsef.png +++ b/data/CLs/plots/p3770_s/0.59Ctt19sFalsef.png Binary files differ diff --git a/data/CLs/plots/p3770_s/0.62Ctt20sTruef.png b/data/CLs/plots/p3770_s/0.62Ctt20sTruef.png index d982a67..bb7caaa 100644 --- a/data/CLs/plots/p3770_s/0.62Ctt20sTruef.png +++ b/data/CLs/plots/p3770_s/0.62Ctt20sTruef.png Binary files differ diff --git a/data/CLs/plots/p3770_s/0.62Ctt21sFalsef.png b/data/CLs/plots/p3770_s/0.62Ctt21sFalsef.png index 4b062de..20571e5 100644 --- a/data/CLs/plots/p3770_s/0.62Ctt21sFalsef.png +++ b/data/CLs/plots/p3770_s/0.62Ctt21sFalsef.png Binary files differ diff --git a/data/CLs/plots/p3770_s/0.65Ctt22sTruef.png b/data/CLs/plots/p3770_s/0.65Ctt22sTruef.png index 98fd2c7..5b23587 100644 --- a/data/CLs/plots/p3770_s/0.65Ctt22sTruef.png +++ b/data/CLs/plots/p3770_s/0.65Ctt22sTruef.png Binary files differ diff --git a/data/CLs/plots/p3770_s/0.65Ctt23sFalsef.png b/data/CLs/plots/p3770_s/0.65Ctt23sFalsef.png index 58f01a1..1fdcd91 100644 --- a/data/CLs/plots/p3770_s/0.65Ctt23sFalsef.png +++ b/data/CLs/plots/p3770_s/0.65Ctt23sFalsef.png Binary files differ diff --git a/data/CLs/plots/p3770_s/0.68Ctt24sTruef.png b/data/CLs/plots/p3770_s/0.68Ctt24sTruef.png index e1ba956..f0334b7 100644 --- a/data/CLs/plots/p3770_s/0.68Ctt24sTruef.png +++ b/data/CLs/plots/p3770_s/0.68Ctt24sTruef.png Binary files differ diff --git a/data/CLs/plots/p3770_s/0.68Ctt25sFalsef.png b/data/CLs/plots/p3770_s/0.68Ctt25sFalsef.png index 769d47d..e29c9cf 100644 --- a/data/CLs/plots/p3770_s/0.68Ctt25sFalsef.png +++ b/data/CLs/plots/p3770_s/0.68Ctt25sFalsef.png Binary files differ diff --git a/data/CLs/plots/p3770_s/0.70Ctt26sTruef.png b/data/CLs/plots/p3770_s/0.70Ctt26sTruef.png index 3d0361c..483ea00 100644 --- a/data/CLs/plots/p3770_s/0.70Ctt26sTruef.png +++ b/data/CLs/plots/p3770_s/0.70Ctt26sTruef.png Binary files differ diff --git a/data/CLs/plots/p3770_s/0.70Ctt27sFalsef.png b/data/CLs/plots/p3770_s/0.70Ctt27sFalsef.png index 9cae222..1a55d1f 100644 --- a/data/CLs/plots/p3770_s/0.70Ctt27sFalsef.png +++ b/data/CLs/plots/p3770_s/0.70Ctt27sFalsef.png Binary files differ diff --git a/data/CLs/plots/p3770_s/0.73Ctt28sTruef.png b/data/CLs/plots/p3770_s/0.73Ctt28sTruef.png index 7f34b9f..a1a903d 100644 --- a/data/CLs/plots/p3770_s/0.73Ctt28sTruef.png +++ b/data/CLs/plots/p3770_s/0.73Ctt28sTruef.png Binary files differ diff --git a/data/CLs/plots/p3770_s/0.73Ctt29sFalsef.png b/data/CLs/plots/p3770_s/0.73Ctt29sFalsef.png index 60da1ce..a4e1616 100644 --- a/data/CLs/plots/p3770_s/0.73Ctt29sFalsef.png +++ b/data/CLs/plots/p3770_s/0.73Ctt29sFalsef.png Binary files differ diff --git a/data/CLs/plots/p3770_s/0.75Ctt30sTruef.png b/data/CLs/plots/p3770_s/0.75Ctt30sTruef.png index ae97b6d..8da9fbe 100644 --- a/data/CLs/plots/p3770_s/0.75Ctt30sTruef.png +++ b/data/CLs/plots/p3770_s/0.75Ctt30sTruef.png Binary files differ diff --git a/data/CLs/plots/p3770_s/0.75Ctt31sFalsef.png b/data/CLs/plots/p3770_s/0.75Ctt31sFalsef.png index 5a5cdbf..7c6f793 100644 --- a/data/CLs/plots/p3770_s/0.75Ctt31sFalsef.png +++ b/data/CLs/plots/p3770_s/0.75Ctt31sFalsef.png Binary files differ diff --git a/data/CLs/plots/p3770_s/0.78Ctt32sTruef.png b/data/CLs/plots/p3770_s/0.78Ctt32sTruef.png index c7151d2..7f7334b 100644 --- a/data/CLs/plots/p3770_s/0.78Ctt32sTruef.png +++ b/data/CLs/plots/p3770_s/0.78Ctt32sTruef.png Binary files differ diff --git a/data/CLs/plots/p3770_s/0.78Ctt33sFalsef.png b/data/CLs/plots/p3770_s/0.78Ctt33sFalsef.png index bc951aa..855c1e7 100644 --- a/data/CLs/plots/p3770_s/0.78Ctt33sFalsef.png +++ b/data/CLs/plots/p3770_s/0.78Ctt33sFalsef.png Binary files differ diff --git a/data/CLs/plots/p3770_s/0.80Ctt34sTruef.png b/data/CLs/plots/p3770_s/0.80Ctt34sTruef.png index d6cd9d5..ac78533 100644 --- a/data/CLs/plots/p3770_s/0.80Ctt34sTruef.png +++ b/data/CLs/plots/p3770_s/0.80Ctt34sTruef.png Binary files differ diff --git a/data/CLs/plots/p3770_s/0.80Ctt35sFalsef.png b/data/CLs/plots/p3770_s/0.80Ctt35sFalsef.png index b599410..2b41de9 100644 --- a/data/CLs/plots/p3770_s/0.80Ctt35sFalsef.png +++ b/data/CLs/plots/p3770_s/0.80Ctt35sFalsef.png Binary files differ diff --git a/data/CLs/plots/p3770_s/0.82Ctt36sTruef.png b/data/CLs/plots/p3770_s/0.82Ctt36sTruef.png index f08b877..54c75f5 100644 --- a/data/CLs/plots/p3770_s/0.82Ctt36sTruef.png +++ b/data/CLs/plots/p3770_s/0.82Ctt36sTruef.png Binary files differ diff --git a/data/CLs/plots/p3770_s/0.82Ctt37sFalsef.png b/data/CLs/plots/p3770_s/0.82Ctt37sFalsef.png index e2c0dae..487745a 100644 --- a/data/CLs/plots/p3770_s/0.82Ctt37sFalsef.png +++ b/data/CLs/plots/p3770_s/0.82Ctt37sFalsef.png Binary files differ diff --git a/data/CLs/plots/p3770_s/0.85Ctt38sTruef.png b/data/CLs/plots/p3770_s/0.85Ctt38sTruef.png index 4384c8f..789b83d 100644 --- a/data/CLs/plots/p3770_s/0.85Ctt38sTruef.png +++ b/data/CLs/plots/p3770_s/0.85Ctt38sTruef.png Binary files differ diff --git a/data/CLs/plots/p3770_s/0.85Ctt39sFalsef.png b/data/CLs/plots/p3770_s/0.85Ctt39sFalsef.png index 6ba8fed..e6cbbbb 100644 --- a/data/CLs/plots/p3770_s/0.85Ctt39sFalsef.png +++ b/data/CLs/plots/p3770_s/0.85Ctt39sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4040_p/0.00Ctt0sTruef.png b/data/CLs/plots/p4040_p/0.00Ctt0sTruef.png index cadc2f8..7fd8acb 100644 --- a/data/CLs/plots/p4040_p/0.00Ctt0sTruef.png +++ b/data/CLs/plots/p4040_p/0.00Ctt0sTruef.png Binary files differ diff --git a/data/CLs/plots/p4040_p/0.00Ctt1sFalsef.png b/data/CLs/plots/p4040_p/0.00Ctt1sFalsef.png index 03ad1d6..1b1872d 100644 --- a/data/CLs/plots/p4040_p/0.00Ctt1sFalsef.png +++ b/data/CLs/plots/p4040_p/0.00Ctt1sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4040_p/0.25Ctt2sTruef.png b/data/CLs/plots/p4040_p/0.25Ctt2sTruef.png index be51f9d..f105199 100644 --- a/data/CLs/plots/p4040_p/0.25Ctt2sTruef.png +++ b/data/CLs/plots/p4040_p/0.25Ctt2sTruef.png Binary files differ diff --git a/data/CLs/plots/p4040_p/0.25Ctt3sFalsef.png b/data/CLs/plots/p4040_p/0.25Ctt3sFalsef.png index 4a55030..c7a5e0a 100644 --- a/data/CLs/plots/p4040_p/0.25Ctt3sFalsef.png +++ b/data/CLs/plots/p4040_p/0.25Ctt3sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4040_p/0.31Ctt4sTruef.png b/data/CLs/plots/p4040_p/0.31Ctt4sTruef.png index 4f504be..ec1ff13 100644 --- a/data/CLs/plots/p4040_p/0.31Ctt4sTruef.png +++ b/data/CLs/plots/p4040_p/0.31Ctt4sTruef.png Binary files differ diff --git a/data/CLs/plots/p4040_p/0.31Ctt5sFalsef.png b/data/CLs/plots/p4040_p/0.31Ctt5sFalsef.png index e1fd80f..9f20461 100644 --- a/data/CLs/plots/p4040_p/0.31Ctt5sFalsef.png +++ b/data/CLs/plots/p4040_p/0.31Ctt5sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4040_p/0.36Ctt6sTruef.png b/data/CLs/plots/p4040_p/0.36Ctt6sTruef.png index adab823..3ba3a05 100644 --- a/data/CLs/plots/p4040_p/0.36Ctt6sTruef.png +++ b/data/CLs/plots/p4040_p/0.36Ctt6sTruef.png Binary files differ diff --git a/data/CLs/plots/p4040_p/0.36Ctt7sFalsef.png b/data/CLs/plots/p4040_p/0.36Ctt7sFalsef.png index c537753..dfb1e18 100644 --- a/data/CLs/plots/p4040_p/0.36Ctt7sFalsef.png +++ b/data/CLs/plots/p4040_p/0.36Ctt7sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4040_p/0.41Ctt8sTruef.png b/data/CLs/plots/p4040_p/0.41Ctt8sTruef.png index 1429301..f2dc855 100644 --- a/data/CLs/plots/p4040_p/0.41Ctt8sTruef.png +++ b/data/CLs/plots/p4040_p/0.41Ctt8sTruef.png Binary files differ diff --git a/data/CLs/plots/p4040_p/0.41Ctt9sFalsef.png b/data/CLs/plots/p4040_p/0.41Ctt9sFalsef.png index 7f1f52b..880f46d 100644 --- a/data/CLs/plots/p4040_p/0.41Ctt9sFalsef.png +++ b/data/CLs/plots/p4040_p/0.41Ctt9sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4040_p/0.45Ctt10sTruef.png b/data/CLs/plots/p4040_p/0.45Ctt10sTruef.png index 14d59f8..9935b57 100644 --- a/data/CLs/plots/p4040_p/0.45Ctt10sTruef.png +++ b/data/CLs/plots/p4040_p/0.45Ctt10sTruef.png Binary files differ diff --git a/data/CLs/plots/p4040_p/0.45Ctt11sFalsef.png b/data/CLs/plots/p4040_p/0.45Ctt11sFalsef.png index 2a30566..efd0fcc 100644 --- a/data/CLs/plots/p4040_p/0.45Ctt11sFalsef.png +++ b/data/CLs/plots/p4040_p/0.45Ctt11sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4040_p/0.49Ctt12sTruef.png b/data/CLs/plots/p4040_p/0.49Ctt12sTruef.png index 92aaf0d..fdc3b4e 100644 --- a/data/CLs/plots/p4040_p/0.49Ctt12sTruef.png +++ b/data/CLs/plots/p4040_p/0.49Ctt12sTruef.png Binary files differ diff --git a/data/CLs/plots/p4040_p/0.49Ctt13sFalsef.png b/data/CLs/plots/p4040_p/0.49Ctt13sFalsef.png index 6cd5a2e..8948c3b 100644 --- a/data/CLs/plots/p4040_p/0.49Ctt13sFalsef.png +++ b/data/CLs/plots/p4040_p/0.49Ctt13sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4040_p/0.53Ctt14sTruef.png b/data/CLs/plots/p4040_p/0.53Ctt14sTruef.png index 258a665..df7f470 100644 --- a/data/CLs/plots/p4040_p/0.53Ctt14sTruef.png +++ b/data/CLs/plots/p4040_p/0.53Ctt14sTruef.png Binary files differ diff --git a/data/CLs/plots/p4040_p/0.53Ctt15sFalsef.png b/data/CLs/plots/p4040_p/0.53Ctt15sFalsef.png index 69af715..c3cbd43 100644 --- a/data/CLs/plots/p4040_p/0.53Ctt15sFalsef.png +++ b/data/CLs/plots/p4040_p/0.53Ctt15sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4040_p/0.56Ctt16sTruef.png b/data/CLs/plots/p4040_p/0.56Ctt16sTruef.png index c4613eb..fedffa9 100644 --- a/data/CLs/plots/p4040_p/0.56Ctt16sTruef.png +++ b/data/CLs/plots/p4040_p/0.56Ctt16sTruef.png Binary files differ diff --git a/data/CLs/plots/p4040_p/0.56Ctt17sFalsef.png b/data/CLs/plots/p4040_p/0.56Ctt17sFalsef.png index 3acf667..ee687b6 100644 --- a/data/CLs/plots/p4040_p/0.56Ctt17sFalsef.png +++ b/data/CLs/plots/p4040_p/0.56Ctt17sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4040_p/0.59Ctt18sTruef.png b/data/CLs/plots/p4040_p/0.59Ctt18sTruef.png index 6c6d101..e9a1d4e 100644 --- a/data/CLs/plots/p4040_p/0.59Ctt18sTruef.png +++ b/data/CLs/plots/p4040_p/0.59Ctt18sTruef.png Binary files differ diff --git a/data/CLs/plots/p4040_p/0.59Ctt19sFalsef.png b/data/CLs/plots/p4040_p/0.59Ctt19sFalsef.png index ce5f93a..18dacb9 100644 --- a/data/CLs/plots/p4040_p/0.59Ctt19sFalsef.png +++ b/data/CLs/plots/p4040_p/0.59Ctt19sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4040_p/0.62Ctt20sTruef.png b/data/CLs/plots/p4040_p/0.62Ctt20sTruef.png index 1092b8f..f94eeaa 100644 --- a/data/CLs/plots/p4040_p/0.62Ctt20sTruef.png +++ b/data/CLs/plots/p4040_p/0.62Ctt20sTruef.png Binary files differ diff --git a/data/CLs/plots/p4040_p/0.62Ctt21sFalsef.png b/data/CLs/plots/p4040_p/0.62Ctt21sFalsef.png index c0ca318..05b4d4b 100644 --- a/data/CLs/plots/p4040_p/0.62Ctt21sFalsef.png +++ b/data/CLs/plots/p4040_p/0.62Ctt21sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4040_p/0.65Ctt22sTruef.png b/data/CLs/plots/p4040_p/0.65Ctt22sTruef.png index e95572b..0a560c5 100644 --- a/data/CLs/plots/p4040_p/0.65Ctt22sTruef.png +++ b/data/CLs/plots/p4040_p/0.65Ctt22sTruef.png Binary files differ diff --git a/data/CLs/plots/p4040_p/0.65Ctt23sFalsef.png b/data/CLs/plots/p4040_p/0.65Ctt23sFalsef.png index 2e53675..7bfea0c 100644 --- a/data/CLs/plots/p4040_p/0.65Ctt23sFalsef.png +++ b/data/CLs/plots/p4040_p/0.65Ctt23sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4040_p/0.68Ctt24sTruef.png b/data/CLs/plots/p4040_p/0.68Ctt24sTruef.png index 37cb50b..efdd00a 100644 --- a/data/CLs/plots/p4040_p/0.68Ctt24sTruef.png +++ b/data/CLs/plots/p4040_p/0.68Ctt24sTruef.png Binary files differ diff --git a/data/CLs/plots/p4040_p/0.68Ctt25sFalsef.png b/data/CLs/plots/p4040_p/0.68Ctt25sFalsef.png index 6375d1c..2c64063 100644 --- a/data/CLs/plots/p4040_p/0.68Ctt25sFalsef.png +++ b/data/CLs/plots/p4040_p/0.68Ctt25sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4040_p/0.70Ctt26sTruef.png b/data/CLs/plots/p4040_p/0.70Ctt26sTruef.png index 2747dcf..f72c9db 100644 --- a/data/CLs/plots/p4040_p/0.70Ctt26sTruef.png +++ b/data/CLs/plots/p4040_p/0.70Ctt26sTruef.png Binary files differ diff --git a/data/CLs/plots/p4040_p/0.70Ctt27sFalsef.png b/data/CLs/plots/p4040_p/0.70Ctt27sFalsef.png index f1de96b..ab69f5a 100644 --- a/data/CLs/plots/p4040_p/0.70Ctt27sFalsef.png +++ b/data/CLs/plots/p4040_p/0.70Ctt27sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4040_p/0.73Ctt28sTruef.png b/data/CLs/plots/p4040_p/0.73Ctt28sTruef.png index 2db473c..873ea1a 100644 --- a/data/CLs/plots/p4040_p/0.73Ctt28sTruef.png +++ b/data/CLs/plots/p4040_p/0.73Ctt28sTruef.png Binary files differ diff --git a/data/CLs/plots/p4040_p/0.73Ctt29sFalsef.png b/data/CLs/plots/p4040_p/0.73Ctt29sFalsef.png index 3ee7b97..c99e968 100644 --- a/data/CLs/plots/p4040_p/0.73Ctt29sFalsef.png +++ b/data/CLs/plots/p4040_p/0.73Ctt29sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4040_p/0.75Ctt30sTruef.png b/data/CLs/plots/p4040_p/0.75Ctt30sTruef.png index 759ae45..68ba9c2 100644 --- a/data/CLs/plots/p4040_p/0.75Ctt30sTruef.png +++ b/data/CLs/plots/p4040_p/0.75Ctt30sTruef.png Binary files differ diff --git a/data/CLs/plots/p4040_p/0.75Ctt31sFalsef.png b/data/CLs/plots/p4040_p/0.75Ctt31sFalsef.png index d97f9e2..4f77b27 100644 --- a/data/CLs/plots/p4040_p/0.75Ctt31sFalsef.png +++ b/data/CLs/plots/p4040_p/0.75Ctt31sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4040_p/0.78Ctt32sTruef.png b/data/CLs/plots/p4040_p/0.78Ctt32sTruef.png index 9148150..7b2a6d8 100644 --- a/data/CLs/plots/p4040_p/0.78Ctt32sTruef.png +++ b/data/CLs/plots/p4040_p/0.78Ctt32sTruef.png Binary files differ diff --git a/data/CLs/plots/p4040_p/0.78Ctt33sFalsef.png b/data/CLs/plots/p4040_p/0.78Ctt33sFalsef.png index fce9490..e6fa05e 100644 --- a/data/CLs/plots/p4040_p/0.78Ctt33sFalsef.png +++ b/data/CLs/plots/p4040_p/0.78Ctt33sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4040_p/0.80Ctt34sTruef.png b/data/CLs/plots/p4040_p/0.80Ctt34sTruef.png index b44bd1f..86df7f4 100644 --- a/data/CLs/plots/p4040_p/0.80Ctt34sTruef.png +++ b/data/CLs/plots/p4040_p/0.80Ctt34sTruef.png Binary files differ diff --git a/data/CLs/plots/p4040_p/0.80Ctt35sFalsef.png b/data/CLs/plots/p4040_p/0.80Ctt35sFalsef.png index 261ab63..ae04d08 100644 --- a/data/CLs/plots/p4040_p/0.80Ctt35sFalsef.png +++ b/data/CLs/plots/p4040_p/0.80Ctt35sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4040_p/0.82Ctt36sTruef.png b/data/CLs/plots/p4040_p/0.82Ctt36sTruef.png index b942b79..b960ff5 100644 --- a/data/CLs/plots/p4040_p/0.82Ctt36sTruef.png +++ b/data/CLs/plots/p4040_p/0.82Ctt36sTruef.png Binary files differ diff --git a/data/CLs/plots/p4040_p/0.82Ctt37sFalsef.png b/data/CLs/plots/p4040_p/0.82Ctt37sFalsef.png index a1c7c15..8b02ef8 100644 --- a/data/CLs/plots/p4040_p/0.82Ctt37sFalsef.png +++ b/data/CLs/plots/p4040_p/0.82Ctt37sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4040_p/0.85Ctt38sTruef.png b/data/CLs/plots/p4040_p/0.85Ctt38sTruef.png index cb9721a..1af1168 100644 --- a/data/CLs/plots/p4040_p/0.85Ctt38sTruef.png +++ b/data/CLs/plots/p4040_p/0.85Ctt38sTruef.png Binary files differ diff --git a/data/CLs/plots/p4040_p/0.85Ctt39sFalsef.png b/data/CLs/plots/p4040_p/0.85Ctt39sFalsef.png index de09e8a..da65a68 100644 --- a/data/CLs/plots/p4040_p/0.85Ctt39sFalsef.png +++ b/data/CLs/plots/p4040_p/0.85Ctt39sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4040_s/0.00Ctt0sTruef.png b/data/CLs/plots/p4040_s/0.00Ctt0sTruef.png index 3fd39fe..2d84401 100644 --- a/data/CLs/plots/p4040_s/0.00Ctt0sTruef.png +++ b/data/CLs/plots/p4040_s/0.00Ctt0sTruef.png Binary files differ diff --git a/data/CLs/plots/p4040_s/0.00Ctt1sFalsef.png b/data/CLs/plots/p4040_s/0.00Ctt1sFalsef.png index cb113a8..a185680 100644 --- a/data/CLs/plots/p4040_s/0.00Ctt1sFalsef.png +++ b/data/CLs/plots/p4040_s/0.00Ctt1sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4040_s/0.25Ctt2sTruef.png b/data/CLs/plots/p4040_s/0.25Ctt2sTruef.png index 6ae5dfa..046a03a 100644 --- a/data/CLs/plots/p4040_s/0.25Ctt2sTruef.png +++ b/data/CLs/plots/p4040_s/0.25Ctt2sTruef.png Binary files differ diff --git a/data/CLs/plots/p4040_s/0.25Ctt3sFalsef.png b/data/CLs/plots/p4040_s/0.25Ctt3sFalsef.png index f58be77..d3cb52b 100644 --- a/data/CLs/plots/p4040_s/0.25Ctt3sFalsef.png +++ b/data/CLs/plots/p4040_s/0.25Ctt3sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4040_s/0.31Ctt4sTruef.png b/data/CLs/plots/p4040_s/0.31Ctt4sTruef.png index 1679534..c17fda5 100644 --- a/data/CLs/plots/p4040_s/0.31Ctt4sTruef.png +++ b/data/CLs/plots/p4040_s/0.31Ctt4sTruef.png Binary files differ diff --git a/data/CLs/plots/p4040_s/0.31Ctt5sFalsef.png b/data/CLs/plots/p4040_s/0.31Ctt5sFalsef.png index e494d5b..e377d33 100644 --- a/data/CLs/plots/p4040_s/0.31Ctt5sFalsef.png +++ b/data/CLs/plots/p4040_s/0.31Ctt5sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4040_s/0.36Ctt6sTruef.png b/data/CLs/plots/p4040_s/0.36Ctt6sTruef.png index 44d3129..fbe9034 100644 --- a/data/CLs/plots/p4040_s/0.36Ctt6sTruef.png +++ b/data/CLs/plots/p4040_s/0.36Ctt6sTruef.png Binary files differ diff --git a/data/CLs/plots/p4040_s/0.36Ctt7sFalsef.png b/data/CLs/plots/p4040_s/0.36Ctt7sFalsef.png index bf3e031..d0c7983 100644 --- a/data/CLs/plots/p4040_s/0.36Ctt7sFalsef.png +++ b/data/CLs/plots/p4040_s/0.36Ctt7sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4040_s/0.41Ctt8sTruef.png b/data/CLs/plots/p4040_s/0.41Ctt8sTruef.png index ee0f01a..ed3c143 100644 --- a/data/CLs/plots/p4040_s/0.41Ctt8sTruef.png +++ b/data/CLs/plots/p4040_s/0.41Ctt8sTruef.png Binary files differ diff --git a/data/CLs/plots/p4040_s/0.41Ctt9sFalsef.png b/data/CLs/plots/p4040_s/0.41Ctt9sFalsef.png index a327f1c..7680d9b 100644 --- a/data/CLs/plots/p4040_s/0.41Ctt9sFalsef.png +++ b/data/CLs/plots/p4040_s/0.41Ctt9sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4040_s/0.45Ctt10sTruef.png b/data/CLs/plots/p4040_s/0.45Ctt10sTruef.png index e67cd4a..6cee461 100644 --- a/data/CLs/plots/p4040_s/0.45Ctt10sTruef.png +++ b/data/CLs/plots/p4040_s/0.45Ctt10sTruef.png Binary files differ diff --git a/data/CLs/plots/p4040_s/0.45Ctt11sFalsef.png b/data/CLs/plots/p4040_s/0.45Ctt11sFalsef.png index 06be107..ccc324e 100644 --- a/data/CLs/plots/p4040_s/0.45Ctt11sFalsef.png +++ b/data/CLs/plots/p4040_s/0.45Ctt11sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4040_s/0.49Ctt12sTruef.png b/data/CLs/plots/p4040_s/0.49Ctt12sTruef.png index 9b7db9d..01033d3 100644 --- a/data/CLs/plots/p4040_s/0.49Ctt12sTruef.png +++ b/data/CLs/plots/p4040_s/0.49Ctt12sTruef.png Binary files differ diff --git a/data/CLs/plots/p4040_s/0.49Ctt13sFalsef.png b/data/CLs/plots/p4040_s/0.49Ctt13sFalsef.png index b0b63fd..a137fd9 100644 --- a/data/CLs/plots/p4040_s/0.49Ctt13sFalsef.png +++ b/data/CLs/plots/p4040_s/0.49Ctt13sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4040_s/0.53Ctt14sTruef.png b/data/CLs/plots/p4040_s/0.53Ctt14sTruef.png index f88c0de..94a3f7b 100644 --- a/data/CLs/plots/p4040_s/0.53Ctt14sTruef.png +++ b/data/CLs/plots/p4040_s/0.53Ctt14sTruef.png Binary files differ diff --git a/data/CLs/plots/p4040_s/0.53Ctt15sFalsef.png b/data/CLs/plots/p4040_s/0.53Ctt15sFalsef.png index ebacbed..04a0479 100644 --- a/data/CLs/plots/p4040_s/0.53Ctt15sFalsef.png +++ b/data/CLs/plots/p4040_s/0.53Ctt15sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4040_s/0.56Ctt16sTruef.png b/data/CLs/plots/p4040_s/0.56Ctt16sTruef.png index d68af9d..d73fbbf 100644 --- a/data/CLs/plots/p4040_s/0.56Ctt16sTruef.png +++ b/data/CLs/plots/p4040_s/0.56Ctt16sTruef.png Binary files differ diff --git a/data/CLs/plots/p4040_s/0.56Ctt17sFalsef.png b/data/CLs/plots/p4040_s/0.56Ctt17sFalsef.png index 33b0006..21e42b5 100644 --- a/data/CLs/plots/p4040_s/0.56Ctt17sFalsef.png +++ b/data/CLs/plots/p4040_s/0.56Ctt17sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4040_s/0.59Ctt18sTruef.png b/data/CLs/plots/p4040_s/0.59Ctt18sTruef.png index 7f6cdd8..230b20f 100644 --- a/data/CLs/plots/p4040_s/0.59Ctt18sTruef.png +++ b/data/CLs/plots/p4040_s/0.59Ctt18sTruef.png Binary files differ diff --git a/data/CLs/plots/p4040_s/0.59Ctt19sFalsef.png b/data/CLs/plots/p4040_s/0.59Ctt19sFalsef.png index 9552fa5..962be24 100644 --- a/data/CLs/plots/p4040_s/0.59Ctt19sFalsef.png +++ b/data/CLs/plots/p4040_s/0.59Ctt19sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4040_s/0.62Ctt20sTruef.png b/data/CLs/plots/p4040_s/0.62Ctt20sTruef.png index b45be66..cdbdc9a 100644 --- a/data/CLs/plots/p4040_s/0.62Ctt20sTruef.png +++ b/data/CLs/plots/p4040_s/0.62Ctt20sTruef.png Binary files differ diff --git a/data/CLs/plots/p4040_s/0.62Ctt21sFalsef.png b/data/CLs/plots/p4040_s/0.62Ctt21sFalsef.png index c994c1d..7ddc6ba 100644 --- a/data/CLs/plots/p4040_s/0.62Ctt21sFalsef.png +++ b/data/CLs/plots/p4040_s/0.62Ctt21sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4040_s/0.65Ctt22sTruef.png b/data/CLs/plots/p4040_s/0.65Ctt22sTruef.png index ff9f585..e470bd9 100644 --- a/data/CLs/plots/p4040_s/0.65Ctt22sTruef.png +++ b/data/CLs/plots/p4040_s/0.65Ctt22sTruef.png Binary files differ diff --git a/data/CLs/plots/p4040_s/0.65Ctt23sFalsef.png b/data/CLs/plots/p4040_s/0.65Ctt23sFalsef.png index 03d6941..8202e3b 100644 --- a/data/CLs/plots/p4040_s/0.65Ctt23sFalsef.png +++ b/data/CLs/plots/p4040_s/0.65Ctt23sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4040_s/0.68Ctt24sTruef.png b/data/CLs/plots/p4040_s/0.68Ctt24sTruef.png index 827f9fe..9340b8d 100644 --- a/data/CLs/plots/p4040_s/0.68Ctt24sTruef.png +++ b/data/CLs/plots/p4040_s/0.68Ctt24sTruef.png Binary files differ diff --git a/data/CLs/plots/p4040_s/0.68Ctt25sFalsef.png b/data/CLs/plots/p4040_s/0.68Ctt25sFalsef.png index ab769c9..a8775d2 100644 --- a/data/CLs/plots/p4040_s/0.68Ctt25sFalsef.png +++ b/data/CLs/plots/p4040_s/0.68Ctt25sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4040_s/0.70Ctt26sTruef.png b/data/CLs/plots/p4040_s/0.70Ctt26sTruef.png index aad7718..628a75a 100644 --- a/data/CLs/plots/p4040_s/0.70Ctt26sTruef.png +++ b/data/CLs/plots/p4040_s/0.70Ctt26sTruef.png Binary files differ diff --git a/data/CLs/plots/p4040_s/0.70Ctt27sFalsef.png b/data/CLs/plots/p4040_s/0.70Ctt27sFalsef.png index fbab263..3714db6 100644 --- a/data/CLs/plots/p4040_s/0.70Ctt27sFalsef.png +++ b/data/CLs/plots/p4040_s/0.70Ctt27sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4040_s/0.73Ctt28sTruef.png b/data/CLs/plots/p4040_s/0.73Ctt28sTruef.png index c38d8f9..e6842ce 100644 --- a/data/CLs/plots/p4040_s/0.73Ctt28sTruef.png +++ b/data/CLs/plots/p4040_s/0.73Ctt28sTruef.png Binary files differ diff --git a/data/CLs/plots/p4040_s/0.73Ctt29sFalsef.png b/data/CLs/plots/p4040_s/0.73Ctt29sFalsef.png index 10e98f5..45fb139 100644 --- a/data/CLs/plots/p4040_s/0.73Ctt29sFalsef.png +++ b/data/CLs/plots/p4040_s/0.73Ctt29sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4040_s/0.75Ctt30sTruef.png b/data/CLs/plots/p4040_s/0.75Ctt30sTruef.png index 358e96e..065ada3 100644 --- a/data/CLs/plots/p4040_s/0.75Ctt30sTruef.png +++ b/data/CLs/plots/p4040_s/0.75Ctt30sTruef.png Binary files differ diff --git a/data/CLs/plots/p4040_s/0.75Ctt31sFalsef.png b/data/CLs/plots/p4040_s/0.75Ctt31sFalsef.png index 4d47043..6cc0520 100644 --- a/data/CLs/plots/p4040_s/0.75Ctt31sFalsef.png +++ b/data/CLs/plots/p4040_s/0.75Ctt31sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4040_s/0.78Ctt32sTruef.png b/data/CLs/plots/p4040_s/0.78Ctt32sTruef.png index 3f69e3a..cf35795 100644 --- a/data/CLs/plots/p4040_s/0.78Ctt32sTruef.png +++ b/data/CLs/plots/p4040_s/0.78Ctt32sTruef.png Binary files differ diff --git a/data/CLs/plots/p4040_s/0.78Ctt33sFalsef.png b/data/CLs/plots/p4040_s/0.78Ctt33sFalsef.png index 0834380..4e5eba5 100644 --- a/data/CLs/plots/p4040_s/0.78Ctt33sFalsef.png +++ b/data/CLs/plots/p4040_s/0.78Ctt33sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4040_s/0.80Ctt34sTruef.png b/data/CLs/plots/p4040_s/0.80Ctt34sTruef.png index de84b43..e2066e7 100644 --- a/data/CLs/plots/p4040_s/0.80Ctt34sTruef.png +++ b/data/CLs/plots/p4040_s/0.80Ctt34sTruef.png Binary files differ diff --git a/data/CLs/plots/p4040_s/0.80Ctt35sFalsef.png b/data/CLs/plots/p4040_s/0.80Ctt35sFalsef.png index 1990842..d3d3fc8 100644 --- a/data/CLs/plots/p4040_s/0.80Ctt35sFalsef.png +++ b/data/CLs/plots/p4040_s/0.80Ctt35sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4040_s/0.82Ctt36sTruef.png b/data/CLs/plots/p4040_s/0.82Ctt36sTruef.png index 4f6350d..e1c775f 100644 --- a/data/CLs/plots/p4040_s/0.82Ctt36sTruef.png +++ b/data/CLs/plots/p4040_s/0.82Ctt36sTruef.png Binary files differ diff --git a/data/CLs/plots/p4040_s/0.82Ctt37sFalsef.png b/data/CLs/plots/p4040_s/0.82Ctt37sFalsef.png index 167ca7d..af1c6bf 100644 --- a/data/CLs/plots/p4040_s/0.82Ctt37sFalsef.png +++ b/data/CLs/plots/p4040_s/0.82Ctt37sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4040_s/0.85Ctt38sTruef.png b/data/CLs/plots/p4040_s/0.85Ctt38sTruef.png index 6a4e5f4..748626f 100644 --- a/data/CLs/plots/p4040_s/0.85Ctt38sTruef.png +++ b/data/CLs/plots/p4040_s/0.85Ctt38sTruef.png Binary files differ diff --git a/data/CLs/plots/p4040_s/0.85Ctt39sFalsef.png b/data/CLs/plots/p4040_s/0.85Ctt39sFalsef.png index e77f4eb..2577bc8 100644 --- a/data/CLs/plots/p4040_s/0.85Ctt39sFalsef.png +++ b/data/CLs/plots/p4040_s/0.85Ctt39sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4160_p/0.00Ctt0sTruef.png b/data/CLs/plots/p4160_p/0.00Ctt0sTruef.png index e3b2fff..3a2d015 100644 --- a/data/CLs/plots/p4160_p/0.00Ctt0sTruef.png +++ b/data/CLs/plots/p4160_p/0.00Ctt0sTruef.png Binary files differ diff --git a/data/CLs/plots/p4160_p/0.00Ctt1sFalsef.png b/data/CLs/plots/p4160_p/0.00Ctt1sFalsef.png index 7ff79c4..bbae033 100644 --- a/data/CLs/plots/p4160_p/0.00Ctt1sFalsef.png +++ b/data/CLs/plots/p4160_p/0.00Ctt1sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4160_p/0.25Ctt2sTruef.png b/data/CLs/plots/p4160_p/0.25Ctt2sTruef.png index 5b7f54c..81e72b1 100644 --- a/data/CLs/plots/p4160_p/0.25Ctt2sTruef.png +++ b/data/CLs/plots/p4160_p/0.25Ctt2sTruef.png Binary files differ diff --git a/data/CLs/plots/p4160_p/0.25Ctt3sFalsef.png b/data/CLs/plots/p4160_p/0.25Ctt3sFalsef.png index 630d3e0..a665d33 100644 --- a/data/CLs/plots/p4160_p/0.25Ctt3sFalsef.png +++ b/data/CLs/plots/p4160_p/0.25Ctt3sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4160_p/0.31Ctt4sTruef.png b/data/CLs/plots/p4160_p/0.31Ctt4sTruef.png index 91ec3ef..0dd5b29 100644 --- a/data/CLs/plots/p4160_p/0.31Ctt4sTruef.png +++ b/data/CLs/plots/p4160_p/0.31Ctt4sTruef.png Binary files differ diff --git a/data/CLs/plots/p4160_p/0.31Ctt5sFalsef.png b/data/CLs/plots/p4160_p/0.31Ctt5sFalsef.png index c76f549..842bfec 100644 --- a/data/CLs/plots/p4160_p/0.31Ctt5sFalsef.png +++ b/data/CLs/plots/p4160_p/0.31Ctt5sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4160_p/0.36Ctt6sTruef.png b/data/CLs/plots/p4160_p/0.36Ctt6sTruef.png index 15e1aaf..2ff7634 100644 --- a/data/CLs/plots/p4160_p/0.36Ctt6sTruef.png +++ b/data/CLs/plots/p4160_p/0.36Ctt6sTruef.png Binary files differ diff --git a/data/CLs/plots/p4160_p/0.36Ctt7sFalsef.png b/data/CLs/plots/p4160_p/0.36Ctt7sFalsef.png index 32a79d8..68844c2 100644 --- a/data/CLs/plots/p4160_p/0.36Ctt7sFalsef.png +++ b/data/CLs/plots/p4160_p/0.36Ctt7sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4160_p/0.41Ctt8sTruef.png b/data/CLs/plots/p4160_p/0.41Ctt8sTruef.png index 77031bc..132fac5 100644 --- a/data/CLs/plots/p4160_p/0.41Ctt8sTruef.png +++ b/data/CLs/plots/p4160_p/0.41Ctt8sTruef.png Binary files differ diff --git a/data/CLs/plots/p4160_p/0.41Ctt9sFalsef.png b/data/CLs/plots/p4160_p/0.41Ctt9sFalsef.png index 5693200..a53dc29 100644 --- a/data/CLs/plots/p4160_p/0.41Ctt9sFalsef.png +++ b/data/CLs/plots/p4160_p/0.41Ctt9sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4160_p/0.45Ctt10sTruef.png b/data/CLs/plots/p4160_p/0.45Ctt10sTruef.png index 09a78a6..5947c06 100644 --- a/data/CLs/plots/p4160_p/0.45Ctt10sTruef.png +++ b/data/CLs/plots/p4160_p/0.45Ctt10sTruef.png Binary files differ diff --git a/data/CLs/plots/p4160_p/0.45Ctt11sFalsef.png b/data/CLs/plots/p4160_p/0.45Ctt11sFalsef.png index d4a66d6..0395c80 100644 --- a/data/CLs/plots/p4160_p/0.45Ctt11sFalsef.png +++ b/data/CLs/plots/p4160_p/0.45Ctt11sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4160_p/0.49Ctt12sTruef.png b/data/CLs/plots/p4160_p/0.49Ctt12sTruef.png index 83da0e9..68a2e9f 100644 --- a/data/CLs/plots/p4160_p/0.49Ctt12sTruef.png +++ b/data/CLs/plots/p4160_p/0.49Ctt12sTruef.png Binary files differ diff --git a/data/CLs/plots/p4160_p/0.49Ctt13sFalsef.png b/data/CLs/plots/p4160_p/0.49Ctt13sFalsef.png index a04ec35..73d5355 100644 --- a/data/CLs/plots/p4160_p/0.49Ctt13sFalsef.png +++ b/data/CLs/plots/p4160_p/0.49Ctt13sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4160_p/0.53Ctt14sTruef.png b/data/CLs/plots/p4160_p/0.53Ctt14sTruef.png index f68473d..01a2bbc 100644 --- a/data/CLs/plots/p4160_p/0.53Ctt14sTruef.png +++ b/data/CLs/plots/p4160_p/0.53Ctt14sTruef.png Binary files differ diff --git a/data/CLs/plots/p4160_p/0.53Ctt15sFalsef.png b/data/CLs/plots/p4160_p/0.53Ctt15sFalsef.png index a4eec90..f0e6fc1 100644 --- a/data/CLs/plots/p4160_p/0.53Ctt15sFalsef.png +++ b/data/CLs/plots/p4160_p/0.53Ctt15sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4160_p/0.56Ctt16sTruef.png b/data/CLs/plots/p4160_p/0.56Ctt16sTruef.png index dc5121a..cc56dc9 100644 --- a/data/CLs/plots/p4160_p/0.56Ctt16sTruef.png +++ b/data/CLs/plots/p4160_p/0.56Ctt16sTruef.png Binary files differ diff --git a/data/CLs/plots/p4160_p/0.56Ctt17sFalsef.png b/data/CLs/plots/p4160_p/0.56Ctt17sFalsef.png index 5b9c90b..193fea4 100644 --- a/data/CLs/plots/p4160_p/0.56Ctt17sFalsef.png +++ b/data/CLs/plots/p4160_p/0.56Ctt17sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4160_p/0.59Ctt18sTruef.png b/data/CLs/plots/p4160_p/0.59Ctt18sTruef.png index 970e0a5..ce6daaa 100644 --- a/data/CLs/plots/p4160_p/0.59Ctt18sTruef.png +++ b/data/CLs/plots/p4160_p/0.59Ctt18sTruef.png Binary files differ diff --git a/data/CLs/plots/p4160_p/0.59Ctt19sFalsef.png b/data/CLs/plots/p4160_p/0.59Ctt19sFalsef.png index a30c970..769fdf1 100644 --- a/data/CLs/plots/p4160_p/0.59Ctt19sFalsef.png +++ b/data/CLs/plots/p4160_p/0.59Ctt19sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4160_p/0.62Ctt20sTruef.png b/data/CLs/plots/p4160_p/0.62Ctt20sTruef.png index 0eca8a2..74ec54a 100644 --- a/data/CLs/plots/p4160_p/0.62Ctt20sTruef.png +++ b/data/CLs/plots/p4160_p/0.62Ctt20sTruef.png Binary files differ diff --git a/data/CLs/plots/p4160_p/0.62Ctt21sFalsef.png b/data/CLs/plots/p4160_p/0.62Ctt21sFalsef.png index a569be9..7b552d7 100644 --- a/data/CLs/plots/p4160_p/0.62Ctt21sFalsef.png +++ b/data/CLs/plots/p4160_p/0.62Ctt21sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4160_p/0.65Ctt22sTruef.png b/data/CLs/plots/p4160_p/0.65Ctt22sTruef.png index f0679e7..ea08a52 100644 --- a/data/CLs/plots/p4160_p/0.65Ctt22sTruef.png +++ b/data/CLs/plots/p4160_p/0.65Ctt22sTruef.png Binary files differ diff --git a/data/CLs/plots/p4160_p/0.65Ctt23sFalsef.png b/data/CLs/plots/p4160_p/0.65Ctt23sFalsef.png index e548a3b..9531696 100644 --- a/data/CLs/plots/p4160_p/0.65Ctt23sFalsef.png +++ b/data/CLs/plots/p4160_p/0.65Ctt23sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4160_p/0.68Ctt24sTruef.png b/data/CLs/plots/p4160_p/0.68Ctt24sTruef.png index 18535e3..5785f47 100644 --- a/data/CLs/plots/p4160_p/0.68Ctt24sTruef.png +++ b/data/CLs/plots/p4160_p/0.68Ctt24sTruef.png Binary files differ diff --git a/data/CLs/plots/p4160_p/0.68Ctt25sFalsef.png b/data/CLs/plots/p4160_p/0.68Ctt25sFalsef.png index 46fde0d..4e74fa1 100644 --- a/data/CLs/plots/p4160_p/0.68Ctt25sFalsef.png +++ b/data/CLs/plots/p4160_p/0.68Ctt25sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4160_p/0.70Ctt26sTruef.png b/data/CLs/plots/p4160_p/0.70Ctt26sTruef.png index f12809e..8d3e6f0 100644 --- a/data/CLs/plots/p4160_p/0.70Ctt26sTruef.png +++ b/data/CLs/plots/p4160_p/0.70Ctt26sTruef.png Binary files differ diff --git a/data/CLs/plots/p4160_p/0.70Ctt27sFalsef.png b/data/CLs/plots/p4160_p/0.70Ctt27sFalsef.png index c6aaedb..3fa9954 100644 --- a/data/CLs/plots/p4160_p/0.70Ctt27sFalsef.png +++ b/data/CLs/plots/p4160_p/0.70Ctt27sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4160_p/0.73Ctt28sTruef.png b/data/CLs/plots/p4160_p/0.73Ctt28sTruef.png index 6823f4d..9321e41 100644 --- a/data/CLs/plots/p4160_p/0.73Ctt28sTruef.png +++ b/data/CLs/plots/p4160_p/0.73Ctt28sTruef.png Binary files differ diff --git a/data/CLs/plots/p4160_p/0.73Ctt29sFalsef.png b/data/CLs/plots/p4160_p/0.73Ctt29sFalsef.png index a5bc09d..8b5d070 100644 --- a/data/CLs/plots/p4160_p/0.73Ctt29sFalsef.png +++ b/data/CLs/plots/p4160_p/0.73Ctt29sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4160_p/0.75Ctt30sTruef.png b/data/CLs/plots/p4160_p/0.75Ctt30sTruef.png index cf97c63..a00e77c 100644 --- a/data/CLs/plots/p4160_p/0.75Ctt30sTruef.png +++ b/data/CLs/plots/p4160_p/0.75Ctt30sTruef.png Binary files differ diff --git a/data/CLs/plots/p4160_p/0.75Ctt31sFalsef.png b/data/CLs/plots/p4160_p/0.75Ctt31sFalsef.png index 8816d0f..5e6e091 100644 --- a/data/CLs/plots/p4160_p/0.75Ctt31sFalsef.png +++ b/data/CLs/plots/p4160_p/0.75Ctt31sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4160_p/0.78Ctt32sTruef.png b/data/CLs/plots/p4160_p/0.78Ctt32sTruef.png index 3024d81..f97776e 100644 --- a/data/CLs/plots/p4160_p/0.78Ctt32sTruef.png +++ b/data/CLs/plots/p4160_p/0.78Ctt32sTruef.png Binary files differ diff --git a/data/CLs/plots/p4160_p/0.78Ctt33sFalsef.png b/data/CLs/plots/p4160_p/0.78Ctt33sFalsef.png index b631cea..7f817ef 100644 --- a/data/CLs/plots/p4160_p/0.78Ctt33sFalsef.png +++ b/data/CLs/plots/p4160_p/0.78Ctt33sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4160_p/0.80Ctt34sTruef.png b/data/CLs/plots/p4160_p/0.80Ctt34sTruef.png index 80a18f9..55507ba 100644 --- a/data/CLs/plots/p4160_p/0.80Ctt34sTruef.png +++ b/data/CLs/plots/p4160_p/0.80Ctt34sTruef.png Binary files differ diff --git a/data/CLs/plots/p4160_p/0.80Ctt35sFalsef.png b/data/CLs/plots/p4160_p/0.80Ctt35sFalsef.png index 1b378c6..4e93ecd 100644 --- a/data/CLs/plots/p4160_p/0.80Ctt35sFalsef.png +++ b/data/CLs/plots/p4160_p/0.80Ctt35sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4160_p/0.82Ctt36sTruef.png b/data/CLs/plots/p4160_p/0.82Ctt36sTruef.png index 080dd41..53aa373 100644 --- a/data/CLs/plots/p4160_p/0.82Ctt36sTruef.png +++ b/data/CLs/plots/p4160_p/0.82Ctt36sTruef.png Binary files differ diff --git a/data/CLs/plots/p4160_p/0.82Ctt37sFalsef.png b/data/CLs/plots/p4160_p/0.82Ctt37sFalsef.png index 38ae3c9..23fcc0f 100644 --- a/data/CLs/plots/p4160_p/0.82Ctt37sFalsef.png +++ b/data/CLs/plots/p4160_p/0.82Ctt37sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4160_p/0.85Ctt38sTruef.png b/data/CLs/plots/p4160_p/0.85Ctt38sTruef.png index 5215323..f16cc60 100644 --- a/data/CLs/plots/p4160_p/0.85Ctt38sTruef.png +++ b/data/CLs/plots/p4160_p/0.85Ctt38sTruef.png Binary files differ diff --git a/data/CLs/plots/p4160_p/0.85Ctt39sFalsef.png b/data/CLs/plots/p4160_p/0.85Ctt39sFalsef.png index 412548d..370d729 100644 --- a/data/CLs/plots/p4160_p/0.85Ctt39sFalsef.png +++ b/data/CLs/plots/p4160_p/0.85Ctt39sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4160_s/0.00Ctt0sTruef.png b/data/CLs/plots/p4160_s/0.00Ctt0sTruef.png index 4ab8d07..beb42aa 100644 --- a/data/CLs/plots/p4160_s/0.00Ctt0sTruef.png +++ b/data/CLs/plots/p4160_s/0.00Ctt0sTruef.png Binary files differ diff --git a/data/CLs/plots/p4160_s/0.00Ctt1sFalsef.png b/data/CLs/plots/p4160_s/0.00Ctt1sFalsef.png index 819f002..428a9e2 100644 --- a/data/CLs/plots/p4160_s/0.00Ctt1sFalsef.png +++ b/data/CLs/plots/p4160_s/0.00Ctt1sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4160_s/0.25Ctt2sTruef.png b/data/CLs/plots/p4160_s/0.25Ctt2sTruef.png index 6421f64..1ec54f6 100644 --- a/data/CLs/plots/p4160_s/0.25Ctt2sTruef.png +++ b/data/CLs/plots/p4160_s/0.25Ctt2sTruef.png Binary files differ diff --git a/data/CLs/plots/p4160_s/0.25Ctt3sFalsef.png b/data/CLs/plots/p4160_s/0.25Ctt3sFalsef.png index aa978f0..68507d9 100644 --- a/data/CLs/plots/p4160_s/0.25Ctt3sFalsef.png +++ b/data/CLs/plots/p4160_s/0.25Ctt3sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4160_s/0.31Ctt4sTruef.png b/data/CLs/plots/p4160_s/0.31Ctt4sTruef.png index 4ec4f41..ed1bf0b 100644 --- a/data/CLs/plots/p4160_s/0.31Ctt4sTruef.png +++ b/data/CLs/plots/p4160_s/0.31Ctt4sTruef.png Binary files differ diff --git a/data/CLs/plots/p4160_s/0.31Ctt5sFalsef.png b/data/CLs/plots/p4160_s/0.31Ctt5sFalsef.png index e5b4007..14eb37d 100644 --- a/data/CLs/plots/p4160_s/0.31Ctt5sFalsef.png +++ b/data/CLs/plots/p4160_s/0.31Ctt5sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4160_s/0.36Ctt6sTruef.png b/data/CLs/plots/p4160_s/0.36Ctt6sTruef.png index e7a7ab3..8588c54 100644 --- a/data/CLs/plots/p4160_s/0.36Ctt6sTruef.png +++ b/data/CLs/plots/p4160_s/0.36Ctt6sTruef.png Binary files differ diff --git a/data/CLs/plots/p4160_s/0.36Ctt7sFalsef.png b/data/CLs/plots/p4160_s/0.36Ctt7sFalsef.png index 79dddee..1499678 100644 --- a/data/CLs/plots/p4160_s/0.36Ctt7sFalsef.png +++ b/data/CLs/plots/p4160_s/0.36Ctt7sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4160_s/0.41Ctt8sTruef.png b/data/CLs/plots/p4160_s/0.41Ctt8sTruef.png index 98a57e1..6d5a06d 100644 --- a/data/CLs/plots/p4160_s/0.41Ctt8sTruef.png +++ b/data/CLs/plots/p4160_s/0.41Ctt8sTruef.png Binary files differ diff --git a/data/CLs/plots/p4160_s/0.41Ctt9sFalsef.png b/data/CLs/plots/p4160_s/0.41Ctt9sFalsef.png index 52c462b..3e1682f 100644 --- a/data/CLs/plots/p4160_s/0.41Ctt9sFalsef.png +++ b/data/CLs/plots/p4160_s/0.41Ctt9sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4160_s/0.45Ctt10sTruef.png b/data/CLs/plots/p4160_s/0.45Ctt10sTruef.png index f2ed29f..8c32ba3 100644 --- a/data/CLs/plots/p4160_s/0.45Ctt10sTruef.png +++ b/data/CLs/plots/p4160_s/0.45Ctt10sTruef.png Binary files differ diff --git a/data/CLs/plots/p4160_s/0.45Ctt11sFalsef.png b/data/CLs/plots/p4160_s/0.45Ctt11sFalsef.png index c67fa6f..ecaf731 100644 --- a/data/CLs/plots/p4160_s/0.45Ctt11sFalsef.png +++ b/data/CLs/plots/p4160_s/0.45Ctt11sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4160_s/0.49Ctt12sTruef.png b/data/CLs/plots/p4160_s/0.49Ctt12sTruef.png index 18c5d91..5c74a7a 100644 --- a/data/CLs/plots/p4160_s/0.49Ctt12sTruef.png +++ b/data/CLs/plots/p4160_s/0.49Ctt12sTruef.png Binary files differ diff --git a/data/CLs/plots/p4160_s/0.49Ctt13sFalsef.png b/data/CLs/plots/p4160_s/0.49Ctt13sFalsef.png index 6c89416..524aea7 100644 --- a/data/CLs/plots/p4160_s/0.49Ctt13sFalsef.png +++ b/data/CLs/plots/p4160_s/0.49Ctt13sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4160_s/0.53Ctt14sTruef.png b/data/CLs/plots/p4160_s/0.53Ctt14sTruef.png index 87b95d5..262b6e9 100644 --- a/data/CLs/plots/p4160_s/0.53Ctt14sTruef.png +++ b/data/CLs/plots/p4160_s/0.53Ctt14sTruef.png Binary files differ diff --git a/data/CLs/plots/p4160_s/0.53Ctt15sFalsef.png b/data/CLs/plots/p4160_s/0.53Ctt15sFalsef.png index dd13ef2..1b3bfb9 100644 --- a/data/CLs/plots/p4160_s/0.53Ctt15sFalsef.png +++ b/data/CLs/plots/p4160_s/0.53Ctt15sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4160_s/0.56Ctt16sTruef.png b/data/CLs/plots/p4160_s/0.56Ctt16sTruef.png index b62ca40..76b157f 100644 --- a/data/CLs/plots/p4160_s/0.56Ctt16sTruef.png +++ b/data/CLs/plots/p4160_s/0.56Ctt16sTruef.png Binary files differ diff --git a/data/CLs/plots/p4160_s/0.56Ctt17sFalsef.png b/data/CLs/plots/p4160_s/0.56Ctt17sFalsef.png index 326b9d3..24f8604 100644 --- a/data/CLs/plots/p4160_s/0.56Ctt17sFalsef.png +++ b/data/CLs/plots/p4160_s/0.56Ctt17sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4160_s/0.59Ctt18sTruef.png b/data/CLs/plots/p4160_s/0.59Ctt18sTruef.png index 49dee87..6b6e448 100644 --- a/data/CLs/plots/p4160_s/0.59Ctt18sTruef.png +++ b/data/CLs/plots/p4160_s/0.59Ctt18sTruef.png Binary files differ diff --git a/data/CLs/plots/p4160_s/0.59Ctt19sFalsef.png b/data/CLs/plots/p4160_s/0.59Ctt19sFalsef.png index aa386b9..a7c2cd1 100644 --- a/data/CLs/plots/p4160_s/0.59Ctt19sFalsef.png +++ b/data/CLs/plots/p4160_s/0.59Ctt19sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4160_s/0.62Ctt20sTruef.png b/data/CLs/plots/p4160_s/0.62Ctt20sTruef.png index 5896af8..1306dc1 100644 --- a/data/CLs/plots/p4160_s/0.62Ctt20sTruef.png +++ b/data/CLs/plots/p4160_s/0.62Ctt20sTruef.png Binary files differ diff --git a/data/CLs/plots/p4160_s/0.62Ctt21sFalsef.png b/data/CLs/plots/p4160_s/0.62Ctt21sFalsef.png index 28510ef..7c1bb87 100644 --- a/data/CLs/plots/p4160_s/0.62Ctt21sFalsef.png +++ b/data/CLs/plots/p4160_s/0.62Ctt21sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4160_s/0.65Ctt22sTruef.png b/data/CLs/plots/p4160_s/0.65Ctt22sTruef.png index 866b1bb..755babc 100644 --- a/data/CLs/plots/p4160_s/0.65Ctt22sTruef.png +++ b/data/CLs/plots/p4160_s/0.65Ctt22sTruef.png Binary files differ diff --git a/data/CLs/plots/p4160_s/0.65Ctt23sFalsef.png b/data/CLs/plots/p4160_s/0.65Ctt23sFalsef.png index 83713f1..dd7b00a 100644 --- a/data/CLs/plots/p4160_s/0.65Ctt23sFalsef.png +++ b/data/CLs/plots/p4160_s/0.65Ctt23sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4160_s/0.68Ctt24sTruef.png b/data/CLs/plots/p4160_s/0.68Ctt24sTruef.png index aa645ab..958606c 100644 --- a/data/CLs/plots/p4160_s/0.68Ctt24sTruef.png +++ b/data/CLs/plots/p4160_s/0.68Ctt24sTruef.png Binary files differ diff --git a/data/CLs/plots/p4160_s/0.68Ctt25sFalsef.png b/data/CLs/plots/p4160_s/0.68Ctt25sFalsef.png index d6a6de9..99826db 100644 --- a/data/CLs/plots/p4160_s/0.68Ctt25sFalsef.png +++ b/data/CLs/plots/p4160_s/0.68Ctt25sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4160_s/0.70Ctt26sTruef.png b/data/CLs/plots/p4160_s/0.70Ctt26sTruef.png index aed316c..9e07541 100644 --- a/data/CLs/plots/p4160_s/0.70Ctt26sTruef.png +++ b/data/CLs/plots/p4160_s/0.70Ctt26sTruef.png Binary files differ diff --git a/data/CLs/plots/p4160_s/0.70Ctt27sFalsef.png b/data/CLs/plots/p4160_s/0.70Ctt27sFalsef.png index 6234ee2..3cc7404 100644 --- a/data/CLs/plots/p4160_s/0.70Ctt27sFalsef.png +++ b/data/CLs/plots/p4160_s/0.70Ctt27sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4160_s/0.73Ctt28sTruef.png b/data/CLs/plots/p4160_s/0.73Ctt28sTruef.png index a4b6f8b..a3189a7 100644 --- a/data/CLs/plots/p4160_s/0.73Ctt28sTruef.png +++ b/data/CLs/plots/p4160_s/0.73Ctt28sTruef.png Binary files differ diff --git a/data/CLs/plots/p4160_s/0.73Ctt29sFalsef.png b/data/CLs/plots/p4160_s/0.73Ctt29sFalsef.png index 74976a1..4442b02 100644 --- a/data/CLs/plots/p4160_s/0.73Ctt29sFalsef.png +++ b/data/CLs/plots/p4160_s/0.73Ctt29sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4160_s/0.75Ctt30sTruef.png b/data/CLs/plots/p4160_s/0.75Ctt30sTruef.png index 93b77d2..1e2fede 100644 --- a/data/CLs/plots/p4160_s/0.75Ctt30sTruef.png +++ b/data/CLs/plots/p4160_s/0.75Ctt30sTruef.png Binary files differ diff --git a/data/CLs/plots/p4160_s/0.75Ctt31sFalsef.png b/data/CLs/plots/p4160_s/0.75Ctt31sFalsef.png index b81eee9..cac1ef5 100644 --- a/data/CLs/plots/p4160_s/0.75Ctt31sFalsef.png +++ b/data/CLs/plots/p4160_s/0.75Ctt31sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4160_s/0.78Ctt32sTruef.png b/data/CLs/plots/p4160_s/0.78Ctt32sTruef.png index 5f571be..a47c827 100644 --- a/data/CLs/plots/p4160_s/0.78Ctt32sTruef.png +++ b/data/CLs/plots/p4160_s/0.78Ctt32sTruef.png Binary files differ diff --git a/data/CLs/plots/p4160_s/0.78Ctt33sFalsef.png b/data/CLs/plots/p4160_s/0.78Ctt33sFalsef.png index 087dce9..a2d1b89 100644 --- a/data/CLs/plots/p4160_s/0.78Ctt33sFalsef.png +++ b/data/CLs/plots/p4160_s/0.78Ctt33sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4160_s/0.80Ctt34sTruef.png b/data/CLs/plots/p4160_s/0.80Ctt34sTruef.png index eba6d7d..e8a49dc 100644 --- a/data/CLs/plots/p4160_s/0.80Ctt34sTruef.png +++ b/data/CLs/plots/p4160_s/0.80Ctt34sTruef.png Binary files differ diff --git a/data/CLs/plots/p4160_s/0.80Ctt35sFalsef.png b/data/CLs/plots/p4160_s/0.80Ctt35sFalsef.png index 11c2453..cc41853 100644 --- a/data/CLs/plots/p4160_s/0.80Ctt35sFalsef.png +++ b/data/CLs/plots/p4160_s/0.80Ctt35sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4160_s/0.82Ctt36sTruef.png b/data/CLs/plots/p4160_s/0.82Ctt36sTruef.png index 79a5902..ba3cfc8 100644 --- a/data/CLs/plots/p4160_s/0.82Ctt36sTruef.png +++ b/data/CLs/plots/p4160_s/0.82Ctt36sTruef.png Binary files differ diff --git a/data/CLs/plots/p4160_s/0.82Ctt37sFalsef.png b/data/CLs/plots/p4160_s/0.82Ctt37sFalsef.png index 7fe9380..58f53e1 100644 --- a/data/CLs/plots/p4160_s/0.82Ctt37sFalsef.png +++ b/data/CLs/plots/p4160_s/0.82Ctt37sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4160_s/0.85Ctt38sTruef.png b/data/CLs/plots/p4160_s/0.85Ctt38sTruef.png index 0eae246..74e0ba8 100644 --- a/data/CLs/plots/p4160_s/0.85Ctt38sTruef.png +++ b/data/CLs/plots/p4160_s/0.85Ctt38sTruef.png Binary files differ diff --git a/data/CLs/plots/p4160_s/0.85Ctt39sFalsef.png b/data/CLs/plots/p4160_s/0.85Ctt39sFalsef.png index 72402e7..c454d5b 100644 --- a/data/CLs/plots/p4160_s/0.85Ctt39sFalsef.png +++ b/data/CLs/plots/p4160_s/0.85Ctt39sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4415_p/0.00Ctt0sTruef.png b/data/CLs/plots/p4415_p/0.00Ctt0sTruef.png index 26776ea..d8a048e 100644 --- a/data/CLs/plots/p4415_p/0.00Ctt0sTruef.png +++ b/data/CLs/plots/p4415_p/0.00Ctt0sTruef.png Binary files differ diff --git a/data/CLs/plots/p4415_p/0.00Ctt1sFalsef.png b/data/CLs/plots/p4415_p/0.00Ctt1sFalsef.png index ec0728f..49092db 100644 --- a/data/CLs/plots/p4415_p/0.00Ctt1sFalsef.png +++ b/data/CLs/plots/p4415_p/0.00Ctt1sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4415_p/0.25Ctt2sTruef.png b/data/CLs/plots/p4415_p/0.25Ctt2sTruef.png index f791b9d..20e2933 100644 --- a/data/CLs/plots/p4415_p/0.25Ctt2sTruef.png +++ b/data/CLs/plots/p4415_p/0.25Ctt2sTruef.png Binary files differ diff --git a/data/CLs/plots/p4415_p/0.25Ctt3sFalsef.png b/data/CLs/plots/p4415_p/0.25Ctt3sFalsef.png index a54a35d..6dcc5a4 100644 --- a/data/CLs/plots/p4415_p/0.25Ctt3sFalsef.png +++ b/data/CLs/plots/p4415_p/0.25Ctt3sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4415_p/0.31Ctt4sTruef.png b/data/CLs/plots/p4415_p/0.31Ctt4sTruef.png index f370142..e1eb150 100644 --- a/data/CLs/plots/p4415_p/0.31Ctt4sTruef.png +++ b/data/CLs/plots/p4415_p/0.31Ctt4sTruef.png Binary files differ diff --git a/data/CLs/plots/p4415_p/0.31Ctt5sFalsef.png b/data/CLs/plots/p4415_p/0.31Ctt5sFalsef.png index 2c17486..b36c033 100644 --- a/data/CLs/plots/p4415_p/0.31Ctt5sFalsef.png +++ b/data/CLs/plots/p4415_p/0.31Ctt5sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4415_p/0.36Ctt6sTruef.png b/data/CLs/plots/p4415_p/0.36Ctt6sTruef.png index 1ab2480..6ae188e 100644 --- a/data/CLs/plots/p4415_p/0.36Ctt6sTruef.png +++ b/data/CLs/plots/p4415_p/0.36Ctt6sTruef.png Binary files differ diff --git a/data/CLs/plots/p4415_p/0.36Ctt7sFalsef.png b/data/CLs/plots/p4415_p/0.36Ctt7sFalsef.png index 733b58b..d4d340b 100644 --- a/data/CLs/plots/p4415_p/0.36Ctt7sFalsef.png +++ b/data/CLs/plots/p4415_p/0.36Ctt7sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4415_p/0.41Ctt8sTruef.png b/data/CLs/plots/p4415_p/0.41Ctt8sTruef.png index d31011a..6b1a9c3 100644 --- a/data/CLs/plots/p4415_p/0.41Ctt8sTruef.png +++ b/data/CLs/plots/p4415_p/0.41Ctt8sTruef.png Binary files differ diff --git a/data/CLs/plots/p4415_p/0.41Ctt9sFalsef.png b/data/CLs/plots/p4415_p/0.41Ctt9sFalsef.png index 9f4e840..c99694c 100644 --- a/data/CLs/plots/p4415_p/0.41Ctt9sFalsef.png +++ b/data/CLs/plots/p4415_p/0.41Ctt9sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4415_p/0.45Ctt10sTruef.png b/data/CLs/plots/p4415_p/0.45Ctt10sTruef.png index 7c649d0..320cca9 100644 --- a/data/CLs/plots/p4415_p/0.45Ctt10sTruef.png +++ b/data/CLs/plots/p4415_p/0.45Ctt10sTruef.png Binary files differ diff --git a/data/CLs/plots/p4415_p/0.45Ctt11sFalsef.png b/data/CLs/plots/p4415_p/0.45Ctt11sFalsef.png index da3010b..8c16b45 100644 --- a/data/CLs/plots/p4415_p/0.45Ctt11sFalsef.png +++ b/data/CLs/plots/p4415_p/0.45Ctt11sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4415_p/0.49Ctt12sTruef.png b/data/CLs/plots/p4415_p/0.49Ctt12sTruef.png index c86b631..bb1815a 100644 --- a/data/CLs/plots/p4415_p/0.49Ctt12sTruef.png +++ b/data/CLs/plots/p4415_p/0.49Ctt12sTruef.png Binary files differ diff --git a/data/CLs/plots/p4415_p/0.49Ctt13sFalsef.png b/data/CLs/plots/p4415_p/0.49Ctt13sFalsef.png index 53c7207..19d1866 100644 --- a/data/CLs/plots/p4415_p/0.49Ctt13sFalsef.png +++ b/data/CLs/plots/p4415_p/0.49Ctt13sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4415_p/0.53Ctt14sTruef.png b/data/CLs/plots/p4415_p/0.53Ctt14sTruef.png index 454336f..eb17c2b 100644 --- a/data/CLs/plots/p4415_p/0.53Ctt14sTruef.png +++ b/data/CLs/plots/p4415_p/0.53Ctt14sTruef.png Binary files differ diff --git a/data/CLs/plots/p4415_p/0.53Ctt15sFalsef.png b/data/CLs/plots/p4415_p/0.53Ctt15sFalsef.png index d6cd51c..9fcf615 100644 --- a/data/CLs/plots/p4415_p/0.53Ctt15sFalsef.png +++ b/data/CLs/plots/p4415_p/0.53Ctt15sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4415_p/0.56Ctt16sTruef.png b/data/CLs/plots/p4415_p/0.56Ctt16sTruef.png index 2b040e0..89997eb 100644 --- a/data/CLs/plots/p4415_p/0.56Ctt16sTruef.png +++ b/data/CLs/plots/p4415_p/0.56Ctt16sTruef.png Binary files differ diff --git a/data/CLs/plots/p4415_p/0.56Ctt17sFalsef.png b/data/CLs/plots/p4415_p/0.56Ctt17sFalsef.png index 899120f..d34440b 100644 --- a/data/CLs/plots/p4415_p/0.56Ctt17sFalsef.png +++ b/data/CLs/plots/p4415_p/0.56Ctt17sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4415_p/0.59Ctt18sTruef.png b/data/CLs/plots/p4415_p/0.59Ctt18sTruef.png index 0b59495..ccc1713 100644 --- a/data/CLs/plots/p4415_p/0.59Ctt18sTruef.png +++ b/data/CLs/plots/p4415_p/0.59Ctt18sTruef.png Binary files differ diff --git a/data/CLs/plots/p4415_p/0.59Ctt19sFalsef.png b/data/CLs/plots/p4415_p/0.59Ctt19sFalsef.png index 4b8ed1d..1d74571 100644 --- a/data/CLs/plots/p4415_p/0.59Ctt19sFalsef.png +++ b/data/CLs/plots/p4415_p/0.59Ctt19sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4415_p/0.62Ctt20sTruef.png b/data/CLs/plots/p4415_p/0.62Ctt20sTruef.png index 0370f21..74fdd85 100644 --- a/data/CLs/plots/p4415_p/0.62Ctt20sTruef.png +++ b/data/CLs/plots/p4415_p/0.62Ctt20sTruef.png Binary files differ diff --git a/data/CLs/plots/p4415_p/0.62Ctt21sFalsef.png b/data/CLs/plots/p4415_p/0.62Ctt21sFalsef.png index 9008e38..5354587 100644 --- a/data/CLs/plots/p4415_p/0.62Ctt21sFalsef.png +++ b/data/CLs/plots/p4415_p/0.62Ctt21sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4415_p/0.65Ctt22sTruef.png b/data/CLs/plots/p4415_p/0.65Ctt22sTruef.png index 55bfde4..fc4860c 100644 --- a/data/CLs/plots/p4415_p/0.65Ctt22sTruef.png +++ b/data/CLs/plots/p4415_p/0.65Ctt22sTruef.png Binary files differ diff --git a/data/CLs/plots/p4415_p/0.65Ctt23sFalsef.png b/data/CLs/plots/p4415_p/0.65Ctt23sFalsef.png index 4c47eec..e79ee30 100644 --- a/data/CLs/plots/p4415_p/0.65Ctt23sFalsef.png +++ b/data/CLs/plots/p4415_p/0.65Ctt23sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4415_p/0.68Ctt24sTruef.png b/data/CLs/plots/p4415_p/0.68Ctt24sTruef.png index 5899924..caf7f43 100644 --- a/data/CLs/plots/p4415_p/0.68Ctt24sTruef.png +++ b/data/CLs/plots/p4415_p/0.68Ctt24sTruef.png Binary files differ diff --git a/data/CLs/plots/p4415_p/0.68Ctt25sFalsef.png b/data/CLs/plots/p4415_p/0.68Ctt25sFalsef.png index 5214f8d..5a1a8e3 100644 --- a/data/CLs/plots/p4415_p/0.68Ctt25sFalsef.png +++ b/data/CLs/plots/p4415_p/0.68Ctt25sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4415_p/0.70Ctt26sTruef.png b/data/CLs/plots/p4415_p/0.70Ctt26sTruef.png index 299eac9..be56f3c 100644 --- a/data/CLs/plots/p4415_p/0.70Ctt26sTruef.png +++ b/data/CLs/plots/p4415_p/0.70Ctt26sTruef.png Binary files differ diff --git a/data/CLs/plots/p4415_p/0.70Ctt27sFalsef.png b/data/CLs/plots/p4415_p/0.70Ctt27sFalsef.png index 0df5e1f..1e46418 100644 --- a/data/CLs/plots/p4415_p/0.70Ctt27sFalsef.png +++ b/data/CLs/plots/p4415_p/0.70Ctt27sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4415_p/0.73Ctt28sTruef.png b/data/CLs/plots/p4415_p/0.73Ctt28sTruef.png index 09f89e4..c9eba82 100644 --- a/data/CLs/plots/p4415_p/0.73Ctt28sTruef.png +++ b/data/CLs/plots/p4415_p/0.73Ctt28sTruef.png Binary files differ diff --git a/data/CLs/plots/p4415_p/0.73Ctt29sFalsef.png b/data/CLs/plots/p4415_p/0.73Ctt29sFalsef.png index c3d771c..79a8ed9 100644 --- a/data/CLs/plots/p4415_p/0.73Ctt29sFalsef.png +++ b/data/CLs/plots/p4415_p/0.73Ctt29sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4415_p/0.75Ctt30sTruef.png b/data/CLs/plots/p4415_p/0.75Ctt30sTruef.png index 5d76f6e..c93f627 100644 --- a/data/CLs/plots/p4415_p/0.75Ctt30sTruef.png +++ b/data/CLs/plots/p4415_p/0.75Ctt30sTruef.png Binary files differ diff --git a/data/CLs/plots/p4415_p/0.75Ctt31sFalsef.png b/data/CLs/plots/p4415_p/0.75Ctt31sFalsef.png index a0d5619..f74ab8e 100644 --- a/data/CLs/plots/p4415_p/0.75Ctt31sFalsef.png +++ b/data/CLs/plots/p4415_p/0.75Ctt31sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4415_p/0.78Ctt32sTruef.png b/data/CLs/plots/p4415_p/0.78Ctt32sTruef.png index d85c350..de83d4a 100644 --- a/data/CLs/plots/p4415_p/0.78Ctt32sTruef.png +++ b/data/CLs/plots/p4415_p/0.78Ctt32sTruef.png Binary files differ diff --git a/data/CLs/plots/p4415_p/0.78Ctt33sFalsef.png b/data/CLs/plots/p4415_p/0.78Ctt33sFalsef.png index 592179a..c63569c 100644 --- a/data/CLs/plots/p4415_p/0.78Ctt33sFalsef.png +++ b/data/CLs/plots/p4415_p/0.78Ctt33sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4415_p/0.80Ctt34sTruef.png b/data/CLs/plots/p4415_p/0.80Ctt34sTruef.png index 53fd4cd..4b6d90c 100644 --- a/data/CLs/plots/p4415_p/0.80Ctt34sTruef.png +++ b/data/CLs/plots/p4415_p/0.80Ctt34sTruef.png Binary files differ diff --git a/data/CLs/plots/p4415_p/0.80Ctt35sFalsef.png b/data/CLs/plots/p4415_p/0.80Ctt35sFalsef.png index 4d372de..5687db4 100644 --- a/data/CLs/plots/p4415_p/0.80Ctt35sFalsef.png +++ b/data/CLs/plots/p4415_p/0.80Ctt35sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4415_p/0.82Ctt36sTruef.png b/data/CLs/plots/p4415_p/0.82Ctt36sTruef.png index 37bb325..b9af359 100644 --- a/data/CLs/plots/p4415_p/0.82Ctt36sTruef.png +++ b/data/CLs/plots/p4415_p/0.82Ctt36sTruef.png Binary files differ diff --git a/data/CLs/plots/p4415_p/0.82Ctt37sFalsef.png b/data/CLs/plots/p4415_p/0.82Ctt37sFalsef.png index 4da0968..a83ec44 100644 --- a/data/CLs/plots/p4415_p/0.82Ctt37sFalsef.png +++ b/data/CLs/plots/p4415_p/0.82Ctt37sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4415_p/0.85Ctt38sTruef.png b/data/CLs/plots/p4415_p/0.85Ctt38sTruef.png index 1011620..4dfaefb 100644 --- a/data/CLs/plots/p4415_p/0.85Ctt38sTruef.png +++ b/data/CLs/plots/p4415_p/0.85Ctt38sTruef.png Binary files differ diff --git a/data/CLs/plots/p4415_p/0.85Ctt39sFalsef.png b/data/CLs/plots/p4415_p/0.85Ctt39sFalsef.png index 4c5903e..cceaf21 100644 --- a/data/CLs/plots/p4415_p/0.85Ctt39sFalsef.png +++ b/data/CLs/plots/p4415_p/0.85Ctt39sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4415_s/0.00Ctt0sTruef.png b/data/CLs/plots/p4415_s/0.00Ctt0sTruef.png index f269f75..9cde182 100644 --- a/data/CLs/plots/p4415_s/0.00Ctt0sTruef.png +++ b/data/CLs/plots/p4415_s/0.00Ctt0sTruef.png Binary files differ diff --git a/data/CLs/plots/p4415_s/0.00Ctt1sFalsef.png b/data/CLs/plots/p4415_s/0.00Ctt1sFalsef.png index 3b3072c..1137931 100644 --- a/data/CLs/plots/p4415_s/0.00Ctt1sFalsef.png +++ b/data/CLs/plots/p4415_s/0.00Ctt1sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4415_s/0.25Ctt2sTruef.png b/data/CLs/plots/p4415_s/0.25Ctt2sTruef.png index 6b9759a..509afed 100644 --- a/data/CLs/plots/p4415_s/0.25Ctt2sTruef.png +++ b/data/CLs/plots/p4415_s/0.25Ctt2sTruef.png Binary files differ diff --git a/data/CLs/plots/p4415_s/0.25Ctt3sFalsef.png b/data/CLs/plots/p4415_s/0.25Ctt3sFalsef.png index 37d3f2e..5e2cabf 100644 --- a/data/CLs/plots/p4415_s/0.25Ctt3sFalsef.png +++ b/data/CLs/plots/p4415_s/0.25Ctt3sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4415_s/0.31Ctt4sTruef.png b/data/CLs/plots/p4415_s/0.31Ctt4sTruef.png index 0e864a8..dd6875d 100644 --- a/data/CLs/plots/p4415_s/0.31Ctt4sTruef.png +++ b/data/CLs/plots/p4415_s/0.31Ctt4sTruef.png Binary files differ diff --git a/data/CLs/plots/p4415_s/0.31Ctt5sFalsef.png b/data/CLs/plots/p4415_s/0.31Ctt5sFalsef.png index 425c7f7..9ea810e 100644 --- a/data/CLs/plots/p4415_s/0.31Ctt5sFalsef.png +++ b/data/CLs/plots/p4415_s/0.31Ctt5sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4415_s/0.36Ctt6sTruef.png b/data/CLs/plots/p4415_s/0.36Ctt6sTruef.png index 08ea1f2..3413544 100644 --- a/data/CLs/plots/p4415_s/0.36Ctt6sTruef.png +++ b/data/CLs/plots/p4415_s/0.36Ctt6sTruef.png Binary files differ diff --git a/data/CLs/plots/p4415_s/0.36Ctt7sFalsef.png b/data/CLs/plots/p4415_s/0.36Ctt7sFalsef.png index 1c0103f..0de7ac5 100644 --- a/data/CLs/plots/p4415_s/0.36Ctt7sFalsef.png +++ b/data/CLs/plots/p4415_s/0.36Ctt7sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4415_s/0.41Ctt8sTruef.png b/data/CLs/plots/p4415_s/0.41Ctt8sTruef.png index eb936ea..3a268fd 100644 --- a/data/CLs/plots/p4415_s/0.41Ctt8sTruef.png +++ b/data/CLs/plots/p4415_s/0.41Ctt8sTruef.png Binary files differ diff --git a/data/CLs/plots/p4415_s/0.41Ctt9sFalsef.png b/data/CLs/plots/p4415_s/0.41Ctt9sFalsef.png index 055c744..007f1f9 100644 --- a/data/CLs/plots/p4415_s/0.41Ctt9sFalsef.png +++ b/data/CLs/plots/p4415_s/0.41Ctt9sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4415_s/0.45Ctt10sTruef.png b/data/CLs/plots/p4415_s/0.45Ctt10sTruef.png index cdfda27..4621871 100644 --- a/data/CLs/plots/p4415_s/0.45Ctt10sTruef.png +++ b/data/CLs/plots/p4415_s/0.45Ctt10sTruef.png Binary files differ diff --git a/data/CLs/plots/p4415_s/0.45Ctt11sFalsef.png b/data/CLs/plots/p4415_s/0.45Ctt11sFalsef.png index b597baf..60ee8ff 100644 --- a/data/CLs/plots/p4415_s/0.45Ctt11sFalsef.png +++ b/data/CLs/plots/p4415_s/0.45Ctt11sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4415_s/0.49Ctt12sTruef.png b/data/CLs/plots/p4415_s/0.49Ctt12sTruef.png index 435feff..be5d7bb 100644 --- a/data/CLs/plots/p4415_s/0.49Ctt12sTruef.png +++ b/data/CLs/plots/p4415_s/0.49Ctt12sTruef.png Binary files differ diff --git a/data/CLs/plots/p4415_s/0.49Ctt13sFalsef.png b/data/CLs/plots/p4415_s/0.49Ctt13sFalsef.png index 4030b4e..c5157d8 100644 --- a/data/CLs/plots/p4415_s/0.49Ctt13sFalsef.png +++ b/data/CLs/plots/p4415_s/0.49Ctt13sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4415_s/0.53Ctt14sTruef.png b/data/CLs/plots/p4415_s/0.53Ctt14sTruef.png index 1445a11..bc632e4 100644 --- a/data/CLs/plots/p4415_s/0.53Ctt14sTruef.png +++ b/data/CLs/plots/p4415_s/0.53Ctt14sTruef.png Binary files differ diff --git a/data/CLs/plots/p4415_s/0.53Ctt15sFalsef.png b/data/CLs/plots/p4415_s/0.53Ctt15sFalsef.png index fa9481c..e9532f7 100644 --- a/data/CLs/plots/p4415_s/0.53Ctt15sFalsef.png +++ b/data/CLs/plots/p4415_s/0.53Ctt15sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4415_s/0.56Ctt16sTruef.png b/data/CLs/plots/p4415_s/0.56Ctt16sTruef.png index dd6246a..d1af6a6 100644 --- a/data/CLs/plots/p4415_s/0.56Ctt16sTruef.png +++ b/data/CLs/plots/p4415_s/0.56Ctt16sTruef.png Binary files differ diff --git a/data/CLs/plots/p4415_s/0.56Ctt17sFalsef.png b/data/CLs/plots/p4415_s/0.56Ctt17sFalsef.png index 8ed877e..20de75f 100644 --- a/data/CLs/plots/p4415_s/0.56Ctt17sFalsef.png +++ b/data/CLs/plots/p4415_s/0.56Ctt17sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4415_s/0.59Ctt18sTruef.png b/data/CLs/plots/p4415_s/0.59Ctt18sTruef.png index d347db9..1f04571 100644 --- a/data/CLs/plots/p4415_s/0.59Ctt18sTruef.png +++ b/data/CLs/plots/p4415_s/0.59Ctt18sTruef.png Binary files differ diff --git a/data/CLs/plots/p4415_s/0.59Ctt19sFalsef.png b/data/CLs/plots/p4415_s/0.59Ctt19sFalsef.png index a37dc55..b41b6f9 100644 --- a/data/CLs/plots/p4415_s/0.59Ctt19sFalsef.png +++ b/data/CLs/plots/p4415_s/0.59Ctt19sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4415_s/0.62Ctt20sTruef.png b/data/CLs/plots/p4415_s/0.62Ctt20sTruef.png index 13dbe85..d523b51 100644 --- a/data/CLs/plots/p4415_s/0.62Ctt20sTruef.png +++ b/data/CLs/plots/p4415_s/0.62Ctt20sTruef.png Binary files differ diff --git a/data/CLs/plots/p4415_s/0.62Ctt21sFalsef.png b/data/CLs/plots/p4415_s/0.62Ctt21sFalsef.png index 33aeaf9..d9239fc 100644 --- a/data/CLs/plots/p4415_s/0.62Ctt21sFalsef.png +++ b/data/CLs/plots/p4415_s/0.62Ctt21sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4415_s/0.65Ctt22sTruef.png b/data/CLs/plots/p4415_s/0.65Ctt22sTruef.png index 613fafa..ce54de8 100644 --- a/data/CLs/plots/p4415_s/0.65Ctt22sTruef.png +++ b/data/CLs/plots/p4415_s/0.65Ctt22sTruef.png Binary files differ diff --git a/data/CLs/plots/p4415_s/0.65Ctt23sFalsef.png b/data/CLs/plots/p4415_s/0.65Ctt23sFalsef.png index 76fe28f..bda8293 100644 --- a/data/CLs/plots/p4415_s/0.65Ctt23sFalsef.png +++ b/data/CLs/plots/p4415_s/0.65Ctt23sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4415_s/0.68Ctt24sTruef.png b/data/CLs/plots/p4415_s/0.68Ctt24sTruef.png index a24bb30..ac8b126 100644 --- a/data/CLs/plots/p4415_s/0.68Ctt24sTruef.png +++ b/data/CLs/plots/p4415_s/0.68Ctt24sTruef.png Binary files differ diff --git a/data/CLs/plots/p4415_s/0.68Ctt25sFalsef.png b/data/CLs/plots/p4415_s/0.68Ctt25sFalsef.png index 668ce24..411efd8 100644 --- a/data/CLs/plots/p4415_s/0.68Ctt25sFalsef.png +++ b/data/CLs/plots/p4415_s/0.68Ctt25sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4415_s/0.70Ctt26sTruef.png b/data/CLs/plots/p4415_s/0.70Ctt26sTruef.png index 78b48d9..747cb8b 100644 --- a/data/CLs/plots/p4415_s/0.70Ctt26sTruef.png +++ b/data/CLs/plots/p4415_s/0.70Ctt26sTruef.png Binary files differ diff --git a/data/CLs/plots/p4415_s/0.70Ctt27sFalsef.png b/data/CLs/plots/p4415_s/0.70Ctt27sFalsef.png index 86838ae..be533c1 100644 --- a/data/CLs/plots/p4415_s/0.70Ctt27sFalsef.png +++ b/data/CLs/plots/p4415_s/0.70Ctt27sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4415_s/0.73Ctt28sTruef.png b/data/CLs/plots/p4415_s/0.73Ctt28sTruef.png index 6e3df88..48d938b 100644 --- a/data/CLs/plots/p4415_s/0.73Ctt28sTruef.png +++ b/data/CLs/plots/p4415_s/0.73Ctt28sTruef.png Binary files differ diff --git a/data/CLs/plots/p4415_s/0.73Ctt29sFalsef.png b/data/CLs/plots/p4415_s/0.73Ctt29sFalsef.png index 91abd52..03ca0a0 100644 --- a/data/CLs/plots/p4415_s/0.73Ctt29sFalsef.png +++ b/data/CLs/plots/p4415_s/0.73Ctt29sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4415_s/0.75Ctt30sTruef.png b/data/CLs/plots/p4415_s/0.75Ctt30sTruef.png index ea82e46..5b96c2b 100644 --- a/data/CLs/plots/p4415_s/0.75Ctt30sTruef.png +++ b/data/CLs/plots/p4415_s/0.75Ctt30sTruef.png Binary files differ diff --git a/data/CLs/plots/p4415_s/0.75Ctt31sFalsef.png b/data/CLs/plots/p4415_s/0.75Ctt31sFalsef.png index 53c323d..3fcdc7e 100644 --- a/data/CLs/plots/p4415_s/0.75Ctt31sFalsef.png +++ b/data/CLs/plots/p4415_s/0.75Ctt31sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4415_s/0.78Ctt32sTruef.png b/data/CLs/plots/p4415_s/0.78Ctt32sTruef.png index ab31e4d..98c43ae 100644 --- a/data/CLs/plots/p4415_s/0.78Ctt32sTruef.png +++ b/data/CLs/plots/p4415_s/0.78Ctt32sTruef.png Binary files differ diff --git a/data/CLs/plots/p4415_s/0.78Ctt33sFalsef.png b/data/CLs/plots/p4415_s/0.78Ctt33sFalsef.png index 914113f..b4893d6 100644 --- a/data/CLs/plots/p4415_s/0.78Ctt33sFalsef.png +++ b/data/CLs/plots/p4415_s/0.78Ctt33sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4415_s/0.80Ctt34sTruef.png b/data/CLs/plots/p4415_s/0.80Ctt34sTruef.png index 65ae83e..68ab814 100644 --- a/data/CLs/plots/p4415_s/0.80Ctt34sTruef.png +++ b/data/CLs/plots/p4415_s/0.80Ctt34sTruef.png Binary files differ diff --git a/data/CLs/plots/p4415_s/0.80Ctt35sFalsef.png b/data/CLs/plots/p4415_s/0.80Ctt35sFalsef.png index ffc22d3..53e9da0 100644 --- a/data/CLs/plots/p4415_s/0.80Ctt35sFalsef.png +++ b/data/CLs/plots/p4415_s/0.80Ctt35sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4415_s/0.82Ctt36sTruef.png b/data/CLs/plots/p4415_s/0.82Ctt36sTruef.png index 7906a92..4184f37 100644 --- a/data/CLs/plots/p4415_s/0.82Ctt36sTruef.png +++ b/data/CLs/plots/p4415_s/0.82Ctt36sTruef.png Binary files differ diff --git a/data/CLs/plots/p4415_s/0.82Ctt37sFalsef.png b/data/CLs/plots/p4415_s/0.82Ctt37sFalsef.png index 9d357b0..592a7c7 100644 --- a/data/CLs/plots/p4415_s/0.82Ctt37sFalsef.png +++ b/data/CLs/plots/p4415_s/0.82Ctt37sFalsef.png Binary files differ diff --git a/data/CLs/plots/p4415_s/0.85Ctt38sTruef.png b/data/CLs/plots/p4415_s/0.85Ctt38sTruef.png index 6068633..399767c 100644 --- a/data/CLs/plots/p4415_s/0.85Ctt38sTruef.png +++ b/data/CLs/plots/p4415_s/0.85Ctt38sTruef.png Binary files differ diff --git a/data/CLs/plots/p4415_s/0.85Ctt39sFalsef.png b/data/CLs/plots/p4415_s/0.85Ctt39sFalsef.png index eea14e2..2730be8 100644 --- a/data/CLs/plots/p4415_s/0.85Ctt39sFalsef.png +++ b/data/CLs/plots/p4415_s/0.85Ctt39sFalsef.png Binary files differ diff --git a/data/CLs/plots/phi_p/0.00Ctt0sTruef.png b/data/CLs/plots/phi_p/0.00Ctt0sTruef.png index 9ac4efc..fb3e7d6 100644 --- a/data/CLs/plots/phi_p/0.00Ctt0sTruef.png +++ b/data/CLs/plots/phi_p/0.00Ctt0sTruef.png Binary files differ diff --git a/data/CLs/plots/phi_p/0.00Ctt1sFalsef.png b/data/CLs/plots/phi_p/0.00Ctt1sFalsef.png index 4779c34..ad7cc25 100644 --- a/data/CLs/plots/phi_p/0.00Ctt1sFalsef.png +++ b/data/CLs/plots/phi_p/0.00Ctt1sFalsef.png Binary files differ diff --git a/data/CLs/plots/phi_p/0.25Ctt2sTruef.png b/data/CLs/plots/phi_p/0.25Ctt2sTruef.png index 234f6f0..f6ebd8a 100644 --- a/data/CLs/plots/phi_p/0.25Ctt2sTruef.png +++ b/data/CLs/plots/phi_p/0.25Ctt2sTruef.png Binary files differ diff --git a/data/CLs/plots/phi_p/0.25Ctt3sFalsef.png b/data/CLs/plots/phi_p/0.25Ctt3sFalsef.png index 1969b7c..2e56882 100644 --- a/data/CLs/plots/phi_p/0.25Ctt3sFalsef.png +++ b/data/CLs/plots/phi_p/0.25Ctt3sFalsef.png Binary files differ diff --git a/data/CLs/plots/phi_p/0.31Ctt4sTruef.png b/data/CLs/plots/phi_p/0.31Ctt4sTruef.png index 98fc7a9..5fcd781 100644 --- a/data/CLs/plots/phi_p/0.31Ctt4sTruef.png +++ b/data/CLs/plots/phi_p/0.31Ctt4sTruef.png Binary files differ diff --git a/data/CLs/plots/phi_p/0.31Ctt5sFalsef.png b/data/CLs/plots/phi_p/0.31Ctt5sFalsef.png index 10ef717..7e025e7 100644 --- a/data/CLs/plots/phi_p/0.31Ctt5sFalsef.png +++ b/data/CLs/plots/phi_p/0.31Ctt5sFalsef.png Binary files differ diff --git a/data/CLs/plots/phi_p/0.36Ctt6sTruef.png b/data/CLs/plots/phi_p/0.36Ctt6sTruef.png index 4c4d3e3..4212eb6 100644 --- a/data/CLs/plots/phi_p/0.36Ctt6sTruef.png +++ b/data/CLs/plots/phi_p/0.36Ctt6sTruef.png Binary files differ diff --git a/data/CLs/plots/phi_p/0.36Ctt7sFalsef.png b/data/CLs/plots/phi_p/0.36Ctt7sFalsef.png index eca1501..ef9da4a 100644 --- a/data/CLs/plots/phi_p/0.36Ctt7sFalsef.png +++ b/data/CLs/plots/phi_p/0.36Ctt7sFalsef.png Binary files differ diff --git a/data/CLs/plots/phi_p/0.41Ctt8sTruef.png b/data/CLs/plots/phi_p/0.41Ctt8sTruef.png index 1e9d08a..4655699 100644 --- a/data/CLs/plots/phi_p/0.41Ctt8sTruef.png +++ b/data/CLs/plots/phi_p/0.41Ctt8sTruef.png Binary files differ diff --git a/data/CLs/plots/phi_p/0.41Ctt9sFalsef.png b/data/CLs/plots/phi_p/0.41Ctt9sFalsef.png index 71808e4..ee67880 100644 --- a/data/CLs/plots/phi_p/0.41Ctt9sFalsef.png +++ b/data/CLs/plots/phi_p/0.41Ctt9sFalsef.png Binary files differ diff --git a/data/CLs/plots/phi_p/0.45Ctt10sTruef.png b/data/CLs/plots/phi_p/0.45Ctt10sTruef.png index 41df96c..b7b07e2 100644 --- a/data/CLs/plots/phi_p/0.45Ctt10sTruef.png +++ b/data/CLs/plots/phi_p/0.45Ctt10sTruef.png Binary files differ diff --git a/data/CLs/plots/phi_p/0.45Ctt11sFalsef.png b/data/CLs/plots/phi_p/0.45Ctt11sFalsef.png index dfc19c2..beda386 100644 --- a/data/CLs/plots/phi_p/0.45Ctt11sFalsef.png +++ b/data/CLs/plots/phi_p/0.45Ctt11sFalsef.png Binary files differ diff --git a/data/CLs/plots/phi_p/0.49Ctt12sTruef.png b/data/CLs/plots/phi_p/0.49Ctt12sTruef.png index e96eb86..aef41db 100644 --- a/data/CLs/plots/phi_p/0.49Ctt12sTruef.png +++ b/data/CLs/plots/phi_p/0.49Ctt12sTruef.png Binary files differ diff --git a/data/CLs/plots/phi_p/0.49Ctt13sFalsef.png b/data/CLs/plots/phi_p/0.49Ctt13sFalsef.png index fe9b545..8ee46f3 100644 --- a/data/CLs/plots/phi_p/0.49Ctt13sFalsef.png +++ b/data/CLs/plots/phi_p/0.49Ctt13sFalsef.png Binary files differ diff --git a/data/CLs/plots/phi_p/0.53Ctt14sTruef.png b/data/CLs/plots/phi_p/0.53Ctt14sTruef.png index 786a59d..0b58c45 100644 --- a/data/CLs/plots/phi_p/0.53Ctt14sTruef.png +++ b/data/CLs/plots/phi_p/0.53Ctt14sTruef.png Binary files differ diff --git a/data/CLs/plots/phi_p/0.53Ctt15sFalsef.png b/data/CLs/plots/phi_p/0.53Ctt15sFalsef.png index 564b5d9..292b024 100644 --- a/data/CLs/plots/phi_p/0.53Ctt15sFalsef.png +++ b/data/CLs/plots/phi_p/0.53Ctt15sFalsef.png Binary files differ diff --git a/data/CLs/plots/phi_p/0.56Ctt16sTruef.png b/data/CLs/plots/phi_p/0.56Ctt16sTruef.png index af40418..3e6896b 100644 --- a/data/CLs/plots/phi_p/0.56Ctt16sTruef.png +++ b/data/CLs/plots/phi_p/0.56Ctt16sTruef.png Binary files differ diff --git a/data/CLs/plots/phi_p/0.56Ctt17sFalsef.png b/data/CLs/plots/phi_p/0.56Ctt17sFalsef.png index aacdad9..2c9cee8 100644 --- a/data/CLs/plots/phi_p/0.56Ctt17sFalsef.png +++ b/data/CLs/plots/phi_p/0.56Ctt17sFalsef.png Binary files differ diff --git a/data/CLs/plots/phi_p/0.59Ctt18sTruef.png b/data/CLs/plots/phi_p/0.59Ctt18sTruef.png index e87c3e8..9f20bb3 100644 --- a/data/CLs/plots/phi_p/0.59Ctt18sTruef.png +++ b/data/CLs/plots/phi_p/0.59Ctt18sTruef.png Binary files differ diff --git a/data/CLs/plots/phi_p/0.59Ctt19sFalsef.png b/data/CLs/plots/phi_p/0.59Ctt19sFalsef.png index a4dabcc..6302c0b 100644 --- a/data/CLs/plots/phi_p/0.59Ctt19sFalsef.png +++ b/data/CLs/plots/phi_p/0.59Ctt19sFalsef.png Binary files differ diff --git a/data/CLs/plots/phi_p/0.62Ctt20sTruef.png b/data/CLs/plots/phi_p/0.62Ctt20sTruef.png index dd4724a..f7354a1 100644 --- a/data/CLs/plots/phi_p/0.62Ctt20sTruef.png +++ b/data/CLs/plots/phi_p/0.62Ctt20sTruef.png Binary files differ diff --git a/data/CLs/plots/phi_p/0.62Ctt21sFalsef.png b/data/CLs/plots/phi_p/0.62Ctt21sFalsef.png index 35a4334..dffc526 100644 --- a/data/CLs/plots/phi_p/0.62Ctt21sFalsef.png +++ b/data/CLs/plots/phi_p/0.62Ctt21sFalsef.png Binary files differ diff --git a/data/CLs/plots/phi_p/0.65Ctt22sTruef.png b/data/CLs/plots/phi_p/0.65Ctt22sTruef.png index c95617d..5765d3d 100644 --- a/data/CLs/plots/phi_p/0.65Ctt22sTruef.png +++ b/data/CLs/plots/phi_p/0.65Ctt22sTruef.png Binary files differ diff --git a/data/CLs/plots/phi_p/0.65Ctt23sFalsef.png b/data/CLs/plots/phi_p/0.65Ctt23sFalsef.png index b640d12..0d1caee 100644 --- a/data/CLs/plots/phi_p/0.65Ctt23sFalsef.png +++ b/data/CLs/plots/phi_p/0.65Ctt23sFalsef.png Binary files differ diff --git a/data/CLs/plots/phi_p/0.68Ctt24sTruef.png b/data/CLs/plots/phi_p/0.68Ctt24sTruef.png index 54521bc..6560d41 100644 --- a/data/CLs/plots/phi_p/0.68Ctt24sTruef.png +++ b/data/CLs/plots/phi_p/0.68Ctt24sTruef.png Binary files differ diff --git a/data/CLs/plots/phi_p/0.68Ctt25sFalsef.png b/data/CLs/plots/phi_p/0.68Ctt25sFalsef.png index ad30afb..1454411 100644 --- a/data/CLs/plots/phi_p/0.68Ctt25sFalsef.png +++ b/data/CLs/plots/phi_p/0.68Ctt25sFalsef.png Binary files differ diff --git a/data/CLs/plots/phi_p/0.70Ctt26sTruef.png b/data/CLs/plots/phi_p/0.70Ctt26sTruef.png index 4e724e7..6cd185d 100644 --- a/data/CLs/plots/phi_p/0.70Ctt26sTruef.png +++ b/data/CLs/plots/phi_p/0.70Ctt26sTruef.png Binary files differ diff --git a/data/CLs/plots/phi_p/0.70Ctt27sFalsef.png b/data/CLs/plots/phi_p/0.70Ctt27sFalsef.png index daaa714..a0b8bab 100644 --- a/data/CLs/plots/phi_p/0.70Ctt27sFalsef.png +++ b/data/CLs/plots/phi_p/0.70Ctt27sFalsef.png Binary files differ diff --git a/data/CLs/plots/phi_p/0.73Ctt28sTruef.png b/data/CLs/plots/phi_p/0.73Ctt28sTruef.png index edc1c9d..785c04a 100644 --- a/data/CLs/plots/phi_p/0.73Ctt28sTruef.png +++ b/data/CLs/plots/phi_p/0.73Ctt28sTruef.png Binary files differ diff --git a/data/CLs/plots/phi_p/0.73Ctt29sFalsef.png b/data/CLs/plots/phi_p/0.73Ctt29sFalsef.png index e9acafc..9311e9e 100644 --- a/data/CLs/plots/phi_p/0.73Ctt29sFalsef.png +++ b/data/CLs/plots/phi_p/0.73Ctt29sFalsef.png Binary files differ diff --git a/data/CLs/plots/phi_p/0.75Ctt30sTruef.png b/data/CLs/plots/phi_p/0.75Ctt30sTruef.png index e9a7006..e4af94d 100644 --- a/data/CLs/plots/phi_p/0.75Ctt30sTruef.png +++ b/data/CLs/plots/phi_p/0.75Ctt30sTruef.png Binary files differ diff --git a/data/CLs/plots/phi_p/0.75Ctt31sFalsef.png b/data/CLs/plots/phi_p/0.75Ctt31sFalsef.png index 7d2be87..3d5c3ea 100644 --- a/data/CLs/plots/phi_p/0.75Ctt31sFalsef.png +++ b/data/CLs/plots/phi_p/0.75Ctt31sFalsef.png Binary files differ diff --git a/data/CLs/plots/phi_p/0.78Ctt32sTruef.png b/data/CLs/plots/phi_p/0.78Ctt32sTruef.png index 3a1aef6..54bb004 100644 --- a/data/CLs/plots/phi_p/0.78Ctt32sTruef.png +++ b/data/CLs/plots/phi_p/0.78Ctt32sTruef.png Binary files differ diff --git a/data/CLs/plots/phi_p/0.78Ctt33sFalsef.png b/data/CLs/plots/phi_p/0.78Ctt33sFalsef.png index f3e00f2..528e574 100644 --- a/data/CLs/plots/phi_p/0.78Ctt33sFalsef.png +++ b/data/CLs/plots/phi_p/0.78Ctt33sFalsef.png Binary files differ diff --git a/data/CLs/plots/phi_p/0.80Ctt34sTruef.png b/data/CLs/plots/phi_p/0.80Ctt34sTruef.png index c9a2a4b..ea123db 100644 --- a/data/CLs/plots/phi_p/0.80Ctt34sTruef.png +++ b/data/CLs/plots/phi_p/0.80Ctt34sTruef.png Binary files differ diff --git a/data/CLs/plots/phi_p/0.80Ctt35sFalsef.png b/data/CLs/plots/phi_p/0.80Ctt35sFalsef.png index f1f6059..a0d0a71 100644 --- a/data/CLs/plots/phi_p/0.80Ctt35sFalsef.png +++ b/data/CLs/plots/phi_p/0.80Ctt35sFalsef.png Binary files differ diff --git a/data/CLs/plots/phi_p/0.82Ctt36sTruef.png b/data/CLs/plots/phi_p/0.82Ctt36sTruef.png index f8bd649..40895c3 100644 --- a/data/CLs/plots/phi_p/0.82Ctt36sTruef.png +++ b/data/CLs/plots/phi_p/0.82Ctt36sTruef.png Binary files differ diff --git a/data/CLs/plots/phi_p/0.82Ctt37sFalsef.png b/data/CLs/plots/phi_p/0.82Ctt37sFalsef.png index e8dba58..db3a122 100644 --- a/data/CLs/plots/phi_p/0.82Ctt37sFalsef.png +++ b/data/CLs/plots/phi_p/0.82Ctt37sFalsef.png Binary files differ diff --git a/data/CLs/plots/phi_p/0.85Ctt38sTruef.png b/data/CLs/plots/phi_p/0.85Ctt38sTruef.png index 2fcb959..cdac198 100644 --- a/data/CLs/plots/phi_p/0.85Ctt38sTruef.png +++ b/data/CLs/plots/phi_p/0.85Ctt38sTruef.png Binary files differ diff --git a/data/CLs/plots/phi_p/0.85Ctt39sFalsef.png b/data/CLs/plots/phi_p/0.85Ctt39sFalsef.png index 636ec55..093cff8 100644 --- a/data/CLs/plots/phi_p/0.85Ctt39sFalsef.png +++ b/data/CLs/plots/phi_p/0.85Ctt39sFalsef.png Binary files differ diff --git a/data/CLs/plots/phi_s/0.00Ctt0sTruef.png b/data/CLs/plots/phi_s/0.00Ctt0sTruef.png index 7ef15d4..2815da4 100644 --- a/data/CLs/plots/phi_s/0.00Ctt0sTruef.png +++ b/data/CLs/plots/phi_s/0.00Ctt0sTruef.png Binary files differ diff --git a/data/CLs/plots/phi_s/0.00Ctt1sFalsef.png b/data/CLs/plots/phi_s/0.00Ctt1sFalsef.png index b594c5b..04206fa 100644 --- a/data/CLs/plots/phi_s/0.00Ctt1sFalsef.png +++ b/data/CLs/plots/phi_s/0.00Ctt1sFalsef.png Binary files differ diff --git a/data/CLs/plots/phi_s/0.25Ctt2sTruef.png b/data/CLs/plots/phi_s/0.25Ctt2sTruef.png index 5081c7d..c8d8585 100644 --- a/data/CLs/plots/phi_s/0.25Ctt2sTruef.png +++ b/data/CLs/plots/phi_s/0.25Ctt2sTruef.png Binary files differ diff --git a/data/CLs/plots/phi_s/0.25Ctt3sFalsef.png b/data/CLs/plots/phi_s/0.25Ctt3sFalsef.png index 2e49390..19ab938 100644 --- a/data/CLs/plots/phi_s/0.25Ctt3sFalsef.png +++ b/data/CLs/plots/phi_s/0.25Ctt3sFalsef.png Binary files differ diff --git a/data/CLs/plots/phi_s/0.31Ctt4sTruef.png b/data/CLs/plots/phi_s/0.31Ctt4sTruef.png index 154f86e..f3cc5fb 100644 --- a/data/CLs/plots/phi_s/0.31Ctt4sTruef.png +++ b/data/CLs/plots/phi_s/0.31Ctt4sTruef.png Binary files differ diff --git a/data/CLs/plots/phi_s/0.31Ctt5sFalsef.png b/data/CLs/plots/phi_s/0.31Ctt5sFalsef.png index b8046f5..467485b 100644 --- a/data/CLs/plots/phi_s/0.31Ctt5sFalsef.png +++ b/data/CLs/plots/phi_s/0.31Ctt5sFalsef.png Binary files differ diff --git a/data/CLs/plots/phi_s/0.36Ctt6sTruef.png b/data/CLs/plots/phi_s/0.36Ctt6sTruef.png index 7fecba8..135298b 100644 --- a/data/CLs/plots/phi_s/0.36Ctt6sTruef.png +++ b/data/CLs/plots/phi_s/0.36Ctt6sTruef.png Binary files differ diff --git a/data/CLs/plots/phi_s/0.36Ctt7sFalsef.png b/data/CLs/plots/phi_s/0.36Ctt7sFalsef.png index 1f93394..1371e3d 100644 --- a/data/CLs/plots/phi_s/0.36Ctt7sFalsef.png +++ b/data/CLs/plots/phi_s/0.36Ctt7sFalsef.png Binary files differ diff --git a/data/CLs/plots/phi_s/0.41Ctt8sTruef.png b/data/CLs/plots/phi_s/0.41Ctt8sTruef.png index a5a8343..0cb19e4 100644 --- a/data/CLs/plots/phi_s/0.41Ctt8sTruef.png +++ b/data/CLs/plots/phi_s/0.41Ctt8sTruef.png Binary files differ diff --git a/data/CLs/plots/phi_s/0.41Ctt9sFalsef.png b/data/CLs/plots/phi_s/0.41Ctt9sFalsef.png index cdebe50..4e14868 100644 --- a/data/CLs/plots/phi_s/0.41Ctt9sFalsef.png +++ b/data/CLs/plots/phi_s/0.41Ctt9sFalsef.png Binary files differ diff --git a/data/CLs/plots/phi_s/0.45Ctt10sTruef.png b/data/CLs/plots/phi_s/0.45Ctt10sTruef.png index 88e82e7..2ea5c42 100644 --- a/data/CLs/plots/phi_s/0.45Ctt10sTruef.png +++ b/data/CLs/plots/phi_s/0.45Ctt10sTruef.png Binary files differ diff --git a/data/CLs/plots/phi_s/0.45Ctt11sFalsef.png b/data/CLs/plots/phi_s/0.45Ctt11sFalsef.png index 49ecbf1..f4d3076 100644 --- a/data/CLs/plots/phi_s/0.45Ctt11sFalsef.png +++ b/data/CLs/plots/phi_s/0.45Ctt11sFalsef.png Binary files differ diff --git a/data/CLs/plots/phi_s/0.49Ctt12sTruef.png b/data/CLs/plots/phi_s/0.49Ctt12sTruef.png index bb419d0..3368c81 100644 --- a/data/CLs/plots/phi_s/0.49Ctt12sTruef.png +++ b/data/CLs/plots/phi_s/0.49Ctt12sTruef.png Binary files differ diff --git a/data/CLs/plots/phi_s/0.49Ctt13sFalsef.png b/data/CLs/plots/phi_s/0.49Ctt13sFalsef.png index 1953d98..5591af3 100644 --- a/data/CLs/plots/phi_s/0.49Ctt13sFalsef.png +++ b/data/CLs/plots/phi_s/0.49Ctt13sFalsef.png Binary files differ diff --git a/data/CLs/plots/phi_s/0.53Ctt14sTruef.png b/data/CLs/plots/phi_s/0.53Ctt14sTruef.png index d4e162e..5d9d5f4 100644 --- a/data/CLs/plots/phi_s/0.53Ctt14sTruef.png +++ b/data/CLs/plots/phi_s/0.53Ctt14sTruef.png Binary files differ diff --git a/data/CLs/plots/phi_s/0.53Ctt15sFalsef.png b/data/CLs/plots/phi_s/0.53Ctt15sFalsef.png index ff8f134..88a123f 100644 --- a/data/CLs/plots/phi_s/0.53Ctt15sFalsef.png +++ b/data/CLs/plots/phi_s/0.53Ctt15sFalsef.png Binary files differ diff --git a/data/CLs/plots/phi_s/0.56Ctt16sTruef.png b/data/CLs/plots/phi_s/0.56Ctt16sTruef.png index 3f3579d..492fda9 100644 --- a/data/CLs/plots/phi_s/0.56Ctt16sTruef.png +++ b/data/CLs/plots/phi_s/0.56Ctt16sTruef.png Binary files differ diff --git a/data/CLs/plots/phi_s/0.56Ctt17sFalsef.png b/data/CLs/plots/phi_s/0.56Ctt17sFalsef.png index 8b7b810..65b57e4 100644 --- a/data/CLs/plots/phi_s/0.56Ctt17sFalsef.png +++ b/data/CLs/plots/phi_s/0.56Ctt17sFalsef.png Binary files differ diff --git a/data/CLs/plots/phi_s/0.59Ctt18sTruef.png b/data/CLs/plots/phi_s/0.59Ctt18sTruef.png index 48fd8fd..c15a749 100644 --- a/data/CLs/plots/phi_s/0.59Ctt18sTruef.png +++ b/data/CLs/plots/phi_s/0.59Ctt18sTruef.png Binary files differ diff --git a/data/CLs/plots/phi_s/0.59Ctt19sFalsef.png b/data/CLs/plots/phi_s/0.59Ctt19sFalsef.png index 2b0c072..a342893 100644 --- a/data/CLs/plots/phi_s/0.59Ctt19sFalsef.png +++ b/data/CLs/plots/phi_s/0.59Ctt19sFalsef.png Binary files differ diff --git a/data/CLs/plots/phi_s/0.62Ctt20sTruef.png b/data/CLs/plots/phi_s/0.62Ctt20sTruef.png index 018a01c..02fcbef 100644 --- a/data/CLs/plots/phi_s/0.62Ctt20sTruef.png +++ b/data/CLs/plots/phi_s/0.62Ctt20sTruef.png Binary files differ diff --git a/data/CLs/plots/phi_s/0.62Ctt21sFalsef.png b/data/CLs/plots/phi_s/0.62Ctt21sFalsef.png index 6e734d1..4eb303f 100644 --- a/data/CLs/plots/phi_s/0.62Ctt21sFalsef.png +++ b/data/CLs/plots/phi_s/0.62Ctt21sFalsef.png Binary files differ diff --git a/data/CLs/plots/phi_s/0.65Ctt22sTruef.png b/data/CLs/plots/phi_s/0.65Ctt22sTruef.png index 2bf32e9..31f4496 100644 --- a/data/CLs/plots/phi_s/0.65Ctt22sTruef.png +++ b/data/CLs/plots/phi_s/0.65Ctt22sTruef.png Binary files differ diff --git a/data/CLs/plots/phi_s/0.65Ctt23sFalsef.png b/data/CLs/plots/phi_s/0.65Ctt23sFalsef.png index e5e320f..8b9374a 100644 --- a/data/CLs/plots/phi_s/0.65Ctt23sFalsef.png +++ b/data/CLs/plots/phi_s/0.65Ctt23sFalsef.png Binary files differ diff --git a/data/CLs/plots/phi_s/0.68Ctt24sTruef.png b/data/CLs/plots/phi_s/0.68Ctt24sTruef.png index b3a2bb7..b4da123 100644 --- a/data/CLs/plots/phi_s/0.68Ctt24sTruef.png +++ b/data/CLs/plots/phi_s/0.68Ctt24sTruef.png Binary files differ diff --git a/data/CLs/plots/phi_s/0.68Ctt25sFalsef.png b/data/CLs/plots/phi_s/0.68Ctt25sFalsef.png index ee345c7..fe99b12 100644 --- a/data/CLs/plots/phi_s/0.68Ctt25sFalsef.png +++ b/data/CLs/plots/phi_s/0.68Ctt25sFalsef.png Binary files differ diff --git a/data/CLs/plots/phi_s/0.70Ctt26sTruef.png b/data/CLs/plots/phi_s/0.70Ctt26sTruef.png index 1274554..38fe77b 100644 --- a/data/CLs/plots/phi_s/0.70Ctt26sTruef.png +++ b/data/CLs/plots/phi_s/0.70Ctt26sTruef.png Binary files differ diff --git a/data/CLs/plots/phi_s/0.70Ctt27sFalsef.png b/data/CLs/plots/phi_s/0.70Ctt27sFalsef.png index 6273c9f..95c0d88 100644 --- a/data/CLs/plots/phi_s/0.70Ctt27sFalsef.png +++ b/data/CLs/plots/phi_s/0.70Ctt27sFalsef.png Binary files differ diff --git a/data/CLs/plots/phi_s/0.73Ctt28sTruef.png b/data/CLs/plots/phi_s/0.73Ctt28sTruef.png index 86a9e1c..eca4a9b 100644 --- a/data/CLs/plots/phi_s/0.73Ctt28sTruef.png +++ b/data/CLs/plots/phi_s/0.73Ctt28sTruef.png Binary files differ diff --git a/data/CLs/plots/phi_s/0.73Ctt29sFalsef.png b/data/CLs/plots/phi_s/0.73Ctt29sFalsef.png index 426b5bc..4ee0006 100644 --- a/data/CLs/plots/phi_s/0.73Ctt29sFalsef.png +++ b/data/CLs/plots/phi_s/0.73Ctt29sFalsef.png Binary files differ diff --git a/data/CLs/plots/phi_s/0.75Ctt30sTruef.png b/data/CLs/plots/phi_s/0.75Ctt30sTruef.png index c98c49e..9e83b15 100644 --- a/data/CLs/plots/phi_s/0.75Ctt30sTruef.png +++ b/data/CLs/plots/phi_s/0.75Ctt30sTruef.png Binary files differ diff --git a/data/CLs/plots/phi_s/0.75Ctt31sFalsef.png b/data/CLs/plots/phi_s/0.75Ctt31sFalsef.png index 6ed7566..9442ccd 100644 --- a/data/CLs/plots/phi_s/0.75Ctt31sFalsef.png +++ b/data/CLs/plots/phi_s/0.75Ctt31sFalsef.png Binary files differ diff --git a/data/CLs/plots/phi_s/0.78Ctt32sTruef.png b/data/CLs/plots/phi_s/0.78Ctt32sTruef.png index 7f0ab0a..a2ecf2a 100644 --- a/data/CLs/plots/phi_s/0.78Ctt32sTruef.png +++ b/data/CLs/plots/phi_s/0.78Ctt32sTruef.png Binary files differ diff --git a/data/CLs/plots/phi_s/0.78Ctt33sFalsef.png b/data/CLs/plots/phi_s/0.78Ctt33sFalsef.png index c018232..28b1eef 100644 --- a/data/CLs/plots/phi_s/0.78Ctt33sFalsef.png +++ b/data/CLs/plots/phi_s/0.78Ctt33sFalsef.png Binary files differ diff --git a/data/CLs/plots/phi_s/0.80Ctt34sTruef.png b/data/CLs/plots/phi_s/0.80Ctt34sTruef.png index 92ad427..8cdff5c 100644 --- a/data/CLs/plots/phi_s/0.80Ctt34sTruef.png +++ b/data/CLs/plots/phi_s/0.80Ctt34sTruef.png Binary files differ diff --git a/data/CLs/plots/phi_s/0.80Ctt35sFalsef.png b/data/CLs/plots/phi_s/0.80Ctt35sFalsef.png index 0cfc03d..a0fe23a 100644 --- a/data/CLs/plots/phi_s/0.80Ctt35sFalsef.png +++ b/data/CLs/plots/phi_s/0.80Ctt35sFalsef.png Binary files differ diff --git a/data/CLs/plots/phi_s/0.82Ctt36sTruef.png b/data/CLs/plots/phi_s/0.82Ctt36sTruef.png index 26b6d60..5535af1 100644 --- a/data/CLs/plots/phi_s/0.82Ctt36sTruef.png +++ b/data/CLs/plots/phi_s/0.82Ctt36sTruef.png Binary files differ diff --git a/data/CLs/plots/phi_s/0.82Ctt37sFalsef.png b/data/CLs/plots/phi_s/0.82Ctt37sFalsef.png index e262677..9684576 100644 --- a/data/CLs/plots/phi_s/0.82Ctt37sFalsef.png +++ b/data/CLs/plots/phi_s/0.82Ctt37sFalsef.png Binary files differ diff --git a/data/CLs/plots/phi_s/0.85Ctt38sTruef.png b/data/CLs/plots/phi_s/0.85Ctt38sTruef.png index ed754b0..058d26d 100644 --- a/data/CLs/plots/phi_s/0.85Ctt38sTruef.png +++ b/data/CLs/plots/phi_s/0.85Ctt38sTruef.png Binary files differ diff --git a/data/CLs/plots/phi_s/0.85Ctt39sFalsef.png b/data/CLs/plots/phi_s/0.85Ctt39sFalsef.png index a8487f7..67ccd6c 100644 --- a/data/CLs/plots/phi_s/0.85Ctt39sFalsef.png +++ b/data/CLs/plots/phi_s/0.85Ctt39sFalsef.png Binary files differ diff --git a/data/CLs/plots/psi2s_p/0.00Ctt0sTruef.png b/data/CLs/plots/psi2s_p/0.00Ctt0sTruef.png index f6daf5c..014302f 100644 --- a/data/CLs/plots/psi2s_p/0.00Ctt0sTruef.png +++ b/data/CLs/plots/psi2s_p/0.00Ctt0sTruef.png Binary files differ diff --git a/data/CLs/plots/psi2s_p/0.00Ctt1sFalsef.png b/data/CLs/plots/psi2s_p/0.00Ctt1sFalsef.png index a59e8d2..fcad6c9 100644 --- a/data/CLs/plots/psi2s_p/0.00Ctt1sFalsef.png +++ b/data/CLs/plots/psi2s_p/0.00Ctt1sFalsef.png Binary files differ diff --git a/data/CLs/plots/psi2s_p/0.25Ctt2sTruef.png b/data/CLs/plots/psi2s_p/0.25Ctt2sTruef.png index e2e95f0..0e0ea35 100644 --- a/data/CLs/plots/psi2s_p/0.25Ctt2sTruef.png +++ b/data/CLs/plots/psi2s_p/0.25Ctt2sTruef.png Binary files differ diff --git a/data/CLs/plots/psi2s_p/0.25Ctt3sFalsef.png b/data/CLs/plots/psi2s_p/0.25Ctt3sFalsef.png index 6aa0b3c..f1aabe4 100644 --- a/data/CLs/plots/psi2s_p/0.25Ctt3sFalsef.png +++ b/data/CLs/plots/psi2s_p/0.25Ctt3sFalsef.png Binary files differ diff --git a/data/CLs/plots/psi2s_p/0.31Ctt4sTruef.png b/data/CLs/plots/psi2s_p/0.31Ctt4sTruef.png index f279610..e8a8bbc 100644 --- a/data/CLs/plots/psi2s_p/0.31Ctt4sTruef.png +++ b/data/CLs/plots/psi2s_p/0.31Ctt4sTruef.png Binary files differ diff --git a/data/CLs/plots/psi2s_p/0.31Ctt5sFalsef.png b/data/CLs/plots/psi2s_p/0.31Ctt5sFalsef.png index aa5394c..8b9450f 100644 --- a/data/CLs/plots/psi2s_p/0.31Ctt5sFalsef.png +++ b/data/CLs/plots/psi2s_p/0.31Ctt5sFalsef.png Binary files differ diff --git a/data/CLs/plots/psi2s_p/0.36Ctt6sTruef.png b/data/CLs/plots/psi2s_p/0.36Ctt6sTruef.png index 069f09c..ab136e8 100644 --- a/data/CLs/plots/psi2s_p/0.36Ctt6sTruef.png +++ b/data/CLs/plots/psi2s_p/0.36Ctt6sTruef.png Binary files differ diff --git a/data/CLs/plots/psi2s_p/0.36Ctt7sFalsef.png b/data/CLs/plots/psi2s_p/0.36Ctt7sFalsef.png index 48ef7c4..0be6684 100644 --- a/data/CLs/plots/psi2s_p/0.36Ctt7sFalsef.png +++ b/data/CLs/plots/psi2s_p/0.36Ctt7sFalsef.png Binary files differ diff --git a/data/CLs/plots/psi2s_p/0.41Ctt8sTruef.png b/data/CLs/plots/psi2s_p/0.41Ctt8sTruef.png index 8bd13b0..6b3d22e 100644 --- a/data/CLs/plots/psi2s_p/0.41Ctt8sTruef.png +++ b/data/CLs/plots/psi2s_p/0.41Ctt8sTruef.png Binary files differ diff --git a/data/CLs/plots/psi2s_p/0.41Ctt9sFalsef.png b/data/CLs/plots/psi2s_p/0.41Ctt9sFalsef.png index 35020a1..3eb5c02 100644 --- a/data/CLs/plots/psi2s_p/0.41Ctt9sFalsef.png +++ b/data/CLs/plots/psi2s_p/0.41Ctt9sFalsef.png Binary files differ diff --git a/data/CLs/plots/psi2s_p/0.45Ctt10sTruef.png b/data/CLs/plots/psi2s_p/0.45Ctt10sTruef.png index 1715103..8e4f7de 100644 --- a/data/CLs/plots/psi2s_p/0.45Ctt10sTruef.png +++ b/data/CLs/plots/psi2s_p/0.45Ctt10sTruef.png Binary files differ diff --git a/data/CLs/plots/psi2s_p/0.45Ctt11sFalsef.png b/data/CLs/plots/psi2s_p/0.45Ctt11sFalsef.png index 70a549b..438cd8d 100644 --- a/data/CLs/plots/psi2s_p/0.45Ctt11sFalsef.png +++ b/data/CLs/plots/psi2s_p/0.45Ctt11sFalsef.png Binary files differ diff --git a/data/CLs/plots/psi2s_p/0.49Ctt12sTruef.png b/data/CLs/plots/psi2s_p/0.49Ctt12sTruef.png index 219d312..ceb025b 100644 --- a/data/CLs/plots/psi2s_p/0.49Ctt12sTruef.png +++ b/data/CLs/plots/psi2s_p/0.49Ctt12sTruef.png Binary files differ diff --git a/data/CLs/plots/psi2s_p/0.49Ctt13sFalsef.png b/data/CLs/plots/psi2s_p/0.49Ctt13sFalsef.png index fcbe1a5..8845edf 100644 --- a/data/CLs/plots/psi2s_p/0.49Ctt13sFalsef.png +++ b/data/CLs/plots/psi2s_p/0.49Ctt13sFalsef.png Binary files differ diff --git a/data/CLs/plots/psi2s_p/0.53Ctt14sTruef.png b/data/CLs/plots/psi2s_p/0.53Ctt14sTruef.png index 02ac50f..2370f2f 100644 --- a/data/CLs/plots/psi2s_p/0.53Ctt14sTruef.png +++ b/data/CLs/plots/psi2s_p/0.53Ctt14sTruef.png Binary files differ diff --git a/data/CLs/plots/psi2s_p/0.53Ctt15sFalsef.png b/data/CLs/plots/psi2s_p/0.53Ctt15sFalsef.png index ddc8e0a..ce27d80 100644 --- a/data/CLs/plots/psi2s_p/0.53Ctt15sFalsef.png +++ b/data/CLs/plots/psi2s_p/0.53Ctt15sFalsef.png Binary files differ diff --git a/data/CLs/plots/psi2s_p/0.56Ctt16sTruef.png b/data/CLs/plots/psi2s_p/0.56Ctt16sTruef.png index d06d810..5af100e 100644 --- a/data/CLs/plots/psi2s_p/0.56Ctt16sTruef.png +++ b/data/CLs/plots/psi2s_p/0.56Ctt16sTruef.png Binary files differ diff --git a/data/CLs/plots/psi2s_p/0.56Ctt17sFalsef.png b/data/CLs/plots/psi2s_p/0.56Ctt17sFalsef.png index a636609..1c7e67e 100644 --- a/data/CLs/plots/psi2s_p/0.56Ctt17sFalsef.png +++ b/data/CLs/plots/psi2s_p/0.56Ctt17sFalsef.png Binary files differ diff --git a/data/CLs/plots/psi2s_p/0.59Ctt18sTruef.png b/data/CLs/plots/psi2s_p/0.59Ctt18sTruef.png index 9858aca..429fd5b 100644 --- a/data/CLs/plots/psi2s_p/0.59Ctt18sTruef.png +++ b/data/CLs/plots/psi2s_p/0.59Ctt18sTruef.png Binary files differ diff --git a/data/CLs/plots/psi2s_p/0.59Ctt19sFalsef.png b/data/CLs/plots/psi2s_p/0.59Ctt19sFalsef.png index ecd7358..1b9bbcb 100644 --- a/data/CLs/plots/psi2s_p/0.59Ctt19sFalsef.png +++ b/data/CLs/plots/psi2s_p/0.59Ctt19sFalsef.png Binary files differ diff --git a/data/CLs/plots/psi2s_p/0.62Ctt20sTruef.png b/data/CLs/plots/psi2s_p/0.62Ctt20sTruef.png index bea5169..655b021 100644 --- a/data/CLs/plots/psi2s_p/0.62Ctt20sTruef.png +++ b/data/CLs/plots/psi2s_p/0.62Ctt20sTruef.png Binary files differ diff --git a/data/CLs/plots/psi2s_p/0.62Ctt21sFalsef.png b/data/CLs/plots/psi2s_p/0.62Ctt21sFalsef.png index 0787a31..39c3c2b 100644 --- a/data/CLs/plots/psi2s_p/0.62Ctt21sFalsef.png +++ b/data/CLs/plots/psi2s_p/0.62Ctt21sFalsef.png Binary files differ diff --git a/data/CLs/plots/psi2s_p/0.65Ctt22sTruef.png b/data/CLs/plots/psi2s_p/0.65Ctt22sTruef.png index 27671dd..7242440 100644 --- a/data/CLs/plots/psi2s_p/0.65Ctt22sTruef.png +++ b/data/CLs/plots/psi2s_p/0.65Ctt22sTruef.png Binary files differ diff --git a/data/CLs/plots/psi2s_p/0.65Ctt23sFalsef.png b/data/CLs/plots/psi2s_p/0.65Ctt23sFalsef.png index 0a1c6bc..5da52cb 100644 --- a/data/CLs/plots/psi2s_p/0.65Ctt23sFalsef.png +++ b/data/CLs/plots/psi2s_p/0.65Ctt23sFalsef.png Binary files differ diff --git a/data/CLs/plots/psi2s_p/0.68Ctt24sTruef.png b/data/CLs/plots/psi2s_p/0.68Ctt24sTruef.png index 5bd2c27..b3683e0 100644 --- a/data/CLs/plots/psi2s_p/0.68Ctt24sTruef.png +++ b/data/CLs/plots/psi2s_p/0.68Ctt24sTruef.png Binary files differ diff --git a/data/CLs/plots/psi2s_p/0.68Ctt25sFalsef.png b/data/CLs/plots/psi2s_p/0.68Ctt25sFalsef.png index cee5c19..8098630 100644 --- a/data/CLs/plots/psi2s_p/0.68Ctt25sFalsef.png +++ b/data/CLs/plots/psi2s_p/0.68Ctt25sFalsef.png Binary files differ diff --git a/data/CLs/plots/psi2s_p/0.70Ctt26sTruef.png b/data/CLs/plots/psi2s_p/0.70Ctt26sTruef.png index 755cd7a..216d110 100644 --- a/data/CLs/plots/psi2s_p/0.70Ctt26sTruef.png +++ b/data/CLs/plots/psi2s_p/0.70Ctt26sTruef.png Binary files differ diff --git a/data/CLs/plots/psi2s_p/0.70Ctt27sFalsef.png b/data/CLs/plots/psi2s_p/0.70Ctt27sFalsef.png index 8b48acb..b8f3206 100644 --- a/data/CLs/plots/psi2s_p/0.70Ctt27sFalsef.png +++ b/data/CLs/plots/psi2s_p/0.70Ctt27sFalsef.png Binary files differ diff --git a/data/CLs/plots/psi2s_p/0.73Ctt28sTruef.png b/data/CLs/plots/psi2s_p/0.73Ctt28sTruef.png index 3320218..0db505f 100644 --- a/data/CLs/plots/psi2s_p/0.73Ctt28sTruef.png +++ b/data/CLs/plots/psi2s_p/0.73Ctt28sTruef.png Binary files differ diff --git a/data/CLs/plots/psi2s_p/0.73Ctt29sFalsef.png b/data/CLs/plots/psi2s_p/0.73Ctt29sFalsef.png index 48d2c0e..52ee72c 100644 --- a/data/CLs/plots/psi2s_p/0.73Ctt29sFalsef.png +++ b/data/CLs/plots/psi2s_p/0.73Ctt29sFalsef.png Binary files differ diff --git a/data/CLs/plots/psi2s_p/0.75Ctt30sTruef.png b/data/CLs/plots/psi2s_p/0.75Ctt30sTruef.png index c248d43..79f81c8 100644 --- a/data/CLs/plots/psi2s_p/0.75Ctt30sTruef.png +++ b/data/CLs/plots/psi2s_p/0.75Ctt30sTruef.png Binary files differ diff --git a/data/CLs/plots/psi2s_p/0.75Ctt31sFalsef.png b/data/CLs/plots/psi2s_p/0.75Ctt31sFalsef.png index a41034f..ac504a9 100644 --- a/data/CLs/plots/psi2s_p/0.75Ctt31sFalsef.png +++ b/data/CLs/plots/psi2s_p/0.75Ctt31sFalsef.png Binary files differ diff --git a/data/CLs/plots/psi2s_p/0.78Ctt32sTruef.png b/data/CLs/plots/psi2s_p/0.78Ctt32sTruef.png index e39e826..8deb379 100644 --- a/data/CLs/plots/psi2s_p/0.78Ctt32sTruef.png +++ b/data/CLs/plots/psi2s_p/0.78Ctt32sTruef.png Binary files differ diff --git a/data/CLs/plots/psi2s_p/0.78Ctt33sFalsef.png b/data/CLs/plots/psi2s_p/0.78Ctt33sFalsef.png index a810e9c..a39fbd0 100644 --- a/data/CLs/plots/psi2s_p/0.78Ctt33sFalsef.png +++ b/data/CLs/plots/psi2s_p/0.78Ctt33sFalsef.png Binary files differ diff --git a/data/CLs/plots/psi2s_p/0.80Ctt34sTruef.png b/data/CLs/plots/psi2s_p/0.80Ctt34sTruef.png index fddc1f1..ad3b2f6 100644 --- a/data/CLs/plots/psi2s_p/0.80Ctt34sTruef.png +++ b/data/CLs/plots/psi2s_p/0.80Ctt34sTruef.png Binary files differ diff --git a/data/CLs/plots/psi2s_p/0.80Ctt35sFalsef.png b/data/CLs/plots/psi2s_p/0.80Ctt35sFalsef.png index fe8c6b9..ee7f963 100644 --- a/data/CLs/plots/psi2s_p/0.80Ctt35sFalsef.png +++ b/data/CLs/plots/psi2s_p/0.80Ctt35sFalsef.png Binary files differ diff --git a/data/CLs/plots/psi2s_p/0.82Ctt36sTruef.png b/data/CLs/plots/psi2s_p/0.82Ctt36sTruef.png index 5ae7d1d..b4f7aa5 100644 --- a/data/CLs/plots/psi2s_p/0.82Ctt36sTruef.png +++ b/data/CLs/plots/psi2s_p/0.82Ctt36sTruef.png Binary files differ diff --git a/data/CLs/plots/psi2s_p/0.82Ctt37sFalsef.png b/data/CLs/plots/psi2s_p/0.82Ctt37sFalsef.png index d8c8b63..5440fcb 100644 --- a/data/CLs/plots/psi2s_p/0.82Ctt37sFalsef.png +++ b/data/CLs/plots/psi2s_p/0.82Ctt37sFalsef.png Binary files differ diff --git a/data/CLs/plots/psi2s_p/0.85Ctt38sTruef.png b/data/CLs/plots/psi2s_p/0.85Ctt38sTruef.png index eaccefd..6467a36 100644 --- a/data/CLs/plots/psi2s_p/0.85Ctt38sTruef.png +++ b/data/CLs/plots/psi2s_p/0.85Ctt38sTruef.png Binary files differ diff --git a/data/CLs/plots/psi2s_p/0.85Ctt39sFalsef.png b/data/CLs/plots/psi2s_p/0.85Ctt39sFalsef.png index 0f657bd..857b116 100644 --- a/data/CLs/plots/psi2s_p/0.85Ctt39sFalsef.png +++ b/data/CLs/plots/psi2s_p/0.85Ctt39sFalsef.png Binary files differ diff --git a/data/CLs/plots/rho_p/0.00Ctt0sTruef.png b/data/CLs/plots/rho_p/0.00Ctt0sTruef.png index 2bb90fc..b18e757 100644 --- a/data/CLs/plots/rho_p/0.00Ctt0sTruef.png +++ b/data/CLs/plots/rho_p/0.00Ctt0sTruef.png Binary files differ diff --git a/data/CLs/plots/rho_p/0.00Ctt1sFalsef.png b/data/CLs/plots/rho_p/0.00Ctt1sFalsef.png index 68b3d39..7ebe617 100644 --- a/data/CLs/plots/rho_p/0.00Ctt1sFalsef.png +++ b/data/CLs/plots/rho_p/0.00Ctt1sFalsef.png Binary files differ diff --git a/data/CLs/plots/rho_p/0.25Ctt2sTruef.png b/data/CLs/plots/rho_p/0.25Ctt2sTruef.png index 17fdbe8..711a459 100644 --- a/data/CLs/plots/rho_p/0.25Ctt2sTruef.png +++ b/data/CLs/plots/rho_p/0.25Ctt2sTruef.png Binary files differ diff --git a/data/CLs/plots/rho_p/0.25Ctt3sFalsef.png b/data/CLs/plots/rho_p/0.25Ctt3sFalsef.png index b454139..dc7bdc4 100644 --- a/data/CLs/plots/rho_p/0.25Ctt3sFalsef.png +++ b/data/CLs/plots/rho_p/0.25Ctt3sFalsef.png Binary files differ diff --git a/data/CLs/plots/rho_p/0.31Ctt4sTruef.png b/data/CLs/plots/rho_p/0.31Ctt4sTruef.png index 5f9f839..ef2a999 100644 --- a/data/CLs/plots/rho_p/0.31Ctt4sTruef.png +++ b/data/CLs/plots/rho_p/0.31Ctt4sTruef.png Binary files differ diff --git a/data/CLs/plots/rho_p/0.31Ctt5sFalsef.png b/data/CLs/plots/rho_p/0.31Ctt5sFalsef.png index fdda1af..4d81e1f 100644 --- a/data/CLs/plots/rho_p/0.31Ctt5sFalsef.png +++ b/data/CLs/plots/rho_p/0.31Ctt5sFalsef.png Binary files differ diff --git a/data/CLs/plots/rho_p/0.36Ctt6sTruef.png b/data/CLs/plots/rho_p/0.36Ctt6sTruef.png index 9342bb9..899a444 100644 --- a/data/CLs/plots/rho_p/0.36Ctt6sTruef.png +++ b/data/CLs/plots/rho_p/0.36Ctt6sTruef.png Binary files differ diff --git a/data/CLs/plots/rho_p/0.36Ctt7sFalsef.png b/data/CLs/plots/rho_p/0.36Ctt7sFalsef.png index 96a4b2a..36153da 100644 --- a/data/CLs/plots/rho_p/0.36Ctt7sFalsef.png +++ b/data/CLs/plots/rho_p/0.36Ctt7sFalsef.png Binary files differ diff --git a/data/CLs/plots/rho_p/0.41Ctt8sTruef.png b/data/CLs/plots/rho_p/0.41Ctt8sTruef.png index 94f8a16..f050ca6 100644 --- a/data/CLs/plots/rho_p/0.41Ctt8sTruef.png +++ b/data/CLs/plots/rho_p/0.41Ctt8sTruef.png Binary files differ diff --git a/data/CLs/plots/rho_p/0.41Ctt9sFalsef.png b/data/CLs/plots/rho_p/0.41Ctt9sFalsef.png index 50c785d..4eae4e4 100644 --- a/data/CLs/plots/rho_p/0.41Ctt9sFalsef.png +++ b/data/CLs/plots/rho_p/0.41Ctt9sFalsef.png Binary files differ diff --git a/data/CLs/plots/rho_p/0.45Ctt10sTruef.png b/data/CLs/plots/rho_p/0.45Ctt10sTruef.png index 13b292d..c3863d2 100644 --- a/data/CLs/plots/rho_p/0.45Ctt10sTruef.png +++ b/data/CLs/plots/rho_p/0.45Ctt10sTruef.png Binary files differ diff --git a/data/CLs/plots/rho_p/0.45Ctt11sFalsef.png b/data/CLs/plots/rho_p/0.45Ctt11sFalsef.png index 4bc54e3..b56c5e0 100644 --- a/data/CLs/plots/rho_p/0.45Ctt11sFalsef.png +++ b/data/CLs/plots/rho_p/0.45Ctt11sFalsef.png Binary files differ diff --git a/data/CLs/plots/rho_p/0.49Ctt12sTruef.png b/data/CLs/plots/rho_p/0.49Ctt12sTruef.png index afa37f9..3e659c4 100644 --- a/data/CLs/plots/rho_p/0.49Ctt12sTruef.png +++ b/data/CLs/plots/rho_p/0.49Ctt12sTruef.png Binary files differ diff --git a/data/CLs/plots/rho_p/0.49Ctt13sFalsef.png b/data/CLs/plots/rho_p/0.49Ctt13sFalsef.png index 02b462b..d638033 100644 --- a/data/CLs/plots/rho_p/0.49Ctt13sFalsef.png +++ b/data/CLs/plots/rho_p/0.49Ctt13sFalsef.png Binary files differ diff --git a/data/CLs/plots/rho_p/0.53Ctt14sTruef.png b/data/CLs/plots/rho_p/0.53Ctt14sTruef.png index be3d97c..7db69ba 100644 --- a/data/CLs/plots/rho_p/0.53Ctt14sTruef.png +++ b/data/CLs/plots/rho_p/0.53Ctt14sTruef.png Binary files differ diff --git a/data/CLs/plots/rho_p/0.53Ctt15sFalsef.png b/data/CLs/plots/rho_p/0.53Ctt15sFalsef.png index c074d56..2fd3a2d 100644 --- a/data/CLs/plots/rho_p/0.53Ctt15sFalsef.png +++ b/data/CLs/plots/rho_p/0.53Ctt15sFalsef.png Binary files differ diff --git a/data/CLs/plots/rho_p/0.56Ctt16sTruef.png b/data/CLs/plots/rho_p/0.56Ctt16sTruef.png index 46b354c..d68505e 100644 --- a/data/CLs/plots/rho_p/0.56Ctt16sTruef.png +++ b/data/CLs/plots/rho_p/0.56Ctt16sTruef.png Binary files differ diff --git a/data/CLs/plots/rho_p/0.56Ctt17sFalsef.png b/data/CLs/plots/rho_p/0.56Ctt17sFalsef.png index 5a8f8b4..2679e58 100644 --- a/data/CLs/plots/rho_p/0.56Ctt17sFalsef.png +++ b/data/CLs/plots/rho_p/0.56Ctt17sFalsef.png Binary files differ diff --git a/data/CLs/plots/rho_p/0.59Ctt18sTruef.png b/data/CLs/plots/rho_p/0.59Ctt18sTruef.png index 5358ea6..0a7ffc5 100644 --- a/data/CLs/plots/rho_p/0.59Ctt18sTruef.png +++ b/data/CLs/plots/rho_p/0.59Ctt18sTruef.png Binary files differ diff --git a/data/CLs/plots/rho_p/0.59Ctt19sFalsef.png b/data/CLs/plots/rho_p/0.59Ctt19sFalsef.png index 4460aa6..3448ca0 100644 --- a/data/CLs/plots/rho_p/0.59Ctt19sFalsef.png +++ b/data/CLs/plots/rho_p/0.59Ctt19sFalsef.png Binary files differ diff --git a/data/CLs/plots/rho_p/0.62Ctt20sTruef.png b/data/CLs/plots/rho_p/0.62Ctt20sTruef.png index 6e15c67..c7837b8 100644 --- a/data/CLs/plots/rho_p/0.62Ctt20sTruef.png +++ b/data/CLs/plots/rho_p/0.62Ctt20sTruef.png Binary files differ diff --git a/data/CLs/plots/rho_p/0.62Ctt21sFalsef.png b/data/CLs/plots/rho_p/0.62Ctt21sFalsef.png index ad41fe4..2f286b1 100644 --- a/data/CLs/plots/rho_p/0.62Ctt21sFalsef.png +++ b/data/CLs/plots/rho_p/0.62Ctt21sFalsef.png Binary files differ diff --git a/data/CLs/plots/rho_p/0.65Ctt22sTruef.png b/data/CLs/plots/rho_p/0.65Ctt22sTruef.png index e571321..be61017 100644 --- a/data/CLs/plots/rho_p/0.65Ctt22sTruef.png +++ b/data/CLs/plots/rho_p/0.65Ctt22sTruef.png Binary files differ diff --git a/data/CLs/plots/rho_p/0.65Ctt23sFalsef.png b/data/CLs/plots/rho_p/0.65Ctt23sFalsef.png index b8db6a6..326a74b 100644 --- a/data/CLs/plots/rho_p/0.65Ctt23sFalsef.png +++ b/data/CLs/plots/rho_p/0.65Ctt23sFalsef.png Binary files differ diff --git a/data/CLs/plots/rho_p/0.68Ctt24sTruef.png b/data/CLs/plots/rho_p/0.68Ctt24sTruef.png index 2aec94f..7843a69 100644 --- a/data/CLs/plots/rho_p/0.68Ctt24sTruef.png +++ b/data/CLs/plots/rho_p/0.68Ctt24sTruef.png Binary files differ diff --git a/data/CLs/plots/rho_p/0.68Ctt25sFalsef.png b/data/CLs/plots/rho_p/0.68Ctt25sFalsef.png index a0af413..0ea2fd5 100644 --- a/data/CLs/plots/rho_p/0.68Ctt25sFalsef.png +++ b/data/CLs/plots/rho_p/0.68Ctt25sFalsef.png Binary files differ diff --git a/data/CLs/plots/rho_p/0.70Ctt26sTruef.png b/data/CLs/plots/rho_p/0.70Ctt26sTruef.png index 2344ae7..b9c10c7 100644 --- a/data/CLs/plots/rho_p/0.70Ctt26sTruef.png +++ b/data/CLs/plots/rho_p/0.70Ctt26sTruef.png Binary files differ diff --git a/data/CLs/plots/rho_p/0.70Ctt27sFalsef.png b/data/CLs/plots/rho_p/0.70Ctt27sFalsef.png index e5a99c6..fb674b3 100644 --- a/data/CLs/plots/rho_p/0.70Ctt27sFalsef.png +++ b/data/CLs/plots/rho_p/0.70Ctt27sFalsef.png Binary files differ diff --git a/data/CLs/plots/rho_p/0.73Ctt28sTruef.png b/data/CLs/plots/rho_p/0.73Ctt28sTruef.png index f366c5f..3c9cc43 100644 --- a/data/CLs/plots/rho_p/0.73Ctt28sTruef.png +++ b/data/CLs/plots/rho_p/0.73Ctt28sTruef.png Binary files differ diff --git a/data/CLs/plots/rho_p/0.73Ctt29sFalsef.png b/data/CLs/plots/rho_p/0.73Ctt29sFalsef.png index 7cbe01f..e2073fc 100644 --- a/data/CLs/plots/rho_p/0.73Ctt29sFalsef.png +++ b/data/CLs/plots/rho_p/0.73Ctt29sFalsef.png Binary files differ diff --git a/data/CLs/plots/rho_p/0.75Ctt30sTruef.png b/data/CLs/plots/rho_p/0.75Ctt30sTruef.png index 6995d1b..256260f 100644 --- a/data/CLs/plots/rho_p/0.75Ctt30sTruef.png +++ b/data/CLs/plots/rho_p/0.75Ctt30sTruef.png Binary files differ diff --git a/data/CLs/plots/rho_p/0.75Ctt31sFalsef.png b/data/CLs/plots/rho_p/0.75Ctt31sFalsef.png index 62867b4..e652494 100644 --- a/data/CLs/plots/rho_p/0.75Ctt31sFalsef.png +++ b/data/CLs/plots/rho_p/0.75Ctt31sFalsef.png Binary files differ diff --git a/data/CLs/plots/rho_p/0.78Ctt32sTruef.png b/data/CLs/plots/rho_p/0.78Ctt32sTruef.png index 04c816d..b383420 100644 --- a/data/CLs/plots/rho_p/0.78Ctt32sTruef.png +++ b/data/CLs/plots/rho_p/0.78Ctt32sTruef.png Binary files differ diff --git a/data/CLs/plots/rho_p/0.78Ctt33sFalsef.png b/data/CLs/plots/rho_p/0.78Ctt33sFalsef.png index 25933d4..51da0b9 100644 --- a/data/CLs/plots/rho_p/0.78Ctt33sFalsef.png +++ b/data/CLs/plots/rho_p/0.78Ctt33sFalsef.png Binary files differ diff --git a/data/CLs/plots/rho_p/0.80Ctt34sTruef.png b/data/CLs/plots/rho_p/0.80Ctt34sTruef.png index bc50ef9..7b0e544 100644 --- a/data/CLs/plots/rho_p/0.80Ctt34sTruef.png +++ b/data/CLs/plots/rho_p/0.80Ctt34sTruef.png Binary files differ diff --git a/data/CLs/plots/rho_p/0.80Ctt35sFalsef.png b/data/CLs/plots/rho_p/0.80Ctt35sFalsef.png index 519eb0b..ba9e6e3 100644 --- a/data/CLs/plots/rho_p/0.80Ctt35sFalsef.png +++ b/data/CLs/plots/rho_p/0.80Ctt35sFalsef.png Binary files differ diff --git a/data/CLs/plots/rho_p/0.82Ctt36sTruef.png b/data/CLs/plots/rho_p/0.82Ctt36sTruef.png index e00c8ff..15c5289 100644 --- a/data/CLs/plots/rho_p/0.82Ctt36sTruef.png +++ b/data/CLs/plots/rho_p/0.82Ctt36sTruef.png Binary files differ diff --git a/data/CLs/plots/rho_p/0.82Ctt37sFalsef.png b/data/CLs/plots/rho_p/0.82Ctt37sFalsef.png index 56ffe3a..84acad2 100644 --- a/data/CLs/plots/rho_p/0.82Ctt37sFalsef.png +++ b/data/CLs/plots/rho_p/0.82Ctt37sFalsef.png Binary files differ diff --git a/data/CLs/plots/rho_p/0.85Ctt38sTruef.png b/data/CLs/plots/rho_p/0.85Ctt38sTruef.png index e4d932e..2bd4ffd 100644 --- a/data/CLs/plots/rho_p/0.85Ctt38sTruef.png +++ b/data/CLs/plots/rho_p/0.85Ctt38sTruef.png Binary files differ diff --git a/data/CLs/plots/rho_p/0.85Ctt39sFalsef.png b/data/CLs/plots/rho_p/0.85Ctt39sFalsef.png index 7366e11..53ac92c 100644 --- a/data/CLs/plots/rho_p/0.85Ctt39sFalsef.png +++ b/data/CLs/plots/rho_p/0.85Ctt39sFalsef.png Binary files differ diff --git a/data/CLs/plots/rho_s/0.00Ctt0sTruef.png b/data/CLs/plots/rho_s/0.00Ctt0sTruef.png index 2286d09..b9e702f 100644 --- a/data/CLs/plots/rho_s/0.00Ctt0sTruef.png +++ b/data/CLs/plots/rho_s/0.00Ctt0sTruef.png Binary files differ diff --git a/data/CLs/plots/rho_s/0.00Ctt1sFalsef.png b/data/CLs/plots/rho_s/0.00Ctt1sFalsef.png index c27f9da..7fa9d57 100644 --- a/data/CLs/plots/rho_s/0.00Ctt1sFalsef.png +++ b/data/CLs/plots/rho_s/0.00Ctt1sFalsef.png Binary files differ diff --git a/data/CLs/plots/rho_s/0.25Ctt2sTruef.png b/data/CLs/plots/rho_s/0.25Ctt2sTruef.png index 9ffcc1e..da938de 100644 --- a/data/CLs/plots/rho_s/0.25Ctt2sTruef.png +++ b/data/CLs/plots/rho_s/0.25Ctt2sTruef.png Binary files differ diff --git a/data/CLs/plots/rho_s/0.25Ctt3sFalsef.png b/data/CLs/plots/rho_s/0.25Ctt3sFalsef.png index f6ed1a7..a43c21c 100644 --- a/data/CLs/plots/rho_s/0.25Ctt3sFalsef.png +++ b/data/CLs/plots/rho_s/0.25Ctt3sFalsef.png Binary files differ diff --git a/data/CLs/plots/rho_s/0.31Ctt4sTruef.png b/data/CLs/plots/rho_s/0.31Ctt4sTruef.png index 4878d4d..2bc8c49 100644 --- a/data/CLs/plots/rho_s/0.31Ctt4sTruef.png +++ b/data/CLs/plots/rho_s/0.31Ctt4sTruef.png Binary files differ diff --git a/data/CLs/plots/rho_s/0.31Ctt5sFalsef.png b/data/CLs/plots/rho_s/0.31Ctt5sFalsef.png index ca9693e..aa6847e 100644 --- a/data/CLs/plots/rho_s/0.31Ctt5sFalsef.png +++ b/data/CLs/plots/rho_s/0.31Ctt5sFalsef.png Binary files differ diff --git a/data/CLs/plots/rho_s/0.36Ctt6sTruef.png b/data/CLs/plots/rho_s/0.36Ctt6sTruef.png index 23e698f..3b56190 100644 --- a/data/CLs/plots/rho_s/0.36Ctt6sTruef.png +++ b/data/CLs/plots/rho_s/0.36Ctt6sTruef.png Binary files differ diff --git a/data/CLs/plots/rho_s/0.36Ctt7sFalsef.png b/data/CLs/plots/rho_s/0.36Ctt7sFalsef.png index c84a570..6b7239a 100644 --- a/data/CLs/plots/rho_s/0.36Ctt7sFalsef.png +++ b/data/CLs/plots/rho_s/0.36Ctt7sFalsef.png Binary files differ diff --git a/data/CLs/plots/rho_s/0.41Ctt8sTruef.png b/data/CLs/plots/rho_s/0.41Ctt8sTruef.png index 06dabe9..c8b8dbb 100644 --- a/data/CLs/plots/rho_s/0.41Ctt8sTruef.png +++ b/data/CLs/plots/rho_s/0.41Ctt8sTruef.png Binary files differ diff --git a/data/CLs/plots/rho_s/0.41Ctt9sFalsef.png b/data/CLs/plots/rho_s/0.41Ctt9sFalsef.png index b3f1ab8..443fe2d 100644 --- a/data/CLs/plots/rho_s/0.41Ctt9sFalsef.png +++ b/data/CLs/plots/rho_s/0.41Ctt9sFalsef.png Binary files differ diff --git a/data/CLs/plots/rho_s/0.45Ctt10sTruef.png b/data/CLs/plots/rho_s/0.45Ctt10sTruef.png index ab331dd..edbe85f 100644 --- a/data/CLs/plots/rho_s/0.45Ctt10sTruef.png +++ b/data/CLs/plots/rho_s/0.45Ctt10sTruef.png Binary files differ diff --git a/data/CLs/plots/rho_s/0.45Ctt11sFalsef.png b/data/CLs/plots/rho_s/0.45Ctt11sFalsef.png index c335d40..4f5a799 100644 --- a/data/CLs/plots/rho_s/0.45Ctt11sFalsef.png +++ b/data/CLs/plots/rho_s/0.45Ctt11sFalsef.png Binary files differ diff --git a/data/CLs/plots/rho_s/0.49Ctt12sTruef.png b/data/CLs/plots/rho_s/0.49Ctt12sTruef.png index 92c0236..dd81353 100644 --- a/data/CLs/plots/rho_s/0.49Ctt12sTruef.png +++ b/data/CLs/plots/rho_s/0.49Ctt12sTruef.png Binary files differ diff --git a/data/CLs/plots/rho_s/0.49Ctt13sFalsef.png b/data/CLs/plots/rho_s/0.49Ctt13sFalsef.png index a695dd0..3f9b912 100644 --- a/data/CLs/plots/rho_s/0.49Ctt13sFalsef.png +++ b/data/CLs/plots/rho_s/0.49Ctt13sFalsef.png Binary files differ diff --git a/data/CLs/plots/rho_s/0.53Ctt14sTruef.png b/data/CLs/plots/rho_s/0.53Ctt14sTruef.png index f40ad3a..709a8fd 100644 --- a/data/CLs/plots/rho_s/0.53Ctt14sTruef.png +++ b/data/CLs/plots/rho_s/0.53Ctt14sTruef.png Binary files differ diff --git a/data/CLs/plots/rho_s/0.53Ctt15sFalsef.png b/data/CLs/plots/rho_s/0.53Ctt15sFalsef.png index 70efc7a..909eb8d 100644 --- a/data/CLs/plots/rho_s/0.53Ctt15sFalsef.png +++ b/data/CLs/plots/rho_s/0.53Ctt15sFalsef.png Binary files differ diff --git a/data/CLs/plots/rho_s/0.56Ctt16sTruef.png b/data/CLs/plots/rho_s/0.56Ctt16sTruef.png index 2fb3849..1f383e2 100644 --- a/data/CLs/plots/rho_s/0.56Ctt16sTruef.png +++ b/data/CLs/plots/rho_s/0.56Ctt16sTruef.png Binary files differ diff --git a/data/CLs/plots/rho_s/0.56Ctt17sFalsef.png b/data/CLs/plots/rho_s/0.56Ctt17sFalsef.png index 0769394..cffa00d 100644 --- a/data/CLs/plots/rho_s/0.56Ctt17sFalsef.png +++ b/data/CLs/plots/rho_s/0.56Ctt17sFalsef.png Binary files differ diff --git a/data/CLs/plots/rho_s/0.59Ctt18sTruef.png b/data/CLs/plots/rho_s/0.59Ctt18sTruef.png index a9fbf6a..273f980 100644 --- a/data/CLs/plots/rho_s/0.59Ctt18sTruef.png +++ b/data/CLs/plots/rho_s/0.59Ctt18sTruef.png Binary files differ diff --git a/data/CLs/plots/rho_s/0.59Ctt19sFalsef.png b/data/CLs/plots/rho_s/0.59Ctt19sFalsef.png index 5667d49..7392156 100644 --- a/data/CLs/plots/rho_s/0.59Ctt19sFalsef.png +++ b/data/CLs/plots/rho_s/0.59Ctt19sFalsef.png Binary files differ diff --git a/data/CLs/plots/rho_s/0.62Ctt20sTruef.png b/data/CLs/plots/rho_s/0.62Ctt20sTruef.png index 47f6a31..4d076e7 100644 --- a/data/CLs/plots/rho_s/0.62Ctt20sTruef.png +++ b/data/CLs/plots/rho_s/0.62Ctt20sTruef.png Binary files differ diff --git a/data/CLs/plots/rho_s/0.62Ctt21sFalsef.png b/data/CLs/plots/rho_s/0.62Ctt21sFalsef.png index 710893e..106f1e0 100644 --- a/data/CLs/plots/rho_s/0.62Ctt21sFalsef.png +++ b/data/CLs/plots/rho_s/0.62Ctt21sFalsef.png Binary files differ diff --git a/data/CLs/plots/rho_s/0.65Ctt22sTruef.png b/data/CLs/plots/rho_s/0.65Ctt22sTruef.png index 2ed5cbb..14196ce 100644 --- a/data/CLs/plots/rho_s/0.65Ctt22sTruef.png +++ b/data/CLs/plots/rho_s/0.65Ctt22sTruef.png Binary files differ diff --git a/data/CLs/plots/rho_s/0.65Ctt23sFalsef.png b/data/CLs/plots/rho_s/0.65Ctt23sFalsef.png index 6300575..d9b2c8d 100644 --- a/data/CLs/plots/rho_s/0.65Ctt23sFalsef.png +++ b/data/CLs/plots/rho_s/0.65Ctt23sFalsef.png Binary files differ diff --git a/data/CLs/plots/rho_s/0.68Ctt24sTruef.png b/data/CLs/plots/rho_s/0.68Ctt24sTruef.png index 037275a..c6571ae 100644 --- a/data/CLs/plots/rho_s/0.68Ctt24sTruef.png +++ b/data/CLs/plots/rho_s/0.68Ctt24sTruef.png Binary files differ diff --git a/data/CLs/plots/rho_s/0.68Ctt25sFalsef.png b/data/CLs/plots/rho_s/0.68Ctt25sFalsef.png index a462eb4..233e353 100644 --- a/data/CLs/plots/rho_s/0.68Ctt25sFalsef.png +++ b/data/CLs/plots/rho_s/0.68Ctt25sFalsef.png Binary files differ diff --git a/data/CLs/plots/rho_s/0.70Ctt26sTruef.png b/data/CLs/plots/rho_s/0.70Ctt26sTruef.png index daffde7..67b0899 100644 --- a/data/CLs/plots/rho_s/0.70Ctt26sTruef.png +++ b/data/CLs/plots/rho_s/0.70Ctt26sTruef.png Binary files differ diff --git a/data/CLs/plots/rho_s/0.70Ctt27sFalsef.png b/data/CLs/plots/rho_s/0.70Ctt27sFalsef.png index fc1ba99..73c3d14 100644 --- a/data/CLs/plots/rho_s/0.70Ctt27sFalsef.png +++ b/data/CLs/plots/rho_s/0.70Ctt27sFalsef.png Binary files differ diff --git a/data/CLs/plots/rho_s/0.73Ctt28sTruef.png b/data/CLs/plots/rho_s/0.73Ctt28sTruef.png index 3bb1755..d4a4031 100644 --- a/data/CLs/plots/rho_s/0.73Ctt28sTruef.png +++ b/data/CLs/plots/rho_s/0.73Ctt28sTruef.png Binary files differ diff --git a/data/CLs/plots/rho_s/0.73Ctt29sFalsef.png b/data/CLs/plots/rho_s/0.73Ctt29sFalsef.png index 9e6ecaf..ac13593 100644 --- a/data/CLs/plots/rho_s/0.73Ctt29sFalsef.png +++ b/data/CLs/plots/rho_s/0.73Ctt29sFalsef.png Binary files differ diff --git a/data/CLs/plots/rho_s/0.75Ctt30sTruef.png b/data/CLs/plots/rho_s/0.75Ctt30sTruef.png index 6e89b13..c88d5ac 100644 --- a/data/CLs/plots/rho_s/0.75Ctt30sTruef.png +++ b/data/CLs/plots/rho_s/0.75Ctt30sTruef.png Binary files differ diff --git a/data/CLs/plots/rho_s/0.75Ctt31sFalsef.png b/data/CLs/plots/rho_s/0.75Ctt31sFalsef.png index 928becf..91abc1d 100644 --- a/data/CLs/plots/rho_s/0.75Ctt31sFalsef.png +++ b/data/CLs/plots/rho_s/0.75Ctt31sFalsef.png Binary files differ diff --git a/data/CLs/plots/rho_s/0.78Ctt32sTruef.png b/data/CLs/plots/rho_s/0.78Ctt32sTruef.png index 5cbf0f6..6d9fba8 100644 --- a/data/CLs/plots/rho_s/0.78Ctt32sTruef.png +++ b/data/CLs/plots/rho_s/0.78Ctt32sTruef.png Binary files differ diff --git a/data/CLs/plots/rho_s/0.78Ctt33sFalsef.png b/data/CLs/plots/rho_s/0.78Ctt33sFalsef.png index 67b9f1d..732a179 100644 --- a/data/CLs/plots/rho_s/0.78Ctt33sFalsef.png +++ b/data/CLs/plots/rho_s/0.78Ctt33sFalsef.png Binary files differ diff --git a/data/CLs/plots/rho_s/0.80Ctt34sTruef.png b/data/CLs/plots/rho_s/0.80Ctt34sTruef.png index 30d5850..1b2614a 100644 --- a/data/CLs/plots/rho_s/0.80Ctt34sTruef.png +++ b/data/CLs/plots/rho_s/0.80Ctt34sTruef.png Binary files differ diff --git a/data/CLs/plots/rho_s/0.80Ctt35sFalsef.png b/data/CLs/plots/rho_s/0.80Ctt35sFalsef.png index c8c81fa..545b85e 100644 --- a/data/CLs/plots/rho_s/0.80Ctt35sFalsef.png +++ b/data/CLs/plots/rho_s/0.80Ctt35sFalsef.png Binary files differ diff --git a/data/CLs/plots/rho_s/0.82Ctt36sTruef.png b/data/CLs/plots/rho_s/0.82Ctt36sTruef.png index dc1cd77..814acc4 100644 --- a/data/CLs/plots/rho_s/0.82Ctt36sTruef.png +++ b/data/CLs/plots/rho_s/0.82Ctt36sTruef.png Binary files differ diff --git a/data/CLs/plots/rho_s/0.82Ctt37sFalsef.png b/data/CLs/plots/rho_s/0.82Ctt37sFalsef.png index 6534600..e241c11 100644 --- a/data/CLs/plots/rho_s/0.82Ctt37sFalsef.png +++ b/data/CLs/plots/rho_s/0.82Ctt37sFalsef.png Binary files differ diff --git a/data/CLs/plots/rho_s/0.85Ctt38sTruef.png b/data/CLs/plots/rho_s/0.85Ctt38sTruef.png index 40b75a7..96dcea8 100644 --- a/data/CLs/plots/rho_s/0.85Ctt38sTruef.png +++ b/data/CLs/plots/rho_s/0.85Ctt38sTruef.png Binary files differ diff --git a/data/CLs/plots/rho_s/0.85Ctt39sFalsef.png b/data/CLs/plots/rho_s/0.85Ctt39sFalsef.png index cbba8bf..d701c0d 100644 --- a/data/CLs/plots/rho_s/0.85Ctt39sFalsef.png +++ b/data/CLs/plots/rho_s/0.85Ctt39sFalsef.png Binary files differ diff --git a/raremodel-nb.ipynb b/raremodel-nb.ipynb index cbe0604..f701626 100644 --- a/raremodel-nb.ipynb +++ b/raremodel-nb.ipynb @@ -2184,7 +2184,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "Number of jobs: 209\n" + "Number of jobs: 331\n" ] } ], @@ -2324,7 +2324,7 @@ }, { "cell_type": "code", - "execution_count": 53, + "execution_count": 51, "metadata": {}, "outputs": [], "source": [ @@ -2347,12 +2347,12 @@ "name": "stdout", "output_type": "stream", "text": [ - "(20, 209)\n" + "(20, 231)\n" ] }, { "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXAAAAEWCAYAAAB/tMx4AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjAsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+17YcXAAAW6UlEQVR4nO3debRlZX3m8e8jgsoUpkIBgVJBAzGApkRtEkNEXSAYZcWgaAwQCaYNS0w7NK3dgc5SQxKjxmDHYERYLRBBUDFqAhrngViQUsFCQVLKUBbFTAm2DL/+Y+8ipy7n1p3OvYe37vez1l33nH322fu3z/Ccd797SlUhSWrPo8ZdgCRpdgxwSWqUAS5JjTLAJalRBrgkNcoAl6RGGeDTlGRpkkry6P7+l5IcP+66NHNJDk5yw7jrWGhJ3pHkliQ/nfh5HvF8fiPJD0Y93bnol/2scdcxaosuwJOsSnJvknVJ1iT5SJKtRzyPU5Pcl+Tu/u+HSU5PssvAOAcnebCvY12SG5Kcn+RZ05zHWUneMcq651OSA5N8NskdSW5L8m9Jjusfe1ig9q/hR8dT7ez1wfjFJPckuTrJCzYy7g5JPtaH6i1Jzkmy7cDjg5/VdUkumUNduwNvAvatqifMdjqTTLuS7LX+flV9taqeNsp5DMzrS0l+PvCarEvy3PmYVwsWXYD3XlJVWwPPBJ4F/M95mMfHqmobYAfgSOAJwOWDIQ7c1NexDfAc4Grgq0kOmYd6NjAfLa+NzOu5wL8CXwb2AnYE/itw2ELVsIDOA/6dbhnfDnw8yZJJxn0HsD3wZOApwOOBUyeM85Kq2rr/e9Ec6toTuLWqbp7DNB4pThx4Tbauqm+Ou6BxWawBDkBV3Qh8Dng6PNTieajFNIpWYFXdV1VXAa8A1tK1giaOU1V1Q1X9KfAPwF/080+S9ya5OcmdSb6b5OlJTgBeDby1b4F8uh//5CQ/6lv9309y5MCyHJvk6/30buPhQcGQcf+2n+/Vc/xR+Svg7Kr6i6q6pV/ey6vqqCRb0b0Huw60qF4FvA14RX//O0NqPDnJxycM+5sk7+9vH5dkZf9aXJfkdRtZ3g1akBPXbpIckWRFv/bwjST7TTKdp9I1Ck6pqnur6kLge8DvTDLrJwGfrKq7qupO4BPAr0xW52z1n+lL+c/X+Kwh4+ya5OJ+7ejaJH848NiBSb7ZL//qfm1yi/6xr/Sjfaef9ismrlH136s395/fO/u1jscOPP7Wfro3JTl+4vsxg+U8Pd2a7F1Jvp3kv0wy3pZJzk1ya79M/5Zkp/6x7dKtla/up/VnSR6xOfmILWwh9KuVL6ZrMc2rqnoA+BTwG1OMehHwzD7YXgQ8D3gqsB3dj8CtVXUGcA7wl30L5CX9c3/UT/+XgP8NfHRCi//ZwHXAzsA7p6hj/bg7AacAFyXZYTrLOijJlsBzgY8Pe7yqfkbXEr9poEV1LvAuurWYratq/yFPPQ94cfouhySbAUcB5/aP3wwcAWwLHAe8N8kzZ1H/M4EzgdfRtar/Hrg4yWOGjP4rwHVVdffAsO8weSh/ADgiyfZJtqcL+s9NGOecJGuTXJJk2Oswpar6PBu+xscOGe084AZgV+DlwLsGfrQfAP6E7rPwXOAQ4PX9tJ/Xj7N/P+2PTVLGUcChdD9a+wHHAiQ5FPhvwAvo1s5+czbL2Lusn/YOdJ+3CyZ5n44DtgSeSPeevh74ef/YR4F76daIlgGH9+M/Ii3WAP9kkjuAr9Gt1r9rgeZ7E92Ha6pxQhfY99F1r/wykKpaWVWrJ3tiVV1QVTdV1YP9F+ka4MDBaVfV31bV/VV17xR13Ay8r1+D+BjwA7oP80xtT/c5m7Tu2aiqHwNXAC/rBz0fuKeqvtU//pmq+lHf2v8ycAlT/3gO84fA31fVZVX1QFWdDfw/ui6vibYG7pww7E6693CYK4AtgFv7vweA/zPw+KuBpXTdH18E/iXJdrNYho3qGzK/Dvz3qvp5Va2gWxN8DUC/tvSt/nOziu5HbKZB+/7+s3kb8GnggH74UcBHquqqqrqHruEx5bT6lvMdSa5YP7Cq/m9V3VZV9wN/SffjPawlfx/dj9Fe/Xu6vKrWJdmN7sfpT6rqnqr6KfA+4JUzXNYFs1gD/GVVtV1V7VlVr59GmI3KbsBt0xingDuq6l+B0+laamuSnJGBjVwTJfn9gVX9O+i6hnYaGOX6GdR6Y214prMf07XOJs7z1QNdHxNbjwC3Aw8Cuwx5bK7OBY7ub7+K/2x9k+SwJN/quwTuoFvT2mnINKayJ/CmgcC4A9idIa8FsI4uNAZtC9w9ZFyAC4Af0gX8tnRrUA912VXV1/uumHuq6s+BOxjyI5Rkj4H3YN0Mlw+6ZbltwprDj+k+iyR5apJ/Srf3yl10DZ6ZvpY/Hbh9D92P3fp5D34up/MZfUP//d2uqh5aq+q7Yq5Ocifd526rSeo8C/g8cH6SG5Oclm6b0J7AY+i+a+vf6w/QbZt4RFqsAT6Zn9GtWq03sq31fT/aS4CvTjHqkcAVfdcCVfX+qvo1utXwpwJv6cfb4DSSSfYEPgScCOxYVdsBV9K15hn2nCnslmTwuXvQrR1soKrOGej6eNhGyb5V9U0m7weerK7p1HoBcHCSJ9K9bucC9KvNFwLvBh7fvxafZcPXYtA9TP6+Xw+8cyAwtquqLavqvCHTuQp4cpLBFvf+/fBh9qdr3f+sqtYBH6T7oZlMDVuGqvrJ4Ea9jTx/MjcBO0yoew/gxv7239FtYN+7qral2z4x2Ws5U6vpujLW2302E0nyW3RdMb9Dt/a6Pd0P6rDX6xdVdWpV7UO35nEk3drO9XSfhR0G3uttq2roNo9HAgN8QyuAVybZPMkyur7AOemntQ9dH+MTgPcMGSdJdktyCnA83ReEJM9K8uwkm9P9uPycbjUbYA3d3gvrbUX3BV/bP/c4+o2zs7Qz8Ia+/t8F9qELwdl4K3Bskrck2bGvb/8k/9g/vgbYMckvDTxnDbB0YxuQqmot8CXgI8B/VNXK/qEt6FpSa4H7kxxGtz1hMiuAVyXZrO+THewe+BDwR/37kCRbJTl8Qtitr+eH/bROSfLYdBuR96P7MRnm28DxSR6X5HHACXR95utb1Qcl2aKf1lvoWpNf38hyzEpVXQ98A/jzfl77Aa+l284C3RrCXcC6JL9MtwfRoImfxZk4HzguyT799pI/neV0tgHuB24BNqfbSL/VsBGTPD/dzgCPoluu+4AH+tfhy8C7k2yb5FFJ9kryvGHTeSQwwDf0v+g2XtxO1xd37sZH36hX9KuzdwAX0/Vx/lpVDbZid+3HWUf3Zf5V4OCqWr+/77Z0AXI73SrtrXStSoAPA/v2q3qfrKrvA39N19pd009rLl/2y4C96b4Q7wReXlW3zmZCVfUNuj7q5wPXpdsL5gz6H4SqupruB+66fnl2pWtdA9w62M85xLl0G8Aeeq/6roA30IXD7XTdKxdvZBon0a0d3UHXEvvkwLSW0/WDn95P61r6DXCTeCXdxq/bgdPoXrf1P6qvTjLYGv8Duj7uG+hau08emPY2dC3f2/vHDgUOm+17MA1H97XcRLc3zClVdWn/2JvpXsO76T6PEzdUngqc3b93R81kplX1OeD9dH3819J9fqHbzjATn6XrFrkGWEUXzJNtd9mVbmeBu+jWjj5P9/kD+D264P8+3Wt/ASNcEx+1lBd00ARJjgWOr6pfH3ctWlz6tdUrgcf0GyO1EbbAJY1VkiP7rqLt6Y6B+LThPT0G+CKV5IPZ8HDk9X8fHHdtWnReR7e94kd023gm9rFrEnahSFKjpmyBJ9k93cl5Via5KslJ/fBT+30oV/R/G9v9SZI0YlO2wNMdir1LVV3R7zp1Od3Rb0cB66rq3RudwICddtqpli5dOodyJWnxufzyy2+pqoedFG3KM9L1h26v7m/fnWQl/RFaM7V06VKWL18+m6dK0qKV5MfDhs9oI2aSpcAz6PYRBjgx3RnGzuy3IA97zglJlidZvnbt2pnMTpK0EdMO8HQXPbgQeGNV3UV3kMFT6E5Ks5ruIJKHqaozqmpZVS1bsmSy0yJLkmZqWgHeH8p9IXBOVV0EUFVr+jN5PUh3dNaBG5uGJGm0prMXSugO215ZVe8ZGD54drkj6Y6ekiQtkOlcVusguvMCfy/Jin7Y24CjkxxAdwKlVXQ740uSFsh09kL5GsNPHTnbM9NJkkbAQ+klqVEGuCQ1ygCXpEZNZyOmNKWlJ39m6PBVp83mOsiSpsMWuCQ1ygCXpEYZ4JLUKANckhplgEtSowxwSWqUAS5JjTLAJalRBrgkNcoAl6RGGeCS1CgDXJIaZYBLUqMMcElqlAEuSY0ywCWpUV7QQY8oXhhCmj5b4JLUKANckhplgEtSowxwSWqUAS5JjTLAJalRBrgkNcoAl6RGGeCS1CgDXJIaZYBLUqMMcElqlAEuSY2aMsCT7J7ki0lWJrkqyUn98B2SXJrkmv7/9vNfriRpvem0wO8H3lRV+wDPAf44yb7AycAXqmpv4Av9fUnSApkywKtqdVVd0d++G1gJ7Aa8FDi7H+1s4GXzVaQk6eFm1AeeZCnwDOAy4PFVtRq6kAd2nuQ5JyRZnmT52rVr51atJOkh0w7wJFsDFwJvrKq7pvu8qjqjqpZV1bIlS5bMpkZJ0hDTCvAkm9OF9zlVdVE/eE2SXfrHdwFunp8SJUnDTGcvlAAfBlZW1XsGHroYOKa/fQzwqdGXJ0mazHQuanwQ8Brge0lW9MPeBpwGnJ/ktcBPgN+dnxIlScNMGeBV9TUgkzx8yGjLkSRNl0diSlKjDHBJapQBLkmNMsAlqVEGuCQ1ygCXpEYZ4JLUKANckhplgEtSowxwSWqUAS5JjTLAJalRBrgkNcoAl6RGGeCS1CgDXJIaZYBLUqMMcElqlAEuSY0ywCWpUQa4JDXKAJekRhngktQoA1ySGmWAS1KjDHBJapQBLkmNMsAlqVEGuCQ16tHjLkBtWXryZ0Yy/qrTDh9FOdKiZgtckhplgEtSowxwSWqUAS5JjZoywJOcmeTmJFcODDs1yY1JVvR/L57fMiVJE02nBX4WcOiQ4e+tqgP6v8+OtixJ0lSmDPCq+gpw2wLUIkmagbn0gZ+Y5Lt9F8v2k42U5IQky5MsX7t27RxmJ0kaNNsA/zvgKcABwGrgrycbsarOqKplVbVsyZIls5ydJGmiWQV4Va2pqgeq6kHgQ8CBoy1LkjSVWQV4kl0G7h4JXDnZuJKk+THluVCSnAccDOyU5AbgFODgJAcABawCXjePNUqShpgywKvq6CGDPzwPtUiSZsAjMSWpUQa4JDXKAJekRhngktQoA1ySGmWAS1KjDHBJapQBLkmNMsAlqVEGuCQ1ygCXpEYZ4JLUKANckhplgEtSowxwSWqUAS5JjTLAJalRBrgkNcoAl6RGGeCS1KgpL2oszYelJ39m3CVIzbMFLkmNMsAlqVEGuCQ1ygCXpEYZ4JLUKANckhplgEtSowxwSWqUB/KoCZMd+LPqtMPHMp3ZGOe8tWmyBS5JjTLAJalRBrgkNcoAl6RGTRngSc5McnOSKweG7ZDk0iTX9P+3n98yJUkTTacFfhZw6IRhJwNfqKq9gS/09yVJC2jKAK+qrwC3TRj8UuDs/vbZwMtGXJckaQqz7QN/fFWtBuj/7zy6kiRJ0zHvGzGTnJBkeZLla9eune/ZSdKiMdsAX5NkF4D+/82TjVhVZ1TVsqpatmTJklnOTpI00WwD/GLgmP72McCnRlOOJGm6prMb4XnAN4GnJbkhyWuB04AXJrkGeGF/X5K0gKY8mVVVHT3JQ4eMuBZJ0gx4JKYkNcoAl6RGGeCS1Cgv6KCHmezCA5IeWWyBS1KjDHBJapQBLkmNMsAlqVEGuCQ1ygCXpEYZ4JLUKANckhrlgTyLmAfszM1kr9+q0w5f4Eq0WNkCl6RGGeCS1CgDXJIaZYBLUqMMcElqlAEuSY0ywCWpUQa4JDXKAJekRhngktQoA1ySGmWAS1KjDHBJapQBLkmNMsAlqVEGuCQ1ygs6SHhxBrXJFrgkNcoAl6RGGeCS1CgDXJIaNaeNmElWAXcDDwD3V9WyURQlSZraKPZC+a2qumUE05EkzYBdKJLUqLkGeAGXJLk8yQmjKEiSND1z7UI5qKpuSrIzcGmSq6vqK4Mj9MF+AsAee+wxx9lJi4cHF2kqc2qBV9VN/f+bgU8ABw4Z54yqWlZVy5YsWTKX2UmSBsw6wJNslWSb9beBFwFXjqowSdLGzaUL5fHAJ5Ksn865VfXPI6lKkjSlWQd4VV0H7D/CWiRJM+BuhJLUKANckhplgEtSo7ygg5o22b7SrUx/Ibg/+abLFrgkNcoAl6RGGeCS1CgDXJIaZYBLUqMMcElqlAEuSY0ywCWpUamqBZvZsmXLavny5Qs2P3U2hYNRNLXJDsyZ6fs/0+l4QND8S3L5sIvG2wKXpEYZ4JLUKANckhplgEtSowxwSWqUAS5JjTLAJalRBrgkNWrRXZFnYwc1zPcBCR4IIWmUbIFLUqMMcElqlAEuSY0ywCWpUQa4JDXKAJekRhngktSoTXY/8NlcxGBUFz6Y6X7do9o/3As3aBzGeWzFqLR6jIYtcElqlAEuSY0ywCWpUQa4JDXKAJekRs0pwJMcmuQHSa5NcvKoipIkTW3WAZ5kM+ADwGHAvsDRSfYdVWGSpI2bSwv8QODaqrquqn4B/CPw0tGUJUmaSqpqdk9MXg4cWlXH9/dfAzy7qk6cMN4JwAn93acBP5h9uWOzE3DLuItYQIttecFlXixaXeY9q2rJxIFzORIzQ4Y97Negqs4AzpjDfMYuyfKqWjbuOhbKYltecJkXi01tmefShXIDsPvA/ScCN82tHEnSdM0lwL8N7J3kSUm2AF4JXDyasiRJU5l1F0pV3Z/kROBfgM2AM6vqqpFV9sjSdBfQLCy25QWXebHYpJZ51hsxJUnj5ZGYktQoA1ySGmWAz0CSNyepJDuNu5b5luSvklyd5LtJPpFku3HXNF8W2ykhkuye5ItJVia5KslJ465pISTZLMm/J/mncdcyKgb4NCXZHXgh8JNx17JALgWeXlX7AT8E/seY65kXi/SUEPcDb6qqfYDnAH+8CJYZ4CRg5biLGCUDfPreC7yVIQcrbYqq6pKqur+/+y26/fw3RYvulBBVtbqqruhv300XaruNt6r5leSJwOHAP4y7llEywKchyW8DN1bVd8Zdy5j8AfC5cRcxT3YDrh+4fwObeJgNSrIUeAZw2XgrmXfvo2uAPTjuQkZpk72o8Uwl+TzwhCEPvR14G/Ciha1o/m1smavqU/04b6db5T5nIWtbQNM6JcSmKMnWwIXAG6vqrnHXM1+SHAHcXFWXJzl43PWMkgHeq6oXDBue5FeBJwHfSQJdV8IVSQ6sqp8uYIkjN9kyr5fkGOAI4JDadA8YWJSnhEiyOV14n1NVF427nnl2EPDbSV4MPBbYNslHq+r3xlzXnHkgzwwlWQUsq6oWz2g2bUkOBd4D/GZVrR13PfMlyaPpNtIeAtxId4qIV23CRxWTriVyNnBbVb1x3PUspL4F/uaqOmLctYyCfeCazOnANsClSVYk+eC4C5oP/Yba9aeEWAmcvymHd+8g4DXA8/v3dkXfOlVjbIFLUqNsgUtSowxwSWqUAS5JjTLAJalRBrgkNcoA16KQ5IF+d7krk1yQZMspxj8rycv7219KsslcCFebDgNci8W9VXVAVT0d+AXwR+MuSJorA1yL0VeBvZIsTXLl+oH9+d5PHV9Z0swY4FpU+kPnDwO+N+5apLkywLVYPC7JCmA53UU5PjzmeqQ582yEWizuraoDBgckuZ8NGzGPXdiSpLmxBa7FbA2wc5IdkzyG7tS5UjNsgWvRqqr7kvwZ3dVo/gO4eswlSTPi2QglqVF2oUhSowxwSWqUAS5JjTLAJalRBrgkNcoAl6RGGeCS1Kj/Dwy5sJCsONk3AAAAAElFTkSuQmCC\n", + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXAAAAEWCAYAAAB/tMx4AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjAsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+17YcXAAAW90lEQVR4nO3de7QlZX3m8e8jwQu3ANIqINAqajBG0LSoQ2KIqIubUVaMisYgkbSJstQEdRidCUyWGpKoOAZHbaPCGoEI4gWjTkCDdyU2pFWwUZCgAm3T3EFwpOE3f1Qd3H3Yp89tn7N5+3w/a5119q6qXfWrves89dZbteukqpAktecB4y5AkjQ3BrgkNcoAl6RGGeCS1CgDXJIaZYBLUqMM8BlKsjxJJfm1/vmXkhwz7ro0e0kOTHL1uOtYbEnemuT6JD+bvD2PeDm/m+QHo57vfPTrfuq46xi1JRfgSa5KcmeS25OsT/KRJNuNeBknJrkryW39zw+TnJJk14FpDkxyT1/H7UmuTnJWkqfOcBmnJnnrKOteSEn2T/K5JDcnuTHJvyc5uh93n0Dt38OPjqfaueuD8YIkdyS5LMmzNzPtzkk+1ofq9UlOT7LDwPjBbfX2JOfNo649gOOAJ1TVI+Y6nynmXUn2nnheVV+tqsePchkDy/pSkl8MvCe3J3nGQiyrBUsuwHvPq6rtgKcATwX++wIs42NVtT2wM3AE8AjgosEQB67t69geeDpwGfDVJActQD2bWIiW12aW9Qzg34AvA3sDDwX+AjhksWpYRGcC/0G3jm8BPp5k2RTTvhXYCXg08Bjg4cCJk6Z5XlVt1/88dx517QXcUFXXzWMe9xfHDrwn21XVN8dd0Lgs1QAHoKquAT4PPBHubfHc22IaRSuwqu6qqkuBFwMb6FpBk6epqrq6qv4a+Cfg7/rlJ8nJSa5LckuS7yZ5YpKVwMuAN/UtkM/00x+f5Ed9q//7SY4YWJdXJPl6P78buW9QMGTaf+yXe9k8dyr/AJxWVX9XVdf363tRVb0oybZ0n8FuAy2qlwJvBl7cP//OkBqPT/LxScP+V5L39I+PTrK2fy+uTPKqzazvJi3IyUc3SQ5PsqY/evhGkidNMZ/H0TUKTqiqO6vqHOB7wB9OsehHAZ+qqlur6hbgk8BvTlXnXPXb9Pn86j0+dcg0uyU5tz86uiLJnw2M2z/JN/v1X9cfTT6wH/eVfrLv9PN+8eQjqv7v6g399ntLf9Tx4IHxb+rne22SYyZ/HrNYz1PSHcnemuTbSf7LFNNtk+SMJDf06/TvSXbpx+2Y7qh8XT+vv0lyv83J+21hi6E/rDyUrsW0oKrqbuDTwO9OM+kngKf0wfZc4JnA44Ad6XYCN1TVKuB04O/7Fsjz+tf+qJ//rwP/E/jopBb/04ArgYcBb5umjolpdwFOAD6RZOeZrOugJNsAzwA+Pmx8Vf2criV+7UCL6gzg7XRHMdtV1b5DXnomcGj6LockWwEvAs7ox18HHA7sABwNnJzkKXOo/ynAh4FX0bWqPwCcm+RBQyb/TeDKqrptYNh3mDqU3wscnmSnJDvRBf3nJ01zepINSc5LMux9mFZVfYFN3+NXDJnsTOBqYDfghcDbB3badwN/SbctPAM4CHh1P+9n9tPs28/7Y1OU8SLgYLqd1pOAVwAkORj4K+DZdEdnvzeXdexd2M97Z7rt7ewpPqejgW2AR9J9pq8GftGP+yhwJ90R0QrgsH76+6WlGuCfSnIz8DW6w/q3L9Jyr6XbuKabJnSBfRdd98pvAKmqtVW1bqoXVtXZVXVtVd3T/yFdDuw/OO+q+seq2lhVd05Tx3XAu/sjiI8BP6DbmGdrJ7rtbMq656KqfgxcDLygH/Qs4I6q+lY//rNV9aO+tf9l4Dym33kO82fAB6rqwqq6u6pOA/4fXZfXZNsBt0wadgvdZzjMxcADgRv6n7uB/z0w/mXAcrrujwuAf02y4xzWYbP6hszvAP+1qn5RVWvojgRfDtAfLX2r326uotuJzTZo39NvmzcCnwH264e/CPhIVV1aVXfQNTymnVffcr45ycUTA6vq/1TVjVW1Efh7up33sJb8XXQ7o737z3R1Vd2eZHe6ndNfVtUdVfUz4N3AS2a5rotmqQb4C6pqx6raq6pePYMwG5XdgRtnME0BN1fVvwGn0LXU1idZlYGTXJMl+ZOBQ/2b6bqGdhmY5KezqPWa2vROZz+ma51NXubLBro+JrceAW4C7gF2HTJuvs4Ajuwfv5Rftb5JckiSb/VdAjfTHWntMmQe09kLOG4gMG4G9mDIewHcThcag3YAbhsyLcDZwA/pAn4HuiOoe7vsqurrfVfMHVX1t8DNDNkJJdlz4DO4fZbrB9263DjpyOHHdNsiSR6X5F/SXb1yK12DZ7bv5c8GHt9Bt7ObWPbgdjmTbfS1/d/vjlV171FV3xVzWZJb6La7baeo81TgC8BZSa5JclK6c0J7AQ+i+1ub+KzfS3du4n5pqQb4VH5Od2g1YWRn6/t+tOcBX51m0iOAi/uuBarqPVX123SH4Y8D3thPt8ltJJPsBXwQOBZ4aFXtCFxC15pn2GumsXuSwdfuSXd0sImqOn2g6+M+JyX7VtU3mbofeKq6ZlLr2cCBSR5J976dAdAfNp8DvAN4eP9efI5N34tBdzD15/5T4G0DgbFjVW1TVWcOmc+lwKOTDLa49+2HD7MvXev+51V1O/B+uh3NVGrYOlTVTwZP6m3m9VO5Fth5Ut17Atf0j99Hd4L9sVW1A935ianey9laR9eVMWGPucwkye/TdcX8Id3R6050O9Rh79cvq+rEqtqH7sjjCLqjnZ/SbQs7D3zWO1TV0HMe9wcG+KbWAC9JsnWSFXR9gfPSz2sfuj7GRwDvGjJNkuye5ATgGLo/EJI8NcnTkmxNt3P5Bd1hNsB6uqsXJmxL9we+oX/t0fQnZ+foYcBr+/r/CNiHLgTn4k3AK5K8MclD+/r2TfLP/fj1wEOT/PrAa9YDyzd3AqmqNgBfAj4C/GdVre1HPZCuJbUB2JjkELrzCVNZA7w0yVZ9n+xg98AHgT/vP4ck2TbJYZPCbqKeH/bzOiHJg9OdRH4S3c5kmG8DxyR5SJKHACvp+swnWtUHJHlgP6830rUmv76Z9ZiTqvop8A3gb/tlPQl4Jd15FuiOEG4Fbk/yG3RXEA2avC3OxlnA0Un26c+X/PUc57M9sBG4Htia7iT9tsMmTPKsdBcDPIBuve4C7u7fhy8D70iyQ5IHJNk7yTOHzef+wADf1P+gO3lxE11f3Bmbn3yzXtwfzt4MnEvXx/nbVTXYit2tn+Z2uj/m3wIOrKqJ6313oAuQm+gOaW+ga1UCfAh4Qn+o96mq+j7wTrrW7vp+XvP5Y78QeCzdH8TbgBdW1Q1zmVFVfYOuj/pZwJXproJZRb9DqKrL6HZwV/brsxtd6xrghsF+ziHOoDsBdu9n1XcFvJYuHG6i6145dzPzeB3d0dHNdC2xTw3MazVdP/gp/byuoD8BN4WX0J38ugk4ie59m9ipvizJYGv8T+n6uK+ma+0+emDe29O1fG/qxx0MHDLXz2AGjuxruZbuapgTqur8ftwb6N7D2+i2x8knKk8ETus/uxfNZqFV9XngPXR9/FfQbb/QnWeYjc/RdYtcDlxFF8xTnXfZje5igVvpjo6+QLf9AfwxXfB/n+69P5sRHomPWsp/6KBJkrwCOKaqfmfctWhp6Y9WLwEe1J+M1GbYApc0VkmO6LuKdqL7DsRnDO+ZMcCXqCTvz6ZfR574ef+4a9OS8yq68xU/ojvHM7mPXVOwC0WSGmULXJIatWg3NALYZZddavny5Yu5SElq3kUXXXR9Vd3npmiLGuDLly9n9erVi7lISWpekh8PG24XiiQ1ygCXpEYZ4JLUKANckhplgEtSowxwSWqUAS5JjTLAJalRBrgkNWpRv4mpLdfy4z87dPhVJ83l/yBLmglb4JLUKANckhplgEtSowxwSWqUAS5JjTLAJalRBrgkNcoAl6RGGeCS1CgDXJIaZYBLUqOmDfAkeyS5IMnaJJcmeV0//MQk1yRZ0/8cuvDlSpImzORmVhuB46rq4iTbAxclOb8fd3JVvWPhypMkTWXaAK+qdcC6/vFtSdYCuy90YZKkzZtVH3iS5cCTgQv7Qccm+W6SDyfZaYrXrEyyOsnqDRs2zKtYSdKvzDjAk2wHnAO8vqpuBd4HPAbYj66F/s5hr6uqVVW1oqpWLFu2bAQlS5JghgGeZGu68D69qj4BUFXrq+ruqroH+CCw/8KVKUmabCZXoQT4ELC2qt41MHzXgcmOAC4ZfXmSpKnM5CqUA4CXA99LsqYf9mbgyCT7AQVcBbxqQSqUJA01k6tQvgZkyKjPjb4cSdJM+U1MSWqUAS5JjTLAJalRBrgkNcoAl6RGGeCS1CgDXJIaZYBLUqMMcElqlAEuSY0ywCWpUQa4JDXKAJekRhngktQoA1ySGmWAS1KjDHBJatRM/qWatGiWH//ZocOvOumwRa5Euv+zBS5JjTLAJalRBrgkNcoAl6RGGeCS1CgDXJIaZYBLUqMMcElqlAEuSY0ywCWpUQa4JDVq2gBPskeSC5KsTXJpktf1w3dOcn6Sy/vfOy18uZKkCTNpgW8EjquqfYCnA69J8gTgeOCLVfVY4Iv9c0nSIpk2wKtqXVVd3D++DVgL7A48Hzitn+w04AULVaQk6b5m1QeeZDnwZOBC4OFVtQ66kAceNsVrViZZnWT1hg0b5letJOleMw7wJNsB5wCvr6pbZ/q6qlpVVSuqasWyZcvmUqMkaYgZBXiSrenC+/Sq+kQ/eH2SXfvxuwLXLUyJkqRhZnIVSoAPAWur6l0Do84FjuofHwV8evTlSZKmMpN/qXYA8HLge0nW9MPeDJwEnJXklcBPgD9amBIlScNMG+BV9TUgU4w+aLTlSJJmym9iSlKjDHBJatRM+sCley0//rPjLkFSzxa4JDXKAJekRhngktQoA1ySGmWAS1KjDHBJapQBLkmNMsAlqVEGuCQ1ygCXpEYZ4JLUKANckhplgEtSowxwSWqUt5PVgprq9rNXnXTYIlcibXlsgUtSowxwSWqUAS5JjTLAJalRBrgkNcoAl6RGGeCS1CgDXJIaZYBLUqMMcElqlAEuSY0ywCWpUdMGeJIPJ7kuySUDw05Mck2SNf3PoQtbpiRpspm0wE8FDh4y/OSq2q//+dxoy5IkTWfaAK+qrwA3LkItkqRZmM/9wI9N8ifAauC4qrpp2ERJVgIrAfbcc895LE6aP+9Pri3JXE9ivg94DLAfsA5451QTVtWqqlpRVSuWLVs2x8VJkiabU4BX1fqquruq7gE+COw/2rIkSdOZU4An2XXg6RHAJVNNK0laGNP2gSc5EzgQ2CXJ1cAJwIFJ9gMKuAp41QLWKEkaYtoAr6ojhwz+0ALUIkmaBb+JKUmNMsAlqVEGuCQ1ygCXpEYZ4JLUKANckhplgEtSowxwSWqUAS5JjZrP7WSlOZvqtq6znd7bwGopswUuSY0ywCWpUQa4JDXKAJekRhngktQoA1ySGmWAS1KjvA5cWiRey65RswUuSY0ywCWpUQa4JDXKAJekRhngktQoA1ySGuVlhEuYl7VJbbMFLkmNMsAlqVEGuCQ1ygCXpEZNG+BJPpzkuiSXDAzbOcn5SS7vf++0sGVKkiabSQv8VODgScOOB75YVY8Fvtg/lyQtomkDvKq+Atw4afDzgdP6x6cBLxhxXZKkacy1D/zhVbUOoP/9sKkmTLIyyeokqzds2DDHxUmSJlvwk5hVtaqqVlTVimXLli304iRpyZhrgK9PsitA//u60ZUkSZqJuQb4ucBR/eOjgE+PphxJ0kzN5DLCM4FvAo9PcnWSVwInAc9JcjnwnP65JGkRTXszq6o6copRB424FknSLPhNTElqlAEuSY3yfuC6j6nuE65NeT91jZstcElqlAEuSY0ywCWpUQa4JDXKAJekRhngktQoA1ySGmWAS1KjDHBJapQBLkmNMsAlqVEGuCQ1ygCXpEYZ4JLUKG8nK+GtYdUmW+CS1CgDXJIaZYBLUqMMcElqlAEuSY0ywCWpUQa4JDXK68Cl+ymvTdd0bIFLUqMMcElqlAEuSY2aVx94kquA24C7gY1VtWIURUmSpjeKk5i/X1XXj2A+kqRZsAtFkho13xZ4AeclKeADVbVq8gRJVgIrAfbcc895Lk7alJfaaSmbbwv8gKp6CnAI8Jokz5w8QVWtqqoVVbVi2bJl81ycJGnCvAK8qq7tf18HfBLYfxRFSZKmN+cAT7Jtku0nHgPPBS4ZVWGSpM2bTx/4w4FPJpmYzxlV9X9HUpUkaVpzDvCquhLYd4S1SJJmwcsIJalRBrgkNcrbyWqLNNX14eOazzh5rfyWyxa4JDXKAJekRhngktQoA1ySGmWAS1KjDHBJapQBLkmNSlUt2sJWrFhRq1evXrTlqbMlXMus6U11XfdsP//ZzsfryRdekouG/ctKW+CS1CgDXJIaZYBLUqMMcElqlAEuSY0ywCWpUUvudrKbu6RqoS+H8jIsSaNkC1ySGmWAS1KjDHBJapQBLkmNMsAlqVEGuCQ1ygCXpEZtsdeBz+UWqqO67epsr+se1fXh3jZW4zDO71aMSqvf0bAFLkmNMsAlqVEGuCQ1ygCXpEbNK8CTHJzkB0muSHL8qIqSJE1vzgGeZCvgvcAhwBOAI5M8YVSFSZI2bz4t8P2BK6rqyqr6JfDPwPNHU5YkaTqpqrm9MHkhcHBVHdM/fznwtKo6dtJ0K4GV/dPHAz+Ye7ljswtw/biLWERLbX3BdV4qWl3nvapq2eSB8/kiT4YMu8/eoKpWAavmsZyxS7K6qlaMu47FstTWF1znpWJLW+f5dKFcDewx8PyRwLXzK0eSNFPzCfBvA49N8qgkDwReApw7mrIkSdOZcxdKVW1Mcizwr8BWwIer6tKRVXb/0nQX0BwstfUF13mp2KLWec4nMSVJ4+U3MSWpUQa4JDXKAJ+FJG9IUkl2GXctCy3JPyS5LMl3k3wyyY7jrmmhLLVbQiTZI8kFSdYmuTTJ68Zd02JIslWS/0jyL+OuZVQM8BlKsgfwHOAn465lkZwPPLGqngT8EPhvY65nQSzRW0JsBI6rqn2ApwOvWQLrDPA6YO24ixglA3zmTgbexJAvK22Jquq8qtrYP/0W3XX+W6Ild0uIqlpXVRf3j2+jC7Xdx1vVwkrySOAw4J/GXcsoGeAzkOQPgGuq6jvjrmVM/hT4/LiLWCC7Az8deH41W3iYDUqyHHgycOF4K1lw76ZrgN0z7kJGaYv9n5izleQLwCOGjHoL8GbguYtb0cLb3DpX1af7ad5Cd8h9+mLWtohmdEuILVGS7YBzgNdX1a3jrmehJDkcuK6qLkpy4LjrGSUDvFdVzx42PMlvAY8CvpMEuq6Ei5PsX1U/W8QSR26qdZ6Q5CjgcOCg2nK/MLAkbwmRZGu68D69qj4x7noW2AHAHyQ5FHgwsEOSj1bVH4+5rnnzizyzlOQqYEVVtXhHsxlLcjDwLuD3qmrDuOtZKEl+je4k7UHANXS3iHjpFvytYtK1RE4Dbqyq14+7nsXUt8DfUFWHj7uWUbAPXFM5BdgeOD/JmiTvH3dBC6E/UTtxS4i1wFlbcnj3DgBeDjyr/2zX9K1TNcYWuCQ1yha4JDXKAJekRhngktQoA1ySGmWAS1KjDHAtCUnu7i+XuyTJ2Um2mWb6U5O8sH/8pSRbzD/C1ZbDANdScWdV7VdVTwR+Cfz5uAuS5ssA11L0VWDvJMuTXDIxsL/f+4njK0uaHQNcS0r/1flDgO+NuxZpvgxwLRUPSbIGWE33Tzk+NOZ6pHnzboRaKu6sqv0GByTZyKaNmAcvbknS/NgC11K2HnhYkocmeRDdrXOlZtgC15JVVXcl+Ru6/0bzn8BlYy5JmhXvRihJjbILRZIaZYBLUqMMcElqlAEuSY0ywCWpUQa4JDXKAJekRv1/Nouyb4sjZzAAAAAASUVORK5CYII=\n", "text/plain": [ "
" ] @@ -2414,61 +2414,61 @@ "output_type": "stream", "text": [ "BR: 0.0003\n", - "0.8995215311004785\n", + "0.8744588744588745\n", "\n", "BR: 0.0004\n", - "0.8708133971291866\n", + "0.8398268398268398\n", "\n", "BR: 0.0006\n", - "0.6985645933014354\n", + "0.7272727272727273\n", "\n", "BR: 0.0007\n", - "0.6220095693779905\n", + "0.6320346320346321\n", "\n", "BR: 0.0009\n", - "0.49760765550239233\n", + "0.4935064935064935\n", "\n", "BR: 0.0010\n", - "0.45933014354066987\n", + "0.45021645021645024\n", "\n", "BR: 0.0012\n", - "0.36363636363636365\n", + "0.3722943722943723\n", "\n", "BR: 0.0013\n", - "0.2679425837320574\n", + "0.2597402597402597\n", "\n", "BR: 0.0015\n", - "0.1722488038277512\n", + "0.19047619047619047\n", "\n", "BR: 0.0016\n", - "0.15311004784688995\n", + "0.17316017316017315\n", "\n", "BR: 0.0018\n", - "0.14354066985645933\n", + "0.15584415584415584\n", "\n", "BR: 0.0019\n", - "0.14354066985645933\n", + "0.1645021645021645\n", "\n", "BR: 0.0021\n", - "0.09569377990430622\n", + "0.1038961038961039\n", "\n", "BR: 0.0022\n", - "0.06698564593301436\n", + "0.06926406926406926\n", "\n", "BR: 0.0024\n", - "0.09569377990430622\n", + "0.08658008658008658\n", "\n", "BR: 0.0025\n", - "0.04784688995215311\n", + "0.07792207792207792\n", "\n", "BR: 0.0027\n", - "0.03827751196172249\n", + "0.04329004329004329\n", "\n", "BR: 0.0028\n", - "0.05741626794258373\n", + "0.05194805194805195\n", "\n", "BR: 0.0030\n", - "0.04784688995215311\n", + "0.05194805194805195\n", "\n" ] } @@ -2511,7 +2511,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "2 min, 19 s\n" + "2 min, 20 s\n" ] } ], @@ -2521,82 +2521,12 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 57, "metadata": {}, "outputs": [], "source": [ "# variab['mi'] =! mi" ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": {