ATLAS Offline Software
Loading...
Searching...
No Matches
ActsTrk::MutableTrackSummaryContainer Class Reference

#include <TrackSummaryContainer.h>

Inheritance diagram for ActsTrk::MutableTrackSummaryContainer:
Collaboration diagram for ActsTrk::MutableTrackSummaryContainer:

Public Types

using IndexType = uint32_t

Public Member Functions

 MutableTrackSummaryContainer ()
 MutableTrackSummaryContainer (const MutableTrackSummaryContainer &)=delete
MutableTrackSummaryContainer operator= (const MutableTrackSummaryContainer &)=delete
 MutableTrackSummaryContainer (MutableTrackSummaryContainer &&)
MutableTrackSummaryContainer & operator= (MutableTrackSummaryContainer &&other) noexcept
ActsTrk::IndexType addTrack_impl ()
 adds new track to the tail of the container
void removeTrack_impl (ActsTrk::IndexType itrack)
 clears track data under index
template<typename T>
constexpr void addColumn_impl (std::string_view key)
 enables the container to support decoration of given name and type
void copyDynamicFrom_impl (ActsTrk::IndexType itrack, Acts::HashedString key, const std::any &src_ptr)
 copies decorations from other container
std::any component_impl (Acts::HashedString key, ActsTrk::IndexType itrack)
 write access to decorations
ActsTrk::Parameters parameters (ActsTrk::IndexType itrack)
 write access to parameters
ActsTrk::Covariance covariance (ActsTrk::IndexType itrack)
 write access to covariance
void ensureDynamicColumns_impl (const MutableTrackSummaryContainer &other)
 synchronizes decorations
void ensureDynamicColumns_impl (const TrackSummaryContainer &other)
void reserve (ActsTrk::IndexType size)
 preallocate number of track objects
void clear ()
 zeroes container
void setReferenceSurface_impl (ActsTrk::IndexType itrack, std::shared_ptr< const Acts::Surface > surface)
 point given track to surface The surface ownership is shared
void setParticleHypothesis_impl (ActsTrk::IndexType itrack, const Acts::ParticleHypothesis &particleHypothesis)
 sets particle hypothesis
xAOD::TrackSummaryContainer * trackBackend ()
void encodeSurfaces (xAOD::TrackSurfaceAuxContainer *dest, const Acts::GeometryContext &)
std::any component_impl (Acts::HashedString key, ActsTrk::IndexType itrack) const
 access to components by pointer with type
ActsTrk::ConstParameters parameters (ActsTrk::IndexType itrack) const
 parameters of the track
ActsTrk::ConstCovariance covariance (ActsTrk::IndexType itrack) const
 covariance of the track fit
constexpr bool hasColumn_impl (Acts::HashedString key) const
 return true if the container has specific decoration
const Acts::Surface * referenceSurface_impl (ActsTrk::IndexType itrack) const
 return pointer to reference surface
Acts::ParticleHypothesis particleHypothesis_impl (IndexType itrack) const
 return pointer to reference surface
std::size_t size_impl () const
 returns number of stored tracks
void fillFrom (ActsTrk::MutableTrackSummaryContainer &mtb)
void restoreDecorations ()
void decodeSurfaces (const xAOD::TrackSurfaceContainer *src)
std::vector< Acts::HashedString > dynamicKeys_impl () const

Static Public Attributes

static constexpr auto kInvalid = Acts::kTrackIndexInvalid
static const std::set< std::string > staticVariables
static const std::set< Acts::HashedString > staticVariableHashes

Protected Attributes

DataLink< xAOD::TrackSummaryContainer > m_trackBackend = nullptr
std::vector< ActsTrk::detail::Decoration > m_decorations
std::vector< std::shared_ptr< const Acts::Surface > > m_surfaces

Private Attributes

std::unique_ptr< xAOD::TrackSummaryContainer > m_mutableTrackBackend
std::unique_ptr< xAOD::TrackSummaryAuxContainer > m_mutableTrackBackendAux

Friends

class ActsTrk::MutableTrackContainerHandlesHelper

Detailed Description

Member Typedef Documentation

◆ IndexType

Constructor & Destructor Documentation

◆ MutableTrackSummaryContainer() [1/3]

ActsTrk::MutableTrackSummaryContainer::MutableTrackSummaryContainer ( )

Definition at line 140 of file TrackSummaryContainer.cxx.

