Skip to content

Commit 5a71707

Browse files
committed
Move the scale variation check to the operator card creation
1 parent 5a16677 commit 5a71707

File tree

1 file changed

+26
-7
lines changed

1 file changed

+26
-7
lines changed

src/pineko/theory.py

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,29 @@
2323
logger = logging.getLogger(__name__)
2424

2525

26+
def _check_for_scale_variations(tcard, grid_path):
27+
"""Check that the grid is compatible with the requested scale_variations (if any).
28+
29+
Parameters
30+
----------
31+
tcard : dict
32+
theory card
33+
grid_path : pathlib.Path
34+
path to grid
35+
"""
36+
grid = pineappl.grid.Grid.read(grid_path)
37+
xir = tcard["XIR"]
38+
xif = tcard["XIF"]
39+
max_al = 0 # We don't do SV for alpha
40+
max_as = 1 + int(tcard["PTO"])
41+
# In FONLL-B we might need to change max_as
42+
max_as += int(check.is_fonll_mixed(tcard["FNS"], grid.convolutions))
43+
if not np.isclose(xir, 1.0):
44+
check_scvar_evolve(grid, max_as, max_al, check.Scale.REN)
45+
if not np.isclose(xif, 1.0) and evolve.sv_scheme(tcard) is None:
46+
check_scvar_evolve(grid, max_as, max_al, check.Scale.FACT)
47+
48+
2649
def get_eko_names(grid_path, name, filter=True):
2750
"""Get the names of the ekos depending on the types of convolutions.
2851
@@ -276,6 +299,9 @@ def opcard(self, name, grid, tcard):
276299
tcard : dict
277300
theory card
278301
"""
302+
# Before creating the operator card, check whether this grid is legal or not
303+
_check_for_scale_variations(tcard, grid)
304+
279305
opcard_path = self.operator_cards_path / f"{name}.yaml"
280306
if opcard_path.exists():
281307
if not self.overwrite:
@@ -436,7 +462,6 @@ def fk(self, name, grid_path, tcard, pdfs):
436462

437463
# check if grid contains SV if theory is requesting them (in particular
438464
# if theory is requesting scheme A or C)
439-
sv_method = evolve.sv_scheme(tcard)
440465
xir = tcard["XIR"]
441466
xif = tcard["XIF"]
442467
xia = 1.0 # TODO: modify into `tcard["XIA"]`
@@ -473,12 +498,6 @@ def fk(self, name, grid_path, tcard, pdfs):
473498
rich.print("[green] Skipping empty grid.")
474499
return
475500

476-
# check for sv
477-
if not np.isclose(xir, 1.0):
478-
check_scvar_evolve(grid, max_as, max_al, check.Scale.REN)
479-
if sv_method is None:
480-
if not np.isclose(xif, 1.0):
481-
check_scvar_evolve(grid, max_as, max_al, check.Scale.FACT)
482501
# TODO: Add fragmentation scale variations
483502
# loading ekos to produce a tmp copy
484503
n_ekos = len(eko_filename)

0 commit comments

Comments
 (0)