From b88d10a9009faf6ab31b8fa74fcbb52e0e9634cf Mon Sep 17 00:00:00 2001 From: Ianna Osborne Date: Tue, 28 Jan 2020 12:01:13 +0100 Subject: [PATCH 1/2] Provide access to a current iterator path and its volume copy numbers --- .../DDCMS/interface/DDFilteredView.h | 7 ++++++ .../DDCMS/src/DDFilteredView.cc | 25 +++++++++++++++++++ .../DDCMS/test/DDFilteredView.cppunit.cc | 2 ++ 3 files changed, 34 insertions(+) diff --git a/DetectorDescription/DDCMS/interface/DDFilteredView.h b/DetectorDescription/DDCMS/interface/DDFilteredView.h index 941e51149f440..65c2aea802f19 100644 --- a/DetectorDescription/DDCMS/interface/DDFilteredView.h +++ b/DetectorDescription/DDCMS/interface/DDFilteredView.h @@ -66,6 +66,13 @@ namespace cms { //! The physical volume of the current node const PlacedVolume volume() const; + //! The full path to the current node + const std::string path() const; + + //! The list of the volume copy numbers + // along the full path to the current node + const std::vector copyNos() const; + //! The absolute translation of the current node // Return value is Double_t translation[3] with x, y, z elements. const Double_t* trans() const; diff --git a/DetectorDescription/DDCMS/src/DDFilteredView.cc b/DetectorDescription/DDCMS/src/DDFilteredView.cc index 76b187e7badde..4dea63624b52a 100644 --- a/DetectorDescription/DDCMS/src/DDFilteredView.cc +++ b/DetectorDescription/DDCMS/src/DDFilteredView.cc @@ -68,6 +68,31 @@ const PlacedVolume DDFilteredView::volume() const { return PlacedVolume(node_); } +// +// This should be used for debug purpose only +// +const std::string +DDFilteredView::path() const { + TString fullPath; + it_.back().GetPath(fullPath); + return std::string(fullPath.Data()); +} + +// +// The vector is filled from bottom up: +// result[0] contains the current node copy number +// +const std::vector +DDFilteredView::copyNos() const { + std::vector result; + + for( int i = it_.back().GetLevel(); i > 0; --i ) { + result.emplace_back(it_.back().GetNode(i)->GetNumber()); + } + + return result; +} + const Double_t* DDFilteredView::trans() const { return it_.back().GetCurrentMatrix()->GetTranslation(); } const Translation DDFilteredView::translation() const { diff --git a/DetectorDescription/DDCMS/test/DDFilteredView.cppunit.cc b/DetectorDescription/DDCMS/test/DDFilteredView.cppunit.cc index 745beb98bab4f..7d6d72c6a2262 100644 --- a/DetectorDescription/DDCMS/test/DDFilteredView.cppunit.cc +++ b/DetectorDescription/DDCMS/test/DDFilteredView.cppunit.cc @@ -68,6 +68,8 @@ void testDDFilteredView::checkFilteredView() { DDFilteredView fview(det.get(), det->description()->worldVolume()); fview.next(0); std::cout << fview.name() << " is a " << cms::dd::name(cms::DDSolidShapeMap, fview.shape()) << "\n"; + std::cout << "Full path to it is " << fview.path() << "\n"; + auto copyNos = fview.copyNos(); if (fview.isA()) cout << "It's a Box\n"; fview.parent(); From 3fdff9381a6edeaef0a8d35d47781926148d2c94 Mon Sep 17 00:00:00 2001 From: Ianna Osborne Date: Tue, 28 Jan 2020 12:04:12 +0100 Subject: [PATCH 2/2] code format --- DetectorDescription/DDCMS/src/DDFilteredView.cc | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/DetectorDescription/DDCMS/src/DDFilteredView.cc b/DetectorDescription/DDCMS/src/DDFilteredView.cc index 4dea63624b52a..2211eaebb08d9 100644 --- a/DetectorDescription/DDCMS/src/DDFilteredView.cc +++ b/DetectorDescription/DDCMS/src/DDFilteredView.cc @@ -68,11 +68,10 @@ const PlacedVolume DDFilteredView::volume() const { return PlacedVolume(node_); } -// +// // This should be used for debug purpose only // -const std::string -DDFilteredView::path() const { +const std::string DDFilteredView::path() const { TString fullPath; it_.back().GetPath(fullPath); return std::string(fullPath.Data()); @@ -82,14 +81,13 @@ DDFilteredView::path() const { // The vector is filled from bottom up: // result[0] contains the current node copy number // -const std::vector -DDFilteredView::copyNos() const { +const std::vector DDFilteredView::copyNos() const { std::vector result; - for( int i = it_.back().GetLevel(); i > 0; --i ) { + for (int i = it_.back().GetLevel(); i > 0; --i) { result.emplace_back(it_.back().GetNode(i)->GetNumber()); } - + return result; }