Classes | Public Types | Public Member Functions | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
ana::_Var< T > Class Template Reference

Template for Vars applied to any type of object. More...

#include "/cvmfs/nova.opensciencegrid.org/externals/cafanacore/v01.15/src/CAFAna/Core/FwdDeclare.h"

Inheritance diagram for ana::_Var< T >:
ana::VarBase

Classes

struct  AddType
 

Public Types

typedef double( VarFunc_t) (const T *sr)
 The type of the function part of a var. More...
 

Public Member Functions

 _Var (const std::function< VarFunc_t > &func)
 std::function can wrap a real function, function object, or lambda More...
 
template<class FuncT >
 _Var (const FuncT &func)
 
 _Var (const _Var &a, const Binning &binsa, const _Var &b, const Binning &binsb)
 Variable formed from two input variables. More...
 
 _Var (const _Var &a, int na, double a0, double a1, const _Var &b, int nb, double b0, double b1)
 
 _Var (const _Var &a, const Binning &binsa, const _Var &b, const Binning &binsb, const _Var &c, const Binning &binsc)
 
 _Var (const _Var &a, int na, double a0, double a1, const _Var &b, int nb, double b0, double b1, const _Var &c, int nc, double c0, double c1)
 
double operator() (const T *rec) const
 Allows a variable to be called with double value = myVar(rec) syntax. More...
 
_Cut< Toperator< (double c) const
 
_Cut< Toperator> (double c) const
 
_Cut< Toperator>= (double c) const
 
_Cut< Toperator<= (double c) const
 
_Cut< Toperator== (double c) const
 
_Cut< Toperator!= (double c) const
 
_Cut< Toperator> (const _Var &v) const
 
_Cut< Toperator< (const _Var &v) const
 
_Cut< Toperator>= (const _Var &v) const
 
_Cut< Toperator<= (const _Var &v) const
 
_Cut< Toperator== (const _Var &v) const
 
_Cut< Toperator!= (const _Var &v) const
 
_Var operator* (const _Var &v) const
 
_Var operator/ (const _Var &v) const
 
_Var operator+ (const _Var &v) const
 
_Var operator- (const _Var &v) const
 

Protected Types

typedef double( VoidVarFunc_t) (const void *rec)
 

Protected Member Functions

 _Var (const VarBase &v)
 
double operator() (const void *rec) const
 Allows a variable to be called with double value = myVar(rec) syntax. More...
 
int ID () const
 Vars with the same definition will have the same ID. More...
 
CutBase operator< (const VarBase &v) const
 
CutBase operator> (const VarBase &v) const
 
CutBase operator>= (const VarBase &v) const
 
CutBase operator<= (const VarBase &v) const
 
CutBase operator== (const VarBase &v) const
 
CutBase operator!= (const VarBase &v) const
 
VarBase operator* (const VarBase &v) const
 
VarBase operator/ (const VarBase &v) const
 
VarBase operator+ (const VarBase &v) const
 
VarBase operator- (const VarBase &v) const
 

Static Protected Member Functions

static int MaxID ()
 

Protected Attributes

std::function< VoidVarFunc_tfFunc
 
int fID
 

Static Protected Attributes

static int fgNextID = 0
 The next ID that hasn't yet been assigned. More...
 

Detailed Description

template<class T>
class ana::_Var< T >

Template for Vars applied to any type of object.

Definition at line 12 of file FwdDeclare.h.

Member Typedef Documentation

template<class T>
typedef double( ana::_Var< T >::VarFunc_t) (const T *sr)

The type of the function part of a var.

Definition at line 17 of file Var.h.

typedef double( ana::VarBase::VoidVarFunc_t) (const void *rec)
inherited

Definition at line 16 of file VarBase.h.

Constructor & Destructor Documentation

template<class T>
ana::_Var< T >::_Var ( const std::function< VarFunc_t > &  func)
inline

std::function can wrap a real function, function object, or lambda

Definition at line 37 of file Var.h.

