1"""Python configuration objects converted to native HyperIso structures."""
3from dataclasses
import dataclass, field
4from typing
import Set, Union
6from pyhyperiso.phyperiso.pyhyperiso.common
import (
7 WilsonBuildConfig
as _CppWilsonBuildConfig,
8 WilsonRequest
as _CppWilsonRequest,
9 AlphasConfig
as _CppAlphasConfig,
10 MassConfig
as _CppMassConfig,
24WilsonGroupLike = Union[WGroup, WGroupId, str]
25WilsonCoefLike = Union[WCoeff, WCoefId, str]
28def _cpp_group_id(group: WilsonGroupLike):
29 """Convert a group enum/string/id to the bound C++ ``WGroupId``."""
30 if isinstance(group, WGroupId):
31 return group._to_cpp()
35def _cpp_coef_id(coef: WilsonCoefLike):
36 """Convert a coefficient enum/string/id to the bound C++ ``WCoefId``."""
37 if isinstance(coef, WCoefId):
44 """Configuration for building Wilson coefficient groups.
46 The C++ layer stores groups as dynamic ``WGroupId`` values. Python accepts
47 legacy :class:`WGroup` enums, strings/aliases, or :class:`WGroupId` objects.
50 groups: Wilson groups to build. Examples: ``WGroup.B``,
51 ``"BCoefficients"`` or ``GroupMapper.id_of("DEV_GROUP")``.
52 matching_scale: Matching scale in GeV.
53 hadronic_scale: Hadronic/running scale in GeV.
54 order: Maximum QCD order requested for matching/running.
57 groups: Set[WilsonGroupLike] = field(default_factory=set)
58 matching_scale: float = 81.0
59 hadronic_scale: float = 4.8
60 order: QCDOrder = QCDOrder.LO
62 def to_cpp(self) -> _CppWilsonBuildConfig:
63 """Convert this Python config to the bound C++ config object."""
64 cpp = _CppWilsonBuildConfig()
65 cpp.groups = {_cpp_group_id(g)
for g
in self.
groups}
68 cpp.order = self.
order.value
74 """Request for one Wilson coefficient.
76 ``group`` and ``coefficient`` accept both legacy enums and dynamic ids. This
77 means the same wrapper can query builtin Wilson coefficients and custom
78 lambda-backed coefficients.
81 group: WilsonGroupLike
82 coefficient: WilsonCoefLike
83 order: QCDOrder = QCDOrder.LO
84 contribution: ContributionType = ContributionType.TOTAL
85 scale_type: ScaleType = ScaleType.HADRONIC
86 wilson_basis: WilsonBasis = WilsonBasis.STANDARD
87 sum_qcd_orders: bool =
False
89 def to_cpp(self) -> _CppWilsonRequest:
90 """Convert this request to the bound C++ ``WilsonRequest``."""
91 return _CppWilsonRequest(
101 """Return keyword arguments suitable for matching-scale getters."""
110 """Return keyword arguments suitable for running-scale getters."""
122 """Configuration for evaluating the strong coupling constant ``alpha_s``."""
125 m_b_type: MassType = field(default=MassType.POLE)
126 m_t_type: MassType = field(default=MassType.POLE)
129 """Convert this Python config to the bound C++ config object."""
135 """Configuration for computing a particle mass at a given scale."""
137 pdg_id: int = field(default=6)
140 """Convert this Python config to the bound C++ config object."""
static IdOf< WGroupTag > id_of(std::string_view s)
Resolves a string into an IdOf<Tag> via the registry.
_CppAlphasConfig to_cpp(self)
_CppMassConfig to_cpp(self)
_CppWilsonBuildConfig to_cpp(self)
ContributionType contribution
_CppWilsonRequest to_cpp(self)
WilsonCoefLike coefficient