diff --git a/DDCore/include/DD4hep/VolumeManager.h b/DDCore/include/DD4hep/VolumeManager.h index 536d886ef872434dca1eadf0b2a1e1827ae027eb..3813efa5c20478c7174b4f9e38368ed8c5c1289d 100644 --- a/DDCore/include/DD4hep/VolumeManager.h +++ b/DDCore/include/DD4hep/VolumeManager.h @@ -71,7 +71,9 @@ namespace dd4hep { /// Default destructor virtual ~VolumeManagerContext(); /// Acces the sensitive volume placement - PlacedVolume placement() const; + PlacedVolume volumePlacement() const; + /// Acces the detector element volume placement + PlacedVolume elementPlacement() const; /// Access the transformation to the closest detector element const TGeoHMatrix& toElement() const; }; @@ -180,7 +182,9 @@ namespace dd4hep { /// Lookup the context, which belongs to a registered physical volume. VolumeManagerContext* lookupContext(VolumeID volume_id) const; /// Lookup a physical (placed) volume identified by its 64 bit hit ID - PlacedVolume lookupPlacement(VolumeID volume_id) const; + PlacedVolume lookupVolumePlacement(VolumeID volume_id) const; + /// Lookup a physical (placed) volume of the detector element containing a volume identified by its 64 bit hit ID + PlacedVolume lookupDetElementPlacement(VolumeID volume_id) const; /// Convenience routine: Lookup a top level subdetector detector element according to a contained 64 bit hit ID DetElement lookupDetector(VolumeID volume_id) const; /// Convenience routine: Lookup the closest subdetector detector element in the hierarchy according to a contained 64 bit hit ID diff --git a/DDCore/src/VolumeManager.cpp b/DDCore/src/VolumeManager.cpp index af25a90d1560385ab6274b6e42a0c285365b795e..9cbf7229649e5e18fc15df605843f80a5acbf134 100644 --- a/DDCore/src/VolumeManager.cpp +++ b/DDCore/src/VolumeManager.cpp @@ -346,7 +346,7 @@ namespace dd4hep { context->element = e; if ( nodes.size() > 0 ) { ContextExtension* ext = new(_getExtension(context)) ContextExtension(); - context->flag=1; + context->flag = 1; ext->placement = PlacedVolume(n); for (size_t i = nodes.size(); i > 1; --i) { // Omit the placement of the parent DetElement TGeoMatrix* m = nodes[i-1]->GetMatrix(); @@ -384,7 +384,7 @@ namespace dd4hep { printout(m_debug ? INFO : DEBUG, "VolumeManager", log.str().c_str()); } }; - } /* End namespace detail */ + } /* End namespace detail */ } /* End namespace dd4hep */ /// Default destructor @@ -394,14 +394,21 @@ VolumeManagerContext::~VolumeManagerContext() { } /// Acces the sensitive volume placement -PlacedVolume VolumeManagerContext::placement() const { - return (0 == flag ) ? element.placement() : _getExtension(this)->placement; +PlacedVolume VolumeManagerContext::elementPlacement() const { + return element.placement(); +} + +/// Acces the sensitive volume placement +PlacedVolume VolumeManagerContext::volumePlacement() const { + if ( 0 == flag ) + return element.placement(); + return _getExtension(this)->placement; } /// Access the transformation to the closest detector element const TGeoHMatrix& VolumeManagerContext::toElement() const { static TGeoHMatrix identity; - return (0 == flag ) ? identity : _getExtension(this)->toElement; + return ( 0 == flag ) ? identity : _getExtension(this)->toElement; } /// Initializing constructor to create a new object @@ -412,8 +419,8 @@ VolumeManager::VolumeManager(Detector& description, const string& nam, DetElemen if (elt.isValid()) { detail::VolumeManager_Populator p(description, *this); obj_ptr->detector = elt; - obj_ptr->id = ro.isValid() ? ro.idSpec() : IDDescriptor(); - obj_ptr->top = obj_ptr; + obj_ptr->id = ro.isValid() ? ro.idSpec() : IDDescriptor(); + obj_ptr->top = obj_ptr; obj_ptr->flags = flags; p.populate(elt); } @@ -523,7 +530,7 @@ bool VolumeManager::adoptPlacement(VolumeID /* sys_id */, VolumeManagerContext* Object& o = _data(); VolumeID vid = context->identifier; VolumeID mask = context->mask; - PlacedVolume pv = context->placement(); + PlacedVolume pv = context->elementPlacement(); auto i = o.volumes.find(vid); if ( (vid&mask) != vid ) { @@ -640,9 +647,15 @@ VolumeManagerContext* VolumeManager::lookupContext(VolumeID volume_id) const { } /// Lookup a physical (placed) volume identified by its 64 bit hit ID -PlacedVolume VolumeManager::lookupPlacement(VolumeID volume_id) const { +PlacedVolume VolumeManager::lookupDetElementPlacement(VolumeID volume_id) const { + VolumeManagerContext* c = lookupContext(volume_id); // Throws exception if not found! + return c->elementPlacement(); +} + +/// Lookup a physical (placed) volume identified by its 64 bit hit ID +PlacedVolume VolumeManager::lookupVolumePlacement(VolumeID volume_id) const { VolumeManagerContext* c = lookupContext(volume_id); // Throws exception if not found! - return c->placement(); + return c->volumePlacement(); } /// Lookup a top level subdetector detector element according to a contained 64 bit hit ID @@ -704,7 +717,7 @@ std::ostream& dd4hep::operator<<(std::ostream& os, const VolumeManager& m) { const VolumeManagerContext* c = i.second; os << prefix << "Element:" << setw(32) << left << c->element.path() - << " pv:" << setw(32) << left << c->placement().name() + //<< " pv:" << setw(32) << left << c->placement().name() << " id:" << setw(18) << left << (void*) c->identifier << " mask:" << setw(18) << left << (void*) c->mask << endl; diff --git a/DDCore/src/VolumeManagerInterna.cpp b/DDCore/src/VolumeManagerInterna.cpp index fa461b1fa45877aed0d525bd2fc1df2ff1d42462..a01d1ef31b3446f2bdf80a93bc2e361dac700a36 100644 --- a/DDCore/src/VolumeManagerInterna.cpp +++ b/DDCore/src/VolumeManagerInterna.cpp @@ -39,7 +39,7 @@ void VolumeManagerObject::update(unsigned long tags, DetElement& det, void* para printout(DEBUG,"VolumeManager","+++ Alignment update %s param:%p",det.path().c_str(),param); for(const auto& i : volumes ) - printout(DEBUG,"VolumeManager","+++ Alignment update %s",i.second->placement().name()); + printout(DEBUG,"VolumeManager","+++ Alignment update %s",i.second->elementPlacement().name()); } /// Search the locally cached volumes for a matching ID diff --git a/DDCore/src/plugins/VolumeMgrTest.cpp b/DDCore/src/plugins/VolumeMgrTest.cpp index 61420c10375860bdd96d193bc19c9ff34af25b14..11d856566bcc733389f01bda9a56f21334d71aa7 100644 --- a/DDCore/src/plugins/VolumeMgrTest.cpp +++ b/DDCore/src/plugins/VolumeMgrTest.cpp @@ -112,7 +112,7 @@ void VolIDTest::checkVolume(DetElement detector, PlacedVolume pv, const VolIDs& mgr_ctxt = m_mgr.lookupContext(vid); if ( pv.volume().isSensitive() ) { - PlacedVolume det_place = m_mgr.lookupPlacement(vid); + PlacedVolume det_place = m_mgr.lookupDetElementPlacement(vid); if ( pv.ptr() != det_place.ptr() ) { err << "VolumeMgrTest: Wrong placement " << " got " << det_place.name() << " (" << (void*)det_place.ptr() << ")" diff --git a/DDG4/src/Geant4DataConversion.cpp b/DDG4/src/Geant4DataConversion.cpp index bcb7fe2a9ec0028e05f0c0b2116c9b8e3341b406..b1982dffcfccfdd737f89bb2b2b5d32aba565ee2 100644 --- a/DDG4/src/Geant4DataConversion.cpp +++ b/DDG4/src/Geant4DataConversion.cpp @@ -26,7 +26,7 @@ Geant4ConversionHelper::~Geant4ConversionHelper() { /// Access to the data encoding using the volume manager and a specified volume id std::string Geant4ConversionHelper::encoding(VolumeManager vm, VolumeID vid) { - PlacedVolume pv = vm.lookupPlacement(vid); + PlacedVolume pv = vm.lookupVolumePlacement(vid); SensitiveDetector sd = pv.volume().sensitiveDetector(); return encoding(sd); } diff --git a/DDRec/src/IDDecoder.cpp b/DDRec/src/IDDecoder.cpp index 85a2ecbcf4325394fdeb0c8b862aeeff82a1b60a..7dd175a345649faf257d6d88960dcb53cc8c0066 100644 --- a/DDRec/src/IDDecoder.cpp +++ b/DDRec/src/IDDecoder.cpp @@ -104,7 +104,7 @@ VolumeID IDDecoder::volumeID(const Position& pos) const { * Returns the placement for a given cell ID */ PlacedVolume IDDecoder::placement(const CellID& cell) const { - return _volumeManager.lookupPlacement(cell); + return _volumeManager.lookupVolumePlacement(cell); } /*