Analysis Software
Documentation for sPHENIX simulation 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 
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>
44 
45 #ifndef DOXYGEN
46  template <typename T>
47  struct NeedsRemovedTracks<T, decltype((void)T::tracksToRemove, 0)>
48  : std::true_type {};
49 #endif
50 
51  public:
53  struct Config {
61  Config(vfitter_t fitter, const sfinder_t& sfinder,
63  Linearizer_t lin, std::shared_ptr<const MagneticFieldProvider> bIn)
64  : vertexFitter(std::move(fitter)),
65  seedFinder(sfinder),
66  ipEstimator(ipEst),
67  linearizer(std::move(lin)),
68  bField{std::move(bIn)} {}
69 
70  // Vertex fitter
71  vfitter_t vertexFitter;
72 
73  // Vertex seed finder
74  sfinder_t seedFinder;
75 
76  // ImpactPointEstimator
78 
79  // Track linearizer
81 
82  std::shared_ptr<const MagneticFieldProvider> bField;
83 
84  // Max z interval used for adding tracks to fit:
85  // When adding a new vertex to the multi vertex fit,
86  // only the tracks whose z at PCA is closer
87  // to the seeded vertex than tracksMaxZinterval
88  // are added to this new vertex.
89  //
90  // Note: If you cut too hard, you cut out
91  // the good cases where the seed finder is not
92  // reliable, but the fit would be still able to converge
93  // towards the right vertex. If you cut too soft, you
94  // consider a lot of tracks which just slow down the fit.
96 
97  // Maximum allowed significance of track position to vertex seed
98  // to consider track as compatible track for vertex fit
99  double tracksMaxSignificance = 5.;
100 
101  // Max chi2 value for which tracks are considered compatible with
102  // the fitted vertex. These tracks are removed from the seedTracks
103  // after the fit has been performed.
104  double maxVertexChi2 = 18.42;
105 
106  // Perform a 'real' multi-vertex fit as intended by the algorithm.
107  // If switched to true, always all (!) tracks are considered to be
108  // added to the new vertex candidate after seeding. If switched to
109  // false, only the seedTracks, i.e. all tracks that are considered
110  // as outliers of previously fitted vertices, are used.
111  bool doRealMultiVertex = true;
112 
113  // Decides if you want to use the ```vertexCompatibility``` of the
114  // track (set to true) or the ```chi2Track``` (set to false) as an
115  // estimate for a track being an outlier or not.
116  // In case the track refitting is switched on in the AMVFitter, you
117  // may want to use the refitted ```chi2Track```.
118  bool useFastCompatibility = true;
119 
120  // Maximum significance on the distance between two vertices
121  // to allow merging of two vertices.
123 
124  // Minimum weight a track has to have to be considered a compatible
125  // track with a vertex candidate.
126  //
127  // Note: This value has to be the same as the one in the AMVFitter.
128  double minWeight = 0.0001;
129 
130  // Maximal number of iterations in the finding procedure
131  int maxIterations = 100;
132 
133  // Include also single track vertices
135 
136  // Use 3d information for evaluating the vertex distance significance
137  // for vertex merging/splitting
138  bool do3dSplitting = false;
139 
140  // Maximum vertex contamination value
142 
143  // Use seed vertex as a constraint for the fit
144  bool useSeedConstraint = true;
145 
146  // Diagonal constraint covariance entries in case
147  // no beamspot constraint is provided
148  double looseConstrValue = 1e+8;
149 
150  // Default fitQuality for constraint vertex in case no beamspot
151  // constraint is provided
152  std::pair<double, double> defaultConstrFitQuality{0., -3.};
153 
154  // Use the full available vertex covariance information after
155  // seeding for the IP estimation. In original implementation
156  // this is not (!) done, however, this is probably not correct.
157  // So definitely consider setting this to true.
159 
160  }; // Config struct
161 
163  struct State {};
164 
169  template <
170  typename T = InputTrack_t,
173  std::unique_ptr<const Logger> logger =
174  getDefaultLogger("AdaptiveMultiVertexFinder",
175  Logging::INFO))
176  : m_cfg(std::move(cfg)),
177  m_extractParameters([](T params) { return params; }),
179 
188  Config& cfg, std::function<BoundTrackParameters(InputTrack_t)> func,
189  std::unique_ptr<const Logger> logger =
190  getDefaultLogger("AdaptiveMultiVertexFinder", Logging::INFO))
191  : m_cfg(std::move(cfg)),
192  m_extractParameters(func),
193  m_logger(std::move(logger)) {}
194 
196 
206  const std::vector<const InputTrack_t*>& allTracks,
207  const VertexingOptions<InputTrack_t>& vertexingOptions,
208  State& state) const;
209 
210  private:
213 
217  std::function<BoundTrackParameters(InputTrack_t)> m_extractParameters;
218 
220  std::unique_ptr<const Logger> m_logger;
221 
223  const Logger& logger() const {
224  return *m_logger;
225  }
226 
239  const std::vector<const InputTrack_t*>& trackVector,
240  Vertex<InputTrack_t>& currentConstraint,
241  const VertexingOptions<InputTrack_t>& vertexingOptions,
242  SeedFinderState_t& seedFinderState,
243  const std::vector<const InputTrack_t*>& removedSeedTracks) const;
244 
250  void setConstraintAfterSeeding(Vertex<InputTrack_t>& currentConstraint,
251  bool useVertexConstraintInFit,
252  Vertex<InputTrack_t>& seedVertex) const;
253 
262  const InputTrack_t* track, const Vertex<InputTrack_t>& vtx,
263  const VertexingOptions<InputTrack_t>& vertexingOptions) const;
264 
272  const std::vector<const InputTrack_t*>& tracks, Vertex<InputTrack_t>& vtx,
273  FitterState_t& fitterState,
274  const VertexingOptions<InputTrack_t>& vertexingOptions) const;
275 
289  const std::vector<const InputTrack_t*>& allTracks,
290  const std::vector<const InputTrack_t*>& seedTracks,
291  Vertex<InputTrack_t>& vtx, const Vertex<InputTrack_t>& currentConstraint,
292  FitterState_t& fitterState,
293  const VertexingOptions<InputTrack_t>& vertexingOptions) const;
294 
307  const std::vector<const InputTrack_t*>& allTracks,
308  const std::vector<const InputTrack_t*>& seedTracks,
309  Vertex<InputTrack_t>& vtx, const Vertex<InputTrack_t>& currentConstraint,
310  FitterState_t& fitterState,
311  const VertexingOptions<InputTrack_t>& vertexingOptions) const;
312 
322  std::pair<int, bool> checkVertexAndCompatibleTracks(
324  const std::vector<const InputTrack_t*>& seedTracks,
325  FitterState_t& fitterState, bool useVertexConstraintInFit) const;
326 
336  Vertex<InputTrack_t>& vtx, std::vector<const InputTrack_t*>& seedTracks,
337  FitterState_t& fitterState,
338  std::vector<const InputTrack_t*>& removedSeedTracks) const;
339 
352  Vertex<InputTrack_t>& vtx, std::vector<const InputTrack_t*>& seedTracks,
353  FitterState_t& fitterState,
354  std::vector<const InputTrack_t*>& removedSeedTracks,
355  const GeometryContext& geoCtx) const;
356 
366  const std::vector<Vertex<InputTrack_t>*>& allVertices,
367  FitterState_t& fitterState) const;
368 
376  bool isMergedVertex(
377  const Vertex<InputTrack_t>& vtx,
378  const std::vector<Vertex<InputTrack_t>*>& allVertices) const;
379 
390  std::vector<std::unique_ptr<Vertex<InputTrack_t>>>& allVertices,
391  std::vector<Vertex<InputTrack_t>*>& allVerticesPtr,
392  FitterState_t& fitterState,
393  const VertexingOptions<InputTrack_t>& vertexingOptions) const;
394 
402  const std::vector<Vertex<InputTrack_t>*>& allVerticesPtr,
403  FitterState_t& fitterState) const;
404 };
405 
406 } // namespace Acts
407