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)) {
96 gslpp::matrix<double> myCorr(gslpp::matrix<double>::Id(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!");
128 InvCov =
new gslpp::matrix<double>(nrows, nrows, 0.);
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())
173 gslpp::vector<double> theObsVal(
channels.GetNrows(), 0.);
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) {
224 hthobs.push_back(myObsFactory.
CreateThMethod(
"ggH196", *myModel));
225 hthobs.push_back(myObsFactory.
CreateThMethod(
"VBF196", *myModel));
227 hthobs.push_back(myObsFactory.
CreateThMethod(
"ttH196", *myModel));
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());
A class for Higgs experimental analyses.
virtual void setParametricLikelihood(std::string filename, std::vector< ThObservable * > thObsV)
Set the parametric likelihood describing one Higgs decay channel from a config file.
TMatrixD channels
A matrix holding the information of all the channels.
gslpp::matrix< double > * InvCov
The inverse covariance matrix.
double channelsize
The number of channels in the Higgs Observable.
int rank
The rank of the process initializing this observable.
bool isnew
A boolean which is true if the parametrization is new.
bool isCorrelated
A flag for correlated Higgs Observable.
HiggsObservable(const Observable &Obs)
std::vector< double > theoryValues
A vector to contain the theoryvalues.
void setIsnew(bool isnew)
A method to set the observable to the new parametric form.
std::vector< ThObservable * > thObsV
A vector of ThObservables.
virtual double computeWeight()
A method to compute the weight associated with the observable.
double thobsvsize
The size of the theory observables vector.
boost::tokenizer< boost::char_separator< char > >::iterator & ParseHiggsObservable(boost::tokenizer< boost::char_separator< char > >::iterator &beg, ThObsFactory &myObsFactory, StandardModel *myModel, int rank)
the parser for HiggsObservables
bool covarianceFromConfig
A flag for reading inverse covariance from config file.
std::string distr
The name of the distribution of the the observable.
double LogSplitGaussian(double x, double ave, double errl, double errr)
std::string getName() const
A get method to access the name of the observable.
std::string filename
The name of the file containing the experimental likelihood for the observable.
void setObsType(std::string &obsType_s)
A set method to set the Observable type.
ThObservable * tho
A pointer of to the object of the ThObservables class.
std::string name
A name for the observable.
A model class for the Standard Model.
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...
virtual double computeThValue()=0
A member to be overloaded by the respective theory observable. class that calculates the value of the...