140 :
141 m_mutableTrackBackend(std::make_unique<xAOD::TrackSummaryContainer>()),
142 m_mutableTrackBackendAux(std::make_unique<xAOD::TrackSummaryAuxContainer>())
143{
146}
std::unique_ptr< xAOD::TrackSummaryAuxContainer > m_mutableTrackBackendAux

◆ MutableTrackSummaryContainer() [2/3]

ActsTrk::MutableTrackSummaryContainer::MutableTrackSummaryContainer ( const MutableTrackSummaryContainer & )
delete

◆ MutableTrackSummaryContainer() [3/3]

ActsTrk::MutableTrackSummaryContainer::MutableTrackSummaryContainer ( MutableTrackSummaryContainer && other)

Definition at line 148 of file TrackSummaryContainer.cxx.

149 :
150 m_mutableTrackBackend(std::move(other.m_mutableTrackBackend)),
151 m_mutableTrackBackendAux(std::move(other.m_mutableTrackBackendAux))
152{
155
156 m_surfaces = std::move(other.m_surfaces);
157 m_decorations = std::move(other.m_decorations);
158}
std::vector< std::shared_ptr< const Acts::Surface > > m_surfaces

Member Function Documentation

◆ addColumn_impl()

template<typename T>
void ActsTrk::MutableTrackSummaryContainer::addColumn_impl ( std::string_view key)
constexpr

enables the container to support decoration of given name and type

Definition at line 243 of file Tracking/Acts/ActsEvent/ActsEvent/TrackSummaryContainer.h.

244 {
246 throw std::runtime_error(
247 "TrackSummaryContainer::addColumn_impl: "
248 "unsupported decoration type");
249 }
251 name,
255 ));
256}
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
static Decoration decoration(std::string_view n, GetterType g, CopierType c, SetterType s=static_cast< SetterType >(nullptr))
Definition Decoration.h:87
std::any decorationSetter(SG::IAuxStore *container, ActsTrk::IndexType idx, SG::auxid_t decorationId)
Definition Decoration.h:71

◆ addTrack_impl()

ActsTrk::IndexType ActsTrk::MutableTrackSummaryContainer::addTrack_impl ( )

adds new track to the tail of the container

Definition at line 188 of file TrackSummaryContainer.cxx.

188 {
189 m_mutableTrackBackend->push_back(std::make_unique<xAOD::TrackSummary>());
190 m_mutableTrackBackend->back()->resize();
191 // ACTS assumes default to be pion, xAOD::ParticleHypothesis == 0 is geantino
192 m_mutableTrackBackend->back()->setParticleHypothesis(xAOD::pion);
193 m_surfaces.push_back(nullptr);
194 return m_mutableTrackBackend->size() - 1;
195}

◆ clear()

void ActsTrk::MutableTrackSummaryContainer::clear ( )

zeroes container

Definition at line 263 of file TrackSummaryContainer.cxx.

263 {
264 m_mutableTrackBackend->clear();
265 m_surfaces.clear();
266}

◆ component_impl() [1/2]

std::any ActsTrk::MutableTrackSummaryContainer::component_impl ( Acts::HashedString key,
ActsTrk::IndexType itrack )

write access to decorations

Definition at line 220 of file TrackSummaryContainer.cxx.

221 {
222 std::any result = ::component_impl(*m_mutableTrackBackend, key, itrack);
223 if (result.has_value()) {
224 return result;
225 }
226 for (auto& d : m_decorations) {
227 if (d.hash == key) {
228 return d.setter(m_mutableTrackBackendAux.get(), itrack, d.auxid);
229 }
230 }
231 throw std::runtime_error("TrackSummaryContainer no such component " +
232 std::to_string(key));
233}
std::any component_impl(Acts::HashedString key, ActsTrk::IndexType itrack)
write access to decorations

◆ component_impl() [2/2]

std::any ActsTrk::TrackSummaryContainer::component_impl ( Acts::HashedString key,
ActsTrk::IndexType itrack ) const

access to components by pointer with type

Definition at line 86 of file TrackSummaryContainer.cxx.

82 {
83 std::any result = ::component_impl(*m_trackBackend, key, itrack);
84 if (result.has_value()) {
85 return result;
86 }
87 for (auto& d : m_decorations) {
88 if (d.hash == key) {
89 // TODO the dynamic case will be eliminated once we switch to use Aux containers directly
90 return d.getter(m_trackBackend->getStore(), itrack, d.auxid);
91 }
92 }
93 throw std::runtime_error("TrackSummaryContainer no such component " +
94 std::to_string(key));
95}

◆ copyDynamicFrom_impl()

