Beispiel #1
0
def test_duplicate_decay_definitions():
    p = DecFileParser(DIR / '../data/duplicate-decays.dec')
    p.parse()

    assert p.number_of_decays == 2

    assert p.list_decay_mother_names() == ['Sigma(1775)0', 'anti-Sigma(1775)0']
Beispiel #2
0
def test_graphs_with_EvtGen_specific_names():
    p = DecFileParser(DIR / "../../src/decaylanguage/data/DECAY_LHCB.DEC")
    p.parse()

    # Not setting many of the particles as stable would result in a gargantuesque chain,
    # which would also take a fair amount of time to build!
    list_stable_particles = [
        "Xi_c0",
        "Xi-",
        "D0",
        "Omega_c0",
        "Sigma_c0",
        "tau-",
        "D_s-",
        "J/psi",
        "pi0",
        "Lambda0",
        "psi(2S)",
    ]

    chain = p.build_decay_chains("Xi_b-",
                                 stable_particles=list_stable_particles)
    dcv = DecayChainViewer(chain)

    assert "(cs)<SUB>0</SUB>" in dcv.to_string()  # not 'cs_0' ;-)
    assert "&#x039e;<SUB>b</SUB><SUP>-</SUP>" in dcv.to_string()
    assert "&#x039e;<SUB>c</SUB><SUP>0</SUP>" in dcv.to_string()
Beispiel #3
0
def test_list_charge_conjugate_decays():
    p = DecFileParser(DIR / '../data/test_Bd2DmTauNu_Dm23PiPi0_Tau2MuNu.dec')
    p.parse()

    assert p.list_charge_conjugate_decays() == [
        'MyD+', 'MyTau+', 'Mya_1-', 'anti-B0sig'
    ]
Beispiel #4
0
def test_constructor_multiple_files():
    p = DecFileParser(DIR / '../data/test_Xicc2XicPiPi.dec',
                      DIR / '../data/test_Bc2BsPi_Bs2KK.dec')
    p.parse()

    assert len(p._dec_file_names) == 2
    assert p.number_of_decays == 7
Beispiel #5
0
def test_BELLE2_decfile():
    p = DecFileParser(DIR / '../../decaylanguage/data/DECAY_BELLE2.DEC')
    p.parse()

    # Just check the dec file will parse since I do not know
    # how many decays are in the dec file.
    assert p.number_of_decays == 356
Beispiel #6
0
def test_init_non_defaults():
    p = DecFileParser(DIR / '../data/test_example_Dst.dec')
    p.parse()

    chain = p.build_decay_chains('D*+')
    dcv = DecayChainViewer(chain, graph_name='TEST', rankdir='TB')

    assert dcv.graph.get_name() == 'TEST'
    assert dcv.graph.get_rankdir() == 'TB'
Beispiel #7
0
def test_init_non_defaults_basic():
    p = DecFileParser(DIR / "../data/test_example_Dst.dec")
    p.parse()

    chain = p.build_decay_chains("D*+")
    dcv = DecayChainViewer(chain, name="TEST", format="pdf")

    assert dcv.graph.name == "TEST"
    assert dcv.graph.format == "pdf"
Beispiel #8
0
def test_constructor_multiple_files():
    p = DecFileParser(DIR / "../data/test_Xicc2XicPiPi.dec",
                      DIR / "../data/test_Bc2BsPi_Bs2KK.dec")

    with pytest.warns(UserWarning) as record:
        p.parse()
    assert len(record) == 1

    assert len(p._dec_file_names) == 2
    assert p.number_of_decays == 7
Beispiel #9
0
def test_list_charge_conjugate_decays():
    p = DecFileParser(DIR / "../data/test_Bd2DmTauNu_Dm23PiPi0_Tau2MuNu.dec")
    p.parse()

    assert p.list_charge_conjugate_decays() == [
        "MyD+",
        "MyTau+",
        "Mya_1-",
        "anti-B0sig",
    ]
