54 std::pair<int,int>, PairHash,
55 wcoef_mapping, wcoef_flha_mapping
75 static const auto inv = []{
76 std::map<std::pair<int,int>,
WCoef> m;
80 auto it = inv.find({a,b});
81 if (it==inv.end())
throw std::out_of_range(
"Unsupported FLHA key");
127 if (!k)
throw std::runtime_error(
"No FLHA key for " +
id.
str());
158 return LhaID{x,y, int(q)-1, int(c)};
174 auto parts =
id.get_parts();
175 auto w_id = std::make_pair(parts[0], parts[1]);
179 LOG_ERROR(
"ValueError",
"bad lha id for wilson conversion (unknown custom/base key)");
185 std::pair<WCoefId, std::pair<QCDOrder, ContributionType>> ret;
186 ret = {coef, {order, part}};
208 return LhaID{it->second.first, it->second.second, int(q)-1, int(c)};
213 if (!k)
throw std::runtime_error(
"No FLHA key for "+
id.
str());
214 return LhaID{k->first, k->second, int(q)-1, int(c)};
230 static const std::map<std::pair<int,int>,
WCoef> inv = []{
231 std::map<std::pair<int,int>,
WCoef> m;
240 static const std::vector<WCoef>
g = {
247 return 31 + lepton_index;
251 return 101 + lepton_index;
255 return pdg == 11 ? 0 : pdg == 13 ? 1 : pdg == 15 ? 2 : -1;
265 default:
throw std::out_of_range(
"Coefficient is not a CQ1 lepton-specific coefficient");
275 default:
throw std::out_of_range(
"Coefficient is not a CQ2 lepton-specific coefficient");
285 default:
throw std::out_of_range(
"Coefficient is not a CPQ1 lepton-specific coefficient");
295 default:
throw std::out_of_range(
"Coefficient is not a CPQ2 lepton-specific coefficient");
300 switch (lepton_index) {
304 default:
throw std::out_of_range(
"Invalid zero-based lepton generation index for CQ1");
309 switch (lepton_index) {
313 default:
throw std::out_of_range(
"Invalid zero-based lepton generation index for CQ2");
318 switch (lepton_index) {
322 default:
throw std::out_of_range(
"Invalid zero-based lepton generation index for CPQ1");
327 switch (lepton_index) {
331 default:
throw std::out_of_range(
"Invalid zero-based lepton generation index for CPQ2");
343 static const std::vector<WCoef>
g = {
353 static const std::vector<WCoef>
g = {
396 static const std::vector<WCoef>
g = {
431 default:
LOG_ERROR(
"Invalid WGroup",
"get_group couldn't find your group");
return {};
449 static const std::map<WCoef, WGroup> inv = []{
450 std::map<WCoef, WGroup> m;
452 auto add = [&](
WGroup g,
const std::vector<WCoef>& v){
455 if (m.find(e) != m.end())
456 throw std::runtime_error(
"WCoef appears in multiple WGroups");
476 auto it = inv.find(c);
477 if (it == inv.end())
throw std::out_of_range(
"WCoef not assigned to any WGroup");
486 catch (...) {
return std::nullopt; }
496 if (!e)
throw std::runtime_error(
"Unknown WCoefId: " +
id.
str());
Lightweight representation of LHAPDF / SLHA-style identifiers.
#define LOG_ERROR(type,...)
Macro for logging error messages and terminating the application.
const std::map< WCoef, std::pair< int, int > > & wcoef_flha_mapping()
Returns the mapping between WCoef and its FLHA (block, index) pair.
const std::map< WCoef, std::string > & wcoef_mapping()
Returns the mapping between WCoef and its string name.
Static mappings between enum classes and string (or FLHA) identifiers.
Generic enum↔string mapper with external keys and dynamic aliases.
static std::optional< std::pair< int, int > > external_of(const IdOf< WCoefTag > &id)
Returns the external key associated with a given identifier.
static std::optional< WCoef > enum_of(const IdOf< WCoefTag > &id)
Attempts to recover the enum value associated with an identifier.
static IdOf< WCoefTag > enum_elt(std::string_view s)
Alias for id_of(), kept for compatibility.
static std::optional< IdOf< WCoefTag > > from_external(const std::pair< int, int > &k)
Resolves an external key into an identifier.
static IdOf< WCoefTag > to_id(WCoef e)
Converts an enum value to an IdOf<Tag>.
static std::string str(const IdOf< WCoefTag > &id)
Returns the string representation of an identifier.
High-level mapper for WCoef <-> text <-> FLHA base indices.
static const std::vector< WCoef > & s_ulnu_group()
Charged-current Wilsons for s -> u l ν.
static LhaID flha_full(const WCoefId &id, QCDOrder q, ContributionType c)
Builds a full FLHA LhaID for a given WCoefId, order and contribution.
static std::pair< int, int > flha_base(WCoef e)
Returns the base FLHA pair (a,b) for a given WCoef.
static constexpr int lepton_index_from_pdg(int pdg)
static WCoef canonical_flha_coef(WCoef e)
Builds a full FLHA LhaID for a given WCoef, order and contribution.
static const std::vector< WCoef > & c_slnu_group()
Charged-current Wilsons for c -> s l ν.
static LhaID flha_full(WCoef e, QCDOrder q, ContributionType c)
static constexpr int lepton_mass_slot_from_index(int lepton_index)
static const std::vector< WCoef > & b_ulnu_group()
Charged-current Wilsons for b -> u l ν.
static WCoef cpq1_for_lepton_index(int lepton_index)
static std::pair< int, int > flha_base(const WCoefId &id)
Returns the base FLHA pair (a,b) for a given WCoefId.
static std::optional< WGroup > group_of_opt(WCoef c)
Optional version: returns std::nullopt if not in any group.
static const std::vector< WCoef > & b_clnu_group()
Charged-current Wilsons for b -> c l ν.
static const std::vector< WCoef > & k_group()
Kaon-sector Wilsons (K group).
static int lepton_index_from_cq1(WCoef coef)
static bool is_cpq(WCoef c)
static const std::vector< WCoef > & B_scalar_group()
Scalar B-group coefficients, split by charged-lepton generation.
static WGroup group_of(const WCoefId &id)
Convenience overload for identifiers.
static WCoef cq1_for_lepton_index(int lepton_index)
static WCoef cq2_for_lepton_index(int lepton_index)
static WCoef from_flha(int a, int b)
Returns the WCoef associated with a given FLHA base key (a,b).
static std::vector< WCoef > get_group(WGroup g)
Returns the list of Wilson coefficients belonging to a WGroup.
static WCoef cpq2_for_lepton_index(int lepton_index)
static std::optional< WCoefId > from_flha_key(int a, int b)
Registry-based lookup of WCoefId from a FLHA base key (a,b).
static std::pair< WCoefId, std::pair< QCDOrder, ContributionType > > lha_wilson_deserialize(LhaID id)
Deserialize the id of a Wilson coefficient into (WCoefId, QCDOrder, ContributionType) using lha conve...
static int lepton_index_from_cq2(WCoef coef)
static const std::map< std::pair< int, int >, WCoef > & inverse_flha_mapping()
Returns a static inverse mapping FLHA base pair -> WCoef.
static size_t n_wilsons()
Returns the total number of Wilson coefficients in the mapping.
static const std::vector< WCoef > & B_group()
B-group (C1–C10) Wilson coefficients.
static int lepton_index_from_cpq1(WCoef coef)
static constexpr int thdm_lepton_yukawa_slot_from_index(int lepton_index)
static const std::vector< WCoef > & c_dlnu_group()
Charged-current Wilsons for c -> d l ν.
static int lepton_index_from_cpq2(WCoef coef)
static const std::vector< WCoef > & meson_mixing_group()
Wilsons relevant for neutral meson mixing (B, K, D sectors).
static WGroup group_of(WCoef c)
Returns the WGroup to which a given Wilson coefficient belongs.
static const std::vector< WCoef > & B_prime_group()
B'-group coefficients (primed + lepton-specific scalar primed).
static const std::vector< WCoef > & d_ulnu_group()
Charged-current Wilsons for d -> u l ν.
Generic enum↔string (and optional external key) mappers built on DynamicRegistry.
Represents an identifier of a LHA element, possibly containing several sub-ids.
Hash functor for std::pair<int,int>.
Tag type for Wilson-coefficient identifiers.