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
22 if(m_byVertex){
23 ATH_MSG_INFO("Running ChargedHadronSubtractionTool by-vertex: " << m_byVertex.value());
24 }
26 ATH_MSG_INFO("Running ChargedHadronSubtractionTool using TTVA: " << m_useTrackToVertexTool.value());
27 }
28
31
32 return StatusCode::SUCCESS;
33}
34
36{
37
38 // Type-checking happens in the JetConstituentModifierBase class
39 // so it is safe just to static_cast
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
53 }
54 xAOD::PFOContainer *pfoCont = static_cast<xAOD::PFOContainer *>(cont);
56}
57
59{
60 // Retrieve Primary Vertices
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
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}
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.