Skip to content

Commit

Permalink
Propagate theory card requirement to TheoryBuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
alecandido committed Oct 27, 2022
1 parent b5eb520 commit 1cd3c83
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
21 changes: 16 additions & 5 deletions benchmarks/bench_theory.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
Expand Down Expand Up @@ -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"
Expand All @@ -87,14 +91,17 @@ 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)
else:
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)
Expand All @@ -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)

Expand Down Expand Up @@ -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")
Expand All @@ -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
Expand Down
6 changes: 5 additions & 1 deletion src/pineko/theory.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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():
Expand All @@ -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(
Expand Down

0 comments on commit 1cd3c83

Please sign in to comment.