CMS 3D CMS Logo

DDNamespace.h
Go to the documentation of this file.
1 #ifndef DETECTOR_DESCRIPTION_DD_NAMESPACE_H
2 #define DETECTOR_DESCRIPTION_DD_NAMESPACE_H
3 
4 #include "XML/XML.h"
5 #include "DD4hep/Objects.h"
6 #include "DD4hep/Shapes.h"
7 #include "DD4hep/Volumes.h"
8 
9 namespace cms {
10 
11  class DDParsingContext;
12 
13  class DDNamespace {
14 
15  public:
16 
17  DDNamespace( DDParsingContext*, xml_h );
18  DDNamespace( DDParsingContext&, xml_h, bool );
21  ~DDNamespace();
22 
23  DDNamespace() = delete;
24  DDNamespace( const DDNamespace& ) = delete;
25  DDNamespace& operator=( const DDNamespace& ) = delete;
26 
27  std::string prepend( const std::string& ) const;
28  std::string realName( const std::string& ) const;
29  static std::string objName( const std::string& );
30  static std::string nsName( const std::string& );
31 
32  template<typename T> T attr( xml_elt_t element, const xml_tag_t& name ) const {
33  std::string val = realName( element.attr<std::string>( name ));
34  element.setAttr( name, val );
35  return element.attr<T>( name );
36  }
37 
38  template<typename T> T attr( xml_elt_t element, const xml_tag_t& name, T defaultValue ) const {
39  if( element.hasAttr( name )) {
40  std::string val = realName( element.attr<std::string>( name ));
41  element.setAttr( name, val );
42  return element.attr<T>( name );
43  }
44  return defaultValue;
45  }
46 
47  void addConstant( const std::string& name, const std::string& value, const std::string& type ) const;
48  void addConstantNS( const std::string& name, const std::string& value, const std::string& type ) const;
49  void addVector( const std::string& name, const std::vector<double>& value ) const;
50 
51  dd4hep::Material material( const std::string& name ) const;
52  dd4hep::Solid solid( const std::string& name ) const;
53  dd4hep::Solid addSolid( const std::string& name, dd4hep::Solid solid ) const;
54  dd4hep::Solid addSolidNS( const std::string& name, dd4hep::Solid solid ) const;
55 
56  dd4hep::Volume volume( const std::string& name, bool exc = true ) const;
59 
60  const dd4hep::Rotation3D& rotation( const std::string& name ) const;
61  void addRotation( const std::string& name, const dd4hep::Rotation3D& rot ) const;
62 
64 
65  const std::string& name() const {
66  return m_name;
67  }
68 
69  private:
71  bool m_pop = false;
72  };
73 }
74 
75 #define NAMESPACE_SEP ':'
76 
77 #endif
dd4hep::Solid addSolidNS(const std::string &name, dd4hep::Solid solid) const
Definition: DDNamespace.cc:247
type
Definition: HCALResponse.h:21
dd4hep::Volume volume(const std::string &name, bool exc=true) const
Definition: DDNamespace.cc:226
dd4hep::Volume addVolumeNS(dd4hep::Volume vol) const
Definition: DDNamespace.cc:197
std::string m_name
Definition: DDNamespace.h:70
dd4hep::Volume addVolume(dd4hep::Volume vol) const
Add rotation matrix to current namespace.
Definition: DDNamespace.cc:212
dd4hep::Solid solid(const std::string &name) const
Definition: DDNamespace.cc:263
void addConstantNS(const std::string &name, const std::string &value, const std::string &type) const
Definition: DDNamespace.cc:134
static std::string nsName(const std::string &)
Definition: DDNamespace.cc:110
void addVector(const std::string &name, const std::vector< double > &value) const
Definition: DDNamespace.cc:147
void addRotation(const std::string &name, const dd4hep::Rotation3D &rot) const
Definition: DDNamespace.cc:164
std::string realName(const std::string &) const
Definition: DDNamespace.cc:91
T attr(xml_elt_t element, const xml_tag_t &name) const
Definition: DDNamespace.h:32
static std::string objName(const std::string &)
Definition: DDNamespace.cc:119
dd4hep::Material material(const std::string &name) const
Definition: DDNamespace.cc:158
DDNamespace & operator=(const DDNamespace &)=delete
Definition: value.py:1
std::string prepend(const std::string &) const
Definition: DDNamespace.cc:85
T attr(xml_elt_t element, const xml_tag_t &name, T defaultValue) const
Definition: DDNamespace.h:38
Namespace of DDCMS conversion namespace.
dd4hep::Solid addSolid(const std::string &name, dd4hep::Solid solid) const
Definition: DDNamespace.cc:257
DDParsingContext * context
Definition: DDNamespace.h:63
const std::string & name() const
Definition: DDNamespace.h:65
const dd4hep::Rotation3D & rotation(const std::string &name) const
Definition: DDNamespace.cc:171
DDNamespace()=delete
long double T
void addConstant(const std::string &name, const std::string &value, const std::string &type) const
Definition: DDNamespace.cc:128