CMS 3D CMS Logo

DDConstant.cc
Go to the documentation of this file.
2 
3 #include <string>
4 #include <utility>
5 #include <vector>
6 
9 
11  : DDBase< DDName, std::unique_ptr<double> >()
12 { }
13 
15  : DDBase< DDName, std::unique_ptr<double> >()
16 {
17  create( name );
18 }
19 
20 DDConstant::DDConstant( const DDName & name, std::unique_ptr<double> vals )
21 {
22  create( name, std::move( vals ));
23 }
24 
25 std::ostream & operator<<(std::ostream & os, const DDConstant & cons)
26 {
27  os << "DDConstant name=" << cons.name();
28 
29  if(cons.isDefined().second) {
30  os << " val=" << cons.value();
31  }
32  else {
33  os << " constant is not yet defined, only declared.";
34  }
35  return os;
36 }
37 
38 void
40 {
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  DDConstant cst( name, std::make_unique<double>( eval.eval( it.c_str())));
51  }
52 }
Definition: DDBase.h:10
def_type isDefined() const
Definition: DDBase.h:107
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:15
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:34
DDConstant()
an uninitialized constant; one can assign an initialized constant to make it valid ...
Definition: DDConstant.cc:10
static void createConstantsFromEvaluator(ClhepEvaluator &)
creates all DDConstants from the variables of the ClhepEvaluator
Definition: DDConstant.cc:39
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:18
def move(src, dest)
Definition: eostools.py:511
std::ostream & operator<<(std::ostream &os, const DDConstant &cons)
output operator for printing ...
Definition: DDConstant.cc:25
void create(const DDName &name, std::unique_ptr< double > vals)
Definition: DDBase.h:121