|
[yoda-svn] r366 - in trunk: include/YODA tests/Histo2Dblackhole at projects.hepforge.org blackhole at projects.hepforge.orgThu Aug 25 15:04:25 BST 2011
Author: mkawalec Date: Thu Aug 25 15:04:25 2011 New Revision: 366 Log: Added (in)equality operators to Profile1D. Proved (1M random points, included in tests) that Histo2D is equivalent to Profile1D binned in the same way. Modified: trunk/include/YODA/Profile1D.h trunk/tests/Histo2D/H2DModify.cc Modified: trunk/include/YODA/Profile1D.h ============================================================================== --- trunk/include/YODA/Profile1D.h Thu Aug 25 14:47:01 2011 (r365) +++ trunk/include/YODA/Profile1D.h Thu Aug 25 15:04:25 2011 (r366) @@ -254,6 +254,13 @@ return *this; } + inline bool operator == (const Profile1D& other){ + return _axis == other._axis; + } + + inline bool operator != (const Profile1D& other){ + return ! operator == (other); + } //@} @@ -273,6 +280,7 @@ /// @name Combining profile histos: global operators //@{ + /// Add two profile histograms inline Profile1D add(const Profile1D& first, const Profile1D& second) { Profile1D tmp = first; Modified: trunk/tests/Histo2D/H2DModify.cc ============================================================================== --- trunk/tests/Histo2D/H2DModify.cc Thu Aug 25 14:47:01 2011 (r365) +++ trunk/tests/Histo2D/H2DModify.cc Thu Aug 25 15:04:25 2011 (r366) @@ -1,9 +1,11 @@ #include "YODA/Histo2D.h" +#include "YODA/Profile1D.h" #include "YODA/Scatter3D.h" #include <cmath> #include <iostream> #include <unistd.h> +#include <cstdlib> #include <sys/time.h> using namespace std; @@ -154,6 +156,30 @@ tS = (startTime.tv_sec*1000000 + startTime.tv_usec)/(double)1000000; tE = (endTime.tv_sec*1000000 + endTime.tv_usec)/(double)1000000; cout << "PASS (" << tE - tS << ")" << endl; + + cout << "Testing if histo2D transforms to Profile:"; + Histo2D test1(100, 0, 100, 100, 0, 100); + Profile1D test2(100, 0, 100); + + test1.fill(1,1,1); + test2.fill(1,1,1); + if(test2 != test1.mkProfileX()){ + cout << "FAIL" << endl; + return -1; + } + cout << "PASS" << endl; + cout << "A more elaborate test: "; + for(size_t i = 0; i < 100000; ++i){ + size_t x = rand()%100; + size_t y = rand()%100; + test1.fill(x,y,1); + test2.fill(x,y,2); + } + if(test2 != test1.mkProfileX()){ + cout << "FAIL" << endl; + return -1; + } + cout << "PASS" << endl; return EXIT_SUCCESS; }
More information about the yoda-svn mailing list |