ATLAS Offline Software
TrackParticlePerigeeAtPVAssociationTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
12 
13 #include "Particle/TrackParticle.h"
18 
19 namespace D3PD {
20 
28  (const std::string& type,
29  const std::string& name,
30  const IInterface* parent)
31  : Base (type, name, parent),
32  m_resolver ("TrackParticlePerigeeAtPVAssociationTool",
33  evtStore(),
34  m_vxCandidate)
35 {
36  declareProperty ("SGKey", m_vxCandidate = "PrimaryVertices,VxPrimaryCandidate");
37 }
38 
40 
42  CHECK( m_trackToVertexTool.retrieve() );
43 
44  return StatusCode::SUCCESS;
45 }
46 
47 
56 {
58  const VxContainer* vxContainer = 0;
59  StatusCode sc = evtStore()->retrieve(vxContainer, m_resolver.key());
60  if (sc.isFailure() || !vxContainer) {
61  REPORT_MESSAGE (MSG::WARNING) << "Could not retrieve primary vertex container: " << m_vxCandidate;
62  return 0;
63  }
64 
65  if(vxContainer->size()<1){
66  REPORT_MESSAGE (MSG::WARNING) << "No primary vertices reconstructed";
67  return 0;
68  }
69 
70  if (track.measuredPerigee()->covariance() && track.measuredPerigee()->covariance()->rows() == 0)
71  {
72  REPORT_MESSAGE (MSG::WARNING) << "Bad track; can't find perigee at vertex.";
73  return 0;
74  }
75 
76  const Trk::VxCandidate* vxI = PrimaryVertexSelector(*vxContainer);
77  if (!vxI){
78  REPORT_MESSAGE (MSG::WARNING) << "No primary vertices reconstructed";
79  return 0;
80  }
81 
82  return m_trackToVertexTool->perigeeAtVertex(Gaudi::Hive::currentContext(), track, vxI->recVertex().position()).release();
83 }
84 
85 
94 {
96  const xAOD::VertexContainer* vxContainer = 0;
97  StatusCode sc = evtStore()->retrieve(vxContainer, m_resolver.key());
98  if (sc.isFailure() || !vxContainer) {
99  REPORT_MESSAGE (MSG::WARNING) << "Could not retrieve primary vertex container: " << m_vxCandidate;
100  return 0;
101  }
102 
103  if(vxContainer->size()<1){
104  REPORT_MESSAGE (MSG::WARNING) << "No primary vertices reconstructed";
105  return 0;
106  }
107 
108  for (const xAOD::Vertex* vx : *vxContainer) {
109  if (vx->vertexType() == xAOD::VxType::PriVtx)
110  return m_trackToVertexTool->perigeeAtVertex(Gaudi::Hive::currentContext(), track, vx->position()).release();
111  }
112 
113  REPORT_MESSAGE (MSG::WARNING) << "No primary vertices reconstructed";
114  return 0;
115 }
116 
117 
128 {
129  if(p) delete p;
130 }
131 
132 } // namespace D3PD
Trk::VxCandidate::recVertex
const Trk::RecVertex & recVertex(void) const
Returns a reference to reconstructed vertex.
Definition: VxCandidate.h:132
TrackParameters.h
TrackParticle.h
D3PD::TrackParticlePerigeeAtPVAssociationTool::get
virtual const Trk::TrackParameters * get(const Rec::TrackParticle &p) override
Return the target object.
Definition: TrackParticlePerigeeAtPVAssociationTool.cxx:55
D3PD::TrackParticlePerigeeAtPVAssociationTool::TrackParticlePerigeeAtPVAssociationTool
TrackParticlePerigeeAtPVAssociationTool(const std::string &type, const std::string &name, const IInterface *parent)
Standard Gaudi tool constructor.
Definition: TrackParticlePerigeeAtPVAssociationTool.cxx:28
initialize
void initialize()
Definition: run_EoverP.cxx:894
D3PD::SGKeyResolver::initialize
StatusCode initialize(CLID clid, const std::string &typname)
Initialize.
Definition: SGKeyResolver.cxx:44
D3PD::SingleAssociationTool< Types< Rec::TrackParticle, xAOD::TrackParticle >, Trk::TrackParameters >
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
D3PD::TrackParticlePerigeeAtPVAssociationTool::initialize
virtual StatusCode initialize() override
Definition: TrackParticlePerigeeAtPVAssociationTool.cxx:39
DiTauMassTools::ignore
void ignore(T &&)
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:58
TrackParticlePerigeeAtPVAssociationTool.h
Associate from a TrackParticle to its perigee at PV.
D3PD
Block filler tool for noisy FEB information.
Definition: CaloCellDetailsFillerTool.cxx:29
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
D3PD::TrackParticlePerigeeAtPVAssociationTool::m_resolver
SGKeyResolver m_resolver
Definition: TrackParticlePerigeeAtPVAssociationTool.h:81
xAOD::VxType::PriVtx
@ PriVtx
Primary vertex.
Definition: TrackingPrimitives.h:571
test_pyathena.parent
parent
Definition: test_pyathena.py:15
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
Trk::ParametersBase
Definition: ParametersBase.h:55
Trk::Vertex::position
const Amg::Vector3D & position() const
return position of vertex
Definition: Vertex.cxx:72
VxContainer
Definition: VxContainer.h:28
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
D3PD::SGKeyResolver::key
std::string key()
Return the SG key we should use.
Definition: SGKeyResolver.cxx:55
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
D3PD::TrackParticlePerigeeAtPVAssociationTool::m_trackToVertexTool
ToolHandle< Reco::ITrackToVertex > m_trackToVertexTool
Definition: TrackParticlePerigeeAtPVAssociationTool.h:78
errorcheck.h
Helpers for checking error return status codes and reporting errors.
D3PD::TrackParticlePerigeeAtPVAssociationTool::m_vxCandidate
std::string m_vxCandidate
Definition: TrackParticlePerigeeAtPVAssociationTool.h:74
D3PD::TrackParticlePerigeeAtPVAssociationTool::releaseObject
virtual void releaseObject(const Trk::TrackParameters *p) override
Release an object retrieved from the association.
Definition: TrackParticlePerigeeAtPVAssociationTool.cxx:127
REPORT_MESSAGE
#define REPORT_MESSAGE(LVL)
Report a message.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:365
Rec::TrackParticle
Definition: Reconstruction/Particle/Particle/TrackParticle.h:47
VertexContainer.h
xAOD::Vertex_v1
Class describing a Vertex.
Definition: Vertex_v1.h:42
PrimaryVertexSelector
const Trk::VxCandidate * PrimaryVertexSelector(const VxContainer &vxContainer)
Simple Global Function to wrap around the VxCandidate container.
Definition: PrimaryVertexSelector.h:20
Trk::VxCandidate
Definition: VxCandidate.h:27
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
xAOD::track
@ track
Definition: TrackingPrimitives.h:512
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
PrimaryVertexSelector.h
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.