Esempio n. 1
0
def test_ys_from_p4s(nevents, nparticles):
    p4s = ef.gen_random_events(nevents, nparticles, dim=4,
                               mass='random').reshape(nevents, nparticles, 4)
    ys = 0.5 * np.log(
        (p4s[..., 0] + p4s[..., 3]) / (p4s[..., 0] - p4s[..., 3]))

    assert epsilon_diff(ys, ef.ys_from_p4s(p4s))
Esempio 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)