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

blackhole at projects.hepforge.org blackhole at projects.hepforge.org
Tue Aug 16 15:16:43 BST 2011


Author: buckley
Date: Tue Aug 16 15:16:43 2011
New Revision: 254

Log:
Doxygen and other clean-ups

Modified:
   trunk/TODO
   trunk/include/YODA/Axis1D.h
   trunk/include/YODA/Axis2D.h
   trunk/include/YODA/Bin.h
   trunk/include/YODA/Bin2D.h
   trunk/include/YODA/Dbn1D.h
   trunk/include/YODA/Exceptions.h
   trunk/src/Bin2D.cc

Modified: trunk/TODO
==============================================================================
--- trunk/TODO	Tue Aug 16 15:04:57 2011	(r253)
+++ trunk/TODO	Tue Aug 16 15:16:43 2011	(r254)
@@ -9,6 +9,11 @@
 * Rebinning: merges of n adjacent bins and global rebinning by integer factor
   (on widths or on bin groups?) (AB for 1D, MICHAL for 2D (done))
 
+* Completely hide the Bin2D::isReal from public view: this is absolutely an
+  internal implementation detail and should not be public in any way.
+  Similarly, is there any reason to expose the isGriddy function publicly on
+  Axis2D and Histo1D? Can't it just be a private _isGrid()? (MICHAL)
+
 * Add copy constructors for Dbn1D/2D, Scatter2D, Histo/ProfileBin1D, Point2D/3D, HistoBin2D.
   Rule of three: also need explicit assignment operator= for all classes
   with copy constructors?
@@ -16,7 +21,7 @@
 * Conversion functions to build Histo1D and Profile1D objects for slicings and
   marginalisations along both X and Y directions of 2D histos. Throw an
   exception if binnings are not complete grids. (MICHAL)
-  (done -- to be reviewed)
+  (done -- to be reviewed. AB: Profile1D slices still needed. Ignore outflows for now.)
 
 * Implement hierarchy-cascading state-setting constructor for Histo2D.(done) (MICHAL)
 

Modified: trunk/include/YODA/Axis1D.h
==============================================================================
--- trunk/include/YODA/Axis1D.h	Tue Aug 16 15:04:57 2011	(r253)
+++ trunk/include/YODA/Axis1D.h	Tue Aug 16 15:16:43 2011	(r254)
@@ -20,6 +20,7 @@
 
 
   /// @brief A 1D templated container of ordered bins
