27 auto names = Get<std::vector<std::string>>(
config[
"MaCh3Modes"], __FILE__, __LINE__);
29 for(
size_t i = 0; i < names.size(); i++)
32 Get<std::string>(
config[names[i]][
"Name"], __FILE__, __LINE__),
33 Get<int>(
config[names[i]][
"PlotColor"], __FILE__, __LINE__),
34 Get<std::vector<int>>(
config[names[i]][
"GeneratorMaping"], __FILE__, __LINE__),
35 Get<bool>(
config[names[i]][
"IsNC"], __FILE__, __LINE__),
36 Get<std::string>(
config[names[i]][
"SplineSuffix"], __FILE__, __LINE__));
38 if (!Get<bool>(
config[names[i]][
"IsNC"], __FILE__, __LINE__)) {
62 MACH3LOG_INFO(
"========================================================================");
63 MACH3LOG_INFO(
"{:<5} {:2} {:<20} {:2} {:<20} {:2} {:<30}",
"#",
"|",
"Name",
"|",
"FancyName",
"|",
Generator+
" Modes");
64 MACH3LOG_INFO(
"------------------------------------------------------------------------");
65 for(
int i = 0; i <
NModes; ++i) {
67 auto Name =
fMode.at(i).Name;
68 auto FancyName =
fMode.at(i).FancyName;
69 auto Values =
fMode.at(i).GeneratorMaping;
70 std::string generatorModes;
71 for (
const int& element : Values) {
72 generatorModes += std::to_string(element) +
" ";
74 MACH3LOG_INFO(
"{:<5} {:2} {:<20} {:2} {:<20} {:2} {:<30}", i,
"|", Name,
"|", FancyName,
"|", generatorModes);
75 }
catch (
const std::out_of_range& e) {
76 MACH3LOG_ERROR(
"Index {} is out of bounds for fMode. Check NModes or fMode size.", i);
80 MACH3LOG_INFO(
"========================================================================");
84 for (
size_t i = 0; i <
ModeMap.size(); ++i) {
87 }
catch (
const std::out_of_range& e) {
88 MACH3LOG_ERROR(
"ModeMap[{}] = {} is out of bounds for fMode. Check ModeMap or fMode size.", i,
ModeMap[i]);
98 if (
Mode.count(name)) {
108 std::string
const &fancyname,
110 std::vector<int>
const &GenMap,
112 std::string
const &SplineSuffix) {
124 fMode.emplace(index, newinfo);
132 for(
int i = 0; i <
NModes; ++i) {
133 for(
size_t j = 0; j <
fMode[i].GeneratorMaping.size(); j++) {
134 maxElement = std::max(maxElement,
fMode[i].GeneratorMaping[j]);
139 for(
int m = 0; m <
NModes; ++m) {
140 for(
size_t i = 0; i <
fMode[m].GeneratorMaping.size(); ++i) {
141 if(
fMode[m].GeneratorMaping[i] < 0) {
167 return fMode.at(Index).Name;
182 return fMode.at(Index).IsNC;
197 return fMode.at(Index).FancyName;
203 if (
Mode.count(name)) {
204 return Mode.at(name);
218 if(Index >=
static_cast<int>(
ModeMap.size()))
239 return fMode.at(Index).PlotColor;
254 return fMode[Index].SplineSuffix;
#define MACH3LOG_CRITICAL
int MaCh3Modes_t
Enumerator of MaCh3Mode.
Type Get(const YAML::Node &node, const std::string File, const int Line)
Get content of config file.
#define M3OpenConfig(filename)
Macro to simplify calling LoadYaml with file and line info.
Custom exception class for MaCh3 errors.
std::map< std::string, MaCh3Modes_t > Mode
KS: Handy map which helps find mode number based on string.
int nCCModes
DB: Number of CC modes.
bool IsMaCh3ModeNC(const int Index) const
DB: Get IsNC (a check whether the given MaCh3 corresponds to a Neutral Current mode)
void Initialise(const YAML::Node &config)
KS: Initialise MaCh3 modes based on provided config.
MaCh3Modes(std::string const &filename)
KS: Initialise MaCh3 modes using path to config.
void DeclareNewMode(std::string const &name, std::string const &fancyname, int PlotColor, std::vector< int > const &GenMap, const bool IsNC, const std::string &SplineSuffix)
KS: Add new mode.
int NModes
KS: Number of modes, keep in mind actual number is +1 greater due to unknown category.
std::vector< int > ModeMap
KS: Handy map helping us find MaCh3 mode based on Generator mode value.
void Print() const
KS: Print info about initialised modes.
std::string Generator
KS: Name of generator like NEUT, NuWro etc. this is to make stuff fancy.
MaCh3Modes_t GetMode(const std::string &name) const
std::string GetSplineSuffixFromMaCh3Mode(const int Index)
DB: Get binned spline mode suffic from MaCh3 Mode.
std::string Title
KS: Name of loaded modes.
MaCh3Modes_t EnsureModeNameRegistered(std::string const &name)
int GetMaCh3ModePlotColor(const int Index) const
KS: Get normal name of mode, if mode not known you will get UNKNOWN_BAD.
void PrepareMap()
KS: Fill ModeMap.
std::string GetMaCh3ModeFancyName(const int Index) const
KS: Get fancy name of mode, if mode not known you will get UNKNOWN_BAD.
std::map< MaCh3Modes_t, MaCh3ModeInfo > fMode
KS: Main map storing info about used modes.
std::string GetMaCh3ModeName(const int Index) const
KS: Get normal name of mode, if mode not known you will get UNKNOWN_BAD.
MaCh3Modes_t GetModeFromGenerator(const int Index) const
KS: Get MaCh3 mode from generator mode.
KS: Class containing information for a single MaCh3Mode.
std::vector< int > GeneratorMaping
Mapping between mode and generator integers.
std::string SplineSuffix
Spline suffix.
std::string FancyName
Mode fancy name.
std::string Name
Mode name.
int PlotColor
Mode color for plotting purposes.