ATLAS Offline Software
Public Member Functions | Protected Attributes | List of all members
jet::TrackVertexAssociation Class Reference

Class to hold N-to-one aassociations between tracks and vertices. More...

#include <TrackVertexAssociation.h>

Collaboration diagram for jet::TrackVertexAssociation:

Public Member Functions

 TrackVertexAssociation (const xAOD::TrackParticleContainer *trkCont=0)
 
void associate (const xAOD::TrackParticle *trk, const xAOD::Vertex *vtx)
 
const xAOD::VertexassociatedVertex (const xAOD::TrackParticle *trk) const
 
std::vector< const xAOD::TrackParticle * > associatedTracks (const xAOD::Vertex *vtx) const
 

Protected Attributes

std::vector< const xAOD::Vertex * > m_vertex
 
const xAOD::TrackParticleContainerm_trackContainer
 

Detailed Description

Class to hold N-to-one aassociations between tracks and vertices.

It is assumed the track container is the one that directly holds the tracks, i.e. is not a view container.

Definition at line 23 of file TrackVertexAssociation.h.

Constructor & Destructor Documentation

◆ TrackVertexAssociation()

jet::TrackVertexAssociation::TrackVertexAssociation ( const xAOD::TrackParticleContainer trkCont = 0)

Definition at line 9 of file TrackVertexAssociation.cxx.

9  :
10  m_trackContainer(trkCont) {
11  // Check if this is a view container, in which case we need to use the size of the owning container.
12  size_t Ntracks = trkCont->size();
13  if(Ntracks>0 && trkCont->ownPolicy() != SG::OWN_ELEMENTS) {
14  Ntracks = trkCont->front()->container()->size_v();
15  }
16  m_vertex.resize(Ntracks, nullptr );
17  }

Member Function Documentation

◆ associate()

void jet::TrackVertexAssociation::associate ( const xAOD::TrackParticle trk,
const xAOD::Vertex vtx 
)

Definition at line 19 of file TrackVertexAssociation.cxx.

19  {
20  m_vertex[ trk->index() ] = vtx;
21  }

◆ associatedTracks()

std::vector< const xAOD::TrackParticle * > jet::TrackVertexAssociation::associatedTracks ( const xAOD::Vertex vtx) const

Definition at line 27 of file TrackVertexAssociation.cxx.

28  {
29  std::vector<const xAOD::TrackParticle*> tracks;
30  for (size_t iTrack = 0; iTrack < m_trackContainer->size(); ++iTrack)
31  if (associatedVertex(m_trackContainer->at(iTrack))->index() == vtx->index())
32  tracks.push_back(m_trackContainer->at(iTrack));
33 
34  return tracks;
35  }

◆ associatedVertex()

const xAOD::Vertex * jet::TrackVertexAssociation::associatedVertex ( const xAOD::TrackParticle trk) const

Definition at line 23 of file TrackVertexAssociation.cxx.

23  {
24  return m_vertex[trk->index()];
25  }

Member Data Documentation

◆ m_trackContainer

const xAOD::TrackParticleContainer* jet::TrackVertexAssociation::m_trackContainer
protected

Definition at line 42 of file TrackVertexAssociation.h.

◆ m_vertex

std::vector<const xAOD::Vertex*> jet::TrackVertexAssociation::m_vertex
protected

Definition at line 41 of file TrackVertexAssociation.h.


The documentation for this class was generated from the following files:
jet::TrackVertexAssociation::m_trackContainer
const xAOD::TrackParticleContainer * m_trackContainer
Definition: TrackVertexAssociation.h:42
SG::OWN_ELEMENTS
@ OWN_ELEMENTS
this data object owns its elements
Definition: OwnershipPolicy.h:17
DataVector::front
const T * front() const
Access the first element in the collection as an rvalue.
SG::AuxElement::index
size_t index() const
Return the index of this element within its container.
jet::TrackVertexAssociation::associatedVertex
const xAOD::Vertex * associatedVertex(const xAOD::TrackParticle *trk) const
Definition: TrackVertexAssociation.cxx:23
jet::TrackVertexAssociation::m_vertex
std::vector< const xAOD::Vertex * > m_vertex
Definition: TrackVertexAssociation.h:41
DataVector::ownPolicy
SG::OwnershipPolicy ownPolicy() const
Return the ownership policy setting for this container.
DataVector::at
const T * at(size_type n) const
Access an element, as an rvalue.
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.