[Rivet-svn] rivet: 3 new changesets

Rivet Mercurial rivet at projects.hepforge.org
Sun Aug 16 22:00:01 BST 2015


details:   https://rivet.hepforge.org/hg/rivet/rev/ced8957457c2
branches:  
changeset: 4836:ced8957457c2
user:      Andy Buckley <andy at insectnation.org>
date:      Fri Aug 14 17:09:42 2015 +0100
description:
Tweak/decouple the YODA typedefs and includes a little

details:   https://rivet.hepforge.org/hg/rivet/rev/552f8b87ce7b
branches:  
changeset: 4837:552f8b87ce7b
user:      Andy Buckley <andy at insectnation.org>
date:      Sat Aug 15 23:15:48 2015 +0100
description:
Tweaks... but actually I think I do have a solution for this

details:   https://rivet.hepforge.org/hg/rivet/rev/01595ad4307a
branches:  
changeset: 4838:01595ad4307a
user:      Andy Buckley <andy at insectnation.org>
date:      Sun Aug 16 21:55:52 2015 +0100
description:
Add templated versions of Analysis::refData() to use data types other than Scatter2DPtr, and convert the cached ref data store to generic AnalysisObjectPtrs to make it possible.

diffs (truncated from 187 to 50 lines):

--- a/ChangeLog	Thu Aug 06 12:45:00 2015 +0100
+++ b/ChangeLog	Sun Aug 16 21:55:52 2015 +0100
@@ -1,3 +1,9 @@
+2015-08-16  Andy Buckley  <andy.buckley at cern.ch>
+
+	* Add templated versions of Analysis::refData() to use data types
+	other than Scatter2DPtr, and convert the cached ref data store to
+	generic AnalysisObjectPtrs to make it possible.
+
 2015-07-29  Andy Buckley  <andy.buckley at cern.ch>
 
 	* Add optional Cut arguments to all the Jet tag methods.
--- a/include/Rivet/Analysis.hh	Thu Aug 06 12:45:00 2015 +0100
+++ b/include/Rivet/Analysis.hh	Sun Aug 16 21:55:52 2015 +0100
@@ -333,12 +333,40 @@
     //@{
 
     /// Get reference data for a named histo
+    /// @todo Move to the templated version when we have C++11 and can have a default fn template type
     const YODA::Scatter2D& refData(const string& hname) const;
 
     /// Get reference data for a numbered histo
+    /// @todo Move to the templated version when we have C++11 and can have a default fn template type
     const YODA::Scatter2D& refData(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) const;
 
-    /// @todo Provide 3D versions as well? (How to distinguish the signatures? Template magic or explicit name?)
+    /// Get reference data for a named histo
+    /// @todo Would be nice to just use these and ditch the S2D no-template version,
+    ///   but we need C++11 for default args in function templates
+    // template <typename T=Scatter2D>
+    /// @todo SFINAE to ensure that the type inherits from YODA::AnalysisObject?
+    template <typename T>
+    const T& refData(const string& hname) const {
+      _cacheRefData();
+      MSG_TRACE("Using histo bin edges for " << name() << ":" << hname);
+      if (!_refdata[hname]) {
+        MSG_ERROR("Can't find reference histogram " << hname);
+        throw Exception("Reference data " + hname + " not found.");
+      }
+      return dynamic_cast<T&>(*_refdata[hname]);
+    }
+
+    /// Get reference data for a numbered histo
+    /// @todo Would be nice to just use these and ditch the S2D no-template version,
+    ///   but we need C++11 for default args in function templates
+    // template <typename T=Scatter2D>
+    /// @todo SFINAE to ensure that the type inherits from YODA::AnalysisObject?
+    template <typename T>
+    const T& refData(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) const {
+      const string hname = makeAxisCode(datasetId, xAxisId, yAxisId);


More information about the Rivet-svn mailing list