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

Template for Cut and SpillCut. More...

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

Public Types

typedef bool( CutFunc_t) (const T *sr)
 The type of the function part of a cut. More...
 

Public Member Functions

 _Cut (const std::function< CutFunc_t > &func, const std::function< ExposureFunc_t > &liveFunc=0, const std::function< ExposureFunc_t > &potFunc=0)
 std::function can wrap a real function, function object, or lambda More...
 
 _Cut (const _Cut< T > &c)
 
_Cutoperator= (const _Cut< T > &c)
 
 ~_Cut ()
 
bool operator() (const T *sr) const
 Allows a cut to be called with bool result = myCut(sr) syntax. More...
 
double Livetime (const caf::SRSpillProxy *spill) const
 Provide a Livetime function if your cut is a timing cut etc. More...
 
double POT (const caf::SRSpillProxy *spill) const
 Could be useful for cuts on specific batches? More...
 
_Cut< Toperator&& (const _Cut< T > &c) const
 
_Cut< Toperator|| (const _Cut< T > &b) const
 
_Cut< Toperator! () const
 
int ID () const
 Cuts with the same definition will have the same ID. More...
 

Static Public Member Functions

static int MaxID ()
 

Protected Member Functions

 operator bool () const
 
 _Cut (const std::function< CutFunc_t > &fun, const std::function< ExposureFunc_t > &liveFunc, const std::function< ExposureFunc_t > &potFunc, int id)
 

Protected Attributes

std::function< CutFunc_tfFunc
 
std::function< ExposureFunc_tfLiveFunc
 
std::function< ExposureFunc_tfPOTFunc
 
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::_Cut< T >

Template for Cut and SpillCut.

Definition at line 15 of file Cut.h.

Member Typedef Documentation

template<class T>
typedef bool( ana::_Cut< T >::CutFunc_t) (const T *sr)

The type of the function part of a cut.

Definition at line 19 of file Cut.h.

Constructor & Destructor Documentation

template<class T >
ana::_Cut< T >::_Cut ( const std::function< CutFunc_t > &  func,
const std::function< ExposureFunc_t > &  liveFunc = 0,
const std::function< ExposureFunc_t > &  potFunc = 0 
)

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

Definition at line 12 of file Cut.cxx.

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

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

15  : fFunc(func), fLiveFunc(liveFunc), fPOTFunc(potFunc),
16  fID(fgNextID++)
17  {
18  DepMan<_Cut<T>>::Instance().RegisterConstruction(this);
19  }
std::function< ExposureFunc_t > fPOTFunc
Definition: Cut.h:81
static int fgNextID
The next ID that hasn&#39;t yet been assigned.
Definition: Cut.h:85
double func(double x, double y)
std::function< ExposureFunc_t > fLiveFunc
Definition: Cut.h:81
std::function< CutFunc_t > fFunc
Definition: Cut.h:80
int fID
Definition: Cut.h:83
template<class T>
ana::_Cut< T >::_Cut ( const _Cut< T > &  c)

Definition at line 39 of file Cut.cxx.

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

40  : fFunc(0), fLiveFunc(0), fPOTFunc(0), fID(-1)
41  {
42  if(&c == this) return;
43 
44  if(c.fFunc){
45  fFunc = c.fFunc;
46  fLiveFunc = c.fLiveFunc;
47  fPOTFunc = c.fPOTFunc;
48  fID = c.fID;
49 
50  DepMan<_Cut<T>>::Instance().RegisterConstruction(this);
51  }
52  else{
53  // If we are copying from a Cut with NULL func, that is probably because
54  // it is all zero because it hasn't been statically constructed
55  // yet. Register our interest of getting constructed in turn once it is.
56  DepMan<_Cut<T>>::Instance().RegisterDependency(&c, this);
57  }
58  }
std::function< ExposureFunc_t > fPOTFunc
Definition: Cut.h:81
std::function< ExposureFunc_t > fLiveFunc
Definition: Cut.h:81
std::function< CutFunc_t > fFunc
Definition: Cut.h:80
int fID
Definition: Cut.h:83
template<class T >
ana::_Cut< T >::~_Cut ( )

Definition at line 33 of file Cut.cxx.

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

34  {
35  DepMan<_Cut<T>>::Instance().RegisterDestruction(this);
36  }
template<class T>
ana::_Cut< T >::_Cut ( const std::function< CutFunc_t > &  fun,
const std::function< ExposureFunc_t > &  liveFunc,
const std::function< ExposureFunc_t > &  potFunc,
int  id 
)
protected

Definition at line 23 of file Cut.cxx.

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

