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 
13 
14 #include <algorithm>
15 #include <cmath>
16 #include <iterator>
17 #include <vector>
18 
19 namespace l1tVertexFinder {
20 
21  // Returns the number of bits needed to represent and integer decimal
22  static constexpr unsigned BitsToRepresent(unsigned x) { return x < 2 ? 1 : 1 + BitsToRepresent(x >> 1); }
23 
24  typedef std::vector<L1Track> FitTrackCollection;
25  typedef std::vector<RecoVertex<>> RecoVertexCollection;
26 
27  class VertexFinder {
28  public:
32  settings_ = &settings;
33  }
35 
37  struct SortTracksByZ0 {
38  inline bool operator()(const L1Track track0, const L1Track track1) { return (track0.z0() < track1.z0()); }
39  };
40 
41  struct SortTracksByPt {
42  inline bool operator()(const L1Track track0, const L1Track track1) {
43  return (std::abs(track0.pt()) > std::abs(track1.pt()));
44  }
45  };
46 
48 
50  const FitTrackCollection& fitTracks() const { return fitTracks_; }
52  unsigned int iterationsPerTrack() const { return double(iterations_) / double(fitTracks_.size()); }
54  unsigned int numInputTracks() const { return fitTracks_.size(); }
56  unsigned int numIterations() const { return iterations_; }
58  unsigned int numVertices() const { return vertices_.size(); }
60  unsigned int numVerticesEmulation() const { return verticesEmulation_.size(); }
62  template <typename T>
63  T PrimaryVertex() const {
65  return vertices_[pv_index_];
66  else if ((settings_->vx_precision() == Precision::Emulation) && (pv_index_ < vertices_.size()))
68  else {
69  edm::LogWarning("VertexFinder") << "PrimaryVertex::No primary vertex has been found.";
70  return RecoVertex<>();
71  }
72  }
74  unsigned int primaryVertexId() const { return pv_index_; }
76  const std::vector<RecoVertex<>>& vertices() const { return vertices_; }
79 
81  void findPrimaryVertex();
83  void associatePrimaryVertex(double trueZ0);
85  void GapClustering();
87  float maxDistance(RecoVertex<> cluster0, RecoVertex<> cluster1);
89  float minDistance(RecoVertex<> cluster0, RecoVertex<> cluster1);
91  float meanDistance(RecoVertex<> cluster0, RecoVertex<> cluster1);
93  float centralDistance(RecoVertex<> cluster0, RecoVertex<> cluster1);
101  void fastHisto(const TrackerTopology* tTopo);
103  void fastHistoEmulation();
105  void NNVtxEmulation(tensorflow::Session* TrackWeightSesh = nullptr,
106  tensorflow::Session* PatternRecSesh = nullptr,
107  tensorflow::Session* AssociationSesh = nullptr);
108 
110  void sortVerticesInPt();
112  void sortVerticesInZ0();
113 
115  template <class data_type, typename stream_type = std::ostream>
116  void printHistogram(stream_type& stream,
117  std::vector<data_type> data,
118  int width = 80,
119  int minimum = 0,
120  int maximum = -1,
121  std::string title = "",
122  std::string color = "");
123 
124  template <typename ForwardIterator, typename T>
125  void strided_iota(ForwardIterator first, ForwardIterator last, T value, T stride) {
126  while (first != last) {
127  *first++ = value;
128  value += stride;
129  }
130  }
131 
133 
136  const std::vector<float>& bin_centers,
137  const std::vector<unsigned int>& counts);
139  void DBSCAN();
141  void HPV();
143  void Kmeans();
145  void PVR();
146 
147  private:
151  unsigned int numMatchedVertices_;
153  unsigned int pv_index_;
154  unsigned int iterations_;
155  };
156 
157 } // end namespace l1tVertexFinder
158 
159 #endif
bool operator()(const L1Track track0, const L1Track track1)
Definition: VertexFinder.h:38
const FitTrackCollection & fitTracks() const
Accessors.
Definition: VertexFinder.h:50
FitTrackCollection fitTracks_
Definition: VertexFinder.h:152
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:42
float pt() const
Definition: L1Track.h:24
void NNVtxEmulation(tensorflow::Session *TrackWeightSesh=nullptr, tensorflow::Session *PatternRecSesh=nullptr, tensorflow::Session *AssociationSesh=nullptr)
NNVtx algorithm.
std::vector< L1Track > FitTrackCollection
Definition: VertexFinder.h:24
float centralDistance(RecoVertex<> cluster0, RecoVertex<> cluster1)
Find distance between centres of two clusters.
unsigned int numVerticesEmulation() const
Number of emulation vertices.
Definition: VertexFinder.h:60
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:63
constexpr uint32_t stride
Definition: HelixFit.h:22
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:22
const std::vector< RecoVertex<> > & vertices() const
Returns the z positions of the reconstructed primary vertices.
Definition: VertexFinder.h:76
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:30
RecoVertexCollection vertices_
Definition: VertexFinder.h:149
unsigned int numInputTracks() const
Storage for tracks out of the L1 Track finder.
Definition: VertexFinder.h:54
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:125
const AlgoSettings * settings_
Definition: VertexFinder.h:148
Precision vx_precision() const
Definition: AlgoSettings.h:37
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:25
void sortVerticesInZ0()
Sort vertices in z.
l1t::VertexWordCollection verticesEmulation_
Definition: VertexFinder.h:150
unsigned int numIterations() const
Number of iterations.
Definition: VertexFinder.h:56
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:78
unsigned int primaryVertexId() const
Reconstructed Primary Vertex Id.
Definition: VertexFinder.h:74
Log< level::Warning, false > LogWarning
unsigned int numVertices() const
Number of reconstructed vertices.
Definition: VertexFinder.h:58
long double T
unsigned int iterationsPerTrack() const
Number of iterations.
Definition: VertexFinder.h:52
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