Skip to content

Commit c42b408

Browse files
committed
add autodiscovery for photon processes
1 parent b6731e7 commit c42b408

3 files changed

Lines changed: 49 additions & 19 deletions

File tree

src/pinefarm/external/nnlojet/nnpdf_interface.py

Lines changed: 41 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
yaml.default_flow_style = False
2929
yaml.indent(sequence=4, offset=2, mapping=4)
3030

31-
HISTOGRAM_VARIABLES = {"y", "etay", "eta", "pT", "pT2", "M2"}
31+
HISTOGRAM_VARIABLES = {"y", "etay", "eta", "pT", "pT2", "M2", "ET"}
3232

3333

3434
def _legacy_nnpdf_translation(df, proc_type):
@@ -88,23 +88,28 @@ def _1d_histogram(kin_df, hist_var):
8888
def _nnlojet_observable(observable, process):
8989
"""Try to automatically understand the NNLOJET observables given the NNPDF process and obs."""
9090
observable = observable.lower()
91+
process = process.upper()
9192
if observable in ("eta", "y", "etay"):
92-
if process.upper().startswith("Z"):
93+
if process.startswith("Z"):
9394
return "yz"
94-
if process.upper().startswith("WP") and not process.upper().endswith("J"):
95+
if process.startswith("WP") and not process.endswith("J"):
9596
return "ylp"
96-
if process.upper().startswith("WM") and not process.upper().endswith("J"):
97+
if process.startswith("WM") and not process.endswith("J"):
9798
return "ylm"
99+
if process.startswith("GJ"):
100+
return "y_gam"
98101
if observable == "pt":
99-
if process.upper().startswith("Z"):
102+
if process.startswith("Z"):
100103
return "ptz"
101-
if process.upper().startswith("W"):
104+
if process.startswith("W"):
102105
return "ptw"
103-
if observable == "m" and process.upper().startswith("Z"):
106+
if observable == "m" and process.startswith("Z"):
104107
return "mll"
105108
if observable == "m2":
106109
print("\033[91m [WARNING] \033[0m Changed M2 to M in the selectors")
107110
return "mll"
111+
if observable == "et" and process.startswith("GJ"):
112+
return "pt_gam"
108113

109114
raise ValueError(f"Observable {observable} not recognized for process {process}")
110115

@@ -194,8 +199,15 @@ def _generate_nnlojet_pinecard(runname, process, energy, experiment, histograms)
194199
selectors = select_selectors(experiment, process)
195200
histograms = deepcopy(histograms)
196201

202+
# Digest the process variable
197203
if process.startswith("Z0"):
198204
process = process.replace("Z0", "Z")
205+
if process.startswith("G"):
206+
# Defaults for: 2302.00510
207+
photon = {
208+
"photon_isolation": "etsum[R=0.4, ETmax_const=4.8, ETmax_epsilon=0.0042, ET_threshold=0]",
209+
"photon_fragmentation": "BFG2",
210+
}
199211

200212
# Digest the histogram variable
201213
for histo in histograms:
@@ -204,7 +216,7 @@ def _generate_nnlojet_pinecard(runname, process, energy, experiment, histograms)
204216

205217
ret = {
206218
"runname": runname,
207-
"process": {"proc": process, "sqrts": energy},
219+
"process": {"proc": process, "sqrts": energy, **photon},
208220
"pdf": "NNPDF40_nnlo_as_01180",
209221
"techcut": 1e-7,
210222
"histograms": histograms,
@@ -227,11 +239,21 @@ def _generate_nnlojet_pinecard(runname, process, energy, experiment, histograms)
227239
},
228240
"selectors": selectors,
229241
}
242+
243+
# Add the scale
244+
if process.startswith("Z"):
245+
ret["scales"] = {"mur": "etz", "muf": "etz"}
246+
elif process.startswith("W"):
247+
ret["scales"] = {"mur": "etw", "muf": "etw"}
248+
elif process.startswith("G"):
249+
# Defaults for: 2302.00510 R=0.4
250+
ret["scales"] = {"mur": "pt_gam", "muf": "[pt_gam, 0.871*sqrt_pt_gam]"}
251+
230252
return ret
231253

