ATLAS Offline Software
LeptonSFCalculatorAlg.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 
8 
9 namespace CP {
10 
12 
17 
21 
25 
27 
29 
30  return StatusCode::SUCCESS;
31  }
32 
34  for (const auto& syst : m_systematicsList.systematicsVector()) {
35  const xAOD::EventInfo *evtInfo {nullptr};
36  ANA_CHECK(m_eventInfoHandle.retrieve(evtInfo, syst));
37 
38  const xAOD::ElectronContainer *electrons {nullptr};
40 
41  const xAOD::MuonContainer *muons {nullptr};
42  if (m_muonsHandle) ANA_CHECK(m_muonsHandle.retrieve(muons, syst));
43 
44  const xAOD::PhotonContainer *photons {nullptr};
46 
47  double leptonSF {1.};
48  if (m_electronsHandle){
49  for (const xAOD::Electron *el : *electrons) {
50  if (m_electronSelection.getBool(*el, syst)) {
51  for (size_t i{}; i < m_electronSFs.size(); i++) {
52  leptonSF *= m_electronSFs.at(i).get(*el, syst);
53  }
54  }
55  }
56  }
57  if (m_muonsHandle){
58  for (const xAOD::Muon *mu : *muons) {
59  if (m_muonSelection.getBool(*mu, syst)) {
60  for (size_t i{}; i < m_muonSFs.size(); i++) {
61  leptonSF *= m_muonSFs.at(i).get(*mu, syst);
62  }
63  }
64  }
65  }
66  if (m_photonsHandle){
67  for (const xAOD::Photon *ph : *photons) {
68  if (m_photonSelection.getBool(*ph, syst)) {
69  for (size_t i{}; i < m_photonSFs.size(); i++) {
70  leptonSF *= m_photonSFs.at(i).get(*ph, syst);
71  }
72  }
73  }
74  }
75 
76  m_event_leptonSF.set(*evtInfo, leptonSF, syst);
77  }
78  return StatusCode::SUCCESS;
79  }
80 
81 } // namespace
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::LeptonSFCalculatorAlg::m_electronSFs
CP::SysReadDecorHandleArray< float > m_electronSFs
Definition: LeptonSFCalculatorAlg.h:58
CP::LeptonSFCalculatorAlg::m_electronSelection
CP::SysReadSelectionHandle m_electronSelection
Definition: LeptonSFCalculatorAlg.h:36
CP::LeptonSFCalculatorAlg::m_event_leptonSF
CP::SysWriteDecorHandle< float > m_event_leptonSF
Definition: LeptonSFCalculatorAlg.h:70
ANA_CHECK
#define ANA_CHECK(EXP)
check whether the given expression was successful
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:324
CP::LeptonSFCalculatorAlg::m_muonSelection
CP::SysReadSelectionHandle m_muonSelection
Definition: LeptonSFCalculatorAlg.h:43
CP::SysReadHandle::retrieve
::StatusCode retrieve(const T *&object, const CP::SystematicSet &sys) const
retrieve the object for the given name
CP::SysListHandle::systematicsVector
const std::vector< CP::SystematicSet > & systematicsVector() const
the list of systematics to loop over
Definition: SysListHandle.cxx:96
CP::LeptonSFCalculatorAlg::m_photonsHandle
CP::SysReadHandle< xAOD::PhotonContainer > m_photonsHandle
Definition: LeptonSFCalculatorAlg.h:47
CP
Select isolated Photons, Electrons and Muons.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:48
xAOD::Muon_v1
Class describing a Muon.
Definition: Muon_v1.h:38
CP::LeptonSFCalculatorAlg::m_eventInfoHandle
CP::SysReadHandle< xAOD::EventInfo > m_eventInfoHandle
Definition: LeptonSFCalculatorAlg.h:54
CP::LeptonSFCalculatorAlg::m_muonSFs
CP::SysReadDecorHandleArray< float > m_muonSFs
Definition: LeptonSFCalculatorAlg.h:62
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::LeptonSFCalculatorAlg::initialize
virtual StatusCode initialize() final
Definition: LeptonSFCalculatorAlg.cxx:11
lumiFormat.i
int i
Definition: lumiFormat.py:85
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
plotIsoValidation.el
el
Definition: plotIsoValidation.py:197
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
CP::LeptonSFCalculatorAlg::execute
virtual StatusCode execute() final
Definition: LeptonSFCalculatorAlg.cxx:33
CP::LeptonSFCalculatorAlg::m_electronsHandle
CP::SysReadHandle< xAOD::ElectronContainer > m_electronsHandle
Definition: LeptonSFCalculatorAlg.h:33
CP::LeptonSFCalculatorAlg::m_systematicsList
CP::SysListHandle m_systematicsList
Definition: LeptonSFCalculatorAlg.h:31
CP::LeptonSFCalculatorAlg::m_photonSFs
CP::SysReadDecorHandleArray< float > m_photonSFs
Definition: LeptonSFCalculatorAlg.h:66
xAOD::Electron_v1
Definition: Electron_v1.h:34
xAOD::EventInfo_v1
Class describing the basic event information.
Definition: EventInfo_v1.h:43
CP::LeptonSFCalculatorAlg::m_photonSelection
CP::SysReadSelectionHandle m_photonSelection
Definition: LeptonSFCalculatorAlg.h:50
xAOD::Photon_v1
Definition: Photon_v1.h:37
CP::SysReadSelectionHandle::initialize
StatusCode initialize(SysListHandle &sysListHandle, const ISysHandleBase &objectHandle)
initialize the accessor
Definition: SysReadSelectionHandle.cxx:34
CP::LeptonSFCalculatorAlg::m_muonsHandle
CP::SysReadHandle< xAOD::MuonContainer > m_muonsHandle
Definition: LeptonSFCalculatorAlg.h:40
CaloNoise_fillDB.mu
mu
Definition: CaloNoise_fillDB.py:53
SG::AllowEmpty
@ AllowEmpty
Definition: StoreGate/StoreGate/VarHandleKey.h:30
LeptonSFCalculatorAlg.h
InDetDD::electrons
@ electrons
Definition: InDetDD_Defs.h:17