CMS 3D CMS Logo

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