ATLAS Offline Software
MuonTriggerEfficiencyScaleFactorAlg.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 #include <RootCoreUtils/Assert.h>
17 
18 //
19 // method implementations
20 //
21 
22 namespace CP
23 {
24 
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 
50 
51  return StatusCode::SUCCESS;
52  }
53 
54 
55 
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;
64  const xAOD::EventInfo *eventInfo = nullptr;
65  ANA_CHECK (m_eventInfoHandle.retrieve (eventInfo, sys));
66 
67  static const SG::AuxElement::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));
81  }
82 
84  double eff = 0;
87  }
88 
90  double eff = 0;
93  }
94  } else {
97  }
98 
101  }
102 
105  }
106  }
107  }
108  }
109  return StatusCode::SUCCESS;
110  }
111 }
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
CP::MuonTriggerEfficiencyScaleFactorAlg::m_outOfValidity
OutOfValidityHelper m_outOfValidity
the helper for OutOfValidity results
Definition: MuonTriggerEfficiencyScaleFactorAlg.h:62
xAOD::muon
@ muon
Definition: TrackingPrimitives.h:195
SG::VIEW_ELEMENTS
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Definition: OwnershipPolicy.h:18
ConstDataVector.h
DataVector adapter that acts like it holds const pointers.
CP::MuonTriggerEfficiencyScaleFactorAlg::m_dataEfficiencyDecoration
SysWriteDecorHandle< float > m_dataEfficiencyDecoration
the decoration for the muon data efficiency
Definition: MuonTriggerEfficiencyScaleFactorAlg.h:88
CP::MuonTriggerEfficiencyScaleFactorAlg::m_muonHandle
SysReadHandle< xAOD::MuonContainer > m_muonHandle
the muon collection we run on
Definition: MuonTriggerEfficiencyScaleFactorAlg.h:47
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
SG::ConstAccessor
Helper class to provide constant type-safe access to aux data.
Definition: ConstAccessor.h:55
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
ConstDataVector::asDataVector
const DV * asDataVector() const
Return a pointer to this object, as a const DataVector.
CP::invalidScaleFactor
constexpr float invalidScaleFactor()
the decoration value to use if there is no valid scale factor decoration
Definition: SysWriteDecorHandle.h:31
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
CP::MuonTriggerEfficiencyScaleFactorAlg::initialize
StatusCode initialize() override
Definition: MuonTriggerEfficiencyScaleFactorAlg.cxx:26
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
CP::MuonTriggerEfficiencyScaleFactorAlg::m_eventInfoHandle
SysReadHandle< xAOD::EventInfo > m_eventInfoHandle
the EventInfo collection we use
Definition: MuonTriggerEfficiencyScaleFactorAlg.h:52
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
CP::MuonTriggerEfficiencyScaleFactorAlg::m_preselection
SysReadSelectionHandle m_preselection
the preselection we apply to our input
Definition: MuonTriggerEfficiencyScaleFactorAlg.h:57
CP::MuonTriggerEfficiencyScaleFactorAlg::m_trigger
Gaudi::Property< std::string > m_trigger
trigger to run efficiency for
Definition: MuonTriggerEfficiencyScaleFactorAlg.h:66
ANA_CHECK_CORRECTION
#define ANA_CHECK_CORRECTION(helper, object, expr)
a helper check macro to work with OutOfValidityHelper
Definition: OutOfValidityHelper.h:132
CP::MuonTriggerEfficiencyScaleFactorAlg::m_systematicsList
SysListHandle m_systematicsList
the systematics list we run
Definition: MuonTriggerEfficiencyScaleFactorAlg.h:43
CP::SysWriteDecorHandle::empty
virtual bool empty() const noexcept override
whether we have a name configured
ConstDataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
CP::OutOfValidityHelper::initialize
::StatusCode initialize()
standard initialize
Definition: OutOfValidityHelper.cxx:25
MuonTriggerEfficiencyScaleFactorAlg.h
CP::MuonTriggerEfficiencyScaleFactorAlg::m_efficiencyScaleFactorTool
ToolHandle< IMuonTriggerScaleFactors > m_efficiencyScaleFactorTool
the smearing tool
Definition: MuonTriggerEfficiencyScaleFactorAlg.h:39
CP::MuonTriggerEfficiencyScaleFactorAlg::execute
StatusCode execute() override
Definition: MuonTriggerEfficiencyScaleFactorAlg.cxx:57
xAOD::EventInfo_v1
Class describing the basic event information.
Definition: EventInfo_v1.h:43
CP::MuonTriggerEfficiencyScaleFactorAlg::m_scaleFactorDecoration
SysWriteDecorHandle< float > m_scaleFactorDecoration
the decoration for the muon scale factor
Definition: MuonTriggerEfficiencyScaleFactorAlg.h:78
mapkey::sf
@ sf
Definition: TElectronEfficiencyCorrectionTool.cxx:38
ConstDataVector
DataVector adapter that acts like it holds const pointers.
Definition: ConstDataVector.h:76
CP::SysReadSelectionHandle::initialize
StatusCode initialize(SysListHandle &sysListHandle, const ISysHandleBase &objectHandle)
initialize the accessor
Definition: SysReadSelectionHandle.cxx:34
CP::MuonTriggerEfficiencyScaleFactorAlg::m_mcEfficiencyDecoration
SysWriteDecorHandle< float > m_mcEfficiencyDecoration
the decoration for the muon mc efficiency
Definition: MuonTriggerEfficiencyScaleFactorAlg.h:83
dqt_zlumi_alleff_HIST.eff
int eff
Definition: dqt_zlumi_alleff_HIST.py:113
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