ATLAS Offline Software
TIDAVertexBuilder.cxx
Go to the documentation of this file.
1 
11 
12 
13 std::vector<TIDA::Vertex> TIDAVertexBuilder::select(
14  const xAOD::VertexContainer* xAODVertices,
15  const std::vector<TIDA::Track*>* trackCollection,
16  bool useType0,
17  bool require_tracks ) {
18 
19  std::vector<TIDA::Vertex> vertices;
20 
21  xAOD::VertexContainer::const_iterator vtxitr = xAODVertices->begin();
22 
23  for ( ; vtxitr != xAODVertices->end(); ++vtxitr ) {
24 
25  if ( require_tracks && (*vtxitr)->nTrackParticles()==0 ) continue;
26 
27  if ( (*vtxitr)->vertexType()!=0 || useType0 ) {
28  TIDA::Vertex vertex = selectVertex( *vtxitr );
29 
30  if ( trackCollection ) {
31  std::vector< unsigned long > trackIds;
32 
33  const std::vector< ElementLink< xAOD::TrackParticleContainer > >& xAODtracks = (*vtxitr)->trackParticleLinks();
34 
35  for ( const auto& track : xAODtracks ) {
36  unsigned long id = 0;
37  if (track.isValid()) id = getTrackId( *track );
38  trackIds.push_back( id );
39  }
40 
41  vertex.selectTracks( *trackCollection, trackIds );
42  }
43 
44  vertices.push_back( vertex );
45  }
46  }
47 
48  return vertices;
49 }
50 
51 
52 std::vector<TIDA::Vertex> TIDAVertexBuilder::select(
55  const std::vector<TIDA::Track*>* trackCollection,
56  bool useType0,
57  bool require_tracks ) {
58 
59  std::vector<TIDA::Vertex> vertices;
60 
62 
63  for ( ; vtxitr!=enditr; ++vtxitr ) {
64 
65  if ( require_tracks && (*vtxitr)->nTrackParticles()==0 ) continue;
66 
67  if ( (*vtxitr)->vertexType()!=0 || useType0 ) {
68 
69  TIDA::Vertex vertex = selectVertex( *vtxitr );
70 
71  if( trackCollection ) {
72  std::vector< unsigned long > trackIds;
73 
74  const std::vector< ElementLink< xAOD::TrackParticleContainer > >& xAODtracks = (*vtxitr)->trackParticleLinks();
75 
76  for( const auto& track : xAODtracks ) {
77  unsigned long id = getTrackId( *track );
78  trackIds.push_back( id );
79  }
80 
81  vertex.selectTracks( *trackCollection, trackIds );
82  }
83 
84  vertices.push_back( vertex );
85  }
86  }
87 
88  return vertices;
89 }
90 
91 
93 
94  // convert xAOD::Vertex into TIDA::Vertex
95  TIDA::Vertex tidav( v->x(),
96  v->y(),
97  v->z(),
99  v->covariancePosition()(Trk::x,Trk::x),
100  v->covariancePosition()(Trk::y,Trk::y),
101  v->covariancePosition()(Trk::z,Trk::z),
102  v->nTrackParticles(),
104  v->chiSquared(),
105  v->numberDoF() );
106 
107  return tidav;
108 }
109 
110 
112  unsigned long id = (unsigned long)track;
113  return id;
114 }
Trk::y
@ y
Definition: ParamDefs.h:56
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
TIDAVertexBuilder::select
static std::vector< TIDA::Vertex > select(const xAOD::VertexContainer *xAODVertices, const std::vector< TIDA::Track * > *trackCollection=0, bool useType0=false, bool require_tracks=true)
Definition: TIDAVertexBuilder.cxx:13
Trk::z
@ z
global position (cartesian)
Definition: ParamDefs.h:57
TIDAVertexBuilder::getTrackId
static unsigned long getTrackId(const xAOD::TrackParticle *track)
Definition: TIDAVertexBuilder.cxx:111
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
TIDA::Vertex
Definition: TIDAVertex.h:23
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:227
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
TIDAVertexBuilder.h
python.PyAthena.v
v
Definition: PyAthena.py:154
Trk::vertex
@ vertex
Definition: MeasurementType.h:21
xAOD::Vertex_v1
Class describing a Vertex.
Definition: Vertex_v1.h:42
xAOD::track
@ track
Definition: TrackingPrimitives.h:512
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
Trk::x
@ x
Definition: ParamDefs.h:55
TIDAVertexBuilder::selectVertex
static TIDA::Vertex selectVertex(const xAOD::Vertex *v)
Definition: TIDAVertexBuilder.cxx:92
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.