Skip to content

Commit

Permalink
misc fixes for nnlojet interface
Browse files Browse the repository at this point in the history
  • Loading branch information
scarlehoff committed Nov 4, 2024
1 parent 1b5659c commit 5b5b8ac
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 25 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
14 changes: 6 additions & 8 deletions src/pinefarm/cli/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 4 additions & 0 deletions src/pinefarm/external/nnlojet/nnpdf_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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]
Expand Down
1 change: 0 additions & 1 deletion src/pinefarm/external/nnlojet/runcardgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
"""
Expand Down
31 changes: 17 additions & 14 deletions src/pinefarm/external/nnlojet/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion src/pinefarm/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5b5b8ac

Please sign in to comment.