ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
Algorithms
EventSelectionAlgorithms
Root
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
7
#include "
EventSelectionAlgorithms/EventScalarSelectorAlg.h
"
8
9
namespace
CP
{
10
11
EventScalarSelectorAlg::EventScalarSelectorAlg
(
const
std::string &
name
, ISvcLocator *pSvcLocator)
12
:
EL
::
AnaAlgorithm
(
name
, pSvcLocator)
13
{}
14
15
StatusCode
EventScalarSelectorAlg::initialize
() {
16
ANA_CHECK
(
m_eventInfoHandle
.initialize(
m_systematicsList
));
17
18
ANA_CHECK
(
m_floatVariable
.initialize(
m_systematicsList
,
m_eventInfoHandle
,
SG::AllowEmpty
));
19
ANA_CHECK
(
m_intVariable
.initialize(
m_systematicsList
,
m_eventInfoHandle
,
SG::AllowEmpty
));
20
ANA_CHECK
(
m_doubleVariable
.initialize(
m_systematicsList
,
m_eventInfoHandle
,
SG::AllowEmpty
));
21
22
ANA_CHECK
(
m_preselection
.initialize(
m_systematicsList
,
m_eventInfoHandle
,
SG::AllowEmpty
));
23
ANA_CHECK
(
m_decoration
.initialize(
m_systematicsList
,
m_eventInfoHandle
));
24
ANA_CHECK
(
m_systematicsList
.initialize());
25
26
m_signEnum
=
SignEnum::stringToOperator
.at(
m_sign
);
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
ANA_MSG_ERROR
#define ANA_MSG_ERROR(xmsg)
Macro printing error messages.
Definition
Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:294
ANA_CHECK
#define ANA_CHECK(EXP)
check whether the given expression was successful
Definition
Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:324
EventScalarSelectorAlg.h
CP::EventScalarSelectorAlg::m_preselection
CP::SysReadSelectionHandle m_preselection
the preselection
Definition
EventScalarSelectorAlg.h:70
CP::EventScalarSelectorAlg::m_intVariable
CP::SysReadDecorHandle< int > m_intVariable
Definition
EventScalarSelectorAlg.h:62
CP::EventScalarSelectorAlg::m_sign
Gaudi::Property< std::string > m_sign
the comparison sign (GT, LT, etc)
Definition
EventScalarSelectorAlg.h:41
CP::EventScalarSelectorAlg::m_refValue
Gaudi::Property< float > m_refValue
the reference value against which to compare
Definition
EventScalarSelectorAlg.h:44
CP::EventScalarSelectorAlg::m_decoration
CP::SysWriteSelectionHandle m_decoration
the output selection decoration
Definition
EventScalarSelectorAlg.h:75
CP::EventScalarSelectorAlg::m_signEnum
SignEnum::ComparisonOperator m_signEnum
the operator version of the comparison (>, <, etc)
Definition
EventScalarSelectorAlg.h:47
CP::EventScalarSelectorAlg::m_floatVariable
CP::SysReadDecorHandle< float > m_floatVariable
the EventInfo scalar decoration to cut on; exactly one of the typed handles below is configured,...
Definition
EventScalarSelectorAlg.h:59
CP::EventScalarSelectorAlg::m_systematicsList
CP::SysListHandle m_systematicsList
the systematics list
Definition
EventScalarSelectorAlg.h:50
CP::EventScalarSelectorAlg::m_doubleVariable
CP::SysReadDecorHandle< double > m_doubleVariable
Definition
EventScalarSelectorAlg.h:65
CP::EventScalarSelectorAlg::m_eventInfoHandle
CP::SysReadHandle< xAOD::EventInfo > m_eventInfoHandle
the event info handle
Definition
EventScalarSelectorAlg.h:53
CP::EventScalarSelectorAlg::initialize
virtual StatusCode initialize() override
Definition
EventScalarSelectorAlg.cxx:15
CP::EventScalarSelectorAlg::EventScalarSelectorAlg
EventScalarSelectorAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition
EventScalarSelectorAlg.cxx:11
EL::AnaAlgorithm::AnaAlgorithm
AnaAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
constructor with parameters
Definition
AnaAlgorithm.cxx:40
EL::AnaAlgorithm::execute
virtual::StatusCode execute()
execute this algorithm
Definition
AnaAlgorithm.cxx:315
CP
Select isolated Photons, Electrons and Muons.
Definition
Control/xAODRootAccess/xAODRootAccess/TEvent.h:27
EL
This module defines the arguments passed from the BATCH driver to the BATCH worker.
Definition
AsgComponentFactories.h:16
SG::AllowEmpty
@ AllowEmpty
Definition
StoreGate/StoreGate/VarHandleKey.h:27
SignEnum::checkValue
bool checkValue(T reference, ComparisonOperator sign, T test)
the comparison test given the specified sign and two test values
Definition
SignEnums.h:37
SignEnum::stringToOperator
static const std::map< std::string, ComparisonOperator > stringToOperator
the map between user inputs and comparison operators
Definition
SignEnums.h:27
xAOD::name
name
Definition
TriggerMenuJson_v1.cxx:29
xAOD::EventInfo
EventInfo_v1 EventInfo
Definition of the latest event info version.
Definition
IEventInfoCnvTool.h:16
Generated on
for ATLAS Offline Software by
1.17.0