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,
35 std::vector<std::string>::iterator it(vars.begin()), ed(vars.end());
37 for (; it != ed; ++it) {
54 prepare(ns,name,exprValue,newVar,newVal);
55 evaluator_.setVariable(newVar.c_str(), newVal.c_str());
57 case HepTool::Evaluator::WARNING_EXISTING_VARIABLE:
61 case HepTool::Evaluator::WARNING_EXISTING_FUNCTION:
62 case HepTool::Evaluator::WARNING_BLANK_STRING:
67 std::cout <<
"set-var: ns=" << ns <<
" nm=" << name <<
" val=" << exprValue << std::endl;
69 throwex(ns,name,exprValue,
"can't set parameter !");
77 case HepTool::Evaluator::WARNING_EXISTING_VARIABLE:
81 case HepTool::Evaluator::WARNING_EXISTING_FUNCTION:
82 case HepTool::Evaluator::WARNING_BLANK_STRING:
87 std::cout <<
"set-varname=" << n <<
" val=" << v << std::endl;
89 throwex(
"",n,v,
"can't set parameter !");
102 prepare(ns,pseudo,expr, pseudo,prepared);
106 std::cout <<
"expr: " << prepared << std::endl;
121 std::cout <<
"expr: " << expression << std::endl;
137 prepare(ns,name,
"0", newVar,newVal);
138 return evaluator_.findVariable(newVar.c_str());
164 nameResult = ns + sep +
name;
175 bool insideBracket =
false;
176 bool nsFound =
false;
178 std::vector<int> hasNs(1);
182 switch(exprValue[idx])
185 if (nsFound || insideBracket)
188 "found a ':' outside '[..]' , or too many '[' !",idx);
196 throwex(ns,name,exprValue,
"too many ']' !",idx);
210 if ( (!insideBracket) || nsFound )
213 "found a ':' outside '[..]' , or multiple ':' inside '[..]'",idx);
224 if ( insideBracket || nsFound ) {
226 "'[..]' not closed , or ':' outside of '[..]'",idx);
236 switch(exprValue[idx])
240 if ( !hasNs[varCount] )
242 valResult = valResult + ns + sep;
248 valResult = valResult + sep;
251 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)