+  ///
   /// This class is separately templated on the bin and distribution types.
   template <typename BIN1D, typename DBN>
   class Axis1D {

Modified: trunk/include/YODA/Axis2D.h
==============================================================================
--- trunk/include/YODA/Axis2D.h	Tue Aug 16 15:04:57 2011	(r253)
+++ trunk/include/YODA/Axis2D.h	Tue Aug 16 15:16:43 2011	(r254)
@@ -25,6 +25,7 @@
 
 
   /// @brief 2D bin container and provider
+  ///
   /// This class handles almost all boiler-plate operations
   /// on 2D bins (like creating axis, adding, searching, testing).
   template <typename BIN>

Modified: trunk/include/YODA/Bin.h
==============================================================================
--- trunk/include/YODA/Bin.h	Tue Aug 16 15:04:57 2011	(r253)
+++ trunk/include/YODA/Bin.h	Tue Aug 16 15:16:43 2011	(r254)
@@ -13,6 +13,7 @@
 
 
   /// @brief Base class for bins in 1D and 2D histograms.
+  ///
   /// This base class only provides very basic functionality for fill
   /// weight statistics access, as 1D/2D and basic/profile histos have
   /// quite difference implementations.

Modified: trunk/include/YODA/Bin2D.h
==============================================================================
--- trunk/include/YODA/Bin2D.h	Tue Aug 16 15:04:57 2011	(r253)
+++ trunk/include/YODA/Bin2D.h	Tue Aug 16 15:16:43 2011	(r254)
@@ -11,7 +11,7 @@
 using namespace std;
 
 namespace YODA {
-  
+
   /// @brief A generic 2D bin type
   ///
   /// This is a generic 2D bin type which supplies the accessors for the two "x"
@@ -23,7 +23,7 @@
   class Bin2D : public Bin {
   public:
 
-    /// Convinience typedefs
+    /// Convenience typedefs
     typedef typename std::pair<double, double> Point;
     typedef typename std::pair<Point, Point> Segment;
 
@@ -41,7 +41,7 @@
     /// Bin slightly faster (this claim is very weakly true).  It is not
     /// suggested to use it if it is just needed to add few bins to an already
     /// created Histo2D.
-    Bin2D(std::vector<Segment> edges);
+    Bin2D(const std::vector<Segment>& edges);
 
     //@}
 
@@ -49,13 +49,12 @@
     /// @name Modifiers
     //@{
 
-    const vector<Segment> edges() const { 
+    const vector<Segment> edges() const {
       vector<Segment> ret;
       ret.push_back(make_pair(make_pair(xMin(), yMin()), make_pair(xMin(), yMax())));
       ret.push_back(make_pair(make_pair(xMin(), yMax()), make_pair(xMax(), yMax())));
       ret.push_back(make_pair(make_pair(xMax(), yMin()), make_pair(xMax(), yMax())));
       ret.push_back(make_pair(make_pair(xMin(), yMin()), make_pair(xMax(), yMin())));
-
       return ret;
     }
 
@@ -84,15 +83,9 @@
     double lowEdgeY() const {
       return _edges.first.second;
     }
-
     /// Synonym for lowEdgeY()
     double yMin() const { return lowEdgeY(); }
 
-    /// A variable that specifies if the bin should be plotted
-    bool isReal;
-
-    ///@name Transformers
-    //@{
     /// Get the high x edge of the bin.
     double highEdgeX() const {
       return _edges.second.first;
@@ -118,11 +111,12 @@
     }
     //@}
 
+
     /// @name Distribution statistics
     //@{
 
     /// Find the geometric midpoint of the bin
-    Point midpoint() const; 
+    Point midpoint() const;
 
     /// Find the weighted mean point of the bin, or the midpoint if unfilled
     Point focus() const {
@@ -221,15 +215,9 @@
 
     //@}
 
-  protected:
-
-    Bin2D& add(const Bin2D& b); 
 
-    Bin2D& subtract(const Bin2D& b);
+  protected:
 
-    Segment _edges;
-    Dbn2D _dbn;
-        
     /// Boundaries setter
     void _setBounds(double xMin, double yMin, double xMax, double yMax) {
       _edges.first.first = xMin;
@@ -238,8 +226,31 @@
       _edges.second.second = yMax;
     }
 
+
+  protected:
+
+    Bin2D& add(const Bin2D& b);
+
+    Bin2D& subtract(const Bin2D& b);
+
+    Segment _edges;
+    Dbn2D _dbn;
+
+
+  public:
+
+    /// 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;
+
   };
 
+
+  /// @name Operators
+  //@{
+
   inline Bin2D operator + (const Bin2D& a, const Bin2D& b) {
     Bin2D rtn = a;
     rtn += b;
@@ -252,6 +263,8 @@
     return rtn;
   }
 
+  //@}
+
 
 }
 

Modified: trunk/include/YODA/Dbn1D.h
==============================================================================
--- trunk/include/YODA/Dbn1D.h	Tue Aug 16 15:04:57 2011	(r253)
+++ trunk/include/YODA/Dbn1D.h	Tue Aug 16 15:16:43 2011	(r254)
@@ -12,15 +12,17 @@
 namespace YODA {
 
 
-  /// @brief A 1D distribution This class is used internally by YODA to
-  /// centralise the calculation of statistics of unbounded, unbinned sampled
-  /// distributions. Each distribution fill contributes a weight, \f$ w \f$, and
-  /// a value, \f$ x \f$. By storing the total number of fills (ignoring
-  /// weights), \f$ \sum w \f$, \f$ \sum w^2 \f$, \f$ \sum wx \f$,
-  /// and \f$ \sum wx^2 \f$, the Dbn1D can calculate the mean and spread
-  /// (\f$ \sigma^2 \f$, \f$ \sigma \f$ and \f$ \hat{\sigma} \f$) of the
-  /// sampled distribution. It is used to provide this information in bins
-  /// and for the "hidden" \f$ y \f$ distribution in profile histogram bins.
+  /// @brief A 1D distribution
+  ///
+  /// This class is used internally by YODA to centralise the calculation of
+  /// statistics of unbounded, unbinned sampled distributions. Each distribution
+  /// fill contributes a weight, \f$ w \f$, and a value, \f$ x \f$. By storing
+  /// the total number of fills (ignoring weights), \f$ \sum w \f$, \f$ \sum w^2
+  /// \f$, \f$ \sum wx \f$, and \f$ \sum wx^2 \f$, the Dbn1D can calculate the
+  /// mean and spread (\f$ \sigma^2 \f$, \f$ \sigma \f$ and \f$ \hat{\sigma}
+  /// \f$) of the sampled distribution. It is used to provide this information
+  /// in bins and for the "hidden" \f$ y \f$ distribution in profile histogram
+  /// bins.
   class Dbn1D {
   public:
 

Modified: trunk/include/YODA/Exceptions.h
==============================================================================
--- trunk/include/YODA/Exceptions.h	Tue Aug 16 15:04:57 2011	(r253)
+++ trunk/include/YODA/Exceptions.h	Tue Aug 16 15:16:43 2011	(r254)
@@ -14,8 +14,9 @@
 
 
   /// @brief Generic unspecialised YODA runtime error.
-  /// NB. We don't use "Error" because that's a useful stats
-  /// word to have available!
+  ///
+  /// NB. We don't use "Error" because that's a useful stats word to have
+  /// available!
   class Exception : public std::runtime_error {
   public:
     Exception(const std::string& what) : std::runtime_error(what) {}
@@ -43,6 +44,7 @@
 
 
   /// @brief Errors relating to event/bin weights
+  ///
   /// Arises in computing statistical quantities because e.g. the bin
   /// weight is zero or negative.
   class WeightError : public Exception {

Modified: trunk/src/Bin2D.cc
==============================================================================
--- trunk/src/Bin2D.cc	Tue Aug 16 15:04:57 2011	(r253)
+++ trunk/src/Bin2D.cc	Tue Aug 16 15:16:43 2011	(r254)
@@ -11,9 +11,11 @@
 
 namespace YODA {
 
+
   Bin2D::Bin2D(double lowedgeX, double lowedgeY, double highedgeX, double highedgeY) {
-    if(lowedgeX > highedgeX || lowedgeY > highedgeY) throw RangeError("The bins are wrongly defined!"); 
-    
+    if (lowedgeX > highedgeX || lowedgeY > highedgeY) {
+      throw RangeError("The bins are wrongly defined!");
+    }
     _edges.first.first = lowedgeX;
     _edges.first.second = lowedgeY;
     _edges.second.first = highedgeX;
@@ -22,17 +24,20 @@
     isReal = true;
   }
 
-  Bin2D::Bin2D(std::vector<std::pair<std::pair<double,double>,
-               std::pair<double,double> > > edges) {
-    if(edges.size() != 4) throw RangeError("The edge vector does not define a full rectangle!");
-    
-    _edges.first.first = edges[0].first.first;
-    _edges.first.second = edges[0].first.second;
-    _edges.second.first = edges[1].second.first;
-    _edges.second.second = edges[1].second.second;
 
-    isReal = true;
-  }
+  // Bin2D::Bin2D(std::vector<std::pair<std::pair<double,double>,
+  //              std::pair<double,double> > > edges) {
+  //   if (edges.size() != 4) {
+  //     throw RangeError("The edge vector does not define a full rectangle!");
+  //   }
+  //   _edges.first.first = edges[0].first.first;
+  //   _edges.first.second = edges[0].first.second;
+  //   _edges.second.first = edges[1].second.first;
+  //   _edges.second.second = edges[1].second.second;
+
+  //   isReal = true;
+  // }
+
 
   void Bin2D::scaleXY(double scaleX, double scaleY) {
     _edges.first.first *= scaleX;
@@ -44,31 +49,36 @@
     _dbn.scaleXY(scaleX, scaleY);
   }
 
+
   std::pair<double,double> Bin2D::midpoint() const {
     return make_pair((double)(xMax() - xMin())/2 + xMin(), (double)(yMax() - yMin())/2 + yMin());
   }
 
-    Bin2D& Bin2D::subtract(const Bin2D& b) {
-        /// Automatically resize if adding a bin that does not have the same location
-        /// this way merging the bins works perfectly
-        if(_edges != b._edges) {
-          if (b.xMax() > xMax()) _setBounds(xMin(), yMin(), b.xMax(), yMax());
-          if (b.yMax() > yMax()) _setBounds(xMin(), yMin(), xMax(), b.yMax());
-          if (b.xMin() < xMin()) _setBounds(b.xMin(), yMin(), xMax(), yMax());
-          if (b.yMin() < yMin()) _setBounds(xMin(), b.yMin(), xMax(), yMax());
-        }
-        _dbn -= b._dbn;
-        return *this;
+
+  Bin2D& Bin2D::subtract(const Bin2D& b) {
+    // Automatically resize if adding a bin that does not have the same location
+    // this way merging the bins works perfectly
+    if (_edges != b._edges) {
+      if (b.xMax() > xMax()) _setBounds(xMin(), yMin(), b.xMax(), yMax());
+      if (b.yMax() > yMax()) _setBounds(xMin(), yMin(), xMax(), b.yMax());
+      if (b.xMin() < xMin()) _setBounds(b.xMin(), yMin(), xMax(), yMax());
+      if (b.yMin() < yMin()) _setBounds(xMin(), b.yMin(), xMax(), yMax());
     }
+    _dbn -= b._dbn;
+    return *this;
+  }
+
 
     Bin2D& Bin2D::add(const Bin2D& b) {
-        if(_edges != b._edges) {
-          if (b.highEdgeX() > highEdgeX());// _setBounds(xMin(), yMin(), b.xMax(), yMax());
-          if (b.yMax() > yMax()) _setBounds(xMin(), yMin(), xMax(), b.yMax());
-          if (b.xMin() < xMin()) _setBounds(b.xMin(), yMin(), xMax(), yMax());
-          if (b.yMin() < yMin()) _setBounds(xMin(), b.yMin(), xMax(), yMax());
-        }
-        _dbn += b._dbn;
-        return *this;
+      if (_edges != b._edges) {
+        if (b.highEdgeX() > highEdgeX());// _setBounds(xMin(), yMin(), b.xMax(), yMax());
+        if (b.yMax() > yMax()) _setBounds(xMin(), yMin(), xMax(), b.yMax());
+        if (b.xMin() < xMin()) _setBounds(b.xMin(), yMin(), xMax(), yMax());
+        if (b.yMin() < yMin()) _setBounds(xMin(), b.yMin(), xMax(), yMax());
+      }
+      _dbn += b._dbn;
+      return *this;
     }
+
+
 }


More information about the yoda-svn mailing list