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 #include <type_traits>
21 
22 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  using SeedFinderState_t = typename sfinder_t::State;
41 
42  template <typename T, typename = int>
43  struct NeedsRemovedTracks : std::false_type {};
44 
45  template <typename T>
46  struct NeedsRemovedTracks<T, decltype((void)T::tracksToRemove, 0)>
47  : std::true_type {};
48 
49  public:
51  struct Config {
58  Config(vfitter_t fitter, const sfinder_t& sfinder,
60  const Linearizer_t& lin)
61  : vertexFitter(std::move(fitter)),
62  seedFinder(sfinder),
63  ipEstimator(ipEst),
64  linearizer(lin) {}
65 
66  // Vertex fitter
67  vfitter_t vertexFitter;
68 
69  // Vertex seed finder
70  sfinder_t seedFinder;
71 
72  // ImpactPointEstimator
74 
75  // Track linearizer
77 
78  // Use a beam spot constraint, vertexConstraint in VertexingOptions
79  // has to be set in this case
80  bool useBeamSpotConstraint = true;
81 
82  // Max z interval used for adding tracks to fit:
83  // When adding a new vertex to the multi vertex fit,
84  // only the tracks whose z at PCA is closer
85  // to the seeded vertex than tracksMaxZinterval
86  // are added to this new vertex.
87  //
88  // Note: If you cut too hard, you cut out
89  // the good cases where the seed finder is not
90  // reliable, but the fit would be still able to converge
91  // towards the right vertex. If you cut too soft, you
92  // consider a lot of tracks which just slow down the fit.
94 
95  // Maximum allowed significance of track position to vertex seed
96  // to consider track as compatible track for vertex fit
97  double tracksMaxSignificance = 5.;
98 
99  // Max chi2 value for which tracks are considered compatible with
100  // the fitted vertex. These tracks are removed from the seedTracks
101  // after the fit has been performed.
102  double maxVertexChi2 = 18.42;
103 
104  // Perform a 'real' multi-vertex fit as intended by the algorithm.
105  // If switched to true, always all (!) tracks are considered to be
106  // added to the new vertex candidate after seeding. If switched to
107  // false, only the seedTracks, i.e. all tracks that are considered
108  // as outliers of previously fitted vertices, are used.
109  bool doRealMultiVertex = true;
110 
111  // Decides if you want to use the ```vertexCompatibility``` of the
112  // track (set to true) or the ```chi2Track``` (set to false) as an
113  // estimate for a track being an outlier or not.
114  // In case the track refitting is switched on in the AMVFitter, you
115  // may want to use the refitted ```chi2Track```.
116  bool useFastCompatibility = true;
117 
118  // Maximum significance on the distance between two vertices
119  // to allow merging of two vertices.
121 
122  // Minimum weight a track has to have to be considered a compatible
123  // track with a vertex candidate.
124  //
125  // Note: This value has to be the same as the one in the AMVFitter.
126  double minWeight = 0.0001;
127 
128  // Maximal number of iterations in the finding procedure
129  int maxIterations = 100;
130 
131  // Include also single track vertices
133 
134  // Use 3d information fo evaluating the vertex distance significance
135  // for vertex merging/splitting
136  bool do3dSplitting = false;
137 
138  // Maximum vertex contamination value
140 
141  // Use seed vertex as a constraint for the fit
142  bool useSeedConstraint = true;
143 
144  // Diagonal constraint covariance entries in case
145  // no beamspot constraint is provided
146  double looseConstrValue = 1e+8;
147 
148  // Default fitQuality for constraint vertex in case no beamspot
149  // constraint is provided
150  std::pair<double, double> defaultConstrFitQuality{0., -3.};
151 
152  // Use the full available vertex covariance information after
153  // seeding for the IP estimation. In original implementation
154  // this is not (!) done, however, this is probably not correct.
155  // So definitely consider setting this to true.
157 
158  }; // Config struct
159 
161  struct State {};
162 
167  template <
168  typename T = InputTrack_t,
171  std::unique_ptr<const Logger> logger =
172  getDefaultLogger("AdaptiveMultiVertexFinder",
173  Logging::INFO))
174  : m_cfg(std::move(cfg)),
175  m_extractParameters([](T params) { return params; }),
176  m_logger(std::move(logger)) {}
177 
186  Config& cfg, std::function<BoundTrackParameters(InputTrack_t)> func,
187  std::unique_ptr<const Logger> logger =
188  getDefaultLogger("AdaptiveMultiVertexFinder", Logging::INFO))
189  : m_cfg(std::move(cfg)),
191  m_logger(std::move(logger)) {}
192 
202  const std::vector<const InputTrack_t*>& allTracks,
203  const VertexingOptions<InputTrack_t>& vertexingOptions,
204  State& state) const;
205 
206  private:
209 
215  std::function<BoundTrackParameters(InputTrack_t)> m_extractParameters;
216 
218  std::unique_ptr<const Logger> m_logger;
219 
221  const Logger& logger() const { return *m_logger; }
222 
235  const std::vector<const InputTrack_t*>& trackVector,
236  Vertex<InputTrack_t>& currentConstraint,
237  const VertexingOptions<InputTrack_t>& vertexingOptions,
238  SeedFinderState_t& seedFinderState,
239  const std::vector<const InputTrack_t*>& removedSeedTracks) const;
240 
245  void setConstraintAfterSeeding(Vertex<InputTrack_t>& currentConstraint,
246  const Vertex<InputTrack_t>& seedVertex) const;
247 
256  const InputTrack_t* track, const Vertex<InputTrack_t>& vtx,
257  const VertexingOptions<InputTrack_t>& vertexingOptions) const;
258 
266  const std::vector<const InputTrack_t*>& tracks, Vertex<InputTrack_t>& vtx,
267  FitterState_t& fitterState,
268  const VertexingOptions<InputTrack_t>& vertexingOptions) const;
269 
283  const std::vector<const InputTrack_t*>& allTracks,
284  const std::vector<const InputTrack_t*>& seedTracks,
285  Vertex<InputTrack_t>& vtx, const Vertex<InputTrack_t>& currentConstraint,
286  FitterState_t& fitterState,
287  const VertexingOptions<InputTrack_t>& vertexingOptions) const;
288 
301  const std::vector<const InputTrack_t*>& allTracks,
302  const std::vector<const InputTrack_t*>& seedTracks,
303  Vertex<InputTrack_t>& vtx, const Vertex<InputTrack_t>& currentConstraint,
304  FitterState_t& fitterState,
305  const VertexingOptions<InputTrack_t>& vertexingOptions) const;
306 
315  std::pair<int, bool> checkVertexAndCompatibleTracks(
317  const std::vector<const InputTrack_t*>& seedTracks,
318  FitterState_t& fitterState) const;
319 
329  Vertex<InputTrack_t>& vtx, std::vector<const InputTrack_t*>& seedTracks,
330  FitterState_t& fitterState,
331  std::vector<const InputTrack_t*>& removedSeedTracks) const;
332 
345  Vertex<InputTrack_t>& vtx, std::vector<const InputTrack_t*>& seedTracks,
346  FitterState_t& fitterState,
347  std::vector<const InputTrack_t*>& removedSeedTracks,
348  const GeometryContext& geoCtx) const;
349 
359  const std::vector<Vertex<InputTrack_t>*>& allVertices,
360  FitterState_t& fitterState) const;
361 
369  bool isMergedVertex(
370  const Vertex<InputTrack_t>& vtx,
371  const std::vector<Vertex<InputTrack_t>*>& allVertices) const;
372 
383  std::vector<std::unique_ptr<Vertex<InputTrack_t>>>& allVertices,
384  std::vector<Vertex<InputTrack_t>*>& allVerticesPtr,
385  FitterState_t& fitterState,
386  const VertexingOptions<InputTrack_t>& vertexingOptions) const;
387 
395  const std::vector<Vertex<InputTrack_t>*>& allVerticesPtr,
396  FitterState_t& fitterState) const;
397 };
398 
399 } // namespace Acts
400