ATLAS Offline Software
Loading...
Searching...
No Matches
PhysicsAnalysis
Algorithms
AsgAnalysisAlgorithms
Root
AsgMaskSelectionTool.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/AsgMaskSelectionTool.h
>
14
15
//
16
// method implementations
17
//
18
19
namespace
CP
20
{
21
22
StatusCode AsgMaskSelectionTool ::
23
initialize ()
24
{
25
if
(
m_selVars
.size() !=
m_selMasks
.size()) {
26
ATH_MSG_ERROR
(
"Property selectionMasks has different size to selectionVars. 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_selVars
.size(); ++
index
) {
33
const
std::string& thisVar =
m_selVars
[
index
];
34
if
(thisVar.empty()) {
35
ATH_MSG_ERROR
(
"Empty string passed as selection variable!"
);
36
return
StatusCode::FAILURE;
37
}
else
{
38
// Setup acceptInfo and create accessor to read variable on execute
39
m_accept
.addCut (thisVar, thisVar);
40
std::unique_ptr<ISelectionReadAccessor> accessor;
41
ATH_CHECK
(
makeSelectionReadAccessor
(thisVar, accessor));
42
m_acc_selVars
.push_back (std::move (accessor));
43
}
44
}
45
46
return
StatusCode::SUCCESS;
47
}
48
49
const
asg::AcceptInfo
& AsgMaskSelectionTool ::
50
getAcceptInfo ()
const
51
{
52
return
m_accept
;
53
}
54
55
asg::AcceptData
AsgMaskSelectionTool ::
56
accept (
const
xAOD::IParticle
*particle)
const
57
{
58
asg::AcceptData
accept
(&
m_accept
);
59
for
(std::size_t cutIndex=0; cutIndex<
m_accept
.getNCuts(); ++cutIndex) {
60
// Apply mask and test
61
int
mask =
m_selMasks
[cutIndex];
62
ATH_MSG_VERBOSE
(
"Now testing var \""
<<
m_selVars
[cutIndex] <<
"\" requiring value "
<< mask);
63
accept
.setCutResult (cutIndex, ((
m_acc_selVars
[cutIndex]->getBits (*particle) & mask ) == 0 ));
64
}
65
66
return
accept
;
67
}
68
}
69
AsgMaskSelectionTool.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::AsgMaskSelectionTool::accept
virtual asg::AcceptData accept(const xAOD::IParticle *part) const override
The main accept method: the actual cuts are applied here.
Definition
AsgMaskSelectionTool.cxx:56
CP::AsgMaskSelectionTool::m_acc_selVars
std::vector< std::unique_ptr< ISelectionReadAccessor > > m_acc_selVars
Definition
AsgMaskSelectionTool.h:70
CP::AsgMaskSelectionTool::m_selMasks
Gaudi::Property< std::vector< unsigned int > > m_selMasks
Definition
AsgMaskSelectionTool.h:69
CP::AsgMaskSelectionTool::m_selVars
Gaudi::Property< std::vector< std::string > > m_selVars
tool properties
Definition
AsgMaskSelectionTool.h:68
CP::AsgMaskSelectionTool::m_accept
asg::AcceptInfo m_accept
the asg::AcceptInfo we are using
Definition
AsgMaskSelectionTool.h:77
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