ATLAS Offline Software
Loading...
Searching...
No Matches
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
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
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;
34 m_accessors.push_back(std::move(accessor));
35 }
36 }
37
38 ANA_CHECK(m_filterParams.initialize());
39
40 return StatusCode::SUCCESS;
41}
42
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
69{
70 ANA_MSG_INFO (m_filterParams.summary());
71
72 return StatusCode::SUCCESS;
73}
#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
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
virtual StatusCode execute() final
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
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.