void ActsTrk::MutableTrackSummaryContainer::copyDynamicFrom_impl ( ActsTrk::IndexType itrack,
Acts::HashedString key,
const std::any & src_ptr )

copies decorations from other container

Definition at line 210 of file TrackSummaryContainer.cxx.

212 {
213 if ( staticVariableHashes.count(key) == 1) { return; }
214 for ( const auto& d: m_decorations) {
215 if (d.hash != key) { continue; }
216 d.copier(m_mutableTrackBackendAux.get(), itrack, d.auxid, src_ptr);
217 }
218}
static const std::set< Acts::HashedString > staticVariableHashes

◆ covariance() [1/2]

ActsTrk::Covariance ActsTrk::MutableTrackSummaryContainer::covariance ( ActsTrk::IndexType itrack)

write access to covariance

Definition at line 240 of file TrackSummaryContainer.cxx.

241 {
242 return m_mutableTrackBackend->at(itrack)->covParamsEigen();
243}

◆ covariance() [2/2]

covariance of the track fit

Definition at line 97 of file TrackSummaryContainer.cxx.

103 {
104 return m_trackBackend->at(itrack)->covParamsEigen();
105}

◆ decodeSurfaces()

void ActsTrk::TrackSummaryContainer::decodeSurfaces ( const xAOD::TrackSurfaceContainer * src)
inherited

Definition at line 127 of file TrackSummaryContainer.cxx.

127 {
128 m_surfaces.reserve(src->size());
129 for ( auto xAODSurfacePtr: *src) {
130 m_surfaces.push_back( decodeSurface(xAODSurfacePtr));
131 }
132}
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 ...

◆ dynamicKeys_impl()

std::vector< Acts::HashedString > ActsTrk::TrackSummaryContainer::dynamicKeys_impl ( ) const
inherited

Definition at line 116 of file TrackSummaryContainer.cxx.

116 {
117 std::vector<Acts::HashedString> result;
118 for ( const auto& d: m_decorations) {
119 if (staticVariableHashes.count(d.hash) == 1) {
120 continue;
121 }
122 result.push_back(d.hash);
123 }
124 return result;
125}

◆ encodeSurfaces()

void ActsTrk::MutableTrackSummaryContainer::encodeSurfaces ( xAOD::TrackSurfaceAuxContainer * dest,
const Acts::GeometryContext & geoContext )

Definition at line 273 of file TrackSummaryContainer.cxx.

273 {
274 dest->resize(m_surfaces.size());
275 size_t destIndex = 0;
276 // go over all surfaces and for each free surface record persistent version of it in the xAOD
277 // at the same time store index to it updating TrackSummary
278 for ( ActsTrk::IndexType index = 0, eindex = m_surfaces.size(); index < eindex; ++index ) {
279 if ( m_surfaces[index] == nullptr or m_surfaces[index]->geometryId().value() != 0 ) {
280 m_mutableTrackBackend->at(index)->setSurfaceIndex(Acts::kTrackIndexInvalid);
281 } else {
282 m_mutableTrackBackend->at(index)->setSurfaceIndex(destIndex);
283 encodeSurface(dest, destIndex, m_surfaces[index].get(), geoContext);
284 destIndex++;
285 }
286 }
287 dest->resize(destIndex);
288}
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition hcg.cxx:132
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::uint32_t IndexType
Definition Decoration.h:18

◆ ensureDynamicColumns_impl() [1/2]

void ActsTrk::MutableTrackSummaryContainer::ensureDynamicColumns_impl ( const MutableTrackSummaryContainer & other)

synchronizes decorations

Definition at line 245 of file TrackSummaryContainer.cxx.

246 {
247 for (auto& d : other.m_decorations) {
248 m_decorations.push_back(d);
249 }
250}

◆ ensureDynamicColumns_impl() [2/2]

void ActsTrk::MutableTrackSummaryContainer::ensureDynamicColumns_impl ( const TrackSummaryContainer & other)

Definition at line 252 of file TrackSummaryContainer.cxx.

253 {
254 for (auto& d : other.m_decorations) {
255 m_decorations.push_back(d);
256 }
257}

◆ fillFrom()

void ActsTrk::TrackSummaryContainer::fillFrom ( ActsTrk::MutableTrackSummaryContainer & mtb)
inherited

Definition at line 107 of file TrackSummaryContainer.cxx.

108 {
109 m_surfaces = std::move(mtb.m_surfaces);
110}

◆ hasColumn_impl()

