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.
3 
5 
7 {
8  prep_ = StoreT::instance().create(name);
9 }
10 
12 {
13  prep_ = StoreT::instance().create(name,vals);
14 }
15 
16 std::ostream & operator<<(std::ostream & os, const DDConstant & cons)
17 {
18  os << "DDConstant name=" << cons.name();
19 
20  if(cons.isDefined().second) {
21  os << " val=" << cons.value();
22  }
23  else {
24  os << " constant is not yet defined, only declared.";
25  }
26  return os;
27 }
28 
29 void
31 {
32  auto& eval = ExprEvalSingleton::instance();
33  const auto& vars = eval.variables();
34  const auto& vals = eval.values();
35  if( vars.size() != vals.size()) {
36  throw cms::Exception( "DDException" )
37  << "DDConstants::createConstansFromEvaluator(): different size of variable names & values!";
38  }
39  for( const auto& it : vars ) {
40  auto found = it.find( "___" );
41  DDName name( std::string( it, found + 3, it.size() - 1 ), std::string( it, 0, found ));
42  double* dv = new double;
43  *dv = eval.eval( it.c_str());
44  DDConstant cst( name, dv );
45  }
46 }
Definition: DDBase.h:10
def_type isDefined() const
Definition: DDBase.h:110
const N & name() const
Definition: DDBase.h:78
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:14
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:187
static value_type & instance()
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:4
static void createConstantsFromEvaluator()
creates all DDConstants from the variables of the ClhepEvaluator
Definition: DDConstant.cc:30
a named constant corresponding to the DDL-XML tag &lt;Constant&gt; and &lt;ConstantsVector&gt; ...
Definition: DDConstant.h:15