Skip to content

Commit 6822910

Browse files
authored
Merge pull request #239 from NNPDF/fix-mur-neq-muf
Fix FK computation when`mur != muf`
2 parents 2b7174c + 0e58503 commit 6822910

7 files changed

Lines changed: 1054 additions & 798 deletions

File tree

benchmarks/bench_cli.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,16 +86,27 @@ def benchmark_compare_cli(lhapdf_path, test_files, test_pdf):
8686
assert "right" in result.output
8787

8888

89-
def benchmark_convolve_cli(test_files, tmp_path):
89+
def benchmark_convolve_cli(test_files, tmp_path, test_configs):
90+
theoryid = 400
9091
grid_path = pathlib.Path(
91-
test_files / "data/grids/400/HERA_NC_225GEV_EP_SIGMARED.pineappl.lz4"
92+
test_files / f"data/grids/{theoryid}/HERA_NC_225GEV_EP_SIGMARED.pineappl.lz4"
93+
)
94+
eko_path = pathlib.Path(
95+
test_files / f"data/ekos/{theoryid}/HERA_NC_225GEV_EP_SIGMARED.tar"
9296
)
93-
eko_path = pathlib.Path(test_files / "data/ekos/400/HERA_NC_225GEV_EP_SIGMARED.tar")
9497
fk_path = tmp_path / "testfk.pineappl.lz4"
9598
runner = CliRunner()
9699
result = runner.invoke(
97100
command,
98-
["convolve", str(fk_path), str(grid_path), "2", "0", str(eko_path)],
101+
[
102+
"convolve",
103+
str(fk_path),
104+
str(grid_path),
105+
str(theoryid),
106+
"2",
107+
"0",
108+
str(eko_path),
109+
],
99110
)
100111
assert "Optimizing for Nf6Ind" in result.output
101112

benchmarks/bench_evolve.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,11 @@ def benchmark_dglap(tmp_path, test_files, test_configs):
9898

9999

100100
def benchmark_evolve_grid(tmp_path, lhapdf_path, test_files, test_pdf):
101-
pine_path = test_files / "data/grids/400/HERA_NC_225GEV_EP_SIGMARED.pineappl.lz4"
101+
tid = 400
102+
tcard = pineko.theory_card.load(tid)
103+
pine_path = test_files / f"data/grids/{tid}/HERA_NC_225GEV_EP_SIGMARED.pineappl.lz4"
102104
pinegrid = pineappl.grid.Grid.read(pine_path)
103-
eko_path = test_files / "data/ekos/400/HERA_NC_225GEV_EP_SIGMARED.tar"
105+
eko_path = test_files / f"data/ekos/{tid}/HERA_NC_225GEV_EP_SIGMARED.tar"
104106
target_path = pathlib.Path(tmp_path / "test_fktable.pineappl.lz4")
105107
max_as = 3
106108
max_al = 0
@@ -119,6 +121,7 @@ def benchmark_evolve_grid(tmp_path, lhapdf_path, test_files, test_pdf):
119121
xir=1.0,
120122
xif=1.0,
121123
xia=1.0,
124+
theory_meta=tcard,
122125
assumptions=assumptions,
123126
comparison_pdfs=["NNPDF40_nnlo_as_01180"],
124127
)

poetry.lock

Lines changed: 995 additions & 769 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ packages = [{ include = "pineko", from = "src" }]
2828
[tool.poetry.dependencies]
2929
python = ">=3.9,<3.13"
3030
eko = "^0.15.0"
31-
pineappl = "^1.0.0"
31+
pineappl = "^1.3.0"
3232
PyYAML = "^6.0"
3333
numpy = "^1.21.0"
3434
pandas = "^2.1"
@@ -59,7 +59,7 @@ pytest-cov = "^4.0.0"
5959
pytest-env = "^0.6.2"
6060
pylint = "^3.1.0"
6161
banana-hep = "^0.6.13"
62-
pineappl-cli = "^1.0.0"
62+
pineappl-cli = "^1.3.0"
6363

