diff --git a/DetectorDescription/DDCMS/interface/DDNamespace.h b/DetectorDescription/DDCMS/interface/DDNamespace.h index a7357e442e6cf..ddadd38665444 100644 --- a/DetectorDescription/DDCMS/interface/DDNamespace.h +++ b/DetectorDescription/DDCMS/interface/DDNamespace.h @@ -70,6 +70,7 @@ namespace cms { DDParsingContext* setContext() { return m_context; } std::string_view name() const { return m_name; } + std::string noNamespace(const std::string&) const; std::vector vecDbl(const std::string& name) const; std::vector vecFloat(const std::string& name) const; diff --git a/DetectorDescription/DDCMS/plugins/dd4hep/DDDefinitions2Objects.cc b/DetectorDescription/DDCMS/plugins/dd4hep/DDDefinitions2Objects.cc index 576b4e8353f23..25410e31bb4d2 100644 --- a/DetectorDescription/DDCMS/plugins/dd4hep/DDDefinitions2Objects.cc +++ b/DetectorDescription/DDCMS/plugins/dd4hep/DDDefinitions2Objects.cc @@ -758,7 +758,7 @@ void Converter::operator()(xml_h element) const { xml_dim_t xrot(element); xml_dim_t par(xrot.parent()); if (xrot.hasAttr(_U(name))) { - string nam = xrot.nameStr(); // + string("Rotation"); // xrot.hasAttr(_U(name)) ? xrot.nameStr() : par.nameStr(); + string nam = xrot.nameStr(); string axis = ns.attr(xrot, DD_CMU(axis)); double angle = ns.attr(xrot, _U(angle)); Rotation3D rot; @@ -786,7 +786,7 @@ void Converter::operator()(xml_h element) const { xml_dim_t e(element); string sol = e.child(DD_CMU(rSolid)).attr(_U(name)); string mat = e.child(DD_CMU(rMaterial)).attr(_U(name)); - string volName = e.attr(_U(name)); + string volName = ns.prepend(e.attr(_U(name))); Solid solid = ns.solid(sol); Material material = ns.material(mat); @@ -852,8 +852,8 @@ void Converter::operator()(xml_h element) const { cms::DDNamespace ns(_param()); //, element, true ); xml_dim_t e(element); int copy = e.attr(DD_CMU(copyNumber)); - string parentName = ns.attr(e.child(DD_CMU(rParent)), _U(name)); - string childName = ns.attr(e.child(DD_CMU(rChild)), _U(name)); + string parentName = ns.prepend(ns.attr(e.child(DD_CMU(rParent)), _U(name))); + string childName = ns.prepend(ns.attr(e.child(DD_CMU(rChild)), _U(name))); Volume parent = ns.volume(parentName, false); Volume child = ns.volume(childName, false); diff --git a/DetectorDescription/DDCMS/src/DDNamespace.cc b/DetectorDescription/DDCMS/src/DDNamespace.cc index 3c2ccf0736375..4628633f94895 100644 --- a/DetectorDescription/DDCMS/src/DDNamespace.cc +++ b/DetectorDescription/DDCMS/src/DDNamespace.cc @@ -143,7 +143,7 @@ const dd4hep::Rotation3D& DDNamespace::rotation(const string& name) const { } dd4hep::Volume DDNamespace::addVolumeNS(dd4hep::Volume vol) const { - string n = vol.name(); + string n = prepend(vol.name()); dd4hep::Solid s = vol.solid(); dd4hep::Material m = vol.material(); vol->SetName(n.c_str()); @@ -278,3 +278,13 @@ std::vector DDNamespace::vecFloat(const std::string& name) const { } else return std::vector(); } + +std::string DDNamespace::noNamespace(const std::string& fullName) const { + std::string result(fullName); + auto n = result.find(':'); + if (n == std::string::npos) { + return result; + } else { + return result.substr(n + 1); + } +} diff --git a/DetectorDescription/DDCMS/test/DDFilteredView.find.cppunit.cc b/DetectorDescription/DDCMS/test/DDFilteredView.find.cppunit.cc index bcdca588e3607..715053549ab78 100644 --- a/DetectorDescription/DDCMS/test/DDFilteredView.find.cppunit.cc +++ b/DetectorDescription/DDCMS/test/DDFilteredView.find.cppunit.cc @@ -92,7 +92,7 @@ void testDDFilteredViewFind::checkFilteredView() { fview.goTo({0, 0, 8}); printMe(fview); - CPPUNIT_ASSERT(fview.name() == "MUON"); + CPPUNIT_ASSERT(fview.name() == "muonBase:MUON"); // Go to the first daughter fview.next(0); @@ -129,7 +129,7 @@ void testDDFilteredViewFind::checkFilteredView() { std::cout << "\n==== Let's do it again, go to Muon\n"; fview.goTo({0, 0, 8}); printMe(fview); - CPPUNIT_ASSERT(fview.name() == "MUON"); + CPPUNIT_ASSERT(fview.name() == "muonBase:MUON"); // Go to the first daughter fview.next(0); diff --git a/DetectorDescription/DDCMS/test/DDFilteredView.get.cppunit.cc b/DetectorDescription/DDCMS/test/DDFilteredView.get.cppunit.cc index 76a0590792ad3..b681726f5f0d5 100644 --- a/DetectorDescription/DDCMS/test/DDFilteredView.get.cppunit.cc +++ b/DetectorDescription/DDCMS/test/DDFilteredView.get.cppunit.cc @@ -95,7 +95,7 @@ void testDDFilteredViewGet::checkFilteredView() { fview.goTo({0, 0, 8}); printMe(fview); - CPPUNIT_ASSERT(fview.name() == "MUON"); + CPPUNIT_ASSERT(fview.name() == "muonBase:MUON"); // Go to the first daughter fview.next(0); @@ -132,7 +132,7 @@ void testDDFilteredViewGet::checkFilteredView() { std::cout << "\n==== Let's do it again, go to Muon\n"; fview.goTo({0, 0, 8}); printMe(fview); - CPPUNIT_ASSERT(fview.name() == "MUON"); + CPPUNIT_ASSERT(fview.name() == "muonBase:MUON"); // Go to the first daughter fview.next(0); diff --git a/DetectorDescription/DDCMS/test/DDFilteredView.goto.cppunit.cc b/DetectorDescription/DDCMS/test/DDFilteredView.goto.cppunit.cc index f1462b353e411..ac5769331d455 100644 --- a/DetectorDescription/DDCMS/test/DDFilteredView.goto.cppunit.cc +++ b/DetectorDescription/DDCMS/test/DDFilteredView.goto.cppunit.cc @@ -86,7 +86,7 @@ void testDDFilteredViewGoTo::checkFilteredView() { // Start with Tracker std::cout << "\n==== Let's go to Tracker\n"; fview.goTo({0, 0, 6}); - CPPUNIT_ASSERT(fview.name() == "Tracker"); + CPPUNIT_ASSERT(fview.name() == "tracker:Tracker"); printMe(fview); // Go to the first daughter @@ -123,7 +123,7 @@ void testDDFilteredViewGoTo::checkFilteredView() { std::cout << "\n==== Let's do it again, go to Tracker\n"; fview.goTo({0, 0, 6}); - CPPUNIT_ASSERT(fview.name() == "Tracker"); + CPPUNIT_ASSERT(fview.name() == "tracker:Tracker"); printMe(fview); // Go to the first daughter diff --git a/Geometry/MTDCommonData/test/DD4hep_TestMTDIdealGeometry.cc b/Geometry/MTDCommonData/test/DD4hep_TestMTDIdealGeometry.cc index 8fac42a0d9199..1bfadf41a72bf 100644 --- a/Geometry/MTDCommonData/test/DD4hep_TestMTDIdealGeometry.cc +++ b/Geometry/MTDCommonData/test/DD4hep_TestMTDIdealGeometry.cc @@ -141,10 +141,10 @@ void DD4hep_TestMTDIdealGeometry::analyze(const edm::Event& iEvent, const edm::E uint32_t level(0); do { - if (fv.name() == "BarrelTimingLayer") { + if (dd4hep::dd::noNamespace(fv.name()) == "BarrelTimingLayer") { isBarrel = true; edm::LogInfo("DD4hep_TestMTDIdealGeometry") << "isBarrel = " << isBarrel; - } else if (fv.name() == "EndcapTimingLayer") { + } else if (dd4hep::dd::noNamespace(fv.name()) == "EndcapTimingLayer") { isBarrel = false; edm::LogInfo("DD4hep_TestMTDIdealGeometry") << "isBarrel = " << isBarrel; } @@ -168,7 +168,7 @@ void DD4hep_TestMTDIdealGeometry::analyze(const edm::Event& iEvent, const edm::E write = false; exitLoop = true; } - if (fv.name() == ddTopNodeName_) { + if (dd4hep::dd::noNamespace(fv.name()) == ddTopNodeName_) { write = true; level = fv.navPos().size(); } @@ -194,7 +194,7 @@ void DD4hep_TestMTDIdealGeometry::analyze(const edm::Event& iEvent, const edm::E for (auto const& t : specs) { for (auto const& it : t.second->paths) { - if (dd4hep::dd::compareEqual(fv.name(), dd4hep::dd::realTopName(it))) { + if (dd4hep::dd::compareEqual(dd4hep::dd::noNamespace(fv.name()), dd4hep::dd::realTopName(it))) { isSens = true; break; } diff --git a/Geometry/TrackerCommonData/plugins/dd4hep/DDTECModuleAlgo.cc b/Geometry/TrackerCommonData/plugins/dd4hep/DDTECModuleAlgo.cc index 90bea5e91b823..fd30748af1b04 100644 --- a/Geometry/TrackerCommonData/plugins/dd4hep/DDTECModuleAlgo.cc +++ b/Geometry/TrackerCommonData/plugins/dd4hep/DDTECModuleAlgo.cc @@ -164,7 +164,7 @@ static long algorithm(Detector& /* description */, cms::DDParsingContext& ctxt, tag = "Stereo"; //usefull constants const double topFrameEndZ = 0.5 * (-waferPosition + fullHeight) + pitchHeight + hybridHeight - topFrameHeight; - string idName = ns.prepend(ns.realName(mother.name())); + string idName = ns.noNamespace(mother.name()); edm::LogVerbatim("TECGeom") << "idName: " << idName << " parent " << mother.name() << " namespace " << ns.name(); Solid solid; diff --git a/Geometry/TrackerCommonData/plugins/dd4hep/DDTrackerZPosAlgo.cc b/Geometry/TrackerCommonData/plugins/dd4hep/DDTrackerZPosAlgo.cc index 5d3c8450d7060..59a2e07564480 100644 --- a/Geometry/TrackerCommonData/plugins/dd4hep/DDTrackerZPosAlgo.cc +++ b/Geometry/TrackerCommonData/plugins/dd4hep/DDTrackerZPosAlgo.cc @@ -1,7 +1,6 @@ #include "DD4hep/DetFactoryHelper.h" #include "DetectorDescription/DDCMS/interface/DDPlugins.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "FWCore/MessageLogger/interface/MessageLogger.h" using namespace std; using namespace dd4hep;