From 78a8d9ee70839927c7f7d401e1de1a739d406c55 Mon Sep 17 00:00:00 2001 From: lintao <lintao@ihep.ac.cn> Date: Wed, 25 Sep 2024 18:23:33 +0800 Subject: [PATCH] Fix the issue when there is no tracker_region_rmax and tracker_region_zmax --- Simulation/DetSimAna/src/Edm4hepWriterAnaElemTool.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Simulation/DetSimAna/src/Edm4hepWriterAnaElemTool.cpp b/Simulation/DetSimAna/src/Edm4hepWriterAnaElemTool.cpp index 76abc3de..ff61a5f5 100644 --- a/Simulation/DetSimAna/src/Edm4hepWriterAnaElemTool.cpp +++ b/Simulation/DetSimAna/src/Edm4hepWriterAnaElemTool.cpp @@ -30,9 +30,13 @@ Edm4hepWriterAnaElemTool::BeginOfRunAction(const G4Run*) { m_geosvc = service<IGeomSvc>("GeomSvc"); if (m_geosvc) { dd4hep::Detector* dd4hep_geo = m_geosvc->lcdd(); - // try to get the constants - R = dd4hep_geo->constant<double>("tracker_region_rmax")/dd4hep::mm*CLHEP::mm; - Z = dd4hep_geo->constant<double>("tracker_region_zmax")/dd4hep::mm*CLHEP::mm; + try { + // try to get the constants + R = dd4hep_geo->constant<double>("tracker_region_rmax")/dd4hep::mm*CLHEP::mm; + Z = dd4hep_geo->constant<double>("tracker_region_zmax")/dd4hep::mm*CLHEP::mm; + } catch (std::runtime_error&e) { + warning() << "constant tracker_region_rmax and tracker_region_zmax is not defined. " << endmsg; + } info() << "Tracker Region " << " R: " << R -- GitLab