3from AthenaCommon.SystemOfUnits
import GeV
6from AthenaCommon.Logging
import logging
7log = logging.getLogger(
"SherpaConfig")
12 Keep multiline fragments readable in source code while preserving output indentation.
13 Sherpa_i C++ currently strips the first line and final character of the incoming string,
14 so we intentionally prepend a blank line and append a trailing newline.
16 from textwrap
import dedent
17 return "\n" + dedent(text).
strip(
"\n") +
"\n"
21 """Validate Sherpa 3 YAML input."""
22 if fragment_text
is None:
25 text = fragment_text
if isinstance(fragment_text, str)
else str(fragment_text)
31 except Exception
as exc:
32 log.warning(f
"YAML validation skipped for {fragment_name} (could not import yaml: {exc})")
37 except Exception
as exc:
38 mark = getattr(exc,
"problem_mark",
None)
39 problem = getattr(exc,
"problem",
None)
42 location = f
" (line {mark.line + 1}, column {mark.column + 1})"
44 detail = problem
if problem
else str(exc).splitlines()[0]
45 raise RuntimeError(f
"{fragment_name} is invalid YAML{location}: {detail}")
49 """Default particle data used in Sherpa base fragments"""
52 "5": {
"mass":
"4.95",
"width":
"0."},
53 "6": {
"mass":
"1.725E+02",
"width":
"1.32E+00"},
54 "15": {
"mass":
"1.777",
"width":
"2.26735e-12"},
55 "23": {
"mass":
"91.1876",
"width":
"2.4952"},
56 "24": {
"mass":
"80.399",
"width":
"2.085"},
61 """Build the Sherpa 3 BaseFragment YAML string."""
67 BEAM_ENERGIES: {flags.Beam.Energy / GeV}
69 MAX_PROPER_LIFETIME: 10.0
72 EXTERNAL_RNG: Atlas_RNG
74 OVERWEIGHT_THRESHOLD: 10
86 for pdg_id
in sorted(particle_data, key=int):
87 values = particle_data[pdg_id]
90 f
" Mass: {values['mass']}\n"
91 f
" Width: {values['width']}\n"
104 "6 -> 24 5": { Width: 1.32 }
105 "-6 -> -24 -5": { Width: 1.32 }
106 "25 -> 5 -5": { Width: 2.35e-3 }
107 "25 -> 15 -15": { Width: 2.57e-4 }
108 "25 -> 13 -13": { Width: 8.91e-7 }
109 "25 -> 4 -4": { Width: 1.18e-4 }
110 "25 -> 3 -3": { Width: 1.00e-6 }
111 "25 -> 21 21": { Width: 3.49e-4 }
112 "25 -> 22 22": { Width: 9.28e-6 }
113 "24 -> 2 -1": { Width: 0.7041 }
114 "24 -> 4 -3": { Width: 0.7041 }
115 "24 -> 12 -11": { Width: 0.2256 }
116 "24 -> 14 -13": { Width: 0.2256 }
117 "24 -> 16 -15": { Width: 0.2256 }
118 "-24 -> -2 1": { Width: 0.7041 }
119 "-24 -> -4 3": { Width: 0.7041 }
120 "-24 -> -12 11": { Width: 0.2256 }
121 "-24 -> -14 13": { Width: 0.2256 }
122 "-24 -> -16 15": { Width: 0.2256 }
123 "23 -> 1 -1": { Width: 0.3828 }
124 "23 -> 2 -2": { Width: 0.2980 }
125 "23 -> 3 -3": { Width: 0.3828 }
126 "23 -> 4 -4": { Width: 0.2980 }
127 "23 -> 5 -5": { Width: 0.3828 }
128 "23 -> 11 -11": { Width: 0.0840 }
129 "23 -> 12 -12": { Width: 0.1663 }
130 "23 -> 13 -13": { Width: 0.0840 }
131 "23 -> 14 -14": { Width: 0.1663 }
132 "23 -> 15 -15": { Width: 0.0840 }
133 "23 -> 16 -16": { Width: 0.1663 }
141 from os
import environ
142 openloops_path = environ.get(
"OPENLOOPSPATH")
144 base_fragment += f
"OL_PREFIX: {openloops_path}\n"
146 log.warning(
"OPENLOOPSPATH not set")
build_sherpa3_base_fragment(flags)
validate_sherpa3_yaml_fragment(fragment_name, fragment_text)
write_pretty_fragment(text)