ATLAS Offline Software
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 
15 #include <RootCoreUtils/Assert.h>
16 
17 //
18 // method implementations
19 //
20 
21 namespace CP
22 {
23 
25  initialize ()
26  {
28  {
29  ANA_MSG_ERROR ("no scale factor or efficiency decoration name set");
30  return StatusCode::FAILURE;
31  }
32 
43 
44  return StatusCode::SUCCESS;
45  }
46 
47 
48 
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;
57  const xAOD::EventInfo *eventInfo = nullptr;
58  ANA_CHECK (m_eventInfoHandle.retrieve (eventInfo, sys));
59  for (const xAOD::Muon *muon : *muons)
60  {
62  {
64  float sf = 0;
65  ANA_CHECK_CORRECTION (m_outOfValidity, *muon, m_efficiencyScaleFactorTool->getEfficiencyScaleFactor (*muon, sf, eventInfo));
67  }
68 
70  float eff = 0;
71  ANA_CHECK_CORRECTION (m_outOfValidity, *muon, m_efficiencyScaleFactorTool->getMCEfficiency (*muon, eff, eventInfo));
73  }
74 
76  float eff = 0;
77  ANA_CHECK_CORRECTION (m_outOfValidity, *muon, m_efficiencyScaleFactorTool->getDataEfficiency (*muon, eff, eventInfo));
79  }
80  } else
81  {
84  }
85 
88  }
89 
92  }
93  }
94  }
95  }
96 
97  return StatusCode::SUCCESS;
98  }
99 }
CP::SysWriteDecorHandle::set
void set(const SG::AuxElement &object, const T &value, const CP::SystematicSet &sys) const
set the object decoration for the given systematic
xAOD::muon
@ muon
Definition: TrackingPrimitives.h:195
CP::MuonEfficiencyScaleFactorAlg::m_preselection
SysReadSelectionHandle m_preselection
the preselection we apply to our input
Definition: MuonEfficiencyScaleFactorAlg.h:56
CP::SysListHandle::addSystematics
StatusCode addSystematics(const CP::SystematicSet &recommended, const CP::SystematicSet &affecting)
register a set of affecting variables for the current algorithm (usually obtained from an CP::ISystem...
Definition: SysListHandle.cxx:48
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
CP::SysReadHandle::retrieve
::StatusCode retrieve(const T *&object, const CP::SystematicSet &sys) const
retrieve the object for the given name
MuonEfficiencyScaleFactorAlg.h
CP::SysListHandle::systematicsVector
const std::vector< CP::SystematicSet > & systematicsVector() const
the list of systematics to loop over
Definition: SysListHandle.cxx:96
Assert.h
CP
Select isolated Photons, Electrons and Muons.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:48
mapkey::sys
@ sys
Definition: TElectronEfficiencyCorrectionTool.cxx:42
xAOD::Muon_v1
Class describing a Muon.
Definition: Muon_v1.h:38
CP::invalidScaleFactor
constexpr float invalidScaleFactor()
the decoration value to use if there is no valid scale factor decoration
Definition: SysWriteDecorHandle.h:31
CP::MuonEfficiencyScaleFactorAlg::m_efficiencyScaleFactorTool
ToolHandle< IMuonEfficiencyScaleFactors > m_efficiencyScaleFactorTool
the smearing tool
Definition: MuonEfficiencyScaleFactorAlg.h:38
CP::SysReadHandle::initialize
StatusCode initialize(SysListHandle &sysListHandle)
initialize this handle
CP::SysListHandle::initialize
::StatusCode initialize()
intialize this property
Definition: SysListHandle.cxx:69
CP::SysReadSelectionHandle::getBool
bool getBool(const SG::AuxElement &element, const CP::SystematicSet &sys) const
get the selection as a bool
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
CP::SysWriteDecorHandle::initialize
StatusCode initialize(SysListHandle &sysListHandle, const ISysHandleBase &objectHandle)
initialize this handle
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
CP::MuonEfficiencyScaleFactorAlg::m_outOfValidity
OutOfValidityHelper m_outOfValidity
the helper for OutOfValidity results
Definition: MuonEfficiencyScaleFactorAlg.h:61
CP::MuonEfficiencyScaleFactorAlg::m_mcEfficiencyDecoration
SysWriteDecorHandle< float > m_mcEfficiencyDecoration
the decoration for the muon mc efficiency
Definition: MuonEfficiencyScaleFactorAlg.h:70
ANA_CHECK_CORRECTION
#define ANA_CHECK_CORRECTION(helper, object, expr)
a helper check macro to work with OutOfValidityHelper
Definition: OutOfValidityHelper.h:132
CP::SysWriteDecorHandle::empty
virtual bool empty() const noexcept override
whether we have a name configured
CP::OutOfValidityHelper::initialize
::StatusCode initialize()
standard initialize
Definition: OutOfValidityHelper.cxx:25
CP::MuonEfficiencyScaleFactorAlg::m_eventInfoHandle
SysReadHandle< xAOD::EventInfo > m_eventInfoHandle
the EventInfo collection we use
Definition: MuonEfficiencyScaleFactorAlg.h:51
xAOD::EventInfo_v1
Class describing the basic event information.
Definition: EventInfo_v1.h:43
CP::MuonEfficiencyScaleFactorAlg::initialize
StatusCode initialize() override
Definition: MuonEfficiencyScaleFactorAlg.cxx:25
mapkey::sf
@ sf
Definition: TElectronEfficiencyCorrectionTool.cxx:38
CP::SysReadSelectionHandle::initialize
StatusCode initialize(SysListHandle &sysListHandle, const ISysHandleBase &objectHandle)
initialize the accessor
Definition: SysReadSelectionHandle.cxx:34
CP::MuonEfficiencyScaleFactorAlg::m_muonHandle
SysReadHandle< xAOD::MuonContainer > m_muonHandle
the muon collection we run on
Definition: MuonEfficiencyScaleFactorAlg.h:46
CP::MuonEfficiencyScaleFactorAlg::m_scaleFactorDecoration
SysWriteDecorHandle< float > m_scaleFactorDecoration
the decoration for the muon scale factor
Definition: MuonEfficiencyScaleFactorAlg.h:65
CP::MuonEfficiencyScaleFactorAlg::m_dataEfficiencyDecoration
SysWriteDecorHandle< float > m_dataEfficiencyDecoration
the decoration for the muon data efficiency
Definition: MuonEfficiencyScaleFactorAlg.h:75
dqt_zlumi_alleff_HIST.eff
int eff
Definition: dqt_zlumi_alleff_HIST.py:113
CP::MuonEfficiencyScaleFactorAlg::execute
StatusCode execute() override
Definition: MuonEfficiencyScaleFactorAlg.cxx:50
SG::AllowEmpty
@ AllowEmpty
Definition: StoreGate/StoreGate/VarHandleKey.h:30
CP::invalidEfficiency
constexpr float invalidEfficiency()
the decoration value to use if there is no valid efficiency decoration
Definition: SysWriteDecorHandle.h:35
CP::MuonEfficiencyScaleFactorAlg::m_systematicsList
SysListHandle m_systematicsList
the systematics list we run
Definition: MuonEfficiencyScaleFactorAlg.h:42