[Rivet-svn] rivet: Tidying and interface improvements to BinnedHistogram

Rivet Mercurial rivet at projects.hepforge.org
Thu Jun 8 21:15:01 BST 2017


details:   https://rivet.hepforge.org/hg/rivet/rev/163d2c9e540f
branches:  release-2-5-x
changeset: 5808:163d2c9e540f
user:      Andy Buckley <andy at insectnation.org>
date:      Thu Jun 08 20:38:22 2017 +0100
description:
Tidying and interface improvements to BinnedHistogram

diffs (truncated from 204 to 50 lines):

--- a/include/Rivet/Tools/BinnedHistogram.hh	Mon Jun 05 21:48:23 2017 +0100
+++ b/include/Rivet/Tools/BinnedHistogram.hh	Thu Jun 08 20:38:22 2017 +0100
@@ -1,6 +1,7 @@
 // -*- C++ -*-
 #ifndef RIVET_BINNEDHISTOGRAM_HH
 #define RIVET_BINNEDHISTOGRAM_HH
+
 #include "Rivet/Config/RivetCommon.hh"
 #include "Rivet/Tools/RivetYODA.hh"
 
@@ -9,45 +10,65 @@
   class Analysis;
 
 
-  /**
-   * BinnedHistogram contains a series of histograms of the same quantity
-   * each in a different region of a second quantity.  For example, a
-   * BinnedHistogram may contain histograms of the cross section differential
-   * in \f$ p_T \f$ in different \f$ \eta \f$  regions.
-   **/
+  /// A set of booked Histo1DPtr, each in a bin of a second variable.
+  ///
+  /// BinnedHistogram contains a series of histograms of the same quantity
+  /// each in a different region of a second quantity.  For example, a
+  /// BinnedHistogram may contain histograms of the cross-section differential
+  /// in \f$ p_T \f$ in different \f$ \eta \f$  regions.
   template<typename T>
   class BinnedHistogram {
   public:
 
     /// Create a new empty BinnedHistogram
-    BinnedHistogram() {
-      return;
+    BinnedHistogram() {    }
+
+    /// Create a new BinnedHistogram with the given bin edges and contents
+    BinnedHistogram(const vector<T>& edges, const vector<Histo1DPtr>& histos) {
+      assert(edges.size() == histos.size()+1);
+      for (size_t i = 0; i < histos.size(); ++i)
+        addHistogram(edges[i], edges[i+1], histos[i]);
     }
 
-    ///  Add a histogram in the region between @a binMin and @a binMax to this
-    ///  set of BinnedHistograms.
-    const BinnedHistogram<T>& addHistogram(const T& binMin,
-                                           const T& binMax,
-                                           Histo1DPtr histo);
+    /// @todo Can we have an "emplace constructor", passing tuples of bookHisto1D args?
 
-    /// Fill the histogram that lies in the same region as @a bin with the value


More information about the Rivet-svn mailing list