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

Templated class containing a cut, name of cut and description of cut(optional) Typically, the class will be templated on <xAOD::TruthParticle> or <xAOD::TrackParticle>. More...

#include <CutFlow.h>

Collaboration diagram for Accept< A >:

Public Types

typedef A value_type
 Utility typedefs to help callers: the value type. More...
 
typedef const std::function< bool(const A &)> func_type
 Utility typedefs to help callers: the function type. More...
 

Public Member Functions

 Accept ()
 Default constructor with a simple predicate returning false. More...
 
 Accept (const std::function< bool(const A &)> &predicate, const std::string &name="", const std::string &description="")
 Normal constructor. More...
 
bool operator() (const A &i) const
 Overloading the () operator allows the class to be used as a functional. More...
 
bool pass (const A &i) const
 Apply the predicate function and return the value, also updating an internal counter. More...
 
const std::string & name () const
 Return cut name. More...
 
const std::string & description () const
 Return cut description. More...
 

Private Attributes

func_type m_predicate
 
std::string m_name
 
std::string m_desc
 

Detailed Description

template<class A>
class Accept< A >

Templated class containing a cut, name of cut and description of cut(optional) Typically, the class will be templated on <xAOD::TruthParticle> or <xAOD::TrackParticle>.

The cut is passed in as any predicate function, the type is declared as function<bool(A)> although typically these will be lambda functions. The cut is an 'accept' cut, i.e. the value passes if it is true. These predicate functions are called each time the 'pass' method is called. The class keeps an internal count of how many values passed, and may be used as a functional due to the overloaded () operator.

Definition at line 28 of file CutFlow.h.

Member Typedef Documentation

◆ func_type

template<class A >
typedef const std::function<bool (const A&)> Accept< A >::func_type

Utility typedefs to help callers: the function type.

Definition at line 76 of file CutFlow.h.

◆ value_type

template<class A >
typedef A Accept< A >::value_type

Utility typedefs to help callers: the value type.

Definition at line 74 of file CutFlow.h.

Constructor & Destructor Documentation

◆ Accept() [1/2]

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

Default constructor with a simple predicate returning false.

Definition at line 31 of file CutFlow.h.

31  : m_predicate([](A) {
32  return false;
33  }), m_name {}, m_desc {} {
34  // nop
35  }

◆ Accept() [2/2]

template<class A >
Accept< A >::Accept ( const std::function< bool(const A &)> &  predicate,
const std::string &  name = "",
const std::string &  description = "" 
)
inline

Normal constructor.

Parameters
predicateany function taking the templated value and returning a bool
nameoptional name for this cut
descriptionoptional description for this cut

Definition at line 41 of file CutFlow.h.

42  : m_predicate(predicate), m_name(name), m_desc(description)
43  {
44  // nop
45  }

Member Function Documentation

◆ description()

template<class A >
const std::string& Accept< A >::description ( ) const
inline

Return cut description.

Definition at line 69 of file CutFlow.h.

69  {
70  return m_desc;
71  }

◆ name()

template<class A >
const std::string& Accept< A >::name ( ) const
inline

Return cut name.

Definition at line 63 of file CutFlow.h.

63  {
64  return m_name;
65  }

◆ operator()()

template<class A >
bool Accept< A >::operator() ( const A &  i) const
inline

Overloading the () operator allows the class to be used as a functional.

Definition at line 49 of file CutFlow.h.

49  {
50  return pass(i);
51  }

◆ pass()

template<class A >
bool Accept< A >::pass ( const A &  i) const
inline

Apply the predicate function and return the value, also updating an internal counter.

Definition at line 55 of file CutFlow.h.

55  {
56  const bool passed = m_predicate(i);
57  return passed;
58  }

Member Data Documentation

◆ m_desc

template<class A >
std::string Accept< A >::m_desc
private

Definition at line 81 of file CutFlow.h.

◆ m_name

template<class A >
std::string Accept< A >::m_name
private

Definition at line 80 of file CutFlow.h.

◆ m_predicate

template<class A >
func_type Accept< A >::m_predicate
private

Definition at line 79 of file CutFlow.h.


The documentation for this class was generated from the following file:
Accept::name
const std::string & name() const
Return cut name.
Definition: CutFlow.h:63
TrigCompositeUtils::passed
bool passed(DecisionID id, const DecisionIDContainer &idSet)
checks if required decision ID is in the set of IDs in the container
Definition: TrigCompositeUtilsRoot.cxx:117
Accept::m_desc
std::string m_desc
Definition: CutFlow.h:81
dqt_zlumi_alleff_HIST.A
A
Definition: dqt_zlumi_alleff_HIST.py:110
lumiFormat.i
int i
Definition: lumiFormat.py:92
Accept::m_name
std::string m_name
Definition: CutFlow.h:80
Accept::description
const std::string & description() const
Return cut description.
Definition: CutFlow.h:69
Accept::pass
bool pass(const A &i) const
Apply the predicate function and return the value, also updating an internal counter.
Definition: CutFlow.h:55
Accept::m_predicate
func_type m_predicate
Definition: CutFlow.h:79