Browse Source

Updates to analysis routine, adding additional histograms

Caleb Fangmeier 7 years ago
parent
commit
b33cf01876
3 changed files with 15 additions and 27 deletions
  1. 1 1
      dataset.hpp
  2. 1 13
      filter.hpp
  3. 13 13
      value.hpp

+ 1 - 1
dataset.hpp

@@ -79,7 +79,7 @@ class DataSet{
         }
         }
     public:
     public:
         DataSet(){
         DataSet(){
-            auto& event_check = GenFunction::register_function<int()>("event_number",
+            auto& event_check = GenFunction::reg_func<int()>("event_number",
                 FUNC(([ds=this](){
                 FUNC(([ds=this](){
                     return ds->get_current_event();
                     return ds->get_current_event();
                 })));
                 })));

+ 1 - 13
filter.hpp

@@ -52,7 +52,7 @@ class ObsFilter : public DerivedValue<bool>{
     public:
     public:
         ObsFilter(const std::string& name, std::function<bool()> filter_function, const std::string& impl="")
         ObsFilter(const std::string& name, std::function<bool()> filter_function, const std::string& impl="")
           :DerivedValue<bool>(name),
           :DerivedValue<bool>(name),
-           filter_function(GenFunction::register_function<bool()>("filter::"+name, filter_function, impl)){ }
+           filter_function(GenFunction::reg_func<bool()>("filter::"+name, filter_function, impl)){ }
 };
 };
 
 
 /** Return a new filter that is the conjuction of a vector of source filters
 /** Return a new filter that is the conjuction of a vector of source filters
@@ -85,17 +85,5 @@ ObsFilter* any(const std::vector<ObsFilter*>&& fs){
     }
     }
 }
 }
 
 
-/** Return a new filter that is the conjuction of the two source filters.
- */
-ObsFilter* all(ObsFilter *f1, ObsFilter *f2){
-    return all({f1, f2});
-}
-
-/** Return a new filter that is the conjuction of the two source filters.
- */
-ObsFilter* any(ObsFilter *f1, ObsFilter *f2){
-    return any({f1, f2});
-}
-
 }
 }
 #endif // filter_h
 #endif // filter_h

+ 13 - 13
value.hpp

