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

blackhole at projects.hepforge.org blackhole at projects.hepforge.org
Fri Aug 19 11:45:35 BST 2011


Author: mkawalec
Date: Fri Aug 19 11:45:35 2011
New Revision: 303

Log:
Isolated out the copy constructor/division part of Histo2D tests into a new test as this part crashes the most.

Added:
   trunk/tests/TestHisto2Da.cc
Modified:
   trunk/include/YODA/Histo2D.h
   trunk/tests/Makefile.am
   trunk/tests/TestHisto2D.cc

Modified: trunk/include/YODA/Histo2D.h
==============================================================================
--- trunk/include/YODA/Histo2D.h	Fri Aug 19 10:45:37 2011	(r302)
+++ trunk/include/YODA/Histo2D.h	Fri Aug 19 11:45:35 2011	(r303)
@@ -64,7 +64,11 @@
     Histo2D(const Histo2D& h, const std::string& path="")
       : AnalysisObject("Histo2D", (path.size() == 0) ? h.path() : path, h, h.title())
     {
+      cout << " blah" << endl << endl << endl;
+     cout << "dasdasd"; 
+      cout << "in" << endl;
       _axis = h._axis;
+      cout << "out" << endl;
     }
 
 

Modified: trunk/tests/Makefile.am
==============================================================================
--- trunk/tests/Makefile.am	Fri Aug 19 10:45:37 2011	(r302)
+++ trunk/tests/Makefile.am	Fri Aug 19 11:45:35 2011	(r303)
@@ -3,6 +3,7 @@
 	testhisto1Da testhisto1Db \
 	testprofile1Da \
   testhisto2D  \
+  testhisto2Da  \
   testpoint3D  \
   testscatter3D\
 	testindexedset testsortedvector
@@ -17,6 +18,7 @@
 testindexedset_SOURCES = TestIndexedSet.cc
 testsortedvector_SOURCES = TestSortedVector.cc
 testhisto2D_SOURCES = TestHisto2D.cc
+testhisto2Da_SOURCES = TestHisto2Da.cc
 testpoint3D_SOURCES = TestPoint3D.cc
 testscatter3D_SOURCES = TestScatter3D.cc
 
@@ -31,6 +33,7 @@
 	testhisto1Da testhisto1Db \
 	testprofile1Da \
   testhisto2D    \
+  testhisto2Da    \
   testpoint3D    \
   testscatter3D  \
 	testindexedset testsortedvector \

Modified: trunk/tests/TestHisto2D.cc
==============================================================================
--- trunk/tests/TestHisto2D.cc	Fri Aug 19 10:45:37 2011	(r302)
+++ trunk/tests/TestHisto2D.cc	Fri Aug 19 11:45:35 2011	(r303)
@@ -157,23 +157,6 @@
         return -1;
     }
 
-    // Addition/Subtraction:
-    cout << "Creating histos to be added/subtracted/divided:" << endl;
-
-    Histo2D first(10, 0, 100, 10, 0, 100);
-    first.fill(1,1,1);
-    first.fill(23,1,1);
-    Histo2D second(10, 0, 100, 10, 0, 100);
-    second.fill(1,1,1);
-
-    cout << "Adding/Subtracting/Dividing" << endl;
-    Histo2D added(first+second);
-    Histo2D subtracted(first-second);
-    Scatter3D divided(first/second);
-
-    cout << "Done!" << endl;
-    printStats(added);
-    printStats(subtracted);
 
 
     // And now, test cuts:
@@ -222,5 +205,6 @@
 
     cout << "Time to merge 20k bins: " << tE - tS << "s" << endl;
 
+    cout << "-----------------------------" << endl;
     return EXIT_SUCCESS;
 }

Added: trunk/tests/TestHisto2Da.cc
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ trunk/tests/TestHisto2Da.cc	Fri Aug 19 11:45:35 2011	(r303)
@@ -0,0 +1,66 @@
+
+#include "YODA/Histo2D.h"
+#include "YODA/Scatter3D.h"
+
+#include <cmath>
+#include <iostream>
+#include <unistd.h>
+#include <sys/time.h>
+
+using namespace std;
+using namespace YODA;
+
+
+// A stats printing function.
+//
+// A very unpolished stats printing function. It prints some stats, sometimes
+// looking at the full distribution and sometimes not. A better version is not
+// too high on the priority list right now!
+void printStats(Histo2D& h, bool full=false){
+    cout << "-----------------------------" << endl;
+    cout << "LowEdgeX = " << h.lowEdgeX() << " HighEdgeX = " << h.highEdgeX() << endl;
+    cout << "LowEdgeY = " << h.lowEdgeY() << " HighEdgeY = " << h.highEdgeY() << endl;
+
+    cout << "Sum of weights is " << h.sumW(true) << ", squared: " << h.sumW2(true) << endl;
+
+    if (full) {
+        cout << "Means: " << h.xMean(true) << " " << h.yMean(true) << endl;
+        cout << "Variance: " << h.xVariance(true) << " " << h.yVariance(true) << endl;
+        cout << "StdDevs: " << h.xStdDev(true) << " " << h.yStdDev(true) << endl;
+    }
+    cout << "-----------------------------" << endl;
+}
+
+
+
+int main() {
+ 
+    cout << "-----------------------------" << endl;
+    // Addition/Subtraction:
+    cout << "Creating histos to be added/subtracted/divided:" << endl;
+
+    Histo2D first(10, 0, 100, 10, 0, 100);
+    first.fill(1,1,1);
+    first.fill(23,1,1);
+    Histo2D second(10, 0, 100, 10, 0, 100);
+    second.fill(1,1,1);
+
+    cout << "Adding/Subtracting/Dividing" << endl;
+    cout << "Testing the copy constructor:" << endl;
+    Histo2D h(20, 0, 100, 20, 0, 100);
+    Histo2D copyTest(h);
+    cout << "Tested" << endl;
+
+    Histo2D added(first+second);
+    cout << "Addition? Copy constructor?" << endl;
+    Histo2D subtracted(first-second);
+    cout << "Division crashes!" << endl;
+    Scatter3D divided(first/second);
+
+    cout << "Done!" << endl;
+    printStats(added);
+    printStats(subtracted);
+
+    cout << "-----------------------------" << endl;
+    return EXIT_SUCCESS;
+}


More information about the yoda-svn mailing list