Beispiel #10
0
def test_pythia_definitions_parsing():
    p = DecFileParser(DIR / '../data/defs-aliases-chargeconj.dec')
    p.parse()

    assert p.dict_pythia_definitions() == {
        'ParticleDecays:mixB': 'off',
        'Init:showChangedSettings': 'off',
        'Init:showChangedParticleData': 'off',
        'Next:numberShowEvent': 0.0
    }
Beispiel #11
0
def test_list_lineshape_definitions():
    p = DecFileParser(DIR / '../data/defs-aliases-chargeconj.dec')
    p.parse()

    assert p.list_lineshape_definitions() == [
        (['D_1+', 'D*+', 'pi0'], 2), (['D_1+', 'D*0', 'pi+'], 2),
        (['D_1-', 'D*-', 'pi0'], 2), (['D_1-', 'anti-D*0', 'pi-'], 2),
        (['D_10', 'D*0', 'pi0'], 2), (['D_10', 'D*+', 'pi-'], 2),
        (['anti-D_10', 'anti-D*0', 'pi0'], 2), (['anti-D_10', 'D*-', 'pi+'], 2)
    ]
Beispiel #12
0
def test_pythia_definitions_parsing():
    p = DecFileParser(DIR / "../data/defs-aliases-chargeconj.dec")
    p.parse()

    assert p.dict_pythia_definitions() == {
        "ParticleDecays:mixB": "off",
        "Init:showChangedSettings": "off",
        "Init:showChangedParticleData": "off",
        "Next:numberShowEvent": 0.0,
    }
Beispiel #13
0
def test_single_decay():
    p = DecFileParser(DIR / '../data/test_example_Dst.dec')
    p.parse()

    chain = p.build_decay_chains('D*+', stable_particles=['D+', 'D0', 'pi0'])
    dcv = DecayChainViewer(chain)
    graph_output_as_dot = dcv.to_string()

    assert 'mother -> dec0  [label="0.677"]' in graph_output_as_dot
    assert 'mother -> dec1  [label="0.307"]' in graph_output_as_dot
    assert 'mother -> dec2  [label="0.016"]' in graph_output_as_dot
Beispiel #14
0
def test_duplicate_decay_definitions():
    p = DecFileParser(DIR / "../data/duplicate-decays.dec")

    with pytest.warns(UserWarning) as w:
        p.parse()

    assert len(w) == 2

    assert p.number_of_decays == 2

    assert p.list_decay_mother_names() == ["Sigma(1775)0", "anti-Sigma(1775)0"]
Beispiel #15
0
def test_creation_charge_conjugate_decays_in_decfile_with_aliases():
    """
    Decay file contains 5 particle decays defined via a 'Decay' statement
    and the 5 charge-conjugate decays defined via a 'CDecay' statement.
    The decay modes for the latter 5 should be created on the fly,
    hence providing in total 10 sets of particle decays parsed.
    """
    p = DecFileParser(DIR / '../data/test_Bd2DstDst.dec')
    p.parse()

    assert p.number_of_decays == 10
Beispiel #16
0
def test_single_decay():
    p = DecFileParser(DIR / "../data/test_example_Dst.dec")
    p.parse()

    chain = p.build_decay_chains("D*+", stable_particles=["D+", "D0", "pi0"])
    dcv = DecayChainViewer(chain)
    graph_output_as_dot = dcv.to_string()

    assert "mother -> dec0 [label=0.677]" in graph_output_as_dot
    assert "mother -> dec1 [label=0.307]" in graph_output_as_dot
    assert "mother -> dec2 [label=0.016]" in graph_output_as_dot
Beispiel #17
0
def test_build_decay_chains():
    p = DecFileParser(DIR / '../data/test_example_Dst.dec')
    p.parse()

    output = {
        'D+': [{
            'bf': 1.0,
            'fs': ['K-', 'pi+', 'pi+', 'pi0'],
            'model': 'PHSP',
            'model_params': ''
        }]
    }
    assert p.build_decay_chains('D+', stable_particles=['pi0']) == output
