1 #include <ext/alloc_traits.h> 6 #include "CLHEP/Evaluator/Evaluator.h" 17 evaluator_.setSystemOfUnits(1.
e+3, 1./1.60217733
e-25, 1.
e+9, 1./1.60217733
e-10,
33 std::vector<std::string> &
vals,
37 std::vector<std::string>::iterator it(vars.begin()), ed(vars.end());
39 for (; it != ed; ++it) {
57 prepare(ns,name,exprValue,newVar,newVal);
58 evaluator_.setVariable(newVar.c_str(), newVal.c_str());
60 case HepTool::Evaluator::WARNING_EXISTING_VARIABLE:
64 case HepTool::Evaluator::WARNING_EXISTING_FUNCTION:
65 case HepTool::Evaluator::WARNING_BLANK_STRING:
70 std::cout <<
"set-var: ns=" << ns <<
" nm=" << name <<
" val=" << exprValue << std::endl;
72 throwex(ns,name,exprValue,
"can't set parameter !");
81 case HepTool::Evaluator::WARNING_EXISTING_VARIABLE:
85 case HepTool::Evaluator::WARNING_EXISTING_FUNCTION:
86 case HepTool::Evaluator::WARNING_BLANK_STRING:
91 std::cout <<
"set-varname=" << n <<
" val=" << v << std::endl;
93 throwex(
"",n,v,
"can't set parameter !");
105 prepare(ns,pseudo,expr, pseudo,prepared);
109 std::cout <<
"expr: " << prepared << std::endl;
125 std::cout <<
"expr: " << expression << std::endl;
142 prepare(ns,name,
"0", newVar,newVal);
143 return evaluator_.findVariable(newVar.c_str());
168 nameResult = ns + sep +
name;
179 bool insideBracket =
false;
180 bool nsFound =
false;
182 std::vector<int> hasNs(1);
186 switch(exprValue[idx])
189 if (nsFound || insideBracket)
192 "found a ':' outside '[..]' , or too many '[' !",idx);
200 throwex(ns,name,exprValue,
"too many ']' !",idx);
206 hasNs.emplace_back(1);
210 hasNs.emplace_back(0);
214 if ( (!insideBracket) || nsFound )
217 "found a ':' outside '[..]' , or multiple ':' inside '[..]'",idx);
228 if ( insideBracket || nsFound ) {
230 "'[..]' not closed , or ':' outside of '[..]'",idx);
240 switch(exprValue[idx])
244 if ( !hasNs[varCount] )
246 valResult = valResult + ns + sep;
252 valResult = valResult + sep;
255 valResult = valResult + exprValue[
idx];
bool isDefined(const std::string &ns, const std::string &name)
std::vector< std::string > variables_
std::vector< std::string > values_
HepTool::Evaluator evaluator_
std::pair< int, edm::FunctionWithDict > OK
void checkname(const std::string &name) const
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 prepare(const std::string &ns, const std::string &name, const std::string &exprValue, std::string &nameResult, std::string &valResult) const
void dd_exchange_value(std::vector< std::string > &vars, std::vector< std::string > &vals, const std::string &var, const std::string &val)