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::_Cut< T > Class Template Reference

Template for Cut and SpillCut. More...

#include <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...
 
bool operator() (const T *sr) const
 Allows a cut to be called with bool result = myCut(sr) syntax. More...
 
double Livetime (const caf::SRSpill *spill) const
 Provide a Livetime function if your cut is a timing cut etc. More...
 
double POT (const caf::SRSpill *spill) const
 Could be useful for cuts on specific batches? More...
 
int ID () const
 Cuts with the same definition will have the same ID. More...
 

Static Public Member Functions

static int MaxID ()
 

Protected Member Functions

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

Friends

std::function< ExposureFunc_tCombineExposures (const std::function< ExposureFunc_t > &a, const std::function< ExposureFunc_t > &b)
 
_Cut< T > operator&& (const _Cut< T > &a, const _Cut< T > &b)
 
_Cut< T > operator|| (const _Cut< T > &a, const _Cut< T > &b)
 
_Cut< T > operator! (const _Cut< T > &a)
 

Detailed Description

template<class T>
class ana::_Cut< T >

Template for Cut and SpillCut.

Definition at line 16 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 31 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 10 of file Cut.cxx.

13  : fFunc(func), fLiveFunc(liveFunc), fPOTFunc(potFunc),
14  fID(fgNextID++)
15  {
16  }
std::function< ExposureFunc_t > fPOTFunc
Definition: Cut.h:79
static int fgNextID
The next ID that hasn&#39;t yet been assigned.
Definition: Cut.h:83
std::function< ExposureFunc_t > fLiveFunc
Definition: Cut.h:79
std::function< CutFunc_t > fFunc
Definition: Cut.h:78
int fID
Definition: Cut.h:81
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 
)
inlineprotected

Definition at line 70 of file Cut.h.

74  : fFunc(fun), fLiveFunc(liveFunc), fPOTFunc(potFunc), fID(id)
75  {
76  }
std::function< ExposureFunc_t > fPOTFunc
Definition: Cut.h:79
std::function< ExposureFunc_t > fLiveFunc
Definition: Cut.h:79
std::function< CutFunc_t > fFunc
Definition: Cut.h:78
int fID
Definition: Cut.h:81

Member Function Documentation

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

Cuts with the same definition will have the same ID.

Definition at line 57 of file Cut.h.

57 {return fID;}
int fID
Definition: Cut.h:81
template<class T>
double ana::_Cut< T >::Livetime ( const caf::SRSpill *  spill) const
inline

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

Definition at line 45 of file Cut.h.

46  {
47  return fLiveFunc ? fLiveFunc(spill) : -1;
48  }
std::function< ExposureFunc_t > fLiveFunc
Definition: Cut.h:79
template<class T >
int ana::_Cut< T >::MaxID ( )
static

Definition at line 19 of file Cut.cxx.

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

40  {
41  return fFunc(sr);
42  }
std::function< CutFunc_t > fFunc
Definition: Cut.h:78
template<class T>
double ana::_Cut< T >::POT ( const caf::SRSpill *  spill) const
inline

Could be useful for cuts on specific batches?

Definition at line 51 of file Cut.h.

52  {
53  return fPOTFunc ? fPOTFunc(spill) : -1;
54  }
std::function< ExposureFunc_t > fPOTFunc
Definition: Cut.h:79

Friends And Related Function Documentation

template<class T>
std::function<ExposureFunc_t> CombineExposures ( const std::function< ExposureFunc_t > &  a,
const std::function< ExposureFunc_t > &  b 
)
friend

Definition at line 26 of file Cut.cxx.

28  {
29  if(!a && !b) return 0;
30  if(!a) return b;
31  if(!b) return a;
32 
33  return [a, b](const caf::SRSpill* spill){
34  const double va = a(spill);
35  const double vb = b(spill);
36 
37  if(va >= 0 && vb >= 0){
38  std::cout << "Inconsistent pot/livetime values of "
39  << va << " and " << vb
40  << " from two cuts being combined." << std::endl;
41  abort();
42  }
43 
44  return std::max(va, vb);
45  };
46  }
process_name gaushit a
BEGIN_PROLOG could also be cout
template<class T>
_Cut<T> operator! ( const _Cut< T > &  a)
friend

Definition at line 100 of file Cut.cxx.

101  {
102  static std::map<int, int> ids;
103  if(ids.count(a.ID())){
104  return _Cut<T>([a](const T* sr){return !a(sr);},
105  0, 0, ids[a.ID()]);
106  }
107  else{
108  const _Cut<T> ret([a](const T* sr){return !a(sr);});
109  ids[a.ID()] = ret.ID();
110  return ret;
111  }
112  }
process_name gaushit a
template<class T>
_Cut<T> operator&& ( const _Cut< T > &  a,
const _Cut< T > &  b 
)
friend

Definition at line 49 of file Cut.cxx.

50  {
51  // The same pairs of cuts are frequently and-ed together. Make sure those
52  // duplicates get the same IDs by remembering what we've done in the past.
53  static std::map<std::pair<int, int>, int> ids;
54  const std::pair<int, int> key(a.ID(), b.ID());
55 
56  if(ids.count(key)){
57  return _Cut<T>([a, b](const T* sr){return a(sr) && b(sr);},
58  CombineExposures(a.fLiveFunc, b.fLiveFunc),
59  CombineExposures(a.fPOTFunc, b.fPOTFunc),
60  ids[key]);
61  }
62  else{
63  const _Cut<T> ret([a, b](const T* sr){return a(sr) && b(sr);},
64  CombineExposures(a.fLiveFunc, b.fLiveFunc),
65  CombineExposures(a.fPOTFunc, b.fPOTFunc));
66  ids[key] = ret.ID();
67  return ret;
68  }
69  }
process_name gaushit a
friend std::function< ExposureFunc_t > CombineExposures(const std::function< ExposureFunc_t > &a, const std::function< ExposureFunc_t > &b)
Definition: Cut.cxx:26
template<class T>
_Cut<T> operator|| ( const _Cut< T > &  a,
const _Cut< T > &  b 
)
friend

Definition at line 76 of file Cut.cxx.

77  {
78  static std::map<std::pair<int, int>, int> ids;
79  const std::pair<int, int> key(a.ID(), b.ID());
80  if(ids.count(key)){
81  return _Cut<T>([a, b](const T* sr){return a(sr) || b(sr);},
82  CombineExposures(a.fLiveFunc, b.fLiveFunc),
83  CombineExposures(a.fPOTFunc, b.fPOTFunc),
84  ids[key]);
85  }
86  else{
87  const _Cut<T> ret([a, b](const T* sr){return a(sr) || b(sr);},
88  CombineExposures(a.fLiveFunc, b.fLiveFunc),
89  CombineExposures(a.fPOTFunc, b.fPOTFunc));
90  ids[key] = ret.ID();
91  return ret;
92  }
93  }
process_name gaushit a
friend std::function< ExposureFunc_t > CombineExposures(const std::function< ExposureFunc_t > &a, const std::function< ExposureFunc_t > &b)
Definition: Cut.cxx:26

Member Data Documentation

template<class T>
std::function<CutFunc_t> ana::_Cut< T >::fFunc
protected

Definition at line 78 of file Cut.h.

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

The next ID that hasn't yet been assigned.

Definition at line 83 of file Cut.h.

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

Definition at line 81 of file Cut.h.

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

Definition at line 79 of file Cut.h.

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

Definition at line 79 of file Cut.h.


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