Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Numerical FONLL #99

Merged
merged 142 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
142 commits
Select commit Hold shift + click to select a range
9d24291
produce new theory cards if fns=fonll
RoyStegeman Jun 9, 2023
24cf458
first draft for merging of fonll grids
RoyStegeman Jun 12, 2023
16cce40
Merge branch 'main' into num_fonll
andreab1997 Jul 25, 2023
a3a4e76
First draft on cli producing theory cards for pinefarm
andreab1997 Jul 27, 2023
715f231
Add fonll-parts key
andreab1997 Jul 27, 2023
3df8311
Add fonll-parts key
andreab1997 Jul 27, 2023
73f4b81
First draft of full implementation
andreab1997 Jul 31, 2023
cbd6abe
Add possibility of doing the combination only with step func
andreab1997 Jul 31, 2023
3ca875c
Use DAMPPOWER key
andreab1997 Jul 31, 2023
b47308e
Add issimFONLL func
andreab1997 Jul 31, 2023
4620046
Remove wrong .self
andreab1997 Jul 31, 2023
9cc79dc
Add test on is_dis
andreab1997 Jul 31, 2023
80595d0
Add test on issimFONLL
andreab1997 Jul 31, 2023
34638e0
Add test for produce_fonll_tcards
andreab1997 Jul 31, 2023
761bdbc
Add test also for FONLL-B
andreab1997 Jul 31, 2023
a0201bb
Change naming conventions for theorycards
andreab1997 Jul 31, 2023
db43104
Add test for operator cards production
andreab1997 Jul 31, 2023
a189ff7
Add tests for FONLLInfo
andreab1997 Jul 31, 2023
bf985eb
Update pineappl
felixhekhorn Jul 31, 2023
986cf46
Change fonll-parts to FONLLParts
andreab1997 Jul 31, 2023
904cbb9
Merge branch 'num_fonll' of github.com:NNPDF/pineko into num_fonll
andreab1997 Jul 31, 2023
4b16a92
Fix case without damping
andreab1997 Jul 31, 2023
099523a
Use function scale instead of scale by bin
andreab1997 Jul 31, 2023
aecf0cd
Avoid counting the minus sign twice
andreab1997 Jul 31, 2023
0399a59
Fix damping
andreab1997 Jul 31, 2023
499f857
Make damping setting depend on theory card
andreab1997 Jul 31, 2023
48c83d4
Doing the damp correctly despite the paper...
andreab1997 Jul 31, 2023
b4ca9b7
Change fonll paths
andreab1997 Aug 2, 2023
b474004
Make all the fktables to be merged optional
andreab1997 Aug 2, 2023
8b45356
Correct small bug
andreab1997 Aug 2, 2023
1b206d0
Correct other small bug
andreab1997 Aug 2, 2023
12c1693
First draft of automation for combine_fonll
andreab1997 Aug 2, 2023
88e780d
Correct small bug
andreab1997 Aug 2, 2023
9ac3cb7
Correct other small bug
andreab1997 Aug 2, 2023
77bfad4
Add dot
andreab1997 Aug 2, 2023
967a9d7
Allow ingredients to not exists
andreab1997 Aug 2, 2023
6d6d310
Correct spelling error
andreab1997 Aug 2, 2023
f6906ec
Add some utility to the CLI
andreab1997 Aug 2, 2023
74eb2fa
Remove help for args
andreab1997 Aug 2, 2023
96394dd
Remove wrong stem
andreab1997 Aug 2, 2023
c0e613c
Write Success and Failure messages
andreab1997 Aug 2, 2023
e14e22f
Modify skipping message
andreab1997 Aug 2, 2023
ebcd6fe
fix theorycards check in case only one
RoyStegeman Aug 22, 2023
524429a
Add N3LO
andreab1997 Sep 18, 2023
24bfe64
Merge branch 'num_fonll' of github.com:NNPDF/pineko into num_fonll
andreab1997 Sep 18, 2023
c29463b
add config to nfonll cli
giacomomagni Sep 18, 2023
fbb7500
run pre-commit
andreab1997 Sep 19, 2023
3778f27
Use recipe for PTO of FNS
andreab1997 Sep 19, 2023
fa7a60b
Correct bug
andreab1997 Sep 19, 2023
523498a
Try to reduce theories form 7 to 5
giacomomagni Sep 20, 2023
acd6d81
fix tests
giacomomagni Sep 20, 2023
56ec7d9
black
giacomomagni Sep 20, 2023
6de60e0
Merge branch 'main' into num_fonll
giacomomagni Sep 21, 2023
b59b268
Merge branch 'num_fonll' into optimize_number_theories
giacomomagni Sep 21, 2023
4a44d08
Update src/pineko/check.py
andreab1997 Sep 21, 2023
c718a1f
Avoid repetition in fonll and change back to nFONLL
andreab1997 Sep 21, 2023
238f880
Fix bench_fonll
andreab1997 Sep 21, 2023
864742f
Fix bench_evolve
andreab1997 Sep 21, 2023
b4fd0d3
Merge branch 'num_fonll' into optimize_number_theories
andreab1997 Sep 21, 2023
175ee2a
Update src/pineko/cli/fonll.py
andreab1997 Sep 21, 2023
3708a89
add a check on FONLL theories
giacomomagni Sep 21, 2023
f4f0a2c
black
giacomomagni Sep 21, 2023
a7d64ca
fix merge
giacomomagni Sep 21, 2023
999daee
Merge pull request #119 from NNPDF/optimize_number_theories
giacomomagni Sep 25, 2023
9aad606
update theory ID in fonll tcards
giacomomagni Sep 28, 2023
5bca6e7
print theory card path for fonll_tcards
RoyStegeman Sep 29, 2023
a2998a3
Change simFONLL to num_fonll
andreab1997 Oct 3, 2023
1b310eb
Minor changes
andreab1997 Oct 3, 2023
315ed38
Remove cast to int for nf_default
andreab1997 Oct 3, 2023
04f0ed7
remove unused value in MIXED_NFFF_LIST
RoyStegeman Oct 3, 2023
e116783
Minor changes
andreab1997 Oct 4, 2023
034db70
fix mixed FONLL by decoupling PTO and PTODIS
RoyStegeman Oct 4, 2023
25a13d5
Fix benchmarks
andreab1997 Oct 5, 2023
fba7f9f
Update src/pineko/fonll.py
andreab1997 Oct 5, 2023
35371fd
Update src/pineko/fonll.py
andreab1997 Oct 5, 2023
860e5f4
Update src/pineko/fonll.py
andreab1997 Oct 5, 2023
43bcaa3
Update src/pineko/fonll.py
andreab1997 Oct 5, 2023
b21ee31
Update src/pineko/fonll.py
andreab1997 Oct 5, 2023
91c527f
Remove random names
andreab1997 Oct 5, 2023
c8b8f03
Remove unnecessary else
andreab1997 Oct 5, 2023
11d8f84
Remove print in the fonll cli
andreab1997 Oct 5, 2023
03d061b
tiny fix
RoyStegeman Oct 5, 2023
dada400
update PTO to PTODIS for covoluting with eko
RoyStegeman Oct 5, 2023
3f3c887
improve comment
RoyStegeman Oct 5, 2023
785fc11
fix check same tcards fonll
RoyStegeman Oct 9, 2023
233037b
don't add PTODIS because DAMP!=0
RoyStegeman Oct 9, 2023
3745e92
minor updates num fonll
RoyStegeman Oct 9, 2023
f0ec07c
Update tests/test_fonll.py
andreab1997 Oct 10, 2023
8ad2d1f
Update tests/test_fonll.py
andreab1997 Oct 10, 2023
f22cc27
Run pre-commit
andreab1997 Oct 10, 2023
5313744
Correct test error
andreab1997 Oct 10, 2023
cc66bb4
Print a warning for the fktables that do not exist during combination
andreab1997 Oct 10, 2023
4cfc8dd
pass cfg to configs.detect
giacomomagni Oct 10, 2023
e364fff
Update pineappl version
andreab1997 Oct 10, 2023
d59ea5c
Merge branch 'main' into num_fonll
felixhekhorn Oct 10, 2023
eb73599
Add explicit check for empty ekos
andreab1997 Oct 11, 2023
1b32ca0
Extend fonll_b check
andreab1997 Oct 12, 2023
025a578
improve empty eko error
giacomomagni Oct 12, 2023
1a495a7
Update check if the grid is empty
giacomomagni Oct 13, 2023
790c0a5
Put the paths check in the constructor of FONLLInfo
andreab1997 Oct 17, 2023
3e688bc
Correct bug in FONLLInfo constructor
andreab1997 Oct 17, 2023
d7b610f
Correct other small typo
andreab1997 Oct 17, 2023
b8ca270
Add grid name to tmp eko file
andreab1997 Oct 17, 2023
8a1c916
Merge branch 'main' into num_fonll
giacomomagni Oct 18, 2023
04374a4
Update src/pineko/fonll.py
andreab1997 Oct 18, 2023
efd9a0b
Update src/pineko/fonll.py
andreab1997 Oct 18, 2023
9b7edb1
Update src/pineko/fonll.py
andreab1997 Oct 18, 2023
73c5052
Update src/pineko/fonll.py
andreab1997 Oct 18, 2023
61b1802
Update src/pineko/fonll.py
andreab1997 Oct 18, 2023
837ce2a
Update src/pineko/fonll.py
andreab1997 Oct 18, 2023
f5cec44
Update src/pineko/fonll.py
andreab1997 Oct 18, 2023
115b820
Update src/pineko/check.py
andreab1997 Oct 18, 2023
ece695b
Move the dampings construction in a separate function
andreab1997 Oct 18, 2023
e406de6
Move update of fk theorycard to separate function
andreab1997 Oct 18, 2023
5efe537
Clarify the relation between damping and 5 subtheories
andreab1997 Oct 18, 2023
34fd85d
Move combination to separate function
andreab1997 Oct 18, 2023
babe6ae
Use bin_left to get the q2grid
andreab1997 Oct 18, 2023
5a3252e
Use CONFIG for FNS, NFFF and parts
andreab1997 Oct 18, 2023
8c9fcef
Cast explicitly theory cards entries
andreab1997 Oct 18, 2023
bb0d3f4
Correct missing test
andreab1997 Oct 18, 2023
bc78002
save NfFF as int instead of str
RoyStegeman Oct 18, 2023
bcfe6ef
Cast again
andreab1997 Oct 18, 2023
b284bb1
Merge branch 'num_fonll' of github.com:NNPDF/pineko into num_fonll
andreab1997 Oct 18, 2023
5ecc635
Correction to tests
andreab1997 Oct 18, 2023
eb6d734
fix: move PTO=PTODIS for fonll-b before extracting PTO value
RoyStegeman Oct 18, 2023
7e385a3
Rework nFONLL config
andreab1997 Oct 19, 2023
6d38acb
Correct error for pylint
andreab1997 Oct 19, 2023
2e76e57
Revert "Correct error for pylint"
felixhekhorn Oct 19, 2023
1165dd9
Revert "Rework nFONLL config"
felixhekhorn Oct 19, 2023
6d87995
Update src/pineko/cli/fonll.py
andreab1997 Oct 19, 2023
e64aa94
Use SubTheoryConfig
felixhekhorn Oct 19, 2023
61c487a
Update src/pineko/cli/fonll.py
felixhekhorn Oct 19, 2023
b5674d0
Booleanize subtheory scheme
felixhekhorn Oct 19, 2023
155200f
Merge branch 'num_fonll-fh-1' of github.com:N3PDF/pineko into num_fon…
felixhekhorn Oct 19, 2023
f28d9a2
adding some docstring about fonll mapping
giacomomagni Oct 19, 2023
17d5956
fix minor
giacomomagni Oct 19, 2023
fdf9a05
Merge branch 'num_fonll-fh-1' into num_fonll
felixhekhorn Oct 20, 2023
78ab9c9
Recover bench_fonll
felixhekhorn Oct 20, 2023
914dec1
Update benchmarks/bench_evolve.py
andreab1997 Oct 23, 2023
b37cb54
Update src/pineko/check.py
andreab1997 Oct 23, 2023
e35a95f
Update src/pineko/check.py
andreab1997 Oct 23, 2023
7dca3a4
Update src/pineko/check.py
felixhekhorn Oct 23, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 23 additions & 6 deletions src/pineko/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,28 @@ def check_grid_and_eko_compatible(pineappl_grid, operators, xif, max_as, max_al)
raise ValueError("x grid in pineappl grid and eko operator are NOT compatible!")


