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

blackhole at projects.hepforge.org blackhole at projects.hepforge.org
Thu Aug 18 10:22:10 BST 2011


Author: mkawalec
Date: Thu Aug 18 10:22:10 2011
New Revision: 271

Log:
Removed isGrid(), added Histo2D as a friend class of Axis2D.

Modified:
   trunk/include/YODA/Axis2D.h
   trunk/include/YODA/Histo2D.h

Modified: trunk/include/YODA/Axis2D.h
==============================================================================
--- trunk/include/YODA/Axis2D.h	Wed Aug 17 17:33:29 2011	(r270)
+++ trunk/include/YODA/Axis2D.h	Thu Aug 18 10:22:10 2011	(r271)
@@ -21,6 +21,9 @@
   template <typename BIN>
   class Axis2D {
   public:
+    
+    /// Enabling Histo2D to check if its axis is a grid
+    friend class Histo2D;
 
     // A few helpful typedefs
     typedef BIN Bin;
@@ -134,13 +137,6 @@
     /// @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) {
       if(x < _lowEdgeX && y > _highEdgeY) _outflows[0][0].fill(x, y, weight);
@@ -209,9 +205,19 @@
 
 
     /// Get the total number of bins
-    unsigned int numBinsTotal() const {
+    size_t numBinsTotal() const {
       return _bins.size();
     }
+    
+    /// Get the number of bins along X axis
+    size_t numBinsX() const {
+      return _binHashSparse.second.size()/2;
+    }
+
+    /// Get the number of bins along Y axis
+    size_t numBinsY() const {
+      return _binHashSparse.first.size()/2;
+    }
 
 
     /// Get the value of the lowest x-edge on the axis

Modified: trunk/include/YODA/Histo2D.h
==============================================================================
--- trunk/include/YODA/Histo2D.h	Wed Aug 17 17:33:29 2011	(r270)
+++ trunk/include/YODA/Histo2D.h	Thu Aug 18 10:22:10 2011	(r271)
@@ -215,12 +215,32 @@
     // }
 
     /// Return a total number of bins in Histo(non-const version)
-    unsigned int numBinsTotal() {
-        return _axis.numBinsTotal();
+    size_t numBinsTotal() {
+      return _axis.numBinsTotal();
     }
 
-    const unsigned int numBinsTotal() const {
-        return _axis.numBinsTotal();
+    const size_t numBinsTotal() const {
+      return _axis.numBinsTotal();
+    }
+
+    /// Return number of bins along X axis (non-const version)
+    size_t numBinsX() {
+      return _axis.numBinsX();
+    }
+
+    /// Return number of bins along X axis (const version)
+    const size_t numBinsX() const {
+      return _axis.numBinsX();
+    }
+
+    /// Return the number of bins along Y axis (non-const version)
+    size_t numBinsY() {
+      return _axis.numBinsY();
+    }
+    
+    /// Return the number of bins along Y axis (const version)
+    const size_t numBinsY() const{
+      return _axis.numBinsY();
     }
 
     //@}
@@ -306,7 +326,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.isGrid()) 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;
@@ -335,7 +355,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.isGrid()) 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;
@@ -358,7 +378,14 @@
 
 
     /// @todo Create x-wise and y-wise conversions to Profile1D -- ignore outflows for now, but mark as such
-
+    /*Profile1D mkProfileX() {
+      throw Exception("To implement!"); 
+      if(!_axis._isGrid()) throw GridError("Profile1D cannot be made from a histogram that is not a grid!");
+      
+      //Profile1D ret;
+      return Profile1D();
+    }
+*/
 
     //@}
 


More information about the yoda-svn mailing list