ATLAS Offline Software
Loading...
Searching...
No Matches
PhysicsAnalysis
Algorithms
AsgAnalysisAlgorithms
Root
AsgFlagSelectionTool.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3
*/
4
6
7
8
9
//
10
// includes
11
//
12
13
#include <
AsgAnalysisAlgorithms/AsgFlagSelectionTool.h
>
14
15
//
16
// method implementations
17
//
18
19
namespace
CP
20
{
21
22
StatusCode AsgFlagSelectionTool ::
23
initialize ()
24
{
25
if
(
m_invertFlags
.size()!=
m_selFlags
.size() && !
m_invertFlags
.empty()) {
26
ATH_MSG_ERROR
(
"Property invertFlags has different size to selectionFlags. Please check your configuration"
);
27
return
StatusCode::FAILURE;
28
}
29
// Could also warn if there are fewer values, but we don't have to force users to set where irrelevant.
30
// Maybe warn unless the size is 0, in which case assume all default?
31
32
for
(
size_t
index
=0;
index
<
m_selFlags
.size(); ++
index
) {
33
const
std::string& thisflag =
m_selFlags
[
index
];
34
if
(thisflag.empty()) {
35
ATH_MSG_ERROR
(
"Empty string passed as selection flag!"
);
36
return
StatusCode::FAILURE;
37
}
else
{
38
// Extend m_invertFlags until the size matches m_selectionFlags
39
// Only done in the case that m_invert was empty
40
if
(
m_invertFlags
.size()<
index
+1) {
41
std::vector<bool> flags =
m_invertFlags
.value();
42
flags.resize(
index
+ 1,
false
);
43
m_invertFlags
= flags;
44
}
45
std::string doInvertStr =
m_invertFlags
[
index
] ?
"!"
:
""
;
46
m_accept
.addCut (doInvertStr + thisflag, doInvertStr + thisflag);
47
std::unique_ptr<ISelectionReadAccessor> accessor;
48
ATH_CHECK
(
makeSelectionReadAccessor
(thisflag, accessor,
true
));
49
m_acc_selFlags
.push_back (std::move (accessor));
50
}
51
}
52
53
return
StatusCode::SUCCESS;
54
}
55
56
57
58
const
asg::AcceptInfo
& AsgFlagSelectionTool ::
59
getAcceptInfo ()
const
60
{
61
return
m_accept
;
62
}
63
64
65
66
asg::AcceptData
AsgFlagSelectionTool ::
67
accept (
const
xAOD::IParticle
*particle)
const
68
{
69
asg::AcceptData
accept
(&
m_accept
);
70
for
(std::size_t cutIndex=0; cutIndex<
m_accept
.getNCuts(); ++cutIndex) {
71
// Test against the opposite of the invert value
72
bool
testval = !
m_invertFlags
[cutIndex];
73
ATH_MSG_VERBOSE
(
"Now testing flag \""
<<
m_selFlags
[cutIndex] <<
"\" requiring value "
<< testval);
74
accept
.setCutResult (cutIndex,
m_acc_selFlags
[cutIndex]->getBool (*particle)==testval);
75
}
76
77
return
accept
;
78
}
79
}
80
AsgFlagSelectionTool.h
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition
AthMsgStreamMacros.h:28
CP::AsgFlagSelectionTool::m_invertFlags
Gaudi::Property< std::vector< bool > > m_invertFlags
Definition
AsgFlagSelectionTool.h:78
CP::AsgFlagSelectionTool::m_accept
asg::AcceptInfo m_accept
the asg::AcceptInfo we are using
Definition
AsgFlagSelectionTool.h:86
CP::AsgFlagSelectionTool::m_selFlags
Gaudi::Property< std::vector< std::string > > m_selFlags
tool properties
Definition
AsgFlagSelectionTool.h:77
CP::AsgFlagSelectionTool::accept
virtual asg::AcceptData accept(const xAOD::IParticle *part) const override
The main accept method: the actual cuts are applied here.
Definition
AsgFlagSelectionTool.cxx:67
CP::AsgFlagSelectionTool::m_acc_selFlags
std::vector< std::unique_ptr< ISelectionReadAccessor > > m_acc_selFlags
Definition
AsgFlagSelectionTool.h:79
asg::AcceptData
Definition
AcceptData.h:31
asg::AcceptInfo
Definition
AcceptInfo.h:28
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition
Event/xAOD/xAODBase/xAODBase/IParticle.h:41
CP
Select isolated Photons, Electrons and Muons.
Definition
Control/xAODRootAccess/xAODRootAccess/TEvent.h:27
CP::makeSelectionReadAccessor
StatusCode makeSelectionReadAccessor(const std::string &expr, std::unique_ptr< ISelectionReadAccessor > &accessor, bool defaultToChar)
make the ISelectionReadAccessor for the given name
Definition
ISelectionAccessor.cxx:53
index
Definition
index.py:1
Generated on
for ATLAS Offline Software by
1.16.1