def is_dis(lumi):
"""Check if the fktable we are computing is a DIS fktable.

Parameters
----------
lumi : list(list(tuple))
luminosity info

Returns
-------
bool
true if the fktable is a DIS fktable
"""
for lists in lumi:
for el in lists:
andreab1997 marked this conversation as resolved.
Show resolved Hide resolved
if (not islepton(el[0])) and (not islepton(el[1])):
# If neither of the incoming particles is a lepton we are sure
# it is not DIS
return False
return True


def is_fonll_b(fns, lumi):
"""Check if the fktable we are computing is a DIS FONLL-B fktable.

Expand All @@ -131,12 +153,7 @@ def is_fonll_b(fns, lumi):
bool
true if the fktable is a FONLL-B DIS fktable
"""
for lists in lumi:
for el in lists:
if (not islepton(el[0])) and (not islepton(el[1])):
# in this case we are sure it is not DIS so for sure it is not FONLL-B
return False
if fns == "FONLL-B":
if is_dis(lumi) and fns == "FONLL-B":
andreab1997 marked this conversation as resolved.
Show resolved Hide resolved
return True
return False

Expand Down
12 changes: 11 additions & 1 deletion src/pineko/cli/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
"""CLI entry point."""
from . import check, compare, convolute, gen_sv, kfactor, opcard, scaffold, theory_
from . import (
check,
compare,
convolute,
fonll,
gen_sv,
kfactor,
opcard,
scaffold,
theory_,
)
from ._base import command
52 changes: 52 additions & 0 deletions src/pineko/cli/fonll.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
"""CLI entry point to FONLL."""
import click

