ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
DerivationFramework
DerivationFrameworkMuons
src
MuonJetDrTool.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
// Finds the nearest jet and adds its info to the muon.
6
#include "
MuonJetDrTool.h
"
7
8
#include "
FourMomUtils/xAODP4Helpers.h
"
9
#include "
StoreGate/WriteDecorHandle.h
"
10
11
StatusCode
DerivationFramework::MuonJetDrTool::initialize
() {
12
ATH_CHECK
(
m_muonSGKey
.initialize());
13
ATH_CHECK
(
m_jetSGKey
.initialize());
14
ATH_CHECK
(
m_jetDR_SGKey
.initialize());
15
return
StatusCode::SUCCESS;
16
}
17
18
19
StatusCode
DerivationFramework::MuonJetDrTool::addBranches
(
const
EventContext& ctx)
const
{
20
21
// Retrieve main muonicle collection
22
SG::ReadHandle<xAOD::MuonContainer>
muons{
m_muonSGKey
, ctx};
23
if
(!muons.
isValid
()) {
24
ATH_MSG_FATAL
(
"Failed to retrieve container "
<<
m_muonSGKey
.fullKey());
25
return
StatusCode::FAILURE;
26
}
27
SG::ReadHandle<xAOD::JetContainer>
jets{
m_jetSGKey
, ctx};
28
if
(!jets.isValid()) {
29
ATH_MSG_FATAL
(
"Failed to retrieve "
<<
m_jetSGKey
.fullKey());
30
return
StatusCode::FAILURE;
31
}
32
SG::WriteDecorHandle<xAOD::MuonContainer, float>
decorator_jetdR{
m_jetDR_SGKey
, ctx};
33
34
for
(
auto
muon : *muons) {
35
double
new_jetdR = FLT_MAX;
36
bool
found{
false
};
37
for
(
auto
jet
: *jets) {
38
if
(
jet
->pt() <=
m_jetMinPt
)
continue
;
39
new_jetdR = std::min(
xAOD::P4Helpers::deltaR
(
jet
, muon), new_jetdR);
40
found =
true
;
41
}
42
decorator_jetdR(*muon) = found ? new_jetdR : -1;
43
}
44
return
StatusCode::SUCCESS;
45
}
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition
AthMsgStreamMacros.h:34
MuonJetDrTool.h
WriteDecorHandle.h
Handle class for adding a decoration to an object.
DerivationFramework::MuonJetDrTool::initialize
virtual StatusCode initialize() override final
Definition
MuonJetDrTool.cxx:11
DerivationFramework::MuonJetDrTool::addBranches
virtual StatusCode addBranches(const EventContext &ctx) const override final
Definition
MuonJetDrTool.cxx:19
DerivationFramework::MuonJetDrTool::m_jetMinPt
Gaudi::Property< float > m_jetMinPt
Definition
MuonJetDrTool.h:34
DerivationFramework::MuonJetDrTool::m_muonSGKey
SG::ReadHandleKey< xAOD::MuonContainer > m_muonSGKey
Definition
MuonJetDrTool.h:30
DerivationFramework::MuonJetDrTool::m_jetDR_SGKey
SG::WriteDecorHandleKey< xAOD::MuonContainer > m_jetDR_SGKey
Definition
MuonJetDrTool.h:32
DerivationFramework::MuonJetDrTool::m_jetSGKey
SG::ReadHandleKey< xAOD::JetContainer > m_jetSGKey
Definition
MuonJetDrTool.h:31
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
SG::WriteDecorHandle
Handle class for adding a decoration to an object.
Definition
StoreGate/StoreGate/WriteDecorHandle.h:100
jet
Definition
JetCalibTools_PlotJESFactors.cxx:23
xAOD::P4Helpers::deltaR
double deltaR(double rapidity1, double phi1, double rapidity2, double phi2)
from bare bare rapidity,phi
Definition
xAODP4Helpers.h:150
xAODP4Helpers.h
Generated on
for ATLAS Offline Software by
1.17.0