ATLAS Offline Software
PrimaryVertexSelector.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 // PrimaryVertexSelector, (c) ATLAS Detector software
8 
9 #ifndef TRKEVENTUTILS_PRIMARYVERTEXSELECTOR_H
10 #define TRKEVENTUTILS_PRIMARYVERTEXSELECTOR_H
11 
12 //Trk
13 #include "VxVertex/VxContainer.h"
14 #include "VxVertex/VxCandidate.h"
15 
20 inline const Trk::VxCandidate* PrimaryVertexSelector(const VxContainer& vxContainer){
21  // the return vertex
22  const Trk::VxCandidate* primaryVxCandidate = 0;
23  // simple loop through and get the primary vertex
24  VxContainer::const_iterator vxIter = vxContainer.begin();
25  VxContainer::const_iterator vxIterEnd = vxContainer.end();
26  for ( size_t ivtx = 0; vxIter != vxIterEnd; ++vxIter, ++ivtx ){
27  // the first and only primary vertex candidate is picked
28  if ( (*vxIter)->vertexType() == Trk::PriVtx){
29  primaryVxCandidate = (*vxIter);
30  break;
31  }
32  }
33  // return what you have - users need to check
34  return primaryVxCandidate;
35 }
36 
37 #endif
38 
39 
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
VxContainer.h
VxContainer
Definition: VxContainer.h:28
VxCandidate.h
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
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
Trk::PriVtx
@ PriVtx
Primary Vertex.
Definition: VertexType.h:27
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.