From 98b0f9c713a1f4b44979e36fc590a49e70faaff2 Mon Sep 17 00:00:00 2001
From: Shaun Roe <shaun.roe@cern.ch>
Date: Wed, 12 Feb 2025 16:24:47 +0100
Subject: [PATCH] catch divide by zero

---
 .../MuonCondDump/src/MdtCalibJsonDumpAlg.cxx                | 6 +++++-
 .../MuonCondGeneral/MuonCondDump/src/MdtCondJsonDumpAlg.cxx | 2 +-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/MuonSpectrometer/MuonConditions/MuonCondGeneral/MuonCondDump/src/MdtCalibJsonDumpAlg.cxx b/MuonSpectrometer/MuonConditions/MuonCondGeneral/MuonCondDump/src/MdtCalibJsonDumpAlg.cxx
index 37a0613269a5..7424f9f95a56 100644
--- a/MuonSpectrometer/MuonConditions/MuonCondGeneral/MuonCondDump/src/MdtCalibJsonDumpAlg.cxx
+++ b/MuonSpectrometer/MuonConditions/MuonCondGeneral/MuonCondDump/src/MdtCalibJsonDumpAlg.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
 */
 #include "MdtCalibJsonDumpAlg.h"
 #include "StoreGate/ReadCondHandle.h"
@@ -129,6 +129,10 @@ namespace Muon {
         for (const auto&[chId, t0Channels] : t0Groups) {
             t0GrpCounter+=t0Channels.size();
         }
+        if ((rtCounter == 0) or (t0Counter == 0)){
+          ATH_MSG_ERROR("MdtCalibJsonDumpAlg::execute: Counter is zero in numerator");
+          return StatusCode::FAILURE;
+        }
         ATH_MSG_INFO(std::format("Grouped {:d} / {:d} ({:.2f}%) rt relations &  {:d}/ {:d}  ({:.2f}%) t0 calibration constants",
                         rtGroups.size(), rtCounter, (100.* rtGroups.size() / rtCounter), 
                         t0GrpCounter, t0Counter,(100.*t0GrpCounter / t0Counter)));
diff --git a/MuonSpectrometer/MuonConditions/MuonCondGeneral/MuonCondDump/src/MdtCondJsonDumpAlg.cxx b/MuonSpectrometer/MuonConditions/MuonCondGeneral/MuonCondDump/src/MdtCondJsonDumpAlg.cxx
index 6245acba28b9..f9c64409c4a7 100644
--- a/MuonSpectrometer/MuonConditions/MuonCondGeneral/MuonCondDump/src/MdtCondJsonDumpAlg.cxx
+++ b/MuonSpectrometer/MuonConditions/MuonCondGeneral/MuonCondDump/src/MdtCondJsonDumpAlg.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
 */
 
 #include "MdtCondJsonDumpAlg.h"
-- 
GitLab