Skip to content
Snippets Groups Projects

Make sure there is a TGeoNavigator per thread before calling Contains

Merged Izaac Sanderswood requested to merge isanders-fix-mt-nav into master
+ 10
0
@@ -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,13 @@ 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();
+2
if ( !nav ) nav = manager.AddNavigator();
assert( nav != nullptr );
return detector().solid()->Contains( p );
}
Loading