How to use the flavio.WilsonCoefficients function in flavio

To help you get started, we’ve selected a few flavio examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github flav-io / flavio / flavio / physics / higgs / test_higgs.py View on Github external
import unittest
import flavio
import wilson
from math import sqrt


par = flavio.default_parameters.get_central_all()
wc = flavio.WilsonCoefficients()
wc.set_initial({}, 91.1876, 'SMEFT', 'Warsaw')


class TestHiggsProduction(unittest.TestCase):
    def test_mugg(self):
        RSM = flavio.physics.higgs.production.ggF(wc.wc)
        self.assertEqual(RSM, 1)


class TestHiggsDecay(unittest.TestCase):
    def test_mugg(self):
        RSM = flavio.physics.higgs.decay.h_bb(wc.wc)
        self.assertEqual(RSM, 1)


class TestHiggsWidth(unittest.TestCase):
github flav-io / flavio / flavio / physics / bdecays / bvll / test_bvll.py View on Github external
def test_bs_timedep(self):
        q2 = 3
        wc_obj = flavio.WilsonCoefficients()
        par = flavio.default_parameters.get_central_all()
        B = 'Bs'
        V = 'phi'
        l = 'mu'
        # a set of parameters with y_s=0!
        par_y0 = par.copy()
        par_y0['DeltaGamma/Gamma_Bs']=0

        # compare without lifetime effect: must be equal!
        self.assertEqual(
            observables.BVll_obs(observables.dGdq2_ave, q2, B, V, l, wc_obj, par_y0)(),
            observables_bs.bsvll_obs(observables_bs.dGdq2_ave_Bs, q2, wc_obj, par_y0, B, V, l))
        self.assertEqual(
            observables.BVll_obs(observables.FL, q2, B, V, l, wc_obj, par_y0)(),
            observables_bs.bsvll_obs( observables_bs.FL_Bs, q2, wc_obj, par_y0, B, V, l))
        for i in [3, 4, 7]: # S3,4,7
github flav-io / flavio / flavio / physics / kdecays / test_kpilnu.py View on Github external
def test_RT(self):
        self.assertEqual(flavio.sm_prediction('RT(K->pimunu)'), 0)
        wc = flavio.WilsonCoefficients()
        wc.set_initial({'CT_sumunumu': 1}, par['m_rho0'])
        self.assertEqual(flavio.np_prediction('RT(K->pienu)', wc), 0)
        self.assertNotEqual(flavio.np_prediction('RT(K->pimunu)', wc), 0)
github flav-io / flavio / flavio / physics / ddecays / test_dplnu.py View on Github external
def test_dplnu_nu(self):
        wc_sm = flavio.WilsonCoefficients()
        wc_np_mu = flavio.WilsonCoefficients()
        wc_np_mu.set_initial({'CVL_dcmunumu': 1}, 2)
        wc_np_e = flavio.WilsonCoefficients()
        wc_np_e.set_initial({'CVL_dcmunue': 1}, 2)
        obs = flavio.Observable["BR(D+->pimunu)"]
        constraints = flavio.default_parameters
        br_sm = obs.prediction_central(constraints, wc_sm)
        br_mu = obs.prediction_central(constraints, wc_np_mu)
        br_e = obs.prediction_central(constraints, wc_np_e)
        # with interference: (1 + 1)^2 = 4
        self.assertAlmostEqual(br_mu / br_sm, 4, delta=0.04)
        # without interference: 1 + 1 = 2
        self.assertAlmostEqual(br_e / br_sm, 2, delta=0.02)
github flav-io / flavio / flavio / physics / bdecays / test_lambdablambdall.py View on Github external
import unittest
import numpy as np
import flavio


wc_sm = flavio.WilsonCoefficients()
# choose parameters as required to compare numerics to arXiv:1602.01399
par_nominal = flavio.default_parameters.copy()
flavio.physics.bdecays.formfactors.lambdab_12.lattice_parameters.lattice_load_nominal(par_nominal)
par_nominal.set_constraint('Vcb', 0.04175)
par_nominal.set_constraint('tau_Lambdab', 1/4.49e-13) # PDG 2016 value
par_nominal.set_constraint('Lambda->ppi alpha_-', 0.642) # PDG 2016 value
par_dict = par_nominal.get_central_all()

def ass_sm(s, name, q2min, q2max, target, delta, scalef=1):
    obs = flavio.classes.Observable[name]
    c = obs.prediction_central(par_nominal, wc_sm, q2min, q2max)*scalef
    s.assertAlmostEqual(c, target, delta=delta)

class TestLambdabLambdall(unittest.TestCase):
    def test_lambdablambdall(self):
        # first, make sure we use the same CKM factor as in arXiv:1602.01399 eq. (69)
github flav-io / flavio / flavio / physics / bdecays / test_angular.py View on Github external
import unittest
import numpy as np
import flavio

constraints = flavio.default_parameters
wc_obj = flavio.WilsonCoefficients()
par = constraints.get_central_all()

