From ef28af315a3339fb3fc62cb5ee5cd2ff309e3efc Mon Sep 17 00:00:00 2001
From: Andre Sailer <andre.philippe.sailer@cern.ch>
Date: Thu, 19 Mar 2015 13:03:15 +0000
Subject: [PATCH] Segmentation: More detailed exception message

---
 DDSegmentation/src/Segmentation.cpp | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/DDSegmentation/src/Segmentation.cpp b/DDSegmentation/src/Segmentation.cpp
index 8430bb59c..3337d8f84 100644
--- a/DDSegmentation/src/Segmentation.cpp
+++ b/DDSegmentation/src/Segmentation.cpp
@@ -159,8 +159,20 @@ int Segmentation::positionToBin(double position, std::vector<double> const& cell
   if(fabs(position - cellBoundaries.back())  < 1e-12) return int(cellBoundaries.size()-2);
 
   // hits outside cannot be treated
-  if(position < cellBoundaries.front()) throw std::runtime_error("Hit Position is outside of segmentation");
-  if(position > cellBoundaries.back() ) throw std::runtime_error("Hit Position is outside of segmentation");
+  if(position < cellBoundaries.front()) {
+    std::stringstream err;
+    err << "Hit Position (" << position << ") is below the acceptance"
+	<< "(" << cellBoundaries.front() << ")"
+	<< "of the segmentation";
+    throw std::runtime_error(err.str());
+  }
+  if(position > cellBoundaries.back() ) {
+    std::stringstream err;
+    err << "Hit Position (" << position << ") is above the acceptance"
+	<< "(" << cellBoundaries.back() << ")"
+	<< "of the segmentation";
+    throw std::runtime_error(err.str());
+  }
 
 
   std::vector<double>::const_iterator bin = std::upper_bound(cellBoundaries.begin(),
-- 
GitLab