[yoda-svn] r268 - in trunk: . include/YODA tests

blackhole at projects.hepforge.org blackhole at projects.hepforge.org
Wed Aug 17 16:57:50 BST 2011


Author: mkawalec
Date: Wed Aug 17 16:57:50 2011
New Revision: 268

Log:
In Axis2D: isGriddy -> _isGrid, added a public const function isGrid() to enable Histo2D to check if its Axis is a grid (needed for making cuts).

Modified:
   trunk/TODO
   trunk/include/YODA/Axis2D.h
   trunk/include/YODA/Histo2D.h
   trunk/tests/TestHisto2D.cc

Modified: trunk/TODO
==============================================================================
--- trunk/TODO	Wed Aug 17 15:48:17 2011	(r267)
+++ trunk/TODO	Wed Aug 17 16:57:50 2011	(r268)
@@ -14,7 +14,7 @@
 
 * Remove the "using namespace std" from the Bin2D.h and Axis2D.h headers: you
   should avoid publicly using namespaces in API headers since it pollutes the
-  global namespace for any users of the API. (MICHAL)
+  global namespace for any users of the API. (done) (MICHAL)
 
 * Completely hide the Bin2D::isReal from public view: this is absolutely an
   internal implementation detail and should not be public in any way. I'm also
@@ -42,6 +42,7 @@
   MK: done
   AB: You still need to add state-setting for the total dbn and the outflows: at
   the moment this only sets the state on the Bin2Ds.
+  MK: Done
 
 * Use state-setting constructors for Histo and Profile persistency via the
   Reader classes. (HH)

Modified: trunk/include/YODA/Axis2D.h
==============================================================================
--- trunk/include/YODA/Axis2D.h	Wed Aug 17 15:48:17 2011	(r267)
+++ trunk/include/YODA/Axis2D.h	Wed Aug 17 16:57:50 2011	(r268)
@@ -61,7 +61,7 @@
     /// Constructor provided with a vector of bin delimiters
     Axis2D(const vector<Segment>& binLimits) {
       _mkAxis(binLimits);
-      if(isGriddy()) _setOutflows();
+      if(_isGrid()) _setOutflows();
     }
 
 
@@ -96,7 +96,7 @@
         _bins[i] = bins[i];
       }
       _regenDelimiters();
-      if(isGriddy()) _setOutflows();
+      if(_isGrid()) _setOutflows();
       _outflows = outflows;
 
       _dbn = totalDbn;
@@ -133,6 +133,13 @@
 
     /// @name Helper functions
     //@{
+    
+    /// @brief Check if Axis represents a grid
+    /// For more information, please refer to the documentation
+    /// of _isGrid().
+    const bool isGrid() const {
+      return _isGrid();
+    }
 
     /// Outflow filler
     void fillOutflows(double x, double y, double weight) {
@@ -201,47 +208,6 @@
     }
 
 
