ATLAS Offline Software
Loading...
Searching...
No Matches
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
12
13namespace 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
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
113{
114 // reached the end
115 if (m_itrack >= m_xaod_vx->nTrackParticles()) return 0;
116
117 *m_weight = m_xaod_vx->trackWeight(m_itrack);
118 return m_xaod_vx->trackParticle(m_itrack++);
119}
120
121
122} // namespace D3PD
Helpers for checking error return status codes and reporting errors.
#define REPORT_MESSAGE(LVL)
Report a message.
#define CHECK(...)
Evaluate an expression and check for errors.
virtual StatusCode addVariable(const std::string &name, const std::type_info &ti, void *&ptr, const std::string &docstring="", const void *defval=0)
virtual const TO_T * next()=0
Return a pointer to the next element in the association.
MultiAssociationTool< Types< Trk::VxCandidate, xAOD::Vertex >, Types< Rec::TrackParticle, xAOD::TrackParticle > > Base
virtual StatusCode book() final
Book variables for this block.
virtual StatusCode reset(const Trk::VxCandidate &p) override
Start the iteration for a new association.
VertexTrackParticleAssociationTool(const std::string &type, const std::string &name, const IInterface *parent)
The VxTrackAtVertex is a common class for all present TrkVertexFitters The VxTrackAtVertex is designe...
Block filler tool for noisy FEB information.
TrackParticle_v1 TrackParticle
Reference the current persistent version:
Vertex_v1 Vertex
Define the latest version of the vertex class.