MultiVar.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <functional>
4 #include <vector>
5 
6 //#include "StandardRecord/Proxy/FwdDeclare.h"
7 
8 // TODO unify into one header
9 namespace caf{
10  class StandardRecord;
11  class SRSpill;
12  class SRNeutrino;
13  template<class T> class Proxy;
14  typedef Proxy<StandardRecord> SRProxy;
15  typedef Proxy<SRSpill> SRSpillProxy;
16  typedef Proxy<SRNeutrino> SRNeutrinoProxy;
17 }
18 
19 namespace ana
20 {
21  class Binning;
22 
23  /// A Var that returns multiple results for each slice. eg the properties of
24  /// multiple prongs. All results will be filled into the Spectrum.
25  template<class T> class _MultiVar
26  {
27  public:
28  /// The type of the function part of a var
29  typedef std::vector<double> (VarFunc_t)(const T* sr);
30 
31  /// std::function can wrap a real function, function object, or lambda
32  _MultiVar(const std::function<VarFunc_t>& fun);
33 
34  /// Allows a variable to be called with double value = myVar(sr) syntax
35  std::vector<double> operator()(const T* sr) const
36  {
37  return fFunc(sr);
38  }
39 
40  /// Vars with the same definition will have the same ID
41  int ID() const {return fID;}
42 
43  static int MaxID() {return fgNextID-1;}
44  protected:
45  std::function<VarFunc_t> fFunc;
46 
47  int fID;
48  /// The next ID that hasn't yet been assigned
49  static int fgNextID;
50  };
51 
53 
54  MultiVar MultiVar2D(const MultiVar& a, const Binning& binsa,
55  const MultiVar& b, const Binning& binsb);
56 
57  MultiVar MultiVar2D(const MultiVar& a, int na, double a0, double a1,
58  const MultiVar& b, int nb, double b0, double b1);
59 } // namespace
Represent the binning of a Spectrum&#39;s x-axis.
Definition: Binning.h:16
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
static int MaxID()
Definition: MultiVar.h:43
MultiVar MultiVar2D(const MultiVar &a, const Binning &binsa, const MultiVar &b, const Binning &binsb)
Definition: MultiVar.cxx:68
std::function< VarFunc_t > fFunc
Definition: MultiVar.h:45
static int fgNextID
The next ID that hasn&#39;t yet been assigned.
Definition: MultiVar.h:49
caf::Proxy< caf::SRNeutrino > SRNeutrinoProxy
Definition: FwdDeclare.h:128
int ID() const
Vars with the same definition will have the same ID.
Definition: MultiVar.h:41
TH1F * a1
Definition: f2_nu.C:476
const double a
caf::Proxy< caf::StandardRecord > SRProxy
Definition: EpilogFwd.h:2
caf::StandardRecord * sr
caf::Proxy< caf::SRSpill > SRSpillProxy
Definition: FwdDeclare.h:302
_MultiVar< caf::SRProxy > MultiVar
Definition: MultiVar.h:52
const hit & b
Definition: hits.cxx:21
double T
Definition: Xdiff_gwt.C:5
This module creates Common Analysis Files.
Definition: FileReducer.h:10
static const double nb
Definition: Units.h:89
std::vector< double > operator()(const T *sr) const
Allows a variable to be called with double value = myVar(sr) syntax.
Definition: MultiVar.h:35