6464
[tool.poetry.group.dev.dependencies]
6565
pdbpp = "^0.11.6"

src/pineko/cli/convolve.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@
77
import rich
88
import rich_click as click
99

10-
from .. import evolve
10+
from .. import evolve, theory_card
1111
from ._base import command
1212

1313

1414
@command.command("convolve")
1515
@click.argument("fktable", type=click.Path())
1616
@click.argument("grid_path", type=click.Path(exists=True))
17+
@click.argument("theoryid", type=int)
1718
@click.argument("max_as", type=int)
1819
@click.argument("max_al", type=int)
1920
@click.argument("op_paths", type=click.Path(exists=True), nargs=-1)
@@ -37,6 +38,7 @@
3738
def subcommand(
3839
fktable,
3940
grid_path,
41+
theoryid,
4042
max_as,
4143
max_al,
4244
op_paths,
@@ -73,6 +75,7 @@ def subcommand(
7375
grid = pineappl.grid.Grid.read(grid_path)
7476
grid.optimize()
7577
n_ekos = len(op_paths)
78+
tcard = theory_card.load(theoryid)
7679
with eko.EKO.edit(pathlib.Path(op_paths[0])) as first_operator:
7780
operators = [first_operator]
7881
path_operators = f"[+] {op_paths[0]}\n"
@@ -101,6 +104,7 @@ def subcommand(
101104
xir,
102105
xif,
103106
xia,
107+
theory_meta=tcard,
104108
assumptions=assumptions,
105109
comparison_pdfs=pdfs,
106110
min_as=min_as,

src/pineko/evolve.py

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ def sv_scheme(tcard):
3434
----------
3535
tcard : dict
3636
theory card
37-
3837
"""
3938
modsv_list = {a.value for a in ScaleVariationsMethod}
4039
xif = tcard["XIF"]
@@ -49,6 +48,25 @@ def sv_scheme(tcard):
4948
return modsv
5049

5150

51+
def construct_atlas(tcard):
52+
"""Construct the atlas for heavy quarks matching.
53+
54+
Parameters
55+
----------
56+
tcard : dict
57+
theory card
58+
"""
59+
masses = np.array([tcard["mc"], tcard["mb"], tcard["mt"]]) ** 2
60+
thresholds_ratios = np.array([tcard["kcThr"], tcard["kbThr"], tcard["ktThr"]]) ** 2
61+
for q in range(tcard["MaxNfPdf"] + 1, 6 + 1):
62+
thresholds_ratios[q - 4] = np.inf
63+
atlas = Atlas(
64+
matching_scales=heavy_quarks.MatchingScales(masses * thresholds_ratios),
65+
origin=(tcard["Q0"] ** 2, tcard["nf0"]),
66+
)
67+
return atlas
68+
69+
5270
def get_convolution_suffix(convolution: pineappl.convolutions.Conv) -> str:
5371
"""Get the correct suffix for a given convolution.
5472
@@ -200,19 +218,12 @@ def write_operator_card(
200218
raise ValueError("Template declares a value of Q0, nf0 different from theory")
201219

202220
q2_grid = (xif * xif * muf2_grid).tolist()
203-
masses = np.array([tcard["mc"], tcard["mb"], tcard["mt"]]) ** 2
204-
thresholds_ratios = np.array([tcard["kcThr"], tcard["kbThr"], tcard["ktThr"]]) ** 2
205-
for q in range(tcard["MaxNfPdf"] + 1, 6 + 1):
206-
thresholds_ratios[q - 4] = np.inf
207-
atlas = Atlas(
208-
matching_scales=heavy_quarks.MatchingScales(masses * thresholds_ratios),
209-
origin=(tcard["Q0"] ** 2, tcard["nf0"]),
210-
)
211221
# If we are producing nFONLL FKs we need to look to NfFF...
212222
if check.is_num_fonll(tcard["FNS"]):
213223
nf = tcard["NfFF"]
214224
operators_card["mugrid"] = [(float(np.sqrt(q2)), int(nf)) for q2 in q2_grid]
215225
else:
226+
atlas = construct_atlas(tcard)
216227
operators_card["mugrid"] = [
217228
(float(np.sqrt(q2)), nf_default(q2, atlas)) for q2 in q2_grid
218229
]
@@ -287,9 +298,9 @@ def evolve_grid(
287298
xir: float,
288299
xif: float,
289300
xia: float,
301+
theory_meta: dict,
290302
assumptions="Nf6Ind",
291303
comparison_pdfs: Optional[list[str]] = None,
292-
meta_data=None,
293304
min_as=None,
294305
):
295306
"""Convolute grid with EKO from file paths.
@@ -312,12 +323,12 @@ def evolve_grid(
312323
factorization scale variation
313324
xia : float
314325
fragmentation scale variation
326+
tcard: dict
327+
card containing the theory parameters
315328
assumptions : str
316329
assumptions on the flavor dimension
317330
comparison_pdfs : list(str) or None
318331
if given, a comparison table (with / without evolution) will be printed
319-
meta_data : None or dict
320-
if given, additional meta data written to the FK table
321332
min_as: None or int
322333
minimum power of strong coupling
323334
"""
@@ -335,6 +346,7 @@ def evolve_grid(
335346
if "integrability_version" in grid.metadata:
336347
x_grid = np.append(x_grid, 1.0)
337348

349+
muf2_grid = evol_info.fac1
338350
mur2_grid = evol_info.ren1
339351
xif = 1.0 if operators[0].operator_card.configs.scvar_method is not None else xif
340352
tcard = operators[0].theory_card
@@ -356,9 +368,12 @@ def evolve_grid(
356368
# To compute the alphas values we are first reverting the factorization scale shift
357369
# and then obtaining the renormalization scale using xir.
358370
ren_grid2 = xir * xir * mur2_grid
359-
# NOTE: Currently, getting `nfgrid` from the first Operator is correct but this
360-
# might need to be addressed in the future
361-
nfgrid = [x[1] for x in operators[0].operator_card.mugrid]
371+
if check.is_num_fonll(theory_meta["FNS"]):
372+
nfgrid = [int(theory_meta["NfFF"]) for _ in mur2_grid]
373+
else:
374+
q2mur_grid = (xir * xir * mur2_grid).tolist()
375+
atlas = construct_atlas(theory_meta)
376+
nfgrid = [nf_default(q2, atlas) for q2 in q2mur_grid]
362377
alphas_values = [
363378
4.0 * np.pi * sc.a_s(mur2, nf_to=nf) for mur2, nf in zip(ren_grid2, nfgrid)
364379
]
@@ -415,9 +430,7 @@ def prepare(operator, convolution_types):
415430
)
416431

417432
fktable.set_metadata("pineko_version", version.__version__)
418-
if meta_data is not None:
419-
for k, v in meta_data.items():
420-
fktable.set_metadata(k, v)
433+
fktable.set_metadata("theory_card", json.dumps(theory_meta))
421434

422435
# compare before/after
423436
comparison = None

src/pineko/theory.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
commonly referred to as 'theory'.
77
"""
88

9-
import json
109
import logging
1110
import time
1211

@@ -563,9 +562,9 @@ def fk(self, name, grid_path, tcard, pdfs):
563562
xir=xir,
564563
xif=xif,
565564
xia=xia,
565+
theory_meta=tcard,
566566
assumptions=assumptions,
567567
comparison_pdfs=pdfs,
568-
meta_data={"theory_card": json.dumps(tcard)},
569568
)
570569

571570
if n_ekos > 1:

0 commit comments

Comments
 (0)