Browse Source

Adds `get` method in addition to operator() to get Values

Caleb Fangmeier 6 years ago
parent
commit
05ba0b016f
3 changed files with 16 additions and 4 deletions
  1. 1 1
      examples/config.yaml
  2. 1 1
      examples/example1.cpp
  3. 14 2
      include/value.hpp

+ 1 - 1
examples/config.yaml

@@ -3,7 +3,7 @@ debug: false
 
 output-file: example.root
 source-files:
-    - filename: /home/caleb/Sources/PycharmProjects/EGamma/data/new_trees/trackingNtuple_1.root
+    - filename: /home/caleb/Sources/EGamma/data/new_trees/trackingNtuple_1.root
 
 hist-params:
     track_px:

+ 1 - 1
examples/example1.cpp

@@ -131,7 +131,7 @@ void run(bool silent) {
 
     auto& cont = *tds.register_container<ContainerTH1<int>>("trk_py", "Track Px", TH1Params::lookup("track_px"));
 
-    while(tds.next(silent)) {
+    while(tds.next(!silent)) {
         for (const float& p : px()) {
             cont.fill(p);
         }

+ 14 - 2
include/value.hpp

@@ -217,6 +217,10 @@ namespace fv {
 
         /** Calculate, if necessary, and return the value held by this object.
          */
+        virtual T &get() = 0;
+
+        /** Alias to get
+         */
         virtual T &operator() () = 0;
     };
 
@@ -244,7 +248,7 @@ namespace fv {
             return name;
         }
 
-        T &operator() (){
+        T &get() {
             if (!this->value_valid) {
                 if (fv_util::debug_on) {
                     std::cout << "Calculating Value: " << this->get_name() << std::endl;
@@ -253,6 +257,10 @@ namespace fv {
             }
             return *val_ref;
         }
+
+        T &operator() (){
+            return this->get();
+        }
     };
 
 
@@ -290,7 +298,7 @@ namespace fv {
         DerivedValue(const std::string &name, const std::string &alias = "")
                 : Value<T>(name, alias) {}
 
-        T &operator() () {
+        T &get() {
             if (!this->value_valid) {
                 if (fv_util::debug_on) {
                     std::cout << "Calculating Value: " << this->get_name() << std::endl;
@@ -300,6 +308,10 @@ namespace fv {
             }
             return value;
         }
+
+        T &operator() () {
+            return this->get();
+        }
     };