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-2024 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
18
for
(
size_t
index
= 0;
index
<
m_selFlags
.size(); ++
index
) {
19
const
std::string& thisflag =
m_selFlags
[
index
];
20
if
(thisflag.empty()) {
21
ATH_MSG_ERROR
(
"Empty string passed as selection flag!"
);
22
return
StatusCode::FAILURE;
23
}
else
{
24
// Extend m_invertFlags until the size matches m_selectionFlags
25
// Only done in the case that m_invert was empty
26
if
(
m_invertFlags
.size() <
index
+ 1) {
27
std::vector<bool> flags =
m_invertFlags
.value();
28
flags.resize(
index
+ 1,
false
);
29
m_invertFlags
= flags;
30
}
31
32
std::unique_ptr<ISelectionReadAccessor> accessor;
33
ANA_CHECK
(
makeSelectionReadAccessor
(
m_selFlags
[
index
], accessor));
34
m_accessors
.push_back(std::move(accessor));
35
}
36
}
37
38
ANA_CHECK
(
m_filterParams
.initialize());
39
40
return
StatusCode::SUCCESS;
41
}
42
43
StatusCode
CP::EventFlagSelectionAlg::execute
(
const
EventContext&
/*ctx*/
)
44
{
45
FilterReporter
filter (
m_filterParams
,
false
);
46
47
const
xAOD::EventInfo
*evtInfo = 0;
48
ANA_CHECK
(
evtStore
()->retrieve(evtInfo,
"EventInfo"
));
49
50
for
(
size_t
index
= 0;
index
<
m_selFlags
.size(); ++
index
) {
51
// Test against the opposite of the invert value
52
bool
testval = !
m_invertFlags
[
index
];
53
ATH_MSG_VERBOSE
(
"Now testing flag \""
<<
m_selFlags
[
index
] <<
"\" requiring value "
<< testval);
54
55
if
(
m_accessors
[
index
]->getBool(*evtInfo) != testval) {
56
ATH_MSG_VERBOSE
(
"Event failed."
);
57
filter.setPassed(
false
);
58
return
StatusCode::SUCCESS;
59
}
60
}
61
62
ATH_MSG_VERBOSE
(
"Event passed all flags."
);
63
filter.setPassed(
true
);
64
65
return
StatusCode::SUCCESS;
66
}
67
68
StatusCode
CP::EventFlagSelectionAlg::finalize
()
69
{
70
ANA_MSG_INFO
(
m_filterParams
.summary());
71
72
return
StatusCode::SUCCESS;
73
}
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition
AthMsgStreamMacros.h:28
ANA_MSG_INFO
#define ANA_MSG_INFO(xmsg)
Macro printing info messages.
Definition
Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:290
ANA_CHECK
#define ANA_CHECK(EXP)
check whether the given expression was successful
Definition
Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:324
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:68
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