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

blackhole at projects.hepforge.org blackhole at projects.hepforge.org
Thu Aug 18 18:13:42 BST 2011


Author: mkawalec
Date: Thu Aug 18 18:13:41 2011
New Revision: 291

Log:
Histo2D is no longer a friend of Axis2D, _isGrid -> isGrid and moved to the front of Axis2D.

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

Modified: trunk/TODO
==============================================================================
--- trunk/TODO	Thu Aug 18 18:03:02 2011	(r290)
+++ trunk/TODO	Thu Aug 18 18:13:41 2011	(r291)
@@ -20,6 +20,7 @@
     but since the Axis objects are for internal use only, I don't think there is a
     reason for the is-grid? method to be private on Axis2D -- this is the only reason
     for Histo2D to have to be a friend of Axis2D, right?
+  MK: Thanks for pointing that out. I have got lost in my own code;)
 
 * Add copy constructors for Dbn1D/2D, Scatter2D, Histo/ProfileBin1D, Point2D/3D, HistoBin2D.
   Rule of three: also need explicit assignment operator= for all classes

Modified: trunk/include/YODA/Axis2D.h
==============================================================================
--- trunk/include/YODA/Axis2D.h	Thu Aug 18 18:03:02 2011	(r290)
+++ trunk/include/YODA/Axis2D.h	Thu Aug 18 18:13:41 2011	(r291)
@@ -23,10 +23,6 @@
   template <typename BIN>
   class Axis2D {
 
-    /// Enabling Histo2D to check if its axis is a grid
-    /// @todo This should not be necessary
-    friend class Histo2D;
-
     /// When edge is added to the collection it must
     /// obey the following format. size_t specifies the bin this
     /// edge is a member of, a pair contains a beginning and end of the edge.
@@ -57,6 +53,8 @@
     /// mergeBins() function ~100 lines below this point.
     typedef typename std::vector<std::pair<Bin, bool> > Bins;
 
+    /// Is it a grid?
+    bool isGrid;
 
   public:
 
@@ -76,7 +74,7 @@
     /// Constructor provided with a vector of bin delimiters
     Axis2D(const vector<Segment>& binLimits) {
       _mkAxis(binLimits);
-      if(_isGrid) _setOutflows();
+      if(isGrid) _setOutflows();
     }
 
 
@@ -115,7 +113,7 @@
         _bins[i] = bins[i];
       }
       _regenDelimiters();
-      if(_isGrid) _setOutflows();
+      if(isGrid) _setOutflows();
       _outflows = outflows;
 
       _dbn = totalDbn;
@@ -373,7 +371,7 @@
     /// interest.
     const int getBinIndex(double coordX, double coordY) const {
       /// In case we are just operating on a regular grid
-      if(_isGrid) {  
+      if(isGrid) {  
         coordX += 0.00000000001; coordY += 0.00000000001;
              size_t indexY = (*_binHashSparse.first._cache.lower_bound(approx(coordY))).second;
  
@@ -577,7 +575,7 @@
     /// 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.
+    /// subcaches. This makes isGrid() a very, very fast function.
     /// @todo This is far too big to be inline: move it to the .cc
     void _genGridCache() {
 
@@ -587,11 +585,11 @@
       for (size_t i = 1; i < _binHashSparse.first.size(); ++i) {
         if (i == _binHashSparse.first.size() - 1) {
           if (_binHashSparse.first[i].second.size() != sizeX) {
-            _isGrid = false;
+            isGrid = false;
           }
         }
         else if (_binHashSparse.first[i].second.size() != 2*sizeX) {
-          _isGrid = false;
+          isGrid = false;
         }
       }
 
@@ -600,16 +598,16 @@
       for (size_t i=1; i < _binHashSparse.second.size(); ++i) {
         if (i != _binHashSparse.second.size() - 1) {
           if (2*sizeY != _binHashSparse.second[i].second.size()) {
-            _isGrid = false;
+            isGrid = false;
           }
         }
         else if (_binHashSparse.second[i].second.size() != sizeY) {
-          _isGrid = false;
+          isGrid = false;
         }
       }
 
       /// If everything is proper, announce it.
-      _isGrid = true;
+      isGrid = true;
     }
 
 
@@ -977,9 +975,6 @@
     /// Low/high edges
     double _highEdgeX, _highEdgeY, _lowEdgeX, _lowEdgeY;
 
-    /// Is it a grid?
-    bool _isGrid;
-
   };
 
 

Modified: trunk/include/YODA/Histo2D.h
==============================================================================
--- trunk/include/YODA/Histo2D.h	Thu Aug 18 18:03:02 2011	(r290)
+++ trunk/include/YODA/Histo2D.h	Thu Aug 18 18:13:41 2011	(r291)
@@ -295,7 +295,7 @@
     /// @todo It's not really *at* the specified y coord: it's for the corresponding bin row.
     /// @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;
@@ -307,7 +307,7 @@
       }
 
       /// Setting under/over flows
-      vector<vector<Dbn2D> >& outflows = _axis._outflows;
+      vector<vector<Dbn2D> >& outflows = _axis.outflows();
       Dbn2D underflow;
       underflow += outflows[0][0]; underflow += outflows[6][0];
       for(size_t i=0; i < outflows[7].size(); ++i) underflow += outflows[7][i];
@@ -327,7 +327,7 @@
     /// @todo It's not really *at* the specified x coord: it's for the corresponding bin row.
     /// @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;
@@ -339,7 +339,7 @@
       }
 
       /// Setting under/over flows
-      vector<vector<Dbn2D> >& outflows = _axis._outflows;
+      vector<vector<Dbn2D> >& outflows = _axis.outflows();
       Dbn2D underflow;
       underflow += outflows[0][0]; underflow += outflows[2][0];
       for(size_t i=0; i < outflows[1].size(); ++i) underflow += outflows[1][i];
@@ -361,7 +361,7 @@
 
     /// @brief X-wise Profile1D creator from Histo2D
     Profile1D mkProfileX() {
-      if (!_axis._isGrid) throw GridError("Profile1D cannot be made from a histogram that is not a grid!");
+      if (!_axis.isGrid) throw GridError("Profile1D cannot be made from a histogram that is not a grid!");
 
       vector<ProfileBin1D> prof;
       for(int i = lowEdgeX() + _axis.bin(0).midpoint().first; i < highEdgeX(); i+= _axis.bin(0).widthX()) {
@@ -397,7 +397,7 @@
 
     /// @brief Y-wise Profile1D creator from Histo2D
     Profile1D mkProfileY() {
-      if (!_axis._isGrid) throw GridError("Profile1D cannot be made from a histogram that is not a grid!");
+      if (!_axis.isGrid) throw GridError("Profile1D cannot be made from a histogram that is not a grid!");
 
       vector<ProfileBin1D> prof;
       for(int i = lowEdgeY() + _axis.bin(0).midpoint().second; i < highEdgeY(); i+= _axis.bin(0).widthY()) {


More information about the yoda-svn mailing list