ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Reconstruction
Jet
JetMomentTools
Root
JetOriginCorrectionTool.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
// JetOriginCorrectionTool.cxx
6
7
#include "
JetMomentTools/JetOriginCorrectionTool.h
"
8
9
#include "
JetUtils/JetOriginHelpers.h
"
10
#include "
AsgDataHandles/WriteDecorHandle.h
"
11
12
13
14
15
//**********************************************************************
16
17
JetOriginCorrectionTool::JetOriginCorrectionTool
(
const
std::string& myname)
18
:
asg
::
AsgTool
(myname) {
19
20
}
21
22
23
//**********************************************************************
24
25
StatusCode
JetOriginCorrectionTool::initialize
() {
26
ATH_CHECK
(
m_vertexContainer_key
.initialize());
27
ATH_CHECK
(
m_eventInfo_key
.initialize());
28
if
(
m_jetContainerName
.empty()) {
29
ATH_MSG_ERROR
(
"JetOriginCorrectionTool needs to have its input jet container configured!"
);
30
return
StatusCode::FAILURE;
31
}
32
33
m_scaleMomentumPtKey
=
m_jetContainerName
+
"."
+
m_scaleMomentumName
+
"_"
+
m_scaleMomentumPtKey
.key();
34
m_scaleMomentumPhiKey
=
m_jetContainerName
+
"."
+
m_scaleMomentumName
+
"_"
+
m_scaleMomentumPhiKey
.key();
35
m_scaleMomentumEtaKey
=
m_jetContainerName
+
"."
+
m_scaleMomentumName
+
"_"
+
m_scaleMomentumEtaKey
.key();
36
m_scaleMomentumMKey
=
m_jetContainerName
+
"."
+
m_scaleMomentumName
+
"_"
+
m_scaleMomentumMKey
.key();
37
m_originVertexKey
=
m_jetContainerName
+
"."
+
m_originVertexKey
.key();
38
39
ATH_CHECK
(
m_scaleMomentumPtKey
.initialize());
40
ATH_CHECK
(
m_scaleMomentumPhiKey
.initialize());
41
ATH_CHECK
(
m_scaleMomentumEtaKey
.initialize());
42
ATH_CHECK
(
m_scaleMomentumMKey
.initialize());
43
ATH_CHECK
(
m_originVertexKey
.initialize());
44
45
return
StatusCode::SUCCESS;
46
}
47
48
//**********************************************************************
49
50
StatusCode
JetOriginCorrectionTool::decorate
(
const
xAOD::JetContainer
& jetCont)
const
{
51
SG::WriteDecorHandle<xAOD::JetContainer, float>
scaleMomentumPtHandle(
m_scaleMomentumPtKey
);
52
SG::WriteDecorHandle<xAOD::JetContainer, float>
scaleMomentumPhiHandle(
m_scaleMomentumPhiKey
);
53
SG::WriteDecorHandle<xAOD::JetContainer, float>
scaleMomentumEtaHandle(
m_scaleMomentumEtaKey
);
54
SG::WriteDecorHandle<xAOD::JetContainer, float>
scaleMomentumMHandle(
m_scaleMomentumMKey
);
55
SG::WriteDecorHandle<xAOD::JetContainer, ElementLink<xAOD::VertexContainer>
> originVertexHandle(
m_originVertexKey
);
56
57
// static accessor for PV index access
58
static
const
SG::AuxElement::ConstAccessor<int> PVIndexAccessor(
"PVIndex"
);
59
60
61
62
// retrieve the VertexContainer. if fails, fill the jets with null vector
63
auto
handle =
SG::makeHandle
(
m_vertexContainer_key
);
64
if
(!handle.isValid()){
65
ATH_MSG_WARNING
(
"Invalid VertexContainer datahandle: "
66
<<
m_correctionName
67
<<
": filling jet with -1"
);
68
xAOD::JetFourMom_t
null;
69
for
(
const
xAOD::Jet
* j : jetCont) {
70
scaleMomentumPtHandle(*j) = -1;
71
scaleMomentumPhiHandle(*j) = -1;
72
scaleMomentumEtaHandle(*j) = -1;
73
scaleMomentumMHandle(*j) = -1;
74
}
75
return
StatusCode::SUCCESS;
76
}
77
78
const
auto
*vxContainer = handle.cptr();
79
80
81
// Retrieve EventInfo to check for a PV# specification != PV0
82
// No errors if EventInfo or PV index is not specified,
83
// as this is the standard scenario
84
// Warn if EventInfo is specified but cannot be retrieved
85
// Specifying the PV index is only for special cases
86
int
PVindex = 0;
87
//if (m_eventInfoName.key() != "") {
88
if
(!
m_eventInfo_key
.key().empty()) {
89
// retrieve the VertexContainer. if fails, fill the jets with null vector
90
91
auto
eInfo =
SG::makeHandle
(
m_eventInfo_key
);
92
if
(!eInfo.isValid()){
93
ATH_MSG_WARNING
(
"Invalid eventInfo datahandle. Defaulting to PV0 for "
94
<<
m_correctionName
);
95
}
else
if
(PVIndexAccessor.isAvailable(*(eInfo.cptr()))) {
96
PVindex = PVIndexAccessor(*(eInfo.cptr()));
97
ATH_MSG_DEBUG
(
"Found PVIndex value of "
<< PVindex <<
" for "
<<
m_correctionName
);
98
99
if
(PVindex < 0 ||
static_cast<
size_t
>
(PVindex) >= vxContainer->size()){
100
ATH_MSG_WARNING
(
"Specified PV index of "
101
<< PVindex <<
" is out of bounds. Filling jet with -1"
102
<<
m_correctionName
);
103
xAOD::JetFourMom_t
null;
104
for
(
const
xAOD::Jet
* j : jetCont) {
105
scaleMomentumPtHandle(*j) = -1;
106
scaleMomentumPhiHandle(*j) = -1;
107
scaleMomentumEtaHandle(*j) = -1;
108
scaleMomentumMHandle(*j) = -1;
109
}
110
return
StatusCode::SUCCESS;
111
}
112
113
}
114
}
115
116
// choose PV.
117
const
xAOD::Vertex
*vx = vxContainer->at(PVindex);
118
119
ATH_MSG_DEBUG
(
" correcting jets "
);
120
for
(
const
xAOD::Jet
*
jet
: jetCont){
121
ATH_MSG_DEBUG
(
" ----> jet "
<<
jet
);
122
ATH_MSG_DEBUG
(
" jet pT: "
<<
jet
->pt());
123
124
if
(!
m_onlyAssignPV
) {
125
xAOD::CaloCluster::State
state =
xAOD::CaloCluster::UNKNOWN
;
126
if
(
m_forceEMScale
) state =
xAOD::CaloCluster::UNCALIBRATED
;
127
xAOD::JetFourMom_t
fv =
jet::clusterOriginCorrection
(*
jet
,*vx,state);
128
ATH_MSG_DEBUG
(
" "
<<
m_correctionName
<<
" pT: "
<< fv.pt());
129
scaleMomentumPtHandle(*
jet
) = fv.pt();
130
scaleMomentumPhiHandle(*
jet
) = fv.phi();
131
scaleMomentumEtaHandle(*
jet
) = fv.eta();
132
scaleMomentumMHandle(*
jet
) = fv.M();
133
}
134
originVertexHandle(*
jet
) =
ElementLink<xAOD::VertexContainer>
(*vxContainer, vxContainer->at(PVindex)->index());
135
136
}
137
return
StatusCode::SUCCESS;
138
}
139
140
//**********************************************************************
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_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.
JetOriginCorrectionTool.h
JetOriginHelpers.h
Helpers to calculate corrected 4-vectors w.r.t to a given orign.
ElementLink
ElementLink implementation for ROOT usage.
Definition
A/AthLinks/ElementLink.h:40
JetOriginCorrectionTool::m_eventInfo_key
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfo_key
Definition
JetOriginCorrectionTool.h:59
JetOriginCorrectionTool::m_scaleMomentumPhiKey
SG::WriteDecorHandleKey< xAOD::JetContainer > m_scaleMomentumPhiKey
Definition
JetOriginCorrectionTool.h:63
JetOriginCorrectionTool::initialize
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
Definition
JetOriginCorrectionTool.cxx:25
JetOriginCorrectionTool::decorate
StatusCode decorate(const xAOD::JetContainer &jet) const override
Inherited method to modify a jet container.
Definition
JetOriginCorrectionTool.cxx:50
JetOriginCorrectionTool::m_vertexContainer_key
SG::ReadHandleKey< xAOD::VertexContainer > m_vertexContainer_key
Definition
JetOriginCorrectionTool.h:58
JetOriginCorrectionTool::m_scaleMomentumName
Gaudi::Property< std::string > m_scaleMomentumName
Definition
JetOriginCorrectionTool.h:61
JetOriginCorrectionTool::m_scaleMomentumPtKey
SG::WriteDecorHandleKey< xAOD::JetContainer > m_scaleMomentumPtKey
Definition
JetOriginCorrectionTool.h:62
JetOriginCorrectionTool::JetOriginCorrectionTool
JetOriginCorrectionTool(const std::string &myname)
Constructor from tool name.
Definition
JetOriginCorrectionTool.cxx:17
JetOriginCorrectionTool::m_scaleMomentumMKey
SG::WriteDecorHandleKey< xAOD::JetContainer > m_scaleMomentumMKey
Definition
JetOriginCorrectionTool.h:65
JetOriginCorrectionTool::m_correctionName
Gaudi::Property< std::string > m_correctionName
Definition
JetOriginCorrectionTool.h:51
JetOriginCorrectionTool::m_onlyAssignPV
Gaudi::Property< bool > m_onlyAssignPV
Definition
JetOriginCorrectionTool.h:53
JetOriginCorrectionTool::m_originVertexKey
SG::WriteDecorHandleKey< xAOD::JetContainer > m_originVertexKey
Definition
JetOriginCorrectionTool.h:66
JetOriginCorrectionTool::m_forceEMScale
Gaudi::Property< bool > m_forceEMScale
Definition
JetOriginCorrectionTool.h:54
JetOriginCorrectionTool::m_jetContainerName
Gaudi::Property< std::string > m_jetContainerName
Definition
JetOriginCorrectionTool.h:52
JetOriginCorrectionTool::m_scaleMomentumEtaKey
SG::WriteDecorHandleKey< xAOD::JetContainer > m_scaleMomentumEtaKey
Definition
JetOriginCorrectionTool.h:64
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::CaloCluster_v1::State
State
enum of possible signal states.
Definition
CaloCluster_v1.h:307
xAOD::CaloCluster_v1::UNKNOWN
@ UNKNOWN
Definition
CaloCluster_v1.h:308
xAOD::CaloCluster_v1::UNCALIBRATED
@ UNCALIBRATED
Definition
CaloCluster_v1.h:309
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition
ReadCondHandle.h:269
asg
Definition
DataHandleTestTool.h:28
jet
Definition
JetCalibTools_PlotJESFactors.cxx:23
jet::clusterOriginCorrection
xAOD::JetFourMom_t clusterOriginCorrection(const xAOD::Jet &jet, const xAOD::Vertex &vx)
returns 4-vector of the jet relative to the vertex
xAOD::Jet
Jet_v1 Jet
Definition of the current "jet version".
Definition
Event/xAOD/xAODJet/xAODJet/Jet.h:17
xAOD::Vertex
Vertex_v1 Vertex
Define the latest version of the vertex class.
Definition
Event/xAOD/xAODTracking/xAODTracking/Vertex.h:16
xAOD::JetContainer
JetContainer_v1 JetContainer
Definition of the current "jet container version".
Definition
JetContainer.h:17
xAOD::JetFourMom_t
ROOT::Math::LorentzVector< ROOT::Math::PtEtaPhiM4D< double > > JetFourMom_t
Base 4 Momentum type for Jet.
Definition
JetTypes.h:17
Generated on
for ATLAS Offline Software by
1.17.0