bool ActsTrk::TrackSummaryContainer::hasColumn_impl ( Acts::HashedString key) const
constexprinherited

return true if the container has specific decoration

Definition at line 214 of file Tracking/Acts/ActsEvent/ActsEvent/TrackSummaryContainer.h.

215 {
216 using namespace Acts::HashedStringLiteral;
217 switch (key) {
218 case "params"_hash:
219 case "cov"_hash:
220 case "nMeasurements"_hash:
221 case "nHoles"_hash:
222 case "chi2"_hash:
223 case "ndf"_hash:
224 case "nOutliers"_hash:
225 case "nSharedHits"_hash:
226 case "nSplitHits"_hash:
227 case "tipIndex"_hash:
228 case "stemIndex"_hash:
229 return true;
230 }
231 for (auto& d : m_decorations) {
232 if (d.hash == key) {
233 return true;
234 }
235 }
236 return false;
237}

◆ operator=() [1/2]

MutableTrackSummaryContainer ActsTrk::MutableTrackSummaryContainer::operator= ( const MutableTrackSummaryContainer & )
delete

◆ operator=() [2/2]

ActsTrk::MutableTrackSummaryContainer & ActsTrk::MutableTrackSummaryContainer::operator= ( ActsTrk::MutableTrackSummaryContainer && other)
noexcept

Definition at line 162 of file TrackSummaryContainer.cxx.

163 {
164 //NB. restoreDecorations may throw a GaudiException, resulting in a call to terminate()
165 // because the function is annotated 'noexcept'
166 m_mutableTrackBackend = std::exchange(other.m_mutableTrackBackend, nullptr);
167 m_mutableTrackBackendAux = std::exchange(other.m_mutableTrackBackendAux, nullptr);
168 //setStore throws an exception of type SG::ExcUntrackedSetStore, SG::ExcCLIDMismatch
169 //resulting in a call to terminate() because the function is marked 'noexcept'
172
173 m_surfaces = std::move(other.m_surfaces);
174 m_decorations = std::move(other.m_decorations);
175
176 //restore decorations
177 // restoreDecorations may throw a GaudiException or SG::ExcBadVarName
178 // resulting in a call to terminate() because the function is marked 'noexcept'
180
181 // invalidate vector type components of 'other'
182 other.m_surfaces.clear();
183 other.m_decorations.clear();
184
185 return *this;
186}

◆ parameters() [1/2]

ActsTrk::Parameters ActsTrk::MutableTrackSummaryContainer::parameters ( ActsTrk::IndexType itrack)

write access to parameters

Definition at line 235 of file TrackSummaryContainer.cxx.

236 {
237 return m_mutableTrackBackend->at(itrack)->paramsEigen();
238}

◆ parameters() [2/2]

parameters of the track

Definition at line 92 of file TrackSummaryContainer.cxx.

98 {
99 return m_trackBackend->at(itrack)->paramsEigen();
100}

◆ particleHypothesis_impl()

Acts::ParticleHypothesis ActsTrk::TrackSummaryContainer::particleHypothesis_impl ( IndexType itrack) const
inherited

return pointer to reference surface

Definition at line 42 of file TrackSummaryContainer.cxx.

42 {
43 return ActsTrk::ParticleHypothesis::convert( static_cast<xAOD::ParticleHypothesis>(m_trackBackend->at(itrack)->particleHypothesis()));
44}
xAOD::ParticleHypothesis convert(Acts::ParticleHypothesis h)

◆ referenceSurface_impl()

const Acts::Surface * ActsTrk::TrackSummaryContainer::referenceSurface_impl ( ActsTrk::IndexType itrack) const
inherited

return pointer to reference surface

Definition at line 33 of file TrackSummaryContainer.cxx.

34 {
35 if (itrack >= m_surfaces.size())
36 throw std::out_of_range(
37 "TrackSummaryContainer index out of range when accessing reference "
38 "surface");
39 return m_surfaces[itrack].get();
40}

◆ removeTrack_impl()

void ActsTrk::MutableTrackSummaryContainer::removeTrack_impl ( ActsTrk::IndexType itrack)

clears track data under index

Definition at line 197 of file TrackSummaryContainer.cxx.

198 {
199 if (itrack >= m_mutableTrackBackend->size()) {
200 throw std::out_of_range("removeTrack_impl track backend");
201 }
202 if (itrack >= m_surfaces.size()) {
203 throw std::out_of_range("removeTrack_impl surfaces");
204 }
205 m_mutableTrackBackend->erase(m_mutableTrackBackend->begin() + itrack);
206 m_surfaces.erase(m_surfaces.begin() + itrack);
207}

