ATLAS Offline Software
Loading...
Searching...
No Matches
Pepper_Common.py
Go to the documentation of this file.
1# Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
2#
3# Generators/Pepper_i/share/common/Pepper_Common.py
4#
5# JO fragment that runs Pepper and hands the parton-level events to
6# the transform. Include this from a DSID JO file after setting at
7# minimum:
8#
9# PEPPER_PROCESS = "ppjj" # any built-in Pepper process shortcut
10#
11# Optional overrides:
12#
13# PEPPER_NEVENTS - minimum number of events to be written.
14# default: PEPPER_SAFETY_FACTOR times the
15# number of events the job has to deliver
16# (runArgs.maxEvents if given, otherwise
17# evgenConfig.nEventsPerJob), rounded up
18# PEPPER_SAFETY_FACTOR - default: 1.1 when the events are showered
19# in this job, so that the shower does not
20# run out of them; 1.0 for LHE-only jobs
21# PEPPER_SEED - default: runArgs.randomSeed
22# PEPPER_ECM - default: runArgs.ecmEnergy
23# PEPPER_OUTPUT - default: "pepper.lhef"
24# PEPPER_BATCH_SIZE - phase-space points per batch (throughput
25# tuning only), default: 1000
26# PEPPER_EXTRA_ARGS - list of additional CLI args, default: []
27#
28# After this fragment has run, the events are available to the
29# transform in the same way as for MadGraphControl: the skeleton links
30# them to `events.lhe`, and they are packed into the TXT output if the
31# job was given --outputTXTFile. `PEPPER_OUTPUT` holds the path of the
32# file Pepper wrote.
33#
34# Pepper + Pythia8 in one job (run with --outputEVNTFile):
35#
36# evgenConfig.generators = ["Pepper", "Pythia8", "EvtGen"]
37# PEPPER_PROCESS = "ppjj"
38# include("Pepper_i/Pepper_Common.py")
39# include("Pythia8_i/Pythia8_A14_NNPDF23LO_EvtGen_Common.py")
40# include("Pythia8_i/Pythia8_LHEF.py")
41#
42# LHE only (run with --outputTXTFile and no --outputEVNTFile):
43#
44# evgenConfig.generators = ["Pepper"]
45# PEPPER_PROCESS = "ppjj"
46# include("Pepper_i/Pepper_Common.py")
47#
48# This fragment requires the Pepper_i package and a GPU-equipped
49# worker node. See Generators/Pepper_i/doc/README.md.
50
51import math
52
53from Pepper_i.PepperConfig import run_pepper, arrange_output
54
55if "PEPPER_N_BATCHES" in globals():
56 raise RuntimeError(
57 "Pepper_Common.py: PEPPER_N_BATCHES is no longer supported. It "
58 "counted trial phase-space points rather than written events; "
59 "set PEPPER_NEVENTS (minimum number of written events) instead.")
60
61# LHE-only job: a TXT output and no EVNT output.
62_lhe_only = (hasattr(runArgs, "outputTXTFile")
63 and not hasattr(runArgs, "outputEVNTFile")
64 and not hasattr(runArgs, "outputEVNT_PreFile"))
65
66_process = globals().get("PEPPER_PROCESS")
67_safety = globals().get("PEPPER_SAFETY_FACTOR", 1.0 if _lhe_only else 1.1)
68_seed = globals().get("PEPPER_SEED", runArgs.randomSeed)
69_ecm = globals().get("PEPPER_ECM", runArgs.ecmEnergy)
70_output = globals().get("PEPPER_OUTPUT", "pepper.lhef")
71_batch_size = globals().get("PEPPER_BATCH_SIZE", None)
72_extra = globals().get("PEPPER_EXTRA_ARGS", None)
73
74if _process is None:
75 raise RuntimeError(
76 "Pepper_Common.py: please set PEPPER_PROCESS in the JO "
77 "(e.g. PEPPER_PROCESS = 'ppjj').")
78
79# Number of events this job has to deliver: --maxEvents if given on
80# the command line, otherwise evgenConfig.nEventsPerJob.
81_target = getattr(runArgs, "maxEvents", -1)
82if not _target or _target < 1:
83 _target = evgenConfig.nEventsPerJob
84
85# Small tolerance so that e.g. 1.1 * 10000 does not round up to 11001.
86_nevents = globals().get("PEPPER_NEVENTS",
87 int(math.ceil(_target * _safety - 1e-9)))
88
89# Run Pepper. PEPPER_OUTPUT is exported back into the JO scope.
90PEPPER_OUTPUT = run_pepper(
91 process = _process,
92 nevents = _nevents,
93 seed = _seed,
94 ecm = _ecm,
95 output = _output,
96 batch_size = _batch_size,
97 extra_args = _extra,
98)
99
100# Hand the events to the transform (events.lhe link, TXT output).
101arrange_output(PEPPER_OUTPUT, runArgs)
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition hcg.cxx:132