ATLAS Offline Software
Loading...
Searching...
No Matches
ChargeFilter< T > Class Template Reference

ChargeFilter can filter objects upon their charge. More...

#include <ChargeFilter.h>

Inheritance diagram for ChargeFilter< T >:
Collaboration diagram for ChargeFilter< T >:

Public Member Functions

 ChargeFilter ()
 Default constructor:
 ChargeFilter (const ChargeFilter< T > &rhs)
 Copy constructor:
virtual ~ChargeFilter ()
 Destructor:
ChargeFilter< T > & operator= (const ChargeFilter< T > &rhs)
 Assignment operator:
virtual bool isAccepted (const T *element) const
 Main filter method.
double charge () const
 Returns the charge the filter is looking for.
void setFilter (const IFilterCuts *filter)
 Copies the IFilterCuts properties of the given object to the current IFilterCuts object (ie: it copies the required charge() to the current object)
void setCharge (const ChargeType &charge)
 Set the filter to look for the given charge.
bool operator() (const T *element) const

Protected Attributes

std::optional< ChargeTypem_charge
 The charge the filter is looking for.

Detailed Description

template<typename T>
class ChargeFilter< T >

ChargeFilter can filter objects upon their charge.

One can only require a charge (not a range in charges). But it could be extended to a range.

Definition at line 31 of file ChargeFilter.h.

Constructor & Destructor Documentation

◆ ChargeFilter() [1/2]

template<typename T>
ChargeFilter< T >::ChargeFilter ( )

Default constructor:

Implementation.

Definition at line 103 of file ChargeFilter.h.

103 :
104 IFilterCuts(),
105 IFilter<T>(),
106 m_charge()
107{}
std::optional< ChargeType > m_charge
The charge the filter is looking for.
IFilterCuts()
Default constructor:
Definition IFilterCuts.h:69
IFilter()
Default constructor:
Definition IFilter.h:78

◆ ChargeFilter() [2/2]

template<typename T>
ChargeFilter< T >::ChargeFilter ( const ChargeFilter< T > & rhs)

Copy constructor:

Definition at line 110 of file ChargeFilter.h.

110 :
114{}
ChargeFilter can filter objects upon their charge.

◆ ~ChargeFilter()

template<typename T>
ChargeFilter< T >::~ChargeFilter ( )
virtual

Destructor:

Definition at line 130 of file ChargeFilter.h.

130{}

Member Function Documentation

◆ charge()

template<typename T>
double ChargeFilter< T >::charge ( ) const

Returns the charge the filter is looking for.

Definition at line 154 of file ChargeFilter.h.

155{
156 if (m_charge) {
157 return *m_charge;
158 }
159 throw std::domain_error( "No charge selection defined" );
160}

◆ isAccepted()

template<typename T>
bool ChargeFilter< T >::isAccepted ( const T * element) const
virtual

Main filter method.

This method takes the decision whether or not the filter has to accept the element. It returns true or false accordingly if the charge of the particle matchs the one of the filter, it is accepted. If no cut has been defined, it returns true by default.

Check if a charge cut has been set-up

The charge cut is un-initialized so by convention we return true;

Otherwise return true by convention

Implements IFilter< T >.

Definition at line 133 of file ChargeFilter.h.

134{
136 if ( !m_charge ) {
139 return true;
140 } else {
141 const ChargeType charge = element->charge();
142 if ( *m_charge == charge ) {
143 return true;
144 } else {
145 return false;
146 }
147 }
148
150 return true;
151}
double charge() const
Returns the charge the filter is looking for.

◆ operator()()

template<typename T>
bool IFilter< T >::operator() ( const T * element) const
inlineinherited

Definition at line 101 of file IFilter.h.

102{
103 return isAccepted(element);
104}
IFilter is the main interface to the filters.
Definition IFilter.h:31
virtual bool isAccepted(const T *element) const =0
Main filter method.

◆ operator=()

template<typename T>
ChargeFilter< T > & ChargeFilter< T >::operator= ( const ChargeFilter< T > & rhs)
inline

Assignment operator:

Definition at line 118 of file ChargeFilter.h.

119{
120 if ( this != &rhs ) {
124 }
125 return *this;
126}
IFilterCuts & operator=(const IFilterCuts &rhs)
Assignment operator:
Definition IFilterCuts.h:78
IFilter< T > & operator=(const IFilter< T > &rhs)
Assignment operator:
Definition IFilter.h:91

◆ setCharge()

template<typename T>
void ChargeFilter< T >::setCharge ( const ChargeType & charge)

Set the filter to look for the given charge.

Parameters
charge: the charge the filter will be looking for.

Definition at line 181 of file ChargeFilter.h.

182{
184}

◆ setFilter()

template<typename T>
void ChargeFilter< T >::setFilter ( const IFilterCuts * filter)
virtual

Copies the IFilterCuts properties of the given object to the current IFilterCuts object (ie: it copies the required charge() to the current object)

Implements IFilterCuts.

Definition at line 163 of file ChargeFilter.h.

164{
165 if ( filter ) {
166 const ChargeFilter<T> * chFilter =
167 dynamic_cast<const ChargeFilter<T> *>(filter);
168 if ( chFilter ) {
170 } else {
171 MsgStream log( Athena::getMessageSvc(), "ChargeFilter" );
172 log << MSG::ERROR
173 << "Can't dynamic_cast " << typeid(filter).name()
174 << " to a ChargeFilter"
175 << endmsg;
176 }
177 }
178}
ChargeFilter()
Default constructor:
ChargeFilter< T > & operator=(const ChargeFilter< T > &rhs)
Assignment operator:

Member Data Documentation

◆ m_charge

template<typename T>
std::optional<ChargeType> ChargeFilter< T >::m_charge
protected

The charge the filter is looking for.

It is unitialized by default (in the std::optional sense)

Definition at line 95 of file ChargeFilter.h.


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