Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
614bd43
first understanding
giacomomagni Mar 15, 2024
664a798
init some refactoring
giacomomagni Mar 15, 2024
8305507
make test working
giacomomagni Mar 15, 2024
93131b1
try to make it working again
giacomomagni Mar 15, 2024
4dfd7a8
try to make bench passing
giacomomagni Mar 15, 2024
746bc4d
remove pdb
giacomomagni Mar 15, 2024
4d97c72
restore mask
giacomomagni Mar 15, 2024
fb5b9f8
more work
giacomomagni Mar 15, 2024
16d8279
more fixes
giacomomagni Mar 15, 2024
a4626f2
remove pdb
giacomomagni Mar 15, 2024
c9d4c43
add some docs and fix names
giacomomagni Mar 16, 2024
8dc15f0
some cleaning in scale variations
giacomomagni Mar 16, 2024
3f94e4c
pre-commit
giacomomagni Mar 16, 2024
64e252d
update pineappl version
giacomomagni Mar 16, 2024
770ce81
Fix pre-commit, fix kfactor docs
felixhekhorn Mar 18, 2024
40124ea
Update scale_subgrid
felixhekhorn Mar 18, 2024
3163be4
first round of review
giacomomagni Mar 18, 2024
7d04323
second round of updates
giacomomagni Mar 18, 2024
55e015d
Rework kfactors.to_list
felixhekhorn Mar 19, 2024
82e4657
Drop type hints from kfactors.to_list
felixhekhorn Mar 19, 2024
7ea62d7
Update src/pineko/cli/kfactor.py
giacomomagni Mar 19, 2024
5a31fc0
more fixes from review suggestions
giacomomagni Mar 19, 2024
53f939a
Update docs/source/theory/kfactors.rst
giacomomagni Mar 19, 2024
b62249b
make kfactor names more uniform
giacomomagni Mar 19, 2024
4665cad
do_it -> apply_to_grid
giacomomagni Mar 19, 2024
21572f8
clarification on PTO_TO_UPDATE
giacomomagni Mar 19, 2024
25be7c4
drop target_folder=None
giacomomagni Mar 19, 2024
3d067f0
more typos here and there
giacomomagni Mar 19, 2024
9821965
Merge branch 'main' into issue_160
giacomomagni Mar 26, 2024
0a27fbe
run poetry lock
giacomomagni Mar 26, 2024
4ce5921
restore poetry lock
giacomomagni Mar 26, 2024
c87c39e
Merge branch 'main' into issue_160
giacomomagni Jun 10, 2024
41a4649
make kfactors working again with nnpdf settings
giacomomagni Jun 10, 2024
9fab164
exterminate yamldb
giacomomagni Jun 10, 2024
3aaa411
Merge branch 'main' into issue_160
giacomomagni Jun 18, 2024
a314490
update poetry lock
giacomomagni Jun 19, 2024
02940a3
Merge branch 'main' into issue_160
giacomomagni Aug 21, 2024
011ec6c
fix benchmarks
giacomomagni Aug 21, 2024
d33d2f9
other fix to benchmarks
giacomomagni Aug 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions benchmarks/bench_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,18 +113,15 @@ def benchmark_scaffold_cli(test_empty_proj):
assert "Success: All the folders are correctly configured" in res.output


