[yoda-svn] r297 - trunk/tests

blackhole at projects.hepforge.org blackhole at projects.hepforge.org
Thu Aug 18 22:36:54 BST 2011


Author: buckley
Date: Thu Aug 18 22:36:54 2011
New Revision: 297

Log:
Cosmetics

Modified:
   trunk/tests/TestHisto2D.cc

Modified: trunk/tests/TestHisto2D.cc
==============================================================================
--- trunk/tests/TestHisto2D.cc	Thu Aug 18 22:36:40 2011	(r296)
+++ trunk/tests/TestHisto2D.cc	Thu Aug 18 22:36:54 2011	(r297)
@@ -10,13 +10,11 @@
 using namespace YODA;
 
 
-/// A stats printing function.
-/**
- * This is a very, very unpolished version of a stats
- * printing function. It prints some stats sometimest
- * looking at the full distribution and sometimes not.
- * A better verion is not to high in priority list now.
- */
+// 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;
@@ -24,7 +22,7 @@
 
     cout << "Sum of weights is " << h.sumW(true) << ", squared: " << h.sumW2(true) << endl;
 
-    if(full) {
+    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;
@@ -32,9 +30,11 @@
     cout << "-----------------------------" << endl;
 }
 
+
+
 int main() {
 
-    /// Creating a histogram and measuring the time it takes to do it.
+    // Creating a histogram and measuring the time it takes to do it.
     struct timeval startTime;
     struct timeval endTime;
     gettimeofday(&startTime, NULL);
@@ -47,11 +47,11 @@
     printStats(h);
 
 
-    /// Trying to fill a bin.
+    // Trying to fill a bin.
     gettimeofday(&startTime, NULL);
     for (int i=0; i < 2000; i++) {
         int out = h.fill(16.0123, 12.213, 2);
-        if(out == -1) {
+        if (out == -1) {
             cout << "I wasn't able to find the bin, something must be incorrect in the search algorithm." << endl;
             return -1;
         }
@@ -61,7 +61,7 @@
     tS = (startTime.tv_sec*1000000 + startTime.tv_usec)/(double)1000000;
     tE = (endTime.tv_sec*1000000 + endTime.tv_usec)/(double)1000000;
     cout << "Time taken to fill 2000 bins: " << tE - tS << "s" << endl;
-    if((tE - tS) > 50.0) {
+    if ((tE - tS) > 50.0) {
         cout << "Performance is not sufficient. Probably broken caches?" << endl;
         return -1;
     }
@@ -75,71 +75,69 @@
     printStats(h, false);
     cout << h.numBinsTotal() << endl;
 
-    /// Testing if fill() function does what it should
+    // Testing if fill() function does what it should
     unsigned int beforeAdd = h.numBinsTotal();
     cout << "Does a too high bin exist? " << h.fill(10000, 34234, 1) << endl;
-    if(h.numBinsTotal() != beforeAdd) {
+    if (h.numBinsTotal() != beforeAdd) {
         cout << "An incorrect bin seems to have been added. The other solution is an error in numBinsTotal()" << endl;
         return -1;
     }
 
 
-    /// Checking if everything is still working as desired.
-    /**
-     * It is actually a good thing to do, as at some earlier stages
-     * in developement adding a broken bin destroyed the cache of edges.
-     */
+    // Checking if everything is still working as desired.
+    // It is actually a good thing to do, as at some earlier stages
+    // in development adding a broken bin destroyed the cache of edges.
     int originIndex = h.fill(0.0, 0.0, 1);
     cout << "And is the origin working in the right way? " << originIndex << endl;
-    if(originIndex == -1) {
+    if (originIndex == -1) {
         cout << "The origin was not found!" << endl;
         return -1;
     }
 
     printStats(h, true);
 
-    /// Now, adding a square that is in a non-overlapping location:
+    // Now, adding a square that is in a non-overlapping location:
     beforeAdd = h.numBinsTotal();
     h.addBin(150, 150, 200, 200);
-    cout << "Added proprely? " << h.fill(150.1, 150.1, 1) << " Size: " << h.numBinsTotal() << endl;
-    if(beforeAdd == h.numBinsTotal()) {
+    cout << "Added properly? " << h.fill(150.1, 150.1, 1) << " Size: " << h.numBinsTotal() << endl;
+    if (beforeAdd == h.numBinsTotal()) {
         cout << "A bin that should be added wasn't added." << endl;
         return -1;
     }
 
-    /// Checking if a broken bin triggers _dropEdge().
+    // Checking if a broken bin triggers _dropEdge().
     beforeAdd = h.numBinsTotal();
     h.addBin(0.756, 0.213, 12.1234, 23);
     cout << "Size: " << h.numBinsTotal() << endl;
-    if(beforeAdd != h.numBinsTotal()) {
+    if (beforeAdd != h.numBinsTotal()) {
         cout << "Detection of overlapping edges doesn't work!" << endl;
         return -1;
     }
 
     int fillTest = h.fill(0.0, 1.0, 1);
     cout << "And a fill sanity check: " << fillTest << endl;
-    if(fillTest == -1) {
+    if (fillTest == -1) {
         cout << "An undefined error with fill had occured." << endl;
         return -1;
     }
 
-    /// A check testing mostly _fixOrientation()
+    // A check testing mostly _fixOrientation()
     cout << "Now, how about another quadrant? " << endl;
     beforeAdd = h.numBinsTotal();
     h.addBin(-12, -12, -1, -1);
-    if(beforeAdd == h.numBinsTotal()) {
+    if (beforeAdd == h.numBinsTotal()) {
         cout << "A bin that should be added could not be added." << endl;
         return -1;
     }
 
     fillTest = h.fill(-3, -3, 1);
     cout << "Trying to fill the newly created bin: " << fillTest << endl;
-    if(fillTest == -1 || fillTest != (int)h.numBinsTotal() - 1) {
+    if (fillTest == -1 || fillTest != (int)h.numBinsTotal() - 1) {
         cout << "Could not fill the bin that should be filled" << endl;
         return -1;
     }
 
-    /// And a scaling test.
+    // And a scaling test.
     printStats(h, true);
     cout << "Scaling: " << endl;
 
@@ -154,13 +152,13 @@
 
     fillTest = h.fill(180, 180, 1);
     cout << "Was everything scaled as it should be? " << fillTest << endl;
-    if(fillTest == -1) {
+    if (fillTest == -1) {
         cout << "Something went wrong while scaling." << endl;
         return -1;
     }
 
-    /// Addition/Subtraction:
-    cout << "Creating histos to be added/substracted/divided:" << 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);
@@ -168,7 +166,7 @@
     Histo2D second(10, 0, 100, 10, 0, 100);
     second.fill(1,1,1);
 
-    cout << "Adding/Substracting/Dividing" << endl;
+    cout << "Adding/Subtracting/Dividing" << endl;
     Histo2D added(first+second);
     Histo2D subtracted(first-second);
     Scatter3D divided(first/second);
@@ -178,40 +176,39 @@
     printStats(subtracted);
 
 
-    ///And now, test cuts:
+    // And now, test cuts:
 
     cout << endl << endl << endl << "Testing cuts: " << endl;
     Histo2D sampleHisto(50, 0, 100, 39, 0, 10);
     sampleHisto.fill(0,0,123121);
     cout << sampleHisto.sumW(false) << " " << sampleHisto.sumW2(false) << endl;
     printStats(sampleHisto);
-    if(!fuzzyEquals(sampleHisto.sumW(false), (double)123121)) {
+    if (!fuzzyEquals(sampleHisto.sumW(false), (double)123121)) {
         cout << "Something is wrong with weight filling!!" << endl;
         return -1;
     }
-    if(!fuzzyEquals(sampleHisto.sumW2(false), 1.51588e+10)) {
+    if (!fuzzyEquals(sampleHisto.sumW2(false), 1.51588e+10)) {
         cout << "Something is wrong with weight squared! It is: " << sampleHisto.sumW2(false)<< endl;
         return -1;
     }
 
     Histo1D atY(sampleHisto.cutterX(0));
     cout << atY.sumW(false) << " " <<sampleHisto.sumW(false) << endl;
-    if(!fuzzyEquals(atY.sumW(false), sampleHisto.sumW(false))){
+    if (!fuzzyEquals(atY.sumW(false), sampleHisto.sumW(false))){
         cout << "Something is wrong with weights when cut parallell to X axis." << endl;
         return -1;
     }
 
     Histo1D atX(sampleHisto.cutterY(0));
     cout << atX.sumW(false) << " " << atX.numBins() << endl;
-    if(!fuzzyEquals(atX.sumW(false), sampleHisto.sumW(false))){
+    if (!fuzzyEquals(atX.sumW(false), sampleHisto.sumW(false))){
         cout << "Something is wrong with weights when cut parallell to Y axis." << endl;
         return -1;
     }
 
-
     Histo1D atX2(sampleHisto.cutterX(2));
     cout << atX2.sumW(false) << " " << atX2.numBins() << endl;
-    if(!fuzzyEquals(atX2.sumW(false), 0)){
+    if (!fuzzyEquals(atX2.sumW(false), 0)){
         cout << "Probably the cuts are not done properly!" << endl;
         return -1;
     }
@@ -222,7 +219,7 @@
     gettimeofday(&endTime, NULL);
     tS = (startTime.tv_sec*1000000 + startTime.tv_usec)/(double)1000000;
     tE = (endTime.tv_sec*1000000 + endTime.tv_usec)/(double)1000000;
-    
+
     cout << "Time to merge 20k bins: " << tE - tS << "s" << endl;
 
     return EXIT_SUCCESS;


More information about the yoda-svn mailing list