38  : VarBase(AddType<decltype(func), T>(func))
39  {
40  }
VarBase(const std::function< VoidVarFunc_t > &func, int id=-1)
Definition: VarBase.cxx:14
double func(double x, double y)
double T
Definition: Xdiff_gwt.C:5
template<class T>
template<class FuncT >
ana::_Var< T >::_Var ( const FuncT &  func)
inline

Definition at line 42 of file Var.h.

43  : VarBase(AddType<FuncT, T>(func))
44  {
45  }
VarBase(const std::function< VoidVarFunc_t > &func, int id=-1)
Definition: VarBase.cxx:14
double func(double x, double y)
template<class T>
ana::_Var< T >::_Var ( const _Var< T > &  a,
const Binning binsa,
const _Var< T > &  b,
const Binning binsb 
)
inline

Variable formed from two input variables.

The binning of each variable has to be given to allow conversion into a 1D binned representation.

Definition at line 51 of file Var.h.

53  : VarBase(a, binsa, b, binsb)
54  {
55  }
VarBase(const std::function< VoidVarFunc_t > &func, int id=-1)
Definition: VarBase.cxx:14
const double a
const hit & b
Definition: hits.cxx:21
template<class T>
ana::_Var< T >::_Var ( const _Var< T > &  a,
int  na,
double  a0,
double  a1,
const _Var< T > &  b,
int  nb,
double  b0,
double  b1 
)
inline

Definition at line 57 of file Var.h.

59  : VarBase(a, Binning::Simple(na, a0, a1),
60  b, Binning::Simple(nb, b0, b1))
61  {
62  }
VarBase(const std::function< VoidVarFunc_t > &func, int id=-1)
Definition: VarBase.cxx:14
TH1F * a1
Definition: f2_nu.C:476
const double a
const hit & b
Definition: hits.cxx:21
static const double nb
Definition: Units.h:89
static Binning Simple(int n, double lo, double hi, const std::vector< std::string > &labels={})
Definition: Binning.cxx:107
template<class T>
ana::_Var< T >::_Var ( const _Var< T > &  a,
const Binning binsa,
const _Var< T > &  b,
const Binning binsb,
const _Var< T > &  c,
const Binning binsc 
)
inline

Definition at line 64 of file Var.h.

67  : VarBase(a, binsa, b, binsb, c, binsc)
68  {
69  }
VarBase(const std::function< VoidVarFunc_t > &func, int id=-1)
Definition: VarBase.cxx:14
const double a
const hit & b
Definition: hits.cxx:21
template<class T>
ana::_Var< T >::_Var ( const _Var< T > &  a,
int  na,
double  a0,
double  a1,
const _Var< T > &  b,
int  nb,
double  b0,
double  b1,
const _Var< T > &  c,
int  nc,
double  c0,
double  c1 
)
inline

Definition at line 71 of file Var.h.

74  : VarBase(a, Binning::Simple(na, a0, a1),
75  b, Binning::Simple(nb, b0, b1),
76  c, Binning::Simple(nc, c0, c1))
77  {
78  }
VarBase(const std::function< VoidVarFunc_t > &func, int id=-1)
Definition: VarBase.cxx:14
TH1F * a1
Definition: f2_nu.C:476
const double a
const hit & b
Definition: hits.cxx:21
enum BeamMode nc
c1
Definition: demo5.py:24
static const double nb
Definition: Units.h:89
static Binning Simple(int n, double lo, double hi, const std::vector< std::string > &labels={})
Definition: Binning.cxx:107
template<class T>
ana::_Var< T >::_Var ( const VarBase v)
inlineprotected

Definition at line 111 of file Var.h.

111 : VarBase(v) {}
VarBase(const std::function< VoidVarFunc_t > &func, int id=-1)
Definition: VarBase.cxx:14

Member Function Documentation

int ana::VarBase::ID ( ) const
inlineprotectedinherited

Vars with the same definition will have the same ID.

Definition at line 48 of file VarBase.h.

References ana::VarBase::fID.

Referenced by ana::SpectrumLoaderBase::GetSinkSCW(), ana::_Var< caf::SRProxy >::operator()(), ana::VarBase::operator*(), ana::VarBase::operator+(), ana::VarBase::operator-(), and ana::VarBase::operator/().

