ATLAS Offline Software
Loading...
Searching...
No Matches
SuperChicConfig.py
Go to the documentation of this file.
1# Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
2
3from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
4from GeneratorConfig.Sequences import EvgenSequence, EvgenSequenceFactory
5from Pythia8_i.Pythia8Config import (
6 Pythia8BaseCfg,
7 Pythia8_A14_NNPDF23LO_Common_Cfg
8)
9from AthenaCommon.SystemOfUnits import GeV
10from EvgenJobTransforms.EvgenHelpers import _get_nevents
11
12# Get logger
13from AthenaCommon.Logging import logging
14log = logging.getLogger("SuperChicConfig")
15
16
17def SuperChicBaseCfg(flags, Config={}, safety=1.1, **kwargs):
18 """
19 The main SuperChic configuration fragment. It creates a SuperChicControl
20 instance that stores the generator configuration parameters and is used
21 to call SuperChicUtils functions responsible for event generation.
22
23 All the configurable parameters and their default values can be found
24 in SuperChicUtils.
25 """
26
27 Config.setdefault("rts", 2*flags.Beam.Energy/GeV)
28 Config.setdefault("nev", _get_nevents(flags, safety))
29 Config.setdefault("iseed", flags.Random.SeedOffset)
30
31 # Create SuperChicControl instance and generate events
32 from Superchic_i.SuperChicControl import SuperChicControl
33 control = SuperChicControl(Config=Config)
34 control.initialize()
35 control.generate()
36
37 # Create CA object
38 ca = ComponentAccumulator(EvgenSequenceFactory(EvgenSequence.Generator))
39
40 # Announce generator to service
41 from GeneratorConfig.GeneratorInfoSvcConfig import GeneratorInfoSvcCfg
42 ca.merge(GeneratorInfoSvcCfg(flags, Generators=["SuperChic"]), sequenceName=EvgenSequence.Generator.value)
43
44 return ca
45
46
47def SuperChicPythia8BaseCfg(flags, Commands=[],
48 LHEFile=None, Config={}, **kwargs):
49 """
50 Modular fragment for setting up base Pythia8 on top of SuperChic.
51
52 LHEFile is the path to LHE output file produced by SuperChic,
53 that is taken as input for Pythia8. It can be set explicitly,
54 or read from the Config dictionary. Otherwise it is set to
55 the default "evrecs/evrecout.dat".
56
57 TestHepMC selection is additionally loosened to avoid crashes.
58 """
59
60 if LHEFile is None:
61 # if no path for LHE file was specify try to read it from Config
62 if 'outtg' in Config:
63 LHEFile = f"evrecs/evrec{Config['outtg']}.dat"
64 # if there was none set in Config use the default
65 else:
66 LHEFile = "evrecs/evrecout.dat"
67
68 # Add Pythia8
69 ca = Pythia8BaseCfg(
70 flags,
71 Commands=Commands,
72 LHEFile=LHEFile,
73 **kwargs
74 )
75
76 # Add TestHepMC configuration
77 from EvgenProdTools.EvgenProdToolsConfig import TestHepMCCfg
78 ca.merge(TestHepMCCfg(
79 flags,
80 MaxTransVtxDisp=1000000,
81 MaxVtxDisp=1000000000
82 ))
83
84 return ca
85
86
88 LHEFile=None, Config={}, **kwargs):
89 """
90 Modular fragment for setting up Pythia8 with A14_NNPDF23LO
91 tunes on top of SuperChic.
92
93 LHEFile is the path to LHE output file produced by SuperChic,
94 that is taken as input for Pythia8. It can be set explicitly,
95 or read from the Config dictionary. Otherwise it is set to
96 the default "evrecs/evrecout.dat".
97
98 TestHepMC selection is additionally loosened to avoid crashes.
99 """
100
101 if LHEFile is None:
102 # if no path for LHE file was specify try to read it from Config
103 if 'outtg' in Config:
104 LHEFile = f"evrecs/evrec{Config['outtg']}.dat"
105 # if there was none set in Config use the default
106 else:
107 LHEFile = "evrecs/evrecout.dat"
108
109 # Add Pythia8
110 ca = Pythia8_A14_NNPDF23LO_Common_Cfg(
111 flags,
112 Commands=Commands,
113 LHEFile=LHEFile,
114 **kwargs
115 )
116
117 # Add TestHepMC configuration
118 from EvgenProdTools.EvgenProdToolsConfig import TestHepMCCfg
119 ca.merge(TestHepMCCfg(
120 flags,
121 MaxTransVtxDisp=1000000,
122 MaxVtxDisp=1000000000
123 ))
124
125 return ca
126
127
129 inputLHEFile="evrecs/evrecout.dat", **kwargs):
130 """
131 Modular fragment for setting the LheConverterUpc.
132 """
133 from MCJobOptionUtils.LheConverterUpc import LheConverterUpc
134 lheConverter = LheConverterUpc(generator='SuperChic',
135 mode='Pythia8',
136 energy=2*flags.Beam.Energy/GeV)
137 lheConverter.fileName = inputLHEFile
138
139 # Create CA object
140 ca = ComponentAccumulator(EvgenSequenceFactory(EvgenSequence.Generator))
141 ca.addEventAlgo(lheConverter)
142
143 return ca
144
145
146def SuperChicLheEvntFillerCfg(flags, name="LheEVNTFiller", **kwargs):
147 """
148 Modular fragment for setting the LheEVNTFiller.
149 """
150
151 from Superchic_i.EventFiller import LheEVNTFiller
152
153 # Create CA object
154 ca = ComponentAccumulator(EvgenSequenceFactory(EvgenSequence.Generator))
155 ca.addEventAlgo(LheEVNTFiller(
156 flags,
157 ecmEnergy=2*flags.Beam.Energy/GeV,
158 name=name,
159 **kwargs
160 ))
161
162 return ca
163
SuperChicPythia8LheConverterUpcCfg(flags, inputLHEFile="evrecs/evrecout.dat", **kwargs)
SuperChicLheEvntFillerCfg(flags, name="LheEVNTFiller", **kwargs)
SuperChicBaseCfg(flags, Config={}, safety=1.1, **kwargs)
SuperChic_Pythia8_A14_NNPDF23LO_Common_Cfg(flags, Commands=[], LHEFile=None, Config={}, **kwargs)
SuperChicPythia8BaseCfg(flags, Commands=[], LHEFile=None, Config={}, **kwargs)