CMS 3D CMS Logo

DDConstant.cc
Go to the documentation of this file.
2 
3 #include <string>
4 #include <utility>
5 #include <vector>
6 
11 
13 
15 {
16  prep_ = StoreT::instance().create(name);
17 }
18 
20 {
21  prep_ = StoreT::instance().create(name,vals);
22 }
23 
24 std::ostream & operator<<(std::ostream & os, const DDConstant & cons)
25 {
26  os << "DDConstant name=" << cons.name();
27 
28  if(cons.isDefined().second) {
29  os << " val=" << cons.value();
30  }
31  else {
32  os << " constant is not yet defined, only declared.";
33  }
34  return os;
35 }
36 
37 void
39 {
40  auto& eval = ExprEvalSingleton::instance();
41  const auto& vars = eval.variables();
42  const auto& vals = eval.values();
43  if( vars.size() != vals.size()) {
44  throw cms::Exception( "DDException" )
45  << "DDConstants::createConstansFromEvaluator(): different size of variable names & values!";
46  }
47  for( const auto& it : vars ) {
48  auto found = it.find( "___" );
49  DDName name( std::string( it, found + 3, it.size() - 1 ), std::string( it, 0, found ));
50  double* dv = new double;
51  *dv = eval.eval( it.c_str());
52  DDConstant cst( name, dv );
53  }
54 }
Definition: DDBase.h:10
def_type isDefined() const
Definition: DDBase.h:110
const DDName & name() const
Definition: DDBase.h:78
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:16
static value_type & instance()
double value() const
return the first stored value; does not check boundaries!
Definition: DDConstant.h:32
DDConstant()
an uninitialized constant; one can assign an initialized constant to make it valid ...
Definition: DDConstant.cc:12
static void createConstantsFromEvaluator()
creates all DDConstants from the variables of the ClhepEvaluator
Definition: DDConstant.cc:38
a named constant corresponding to the DDL-XML tag <Constant> and <ConstantsVector> ...
Definition: DDConstant.h:16
std::ostream & operator<<(std::ostream &os, const DDConstant &cons)
output operator for printing ...
Definition: DDConstant.cc:24