All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | Friends | List of all members
ana::_Var< T > Class Template Reference

Most useful for combining weights. More...

#include <Var.h>

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...
 
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...
 

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...
 

Friends

_Var< T > operator* (const _Var< T > &a, const _Var< T > &b)
 
_Var< T > operator/ (const _Var< T > &a, const _Var< T > &b)
 
_Var< T > operator+ (const _Var< T > &a, const _Var< T > &b)
 
_Var< T > operator- (const _Var< T > &a, const _Var< T > &b)
 

Detailed Description

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

Most useful for combining weights.

Template for Var and SpillVar.

Definition at line 23 of file Var.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 34 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 12 of file Var.cxx.

13  : fFunc(fun), fID(fgNextID++)
14  {
15  }
std::function< VarFunc_t > fFunc
Definition: Var.h:61
int fID
Definition: Var.h:63
static int fgNextID
The next ID that hasn&#39;t yet been assigned.
Definition: Var.h:65
template<class T>
ana::_Var< T >::_Var ( const std::function< VarFunc_t > &  fun,
int  id 
)
inlineprotected

Definition at line 56 of file Var.h.

57  : fFunc(fun), fID(id)
58  {
59  }
std::function< VarFunc_t > fFunc
Definition: Var.h:61
int fID
Definition: Var.h:63

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 46 of file Var.h.

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

Definition at line 18 of file Var.cxx.

19  {
20  return fgNextID-1;
21  }
static int fgNextID
The next ID that hasn&#39;t yet been assigned.
Definition: Var.h:65
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 40 of file Var.h.

41  {
42  return fFunc(sr);
43  }
std::function< VarFunc_t > fFunc
Definition: Var.h:61

Friends And Related Function Documentation

template<class T>
_Var<T> operator* ( const _Var< T > &  a,
const _Var< T > &  b 
)
friend

Definition at line 179 of file Var.cxx.

180  {
181  static std::map<std::pair<int, int>, int> ids;
182  const std::pair<int, int> key(a.ID(), b.ID());
183 
184  if(ids.count(key)){
185  return _Var<T>([a, b](const T* sr){return a(sr) * b(sr);},
186  ids[key]);
187  }
188  else{
189  const _Var<T> ret([a, b](const T* sr){return a(sr) * b(sr);});
190  ids[key] = ret.ID();
191  return ret;
192  }
193  }
process_name gaushit a
template<class T>
_Var<T> operator+ ( const _Var< T > &  a,
const _Var< T > &  b 
)
friend

Definition at line 229 of file Var.cxx.

230  {
231  static std::map<std::pair<int, int>, int> ids;
232  const std::pair<int, int> key(a.ID(), b.ID());
233 
234  if(ids.count(key)){
235  return _Var<T>([a, b](const T* sr){return a(sr) + b(sr);},
236  ids[key]);
237  }
238  else{
239  const _Var<T> ret([a, b](const T* sr){return a(sr) + b(sr);});
240  ids[key] = ret.ID();
241  return ret;
242  }
243  }
process_name gaushit a
template<class T>
_Var<T> operator- ( const _Var< T > &  a,
const _Var< T > &  b 
)
friend

Definition at line 247 of file Var.cxx.

248  {
249  static std::map<std::pair<int, int>, int> ids;
250  const std::pair<int, int> key(a.ID(), b.ID());
251 
252  if(ids.count(key)){
253  return _Var<T>([a, b](const T* sr){return a(sr) - b(sr);},
254  ids[key]);
255  }
256  else{
257  const _Var<T> ret([a, b](const T* sr){return a(sr) - b(sr);});
258  ids[key] = ret.ID();
259  return ret;
260  }
261  }
process_name gaushit a
template<class T>
_Var<T> operator/ ( const _Var< T > &  a,
const _Var< T > &  b 
)
friend

Definition at line 197 of file Var.cxx.

198  {
199  static std::map<std::pair<int, int>, int> ids;
200  const std::pair<int, int> key(a.ID(), b.ID());
201 
202  if(ids.count(key)){
203  return _Var<T>([a, b](const T* sr)
204  {
205  const double denom = b(sr);
206  if(denom != 0)
207  return a(sr) / denom;
208  else
209  return 0.0;
210  },
211  ids[key]);
212  }
213  else{
214  const _Var<T> ret([a, b](const T* sr)
215  {
216  const double denom = b(sr);
217  if(denom != 0)
218  return a(sr) / denom;
219  else
220  return 0.0;
221  });
222  ids[key] = ret.ID();
223  return ret;
224  }
225  }
process_name gaushit a

Member Data Documentation

template<class T>
std::function<VarFunc_t> ana::_Var< T >::fFunc
protected

Definition at line 61 of file Var.h.

template<class T>
int ana::_Var< T >::fgNextID = 0
staticprotected

The next ID that hasn't yet been assigned.

Definition at line 65 of file Var.h.

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

Definition at line 63 of file Var.h.


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