From 87e74fb80b241c2da34e0359147edf536e13fd53 Mon Sep 17 00:00:00 2001 From: Jean-Marco Alameddine Date: Wed, 31 Jan 2024 12:46:39 +0100 Subject: [PATCH] Harmonize error treatment of PropagationUtility::GetUpperLim Fixes #387 --- .../propagation_utility/PropagationUtilityIntegral.cxx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/PROPOSAL/detail/PROPOSAL/propagation_utility/PropagationUtilityIntegral.cxx b/src/PROPOSAL/detail/PROPOSAL/propagation_utility/PropagationUtilityIntegral.cxx index 1d572d70c..4625857a0 100644 --- a/src/PROPOSAL/detail/PROPOSAL/propagation_utility/PropagationUtilityIntegral.cxx +++ b/src/PROPOSAL/detail/PROPOSAL/propagation_utility/PropagationUtilityIntegral.cxx @@ -26,7 +26,11 @@ double UtilityIntegral::GetUpperLimit(double energy_initial, double rnd) auto sum = integral.IntegrateWithRandomRatio( energy_initial, lower_lim, FunctionToIntegral, 4, -rnd); - assert(sum > rnd); // searched energy is below lower_lim + if (rnd > sum) { + throw std::logic_error("Unable to calculate GetUpperLimit since result" + "is below lower_lim. rnd was " + std::to_string(rnd) + + " with rnd_max " + std::to_string(sum)); + } (void)sum; return integral.GetUpperLimit();