CMS 3D CMS Logo

selection.cc
Go to the documentation of this file.
1 
3 
4 #include <algorithm>
5 #include <stdexcept>
6 
7 namespace l1tVertexFinder {
8 
9  const l1t::Vertex& getPrimaryVertex(const std::vector<l1t::Vertex>& aVertexCollection) {
10  typedef std::vector<edm::Ptr<l1t::Vertex::Track_t>> Tracks_t;
11 
12  return getPrimaryVertex(aVertexCollection, [](const Tracks_t& tracks) -> float {
13  float sumPt = 0.0;
14  for (const auto& t : tracks)
15  sumPt += t->momentum().transverse();
16  return sumPt;
17  });
18  }
19 
21  const std::vector<l1t::Vertex>& aVertexCollection,
22  const std::function<float(const std::vector<edm::Ptr<l1t::Vertex::Track_t>>&)>& aFunction) {
23  if (aVertexCollection.empty())
24  throw std::invalid_argument("Cannot find primary vertex from empty vertex collection");
25  return *std::max_element(aVertexCollection.begin(),
26  aVertexCollection.end(),
27  [aFunction](const l1t::Vertex& v1, const l1t::Vertex& v2) -> bool {
28  return (aFunction(v1.tracks()) < aFunction(v2.tracks()));
29  });
30  }
31 
32 } // end namespace l1tVertexFinder
l1tVertexFinder
Definition: AlgoSettings.h:10
selection.h
l1t::Vertex
Definition: Vertex.h:15
TtFullHadEvtBuilder_cfi.sumPt
sumPt
Definition: TtFullHadEvtBuilder_cfi.py:38
tracks
const uint32_t *__restrict__ const HitContainer *__restrict__ TkSoA *__restrict__ tracks
Definition: CAHitNtupletGeneratorKernelsImpl.h:176
l1tVertexFinder::getPrimaryVertex
const l1t::Vertex & getPrimaryVertex(const std::vector< l1t::Vertex > &aVertexCollection)
Returns primary vertex based on default criterion (max sum pT from all constituent tracks); throws if...
Definition: selection.cc:9
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
l1t::Vertex::tracks
const std::vector< edm::Ptr< Track_t > > & tracks() const
Definition: Vertex.cc:16
edm::Ptr
Definition: AssociationVector.h:31
HiBiasedCentrality_cfi.function
function
Definition: HiBiasedCentrality_cfi.py:4
submitPVValidationJobs.t
string t
Definition: submitPVValidationJobs.py:644