From a9cc7216c67a4758d0b294870711c93bd58aae9f Mon Sep 17 00:00:00 2001 From: andreab1997 Date: Tue, 5 Jul 2022 11:48:29 +0200 Subject: [PATCH 01/11] First draft of implementation --- src/pineko/check.py | 18 ++++++++++++++++++ src/pineko/theory.py | 5 +++++ 2 files changed, 23 insertions(+) diff --git a/src/pineko/check.py b/src/pineko/check.py index 49a8d9a2..3b0ab687 100644 --- a/src/pineko/check.py +++ b/src/pineko/check.py @@ -41,3 +41,21 @@ def check_grid_and_eko_compatible(pineappl_grid, operators): # x-grid if not np.all(in1d(np.unique(operators["targetgrid"]), np.array(x_grid))): raise ValueError("x grid in pineappl grid and eko operator are NOT compatible!") + + +def check_fonll_b(fns): + """Checks if the fktable we are computing is a DIS FONLL-B fktable + + Parameters + ---------- + fns : str + flavor number scheme (from the theory card) + + Returns + ------- + : bool + true if the fktable is a FONLL-B DIS fktable + """ + if fns == "FONLL-B": + return True + return False diff --git a/src/pineko/theory.py b/src/pineko/theory.py index 6c04ebf1..d96d26b5 100644 --- a/src/pineko/theory.py +++ b/src/pineko/theory.py @@ -323,6 +323,11 @@ def fk(self, name, grid_path, tcard, pdf): rich.print(f"Skipping existing FK Table {fk_filename}") return max_as = 1 + int(tcard["PTO"]) + # Check if we are computing FONLL-B fktable and eventually change max_as + if check.check_fonll_b( + tcard["FNS"], + ): + max_as += 1 max_al = 0 # Obtain the assumptions hash assumptions = theory_card.construct_assumption(tcard) From e8f28bb784ed1141a441a9e8cabd0b2e8c42c481 Mon Sep 17 00:00:00 2001 From: andreab1997 Date: Fri, 8 Jul 2022 12:04:22 +0200 Subject: [PATCH 02/11] Added check on lumi --- src/pineko/check.py | 14 ++++++++++++-- src/pineko/theory.py | 2 ++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/pineko/check.py b/src/pineko/check.py index 3b0ab687..b5ff1a45 100644 --- a/src/pineko/check.py +++ b/src/pineko/check.py @@ -43,19 +43,29 @@ def check_grid_and_eko_compatible(pineappl_grid, operators): raise ValueError("x grid in pineappl grid and eko operator are NOT compatible!") -def check_fonll_b(fns): +def check_fonll_b(fns, lumi): """Checks if the fktable we are computing is a DIS FONLL-B fktable Parameters ---------- fns : str flavor number scheme (from the theory card) + lumi : list(list(tuple)) + luminosity info Returns ------- : bool true if the fktable is a FONLL-B DIS fktable """ - if fns == "FONLL-B": + import ipdb + + ipdb.set_trace() + isDIS = True + for lists in lumi: + for el in lists: + if el[1] != 11: + isDIS = False + if fns == "FONLL-B" and isDIS: return True return False diff --git a/src/pineko/theory.py b/src/pineko/theory.py index d96d26b5..e7274e1d 100644 --- a/src/pineko/theory.py +++ b/src/pineko/theory.py @@ -324,8 +324,10 @@ def fk(self, name, grid_path, tcard, pdf): return max_as = 1 + int(tcard["PTO"]) # Check if we are computing FONLL-B fktable and eventually change max_as + pine_grid = pineappl.grid.Grid.read(grid_path) if check.check_fonll_b( tcard["FNS"], + pine_grid.lumi(), ): max_as += 1 max_al = 0 From addc9daed22b23a06394553aca54877d65c9257e Mon Sep 17 00:00:00 2001 From: andreab1997 Date: Fri, 8 Jul 2022 12:52:13 +0200 Subject: [PATCH 03/11] Removed pdb --- src/pineko/check.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/pineko/check.py b/src/pineko/check.py index b5ff1a45..8ab5574d 100644 --- a/src/pineko/check.py +++ b/src/pineko/check.py @@ -58,9 +58,6 @@ def check_fonll_b(fns, lumi): : bool true if the fktable is a FONLL-B DIS fktable """ - import ipdb - - ipdb.set_trace() isDIS = True for lists in lumi: for el in lists: From 12bbdf5fff7c384d0a1377ca59b4cce85aadf8f3 Mon Sep 17 00:00:00 2001 From: andreab1997 Date: Mon, 11 Jul 2022 11:30:39 +0200 Subject: [PATCH 04/11] Fixing --- src/pineko/theory.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pineko/theory.py b/src/pineko/theory.py index e7274e1d..a4c8bab6 100644 --- a/src/pineko/theory.py +++ b/src/pineko/theory.py @@ -3,10 +3,11 @@ import time import eko +import pineappl import rich import yaml -from . import configs, evolve, parser, theory_card +from . import check, configs, evolve, parser, theory_card logger = logging.getLogger(__name__) From 5a31f9040c7f7d6423925b88263f6839b191f2d5 Mon Sep 17 00:00:00 2001 From: andreab1997 Date: Mon, 11 Jul 2022 11:58:18 +0200 Subject: [PATCH 05/11] Changed name --- src/pineko/check.py | 2 +- src/pineko/theory.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pineko/check.py b/src/pineko/check.py index 8ab5574d..df3c1f92 100644 --- a/src/pineko/check.py +++ b/src/pineko/check.py @@ -43,7 +43,7 @@ def check_grid_and_eko_compatible(pineappl_grid, operators): raise ValueError("x grid in pineappl grid and eko operator are NOT compatible!") -def check_fonll_b(fns, lumi): +def is_fonll_b(fns, lumi): """Checks if the fktable we are computing is a DIS FONLL-B fktable Parameters diff --git a/src/pineko/theory.py b/src/pineko/theory.py index a4c8bab6..e72f0120 100644 --- a/src/pineko/theory.py +++ b/src/pineko/theory.py @@ -326,7 +326,7 @@ def fk(self, name, grid_path, tcard, pdf): max_as = 1 + int(tcard["PTO"]) # Check if we are computing FONLL-B fktable and eventually change max_as pine_grid = pineappl.grid.Grid.read(grid_path) - if check.check_fonll_b( + if check.is_fonll_b( tcard["FNS"], pine_grid.lumi(), ): From a2e46c8ade9caa76ff22de402a2c8eace57c17cd Mon Sep 17 00:00:00 2001 From: andreab1997 Date: Tue, 12 Jul 2022 13:35:54 +0200 Subject: [PATCH 06/11] Added relevant test --- tests/test_check.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 tests/test_check.py diff --git a/tests/test_check.py b/tests/test_check.py new file mode 100644 index 00000000..444c00a5 --- /dev/null +++ b/tests/test_check.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +import pathlib + +import eko +import numpy as np +import pineappl +import pytest + +import pineko.check + + +def test_is_fonll_b(): + fns = "FONLL-B" + lumi = [[(1, 11, 3, 4), (3, 11, 5, 6)], [(9, 11, 0, 3), (8, 11, -2, -1)]] + assert pineko.check.is_fonll_b(fns, lumi) is True + lumi.append([(1, 11, 2, 3), (2, 4, 5, 6)]) + assert pineko.check.is_fonll_b(fns, lumi) is False + lumi.pop(-1) + fns = "FONLL-C" + assert pineko.check.is_fonll_b(fns, lumi) is False From 1ce929df3e9a6fc01d916dcfeb487be8d2d690cd Mon Sep 17 00:00:00 2001 From: andreab1997 Date: Tue, 12 Jul 2022 14:56:57 +0200 Subject: [PATCH 07/11] Fixed conflict --- src/pineko/theory.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pineko/theory.py b/src/pineko/theory.py index e72f0120..976a6c6b 100644 --- a/src/pineko/theory.py +++ b/src/pineko/theory.py @@ -3,6 +3,7 @@ import time import eko +import numpy as np import pineappl import rich import yaml From f1a9cdbc22e9ba98c9043a34239f363e2ebf3b57 Mon Sep 17 00:00:00 2001 From: andreab1997 Date: Tue, 12 Jul 2022 17:34:29 +0200 Subject: [PATCH 08/11] Removed isDIS --- src/pineko/check.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/pineko/check.py b/src/pineko/check.py index 313b02f6..a8676db1 100644 --- a/src/pineko/check.py +++ b/src/pineko/check.py @@ -66,8 +66,9 @@ def check_grid_and_eko_compatible(pineappl_grid, operators, xif): if not np.all(in1d(np.unique(operators["targetgrid"]), np.array(x_grid))): raise ValueError("x grid in pineappl grid and eko operator are NOT compatible!") + def is_fonll_b(fns, lumi): - """Checks if the fktable we are computing is a DIS FONLL-B fktable + """Check if the fktable we are computing is a DIS FONLL-B fktable. Parameters ---------- @@ -81,15 +82,16 @@ def is_fonll_b(fns, lumi): : bool true if the fktable is a FONLL-B DIS fktable """ - isDIS = True for lists in lumi: for el in lists: if el[1] != 11: - isDIS = False - if fns == "FONLL-B" and isDIS: + # in this case we are sure it is not DIS so for sure it is not FONLL-B + return False + if fns == "FONLL-B": return True return False + def contains_fact(grid): """Check whether factorization scale-variations are available in the pineappl grid. @@ -118,4 +120,3 @@ def contains_ren(grid): if order[-2] != 0: return raise ValueError("Renormalization scale variations are not available for this grid") - From a4219445710a3a43205300cd2533fe588283a82b Mon Sep 17 00:00:00 2001 From: andreab1997 Date: Tue, 12 Jul 2022 17:37:48 +0200 Subject: [PATCH 09/11] Changed grid name --- src/pineko/theory.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/pineko/theory.py b/src/pineko/theory.py index 894bab86..69091257 100644 --- a/src/pineko/theory.py +++ b/src/pineko/theory.py @@ -351,11 +351,11 @@ def fk(self, name, grid_path, tcard, pdf): xir = tcard["XIR"] xif = tcard["XIF"] ftr = tcard["fact_to_ren_scale_ratio"] - pineappl_grid = pineappl.grid.Grid.read(grid_path) + grid = pineappl.grid.Grid.read(grid_path) if not np.isclose(xir, 1.0): - check.contains_ren(pineappl_grid) + check.contains_ren(grid) if not (np.isclose(xif, 1.0) and np.isclose(ftr, 1.0)): - check.contains_fact(pineappl_grid) + check.contains_fact(grid) # setup data eko_filename = self.ekos_path() / f"{name}.tar" fk_filename = self.fks_path / f"{name}.{parser.EXT}" @@ -365,10 +365,9 @@ def fk(self, name, grid_path, tcard, pdf): return max_as = 1 + int(tcard["PTO"]) # Check if we are computing FONLL-B fktable and eventually change max_as - pine_grid = pineappl.grid.Grid.read(grid_path) if check.is_fonll_b( tcard["FNS"], - pine_grid.lumi(), + grid.lumi(), ): max_as += 1 max_al = 0 @@ -398,7 +397,7 @@ def fk(self, name, grid_path, tcard, pdf): f"with max_as={max_as}, max_al={max_al}, xir={xir}, xif={xif}", ) _grid, _fk, comparison = evolve.evolve_grid( - pineappl_grid, + grid, eko_filename, fk_filename, max_as, From b2a94f9acdee153ac3f0ceb3dd5c36bb99bced36 Mon Sep 17 00:00:00 2001 From: Andrea Barontini Date: Tue, 12 Jul 2022 17:44:26 +0200 Subject: [PATCH 10/11] Update src/pineko/check.py look for a generic lepton Co-authored-by: Alessandro Candido --- src/pineko/check.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pineko/check.py b/src/pineko/check.py index a8676db1..af511c9d 100644 --- a/src/pineko/check.py +++ b/src/pineko/check.py @@ -84,7 +84,7 @@ def is_fonll_b(fns, lumi): """ for lists in lumi: for el in lists: - if el[1] != 11: + if 10 < abs(el[1]) < 17: # in this case we are sure it is not DIS so for sure it is not FONLL-B return False if fns == "FONLL-B": From 6fe4865daa9f9d5628a963ceab033ae0a54a2ca3 Mon Sep 17 00:00:00 2001 From: Alessandro Candido Date: Tue, 12 Jul 2022 17:54:17 +0200 Subject: [PATCH 11/11] Fix missing not --- src/pineko/check.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pineko/check.py b/src/pineko/check.py index af511c9d..aad141d3 100644 --- a/src/pineko/check.py +++ b/src/pineko/check.py @@ -84,7 +84,7 @@ def is_fonll_b(fns, lumi): """ for lists in lumi: for el in lists: - if 10 < abs(el[1]) < 17: + if not (10 < abs(el[1]) < 17): # in this case we are sure it is not DIS so for sure it is not FONLL-B return False if fns == "FONLL-B":