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
16
17//
18// method implementations
19//
20
21namespace CP
22{
23
25 ISvcLocator* svcLoc)
26 : AnaAlgorithm(name, svcLoc)
27 {
28 declareProperty("efficiencyScaleFactorTool", m_efficiencyScaleFactorTool, "trigger efficiency scale factor tool");
29 }
30
31 StatusCode MuonTriggerEfficiencyScaleFactorAlg ::
32 initialize ()
33 {
34 if (m_trigger.empty())
35 {
36 ANA_MSG_ERROR ("trigger name needs to be set");
37 return StatusCode::FAILURE;
38 }
39
41 {
42 ANA_MSG_ERROR ("efficiency scale factor tool needs to be set");
43 return StatusCode::FAILURE;
44 }
45
47 {
48 ANA_MSG_ERROR ("no scale factor or efficiency decoration name set");
49 return StatusCode::FAILURE;
50 }
51
60 ANA_CHECK (m_systematicsList.initialize());
61 ANA_CHECK (m_outOfValidity.initialize());
62
63 return StatusCode::SUCCESS;
64 }
65
66
67
68 StatusCode MuonTriggerEfficiencyScaleFactorAlg ::
69 execute (const EventContext& ctx)
70 {
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, ctx));
77 const xAOD::EventInfo *eventInfo = nullptr;
78 ANA_CHECK (m_eventInfoHandle.retrieve (eventInfo, sys, ctx));
79 //coverity[UNNECESSARY_STRING_COPY:FALSE]
80 static const SG::ConstAccessor<unsigned int> acc_rnd("RandomRunNumber");
81 if (!acc_rnd.isAvailable(*eventInfo))
82 {
83 ANA_MSG_ERROR ("RandomRunNumber decoration not found on EventInfo; make sure the pileup reweighting is scheduled before this algorithm");
84 return StatusCode::FAILURE;
85 }
86 unsigned int randomRunNumber = acc_rnd(*eventInfo);
87 bool validEvent = m_minRunNumber <= randomRunNumber && m_maxRunNumber >= randomRunNumber;
88
89 for (const xAOD::Muon *muon : *muons)
90 {
91 if (validEvent && m_preselection.getBool (*muon, sys))
92 {
94 double sf = 0;
95 singleMuonContainer.clear();
96 singleMuonContainer.push_back(muon);
97 ANA_CHECK_CORRECTION (m_outOfValidity, *muon, m_efficiencyScaleFactorTool->getTriggerScaleFactor (*singleMuonContainer.asDataVector(), sf, m_trigger));
98 m_scaleFactorDecoration.set (*muon, sf, sys);
99 }
100
102 double eff = 0;
103 ANA_CHECK_CORRECTION (m_outOfValidity, *muon, m_efficiencyScaleFactorTool->getTriggerEfficiency (*muon, eff, m_trigger, false));
104 m_mcEfficiencyDecoration.set (*muon, eff, sys);
105 }
106
108 double eff = 0;
109 ANA_CHECK_CORRECTION (m_outOfValidity, *muon, m_efficiencyScaleFactorTool->getTriggerEfficiency (*muon, eff, m_trigger, true));
110 m_dataEfficiencyDecoration.set (*muon, eff, sys);
111 }
112 } else {
115 }
116
119 }
120
123 }
124 }
125 }
126 }
127 return StatusCode::SUCCESS;
128 }
129}
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 trigger efficiency scale factor 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.
void clear()
Erase all the elements in the collection.
AnaAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
constructor with parameters
Helper class to provide constant type-safe access to aux data.
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
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".