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

Template for Var and SpillVar. More...

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

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

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 > &fun)
 std::function can wrap a real function, function object, or lambda More...
 
 _Var (const _Var< T > &v)
 
_Varoperator= (const _Var< T > &v)
 
 ~_Var ()
 
double operator() (const T *sr) const
 Allows a variable to be called with double value = myVar(sr) syntax. More...
 
int ID () const
 Vars with the same definition will have the same ID. 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< T > &v) const
 
_Cut< Toperator< (const _Var< T > &v) const
 
_Cut< Toperator>= (const _Var< T > &v) const
 
_Cut< Toperator<= (const _Var< T > &v) const
 
_Cut< Toperator== (const _Var< T > &v) const
 
_Cut< Toperator!= (const _Var< T > &v) const
 
_Var< Toperator* (const _Var< T > &v) const
 
_Var< Toperator/ (const _Var< T > &v) const
 
_Var< Toperator+ (const _Var< T > &v) const
 
_Var< Toperator- (const _Var< T > &v) const
 

Static Public Member Functions

static int MaxID ()
 

Protected Member Functions

 _Var (const std::function< VarFunc_t > &fun, int id)
 

Protected Attributes

std::function< VarFunc_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 Var and SpillVar.

Definition at line 13 of file ReweightableSpectrum.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 18 of file Var.h.

Constructor & Destructor Documentation

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

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

Definition at line 14 of file Var.cxx.

References ana::DepMan< T >::RegisterConstruction().

Referenced by ana::_Var< caf::SRProxy >::MaxID().

15  : fFunc(fun), fID(fgNextID++)
16  {
17  DepMan<_Var<T>>::Instance().RegisterConstruction(this);
18  }
std::function< VarFunc_t > fFunc
Definition: Var.h:62
int fID
Definition: Var.h:64
static int fgNextID
The next ID that hasn&#39;t yet been assigned.
Definition: Var.h:66
template<class T>
ana::_Var< T >::_Var ( const _Var< T > &  v)

Definition at line 35 of file Var.cxx.

References ana::_Var< T >::fFunc, ana::_Var< T >::fID, ana::_Var< T >::operator=(), ana::DepMan< T >::RegisterConstruction(), and ana::DepMan< T >::RegisterDependency().

36  : fFunc(0), fID(-1)
37  {
38  if(&v == this) return;
39 
40  if(v.fFunc){
41  fFunc = v.fFunc;
42  fID = v.fID;
43 
44  DepMan<_Var<T>>::Instance().RegisterConstruction(this);
45  }
46  else{
47  // If we are copying from a Var with NULL func, that is probably because
48  // it is all zero because it hasn't been statically constructed
49  // yet. Register our interest of getting constructed in turn once it is.
50  DepMan<_Var<T>>::Instance().RegisterDependency(&v, this);
51  }
52  }
std::function< VarFunc_t > fFunc
Definition: Var.h:62
int fID
Definition: Var.h:64
template<class T >
ana::_Var< T >::~_Var ( )

Definition at line 29 of file Var.cxx.

References ana::DepMan< T >::RegisterDestruction().

30  {
31  DepMan<_Var<T>>::Instance().RegisterDestruction(this);
32  }
template<class T>
ana::_Var< T >::_Var ( const std::function< VarFunc_t > &  fun,
int  id 
)
protected

Definition at line 22 of file Var.cxx.

References ana::DepMan< T >::RegisterConstruction().

23  : fFunc(fun), fID(id)
24  {
25  DepMan<_Var<T>>::Instance().RegisterConstruction(this);
26  }
std::function< VarFunc_t > fFunc
Definition: Var.h:62
int fID
Definition: Var.h:64

Member Function Documentation

template<class T>
int ana::_Var< T >::ID ( ) const
inline

Vars with the same definition will have the same ID.

Definition at line 36 of file Var.h.

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

36 {return fID;}
int fID
Definition: Var.h:64
template<class T>
static int ana::_Var< T >::MaxID ( )
inlinestatic

Definition at line 38 of file Var.h.

38 {return fgNextID-1;}
static int fgNextID
The next ID that hasn&#39;t yet been assigned.
Definition: Var.h:66
template<class T>
_Cut<T> ana::_Var< T >::operator!= ( double  c) const
template<class T>
_Cut<T> ana::_Var< T >::operator!= ( const _Var< T > &  v) const
template<class T>
double ana::_Var< T >::operator() ( const T sr) const
inline

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

Definition at line 30 of file Var.h.

Referenced by ana::Constant(), ana::_Var< T >::operator*(), ana::_Var< T >::operator+(), ana::_Var< T >::operator-(), ana::_Var< T >::operator/(), ana::Scaled(), and ana::Sqrt().

31  {
32  return fFunc(sr);
33  }
std::function< VarFunc_t > fFunc
Definition: Var.h:62
caf::StandardRecord * sr
template<class T>
_Var< T > ana::_Var< T >::operator* ( const _Var< T > &  v) const

Definition at line 339 of file Var.cxx.

References a, b, ana::_Var< T >::fgNextID, ana::_Var< T >::ID(), PandAna.Demos.tute_pid_validation::ids, findDuplicateFiles::key, ana::_Var< T >::operator()(), ana::_Var< T >::operator/(), sr, and T.

Referenced by ana::_Var< caf::SRProxy >::MaxID(), and ana::Sqrt().

340  {
341  static std::map<std::pair<int, int>, int> ids;
342  const std::pair<int, int> key(ID(), v.ID());
343 
344  struct Times
345  {
346  const _Var<T> a, b;
347  double operator()(const T* sr) const {return a(sr) * b(sr);}
348  };
349 
350  if(ids.count(key) == 0) ids[key] = fgNextID++;
351  return _Var<T>(Times{*this, v});
352  }
int ID() const
Vars with the same definition will have the same ID.
Definition: Var.h:36
const double a
double operator()(const T *sr) const
Allows a variable to be called with double value = myVar(sr) syntax.
Definition: Var.h:30
caf::StandardRecord * sr
const hit & b
Definition: hits.cxx:21
double T
Definition: Xdiff_gwt.C:5
static int fgNextID
The next ID that hasn&#39;t yet been assigned.
Definition: Var.h:66
template<class T>
_Var< T > ana::_Var< T >::operator+ ( const _Var< T > &  v) const

Definition at line 380 of file Var.cxx.

References a, b, ana::_Var< T >::fgNextID, ana::_Var< T >::ID(), PandAna.Demos.tute_pid_validation::ids, findDuplicateFiles::key, ana::_Var< T >::operator()(), ana::_Var< T >::operator-(), sr, and T.

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

381  {
382  static std::map<std::pair<int, int>, int> ids;
383  const std::pair<int, int> key(ID(), v.ID());
384 
385  struct Plus
386  {
387  const _Var<T> a, b;
388  double operator()(const T* sr) const {return a(sr) + b(sr);}
389  };
390 
391  if(ids.count(key) == 0) ids[key] = fgNextID++;
392  return _Var<T>(Plus{*this, v}, ids[key]);
393  }
int ID() const
Vars with the same definition will have the same ID.
Definition: Var.h:36
const double a
double operator()(const T *sr) const
Allows a variable to be called with double value = myVar(sr) syntax.
Definition: Var.h:30
caf::StandardRecord * sr
const hit & b
Definition: hits.cxx:21
double T
Definition: Xdiff_gwt.C:5
static int fgNextID
The next ID that hasn&#39;t yet been assigned.
Definition: Var.h:66
template<class T>
_Var< T > ana::_Var< T >::operator- ( const _Var< T > &  v) const

Definition at line 397 of file Var.cxx.

References a, b, ana::_Var< T >::fgNextID, ana::_Var< T >::ID(), PandAna.Demos.tute_pid_validation::ids, findDuplicateFiles::key, ana::_Var< T >::operator()(), sr, and T.

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

398  {
399  static std::map<std::pair<int, int>, int> ids;
400  const std::pair<int, int> key(ID(), v.ID());
401 
402  struct Minus
403  {
404  const _Var<T> a, b;
405  double operator()(const T* sr) const {return a(sr) - b(sr);}
406  };
407 
408  if(ids.count(key) == 0) ids[key] = fgNextID++;
409  return _Var<T>(Minus{*this, v}, ids[key]);
410  }
int ID() const
Vars with the same definition will have the same ID.
Definition: Var.h:36
const double a
double operator()(const T *sr) const
Allows a variable to be called with double value = myVar(sr) syntax.
Definition: Var.h:30
caf::StandardRecord * sr
const hit & b
Definition: hits.cxx:21
double T
Definition: Xdiff_gwt.C:5
static int fgNextID
The next ID that hasn&#39;t yet been assigned.
Definition: Var.h:66
template<class T>
_Var< T > ana::_Var< T >::operator/ ( const _Var< T > &  v) const

