ATLAS Offline Software
Public Member Functions | Protected Attributes | List of all members
PdgIdFilter< T > Class Template Reference

PdgIdFilter selects particles from their pdg id code. More...

#include <PdgIdFilter.h>

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

Public Member Functions

 PdgIdFilter ()
 Default constructor: More...
 
 PdgIdFilter (const PdgIdFilter< T > &rhs)
 Copy constructor: More...
 
virtual ~PdgIdFilter ()
 Destructor: More...
 
PdgIdFilter< T > & operator= (const PdgIdFilter< T > &rhs)
 Assignment operator: More...
 
virtual bool isAccepted (const T *element) const
 Main filter method. More...
 
const ParticleCandidateListpdgIds () const
 Return the list of pdg ids the filter is looking for. More...
 
bool matchSign () const
 Return true if the filter requires a strict sign matching. More...
 
void setFilter (const IFilterCuts *filter)
 Pure virtual function (to be overloaded by each of the children classes) to copy the cut properties of a given filter to another one. More...
 
void setPdgId (const int &pdgId)
 
void setPdgIds (const std::list< int > &pdgIds)
 
void setPdgIds (const ParticleCandidateList &pdgIds)
 
void setMatchSign (const bool matchSign)
 
bool operator() (const T *element) const
 

Protected Attributes

ParticleCandidateList m_pdgIds
 The list of particles ids which might be accepted. More...
 
bool m_matchSign
 Tells to also match the sign of the pdg id of particles => true by default. More...
 

Detailed Description

template<typename T>
class PdgIdFilter< T >

PdgIdFilter selects particles from their pdg id code.

Up to now, it is based on a ParticleCandidateList but it is very likely that internally it will be based on DecayPattern See AnalysisExamples/FilterExample.cxx for a concrete example

Definition at line 34 of file PdgIdFilter.h.

Constructor & Destructor Documentation

◆ PdgIdFilter() [1/2]

template<typename T >
PdgIdFilter< T >::PdgIdFilter
inline

Default constructor:

I/O operators.

Inline methods:

Definition at line 114 of file PdgIdFilter.h.

114  :
115  IFilterCuts(),
116  IFilter<T>(),
117  m_pdgIds(),
118  m_matchSign( true )
119 {}

◆ PdgIdFilter() [2/2]

template<typename T >
PdgIdFilter< T >::PdgIdFilter ( const PdgIdFilter< T > &  rhs)
inline

Copy constructor:

Definition at line 122 of file PdgIdFilter.h.

122  :
123  IFilterCuts(rhs),
124  IFilter<T>(rhs),
125  m_pdgIds( rhs.m_pdgIds ),
126  m_matchSign( rhs.m_matchSign )
127 {}

◆ ~PdgIdFilter()

template<typename T >
PdgIdFilter< T >::~PdgIdFilter
virtual

Destructor:

Definition at line 130 of file PdgIdFilter.h.

130 {}

Member Function Documentation

◆ isAccepted()

template<typename T >
bool PdgIdFilter< 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 particle's id matches one of the required one.

Check if a pdg-id set has been set-up

Otherwise return true by convention

Implements IFilter< T >.

Definition at line 150 of file PdgIdFilter.h.

151 {
153  if ( false == m_pdgIds.empty() ) {
154  const int pdgId = element->pdgId();
155  //std::cout << "Received PDG: " << pdgId << std::endl;
156  //m_pdgIds.dropList();
157  if ( m_pdgIds.hasInList( pdgId, m_matchSign ) ) return true;
158  else return false;
159  }
160 
162  return true;
163 }

◆ matchSign()

template<typename T >
bool PdgIdFilter< T >::matchSign
inline

Return true if the filter requires a strict sign matching.

Definition at line 172 of file PdgIdFilter.h.

173 {
174  return m_matchSign;
175 }

◆ 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 }

◆ operator=()

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

Assignment operator:

Definition at line 134 of file PdgIdFilter.h.

135 {
136  if ( this != &rhs ) {
139  m_pdgIds = rhs.m_pdgIds;
140  m_matchSign = rhs.m_matchSign;
141  }
142  return *this;
143 }

◆ pdgIds()

template<typename T >
const ParticleCandidateList * PdgIdFilter< T >::pdgIds
inline

Return the list of pdg ids the filter is looking for.

Definition at line 166 of file PdgIdFilter.h.

167 {
168  return &m_pdgIds;
169 }

◆ setFilter()

template<typename T >
void PdgIdFilter< T >::setFilter ( const IFilterCuts ifilter)
virtual

Pure virtual function (to be overloaded by each of the children classes) to copy the cut properties of a given filter to another one.

It copies the properties of ifilter to the current IFilterCuts object.

Parameters
ifilterthe IFilterCuts which holds a set of properties one wants to copy to the current IFilterCuts object.

Implements IFilterCuts.

Definition at line 178 of file PdgIdFilter.h.

