Skip to content

Commit

Permalink
Merge pull request #28809 from ianna/dd4hep-dd-filtered-view-api-upda…
Browse files Browse the repository at this point in the history
…te-v1

[DD4hep] DDFilteredView current volume path and its copy numbers
  • Loading branch information
cmsbuild authored Jan 29, 2020
2 parents 53165eb + 3fdff93 commit d0daeae
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
7 changes: 7 additions & 0 deletions DetectorDescription/DDCMS/interface/DDFilteredView.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<int> 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;
Expand Down
23 changes: 23 additions & 0 deletions DetectorDescription/DDCMS/src/DDFilteredView.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,29 @@ 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<int> DDFilteredView::copyNos() const {
std::vector<int> 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 {
Expand Down
2 changes: 2 additions & 0 deletions DetectorDescription/DDCMS/test/DDFilteredView.cppunit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<dd4hep::Box>())
cout << "It's a Box\n";
fview.parent();
Expand Down

0 comments on commit d0daeae

Please sign in to comment.