Definition at line 356 of file Var.cxx.

References a, b, Divide(), ana::_Var< T >::fgNextID, ana::_Var< T >::ID(), PandAna.Demos.tute_pid_validation::ids, findDuplicateFiles::key, ana::_Var< T >::operator()(), ana::_Var< T >::operator+(), sr, and T.

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

357  {
358  static std::map<std::pair<int, int>, int> ids;
359  const std::pair<int, int> key(ID(), v.ID());
360 
361  struct Divide
362  {
363  const _Var<T> a, b;
364  double operator()(const T* sr) const
365  {
366  const double denom = b(sr);
367  if(denom != 0)
368  return a(sr) / denom;
369  else
370  return 0.0;
371  }
372  };
373 
374  if(ids.count(key) == 0) ids[key] = fgNextID++;
375  return _Var<T>(Divide{*this, v}, ids[key]);
376  }
ratio_hxv Divide(hxv, goal_hxv)
int ID() const
Vars with the same definition will have the same ID.
Definition: Var.h:36
const double a
double operator()(const T *sr) const
Allows a variable to be called with double value = myVar(sr) syntax.
Definition: Var.h:30
caf::StandardRecord * sr
const hit & b
Definition: hits.cxx:21
double T
Definition: Xdiff_gwt.C:5
static int fgNextID
The next ID that hasn&#39;t yet been assigned.
Definition: Var.h:66
template<class T>
_Cut<T> ana::_Var< T >::operator< ( double  c) const
template<class T>
_Cut<T> ana::_Var< T >::operator< ( const _Var< T > &  v) const
template<class T>
_Cut<T> ana::_Var< T >::operator<= ( double  c) const
template<class T>
_Cut<T> ana::_Var< T >::operator<= ( const _Var< T > &  v) const
template<class T>
_Var< T > & ana::_Var< T >::operator= ( const _Var< T > &  v)

Definition at line 56 of file Var.cxx.

References ana::_Var< T >::fFunc, ana::_Var< T >::fID, ana::DepMan< T >::RegisterConstruction(), and ana::DepMan< T >::RegisterDependency().

Referenced by ana::_Var< T >::_Var().

57  {
58  if(&v == this) return *this;
59 
60  if(v.fFunc){
61  fFunc = v.fFunc;
62  fID = v.fID;
63 
64  DepMan<_Var<T>>::Instance().RegisterConstruction(this);
65  }
66  else{
67  fFunc = 0;
68  fID = -1;
69 
70  // If we are copying from a Var with NULL func, that is probably because
71  // it is all zero because it hasn't been statically constructed
72  // yet. Register our interest of getting constructed in turn once it is.
73  DepMan<_Var<T>>::Instance().RegisterDependency(&v, this);
74  }
75 
76  return *this;
77  }
std::function< VarFunc_t > fFunc
Definition: Var.h:62
int fID
Definition: Var.h:64
template<class T>
_Cut<T> ana::_Var< T >::operator== ( double  c) const
template<class T>
_Cut<T> ana::_Var< T >::operator== ( const _Var< T > &  v) const
template<class T>
_Cut<T> ana::_Var< T >::operator> ( double  c) const
template<class T>
_Cut<T> ana::_Var< T >::operator> ( const _Var< T > &  v) const
template<class T>
_Cut<T> ana::_Var< T >::operator>= ( double  c) const
template<class T>
_Cut<T> ana::_Var< T >::operator>= ( const _Var< T > &  v) const

Member Data Documentation

template<class T>
std::function<VarFunc_t> ana::_Var< T >::fFunc
protected
template<class T>
int ana::_Var< T >::fgNextID = 0
staticprotected

The next ID that hasn't yet been assigned.

Definition at line 66 of file Var.h.

Referenced by ana::_Var< caf::SRProxy >::MaxID(), ana::_Var< T >::operator*(), ana::_Var< T >::operator+(), ana::_Var< T >::operator-(), and ana::_Var< T >::operator/().

template<class T>
int ana::_Var< T >::fID
protected

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