From 3091b9f71cf0cb5bb9e05aae00a2411e60e06f84 Mon Sep 17 00:00:00 2001 From: Manuel Huber Date: Fri, 20 Dec 2024 17:56:13 +0100 Subject: [PATCH] only store G4TouchableHandle if visualization is enabled --- src/RMGOpticalDetector.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/RMGOpticalDetector.cc b/src/RMGOpticalDetector.cc index 9c29c5f2..038fd851 100644 --- a/src/RMGOpticalDetector.cc +++ b/src/RMGOpticalDetector.cc @@ -43,7 +43,7 @@ void RMGOpticalDetectorHit::Print() { void RMGOpticalDetectorHit::Draw() { const auto vis_man = G4VVisManager::GetConcreteInstance(); - if (!vis_man) return; + if (!vis_man || !detector_touchable) return; auto lv_va = detector_touchable->GetVolume()->GetLogicalVolume()->GetVisAttributes(); G4VisAttributes va; @@ -120,7 +120,7 @@ bool RMGOpticalDetector::ProcessHits(G4Step* step, G4TouchableHistory* /*history // initialize hit object for uid, if not already there auto* hit = new RMGOpticalDetectorHit(); - hit->detector_touchable = touchable; + if (G4VVisManager::GetConcreteInstance()) { hit->detector_touchable = touchable; } hit->detector_uid = det_uid; hit->photon_wavelength = CLHEP::c_light * CLHEP::h_Planck / step->GetTotalEnergyDeposit(); hit->global_time = step->GetPostStepPoint()->GetGlobalTime();