179 {
180  if ( filter ) {
181  const PdgIdFilter<T> * pdgFilter =
182  dynamic_cast<const PdgIdFilter<T> *>(filter );
183 
184  if ( pdgFilter ) {
185  operator=(*pdgFilter);
186  } else {
187  MsgStream log( Athena::getMessageSvc(), "PdgIdFilter" );
188  log << MSG::ERROR
189  << "Can't dynamic_cast " << typeid(filter).name()
190  << " to a PdgIdFilter"
191  << endmsg;
192  }
193  } //> filter is not a NULL pointer
194 }

◆ setMatchSign()

template<typename T >
void PdgIdFilter< T >::setMatchSign ( const bool  matchSign)
inline

Definition at line 219 of file PdgIdFilter.h.

220 {
222 }

◆ setPdgId()

template<typename T >
void PdgIdFilter< T >::setPdgId ( const int &  pdgId)
inline

Definition at line 197 of file PdgIdFilter.h.

198 {
199  m_pdgIds.add( pdgId );
200 }

◆ setPdgIds() [1/2]

template<typename T >
void PdgIdFilter< T >::setPdgIds ( const ParticleCandidateList pdgIds)
inline

Definition at line 213 of file PdgIdFilter.h.

214 {
215  setPdgIds( pdgIds.list() );
216 }

◆ setPdgIds() [2/2]

template<typename T >
void PdgIdFilter< T >::setPdgIds ( const std::list< int > &  pdgIds)

Definition at line 203 of file PdgIdFilter.h.

204 {
205  for ( auto itr = pdgIds.begin();
206  itr != pdgIds.end();
207  ++itr ) {
208  m_pdgIds.add( *itr );
209  }
210 }

Member Data Documentation

◆ m_matchSign

template<typename T >
bool PdgIdFilter< T >::m_matchSign
protected

Tells to also match the sign of the pdg id of particles => true by default.

Definition at line 101 of file PdgIdFilter.h.

◆ m_pdgIds

template<typename T >
ParticleCandidateList PdgIdFilter< T >::m_pdgIds
protected

The list of particles ids which might be accepted.

Definition at line 96 of file PdgIdFilter.h.


The documentation for this class was generated from the following file:
ParticleCandidateList::begin
const_iterator begin() const
Definition: ParticleCandidateList.h:145
IFilter
IFilter is the main interface to the filters.
Definition: IFilter.h:31
PowhegPy8EG_H2a.pdgId
dictionary pdgId
Definition: PowhegPy8EG_H2a.py:128
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
PdgIdFilter::m_pdgIds
ParticleCandidateList m_pdgIds
The list of particles ids which might be accepted.
Definition: PdgIdFilter.h:96
IFilter::operator=
IFilter< T > & operator=(const IFilter< T > &rhs)
Assignment operator:
Definition: IFilter.h:91
PdgIdFilter::setPdgIds
void setPdgIds(const std::list< int > &pdgIds)
Definition: PdgIdFilter.h:203
covarianceTool.filter
filter
Definition: covarianceTool.py:514
ParticleCandidateList::list
const std::list< int > & list() const
Return the wrapped STL list.
Definition: ParticleCandidateList.h:140
PdgIdFilter::pdgIds
const ParticleCandidateList * pdgIds() const
Return the list of pdg ids the filter is looking for.
Definition: PdgIdFilter.h:166
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
IFilter::isAccepted
virtual bool isAccepted(const T *element) const =0
Main filter method.
ParticleCandidateList::empty
bool empty() const
Definition: ParticleCandidateList.h:155
PdgIdFilter::operator=
PdgIdFilter< T > & operator=(const PdgIdFilter< T > &rhs)
Assignment operator:
Definition: PdgIdFilter.h:134
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
IFilterCuts::IFilterCuts
IFilterCuts()
Default constructor:
Definition: IFilterCuts.h:69
ParticleCandidateList::hasInList
bool hasInList(const int &pdgID, const bool tightMatch=false) const
Tells if a given particle or pID is in the list if tightMatch = false : look only if std::abs() of pa...
Definition: ParticleCandidateList.cxx:29
ParticleCandidateList::end
const_iterator end() const
Definition: ParticleCandidateList.h:150
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
PdgIdFilter
PdgIdFilter selects particles from their pdg id code.
Definition: PdgIdFilter.h:35
IFilterCuts::operator=
IFilterCuts & operator=(const IFilterCuts &rhs)
Assignment operator:
Definition: IFilterCuts.h:78
PdgIdFilter::matchSign
bool matchSign() const
Return true if the filter requires a strict sign matching.
Definition: PdgIdFilter.h:172
ParticleCandidateList::add
void add(const int &partID)
Definition: ParticleCandidateList.h:185
PdgIdFilter::m_matchSign
bool m_matchSign
Tells to also match the sign of the pdg id of particles => true by default.
Definition: PdgIdFilter.h:101