ATLAS Offline Software
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);
30  }
31 
32  std::unique_ptr<ISelectionReadAccessor> accessor;
34  m_accessors.push_back(std::move(accessor));
35  }
36  }
37 
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 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
CP::EventFlagSelectionAlg::m_selFlags
Gaudi::Property< std::vector< std::string > > m_selFlags
flags that we want to select events with
Definition: EventFlagSelectionAlg.h:28
FilterReporter
a guard class for use with ref FilterReporterParams
Definition: FilterReporter.h:35
CP::EventFlagSelectionAlg::m_filterParams
FilterReporterParams m_filterParams
the filter reporter params
Definition: EventFlagSelectionAlg.h:37
index
Definition: index.py:1
AthenaPoolTestRead.flags
flags
Definition: AthenaPoolTestRead.py:8
ANA_CHECK
#define ANA_CHECK(EXP)
check whether the given expression was successful
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:324
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
EventFlagSelectionAlg.h
covarianceTool.filter
filter
Definition: covarianceTool.py:514
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ANA_MSG_INFO
#define ANA_MSG_INFO(xmsg)
Macro printing info messages.
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:290
FilterReporterParams::initialize
StatusCode initialize(bool enabled=true)
do anything we need to do in initialize
Definition: FilterReporterParams.cxx:24
CP::EventFlagSelectionAlg::m_invertFlags
Gaudi::Property< std::vector< bool > > m_invertFlags
invert flags
Definition: EventFlagSelectionAlg.h:31
FilterReporter.h
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:54
EventInfo.h
xAOD::JetAttributeAccessor::accessor
const AccessorWrapper< T > * accessor(xAOD::JetAttribute::AttributeID id)
Returns an attribute accessor corresponding to an AttributeID.
Definition: JetAccessorMap.h:26
xAOD::EventInfo_v1
Class describing the basic event information.
Definition: EventInfo_v1.h:43
CP::EventFlagSelectionAlg::finalize
virtual StatusCode finalize() final
Definition: EventFlagSelectionAlg.cxx:68
DeMoScan.index
string index
Definition: DeMoScan.py:364
CP::EventFlagSelectionAlg::initialize
virtual StatusCode initialize() final
Definition: EventFlagSelectionAlg.cxx:11
CP::EventFlagSelectionAlg::execute
virtual StatusCode execute() final
Definition: EventFlagSelectionAlg.cxx:43
CP::EventFlagSelectionAlg::m_accessors
std::vector< std::unique_ptr< ISelectionReadAccessor > > m_accessors
a vector of accessors to read the flags
Definition: EventFlagSelectionAlg.h:34