ATLAS Offline Software
PhysicsAnalysis
AnalysisCommon
AnalysisUtils
AnalysisUtils
ChargeFilter.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
// ChargeFilter.h
8
// Header file for class ChargeFilter
9
// Author: S.Binet<binet@cern.ch>
11
#ifndef ANALYSISUTILS_CHARGEFILTER_H
12
#define ANALYSISUTILS_CHARGEFILTER_H
13
19
// FrameWork includes
20
#include "
AthenaKernel/getMessageSvc.h
"
21
#include "GaudiKernel/MsgStream.h"
22
#include <optional>
23
24
// EventKernel includes
25
#include "
EventKernel/IParticle.h
"
26
27
// AnalysisUtils includes
28
#include "
AnalysisUtils/IFilter.h
"
29
30
template
<
typename
T>
31
class
ChargeFilter
:
virtual
public
IFilter
<T>
32
{
33
35
// Public methods:
37
public
:
38
41
ChargeFilter
();
42
45
ChargeFilter
(
const
ChargeFilter<T>
& rhs );
46
47
// Constructor with parameters:
48
51
virtual
~ChargeFilter
();
52
55
ChargeFilter<T>
&
operator=
(
const
ChargeFilter<T>
& rhs );
56
58
// Const methods:
60
66
virtual
bool
isAccepted
(
const
T
* element )
const
;
67
70
double
charge
()
const
;
71
73
// Non-const methods:
75
80
void
setFilter
(
const
IFilterCuts
*
filter
);
81
85
void
setCharge
(
const
ChargeType
&
charge
);
86
88
// Protected data:
90
protected
:
91
95
std::optional<ChargeType>
m_charge
;
96
97
};
98
102
template
<
typename
T>
103
ChargeFilter<T>::ChargeFilter
() :
104
IFilterCuts
(),
105
IFilter
<
T
>(),
106
m_charge()
107
{}
108
109
template
<
typename
T>
110
ChargeFilter<T>::ChargeFilter
(
const
ChargeFilter<T>
& rhs ) :
111
IFilterCuts
(rhs),
112
IFilter
<
T
>(rhs),
113
m_charge(rhs.m_charge)
114
{}
115
116
template
<
typename
T>
117
inline
118
ChargeFilter<T>
&
ChargeFilter<T>::operator=
(
const
ChargeFilter<T>
& rhs )
119
{
120
if
(
this
!= &rhs ) {
121
IFilterCuts::operator=
(rhs);
122
IFilter<T>::operator=
(rhs);
123
m_charge = rhs.
m_charge
;
124
}
125
return
*
this
;
126
}
127
128
129
template
<
typename
T>
130
ChargeFilter<T>::~ChargeFilter
(){}
131
132
template
<
typename
T>
133
bool
ChargeFilter<T>::isAccepted
(
const
T
* element )
const
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
}
152
153
template
<
typename
T>
154
double
ChargeFilter<T>::charge
()
const
155
{
156
if
(m_charge) {
157
return
*m_charge;
158
}
159
throw
std::domain_error(
"No charge selection defined"
);
160
}
161
162
template
<
typename
T>
163
void
ChargeFilter<T>::setFilter
(
const
IFilterCuts
*
filter
)
164
{
165
if
(
filter
) {
166
const
ChargeFilter<T>
* chFilter =
167
dynamic_cast<
const
ChargeFilter<T>
*
>
(
filter
);
168
if
( chFilter ) {
169
operator=(*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
}
179
180
template
<
typename
T>
181
void
ChargeFilter<T>::setCharge
(
const
ChargeType
&
charge
)
182
{
183
m_charge =
charge
;
184
}
185
186
#endif //> ANALYSISUTILS_CHARGEFILTER_H
getMessageSvc.h
singleton-like access to IMessageSvc via open function and helper
IFilter
IFilter is the main interface to the filters.
Definition:
IFilter.h:31
IParticle.h
ChargeFilter::isAccepted
virtual bool isAccepted(const T *element) const
Main filter method.
Definition:
ChargeFilter.h:133
ChargeFilter::setCharge
void setCharge(const ChargeType &charge)
Set the filter to look for the given charge.
Definition:
ChargeFilter.h:181
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition:
getMessageSvc.cxx:20
IFilter::operator=
IFilter< T > & operator=(const IFilter< T > &rhs)
Assignment operator:
Definition:
IFilter.h:91
covarianceTool.filter
filter
Definition:
covarianceTool.py:514
ChargeFilter::ChargeFilter
ChargeFilter()
Default constructor:
Definition:
ChargeFilter.h:103
ChargeFilter::~ChargeFilter
virtual ~ChargeFilter()
Destructor:
Definition:
ChargeFilter.h:130
ChargeFilter::charge
double charge() const
Returns the charge the filter is looking for.
Definition:
ChargeFilter.h:154
endmsg
#define endmsg
Definition:
AnalysisConfig_Ntuple.cxx:63
ChargeFilter::m_charge
std::optional< ChargeType > m_charge
The charge the filter is looking for.
Definition:
ChargeFilter.h:95
name
std::string name
Definition:
Control/AthContainers/Root/debug.cxx:195
charge
double charge(const T &p)
Definition:
AtlasPID.h:494
ChargeType
double ChargeType
typedef ChargeType used to anticipate changes here
Definition:
Event/EventKernel/EventKernel/IParticle.h:40
ChargeFilter
ChargeFilter can filter objects upon their charge.
Definition:
ChargeFilter.h:32
python.CaloCondTools.log
log
Definition:
CaloCondTools.py:20
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
ChargeFilter::setFilter
void setFilter(const IFilterCuts *filter)
Copies the IFilterCuts properties of the given object to the current IFilterCuts object (ie: it copie...
Definition:
ChargeFilter.h:163
IFilter.h
ChargeFilter::operator=
ChargeFilter< T > & operator=(const ChargeFilter< T > &rhs)
Assignment operator:
Definition:
ChargeFilter.h:118
TSU::T
unsigned long long T
Definition:
L1TopoDataTypes.h:35
Generated on Fri Jul 5 2024 21:12:21 for ATLAS Offline Software by
1.8.18