ATLAS Offline Software
Loading...
Searching...
No Matches
ChargedHadronSubtractionTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3*/
6
7using namespace std;
8
12
14{
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
26
27 return StatusCode::SUCCESS;
28}
29
31{
32
33 // Type-checking happens in the JetConstituentModifierBase class
34 // so it is safe just to static_cast
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
48 }
49 xAOD::PFOContainer *pfoCont = static_cast<xAOD::PFOContainer *>(cont);
51}
52
54{
55 // Retrieve Primary Vertices
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
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}
Scalar theta() const
theta method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
Handle class for reading from StoreGate.
ChargedHadronSubtractionTool(const std::string &name)
StatusCode initialize()
Dummy implementation of the initialisation function.
static double calcAbsZ0SinTheta(const xAOD::TrackParticle &trk, const xAOD::Vertex &vtx)
SG::ReadHandleKey< jet::TrackVertexAssociation > m_trkVtxAssoc_key
const xAOD::Vertex * getPrimaryVertex() const
Gaudi::Property< bool > m_useTrackToVertexTool
SG::ReadHandleKey< xAOD::VertexContainer > m_vertexContainer_key
StatusCode process_impl(xAOD::IParticleContainer *cont) const
const T * front() const
Access the first element in the collection as an rvalue.
bool empty() const noexcept
Returns true if the collection is empty.
JetConstituentModifierBase(const std::string &name)
signal_t signalType() const
float z0() const
Returns the parameter.
float theta() const
Returns the parameter, which has range 0 to .
float vz() const
The z origin for the parameters.
float z() const
Returns the z position.
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
STL namespace.
@ ParticleFlow
The object is a particle-flow object.
Definition ObjectType.h:41
@ FlowElement
The object is a track-calo-cluster.
Definition ObjectType.h:52
@ PriVtx
Primary vertex.
@ NoVtx
Dummy vertex. TrackParticle was not used in vertex fit.
FlowElementContainer_v1 FlowElementContainer
Definition of the current "pfo container version".
PFOContainer_v1 PFOContainer
Definition of the current "pfo container version".
TrackParticle_v1 TrackParticle
Reference the current persistent version:
VertexContainer_v1 VertexContainer
Definition of the current "Vertex container version".
Vertex_v1 Vertex
Define the latest version of the vertex class.
DataVector< IParticle > IParticleContainer
Simple convenience declaration of IParticleContainer.