ATLAS Offline Software
Loading...
Searching...
No Matches
MuonEfficiencyScaleFactorAlg.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
7
8
9//
10// includes
11//
12
14
16
17//
18// method implementations
19//
20
21namespace CP
22{
23
24 StatusCode MuonEfficiencyScaleFactorAlg ::
25 initialize ()
26 {
28 {
29 ANA_MSG_ERROR ("no scale factor or efficiency decoration name set");
30 return StatusCode::FAILURE;
31 }
32
41 ANA_CHECK (m_systematicsList.initialize());
42 ANA_CHECK (m_outOfValidity.initialize());
43
44 return StatusCode::SUCCESS;
45 }
46
47
48
49 StatusCode MuonEfficiencyScaleFactorAlg ::
50 execute ()
51 {
52 for (const auto& sys : m_systematicsList.systematicsVector())
53 {
54 ANA_CHECK (m_efficiencyScaleFactorTool->applySystematicVariation (sys));
55 const xAOD::MuonContainer *muons = nullptr;
56 ANA_CHECK (m_muonHandle.retrieve (muons, sys));
57 const xAOD::EventInfo *eventInfo = nullptr;
58 ANA_CHECK (m_eventInfoHandle.retrieve (eventInfo, sys));
59 for (const xAOD::Muon *muon : *muons)
60 {
61 if (m_preselection.getBool (*muon, sys))
62 {
64 float sf = 0;
65 ANA_CHECK_CORRECTION (m_outOfValidity, *muon, m_efficiencyScaleFactorTool->getEfficiencyScaleFactor (*muon, sf, eventInfo));
66 m_scaleFactorDecoration.set (*muon, sf, sys);
67 }
68
70 float eff = 0;
71 ANA_CHECK_CORRECTION (m_outOfValidity, *muon, m_efficiencyScaleFactorTool->getMCEfficiency (*muon, eff, eventInfo));
72 m_mcEfficiencyDecoration.set (*muon, eff, sys);
73 }
74
76 float eff = 0;
77 ANA_CHECK_CORRECTION (m_outOfValidity, *muon, m_efficiencyScaleFactorTool->getDataEfficiency (*muon, eff, eventInfo));
78 m_dataEfficiencyDecoration.set (*muon, eff, sys);
79 }
80 } else
81 {
84 }
85
88 }
89
92 }
93 }
94 }
95 }
96
97 return StatusCode::SUCCESS;
98 }
99}
#define ANA_MSG_ERROR(xmsg)
Macro printing error messages.
#define ANA_CHECK(EXP)
check whether the given expression was successful
#define ANA_CHECK_CORRECTION(helper, object, expr)
a helper check macro to work with OutOfValidityHelper
SysReadSelectionHandle m_preselection
the preselection we apply to our input
SysListHandle m_systematicsList
the systematics list we run
ToolHandle< IMuonEfficiencyScaleFactors > m_efficiencyScaleFactorTool
the smearing tool
SysWriteDecorHandle< float > m_scaleFactorDecoration
the decoration for the muon scale factor
OutOfValidityHelper m_outOfValidity
the helper for OutOfValidity results
SysWriteDecorHandle< float > m_dataEfficiencyDecoration
the decoration for the muon data efficiency
SysReadHandle< xAOD::EventInfo > m_eventInfoHandle
the EventInfo collection we use
SysReadHandle< xAOD::MuonContainer > m_muonHandle
the muon collection we run on
SysWriteDecorHandle< float > m_mcEfficiencyDecoration
the decoration for the muon mc efficiency
Select isolated Photons, Electrons and Muons.
constexpr float invalidEfficiency()
the decoration value to use if there is no valid efficiency decoration
constexpr float invalidScaleFactor()
the decoration value to use if there is no valid scale factor decoration
EventInfo_v1 EventInfo
Definition of the latest event info version.
Muon_v1 Muon
Reference the current persistent version:
MuonContainer_v1 MuonContainer
Definition of the current "Muon container version".