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

blackhole at projects.hepforge.org blackhole at projects.hepforge.org
Wed Aug 17 17:11:19 BST 2011


Author: mkawalec
Date: Wed Aug 17 17:11:16 2011
New Revision: 269

Log:
isReal -> _isGhost (protected). Added accessors (isGhost()), both const and nonconst (it is essensial to set the isReal state from the level of Axis2D. Making other files nicely work with this modification.

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

Modified: trunk/TODO
==============================================================================
--- trunk/TODO	Wed Aug 17 16:57:50 2011	(r268)
+++ trunk/TODO	Wed Aug 17 17:11:16 2011	(r269)
@@ -23,9 +23,11 @@
   all of us: can better names be chosen? "Ghost bins" with an _isGhost()
   internal should be enough. Hopefully there's no need to invent a term for
   non-ghost bins, since that is just covered by !_isGhost()... (MICHAL)
+  MK: Done
 
 * Similarly, is there any reason to expose the isGriddy function publicly on
   Axis2D and Histo1D? Can't it just be a private _isGrid()? (MICHAL)
+  MK: Done
 
 * 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	Wed Aug 17 16:57:50 2011	(r268)
+++ trunk/include/YODA/Axis2D.h	Wed Aug 17 17:11:16 2011	(r269)
@@ -177,7 +177,7 @@
       HistoBin2D& start = bin(from);
       HistoBin2D& end = bin(to);
       HistoBin2D temp = start;
-      start.isReal = false;
+      start.isGhost() = true;
 
       if (start.midpoint().first > end.midpoint().first ||
           start.midpoint().second > end.midpoint().second)
@@ -192,10 +192,10 @@
                fuzzyEquals(_binHashSparse.first[y].second[x].second.first, start.xMin())) &&
               (_binHashSparse.first[y].second[x].second.second < end.xMax() ||
                fuzzyEquals(_binHashSparse.first[y].second[x].second.second, end.xMax())) &&
-              bin(_binHashSparse.first[y].second[x].first).isReal)
+              bin(!_binHashSparse.first[y].second[x].first).isGhost())
             {
               temp += bin(_binHashSparse.first[y].second[x].first);
-              bin(_binHashSparse.first[y].second[x].first).isReal = false;
+              bin(_binHashSparse.first[y].second[x].first).isGhost() = true;
             }
         }
       }
@@ -815,7 +815,7 @@
       for (size_t i=0; i < _bins.size(); ++i) {
         if(_bins[i].xMin() <= coordX && _bins[i].xMax()  >= coordX &&
            _bins[i].yMin() <= coordY && _bins[i].yMax() >= coordY &&
-           _bins[i].isReal) return i;
+           !_bins[i].isGhost()) return i;
       }
       return -1;
     }

Modified: trunk/include/YODA/Bin2D.h
==============================================================================
--- trunk/include/YODA/Bin2D.h	Wed Aug 17 16:57:50 2011	(r268)
+++ trunk/include/YODA/Bin2D.h	Wed Aug 17 17:11:16 2011	(r269)
@@ -215,7 +215,21 @@
     }
 
     //@}
+    
+    /// @name _isGhost accessor
+    //@{
+
+    /// non-const version
+    bool& isGhost() {
+      return _isGhost;
+    }
 
+    /// const version
+    const bool isGhost() const {
+      return _isGhost;
+    }
+
+    //@}
 
   protected:
 
@@ -238,13 +252,10 @@
     Dbn2D _dbn;
 
 
-  public:
+  protected:
 
     /// A variable that specifies if the bin should be plotted
-    ///
-    /// @todo Access to this variable needs to be restricted -- the existence of
-    /// this should not be known to the average user.
-    bool isReal;
+    bool _isGhost;
 
   };
 

Modified: trunk/src/Bin2D.cc
==============================================================================
--- trunk/src/Bin2D.cc	Wed Aug 17 16:57:50 2011	(r268)
+++ trunk/src/Bin2D.cc	Wed Aug 17 17:11:16 2011	(r269)
@@ -21,7 +21,7 @@
     _edges.second.first = highedgeX;
     _edges.second.second = highedgeY;
 
-    isReal = true;
+    isGhost() = false;
   }
 
 
@@ -34,7 +34,7 @@
      _edges.second.first = edges[1].second.first;
      _edges.second.second = edges[1].second.second;
 
-     isReal = true;
+     isGhost() = false;
    }
 
 

Modified: trunk/tests/TestHisto2D.cc
==============================================================================
--- trunk/tests/TestHisto2D.cc	Wed Aug 17 16:57:50 2011	(r268)
+++ trunk/tests/TestHisto2D.cc	Wed Aug 17 17:11:16 2011	(r269)
@@ -40,7 +40,7 @@
     gettimeofday(&startTime, NULL);
     Histo2D h(200, 0, 100, 200, 0, 100);
     gettimeofday(&endTime, NULL);
-    cout << h.binByCoord(1,1).isReal << endl;
+    cout << h.binByCoord(1,1).isGhost() << endl;
 
     double tS = (startTime.tv_sec*1000000 + startTime.tv_usec)/(double)1000000;
     double tE = (endTime.tv_sec*1000000 + endTime.tv_usec)/(double)1000000;


More information about the yoda-svn mailing list