From 32431b79184b362e52b63ca098bf693bff8ccb31 Mon Sep 17 00:00:00 2001 From: Ianna Osborne Date: Sun, 25 Oct 2020 16:08:30 +0100 Subject: [PATCH 1/2] do not use namespace for navigation --- DetectorDescription/DDCMS/src/DDFilteredView.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DetectorDescription/DDCMS/src/DDFilteredView.cc b/DetectorDescription/DDCMS/src/DDFilteredView.cc index 04febf2136a10..1b4874af9b6f6 100644 --- a/DetectorDescription/DDCMS/src/DDFilteredView.cc +++ b/DetectorDescription/DDCMS/src/DDFilteredView.cc @@ -455,7 +455,7 @@ bool DDFilteredView::sibling() { it_.back().SetType(1); Node* node = nullptr; while ((node = it_.back().Next())) { - if (dd4hep::dd::accepted(currentFilter_, node->GetVolume()->GetName())) { + if (dd4hep::dd::accepted(currentFilter_, noNamespace(node->GetVolume()->GetName()))) { node_ = node; return true; } @@ -471,7 +471,7 @@ bool DDFilteredView::checkChild() { it_.back().SetType(1); Node* node = nullptr; while ((node = it_.back().Next())) { - if (dd4hep::dd::accepted(currentFilter_, node->GetVolume()->GetName())) { + if (dd4hep::dd::accepted(currentFilter_, noNamespace(node->GetVolume()->GetName()))) { return true; } } From 8c8c0485a9169b7005033e7b59b47313da2d5e05 Mon Sep 17 00:00:00 2001 From: Ianna Osborne Date: Sun, 25 Oct 2020 17:18:29 +0100 Subject: [PATCH 2/2] add fullName that returns a current node name with a namespace --- DetectorDescription/DDCMS/interface/DDFilteredView.h | 3 +++ DetectorDescription/DDCMS/src/DDFilteredView.cc | 4 ++++ DetectorDescription/DDCMS/test/DDFilteredView.find.cppunit.cc | 4 ++-- DetectorDescription/DDCMS/test/DDFilteredView.get.cppunit.cc | 4 ++-- DetectorDescription/DDCMS/test/DDFilteredView.goto.cppunit.cc | 4 ++-- .../MTDNumberingBuilder/test/DD4hep_MTDTopologyAnalyzer.cc | 2 +- 6 files changed, 14 insertions(+), 7 deletions(-) diff --git a/DetectorDescription/DDCMS/interface/DDFilteredView.h b/DetectorDescription/DDCMS/interface/DDFilteredView.h index 38fc916db11be..333c21904a06a 100644 --- a/DetectorDescription/DDCMS/interface/DDFilteredView.h +++ b/DetectorDescription/DDCMS/interface/DDFilteredView.h @@ -144,6 +144,9 @@ namespace cms { // Name of current node std::string_view name() const; + // Name of current node with namespace + std::string_view fullName() const; + // Copy number of current node unsigned short copyNum() const; diff --git a/DetectorDescription/DDCMS/src/DDFilteredView.cc b/DetectorDescription/DDCMS/src/DDFilteredView.cc index 1b4874af9b6f6..93da987955292 100644 --- a/DetectorDescription/DDCMS/src/DDFilteredView.cc +++ b/DetectorDescription/DDCMS/src/DDFilteredView.cc @@ -856,6 +856,10 @@ double DDFilteredView::getNextValue(const std::string& key) const { } std::string_view DDFilteredView::name() const { + return (node_ == nullptr ? std::string_view() : (dd4hep::dd::noNamespace(volume().volume().name()))); +} + +std::string_view DDFilteredView::fullName() const { return (node_ == nullptr ? std::string_view() : (volume().volume().name())); } diff --git a/DetectorDescription/DDCMS/test/DDFilteredView.find.cppunit.cc b/DetectorDescription/DDCMS/test/DDFilteredView.find.cppunit.cc index 715053549ab78..0418be93d9b1a 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() == "muonBase:MUON"); + CPPUNIT_ASSERT(fview.fullName() == "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() == "muonBase:MUON"); + CPPUNIT_ASSERT(fview.name() == "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 b681726f5f0d5..bea43d8d940f6 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() == "muonBase:MUON"); + CPPUNIT_ASSERT(fview.fullName() == "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() == "muonBase:MUON"); + CPPUNIT_ASSERT(fview.name() == "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 ac5769331d455..6767590448957 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:Tracker"); + CPPUNIT_ASSERT(fview.fullName() == "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:Tracker"); + CPPUNIT_ASSERT(fview.name() == "Tracker"); printMe(fview); // Go to the first daughter diff --git a/Geometry/MTDNumberingBuilder/test/DD4hep_MTDTopologyAnalyzer.cc b/Geometry/MTDNumberingBuilder/test/DD4hep_MTDTopologyAnalyzer.cc index d16aac25d1390..83e2ef94d716e 100644 --- a/Geometry/MTDNumberingBuilder/test/DD4hep_MTDTopologyAnalyzer.cc +++ b/Geometry/MTDNumberingBuilder/test/DD4hep_MTDTopologyAnalyzer.cc @@ -212,7 +212,7 @@ void DD4hep_MTDTopologyAnalyzer::theBaseNumber(cms::DDFilteredView& fv) { thisN_.setSize(fv.copyNos().size()); for (uint ii = 0; ii < fv.copyNos().size(); ii++) { - std::string name((fv.geoHistory()[ii])->GetName()); + std::string name(dd4hep::dd::noNamespace((fv.geoHistory()[ii])->GetName())); name.assign(name.erase(name.rfind('_'))); int copyN(fv.copyNos()[ii]); thisN_.addLevel(name, copyN);