master
|
a Code for the Combination of Indirect and Direct Constraints on High Energy Physics Models
|
|
Go to the documentation of this file.
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();
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));
86 boost::tokenizer<boost::char_separator<char> >::iterator& beg,
87 std::string& infilename,
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();
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.
A model class for the Standard Model.
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...