[yoda-svn] r486 - trunk/src

blackhole at projects.hepforge.org blackhole at projects.hepforge.org
Tue Jul 3 14:29:15 BST 2012


Author: hoeth
Date: Tue Jul  3 14:29:15 2012
New Revision: 486

Log:
Fix crash when filling histograms with gaps

Modified:
   trunk/src/Histo1D.cc
   trunk/src/Profile1D.cc

Modified: trunk/src/Histo1D.cc
==============================================================================
--- trunk/src/Histo1D.cc	Tue Jul  3 14:00:24 2012	(r485)
+++ trunk/src/Histo1D.cc	Tue Jul  3 14:29:15 2012	(r486)
@@ -18,11 +18,13 @@
   void Histo1D::fill(double x, double weight) {
     // Fill the underflow and overflow nicely
     _axis.totalDbn().fill(x, weight);
-    if (x < _axis.lowEdge()) { _axis.underflow().fill(x, weight); return; }
-    if (x >= _axis.highEdge()) { _axis.overflow().fill(x, weight); return; }
+    if (x < _axis.xMin()) { _axis.underflow().fill(x, weight); return; }
+    if (x >= _axis.xMax()) { _axis.overflow().fill(x, weight); return; }
     // Fill the normal bins
-    HistoBin1D& b = binByCoord(x);
-    b.fill(x, weight);
+    try {
+      HistoBin1D& b = binByCoord(x);
+      b.fill(x, weight);
+    } catch (const RangeError& re) {}
   }
 
 

Modified: trunk/src/Profile1D.cc
==============================================================================
--- trunk/src/Profile1D.cc	Tue Jul  3 14:00:24 2012	(r485)
+++ trunk/src/Profile1D.cc	Tue Jul  3 14:29:15 2012	(r486)
@@ -13,16 +13,15 @@
 
 
   void Profile1D::fill(double x, double y, double weight) {
-    // Filling under/over flows
-    if (x < _axis.xMin()) {
-      _axis.underflow().fill(x, y, weight);
-    } else if (x >= _axis.xMax()) {
-      _axis.overflow().fill(x, y, weight);
-    } else {
+    // Fill the underflow and overflow nicely
+    _axis.totalDbn().fill(x, y, weight);
+    if (x < _axis.xMin()) { _axis.underflow().fill(x, y, weight); return; }
+    if (x >= _axis.xMax()) { _axis.overflow().fill(x, y, weight); return; }
+    // Fill the normal bins
+    try {
       ProfileBin1D& b = binByCoord(x);
       b.fill(x, y, weight);
-    }
-    _axis.totalDbn().fill(x, y, weight);
+    } catch (const RangeError& re) {}
   }
 
 


More information about the yoda-svn mailing list