Hyperiso 1.0.3
Modular flavour-physics calculations, Wilson coefficients and statistical inference
Loading...
Searching...
No Matches
mapper_hub.hpp
Go to the documentation of this file.
1#ifndef MAPPER_HUB_H
2#define MAPPER_HUB_H
3
4#include <memory>
5#include <optional>
6#include <string>
7#include <string_view>
8#include <utility>
9#include <vector>
10
11#include "observable_ids.hpp"
12#include "wcoef_ids.hpp"
13#include "wgroup_ids.hpp"
14#include "parametertype_ids.hpp"
15#include "model_ids.hpp"
16#include "wilsonbasis_ids.hpp"
18#include "masstype_ids.hpp"
19#include "scaletype_ids.hpp"
21#include "decay_ids.hpp"
22#include "qcdorder_ids.hpp"
23
54
59 virtual ~IMapperView() = default;
60
67 virtual std::string canonical(std::string_view s) const = 0;
68
74 virtual std::vector<std::string> list_all() const = 0;
75
87 virtual bool register_custom(std::string canonical,
88 std::vector<std::string> aliases) = 0;
89};
90
100template<class Concrete>
102 std::string canonical(std::string_view s) const override {
103 auto id = Concrete::id_of(s);
104 return Concrete::str(id);
105 }
106
107 std::vector<std::string> list_all() const override {
108 std::vector<std::string> out;
109 for (auto& id : Concrete::list_all()) {
110 out.push_back(Concrete::str(id));
111 }
112 return out;
113 }
114
115 bool register_custom(std::string canonical,
116 std::vector<std::string> aliases) override
117 {
118 return Concrete::register_custom(std::move(canonical), std::move(aliases));
119 }
120};
121
128template<class Concrete>
130 std::string canonical(std::string_view s) const override {
131 auto id = Concrete::id_of(s);
132 return Concrete::str(id);
133 }
134
135 std::vector<std::string> list_all() const override {
136 std::vector<std::string> out;
137 for (auto& id : Concrete::list_all()) {
138 out.push_back(Concrete::str(id));
139 }
140 return out;
141 }
142
143 bool register_custom(std::string, std::vector<std::string>) override {
144 return false;
145 }
146};
147
167
168 switch (k) {
169 case MapperKind::Observable: return obs;
170 case MapperKind::WCoef: return wcoef;
171 case MapperKind::Group: return group;
172 case MapperKind::ParameterType: return ptype;
173 case MapperKind::Model: return model;
174 case MapperKind::WilsonBasis: return basis;
175 case MapperKind::ContributionType:return contri;
176 case MapperKind::MassType: return mass;
177 case MapperKind::ScaleType: return scale;
178 case MapperKind::UncertaintyType: return unc;
179 case MapperKind::Decay: return decay;
180 case MapperKind::QCDOrder: return qcd;
181 }
182
183 return obs;
184}
185
189inline std::string canonical_of(MapperKind k, std::string_view s) {
190 return mapper_view(k).canonical(s);
191}
192
196inline std::vector<std::string> list_all(MapperKind k) {
197 return mapper_view(k).list_all();
198}
199
206 std::string canonical,
207 std::vector<std::string> aliases)
208{
209 return mapper_view(k).register_custom(std::move(canonical), std::move(aliases));
210}
211
220inline bool register_custom_wcoef(std::string canonical,
221 std::vector<std::string> aliases,
222 std::pair<int,int> flha)
223{
225 std::move(canonical),
226 std::move(aliases),
227 flha
228 );
229}
230
242inline bool register_custom_observable(std::string canonical,
243 std::vector<std::string> aliases,
244 std::optional<LhaID> ext,
245 std::string_view parent_decay)
246{
248 canonical,
249 std::move(aliases),
250 std::move(ext),
251 parent_decay
252 );
253}
254
267 std::string canonical,
268 std::vector<std::string> aliases,
269 std::vector<CustomObservableSpec> observables)
270{
272 std::move(canonical),
273 std::move(aliases),
274 std::move(observables)
275 );
276}
277
278#endif // MAPPER_HUB_H
QCDOrder
static bool register_custom_with_observables(std::string canonical, std::vector< std::string > aliases, std::vector< CustomObservableSpec > observables)
Register a custom decay and its custom observables in one call.
static bool register_custom(std::string canonical, std::vector< std::string > aliases={}, std::optional< std::pair< int, int > > ext=std::nullopt)
Registers a custom entry with optional external key.
static bool register_custom(const std::string &canonical, std::vector< std::string > aliases, std::optional< LhaID > ext, const DecayId &parent_decay)
Register a custom observable and attach it to a parent decay.
Mapper and dynamic identifiers for decay channels.
MapperKind
Enumeration of mapper families supported by the hub.
std::vector< std::string > list_all(MapperKind k)
List all canonical names known to a mapper kind.
bool register_custom(MapperKind k, std::string canonical, std::vector< std::string > aliases)
Generic registration helper for simple mapper kinds.
bool register_custom_wcoef(std::string canonical, std::vector< std::string > aliases, std::pair< int, int > flha)
Specialized registration helper for Wilson coefficients.
std::string canonical_of(MapperKind k, std::string_view s)
Resolve a name to its canonical representation for a mapper kind.
IMapperView & mapper_view(MapperKind k)
Return the mapper view associated with a mapper kind.
bool register_custom_decay_with_observables(std::string canonical, std::vector< std::string > aliases, std::vector< CustomObservableSpec > observables)
Specialized registration helper for a custom decay with observables.
bool register_custom_observable(std::string canonical, std::vector< std::string > aliases, std::optional< LhaID > ext, std::string_view parent_decay)
Specialized registration helper for custom observables.
Mapper for builtin and runtime observable identifiers.
Minimal runtime-polymorphic view over a mapper.
virtual std::vector< std::string > list_all() const =0
List all known canonical strings.
virtual ~IMapperView()=default
virtual std::string canonical(std::string_view s) const =0
Resolve a name or alias to its canonical string.
virtual bool register_custom(std::string canonical, std::vector< std::string > aliases)=0
Generic custom registration hook.
Adapter for mappers that can be queried generically but not registered.
std::string canonical(std::string_view s) const override
Resolve a name or alias to its canonical string.
std::vector< std::string > list_all() const override
List all known canonical strings.
bool register_custom(std::string, std::vector< std::string >) override
Generic custom registration hook.
Adapter for mappers with simple no-extra-data registration.
std::vector< std::string > list_all() const override
List all known canonical strings.
std::string canonical(std::string_view s) const override
Resolve a name or alias to its canonical string.
bool register_custom(std::string canonical, std::vector< std::string > aliases) override
Generic custom registration hook.
Mapping and helpers for uncertainty types.