ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Reconstruction
Jet
JetRecTools
Root
ChargedHadronSubtractionTool.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3
*/
4
#include "
JetRecTools/ChargedHadronSubtractionTool.h
"
5
#include "
AsgDataHandles/ReadHandle.h
"
6
7
using namespace
std
;
8
9
ChargedHadronSubtractionTool::ChargedHadronSubtractionTool
(
const
std::string &name) :
JetConstituentModifierBase
(name)
10
{
11
}
12
13
StatusCode
ChargedHadronSubtractionTool::initialize
()
14
{
15
if
(
m_inputType
!=
xAOD::Type::ParticleFlow
&&
m_inputType
!=
xAOD::Type::FlowElement
)
16
{
17
ATH_MSG_ERROR
(
"ChargedHadronSubtractionTool requires PFO inputs. It cannot operate on objects of type "
18
<<
m_inputType
);
19
return
StatusCode::FAILURE;
20
}
21
22
if
(
m_byVertex
){
23
ATH_MSG_INFO
(
"Running ChargedHadronSubtractionTool by-vertex: "
<<
m_byVertex
.value());
24
}
25
if
(
m_useTrackToVertexTool
){
26
ATH_MSG_INFO
(
"Running ChargedHadronSubtractionTool using TTVA: "
<<
m_useTrackToVertexTool
.value());
27
}
28
29
ATH_CHECK
(
m_trkVtxAssoc_key
.initialize(
m_useTrackToVertexTool
&& !
m_ignoreVertex
));
30
ATH_CHECK
(
m_vertexContainer_key
.initialize(!
m_ignoreVertex
));
31
32
return
StatusCode::SUCCESS;
33
}
34
35
StatusCode
ChargedHadronSubtractionTool::process_impl
(
xAOD::IParticleContainer
*cont)
const
36
{
37
38
// Type-checking happens in the JetConstituentModifierBase class
39
// so it is safe just to static_cast
40
if
(
m_inputType
==
xAOD::Type::FlowElement
)
41
{
42
xAOD::FlowElementContainer
*feCont =
static_cast<
xAOD::FlowElementContainer
*
>
(cont);
43
44
// Check that these FlowElements are actually PFOs; nothing else is supported
45
if
(!feCont->
empty
() && !(feCont->
front
()->
signalType
() &
xAOD::FlowElement::PFlow
))
46
{
47
ATH_MSG_ERROR
(
"This tool correctly recieved a FlowElement, but it wasn't a PFO!"
48
<<
" Signal type was "
<< feCont->
front
()->
signalType
());
49
return
StatusCode::FAILURE;
50
}
51
52
return
!
m_byVertex
?
matchToPrimaryVertex<xAOD::FlowElementContainer, xAOD::FlowElement>
(*feCont) :
matchByPrimaryVertex<xAOD::FlowElementContainer, xAOD::FlowElement>
(*feCont);
53
}
54
xAOD::PFOContainer
*pfoCont =
static_cast<
xAOD::PFOContainer
*
>
(cont);
55
return
!
m_byVertex
?
matchToPrimaryVertex<xAOD::PFOContainer, xAOD::PFO>
(*pfoCont) :
matchByPrimaryVertex<xAOD::PFOContainer, xAOD::PFO>
(*pfoCont);
56
}
57
58
const
xAOD::Vertex
*
ChargedHadronSubtractionTool::getPrimaryVertex
()
const
59
{
60
// Retrieve Primary Vertices
61
auto
handle =
SG::makeHandle
(
m_vertexContainer_key
);
62
if
(!handle.isValid())
63
{
64
ATH_MSG_WARNING
(
" This event has no primary vertex container"
);
65
return
nullptr
;
66
}
67
68
const
xAOD::VertexContainer
*pvtxs = handle.cptr();
69
if
(pvtxs->
empty
())
70
{
71
ATH_MSG_WARNING
(
" Failed to retrieve valid primary vertex container"
);
72
return
nullptr
;
73
}
74
75
// Usually the 0th vertex is the primary one, but this is not always
76
// the case. So we will choose the first vertex of type PriVtx
77
for
(
const
auto
*theVertex : *pvtxs)
78
{
79
if
(theVertex->vertexType() ==
xAOD::VxType::PriVtx
)
80
{
81
return
theVertex;
82
}
// If we have a vertex of type primary vertex
83
}
// iterate over the vertices and check their type
84
85
// If we failed to find an appropriate vertex, return the dummy vertex
86
ATH_MSG_DEBUG
(
"Could not find a primary vertex in this event"
);
87
for
(
const
auto
*theVertex : *pvtxs)
88
{
89
if
(theVertex->vertexType() ==
xAOD::VxType::NoVtx
)
90
{
91
return
theVertex;
92
}
93
}
94
95
// If there is no primary vertex, then we cannot do PV matching.
96
ATH_MSG_WARNING
(
"Primary vertex container is empty"
);
97
return
nullptr
;
98
}
99
100
double
ChargedHadronSubtractionTool::calcAbsZ0SinTheta
(
const
xAOD::TrackParticle
&trk,
const
xAOD::Vertex
&vtx)
101
{
102
// vtz.z() provides z of that vertex w.r.t the center of the beamspot (z = 0).
103
// Thus we correct the track z0 to be w.r.t z = 0
104
const
float
z0 = trk.
z0
() + trk.
vz
() - vtx.
z
();
105
const
float
theta
= trk.
theta
();
106
return
std::abs(z0 * std::sin(
theta
));
107
}
theta
Scalar theta() const
theta method
Definition
AmgMatrixBasePlugin.h:75
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_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition
AthMsgStreamMacros.h:32
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
ReadHandle.h
Handle class for reading from StoreGate.
ChargedHadronSubtractionTool.h
ChargedHadronSubtractionTool::ChargedHadronSubtractionTool
ChargedHadronSubtractionTool(const std::string &name)
Definition
ChargedHadronSubtractionTool.cxx:9
ChargedHadronSubtractionTool::initialize
StatusCode initialize()
Dummy implementation of the initialisation function.
Definition
ChargedHadronSubtractionTool.cxx:13
ChargedHadronSubtractionTool::calcAbsZ0SinTheta
static double calcAbsZ0SinTheta(const xAOD::TrackParticle &trk, const xAOD::Vertex &vtx)
Definition
ChargedHadronSubtractionTool.cxx:100
ChargedHadronSubtractionTool::m_trkVtxAssoc_key
SG::ReadHandleKey< jet::TrackVertexAssociation > m_trkVtxAssoc_key
Definition
ChargedHadronSubtractionTool.h:59
ChargedHadronSubtractionTool::getPrimaryVertex
const xAOD::Vertex * getPrimaryVertex() const
Definition
ChargedHadronSubtractionTool.cxx:58
ChargedHadronSubtractionTool::matchByPrimaryVertex
StatusCode matchByPrimaryVertex(T &) const
Definition
ChargedHadronSubtractionTool.h:185
ChargedHadronSubtractionTool::m_useTrackToVertexTool
Gaudi::Property< bool > m_useTrackToVertexTool
Definition
ChargedHadronSubtractionTool.h:51
ChargedHadronSubtractionTool::m_vertexContainer_key
SG::ReadHandleKey< xAOD::VertexContainer > m_vertexContainer_key
Definition
ChargedHadronSubtractionTool.h:58
ChargedHadronSubtractionTool::matchToPrimaryVertex
StatusCode matchToPrimaryVertex(T &) const
Definition
ChargedHadronSubtractionTool.h:66
ChargedHadronSubtractionTool::m_byVertex
Gaudi::Property< bool > m_byVertex
Definition
ChargedHadronSubtractionTool.h:54
ChargedHadronSubtractionTool::m_ignoreVertex
Gaudi::Property< bool > m_ignoreVertex
Definition
ChargedHadronSubtractionTool.h:52
ChargedHadronSubtractionTool::process_impl
StatusCode process_impl(xAOD::IParticleContainer *cont) const
Definition
ChargedHadronSubtractionTool.cxx:35
DataVector::front
const T * front() const
Access the first element in the collection as an rvalue.
DataVector::empty
bool empty() const noexcept
Returns true if the collection is empty.
JetConstituentModifierBase::JetConstituentModifierBase
JetConstituentModifierBase(const std::string &name)
Definition
JetConstituentModifierBase.cxx:14
JetConstituentModifierBase::m_inputType
unsigned int m_inputType
Definition
JetConstituentModifierBase.h:60
xAOD::FlowElement_v1::signalType
signal_t signalType() const
xAOD::FlowElement_v1::PFlow
@ PFlow
Definition
FlowElement_v1.h:45
xAOD::TrackParticle_v1::z0
float z0() const
Returns the parameter.
xAOD::TrackParticle_v1::theta
float theta() const
Returns the parameter, which has range 0 to .
xAOD::TrackParticle_v1::vz
float vz() const
The z origin for the parameters.
xAOD::Vertex_v1::z
float z() const
Returns the z position.
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition
ReadCondHandle.h:269
std
STL namespace.
xAODType::ParticleFlow
@ ParticleFlow
The object is a particle-flow object.
Definition
ObjectType.h:41
xAODType::FlowElement
@ FlowElement
The object is a track-calo-cluster.
Definition
ObjectType.h:52
xAOD::VxType::PriVtx
@ PriVtx
Primary vertex.
Definition
TrackingPrimitives.h:590
xAOD::VxType::NoVtx
@ NoVtx
Dummy vertex. TrackParticle was not used in vertex fit.
Definition
TrackingPrimitives.h:589
xAOD::FlowElementContainer
FlowElementContainer_v1 FlowElementContainer
Definition of the current "pfo container version".
Definition
FlowElementContainer.h:16
xAOD::PFOContainer
PFOContainer_v1 PFOContainer
Definition of the current "pfo container version".
Definition
PFOContainer.h:17
xAOD::TrackParticle
TrackParticle_v1 TrackParticle
Reference the current persistent version:
Definition
Event/xAOD/xAODTracking/xAODTracking/TrackParticle.h:13
xAOD::VertexContainer
VertexContainer_v1 VertexContainer
Definition of the current "Vertex container version".
Definition
VertexContainer.h:14
xAOD::Vertex
Vertex_v1 Vertex
Define the latest version of the vertex class.
Definition
Event/xAOD/xAODTracking/xAODTracking/Vertex.h:16
xAOD::IParticleContainer
DataVector< IParticle > IParticleContainer
Simple convenience declaration of IParticleContainer.
Definition
xAOD/xAODBase/xAODBase/IParticleContainer.h:32
Generated on
for ATLAS Offline Software by
1.17.0