[yoda-svn] r351 - in trunk: include/YODA tests/Profile1D

blackhole at projects.hepforge.org blackhole at projects.hepforge.org
Wed Aug 24 14:31:20 BST 2011


Author: mkawalec
Date: Wed Aug 24 14:31:19 2011
New Revision: 351

Log:
Added bin addition operators to Profile1D, added one more constructor test to Profile1D/Create test.

Modified:
   trunk/include/YODA/Axis1D.h
   trunk/include/YODA/Profile1D.h
   trunk/tests/Profile1D/P1DCreate.cc

Modified: trunk/include/YODA/Axis1D.h
==============================================================================
--- trunk/include/YODA/Axis1D.h	Wed Aug 24 14:03:01 2011	(r350)
+++ trunk/include/YODA/Axis1D.h	Wed Aug 24 14:31:19 2011	(r351)
@@ -250,7 +250,7 @@
 
 
     /// Add a set of bins specifying start/end of each
-    void addBin(const std::vector<std::pair<double,double> > edges) {
+    void addBin(const std::vector<std::pair<double,double> >& edges) {
       for (size_t i = 0; i < edges.size(); ++i) {
         std::vector<double> temp;
         temp.push_back(edges[i].first);

Modified: trunk/include/YODA/Profile1D.h
==============================================================================
--- trunk/include/YODA/Profile1D.h	Wed Aug 24 14:03:01 2011	(r350)
+++ trunk/include/YODA/Profile1D.h	Wed Aug 24 14:31:19 2011	(r351)
@@ -137,6 +137,19 @@
     void rebin(int n) {
       _axis.rebin(n);
     }
+    
+    /// Bin addition operator
+    void addBin(size_t& from, size_t& to) {
+      _axis.addBin(from, to);
+    }
+
+    void addBin(const std::vector<double>& binedges) {
+      _axis.addBin(binedges);
+    }
+
+    void addBin(const std::vector<std::pair<double,double> >& edges) {
+      _axis.addBin(edges);
+    }
 
     //@}
 

Modified: trunk/tests/Profile1D/P1DCreate.cc
==============================================================================
--- trunk/tests/Profile1D/P1DCreate.cc	Wed Aug 24 14:03:01 2011	(r350)
+++ trunk/tests/Profile1D/P1DCreate.cc	Wed Aug 24 14:31:19 2011	(r351)
@@ -7,7 +7,27 @@
 int main() {
   cout << "Testing range/number constructor         ";
   Profile1D p1(100, 0, 100);
+  if(p1.sumW() != 0 || p1.sumW2() != 0 || p1.sumW(false) != 0 || p1.sumW2(false) != 0){
+    cout << "FAIL" << endl;
+    return -1;
+  }
+  cout << "PASS" << endl;
+
+  cout << "Testing explicit edges constructor       ";
+  vector<double> edges;
+  for(size_t i = 0; i < 101; ++i) edges.push_back(i);
+  Profile1D p2(edges);
   
+  if(p2.sumW() != 0 || p2.sumW2() != 0 || p2.sumW(false) != 0 || p2.sumW2(false) != 0){
+    cout << "FAIL" << endl;
+    return -1;
+  }
+  if(p2.numBins() != 100){
+    cout << "FAIL" << endl;
+    return -1;
+  }
   cout << "PASS" << endl;
+
+
   return EXIT_SUCCESS;
 }


More information about the yoda-svn mailing list