From 6366ecf91db5d9a0b8918b3e1a2f72756f954d6c Mon Sep 17 00:00:00 2001
From: Maximilian Reininghaus <maximilian.reininghaus@tu-dortmund.de>
Date: Sat, 4 Jul 2020 20:11:51 +0200
Subject: [PATCH] fixed signed/unsigned comparison

---
 Environment/ShowerAxis.cc | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/Environment/ShowerAxis.cc b/Environment/ShowerAxis.cc
index 3ae28638a..f67cfb42f 100644
--- a/Environment/ShowerAxis.cc
+++ b/Environment/ShowerAxis.cc
@@ -18,18 +18,21 @@ GrammageType ShowerAxis::X(LengthType l) const {
   auto const fractionalBin = l / steplength_;
   int const lower = fractionalBin; // indices of nearest X support points
   auto const lambda = fractionalBin - lower;
-  int const upper = lower + 1;
+  decltype(X_.size()) const upper = lower + 1;
+
+  if (lower < 0) {
+    throw std::runtime_error("cannot extrapolate to points behind point of injection");
+  }
 
   if (upper >= X_.size()) {
     std::stringstream errormsg;
     errormsg << "shower axis too short, cannot extrapolate (l / max_length_ = "
              << l / max_length_ << ")";
     throw std::runtime_error(errormsg.str().c_str());
-  } else if (lower < 0) {
-    throw std::runtime_error("cannot extrapolate to points behind point of injection");
   }
 
   assert(0 <= lambda && lambda <= 1.);
+
   // linear interpolation between X[lower] and X[upper]
   return X_[lower] * lambda + X_[upper] * (1 - lambda);
 }
-- 
GitLab