ATLAS Offline Software
PhysicsAnalysis
AnalysisCommon
AnalysisUtils
AnalysisUtils
PdgIdFilter.h
Go to the documentation of this file.
1
3
/*
4
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
5
*/
6
7
// PdgIdFilter.h
8
// Header file for class PdgIdFilter
9
// Author: S.Binet<binet@cern.ch>
11
#ifndef ANALYSISUTILS_PDGIDFILTER_H
12
#define ANALYSISUTILS_PDGIDFILTER_H
13
20
// STL includes
21
#include <list>
22
23
// Gaudi includes
24
#include "
AthenaKernel/getMessageSvc.h
"
25
#include "GaudiKernel/MsgStream.h"
26
27
// AnalysisUtils includes
28
#include "
AnalysisUtils/IFilter.h
"
29
#include "
AnalysisUtils/ParticleCandidateList.h
"
30
31
// Forward declaration
32
33
template
<
typename
T>
34
class
PdgIdFilter
:
virtual
public
IFilter
<T>
35
{
36
38
// Public methods:
40
public
:
41
44
PdgIdFilter
();
45
48
PdgIdFilter
(
const
PdgIdFilter<T>
& rhs );
49
50
// Constructor with parameters:
51
54
virtual
~PdgIdFilter
();
55
58
PdgIdFilter<T>
&
operator=
(
const
PdgIdFilter<T>
& rhs );
59
61
// Const methods:
63
68
virtual
bool
isAccepted
(
const
T
* element )
const
;
69
72
const
ParticleCandidateList
*
pdgIds
()
const
;
73
76
bool
matchSign
()
const
;
77
79
// Non-const methods:
81
void
setFilter
(
const
IFilterCuts
*
filter
);
82
83
void
setPdgId
(
const
int
&
pdgId
);
84
void
setPdgIds
(
const
std::list<int>&
pdgIds
);
85
void
setPdgIds
(
const
ParticleCandidateList
&
pdgIds
);
86
87
void
setMatchSign
(
const
bool
matchSign
);
88
90
// Protected data:
92
protected
:
93
96
ParticleCandidateList
m_pdgIds
;
97
101
bool
m_matchSign
;
102
103
};
104
107
//MsgStream& operator<<( MsgStream & msg, const PdgIdFilter &obj );
108
112
113
template
<
typename
T>
114
inline
PdgIdFilter<T>::PdgIdFilter
() :
115
IFilterCuts
(),
116
IFilter
<
T
>(),
117
m_pdgIds(),
118
m_matchSign( true )
119
{}
120
121
template
<
typename
T>
122
inline
PdgIdFilter<T>::PdgIdFilter
(
const
PdgIdFilter<T>
& rhs ) :
123
IFilterCuts
(rhs),
124
IFilter
<
T
>(rhs),
125
m_pdgIds( rhs.m_pdgIds ),
126
m_matchSign( rhs.m_matchSign )
127
{}
128
129
template
<
typename
T>
130
PdgIdFilter<T>::~PdgIdFilter
(){}
131
132
template
<
typename
T>
133
inline
134
PdgIdFilter<T>
&
PdgIdFilter<T>::operator=
(
const
PdgIdFilter<T>
& rhs)
135
{
136
if
(
this
!= &rhs ) {
137
IFilterCuts::operator=
(rhs);
138
IFilter<T>::operator=
(rhs);
139
m_pdgIds = rhs.
m_pdgIds
;
140
m_matchSign = rhs.
m_matchSign
;
141
}
142
return
*
this
;
143
}
144
146
// Const methods:
148
149
template
<
typename
T>
150
bool
PdgIdFilter<T>::isAccepted
(
const
T
* element )
const
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
}
164
165
template
<
typename
T>
166
inline
const
ParticleCandidateList
*
PdgIdFilter<T>::pdgIds
()
const
167
{
168
return
&m_pdgIds;
169
}
170
171
template
<
typename
T>
172
inline
bool
PdgIdFilter<T>::matchSign
()
const
173
{
174
return
m_matchSign;
175
}
176
177
template
<
typename
T>
178
void
PdgIdFilter<T>::setFilter
(
const
IFilterCuts
*
filter
)
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
}
195
196
template
<
typename
T>
197
inline
void
PdgIdFilter<T>::setPdgId
(
const
int
&
pdgId
)
198
{
199
m_pdgIds.add(
pdgId
);
200
}
201
202
template
<
typename
T>
203
void
PdgIdFilter<T>::setPdgIds
(
const
std::list<int>& pdgIds )
204
{
205
for
(
auto
itr = pdgIds.begin();
206
itr != pdgIds.end();
207
++itr ) {
208
m_pdgIds.add( *itr );
209
}
210
}
211
212
template
<
typename
T>
213
inline
void
PdgIdFilter<T>::setPdgIds
(
const
ParticleCandidateList
& pdgIds )
214
{
215
setPdgIds( pdgIds.
list
() );
216
}
217
218
template
<
typename
T>
219
inline
void
PdgIdFilter<T>::setMatchSign
(
const
bool
matchSign )
220
{
221
m_matchSign = matchSign;
222
}
223
224
#endif //> ANALYSISUTILS_PDGIDFILTER_H
getMessageSvc.h
singleton-like access to IMessageSvc via open function and helper
PdgIdFilter::setMatchSign
void setMatchSign(const bool matchSign)
Definition:
PdgIdFilter.h:219
IFilter
IFilter is the main interface to the filters.
Definition:
IFilter.h:31
PdgIdFilter::setPdgId
void setPdgId(const int &pdgId)
Definition:
PdgIdFilter.h:197
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
PdgIdFilter::isAccepted
virtual bool isAccepted(const T *element) const
Main filter method.
Definition:
PdgIdFilter.h:150
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
PdgIdFilter::~PdgIdFilter
virtual ~PdgIdFilter()
Destructor:
Definition:
PdgIdFilter.h:130
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
PdgIdFilter::setFilter
void setFilter(const IFilterCuts *filter)
Pure virtual function (to be overloaded by each of the children classes) to copy the cut properties o...
Definition:
PdgIdFilter.h:178
PdgIdFilter::PdgIdFilter
PdgIdFilter()
Default constructor:
Definition:
PdgIdFilter.h:114
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
IFilterCuts
IFilterCuts is a class which is used internally by the filters to copy their cut properties one to ...
Definition:
IFilterCuts.h:21
ParticleCandidateList.h
PdgIdFilter::matchSign
bool matchSign() const
Return true if the filter requires a strict sign matching.
Definition:
PdgIdFilter.h:172
ParticleCandidateList
A simple wrapper for std::list<int> to model a list of particle identity candidates.
Definition:
ParticleCandidateList.h:31
IFilter.h
TSU::T
unsigned long long T
Definition:
L1TopoDataTypes.h:35
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
Generated on Fri Jul 5 2024 21:24:09 for ATLAS Offline Software by
1.8.18