ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Generators
Sherpa_i
python
SherpaConfig.py
Go to the documentation of this file.
1
# Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
2
3
from
AthenaConfiguration.ComponentAccumulator
import
ComponentAccumulator
4
from
AthenaConfiguration.ComponentFactory
import
CompFactory
5
from
GeneratorConfig.Sequences
import
EvgenSequence, EvgenSequenceFactory
6
7
# This configuration fragment contains the baseline Sherpa settings
8
# and other higher-level configs that the users will call to create
9
# the CA object in the setupProcess method of their sample config class
10
# in the top-level jO.
11
12
# Get logger
13
from
AthenaCommon.Logging
import
logging
14
log = logging.getLogger(
"SherpaConfig"
)
15
16
# Helper functions from SherpaUtils
17
from
Sherpa_i.SherpaUtils
import
(
18
build_sherpa3_base_fragment,
19
validate_sherpa3_yaml_fragment,
20
write_pretty_fragment
21
)
22
23
24
def
SherpaBaseCfg
(flags, name="Sherpa_i", **kwargs):
25
"""
26
Public methods for Sherpa CA configuration fragment,
27
migrated from Sherpa_i/share/common/Base_Fragment.py.
28
This is the the method that users should call (if needed)
29
in their jO. We don't want them to change the BaseFragment
30
so we pop it from kwargs before calling the internal function.
31
"""
32
kwargs.pop(
"BaseFragment"
,
None
)
33
34
return
_SherpaBaseCfg
(flags, name=name, **kwargs)
35
36
37
def
_SherpaBaseCfg
(flags, name="Sherpa_i", _base_fragment="", **kwargs):
38
"""
39
Internal Sherpa base fragment builder.
40
"""
41
42
kwargs.setdefault(
"PluginCode"
,
""
)
43
kwargs.setdefault(
"RandomSeed"
, flags.Random.SeedOffset)
44
kwargs.setdefault(
"Dsid"
, flags.Generator.DSID)
45
46
# Build the Base.yaml fragment from an optional internal prefix plus Sherpa3 defaults.
47
base_fragment = _base_fragment
48
if
base_fragment
and
not
base_fragment.endswith(
"\n"
):
49
base_fragment +=
"\n"
50
kwargs[
"BaseFragment"
] = base_fragment + build_sherpa3_base_fragment(flags)
51
validate_sherpa3_yaml_fragment(
"BaseFragment"
, kwargs[
"BaseFragment"
])
52
if
"RunCard"
in
kwargs:
53
validate_sherpa3_yaml_fragment(
"RunCard"
, kwargs[
"RunCard"
])
54
55
# Create CA object and add Sherpa algorithm
56
ca = ComponentAccumulator(EvgenSequenceFactory(EvgenSequence.Generator))
57
ca.addEventAlgo(CompFactory.Sherpa_i(name, **kwargs))
58
59
# Announce generator to service
60
from
GeneratorConfig.GeneratorInfoSvcConfig
import
GeneratorInfoSvcCfg
61
ca.merge(GeneratorInfoSvcCfg(flags, Generators=[
"Sherpa"
]))
62
63
return
ca
64
65
66
def
Sherpa3_PDF4LHC21_Cfg
(flags, **kwargs):
67
"""Fragment for setting up Sherpa 3 with the PDF4LHC21 tune"""
68
69
from
os
import
environ
70
sherpa_version = environ.get(
"SHERPAVER"
)
71
if
sherpa_version
is
None
:
72
raise
RuntimeError(
"SHERPAVER is not set in the environment."
)
73
if
not
sherpa_version.startswith(
"3."
):
74
raise
RuntimeError(
"Sherpa3_PDF4LHC21_Cfg requires Sherpa 3."
)
75
76
# Nominal PDF settings
77
pdf_fragment = write_pretty_fragment(
78
"""
79
PDF_LIBRARY: LHAPDFSherpa
80
USE_PDF_ALPHAS: 1
81
PDF_SET: PDF4LHC21_40_pdfas
82
"""
83
)
84
85
# Enable PDF variations by default
86
pdf_fragment += write_pretty_fragment(
87
"""
88
PDF_VARIATIONS:
89
- PDF4LHC21_40_pdfas*
90
- MSHT20nnlo_as118
91
- CT18NNLO_as_0118
92
- NNPDF31_nnlo_as_0118_hessian
93
- NNPDF40_nnlo_as_01180_hessian
94
- CT18ANNLO
95
- CT18XNNLO
96
- CT18ZNNLO
97
"""
98
)
99
100
# Append PDF settings through the internal BaseFragment prefix and create the CA object.
101
ca =
_SherpaBaseCfg
(flags, _base_fragment=pdf_fragment, **kwargs)
102
103
# Broadcast tune to service
104
from
GeneratorConfig.GeneratorInfoSvcConfig
import
GeneratorInfoSvcCfg
105
ca.merge(GeneratorInfoSvcCfg(flags, Tune=
"PDF4LHC21"
))
106
107
return
ca
python.SherpaConfig.SherpaBaseCfg
SherpaBaseCfg(flags, name="Sherpa_i", **kwargs)
Definition
SherpaConfig.py:24
python.SherpaConfig._SherpaBaseCfg
_SherpaBaseCfg(flags, name="Sherpa_i", _base_fragment="", **kwargs)
Definition
SherpaConfig.py:37
python.SherpaConfig.Sherpa3_PDF4LHC21_Cfg
Sherpa3_PDF4LHC21_Cfg(flags, **kwargs)
Definition
SherpaConfig.py:66
Generated on
for ATLAS Offline Software by
1.17.0