ATLAS Offline Software
Loading...
Searching...
No Matches
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
10
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;
29 m_accessors.push_back(std::move(accessor));
30 }
31 }
32
33 ANA_CHECK(m_filterParams.initialize());
34
35 return StatusCode::SUCCESS;
36}
37
38StatusCode 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
64{
65 ANA_MSG_INFO (m_filterParams.summary());
66
67 return StatusCode::SUCCESS;
68}
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_VERBOSE(x,...)
#define ANA_MSG_INFO(xmsg,...)
Macro printing info messages.
#define ANA_CHECK(EXP)
check whether the given expression was successful
ServiceHandle< StoreGateSvc > & evtStore()
virtual StatusCode finalize() final
virtual StatusCode initialize() final
FilterReporterParams m_filterParams
the filter reporter params
std::vector< std::unique_ptr< ISelectionReadAccessor > > m_accessors
a vector of accessors to read the flags
Gaudi::Property< std::vector< bool > > m_invertFlags
invert flags
Gaudi::Property< std::vector< std::string > > m_selFlags
flags that we want to select events with
virtual::StatusCode execute()
execute this algorithm
a guard class for use with ref FilterReporterParams
StatusCode makeSelectionReadAccessor(const std::string &expr, std::unique_ptr< ISelectionReadAccessor > &accessor, bool defaultToChar)
make the ISelectionReadAccessor for the given name
Definition index.py:1
EventInfo_v1 EventInfo
Definition of the latest event info version.