From 5b5b8ac79d522ed87a00a5aff962ca1c4b9c1cd8 Mon Sep 17 00:00:00 2001 From: juacrumar Date: Mon, 4 Nov 2024 14:23:39 +0100 Subject: [PATCH] misc fixes for nnlojet interface --- pyproject.toml | 2 +- src/pinefarm/cli/run.py | 14 ++++----- .../external/nnlojet/nnpdf_interface.py | 4 +++ src/pinefarm/external/nnlojet/runcardgen.py | 1 - src/pinefarm/external/nnlojet/runner.py | 31 ++++++++++--------- src/pinefarm/tools.py | 2 +- 6 files changed, 29 insertions(+), 25 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 30921b8..8efae67 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -38,7 +38,7 @@ appdirs = "^1.4.4" tomli = "^2.0.1" yadism = { extras = ["box"], version = "^0.13.3", optional=true, markers = "python_version < '3.13'" } eko = { extras = ["box"], version = "^0.14.2", optional=true, markers = "python_version < '3.13'" } -nnpdf = { git = "https://github.com/NNPDF/nnpdf", optional = true, markers = "python_version > '3.8'" } +nnpdf = { git = "https://github.com/NNPDF/nnpdf", optional = true, markers = "python_version < '3.13'" } [tool.poetry.extras] dis = ["yadism"] diff --git a/src/pinefarm/cli/run.py b/src/pinefarm/cli/run.py index 92da66e..d16b316 100644 --- a/src/pinefarm/cli/run.py +++ b/src/pinefarm/cli/run.py @@ -29,14 +29,12 @@ def subcommand(dataset, theory_path, pdf, dry): Parameters ---------- - dataset : str - dataset name - theory : dict - theory dictionary - pdf : str - pdf name - - + dataset: str + dataset name + theory: dict + theory dictionary + pdf: str + pdf name """ # read theory card from file with open(theory_path) as f: diff --git a/src/pinefarm/external/nnlojet/nnpdf_interface.py b/src/pinefarm/external/nnlojet/nnpdf_interface.py index 09b0beb..19e1833 100755 --- a/src/pinefarm/external/nnlojet/nnpdf_interface.py +++ b/src/pinefarm/external/nnlojet/nnpdf_interface.py @@ -86,6 +86,7 @@ def _1d_histogram(kin_df, hist_var): def _nnlojet_observable(observable, process): """Try to automatically understand the NNLOJET observables given the NNPDF process and obs.""" + observable = observable.lower() if observable in ("eta", "y", "etay"): if process.upper().startswith("Z"): return "yz" @@ -312,6 +313,9 @@ def generate_pinecard_from_nnpdf(nnpdf_dataset, scale="mz", output_path="."): hepdata = f"https://doi.org/{hepdata}" data_comment = f"arXiv number: {arxiv}, hepdata entry: {hepdata} (tables: {tables})" + print( + f"\033[91m [WARNING] \033[0m Remember to update he selection cuts in the runcard, see {hepdata}" + ) # For some NNPDF datasets, different processes/energies might be grouped together processes = [process] diff --git a/src/pinefarm/external/nnlojet/runcardgen.py b/src/pinefarm/external/nnlojet/runcardgen.py index 17ecdcf..2dbb777 100755 --- a/src/pinefarm/external/nnlojet/runcardgen.py +++ b/src/pinefarm/external/nnlojet/runcardgen.py @@ -206,7 +206,6 @@ def _fill_run(runname, pdf, mode_line, techcut=1e-7, multi_channel=3): scale_coefficients = .true. multi_channel = {multi_channel} iseed = 1 - phase_space = qT {mode_line} END_RUN """ diff --git a/src/pinefarm/external/nnlojet/runner.py b/src/pinefarm/external/nnlojet/runner.py index 329714d..f969b0e 100644 --- a/src/pinefarm/external/nnlojet/runner.py +++ b/src/pinefarm/external/nnlojet/runner.py @@ -53,25 +53,28 @@ def preparation(self): raise NotImplementedError("N3LO still not working") pinedata = YamlLOJET(**self._yaml_dict) - # Generate both the production and warmup runcards with reasonable defaults + # Given the allowed channel, generate the possible channel choices + active_channels = pinedata.active_channels(channels) + # Generate both the production and warmup runcards with reasonable defaults self.dest.mkdir(exist_ok=True, parents=True) - for channel in channels: - + for level_name, level_channels in active_channels.items(): + print(f"Preparing {len(level_channels)} runcards for {level_name}") for mode in ["warmup", "production"]: nev = _DEFAULTS[mode]["events"] nit = _DEFAULTS[mode]["iterations"] - is_warmup = mode == "warmup" - _ = generate_runcard( - pinedata, - channel, - output=self.dest, - is_warmup=is_warmup, - events=nev, - iterations=nit, - ) - - generate_combine_ini(pinedata, channels, self.dest) + for channel in level_channels: + is_warmup = mode == "warmup" + _ = generate_runcard( + pinedata, + channel, + output=self.dest, + is_warmup=is_warmup, + events=nev, + iterations=nit, + ) + + generate_combine_ini(pinedata, active_channels, self.dest) return True def run(self): diff --git a/src/pinefarm/tools.py b/src/pinefarm/tools.py index 3e2503f..0ed9752 100644 --- a/src/pinefarm/tools.py +++ b/src/pinefarm/tools.py @@ -32,7 +32,7 @@ def create_output_folder(name, theoryid): + "-" + name + "-" - + datetime.datetime.now().strftime("-%Y%m%d%H%M%S") + + datetime.datetime.now().strftime("%Y%m%d%H%M%S") ) target.mkdir(exist_ok=True, parents=True) return target