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 
13 
14 DDConstant::DDConstant(const DDName& name, std::unique_ptr<double> vals) { create(name, std::move(vals)); }
15 
16 std::ostream& operator<<(std::ostream& os, const DDConstant& cons) {
17  os << "DDConstant name=" << cons.name();
18 
19  if (cons.isDefined().second) {
20  os << " val=" << cons.value();
21  } else {
22  os << " constant is not yet defined, only declared.";
23  }
24  return os;
25 }
26 
28  const auto& vars = eval.variables();
29  const auto& vals = eval.values();
30  if (vars.size() != vals.size()) {
31  throw cms::Exception("DDException")
32  << "DDConstants::createConstansFromEvaluator(): different size of variable names & values!";
33  }
34  for (const auto& it : vars) {
35  auto found = it.find("___");
36  DDName name(std::string(it, found + 3, it.size() - 1), std::string(it, 0, found));
37  DDConstant cst(name, std::make_unique<double>(eval.eval(it.c_str())));
38  }
39 }
DDName
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:15
DDBase::isDefined
def_type isDefined() const
Definition: DDBase.h:90
ClhepEvaluator.h
ClhepEvaluator
Definition: ClhepEvaluator.h:8
newFWLiteAna.found
found
Definition: newFWLiteAna.py:118
DDConstant::DDConstant
DDConstant()
an uninitialized constant; one can assign an initialized constant to make it valid
Definition: DDConstant.cc:10
ClhepEvaluator::variables
const std::vector< std::string > & variables() const
access to the clhep-implementation of the dictionary variables
Definition: ClhepEvaluator.h:23
operator<<
std::ostream & operator<<(std::ostream &os, const DDConstant &cons)
output operator for printing ...
Definition: DDConstant.cc:16
vars
vars
Definition: DeepTauId.cc:164
DDBase< DDName, std::unique_ptr< double > >::name
const DDName & name() const
Definition: DDBase.h:59
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
DDConstant::value
double value() const
return the first stored value; does not check boundaries!
Definition: DDConstant.h:33
cms::cuda::device::unique_ptr
std::unique_ptr< T, impl::DeviceDeleter > unique_ptr
Definition: device_unique_ptr.h:33
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
DDConstant
a named constant corresponding to the DDL-XML tag <Constant> and <ConstantsVector>
Definition: DDConstant.h:18
DDBase< DDName, std::unique_ptr< double > >::create
void create(const DDName &name, std::unique_ptr< double > vals)
Definition: DDBase.h:96
Exception
Definition: hltDiff.cc:245
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
Exception.h
ClhepEvaluator::eval
double eval(const std::string &ns, const std::string &expr)
Definition: ClhepEvaluator.cc:85
DDBase
Definition: DDBase.h:10
DDConstant.h
DDConstant::createConstantsFromEvaluator
static void createConstantsFromEvaluator(ClhepEvaluator &)
creates all DDConstants from the variables of the ClhepEvaluator
Definition: DDConstant.cc:27
ClhepEvaluator::values
const std::vector< std::string > & values() const
Definition: ClhepEvaluator.h:24