From f276c9b1586fc2660cbbc4a328405c2dc3b1643e Mon Sep 17 00:00:00 2001 From: Markus Frank <markus.frank@cern.ch> Date: Thu, 23 Jan 2014 16:59:18 +0000 Subject: [PATCH] Fix backwards compatibility problem using the Volume and Placement extesion mechanism of ROOT. --- DDCore/src/Volumes.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/DDCore/src/Volumes.cpp b/DDCore/src/Volumes.cpp index 8ecbf19e4..a45a3e003 100644 --- a/DDCore/src/Volumes.cpp +++ b/DDCore/src/Volumes.cpp @@ -279,13 +279,23 @@ TGeoVolume* _createTGeoVolumeAssembly(const string& name) { return new Value<TGeoVolumeAssembly,Assembly::Object>(name.c_str()); } PlacedVolume::Object* _userExtension(const PlacedVolume& v) { - geo_node_t* n = (geo_node_t*)v.ptr(); - return (PlacedVolume::Object*)n->m_extension; + geo_node_t* n = dynamic_cast<geo_node_t*>(v.ptr()); + // The above dynamic_cast fails for the top-level volume, where the placement is set by the + // TGeoManager. This volume will not have a placement.... + return (PlacedVolume::Object*)(n ? n->m_extension : 0); } template <typename T> static typename T::Object* _userExtension(const T& v) { return dynamic_cast<typename T::Object*>(v.ptr()); } #else + +/* + * The section below uses the new ROOT features using user extensions to volumes + * and placements. Once this is common, the above mechanism should be thrown away.... + * + * M.Frank + */ + typedef TGeoNode geo_node_t; TGeoVolume* _createTGeoVolume(const string& name, TGeoShape* s, TGeoMedium* m) { TGeoVolume* e = new TGeoVolume(name.c_str(),s,m); -- GitLab