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-2026 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
double
leptonSF {1.};
42
auto
accumulateSFs = [&]<
typename
T>(
CP::SysReadHandle<T>
&
handle
,
43
CP::SysReadSelectionHandle
&
selection
,
44
CP::SysReadDecorHandleArray<float>
& sfs) -> StatusCode {
45
if
(!
handle
)
return
StatusCode::SUCCESS;
46
const
T *particles {
nullptr
};
47
ANA_CHECK
(
handle
.retrieve(particles, syst, ctx));
48
for
(
const
auto
*particle : *particles) {
49
if
(
selection
.getBool(*particle, syst)) {
50
for
(
size_t
i{}; i < sfs.size(); i++) {
51
leptonSF *= sfs.at(i).get(*particle, syst);
52
}
53
}
54
}
55
return
StatusCode::SUCCESS;
56
};
57
ANA_CHECK
(accumulateSFs(
m_electronsHandle
,
m_electronSelection
,
m_electronSFs
));
58
ANA_CHECK
(accumulateSFs(
m_muonsHandle
,
m_muonSelection
,
m_muonSFs
));
59
ANA_CHECK
(accumulateSFs(
m_photonsHandle
,
m_photonSelection
,
m_photonSFs
));
60
ANA_CHECK
(accumulateSFs(
m_tausHandle
,
m_tauSelection
,
m_tauSFs
));
61
62
m_event_leptonSF
.set(*evtInfo, leptonSF, syst);
63
}
64
return
StatusCode::SUCCESS;
65
}
66
67
}
// namespace
ANA_CHECK
#define ANA_CHECK(EXP)
check whether the given expression was successful
Definition
Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:325
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
CP::SysReadHandle
a data handle for reading systematics varied input data
Definition
SysReadHandle.h:33
CP::SysReadSelectionHandle
a data handle for reading systematically varied selection properties from objects
Definition
SysReadSelectionHandle.h:32
EL::AnaAlgorithm::handle
void handle(const Incident &inc)
receive the given incident
Definition
AnaAlgorithm.cxx:524
EL::AnaAlgorithm::execute
virtual::StatusCode execute()
execute this algorithm
Definition
AnaAlgorithm.cxx:315
selection
const std::string selection
Definition
fbtTestBasics.cxx:75
CP
Select isolated Photons, Electrons and Muons.
Definition
Control/xAODRootAccess/xAODRootAccess/TEvent.h:27
CP::SysReadDecorHandleArray
SysHandleArray< SysReadDecorHandle< T > > SysReadDecorHandleArray
Definition
SysReadDecorHandle.h:136
SG::AllowEmpty
@ AllowEmpty
Definition
StoreGate/StoreGate/VarHandleKey.h:29
xAOD::EventInfo
EventInfo_v1 EventInfo
Definition of the latest event info version.
Definition
IEventInfoCnvTool.h:16
Generated on
for ATLAS Offline Software by
1.17.0