ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AdaptiveMultiVertexFitter.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file AdaptiveMultiVertexFitter.hpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2019 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 
22 
23 #include <functional>
24 
25 namespace Acts {
26 
38 template <typename input_track_t, typename linearizer_t>
40  static_assert(LinearizerConcept<linearizer_t>,
41  "Linearizer does not fulfill linearizer concept.");
42 
43  public:
44  using InputTrack_t = input_track_t;
45  using Propagator_t = typename linearizer_t::Propagator_t;
47 
48  private:
50 
51  public:
53  struct State {
54  // Vertex collection to be fitted
55  std::vector<Vertex<InputTrack_t>*> vertexCollection;
56 
57  // Annealing state
59 
60  // Map to store vertices information
61  std::map<Vertex<InputTrack_t>*, VertexInfo<InputTrack_t>> vtxInfoMap;
62 
63  std::multimap<const InputTrack_t*, Vertex<InputTrack_t>*>
65 
66  std::map<std::pair<const InputTrack_t*, Vertex<InputTrack_t>*>,
69 
71  State() = default;
72 
73  // Adds a vertex to trackToVerticesMultiMap
75  for (auto trk : vtxInfoMap[&vtx].trackLinks) {
76  trackToVerticesMultiMap.emplace(trk, &vtx);
77  }
78  }
79 
80  // Removes a vertex from trackToVerticesMultiMap
82  for (auto iter = trackToVerticesMultiMap.begin();
83  iter != trackToVerticesMultiMap.end();) {
84  if (iter->second == &vtx) {
85  iter = trackToVerticesMultiMap.erase(iter);
86  } else {
87  ++iter;
88  }
89  }
90  }
91  };
92 
93  struct Config {
97  Config(const IPEstimator& est) : ipEst(est) {}
98 
99  // ImpactPointEstimator
101 
112 
113  // Number of max iterations
114  unsigned int maxIterations{30};
115 
116  // Max distance to linearization point allowed
117  // without relinearization
118  double maxDistToLinPoint{0.5};
119 
120  // Minimum track weight needed for track to be considered
121  double minWeight{0.0001};
122 
123  // Max relative shift of vertex during one iteration
124  double maxRelativeShift{0.01};
125 
126  // Do smoothing after multivertex fit
127  bool doSmoothing{false};
128  };
129 
134  template <typename T = InputTrack_t,
137  std::unique_ptr<const Logger> logger =
138  getDefaultLogger("AdaptiveMultiVertexFitter",
139  Logging::INFO))
140  : m_cfg(std::move(cfg)),
141  m_extractParameters([](T params) { return params; }),
142  m_logger(std::move(logger)) {}
143 
151  std::unique_ptr<const Logger> logger =
152  getDefaultLogger("AdaptiveMultiVertexFitter",
153  Logging::INFO))
154  : m_cfg(std::move(cfg)),
156  m_logger(std::move(logger)) {}
157 
168  State& state, const std::vector<Vertex<InputTrack_t>*>& verticesToFit,
169  const Linearizer_t& linearizer,
170  const VertexingOptions<InputTrack_t>& vertexingOptions) const;
171 
196  State& state, Vertex<InputTrack_t>& newVertex,
197  const Linearizer_t& linearizer,
198  const VertexingOptions<InputTrack_t>& vertexingOptions) const;
199 
200  private:
202  const Config m_cfg;
203 
209  std::function<BoundParameters(InputTrack_t)> m_extractParameters;
210 
212  std::unique_ptr<const Logger> m_logger;
213 
215  const Logger& logger() const { return *m_logger; }
216 
226  State& state, const Linearizer_t& linearizer,
227  const VertexingOptions<InputTrack_t>& vertexingOptions) const;
228 
235  bool isAlreadyInList(
237  const std::vector<Vertex<InputTrack_t>*>& verticesVec) const;
238 
248  State& state, Vertex<InputTrack_t>* vtx,
249  const VertexingOptions<InputTrack_t>& vertexingOptions) const;
250 
258  State& state, Vertex<InputTrack_t>* currentVtx,
259  const VertexingOptions<input_track_t>& vertexingOptions) const;
260 
268  State& state, const Linearizer_t& linearizer,
269  const VertexingOptions<input_track_t>& vertexingOptions) const;
270 
279  std::vector<double> collectTrackToVertexCompatibilities(
280  State& state, const InputTrack_t* trk) const;
281 
288  bool checkSmallShift(State& state) const;
289 
295  void doVertexSmoothing(State& state, const GeometryContext& geoContext) const;
296 };
297 
298 } // namespace Acts
299