CMS 3D CMS Logo

VertexFinder.h
Go to the documentation of this file.
1 #ifndef __L1Trigger_VertexFinder_VertexFinder_h__
2 #define __L1Trigger_VertexFinder_VertexFinder_h__
3 
12 
13 #include <algorithm>
14 #include <cmath>
15 #include <iterator>
16 #include <vector>
17 
18 namespace l1tVertexFinder {
19 
20  // Returns the number of bits needed to represent and integer decimal
21  static constexpr unsigned BitsToRepresent(unsigned x) { return x < 2 ? 1 : 1 + BitsToRepresent(x >> 1); }
22 
23  typedef std::vector<L1Track> FitTrackCollection;
24  typedef std::vector<RecoVertex<>> RecoVertexCollection;
25 
26  class VertexFinder {
27  public:
31  settings_ = &settings;
32  }
34 
36  struct SortTracksByZ0 {
37  inline bool operator()(const L1Track track0, const L1Track track1) { return (track0.z0() < track1.z0()); }
38  };
39 
40  struct SortTracksByPt {
41  inline bool operator()(const L1Track track0, const L1Track track1) {
42  return (std::abs(track0.pt()) > std::abs(track1.pt()));
43  }
44  };
45 
47 
49  const FitTrackCollection& fitTracks() const { return fitTracks_; }
51  unsigned int iterationsPerTrack() const { return double(iterations_) / double(fitTracks_.size()); }
53  unsigned int numInputTracks() const { return fitTracks_.size(); }
55  unsigned int numIterations() const { return iterations_; }
57  unsigned int numVertices() const { return vertices_.size(); }
59  unsigned int numVerticesEmulation() const { return verticesEmulation_.size(); }
61  template <typename T>
62  T PrimaryVertex() const {
64  return vertices_[pv_index_];
65  else if ((settings_->vx_precision() == Precision::Emulation) && (pv_index_ < vertices_.size()))
67  else {
68  edm::LogWarning("VertexFinder") << "PrimaryVertex::No primary vertex has been found.";
69  return RecoVertex<>();
70  }
71  }
73  unsigned int primaryVertexId() const { return pv_index_; }
75  const std::vector<RecoVertex<>>& vertices() const { return vertices_; }
78 
80  void findPrimaryVertex();
82  void associatePrimaryVertex(double trueZ0);
84  void GapClustering();
86  float maxDistance(RecoVertex<> cluster0, RecoVertex<> cluster1);
88  float minDistance(RecoVertex<> cluster0, RecoVertex<> cluster1);
90  float meanDistance(RecoVertex<> cluster0, RecoVertex<> cluster1);
92  float centralDistance(RecoVertex<> cluster0, RecoVertex<> cluster1);
100  void fastHisto(const TrackerTopology* tTopo);
102  void fastHistoEmulation();
103 
105  void sortVerticesInPt();
107  void sortVerticesInZ0();
108 
110  template <class data_type, typename stream_type = std::ostream>
111  void printHistogram(stream_type& stream,
112  std::vector<data_type> data,
113  int width = 80,
114  int minimum = 0,
115  int maximum = -1,
116  std::string title = "",
117  std::string color = "");
118 
119  template <typename ForwardIterator, typename T>
120  void strided_iota(ForwardIterator first, ForwardIterator last, T value, T stride) {
121  while (first != last) {
122  *first++ = value;
123  value += stride;
124  }
125  }
126 
128 
131  const std::vector<float>& bin_centers,
132  const std::vector<unsigned int>& counts);
134  void DBSCAN();
136  void HPV();
138  void Kmeans();
140  void PVR();
141 
142  private:
146  unsigned int numMatchedVertices_;
148  unsigned int pv_index_;
149  unsigned int iterations_;
150  };
151 
152 } // end namespace l1tVertexFinder
153 
154 #endif
bool operator()(const L1Track track0, const L1Track track1)
Definition: VertexFinder.h:37
const FitTrackCollection & fitTracks() const
Accessors.
Definition: VertexFinder.h:49
FitTrackCollection fitTracks_
Definition: VertexFinder.h:147
void fastHistoLooseAssociation()
High pT Vertex Algorithm.
float maxDistance(RecoVertex<> cluster0, RecoVertex<> cluster1)
Find maximum distance in two clusters of tracks.
Definition: VertexFinder.cc:83
void GapClustering()
Gap Clustering Algorithm.
Definition: VertexFinder.cc:65
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:41
float pt() const
Definition: L1Track.h:24
std::vector< L1Track > FitTrackCollection
Definition: VertexFinder.h:23
float centralDistance(RecoVertex<> cluster0, RecoVertex<> cluster1)
Find distance between centres of two clusters.
unsigned int numVerticesEmulation() const
Number of emulation vertices.
Definition: VertexFinder.h:59
uint32_t T const *__restrict__ uint32_t const *__restrict__ int32_t int Histo::index_type cudaStream_t stream
void agglomerativeHierarchicalClustering()
Simple Merge Algorithm.
T PrimaryVertex() const
Reconstructed primary vertex.
Definition: VertexFinder.h:62
constexpr uint32_t stride
Definition: HelixFit.h:17
void adaptiveVertexReconstruction()
Adaptive Vertex Reconstruction algorithm.
void findPrimaryVertex()
Find the primary vertex.
void fastHisto(const TrackerTopology *tTopo)
Histogramming algorithm.
static constexpr unsigned BitsToRepresent(unsigned x)
Definition: VertexFinder.h:21
const std::vector< RecoVertex<> > & vertices() const
Returns the z positions of the reconstructed primary vertices.
Definition: VertexFinder.h:75
Simple wrapper class for TTTrack.
Definition: L1Track.h:17
void printHistogram(stream_type &stream, std::vector< data_type > data, int width=80, int minimum=0, int maximum=-1, std::string title="", std::string color="")
Print an ASCII histogram.
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< VertexWord > VertexWordCollection
Definition: VertexWord.h:197
Definition: value.py:1
VertexFinder(FitTrackCollection &fitTracks, const AlgoSettings &settings)
Constructor and destructor.
Definition: VertexFinder.h:29
RecoVertexCollection vertices_
Definition: VertexFinder.h:144
unsigned int numInputTracks() const
Storage for tracks out of the L1 Track finder.
Definition: VertexFinder.h:53
float minDistance(RecoVertex<> cluster0, RecoVertex<> cluster1)
Find minimum distance in two clusters of tracks.
Definition: VertexFinder.cc:96
void sortVerticesInPt()
Sort vertices in pT.
void PVR()
Find maximum distance in two clusters of tracks.
void strided_iota(ForwardIterator first, ForwardIterator last, T value, T stride)
Definition: VertexFinder.h:120
const AlgoSettings * settings_
Definition: VertexFinder.h:143
Precision vx_precision() const
Definition: AlgoSettings.h:35
void fastHistoEmulation()
Histogramming algorithm (emulation)
float z0() const
Definition: L1Track.h:25
void HPV()
High pT Vertex Algorithm.
std::vector< RecoVertex<> > RecoVertexCollection
Definition: VertexFinder.h:24
void sortVerticesInZ0()
Sort vertices in z.
l1t::VertexWordCollection verticesEmulation_
Definition: VertexFinder.h:145
unsigned int numIterations() const
Number of iterations.
Definition: VertexFinder.h:55
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80
void Kmeans()
Kmeans Algorithm.
void associatePrimaryVertex(double trueZ0)
Associate the primary vertex with the real one.
const l1t::VertexWordCollection & verticesEmulation() const
Returns the emulation primary vertices.
Definition: VertexFinder.h:77
unsigned int primaryVertexId() const
Reconstructed Primary Vertex Id.
Definition: VertexFinder.h:73
Log< level::Warning, false > LogWarning
unsigned int numVertices() const
Number of reconstructed vertices.
Definition: VertexFinder.h:57
long double T
unsigned int iterationsPerTrack() const
Number of iterations.
Definition: VertexFinder.h:51
void DBSCAN()
DBSCAN algorithm.
void computeAndSetVertexParameters(RecoVertex<> &vertex, const std::vector< float > &bin_centers, const std::vector< unsigned int > &counts)
Vertexing algorithms.
Definition: VertexFinder.cc:7