@@ -141,7 +141,7 @@ class GenFunction {
         std::string name;
         std::string name;
         std::string impl;
         std::string impl;
     protected:
     protected:
-        inline static bool in_register_function=false;
+        inline static bool in_reg_func=false;
 
 
     public:
     public:
         /**
         /**
@@ -194,8 +194,8 @@ class GenFunction {
         }
         }
 
 
         template <typename T>
         template <typename T>
-        static Function<T>& register_function(const std::string& name, std::function<T> f, const std::string& impl){
-            in_register_function = true;
+        static Function<T>& reg_func(const std::string& name, std::function<T> f, const std::string& impl){
+            in_reg_func = true;
             Function<T>* func;
             Function<T>* func;
             if (GenFunction::function_registry[name] != nullptr){
             if (GenFunction::function_registry[name] != nullptr){
                 func = dynamic_cast<Function<T>*>(GenFunction::function_registry[name]);
                 func = dynamic_cast<Function<T>*>(GenFunction::function_registry[name]);
@@ -206,7 +206,7 @@ class GenFunction {
                 func = new Function<T>(name, impl, f);
                 func = new Function<T>(name, impl, f);
                 GenFunction::function_registry[name] = func;
                 GenFunction::function_registry[name] = func;
             }
             }
-            in_register_function = false;
+            in_reg_func = false;
             return *func;
             return *func;
         }
         }
 
 
@@ -244,8 +244,8 @@ class Function<R(ArgTypes...)> : public GenFunction {
     public:
     public:
         Function(const std::string& name, const std::string& impl, std::function<R(ArgTypes...)> f)
         Function(const std::string& name, const std::string& impl, std::function<R(ArgTypes...)> f)
           :GenFunction(name, impl), f(f){
           :GenFunction(name, impl), f(f){
-            if (!in_register_function) {
-                WARNING("Don't instantiate Function objects directly! Use GenFunction::register_function instead.");
+            if (!in_reg_func) {
+                WARNING("Don't instantiate Function objects directly! Use GenFunction::reg_func instead.");
             }
             }
           }
           }
         Function(const std::string& name, std::function<R(ArgTypes...)> f)
         Function(const std::string& name, std::function<R(ArgTypes...)> f)
@@ -980,7 +980,7 @@ class Max : public Reduce<T>{
         }
         }
 
 
         Max(Value<std::vector<T>>* v, const std::string alias)
         Max(Value<std::vector<T>>* v, const std::string alias)
-          :Reduce<T>(GenFunction::register_function<T(std::vector<T>)>("max",
+          :Reduce<T>(GenFunction::reg_func<T(std::vector<T>)>("max",
                       FUNC(([](std::vector<T> vec){
                       FUNC(([](std::vector<T> vec){
                           return *std::max_element(vec.begin(), vec.end());}))),
                           return *std::max_element(vec.begin(), vec.end());}))),
                       v, alias) { }
                       v, alias) { }
@@ -997,7 +997,7 @@ class Min : public Reduce<T>{
         }
         }
 
 
         Min(Value<std::vector<T>>* v, const std::string alias)
         Min(Value<std::vector<T>>* v, const std::string alias)
-          :Reduce<T>(GenFunction::register_function<T(std::vector<T>)>("min",
+          :Reduce<T>(GenFunction::reg_func<T(std::vector<T>)>("min",
                       FUNC(([](std::vector<T> vec){
                       FUNC(([](std::vector<T> vec){
                          return *std::min_element(vec.begin(), vec.end());}))),
                          return *std::min_element(vec.begin(), vec.end());}))),
                      v, alias) { }
                      v, alias) { }
@@ -1014,7 +1014,7 @@ class Mean : public Reduce<T>{
         }
         }
 
 
         Mean(Value<std::vector<T>>* v, const std::string alias)
         Mean(Value<std::vector<T>>* v, const std::string alias)
-          :Reduce<T>(GenFunction::register_function<T(std::vector<T>)>("mean",
+          :Reduce<T>(GenFunction::reg_func<T(std::vector<T>)>("mean",
                       FUNC(([](std::vector<T> vec){
                       FUNC(([](std::vector<T> vec){
                         int n = 0; T sum = 0;
                         int n = 0; T sum = 0;
                         for (T e : vec){ n++; sum += e; }
                         for (T e : vec){ n++; sum += e; }
@@ -1033,7 +1033,7 @@ class Range : public Reduce<T>{
         }
         }
 
 
         Range(Value<std::vector<T>>* v, const std::string alias)
         Range(Value<std::vector<T>>* v, const std::string alias)
-          :Reduce<T>(GenFunction::register_function<T(std::vector<T>)>("range",
+          :Reduce<T>(GenFunction::reg_func<T(std::vector<T>)>("range",
                       FUNC(([](std::vector<T> vec){
                       FUNC(([](std::vector<T> vec){
                         auto minmax = std::minmax_element(vec.begin(), vec.end());
                         auto minmax = std::minmax_element(vec.begin(), vec.end());
                         return (*minmax.second) - (*minmax.first); }))),
                         return (*minmax.second) - (*minmax.first); }))),
@@ -1047,7 +1047,7 @@ template <typename T>
 class ElementOf : public Reduce<T>{
 class ElementOf : public Reduce<T>{
     public:
     public:
         ElementOf(Value<int>* index, Value<std::vector<T>>* v, const std::string alias)
         ElementOf(Value<int>* index, Value<std::vector<T>>* v, const std::string alias)
-          :Reduce<T>(GenFunction::register_function<T(std::vector<T>)>("elementOf",
+          :Reduce<T>(GenFunction::reg_func<T(std::vector<T>)>("elementOf",
                      FUNC(([index](std::vector<T> vec){return vec[index->get_value()];}))),
                      FUNC(([index](std::vector<T> vec){return vec[index->get_value()];}))),
                      v, alias) { }
                      v, alias) { }
 };
 };
@@ -1080,7 +1080,7 @@ template <typename T>
 class MaxIndex : public ReduceIndex<T>{
 class MaxIndex : public ReduceIndex<T>{
     public:
     public:
         MaxIndex(Value<std::vector<T>>* v, const std::string alias="")
         MaxIndex(Value<std::vector<T>>* v, const std::string alias="")
-          :ReduceIndex<T>(GenFunction::register_function<T(std::vector<T>)>("maxIndex",
+          :ReduceIndex<T>(GenFunction::reg_func<T(std::vector<T>)>("maxIndex",
                           FUNC(([](std::vector<T> vec){
                           FUNC(([](std::vector<T> vec){
                                auto elptr = std::max_element(vec.begin(), vec.end());
                                auto elptr = std::max_element(vec.begin(), vec.end());
                                return std::pair<T,int>(*elptr, int(elptr-vec.begin())); }))),
                                return std::pair<T,int>(*elptr, int(elptr-vec.begin())); }))),
@@ -1094,7 +1094,7 @@ template <typename T>
 class MinIndex : public ReduceIndex<T>{
 class MinIndex : public ReduceIndex<T>{
     public:
     public:
         MinIndex(Value<std::vector<T>>* v, const std::string alias="")
         MinIndex(Value<std::vector<T>>* v, const std::string alias="")
-          :ReduceIndex<T>(GenFunction::register_function<T(std::vector<T>)>("minIndex",
+          :ReduceIndex<T>(GenFunction::reg_func<T(std::vector<T>)>("minIndex",
                           FUNC(([](std::vector<T> vec){
                           FUNC(([](std::vector<T> vec){
                                auto elptr = std::min_element(vec.begin(), vec.end());
                                auto elptr = std::min_element(vec.begin(), vec.end());
                                return std::pair<T,int>(*elptr, int(elptr-vec.begin())); }))),
                                return std::pair<T,int>(*elptr, int(elptr-vec.begin())); }))),