CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
VertexFinder.h
Go to the documentation of this file.
1 #ifndef __L1Trigger_VertexFinder_VertexFinder_h__
2 #define __L1Trigger_VertexFinder_VertexFinder_h__
3 
11 
12 #include <algorithm>
13 #include <iterator>
14 #include <vector>
15 
16 namespace l1tVertexFinder {
17 
18  typedef std::vector<L1Track> FitTrackCollection;
19  typedef std::vector<RecoVertex<>> RecoVertexCollection;
20 
21  class VertexFinder {
22  public:
26  settings_ = &settings;
27  }
29 
31  struct SortTracksByZ0 {
32  inline bool operator()(const L1Track track0, const L1Track track1) { return (track0.z0() < track1.z0()); }
33  };
34 
35  struct SortTracksByPt {
36  inline bool operator()(const L1Track track0, const L1Track track1) {
37  return (std::abs(track0.pt()) > std::abs(track1.pt()));
38  }
39  };
40 
42 
44  unsigned int IterationsPerTrack() const { return double(iterations_) / double(fitTracks_.size()); }
46  unsigned int numInputTracks() const { return fitTracks_.size(); }
48  unsigned int NumIterations() const { return iterations_; }
50  unsigned int numVertices() const { return vertices_.size(); }
53  if (pv_index_ < vertices_.size())
54  return vertices_[pv_index_];
55  else {
56  edm::LogWarning("VertexFinder") << "PrimaryVertex::No Primary Vertex has been found.";
57  return RecoVertex<>();
58  }
59  }
61  unsigned int primaryVertexId() const { return pv_index_; }
63  const std::vector<RecoVertex<>>& vertices() const { return vertices_; }
65  const FitTrackCollection& fitTracks() const { return fitTracks_; }
66 
68  void findPrimaryVertex();
70  void associatePrimaryVertex(double trueZ0);
72  void GapClustering();
74  float maxDistance(RecoVertex<> cluster0, RecoVertex<> cluster1);
76  float minDistance(RecoVertex<> cluster0, RecoVertex<> cluster1);
78  float meanDistance(RecoVertex<> cluster0, RecoVertex<> cluster1);
80  float centralDistance(RecoVertex<> cluster0, RecoVertex<> cluster1);
88  void fastHisto(const TrackerTopology* tTopo);
91  std::sort(vertices_.begin(), vertices_.end(), [](const RecoVertex<>& vertex0, const RecoVertex<>& vertex1) {
92  return (vertex0.pt() > vertex1.pt());
93  });
94  }
97  std::sort(vertices_.begin(), vertices_.end(), [](const RecoVertex<>& vertex0, const RecoVertex<>& vertex1) {
98  return (vertex0.z0() < vertex1.z0());
99  });
100  }
102  unsigned int numIterations() const { return iterations_; }
104  unsigned int iterationsPerTrack() const { return double(iterations_) / double(fitTracks_.size()); }
105 
106  template <typename ForwardIterator, typename T>
107  void strided_iota(ForwardIterator first, ForwardIterator last, T value, T stride) {
108  while (first != last) {
109  *first++ = value;
110  value += stride;
111  }
112  }
113 
115 
121  float CentralDistance(RecoVertex<> cluster0, RecoVertex<> cluster1);
124  const std::vector<float>& bin_centers,
125  const std::vector<unsigned int>& counts);
127  void DBSCAN();
131  void FastHisto(const TrackerTopology* tTopo);
133  void HPV();
135  void Kmeans();
137  float MaxDistance(RecoVertex<> cluster0, RecoVertex<> cluster1);
139  float MinDistance(RecoVertex<> cluster0, RecoVertex<> cluster1);
141  float MeanDistance(RecoVertex<> cluster0, RecoVertex<> cluster1);
143  void PVR();
144 
145  private:
147  std::vector<RecoVertex<>> vertices_;
148  unsigned int numMatchedVertices_;
150  unsigned int pv_index_;
151  unsigned int iterations_;
152  };
153 
154 } // end namespace l1tVertexFinder
155 
156 #endif
bool operator()(const L1Track track0, const L1Track track1)
Definition: VertexFinder.h:32
RecoVertex primaryVertex() const
Reconstructed Primary Vertex.
Definition: VertexFinder.h:52
FitTrackCollection fitTracks_
Definition: VertexFinder.h:149
void fastHistoLooseAssociation()
High pT Vertex Algorithm.
const std::vector< RecoVertex<> > & vertices() const
Returns the z positions of the reconstructed primary vertices.
Definition: VertexFinder.h:63
float maxDistance(RecoVertex<> cluster0, RecoVertex<> cluster1)
Find maximum distance in two clusters of tracks.
Definition: VertexFinder.cc:78
void GapClustering()
Gap Clustering Algorithm.
Definition: VertexFinder.cc:60
float CentralDistance(RecoVertex<> cluster0, RecoVertex<> cluster1)
Find distance between centres of two clusters.
float meanDistance(RecoVertex<> cluster0, RecoVertex<> cluster1)
Find average distance in two clusters of tracks.
bool operator()(const L1Track track0, const L1Track track1)
Definition: VertexFinder.h:36
unsigned int numInputTracks() const
Storage for tracks out of the L1 Track finder.
Definition: VertexFinder.h:46
void FastHistoLooseAssociation()
TDR histogramming algorithmn.
void AdaptiveVertexReconstruction()
Vertexing algorithms.
std::vector< L1Track > FitTrackCollection
Definition: VertexFinder.h:18
float centralDistance(RecoVertex<> cluster0, RecoVertex<> cluster1)
Find distance between centres of two clusters.
unsigned int numVertices() const
Number of reconstructed vertices.
Definition: VertexFinder.h:50
void FastHisto(const TrackerTopology *tTopo)
Histogramming algorithm.
void SortVerticesInZ0()
Sort vertices in z.
Definition: VertexFinder.h:96
void agglomerativeHierarchicalClustering()
Simple Merge Algorithm.
float pt() const
Definition: L1Track.h:24
void adaptiveVertexReconstruction()
Adaptive Vertex Reconstruction algorithm.
void findPrimaryVertex()
Find the primary vertex.
unsigned int primaryVertexId() const
Reconstructed Primary Vertex Id.
Definition: VertexFinder.h:61
void fastHisto(const TrackerTopology *tTopo)
Histogramming algorithm.
void AgglomerativeHierarchicalClustering()
Simple Merge Algorithm.
unsigned int numIterations() const
Number of iterations.
Definition: VertexFinder.h:102
Simple wrapper class for TTTrack.
Definition: L1Track.h:17
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
VertexFinder(FitTrackCollection &fitTracks, const AlgoSettings &settings)
Constructor and destructor.
Definition: VertexFinder.h:24
const FitTrackCollection & fitTracks() const
Storage for tracks out of the L1 Track finder.
Definition: VertexFinder.h:65
double z0() const
Vertex z0 position [cm].
Definition: RecoVertex.h:73
double pt() const
Sum of fitted tracks transverse momentum [GeV].
Definition: RecoVertex.h:55
float minDistance(RecoVertex<> cluster0, RecoVertex<> cluster1)
Find minimum distance in two clusters of tracks.
Definition: VertexFinder.cc:91
float MeanDistance(RecoVertex<> cluster0, RecoVertex<> cluster1)
Find average distance in two clusters of tracks.
unsigned int NumIterations() const
Number of iterations.
Definition: VertexFinder.h:48
void PVR()
Principal Vertex Reconstructor algorithm.
void strided_iota(ForwardIterator first, ForwardIterator last, T value, T stride)
Definition: VertexFinder.h:107
const AlgoSettings * settings_
Definition: VertexFinder.h:146
void SortVerticesInPt()
Sort vertices in pT.
Definition: VertexFinder.h:90
void HPV()
High pT Vertex Algorithm.
std::vector< RecoVertex<> > RecoVertexCollection
Definition: VertexFinder.h:19
std::vector< RecoVertex<> > vertices_
Definition: VertexFinder.h:147
float z0() const
Definition: L1Track.h:25
unsigned int iterationsPerTrack() const
Number of iterations.
Definition: VertexFinder.h:104
void Kmeans()
Kmeans Algorithm.
void associatePrimaryVertex(double trueZ0)
Associate the primary vertex with the real one.
tuple last
Definition: dqmdumpme.py:56
Log< level::Warning, false > LogWarning
long double T
void DBSCAN()
DBSCAN algorithm.
float MaxDistance(RecoVertex<> cluster0, RecoVertex<> cluster1)
Find maximum distance in two clusters of tracks.
void computeAndSetVertexParameters(RecoVertex<> &vertex, const std::vector< float > &bin_centers, const std::vector< unsigned int > &counts)
Compute the vertex parameters.
Definition: VertexFinder.cc:7
unsigned int IterationsPerTrack() const
Accessors.
Definition: VertexFinder.h:44
float MinDistance(RecoVertex<> cluster0, RecoVertex<> cluster1)
Find minimum distance in two clusters of tracks.