ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Reconstruction
Jet
JetMomentTools
Root
JetWidthTool.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
// JetWidthTool.cxx
6
7
#include "
JetMomentTools/JetWidthTool.h
"
8
#include "
AsgDataHandles/WriteDecorHandle.h
"
9
#include "
xAODJet/JetConstituentVector.h
"
10
#include "
FourMomUtils/xAODP4Helpers.h
"
11
#include "
PFlowUtils/IWeightPFOTool.h
"
12
13
//**********************************************************************
14
15
JetWidthTool::JetWidthTool
(
const
std::string& myname)
16
:
asg
::
AsgTool
(myname)
17
{
18
}
19
20
//**********************************************************************
21
22
StatusCode
JetWidthTool::initialize
(){
23
24
if
(
m_jetContainerName
.empty()){
25
ATH_MSG_ERROR
(
"JetWidthTool needs to have its input jet container name configured!"
);
26
return
StatusCode::FAILURE;
27
}
28
29
// Prepend jet container name
30
m_widthKey
=
m_jetContainerName
+
"."
+
m_widthKey
.key();
31
m_widthPhiKey
=
m_jetContainerName
+
"."
+
m_widthPhiKey
.key();
32
33
ATH_CHECK
(
m_widthKey
.initialize());
34
ATH_CHECK
(
m_widthPhiKey
.initialize());
35
return
StatusCode::SUCCESS;
36
}
37
38
//**********************************************************************
39
40
StatusCode
JetWidthTool::decorate
(
const
xAOD::JetContainer
& jets)
const
{
41
42
SG::WriteDecorHandle<xAOD::JetContainer, float>
widthHandle(
m_widthKey
);
43
SG::WriteDecorHandle<xAOD::JetContainer, float>
widthPhiHandle(
m_widthPhiKey
);
44
45
for
(
const
xAOD::Jet
*
jet
: jets){
46
float
widthEta = 0, widthPhi = 0;
47
widthHandle(*
jet
) =
width
(*
jet
,widthEta,widthPhi);
48
widthPhiHandle(*
jet
) = widthPhi;
49
}
50
return
StatusCode::SUCCESS;
51
}
52
53
//**********************************************************************
54
55
float
JetWidthTool::width
(
const
xAOD::Jet
&
jet
,
float
& widthEta,
float
& widthPhi)
const
{
56
57
// Calculate the pt weighted width
58
const
float
jetEta =
jet
.eta();
59
const
float
jetPhi =
jet
.phi();
60
float
weightedWidth = 0;
61
float
weightedWidthEta = 0;
62
float
weightedWidthPhi = 0;
63
float
ptSum = 0;
64
65
const
xAOD::JetConstituentVector
constituents =
jet
.getConstituents();
66
for
(
const
auto
*
const
constituent : constituents) {
67
const
float
dR =
xAOD::P4Helpers::deltaR
(jetEta, jetPhi, constituent->eta(), constituent->phi());
68
const
float
dEta = std::abs(
jet
.eta()-constituent->eta());
69
const
float
dPhi = std::abs(
xAOD::P4Helpers::deltaPhi
(jetPhi, constituent->phi()));
70
const
float
pt = constituent->pt();
71
72
weightedWidth += dR * pt;
73
weightedWidthEta += dEta * pt;
74
weightedWidthPhi += dPhi * pt;
75
76
ptSum += pt;
77
}
78
79
widthEta = ptSum > 0 ? weightedWidthEta/ptSum : -1;
80
widthPhi = ptSum > 0 ? weightedWidthPhi/ptSum : -1;
81
82
return
ptSum > 0 ? weightedWidth/ptSum : -1;
83
}
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
WriteDecorHandle.h
Handle class for adding a decoration to an object.
IWeightPFOTool.h
JetConstituentVector.h
This file defines helper classes to deal with jet constituents.
JetWidthTool.h
width
const double width
Definition
TTileTripReader.cxx:24
JetWidthTool::decorate
virtual StatusCode decorate(const xAOD::JetContainer &jets) const override
Decorate a jet collection without otherwise modifying it.
Definition
JetWidthTool.cxx:40
JetWidthTool::m_widthPhiKey
SG::WriteDecorHandleKey< xAOD::JetContainer > m_widthPhiKey
Definition
JetWidthTool.h:48
JetWidthTool::initialize
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
Definition
JetWidthTool.cxx:22
JetWidthTool::width
float width(const xAOD::Jet &jet, float &widthEta, float &widthPhi) const
Definition
JetWidthTool.cxx:55
JetWidthTool::JetWidthTool
JetWidthTool(const std::string &myname)
Definition
JetWidthTool.cxx:15
JetWidthTool::m_jetContainerName
Gaudi::Property< std::string > m_jetContainerName
Definition
JetWidthTool.h:43
JetWidthTool::m_widthKey
SG::WriteDecorHandleKey< xAOD::JetContainer > m_widthKey
Definition
JetWidthTool.h:46
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
asg
Definition
DataHandleTestTool.h:28
jet
Definition
JetCalibTools_PlotJESFactors.cxx:23
xAOD::P4Helpers::deltaPhi
double deltaPhi(double phiA, double phiB)
delta Phi in range [-pi,pi[
Definition
xAODP4Helpers.h:69
xAOD::P4Helpers::deltaR
double deltaR(double rapidity1, double phi1, double rapidity2, double phi2)
from bare bare rapidity,phi
Definition
xAODP4Helpers.h:150
xAOD::Jet
Jet_v1 Jet
Definition of the current "jet version".
Definition
Event/xAOD/xAODJet/xAODJet/Jet.h:17
xAOD::JetContainer
JetContainer_v1 JetContainer
Definition of the current "jet container version".
Definition
JetContainer.h:17
xAODP4Helpers.h
Generated on
for ATLAS Offline Software by
1.17.0