ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
Algorithms
AsgAnalysisAlgorithms
Root
EventFlagSelectionAlg.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
6
7
#include <
AsgAnalysisAlgorithms/EventFlagSelectionAlg.h
>
8
#include <
EventBookkeeperTools/FilterReporter.h
>
9
#include <
xAODEventInfo/EventInfo.h
>
10
11
StatusCode
CP::EventFlagSelectionAlg::initialize
()
12
{
13
if
(
m_invertFlags
.size() !=
m_selFlags
.size() && !
m_invertFlags
.empty()) {
14
ATH_MSG_ERROR
(
"Property invertFlags has different size to selectionFlags. Please check your configuration"
);
15
return
StatusCode::FAILURE;
16
}
17
if
(
m_invertFlags
.empty()) {
18
m_invertFlags
= std::vector<bool>(
m_selFlags
.size(),
false
);
19
}
20
21
for
(
size_t
index
= 0;
index
<
m_selFlags
.size(); ++
index
) {
22
const
std::string& thisflag =
m_selFlags
[
index
];
23
if
(thisflag.empty()) {
24
ATH_MSG_ERROR
(
"Empty string passed as selection flag!"
);
25
return
StatusCode::FAILURE;
26
}
else
{
27
std::unique_ptr<ISelectionReadAccessor> accessor;
28
ANA_CHECK
(
makeSelectionReadAccessor
(
m_selFlags
[
index
], accessor));
29
m_accessors
.push_back(std::move(accessor));
30
}
31
}
32
33
ANA_CHECK
(
m_filterParams
.initialize());
34
35
return
StatusCode::SUCCESS;
36
}
37
38
StatusCode
CP::EventFlagSelectionAlg::execute
(
const
EventContext&
/*ctx*/
)
39
{
40
FilterReporter
filter (
m_filterParams
,
false
);
41
42
const
xAOD::EventInfo
*evtInfo =
nullptr
;
43
ANA_CHECK
(
evtStore
()->retrieve(evtInfo,
"EventInfo"
));
44
45
for
(
size_t
index
= 0;
index
<
m_selFlags
.size(); ++
index
) {
46
// Test against the opposite of the invert value
47
bool
testval = !
m_invertFlags
[
index
];
48
ATH_MSG_VERBOSE
(
"Now testing flag \""
<<
m_selFlags
[
index
] <<
"\" requiring value "
<< testval);
49
50
if
(
m_accessors
[
index
]->getBool(*evtInfo) != testval) {
51
ATH_MSG_VERBOSE
(
"Event failed."
);
52
filter.setPassed(
false
);
53
return
StatusCode::SUCCESS;
54
}
55
}
56
57
ATH_MSG_VERBOSE
(
"Event passed all flags."
);
58
filter.setPassed(
true
);
59
60
return
StatusCode::SUCCESS;
61
}
62
63
StatusCode
CP::EventFlagSelectionAlg::finalize
()
64
{
65
ANA_MSG_INFO
(
m_filterParams
.summary());
66
67
return
StatusCode::SUCCESS;
68
}
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x,...)
Definition
AthMsgStreamMacros.h:47
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x,...)
Definition
AthMsgStreamMacros.h:42
ANA_MSG_INFO
#define ANA_MSG_INFO(xmsg,...)
Macro printing info messages.
Definition
Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:291
ANA_CHECK
#define ANA_CHECK(EXP)
check whether the given expression was successful
Definition
Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:325
EventFlagSelectionAlg.h
FilterReporter.h
AthCommonAlgorithm< Gaudi::Algorithm >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
Definition
AthCommonDataStore.h:85
CP::EventFlagSelectionAlg::finalize
virtual StatusCode finalize() final
Definition
EventFlagSelectionAlg.cxx:63
CP::EventFlagSelectionAlg::initialize
virtual StatusCode initialize() final
Definition
EventFlagSelectionAlg.cxx:11
CP::EventFlagSelectionAlg::m_filterParams
FilterReporterParams m_filterParams
the filter reporter params
Definition
EventFlagSelectionAlg.h:37
CP::EventFlagSelectionAlg::m_accessors
std::vector< std::unique_ptr< ISelectionReadAccessor > > m_accessors
a vector of accessors to read the flags
Definition
EventFlagSelectionAlg.h:34
CP::EventFlagSelectionAlg::m_invertFlags
Gaudi::Property< std::vector< bool > > m_invertFlags
invert flags
Definition
EventFlagSelectionAlg.h:31
CP::EventFlagSelectionAlg::m_selFlags
Gaudi::Property< std::vector< std::string > > m_selFlags
flags that we want to select events with
Definition
EventFlagSelectionAlg.h:28
EL::AnaAlgorithm::execute
virtual::StatusCode execute()
execute this algorithm
Definition
AnaAlgorithm.cxx:315
FilterReporter
a guard class for use with ref FilterReporterParams
Definition
FilterReporter.h:35
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
xAOD::EventInfo
EventInfo_v1 EventInfo
Definition of the latest event info version.
Definition
IEventInfoCnvTool.h:16
EventInfo.h
Generated on
for ATLAS Offline Software by
1.17.0