def test_DecayChain_flatten_complex(): dm1 = DecayMode(1.0, "D0 K_S0 pi+ pi0") dm2 = DecayMode(0.0124, "K_S0 pi0 pi0") dm3 = DecayMode(0.692, "pi+ pi-") dm4 = DecayMode(0.98823, "gamma gamma") dc = DecayChain("X+", {"X+": dm1, "D0": dm2, "K_S0": dm3, "pi0": dm4}) dc_flatten = dc.flatten() assert dc_flatten.decays[dc_flatten.mother].daughters == DaughtersDict({ "gamma": 6, "pi+": 3, "pi-": 2 }) assert dc_flatten.bf == approx(1.0 * 0.0124 * (0.692**2) * (0.98823**3))
def test_DecayChain_constructor_from_dict(): dc_dict = { 'D0': [{ 'bf': 0.0124, 'fs': [{ 'K_S0': [{ 'bf': 0.692, 'fs': ['pi+', 'pi-'], 'model': '', 'model_params': '' }] }, { 'pi0': [{ 'bf': 0.98823, 'fs': ['gamma', 'gamma'], 'model': '', 'model_params': '' }] }], 'model': 'PHSP', 'model_params': '' }] } assert DecayChain.from_dict(dc_dict).to_dict() == dc_dict
def test_DecayChain_constructor_from_dict(): dc_dict = { "D0": [{ "bf": 0.0124, "fs": [ { "K_S0": [{ "bf": 0.692, "fs": ["pi+", "pi-"], "model": "", "model_params": "", }] }, { "pi0": [{ "bf": 0.98823, "fs": ["gamma", "gamma"], "model": "", "model_params": "", }] }, ], "model": "PHSP", "model_params": "", }] } assert DecayChain.from_dict(dc_dict).to_dict() == dc_dict
def test_DecayChain_flatten_with_stable_particles(): dm1 = DecayMode(0.5, "D0 anti-D0 pi+ pi0 pi0") dm2 = DecayMode(0.0124, "K_S0 pi0") dm3 = DecayMode(0.692, "pi+ pi-") dm4 = DecayMode(0.98823, "gamma gamma") dc = DecayChain("X+", { "X+": dm1, "D0": dm2, "anti-D0": dm2, "K_S0": dm3, "pi0": dm4 }) dc_flatten = dc.flatten(stable_particles=["pi0"]) assert dc_flatten.decays[dc_flatten.mother].daughters == DaughtersDict({ "pi0": 4, "pi+": 3, "pi-": 2 }) assert dc_flatten.bf == approx(0.5 * (0.0124**2) * (0.692**2))
def test_DecayMode_string_repr(): dd = DaughtersDict('p p~ K+ pi-') dm = DecayMode(1.e-6, dd, model='PHSP') assert str(dm) == "<DecayMode: daughters=K+ p pi- p~, BF=1e-06>" def test_DecayMode_number_of_final_states(): dd = DaughtersDict('p p~ K+ pi-') dm = DecayMode(1.e-6, dd, model='PHSP') assert len(dm) == 4 dm1 = DecayMode(0.0124, 'K_S0 pi0', model='PHSP') dm2 = DecayMode(0.692, 'pi+ pi-') dm3 = DecayMode(0.98823, 'gamma gamma') dc = DecayChain('D0', {'D0': dm1, 'K_S0': dm2, 'pi0': dm3}) dm1 = DecayMode(0.6770, 'D0 pi+') dm2 = DecayMode(0.0124, 'K_S0 pi0') dm3 = DecayMode(0.692, 'pi+ pi-') dm4 = DecayMode(0.98823, 'gamma gamma') dc2 = DecayChain('D*+', {'D*+': dm1, 'D0': dm2, 'K_S0': dm3, 'pi0': dm4}) def test_DecayChain_constructor_subdecays(): assert len(dc.decays) == 3 assert dc.mother == 'D0' def test_DecayChain_constructor_from_dict(): dc_dict = {
def dc2(): dm1 = DecayMode(0.6770, "D0 pi+") dm2 = DecayMode(0.0124, "K_S0 pi0") dm3 = DecayMode(0.692, "pi+ pi-") dm4 = DecayMode(0.98823, "gamma gamma") return DecayChain("D*+", {"D*+": dm1, "D0": dm2, "K_S0": dm3, "pi0": dm4})
def dc(): dm1 = DecayMode(0.0124, "K_S0 pi0", model="PHSP") dm2 = DecayMode(0.692, "pi+ pi-") dm3 = DecayMode(0.98823, "gamma gamma") return DecayChain("D0", {"D0": dm1, "K_S0": dm2, "pi0": dm3})