From 1cd3c830f2deb3c8a127b96a02f1a2a58fba26e8 Mon Sep 17 00:00:00 2001 From: Alessandro Candido Date: Thu, 27 Oct 2022 19:30:28 +0200 Subject: [PATCH] Propagate theory card requirement to TheoryBuilder --- benchmarks/bench_theory.py | 21 ++++++++++++++++----- src/pineko/theory.py | 6 +++++- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/benchmarks/bench_theory.py b/benchmarks/bench_theory.py index ee216ddc..b8316fd6 100644 --- a/benchmarks/bench_theory.py +++ b/benchmarks/bench_theory.py @@ -4,6 +4,7 @@ import pineko import pineko.configs import pineko.theory +import pineko.theory_card theory_obj = pineko.theory.TheoryBuilder(208, ["LHCB_Z_13TEV_DIMUON"]) theory_obj_hera = pineko.theory.TheoryBuilder(208, ["HERACOMBCCEM"]) @@ -73,12 +74,15 @@ def benchmark_inherit_ekos(test_files): folder_path.rmdir() -def benchmark_opcard(test_files): +def benchmark_opcard(test_files, test_configs): + th_path = pineko.theory_card.path(208) + grid_name = "LHCB_DY_13TEV_DIMUON" theory_obj.opcard( grid_name, pathlib.Path(test_files / "data/grids/208/LHCB_DY_13TEV_DIMUON.pineappl.lz4"), 1.0, + th_path, ) op_path = pathlib.Path( test_files / theory_obj.operator_cards_path / "LHCB_DY_13TEV_DIMUON.yaml" @@ -87,6 +91,7 @@ def benchmark_opcard(test_files): grid_name, pathlib.Path(test_files / "data/grids/208/LHCB_DY_13TEV_DIMUON.pineappl.lz4"), 1.0, + th_path, ) if os.path.exists(op_path): os.remove(op_path) @@ -94,7 +99,9 @@ def benchmark_opcard(test_files): raise ValueError("operator card not found") -def benchmark_eko(test_files): +def benchmark_eko(test_files, test_configs): + th_path = pineko.theory_card.path(208) + grid_name = "LHCB_DY_13TEV_DIMUON" grid_path = pathlib.Path(theory_obj.grids_path() / (grid_name + ".pineappl.lz4")) base_configs = pineko.configs.load(test_files) @@ -105,7 +112,7 @@ def benchmark_eko(test_files): "208-LHCB_DY_13TEV_DIMUON.log", ["208-LHCB_DY_13TEV_DIMUON.log"], ) - theory_obj.opcard(grid_name, pathlib.Path(test_files / grid_path), 1.0) + theory_obj.opcard(grid_name, pathlib.Path(test_files / grid_path), 1.0, th_path) theory_obj.eko(grid_name, grid_path, tcard) @@ -137,7 +144,9 @@ def benchmark_activate_logging(test_files): raise ValueError("log file not found") -def benchmark_fk(test_files): +def benchmark_fk(test_files, test_configs): + th_path = pineko.theory_card.path(208) + grid_name = "HERA_CC_318GEV_EM_SIGMARED" grid_path = pathlib.Path( theory_obj_hera.grids_path() / (grid_name + ".pineappl.lz4") @@ -150,7 +159,9 @@ def benchmark_fk(test_files): "208-HERA_CC_318GEV_EM_SIGMARED.log", ["208-HERA_CC_318GEV_EM_SIGMARED.log"], ) - theory_obj_hera.opcard(grid_name, pathlib.Path(test_files / grid_path), 1.0) + theory_obj_hera.opcard( + grid_name, pathlib.Path(test_files / grid_path), 1.0, th_path + ) theory_obj_hera.fk(grid_name, grid_path, tcard, pdf=None) # test overwrite function diff --git a/src/pineko/theory.py b/src/pineko/theory.py index 904dba60..05a236e7 100644 --- a/src/pineko/theory.py +++ b/src/pineko/theory.py @@ -203,7 +203,7 @@ def iterate(self, f, **kwargs): f(name, grid, **kwargs) rich.print() - def opcard(self, name, grid, xif): + def opcard(self, name, grid, xif, tcard_path): """Write a single operator card. Parameters @@ -214,6 +214,9 @@ def opcard(self, name, grid, xif): path to grid xif : float factorization scale + tcard_path : os.PathLike + path to theory card :func:`pineko.evolve.write_operator_card` + """ opcard_path = self.operator_cards_path / f"{name}.yaml" if opcard_path.exists(): @@ -225,6 +228,7 @@ def opcard(self, name, grid, xif): configs.configs["paths"]["operator_card_template"], opcard_path, xif, + tcard_path, ) if opcard_path.exists(): rich.print(