from .. import configs, fonll, theory_card
from ._base import command


class TheoryCardError(Exception):
"""Raised when asked for FONLL theory cards with an original tcard as input that is not asking for FONLL."""

pass
andreab1997 marked this conversation as resolved.
Show resolved Hide resolved


class InconsistentInputsError(Exception):
"""Raised if the inputs are not consistent with FONLL accounting for only charm mass, or both charm and bottom masses."""

pass
andreab1997 marked this conversation as resolved.
Show resolved Hide resolved


@command.command("combine_fonll")
@click.argument("FFNS3", type=click.Path(exists=True))
@click.argument("FFN03", type=click.Path(exists=True))
@click.argument("FFNS4til", type=click.Path(exists=True))
@click.argument("theoryID", type=int)
@click.option("--FFNS4bar", type=click.Path(exists=True))
@click.option("--FFN04", type=click.Path(exists=True))
@click.option("--FFNS5til", type=click.Path(exists=True))
@click.option("--FFNS5bar", type=click.Path(exists=True))
def subcommand(ffns3, ffn03, ffns4til, theoryid, ffns4bar, ffn04, ffns5til, ffns5bar):
"""Combine the different FKs needed to produce the FONLL prescription."""
if (ffn04 is None and ffns5til is not None) or (
ffn04 is not None and ffns5til is None
):
print(
"One between ffn04 and ffns5til has been provided without the other. Since they are both needed to construct FONLL, this does not make sense."
)
raise InconsistentInputsError
fonll.produce_combined_fk(
ffns3, ffn03, ffns4til, ffns4bar, ffn04, ffns5til, ffns5bar, theoryid
)