def benchmark_gen_sv_cli(test_files, tmp_path, test_pdf, lhapdf_path):
def benchmark_gen_sv_cli(test_files, tmp_path):
runner = CliRunner()
pdf_name = "NNPDF40_nlo_as_01180"
max_as = "2"
nf = "5"
name_grid = "ATLAS_TTB_8TEV_LJ_TRAP_norensv_fixed.pineappl.lz4"
grid_path = test_files / "data" / "grids" / "400" / name_grid
new_grid_path = tmp_path / name_grid
target_path = tmp_path
shutil.copy(grid_path, new_grid_path)
with lhapdf_path(test_pdf):
pdf = lhapdf.mkPDF(pdf_name)
res = runner.invoke(
command,
["ren_sv_grid", str(new_grid_path), str(target_path), max_as, nf, "False"],
Expand All @@ -134,21 +131,23 @@ def benchmark_gen_sv_cli(test_files, tmp_path, test_pdf, lhapdf_path):

def benchmark_kfactor_cli(test_files, tmp_path):
runner = CliRunner()
grid_folder = test_files / "data" / "grids" / "400"
conf_file = test_files / "pineko.toml"
theory_id = 400
dataset = "ATLAS_TTB_FAKE"
kfolder = test_files / "data" / "kfactors"
fake_yaml_path = test_files / "data" / "yamldb" / "ATLAS_TTB_FAKE.yaml"
max_as = "3"
order_to_update = "3"
target_path = tmp_path
res = runner.invoke(
command,
[
"kfactor",
str(grid_folder),
"-c",
str(conf_file),
str(theory_id),
str(dataset),
str(kfolder),
str(fake_yaml_path),
str(target_path),
max_as,
"False",
order_to_update,
],
)
assert "The number of bins match the lenght of the k-factor" in res.output
assert "The number of bins match the length of the kfactor" in res.output
21 changes: 12 additions & 9 deletions benchmarks/bench_kfactor.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,22 @@
import numpy as np
import pineappl

from pineko import kfactor
from pineko import configs, kfactor


def benchmark_kfactor_inclusion(test_files, tmp_path, test_pdf, lhapdf_path):
fake_yaml_path = test_files / "data" / "yamldb" / "ATLAS_TTB_FAKE.yaml"
max_as = 3

base_configs = configs.load(test_files / "pineko.toml")
configs.configs = configs.defaults(base_configs)

pto_to_update = 3 # here we want to update NNLO
pdf_name = "NNPDF40_nnlo_as_01180"
kfactor.compute_k_factor_grid(
test_files / "data" / "grids" / "400",
kfactor.apply_to_dataset(
400,
"ATLAS_TTB_FAKE",
test_files / "data" / "kfactors",
fake_yaml_path,
max_as,
target_folder=tmp_path,
pto_to_update,
tmp_path,
)
pluskfactor_grid_path = tmp_path / "ATLAS_TTB_8TEV_LJ_TRAP.pineappl.lz4"
with lhapdf_path(test_pdf):
Expand Down Expand Up @@ -46,7 +49,7 @@ def benchmark_kfactor_inclusion(test_files, tmp_path, test_pdf, lhapdf_path):
np.array([], dtype=bool),
sv_list,
).reshape(bin_number, len(sv_list))
centrals_kfactor, _ = kfactor.read_kfactor(
centrals_kfactor, _ = kfactor.read_from_file(
test_files / "data" / "kfactors" / "CF_QCD_ATLAS_TTB_8TEV_LJ_TRAP.dat"
)
rtol = 1.0e-15
Expand Down
4 changes: 2 additions & 2 deletions docs/source/overview/running.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ handy utility functions:

- applying the :doc:`FONLL prescription</theory/fonll>`
- applying the :doc:`scale variation prescription</theory/scalevar>`
- burning the :doc:`K-factor</theory/kfactors>` into grids
- burning the :doc:`Kfactor</theory/kfactors>` into grids


Checking the grids
Expand Down Expand Up @@ -100,7 +100,7 @@ Using pineko with NNPDF
"""""""""""""""""""""""

It is possible to use ``pineko`` without providing an explicit mapping between data and grids
(i.e., without a ``yamldb`` database) or theory cards, by using the data declared in the NNPDF
(i.e., without a ``ymldb`` database) or theory cards, by using the data declared in the NNPDF
repository (which includes a data-theory mapping).

In order to do this you need to install ``pineko`` with the ``nnpdf`` extra, which installs
Expand Down
23 changes: 18 additions & 5 deletions docs/source/theory/kfactors.rst
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
K-Factors
Kfactors
=========

Another useful tool that `pineko` includes is ``pineko kfactor`` which allows the embedding of a kfactor
as a proper order in a grid. The usage is the following::

pineko kfactor GRIDS_FOLDER KFACTOR_FOLDER YAMLDB_PATH TARGET_FOLDER MAX_AS ORDER_EXISTS
pineko kfactor THEORY_ID DATASET KFACTOR_FOLDER TARGET_FOLDER PTO_TO_UPDATE [--order_exists]

where ``GRIDS_FOLDER`` is the folder containing the grids to update, ``KFACTOR_FOLDER`` is the folder
containing the kfactor files and ``YAMLDB_PATH`` is the path to the yamldb file of the requested dataset.
The other inputs have already been described in the previous section.
where:

- ``THEORY_ID`` is the theory ID of the source grid,
- ``DATASET`` is the dataset name,
- ``KFACTOR_FOLDER`` is the folder containing the kfactor files,
- ``TARGET_FOLDER`` is the folder where the new updated grids is going to be saved,
- ``PTO_TO_UPDATE`` is the :math:`\alpha_s` perturbative order to update or create,
with the convention that ``LO=1``, ``NLO=2`` and so on, irrespectively to the powers of :math:`\alpha_s`.
Note also that this differs from the conventions by the NNPDF collaboration,
but it is consistent with the pineappl convention.
- ``--order_exists`` is a flag used to apply the kfactor to the specified perturbative order, insead of the next.

Note that only pure QCD kfactors are taken into account.
For example to add the NNLO in a grid containing at most NLO one has to select ``PTO_TO_UPDATE=2``;
nn the other hand to reweight the NNLO present in a grid with a kfactor,
one should do ``PTO_TO_UPDATE=2 --order_exists``.
Comment thread
giacomomagni marked this conversation as resolved.
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ authors = [
"Alessandro Candido <alessandro.candido@mi.infn.it>",
"Andrea Barontini <andrea.barontini@mi.infn.it>",
"Felix Hekhorn <felix.hekhorn@mi.infn.it>",
"Giacomo Magni <gmagni@nikhef.nl>",
"Roy Stegeman <r.stegeman@ed.ac.uk>",
"Juan Cruz-Martinez <juacrumar@lairen.eu>",
]
classifiers = [
Expand Down
2 changes: 1 addition & 1 deletion src/pineko/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def check_grid_and_eko_compatible(pineappl_grid, operators, xif, max_as, max_al)
xif : float
factorization scale variation
max_as: int
max order of alpa_s
max order of alpha_s
max_al: int
max order of alpha

Expand Down
33 changes: 17 additions & 16 deletions src/pineko/cli/kfactor.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,35 @@
import click

from .. import kfactor
from ._base import command
from ._base import command, config_option, load_config


@command.command("kfactor")
@click.argument("grids_folder", type=click.Path(exists=True))
@config_option
@click.argument("theoryID", type=int)
@click.argument("dataset", type=str)
@click.argument("kfactor_folder", type=click.Path(exists=True))
@click.argument("yamldb_path", type=click.Path(exists=True))
@click.argument("target_folder", type=click.Path(exists=True))
@click.argument("max_as", type=int)
@click.argument("order_exists", type=bool)
def k_factor_inclusion(
grids_folder,
@click.argument("pto_to_update", type=int)
@click.option("--order_exists", is_flag=True, help="Overwrite an existing order.")
def kfactor_inclusion(
cfg,
theoryid,
dataset,
kfactor_folder,
yamldb_path,
target_folder,
max_as,
pto_to_update,
order_exists,
):
"""Construct new grid with k_factor included."""
grids_folder = pathlib.Path(grids_folder)
"""Construct new grid with kfactor included."""
load_config(cfg)
kfactor_folder = pathlib.Path(kfactor_folder)
yamldb_path = pathlib.Path(yamldb_path)
target_folder = pathlib.Path(target_folder)
kfactor.compute_k_factor_grid(
grids_folder,
kfactor.apply_to_dataset(
theoryid,
dataset,
kfactor_folder,
yamldb_path,
max_as,
pto_to_update,
target_folder=target_folder,
order_exists=order_exists,
)
Loading