CMS 3D CMS Logo

DDDetector.cc
Go to the documentation of this file.
3 #include <DD4hep/Detector.h>
4 #include <DD4hep/DetectorTools.h>
5 #include <DD4hep/Volumes.h>
6 #include <XML/DocumentHandler.h>
7 #include <XML/XMLElements.h>
8 
9 #include <iostream>
10 
11 using namespace cms;
12 using namespace std;
13 
14 DDDetector::DDDetector(const string& tag, const string& fileName, bool bigXML) : m_tag(tag) {
15  m_description = &Detector::getInstance(tag);
16  m_description->addExtension<DDVectorsMap>(&m_vectors);
17  m_description->addExtension<DDPartSelectionMap>(&m_partsels);
18  m_description->addExtension<DDSpecParRegistry>(&m_specpars);
19  if (bigXML)
20  processXML(fileName);
21  else
22  process(fileName);
23 }
24 
25 void DDDetector::process(const string& fileName) {
26  std::string name("DD4hep_CompactLoader");
27  const char* files[] = {fileName.c_str(), nullptr};
28  m_description->apply(name.c_str(), 2, (char**)files);
29 }
30 
32  edm::LogVerbatim("Geometry") << "DDDetector::processXML process string size " << xml.size() << " with max_size "
33  << xml.max_size();
34  std::string name("DD4hep_XMLProcessor");
35  dd4hep::xml::DocumentHolder doc(dd4hep::xml::DocumentHandler().parse(xml.c_str(), xml.length()));
36 
37  char* args[] = {(char*)doc.root().ptr(), nullptr};
38  m_description->apply(name.c_str(), 1, (char**)args);
39 }
40 
42  assert(m_description);
43  return m_description->worldVolume();
44 }
45 
46 dd4hep::PlacedVolume DDDetector::worldPlacement() const { return world().placement(); }
47 
48 dd4hep::DetElement DDDetector::world() const {
49  assert(m_description);
50  return m_description->world();
51 }
52 
53 const dd4hep::Detector::HandleMap& DDDetector::detectors() const {
54  assert(m_description);
55  return m_description->detectors();
56 }
57 
58 TGeoManager& DDDetector::manager() const {
59  assert(m_description);
60  return m_description->manager();
61 }
62 
63 dd4hep::DetElement DDDetector::findElement(const std::string& path) const {
64  assert(m_description);
65  return dd4hep::detail::tools::findElement(*m_description, path);
66 }
void process(const std::string &)
Definition: DDDetector.cc:25
DDDetector()=delete
Volume worldVolume() const
Handle to the world volume containing everything.
Definition: DDDetector.cc:41
DetElement findElement(const std::string &) const
Find DetElement as child of the top level volume by it&#39;s absolute path.
Definition: DDDetector.cc:63
PlacedVolume worldPlacement() const
Access to the physical volume of the world detector element.
Definition: DDDetector.cc:46
TGeoManager & manager() const
The geometry manager of this instance.
Definition: DDDetector.cc:58
dd4hep::PlacedVolume PlacedVolume
tbb::concurrent_unordered_map< std::string, tbb::concurrent_vector< std::string >> DDPartSelectionMap
tbb::concurrent_unordered_map< std::string, tbb::concurrent_vector< double >> DDVectorsMap
Definition: DDNamespace.h:14
dd4hep::Volume Volume
Namespace of DDCMS conversion namespace.
def parse(path, config)
Definition: dumpparser.py:13
const HandleMap & detectors() const
The map of sub-detectors.
Definition: DDDetector.cc:53
DetElement world() const
Reference to the top-most (world) detector element.
Definition: DDDetector.cc:48
void processXML(const std::string &)
Definition: DDDetector.cc:31