v1.0
|
a Code for the Combination of Indirect and Direct Constraints on High Energy Physics Models
|
|
A class for reading input parameters and output directives.
More...
#include <InputParser.h>
A class for reading input parameters and output directives.
- Author
- HEPfit Collaboration
- Copyright
- GNU General Public License
The InputParser parses the SomeModel.conf file for the name of the model, ModelParameters, Observables, * Observables2D, ModelParaVsObs and CorrelatedGaussianObservables. The observables (or set of observables) are parsed for their inclusion in the Monte Carlo run.
Definition at line 48 of file InputParser.h.
◆ InputParser() [1/2]
◆ InputParser() [2/2]
◆ ~InputParser()
| InputParser::~InputParser |
( |
| ) |
|
|
virtual |
◆ addCustomObservableType()
| void InputParser::addCustomObservableType |
( |
const std::string |
name, |
|
|
boost::function< Observable *() > |
funct |
|
) |
| |
◆ CreateObservableType()
| Observable * InputParser::CreateObservableType |
( |
const std::string & |
name | ) |
const |
Definition at line 255 of file InputParser.cpp.
258 if (
rank ==0)
throw std::runtime_error(
"ERROR: No observable defined for " + name +
" so it cannot be created");
◆ getModel()
◆ getModelFactory()
◆ getObsFactory()
◆ ReadParameters()
The member that parses the Observable2D directives from SomeModel.conf file.
- Parameters
-
| [in] | Observables | a vector of Observables |
| [in] | ifile | the file being read |
| [in] | beg | an iterator over words in a line separated by a specific separator character |
Responsible for parsing the SomeModel.conf file.
This method parses the SomeModel.conf file for all input instructions. The algorithm is as follows:
- Search for the predefined names of the available models, initialize the necessary model class and build a ThFactory for that model to define the observables.
- Search and read the ModelParameter list.
- Search and read the CorrelatedGaussianParameters.
- Search and read the Observable list using the ParseObservable() method.
- Search and read the Observable2D list using the ParseObservable() method.
- Search and read the CorrelatedGaussianObservables.
- Return the name of the model initialized.
- Parameters
-
| [in] | filename | name of the SomeModel.conf file passed as an argument to the executable |
| [in] | rank | the rank of the process in an MPI run (set to 0 for a serial run) |
| [out] | ModelPars | the vector of model parameters |
| [out] | Observables | the vector of observables |
| [out] | Observables2D | the vector of observable pairs |
| [out] | CGO | the vector of correlated Gaussian observables |
| [out] | CGP | the vector of correlated Gaussian parameters |
- Returns
- modname the name of the model initialized
Definition at line 35 of file InputParser.cpp.
46 std::ifstream ifile(
filename.c_str());
47 if (!ifile.is_open()) {
48 if(
rank == 0)
throw std::runtime_error(
"\nERROR: " +
filename +
" does not exist. Make sure to specify a valid model configuration file.\n");
54 boost::char_separator<char> * sep =
new boost::char_separator<char>(
" \t");
58 if (*
line.rbegin() ==
'\r')
line.erase(
line.length() - 1);
59 if (
line.empty() ||
line.find_first_not_of(
' ') == std::string::npos ||
line.at(0) ==
'#')
61 boost::tokenizer<boost::char_separator<char> > *tok =
new boost::tokenizer<boost::char_separator<char> >(
line, *sep);
62 boost::tokenizer<boost::char_separator<char> >::iterator beg = tok->begin();
70 if (
rank == 0) std::cout <<
"\nModel Initialized: " <<
modname <<
"\n" << std::endl;
73 throw std::runtime_error(
"\nERROR: " +
modname +
" not initialized successfully.\n");
80 std::string type = *beg;
82 if (type.compare(
"ModelParameter") == 0) {
84 if (std::distance(tok->begin(), tok->end()) < 5) {
85 if (
rank == 0)
throw std::runtime_error(
"ERROR: lack of information on " + *beg +
" in " +
filename +
".\n");
92 if(
rank == 0)
throw std::runtime_error(
"\nERROR: ModelParameter " + tmpMP.
getname() +
" appears more than once ...!! \n" +
95 "2nd Occurrence: Line No:" + boost::lexical_cast<std::string>(
lineNo) +
" in file " +
filename +
".\n");
99 if (beg != tok->end())
100 if (
rank == 0) std::cout <<
"WARNING: unread information in parameter " << tmpMP.
getname() << std::endl;
103 ModelPars.push_back(tmpMP);
106 }
else if (type.compare(
"CorrelatedGaussianParameters") == 0) {
111 CGP.push_back(tmpCGP);
113 }
else if (type.compare(
"Observable") == 0 || type.compare(
"BinnedObservable") == 0 || type.compare(
"FunctionObservable") == 0 || type.compare(
"AsyGausObservable") == 0) {
118 Observables.push_back(tmpObs);
120 }
else if (type.compare(
"Observable2D") == 0) {
126 Observables2D.push_back(tmpObs2D);
128 }
else if (type.compare(
"HiggsObservable") == 0) {
135 Observables.push_back(tmpho);
137 if (beg != tok->end() &&
rank == 0) std::cout <<
"WARNING: unread information in HiggsObservable " << tmpho->
getName() << std::endl;
139 }
else if (type.compare(
"CorrelatedHiggsObservables") == 0) {
147 Observables.push_back(tmpho);
149 if (beg != tok->end() &&
rank == 0) std::cout <<
"WARNING: unread information in HiggsObservable " << tmpho->
getName() << std::endl;
151 }
else if (type.compare(
"CorrelatedGaussianObservables") == 0) {
156 if (tmpCGO.
getObs().size() > 1) CGO.push_back(tmpCGO);
158 }
else if (type.compare(
"ObservablesWithCovarianceInverse") == 0) {
164 if (tmpCGO.
getObs().size() > 1) CGO.push_back(tmpCGO);
166 }
else if (type.compare(
"CorrelatedObservables") == 0) {
172 CGO.push_back(tmpCO);
174 }
else if (type.compare(
"CustomObservable") == 0) {
176 if (std::distance(tok->begin(), tok->end()) < 2) {
177 if (
rank == 0)
throw std::runtime_error(
"ERROR: lack of information on " + *beg +
" in " +
filename +
".\n");
180 std::string customObsName = *beg;
183 if (
rank == 0)
throw std::runtime_error(
"\nERROR: No Observable Type defined for " + customObsName +
"\n");
190 Observables.push_back(tmpcustomObs);
192 }
else if (type.compare(
"ModelFlag") == 0) {
193 if (std::distance(tok->begin(), tok->end()) < 3) {
194 if(
rank == 0)
throw std::runtime_error(
"ERROR: lack of information on " + *beg +
" in " +
filename);
197 std::string flagname = *beg;
199 if (boost::iequals(*beg,
"true") || boost::iequals(*beg,
"false")) {
202 if (boost::iequals(*beg,
"true"))
207 if(
rank == 0)
throw std::runtime_error(
"ERROR: setFlag error for " + flagname);
210 else if (
rank == 0) std::cout <<
"set flag " << flagname <<
"=" << *beg << std::endl;
213 std::string value_str = *beg;
215 if(
rank == 0)
throw std::runtime_error(
"ERROR: setFlag error for " + flagname);
217 }
else if (
rank == 0) std::cout <<
"set flag " << flagname <<
"=" << value_str << std::endl;
220 if (beg != tok->end() &&
rank == 0) std::cout <<
"WARNING: unread information in Flag " << flagname << std::endl;
221 }
else if (type.compare(
"IncludeFile") == 0) {
225 std::string IncludeFileName =
filepath + *beg;
226 if (
rank == 0) std::cout <<
"Including File: " + IncludeFileName << std::endl;
227 ReadParameters(IncludeFileName,
rank, ModelPars, Observables, Observables2D, CGO, CGP);
234 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");
242 throw std::runtime_error(
"ERROR: Incorrect or missing model name in the model configuration file.\n");
244 throw std::runtime_error(
"ERROR: incompatible flag(s)\n");
◆ setModel()
◆ checkDuplicateParameter
| std::map<std::string, boost::tuple<bool, std::string, int> > InputParser::checkDuplicateParameter |
|
private |
◆ customObservableTypeMap
| std::map<std::string, boost::function<Observable* ()> > InputParser::customObservableTypeMap |
|
private |
◆ filename
| std::string InputParser::filename |
|
private |
◆ filepath
| std::string InputParser::filepath |
|
private |
◆ IsEOF
◆ line
| std::string InputParser::line |
|
private |
◆ lineNo
◆ modeldefinedinfile
| std::string InputParser::modeldefinedinfile |
|
private |
◆ modelset
| bool InputParser::modelset |
|
private |
◆ modname
| std::string InputParser::modname |
|
private |
A string to store the model name in.
Definition at line 135 of file InputParser.h.
◆ myModel
◆ myModelFactory
◆ myObsFactory
◆ rank
The documentation for this class was generated from the following files:
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)
A class for Higgs experimental analyses.
std::string getThname2() const
A get method to access the thname of the second observable as defined in ThFactory class.
void setTho(ThObservable *tho_i)
A set method to fix the pointer to object of type ThObservable.
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.
void setIsCorrelated(bool correlated)
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.
boost::tokenizer< boost::char_separator< char > >::iterator & ParseModelParameter(boost::tokenizer< boost::char_separator< char > >::iterator &beg)
Parser for model parameters.
virtual bool InitializeModel()
std::string getname() const
A get method to get the name of each parameter.
virtual bool setFlag(const std::string name, const bool value)
virtual bool setFlagStr(const std::string name, const std::string value)
A method to set a flag of StandardModel.
bool IsModelInitialized() const
A method to check if the model is initialized.
A class for model parameters.
void setModelName(const std::string name)
A method to set the name of the model.
A class for analyzing observables pairwise.
StandardModel * CreateModel(const std::string &ModelName)
bool isEOF()
A method to check if the end of file has been reached.
std::string getModelName() const
A method to fetch the name of the model.
void setObsType(std::string &obsType_s)
A set method to set the Observable type.
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
std::string getName() const
A get method to access the name of the observable.
virtual bool CheckFlags() const
A method to check the sanity of the set of model flags.
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...
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.