Responsible for parsing the SomeModel.conf file.
This method parses the SomeModel.conf file for all input instructions. The algorithm is as follows:
42{
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");
49 else sleep (2);
50 }
51
54 boost::char_separator<char> * sep = new boost::char_separator<char>(" \t");
55 do {
58 continue;
60
62 if (
line.empty() ||
line.find_first_not_of(
' ') == std::string::npos ||
line.at(0) ==
'#')
63 continue;
64
65 boost::tokenizer<boost::char_separator<char> > *tok =
new boost::tokenizer<boost::char_separator<char> >(
line, *sep);
66 boost::tokenizer<boost::char_separator<char> >::iterator beg = tok->begin();
67
74 if (
rank == 0) std::cout <<
"\nModel Initialized: " <<
modname <<
"\n" << std::endl;
77 throw std::runtime_error(
"\nERROR: " +
modname +
" not initialized successfully.\n");
79 continue;
81 continue;
82 }
83
84 std::string type = *beg;
85 ++beg;
86 if (type.compare("ModelParameter") == 0) {
87
88 if (std::distance(tok->begin(), tok->end()) < 5) {
89 if (
rank == 0)
throw std::runtime_error(
"ERROR: lack of information on " + *beg +
" in " +
filename +
".\n");
90 else sleep(2);
91 } else {
95 if(
rank == 0)
throw std::runtime_error(
"\nERROR: ModelParameter " + tmpMP.
getname() +
" appears more than once ...!! \n" +
98 "2nd Occurrence: Line No:" + boost::lexical_cast<std::string>(
lineNo) +
" in file " +
filename +
".\n");
99 else sleep (2);
100 }
101
103 if(
rank == 0)
throw std::runtime_error(
"\nERROR: ModelParameter " + tmpMP.
getname() +
" cannot float in the MonteCarlo run ");
104
105 if (beg != tok->end())
106 if (
rank == 0) std::cout <<
"WARNING: unread information in parameter " << tmpMP.
getname() << std::endl;
108
109 ModelPars.push_back(tmpMP);
110 }
111
112 } else if (type.compare("CorrelatedGaussianParameters") == 0) {
113
117 CGP.push_back(tmpCGP);
118
119 } else if (type.compare("Observable") == 0 || type.compare("BinnedObservable") == 0 || type.compare("FunctionObservable") == 0 || type.compare("AsyGausObservable") == 0) {
120
124 Observables.push_back(tmpObs);
125
126 } else if (type.compare("Observable2D") == 0) {
127
132 Observables2D.push_back(tmpObs2D);
133
134 } else if (type.compare("HiggsObservable") == 0) {
135
141 Observables.push_back(tmpho);
142 ++beg;
143 if (beg != tok->end() &&
rank == 0) std::cout <<
"WARNING: unread information in HiggsObservable " << tmpho->
getName() << std::endl;
144
145 } else if (type.compare("CorrelatedHiggsObservables") == 0) {
146
153 Observables.push_back(tmpho);
154 ++beg;
155 if (beg != tok->end() &&
rank == 0) std::cout <<
"WARNING: unread information in HiggsObservable " << tmpho->
getName() << std::endl;
156
157 } else if (type.compare("CorrelatedGaussianObservables") == 0) {
158
162 if (tmpCGO.
getObs().size() > 1) CGO.push_back(tmpCGO);
163
164 } else if (type.compare("ObservablesWithCovarianceInverse") == 0) {
165
170 if (tmpCGO.
getObs().size() > 1) CGO.push_back(tmpCGO);
171
172 } else if (type.compare("CorrelatedObservables") == 0) {
173
178 CGO.push_back(tmpCO);
179
180 } else if (type.compare("CustomObservable") == 0) {
181
182 if (std::distance(tok->begin(), tok->end()) < 2) {
183 if (
rank == 0)
throw std::runtime_error(
"ERROR: lack of information on " + *beg +
" in " +
filename +
".\n");
184 else sleep(2);
185 }
186 std::string customObsName = *beg;
187 beg++;
189 if (
rank == 0)
throw std::runtime_error(
"\nERROR: No Observable Type defined for " + customObsName +
"\n");
190 else sleep(2);
191 }
196 Observables.push_back(tmpcustomObs);
197
198 } else if (type.compare("ModelFlag") == 0) {
199 if (std::distance(tok->begin(), tok->end()) < 3) {
200 if(
rank == 0)
throw std::runtime_error(
"ERROR: lack of information on " + *beg +
" in " +
filename);
201 else sleep (2);
202 }
203 std::string flagname = *beg;
204 ++beg;
205 if (boost::iequals(*beg, "true") || boost::iequals(*beg, "false")) {
206
207 bool value_bool;
208 if (boost::iequals(*beg, "true"))
209 value_bool = 1;
210 else
211 value_bool = 0;
213 if(
rank == 0)
throw std::runtime_error(
"ERROR: setFlag error for " + flagname);
214 else sleep (2);
215 }
216 else if (
rank == 0) std::cout <<
"set flag " << flagname <<
"=" << *beg << std::endl;
217 } else {
218
219 std::string value_str = *beg;
221 if(
rank == 0)
throw std::runtime_error(
"ERROR: setFlag error for " + flagname);
222 else sleep (2);
223 }
else if (
rank == 0) std::cout <<
"set flag " << flagname <<
"=" << value_str << std::endl;
224 }
225 ++beg;
226 if (beg != tok->end() &&
rank == 0) std::cout <<
"WARNING: unread information in Flag " << flagname << std::endl;
227 } else if (type.compare("IncludeFile") == 0) {
231 std::string IncludeFileName =
filepath + *beg;
232 if (
rank == 0) std::cout <<
"Including File: " + IncludeFileName << std::endl;
233 ReadParameters(IncludeFileName,
rank, ModelPars, Observables, Observables2D, CGO, CGP);
238 ++beg;
239 } else {
240 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");
241 else sleep(2);
242 }
243 delete tok;
244 tok = NULL;
246
248 throw std::runtime_error("ERROR: Incorrect or missing model name in the model configuration file.\n");
250 throw std::runtime_error("ERROR: incompatible flag(s)\n");
251 delete sep;
252 sep = NULL;
254}
A class for Higgs experimental analyses.
void setIsCorrelated(bool correlated)
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
StandardModel * CreateModel(const std::string &ModelName)
bool IsModelInitialized() const
A method to check if the model is initialized.
void setModelName(const std::string name)
A method to set the name of the model.
std::string getModelName() const
A method to fetch the name of the model.
A class for model parameters.
boost::tokenizer< boost::char_separator< char > >::iterator & ParseModelParameter(boost::tokenizer< boost::char_separator< char > >::iterator &beg)
Parser for model parameters.
std::string getname() const
A get method to get the name of each parameter.
double geterrg() const
A get method to get the gaussian error.
double geterrf() const
A get method to get the flat error.
A class for analyzing observables pairwise.
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)
bool isEOF()
A method to check if the end of file has been reached.
std::string getThname2() const
A get method to access the thname of the second observable as defined in ThFactory class.
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.
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 getName() const
A get method to access the name of the observable.
void setObsType(std::string &obsType_s)
A set method to set the Observable type.
virtual bool CheckFlags() const
A method to check the sanity of the set of model flags.
virtual bool setFlagStr(const std::string name, const std::string value)
A method to set a flag of StandardModel.
virtual bool setFlag(const std::string name, const bool value)
A method to set a flag of StandardModel.
virtual bool InitializeModel()
A method to initialize the 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...