ATLAS Offline Software
Loading...
Searching...
No Matches
Pythia8BConfig.py
Go to the documentation of this file.
1# Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
2
3"""ComponentAccumulator configuration for Pythia8B."""
4
5from AthenaCommon.SystemOfUnits import GeV
6from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
7from AthenaConfiguration.ComponentFactory import CompFactory
8from GeneratorConfig.GeneratorSettingsSemantics import (
9 GeneratorSettingsLayer,
10 GeneratorSettingsPrecedence,
11)
12from GeneratorConfig.Sequences import EvgenSequence, EvgenSequenceFactory
13
14
15_BASE_COMMANDS = (
16 "Main:timesAllowErrors = 500",
17 "6:m0 = 172.5",
18 "23:m0 = 91.1876",
19 "23:mWidth = 2.4952",
20 "24:m0 = 80.399",
21 "24:mWidth = 2.085",
22 "StandardModel:sin2thetaW = 0.23113",
23 "StandardModel:sin2thetaWbar = 0.23146",
24 "ParticleDecays:limitTau0 = on",
25 "ParticleDecays:tau0Max = 10.0",
26)
27
28_A14_CTEQ6L1_COMMANDS = (
29 "Tune:ee = 7",
30 "Tune:pp = 14",
31 "PDF:pSet = LHAPDF6:cteq6l1",
32 "SpaceShower:rapidityOrder = on",
33 "SigmaProcess:alphaSvalue = 0.144",
34 "SpaceShower:pT0Ref = 1.30",
35 "SpaceShower:pTmaxFudge = 0.95",
36 "SpaceShower:pTdampFudge = 1.21",
37 "SpaceShower:alphaSvalue = 0.125",
38 "TimeShower:alphaSvalue = 0.126",
39 "BeamRemnants:primordialKThard = 1.72",
40 "MultipartonInteractions:pT0Ref = 1.98",
41 "MultipartonInteractions:alphaSvalue = 0.118",
42 "ColourReconnection:range = 2.08",
43)
44
45_EXCLUSIVE_B_COMMANDS = (
46 "HardQCD:all = on",
47 "ParticleDecays:mixB = off",
48 "HadronLevel:all = off",
49 "511:onMode = 3",
50 "521:onMode = 3",
51 "531:onMode = 3",
52 "541:onMode = 3",
53 "5122:onMode = 2",
54 "5132:onMode = 2",
55 "5232:onMode = 2",
56 "5332:onMode = 2",
57)
58
59_B_PARTICLE_PDG_CODES = (511, 521, 531, 541, 5122, 5132, 5232, 5332)
60_B_PDG_CODES = _B_PARTICLE_PDG_CODES + tuple(
61 -pdg for pdg in _B_PARTICLE_PDG_CODES
62)
63
64
65def _commands_cfg(flags, source, commands, precedence, name):
66 ca = ComponentAccumulator(EvgenSequenceFactory(EvgenSequence.Generator))
67 ca.addEventAlgo(CompFactory.Pythia8B_i(
68 name,
69 Commands=GeneratorSettingsLayer(
70 source=source,
71 values=tuple(commands),
72 precedence=precedence,
73 report_context="Pythia8BCfg.Commands",
74 ),
75 ))
76 return ca
77
78
79def _with_process_commands(flags, *, ShowerCfg, commands, **kwargs):
80 """Collect nested fragments into one layer, with inner commands first.
81
82 The resolver accepts only one distinct layer at each precedence. Pass the
83 private _process_commands argument down to the base fragment so production
84 and Photos settings share a layer while Commands remains the user layer.
85 """
86 pending_commands = tuple(kwargs.pop("_process_commands", ()))
87 return ShowerCfg(
88 flags,
89 _process_commands=tuple(commands) + pending_commands,
90 **kwargs,
91 )
92
93
94def Pythia8BBaseCfg(flags, name="Pythia8B", **kwargs):
95 """Configure Pythia8B with the standard generator settings."""
96 user_commands = kwargs.pop("Commands", ())
97 process_commands = kwargs.pop("_process_commands", ())
98 kwargs.setdefault("CollisionEnergy", flags.Beam.Energy * 2 / GeV)
99 kwargs.setdefault("RandomSeed", flags.Random.SeedOffset)
100 kwargs.setdefault("Dsid", flags.Generator.DSID)
101 kwargs["Commands"] = GeneratorSettingsLayer(
102 source="base_fragment_commands",
103 values=_BASE_COMMANDS,
104 precedence=GeneratorSettingsPrecedence.BASE,
105 report_context="Pythia8BCfg.Commands",
106 )
107
108 ca = ComponentAccumulator(EvgenSequenceFactory(EvgenSequence.Generator))
109 ca.addEventAlgo(CompFactory.Pythia8B_i(name, **kwargs))
110 if process_commands:
111 # MATCHING places process/decay settings above the tune and below user
112 # overrides; the shared resolver has no separate PROCESS precedence.
113 ca.merge(_commands_cfg(
114 flags, "process_commands", process_commands,
115 GeneratorSettingsPrecedence.MATCHING, name,
116 ))
117 if user_commands:
118 ca.merge(_commands_cfg(
119 flags, "user_commands", user_commands,
120 GeneratorSettingsPrecedence.USER, name,
121 ))
122
123 from GeneratorConfig.GeneratorInfoSvcConfig import GeneratorInfoSvcCfg
124 ca.merge(GeneratorInfoSvcCfg(flags, Generators=["Pythia8B"]),
125 sequenceName=EvgenSequence.Generator.value)
126 return ca
127
128
129def Pythia8B_A14_CTEQ6L1_Common_Cfg(flags, name="Pythia8B", **kwargs):
130 """Configure Pythia8B with the A14 CTEQ6L1 tune."""
131 ca = Pythia8BBaseCfg(flags, name=name, **kwargs)
132
133 from Pythia8_i.Pythia8Config import ensureRapidityOrderMPI
134 tune_commands = ensureRapidityOrderMPI(list(_A14_CTEQ6L1_COMMANDS))
135 ca.merge(_commands_cfg(
136 flags, "pythia8b_tune_A14_CTEQ6L1", tune_commands,
137 GeneratorSettingsPrecedence.TUNE, name,
138 ))
139
140 from GeneratorConfig.GeneratorInfoSvcConfig import GeneratorInfoSvcCfg
141 ca.merge(GeneratorInfoSvcCfg(flags, Tune="A14 CTEQ6L1"),
142 sequenceName=EvgenSequence.Generator.value)
143 return ca
144
145
146def Pythia8B_exclusiveB_Common_Cfg(flags, *, ShowerCfg, **kwargs):
147 """Configure exclusive B-hadron production."""
148 kwargs.setdefault("SelectBQuarks", True)
149 kwargs.setdefault("SelectCQuarks", False)
150 kwargs.setdefault("VetoDoubleBEvents", True)
151 kwargs.setdefault("BPDGCodes", list(_B_PDG_CODES))
153 flags, ShowerCfg=ShowerCfg,
154 commands=_EXCLUSIVE_B_COMMANDS, **kwargs,
155 )
156
157
158def Pythia8B_Photospp_Cfg(flags, *, ShowerCfg, **kwargs):
159 """Disable native lepton QED showering and append Photos++."""
161 flags, ShowerCfg=ShowerCfg,
162 commands=("TimeShower:QEDshowerByL = off",), **kwargs,
163 )
164
165 from Photospp_i.PhotosppConfig import PhotosppCfg
166 ca.merge(PhotosppCfg(flags))
167 return ca
_with_process_commands(flags, *, ShowerCfg, commands, **kwargs)
Pythia8BBaseCfg(flags, name="Pythia8B", **kwargs)
Pythia8B_Photospp_Cfg(flags, *, ShowerCfg, **kwargs)
Pythia8B_exclusiveB_Common_Cfg(flags, *, ShowerCfg, **kwargs)
_commands_cfg(flags, source, commands, precedence, name)
Pythia8B_A14_CTEQ6L1_Common_Cfg(flags, name="Pythia8B", **kwargs)