16 #include <boost/tokenizer.hpp>
47 std::ifstream ifile(
filename.c_str());
49 throw std::runtime_error(
"\nERROR: " +
filename +
" does not exist. Make sure to specify a valid Higgs parameters configuration file.\n");
52 bool readCorrelations =
false;
54 unsigned int nrows = 0;
56 IsEOF = getline(ifile, line).eof();
57 if (line.compare(0, 11,
"MEASUREMENT") == 0) nrows++;
61 ss <<
"\nERROR: " <<
filename <<
" should contain at least 1 measurement.\n";
62 throw std::runtime_error(ss.str());
64 int implicit_tth = (
isnew ? 0 : -1);
67 ifile.seekg(0, ifile.beg);
70 IsEOF = getline(ifile, line).eof();
72 if (*line.rbegin() ==
'\r') line.erase(line.length() - 1);
73 if (line.compare(0, 11,
"MEASUREMENT") != 0 && !readCorrelations) {
76 boost::char_separator<char> sep(
" |\t");
77 boost::tokenizer<boost::char_separator<char> > tok(line, sep);
78 boost::tokenizer<boost::char_separator<char> >::iterator beg = tok.begin();
88 for (
int j = 0; j <
channels.GetNcols(); j++)
89 channels(i, j) = atof((*(++beg)).c_str());
91 if (
rank == 0)
throw std::runtime_error(
"ERROR: Gaussian errors must be symmetric for CorrelatedHiggsObservables in " +
filename +
" at line number:" + boost::lexical_cast<std::string>(lineNo) +
".\n");
95 if (readCorrelations && (i == nrows)) {
98 for (
unsigned int irow = 0; irow < nrows; irow++) {
99 IsEOF = getline(ifile, line).eof();
100 if (line.empty() || line.at(0) ==
'#') {
101 if (
rank == 0)
throw std::runtime_error(
"ERROR: no comments or empty lines in CorrelatedHiggsObservables please! In file " +
filename +
" at line number:" + boost::lexical_cast<std::string>(lineNo) +
".\n");
105 boost::tokenizer<boost::char_separator<char> > mytok(line, sep);
108 for (
unsigned int jcol = 0; jcol < nrows; jcol++) {
109 if ((*beg).compare(0, 1,
"0") == 0
110 || (*beg).compare(0, 1,
"1") == 0
112 if (std::distance(mytok.begin(), mytok.end()) < nrows) {
113 if (
rank == 0)
throw std::runtime_error((
"ERROR: Correlation matrix is of wrong size in CorrelatedHiggsObservables: " +
name + +
" at line number:" + boost::lexical_cast<std::string>(lineNo) +
".\n").c_str());
116 myCorr(ni, nj) = atof((*beg).c_str());
120 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 " +
filename +
".\n");
126 if (myCorr.
size_i() != nrows || myCorr.
size_j() != nrows)
127 throw std::runtime_error(
"The size of the correlated observables in " +
name +
" does not match the size of the correlation matrix!");
130 for (
unsigned int i = 0; i < nrows; i++)
131 for (
unsigned int j = 0; j < nrows; j++)
132 (*
InvCov)(i, j) = myCorr(i, j);
134 for (
unsigned int i = 0; i < nrows; i++)
135 for (
unsigned int j = 0; j < nrows; j++)
139 readCorrelations =
false;
144 std::stringstream ss;
145 ss <<
"\nERROR: " <<
filename <<
" should contain " << nrows <<
" measurements, but I have read " << i <<
" ones instead.\n";
146 throw std::runtime_error(ss.str());
159 for (
int i = 0; i <
channels.GetNrows(); i++) {
161 for (
unsigned int j = 0; j <
thobsvsize; j++) {
166 if (
thObsV.at(0)->getModel().isModelLinearized())
174 for (
int i = 0; i <
channels.GetNrows(); i++) {
177 logprob = (-0.5 * theObsVal * ((*InvCov) * theObsVal));
180 for (
int i = 0; i <
channels.GetNrows(); i++) {
181 double mu = 0, sum = 0.;
182 for (
unsigned int j = 0; j <
thobsvsize - 1; j++) {
198 boost::tokenizer<boost::char_separator<char> >::iterator & beg,
204 std::string type =
"HiggsObservable";
206 std::vector<ThObservable*> hthobs;
209 if (
distr.compare(
"parametric") == 0) {
213 if (
distr.compare(
"LHC7") == 0) {
218 }
else if (
distr.compare(
"LHC8") == 0) {
223 }
else if (
distr.compare(
"TeV196") == 0) {
228 }
else if (
rank == 0)
229 throw std::runtime_error(
"ERROR: wrong keyword " +
distr +
" in " +
getName());
231 }
else if (
distr.compare(
"new_parametric") == 0) {
232 std::string filename_h = *(++beg);
233 std::ifstream ifile(filename_h.c_str());
234 if (!ifile.is_open()) {
235 if (
rank == 0)
throw std::runtime_error(
"\nERROR: " + filename_h +
" does not exist. Make sure to specify a valid Higgs parameters configuration file.\n");
241 IsEOF_h = getline(ifile, line_h).eof();
242 if (line_h.compare(0, 10,
"CATEGORIES") == 0) {
243 boost::char_separator<char> sep(
" \t");
244 boost::tokenizer<boost::char_separator<char> > mytok(line_h, sep);
245 boost::tokenizer<boost::char_separator<char> >::iterator beg2 = mytok.begin();
247 while (beg2 != mytok.end()) {
248 std::string cat = *beg2;
254 if (hthobs.size() > 0)
257 if (
rank == 0)
throw std::runtime_error(
"\nERROR: " +
getName() +
" does not provide at least one category\n");
261 if (
rank == 0)
throw std::runtime_error(
"ERROR: wrong distribution flag " +
distr +
" in " +
getName());