ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AdaptiveMultiVertexFinder.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file AdaptiveMultiVertexFinder.hpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2020 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
9 #pragma once
10 
15 #include "Acts/Utilities/Units.hpp"
19 
20 namespace Acts {
34 template <typename vfitter_t, typename sfinder_t>
36  using Propagator_t = typename vfitter_t::Propagator_t;
37  using InputTrack_t = typename vfitter_t::InputTrack_t;
39  using FitterState_t = typename vfitter_t::State;
40 
41  public:
43  struct Config {
50  Config(vfitter_t fitter, const sfinder_t& sfinder,
52  const Linearizer_t& lin)
53  : vertexFitter(std::move(fitter)),
54  seedFinder(sfinder),
55  ipEstimator(ipEst),
56  linearizer(lin) {}
57 
58  // Vertex fitter
59  vfitter_t vertexFitter;
60 
61  // Vertex seed finder
62  sfinder_t seedFinder;
63 
64  // ImpactPointEstimator
66 
67  // Track linearizer
69 
70  // Use a beam spot constraint, vertexConstraint in VertexingOptions
71  // has to be set in this case
72  bool useBeamSpotConstraint = true;
73 
74  // Max z interval used for adding tracks to fit:
75  // When adding a new vertex to the multi vertex fit,
76  // only the tracks whose z at PCA is closer
77  // to the seeded vertex than tracksMaxZinterval
78  // are added to this new vertex.
79  //
80  // Note: If you cut too hard, you cut out
81  // the good cases where the seed finder is not
82  // reliable, but the fit would be still able to converge
83  // towards the right vertex. If you cut too soft, you
84  // consider a lot of tracks which just slow down the fit.
86 
87  // Maximum allowed significance of track position to vertex seed
88  // to consider track as compatible track for vertex fit
89  double tracksMaxSignificance = 5.;
90 
91  // Max chi2 value for which tracks are considered compatible with
92  // the fitted vertex. These tracks are removed from the seedTracks
93  // after the fit has been performed.
94  double maxVertexChi2 = 18.42;
95 
96  // Perform a 'real' multi-vertex fit as intended by the algorithm.
97  // If switched to true, always all (!) tracks are considered to be
98  // added to the new vertex candidate after seeding. If switched to
99  // false, only the seedTracks, i.e. all tracks that are considered
100  // as outliers of previously fitted vertices, are used.
101  bool doRealMultiVertex = true;
102 
103  // Decides if you want to use the ```vertexCompatibility``` of the
104  // track (set to true) or the ```chi2Track``` (set to false) as an
105  // estimate for a track being an outlier or not.
106  // In case the track refitting is switched on in the AMVFitter, you
107  // may want to use the refitted ```chi2Track```.
108  bool useFastCompatibility = true;
109 
110  // Maximum significance on the distance between two vertices
111  // to allow merging of two vertices.
113 
114  // Minimum weight a track has to have to be considered a compatible
115  // track with a vertex candidate.
116  //
117  // Note: This value has to be the same as the one in the AMVFitter.
118  double minWeight = 0.0001;
119 
120  // Maximal number of iterations in the finding procedure
121  int maxIterations = 100;
122 
123  // Include also single track vertices
125 
126  // Use 3d information fo evaluating the vertex distance significance
127  // for vertex merging/splitting
128  bool do3dSplitting = false;
129 
130  // Maximum vertex contamination value
132 
133  // Use seed vertex as a constraint for the fit
134  bool useSeedConstraint = true;
135 
136  // Diagonal constraint covariance entries in case
137  // no beamspot constraint is provided
138  double looseConstrValue = 1e+8;
139 
140  // Default fitQuality for constraint vertex in case no beamspot
141  // constraint is provided
142  std::pair<double, double> defaultConstrFitQuality{0., -3.};
143 
144  // Do an adaptive multi vertex fit after
145  // a bad vertex was removed.
146  // If false, the old fitter state is just copied,
147  // this should give the same results with better
148  // performance. To be further investigated.
149  bool refitAfterBadVertex = true;
150 
151  // Use the full available vertex covariance information after
152  // seeding for the IP estimation. In original implementation
153  // this is not (!) done, however, this is probably not correct.
154  // So definitely consider setting this to true.
156 
157  }; // Config struct
158 
163  template <typename T = InputTrack_t,
166  std::unique_ptr<const Logger> logger =
167  getDefaultLogger("AdaptiveMultiVertexFinder",
168  Logging::INFO))
169  : m_cfg(std::move(cfg)),
170  m_extractParameters([](T params) { return params; }),
171  m_logger(std::move(logger)) {}
172 
180  std::unique_ptr<const Logger> logger =
181  getDefaultLogger("AdaptiveMultiVertexFinder",
182  Logging::INFO))
183  : m_cfg(std::move(cfg)),
185  m_logger(std::move(logger)) {}
186 
195  const std::vector<const InputTrack_t*>& allTracks,
196  const VertexingOptions<InputTrack_t>& vertexingOptions) const;
197 
198  private:
201 
207  std::function<BoundParameters(InputTrack_t)> m_extractParameters;
208 
210  std::unique_ptr<const Logger> m_logger;
211 
213  const Logger& logger() const { return *m_logger; }
214 
224  const std::vector<const InputTrack_t*>& trackVector,
225  Vertex<InputTrack_t>& currentConstraint,
226  const VertexingOptions<InputTrack_t>& vertexingOptions) const;
227 
234  double estimateDeltaZ(const BoundParameters& track,
235  const Vector3D& vtxPos) const;
236 
245  const InputTrack_t* track, const Vertex<InputTrack_t>& vtx,
246  const VertexingOptions<InputTrack_t>& vertexingOptions) const;
247 
255  const std::vector<const InputTrack_t*>& tracks, Vertex<InputTrack_t>& vtx,
256  FitterState_t& fitterState,
257  const VertexingOptions<InputTrack_t>& vertexingOptions) const;
258 
272  const std::vector<const InputTrack_t*>& allTracks,
273  const std::vector<const InputTrack_t*>& seedTracks,
274  Vertex<InputTrack_t>& vtx, const Vertex<InputTrack_t>& currentConstraint,
275  FitterState_t& fitterState,
276  const VertexingOptions<InputTrack_t>& vertexingOptions) const;
277 
290  const std::vector<const InputTrack_t*>& allTracks,
291  const std::vector<const InputTrack_t*>& seedTracks,
292  Vertex<InputTrack_t>& vtx, const Vertex<InputTrack_t>& currentConstraint,
293  FitterState_t& fitterState,
294  const VertexingOptions<InputTrack_t>& vertexingOptions) const;
295 
304  std::pair<int, bool> checkVertexAndCompatibleTracks(
306  const std::vector<const InputTrack_t*>& seedTracks,
307  FitterState_t& fitterState) const;
308 
316  Vertex<InputTrack_t>& vtx, std::vector<const InputTrack_t*>& seedTracks,
317  FitterState_t& fitterState) const;
318 
328  Vertex<InputTrack_t>& vtx, std::vector<const InputTrack_t*>& seedTracks,
329  FitterState_t& fitterState) const;
330 
340  const std::vector<Vertex<InputTrack_t>*>& allVertices,
341  FitterState_t& fitterState) const;
342 
350  bool isMergedVertex(
351  const Vertex<InputTrack_t>& vtx,
352  const std::vector<Vertex<InputTrack_t>*>& allVertices) const;
353 
367  std::vector<std::unique_ptr<Vertex<InputTrack_t>>>& allVertices,
368  std::vector<Vertex<InputTrack_t>*>& allVerticesPtr,
369  FitterState_t& fitterState, FitterState_t& oldFitterState,
370  const VertexingOptions<InputTrack_t>& vertexingOptions) const;
371 
378  std::vector<Vertex<InputTrack_t>> getVertexOutputList(
379  const std::vector<Vertex<InputTrack_t>*>& allVerticesPtr,
380  FitterState_t& fitterState) const;
381 };
382 
383 } // namespace Acts
384