@command.command("fonll_tcards")
@click.argument("theoryID", type=int)
def fonll_tcards(theoryid):
"""Produce the FONLL tcards starting from the original tcard given by the theoryID."""
configs.configs = configs.defaults(configs.load())
tcard = theory_card.load(theoryid)
tcard_parent_path = theory_card.path(theoryid).parent
if "FONLL" not in tcard["FNS"]:
raise TheoryCardError
andreab1997 marked this conversation as resolved.
Show resolved Hide resolved
fonll.produce_fonll_tcards(tcard, tcard_parent_path)
12 changes: 9 additions & 3 deletions src/pineko/evolve.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ 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()))
andreab1997 marked this conversation as resolved.
Show resolved Hide resolved
# NB: This would not happen for simFONLL
andreab1997 marked this conversation as resolved.
Show resolved Hide resolved
max_as = 1 + tcard["PTO"] + is_fns
max_al = 1 + tcard["QED"]
# ... in order to create a mask ...
Expand All @@ -128,9 +129,14 @@ 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"]),
)
operators_card["mugrid"] = [
(float(np.sqrt(q2)), int(nf_default(q2, atlas))) for q2 in q2_grid
]
# If we are producing simFONLL FKs we need to look to NfFF...
if issimFONLL(tcard["FNS"]):
nfff = tcard["NfFF"]
operators_card["mugrid"] = [(float(np.sqrt(q2)), int(nfff)) for q2 in q2_grid]
andreab1997 marked this conversation as resolved.
Show resolved Hide resolved
else:
operators_card["mugrid"] = [
(float(np.sqrt(q2)), int(nf_default(q2, atlas))) for q2 in q2_grid
andreab1997 marked this conversation as resolved.
Show resolved Hide resolved
]
if "integrability_version" in pineappl_grid.key_values():
x_grid = evol_info.x1
x_grid = np.append(x_grid, 1.0)
Expand Down
190 changes: 190 additions & 0 deletions src/pineko/fonll.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
"""Module to manage FONLL predictions."""

