ATLAS Offline Software
Loading...
Searching...
No Matches
Decoration.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4#include "Acts/Utilities/HashedString.hpp"
7
8namespace ActsTrk{
9 std::optional<TrackContainer::ConstTrackProxy> getActsTrack(const xAOD::TrackParticle& trkPart) {
10 static const SG::AuxElement::ConstAccessor<ElementLink<TrackContainer> > acc("actsTrack");
11 static_assert(std::is_same<ElementLink<TrackContainer>::ElementConstReference,
12 std::optional<TrackContainer::ConstTrackProxy> >::value);
13
14 if (!acc.isAvailable(trkPart) || !acc(trkPart).isValid()) {
15 return std::nullopt;
16 }
17 return(*acc(trkPart));
18
19}
20std::optional<ActsTrk::TrackContainer::ConstTrackStateProxy>
22 const bool skipOutlier) {
23 auto actsTrk = getActsTrack(trkPart);
24 if (!actsTrk) {
25 return std::nullopt;
26 }
27 for (const auto& state : actsTrk->trackStatesReversed()) {
28 if ((state.typeFlags().isOutlier() && skipOutlier) ||
29 !state.hasUncalibratedSourceLink()) {
30 continue;
31 }
32 return state;
33 }
34 return std::nullopt;
35}
36
37std::optional<ActsTrk::TrackContainer::ConstTrackStateProxy>
39 const bool skipOutlier) {
40 auto actsTrk = getActsTrack(trkPart);
41 if (!actsTrk) {
42 return std::nullopt;
43 }
44 for (const auto& state : actsTrk->trackStates()) {
45 if ((state.typeFlags().isOutlier() && skipOutlier) ||
46 !state.hasUncalibratedSourceLink()) {
47 continue;
48 }
49 return state;
50 }
51 return std::nullopt;
52}
53
54std::optional<Acts::BoundTrackParameters>
56 const bool skipOutlier) {
57 auto lastTrkProxy = lastMeasurementState(trkPart, skipOutlier);
58 if (!lastTrkProxy) {
59 return std::nullopt;
60 }
61 return getActsTrack(trkPart)->createParametersFromState(*lastTrkProxy);
62}
63
64std::optional<Acts::BoundTrackParameters>
66 const bool skipOutlier) {
67 auto firstTrkProxy = firstMeasurementState(trkPart, skipOutlier);
68 if (!firstTrkProxy) {
69 return std::nullopt;
70 }
71 return getActsTrack(trkPart)->createParametersFromState(*firstTrkProxy);
72}
73}
74
75namespace ActsTrk::detail {
76
77template<typename T>
78bool build (const std::type_info* typeInfo, const std::string& name, std::vector<Decoration>& decorations){
79 if (*typeInfo == typeid(T)) {
80 decorations.emplace_back(
83 return true;
84 }
85 return false;
86}
87
88
89std::vector<Decoration> restoreDecorations(
90 const SG::IConstAuxStore* container,
91 const std::set<std::string>& staticVariables) {
92 std::vector<Decoration> decorations;
93 for (auto id : container->getAuxIDs()) {
94 const std::string name = SG::AuxTypeRegistry::instance().getName(id);
95 const std::type_info* typeInfo =
97 if (staticVariables.count(name) == 1) {
98 continue;
99 }
100
101 // try making decoration accessor of matching type
102 // there is a fixed set of supported types (as there is a fixed set
103 // available in MutableMTJ) setters are not needed so replaced by a
104 if ( build<float>(typeInfo, name, decorations) ||
105 build<double>(typeInfo, name, decorations) ||
106 build<short>(typeInfo, name, decorations) ||
107 build<int>(typeInfo, name, decorations) ||
108 build<uint8_t>(typeInfo, name, decorations) ||
109 build<uint16_t>(typeInfo, name, decorations) ||
110 build<uint32_t>(typeInfo, name, decorations) ||
111 build<uint64_t>(typeInfo, name, decorations) ||
112 build<int8_t>(typeInfo, name, decorations) ||
113 build<int16_t>(typeInfo, name, decorations) ||
114 build<int32_t>(typeInfo, name, decorations) ||
115 build<int64_t>(typeInfo, name, decorations)
116 ) {
117 continue;
118 }
119 throw std::runtime_error("Can't restore decoration of " + name +
120 " because it is of an unsupported type");
121 }
122 return decorations;
123}
124} // namespace ActsTrk::detail
const std::type_info * getType(SG::auxid_t auxid) const
Return the type of an aux data item.
std::string getName(SG::auxid_t auxid) const
Return the name of an aux data item.
static AuxTypeRegistry & instance()
Return the singleton registry instance.
const SG::auxid_set_t & getAuxIDs() const
Return a set of identifiers for existing data items in store associated with this object.
Hash functions to pack the source link into unordered_maps / unordered_sets.
void decorationCopier(SG::IAuxStore *dst, ActsTrk::IndexType dst_idx, SG::auxid_t decorationId, const std::any &src_ptr)
Definition Decoration.h:80
const std::any constDecorationGetter(const SG::IConstAuxStore *container, ActsTrk::IndexType idx, SG::auxid_t decorationId)
Definition Decoration.h:53
bool build(const std::type_info *typeInfo, const std::string &name, std::vector< Decoration > &decorations)
static Decoration decoration(std::string_view n, GetterType g, CopierType c, SetterType s=static_cast< SetterType >(nullptr))
Definition Decoration.h:87
std::vector< Decoration > restoreDecorations(const SG::IConstAuxStore *container, const std::set< std::string > &staticVariables)
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
std::optional< ActsTrk::TrackContainer::ConstTrackStateProxy > firstMeasurementState(const xAOD::TrackParticle &trkPart, const bool skipOutlier=true)
Returns the track state proxy corresponding to the measurement that is closest to the defining track ...
std::optional< ActsTrk::TrackContainer::ConstTrackStateProxy > lastMeasurementState(const xAOD::TrackParticle &trkPart, const bool skipOutlier=true)
Returns the track state proxy corresponding to the last measurement on track.
std::optional< Acts::BoundTrackParameters > firstTrackParameters(const xAOD::TrackParticle &trkPart, const bool skipOutlier=true)
Returns the first MeasurementState in form of Acts::BoundTrackParameters.
std::optional< Acts::BoundTrackParameters > lastTrackParameters(const xAOD::TrackParticle &trkPart, const bool skipOutlier=true)
Returns the last MeasurementState in form of Acts::BoundTrackParameters.
std::optional< ActsTrk::TrackContainer::ConstTrackProxy > getActsTrack(const xAOD::TrackParticle &trkPart)
Return the proxy to the Acts track from which the track particle was made frome.
Definition Decoration.cxx:9
TrackParticle_v1 TrackParticle
Reference the current persistent version: