Skip to content

Commit

Permalink
minor updates num fonll
Browse files Browse the repository at this point in the history
  • Loading branch information
RoyStegeman committed Oct 9, 2023
1 parent 233037b commit 3745e92
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 26 deletions.
1 change: 0 additions & 1 deletion benchmarks/bench_evolve.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import pineappl
import pytest
import yaml
from eko import couplings as sc

import pineko
import pineko.evolve
Expand Down
2 changes: 1 addition & 1 deletion src/pineko/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def is_fonll_b(fns, lumi):


def is_num_fonll(FNS):
"""Check if the FNS is a num_fonll FNS."""
"""Check if the FNS is a nFONLL FNS."""
return FNS in ["FONLL-FFNS", "FONLL-FFN0"]


Expand Down
56 changes: 37 additions & 19 deletions src/pineko/cli/fonll.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,31 +79,49 @@ def subcommand(
print(f"Configurations loaded from '{path}'")

# Checks
if (ffn04 is None and (ffns5til is not None or ffns5 is not None)) or (
ffn04 is not None and (ffns5til is None and ffns5 is None)
):
raise InconsistentInputsError(
"One between ffn04 and ffns5til has been provided without the other. Since they are both needed to construct FONLL, this does not make sense."
)
if (ffn03 is None and (ffns4til is not None or ffns4 is not None)) or (
ffn03 is not None and (ffns4til is None and ffns4 is None)
):

if not ffns3 or not ffn03:
raise InconsistentInputsError("ffns3 and/or ffn03 is not provided.")

if any([ffns4, ffns4til, ffns4bar]):
if ffns4:
if any([ffns4til, ffns4bar]):
raise InconsistentInputsError(
"If ffns4 is provided no ffnstil or ffnsbar should be provided."
)
else:
if ffns4til is None or ffns4bar is None:
raise InconsistentInputsError(
"if ffnstil is provided also ffnsbar should be provided, and vice versa."
)
else:
raise InconsistentInputsError("ffns4 is not provided.")

# Do we consider two masses, i.e. mc and mb
two_masses = False
if any([ffns5, ffns5til, ffns5bar]):
two_masses = True
if ffns5:
if any([ffns5til, ffns5bar]):
raise InconsistentInputsError(
"If ffns5 is provided no ffnstil or ffnsbar should be provided."
)
else:
if ffns5til is None or ffns5bar is None:
raise InconsistentInputsError(
"if ffnstil is provided also ffnsbar should be provided, and vice versa."
)

if (ffn04 is None and two_masses) or (ffn04 is not None and not two_masses):
raise InconsistentInputsError(
"One between ffn03 and ffns4til has been provided without the other. Since they are both needed to construct FONLL, this does not make sense."
"If two masses are to be considered, both ffn04 and the nf=5 coefficient should be provided"
)

# check that if we have ffns we dont have any bar or til
if ffns4 is not None or ffns5 is not None:
if not all([fk is None for fk in [ffns4til, ffns4bar, ffns5til, ffns5bar]]):
raise InconsistentInputsError(
"If ffns4 and ffns5 are provided, no ffnstil or ffnsbar should be provided."
)

# Get theory info
tcard = theory_card.load(theoryid)
if not "DAMPPOWER" in tcard:
if tcard["DAMP"] != 0:
raise InconsistentInputsError
raise InconsistentInputsError("If DAMP is set, set also DAMPPOWER")
tcard["DAMPPOWER"] = None
# Getting the paths to the grids
grids_name = grids_names(configs.configs["paths"]["ymldb"] / f"{dataset}.yaml")
Expand Down Expand Up @@ -151,5 +169,5 @@ def fonll_tcards(theoryid, cfg):
tcard = theory_card.load(theoryid)
tcard_parent_path = theory_card.path(theoryid).parent
if "FONLL" not in tcard["FNS"]:
raise TheoryCardError
raise TheoryCardError("The theorycard does not correspond to an FONLL scheme.")
_ = fonll.produce_fonll_tcards(tcard, tcard_parent_path, theoryid)
4 changes: 2 additions & 2 deletions src/pineko/evolve.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ def write_operator_card(pineappl_grid, default_card, card_path, tcard):
"""
# Add a +1 to the orders for the difference in convention between nnpdf and pineappl
is_fns = int(check.is_fonll_b(tcard["FNS"], pineappl_grid.lumi()))
# NB: This would not happen for nFONLL
is_fns = int(check.is_fonll_b(tcard["FNS"], pineappl_grid.lumi()))
max_as = 1 + tcard["PTO"] + is_fns
max_al = 1 + tcard["QED"]
# ... in order to create a mask ...
Expand All @@ -129,7 +129,7 @@ def write_operator_card(pineappl_grid, default_card, card_path, tcard):
matching_scales=heavy_quarks.MatchingScales(masses * thresholds_ratios),
origin=(tcard["Q0"] ** 2, tcard["nf0"]),
)
# If we are producing num_fonll FKs we need to look to NfFF...
# If we are producing nFONLL FKs we need to look to NfFF...
if check.is_num_fonll(tcard["FNS"]):
nf = tcard["NfFF"]
operators_card["mugrid"] = [(float(np.sqrt(q2)), int(nf)) for q2 in q2_grid]
Expand Down
4 changes: 2 additions & 2 deletions src/pineko/fonll.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ def produce_combined_fk(
if damp[0] == 0:
# then there is no damping, not even Heaviside only
combined_fk = fk_dict[list(fk_dict)[0]]
# pineappl does not support operating with two grids in memory:
# https://github.com/NNPDF/pineappl/blob/8a672bef6d91b07a4edfdefbe4e30e4b1dd1f976/pineappl_py/src/grid.rs#L614-L617
with tempfile.TemporaryDirectory() as tmpdirname:
for fk in list(fk_dict)[1:]:
tmpfile_path = Path(tmpdirname) / f"{fk}.pineappl.lz4"
Expand All @@ -138,8 +140,6 @@ def produce_combined_fk(
damping_factor_charm *= step_function_charm
damping_factor_bottom *= step_function_bottom
dampings = {"mc": damping_factor_charm, "mb": damping_factor_bottom}
# pineappl does not support operating with two grids in memory:
# https://github.com/NNPDF/pineappl/blob/8a672bef6d91b07a4edfdefbe4e30e4b1dd1f976/pineappl_py/src/grid.rs#L614-L617
with tempfile.TemporaryDirectory() as tmpdirname:
combined_fk = fk_dict[list(fk_dict)[0]]
for fk in list(fk_dict)[1:]:
Expand Down
2 changes: 1 addition & 1 deletion src/pineko/theory.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ def fk(self, name, grid_path, tcard, pdf):
if "PTODIS" in tcard and "FONLL" in tcard["FNS"]:
tcard["PTO"] = tcard["PTODIS"]

# NB: This would not happen for num_fonll
# NB: This would not happen for nFONLL
max_al = 0
# check for sv
if not np.isclose(xir, 1.0):
Expand Down

0 comments on commit 3745e92

Please sign in to comment.