Beispiel #18
0
def test_build_decay_chains():
    p = DecFileParser(DIR / "../data/test_example_Dst.dec")
    p.parse()

    output = {
        "D+": [{
            "bf": 1.0,
            "fs": ["K-", "pi+", "pi+", "pi0"],
            "model": "PHSP",
            "model_params": "",
        }]
    }
    assert p.build_decay_chains("D+", stable_particles=["pi0"]) == output
Beispiel #19
0
def test_simple_decay_chain():
    p = DecFileParser(DIR / '../data/test_example_Dst.dec')
    p.parse()

    chain = p.build_decay_chains('D*+')
    dcv = DecayChainViewer(chain)
    graph_output_as_dot = dcv.to_string()

    assert 'mother -> dec3  [label="0.677"]' in graph_output_as_dot
    assert 'dec3:p0 -> dec4  [label="1.0"]' in graph_output_as_dot
    assert 'mother -> dec5  [label="0.307"]' in graph_output_as_dot
    assert 'dec5:p0 -> dec6  [label="1.0"]' in graph_output_as_dot
    assert 'dec6:p3 -> dec7  [label="0.988228297"]' in graph_output_as_dot
Beispiel #20
0
def test_init_non_defaults_attributes():
    p = DecFileParser(DIR / "../data/test_example_Dst.dec")
    p.parse()

    chain = p.build_decay_chains("D*+")
    node_attr = dict(shape="egg")
    edge_attr = dict(fontsize="9")
    dcv = DecayChainViewer(chain, node_attr=node_attr, edge_attr=edge_attr)

    assert dcv.graph.node_attr == dict(fontname="Helvetica",
                                       fontsize="11",
                                       shape="egg")
    assert dcv.graph.edge_attr == dict(fontcolor="#4c4c4c", fontsize="9")
Beispiel #21
0
def test_simple_decay_chain():
    p = DecFileParser(DIR / "../data/test_example_Dst.dec")
    p.parse()

    chain = p.build_decay_chains("D*+")
    dcv = DecayChainViewer(chain)
    graph_output_as_dot = dcv.to_string()

    assert "mother -> dec3 [label=0.677]" in graph_output_as_dot
    assert "dec3:p0 -> dec4 [label=1.0]" in graph_output_as_dot
    assert "mother -> dec5 [label=0.307]" in graph_output_as_dot
    assert "dec5:p0 -> dec6 [label=1.0]" in graph_output_as_dot
    assert "dec6:p3 -> dec7 [label=0.988228297]" in graph_output_as_dot
Beispiel #22
0
def test_list_lineshape_definitions():
    p = DecFileParser(DIR / "../data/defs-aliases-chargeconj.dec")
    p.parse()

    assert p.list_lineshape_definitions() == [
        (["D_1+", "D*+", "pi0"], 2),
        (["D_1+", "D*0", "pi+"], 2),
        (["D_1-", "D*-", "pi0"], 2),
        (["D_1-", "anti-D*0", "pi-"], 2),
        (["D_10", "D*0", "pi0"], 2),
        (["D_10", "D*+", "pi-"], 2),
        (["anti-D_10", "anti-D*0", "pi0"], 2),
        (["anti-D_10", "D*-", "pi+"], 2),
    ]
Beispiel #23
0
def test_creation_charge_conjugate_decays_in_decfile_without_CDecay_defs():
    """
    Decay file contains 5 particle decays defined via a 'Decay' statement,
    but no related charge-conjugate (CC) decays defined via a 'CDecay' statement
    since the CC particle decays are also defined via a 'Decay' statement
    for all cases except self-conjugate (mother) particles, obviously ;-).
    This being said, this decay file is in fact incomplete by itself,
    as there are no instructions on how to decay the anti-D0 and the D-!
    In short, there should only be 5 sets of decay modes parsed.
    """
    p = DecFileParser(DIR / '../data/test_example_Dst.dec')
    p.parse()

    assert p.number_of_decays == 5
