Skip to content

Commit

Permalink
Introduce assemblies and fix overlaps in Ecal Proshower
Browse files Browse the repository at this point in the history
  • Loading branch information
ianna committed Jun 7, 2020
1 parent e1a5aee commit 904d604
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 343 deletions.
3 changes: 3 additions & 0 deletions DetectorDescription/DDCMS/interface/DDNamespace.h
Expand Up @@ -55,6 +55,9 @@ namespace cms {
dd4hep::Solid addSolid(const std::string& name, dd4hep::Solid solid) const;
dd4hep::Solid addSolidNS(const std::string& name, dd4hep::Solid solid) const;

dd4hep::Assembly addAssembly(dd4hep::Assembly asmb) const;
dd4hep::Assembly assembly(const std::string& name) const;

dd4hep::Volume volume(const std::string& name, bool exc = true) const;
dd4hep::Volume addVolume(dd4hep::Volume vol) const;
dd4hep::Volume addVolumeNS(dd4hep::Volume vol) const;
Expand Down
2 changes: 2 additions & 0 deletions DetectorDescription/DDCMS/interface/DDParsingContext.h
Expand Up @@ -16,6 +16,7 @@ namespace cms {
DDParsingContext(dd4hep::Detector* det) : description(det) {}

~DDParsingContext() {
assemblies.clear();
rotations.clear();
shapes.clear();
volumes.clear();
Expand All @@ -34,6 +35,7 @@ namespace cms {
}

std::atomic<dd4hep::Detector*> description;
tbb::concurrent_unordered_map<std::string, dd4hep::Assembly> assemblies;
tbb::concurrent_unordered_map<std::string, dd4hep::Rotation3D> rotations;
tbb::concurrent_unordered_map<std::string, dd4hep::Solid> shapes;
tbb::concurrent_unordered_map<std::string, dd4hep::Volume> volumes;
Expand Down
21 changes: 21 additions & 0 deletions DetectorDescription/DDCMS/src/DDNamespace.cc
Expand Up @@ -187,6 +187,27 @@ dd4hep::Volume DDNamespace::addVolume(dd4hep::Volume vol) const {
return vol;
}

dd4hep::Assembly DDNamespace::addAssembly(dd4hep::Assembly assembly) const {
string n = assembly.name();
m_context->assemblies[n] = assembly;
dd4hep::printout(
m_context->debug_volumes ? dd4hep::ALWAYS : dd4hep::DEBUG, "DD4CMS", "+++ Add assemblyNS:%-38s", assembly.name());
return assembly;
}

dd4hep::Assembly DDNamespace::assembly(const std::string& name) const {
auto i = m_context->assemblies.find(name);
if (i != m_context->assemblies.end()) {
return (*i).second;
}
if (name.front() == NAMESPACE_SEP) {
i = m_context->assemblies.find(name.substr(1, name.size()));
if (i != m_context->assemblies.end())
return (*i).second;
}
throw runtime_error("Unknown assembly identifier:" + name);
}

dd4hep::Volume DDNamespace::volume(const string& name, bool exc) const {
auto i = m_context->volumes.find(name);
if (i != m_context->volumes.end()) {
Expand Down

0 comments on commit 904d604

Please sign in to comment.