ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
Algorithms
AsgAnalysisAlgorithms
Root
LeptonSFCalculatorAlg.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3
*/
4
6
7
#include "
AsgAnalysisAlgorithms/LeptonSFCalculatorAlg.h
"
8
9
namespace
CP
{
10
11
StatusCode
LeptonSFCalculatorAlg::initialize
() {
12
13
ANA_CHECK
(
m_electronsHandle
.initialize(
m_systematicsList
,
SG::AllowEmpty
));
14
ANA_CHECK
(
m_muonsHandle
.initialize(
m_systematicsList
,
SG::AllowEmpty
));
15
ANA_CHECK
(
m_photonsHandle
.initialize(
m_systematicsList
,
SG::AllowEmpty
));
16
ANA_CHECK
(
m_tausHandle
.initialize(
m_systematicsList
,
SG::AllowEmpty
));
17
ANA_CHECK
(
m_eventInfoHandle
.initialize(
m_systematicsList
));
18
19
ANA_CHECK
(
m_electronSelection
.initialize(
m_systematicsList
,
m_electronsHandle
,
SG::AllowEmpty
));
20
ANA_CHECK
(
m_muonSelection
.initialize(
m_systematicsList
,
m_muonsHandle
,
SG::AllowEmpty
));
21
ANA_CHECK
(
m_photonSelection
.initialize(
m_systematicsList
,
m_photonsHandle
,
SG::AllowEmpty
));
22
ANA_CHECK
(
m_tauSelection
.initialize(
m_systematicsList
,
m_tausHandle
,
SG::AllowEmpty
));
23
24
ANA_CHECK
(
m_electronSFs
.initialize(
m_systematicsList
,
m_electronsHandle
));
25
ANA_CHECK
(
m_muonSFs
.initialize(
m_systematicsList
,
m_muonsHandle
));
26
ANA_CHECK
(
m_photonSFs
.initialize(
m_systematicsList
,
m_photonsHandle
));
27
ANA_CHECK
(
m_tauSFs
.initialize(
m_systematicsList
,
m_tausHandle
));
28
29
ANA_CHECK
(
m_event_leptonSF
.initialize(
m_systematicsList
,
m_eventInfoHandle
));
30
31
ANA_CHECK
(
m_systematicsList
.initialize());
32
33
return
StatusCode::SUCCESS;
34
}
35
36
StatusCode
LeptonSFCalculatorAlg::execute
(
const
EventContext& ctx) {
37
for
(
const
auto
& syst :
m_systematicsList
.systematicsVector()) {
38
const
xAOD::EventInfo
*evtInfo {
nullptr
};
39
ANA_CHECK
(
m_eventInfoHandle
.retrieve(evtInfo, syst, ctx));
40
41
const
xAOD::ElectronContainer
*electrons {
nullptr
};
42
if
(
m_electronsHandle
)
ANA_CHECK
(
m_electronsHandle
.retrieve(electrons, syst, ctx));
43
44
const
xAOD::MuonContainer
*muons {
nullptr
};
45
if
(
m_muonsHandle
)
ANA_CHECK
(
m_muonsHandle
.retrieve(muons, syst, ctx));
46
47
const
xAOD::PhotonContainer
*photons {
nullptr
};
48
if
(
m_photonsHandle
)
ANA_CHECK
(
m_photonsHandle
.retrieve(photons, syst, ctx));
49
50
const
xAOD::TauJetContainer
*
taus
{
nullptr
};
51
if
(
m_tausHandle
)
ANA_CHECK
(
m_tausHandle
.retrieve(
taus
, syst, ctx));
52
53
double
leptonSF {1.};
54
if
(
m_electronsHandle
){
55
for
(
const
xAOD::Electron
*el : *electrons) {
56
if
(
m_electronSelection
.getBool(*el, syst)) {
57
for
(
size_t
i{}; i <
m_electronSFs
.size(); i++) {
58
leptonSF *=
m_electronSFs
.at(i).get(*el, syst);
59
}
60
}
61
}
62
}
63
if
(
m_muonsHandle
){
64
for
(
const
xAOD::Muon
*mu : *muons) {
65
if
(
m_muonSelection
.getBool(*mu, syst)) {
66
for
(
size_t
i{}; i <
m_muonSFs
.size(); i++) {
67
leptonSF *=
m_muonSFs
.at(i).get(*mu, syst);
68
}
69
}
70
}
71
}
72
if
(
m_photonsHandle
){
73
for
(
const
xAOD::Photon
*ph : *photons) {
74
if
(
m_photonSelection
.getBool(*ph, syst)) {
75
for
(
size_t
i{}; i <
m_photonSFs
.size(); i++) {
76
leptonSF *=
m_photonSFs
.at(i).get(*ph, syst);
77
}
78
}
79
}
80
}
81
if
(
m_tausHandle
){
82
for
(
const
xAOD::TauJet
*tau : *
taus
) {
83
if
(
m_tauSelection
.getBool(*tau, syst)) {
84
for
(
size_t
i{}; i <
m_tauSFs
.size(); i++) {
85
leptonSF *=
m_tauSFs
.at(i).get(*tau, syst);
86
}
87
}
88
}
89
}
90
91
m_event_leptonSF
.set(*evtInfo, leptonSF, syst);
92
}
93
return
StatusCode::SUCCESS;
94
}
95
96
}
// namespace
ANA_CHECK
#define ANA_CHECK(EXP)
check whether the given expression was successful
Definition
Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:325
taus
static Double_t taus
Definition
LArPhysWaveHECTool.cxx:37
LeptonSFCalculatorAlg.h
CP::LeptonSFCalculatorAlg::m_tausHandle
CP::SysReadHandle< xAOD::TauJetContainer > m_tausHandle
Definition
LeptonSFCalculatorAlg.h:55
CP::LeptonSFCalculatorAlg::m_photonSFs
CP::SysReadDecorHandleArray< float > m_photonSFs
Definition
LeptonSFCalculatorAlg.h:74
CP::LeptonSFCalculatorAlg::m_muonsHandle
CP::SysReadHandle< xAOD::MuonContainer > m_muonsHandle
Definition
LeptonSFCalculatorAlg.h:41
CP::LeptonSFCalculatorAlg::initialize
virtual StatusCode initialize() final
Definition
LeptonSFCalculatorAlg.cxx:11
CP::LeptonSFCalculatorAlg::m_electronsHandle
CP::SysReadHandle< xAOD::ElectronContainer > m_electronsHandle
Definition
LeptonSFCalculatorAlg.h:34
CP::LeptonSFCalculatorAlg::m_photonSelection
CP::SysReadSelectionHandle m_photonSelection
Definition
LeptonSFCalculatorAlg.h:51
CP::LeptonSFCalculatorAlg::m_tauSFs
CP::SysReadDecorHandleArray< float > m_tauSFs
Definition
LeptonSFCalculatorAlg.h:78
CP::LeptonSFCalculatorAlg::m_event_leptonSF
CP::SysWriteDecorHandle< float > m_event_leptonSF
Definition
LeptonSFCalculatorAlg.h:82
CP::LeptonSFCalculatorAlg::m_systematicsList
CP::SysListHandle m_systematicsList
Definition
LeptonSFCalculatorAlg.h:32
CP::LeptonSFCalculatorAlg::m_muonSelection
CP::SysReadSelectionHandle m_muonSelection
Definition
LeptonSFCalculatorAlg.h:44
CP::LeptonSFCalculatorAlg::m_photonsHandle
CP::SysReadHandle< xAOD::PhotonContainer > m_photonsHandle
Definition
LeptonSFCalculatorAlg.h:48
CP::LeptonSFCalculatorAlg::m_electronSFs
CP::SysReadDecorHandleArray< float > m_electronSFs
Definition
LeptonSFCalculatorAlg.h:66
CP::LeptonSFCalculatorAlg::m_electronSelection
CP::SysReadSelectionHandle m_electronSelection
Definition
LeptonSFCalculatorAlg.h:37
CP::LeptonSFCalculatorAlg::m_tauSelection
CP::SysReadSelectionHandle m_tauSelection
Definition
LeptonSFCalculatorAlg.h:58
CP::LeptonSFCalculatorAlg::m_muonSFs
CP::SysReadDecorHandleArray< float > m_muonSFs
Definition
LeptonSFCalculatorAlg.h:70
CP::LeptonSFCalculatorAlg::m_eventInfoHandle
CP::SysReadHandle< xAOD::EventInfo > m_eventInfoHandle
Definition
LeptonSFCalculatorAlg.h:62
EL::AnaAlgorithm::execute
virtual::StatusCode execute()
execute this algorithm
Definition
AnaAlgorithm.cxx:315
CP
Select isolated Photons, Electrons and Muons.
Definition
Control/xAODRootAccess/xAODRootAccess/TEvent.h:27
SG::AllowEmpty
@ AllowEmpty
Definition
StoreGate/StoreGate/VarHandleKey.h:27
xAOD::PhotonContainer
PhotonContainer_v1 PhotonContainer
Definition of the current "photon container version".
Definition
Event/xAOD/xAODEgamma/xAODEgamma/PhotonContainer.h:17
xAOD::ElectronContainer
ElectronContainer_v1 ElectronContainer
Definition of the current "electron container version".
Definition
Event/xAOD/xAODEgamma/xAODEgamma/ElectronContainer.h:17
xAOD::EventInfo
EventInfo_v1 EventInfo
Definition of the latest event info version.
Definition
IEventInfoCnvTool.h:16
xAOD::TauJet
TauJet_v3 TauJet
Definition of the current "tau version".
Definition
TauJet.h:17
xAOD::Muon
Muon_v1 Muon
Reference the current persistent version:
Definition
Event/xAOD/xAODMuon/xAODMuon/Muon.h:13
xAOD::Photon
Photon_v1 Photon
Definition of the current "egamma version".
Definition
Event/xAOD/xAODEgamma/xAODEgamma/Photon.h:17
xAOD::TauJetContainer
TauJetContainer_v3 TauJetContainer
Definition of the current "taujet container version".
Definition
TauJetContainer.h:17
xAOD::MuonContainer
MuonContainer_v1 MuonContainer
Definition of the current "Muon container version".
Definition
Event/xAOD/xAODMuon/xAODMuon/MuonContainer.h:14
xAOD::Electron
Electron_v1 Electron
Definition of the current "egamma version".
Definition
Event/xAOD/xAODEgamma/xAODEgamma/Electron.h:17
Generated on
for ATLAS Offline Software by
1.17.0