Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MultiTrajectory.ipp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file MultiTrajectory.ipp
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 
11 
12 #include <bitset>
13 #include <cstdint>
14 #include <type_traits>
15 #include <vector>
16 
17 #include <Eigen/Core>
18 
19 namespace Acts {
20 namespace detail_lt {
21 template <typename D, size_t M, bool ReadOnly>
23  ConstIf<MultiTrajectory<D>, ReadOnly>& trajectory, IndexType istate)
24  : m_traj(&trajectory), m_istate(istate) {}
25 
26 template <typename D, size_t M, bool ReadOnly>
27 TrackStatePropMask TrackStateProxy<D, M, ReadOnly>::getMask() const {
28  using PM = TrackStatePropMask;
29 
30  PM mask = PM::None;
31  if (hasPredicted()) {
32  mask |= PM::Predicted;
33  }
34  if (hasFiltered()) {
35  mask |= PM::Filtered;
36  }
37  if (hasSmoothed()) {
38  mask |= PM::Smoothed;
39  }
40  if (hasJacobian()) {
41  mask |= PM::Jacobian;
42  }
43  if (hasCalibrated()) {
44  mask |= PM::Calibrated;
45  }
46  return mask;
47 }
48 
49 template <typename D, size_t M, bool ReadOnly>
51  -> ConstParameters {
52  if (hasSmoothed()) {
53  return smoothed();
54  } else if (hasFiltered()) {
55  return filtered();
56  } else {
57  return predicted();
58  }
59 }
60 
61 template <typename D, size_t M, bool ReadOnly>
63  -> ConstCovariance {
64  if (hasSmoothed()) {
65  return smoothedCovariance();
66  } else if (hasFiltered()) {
67  return filteredCovariance();
68  } else {
69  return predictedCovariance();
70  }
71 }
72 
73 template <typename D, size_t M, bool ReadOnly>
75  assert(has<hashString("projector")>());
76  return bitsetToMatrix<Projector>(
77  component<ProjectorBitset, hashString("projector")>());
78 }
79 
80 template <typename D, size_t M, bool ReadOnly>
82  -> SourceLink {
83  assert(has<hashString("uncalibratedSourceLink")>());
84  return m_traj->getUncalibratedSourceLink(m_istate);
85 }
86 
87 } // namespace detail_lt
88 
89 template <typename D>
90 template <typename F>
92  F&& callable) const {
93  static_assert(detail_lt::VisitorConcept<F, ConstTrackStateProxy>,
94  "Callable needs to satisfy VisitorConcept");
95 
96  if (iendpoint == MultiTrajectoryTraits::kInvalid) {
97  throw std::runtime_error(
98  "Cannot visit backwards with kInvalid as endpoint");
99  }
100 
101  while (true) {
102  auto ts = getTrackState(iendpoint);
103  if constexpr (std::is_same_v<std::invoke_result_t<F, ConstTrackStateProxy>,
104  bool>) {
105  bool proceed = callable(ts);
106  // this point has no parent and ends the trajectory, or a break was
107  // requested
108  if (!proceed || !ts.hasPrevious()) {
109  break;
110  }
111  } else {
112  callable(ts);
113  // this point has no parent and ends the trajectory
114  if (!ts.hasPrevious()) {
115  break;
116  }
117  }
118  iendpoint = ts.previous();
119  }
120 }
121 
122 } // namespace Acts