From d665fb29621575bfc7ab366e98c3e01f09ca0a32 Mon Sep 17 00:00:00 2001
From: ralfulrich <ralf.ulrich@kit.edu>
Date: Mon, 25 Jan 2021 09:11:10 +0100
Subject: [PATCH] comment

---
 corsika/detail/modules/energy_loss/BetheBlochPDG.inl | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/corsika/detail/modules/energy_loss/BetheBlochPDG.inl b/corsika/detail/modules/energy_loss/BetheBlochPDG.inl
index 75d12f949..5dcd7de4f 100644
--- a/corsika/detail/modules/energy_loss/BetheBlochPDG.inl
+++ b/corsika/detail/modules/energy_loss/BetheBlochPDG.inl
@@ -211,7 +211,11 @@ namespace corsika {
     int binEnd = grammageEnd / dX_;
     if (binEnd < 0) binEnd = 0;
     if (binEnd > maxBin) binEnd = maxBin;
-
+    // in upward going showers binEnd may be smaller than binStart, but we don't care:
+    if (binStart>binEnd) {
+      std::swap(binStart, binEnd);
+    }
+    
     CORSIKA_LOG_DEBUG("energy deposit of -dE={} between {} and {}", -dE, grammageStart,
                       grammageEnd);
 
-- 
GitLab