From 607787585eff5d52b73fff3e1b54d00fe2d25981 Mon Sep 17 00:00:00 2001 From: Izaac Sanderswood <izaac.sanderswood@cern.ch> Date: Thu, 1 Aug 2024 13:15:02 +0200 Subject: [PATCH 1/2] make sure there is a TGeoNavigator per thread before calling Contains --- Core/src/DeIOV.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Core/src/DeIOV.cpp b/Core/src/DeIOV.cpp index 7fd79a4b3..2c79cae66 100644 --- a/Core/src/DeIOV.cpp +++ b/Core/src/DeIOV.cpp @@ -27,6 +27,9 @@ #include <sstream> #include <vector> +#include "TGeoManager.h" +#include "TGeoNavigator.h" + using lhcb::geometrytools::toTransform3D; /// Initialization of sub-classes @@ -115,6 +118,12 @@ void LHCb::Detector::detail::DeIOVObject::print( int indent, int flg ) const { bool LHCb::Detector::detail::DeIOVObject::isInside( const ROOT::Math::XYZPoint& globalPoint ) const { auto localPoint = toLocal( globalPoint ); Double_t p[3]{toDD4hepUnits( localPoint.x() ), toDD4hepUnits( localPoint.y() ), toDD4hepUnits( localPoint.z() )}; + // Geometry navigation requires thread local navigators + // manager.SetMaxThreads(n_threads) should be set once the geometry is locked in the initialisation of DD4hepSvc + // then you need to check there is a TGeoNavigator for the thread + auto& manager = dd4hep::Detector::getInstance().manager(); + TGeoNavigator* nav = manager.GetCurrentNavigator(); + if ( !nav ) nav = manager.AddNavigator(); return detector().solid()->Contains( p ); } -- GitLab From 45cf76fb534e41559702f675121c5d6dae3e6161 Mon Sep 17 00:00:00 2001 From: Izaac Sanderswood <izaac.sanderswood@cern.ch> Date: Wed, 7 Aug 2024 15:28:55 +0200 Subject: [PATCH 2/2] add assert to TGeoNavigator check --- Core/src/DeIOV.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Core/src/DeIOV.cpp b/Core/src/DeIOV.cpp index 2c79cae66..7f03de5bb 100644 --- a/Core/src/DeIOV.cpp +++ b/Core/src/DeIOV.cpp @@ -124,6 +124,7 @@ bool LHCb::Detector::detail::DeIOVObject::isInside( const ROOT::Math::XYZPoint& auto& manager = dd4hep::Detector::getInstance().manager(); TGeoNavigator* nav = manager.GetCurrentNavigator(); if ( !nav ) nav = manager.AddNavigator(); + assert( nav != nullptr ); return detector().solid()->Contains( p ); } -- GitLab