Beispiel #24
0
def test_duplicate_arrows(decfilepath, signal_mother):
    """
    This test effectively checks whether any box node (node with subdecays)
    gets more than one arrow to it, which would show a bug
    in the creation of the DOT file recursively parsing the built decay chain.
    """
    p = DecFileParser(decfilepath, DIR / '../../decaylanguage/data/DECAY_LHCB.DEC')
    p.parse()

    chain = p.build_decay_chains(signal_mother)
    dcv = DecayChainViewer(chain)
    graph_output_as_dot = dcv.to_string()

    l = [i.split(' ')[0] for i in graph_output_as_dot.split('-> dec')[1:]]  # list of node identifiers
    assert len(set(l)) == len(l)
Beispiel #25
0
def test_print_decay_modes():
    p = DecFileParser(DIR / '../data/test_example_Dst.dec')
    p.parse()

    with pytest.raises(DecayNotFound):
        p.print_decay_modes('D*(2010)-')

    p.print_decay_modes('D*(2010)-', pdg_name=True)
Beispiel #26
0
def test_print_decay_modes_basics():
    p = DecFileParser(DIR / "../data/test_example_Dst.dec")
    p.parse()

    with pytest.raises(DecayNotFound):
        p.print_decay_modes("D*(2010)-")

    p.print_decay_modes("D*(2010)-", pdg_name=True)
Beispiel #27
0
def test_decay_model_parsing_with_variable_defs():
    """
    In this example the decay model details are "VSS_BMIX dm",
    where dm stands for a variable name whose value is defined via the statement
    'Define dm 0.507e12'. The parser should recognise this and return
    [0.507e12] rather than ['dm'] as model parameters.
    """
    p = DecFileParser(DIR / '../data/test_Upsilon4S2B0B0bar.dec')
    p.parse()

    assert p.dict_definitions() == {'dm': 507000000000.0}

    dl = p._parsed_decays[0].children[1]
    assert get_model_name(dl) == 'VSS_BMIX'
    assert get_model_parameters(dl) == [0.507e12]
Beispiel #28
0
def test_graphs_with_EvtGen_specific_names():
    p = DecFileParser(DIR / '../../decaylanguage/data/DECAY_LHCB.DEC')
    p.parse()

    # Not setting many of the particles as stable would result in a gargantuesque chain,
    # which would also take a fair amount of time to build!
    list_stable_particles = [
        'Xi_c0', 'Xi-', 'D0', 'Omega_c0', 'Sigma_c0', 'tau-', 'D_s-', 'J/psi',
        'pi0', 'Lambda0', 'psi(2S)'
    ]

    chain = p.build_decay_chains('Xi_b-',
                                 stable_particles=list_stable_particles)
    dcv = DecayChainViewer(chain)

    assert '(cs)<SUB>0</SUB>' in dcv.to_string()  # not 'cs_0' ;-)
    assert '&Xi;<SUB>c</SUB><SUP>0</SUP>' in dcv.to_string()
Beispiel #29
0
def test_copydecay_statement_parsing():
    p = DecFileParser(DIR / "../data/test_CopyDecay_RemoveDecay.dec")
    p.parse()

    assert len(p.dict_decays2copy()) == 2
    assert p.number_of_decays == 4  # 2 original + 2 copied
    assert p.list_decay_modes("phi_copy") == p.list_decay_modes("phi")
Beispiel #30
0
def test_jetset_definitions_parsing():
    p = DecFileParser(DIR / '../data/defs-aliases-chargeconj.dec')
    p.parse()

    assert p.dict_jetset_definitions() == {
        'MSTU': {
            1: 0,
            2: 0
        },
        'PARU': {
            11: 0.001
        },
        'MSTJ': {
            26: 0
        },
        'PARJ': {
            21: 0.36
        }
    }