ATLAS Offline Software
Loading...
Searching...
No Matches
EventScalarSelectorAlg.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
8
9namespace CP {
10
11 EventScalarSelectorAlg::EventScalarSelectorAlg(const std::string &name, ISvcLocator *pSvcLocator)
12 : EL::AnaAlgorithm(name, pSvcLocator)
13 {}
14
17
21
24 ANA_CHECK(m_systematicsList.initialize());
25
27
28 // exactly one typed handle must be configured
29 const int nConfigured = (m_floatVariable ? 1 : 0)
30 + (m_intVariable ? 1 : 0)
31 + (m_doubleVariable ? 1 : 0);
32 if (nConfigured != 1) {
33 ANA_MSG_ERROR("EVENTVAR: exactly one of floatVariable / intVariable / "
34 "doubleVariable must be configured (got " << nConfigured << ")");
35 return StatusCode::FAILURE;
36 }
37
38 return StatusCode::SUCCESS;
39 }
40
41 StatusCode EventScalarSelectorAlg::execute(const EventContext& ctx) {
42 for (const auto &sys : m_systematicsList.systematicsVector()) {
43 // retrieve the EventInfo
44 const xAOD::EventInfo *evtInfo = nullptr;
45 ANA_CHECK(m_eventInfoHandle.retrieve(evtInfo, sys, ctx));
46
47 // default-decorate EventInfo
48 m_decoration.setBool(*evtInfo, 0, sys);
49
50 // check the preselection
51 if (m_preselection && !m_preselection.getBool(*evtInfo, sys))
52 continue;
53
54 // read the configured scalar, promoted to double for the comparison
55 double value = 0.;
56 if (m_floatVariable) value = m_floatVariable.get(*evtInfo, sys);
57 else if (m_intVariable) value = m_intVariable.get(*evtInfo, sys);
58 else if (m_doubleVariable) value = m_doubleVariable.get(*evtInfo, sys);
59
60 // calculate decision
61 bool decision = SignEnum::checkValue(static_cast<double>(m_refValue.value()), m_signEnum, value);
62 m_decoration.setBool(*evtInfo, decision, sys);
63 }
64 return StatusCode::SUCCESS;
65 }
66
67} // namespace CP
#define ANA_MSG_ERROR(xmsg)
Macro printing error messages.
#define ANA_CHECK(EXP)
check whether the given expression was successful
CP::SysReadSelectionHandle m_preselection
the preselection
CP::SysReadDecorHandle< int > m_intVariable
Gaudi::Property< std::string > m_sign
the comparison sign (GT, LT, etc)
Gaudi::Property< float > m_refValue
the reference value against which to compare
CP::SysWriteSelectionHandle m_decoration
the output selection decoration
SignEnum::ComparisonOperator m_signEnum
the operator version of the comparison (>, <, etc)
CP::SysReadDecorHandle< float > m_floatVariable
the EventInfo scalar decoration to cut on; exactly one of the typed handles below is configured,...
CP::SysListHandle m_systematicsList
the systematics list
CP::SysReadDecorHandle< double > m_doubleVariable
CP::SysReadHandle< xAOD::EventInfo > m_eventInfoHandle
the event info handle
virtual StatusCode initialize() override
EventScalarSelectorAlg(const std::string &name, ISvcLocator *pSvcLocator)
AnaAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
constructor with parameters
virtual::StatusCode execute()
execute this algorithm
Select isolated Photons, Electrons and Muons.
This module defines the arguments passed from the BATCH driver to the BATCH worker.
bool checkValue(T reference, ComparisonOperator sign, T test)
the comparison test given the specified sign and two test values
Definition SignEnums.h:37
static const std::map< std::string, ComparisonOperator > stringToOperator
the map between user inputs and comparison operators
Definition SignEnums.h:27
EventInfo_v1 EventInfo
Definition of the latest event info version.