import copy
import json
import tempfile
from pathlib import Path

import numpy as np
import pineappl
import yaml

from . import configs


class FONLLInfo:
"""Class containing all the information for FONLL predictions."""

def __init__(
self, ffns3, ffn03, ffns4til, ffns4bar, ffn04, ffns5til, ffns5bar
) -> None:
self.ffns3 = ffns3
self.ffn03 = ffn03
self.ffns4til = ffns4til
self.ffns4bar = ffns4bar
self.ffn04 = ffn04
self.ffns5til = ffns5til
self.ffns5bar = ffns5bar

@property
def fk_paths(self):
"""Returns the list of the fk paths needed to produce FONLL predictions."""
andreab1997 marked this conversation as resolved.
Show resolved Hide resolved
always_needed = [self.ffns3, self.ffn03, self.ffns4til]
if self.ffns4bar:
paths = always_needed + [self.ffns4bar]
if self.ffn04 and self.ffns5til:
paths = paths + [self.ffn04, self.ffns5til]
# It does not make sense to have ffns5bar without ffns5til
if self.ffns5bar:
paths = paths + [self.self.ffns5bar]
return [Path(p) for p in paths]

@property
def fks(self):
"""Returns the pineappl.Grid objects reading the paths provided by self.fk_paths."""
return [pineappl.grid.Grid.read(fk_path) for fk_path in self.fk_paths]

@property
def dataset_name(self):
"""Return the name of the dataset given by the fktables name, if all the fktables have the same name."""
andreab1997 marked this conversation as resolved.
Show resolved Hide resolved
if len({p.name for p in self.fk_paths}) == 1:
return self.fk_paths[0].name
else:
andreab1997 marked this conversation as resolved.
Show resolved Hide resolved
raise ValueError("not all fktables have the same name")

@property
def theorycard_no_fns_pto(self):
"""Return the common theory info between the different FONLL FKs."""
andreab1997 marked this conversation as resolved.
Show resolved Hide resolved
theorycards = [json.loads(fk.key_values()["theory"]) for fk in self.fks]
# Only these should differ
for card in theorycards:
del card["FNS"]
del card["PTO"]
del card["NfFF"]
del card["ID"]
del card["fonll-parts"]
if not all([theorycards[0] == card in theorycards[1:]]):
raise ValueError("theorycards not the same")
andreab1997 marked this conversation as resolved.
Show resolved Hide resolved
return theorycards[0]

@property
def Q2grid(self):
"""Return the Q2grid of the fktables given by self.fks ."""
andreab1997 marked this conversation as resolved.
Show resolved Hide resolved
aa = json.loads(self.fks[0].raw.key_values()["runcard"])["observables"]
bb = list(aa.values())[
0
] # there is only a single obseravble because it's a dis fktable
cc = np.array([i["Q2"] for i in bb])
andreab1997 marked this conversation as resolved.
Show resolved Hide resolved
return cc
andreab1997 marked this conversation as resolved.
Show resolved Hide resolved


# TODO: check if I want to damp the top mass corrections in 'mc' (i.e. 6)
FK_TO_DAMP = {"mc": [1, 2, 4, 5], "mb": [4, 5]}
FK_WITH_MINUS = [1, 4] # asy terms should be subtracted, therefore the sign


def produce_combined_fk(
ffns3, ffn03, ffns4til, ffns4bar, ffn04, ffns5til, ffns5bar, theoryid
):
"""Combine the FONLL FKs to produce one single final FONLL FK."""
andreab1997 marked this conversation as resolved.
Show resolved Hide resolved
fonll_info = FONLLInfo(ffns3, ffn03, ffns4til, ffns4bar, ffn04, ffns5til, ffns5bar)

