Hyperiso 1.0.3
Modular flavour-physics calculations, Wilson coefficients and statistical inference
Loading...
Searching...
No Matches
ParameterRouter.cpp
Go to the documentation of this file.
1#include "ParameterRouter.h"
2
6
7void ParameterBlockRepartition::register_custom_bsm_blocks(const std::vector<BlockName>& blockNames) {
8 for (const auto& blockName : blockNames) {
10 }
11}
12
14 return CUSTOM_BSM_BLOCKS.contains(blockName);
15}
16
17const std::unordered_set<BlockName>& ParameterBlockRepartition::custom_bsm_blocks() {
18 return CUSTOM_BSM_BLOCKS;
19}
20
21std::unordered_set<BlockName> ParameterBlockRepartition::get_blocks(ParameterType type) {
22 auto blocks = BLOCKS.at(type);
23
24 if (type == ParameterType::BSM) {
25 blocks.insert(CUSTOM_BSM_BLOCKS.begin(), CUSTOM_BSM_BLOCKS.end());
26 }
27
28 return blocks;
29}
30
31std::vector<BlockName> ParameterBlockRepartition::filter_custom_blocks(const std::vector<BlockName> &source) {
32 std::unordered_set<std::string> known_norm;
33 for (const auto& [_, known] : ParameterBlockRepartition::BLOCKS) {
34 for (const auto& b : known) {
35 known_norm.insert(to_lowercase(b));
36 }
37 }
38
39 std::vector<BlockName> custom_blocks;
40 custom_blocks.reserve(source.size());
41
42 for (const auto& block : source) {
43 const auto bnorm = to_lowercase(block);
44
45 // Special cases
46 if (bnorm == "mass" || bnorm == "gauge") {
47 custom_blocks.emplace_back(block);
48 continue;
49 }
50
51 if (!known_norm.count(bnorm)) {
52 custom_blocks.emplace_back(block);
53 }
54 }
55
56 return custom_blocks;
57}
58
60 auto conflict_blocks = get_keys<BlockName, std::unordered_set<long>>(ParametersAccessRights::SM_RIGHTS);
61
62 if (conflict_blocks.contains(block)) {
64 }
65
67 return ParameterType::BSM;
68 }
69
70 for (const auto& [type, _] : ParameterBlockRepartition::BLOCKS) {
71 const auto owned_blocks = ParameterBlockRepartition::get_blocks(type);
72 if (owned_blocks.contains(block)) {
73 return type;
74 }
75 }
76
77 LOG_ERROR("Invalid Parameter", "Parameter", block, ",", id, "is undefined.");
78}
79
80std::vector<ParameterType> ParamRouter::GetType(BlockName block) {
81 std::vector<ParameterType> param_types;
82 for (const auto& [type, _] : ParameterBlockRepartition::BLOCKS) {
83 const auto owned_blocks = ParameterBlockRepartition::get_blocks(type);
84 if (owned_blocks.contains(block)) {
85 param_types.emplace_back(type);
86 }
87 }
88 return param_types;
89}
90
91std::unordered_set<BlockName> ParamRouter::GetOwnedBlocks(ParameterType ptype) {
93}
ParameterType
#define LOG_ERROR(type,...)
Macro for logging error messages and terminating the application.
Definition Logger.h:41
Defines structures and classes for routing and categorizing parameter blocks.
std::string to_lowercase(const std::string &str)
Returns a lowercase copy of the input string.
Definition Utils.cpp:31
Block identifier with alias support.
Definition BlockName.h:59
static std::unordered_set< BlockName > GetOwnedBlocks(ParameterType ptype)
Retrieves all blocks owned by a given ParameterType.
static ParameterType GetType(BlockName block, LhaID id)
Determines the ParameterType of a given (block, LhaID) pair.
Represents an identifier of a LHA element, possibly containing several sub-ids.
Definition LhaID.h:56
static std::unordered_set< BlockName > CUSTOM_BSM_BLOCKS
Runtime-registered blocks that should be treated as BSM blocks.
static void register_custom_bsm_blocks(const std::vector< BlockName > &blockNames)
Registers several runtime blocks as BSM-owned.
static const std::map< ParameterType, std::unordered_set< BlockName > > BLOCKS
Static map associating a ParameterType with a set of block names.
static std::unordered_set< BlockName > get_blocks(ParameterType type)
Returns the static blocks plus runtime BSM blocks when relevant.
static const std::unordered_set< BlockName > & custom_bsm_blocks()
Returns the registered runtime BSM blocks.
static bool is_custom_bsm_block(BlockName blockName)
Checks whether one block was registered dynamically as BSM-owned.
static void register_custom_bsm_block(BlockName blockName)
Registers one runtime block as BSM-owned.
static std::vector< BlockName > filter_custom_blocks(const std::vector< BlockName > &source)
Filters custom (non-standard) blocks from a source list.
static const std::map< BlockName, std::unordered_set< long > > SM_RIGHTS
Access rights for Standard Model (SM) parameters.