27  : fFunc(fun), fLiveFunc(liveFunc), fPOTFunc(potFunc), fID(id)
28  {
29  DepMan<_Cut<T>>::Instance().RegisterConstruction(this);
30  }
std::function< ExposureFunc_t > fPOTFunc
Definition: Cut.h:81
std::function< ExposureFunc_t > fLiveFunc
Definition: Cut.h:81
std::function< CutFunc_t > fFunc
Definition: Cut.h:80
int fID
Definition: Cut.h:83

Member Function Documentation

template<class T>
int ana::_Cut< T >::ID ( ) const
inline
template<class T>
double ana::_Cut< T >::Livetime ( const caf::SRSpillProxy spill) const
inline

Provide a Livetime function if your cut is a timing cut etc.

Definition at line 39 of file Cut.h.

Referenced by ana::ExposureSource::HandleSpill().

40  {
41  return fLiveFunc ? fLiveFunc(spill) : -1;
42  }
std::function< ExposureFunc_t > fLiveFunc
Definition: Cut.h:81
template<class T>
static int ana::_Cut< T >::MaxID ( )
inlinestatic

Definition at line 57 of file Cut.h.

57 {return fgNextID-1;}
static int fgNextID
The next ID that hasn&#39;t yet been assigned.
Definition: Cut.h:85
template<class T >
ana::_Cut< T >::operator bool ( ) const
protected

Definition at line 185 of file Cut.cxx.

References om::cout, and allTimeWatchdog::endl.

186  {
187  std::cout << "*** A Cut object is being evaluated for truth-iness. "
188  << "This very likely means you are using python and attempted "
189  << "to use one of the 'and', 'or', or 'not' operators. Python "
190  << "does not allow these to be overloaded. You should use the "
191  << "corresponding bitwise operators '&', '|', '~' instead."
192  << std::endl;
193  abort();
194  }
OStream cout
Definition: OStream.cxx:6
template<class T >
_Cut< T > ana::_Cut< T >::operator! ( ) const

Definition at line 170 of file Cut.cxx.

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

Referenced by ana::_Cut< caf::SRProxy >::POT().

171  {
172  static std::map<int, int> ids;
173 
174  struct Not
175  {
176  const _Cut<T> a;
177  bool operator()(const T* sr) const {return !a(sr);}
178  };
179 
180  if(ids.count(ID()) == 0) ids[ID()] = fgNextID++;
181  return _Cut<T>(Not{*this}, 0, 0, ids[ID()]);
182  }
static int fgNextID
The next ID that hasn&#39;t yet been assigned.
Definition: Cut.h:85
const double a
int ID() const
Cuts with the same definition will have the same ID.
Definition: Cut.h:55
caf::StandardRecord * sr
double T
Definition: Xdiff_gwt.C:5
bool operator()(const T *sr) const
Allows a cut to be called with bool result = myCut(sr) syntax.
Definition: Cut.h:33
template<class T>
_Cut< T > ana::_Cut< T >::operator&& ( const _Cut< T > &  c) const

Definition at line 129 of file Cut.cxx.

References a, b, ana::CombineExposures(), ana::_Cut< T >::fgNextID, ana::_Cut< T >::fLiveFunc, ana::_Cut< T >::fPOTFunc, ana::_Cut< T >::ID(), PandAna.Demos.tute_pid_validation::ids, findDuplicateFiles::key, ana::_Cut< T >::operator()(), ana::_Cut< T >::operator||(), sr, and T.

Referenced by ana::CombineExposures(), and ana::_Cut< caf::SRProxy >::POT().

130  {
131  // The same pairs of cuts are frequently and-ed together. Make sure those
132  // duplicates get the same IDs by remembering what we've done in the past.
133  static std::map<std::pair<int, int>, int> ids;
134  const std::pair<int, int> key(ID(), c.ID());
135 
136  struct And
137  {
138  const _Cut<T> a, b;
139  bool operator()(const T* sr) const {return a(sr) && b(sr);}
140  };
141 
142  if(ids.count(key) == 0) ids[key] = fgNextID++;
143  return _Cut<T>(And{*this, c},
144  CombineExposures(fLiveFunc, c.fLiveFunc),
145  CombineExposures(fPOTFunc, c.fPOTFunc),
146  ids[key]);
147  }
std::function< ExposureFunc_t > fPOTFunc
Definition: Cut.h:81
std::function< ExposureFunc_t > CombineExposures(const std::function< ExposureFunc_t > &a, const std::function< ExposureFunc_t > &b)
Definition: Cut.cxx:98
static int fgNextID
The next ID that hasn&#39;t yet been assigned.
Definition: Cut.h:85
const double a
int ID() const
Cuts with the same definition will have the same ID.
Definition: Cut.h:55
caf::StandardRecord * sr
std::function< ExposureFunc_t > fLiveFunc
Definition: Cut.h:81
const hit & b
Definition: hits.cxx:21
double T
Definition: Xdiff_gwt.C:5
bool operator()(const T *sr) const
Allows a cut to be called with bool result = myCut(sr) syntax.
Definition: Cut.h:33
template<class T>
bool ana::_Cut< T >::operator() ( const T sr) const
inline

