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 {
55  : ipState(mctx), linearizerState(mctx) {}
56  // Vertex collection to be fitted
57  std::vector<Vertex<InputTrack_t>*> vertexCollection;
58 
59  // Annealing state
61 
62  // IPEstimator state
63  typename IPEstimator::State ipState;
64 
65  // Linearizer state
66  typename Linearizer_t::State linearizerState;
67 
68  // Map to store vertices information
69  std::map<Vertex<InputTrack_t>*, VertexInfo<InputTrack_t>> vtxInfoMap;
70 
71  std::multimap<const InputTrack_t*, Vertex<InputTrack_t>*>
73 
74  std::map<std::pair<const InputTrack_t*, Vertex<InputTrack_t>*>,
77 
79  State() = default;
80 
81  // Adds a vertex to trackToVerticesMultiMap
83  for (auto trk : vtxInfoMap[&vtx].trackLinks) {
84  trackToVerticesMultiMap.emplace(trk, &vtx);
85  }
86  }
87 
88  // Removes a vertex from trackToVerticesMultiMap
90  for (auto iter = trackToVerticesMultiMap.begin();
91  iter != trackToVerticesMultiMap.end();) {
92  if (iter->second == &vtx) {
93  iter = trackToVerticesMultiMap.erase(iter);
94  } else {
95  ++iter;
96  }
97  }
98  }
99  };
100 
101  struct Config {
105  Config(const IPEstimator& est) : ipEst(est) {}
106 
107  // ImpactPointEstimator
109 
120 
121  // Number of max iterations
122  unsigned int maxIterations{30};
123 
124  // Max distance to linearization point allowed
125  // without relinearization
126  double maxDistToLinPoint{0.5};
127 
128  // Minimum track weight needed for track to be considered
129  double minWeight{0.0001};
130 
131  // Max relative shift of vertex during one iteration
132  double maxRelativeShift{0.01};
133 
134  // Do smoothing after multivertex fit
135  bool doSmoothing{false};
136  };
137 
142  template <
143  typename T = InputTrack_t,
146  std::unique_ptr<const Logger> logger =
147  getDefaultLogger("AdaptiveMultiVertexFitter",
148  Logging::INFO))
149  : m_cfg(std::move(cfg)),
150  m_extractParameters([](T params) { return params; }),
151  m_logger(std::move(logger)) {}
152 
161  Config& cfg, std::function<BoundTrackParameters(InputTrack_t)> func,
162  std::unique_ptr<const Logger> logger =
163  getDefaultLogger("AdaptiveMultiVertexFitter", Logging::INFO))
164  : m_cfg(std::move(cfg)),
166  m_logger(std::move(logger)) {}
167 
178  State& state, const std::vector<Vertex<InputTrack_t>*>& verticesToFit,
179  const Linearizer_t& linearizer,
180  const VertexingOptions<InputTrack_t>& vertexingOptions) const;
181 
206  State& state, Vertex<InputTrack_t>& newVertex,
207  const Linearizer_t& linearizer,
208  const VertexingOptions<InputTrack_t>& vertexingOptions) const;
209 
210  private:
212  const Config m_cfg;
213 
219  std::function<BoundTrackParameters(InputTrack_t)> m_extractParameters;
220 
222  std::unique_ptr<const Logger> m_logger;
223 
225  const Logger& logger() const { return *m_logger; }
226 
236  State& state, const Linearizer_t& linearizer,
237  const VertexingOptions<InputTrack_t>& vertexingOptions) const;
238 
245  bool isAlreadyInList(
247  const std::vector<Vertex<InputTrack_t>*>& verticesVec) const;
248 
258  State& state, Vertex<InputTrack_t>* vtx,
259  const VertexingOptions<InputTrack_t>& vertexingOptions) const;
260 
268  State& state, Vertex<InputTrack_t>* currentVtx,
269  const VertexingOptions<input_track_t>& vertexingOptions) const;
270 
278  State& state, const Linearizer_t& linearizer,
279  const VertexingOptions<input_track_t>& vertexingOptions) const;
280 
289  std::vector<double> collectTrackToVertexCompatibilities(
290  State& state, const InputTrack_t* trk) const;
291 
298  bool checkSmallShift(State& state) const;
299 
304  void doVertexSmoothing(State& state) const;
305 };
306 
307 } // namespace Acts
308