48 {return fID;}
static int ana::VarBase::MaxID ( )
inlinestaticprotectedinherited
CutBase ana::VarBase::operator!= ( const VarBase v) const
protectedinherited
template<class T>
_Cut<T> ana::_Var< T >::operator!= ( double  c) const
inline

Definition at line 95 of file Var.h.

95 {return VarBase::operator!=(c);}
CutBase operator!=(double c) const
template<class T>
_Cut<T> ana::_Var< T >::operator!= ( const _Var< T > &  v) const
inline

Definition at line 102 of file Var.h.

102 {return VarBase::operator!=(v);}
CutBase operator!=(double c) const
double ana::VarBase::operator() ( const void rec) const
inlineprotectedinherited

Allows a variable to be called with double value = myVar(rec) syntax.

Definition at line 42 of file VarBase.h.

References ana::VarBase::fFunc.

Referenced by ana::VarBase::operator*(), ana::VarBase::operator+(), ana::VarBase::operator-(), and ana::VarBase::operator/().

43  {
44  return fFunc(rec);
45  }
caf::StandardRecord * rec
Definition: tutCAFMacro.C:20
std::function< VoidVarFunc_t > fFunc
Definition: VarBase.h:72
template<class T>
double ana::_Var< T >::operator() ( const T rec) const
inline

Allows a variable to be called with double value = myVar(rec) syntax.

Definition at line 81 of file Var.h.

82  {
83  return fFunc(rec);
84  }
caf::StandardRecord * rec
Definition: tutCAFMacro.C:20
std::function< VoidVarFunc_t > fFunc
Definition: VarBase.h:72
VarBase ana::VarBase::operator* ( const VarBase v) const
protectedinherited

Definition at line 268 of file VarBase.cxx.

References a, b, ana::VarBase::fgNextID, ana::VarBase::ID(), PandAna.Demos.tute_pid_validation::ids, findDuplicateFiles::key, ana::VarBase::operator()(), rec, and ana::VarBase::VarBase().

Referenced by ana::VarBase::MaxID(), and ana::_Var< caf::SRProxy >::operator*().

269  {
270  static std::map<std::pair<int, int>, int> ids;
271  const std::pair<int, int> key(ID(), v.ID());
272 
273  struct Times
274  {
275  const VarBase a, b;
276  double operator()(const void* rec) const {return a(rec) * b(rec);}
277  };
278 
279  if(ids.count(key) == 0) ids[key] = fgNextID++;
280  return VarBase(Times{*this, v});
281  }
caf::StandardRecord * rec
Definition: tutCAFMacro.C:20
VarBase(const std::function< VoidVarFunc_t > &func, int id=-1)
Definition: VarBase.cxx:14
const double a
double operator()(const void *rec) const
Allows a variable to be called with double value = myVar(rec) syntax.
Definition: VarBase.h:42
const hit & b
Definition: hits.cxx:21
static int fgNextID
The next ID that hasn&#39;t yet been assigned.
Definition: VarBase.h:76
int ID() const
Vars with the same definition will have the same ID.
Definition: VarBase.h:48
template<class T>
_Var ana::_Var< T >::operator* ( const _Var< T > &  v) const
inline

Definition at line 105 of file Var.h.

105 {return VarBase::operator*(v);}
VarBase operator*(const VarBase &v) const
Definition: VarBase.cxx:268
VarBase ana::VarBase::operator+ ( const VarBase v) const
protectedinherited

Definition at line 307 of file VarBase.cxx.

References a, b, ana::VarBase::fgNextID, ana::VarBase::ID(), PandAna.Demos.tute_pid_validation::ids, findDuplicateFiles::key, ana::VarBase::operator()(), rec, and ana::VarBase::VarBase().

Referenced by ana::VarBase::MaxID(), and ana::_Var< caf::SRProxy >::operator+().

308  {
309  static std::map<std::pair<int, int>, int> ids;
310  const std::pair<int, int> key(ID(), v.ID());
311 
312  struct Plus
313  {
314  const VarBase a, b;
315  double operator()(const void* rec) const {return a(rec) + b(rec);}
316  };
317 
318  if(ids.count(key) == 0) ids[key] = fgNextID++;
319  return VarBase(Plus{*this, v}, ids[key]);
320  }
caf::StandardRecord * rec
Definition: tutCAFMacro.C:20
VarBase(const std::function< VoidVarFunc_t > &func, int id=-1)
Definition: VarBase.cxx:14
const double a
double operator()(const void *rec) const
Allows a variable to be called with double value = myVar(rec) syntax.
Definition: VarBase.h:42
const hit & b
Definition: hits.cxx:21
static int fgNextID
The next ID that hasn&#39;t yet been assigned.
Definition: VarBase.h:76
int ID() const
Vars with the same definition will have the same ID.
Definition: VarBase.h:48
template<class T>
_Var ana::_Var< T >::operator+ ( const _Var< T > &  v) const
inline

Definition at line 107 of file Var.h.

107 {return VarBase::operator+(v);}
VarBase operator+(const VarBase &v) const
Definition: VarBase.cxx:307
VarBase ana::VarBase::operator- ( const VarBase v) const
protectedinherited

Definition at line 323 of file VarBase.cxx.

References a, b, ana::VarBase::fgNextID, ana::VarBase::ID(), PandAna.Demos.tute_pid_validation::ids, findDuplicateFiles::key, ana::VarBase::operator()(), rec, and ana::VarBase::VarBase().

Referenced by ana::VarBase::MaxID(), and ana::_Var< caf::SRProxy >::operator-().

324  {
325  static std::map<std::pair<int, int>, int> ids;
326  const std::pair<int, int> key(ID(), v.ID());
327 
328  struct Minus
329  {
330  const VarBase a, b;
331  double operator()(const void* rec) const {return a(rec) - b(rec);}
332  };
333 
334  if(ids.count(key) == 0) ids[key] = fgNextID++;
335  return VarBase(Minus{*this, v}, ids[key]);
336  }
caf::StandardRecord * rec
Definition: tutCAFMacro.C:20
VarBase(const std::function< VoidVarFunc_t > &func, int id=-1)
Definition: VarBase.cxx:14
const double a
double operator()(const void *rec) const
Allows a variable to be called with double value = myVar(rec) syntax.
Definition: VarBase.h:42
const hit & b
Definition: hits.cxx:21
static int fgNextID
The next ID that hasn&#39;t yet been assigned.
Definition: VarBase.h:76
int ID() const
Vars with the same definition will have the same ID.
Definition: VarBase.h:48
template<class T>
_Var ana::_Var< T >::operator- ( const _Var< T > &  v) const
inline

Definition at line 108 of file Var.h.

108 {return VarBase::operator-(v);}
VarBase operator-(const VarBase &v) const
Definition: VarBase.cxx:323
VarBase ana::VarBase::operator/ ( const VarBase v) const
protectedinherited

Definition at line 284 of file VarBase.cxx.

References a, b, Divide(), ana::VarBase::fgNextID, ana::VarBase::ID(), PandAna.Demos.tute_pid_validation::ids, findDuplicateFiles::key, ana::VarBase::operator()(), rec, and ana::VarBase::VarBase().

Referenced by ana::VarBase::MaxID(), and ana::_Var< caf::SRProxy >::operator/().

285  {
286  static std::map<std::pair<int, int>, int> ids;
287  const std::pair<int, int> key(ID(), v.ID());
288 
289  struct Divide
290  {
291  const VarBase a, b;
292  double operator()(const void* rec) const
293  {
294  const double denom = b(rec);
295  if(denom != 0)
296  return a(rec) / denom;
297  else
298  return 0.0;
299  }
300  };
301 
302  if(ids.count(key) == 0) ids[key] = fgNextID++;
303  return VarBase(Divide{*this, v}, ids[key]);
304  }
ratio_hxv Divide(hxv, goal_hxv)
caf::StandardRecord * rec
Definition: tutCAFMacro.C:20
VarBase(const std::function< VoidVarFunc_t > &func, int id=-1)
Definition: VarBase.cxx:14
const double a
double operator()(const void *rec) const
Allows a variable to be called with double value = myVar(rec) syntax.
Definition: VarBase.h:42
const hit & b
Definition: hits.cxx:21
static int fgNextID
The next ID that hasn&#39;t yet been assigned.
Definition: VarBase.h:76
int ID() const
Vars with the same definition will have the same ID.
Definition: VarBase.h:48
template<class T>
_Var ana::_Var< T >::operator/ ( const _Var< T > &  v) const
inline

