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

blackhole at projects.hepforge.org blackhole at projects.hepforge.org
Thu Aug 25 09:05:22 BST 2011


Author: buckley
Date: Thu Aug 25 09:05:22 2011
New Revision: 355

Log:
A few more API typedefs and using foreach where possible in the Profile1D implementation

Modified:
   trunk/include/YODA/Histo1D.h
   trunk/include/YODA/Histo2D.h
   trunk/include/YODA/Profile1D.h
   trunk/src/Profile1D.cc

Modified: trunk/include/YODA/Histo1D.h
==============================================================================
--- trunk/include/YODA/Histo1D.h	Wed Aug 24 14:56:50 2011	(r354)
+++ trunk/include/YODA/Histo1D.h	Thu Aug 25 09:05:22 2011	(r355)
@@ -31,6 +31,7 @@
     /// Convenience typedefs
     typedef Histo1DAxis Axis;
     typedef Axis::Bins Bins;
+    typedef HistoBin1D Bin;
 
 
     /// @name Constructors

Modified: trunk/include/YODA/Histo2D.h
==============================================================================
--- trunk/include/YODA/Histo2D.h	Wed Aug 24 14:56:50 2011	(r354)
+++ trunk/include/YODA/Histo2D.h	Thu Aug 25 09:05:22 2011	(r355)
@@ -36,6 +36,7 @@
     /// Convenience typedefs
     typedef Histo2DAxis Axis;
     typedef Axis::Bins Bins;
+    typedef HistoBin2D Bin;
 
 
     /// @name Constructors

Modified: trunk/include/YODA/Profile1D.h
==============================================================================
--- trunk/include/YODA/Profile1D.h	Wed Aug 24 14:56:50 2011	(r354)
+++ trunk/include/YODA/Profile1D.h	Thu Aug 25 09:05:22 2011	(r355)
@@ -35,6 +35,7 @@
     /// Convenience typedefs
     typedef Profile1DAxis Axis;
     typedef Axis::Bins Bins;
+    typedef ProfileBin1D Bin;
 
 
     /// @name Constructors
@@ -137,7 +138,7 @@
     void rebin(int n) {
       _axis.rebin(n);
     }
-    
+
     /// Bin addition operator
     void addBin(size_t& from, size_t& to) {
       _axis.addBin(from, to);

Modified: trunk/src/Profile1D.cc
==============================================================================
--- trunk/src/Profile1D.cc	Wed Aug 24 14:56:50 2011	(r354)
+++ trunk/src/Profile1D.cc	Thu Aug 25 09:05:22 2011	(r355)
@@ -15,29 +15,25 @@
 namespace YODA {
 
 
-  typedef vector<ProfileBin1D> Bins;
-
-
   void Profile1D::fill(double x, double y, double weight) {
-    
-    /// Filling under/over flows
-    if(x < _axis.xMin()) _axis.underflow().fill(x, y, weight);
-    else if(x >= _axis.xMax()) _axis.overflow().fill(x, y, weight);
-    else {
+    // Filling under/over flows
+    if (x < _axis.xMin()) {
+      _axis.underflow().fill(x, y, weight);
+    } else if (x >= _axis.xMax()) {
+      _axis.overflow().fill(x, y, weight);
+    } else {
       ProfileBin1D& b = binByCoord(x);
       b.fill(x, y, weight);
     }
-
     _axis.totalDbn().fill(x, y, weight);
-
   }
 
 
   double Profile1D::sumW(bool includeoverflows) const {
     if (includeoverflows) return _axis.totalDbn().sumW();
     double sumw = 0;
-    for (Bins::const_iterator b = bins().begin(); b != bins().end(); ++b) {
-      sumw += b->sumW();
+    foreach (const ProfileBin1D& b, bins()) {
+      sumw += b.sumW();
     }
     return sumw;
   }
@@ -46,8 +42,8 @@
   double Profile1D::sumW2(bool includeoverflows) const {
     if (includeoverflows) return _axis.totalDbn().sumW2();
     double sumw2 = 0;
-    for (Bins::const_iterator b = bins().begin(); b != bins().end(); ++b) {
-      sumw2 += b->sumW2();
+    foreach (const ProfileBin1D& b, bins()) {
+      sumw2 += b.sumW2();
     }
     return sumw2;
   }
@@ -69,8 +65,8 @@
     : AnalysisObject("Profile1D", (path.size() == 0) ? s.path() : path, s, s.title())
   {
     std::vector<ProfileBin1D> bins;
-    for (Scatter2D::Points::const_iterator p = s.points().begin(); p != s.points().end(); ++p) {
-      bins.push_back(ProfileBin1D(p->xMin(), p->xMax()));
+    foreach (const Scatter2D::Point& p, s.points()) {
+      bins.push_back(ProfileBin1D(p.xMin(), p.xMax()));
     }
     _axis = Profile1DAxis(bins);
   }
@@ -81,8 +77,8 @@
     : AnalysisObject("Profile1D", (path.size() == 0) ? h.path() : path, h, h.title())
   {
     Bins bins;
-    for (Histo1D::Bins::const_iterator b = h.bins().begin(); b != h.bins().end(); ++b) {
-      bins.push_back(ProfileBin1D(b->xMin(), b->xMax()));
+    foreach (const Histo1D::Bin& b, h.bins()) {
+      bins.push_back(ProfileBin1D(b.xMin(), b.xMax()));
     }
     _axis = Profile1DAxis(bins);
 


More information about the yoda-svn mailing list