diff --git a/corsika/detail/modules/proposal/ContinuousProcess.inl b/corsika/detail/modules/proposal/ContinuousProcess.inl index 9ffb5d8fde6798f9adfcb2d21bc7a21edb2ea840..6adf0b7f98959bedd156b017d2643f8a940bf7cb 100644 --- a/corsika/detail/modules/proposal/ContinuousProcess.inl +++ b/corsika/detail/modules/proposal/ContinuousProcess.inl @@ -157,6 +157,13 @@ namespace corsika::proposal { vP.getNode()->getModelProperties().getArclengthFromGrammage(track, grammage); CORSIKA_LOG_TRACE("PROPOSAL::getMaxStepLength X={} g/cm2, l={} m ", grammage / 1_g * square(1_cm), dist / 1_m); + if (dist < 0_m) { + CORSIKA_LOG_WARN( + "PROPOSAL::getMaxStepLength calculated a negative step length of l={} m. " + "Return 0_m instead.", + dist / 1_m); + return 0_m; + } return dist; }