diff --git a/DDCore/include/DD4hep/Volumes.h b/DDCore/include/DD4hep/Volumes.h index 5527892e9fd3663ec46c2e375419f302f2248ad4..e79b1b135ef18739466b7560301cac3052a45fc7 100644 --- a/DDCore/include/DD4hep/Volumes.h +++ b/DDCore/include/DD4hep/Volumes.h @@ -264,6 +264,8 @@ namespace dd4hep { /// Check if placement is properly instrumented Object* data() const; + /// Access the object type from the class information + const char* type() const; /// Access the copy number of this placement within its mother int copyNumber() const; /// Volume material @@ -272,6 +274,10 @@ namespace dd4hep { Volume volume() const; /// Parent volume (envelope) Volume motherVol() const; + /// Number of daughters placed in this volume + std::size_t num_daughters() const; + /// Access the daughter by index + PlacedVolume daughter(std::size_t which) const; /// Access the full transformation matrix to the parent volume const TGeoMatrix& matrix() const; /// Access the translation vector to the parent volume @@ -427,6 +433,9 @@ namespace dd4hep { /// Check if placement is properly instrumented Object* data() const; + /// Access the object type from the class information + const char* type() const; + /// Create a reflected volume tree. The reflected volume has left-handed coordinates Volume reflect() const; @@ -634,7 +643,7 @@ namespace dd4hep { /// Test if this volume is an assembly structure bool isAssembly() const; - + /// Set the volume's option value const Volume& setOption(const std::string& opt) const; /// Access the volume's option value diff --git a/DDCore/src/Volumes.cpp b/DDCore/src/Volumes.cpp index 8ea95078eab8d97c3988124b9479f35c235594e5..e7e3f18b56222d783126141b2e3fdcd97e45ed49 100644 --- a/DDCore/src/Volumes.cpp +++ b/DDCore/src/Volumes.cpp @@ -436,6 +436,11 @@ PlacedVolume::Object* PlacedVolume::data() const { return o; } +/// Access the object type from the class information +const char* PlacedVolume::type() const { + return m_element ? m_element->IsA()->GetName() : "UNKNOWN-PlacedVolume"; +} + /// Access the copy number of this placement within its mother int PlacedVolume::copyNumber() const { return m_element ? m_element->GetNumber() : -1; @@ -456,6 +461,24 @@ Volume PlacedVolume::motherVol() const { return Volume(m_element ? m_element->GetMotherVolume() : 0); } +/// Number of daughters placed in this volume +std::size_t PlacedVolume::num_daughters() const { + return m_element ? m_element->GetNdaughters() : 0; +} + +/// Access the daughter by index +PlacedVolume PlacedVolume::daughter(std::size_t which) const { + if ( m_element ) { + if ( which < (std::size_t)m_element->GetNdaughters() ) { + return m_element->GetDaughter(which); + } + except("Volume","+++ Access daughter %ld of %s [Has only %d daughters]", + which, m_element->GetName(), m_element->GetNdaughters()); + } + except("Volume","+++ Cannot access daughters of a non-existing volume!"); + return nullptr; +} + /// Access to the volume IDs const PlacedVolume::VolIDs& PlacedVolume::volIDs() const { return _data(*this)->volIDs; @@ -623,6 +646,11 @@ Volume::Object* Volume::data() const { return o; } +/// Access the object type from the class information +const char* Volume::type() const { + return m_element ? m_element->IsA()->GetName() : "UNKNOWN-Volume"; +} + /// Create a reflected volume tree. The reflected volume has left-handed coordinates Volume Volume::reflect() const { return this->reflect(this->sensitiveDetector());