Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DD4hep] DDFilteredView current volume path and its copy numbers #28809

Merged
merged 2 commits into from
Jan 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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