|
[yoda-svn] r309 - in trunk: . include/YODAblackhole at projects.hepforge.org blackhole at projects.hepforge.orgMon Aug 22 10:26:08 BST 2011
Author: buckley Date: Mon Aug 22 10:26:08 2011 New Revision: 309 Log: Adding copy constructors and assignment operators to Histo1D, Profile1D, and Scatter2D, and their respective bins/points. Modified: trunk/ChangeLog trunk/TODO trunk/include/YODA/Histo1D.h trunk/include/YODA/Profile1D.h trunk/include/YODA/Scatter2D.h Modified: trunk/ChangeLog ============================================================================== --- trunk/ChangeLog Mon Aug 22 10:15:57 2011 (r308) +++ trunk/ChangeLog Mon Aug 22 10:26:08 2011 (r309) @@ -1,5 +1,8 @@ 2011-08-22 Andy Buckley <andy at insectnation.org> + * Adding copy constructors and assignment operators to Histo1D, + Profile1D, and Scatter2D, and their respective bins/points. + * Remove use of sign(weight) in filling sum(w2) -- I think this was an historical attempt based on a scaling axiom which turned out to be inappropriate. Modified: trunk/TODO ============================================================================== --- trunk/TODO Mon Aug 22 10:15:57 2011 (r308) +++ trunk/TODO Mon Aug 22 10:26:08 2011 (r309) @@ -7,9 +7,6 @@ * Rebinning: merges of n adjacent bins (AB for 1D) -* Add copy constructors and assignment operators for Histo/Profile1D & Scatter2D - (AB) - * Rework Axis1D to operate as Axis2D does (MICHAL) * Template Bin2D and HistoBin2D on DBN type (Dbn2D/3D) cf. Bin1D<DBN> Modified: trunk/include/YODA/Histo1D.h ============================================================================== --- trunk/include/YODA/Histo1D.h Mon Aug 22 10:15:57 2011 (r308) +++ trunk/include/YODA/Histo1D.h Mon Aug 22 10:26:08 2011 (r309) @@ -37,40 +37,38 @@ //@{ /// Constructor giving range and number of bins. - /// @todo Remove binning enum stuff Histo1D(size_t nbins, double lower, double upper, const std::string& path="", const std::string& title="") : AnalysisObject("Histo1D", path, title), _axis(nbins, lower, upper) { } + /// @brief Constructor giving explicit bin edges. - /// For n bins, binedges.size() == n+1, the last - /// one being the upper bound of the last bin + /// + /// For n bins, binedges.size() == n+1, the last one being the upper bound + /// of the last bin Histo1D(const std::vector<double>& binedges, const std::string& path="", const std::string& title="") : AnalysisObject("Histo1D", path, title), _axis(binedges) { } - // /// Constructor giving a vector of bins. - // /// @todo Allow any iterable of bins (use Boost::Range?) - // Histo1D(const std::vector<HistoBin1D>& bins, - // const std::string& path="", const std::string& title="") - // : AnalysisObject("Histo1D", path, title), - // _axis(bins) - // { } /// Copy constructor with optional new path Histo1D(const Histo1D& h, const std::string& path=""); + /// Constructor from a Scatter2D's binning, with optional new path Histo1D(const Scatter2D& s, const std::string& path=""); + /// Constructor from a Profile1D's binning, with optional new path Histo1D(const Profile1D& p, const std::string& path=""); - /// @brief State-setting constructor. + + /// @brief State-setting constructor + /// /// Intended principally for internal persistency use. Histo1D(const std::vector<HistoBin1D>& bins, const Dbn1D& dbn_tot, const Dbn1D& dbn_uflow, const Dbn1D& dbn_oflow, @@ -79,6 +77,15 @@ _axis(bins, dbn_tot, dbn_uflow, dbn_oflow) { } + + /// Assignment operator + Histo1D& operator = (const Histo1D& h1) { + setPath(h1.path()); + setTitle(h1.title()); + _axis = h1._axis; + return *this; + } + //@} Modified: trunk/include/YODA/Profile1D.h ============================================================================== --- trunk/include/YODA/Profile1D.h Mon Aug 22 10:15:57 2011 (r308) +++ trunk/include/YODA/Profile1D.h Mon Aug 22 10:26:08 2011 (r309) @@ -45,25 +45,32 @@ _axis(nxbins, xlower, xupper) { } + /// Constructor giving explicit bin edges - /// For n bins, binedges.size() == n+1, the last - /// one being the upper bound of the last bin + /// + /// For n bins, binedges.size() == n+1, the last one being the upper bound + /// of the last bin Profile1D(const std::vector<double>& xbinedges, const std::string& path="", const std::string& title="") : AnalysisObject("Profile1D", path, title), _axis(xbinedges) { } + /// Copy constructor with optional new path Profile1D(const Profile1D& p, const std::string& path=""); + /// Constructor from a Scatter2D's binning, with optional new path Profile1D(const Scatter2D& s, const std::string& path=""); + /// Constructor from a Histo1D's binning, with optional new path Profile1D(const Histo1D& h, const std::string& path=""); + /// @brief State-setting constructor. + /// /// Intended principally for internal persistency use. Profile1D(const std::vector<ProfileBin1D>& bins, const Dbn2D& dbn_tot, const Dbn2D& dbn_uflow, const Dbn2D& dbn_oflow, @@ -72,6 +79,15 @@ _axis(bins, dbn_tot, dbn_uflow, dbn_oflow) { } + + /// Assignment operator + Profile1D& operator = (const Profile1D& p1) { + setPath(p1.path()); + setTitle(p1.title()); + _axis = p1._axis; + return *this; + } + //@} Modified: trunk/include/YODA/Scatter2D.h ============================================================================== --- trunk/include/YODA/Scatter2D.h Mon Aug 22 10:15:57 2011 (r308) +++ trunk/include/YODA/Scatter2D.h Mon Aug 22 10:26:08 2011 (r309) @@ -132,7 +132,20 @@ } - /// @todo Add copy constructor + /// Copy constructor with optional new path + Scatter2D(const Scatter2D& s2, const std::string& path="") + : AnalysisObject("Scatter2D", (path.size() == 0) ? s2.path() : path, s2, s2.title()), + _points(s2._points) + { } + + + /// Assignment operator + Scatter2D& operator = (const Scatter2D& s2) { + setPath(s2.path()); + setTitle(s2.title()); + _points = s2._points; + return *this; + } //@}
More information about the yoda-svn mailing list |