|
[yoda-svn] r500 - in trunk: . include/YODA srcblackhole at projects.hepforge.org blackhole at projects.hepforge.orgThu Jul 12 18:43:58 BST 2012
Author: buckley Date: Thu Jul 12 18:43:58 2012 New Revision: 500 Log: Fixes to 2D outflow handling Modified: trunk/TODO trunk/include/YODA/Axis2D.h trunk/include/YODA/Histo2D.h trunk/src/WriterYODA.cc Modified: trunk/TODO ============================================================================== --- trunk/TODO Thu Jul 12 18:23:47 2012 (r499) +++ trunk/TODO Thu Jul 12 18:43:58 2012 (r500) @@ -3,9 +3,6 @@ NOW -* Add Axis1D/2D _locked member -> true on first fill. (AB) - Done for Axis1D: is it a good idea? - * Write / support comments on ends of YODA format data lines Ignore anything after "#" on data lines -- use this to write convenience height & error info for each bin since not obvious from sumWX2 etc. Modified: trunk/include/YODA/Axis2D.h ============================================================================== --- trunk/include/YODA/Axis2D.h Thu Jul 12 18:23:47 2012 (r499) +++ trunk/include/YODA/Axis2D.h Thu Jul 12 18:43:58 2012 (r500) @@ -55,7 +55,9 @@ /// Empty constructor Axis2D() : _isPerfectGrid(true), _locked(false) - { } + { + reset(); + } /// A constructor with specified x and y axis bin limits. @@ -63,6 +65,7 @@ : _isPerfectGrid(true), _locked(false) { _addBins(xedges, yedges); + reset(); } @@ -74,12 +77,14 @@ { _addBins(linspace(rangeX.first, rangeX.second, nbinsX), linspace(rangeY.first, rangeY.second, nbinsY)); + reset(); } /// Constructor accepting a list of bins Axis2D(const Bins& bins) { _addBins(bins); + reset(); } @@ -232,8 +237,9 @@ /// Reset the axis statistics void reset() { _dbn.reset(); - for (size_t ix = -1; ix <= 1; ++ix) { - for (size_t iy = -1; ix <= 1; ++ix) { + for (int ix = -1; ix <= 1; ++ix) { + for (int iy = -1; iy <= 1; ++iy) { + if (ix == 0 && iy == 0) continue; outflow(ix, iy).reset(); } } @@ -451,14 +457,15 @@ /// Scales the axis with a given scale. /// @todo Add a specific check for a scaling of 1.0, to avoid doing work when no scaling is wanted. void scaleXY(double scaleX, double scaleY) { - foreach(Bin bin, _bins) { + foreach (Bin bin, _bins) { bin.scaleXY(scaleX, scaleY); } _dbn.scaleXY(scaleX, scaleY); // Outflows - for (size_t i = 0; i < 3; ++i) { - for (size_t j = 0; j < 3; ++j) { - _outflows[3*i+j].scaleXY(scaleX, scaleY);; + for (int ix = -1; ix <= 1; ++ix) { + for (int iy = -1; iy <= 1; ++iy) { + if (ix == 0 && iy == 0) continue; + outflow(ix, iy).scaleXY(scaleX, scaleY); } } // Rehash @@ -468,14 +475,15 @@ /// Scales the bin weights void scaleW(double scalefactor) { - foreach(Bin bin, _bins) { + foreach (Bin bin, _bins) { bin.scaleW(scalefactor); } _dbn.scaleW(scalefactor); // Outflows - for (size_t i = 0; i < 3; ++i) { - for (size_t j = 0; j < 3; ++j) { - _outflows[3*i+j].scaleW(scalefactor); + for (int ix = -1; ix <= 1; ++ix) { + for (int iy = -1; iy <= 1; ++iy) { + if (ix == 0 && iy == 0) continue; + outflow(ix, iy).scaleW(scalefactor); } } } Modified: trunk/include/YODA/Histo2D.h ============================================================================== --- trunk/include/YODA/Histo2D.h Thu Jul 12 18:23:47 2012 (r499) +++ trunk/include/YODA/Histo2D.h Thu Jul 12 18:43:58 2012 (r500) @@ -271,7 +271,7 @@ /// /// Two indices are used, for x and y: -1 = underflow, 0 = in-range, and +1 = overflow. /// (0,0) is not a valid overflow index pair, since it is in range for both x and y. - Dbn2D& outflow(size_t ix, size_t iy) { + Dbn2D& outflow(int ix, int iy) { return _axis.outflow(ix, iy); } @@ -279,7 +279,7 @@ /// /// Two indices are used, for x and y: -1 = underflow, 0 = in-range, and +1 = overflow. /// (0,0) is not a valid overflow index pair, since it is in range for both x and y. - const Dbn2D& outflow(size_t ix, size_t iy) const { + const Dbn2D& outflow(int ix, int iy) const { return _axis.outflow(ix, iy); } Modified: trunk/src/WriterYODA.cc ============================================================================== --- trunk/src/WriterYODA.cc Thu Jul 12 18:23:47 2012 (r499) +++ trunk/src/WriterYODA.cc Thu Jul 12 18:43:58 2012 (r500) @@ -33,6 +33,7 @@ os << scientific << showpoint << setprecision(_precision); typedef pair<string,string> sspair; foreach (const sspair& kv, ao.annotations()) { + if (kv.first.empty() || kv.second.empty()) continue; // <- good idea? os << kv.first << "=" << kv.second << "\n"; } } @@ -92,8 +93,8 @@ os << h.totalDbn().sumWX() << "\t" << h.totalDbn().sumWX2() << "\t"; os << h.totalDbn().sumWY() << "\t" << h.totalDbn().sumWY2() << "\t"; os << h.totalDbn().numEntries() << "\n"; - for (size_t ix = -1; ix <= 1; ++ix) { - for (size_t iy = -1; ix <= 1; ++ix) { + for (int ix = -1; ix <= 1; ++ix) { + for (int iy = -1; iy <= 1; ++iy) { if (ix == 0 && iy == 0) continue; os << "Outflow\t" << ix << ":" << iy << "\t"; const Dbn2D& d = h.outflow(ix, iy);
More information about the yoda-svn mailing list |