Allows a cut to be called with bool result = myCut(sr) syntax.

Definition at line 33 of file Cut.h.

Referenced by ana::CombineExposures(), ana::_Cut< T >::operator!(), ana::_Cut< T >::operator&&(), and ana::_Cut< T >::operator||().

34  {
35  return fFunc(sr);
36  }
caf::StandardRecord * sr
std::function< CutFunc_t > fFunc
Definition: Cut.h:80
template<class T>
_Cut< T > & ana::_Cut< T >::operator= ( const _Cut< T > &  c)

Definition at line 62 of file Cut.cxx.

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

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

63  {
64  if(&c == this) return *this;
65 
66  if(c.fFunc){
67  fFunc = c.fFunc;
68  fLiveFunc = c.fLiveFunc;
69  fPOTFunc = c.fPOTFunc;
70  fID = c.fID;
71 
72  DepMan<_Cut<T>>::Instance().RegisterConstruction(this);
73  }
74  else{
75  fFunc = 0;
76  fLiveFunc = 0;
77  fPOTFunc = 0;
78  fID = -1;
79 
80  // If we are copying from a Cut with NULL func, that is probably because
81  // it is all zero because it hasn't been statically constructed
82  // yet. Register our interest of getting constructed in turn once it is.
83  DepMan<_Cut<T>>::Instance().RegisterDependency(&c, this);
84  }
85 
86  return *this;
87  }
std::function< ExposureFunc_t > fPOTFunc
Definition: Cut.h:81
std::function< ExposureFunc_t > fLiveFunc
Definition: Cut.h:81
std::function< CutFunc_t > fFunc
Definition: Cut.h:80
int fID
Definition: Cut.h:83
template<class T>
_Cut< T > ana::_Cut< T >::operator|| ( const _Cut< T > &  b) const

Definition at line 151 of file Cut.cxx.

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

Referenced by ana::_Cut< T >::operator&&(), and ana::_Cut< caf::SRProxy >::POT().

152  {
153  static std::map<std::pair<int, int>, int> ids;
154  const std::pair<int, int> key(ID(), c.ID());
155 
156  struct Or
157  {
158  const _Cut<T> a, b;
159  bool operator()(const T* sr) const {return a(sr) || b(sr);}
160  };
161 
162  if(ids.count(key) == 0) ids[key] = fgNextID++;
163  return _Cut<T>(Or{*this, c},
164  CombineExposures(fLiveFunc, c.fLiveFunc),
165  CombineExposures(fPOTFunc, c.fPOTFunc),
166  ids[key]);
167  }
std::function< ExposureFunc_t > fPOTFunc
Definition: Cut.h:81
std::function< ExposureFunc_t > CombineExposures(const std::function< ExposureFunc_t > &a, const std::function< ExposureFunc_t > &b)
Definition: Cut.cxx:98
static int fgNextID
The next ID that hasn&#39;t yet been assigned.
Definition: Cut.h:85
const double a
int ID() const
Cuts with the same definition will have the same ID.
Definition: Cut.h:55
caf::StandardRecord * sr
std::function< ExposureFunc_t > fLiveFunc
Definition: Cut.h:81
const hit & b
Definition: hits.cxx:21
double T
Definition: Xdiff_gwt.C:5
bool operator()(const T *sr) const
Allows a cut to be called with bool result = myCut(sr) syntax.
Definition: Cut.h:33
template<class T>
double ana::_Cut< T >::POT ( const caf::SRSpillProxy spill) const
inline

Could be useful for cuts on specific batches?

Definition at line 45 of file Cut.h.

Referenced by ana::ExposureSource::HandleSpill().

46  {
47  return fPOTFunc ? fPOTFunc(spill) : -1;
48  }
std::function< ExposureFunc_t > fPOTFunc
Definition: Cut.h:81

Member Data Documentation

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

The next ID that hasn't yet been assigned.

Definition at line 85 of file Cut.h.

Referenced by ana::_Cut< caf::SRProxy >::MaxID(), ana::_Cut< T >::operator!(), ana::_Cut< T >::operator&&(), and ana::_Cut< T >::operator||().

template<class T>
int ana::_Cut< T >::fID
protected
template<class T>
std::function<ExposureFunc_t> ana::_Cut< T >::fLiveFunc
protected
template<class T>
std::function<ExposureFunc_t> ana::_Cut< T >::fPOTFunc
protected

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