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 #include "tbb/concurrent_unordered_map.h"
9 #include "tbb/concurrent_vector.h"
10 
11 namespace cms {
12 
13  class DDParsingContext;
14  using DDVectorsMap = tbb::concurrent_unordered_map<std::string, tbb::concurrent_vector<double>>;
15 
16  class DDNamespace {
17  public:
19  DDNamespace(DDParsingContext&, xml_h, bool);
22  ~DDNamespace();
23 
24  DDNamespace() = delete;
25  DDNamespace(const DDNamespace&) = delete;
26  DDNamespace& operator=(const DDNamespace&) = delete;
27 
28  std::string prepend(const std::string&) const;
29  std::string realName(const std::string&) const;
30  static std::string objName(const std::string&);
31  static std::string nsName(const std::string&);
32 
33  template <typename T>
34  T attr(xml_elt_t element, const xml_tag_t& name) const {
35  std::string val = realName(element.attr<std::string>(name));
36  element.setAttr(name, val);
37  return element.attr<T>(name);
38  }
39 
40  template <typename T>
41  T attr(xml_elt_t element, const xml_tag_t& name, T defaultValue) const {
42  if (element.hasAttr(name)) {
43  std::string val = realName(element.attr<std::string>(name));
44  element.setAttr(name, val);
45  return element.attr<T>(name);
46  }
47  return defaultValue;
48  }
49 
50  void addConstant(const std::string& name, const std::string& value, const std::string& type) const;
51  void addConstantNS(const std::string& name, const std::string& value, const std::string& type) const;
52 
54  dd4hep::Solid solid(const std::string& name) const;
55  dd4hep::Solid addSolid(const std::string& name, dd4hep::Solid solid) const;
56  dd4hep::Solid addSolidNS(const std::string& name, dd4hep::Solid solid) const;
57 
58  dd4hep::Volume volume(const std::string& name, bool exc = true) const;
61 
62  const dd4hep::Rotation3D& rotation(const std::string& name) const;
63  void addRotation(const std::string& name, const dd4hep::Rotation3D& rot) const;
64 
65  DDParsingContext* const context() const { return m_context; }
67 
68  std::string_view name() const { return m_name; }
69 
70  std::vector<double> vecDbl(const std::string& name) const;
71 
72  private:
75  bool m_pop = false;
76  };
77 } // namespace cms
78 
79 #define NAMESPACE_SEP ':'
80 
81 #endif
cms::DDNamespace::~DDNamespace
~DDNamespace()
Definition: DDNamespace.cc:52
cms::DDNamespace::realName
std::string realName(const std::string &) const
Definition: DDNamespace.cc:73
cms::DDNamespace::m_context
DDParsingContext * m_context
Definition: DDNamespace.h:73
g4SimHits_cfi.Material
Material
Definition: g4SimHits_cfi.py:547
cms::DDNamespace::addRotation
void addRotation(const std::string &name, const dd4hep::Rotation3D &rot) const
Definition: DDNamespace.cc:125
cms::DDNamespace::addConstant
void addConstant(const std::string &name, const std::string &value, const std::string &type) const
Definition: DDNamespace.cc:103
cms::DDNamespace::solid
dd4hep::Solid solid(const std::string &name) const
Definition: DDNamespace.cc:225
cms::DDNamespace::attr
T attr(xml_elt_t element, const xml_tag_t &name) const
Definition: DDNamespace.h:34
cms::DDNamespace::material
dd4hep::Material material(const std::string &name) const
Definition: DDNamespace.cc:121
cms::DDNamespace::m_pop
bool m_pop
Definition: DDNamespace.h:75
cms::DDVectorsMap
tbb::concurrent_unordered_map< std::string, tbb::concurrent_vector< double > > DDVectorsMap
Definition: DDNamespace.h:14
cms::DDParsingContext
Definition: DDParsingContext.h:14
cms::DDNamespace
Definition: DDNamespace.h:16
cms::DDNamespace::addConstantNS
void addConstantNS(const std::string &name, const std::string &value, const std::string &type) const
Definition: DDNamespace.cc:107
cms::DDNamespace::objName
static std::string objName(const std::string &)
Definition: DDNamespace.cc:96
cms::DDNamespace::prepend
std::string prepend(const std::string &) const
Definition: DDNamespace.cc:66
cms::DDNamespace::rotation
const dd4hep::Rotation3D & rotation(const std::string &name) const
Definition: DDNamespace.cc:130
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
cms::Volume
dd4hep::Volume Volume
Definition: DDFilteredView.h:45
hltPixelClustersMultiplicity_cfi.defaultValue
defaultValue
Definition: hltPixelClustersMultiplicity_cfi.py:4
cms::DDNamespace::attr
T attr(xml_elt_t element, const xml_tag_t &name, T defaultValue) const
Definition: DDNamespace.h:41
value
Definition: value.py:1
cms::DDNamespace::addVolume
dd4hep::Volume addVolume(dd4hep::Volume vol) const
Add rotation matrix to current namespace.
Definition: DDNamespace.cc:170
cms::DDNamespace::DDNamespace
DDNamespace()=delete
cms::DDNamespace::addSolidNS
dd4hep::Solid addSolidNS(const std::string &name, dd4hep::Solid solid) const
Definition: DDNamespace.cc:206
cms::DDNamespace::operator=
DDNamespace & operator=(const DDNamespace &)=delete
cms::DDNamespace::addSolid
dd4hep::Solid addSolid(const std::string &name, dd4hep::Solid solid) const
Definition: DDNamespace.cc:221
cms::DDNamespace::addVolumeNS
dd4hep::Volume addVolumeNS(dd4hep::Volume vol) const
Definition: DDNamespace.cc:150
cms::DDNamespace::setContext
DDParsingContext * setContext()
Definition: DDNamespace.h:66
cms::DDNamespace::nsName
static std::string nsName(const std::string &)
Definition: DDNamespace.cc:89
type
type
Definition: HCALResponse.h:21
heppy_batch.val
val
Definition: heppy_batch.py:351
T
long double T
Definition: Basic3DVectorLD.h:48
cms::DDNamespace::context
DDParsingContext *const context() const
Definition: DDNamespace.h:65
makeMuonMisalignmentScenario.rot
rot
Definition: makeMuonMisalignmentScenario.py:322
cms::DDNamespace::vecDbl
std::vector< double > vecDbl(const std::string &name) const
Definition: DDNamespace.cc:246
cms::DDNamespace::m_name
std::string m_name
Definition: DDNamespace.h:74
cms::DDNamespace::name
std::string_view name() const
Definition: DDNamespace.h:68
cms::DDNamespace::volume
dd4hep::Volume volume(const std::string &name, bool exc=true) const
Definition: DDNamespace.cc:190
cms
Namespace of DDCMS conversion namespace.
Definition: ProducerAnalyzer.cc:21