ATLAS Offline Software
Loading...
Searching...
No Matches
MuonTriggerEfficiencyScaleFactorAlg.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
8
9//
10// includes
11//
12
14
17
18//
19// method implementations
20//
21
22namespace CP
23{
24
26 ISvcLocator* svcLoc)
27 : AnaAlgorithm(name, svcLoc)
28 {
29 declareProperty("efficiencyScaleFactorTool", m_efficiencyScaleFactorTool, "trigger efficiency scale factor tool");
30 }
31
32 StatusCode MuonTriggerEfficiencyScaleFactorAlg ::
33 initialize ()
34 {
35 if (m_trigger.empty())
36 {
37 ANA_MSG_ERROR ("trigger name needs to be set");
38 return StatusCode::FAILURE;
39 }
40
42 {
43 ANA_MSG_ERROR ("efficiency scale factor tool needs to be set");
44 return StatusCode::FAILURE;
45 }
46
48 {
49 ANA_MSG_ERROR ("no scale factor or efficiency decoration name set");
50 return StatusCode::FAILURE;
51 }
52
61 ANA_CHECK (m_systematicsList.initialize());
62 ANA_CHECK (m_outOfValidity.initialize());
63
64 return StatusCode::SUCCESS;
65 }
66
67
68
69 StatusCode MuonTriggerEfficiencyScaleFactorAlg ::
70 execute ()
71 {
72 for (const auto& sys : m_systematicsList.systematicsVector())
73 {
74 ANA_CHECK (m_efficiencyScaleFactorTool->applySystematicVariation (sys));
75 const xAOD::MuonContainer *muons = nullptr;
76 ANA_CHECK (m_muonHandle.retrieve (muons, sys));
77 const xAOD::EventInfo *eventInfo = nullptr;
78 ANA_CHECK (m_eventInfoHandle.retrieve (eventInfo, sys));
79
80 static const SG::ConstAccessor<unsigned int> acc_rnd("RandomRunNumber");
81 unsigned int randomRunNumber = acc_rnd(*eventInfo);
82 bool validEvent = m_minRunNumber <= randomRunNumber && m_maxRunNumber >= randomRunNumber;
83
84 for (const xAOD::Muon *muon : *muons)
85 {
86 if (validEvent && m_preselection.getBool (*muon, sys))
87 {
89 double sf = 0;
91 singleMuonContainer.push_back(muon);
92 ANA_CHECK_CORRECTION (m_outOfValidity, *muon, m_efficiencyScaleFactorTool->getTriggerScaleFactor (*singleMuonContainer.asDataVector(), sf, m_trigger));
93 m_scaleFactorDecoration.set (*muon, sf, sys);
94 }
95
97 double eff = 0;
98 ANA_CHECK_CORRECTION (m_outOfValidity, *muon, m_efficiencyScaleFactorTool->getTriggerEfficiency (*muon, eff, m_trigger, false));
99 m_mcEfficiencyDecoration.set (*muon, eff, sys);
100 }
101
103 double eff = 0;
104 ANA_CHECK_CORRECTION (m_outOfValidity, *muon, m_efficiencyScaleFactorTool->getTriggerEfficiency (*muon, eff, m_trigger, true));
105 m_dataEfficiencyDecoration.set (*muon, eff, sys);
106 }
107 } else {
110 }
111
114 }
115
118 }
119 }
120 }
121 }
122 return StatusCode::SUCCESS;
123 }
124}
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
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
SysReadHandle< xAOD::EventInfo > m_eventInfoHandle
the EventInfo collection we use
MuonTriggerEfficiencyScaleFactorAlg(const std::string &name, ISvcLocator *svcLoc=nullptr)
the standard constructor
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.
AnaAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
constructor with parameters
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".