MaCh3 2.2.1
Reference Guide
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
ParameterTunes Class Reference

Class storing tune values, for example allowing flexibly to retrieve parameter values for for PostND tunes. More...

#include <Parameters/ParameterTunes.h>

Collaboration diagram for ParameterTunes:
[legend]

Public Member Functions

 ParameterTunes (const YAML::Node &Settings)
 Constructor.
 
virtual ~ParameterTunes ()
 
std::vector< double > GetTune (const int TuneNumber) const
 Return vector of tune vales for each parameter.
 
std::vector< double > GetTune (const std::string &TuneName) const
 Return vector of tune vales for each parameter.
 
void PrintTunes () const
 Simply print all tunes and associated values.
 

Private Attributes

std::vector< std::string > TuneNames
 Name of each Tun.
 
std::vector< std::vector< double > > TuneValues
 Values for each Tune and Parameter.
 
std::unordered_map< std::string, int > TuneMap
 Map between tune name and value.
 

Detailed Description

Class storing tune values, for example allowing flexibly to retrieve parameter values for for PostND tunes.

Author
Kamil Skwarczynski

Definition at line 9 of file ParameterTunes.h.

Constructor & Destructor Documentation

◆ ParameterTunes()

ParameterTunes::ParameterTunes ( const YAML::Node &  Settings)

Constructor.

Definition at line 4 of file ParameterTunes.cpp.

4 {
5// ********************************************
6 std::map<std::string, std::vector<double>> orderedTunes;
7
8 // Loop over all systematics
9 for (const auto& sysNode : Settings) {
10 const auto& values = sysNode["Systematic"]["ParameterValues"];
11
12 for (const auto& tuneNode : values) {
13 std::string key = tuneNode.first.as<std::string>();
14 if (key == "PreFitValue") continue;
15
16 double val = tuneNode.second.as<double>();
17 orderedTunes[key].push_back(val);
18 }
19 }
20
21 size_t expectedSize = 0;
22 bool hasMismatch = false;
23 std::ostringstream errorMsg;
24 errorMsg << "Inconsistent number of parameter values across tunes:\n";
25
26 for (const auto& kv : orderedTunes) {
27 const auto& vals = kv.second;
28 if (expectedSize == 0) {
29 expectedSize = vals.size();
30 } else if (vals.size() != expectedSize) {
31 hasMismatch = true;
32 }
33 errorMsg << " - Tune '" << kv.first << "': " << vals.size() << " values\n";
34 }
35
36 if (hasMismatch) {
37 errorMsg << "Expected all tunes to have " << expectedSize << " values.";
38 MACH3LOG_ERROR("{}", errorMsg.str());
39 throw MaCh3Exception(__FILE__, __LINE__);
40 }
41
42 int idx = 0;
43 for (const auto& kv : orderedTunes) {
44 TuneNames.push_back(kv.first);
45 TuneValues.push_back(kv.second);
46 TuneMap[kv.first] = idx++;
47 }
48
49 // KS: Log final summary of found tunes
50 MACH3LOG_INFO("Found {} tunes:", TuneNames.size());
51 for (size_t i = 0; i < TuneNames.size(); ++i) {
52 MACH3LOG_INFO(" Tune {} {}", i, TuneNames[i]);
53 }
54 #ifdef DEBUG
55 PrintTunes();
56 #endif
57}
#define MACH3LOG_ERROR
Definition: MaCh3Logger.h:25
#define MACH3LOG_INFO
Definition: MaCh3Logger.h:23
Custom exception class for MaCh3 errors.
std::vector< std::string > TuneNames
Name of each Tun.
void PrintTunes() const
Simply print all tunes and associated values.
std::unordered_map< std::string, int > TuneMap
Map between tune name and value.
std::vector< std::vector< double > > TuneValues
Values for each Tune and Parameter.

◆ ~ParameterTunes()

ParameterTunes::~ParameterTunes ( )
virtual

Definition at line 60 of file ParameterTunes.cpp.

60 {
61// ********************************************
62
63}

Member Function Documentation

◆ GetTune() [1/2]

std::vector< double > ParameterTunes::GetTune ( const int  TuneNumber) const

Return vector of tune vales for each parameter.

◆ GetTune() [2/2]

std::vector< double > ParameterTunes::GetTune ( const std::string &  TuneName) const

Return vector of tune vales for each parameter.

◆ PrintTunes()

void ParameterTunes::PrintTunes ( ) const

Simply print all tunes and associated values.

Member Data Documentation

◆ TuneMap

std::unordered_map<std::string, int> ParameterTunes::TuneMap
private

Map between tune name and value.

Definition at line 28 of file ParameterTunes.h.

◆ TuneNames

std::vector<std::string> ParameterTunes::TuneNames
private

Name of each Tun.

Definition at line 24 of file ParameterTunes.h.

◆ TuneValues

std::vector<std::vector<double> > ParameterTunes::TuneValues
private

Values for each Tune and Parameter.

Definition at line 26 of file ParameterTunes.h.


The documentation for this class was generated from the following files: