65 """Return the directory containing the Pepper process CSVs.
67 Tries (in order): PEPPER_DATA_PATH env var; the share/pepper/data
68 directory next to the binary (1.8.x layout); the share/pepper_data
69 directory next to the binary (1.1.x layout).
71 candidate = os.environ.get(
"PEPPER_DATA_PATH")
72 if candidate
and os.path.isfile(os.path.join(candidate,
"2j.csv")):
75 install_root = os.path.dirname(os.path.dirname(os.path.realpath(exe)))
76 for sub
in (
"share/pepper/data",
"share/pepper_data"):
77 candidate = os.path.join(install_root, sub)
78 if os.path.isfile(os.path.join(candidate,
"2j.csv")):
82 "Could not locate Pepper's process-data directory. "
83 "Set PEPPER_DATA_PATH explicitly to the directory containing "
84 "2j.csv, z0j.csv, etc."
103 output="pepper.events.gz",
107 """Invoke `pepper`, produce an event file, and return its path.
109 The default output is `.events.gz` to match the convention used by
110 AthGeneration's `Gen_tf.py` for upstream-generator input files
111 (`Pythia8_LHEF` and the transform's post-job validator both look
112 for `*.events*`). Internally we invoke pepper with the
113 corresponding `.lhef[.gz]` extension and create the `.events[.gz]`
118 process : Pepper process shortcut, e.g. "ppjj", "ppz1j", "pptt".
119 nevents : Approximate number of unweighted events wanted.
120 seed : Random seed (typically runArgs.randomSeed).
121 ecm : Centre-of-mass energy in GeV (typically runArgs.ecmEnergy).
122 output : Output filename. Must end in one of .events[.gz],
123 .lhef[.gz], .hepmc3[.gz], .hdf5, or .debug.
124 batch_size : Pepper batch size. Defaults to min(nevents, 5000).
125 n_batches : Number of batches. Defaults so that we usually
126 overshoot the requested nevents after accounting for
127 unweighting efficiency.
128 extra_args : List of additional CLI args to pass through.
132 The absolute path of the event file in $PWD.
138 pepper_ext = _EXT_MAP[user_ext]
139 pepper_output = stem + pepper_ext
141 if batch_size
is None:
142 batch_size =
min(nevents, 5000)
143 if n_batches
is None:
146 n_batches =
max(1, (2 * nevents + batch_size - 1) // batch_size)
149 "--process", str(process),
150 "--collision-energy", str(ecm),
152 "--batch-size", str(batch_size),
153 "--n-batches", str(n_batches),
154 "--output", pepper_output]
156 cmd += list(extra_args)
158 env = os.environ.copy()
159 env[
"PEPPER_DATA_PATH"] = data
161 env.setdefault(
"OMP_PROC_BIND",
"spread")
162 env.setdefault(
"OMP_PLACES",
"threads")
164 log.info(
"PEPPER_DATA_PATH = %s", data)
165 log.info(
"Pepper command: %s",
" ".join(cmd))
167 rc = subprocess.call(cmd, env=env)
169 raise RuntimeError(
"pepper exited with rc=%d" % rc)
170 if not os.path.isfile(pepper_output):
171 raise RuntimeError(
"pepper succeeded but %s is missing" % pepper_output)
176 if output != pepper_output:
177 if os.path.lexists(output):
179 os.symlink(os.path.basename(pepper_output), output)
180 log.info(
"Linked %s -> %s", output, pepper_output)
182 return os.path.abspath(output)
run_pepper(process, nevents, seed, ecm, output="pepper.events.gz", batch_size=None, n_batches=None, extra_args=None)