From da1aa536d61edf574762c51efecc4fadad14fdbf Mon Sep 17 00:00:00 2001 From: Giacomo Magni Date: Wed, 24 Jul 2024 14:45:11 +0200 Subject: [PATCH] add a check on convolution types --- src/pineko/evolve.py | 17 +++++++++++++++-- src/pineko/theory.py | 2 +- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/pineko/evolve.py b/src/pineko/evolve.py index 18e448da..fbfabfee 100644 --- a/src/pineko/evolve.py +++ b/src/pineko/evolve.py @@ -49,7 +49,7 @@ def sv_scheme(tcard): return modsv -def get_ekos_convolution_type(kv): +def get_grid_convolution_type(kv): """Retrieve the ekos convolution type. Parameters @@ -80,6 +80,17 @@ def get_ekos_convolution_type(kv): return conv_type_1, conv_type_2 +def check_convolution_types(grid, operators1, operators2): + """Check that grid and eko convolution types are sorted correctly.""" + grid_conv_1, grid_conv_2 = get_grid_convolution_type(grid.key_values()) + grid_conv_1 = grid_conv_1 == "PolPDF" + grid_conv_2 = grid_conv_2 == "PolPDF" + eko_conv_1 = operators1.operator_card.configs.polarized + eko_conv_2 = operators2.operator_card.configs.polarized + if grid_conv_1 != eko_conv_1 or grid_conv_2 != eko_conv_2: + raise ValueError("Grid and Eko convolution types are not matching.") + + def write_operator_card_from_file( pineappl_path: os.PathLike, default_card_path: os.PathLike, @@ -193,7 +204,7 @@ def write_operator_card(pineappl_grid, default_card, card_path, tcard): # switch on polarization ? kv = pineappl_grid.key_values() - conv_type_1, conv_type_2 = get_ekos_convolution_type(kv) + conv_type_1, conv_type_2 = get_grid_convolution_type(kv) # fragmentation function grid? if "timelike" in kv: @@ -391,6 +402,8 @@ def prepare(operator, items): return (info, op.operator) if operators2 is not None: + # check convolutions order + check_convolution_types(grid, operators1, operators2) fktable = grid.evolve_with_slice_iter2( map(lambda it: prepare(operators1, it), operators1.items()), map(lambda it: prepare(operators2, it), operators2.items()), diff --git a/src/pineko/theory.py b/src/pineko/theory.py index abbf926a..aaa233c5 100644 --- a/src/pineko/theory.py +++ b/src/pineko/theory.py @@ -35,7 +35,7 @@ def get_eko_names(grid_path, name): grid name, i.e. it's true stem """ grid_kv = pineappl.grid.Grid.read(grid_path).key_values() - conv_type_1, conv_type_2 = evolve.get_ekos_convolution_type(grid_kv) + conv_type_1, conv_type_2 = evolve.get_grid_convolution_type(grid_kv) names = [] if conv_type_2 is None or conv_type_1 == conv_type_2: names = [name]