|
23 | 23 | logger = logging.getLogger(__name__) |
24 | 24 |
|
25 | 25 |
|
| 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 | + |
26 | 49 | def get_eko_names(grid_path, name, filter=True): |
27 | 50 | """Get the names of the ekos depending on the types of convolutions. |
28 | 51 |
|
@@ -276,6 +299,9 @@ def opcard(self, name, grid, tcard): |
276 | 299 | tcard : dict |
277 | 300 | theory card |
278 | 301 | """ |
| 302 | + # Before creating the operator card, check whether this grid is legal or not |
| 303 | + _check_for_scale_variations(tcard, grid) |
| 304 | + |
279 | 305 | opcard_path = self.operator_cards_path / f"{name}.yaml" |
280 | 306 | if opcard_path.exists(): |
281 | 307 | if not self.overwrite: |
@@ -436,7 +462,6 @@ def fk(self, name, grid_path, tcard, pdfs): |
436 | 462 |
|
437 | 463 | # check if grid contains SV if theory is requesting them (in particular |
438 | 464 | # if theory is requesting scheme A or C) |
439 | | - sv_method = evolve.sv_scheme(tcard) |
440 | 465 | xir = tcard["XIR"] |
441 | 466 | xif = tcard["XIF"] |
442 | 467 | xia = 1.0 # TODO: modify into `tcard["XIA"]` |
@@ -473,12 +498,6 @@ def fk(self, name, grid_path, tcard, pdfs): |
473 | 498 | rich.print("[green] Skipping empty grid.") |
474 | 499 | return |
475 | 500 |
|
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) |
482 | 501 | # TODO: Add fragmentation scale variations |
483 | 502 | # loading ekos to produce a tmp copy |
484 | 503 | n_ekos = len(eko_filename) |
|
0 commit comments