11 #include <boost/lexical_cast.hpp>
12 #include <boost/algorithm/string/predicate.hpp>
30 std::vector<ModelParameter>& ModelPars,
31 boost::ptr_vector<Observable>& Observables,
32 std::vector<Observable2D>& Observables2D,
33 std::vector<CorrelatedGaussianObservables>& CGO,
34 std::vector<CorrelatedGaussianParameters>& CGP)
40 std::ifstream ifile(
filename.c_str());
41 if (!ifile.is_open()) {
42 if(
rank == 0)
throw std::runtime_error(
"\nERROR: " +
filename +
" does not exist. Make sure to specify a valid model configuration file.\n");
51 if (*
line.rbegin() ==
'\r')
line.erase(
line.length() - 1);
52 if (
line.empty() ||
line.find_first_not_of(
' ') == std::string::npos ||
line.at(0) ==
'#')
54 sep =
new boost::char_separator<char>(
" \t");
55 tok =
new boost::tokenizer<boost::char_separator<char> >(
line, *
sep);
56 boost::tokenizer<boost::char_separator<char> >::iterator beg = tok->begin();
64 if (
rank == 0) std::cout <<
"\nModel Initialized: " <<
modname <<
"\n" << std::endl;
67 throw std::runtime_error(
"\nERROR: " +
modname +
" not initialized successfully.\n");
74 std::string type = *beg;
76 if (type.compare(
"ModelParameter") == 0) {
78 if (std::distance(tok->begin(), tok->end()) < 5) {
79 if (
rank == 0)
throw std::runtime_error(
"ERROR: lack of information on " + *beg +
" in " +
filename +
".\n");
86 if(
rank == 0)
throw std::runtime_error(
"\nERROR: ModelParameter " + tmpMP.
getname() +
" appears more than once ...!! \n" +
89 "2nd Occurrence: Line No:" + boost::lexical_cast<std::string>(
lineNo) +
" in file " +
filename +
".\n");
93 if (beg != tok->end())
94 if (
rank == 0) std::cout <<
"WARNING: unread information in parameter " << tmpMP.
getname() << std::endl;
97 ModelPars.push_back(tmpMP);
100 }
else if (type.compare(
"CorrelatedGaussianParameters") == 0) {
105 CGP.push_back(tmpCGP);
107 }
else if (type.compare(
"Observable") == 0 || type.compare(
"BinnedObservable") == 0 || type.compare(
"FunctionObservable") == 0) {
112 Observables.push_back(tmpObs);
114 }
else if (type.compare(
"Observable2D") == 0) {
120 Observables2D.push_back(tmpObs2D);
122 }
else if (type.compare(
"HiggsObservable") == 0) {
129 Observables.push_back(tmpho);
131 if (beg != tok->end() &&
rank == 0) std::cout <<
"WARNING: unread information in HiggsObservable " << tmpho->
getName() << std::endl;
133 }
else if (type.compare(
"CorrelatedGaussianObservables") == 0) {
137 if (tmpCGO.
getObs().size() > 1) CGO.push_back(tmpCGO);
139 }
else if (type.compare(
"CorrelatedObservables") == 0) {
144 CGO.push_back(tmpCO);
146 }
else if (type.compare(
"CustomObservable") == 0) {
147 if (std::distance(tok->begin(), tok->end()) < 2) {
148 if (
rank == 0)
throw std::runtime_error(
"ERROR: lack of information on " + *beg +
" in " +
filename +
".\n");
151 std::string customObsName = *beg;
154 if (
rank == 0)
throw std::runtime_error(
"\nERROR: No Observable Type defined for " + customObsName +
"\n");
161 Observables.push_back(tmpcustomObs);
163 }
else if (type.compare(
"ModelFlag") == 0) {
164 if (std::distance(tok->begin(), tok->end()) < 3) {
165 if(
rank == 0)
throw std::runtime_error(
"ERROR: lack of information on " + *beg +
" in " +
filename);
168 std::string flagname = *beg;
170 if (boost::iequals(*beg,
"true") || boost::iequals(*beg,
"false")) {
173 if (boost::iequals(*beg,
"true"))
178 if(
rank == 0)
throw std::runtime_error(
"ERROR: setFlag error for " + flagname);
181 else if (
rank == 0) std::cout <<
"set flag " << flagname <<
"=" << *beg << std::endl;
184 std::string value_str = *beg;
186 if(
rank == 0)
throw std::runtime_error(
"ERROR: setFlag error for " + flagname);
188 }
else if (
rank == 0) std::cout <<
"set flag " << flagname <<
"=" << value_str << std::endl;
191 if (beg != tok->end() &&
rank == 0) std::cout <<
"WARNING: unread information in Flag " << flagname << std::endl;
192 }
else if (type.compare(
"IncludeFile") == 0) {
193 std::string IncludeFileName =
filepath + *beg;
194 if (
rank == 0) std::cout <<
"Including File: " + IncludeFileName << std::endl;
195 ReadParameters(IncludeFileName,
rank, ModelPars, Observables, Observables2D, CGO, CGP);
199 if (
rank == 0)
throw std::runtime_error(
"\nERROR: wrong keyword " + type +
" in file " +
filename +
" line no. " + boost::lexical_cast<std::string>(
lineNo) +
". Make sure to specify a valid model configuration file.\n");
206 throw std::runtime_error(
"ERROR: Incorrect or missing model name in the model configuration file.\n");
208 throw std::runtime_error(
"ERROR: incompatible flag(s)\n");
221 if (
rank ==0)
throw std::runtime_error(
"ERROR: No observable defined for " + name +
" so it cannot be created");
int ParseObservable2D(std::string &type, boost::tokenizer< boost::char_separator< char > > *tok, boost::tokenizer< boost::char_separator< char > >::iterator &beg, std::string &infilename, std::ifstream &ifile, int lineNo, int rank)
virtual bool setFlagStr(const std::string name, const std::string value)
A method to set a flag of StandardModel.
StandardModel * CreateModel(const std::string &ModelName)
void setTho(ThObservable *tho_i)
A set method to fix the pointer to object of type ThObservable.
std::string getThname2() const
A get method to access the thname of the second observable as defined in ThFactory class...
virtual bool CheckFlags() const
A method to check the sanity of the set of model flags.
virtual bool InitializeModel()
A class for analyzing observables pairwise.
bool isEOF()
A method to check if the end of file has been reached.
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 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.
ThObservable * CreateThMethod(const std::string &name, const StandardModel &model) const
This method checks for the existence of an observable of a specific name in the map thobs and returns...
void setTho1Tho2(ThObservable *tho1_i, ThObservable *tho2_i)
A set method to fix the pointer to object of type ThObservable class for the second observable...
A class for model parameters.
bool IsModelInitialized() const
A method to check if the model is initialized.
std::string getName() const
A get method to access the name of the observable.
void setModelName(const std::string name)
A method to set the name of the model.
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
A class for Higgs experimental analyses.
std::string getname() const
A get method to get the name of each parameter.
boost::tokenizer< boost::char_separator< char > >::iterator & ParseModelParameter(boost::tokenizer< boost::char_separator< char > >::iterator &beg)
Parser for model parameters.
virtual bool setFlag(const std::string name, const bool value)
std::string ModelName() const
A method to fetch the name of the model.
void setObsType(std::string &obsType_s)
A set method to set the Observable type.