232254

233255
def generate_pinecard_from_nnpdf(
234-
nnpdf_dataset, scale="etz", output_path=".", observables=None
256+
nnpdf_dataset, scale=None, output_path=".", observables=None
235257
):
236258
"""Generate a NNLOJET pinecard from an NNPDF dataset.
237259
@@ -277,6 +299,8 @@ def generate_pinecard_from_nnpdf(
277299
if "M2" in hist_vars:
278300
if len(kin_df["M2"]["mid"].unique()) == 1:
279301
hist_vars.remove("M2")
302+
elif process.startswith("PH"):
303+
process = process.replace("PH", "GJ")
280304

281305
# Create the histogram depending on whether this is a 1D or 2D distribution (or total)
282306
histograms = None
@@ -286,10 +310,10 @@ def generate_pinecard_from_nnpdf(
286310
elif len(hist_vars) == 2:
287311

288312
# Let's see whether we know how to do this 2D distribution
289-
if "M2" in hist_vars:
290-
svar = "M2"
291-
elif "y" in hist_vars:
292-
svar = "y"
313+
for var_i_know in ["M2", "y", "eta"]:
314+
if var_i_know in hist_vars:
315+
svar = var_i_know
316+
break
293317
else:
294318
raise NotImplementedError(f"Don't know how to do this 2D: {hist_vars}")
295319
hist_vars.remove(svar)
@@ -349,7 +373,7 @@ def generate_pinecard_from_nnpdf(
349373
processes = [process]
350374
if process.startswith("WPWM"):
351375
processes = [process.replace("WP", ""), process.replace("WM", "")]
352-
if process == "DY":
376+
elif process == "DY":
353377
processes = ["Z0", "WP", "WM"]
354378

355379
parent_folder = output_path.parent
@@ -360,7 +384,9 @@ def generate_pinecard_from_nnpdf(
360384
runname = nnpdf_dataset.replace(process, proc)
361385

362386
ret = _generate_nnlojet_pinecard(runname, proc, energy, experiment, histograms)
363-
ret["scales"] = {"mur": scale, "muf": scale}
387+
if scale is not None:
388+
# Default to etz
389+
ret["scales"] = {"mur": scale, "muf": scale}
364390

365391
# Beautify before dumping
366392
data = CommentedMap(ret)

src/pinefarm/external/nnlojet/runcardgen.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,15 +222,19 @@ def parse_input_yaml(yaml_path):
222222

223223

224224
def _fill_process(process):
225-
"""Fill process options."""
225+
"""Fill process block given the metadata for the process"""
226226
process_name = process["proc"]
227227
sqrts = process["sqrts"]
228228
jet = process.get("jet", "none[0]") # Can be None
229-
"""Fill process block given the metadata for the process"""
229+
fill_photon = ""
230+
if process_name.startswith("G"):
231+
fill_photon = f"""
232+
photon_isolation = {process['photon_isolation']}
233+
photon_fragmentation = {process['photon_fragmentation']}"""
230234
return f"""
231235
PROCESS {process_name}
232236
collider = pp sqrts = {sqrts}
233-
jet = {jet}
237+
jet = {jet}{fill_photon}
234238
decay_type = 1
235239
END_PROCESS
236240
"""
@@ -270,6 +274,7 @@ def _fill_parameters(theory_parameters):
270274
return f"""
271275
PARAMETERS
272276
{ptext}
277+
hard_photon_alpha0 = .true. ! only useful for GJ runs
273278
END_PARAMETERS
274279
"""
275280

src/pinefarm/install.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,6 @@ def lhapdf():
300300
301301
This is currently needed by every tool due to postprocessing requirements.
302302
"""
303-
304303
def installed():
305304
"""Define availability condition."""
306305
try:

0 commit comments

Comments
 (0)