◆ reserve()

void ActsTrk::MutableTrackSummaryContainer::reserve ( ActsTrk::IndexType size)

preallocate number of track objects

Definition at line 259 of file TrackSummaryContainer.cxx.

259 {
260 m_mutableTrackBackend->reserve(size);
261}
size_t size() const
Number of registered mappings.

◆ restoreDecorations()

void ActsTrk::TrackSummaryContainer::restoreDecorations ( )
inherited

Definition at line 112 of file TrackSummaryContainer.cxx.

112 {
114}
std::vector< Decoration > restoreDecorations(const SG::IConstAuxStore *container, const std::set< std::string > &staticVariables)

◆ setParticleHypothesis_impl()

void ActsTrk::MutableTrackSummaryContainer::setParticleHypothesis_impl ( ActsTrk::IndexType itrack,
const Acts::ParticleHypothesis & particleHypothesis )

sets particle hypothesis

Warning
it will fail for an arbitrary particles as it converts to a predefined set (
See also
xAOD::ParticleHypothesis in TrackingPrimitives.h) of values

Definition at line 290 of file TrackSummaryContainer.cxx.

290 {
291 m_mutableTrackBackend->at(itrack)->setParticleHypothesis(ActsTrk::ParticleHypothesis::convert(particleHypothesis));
292}

◆ setReferenceSurface_impl()

void ActsTrk::MutableTrackSummaryContainer::setReferenceSurface_impl ( ActsTrk::IndexType itrack,
std::shared_ptr< const Acts::Surface > surface )

point given track to surface The surface ownership is shared

Definition at line 268 of file TrackSummaryContainer.cxx.

269 {
270 m_surfaces[itrack] = std::move(surface);
271}

◆ size_impl()

std::size_t ActsTrk::TrackSummaryContainer::size_impl ( ) const
inherited

returns number of stored tracks

Definition at line 46 of file TrackSummaryContainer.cxx.

46 {
47 return m_trackBackend->size();
48}

◆ trackBackend()

xAOD::TrackSummaryContainer * ActsTrk::MutableTrackSummaryContainer::trackBackend ( )
inline

Definition at line 202 of file Tracking/Acts/ActsEvent/ActsEvent/TrackSummaryContainer.h.

202 {
203 return m_mutableTrackBackend.get();
204 }

◆ ActsTrk::MutableTrackContainerHandlesHelper

Member Data Documentation

◆ kInvalid

auto ActsTrk::TrackSummaryContainer::kInvalid = Acts::kTrackIndexInvalid
staticconstexprinherited

◆ m_decorations

std::vector<ActsTrk::detail::Decoration> ActsTrk::TrackSummaryContainer::m_decorations
protectedinherited

◆ m_mutableTrackBackend

std::unique_ptr<xAOD::TrackSummaryContainer> ActsTrk::MutableTrackSummaryContainer::m_mutableTrackBackend
private

◆ m_mutableTrackBackendAux

std::unique_ptr<xAOD::TrackSummaryAuxContainer> ActsTrk::MutableTrackSummaryContainer::m_mutableTrackBackendAux
private

◆ m_surfaces

std::vector<std::shared_ptr<const Acts::Surface> > ActsTrk::TrackSummaryContainer::m_surfaces
protectedinherited

◆ m_trackBackend

DataLink<xAOD::TrackSummaryContainer> ActsTrk::TrackSummaryContainer::m_trackBackend = nullptr
protectedinherited

◆ staticVariableHashes

const std::set< Acts::HashedString > ActsTrk::TrackSummaryContainer::staticVariableHashes
staticinherited
Initial value:
= [](){
std::set<Acts::HashedString> result;
result.insert(Acts::hashStringDynamic(s));
}
return result;
}()

Definition at line 19 of file Tracking/Acts/ActsEvent/ActsEvent/TrackSummaryContainer.h.

25 {

◆ staticVariables

const std::set< std::string > ActsTrk::TrackSummaryContainer::staticVariables
staticinherited
Initial value:
= {
"params", "covParams", "nMeasurements", "nHoles", "chi2f",
"ndf", "nOutliers", "nSharedHits", "nSplitHits", "tipIndex", "stemIndex",
"particleHypothesis", "surfaceIndex"}

Definition at line 13 of file Tracking/Acts/ActsEvent/ActsEvent/TrackSummaryContainer.h.


The documentation for this class was generated from the following files: