示例#1
0
def test_efp_efm_naive_compute(measure, normed, event):
    # compute the EFP corresponding to the "icecreamcone" graph in the usual way
    EFP_correlator = ef.EFP([(0,1),(0,1),(0,2),(1,2)], measure=measure, normed=normed, coords='epxpypz', beta=2)(event)

    # compute the EFP corresponding to "icecreamcone" as a contraction of EFMs with the metric
    metric = np.diag([1,-1,-1,-1])

    # compute several energy flow moments
    EFM2 = ef.EFM(2, measure=measure, normed=normed, coords='epxpypz')(event)
    EFM3 = ef.EFM(3, measure=measure, normed=normed, coords='epxpypz')(event)
    EFP_contraction = np.einsum('abc,def,gh,ad,be,cg,fh->', EFM3, EFM3, EFM2, *([metric]*4))

    # compute the EFP corresponding to "icecreamcone" with explicit sums
    if measure == 'hadrefm':
        zs = np.sqrt(event[:,1]**2 + event[:,2]**2)
    if measure == 'eeefm':
        zs = event[:,0]
        
    ns = (event/zs[:,np.newaxis])
    thetas = np.asarray([[np.sum(2*ni*nj*np.asarray([1,-1,-1,-1])) for ni in ns] for nj in ns])

    if normed:
        zs /= zs.sum()
    
    EFP_sums = 0
    for i in range(len(event)):
        for j in range(len(event)):
            for k in range(len(event)):
                EFP_sums += zs[i] * zs[j] * zs[k] * thetas[i,j] * thetas[i,j] * thetas[i,k] * thetas[j,k]

    # ensure that the two values agree
    assert epsilon_percent(EFP_correlator, EFP_contraction, 10**-12)
    assert epsilon_percent(EFP_correlator, EFP_sums, 10**-12)
示例#2
0
def test_efm_batch_compute(v, M, measure, normed):
    events = ef.gen_random_events(2, M)
    e = ef.EFM(v, measure=measure, normed=normed, coords='epxpypz')

    r1 = [e.compute(event) for event in events]
    r2 = e.batch_compute(events)

    assert epsilon_percent(r1, r2, 10**-1)
示例#3
0
def test_efm_vs_efmset_compute(sigs, M, measure, normed):

    efmset = ef.EFMSet(sigs, measure=measure, normed=normed, coords='epxpypz')
    efms = [
        ef.EFM(*sig, measure=measure, normed=normed, coords='epxpypz')
        for sig in sigs
    ]

    for event in ef.gen_random_events(2, M):
        efm_dict = efmset.compute(event)
        for sig, efm in zip(sigs, efms):
            print(sig, np.max(np.abs(efm_dict[sig] - efm.compute(event))))
            assert epsilon_percent(efm_dict[sig], efm.compute(event), 10**-10)
示例#4
0
def test_efm_vs_efmset_batch_compute(sigs, M, measure, normed):

    efmset = ef.EFMSet(sigs, measure=measure, normed=normed, coords='epxpypz')
    efms = [
        ef.EFM(*sig, measure=measure, normed=normed, coords='epxpypz')
        for sig in sigs
    ]

    events = ef.gen_random_events(2, M)
    efm_dict = efmset.batch_compute(events)

    for sig, efm in zip(sigs, efms):
        results = efm.batch_compute(events)
        for i in range(len(events)):
            assert epsilon_percent(efm_dict[i][sig], results[i], 10**-10)
示例#5
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)