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

blackhole at projects.hepforge.org blackhole at projects.hepforge.org
Mon Aug 29 15:59:35 BST 2011


Author: mkawalec
Date: Mon Aug 29 15:59:34 2011
New Revision: 380

Log:
Fixed the functions in src/Profile2D.cc, fixed the maths in Histo2D::divide, added some constructors and (in)equality operators.

Modified:
   trunk/include/YODA/Axis2D.h
   trunk/include/YODA/Profile2D.h
   trunk/src/Histo2D.cc
   trunk/src/Profile2D.cc

Modified: trunk/include/YODA/Axis2D.h
==============================================================================
--- trunk/include/YODA/Axis2D.h	Sun Aug 28 21:30:56 2011	(r379)
+++ trunk/include/YODA/Axis2D.h	Mon Aug 29 15:59:34 2011	(r380)
@@ -132,6 +132,20 @@
       _dbn = totalDbn;
     }
 
+    /// A constructor accepting just a list of bins
+    Axis2D(const Bins& bins) 
+    {
+      std::vector<Segment> binLimits;
+      foreach(Bin bin, bins) {
+        binLimits.push_back(std::make_pair(std::make_pair(bin.xMin(), bin.yMin()),
+                                           std::make_pair(bin.xMax(), bin.yMax())));
+      }
+      _mkAxis(binLimits);
+      for (size_t i = 0; i < _bins.size(); ++i) {
+        _bins[i] = bins[i];
+      }
+      if (isGrid()) _setOutflows();
+    }
 
     /// A copy constructor
     Axis2D(const Axis2D& a) {
@@ -1113,7 +1127,7 @@
     tmp -= second;
     return tmp;
   }
-
+  
   //@}
 
 

Modified: trunk/include/YODA/Profile2D.h
==============================================================================
--- trunk/include/YODA/Profile2D.h	Sun Aug 28 21:30:56 2011	(r379)
+++ trunk/include/YODA/Profile2D.h	Mon Aug 29 15:59:34 2011	(r380)
@@ -28,7 +28,7 @@
     /// Convenience typedefs
     typedef Profile2DAxis Axis;
     typedef Axis::Bins Bins;
-    typedef ProfileBin1D Bin;
+    typedef ProfileBin2D Bin;
     typedef typename std::pair<double, double> Point;
     typedef typename std::pair<Point, Point> Segment;
 
@@ -59,7 +59,7 @@
 
     /// Constructor from a Histo2D's binning, with optional new path
     Profile2D(const Histo2D& h, const std::string& path="");
-
+    
     /// A state setting constructor
     Profile2D();
 

Modified: trunk/src/Histo2D.cc
==============================================================================
--- trunk/src/Histo2D.cc	Sun Aug 28 21:30:56 2011	(r379)
+++ trunk/src/Histo2D.cc	Mon Aug 29 15:59:34 2011	(r380)
@@ -227,11 +227,11 @@
       const double x = bL.focus().first/2;
       const double y = bL.focus().second/2;
 
-      const double exminus = x - bL.xMin();
+      const double exminus = x - bL.xMin()/2;
       const double explus = bL.xMax() - x;
 
-      const double eyminus = y - b1.yMin();
-      const double eyplus = bL.yMax() - y;
+      const double eyminus = y - b1.yMin()/2;
+      const double eyplus = bL.yMax()/2 - y;
 
       const double z = b1.height() / b2.height();
       const double ez = z * sqrt( sqr(b1.heightErr()/b1.height()) + sqr(b2.heightErr()/b2.height()) );

Modified: trunk/src/Profile2D.cc
==============================================================================
--- trunk/src/Profile2D.cc	Sun Aug 28 21:30:56 2011	(r379)
+++ trunk/src/Profile2D.cc	Mon Aug 29 15:59:34 2011	(r380)
@@ -30,30 +30,28 @@
   Profile2D::Profile2D(const Scatter3D& s, const std::string& path)
     : AnalysisObject("Profile2D", (path.size() == 0) ? s.path() : path, s, s.title())
   {
-    throw "IMPLEMENT";
-    std::vector<ProfileBin2D> bins;
+    Bins bins;
     foreach (const Scatter3D::Point& p, s.points()) {
       bins.push_back(ProfileBin2D(p.xMin(), p.yMin(), p.xMax(), p.yMax()));
     }
-    //_axis = Profile2DAxis(bins);
+    _axis = Profile2DAxis(bins);
   }
 
   /// Constructor from a Histo2D's binning, with optional new path
   Profile2D::Profile2D(const Histo2D& h, const std::string& path)
     : AnalysisObject("Profile2D", (path.size() == 0) ? h.path() : path, h, h.title())
   {
-    throw "IMPLEMENT";
     Bins bins;
-    //foreach (const Histo2D::Bin<Dbn2D>& b, h.bins()) {
-     // bins.push_back(ProfileBin2D(b.xMin(), b.yMin(), b.xMax(), b.yMax()));
-    //}
-    //_axis = Profile2DAxis(bins);
+    foreach (const HistoBin2D& b, h.bins()) {
+      bins.push_back(ProfileBin2D(b.xMin(), b.yMin(), b.xMax(), b.yMax()));
+    }
+    _axis = Profile2DAxis(bins);
   }
 
   /// Divide two profile histograms
-  Scatter3D divide(const Profile2D& numer, const Profile2D& denom) {
-    throw "IMPLEMENT!";
-    //assert(numer._axis == denom._axis);
+  Scatter3D divide(Profile2D& numer, Profile2D& denom) {
+    /// @todo Make this check work
+    if(numer != denom) throw "It is impossible to add two incompatibly binned profile histograms!";
     Scatter3D tmp;
     for (size_t i = 0; i < numer.numBins(); ++i) {
       const ProfileBin2D& b1 = numer.bin(i);
@@ -65,7 +63,7 @@
 
       const double x = bA.focus().first/2;
       const double y = bA.focus().second/2;
-      const double z = b1.mean()/b2.mean();;
+      const double z = b1.mean()/b2.mean();
     }
   }  
     //return Scatter3D();


More information about the yoda-svn mailing list