All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MultiVar.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <functional>
4 #include <set>
5 #include <string>
6 #include <vector>
7 
9 
10 #include "sbnanaobj/StandardRecord/Proxy/FwdDeclare.h"
11 
12 namespace ana
13 {
14  /// A Var that returns multiple results for each slice. eg the properties of
15  /// multiple prongs. All results will be filled into the Spectrum.
16  template<class T> class _MultiVar
17  {
18  public:
19  /// The type of the function part of a var
20  typedef std::vector<double> (VarFunc_t)(const T* sr);
21 
22  /// std::function can wrap a real function, function object, or lambda
23  _MultiVar(const std::function<VarFunc_t>& fun);
24 
25  /// Allows a variable to be called with double value = myVar(sr) syntax
26  std::vector<double> operator()(const T* sr) const
27  {
28  return fFunc(sr);
29  }
30 
31  /// Vars with the same definition will have the same ID
32  int ID() const {return fID;}
33 
34  static int MaxID() {return fgNextID-1;}
35  protected:
36  _MultiVar(const std::function<VarFunc_t>& fun, int id)
37  : fFunc(fun), fID(id)
38  {
39  }
40 
41  std::function<VarFunc_t> fFunc;
42 
43  int fID;
44  /// The next ID that hasn't yet been assigned
45  static int fgNextID;
46  };
47 
50 
51  template<class T> _MultiVar<T>
52  MultiVar2D(const _MultiVar<T>& a, const Binning& binsa,
53  const _MultiVar<T>& b, const Binning& binsb);
54 
55 } // namespace
_MultiVar(const std::function< VarFunc_t > &fun)
std::function can wrap a real function, function object, or lambda
Definition: MultiVar.cxx:12
Represent the binning of a Spectrum&#39;s x-axis.
Definition: Binning.h:18
static int MaxID()
Definition: MultiVar.h:34
_MultiVar(const std::function< VarFunc_t > &fun, int id)
Definition: MultiVar.h:36
process_name opflashCryoW ana
std::function< VarFunc_t > fFunc
Definition: MultiVar.h:41
static int fgNextID
The next ID that hasn&#39;t yet been assigned.
Definition: MultiVar.h:45
process_name gaushit a
int ID() const
Vars with the same definition will have the same ID.
Definition: MultiVar.h:32
_MultiVar< caf::SRSpillProxy > SpillMultiVar
Definition: MultiVar.h:49
_MultiVar< caf::SRSliceProxy > MultiVar
Definition: MultiVar.h:48
_MultiVar< T > MultiVar2D(const _MultiVar< T > &a, const Binning &binsa, const _MultiVar< T > &b, const Binning &binsb)
Definition: MultiVar.cxx:69
std::vector< double > operator()(const T *sr) const
Allows a variable to be called with double value = myVar(sr) syntax.
Definition: MultiVar.h:26