theorycard_constituent_fks = fonll_info.theorycard_no_fns_pto
if theorycard_constituent_fks["DAMP"] == "False":
andreab1997 marked this conversation as resolved.
Show resolved Hide resolved
# then there is no damping, not even Heaviside only
combined_fk = fonll_info.fks[0]
for fk_path in fonll_info.fk_paths[1:]:
combined_fk.merge_from_file(fk_path)
else:
mc = theorycard_constituent_fks["mc"]
mb = theorycard_constituent_fks["mb"]
q2grid = fonll_info.Q2grid
step_function_charm = mc**2 < q2grid
step_function_bottom = mb**2 < q2grid
damping_factor_charm = (1 - q2grid / mc) ** theorycard_constituent_fks["DAMP"]
damping_factor_bottom = (1 - q2grid / mb) ** theorycard_constituent_fks["DAMP"]
damping_factor_charm *= step_function_charm
damping_factor_bottom *= step_function_bottom
dampings = {"mc": damping_factor_charm, "mb": damping_factor_bottom}
for i, fk in enumerate(fonll_info.fks):
sign = 1
if i in FK_WITH_MINUS:
sign = -1
for mass in FK_TO_DAMP:
if i in FK_TO_DAMP[mass]:
fk.scale_by_bin(sign * dampings[mass])
# 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 = fonll_info.fks[0]
for i, fk in enumerate(fonll_info.fks[1:]):
tmpfile_path = Path(tmpdirname) / f"{i}.pineappl.lz4"
fk.write_lz4(tmpfile_path)
combined_fk.merge_from_file(tmpfile_path)

# update theorycard entries for the combined fktable by reading the yamldb of the original theory
input_theorycard_path = (
Path(configs.load(configs.detect())["paths"]["theory_cards"])
/ f"{theoryid}.yaml"
)
with open(input_theorycard_path) as f:
final_theorycard = yaml.safe_load(f)
theorycard = json.loads(combined_fk.key_values()["theory"])
theorycard["FNS"] = final_theorycard["FNS"]
theorycard["PTO"] = final_theorycard["PTO"]
theorycard["NfFF"] = final_theorycard["NfFF"]
theorycard["ID"] = final_theorycard["ID"]
# Update the theorycard with the entries set above
combined_fk.set_key_value("theory", str(theorycard))

# save final "fonll" fktable
fk_folder = Path(configs.load(configs.detect())["paths"]["fktables"]) / str(
theoryid
)
fk_folder.mkdir(exist_ok=True)
output_path_fk = fk_folder / fonll_info.dataset_name
combined_fk.write_lz4(output_path_fk)


def produce_fonll_recipe(fns):
"""Produce the different theory cards according to which FONLL is asked for."""
fonll_recipe = []
if fns == "FONLL-A":
pto = [1 for _ in range(7)]
elif fns == "FONLL-C":
pto = [2 for _ in range(7)]
elif fns == "FONLL-B":
pto = [2, 2, 1, 2, 2, 1, 2]
FNS_list = [
"FONLL-FFNS",
"FONLL-FFN0",
"FONLL-FFNS",
"FONLL-FFNS",
"FONLL-FFN0",
"FONLL-FFNS",
"FONLL-FFNS",
]
NfFF_list = [3, 3, 4, 4, 4, 5, 5, 5]
parts_list = ["full", "full", "massless", "massive", "full", "massless", "massive"]
for fns, nfff, po, part in zip(FNS_list, NfFF_list, pto, parts_list):
fonll_recipe.append(
{
"FNS": fns,
"NfFF": nfff,
"PTO": po,
"fonll-parts": part,
}
)
return fonll_recipe


def produce_fonll_tcards(tcard, tcard_parent_path):
"""Produce the seven fonll tcards from an original tcard and dump them in tcard_parent_path with names from '1000.yaml' to '1006.yaml'."""
theorycards = [copy.deepcopy(tcard) for _ in range(7)]
fonll_recipe = produce_fonll_recipe(tcard["FNS"])
for theorycard, recipe in zip(theorycards, fonll_recipe):
theorycard.update(recipe)
paths_list = [tcard_parent_path / f"100{num}.yaml" for num in range(7)]
for newtcard, path in zip(theorycards, paths_list):
with open(path, "w", encoding="UTF-8") as f:
yaml.safe_dump(newtcard, f)
1 change: 0 additions & 1 deletion src/pineko/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ def get_yaml_information(yaml_file, grids_folder):
List (of lists) with all the grids that will need to be loaded
"""
yaml_content = _load_yaml(yaml_file)

# Turn the operands and the members into paths (and check all of them exist)
ret = []
for operand in yaml_content["operands"]:
Expand Down
1 change: 1 addition & 0 deletions src/pineko/theory.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,7 @@ def fk(self, name, grid_path, tcard, pdf):
grid.lumi(),
):
max_as += 1
# NB: This would not happen for simFONLL
andreab1997 marked this conversation as resolved.
Show resolved Hide resolved
max_al = 0
# check for sv
if not np.isclose(xir, 1.0):
Expand Down