class TestAngular(unittest.TestCase):
    def test_timedependent(self):
        # self.assertAlmostEqual(
        #     flavio.sm_prediction('BR(B0->K*nunu)')/9.48e-6,
        #     1, delta=0.2)
        q2 = 3.
        B = 'B0'
        V = 'K*0'
        lep = 'mu'
        mB = par['m_'+B]
        mV = par['m_'+V]
        ml = par['m_'+lep]
        scale = 4.8
        mb = flavio.physics.running.running.get_mb(par, scale)
github flav-io / flavio / flavio / physics / edms / test_neutronedm.py View on Github external
def test_nedm_jms_CEDM(self):
        wc = wcxf.WC('WET', 'JMS', 160, {'dG_11': {'Im': 1e-10}})
        wcf = flavio.WilsonCoefficients()
        wcf.set_initial_wcxf(wc)
        wcd = wcf.get_wc('dF=0', scale=2, par=par, eft='WET-3', basis='flavio')
        self.assertAlmostEqual(wcd['C8_dd'] / 1j, 0.07, delta=0.02)
        par_dG = par.copy()
        par_dG['gT_d'] = 0
        par_dG['nEDM beta_G'] = 0
        par_dG['gT_u'] = 0
        par_dG['nEDM ~rho_u'] = 0
        p = flavio.Observable['d_n'].prediction_par(par_dG, wcf)
        v = 246.22
        self.assertAlmostEqual(p,
                               abs(-2*par_dG['nEDM ~rho_d']*1e-10),
                               delta=0.3e-10)
github flav-io / flavio / flavio / physics / bdecays / test_bxlnu.py View on Github external
import unittest
import numpy as np
import flavio
from flavio.physics.bdecays.bxlnu import g, gLR, gVS, gVSp

par = flavio.default_parameters.get_central_all()
wc_obj = flavio.WilsonCoefficients()
par['Vcb'] = 0.04221 # inclusive Vcb: see 1411.6560

class TestBXlnu(unittest.TestCase):
    def test_bxclnu(self):
        # check that the NLO and NNLO functions reproduce the correct numbers
        self.assertAlmostEqual(
            flavio.physics.bdecays.bxlnu.pc1(r=(0.986/4.6)**2, mb=4.6),
            -1.65019, delta=0.001)
        self.assertAlmostEqual(
            flavio.physics.bdecays.bxlnu.pc2(r=(0.986/4.6)**2, mb=4.6),
            -1.91556 -0.4519 * 9 , delta=0.001)
        # check that the total BR roughly agrees with the experimental value
        self.assertAlmostEqual(
            flavio.sm_prediction('BR(B->Xcenu)'),
            0.1065,
            delta = 0.0023)
github smelli / smelli / smelli / classes.py View on Github external
def obstable_sm(self):
        self._check_sm_cov_loaded()
        if self._obstable_sm is None:
            info = tree()  # nested dict
            for flh_name, flh in self.fast_likelihoods.items():
                # loop over fast likelihoods: they only have a single "measurement"
                m = flh.pseudo_measurement
                ml = flh.full_measurement_likelihood
                pred_sm = ml.get_predictions_par(self.par_dict_sm,
                                                 flavio.WilsonCoefficients())
                sm_cov = flh.sm_covariance.get(force=False)
                _, exp_cov = flh.exp_covariance.get(force=False)
                inspire_dict = self._get_inspire_dict(flh.observables, ml)
                for i, obs in enumerate(flh.observables):
                    info[obs]['lh_name'] = flh_name
                    info[obs]['name'] = obs if isinstance(obs, str) else obs[0]
                    info[obs]['th. unc.'] = np.sqrt(sm_cov[i, i])
                    info[obs]['experiment'] = m.get_central(obs)
                    info[obs]['exp. unc.'] = np.sqrt(exp_cov[i, i])
                    info[obs]['exp. PDF'] = NormalDistribution(m.get_central(obs), np.sqrt(exp_cov[i, i]))
                    info[obs]['inspire'] = sorted(set(inspire_dict[obs]))
                    info[obs]['ll_sm'] = m.get_logprobability_single(obs, pred_sm[obs])
                    info[obs]['ll_central'] = m.get_logprobability_single(obs, m.get_central(obs))
            for lh_name, lh in self.likelihoods.items():
                # loop over "normal" likelihoods
                ml = lh.measurement_likelihood
github flav-io / flavio / flavio / functions.py View on Github external
def __getitem__(self, key):
        """Get an item, adding the key to the `pcalled` set."""
        self.akeys.add(key)
        return dict.__getitem__(self, key)

    def __copy__(self):
        cp = type(self)(self.d)
        cp.akeys = self.akeys
        return cp

    def copy(self):
        return self.__copy__()


class AwareWilson(flavio.WilsonCoefficients):
    """Subclass of `flavio.WilsonCoefficients` that adds the arguments of calls
    to its `match_run`  method to `atuples` attribute."""
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.atuples = set()

    def match_run(self, scale, eft, basis, sectors='all'):
        self.atuples.add((scale, eft, basis, sectors))
        return super().match_run(scale, eft, basis, sectors)


def get_dependent_parameters_sm(obs_name, *args, **kwargs):
    """Get the set of parameters the SM prediction of the observable depends on."""
    obs = flavio.classes.Observable[obs_name]
    wc_sm = flavio.physics.eft._wc_sm
    par_central = flavio.default_parameters.get_central_all()