master
|
a Code for the Combination of Indirect and Direct Constraints on High Energy Physics Models
|
|
A class for correlated Gaussian observables.
More...
#include <CorrelatedGaussianObservables.h>
A class for correlated Gaussian observables.
- Author
- HEPfit Collaboration
- Copyright
- GNU General Public License
This class builds the correlated Gaussian observables that are specified in the SomeModel.conf file or specified by the user.
Definition at line 32 of file CorrelatedGaussianObservables.h.
◆ CorrelatedGaussianObservables() [1/3]
| CorrelatedGaussianObservables::CorrelatedGaussianObservables |
( |
std::string |
name_i | ) |
|
◆ CorrelatedGaussianObservables() [2/3]
| CorrelatedGaussianObservables::CorrelatedGaussianObservables |
( |
| ) |
|
◆ CorrelatedGaussianObservables() [3/3]
◆ ~CorrelatedGaussianObservables()
| CorrelatedGaussianObservables::~CorrelatedGaussianObservables |
( |
| ) |
|
|
virtual |
◆ AddObs()
| void CorrelatedGaussianObservables::AddObs |
( |
Observable & |
Obs_i | ) |
|
◆ ComputeCov()
| void CorrelatedGaussianObservables::ComputeCov |
( |
gslpp::matrix< double > |
Corr | ) |
|
Computes the covariance matrix for the correlated Gaussian observables set.
- Parameters
-
| Corr | the correlation matrix for the correlated Gassian observables set |
Definition at line 53 of file CorrelatedGaussianObservables.cpp.
55 unsigned int size =
Obs.size();
57 throw std::runtime_error(
"The size of the correlated observables in " +
name +
" does not match the size of the correlation matrix!");
60 for (
unsigned int i = 0; i < size; i++)
61 for (
unsigned int j = 0; j < size; j++)
62 (*
InvCov)(i, j) = Corr(i, j);
64 for (
unsigned int i = 0; i < size; i++) {
65 for (
unsigned int j = 0; j < size; j++) {
66 if (Corr(i, j) != Corr(j, i))
throw std::runtime_error(
"Invalid correlation matrix for " +
name +
". The matrix is not symmetric: for elements [" + boost::lexical_cast<std::string>(i) +
", " + boost::lexical_cast<std::string>(j) +
"]");
67 (*InvCov)(i, j) =
Obs.at(i).getErrg() * Corr(i, j) *
Obs.at(j).getErrg();
◆ computeWeight()
| double CorrelatedGaussianObservables::computeWeight |
( |
| ) |
|
|
virtual |
A method to compute the weight associated with the observable.
Definition at line 74 of file CorrelatedGaussianObservables.cpp.
78 for (
unsigned int i = 0; i <
Obs.size(); i++)
79 x(i) =
Obs.at(i).computeTheoryValue() -
Obs.at(i).getAve();
81 return (-0.5 * x * ((*
InvCov) * x));
◆ getCov()
| gslpp::matrix<double> CorrelatedGaussianObservables::getCov |
( |
| ) |
const |
|
inline |
◆ getName()
| std::string CorrelatedGaussianObservables::getName |
( |
| ) |
const |
|
inline |
◆ getObs() [1/2]
| std::vector<Observable> CorrelatedGaussianObservables::getObs |
( |
| ) |
const |
|
inline |
◆ getObs() [2/2]
| Observable CorrelatedGaussianObservables::getObs |
( |
int |
i | ) |
const |
|
inline |
A get method to access an element of the vector of observables that are defined in one correlated Gaussian observables set.
- Returns
- an element of the vector of type Observable()
Definition at line 88 of file CorrelatedGaussianObservables.h.
◆ isEOF()
| bool CorrelatedGaussianObservables::isEOF |
( |
| ) |
|
|
inline |
A method to check if the end of file has been reached.
- Returns
- a boolean which is true if the end of file has been reached
Definition at line 133 of file CorrelatedGaussianObservables.h.
◆ isPrediction()
| bool CorrelatedGaussianObservables::isPrediction |
( |
| ) |
|
|
inline |
A method to check if the Correlated Observables are set for prediction.
- Returns
- a boolean which is true if the set of CGO are to be predicted
Definition at line 151 of file CorrelatedGaussianObservables.h.
◆ ParseCGO()
| int CorrelatedGaussianObservables::ParseCGO |
( |
boost::ptr_vector< Observable > & |
Observables, |
|
|
std::ifstream & |
ifile, |
|
|
boost::tokenizer< boost::char_separator< char > >::iterator & |
beg, |
|
|
std::string & |
infilename, |
|
|
ThObsFactory & |
myObsFactory, |
|
|
StandardModel * |
myModel, |
|
|
int |
lineNo, |
|
|
int |
rank |
|
) |
| |
The parser for CorrelatedGaussianObservables.
- Parameters
-
| [in] | Observables | the pointer vector containing the Observables |
| [in] | ifile | the stream containing the config file to be parsed |
| [in] | beg | the iterator that parses a line in the config file |
| [in] | infilename | the name of the config file being parsed |
| [in] | myModel | a pointer to the model |
| [in] | lineNo | the current line number at which the file is being parsed |
| [in] | rank | the rank of the process that is using the parser |
- Returns
- the line number (integer) after the parsing is done
Definition at line 84 of file CorrelatedGaussianObservables.cpp.
92 if (infilename.find(
"\\/") == std::string::npos)
filepath = infilename.substr(0, infilename.find_last_of(
"\\/") + 1);
93 boost::char_separator<char> sep(
" \t");
96 int size = atoi((*beg).c_str());
99 std::vector<bool> lines;
101 for (
int i = 0; i < size; i++) {
102 IsEOF = getline(ifile, line).eof();
103 if (line.empty() || line.at(0) ==
'#') {
104 if (rank == 0)
throw std::runtime_error(
"ERROR: no comments or empty lines in CorrelatedGaussianObservables please! In file " + infilename +
" at line number:" + boost::lexical_cast<std::string>(lineNo) +
".\n");
108 boost::tokenizer<boost::char_separator<char> > tok(line, sep);
110 std::string type = *beg;
112 if (type.compare(
"Observable") != 0 && type.compare(
"BinnedObservable") != 0 && type.compare(
"FunctionObservable") != 0) {
113 if (rank == 0)
throw std::runtime_error(
"ERROR: in line no." + boost::lexical_cast<std::string>(lineNo) +
" of file " + infilename +
", expecting an Observable or BinnedObservable or FunctionObservable type here...\n");
123 lines.push_back(
true);
126 Observables.push_back(tmpObs);
127 lines.push_back(
false);
131 if (rank == 0)
throw std::runtime_error(
"ERROR: in line no." + boost::lexical_cast<std::string>(lineNo) +
" of file " + infilename +
", Observable/BinnedObservable cannot be set to MCMC in CorrelatedObservable. Use CorrelatedGaussianObservable instead.\n");
137 if (tmpObs->
getDistr().compare(
"weight") == 0 || tmpObs->
getDistr().compare(
"file") == 0) {
138 if (rank == 0)
throw std::runtime_error(
"ERROR: in line no." + boost::lexical_cast<std::string>(lineNo) +
" of file " + infilename +
", Observable/BinnedObservable cannot be set to weight or file in CorrelatedObservable. Use CorrelatedGaussianObservable instead.\n");
148 for (
int i = 0; i < size; i++) {
149 IsEOF = getline(ifile, line).eof();
150 if (line.empty() || line.at(0) ==
'#') {
151 if (rank == 0)
throw std::runtime_error(
"ERROR: no comments or empty lines in CorrelatedGaussianObservables please! In file " + infilename +
" at line number:" + boost::lexical_cast<std::string>(lineNo) +
".\n");
156 boost::tokenizer<boost::char_separator<char> > mytok(line, sep);
159 for (
int j = 0; j < size; j++) {
160 if ((*beg).compare(0, 1,
"0") == 0
161 || (*beg).compare(0, 1,
"1") == 0
163 if (std::distance(mytok.begin(), mytok.end()) < size) {
164 if (rank == 0)
throw std::runtime_error((
"ERROR: Correlation matrix is of wrong size in Correlated Gaussian Observables: " +
name + +
" at line number:" + boost::lexical_cast<std::string>(lineNo) +
".\n").c_str());
168 myCorr(ni, nj) = atof((*beg).c_str());
173 if (rank == 0)
throw std::runtime_error(
"ERROR: invalid correlation matrix for " +
name +
". Check element (" + boost::lexical_cast<std::string>(ni + 1) +
"," + boost::lexical_cast<std::string>(nj + 1) +
") in line number " + boost::lexical_cast<std::string>(lineNo) +
" in file " + infilename +
".\n");
185 if (rank == 0) std::cout <<
"\nWARNING: Correlated (Gaussian) Observable " <<
name.c_str() <<
" defined with less than two observables" <<
" in file " << infilename <<
". The set is being marked as normal Observables." << std::endl;
187 for (
int i = 0; i < size; i++) {
188 IsEOF = getline(ifile, line).eof();
◆ setCovarianceFromConfig()
| void CorrelatedGaussianObservables::setCovarianceFromConfig |
( |
bool |
setInvCov | ) |
|
|
inline |
A method to specify whether the inverse covariance is being set from the config file.
- Parameters
-
| [in] | setInvCov | a boolean which is true if the inverse covariance matrix is set from file |
Definition at line 169 of file CorrelatedGaussianObservables.h.
◆ setIsPrediction()
| void CorrelatedGaussianObservables::setIsPrediction |
( |
bool |
IsPrediction_i | ) |
|
|
inline |
A method to set a set of CGO to be predicted.
- Parameters
-
| [in] | IsPrediction_i | a boolean which is true if the set of CGO is set for prediction |
Definition at line 142 of file CorrelatedGaussianObservables.h.
◆ setName()
| void CorrelatedGaussianObservables::setName |
( |
std::string |
name_i | ) |
|
|
inline |
A method to set a set of CGO to be predicted.
- Parameters
-
| [in] | IsPrediction_i | a boolean which is true if the set of CGO is set for prediction |
Definition at line 160 of file CorrelatedGaussianObservables.h.
◆ covarianceFromConfig
| bool CorrelatedGaussianObservables::covarianceFromConfig |
|
private |
◆ filepath
| std::string CorrelatedGaussianObservables::filepath |
|
private |
◆ InvCov
◆ IsEOF
| bool CorrelatedGaussianObservables::IsEOF |
|
private |
◆ IsPrediction
| bool CorrelatedGaussianObservables::IsPrediction |
|
private |
◆ name
| std::string CorrelatedGaussianObservables::name |
|
private |
◆ Obs
| std::vector<Observable> CorrelatedGaussianObservables::Obs |
|
private |
The documentation for this class was generated from the following files:
std::string getDistr() const
A get method to access the name of the distribution of the observable.
A class for constructing and defining operations on real matrices.
void setTho(ThObservable *tho_i)
A set method to fix the pointer to object of type ThObservable.
boost::tokenizer< boost::char_separator< char > >::iterator & ParseObservable(std::string &type, boost::tokenizer< boost::char_separator< char > > *tok, boost::tokenizer< boost::char_separator< char > >::iterator &beg, std::string &filepath, std::string &infilename, int rank)
The parser for Observables.
A base class for defining operations on matrices, both real and complex.
std::string getThname() const
A get method to access the thname of the observable as defined in ThFactory class.
bool isTMCMC() const
A method to check if the observable is listed for MCMC.
matrix< double > inverse()
A class for constructing and defining operations on real vectors.
void setHasInverseCovariance(bool hasInverseCovariance)
A set method to state that the Observable is a part of ObservablesWithInverseCovariance.
ThObservable * CreateThMethod(const std::string &name, StandardModel &model) const
This method checks for the existence of an observable of a specific name in the map thobs and returns...