[Rivet-svn] rivet: Replace ugly macro with template class.

Rivet Mercurial rivet at projects.hepforge.org
Tue Oct 25 18:00:01 BST 2016


details:   https://rivet.hepforge.org/hg/rivet/rev/9aec6c1feb43
branches:  multiweight
changeset: 5574:9aec6c1feb43
user:      David Grellscheid <david.grellscheid at durham.ac.uk>
date:      Tue Oct 25 17:56:41 2016 +0100
description:
Replace ugly macro with template class.

diffs (truncated from 406 to 50 lines):

--- a/include/Rivet/Tools/RivetYODA.hh	Tue Oct 25 15:12:59 2016 +0100
+++ b/include/Rivet/Tools/RivetYODA.hh	Tue Oct 25 17:56:41 2016 +0100
@@ -149,12 +149,17 @@
     using Fills = multiset<Fill<T>>;
 
 
-class Histo1DTuple : public YODA::Histo1D {
+template <class T>
+class TupleWrapper : public T {
 public:
-    Histo1DTuple(const YODA::Histo1D & h) : YODA::Histo1D(h) {}
+    typedef shared_ptr<TupleWrapper> Ptr;
+
+    TupleWrapper(const T & h) : T(h) {}
+
+    using T::fill;
 
     // todo: do we need to deal with users using fractions directly?
-    void fill(double x, double weight=1.0, double fraction=1.0) {
+    void fill(typename T::FillType x, double weight=1.0, double fraction=1.0) {
         fills_.insert( {x, weight} );
     }
 
@@ -162,154 +167,150 @@
         fills_.clear();
     }
 
-    const Fills<YODA::Histo1D> & fills() const { return fills_; }
+    const Fills<T> & fills() const { return fills_; }
 
 private:
     // x / weight pairs 
-    Fills<YODA::Histo1D> fills_;
+    Fills<T> fills_;
 };
 
 
+    template <class T>
+    class Wrapper : public MultiweightAOPtr {
+        public:
 
+        /* @todo
+         * some things are not really well-defined here
+         * for instance: fill() in the finalize() method and integral() in
+         * the analyze() method.
+         */
 
+        Wrapper(size_t len_of_weightvec, const T & p) {
+            for (size_t i = 0; i < len_of_weightvec; i++)
+                _persistent.push_back(make_shared<T>(p));


More information about the Rivet-svn mailing list