CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions
DDConstant Class Reference

a named constant corresponding to the DDL-XML tag <Constant> and <ConstantsVector> More...

#include <DDConstant.h>

Inheritance diagram for DDConstant:
DDBase< DDName, std::unique_ptr< double > >

Public Member Functions

 DDConstant ()
 an uninitialized constant; one can assign an initialized constant to make it valid More...
 
 DDConstant (const DDName &name)
 a refenrence to a constant More...
 
 DDConstant (const DDName &name, std::unique_ptr< double > value)
 creation of a new named constant; if it already existed with the given name, it's overwritten with new values More...
 
 operator double () const
 convert to a double More...
 
double value () const
 return the first stored value; does not check boundaries! More...
 
- Public Member Functions inherited from DDBase< DDName, std::unique_ptr< double > >
void create (const DDName &name)
 
void create (const DDName &name, std::unique_ptr< double > vals)
 
 DDBase ()
 
const DDNameddname () const
 
def_type isDefined () const
 
bool isValid () const
 true, if the wrapped pointer is valid More...
 
const DDNamename () const
 
 operator bool () const
 
bool operator< (const DDBase &b) const
 
bool operator== (const DDBase &b) const
 
bool operator> (const DDBase &b) const
 
DDI::rep_traits< DDName, std::unique_ptr< double > >::reference rep ()
 
const DDI::rep_traits< DDName, std::unique_ptr< double > >::reference rep () const
 
std::string toString () const
 
const DDI::rep_traits< DDName, std::unique_ptr< double > >::reference val ()
 
const DDI::rep_traits< DDName, std::unique_ptr< double > >::reference val () const
 
virtual ~DDBase ()
 

Static Public Member Functions

static void createConstantsFromEvaluator (ClhepEvaluator &)
 creates all DDConstants from the variables of the ClhepEvaluator More...
 
- Static Public Member Functions inherited from DDBase< DDName, std::unique_ptr< double > >
static auto begin ()
 
static auto end ()
 

Additional Inherited Members

- Public Types inherited from DDBase< DDName, std::unique_ptr< double > >
using def_type = std::pair< const DDName *, bool >
 
using StoreT = DDI::Singleton< DDI::Store< DDName, std::unique_ptr< double > > >
 

Detailed Description

a named constant corresponding to the DDL-XML tag <Constant> and <ConstantsVector>

Definition at line 18 of file DDConstant.h.

Constructor & Destructor Documentation

◆ DDConstant() [1/3]

DDConstant::DDConstant ( )

an uninitialized constant; one can assign an initialized constant to make it valid

Definition at line 10 of file DDConstant.cc.

◆ DDConstant() [2/3]

DDConstant::DDConstant ( const DDName name)

◆ DDConstant() [3/3]

DDConstant::DDConstant ( const DDName name,
std::unique_ptr< double >  value 
)

creation of a new named constant; if it already existed with the given name, it's overwritten with new values

Definition at line 14 of file DDConstant.cc.

14 { create(name, std::move(vals)); }

References DDBase< DDName, std::unique_ptr< double > >::create(), eostools::move(), and DDBase< DDName, std::unique_ptr< double > >::name().

Member Function Documentation

◆ createConstantsFromEvaluator()

void DDConstant::createConstantsFromEvaluator ( ClhepEvaluator eval)
static

creates all DDConstants from the variables of the ClhepEvaluator

Definition at line 27 of file DDConstant.cc.

27  {
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 }

References ClhepEvaluator::eval(), Exception, newFWLiteAna::found, DDBase< DDName, std::unique_ptr< double > >::name(), AlCaHLTBitMon_QueryRunRegistry::string, ClhepEvaluator::values(), and ClhepEvaluator::variables().

Referenced by DDLSAX2FileHandler::createDDConstants().

◆ operator double()

DDConstant::operator double ( ) const
inline

convert to a double

Definition at line 36 of file DDConstant.h.

36 { return rep(); }

References DDBase< DDName, std::unique_ptr< double > >::rep().

◆ value()

double DDConstant::value ( ) const
inline
DDName
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:15
newFWLiteAna.found
found
Definition: newFWLiteAna.py:118
ClhepEvaluator::variables
const std::vector< std::string > & variables() const
access to the clhep-implementation of the dictionary variables
Definition: ClhepEvaluator.h:23
vars
vars
Definition: DeepTauId.cc:164
DDBase< DDName, std::unique_ptr< double > >::name
const DDName & name() const
Definition: DDBase.h:59
DDBase< DDName, std::unique_ptr< double > >::rep
const DDI::rep_traits< DDName, std::unique_ptr< double > >::reference rep() const
Definition: DDBase.h:65
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
eostools.move
def move(src, dest)
Definition: eostools.py:511
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
ClhepEvaluator::eval
double eval(const std::string &ns, const std::string &expr)
Definition: ClhepEvaluator.cc:85
DDBase
Definition: DDBase.h:10
ClhepEvaluator::values
const std::vector< std::string > & values() const
Definition: ClhepEvaluator.h:24