ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Reconstruction
Jet
JetMomentTools
Root
JetEMScaleMomTool.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include <functional>
6
#include "
JetMomentTools/JetEMScaleMomTool.h
"
7
8
#include "
AsgDataHandles/WriteDecorHandle.h
"
9
#include "
xAODJet/JetAccessorMap.h
"
10
11
struct
p4Decorator
{
12
13
SG::WriteDecorHandle<xAOD::JetContainer, float >
ptHandle
;
14
SG::WriteDecorHandle<xAOD::JetContainer, float >
etaHandle
;
15
SG::WriteDecorHandle<xAOD::JetContainer, float >
phiHandle
;
16
SG::WriteDecorHandle<xAOD::JetContainer, float >
massHandle
;
17
18
p4Decorator
(
const
SG::WriteDecorHandleKey<xAOD::JetContainer>
& ptKey,
19
const
SG::WriteDecorHandleKey<xAOD::JetContainer>
& etaKey,
20
const
SG::WriteDecorHandleKey<xAOD::JetContainer>
& phiKey,
21
const
SG::WriteDecorHandleKey<xAOD::JetContainer>
& massKey) :
22
ptHandle
(ptKey),
23
etaHandle
(etaKey),
24
phiHandle
(phiKey),
25
massHandle
(massKey)
26
{}
27
28
void
decorateP4
(
const
xAOD::Jet
&
jet
,
const
xAOD::JetFourMom_t
& p4) {
29
ptHandle
(
jet
) = p4.Pt();
30
etaHandle
(
jet
) = p4.Eta();
31
phiHandle
(
jet
) = p4.Phi();
32
massHandle
(
jet
) = p4.M();
33
}
34
35
};
36
37
xAOD::JetFourMom_t
getEMScaleP4
(
xAOD::JetConstituentVector
& constits) {
38
39
xAOD::JetFourMom_t
emscaleSum;
40
// just sum 4-vectors:
41
for
(
auto
iconstit=constits.
begin
(
xAOD::UncalibratedJetConstituent
); iconstit!=constits.
end
(
xAOD::UncalibratedJetConstituent
); ++iconstit) {
42
emscaleSum += **iconstit;
43
}
44
return
emscaleSum;
45
}
46
47
//**********************************************************************
48
49
JetEMScaleMomTool::JetEMScaleMomTool
(
const
std::string& name)
50
:
AsgTool
(name) { }
51
52
//**********************************************************************
53
54
StatusCode
JetEMScaleMomTool::initialize
() {
55
ATH_MSG_DEBUG
(
"Initializing JetEMScaleMomTool "
<< name());
56
57
if
(
m_jetContainerName
.empty()){
58
ATH_MSG_ERROR
(
"JetEMScaleMomTool needs to have its input jet container configured!"
);
59
return
StatusCode::FAILURE;
60
}
61
62
std::vector<std::reference_wrapper<SG::WriteDecorHandleKey<xAOD::JetContainer> > > keys = {
m_emscalePtKey
,
m_emscaleEtaKey
,
m_emscalePhiKey
,
m_emscaleMassKey
};
63
for
(
SG::WriteDecorHandleKey<xAOD::JetContainer>
& key : keys) {
64
key =
m_jetContainerName
+
"."
+ key.key();
65
ATH_CHECK
( key.initialize() );
66
}
67
68
ATH_MSG_DEBUG
(
"Operating on jets with "
<< (
m_useUncalibConstits
?
""
:
"un"
) <<
"calibrated constituents."
);
69
70
return
StatusCode::SUCCESS;
71
}
72
73
//**********************************************************************
74
75
StatusCode
JetEMScaleMomTool::decorate
(
const
xAOD::JetContainer
& jets)
const
{
76
ATH_MSG_VERBOSE
(
"Begin decorating jets."
);
77
p4Decorator
emscale_decor(
m_emscalePtKey
,
m_emscaleEtaKey
,
m_emscalePhiKey
,
m_emscaleMassKey
);
78
79
for
(
const
xAOD::Jet
*
jet
: jets) {
80
if
(
m_useUncalibConstits
) {
81
// Need to loop and sum the constituents
82
xAOD::JetConstituentVector
constits =
jet
->getConstituents();
83
if
(! constits.
isValid
() ) {
84
ATH_MSG_WARNING
(
"Jet constituent vector is invalid. Can't set EM scale momentum"
);
85
return
StatusCode::FAILURE;
86
}
87
xAOD::JetFourMom_t
em_p4 =
getEMScaleP4
(constits);
88
emscale_decor.
decorateP4
(*
jet
,em_p4);
89
}
else
{
90
// Simply add the constituent-level p4
91
xAOD::JetFourMom_t
constit_p4 =
jet
->jetP4(
xAOD::JetConstitScaleMomentum
);
92
emscale_decor.
decorateP4
(*
jet
,constit_p4);
93
}
94
95
}
96
97
return
StatusCode::SUCCESS;
98
}
99
100
101
//**********************************************************************
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition
AthMsgStreamMacros.h:28
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition
AthMsgStreamMacros.h:32
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
WriteDecorHandle.h
Handle class for adding a decoration to an object.
JetAccessorMap.h
getEMScaleP4
xAOD::JetFourMom_t getEMScaleP4(xAOD::JetConstituentVector &constits)
Definition
JetEMScaleMomTool.cxx:37
JetEMScaleMomTool.h
JetEMScaleMomTool::decorate
virtual StatusCode decorate(const xAOD::JetContainer &jets) const override
Decorate a jet collection without otherwise modifying it.
Definition
JetEMScaleMomTool.cxx:75
JetEMScaleMomTool::m_jetContainerName
Gaudi::Property< std::string > m_jetContainerName
Definition
JetEMScaleMomTool.h:29
JetEMScaleMomTool::JetEMScaleMomTool
JetEMScaleMomTool(const std::string &t)
Definition
JetEMScaleMomTool.cxx:49
JetEMScaleMomTool::m_emscalePtKey
SG::WriteDecorHandleKey< xAOD::JetContainer > m_emscalePtKey
Definition
JetEMScaleMomTool.h:34
JetEMScaleMomTool::m_emscalePhiKey
SG::WriteDecorHandleKey< xAOD::JetContainer > m_emscalePhiKey
Definition
JetEMScaleMomTool.h:36
JetEMScaleMomTool::m_useUncalibConstits
Gaudi::Property< bool > m_useUncalibConstits
Definition
JetEMScaleMomTool.h:32
JetEMScaleMomTool::m_emscaleMassKey
SG::WriteDecorHandleKey< xAOD::JetContainer > m_emscaleMassKey
Definition
JetEMScaleMomTool.h:37
JetEMScaleMomTool::initialize
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
Definition
JetEMScaleMomTool.cxx:54
JetEMScaleMomTool::m_emscaleEtaKey
SG::WriteDecorHandleKey< xAOD::JetContainer > m_emscaleEtaKey
Definition
JetEMScaleMomTool.h:35
SG::WriteDecorHandleKey
Property holding a SG store/key/clid/attr name from which a WriteDecorHandle is made.
Definition
StoreGate/StoreGate/WriteDecorHandleKey.h:90
SG::WriteDecorHandle
Handle class for adding a decoration to an object.
Definition
StoreGate/StoreGate/WriteDecorHandle.h:100
asg::AsgTool::AsgTool
AsgTool(const std::string &name)
Constructor specifying the tool instance's name.
Definition
AsgTool.cxx:58
xAOD::JetConstituentVector
A vector of jet constituents at the scale used during jet finding.
Definition
JetConstituentVector.h:117
xAOD::JetConstituentVector::begin
iterator begin() const
iterator on the first constituent
Definition
JetConstituentVector.cxx:103
xAOD::JetConstituentVector::isValid
bool isValid() const
Check if element links are valid.
Definition
JetConstituentVector.cxx:92
xAOD::JetConstituentVector::end
iterator end() const
iterator after the last constituent
Definition
JetConstituentVector.cxx:104
jet
Definition
JetCalibTools_PlotJESFactors.cxx:23
xAOD::Jet
Jet_v1 Jet
Definition of the current "jet version".
Definition
Event/xAOD/xAODJet/xAODJet/Jet.h:17
xAOD::JetConstitScaleMomentum
@ JetConstitScaleMomentum
Definition
JetTypes.h:29
xAOD::JetContainer
JetContainer_v1 JetContainer
Definition of the current "jet container version".
Definition
JetContainer.h:17
xAOD::UncalibratedJetConstituent
@ UncalibratedJetConstituent
Definition
JetTypes.h:21
xAOD::JetFourMom_t
ROOT::Math::LorentzVector< ROOT::Math::PtEtaPhiM4D< double > > JetFourMom_t
Base 4 Momentum type for Jet.
Definition
JetTypes.h:17
p4Decorator
Definition
JetEMScaleMomTool.cxx:11
p4Decorator::etaHandle
SG::WriteDecorHandle< xAOD::JetContainer, float > etaHandle
Definition
JetEMScaleMomTool.cxx:14
p4Decorator::massHandle
SG::WriteDecorHandle< xAOD::JetContainer, float > massHandle
Definition
JetEMScaleMomTool.cxx:16
p4Decorator::phiHandle
SG::WriteDecorHandle< xAOD::JetContainer, float > phiHandle
Definition
JetEMScaleMomTool.cxx:15
p4Decorator::p4Decorator
p4Decorator(const SG::WriteDecorHandleKey< xAOD::JetContainer > &ptKey, const SG::WriteDecorHandleKey< xAOD::JetContainer > &etaKey, const SG::WriteDecorHandleKey< xAOD::JetContainer > &phiKey, const SG::WriteDecorHandleKey< xAOD::JetContainer > &massKey)
Definition
JetEMScaleMomTool.cxx:18
p4Decorator::ptHandle
SG::WriteDecorHandle< xAOD::JetContainer, float > ptHandle
Definition
JetEMScaleMomTool.cxx:13
p4Decorator::decorateP4
void decorateP4(const xAOD::Jet &jet, const xAOD::JetFourMom_t &p4)
Definition
JetEMScaleMomTool.cxx:28
Generated on
for ATLAS Offline Software by
1.17.0