ATLAS Offline Software
Loading...
Searching...
No Matches
MultiTrajectory.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4#ifndef ActsEvent_MultiTrajectory_h
5#define ActsEvent_MultiTrajectory_h
6#include <memory>
7#include <type_traits>
8#include <variant>
9#include <string_view>
10
11#include "Acts/EventData/MultiTrajectory.hpp"
12#include "Acts/EventData/SourceLink.hpp"
13#include "Acts/EventData/TrackStatePropMask.hpp"
14#include "Acts/EventData/VectorMultiTrajectory.hpp"
15#include "Acts/Utilities/HashedString.hpp"
16#include "Acts/Geometry/TrackingGeometry.hpp"
18#include "Acts/Surfaces/Surface.hpp"
19#include "CxxUtils/concepts.h"
28// #define DEBUG_MTJ
29#ifdef DEBUG_MTJ
30#define INSPECTCALL(_INFO) {std::cout << __FILE__ <<":"<<__LINE__<<" "<<__PRETTY_FUNCTION__<<" "<<_INFO<<std::endl; }
31#else
32#define INSPECTCALL(_INFO)
33#endif
35
36namespace ActsTrk {
37class MutableMultiTrajectory;
38class MultiTrajectory;
39class MutableTrackContainerHandlesHelper;
40} // namespace ActsTrk
41
42namespace Acts {
43class Surface;
44template <typename T>
46
47template <typename T>
49
50template <typename T>
52
53template <>
54struct IsReadOnlyMultiTrajectory<ActsTrk::MultiTrajectory>
55 : std::true_type {};
56
57template <>
58struct IsReadOnlyMultiTrajectory<ActsTrk::MutableMultiTrajectory>
59 : std::false_type {};
60} // namespace Acts
61
62namespace ActsTrk {
63
64using IndexType = std::uint32_t;
65
66using StoredSurface = std::variant<const Acts::Surface*, std::shared_ptr<const Acts::Surface>>;
67
68
78 : public Acts::MultiTrajectory<ActsTrk::MutableMultiTrajectory> {
79 public:
81 using TrackStateProxy = typename Acts::MultiTrajectory<
83 using ConstTrackStateProxy = typename Acts::MultiTrajectory<
85
93
101 ActsTrk::IndexType addTrackState_impl(Acts::TrackStatePropMask mask,
102 ActsTrk::IndexType iprevious);
103
111 Acts::TrackStatePropMask mask);
112
121
122 std::any component_impl(Acts::HashedString key, ActsTrk::IndexType istate) const;
123 std::any component_impl(Acts::HashedString key, ActsTrk::IndexType istate);
124
133 bool has_impl(Acts::HashedString key, ActsTrk::IndexType istate) const;
134
142 constexpr bool hasColumn_impl(Acts::HashedString key) const;
143
150 template <typename T>
151 void addColumn_impl(std::string_view key);
152
159
160 void unset_impl(Acts::TrackStatePropMask target, ActsTrk::IndexType istate);
161
168
170 Acts::TrackStatePropMask shareSource,
171 Acts::TrackStatePropMask shareTarget);
172
179
180 typename ConstTrackStateProxy::Parameters parameters_impl(
182 return typename ConstTrackStateProxy::Parameters{m_trackParametersAux->params[index].data()};
183 }
184
185 typename TrackStateProxy::Parameters parameters_impl(ActsTrk::IndexType index) {
186 return typename TrackStateProxy::Parameters{m_trackParametersAux->params[index].data()};
187 }
188
195 typename ConstTrackStateProxy::Covariance covariance_impl(
197 return typename ConstTrackStateProxy::Covariance{m_trackParametersAux->covMatrix[index].data()};
198 }
199 typename TrackStateProxy::Covariance covariance_impl(ActsTrk::IndexType index) {
200 return typename TrackStateProxy::Covariance{m_trackParametersAux->covMatrix[index].data()};
201 }
202
209 typename ConstTrackStateProxy::Covariance trackMeasurementsCov(
211 return typename ConstTrackStateProxy::Covariance{m_trackMeasurementsAux->covMatrix[index].data()};
212
213 }
214
215 typename TrackStateProxy::Covariance trackMeasurementsCov(ActsTrk::IndexType index) {
216 return typename TrackStateProxy::Covariance{m_trackMeasurementsAux->covMatrix[index].data()};
217
218 }
219
226
227 inline typename ConstTrackStateProxy::Covariance jacobian_impl(
228 ActsTrk::IndexType istate) const {
229 xAOD::TrackStateIndexType jacIdx = m_trackStatesAux->jacobian[istate];
230 return typename ConstTrackStateProxy::Covariance{m_trackJacobiansAux->jac[jacIdx].data()};
231 }
232
233 typename TrackStateProxy::Covariance jacobian_impl(ActsTrk::IndexType istate) {
234 xAOD::TrackStateIndexType jacIdx = m_trackStatesAux->jacobian[istate];
235 return typename TrackStateProxy::Covariance{m_trackJacobiansAux->jac[jacIdx].data()};
236 }
237
244
245 template <std::size_t measdim>
246 inline typename ConstTrackStateProxy::template Calibrated<measdim>
248 xAOD::TrackStateIndexType measIdx = m_trackStatesAux->calibrated[index];
249 return typename ConstTrackStateProxy::template Calibrated<measdim>{m_trackMeasurementsAux->meas[measIdx].data()};
250 }
251
252 template <std::size_t measdim, bool Enable = true>
253 std::enable_if_t<Enable,
254 typename TrackStateProxy::template Calibrated<measdim>>
256 xAOD::TrackStateIndexType measIdx = m_trackStatesAux->calibrated[index];
257 return typename TrackStateProxy::template Calibrated<measdim>{m_trackMeasurementsAux->meas[measIdx].data()};
258 }
259
266
267 template <std::size_t measdim>
268 inline typename ConstTrackStateProxy::template CalibratedCovariance<measdim>
270 xAOD::TrackStateIndexType measIdx = m_trackStatesAux->calibrated[index];
271 return ConstTrackStateProxy::template CalibratedCovariance<measdim>{m_trackMeasurementsAux->covMatrix[measIdx].data()};
272 }
273 template <std::size_t measdim, bool Enable = true>
274 std::enable_if_t<
275 Enable, typename TrackStateProxy::template CalibratedCovariance<measdim>>
277 xAOD::TrackStateIndexType measIdx = m_trackStatesAux->calibrated[index];
278 return TrackStateProxy::template CalibratedCovariance<measdim>{m_trackMeasurementsAux->covMatrix[measIdx].data()};
279 }
280
286
287 inline Acts::TrackIndexType size_impl() const {
288 return m_trackStatesSize;
289 }
290
295 void clear_impl();
296
301 bool has_backends() const;
302
306 template <typename val_t, typename cov_t>
308 const Eigen::DenseBase<val_t>& val,
309 const Eigen::DenseBase<cov_t>& cov)
310 requires(Eigen::PlainObjectBase<val_t>::RowsAtCompileTime > 0 &&
311 Eigen::PlainObjectBase<val_t>::RowsAtCompileTime <= Acts::eBoundSize &&
312 Eigen::PlainObjectBase<val_t>::RowsAtCompileTime ==
313 Eigen::PlainObjectBase<cov_t>::RowsAtCompileTime &&
314 Eigen::PlainObjectBase<cov_t>::RowsAtCompileTime ==
315 Eigen::PlainObjectBase<cov_t>::ColsAtCompileTime);
316
321
326 const Acts::SourceLink& sourceLink);
327
331 typename Acts::SourceLink getUncalibratedSourceLink_impl(
332 ActsTrk::IndexType istate) const;
333
335 std::shared_ptr<const Acts::Surface>);
336 const Acts::Surface* referenceSurface_impl(IndexType ) const;
337
346 Acts::HashedString key,
347 const std::any& src_ptr);
351 std::vector<Acts::HashedString> dynamicKeys_impl() const;
352
353 // access to some backends (for debugging purposes)
354 // the receiver should not assume ownership or similar
356
358 return m_trackParametersAux.get();
359 }
363
367
371
379 return m_surfacesBackend.get();
380 }
381
382 static const std::set<std::string> s_staticVariables;
383
385
386 private:
387
388 std::unique_ptr<xAOD::TrackStateAuxContainer> m_trackStatesAux;
390
391 std::unique_ptr<xAOD::TrackParametersAuxContainer> m_trackParametersAux;
393
394 std::unique_ptr<xAOD::TrackJacobianAuxContainer> m_trackJacobiansAux;
396
397 std::unique_ptr<xAOD::TrackMeasurementAuxContainer> m_trackMeasurementsAux;
399
400 std::unique_ptr<xAOD::TrackSurfaceContainer> m_surfacesBackend;
401 std::unique_ptr<xAOD::TrackSurfaceAuxContainer> m_surfacesBackendAux;
402 std::vector<ActsTrk::detail::Decoration> m_decorations;
403
404 std::vector<std::optional<Acts::SourceLink>> m_calibratedSourceLinks;
405 std::vector<std::optional<Acts::SourceLink>> m_uncalibratedSourceLinks;
406
407 std::vector<StoredSurface> m_surfaces;
409
411
412 // adjust preallocated size to actually used
413 void trim();
414};
415
422 : public Acts::MultiTrajectory<MultiTrajectory> {
423 public:
424
431
433
434 bool has_impl(Acts::HashedString key, ActsTrk::IndexType istate) const;
435
436 std::any component_impl(Acts::HashedString key, ActsTrk::IndexType istate) const;
437
438 bool hasColumn_impl(Acts::HashedString key) const;
439
440 typename ConstTrackStateProxy::Parameters parameters_impl(
442 return typename ConstTrackStateProxy::Parameters{m_trackParametersAux->params[index].data()};
443 }
444
445 typename ConstTrackStateProxy::Covariance covariance_impl(
447 return typename ConstTrackStateProxy::Covariance{m_trackParametersAux->covMatrix[index].data()};
448 }
449
450 inline typename ConstTrackStateProxy::Covariance jacobian_impl(
451 ActsTrk::IndexType istate) const {
452 xAOD::TrackStateIndexType jacIdx = m_trackStatesAux->jacobian[istate];
453 return typename ConstTrackStateProxy::Covariance{m_trackJacobiansAux->jac[jacIdx].data()};
454 }
455
456 template <std::size_t measdim>
457 inline typename ConstTrackStateProxy::template Calibrated<measdim>
459 xAOD::TrackStateIndexType measIdx = m_trackStatesAux->calibrated[istate];
460 return typename ConstTrackStateProxy::template Calibrated<measdim>{m_trackMeasurementsAux->meas[measIdx].data()};
461 }
462
463 template <std::size_t measdim>
464 inline typename ConstTrackStateProxy::template CalibratedCovariance<measdim>
466 xAOD::TrackStateIndexType measIdx = m_trackStatesAux->calibrated[index];
467 return typename ConstTrackStateProxy::template CalibratedCovariance<measdim>{m_trackMeasurementsAux->covMatrix[measIdx].data()};
468 }
469 inline Acts::TrackIndexType size_impl() const { return m_trackStatesAux->size(); }
470
472 typename Acts::SourceLink getUncalibratedSourceLink_impl(ActsTrk::IndexType istate) const;
473
474 const Acts::Surface* referenceSurface_impl(IndexType) const;
475
480 void fillSurfaces(const Acts::TrackingGeometry* geo);
485
487
488 std::vector<Acts::HashedString> dynamicKeys_impl() const;
489
490 private:
496 std::vector<ActsTrk::detail::Decoration> m_decorations;
497
498 // TODO remove once tracking code switches to sourceLinks with EL
499 std::vector<std::optional<Acts::SourceLink>> m_calibratedSourceLinks;
500 // still need this to store SourceLinks with other payloads than
501 // pointer to xAOD::UncalibratedMeasurement e.g. pointer to Trk::Measurements
502 // when converting Trk::Tracks to Acts tracks.
503 std::vector<std::optional<Acts::SourceLink>> m_uncalibratedSourceLinks;
504
505 std::vector<StoredSurface> m_surfaces;
506
508};
509
510
515template<typename IFACE, typename AUX>
516std::unique_ptr<IFACE> makeInterfaceContainer(const AUX* aux) {
517 auto interface = std::make_unique<IFACE>();
518 for ( size_t i = 0, sz = aux->size(); i < sz; ++i) {
519 interface->emplace_back( new std::remove_pointer_t<typename IFACE::value_type>() );
520 }
521 interface->setStore(aux);
522 return interface;
523}
524
525
526} // namespace ActsTrk
527
528#include "MultiTrajectory.icc"
529
530
532CLASS_DEF( ActsTrk::MultiTrajectory , 51219308 , 1 )
533
534// These two lines shouldn't be here, but necessary until we have a proper
535// solution
536#include "Acts/EventData/VectorTrackContainer.hpp"
537CLASS_DEF(Acts::ConstVectorTrackContainer, 1074811884, 1)
538
539#endif
macros to associate a CLID to a type
#define CLASS_DEF(NAME, CID, VERSION)
associate a clid and a version to a type eg
static Double_t sz
Read only version of MTJ The implementation is separate as the details are significantly different an...
ConstTrackStateProxy::Covariance jacobian_impl(ActsTrk::IndexType istate) const
std::vector< std::optional< Acts::SourceLink > > m_uncalibratedSourceLinks
Acts::TrackIndexType size_impl() const
bool has_impl(Acts::HashedString key, ActsTrk::IndexType istate) const
const DataLink< xAOD::TrackParametersAuxContainer > m_trackParametersAux
Acts::SourceLink getUncalibratedSourceLink_impl(ActsTrk::IndexType istate) const
ConstTrackStateProxy::template CalibratedCovariance< measdim > calibratedCovariance_impl(IndexType index) const
const DataLink< xAOD::TrackMeasurementAuxContainer > m_trackMeasurementsAux
std::vector< ActsTrk::detail::Decoration > m_decorations
xAOD::TrackStateContainer m_trackStatesIface
const DataLink< xAOD::TrackStateAuxContainer > m_trackStatesAux
std::vector< Acts::HashedString > dynamicKeys_impl() const
std::vector< std::optional< Acts::SourceLink > > m_calibratedSourceLinks
std::vector< StoredSurface > m_surfaces
ActsTrk::IndexType calibratedSize_impl(ActsTrk::IndexType istate) const
std::any component_impl(Acts::HashedString key, ActsTrk::IndexType istate) const
void moveSurfaces(const ActsTrk::MutableMultiTrajectory *mtj)
reuse surfaces from MutableMultiTrajectory
const Acts::Surface * referenceSurface_impl(IndexType) const
const DataLink< xAOD::TrackSurfaceAuxContainer > m_trackSurfacesAux
const DataLink< xAOD::TrackJacobianAuxContainer > m_trackJacobiansAux
ConstTrackStateProxy::Covariance covariance_impl(ActsTrk::IndexType index) const
MultiTrajectory(DataLink< xAOD::TrackStateAuxContainer > trackStates, DataLink< xAOD::TrackParametersAuxContainer > trackParameters, DataLink< xAOD::TrackJacobianAuxContainer > trackJacobians, DataLink< xAOD::TrackMeasurementAuxContainer > trackMeasurements, DataLink< xAOD::TrackSurfaceAuxContainer > trackSurfaces)
ConstTrackStateProxy::template Calibrated< measdim > calibrated_impl(IndexType istate) const
void fillSurfaces(const Acts::TrackingGeometry *geo)
Fill surfaces either from persistency or from geometry If the surfaces are already there it means tha...
ConstTrackStateProxy::Parameters parameters_impl(ActsTrk::IndexType index) const
void moveLinks(const ActsTrk::MutableMultiTrajectory *mtj)
bool hasColumn_impl(Acts::HashedString key) const
Athena implementation of ACTS::MultiTrajectory (ReadWrite version) The data is stored in 4 external b...
ConstTrackStateProxy::Parameters parameters_impl(ActsTrk::IndexType index) const
obtains proxy to the track state under given index
TrackStateProxy::Covariance trackMeasurementsCov(ActsTrk::IndexType index)
std::vector< StoredSurface > m_surfaces
static const std::set< std::string > s_staticVariables
MutableMultiTrajectory(ActsTrk::MutableMultiTrajectory &&other)=default
ConstTrackStateProxy::Covariance covariance_impl(ActsTrk::IndexType index) const
obtain covariances for a state at given index
ConstTrackStateProxy::Covariance trackMeasurementsCov(ActsTrk::IndexType index) const
obtain measurement covariances for a state at given index
std::vector< std::optional< Acts::SourceLink > > m_calibratedSourceLinks
xAOD::TrackJacobianAuxContainer * trackJacobiansAux()
bool has_impl(Acts::HashedString key, ActsTrk::IndexType istate) const
checks if given state has requested component
constexpr bool hasColumn_impl(Acts::HashedString key) const
checks if MTJ has requested column (irrespectively of the state)
TrackStateProxy::Covariance jacobian_impl(ActsTrk::IndexType istate)
std::vector< ActsTrk::detail::Decoration > m_decorations
Acts::SourceLink getUncalibratedSourceLink_impl(ActsTrk::IndexType istate) const
Implementation of uncalibrated link fetch.
void setReferenceSurface_impl(IndexType, std::shared_ptr< const Acts::Surface >)
std::unique_ptr< xAOD::TrackParametersAuxContainer > m_trackParametersAux
const xAOD::TrackParametersAuxContainer * trackParametersAux() const
ActsTrk::IndexType addTrackState_impl(Acts::TrackStatePropMask mask, ActsTrk::IndexType iprevious)
Add state with stograge for data that depends on the mask.
typename Acts::MultiTrajectory< ActsTrk::MutableMultiTrajectory >::TrackStateProxy TrackStateProxy
MutableMultiTrajectory & operator=(const ActsTrk::MutableMultiTrajectory &other)=delete
void unset_impl(Acts::TrackStatePropMask target, ActsTrk::IndexType istate)
unsets a given state
typename Acts::MultiTrajectory< ActsTrk::MutableMultiTrajectory >::ConstTrackStateProxy ConstTrackStateProxy
std::any component_impl(Acts::HashedString key, ActsTrk::IndexType istate) const
Access component by key.
MutableMultiTrajectory()
Construct a new Multi Trajectory object owning backends.
xAOD::TrackStateContainer m_trackStatesIface
std::vector< Acts::HashedString > dynamicKeys_impl() const
returns the keys of all the dynamic columns
std::unique_ptr< xAOD::TrackStateAuxContainer > m_trackStatesAux
std::enable_if_t< Enable, typename TrackStateProxy::template Calibrated< measdim > > calibrated_impl(ActsTrk::IndexType index)
ConstTrackStateProxy::template CalibratedCovariance< measdim > calibratedCovariance_impl(ActsTrk::IndexType index) const
obtain measurements covariance for a state at given index
std::unique_ptr< xAOD::TrackSurfaceAuxContainer > m_surfacesBackendAux
const Acts::Surface * referenceSurface_impl(IndexType) const
std::vector< std::optional< Acts::SourceLink > > m_uncalibratedSourceLinks
Acts::TrackIndexType size_impl() const
size of the MTJ
xAOD::TrackSurfaceContainer * trackSurfaces()
std::unique_ptr< xAOD::TrackMeasurementAuxContainer > m_trackMeasurementsAux
void addTrackStateComponents_impl(ActsTrk::IndexType istate, Acts::TrackStatePropMask mask)
Add state components for the given mask.
void copyDynamicFrom_impl(ActsTrk::IndexType istate, Acts::HashedString key, const std::any &src_ptr)
copy dynamic data from another MTJ
xAOD::TrackMeasurementAuxContainer * trackMeasurementsAux()
TrackStateProxy::Covariance covariance_impl(ActsTrk::IndexType index)
ConstTrackStateProxy::template Calibrated< measdim > calibrated_impl(ActsTrk::IndexType index) const
obtain calibrated measurements for a state at given index
const xAOD::TrackSurfaceContainer * trackSurfaces() const
std::unique_ptr< xAOD::TrackSurfaceContainer > m_surfacesBackend
ConstTrackStateProxy::Covariance jacobian_impl(ActsTrk::IndexType istate) const
obtain jacobian for a state at given index
TrackStateProxy::Parameters parameters_impl(ActsTrk::IndexType index)
bool has_backends() const
checks if the backends are connected (i.e.
void shareFrom_impl(ActsTrk::IndexType iself, ActsTrk::IndexType iother, Acts::TrackStatePropMask shareSource, Acts::TrackStatePropMask shareTarget)
shares from a given state
ActsTrk::IndexType calibratedSize_impl(ActsTrk::IndexType istate) const
Implementation of calibrated size.
std::enable_if_t< Enable, typename TrackStateProxy::template CalibratedCovariance< measdim > > calibratedCovariance_impl(ActsTrk::IndexType index)
void allocateCalibrated_impl(IndexType istate, const Eigen::DenseBase< val_t > &val, const Eigen::DenseBase< cov_t > &cov)
Implementation of allocation of calibrated measurements.
xAOD::TrackParametersAuxContainer * trackParametersAux()
void addColumn_impl(std::string_view key)
enables particular decoration, type & name need to be specified
xAOD::TrackStateAuxContainer * trackStatesAux()
xAOD::TrackSurfaceAuxContainer * trackSurfacesAux()
std::unique_ptr< xAOD::TrackJacobianAuxContainer > m_trackJacobiansAux
void setUncalibratedSourceLink_impl(ActsTrk::IndexType istate, const Acts::SourceLink &sourceLink)
Implementation of uncalibrated link insertion.
void clear_impl()
clears backends decoration columns are still declared
A couple standard-library related concepts.
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
std::variant< const Acts::Surface *, std::shared_ptr< const Acts::Surface > > StoredSurface
std::unique_ptr< IFACE > makeInterfaceContainer(const AUX *aux)
helper to construct interface container for already filled Aux container TODO maybe should be moved t...
std::uint32_t IndexType
Definition Decoration.h:14
Definition index.py:1
TrackStateContainer_v1 TrackStateContainer
TrackSurfaceAuxContainer_v1 TrackSurfaceAuxContainer
TrackSurfaceContainer_v1 TrackSurfaceContainer
TrackStateAuxContainer_v1 TrackStateAuxContainer
TrackParametersAuxContainer_v1 TrackParametersAuxContainer
TrackJacobianAuxContainer_v1 TrackJacobianAuxContainer
uint32_t TrackStateIndexType
TrackMeasurementAuxContainer_v1 TrackMeasurementAuxContainer