ATLAS Offline Software
VertexTrackParticleAssociationTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 #include <VxVertex/VxCandidate.h>
12 
13 namespace D3PD {
14 
15 
17  (const std::string& type,
18  const std::string& name,
19  const IInterface* parent)
20  : Base (type, name, parent),
21  m_aod_vx(0),
22  m_xaod_vx(0),
23  m_itrack(0)
24 {
25  book().ignore();
26 }
27 
28 
33 {
34  CHECK( addVariable ("weight", m_weight) );
35  return StatusCode::SUCCESS;
36 }
37 
38 
44 {
45  m_aod_vx = &p;
46  m_xaod_vx = 0;
47  m_itrack = 0;
48  return StatusCode::SUCCESS;
49 }
50 
51 
57 {
58  m_aod_vx = 0;
59  m_xaod_vx = &p;
60  m_itrack = 0;
61  return StatusCode::SUCCESS;
62 }
63 
64 
70 const Rec::TrackParticle*
72 {
73  const std::vector<Trk::VxTrackAtVertex*>* tracks = m_aod_vx->vxTrackAtVertex();
74 
75  // reached the end
76  if (m_itrack >= tracks->size()) return 0;
77 
78  const Trk::VxTrackAtVertex *track = (*tracks)[m_itrack++];
79 
80  const Trk::LinkToTrackParticleBase *link = dynamic_cast<const Trk::LinkToTrackParticleBase *>(track->trackOrParticleLink());
81  if(0 == link){ // it's not a link to TrackParticle
82  REPORT_MESSAGE (MSG::WARNING) << "Trying to associate a TrackParticle to a vertex"
83  << " while the vertex was not fitted using TrackParticles";
84  return 0;
85  }
86 
87  const Trk::TrackParticleBase *particle_base = **link;
88  if(0 == particle_base){
89  REPORT_MESSAGE (MSG::WARNING) << "link from VxCandidate to TrackParticle is broken";
90  return 0;
91  }
92 
93  const Rec::TrackParticle* particle = dynamic_cast<const Rec::TrackParticle*>(particle_base);
94 
95  if(0 == particle){
96  REPORT_MESSAGE (MSG::WARNING) << "dynamic cast from Trk::TrackParticleBase to Rec::TrackPArticle failed";
97  return 0;
98  }
99 
100  *m_weight = track->vtxCompatibility();
101 
102  return particle;
103 }
104 
105 
111 const xAOD::TrackParticle*
113 {
114  // reached the end
115  if (m_itrack >= m_xaod_vx->nTrackParticles()) return 0;
116 
118  return m_xaod_vx->trackParticle(m_itrack++);
119 }
120 
121 
122 } // namespace D3PD
Trk::ParticleSwitcher::particle
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses
Definition: ParticleHypothesis.h:76
xAOD::Vertex_v1::nTrackParticles
size_t nTrackParticles() const
Get the number of tracks associated with this vertex.
Definition: Vertex_v1.cxx:270
Trk::VxTrackAtVertex
The VxTrackAtVertex is a common class for all present TrkVertexFitters The VxTrackAtVertex is designe...
Definition: VxTrackAtVertex.h:77
TrackParticle.h
D3PD::VertexTrackParticleAssociationTool::book
virtual StatusCode book() final
Book variables for this block.
Definition: VertexTrackParticleAssociationTool.cxx:32
D3PD::MultiAssociationTool< Types< Trk::VxCandidate, xAOD::Vertex >, Types< Rec::TrackParticle, xAOD::TrackParticle > >
D3PD::AddVariable::addVariable
virtual StatusCode addVariable(const std::string &name, const std::type_info &ti, void *&ptr, const std::string &docstring="", const void *defval=0)
Add a variable to the tuple.
Definition: AddVariable.cxx:85
D3PD::VertexTrackParticleAssociationTool::m_itrack
size_t m_itrack
Definition: VertexTrackParticleAssociationTool.h:79
D3PD::MultiAssociationToolTo< Types< Rec::TrackParticle, xAOD::TrackParticle > >::next
virtual const Types< Rec::TrackParticle, xAOD::TrackParticle > * next()=0
Return a pointer to the next element in the association.
Trk::TrackParticleBase
Definition: TrackParticleBase.h:41
D3PD::VertexTrackParticleAssociationTool::VertexTrackParticleAssociationTool
VertexTrackParticleAssociationTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: VertexTrackParticleAssociationTool.cxx:17
D3PD
Block filler tool for noisy FEB information.
Definition: CaloCellDetailsFillerTool.cxx:29
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
Trk::VxCandidate::vxTrackAtVertex
std::vector< Trk::VxTrackAtVertex * > * vxTrackAtVertex(void)
Unconst pointer to the vector of tracks Required by some of the vertex fitters.
Definition: VxCandidate.h:144
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
test_pyathena.parent
parent
Definition: test_pyathena.py:15
VxTrackAtVertex.h
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
D3PD::VertexTrackParticleAssociationTool::reset
virtual StatusCode reset(const Trk::VxCandidate &p) override
Start the iteration for a new association.
Definition: VertexTrackParticleAssociationTool.cxx:43
xAOD::Vertex_v1::trackParticle
const TrackParticle * trackParticle(size_t i) const
Get the pointer to a given track that was used in vertex reco.
Definition: Vertex_v1.cxx:249
D3PD::VertexTrackParticleAssociationTool::m_xaod_vx
const xAOD::Vertex * m_xaod_vx
Definition: VertexTrackParticleAssociationTool.h:78
LinkToTrackParticleBase.h
Trk::LinkToTrackParticleBase
Definition: LinkToTrackParticleBase.h:17
VxCandidate.h
D3PD::VertexTrackParticleAssociationTool::m_aod_vx
const Trk::VxCandidate * m_aod_vx
Definition: VertexTrackParticleAssociationTool.h:77
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
errorcheck.h
Helpers for checking error return status codes and reporting errors.
xAOD::Vertex_v1::trackWeight
float trackWeight(size_t i) const
Get the weight of a given track in the vertex reconstruction.
Definition: Vertex_v1.cxx:262
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
xAOD::Vertex_v1
Class describing a Vertex.
Definition: Vertex_v1.h:42
Trk::VxCandidate
Definition: VxCandidate.h:27
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
D3PD::VertexTrackParticleAssociationTool::m_weight
float * m_weight
Variable: Track weight.
Definition: VertexTrackParticleAssociationTool.h:75
xAOD::track
@ track
Definition: TrackingPrimitives.h:512
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
VertexTrackParticleAssociationTool.h