Skip to content

Commit

Permalink
fix the toyFF and add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
t7phy committed Jun 18, 2024
1 parent e4fc1e2 commit c48429b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/banana/toy.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,22 +163,22 @@ class toyFF_unpolarized(MockPDF):
"""ToyFF from 1501.00494, Eqn. 3.3 and 3.4"""

def __init__(self):
N_v = 0.401
N_s = 0.094
N_g = 0.238
N_v = 1.00881
N_s = 17.6255
N_g = 438.189

D_u = lambda x: N_v * x ** (-0.963) * (1 - x) ** 1.370
D_ub = lambda x: N_s * x**0.718 * (1 - x) ** 6.266
D_g = lambda x: N_g * x**1.943 * (1 - x) ** 8
xD_u = lambda x: x * N_v * x ** (-0.963) * (1 - x) ** 1.370
xD_ub = lambda x: x * N_s * x**0.718 * (1 - x) ** 6.266
xD_g = lambda x: x * N_g * x**1.943 * (1 - x) ** 8

self.xpdf = {}
self.xpdf[-3] = D_ub
self.xpdf[-2] = D_ub
self.xpdf[-1] = D_u
self.xpdf[0] = D_g
self.xpdf[1] = D_ub
self.xpdf[2] = D_u
self.xpdf[3] = D_ub
self.xpdf[-3] = xD_ub
self.xpdf[-2] = xD_ub
self.xpdf[-1] = xD_u
self.xpdf[0] = xD_g
self.xpdf[1] = xD_ub
self.xpdf[2] = xD_u
self.xpdf[3] = xD_ub
self.xpdf[21] = self.xpdf[0]
self.name = "ToyFF_unpolarized"

Expand Down
14 changes: 14 additions & 0 deletions tests/test_toy.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from banana import toy
from scipy.integrate import quad

pdf = toy.mkPDF("", 0)
ff = toy.mkPDF("ToyFF_unpolarized", 0)


def test_alpha():
Expand All @@ -24,3 +26,15 @@ def test_xf():
for x in [0.1, 0.2]:
assert pdf.xfxQ2(pid, x, Q2) == pdf.xfxQ(pid, x, Q2)
assert pdf.xfxQ2(pid, 2, Q2) == 0


def test_toyFF():
"""Test the ToyFF_unpolarized with Eqn. 3.4 from 1501.00494."""

val_u = round(quad(lambda x: ff.xfxQ2(2, x, 1), 0, 1)[0], 3)
val_d = round(quad(lambda x: ff.xfxQ2(1, x, 1), 0, 1)[0], 3)
val_g = round(quad(lambda x: ff.xfxQ2(21, x, 1), 0, 1)[0], 3)

assert val_u == 0.401
assert val_d == 0.094
assert val_g == 0.238

0 comments on commit c48429b

Please sign in to comment.