CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DDConstant.cc
Go to the documentation of this file.
2 
3 // Evaluator
5 
7 
8 
10 {
11  prep_ = StoreT::instance().create(name);
12 }
13 
15 {
16  prep_ = StoreT::instance().create(name,vals);
17 }
18 
19 
20 std::ostream & operator<<(std::ostream & os, const DDConstant & cons)
21 {
22  os << "DDConstant name=" << cons.name();
23 
24  if(cons.isDefined().second) {
25  os << " val=" << cons.value();
26  }
27  else {
28  os << " constant is not yet defined, only declared.";
29  }
30  return os;
31 }
32 
33 
35 {
37  ClhepEvaluator * eval = dynamic_cast<ClhepEvaluator*>(&ev);
38  if (eval){
39  const std::vector<std::string> & vars = eval->variables();
40  const std::vector<std::string> & vals = eval->values();
41  if (vars.size() != vals.size()) {
42  throw cms::Exception("DDException") << "DDConstants::createConstansFromEvaluator(): different size of variable names & values!";
43  }
44  size_t i(0), s(vars.size());
45  for (; i<s; ++i) {
46  const std::string & sr = vars[i];
47  typedef std::string::size_type ST;
48  ST i1 = sr.find("___");
49  DDName name(std::string(sr,i1+3,sr.size()-1),std::string(sr,0,i1));
50  double* dv = new double;
51  *dv = eval->eval(sr.c_str());
52  DDConstant cst(name,dv);//(ddname);
53  }
54  }
55  else {
56  throw cms::Exception("DDException") << "DDConstants::createConstansFromEvaluator(): expression-evaluator is not a ClhepEvaluator-implementation!";
57  }
58 }
59 
60 
Definition: DDBase.h:14
int i
Definition: DBlmapReader.cc:9
def_type isDefined() const
Definition: DDBase.h:115
const N & name() const
Definition: DDBase.h:82
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:18
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:187
uint16_t size_type
static value_type & instance()
const std::vector< std::string > & variables() const
access to the clhep-implementation of the dictionary variables
const std::vector< std::string > & values() const
double value() const
return the first stored value; does not check boundaries!
Definition: DDConstant.h:31
DDConstant()
an uninitialized constant; one can assign an initialized constant to make it valid ...
Definition: DDConstant.cc:6
static void createConstantsFromEvaluator()
creates all DDConstants from the variables of the ClhepEvaluator
Definition: DDConstant.cc:34
double eval(const std::string &ns, const std::string &expr)
a named constant corresponding to the DDL-XML tag &lt;Constant&gt; and &lt;ConstantsVector&gt; ...
Definition: DDConstant.h:15