131 if (infilename.find(
"\\/") == std::string::npos)
filepath = infilename.substr(0, infilename.find_last_of(
"\\/") + 1);
132 boost::char_separator<char> sep(
" \t");
135 int size = atoi((*beg).c_str());
138 std::vector<bool> lines;
140 for (
int i = 0; i < size; i++) {
141 IsEOF = getline(ifile, line).eof();
142 if (line.empty() || line.at(0) ==
'#') {
143 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");
147 boost::tokenizer<boost::char_separator<char> > tok(line, sep);
149 std::string type = *beg;
151 if (type.compare(
"Observable") != 0 && type.compare(
"BinnedObservable") != 0 && type.compare(
"FunctionObservable") != 0) {
152 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");
162 lines.push_back(
true);
165 Observables.push_back(tmpObs);
166 lines.push_back(
false);
170 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");
176 if (tmpObs->
getDistr().compare(
"weight") == 0 || tmpObs->
getDistr().compare(
"file") == 0) {
177 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");
185 TMatrixD myCorr(nlines, nlines);
187 for (
int i = 0; i < size; i++) {
188 IsEOF = getline(ifile, line).eof();
189 if (line.empty() || line.at(0) ==
'#') {
190 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");
195 boost::tokenizer<boost::char_separator<char> > mytok(line, sep);
198 for (
int j = 0; j < size; j++) {
199 if ((*beg).compare(0, 1,
"0") == 0
200 || (*beg).compare(0, 1,
"1") == 0
202 if (std::distance(mytok.begin(), mytok.end()) < size) {
203 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());
207 myCorr(ni, nj) = atof((*beg).c_str());
212 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");
219 if (!myCorr.IsSymmetric()) {
220 if (rank == 0)
throw std::runtime_error(
"ERROR: invalid correlation matrix for " +
name +
". Correlation matrix is not symmetric.\n");
223 TMatrixDSym mySCorr(nlines);
224 for (
int i = 0; i < nlines; i++) {
225 for (
int j = 0; j <= i; j++) {
226 mySCorr(i, j) = myCorr(i, j);
227 mySCorr(j, i) = mySCorr(i, j);
233 InvCov.ResizeTo(size, size);
236 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;
238 for (
int i = 0; i < size; i++) {
239 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...