Definition at line 106 of file Var.h.

106 {return VarBase::operator/(v);}
VarBase operator/(const VarBase &v) const
Definition: VarBase.cxx:284
CutBase ana::VarBase::operator< ( const VarBase v) const
protectedinherited
template<class T>
_Cut<T> ana::_Var< T >::operator< ( double  c) const
inline

Definition at line 90 of file Var.h.

90 {return VarBase::operator<(c);}
CutBase operator<(double c) const
template<class T>
_Cut<T> ana::_Var< T >::operator< ( const _Var< T > &  v) const
inline

Definition at line 98 of file Var.h.

98 {return VarBase::operator<(v);}
CutBase operator<(double c) const
CutBase ana::VarBase::operator<= ( const VarBase v) const
protectedinherited
template<class T>
_Cut<T> ana::_Var< T >::operator<= ( double  c) const
inline

Definition at line 93 of file Var.h.

93 {return VarBase::operator<=(c);}
CutBase operator<=(double c) const
template<class T>
_Cut<T> ana::_Var< T >::operator<= ( const _Var< T > &  v) const
inline

Definition at line 100 of file Var.h.

100 {return VarBase::operator<=(v);}
CutBase operator<=(double c) const
CutBase ana::VarBase::operator== ( const VarBase v) const
protectedinherited
template<class T>
_Cut<T> ana::_Var< T >::operator== ( double  c) const
inline

Definition at line 94 of file Var.h.

94 {return VarBase::operator==(c);}
CutBase operator==(double c) const
template<class T>
_Cut<T> ana::_Var< T >::operator== ( const _Var< T > &  v) const
inline

Definition at line 101 of file Var.h.

101 {return VarBase::operator==(v);}
CutBase operator==(double c) const
CutBase ana::VarBase::operator> ( const VarBase v) const
protectedinherited
template<class T>
_Cut<T> ana::_Var< T >::operator> ( double  c) const
inline

Definition at line 91 of file Var.h.

91 {return VarBase::operator>(c);}
CutBase operator>(double c) const
template<class T>
_Cut<T> ana::_Var< T >::operator> ( const _Var< T > &  v) const
inline

Definition at line 97 of file Var.h.

97 {return VarBase::operator>(v);}
CutBase operator>(double c) const
CutBase ana::VarBase::operator>= ( const VarBase v) const
protectedinherited
template<class T>
_Cut<T> ana::_Var< T >::operator>= ( double  c) const
inline

Definition at line 92 of file Var.h.

92 {return VarBase::operator>=(c);}
CutBase operator>=(double c) const
template<class T>
_Cut<T> ana::_Var< T >::operator>= ( const _Var< T > &  v) const
inline

Definition at line 99 of file Var.h.

99 {return VarBase::operator>=(v);}
CutBase operator>=(double c) const

Member Data Documentation

std::function<VoidVarFunc_t> ana::VarBase::fFunc
protectedinherited
int ana::VarBase::fgNextID = 0
staticprotectedinherited

The next ID that hasn't yet been assigned.

Definition at line 76 of file VarBase.h.

Referenced by ana::VarBase::MaxID(), ana::VarBase::operator*(), ana::VarBase::operator+(), ana::VarBase::operator-(), and ana::VarBase::operator/().

int ana::VarBase::fID
protectedinherited

Definition at line 74 of file VarBase.h.

Referenced by ana::VarBase::ID(), ana::VarBase::operator=(), and ana::VarBase::VarBase().


The documentation for this class was generated from the following files: