Ejemplo n.º 1
0
def test_pts_from_p4s(nevents, nparticles):
    p4s = ef.gen_random_events(nevents, nparticles, dim=4,
                               mass='random').reshape(nevents, nparticles, 4)

    pts = ef.pts_from_p4s(p4s)
    slow_pts = []
    for i in range(nevents):
        event_pts = []
        for j in range(nparticles):
            event_pts.append(np.sqrt(p4s[i, j, 1]**2 + p4s[i, j, 2]**2))
        slow_pts.append(event_pts)

    slow_pts = np.asarray(slow_pts)
    assert epsilon_diff(slow_pts, pts)
Ejemplo n.º 2
0
def test_ys_from_pts_etas_ms(nevents, nparticles):
    p4s = ef.gen_random_events(nevents, nparticles, dim=4,
                               mass='random').reshape(nevents, nparticles, 4)

    ys = ef.ys_from_p4s(p4s)
    y_primes = ef.ys_from_pts_etas_ms(ef.pts_from_p4s(p4s),
                                      ef.etas_from_p4s(p4s),
                                      ef.ms_from_p4s(p4s))

    assert epsilon_diff(ys, y_primes, 1e-12)

    # test cutoff
    pts, ms = 1000 * np.random.rand(25), 10 * np.random.rand(25)
    etas = np.random.choice([-1., 1.], size=25) * 100 * np.random.rand(25)

    for c1, c2 in zip(np.linspace(20, 100, 5), 20 + 80 * np.random.rand(5)):
        ys_c1 = ef.ys_from_pts_etas_ms(pts, etas, ms, _cutoff=c1)
        ys_c2 = ef.ys_from_pts_etas_ms(pts, etas, ms, _cutoff=c2)

        assert epsilon_diff(ys_c1, ys_c2, 1e-12)
Ejemplo n.º 3
0
def test_efms(v, measure, normed, M):

    events = ef.gen_random_events(2, M)
    e = ef.EFM(v, measure=measure, normed=normed, coords='epxpypz')

    for event in events:
        if measure == 'hadrefm':
            zs = np.atleast_1d(ef.pts_from_p4s(event))
        elif measure == 'eeefm':
            zs = event[:, 0]

        nhats = event / zs[:, np.newaxis]
        if normed:
            zs = zs / zs.sum()

        e_ans = e.compute(event)
        if v == 0:
            assert epsilon_percent(e_ans, zs.sum(), 10**-13)
        else:
            s_ans = slow_efm(zs, nhats, v)
            assert epsilon_percent(s_ans, e_ans, 10**-13)