-    /// @brief Checks if our bins form a grid.
-    /// This function uses a neat property of _binHashSparse.
-    /// If it is containing a set of edges forming a grid without
-    /// gaps in the middle it will have the same number of edges in the
-    /// inner subcaches and half of this amount in the outer (grid boundary)
-    /// subcaches. This makes isGriddy() a very, very fast function.
-    /// @todo Is the name appropriate? Should it be private?
-    bool isGriddy() const {
-
-      /// Check if the number of edges parallel to X axis
-      /// is proper in every subcache.
-      size_t sizeX = _binHashSparse.first[0].second.size();
-      for (size_t i = 1; i < _binHashSparse.first.size(); ++i) {
-        if (i == _binHashSparse.first.size() - 1) {
-          if (_binHashSparse.first[i].second.size() != sizeX) {
-            return false;
-          }
-        }
-        else if (_binHashSparse.first[i].second.size() != 2*sizeX) {
-          return false;
-        }
-      }
-
-      /// Do the same for edges parallel to Y axis.
-      size_t sizeY = _binHashSparse.second[0].second.size();
-      for (size_t i=1; i < _binHashSparse.second.size(); ++i) {
-        if (i != _binHashSparse.second.size() - 1) {
-          if (2*sizeY != _binHashSparse.second[i].second.size()) {
-            return false;
-          }
-        }
-        else if (_binHashSparse.second[i].second.size() != sizeY) {
-          return -1;
-        }
-      }
-
-      /// If everything is proper, announce it.
-      return true;
-    }
-
-
     /// Get the total number of bins
     unsigned int numBinsTotal() const {
       return _bins.size();
@@ -461,6 +427,8 @@
 
   private:
 
+    /// @brief Outflows pre-setter
+    /// Sets the correct number of bins in each of the outflows.
     void _setOutflows() {
       _outflows.resize(8);
       
@@ -474,6 +442,48 @@
       _outflows[7].resize(_binHashSparse.first.size());
 
     }
+    
+    /// @brief Checks if our bins form a grid.
+    /// This function uses a neat property of _binHashSparse.
+    /// If it is containing a set of edges forming a grid without
+    /// gaps in the middle it will have the same number of edges in the
+    /// inner subcaches and half of this amount in the outer (grid boundary)
+    /// subcaches. This makes _isGrid() a very, very fast function.
+    /// @todo Is the name appropriate? Should it be private?
+    bool _isGrid() const {
+
+      /// Check if the number of edges parallel to X axis
+      /// is proper in every subcache.
+      size_t sizeX = _binHashSparse.first[0].second.size();
+      for (size_t i = 1; i < _binHashSparse.first.size(); ++i) {
+        if (i == _binHashSparse.first.size() - 1) {
+          if (_binHashSparse.first[i].second.size() != sizeX) {
+            return false;
+          }
+        }
+        else if (_binHashSparse.first[i].second.size() != 2*sizeX) {
+          return false;
+        }
+      }
+
+      /// Do the same for edges parallel to Y axis.
+      size_t sizeY = _binHashSparse.second[0].second.size();
+      for (size_t i=1; i < _binHashSparse.second.size(); ++i) {
+        if (i != _binHashSparse.second.size() - 1) {
+          if (2*sizeY != _binHashSparse.second[i].second.size()) {
+            return false;
+          }
+        }
+        else if (_binHashSparse.second[i].second.size() != sizeY) {
+          return -1;
+        }
+      }
+
+      /// If everything is proper, announce it.
+      return true;
+    }
+
+
 
 
     /// @brief Segment validator function

Modified: trunk/include/YODA/Histo2D.h
==============================================================================
--- trunk/include/YODA/Histo2D.h	Wed Aug 17 15:48:17 2011	(r267)
+++ trunk/include/YODA/Histo2D.h	Wed Aug 17 16:57:50 2011	(r268)
@@ -100,12 +100,6 @@
       _axis.reset();
     }
 
-    /// Check if this binning is a grid
-    /// @todo Avoid exposing this on the public API
-    bool isGriddy() {
-      return _axis.isGriddy();
-    }
-
     /// Rescale as if all fill weights had been different by factor @a scalefactor.
     void scaleW(double scalefactor) {
       _axis.scaleW(scalefactor);
@@ -116,7 +110,6 @@
       _axis.scaleXY(scaleX, scaleY);
     }
 
-
     /// Adding bins
     void addBin(const vector<pair<pair<double,double>, pair<double,double> > > coords) {
         _axis.addBin(coords);
@@ -313,7 +306,7 @@
     /// @todo Need to check that there is a continuous row for this y
     /// @todo Change the name!
     Histo1D cutterX(double atY, const std::string& path="", const std::string& title="") {
-      if (!_axis.isGriddy()) throw GridError("I cannot cut a Histo2D that is not a grid!");
+      if (!_axis.isGrid()) throw GridError("I cannot cut a Histo2D that is not a grid!");
 
       if (atY < lowEdgeY() || atY > highEdgeY()) throw RangeError("Y is outside the grid");
       vector<HistoBin1D> tempBins;
@@ -342,7 +335,7 @@
     /// @todo Need to check that there is a continuous column for this x
     /// @todo Change the name!
     Histo1D cutterY(double atX, const std::string& path="", const std::string& title="") {
-      if (!_axis.isGriddy()) throw GridError("I cannot cut a Histo2D that is not a grid!");
+      if (!_axis.isGrid()) throw GridError("I cannot cut a Histo2D that is not a grid!");
 
       if (atX < lowEdgeX() || atX > highEdgeX()) throw RangeError("X is outside the grid");
       vector<HistoBin1D> tempBins;

Modified: trunk/tests/TestHisto2D.cc
==============================================================================
--- trunk/tests/TestHisto2D.cc	Wed Aug 17 15:48:17 2011	(r267)
+++ trunk/tests/TestHisto2D.cc	Wed Aug 17 16:57:50 2011	(r268)
@@ -84,7 +84,6 @@
         return -1;
     }
 
-    h.isGriddy();
 
     /// Checking if everything is still working as desired.
     /**


More information about the yoda-svn mailing list