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

blackhole at projects.hepforge.org blackhole at projects.hepforge.org
Thu Aug 18 19:15:18 BST 2011


Author: mkawalec
Date: Thu Aug 18 19:15:18 2011
New Revision: 294

Log:
Made Axis2D to accept a general distribution (added typedef for DBN).

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

Modified: trunk/include/YODA/Axis2D.h
==============================================================================
--- trunk/include/YODA/Axis2D.h	Thu Aug 18 19:00:06 2011	(r293)
+++ trunk/include/YODA/Axis2D.h	Thu Aug 18 19:15:18 2011	(r294)
@@ -20,7 +20,7 @@
   /// on 2D bins (like creating axis, adding, searching, testing).
   ///
   /// @todo This needs an extra DBN template argument, cf. Axis1D
-  template <typename BIN>
+  template <typename BIN, typename DBN>
   class Axis2D {
 
     /// When edge is added to the collection it must
@@ -100,8 +100,8 @@
     /// Creates an Axis2D from existing bins
     /// @todo This is too large to be inline: move to the .cc
     Axis2D(const Bins& bins,
-           const std::vector<std::vector<Dbn2D> >& outflows,
-           const Dbn2D& totalDbn)
+           const std::vector<std::vector<DBN> >& outflows,
+           const DBN& totalDbn)
     {
       vector<Segment> binLimits;
       for (size_t i = 0; i < bins.size(); ++i) {
@@ -305,12 +305,12 @@
     }
 
     /// Get the outflows (non-const version)
-    vector<vector<Dbn2D> >& outflows() {
+    vector<vector<DBN> >& outflows() {
       return _outflows;
     }
 
     /// Get the outflows (const version)
-    const vector<vector<Dbn2D> >& outflows() const {
+    const vector<vector<DBN> >& outflows() const {
       return _outflows;
     }
 
@@ -355,12 +355,12 @@
 
 
     /// Get the total distribution (non-const version)
-    Dbn2D& totalDbn() {
+    DBN& totalDbn() {
       return _dbn;
     }
 
     /// Get the total distribution (const version)
-    const Dbn2D& totalDbn() const {
+    const DBN& totalDbn() const {
       return _dbn;
     }
 
@@ -504,7 +504,7 @@
     /// @brief Addition operator
     /// At this stage it is only possible to add histograms with the same binnings.
     /// @todo Compatible but not equal binning to come soon.
-    Axis2D<BIN>& operator += (const Axis2D<BIN>& toAdd) {
+    Axis2D<BIN, DBN>& operator += (const Axis2D<BIN, DBN>& toAdd) {
       if (*this != toAdd) {
         throw LogicError("YODA::Histo1D: Cannot add axes with different binnings.");
       }
@@ -520,7 +520,7 @@
     ///
     /// At this stage it is only possible to subtract histograms with the same binnings.
     /// @todo Compatible but not equal binning to come soon.
-    Axis2D<BIN>& operator -= (const Axis2D<BIN>& toSubtract) {
+    Axis2D<BIN, DBN>& operator -= (const Axis2D<BIN, DBN>& toSubtract) {
       if (*this != toSubtract) {
         throw LogicError("YODA::Histo1D: Cannot add axes with different binnings.");
       }
@@ -967,12 +967,12 @@
     /// Overflow distributions
     ///
     /// @todo Explain how the vector structure works!
-    vector<vector<Dbn2D> > _outflows;
+    vector<vector<DBN> > _outflows;
 
     /// The total distribution
     ///
     /// @todo This needs to be a templated DBN type
-    Dbn2D _dbn;
+    DBN _dbn;
 
     /// @brief Bin hash structure
     ///
@@ -995,19 +995,19 @@
   //@{
 
   /// Addition operator
-  template <typename BIN>
-  inline Axis2D<BIN> operator + (const Axis2D<BIN>& first, const Axis2D<BIN>& second) {
-    Axis2D<BIN> tmp = first;
+  template <typename BIN, typename DBN>
+  inline Axis2D<BIN, DBN> operator + (const Axis2D<BIN, DBN>& first, const Axis2D<BIN, DBN>& second) {
+    Axis2D<BIN, DBN> tmp = first;
     tmp += second;
     return tmp;
   }
 
 
   /// Subtraction operator
-  template <typename BIN>
-  inline Axis2D<BIN> operator - (const Axis2D<BIN>& first, const Axis2D<BIN>& second)
+  template <typename BIN, typename DBN>
+  inline Axis2D<BIN, DBN> operator - (const Axis2D<BIN, DBN>& first, const Axis2D<BIN, DBN>& second)
   {
-    Axis2D<BIN> tmp = first;
+    Axis2D<BIN, DBN> tmp = first;
     tmp -= second;
     return tmp;
   }

Modified: trunk/include/YODA/Histo2D.h
==============================================================================
--- trunk/include/YODA/Histo2D.h	Thu Aug 18 19:00:06 2011	(r293)
+++ trunk/include/YODA/Histo2D.h	Thu Aug 18 19:15:18 2011	(r294)
@@ -24,7 +24,7 @@
   class Scatter3D;
 
   /// Convenience typedef
-  typedef Axis2D<HistoBin2D> Histo2DAxis;
+  typedef Axis2D<HistoBin2D, Dbn2D> Histo2DAxis;
 
 
   /// A  one-dimensional histogram.
@@ -445,7 +445,7 @@
     //@{
 
     /// Definition of bin edges and contents
-    Axis2D<HistoBin2D> _axis;
+    Axis2D<HistoBin2D, Dbn2D> _axis;
 
     //@}
 


More information about the yoda-svn mailing list