[yoda-svn] r322 - trunk/include/YODA

blackhole at projects.hepforge.org blackhole at projects.hepforge.org
Mon Aug 22 15:58:27 BST 2011


Author: mkawalec
Date: Mon Aug 22 15:58:26 2011
New Revision: 322

Log:
Added the ability to add bins to Axis1D (also works 'on the fly'). Analogous to the 2D case the inclusion is not checked for/tested.

Modified:
   trunk/include/YODA/Axis1D.h
   trunk/include/YODA/Histo1D.h

Modified: trunk/include/YODA/Axis1D.h
==============================================================================
--- trunk/include/YODA/Axis1D.h	Mon Aug 22 14:24:24 2011	(r321)
+++ trunk/include/YODA/Axis1D.h	Mon Aug 22 15:58:26 2011	(r322)
@@ -119,6 +119,8 @@
     }
     //@}
 
+    /// @name Modifiers and helpers
+    //@{
     int getBinIndex(double coord) const {
       coord += 0.00000000001; 
       
@@ -126,8 +128,8 @@
 
       if(index == _binHashSparse.size() - 1) return -1;
 
-      if(_binHashSparse[index].second == _binHashSparse[index+1].second ||
-         _binHashSparse[index].second == _binHashSparse[index-1].second) {
+      if(_binHashSparse[index].second == _binHashSparse[index+1].second)
+      {
         return _binHashSparse[index].second;
       }
       return -1;
@@ -152,6 +154,17 @@
       throw std::runtime_error("Implement!");  
       //@todo Implement!
     }
+
+    void addBin(double& from, double& to) {
+      vector<double> binedges;
+      binedges.push_back(from); binedges.push_back(to);
+
+      _mkAxis(binedges);
+    }
+
+    void addBin(vector<double>& binedges) {
+      _mkAxis(binedges);
+    }
     
     void scaleX(double scalefactor) {
       _dbn.scaleX(scalefactor);
@@ -168,8 +181,11 @@
       _overflow.scaleW(scalefactor);
       for(size_t i = 0; i < _bins.size(); ++i) _bins[i].scaleW(scalefactor);
     }
-  
-  public:
+    //@}
+
+    /// @name Operators
+    //@{
+
     bool operator == (const Axis1D& other) const {
       return _binHashSparse == other._binHashSparse;
     }
@@ -203,7 +219,8 @@
       _overflow += toSubtract._overflow;
       return *this;
     }
-
+    
+    //@}
 
   private:
     void _mkAxis(const std::vector<double>& binedges) {
@@ -243,7 +260,6 @@
       }
 
       if (where == 0) return where;
-      if (value >= _binHashSparse[where-1].first) return where;
       return _binaryS(value, lower, where);
     }
 

Modified: trunk/include/YODA/Histo1D.h
==============================================================================
--- trunk/include/YODA/Histo1D.h	Mon Aug 22 14:24:24 2011	(r321)
+++ trunk/include/YODA/Histo1D.h	Mon Aug 22 15:58:26 2011	(r322)
@@ -182,6 +182,14 @@
       return _axis.overflow();
     }
 
+    void addBin(double from, double to) {
+      _axis.addBin(from, to);
+    }
+
+    void addBin(vector<double> edges) {
+      _axis.addBin(edges);
+    }
+
     //@}
 
 


More information about the yoda-svn mailing list