Hyperiso 1.0.3
Modular flavour-physics calculations, Wilson coefficients and statistical inference
Loading...
Searching...
No Matches
LhaID.cpp
Go to the documentation of this file.
1#include "LhaID.h"
2
3std::ostream &operator<<(std::ostream &os, const LhaID &id) {
4 os << id.to_string();
5 return os;
6}
7
8LhaID::LhaID(const std::string &str_id) {
9 // std::cout << "herhe : " << str_id << " : " << str_id.size() << std::endl;
10 if (str_id.size() == 0) {
11 parts = {};
12 } else {
13 for (const auto &num : split(str_id, '_')) {
14 parts.emplace_back(std::stol(num));
15 }
16 }
17}
18
19std::string LhaID::to_string() const {
20 std::stringstream ss;
21 if (!this->parts.empty()) {
22 ss << this->parts.at(0);
23 for (size_t i = 1; i < this->parts.size(); i++) {
24 ss << '_' << this->parts.at(i);
25 }
26 }
27 return ss.str();
28}
29
30LhaID::operator long() const {
31 if (this->parts.size() > 1) {
32 LOG_WARN("Casting nontrivial LhaID to int discards information.");
33 for (auto& part : this->parts){
34 std::cout << part<< std::endl;
35 }
36 }
37
38 return this->parts.at(0);
39};
std::ostream & operator<<(std::ostream &os, const LhaID &id)
Definition LhaID.cpp:3
Lightweight representation of LHAPDF / SLHA-style identifiers.
#define LOG_WARN(...)
Macro for logging warning messages.
Definition Logger.h:40
std::vector< std::string > split(const std::string &s, char delimiter)
Splits a string into parts using a single-character delimiter.
Definition Utils.cpp:8
Represents an identifier of a LHA element, possibly containing several sub-ids.
Definition LhaID.h:56
std::vector< long > parts
Definition LhaID.h:57
LhaID(Args... sub_ids)
Constructs an LhaID from a list of integral sub-ids.
Definition LhaID.h:77
std::string to_string() const
Returns the canonical string representation of this LhaID.
Definition LhaID.cpp:19