113 if (infilename.find(
"\\/") == std::string::npos)
filepath = infilename.substr(0, infilename.find_last_of(
"\\/") + 1);
114 boost::char_separator<char> sep(
" \t");
117 int size = atoi((*beg).c_str());
120 std::vector<bool> lines;
122 for (
int i = 0; i < size; i++) {
123 IsEOF = getline(ifile, line).eof();
124 if (line.empty() || line.at(0) ==
'#') {
125 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");
129 boost::tokenizer<boost::char_separator<char> > tok(line, sep);
131 std::string type = *beg;
133 if (type.compare(
"Observable") != 0 && type.compare(
"BinnedObservable") != 0 && type.compare(
"FunctionObservable") != 0) {
134 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");
144 lines.push_back(
true);
147 Observables.push_back(tmpObs);
148 lines.push_back(
false);
152 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");
158 if (tmpObs->
getDistr().compare(
"weight") == 0 || tmpObs->
getDistr().compare(
"file") == 0) {
159 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");
167 TMatrixD myCorr(nlines, nlines);
169 for (
int i = 0; i < size; i++) {
170 IsEOF = getline(ifile, line).eof();
171 if (line.empty() || line.at(0) ==
'#') {
172 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");
177 boost::tokenizer<boost::char_separator<char> > mytok(line, sep);
180 for (
int j = 0; j < size; j++) {
181 if ((*beg).compare(0, 1,
"0") == 0
182 || (*beg).compare(0, 1,
"1") == 0
184 if (std::distance(mytok.begin(), mytok.end()) < size) {
185 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());
189 myCorr(ni, nj) = atof((*beg).c_str());
194 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");
201 if (!myCorr.IsSymmetric()) {
202 if (rank == 0)
throw std::runtime_error(
"ERROR: invalid correlation matrix for " +
name +
". Correlation matrix is not symmetric.\n");
205 TMatrixDSym mySCorr(nlines);
206 for (
int i = 0; i < nlines; i++) {
207 for (
int j = 0; j <= i; j++) {
208 mySCorr(i, j) = myCorr(i, j);
209 mySCorr(j, i) = mySCorr(i, j);
215 InvCov.ResizeTo(size, size);
218 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;
220 for (
int i = 0; i < size; i++) {
221 IsEOF = getline(ifile, line).eof();
bool isTMCMC() const
A method to check if the observable is listed for MCMC.
void setHasInverseCovariance(bool hasInverseCovariance)
A set method to state that the Observable is a part of ObservablesWithInverseCovariance.
void setTho(ThObservable *tho_i)
A set method to fix the pointer to object of type ThObservable.
std::string getThname() const
A get method to access the thname of the observable as defined in ThFactory class.
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.
std::string getDistr() const
A get method to access the name of the distribution of the observable.
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...