Skip to content

Commit

Permalink
Merge pull request #31934 from ianna/dd4hep-namespaces-dt-test-fix-v1
Browse files Browse the repository at this point in the history
[DD4hep] do not use namespace for navigation
  • Loading branch information
cmsbuild authored Oct 26, 2020
2 parents 272967e + 8c8c048 commit f403722
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 9 deletions.
3 changes: 3 additions & 0 deletions DetectorDescription/DDCMS/interface/DDFilteredView.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
8 changes: 6 additions & 2 deletions DetectorDescription/DDCMS/src/DDFilteredView.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
}
Expand Down Expand Up @@ -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()));
}

Expand Down
4 changes: 2 additions & 2 deletions DetectorDescription/DDCMS/test/DDFilteredView.find.cppunit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions DetectorDescription/DDCMS/test/DDFilteredView.get.cppunit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions DetectorDescription/DDCMS/test/DDFilteredView.goto.cppunit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit f403722

Please sign in to comment.