5#include <Acts/Geometry/GeometryIdentifier.hpp>
15constexpr uint64_t
InvalidGeoID = std::numeric_limits<uint64_t>::max();
18constexpr std::optional<bool> has_impl(
21 using namespace Acts::HashedStringLiteral;
22 constexpr auto kInvalid = Acts::kTrackIndexInvalid;
27 return trackStates->
previous[istate] < kInvalid;
32 case "pathLength"_hash:{
36 case "typeFlags"_hash:{
40 case "predicted"_hash:{
42 return trackStates->
predicted[istate] < kInvalid;
44 case "filtered"_hash:{
46 return trackStates->
filtered[istate] < kInvalid;
48 case "smoothed"_hash:{
50 return trackStates->
smoothed[istate] < kInvalid;
52 case "jacobian"_hash:{
54 return trackStates->
jacobian[istate] < kInvalid;
56 case "projector"_hash:{
58 return trackStates->
calibrated[istate] < kInvalid;
60 case "calibrated"_hash:{
62 return trackStates->
measDim[istate] < kInvalid;
64 case "calibratedCov"_hash: {
65 INSPECTCALL(key <<
" " << istate <<
" calibratedCov");
66 return trackStates->
measDim[istate] < kInvalid;
68 case "measdim"_hash: {
72 case "referenceSurface"_hash: {
73 INSPECTCALL(key <<
" " << istate <<
" referenceSurfaceEnco");
80 INSPECTCALL(key <<
" " << istate <<
" not a predefined component");
81 return std::optional<bool>();
96 "chi2",
"pathLength",
"typeFlags",
"previous",
"next",
"predicted",
"filtered",
"smoothed",
"jacobian",
"calibrated",
"measDim",
97 "uncalibratedMeasurement",
"uncalibratedMeasurementLink" ,
"geometryId",
"surfaceIndex"
119 INSPECTCALL(
"copy c-tor " <<
this <<
" src " << &other <<
" " << other.size())
141 throw std::runtime_error(std::format(
"{:}() - Key is unknown {:}",__func__, key));
150 throw std::runtime_error(std::format(
"{:}() - Key is unknown {:}",__func__, key));
151 return typeid(
const void*);
165 m_excluded.insert(Acts::hashStringDynamic(decorName));
169 template<
typename CONT>
170 void stepResize( CONT* auxPtr,
const size_t realSize,
const size_t sizeStep = 20) {
171 if( realSize >= auxPtr->size() ) auxPtr->resize(auxPtr->size()+sizeStep);
176 Acts::TrackStatePropMask mask,
178 using namespace Acts::HashedStringLiteral;
185 constexpr auto kInvalid = Acts::kTrackIndexInvalid;
187 if (previous >= kInvalid - 1)
190 using namespace Acts;
201 auto addJacobian = [
this]() ->
IndexType {
208 auto addMeasurement = [
this]() ->
IndexType {
217 if (ACTS_CHECK_BIT(mask, TrackStatePropMask::Predicted)) {
222 if (ACTS_CHECK_BIT(mask, TrackStatePropMask::Filtered)) {
227 if (ACTS_CHECK_BIT(mask, TrackStatePropMask::Smoothed)) {
232 if (ACTS_CHECK_BIT(mask, TrackStatePropMask::Jacobian)) {
240 if (ACTS_CHECK_BIT(mask, TrackStatePropMask::Calibrated)) {
253 Acts::TrackStatePropMask mask) {
254 using namespace Acts::HashedStringLiteral;
260 constexpr auto kInvalid = Acts::kTrackIndexInvalid;
262 using namespace Acts;
273 auto addJacobian = [
this]() ->
IndexType {
280 auto addMeasurement = [
this]() ->
IndexType {
289 ACTS_CHECK_BIT(mask, TrackStatePropMask::Predicted)) {
294 ACTS_CHECK_BIT(mask, TrackStatePropMask::Filtered)) {
299 ACTS_CHECK_BIT(mask, TrackStatePropMask::Smoothed)) {
304 ACTS_CHECK_BIT(mask, TrackStatePropMask::Jacobian)) {
309 ACTS_CHECK_BIT(mask, TrackStatePropMask::Calibrated)) {
319 Acts::TrackStatePropMask shareSource,
320 Acts::TrackStatePropMask shareTarget) {
322 assert(ACTS_CHECK_BIT(this->getTrackState(iother).getMask(), shareSource) &&
323 "Source has incompatible allocation");
325 using PM = Acts::TrackStatePropMask;
327 constexpr auto kInvalid = Acts::kTrackIndexInvalid;
330 switch (shareSource) {
344 throw std::domain_error{
"MutableMultiTrajectory Unable to share this component"};
347 assert(sourceIndex != kInvalid);
349 switch (shareTarget) {
351 assert(shareSource != PM::Jacobian);
355 assert(shareSource != PM::Jacobian);
359 assert(shareSource != PM::Jacobian);
363 assert(shareSource == PM::Jacobian);
367 throw std::domain_error{
"MutableMultiTrajectory Unable to share this component"};
373 Acts::TrackStatePropMask target,
376 using PM = Acts::TrackStatePropMask;
378 constexpr auto kInvalid = Acts::kTrackIndexInvalid;
402 throw std::domain_error{
"MutableMultiTrajectory Unable to unset this component"};
407 Acts::HashedString key,
IndexType istate) {
408 using namespace Acts::HashedStringLiteral;
410 "Attempt to reach beyond the Track States container size");
411 INSPECTCALL(key <<
" " << istate <<
" non-const component_impl")
414 case "previous"_hash:
420 case "pathLength"_hash:
422 case "predicted"_hash:
424 case "filtered"_hash:
426 case "smoothed"_hash:
428 case "projector"_hash: {
434 case "typeFlags"_hash:
443 throw std::runtime_error(
"MutableMultiTrajectory::component_impl no such component " + std::to_string(key));
450 Acts::HashedString key,
452 using namespace Acts::HashedStringLiteral;
454 "Attempt to reach beyond the Track States container size");
455 INSPECTCALL(key <<
" " << istate <<
" const component_impl")
457 case "previous"_hash:
463 case "pathLength"_hash:
465 case "predicted"_hash:
467 case "filtered"_hash:
469 case "smoothed"_hash:
471 case "jacobian"_hash:
473 case "projector"_hash:{
477 case "calibrated"_hash: {
480 case "calibratedCov"_hash: {
485 case "typeFlags"_hash:
490 INSPECTCALL(
"getting dynamic variable " << d.name <<
" " << istate);
494 throw std::runtime_error(
"MutableMultiTrajectory::component_impl const no such component " + std::to_string(key));
500 Acts::HashedString key,
IndexType istate)
const {
502 if (inTrackState.has_value())
503 return inTrackState.value();
506 using namespace Acts::HashedStringLiteral;
507 if (key ==
"uncalibratedSourceLink"_hash){
508 INSPECTCALL(key <<
" " << istate <<
" uncalibratedSourceLink")
556 const Acts::SourceLink& sourceLink) {
560 static const Decor_t decor{
"uncalibratedMeasurement"};
562 throw std::range_error(
"istate out of range on TrackStates when attempting to access uncalibrated measurements");
575 uncalibratedMeasurements.at(istate) = std::get<const xAOD::UncalibratedMeasurement*>(unpacked);
580 }
catch (
const std::bad_any_cast &err) {
583 uncalibratedMeasurements.at(istate) = unpacked;
584 }
catch (
const std::bad_any_cast &err1) {
592 std::shared_ptr<const Acts::Surface> surface) {
597 if (surface->geometryId().value() == 0) {
610 const Acts::Surface* toSurfacePtr(
const StoredSurface& surfaceVariant) {
611 if ( std::holds_alternative<const Acts::Surface*>(surfaceVariant))
612 return std::get<const Acts::Surface*>(surfaceVariant);
613 return std::get<std::shared_ptr<const Acts::Surface>>(surfaceVariant).
get();
618 if ( istate >=
m_surfaces.size() )
throw std::out_of_range(
"MutableMultiTrajectory index " + std::to_string(istate) +
" out of range " + std::to_string(
m_surfaces.size()) +
" when accessing reference surface");
623 Acts::HashedString key,
624 const std::any& src_ptr) {
626 INSPECTCALL(
"copy dynamic decoration of key " << key <<
" destination MTJ has " <<
m_decorations.size() <<
" decorations");
628 INSPECTCALL(
"checking for destination of dynamic decoration " << d.name <<
" hash " << d.hash <<
" while looking for the key " << key);
634 throw std::invalid_argument(
"MultiTrajectory::copyDynamicFrom_impl no such decoration in destination MTJ " + std::to_string(key));
638 std::vector<Acts::HashedString> keys;
640 keys.push_back(d.hash);
641 INSPECTCALL(
"collecting dynamic decoration " << d.name <<
" hash " << d.hash);
694 if (inTrackState.has_value())
695 return inTrackState.value();
697 using namespace Acts::HashedStringLiteral;
698 if (key ==
"uncalibratedSourceLink"_hash) {
711 Acts::HashedString key,
IndexType istate)
const {
712 using namespace Acts::HashedStringLiteral;
714 case "previous"_hash:
720 case "pathLength"_hash:
722 case "predicted"_hash:
724 case "filtered"_hash:
726 case "smoothed"_hash:
728 case "jacobian"_hash:
730 case "projector"_hash: {
733 case "calibrated"_hash: {
736 case "calibratedCov"_hash: {
741 case "typeFlags"_hash:
750 throw std::runtime_error(
"MultiTrajectory::component_impl no such component " + std::to_string(key));
756 Acts::HashedString key)
const {
757 using namespace Acts::HashedStringLiteral;
760 case "previous"_hash:
763 case "pathLength"_hash:
764 case "predicted"_hash:
765 case "filtered"_hash:
766 case "smoothed"_hash:
767 case "jacobian"_hash:
768 case "projector"_hash:
769 case "uncalibratedSourceLink"_hash:
770 case "calibrated"_hash:
771 case "calibratedCov"_hash:
773 case "typeFlags"_hash:
802 std::vector<Acts::HashedString> keys;
804 keys.push_back(d.hash);
821 m_surfaces[i] = geo->findSurface(Acts::GeometryIdentifier{geoID});
834 if ( istate >=
m_surfaces.size() )
throw std::out_of_range(
"MultiTrajectory index " + std::to_string(istate) +
" out of range " + std::to_string(
m_surfaces.size()) +
" when accessing reference surface");
838typename Acts::SourceLink
855typename Acts::SourceLink
const T * to_const_ptr(const std::unique_ptr< T > &ptr)
constexpr uint64_t InvalidGeoID
#define INSPECTCALL(_INFO)
size_t size() const
Number of registered mappings.
std::vector< std::optional< Acts::SourceLink > > m_uncalibratedSourceLinks
bool has_impl(Acts::HashedString key, ActsTrk::IndexType istate) const
const DataLink< xAOD::TrackParametersAuxContainer > m_trackParametersAux
Acts::SourceLink getUncalibratedSourceLink_impl(ActsTrk::IndexType istate) 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
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
ActsTrk::IndexType calibratedSize_impl(ActsTrk::IndexType istate) const
MultiTrajectory(DataLink< xAOD::TrackStateAuxContainer > trackStates, DataLink< xAOD::TrackParametersAuxContainer > trackParameters, DataLink< xAOD::TrackJacobianAuxContainer > trackJacobians, DataLink< xAOD::TrackMeasurementAuxContainer > trackMeasurements, DataLink< xAOD::TrackSurfaceAuxContainer > trackSurfaces)
void fillSurfaces(const Acts::TrackingGeometry *geo)
Fill surfaces either from persistency or from geometry If the surfaces are already there it means tha...
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...
std::vector< StoredSurface > m_surfaces
static const std::set< std::string > s_staticVariables
GeometryContext m_geoContext
void ensureDynamicColumns_impl(const Acts::ConstVectorMultiTrajectory &other)
std::vector< std::optional< Acts::SourceLink > > m_calibratedSourceLinks
void excludeDecoration(std::string_view decorName)
size_t m_trackMeasurementsSize
bool has_impl(Acts::HashedString key, ActsTrk::IndexType istate) const
checks if given state has requested component
std::vector< ActsTrk::detail::Decoration > m_decorations
Acts::SourceLink getUncalibratedSourceLink_impl(ActsTrk::IndexType istate) const
Implementation of uncalibrated link fetch.
std::unordered_set< Acts::HashedString > m_excluded
void setReferenceSurface_impl(IndexType, std::shared_ptr< const Acts::Surface >)
std::unique_ptr< xAOD::TrackParametersAuxContainer > m_trackParametersAux
void unset_impl(Acts::TrackStatePropMask target, ActsTrk::IndexType istate)
unsets a given state
std::any component_impl(Acts::HashedString key, ActsTrk::IndexType istate) const
Access component by key.
MutableMultiTrajectory()
Construct a new Multi Trajectory object owning backends.
size_t m_trackParametersSize
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::unique_ptr< xAOD::TrackSurfaceAuxContainer > m_surfacesBackendAux
const Acts::Surface * referenceSurface_impl(IndexType) const
std::vector< std::optional< Acts::SourceLink > > m_uncalibratedSourceLinks
ActsTrk::IndexType calibratedSize_impl(ActsTrk::IndexType istate) const
Implementation of calibrated size.
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
const std::type_info & columnDataType_impl(Acts::HashedString key) const
std::unique_ptr< xAOD::TrackSurfaceContainer > m_surfacesBackend
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
std::string_view columnName_impl(Acts::HashedString key) const
ActsTrk::IndexType addTrackState_impl(Acts::TrackStatePropMask mask, ActsTrk::IndexType iprevious)
Add state with stograge for data that depends on the mask.
size_t m_trackJacobiansSize
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
static Acts::SourceLink pack(const Ptr_t &measurement)
Pack the measurement type pointer to an Acts::SourceLink including the intermediate conversion into a...
static SourceLinkType getType(const Acts::SourceLink &sl)
Returns the enumeration corresponding to the object type cached within the Acts::SourceLink.
static SourceLink_t unpackBase(const Acts::SourceLink &sl)
Unpack the SourceLink_t from the passed Acts source link.
Object reference supporting deferred reading from StoreGate.
const_pointer cptr() const
Dereference the link.
const std::type_info * getType(SG::auxid_t auxid) const
Return the type of an aux data item.
static AuxTypeRegistry & instance()
Return the singleton registry instance.
Helper class to provide constant type-safe access to aux data.
std::vector< TrackStateIndexType > measDim
std::vector< TrackStateIndexType > filtered
std::vector< TrackStateIndexType > calibrated
std::vector< TrackStateIndexType > smoothed
std::vector< TrackStateIndexType > predicted
std::vector< TrackStateIndexType > jacobian
std::vector< TrackStateIndexType > previous
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
std::vector< Decoration > restoreDecorations(const SG::IConstAuxStore *container, const std::set< std::string > &staticVariables)
@ xAODUnCalibMeas
UnCalibrated Trk::PrepRawData objects.
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
void encodeSurface(xAOD::TrackSurfaceAuxContainer *backend, size_t index, const Acts::Surface *surface, const Acts::GeometryContext &geoContext)
Prepares persistifiable representation of surface into xAOD::TrackSurface object.
std::shared_ptr< const Acts::Surface > decodeSurface(const xAOD::TrackSurface *backend)
Creates transient Acts Surface objects given a surface backend implementation should be exact mirror ...
void ensureDynamicColumns(const std::unordered_set< Acts::HashedString > &exclude, const cont_in &in_container, cont_out &out_container)
std::variant< const Acts::Surface *, std::shared_ptr< const Acts::Surface > > StoredSurface
This class is not to needed in AthSimulation.
SG::Decorator< T, ALLOC > Decorator
Helper class to provide type-safe access to aux data, specialized for JaggedVecElt.
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
TrackStateAuxContainer_v1 TrackStateAuxContainer
UncalibratedMeasurement_v1 UncalibratedMeasurement
Define the version of the uncalibrated measurement class.
TrackSurface_v1 TrackSurface