|
[yoda-svn] r400 - in trunk: . include/YODA include/YODA/Utils src tests/Histo2Dblackhole at projects.hepforge.org blackhole at projects.hepforge.orgSun Oct 23 19:54:58 BST 2011
Author: mkawalec Date: Sun Oct 23 19:54:58 2011 New Revision: 400 Log: Fixed some simple, yet critical bugs with logspace and Axis2D. The h2dFill test now takes ages, but it will be fixed tomorrow. Modified: trunk/TODO trunk/include/YODA/Axis2D.h trunk/include/YODA/Histo2D.h trunk/include/YODA/Makefile.am trunk/include/YODA/Utils/MathUtils.h trunk/include/YODA/Writer.h trunk/include/YODA/WriterAIDA.h trunk/include/YODA/WriterYODA.h trunk/src/WriterYODA.cc trunk/tests/Histo2D/H2DFill.cc Modified: trunk/TODO ============================================================================== --- trunk/TODO Wed Oct 12 23:00:26 2011 (r399) +++ trunk/TODO Sun Oct 23 19:54:58 2011 (r400) @@ -40,6 +40,7 @@ MK: Tested, test included in the test suite. * Test bin-comparison and negative-weighted mean calculations. + MK: Scaling of errors is fine;) * Review and SWIG-map Histo2D -> Histo/Profile1D conversion functions. (AB) Modified: trunk/include/YODA/Axis2D.h ============================================================================== --- trunk/include/YODA/Axis2D.h Wed Oct 12 23:00:26 2011 (r399) +++ trunk/include/YODA/Axis2D.h Sun Oct 23 19:54:58 2011 (r400) @@ -476,7 +476,6 @@ const int getBinIndex(double coordX, double coordY) const { // In case we are just operating on a regular grid if (isGrid()) { - /// @todo You can't do this... what if the typical scale of coord is 10e-10? This has to go. coordX += coordX/2000000000; coordY += coordY/2000000000; size_t indexY = (*_binHashSparse.first._cache.lower_bound(approx(coordY))).second; @@ -796,10 +795,12 @@ if (i == _binHashSparse.first.size() - 1) { if (_binHashSparse.first[i].second.size() != sizeX) { _isGrid = false; + return; } } else if (_binHashSparse.first[i].second.size() != 2*sizeX) { _isGrid = false; + return; } } @@ -809,10 +810,12 @@ if (i != _binHashSparse.second.size() - 1) { if (2*sizeY != _binHashSparse.second[i].second.size()) { _isGrid = false; + return; } } else if (_binHashSparse.second[i].second.size() != sizeY) { _isGrid = false; + return; } } Modified: trunk/include/YODA/Histo2D.h ============================================================================== --- trunk/include/YODA/Histo2D.h Wed Oct 12 23:00:26 2011 (r399) +++ trunk/include/YODA/Histo2D.h Sun Oct 23 19:54:58 2011 (r400) @@ -60,7 +60,13 @@ : AnalysisObject("Histo2D", path, title), _axis(binedges) { } - + + /// Constructor accepting the bin edges on X and Y axis. + Histo2D(const std::vector<double>& xedges, const std::vector<double>& yedges, + const std::string& path="", const std::string& title="") + : AnalysisObject("Histo2D", path, title), + _axis(xedges, yedges) + { } /// Copy constructor with optional new path Histo2D(const Histo2D& h, const std::string& path=""); @@ -83,7 +89,6 @@ public: - /// @name Modifiers //@{ Modified: trunk/include/YODA/Makefile.am ============================================================================== --- trunk/include/YODA/Makefile.am Wed Oct 12 23:00:26 2011 (r399) +++ trunk/include/YODA/Makefile.am Sun Oct 23 19:54:58 2011 (r400) @@ -18,7 +18,7 @@ Utils/MathUtils.h \ Utils/Formatting.h \ Utils/sortedvector.h \ - Utils/cachedvector.h \ + Utils/cachedvector.h \ Utils/nvector.h \ Config/YodaConfig.h \ Config/BuildConfig.h Modified: trunk/include/YODA/Utils/MathUtils.h ============================================================================== --- trunk/include/YODA/Utils/MathUtils.h Wed Oct 12 23:00:26 2011 (r399) +++ trunk/include/YODA/Utils/MathUtils.h Sun Oct 23 19:54:58 2011 (r400) @@ -260,7 +260,7 @@ const double logend = std::log(end); const std::vector<double> logvals = linspace(logstart, logend, nbins); std::vector<double> rtn; - for (size_t i = 1; i < logvals.size(); ++i) { + for (size_t i = 0; i < logvals.size(); ++i) { rtn.push_back(std::exp(logvals[i])); } assert(rtn.size() == nbins+1); Modified: trunk/include/YODA/Writer.h ============================================================================== --- trunk/include/YODA/Writer.h Wed Oct 12 23:00:26 2011 (r399) +++ trunk/include/YODA/Writer.h Sun Oct 23 19:54:58 2011 (r400) @@ -121,6 +121,7 @@ virtual void writeHisto1D(std::ostream& os, const Histo1D& h) = 0; virtual void writeProfile1D(std::ostream& os, const Profile1D& p) = 0; virtual void writeScatter2D(std::ostream& os, const Scatter2D& s) = 0; + //virtual void writeScatter3D(std::ostream& os, const Scatter3D& s) = 0; }; Modified: trunk/include/YODA/WriterAIDA.h ============================================================================== --- trunk/include/YODA/WriterAIDA.h Wed Oct 12 23:00:26 2011 (r399) +++ trunk/include/YODA/WriterAIDA.h Sun Oct 23 19:54:58 2011 (r400) @@ -40,7 +40,6 @@ void writeProfile1D(std::ostream& os, const Profile1D& p); void writeScatter2D(std::ostream& os, const Scatter2D& s); - private: /// Private since it's a singleton. Modified: trunk/include/YODA/WriterYODA.h ============================================================================== --- trunk/include/YODA/WriterYODA.h Wed Oct 12 23:00:26 2011 (r399) +++ trunk/include/YODA/WriterYODA.h Sun Oct 23 19:54:58 2011 (r400) @@ -40,7 +40,7 @@ void writeHisto1D(std::ostream& stream, const Histo1D& h); void writeProfile1D(std::ostream& stream, const Profile1D& p); void writeScatter2D(std::ostream& stream, const Scatter2D& s); - + //void writeScatter3D(std::ostream& stream, const Scatter3D& s); private: Modified: trunk/src/WriterYODA.cc ============================================================================== --- trunk/src/WriterYODA.cc Wed Oct 12 23:00:26 2011 (r399) +++ trunk/src/WriterYODA.cc Sun Oct 23 19:54:58 2011 (r400) @@ -115,6 +115,23 @@ os << flush; os.flags(oldflags); } + + /*void WriterYODA::writeScatter3D(std::ostream& os, const Scatter3D& s) { + ios_base::fmtflags oldflags = os.flags(); + const int precision = 6; + os << scientific << showpoint << setprecision(precision); + os << "# BEGIN YODA_SCATTER3D\n"; + _writeAnnotations(os, s); + os << "# xval\t xerr-\t xerr+\t yval\t yerr-\t yerr+\t zval\t zerr-\t zerr+\n"; + foreach (Point3D pt, s.points()) { + os << pt.x() << "\t" << pt.xErrMinus() << "\t" << pt.xErrMinus() << "\t"; + os << pt.y() << "\t" << pt.yErrMinus() << "\t" << pt.yErrMinus() << "\t"; + os << pt.z() << "\t" << pt.zErrMinus() << "\t" << pt.zErrMinus() << "\n"; + } + os << "# END YODA_SCATTER2D\n"; + os << flush; + os.flags(oldflags); + }*/ } Modified: trunk/tests/Histo2D/H2DFill.cc ============================================================================== --- trunk/tests/Histo2D/H2DFill.cc Wed Oct 12 23:00:26 2011 (r399) +++ trunk/tests/Histo2D/H2DFill.cc Sun Oct 23 19:54:58 2011 (r400) @@ -1,8 +1,10 @@ #include "YODA/Histo2D.h" #include "YODA/Scatter3D.h" +#include "YODA/Utils/MathUtils.h" #include <cmath> #include <iostream> +#include <fstream> #include <unistd.h> #include <sys/time.h> using namespace std; @@ -32,6 +34,47 @@ } cout << "PASS (" << tE - tS << "s)" << endl; + cout << "Now, generating benchmark... "; + ofstream file("bench2.dat"); + + for(int i = 10; i < 310; i+=10){ + Histo2D temp(i, 0, 100, i, 0, 100); + + gettimeofday(&startTime, NULL); + for(int j = 0; j < 100000; j++) temp.fill(99, 99, 2); + gettimeofday(&endTime, NULL); + + tE = (endTime.tv_sec*1000000 + endTime.tv_usec)/(double)1000000; + tS = (startTime.tv_sec*1000000 + startTime.tv_usec)/(double)1000000; + file << i*i << " " << tE-tS << " "; + cout << tE-tS << endl; + + Histo2D temp2(logspace(1, 100, i), logspace(1, 100, i)); + gettimeofday(&startTime, NULL); + for(int j = 0; j < 100000; j++) temp2.fill(99, 99, 2); + gettimeofday(&endTime, NULL); + + tE = (endTime.tv_sec*1000000 + endTime.tv_usec)/(double)1000000; + tS = (startTime.tv_sec*1000000 + startTime.tv_usec)/(double)1000000; + file << tE-tS << " "; + cout << tE-tS << endl; + + temp.addBin(200, 0, 300, 300); + gettimeofday(&startTime, NULL); + for(int j = 0; j < 1000; j++) temp.fill(99, 99, 2); + gettimeofday(&endTime, NULL); + + tE = (endTime.tv_sec*1000000 + endTime.tv_usec)/(double)1000000; + tS = (startTime.tv_sec*1000000 + startTime.tv_usec)/(double)1000000; + file << tE-tS << endl; + cout << tE-tS << endl; + + cout << i << endl; + } + cout << endl; + + + // Testing if fill() function does what it should cout << "Does fill() do what it should? "; if(-1 != h.fill(1123123,312312,1)){
More information about the yoda-svn mailing list |