ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
CutList< A > Class Template Reference

Templated CutList class to contain a group of cuts. More...

#include <CutFlow.h>

Collaboration diagram for CutList< A >:

Public Member Functions

 CutList (const std::vector< Accept< A > > &cuts)
 Normal constructor takes a vector<Accept>. Note default mode is 'ALL'. More...
 
 CutList ()
 Default constructor with no cuts implemented. More...
 
void add (const Accept< A > &newCut)
 Add one cut. More...
 
unsigned int accept (const A &value) const
 Apply cuts and return the boolean result; keep count of number of calls and passes. More...
 
unsigned int testAllCuts (const A &value, std::vector< unsigned int > &counter) const
 
unsigned int size () const
 Return the number of cuts. More...
 
std::vector< std::string > names () const
 Return a vector of the cut names. More...
 

Private Attributes

std::vector< Accept< A > > m_cuts
 

Detailed Description

template<class A>
class CutList< A >

Templated CutList class to contain a group of cuts.

The CutList is typically instantiated with a vector of Accept objects, although additional cuts may be added with the 'add' method. Cuts may be applied in one of two ways, determined by the 'mode' parameter: ALL: Always apply every cut UNTIL_FAIL: Apply cuts until the first one fails The 'accept' method applies the cuts and keeps internal count of how many times it is called.

Definition at line 93 of file CutFlow.h.

Constructor & Destructor Documentation

◆ CutList() [1/2]

template<class A >
CutList< A >::CutList ( const std::vector< Accept< A > > &  cuts)
inline

Normal constructor takes a vector<Accept>. Note default mode is 'ALL'.

Definition at line 97 of file CutFlow.h.

97  : m_cuts(cuts) {
98  // nop
99  }

◆ CutList() [2/2]

template<class A >
CutList< A >::CutList ( )
inline

Default constructor with no cuts implemented.

Definition at line 102 of file CutFlow.h.

102  : m_cuts{} {
103  // nop
104  }

Member Function Documentation

◆ accept()

template<class A >
unsigned int CutList< A >::accept ( const A &  value) const
inline

Apply cuts and return the boolean result; keep count of number of calls and passes.

Definition at line 115 of file CutFlow.h.

115  {
116  unsigned int missing_cuts = m_cuts.size();
117 
118  for (auto& thisCut:m_cuts) {
119  if (not thisCut.pass(value)) {
120  break;
121  }
122  --missing_cuts;
123  }
124  return missing_cuts;
125  }

◆ add()

template<class A >
void CutList< A >::add ( const Accept< A > &  newCut)
inline

Add one cut.

Definition at line 109 of file CutFlow.h.

109  {
110  m_cuts.push_back(newCut);
111  }

◆ names()

template<class A >
std::vector<std::string> CutList< A >::names ( ) const
inline

Return a vector of the cut names.

Definition at line 152 of file CutFlow.h.

152  {
153  std::vector<std::string> result(m_cuts.size());
154  unsigned int idx(0);
155  for (const auto& i:m_cuts) {
156  result[idx++] = i.name();
157  }
158  return result; // return-value-optimisation is invoked
159  }

◆ size()

template<class A >
unsigned int CutList< A >::size ( ) const
inline

Return the number of cuts.

Definition at line 146 of file CutFlow.h.

146  {
147  return m_cuts.size();
148  }

◆ testAllCuts()

template<class A >
unsigned int CutList< A >::testAllCuts ( const A &  value,
std::vector< unsigned int > &  counter 
) const
inline

Definition at line 128 of file CutFlow.h.

128  {
129  unsigned int idx = 0;
130  ++(counter[idx++]);
131  if (counter.size() != m_cuts.size()+2 /* CutFlow::kNReserved */) {
132  throw std::logic_error("Number of cuts and counters do not match." );
133  }
134  unsigned int missing_cuts = 0;
135  ++(counter[idx++]);
136  for (auto& thisCut:m_cuts) {
137  if (!thisCut.pass(value)) { ++missing_cuts; }
138  else { ++(counter[idx]); }
139  ++idx;
140  }
141  return missing_cuts;
142  }

Member Data Documentation

◆ m_cuts

template<class A >
std::vector<Accept<A> > CutList< A >::m_cuts
private

Definition at line 162 of file CutFlow.h.


The documentation for this class was generated from the following file:
get_generator_info.result
result
Definition: get_generator_info.py:21
athena.value
value
Definition: athena.py:122
lumiFormat.i
int i
Definition: lumiFormat.py:92
plotBeamSpotVert.cuts
string cuts
Definition: plotBeamSpotVert.py:93
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition: LArNewCalib_DelayDump_OFC_Cali.py:69
test_pyathena.counter
counter
Definition: test_pyathena.py:15
CutList::m_cuts
std::vector< Accept< A > > m_cuts
Definition: CutFlow.h:162