ATLAS Offline Software
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
ATH_MSG_INFO
(
"Running ChargedHadronSubtractionTool by-vertex: "
<<
m_byVertex
.value());
22
ATH_MSG_INFO
(
"Running ChargedHadronSubtractionTool using TTVA: "
<<
m_useTrackToVertexTool
.value());
23
24
ATH_CHECK
(
m_trkVtxAssoc_key
.
initialize
(
m_useTrackToVertexTool
&& !
m_ignoreVertex
));
25
ATH_CHECK
(
m_vertexContainer_key
.initialize(!
m_ignoreVertex
));
26
27
return
StatusCode::SUCCESS;
28
}
29
30
StatusCode
ChargedHadronSubtractionTool::process_impl
(
xAOD::IParticleContainer
*cont)
const
31
{
32
33
// Type-checking happens in the JetConstituentModifierBase class
34
// so it is safe just to static_cast
35
if
(
m_inputType
==
xAOD::Type::FlowElement
)
36
{
37
xAOD::FlowElementContainer
*feCont =
static_cast<
xAOD::FlowElementContainer
*
>
(cont);
38
39
// Check that these FlowElements are actually PFOs; nothing else is supported
40
if
(!feCont->
empty
() && !(feCont->
front
()->signalType() &
xAOD::FlowElement::PFlow
))
41
{
42
ATH_MSG_ERROR
(
"This tool correctly recieved a FlowElement, but it wasn't a PFO!"
43
<<
" Signal type was "
<< feCont->
front
()->signalType());
44
return
StatusCode::FAILURE;
45
}
46
47
return
!
m_byVertex
? matchToPrimaryVertex<xAOD::FlowElementContainer, xAOD::FlowElement>(*feCont) : matchByPrimaryVertex<xAOD::FlowElementContainer, xAOD::FlowElement>(*feCont);
48
}
49
xAOD::PFOContainer
*pfoCont =
static_cast<
xAOD::PFOContainer
*
>
(cont);
50
return
!
m_byVertex
? matchToPrimaryVertex<xAOD::PFOContainer, xAOD::PFO>(*pfoCont) : matchByPrimaryVertex<xAOD::PFOContainer, xAOD::PFO>(*pfoCont);
51
}
52
53
const
xAOD::Vertex
*
ChargedHadronSubtractionTool::getPrimaryVertex
()
const
54
{
55
// Retrieve Primary Vertices
56
auto
handle =
SG::makeHandle
(
m_vertexContainer_key
);
57
if
(!handle.isValid())
58
{
59
ATH_MSG_WARNING
(
" This event has no primary vertex container"
);
60
return
nullptr
;
61
}
62
63
const
xAOD::VertexContainer
*pvtxs = handle.cptr();
64
if
(pvtxs->
empty
())
65
{
66
ATH_MSG_WARNING
(
" Failed to retrieve valid primary vertex container"
);
67
return
nullptr
;
68
}
69
70
// Usually the 0th vertex is the primary one, but this is not always
71
// the case. So we will choose the first vertex of type PriVtx
72
for
(
const
auto
*theVertex : *pvtxs)
73
{
74
if
(theVertex->vertexType() ==
xAOD::VxType::PriVtx
)
75
{
76
return
theVertex;
77
}
// If we have a vertex of type primary vertex
78
}
// iterate over the vertices and check their type
79
80
// If we failed to find an appropriate vertex, return the dummy vertex
81
ATH_MSG_DEBUG
(
"Could not find a primary vertex in this event"
);
82
for
(
const
auto
*theVertex : *pvtxs)
83
{
84
if
(theVertex->vertexType() ==
xAOD::VxType::NoVtx
)
85
{
86
return
theVertex;
87
}
88
}
89
90
// If there is no primary vertex, then we cannot do PV matching.
91
ATH_MSG_WARNING
(
"Primary vertex container is empty"
);
92
return
nullptr
;
93
}
94
95
double
ChargedHadronSubtractionTool::calcAbsZ0SinTheta
(
const
xAOD::TrackParticle
&trk,
const
xAOD::Vertex
&vtx)
96
{
97
// vtz.z() provides z of that vertex w.r.t the center of the beamspot (z = 0).
98
// Thus we correct the track z0 to be w.r.t z = 0
99
const
float
z0
= trk.
z0
() + trk.
vz
() - vtx.
z
();
100
const
float
theta
= trk.
theta
();
101
return
std::abs(
z0
*
std::sin
(
theta
));
102
}
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition:
AthMsgStreamMacros.h:31
ChargedHadronSubtractionTool::ChargedHadronSubtractionTool
ChargedHadronSubtractionTool(const std::string &name)
Definition:
ChargedHadronSubtractionTool.cxx:9
xAOD::TrackParticle_v1::vz
float vz() const
The z origin for the parameters.
theta
Scalar theta() const
theta method
Definition:
AmgMatrixBasePlugin.h:75
xAOD::TrackParticle_v1::z0
float z0() const
Returns the parameter.
ChargedHadronSubtractionTool.h
xAOD::VxType::NoVtx
@ NoVtx
Dummy vertex. TrackParticle was not used in vertex fit.
Definition:
TrackingPrimitives.h:570
xAOD::FlowElement_v1::PFlow
@ PFlow
Definition:
FlowElement_v1.h:45
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition:
ReadCondHandle.h:270
ChargedHadronSubtractionTool::m_ignoreVertex
Gaudi::Property< bool > m_ignoreVertex
Definition:
ChargedHadronSubtractionTool.h:51
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition:
AthMsgStreamMacros.h:33
ChargedHadronSubtractionTool::m_vertexContainer_key
SG::ReadHandleKey< xAOD::VertexContainer > m_vertexContainer_key
Definition:
ChargedHadronSubtractionTool.h:57
ChargedHadronSubtractionTool::m_useTrackToVertexTool
Gaudi::Property< bool > m_useTrackToVertexTool
Definition:
ChargedHadronSubtractionTool.h:50
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition:
PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition:
AthMsgStreamMacros.h:29
xAOD::FlowElement
FlowElement_v1 FlowElement
Definition of the current "pfo version".
Definition:
FlowElement.h:16
xAOD::VxType::PriVtx
@ PriVtx
Primary vertex.
Definition:
TrackingPrimitives.h:571
DataVector::front
const T * front() const
Access the first element in the collection as an rvalue.
ATH_CHECK
#define ATH_CHECK
Definition:
AthCheckMacros.h:40
xAODType::ParticleFlow
@ ParticleFlow
The object is a particle-flow object.
Definition:
ObjectType.h:41
ChargedHadronSubtractionTool::getPrimaryVertex
const xAOD::Vertex * getPrimaryVertex() const
Definition:
ChargedHadronSubtractionTool.cxx:53
xAOD::Vertex_v1::z
float z() const
Returns the z position.
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition:
AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
TRT::Track::z0
@ z0
Definition:
InnerDetector/InDetCalibEvent/TRT_CalibData/TRT_CalibData/TrackInfo.h:63
DataVector
Derived DataVector<T>.
Definition:
DataVector.h:581
ChargedHadronSubtractionTool::m_trkVtxAssoc_key
SG::ReadHandleKey< jet::TrackVertexAssociation > m_trkVtxAssoc_key
Definition:
ChargedHadronSubtractionTool.h:58
name
std::string name
Definition:
Control/AthContainers/Root/debug.cxx:221
JetConstituentModifierBase
Definition:
JetConstituentModifierBase.h:22
ReadHandle.h
Handle class for reading from StoreGate.
ChargedHadronSubtractionTool::calcAbsZ0SinTheta
static double calcAbsZ0SinTheta(const xAOD::TrackParticle &trk, const xAOD::Vertex &vtx)
Definition:
ChargedHadronSubtractionTool.cxx:95
ChargedHadronSubtractionTool::process_impl
StatusCode process_impl(xAOD::IParticleContainer *cont) const
Definition:
ChargedHadronSubtractionTool.cxx:30
ChargedHadronSubtractionTool::initialize
StatusCode initialize()
Dummy implementation of the initialisation function.
Definition:
ChargedHadronSubtractionTool.cxx:13
JetConstituentModifierBase::m_inputType
unsigned int m_inputType
Definition:
JetConstituentModifierBase.h:60
xAOD::Vertex_v1
Class describing a Vertex.
Definition:
Vertex_v1.h:42
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition:
AthMsgStreamMacros.h:32
ChargedHadronSubtractionTool::m_byVertex
Gaudi::Property< bool > m_byVertex
Definition:
ChargedHadronSubtractionTool.h:53
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition:
TrackParticle_v1.h:43
drawFromPickle.sin
sin
Definition:
drawFromPickle.py:36
xAOD::TrackParticle_v1::theta
float theta() const
Returns the parameter, which has range 0 to .
DataVector::empty
bool empty() const noexcept
Returns true if the collection is empty.
Generated on Thu Nov 7 2024 21:11:53 for ATLAS Offline Software by
1.8.18