EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MeasurementHelpers.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file MeasurementHelpers.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
12 
13 #include <variant>
14 
15 namespace Acts {
16 
17 class Surface;
18 
19 namespace MeasurementHelpers {
20 
24 template <typename T>
25 const Surface* getSurface(const T& fittable_measurement) {
26  return std::visit([](const auto& meas) { return &meas.referenceObject(); },
27  fittable_measurement);
28 }
29 
30 template <typename T>
31 size_t getSize(const T& fittable_measurement) {
32  return std::visit([](const auto& meas) { return meas.size(); },
33  fittable_measurement);
34 }
35 } // namespace MeasurementHelpers
36 
39 
40  bool operator==(const MinimalSourceLink& rhs) const;
41 
42  const Surface& referenceSurface() const;
43 
45 };
46 
47 inline std::ostream& operator<<(std::ostream& os, const MinimalSourceLink& sl) {
48  os << "SourceLink(" << sl.meas << ")";
49  return os;
50 }
51 
52 static_assert(SourceLinkConcept<MinimalSourceLink>,
53  "MinimalSourceLink does not fulfill SourceLinkConcept");
54 
55 namespace detail {
56 
60 template <size_t I>
72  template <typename L, typename A, typename B>
73  auto static constexpr invoke(A&& param, B&& cov, L&& lambda) {
74  return lambda(param.template head<I>(), cov.template topLeftCorner<I, I>());
75  }
76 };
77 } // namespace detail
78 
92 template <typename L, typename A, typename B>
93 auto visit_measurement(A&& param, B&& cov, size_t dim, L&& lambda) {
94  return template_switch<detail::visit_measurement_callable, 1, eBoundSize>(
95  dim, param, cov, lambda);
96 }
97 
98 } // namespace Acts