ATLAS Offline Software
Loading...
Searching...
No Matches
MuonTriggerEfficiencyScaleFactorAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7
8
9//
10// includes
11//
12
14
17
18//
19// method implementations
20//
21
22namespace CP
23{
24
25 StatusCode MuonTriggerEfficiencyScaleFactorAlg ::
26 initialize ()
27 {
28 if (m_trigger.empty())
29 {
30 ANA_MSG_ERROR ("trigger name needs to be set");
31 return StatusCode::FAILURE;
32 }
33
35 {
36 ANA_MSG_ERROR ("no scale factor or efficiency decoration name set");
37 return StatusCode::FAILURE;
38 }
39
48 ANA_CHECK (m_systematicsList.initialize());
49 ANA_CHECK (m_outOfValidity.initialize());
50
51 return StatusCode::SUCCESS;
52 }
53
54
55
56 StatusCode MuonTriggerEfficiencyScaleFactorAlg ::
57 execute ()
58 {
59 for (const auto& sys : m_systematicsList.systematicsVector())
60 {
61 ANA_CHECK (m_efficiencyScaleFactorTool->applySystematicVariation (sys));
62 const xAOD::MuonContainer *muons = nullptr;
63 ANA_CHECK (m_muonHandle.retrieve (muons, sys));
64 const xAOD::EventInfo *eventInfo = nullptr;
65 ANA_CHECK (m_eventInfoHandle.retrieve (eventInfo, sys));
66
67 static const SG::ConstAccessor<unsigned int> acc_rnd("RandomRunNumber");
68 unsigned int randomRunNumber = acc_rnd(*eventInfo);
69 bool validEvent = m_minRunNumber <= randomRunNumber && m_maxRunNumber >= randomRunNumber;
70
71 for (const xAOD::Muon *muon : *muons)
72 {
73 if (validEvent && m_preselection.getBool (*muon, sys))
74 {
76 double sf = 0;
78 singleMuonContainer.push_back(muon);
79 ANA_CHECK_CORRECTION (m_outOfValidity, *muon, m_efficiencyScaleFactorTool->getTriggerScaleFactor (*singleMuonContainer.asDataVector(), sf, m_trigger));
80 m_scaleFactorDecoration.set (*muon, sf, sys);
81 }
82
84 double eff = 0;
85 ANA_CHECK_CORRECTION (m_outOfValidity, *muon, m_efficiencyScaleFactorTool->getTriggerEfficiency (*muon, eff, m_trigger, false));
86 m_mcEfficiencyDecoration.set (*muon, eff, sys);
87 }
88
90 double eff = 0;
92 m_dataEfficiencyDecoration.set (*muon, eff, sys);
93 }
94 } else {
97 }
98
101 }
102
105 }
106 }
107 }
108 }
109 return StatusCode::SUCCESS;
110 }
111}
DataVector adapter that acts like it holds const pointers.
#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
SysReadHandle< xAOD::EventInfo > m_eventInfoHandle
the EventInfo collection we use
Gaudi::Property< std::string > m_trigger
trigger to run efficiency for
SysListHandle m_systematicsList
the systematics list we run
SysWriteDecorHandle< float > m_dataEfficiencyDecoration
the decoration for the muon data efficiency
ToolHandle< IMuonTriggerScaleFactors > m_efficiencyScaleFactorTool
the smearing tool
SysWriteDecorHandle< float > m_scaleFactorDecoration
the decoration for the muon scale factor
SysReadHandle< xAOD::MuonContainer > m_muonHandle
the muon collection we run on
SysWriteDecorHandle< float > m_mcEfficiencyDecoration
the decoration for the muon mc efficiency
SysReadSelectionHandle m_preselection
the preselection we apply to our input
OutOfValidityHelper m_outOfValidity
the helper for OutOfValidity results
DataVector adapter that acts like it holds const pointers.
value_type push_back(value_type pElem)
Add an element to the end of the collection.
const DV * asDataVector() const
Return a pointer to this object, as a const DataVector.
Helper class to provide constant type-safe access to aux data.
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
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
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".