1 #include <ext/alloc_traits.h> 6 #include "CLHEP/Evaluator/Evaluator.h" 16 evaluator_.setSystemOfUnits(1.
e+3, 1. / 1.60217733
e-25, 1.
e+9, 1. / 1.60217733
e-10, 1.0, 1.0, 1.0);
27 std::vector<std::string>& vals,
30 std::vector<std::string>::iterator it(
vars.begin()), ed(
vars.end());
32 for (; it != ed; ++it) {
48 evaluator_.setVariable(newVar.c_str(), newVal.c_str());
50 case HepTool::Evaluator::WARNING_EXISTING_VARIABLE:
54 case HepTool::Evaluator::WARNING_EXISTING_FUNCTION:
55 case HepTool::Evaluator::WARNING_BLANK_STRING:
60 std::cout <<
"set-var: ns=" << ns <<
" nm=" <<
name <<
" val=" << exprValue << std::endl;
62 throwex(ns,
name, exprValue,
"can't set parameter !");
69 case HepTool::Evaluator::WARNING_EXISTING_VARIABLE:
73 case HepTool::Evaluator::WARNING_EXISTING_FUNCTION:
74 case HepTool::Evaluator::WARNING_BLANK_STRING:
79 std::cout <<
"set-varname=" <<
n <<
" val=" <<
v << std::endl;
81 throwex(
"",
n,
v,
"can't set parameter !");
91 prepare(ns, pseudo, expr, pseudo, prepared);
95 std::cout <<
"expr: " << prepared << std::endl;
110 std::cout <<
"expr: " << expression << std::endl;
127 return evaluator_.findVariable(newVar.c_str());
149 nameResult = ns + sep +
name;
160 bool insideBracket =
false;
161 bool nsFound =
false;
163 std::vector<int> hasNs(1);
166 switch (exprValue[
idx]) {
168 if (nsFound || insideBracket) {
169 throwex(ns,
name, exprValue,
"found a ':' outside '[..]' , or too many '[' !",
idx);
171 insideBracket =
true;
175 if (!insideBracket) {
178 insideBracket =
false;
181 hasNs.emplace_back(1);
183 hasNs.emplace_back(0);
187 if ((!insideBracket) || nsFound) {
188 throwex(ns,
name, exprValue,
"found a ':' outside '[..]' , or multiple ':' inside '[..]'",
idx);
198 if (insideBracket || nsFound) {
199 throwex(ns,
name, exprValue,
"'[..]' not closed , or ':' outside of '[..]'",
idx);
208 switch (exprValue[
idx]) {
211 if (!hasNs[varCount]) {
212 valResult = valResult + ns + sep;
218 valResult = valResult + sep;
221 valResult = valResult + exprValue[
idx];
bool isDefined(const std::string &ns, const std::string &name)
std::vector< std::string > variables_
void prepare(const std::string &ns, const std::string &name, const std::string &exprValue, std::string &nameResult, std::string &valResult) const
void checkname(const std::string &name) const
std::vector< std::string > values_
HepTool::Evaluator evaluator_
std::pair< int, edm::FunctionWithDict > OK
void throwex(const std::string &ns, const std::string &name, const std::string &expr, const std::string &reason, int idx=0) const
void set(const std::string &ns, const std::string &name, const std::string &exprValue)
double eval(const std::string &ns, const std::string &expr)
void dd_exchange_value(std::vector< std::string > &vars, std::vector< std::string > &vals, const std::string &var, const std::string &val)