예제 #1
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()
예제 #2
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'
예제 #3
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"
예제 #4
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
예제 #5
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
예제 #6
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
예제 #7
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
예제 #8
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")
예제 #9
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
예제 #10
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
예제 #11
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)
예제 #12
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()
예제 #13
0
def test_duplicate_arrows(decfilepath, signal_mother, dup):
    """
    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 / "../../src/decaylanguage/data/DECAY_LHCB.DEC")

    if dup:
        with pytest.warns(UserWarning, match="pi0"):
            p.parse()
    else:
        p.parse()

    chain = p.build_decay_chains(signal_mother)

    dcv = DecayChainViewer(chain)
    graph_output_as_dot = dcv.to_string()

    ls = [i.split(" ")[0] for i in graph_output_as_dot.split("-> dec")[1:]
          ]  # list of node identifiers
    assert len(set(ls)) == len(ls)