3from AthenaConfiguration.ComponentAccumulator
import ComponentAccumulator
4from AthenaConfiguration.ComponentFactory
import CompFactory
5from GeneratorConfig.GeneratorSettingsSemantics
import (
6 GeneratorSettingsLayer,
7 GeneratorSettingsPrecedence,
9from GeneratorConfig.Sequences
import EvgenSequence, EvgenSequenceFactory
10from Pythia8_i.Pythia8Tunes
import (
11 a14_nnpdf23lo_tune_cmds,
12 a2_mstw2008lo_tune_cmds,
14from AthenaCommon.SystemOfUnits
import GeV
17from AthenaCommon.Logging
import logging
18log = logging.getLogger(
"Pythia8Config")
23 Return a CA fragment that adds one command layer to Pythia8_i.
25 ca = ComponentAccumulator(EvgenSequenceFactory(EvgenSequence.Generator))
27 CompFactory.Pythia8_i(name, Commands=GeneratorSettingsLayer(
29 values=tuple(commands
or ()),
30 precedence=precedence,
31 report_context=
"Pythia8Cfg.Commands",
39 The main Pythia8 configuration fragment that sets up the Pythia8_i algorithm
40 and returns a CA instance
44 "Main:timesAllowErrors = 500",
45 "ParticleDecays:limitTau0 = on",
46 "ParticleDecays:tau0Max = 10.0"
50 if "CollisionEnergy" not in kwargs:
51 kwargs[
"CollisionEnergy"] = flags.Beam.Energy * 2 / GeV
54 kwargs.setdefault(
"RandomSeed", flags.Random.SeedOffset)
55 kwargs.setdefault(
"Dsid", flags.Generator.DSID)
64 "StandardModel:sin2thetaW = 0.23113",
65 "StandardModel:sin2thetaWbar = 0.23146",
68 user_cmds = kwargs.pop(
"Commands",
None)
69 kwargs[
"Commands"] = GeneratorSettingsLayer(
70 source=
"base_fragment_commands",
71 values=tuple(base_cmds),
72 precedence=GeneratorSettingsPrecedence.BASE,
73 report_context=
"Pythia8Cfg.Commands",
77 ca = ComponentAccumulator(EvgenSequenceFactory(EvgenSequence.Generator))
79 CompFactory.Pythia8_i(name, **kwargs)
86 source=
"user_commands",
88 precedence=GeneratorSettingsPrecedence.USER,
93 from GeneratorConfig.GeneratorInfoSvcConfig
import GeneratorInfoSvcCfg
94 ca.merge(GeneratorInfoSvcCfg(flags, Generators=[
"Pythia8"]), sequenceName=EvgenSequence.Generator.value)
101 Fragment for setting up EvtGen on top of Pythia 8
104 auxfiles = [
"inclusiveP8DsDPlus.pdt"]
106 whiteList = [-5334, 5334]
109 from EvtGen_i.EvtGenConfig
import EvtGenCfg
112 whiteList = whiteList,
122 Fragment for setting up A2 MSTW2008LO tune
126 user_cmds = list(kwargs.pop(
"Commands", []))
132 tune_cmds = a2_mstw2008lo_tune_cmds()
138 source=
"pythia_tune_A2_MSTW2008LO",
140 precedence=GeneratorSettingsPrecedence.TUNE,
147 source=
"job_options",
149 precedence=GeneratorSettingsPrecedence.USER,
153 from GeneratorConfig.GeneratorInfoSvcConfig
import GeneratorInfoSvcCfg
154 ca.merge(GeneratorInfoSvcCfg(flags, Tune=
"A2 MSTW2008LO"), sequenceName=EvgenSequence.Generator.value)
162 Fragment for setting up A14 tune with NNPDF23LO PDF
166 user_cmds = list(kwargs.pop(
"Commands", []))
172 tune_cmds = a14_nnpdf23lo_tune_cmds()
178 source=
"pythia_tune_A14_NNPDF23LO",
180 precedence=GeneratorSettingsPrecedence.TUNE,
187 source=
"job_options",
189 precedence=GeneratorSettingsPrecedence.USER,
193 from GeneratorConfig.GeneratorInfoSvcConfig
import GeneratorInfoSvcCfg
194 ca.merge(GeneratorInfoSvcCfg(flags, Tune=
"A14 NNPDF23LO"), sequenceName=EvgenSequence.Generator.value)
202 Config for Py8 tune A2 with MSTW2008LO tune
203 The default version of this includes EvtGen for standardised b fragmentation
204 This tune is generally only used for pile up samples at the start of run 2
205 for high pT physics at the start of run 2 the A14 tune is more appropriate.
206 There are also more recent soft QCD tunes, such as Monash,
207 but A2 was a conservative choice for initial 13 TeV pile up
221 Config for setting up Py8 with A14 tune
236 A function that ensures rapidity ordering is set
239 if any(
"SpaceShower:rapidityOrderMPI" in c
for c
in cmds):
244 if "SpaceShower:rapidityOrder" in c
and "MPI" not in c:
245 val = c.split(
"=", 1)[-1].
strip()
246 cmds.append(f
"SpaceShower:rapidityOrderMPI = {val}")
253 Modular fragment for MadGraph LHE input in Pythia8.
254 The Pythia8_i algorithm is configured through ShowerCfg (defaults to
255 Pythia8BaseCfg) so tune/EvtGen fragments can be injected without
256 instantiating Pythia8_i twice.
262 if flags.Generator.avoidExtracting
265 kwargs.setdefault(
"LHEFile", lhe_file)
268 ca = ShowerCfg(flags, **kwargs)
271 from GeneratorConfig.GeneratorInfoSvcConfig
import GeneratorInfoSvcCfg
272 ca.merge(GeneratorInfoSvcCfg(flags, Generators=[
"MadGraph"]), sequenceName=EvgenSequence.Generator.value)
279 Configure Pythia8 to shower POWHEG-BOX LHE input without veto matching.
280 CA translation of share/common/Pythia8_Powheg.py (+ Pythia8_LHEF.py).
281 The Pythia8_i algorithm is configured through ShowerCfg so tune/EvtGen
282 fragments can be injected without instantiating Pythia8_i twice.
286 if flags.Generator.avoidExtracting
289 kwargs.setdefault(
"LHEFile", lhe_file)
291 ca = ShowerCfg(flags, **kwargs)
293 from GeneratorConfig.GeneratorInfoSvcConfig
import GeneratorInfoSvcCfg
295 ca.merge(GeneratorInfoSvcCfg(flags, Generators=[
"Powheg"]), sequenceName=EvgenSequence.Generator.value)
302 ShowerCfg=Pythia8BaseCfg,
305 enable_shower_weights=True,
306 include_pdf_variations=False,
310 Configure POWHEG LHE showering with the PowhegMain31 veto hook.
311 CA translation of share/common/Pythia8_Powheg_Main31.py.
312 NFinal is the number of outgoing particles in the Born-level POWHEG
313 process, excluding additional POWHEG radiation.
315 By default this fragment also enables the legacy Pythia8 shower
316 uncertainty weights. Set enable_shower_weights=False to disable, or
317 include_pdf_variations=True to add the PDF-variation weights.
320 raise ValueError(
"Pythia8_Powheg_Main31_Cfg: NFinal is process-specific "
321 "and must be set explicitly (Born final-state multiplicity)")
325 user_commands = kwargs.pop(
"Commands",
None)
327 user_hooks = list(kwargs.pop(
"UserHooks", ())
or ())
328 if "PowhegMain31" not in user_hooks:
329 user_hooks.append(
"PowhegMain31")
331 ca =
Pythia8_Powheg_Cfg(flags, ShowerCfg=ShowerCfg, name=name, UserHooks=user_hooks, **kwargs)
335 source=
"powheg_main31_matching",
337 "SpaceShower:pTmaxMatch = 2",
338 "TimeShower:pTmaxMatch = 2",
340 f
"Powheg:NFinal = {NFinal}",
342 precedence=GeneratorSettingsPrecedence.MATCHING,
346 if enable_shower_weights:
347 from Pythia8_i.Pythia8ShowerWeights
import Pythia8ShowerWeightsCfg
348 ca.merge(Pythia8ShowerWeightsCfg(
351 include_pdf_variations=include_pdf_variations,
357 source=
"job_options",
358 commands=user_commands,
359 precedence=GeneratorSettingsPrecedence.USER,
Pythia8CommandsCfg(flags, source, commands, precedence, name="Pythia8_i")
Pythia8_A2_MSTW2008LO_Common_Cfg(flags, **kwargs)
Pythia8_A14_NNPDF23LO_Common_Cfg(flags, **kwargs)
ensureRapidityOrderMPI(cmds)
Pythia8EvtGenBaseCfg(flags, **kwargs)
Pythia8_A14_NNPDF23LO_EvtGen_Common_Cfg(flags, **kwargs)
Pythia8_Powheg_Main31_Cfg(flags, ShowerCfg=Pythia8BaseCfg, NFinal=None, name="Pythia8_i", enable_shower_weights=True, include_pdf_variations=False, **kwargs)
Pythia8_Powheg_Cfg(flags, *, ShowerCfg, **kwargs)
Pythia8_MadGraph_Cfg(flags, ShowerCfg=Pythia8BaseCfg, **kwargs)
Pythia8_A2_MSTW2008LO_EvtGen_Common_Cfg(flags, **kwargs)
Pythia8BaseCfg(flags, name="Pythia8_i", **kwargs)