ATLAS Offline Software
MultiTrajectory.icc
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // has_impl implementation
6 namespace ActsTrk {
7 namespace details {
8 constexpr std::optional<bool> has_impl(
9  const xAOD::TrackStateAuxContainer* trackStates, Acts::HashedString key,
10  ActsTrk::IndexType istate) {
11  using namespace Acts::HashedStringLiteral;
12  using Acts::MultiTrajectoryTraits::kInvalid;
13  INSPECTCALL(key << " " << istate);
14 
15  switch (key) {
16  case "previous"_hash:
17  return trackStates->previous[istate] < kInvalid;
18  case "chi2"_hash:{
19  INSPECTCALL(key << " " << istate << " chi2");
20  return true;
21  }
22  case "pathLength"_hash:{
23  INSPECTCALL(key << " " << istate << " pathLength");
24  return true;
25  }
26  case "typeFlags"_hash:{
27  INSPECTCALL(key << " " << istate << " type flags");
28  return true;
29  }
30  case "predicted"_hash:{
31  INSPECTCALL(key << " " << istate << " predicted");
32  return trackStates->predicted[istate] < kInvalid;
33  }
34  case "filtered"_hash:{
35  INSPECTCALL(key << " " << istate << " filtered");
36  return trackStates->filtered[istate] < kInvalid;
37  }
38  case "smoothed"_hash:{
39  INSPECTCALL(key << " " << istate << " smoothed");
40  return trackStates->smoothed[istate] < kInvalid;
41  }
42  case "jacobian"_hash:{
43  INSPECTCALL(key << " " << istate << " jacobian");
44  return trackStates->jacobian[istate] < kInvalid;
45  }
46  case "projector"_hash:{
47  INSPECTCALL(key << " " << istate << " projector");
48  return trackStates->calibrated[istate] < kInvalid;
49  }
50  case "calibrated"_hash:{
51  INSPECTCALL(key << " " << istate << " calibrated");
52  return trackStates->calibrated[istate] < kInvalid;
53  }
54  case "calibratedCov"_hash: {
55  INSPECTCALL(key << " " << istate << " calibratedCov");
56  return trackStates->calibrated[istate] < kInvalid;
57  }
58  case "measdim"_hash: {
59  INSPECTCALL(key << " " << istate << " measdim");
60  return trackStates->measDim[istate] < kInvalid;
61  }
62  case "referenceSurface"_hash: {
63  INSPECTCALL(key << " " << istate << " referenceSurfaceEnco");
64  return true;
65  }
66 
67  // TODO restore once only the EL Source Links are in use
68  // return !trackStates[istate]->uncalibratedMeasurementLink().isDefault();
69  }
70  INSPECTCALL(key << " " << istate << " not a predefined component");
71  return std::optional<bool>();
72 }
73 } // namespace details
74 } // namespace ActsTrk
75 
76 
77 constexpr bool ActsTrk::MutableMultiTrajectory::hasColumn_impl(
78  Acts::HashedString key) const {
79  using namespace Acts::HashedStringLiteral;
80  INSPECTCALL(key);
81 
82  switch (key) {
83  case "previous"_hash:
84  case "chi2"_hash:
85  case "pathLength"_hash:
86  case "typeFlags"_hash:
87  case "predicted"_hash:
88  case "filtered"_hash:
89  case "smoothed"_hash:
90  case "jacobian"_hash:
91  case "projector"_hash:
92  case "uncalibratedSourceLink"_hash:
93  case "calibrated"_hash:
94  case "calibratedCov"_hash:
95  case "measdim"_hash:
96  case "referenceSurface"_hash:
97  return true;
98  default:
99  for (auto& d : m_decorations) {
100  if (d.hash == key) {
101  return true;
102  }
103  }
104  return false;
105  }
106 }
107 
108 template <typename T>
109 void ActsTrk::MutableMultiTrajectory::addColumn_impl(std::string_view name) {
110  // It is actually not clear if we would allow decorating RO MTJ, maybe we do
111  if constexpr (ActsTrk::detail::accepted_decoration_types<T>::value) {
112  m_decorations.emplace_back( ActsTrk::detail::decoration<T>(
113  name,
114  ActsTrk::detail::constDecorationGetter<T>,
115  ActsTrk::detail::decorationCopier<T>,
116  ActsTrk::detail::decorationSetter<T>
117  )
118  );
119  // it would be useful to force presence of decoration already here
120  } else {
121  throw std::runtime_error("Can't add decoration of this type to MutableMultiTrajectory");
122  }
123 }
124 
125 template <typename val_t, typename cov_t>
126 void ActsTrk::MutableMultiTrajectory::allocateCalibrated_impl(IndexType istate,
127  const Eigen::DenseBase<val_t>& val,
128  const Eigen::DenseBase<cov_t>& cov)
129 
130  requires(Eigen::PlainObjectBase<val_t>::RowsAtCompileTime > 0 &&
131  Eigen::PlainObjectBase<val_t>::RowsAtCompileTime <= Acts::eBoundSize &&
132  Eigen::PlainObjectBase<val_t>::RowsAtCompileTime ==
133  Eigen::PlainObjectBase<cov_t>::RowsAtCompileTime &&
134  Eigen::PlainObjectBase<cov_t>::RowsAtCompileTime ==
135  Eigen::PlainObjectBase<cov_t>::ColsAtCompileTime)
136 {
137  constexpr std::size_t measdim = val_t::RowsAtCompileTime;
138 
139  m_trackStatesAux->measDim[istate] = measdim;
140  auto idx = m_trackStatesAux->calibrated[istate];
141  m_trackMeasurementsAux->meas[idx].resize(measdim);
142  m_trackMeasurementsAux->covMatrix[idx].resize(measdim*measdim);
143 
144  double* measPtr = m_trackMeasurementsAux->meas[idx].data();
145  Eigen::Map<Acts::ActsVector<measdim>> valMap(measPtr);
146  valMap = val;
147 
148  double* covPtr = m_trackMeasurementsAux->covMatrix[idx].data();
149  Eigen::Map<Acts::ActsSquareMatrix<measdim>> covMap(covPtr);
150  covMap = cov;
151 }
152