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 &&)
MutableTrackSummaryContaineroperator= (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::TrackSummaryContainertrackBackend ()
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::MultiTrajectoryTraits::kInvalid
static const std::set< std::string > staticVariables
static const std::set< Acts::HashedString > staticVariableHashes

Protected Attributes

DataLink< xAOD::TrackSummaryContainerm_trackBackend = nullptr
std::vector< ActsTrk::detail::Decorationm_decorations
std::vector< std::shared_ptr< const Acts::Surface > > m_surfaces

Private Attributes

std::unique_ptr< xAOD::TrackSummaryContainerm_mutableTrackBackend
std::unique_ptr< xAOD::TrackSummaryAuxContainerm_mutableTrackBackendAux

Friends

class ActsTrk::MutableTrackContainerHandlesHelper

Detailed Description

Member Typedef Documentation

◆ IndexType

Constructor & Destructor Documentation

◆ MutableTrackSummaryContainer() [1/3]

ActsTrk::MutableTrackSummaryContainer::MutableTrackSummaryContainer ( )

Definition at line 138 of file TrackSummaryContainer.cxx.

138 :
139 m_mutableTrackBackend(std::make_unique<xAOD::TrackSummaryContainer>()),
140 m_mutableTrackBackendAux(std::make_unique<xAOD::TrackSummaryAuxContainer>())
141{
144}
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 146 of file TrackSummaryContainer.cxx.

147 :
148 m_mutableTrackBackend(std::move(other.m_mutableTrackBackend)),
149 m_mutableTrackBackendAux(std::move(other.m_mutableTrackBackendAux))
150{
153
154 m_surfaces = std::move(other.m_surfaces);
155 m_decorations = std::move(other.m_decorations);
156}
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 244 of file Tracking/Acts/ActsEvent/ActsEvent/TrackSummaryContainer.h.

245 {
247 throw std::runtime_error(
248 "TrackSummaryContainer::addColumn_impl: "
249 "unsupported decoration type");
250 }
252 name,
256 ));
257}
void decorationCopier(SG::IAuxStore *dst, ActsTrk::IndexType dst_idx, SG::auxid_t decorationId, const std::any &src_ptr)
Definition Decoration.h:76
const std::any constDecorationGetter(const SG::IConstAuxStore *container, ActsTrk::IndexType idx, SG::auxid_t decorationId)
Definition Decoration.h:49
static Decoration decoration(std::string_view n, GetterType g, CopierType c, SetterType s=static_cast< SetterType >(nullptr))
Definition Decoration.h:83
std::any decorationSetter(SG::IAuxStore *container, ActsTrk::IndexType idx, SG::auxid_t decorationId)
Definition Decoration.h:67

◆ addTrack_impl()

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

adds new track to the tail of the container

Definition at line 186 of file TrackSummaryContainer.cxx.

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

◆ clear()

void ActsTrk::MutableTrackSummaryContainer::clear ( )

zeroes container

Definition at line 261 of file TrackSummaryContainer.cxx.

261 {
262 m_mutableTrackBackend->clear();
263 m_surfaces.clear();
264}

◆ component_impl() [1/2]

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

write access to decorations

Definition at line 218 of file TrackSummaryContainer.cxx.

219 {
220 std::any result = ::component_impl(*m_mutableTrackBackend, key, itrack);
221 if (result.has_value()) {
222 return result;
223 }
224 for (auto& d : m_decorations) {
225 if (d.hash == key) {
226 return d.setter(m_mutableTrackBackendAux.get(), itrack, d.auxid);
227 }
228 }
229 throw std::runtime_error("TrackSummaryContainer no such component " +
230 std::to_string(key));
231}
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.

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

◆ 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 208 of file TrackSummaryContainer.cxx.

210 {
211 if ( staticVariableHashes.count(key) == 1) { return; }
212 for ( const auto& d: m_decorations) {
213 if (d.hash != key) { continue; }
214 d.copier(m_mutableTrackBackendAux.get(), itrack, d.auxid, src_ptr);
215 }
216}
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 238 of file TrackSummaryContainer.cxx.

239 {
240 return m_mutableTrackBackend->at(itrack)->covParamsEigen();
241}

◆ covariance() [2/2]

ActsTrk::ConstCovariance ActsTrk::TrackSummaryContainer::covariance ( ActsTrk::IndexType itrack) const

covariance of the track fit

Definition at line 97 of file TrackSummaryContainer.cxx.

101 {
102 return m_trackBackend->at(itrack)->covParamsEigen();
103}

◆ decodeSurfaces()

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

Definition at line 125 of file TrackSummaryContainer.cxx.

125 {
126 m_surfaces.reserve(src->size());
127 for ( auto xAODSurfacePtr: *src) {
128 m_surfaces.push_back( decodeSurface(xAODSurfacePtr));
129 }
130}
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 114 of file TrackSummaryContainer.cxx.

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

◆ encodeSurfaces()

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

Definition at line 271 of file TrackSummaryContainer.cxx.

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

◆ ensureDynamicColumns_impl() [1/2]

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

synchronizes decorations

Definition at line 243 of file TrackSummaryContainer.cxx.

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

◆ ensureDynamicColumns_impl() [2/2]

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

Definition at line 250 of file TrackSummaryContainer.cxx.

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

◆ fillFrom()

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

Definition at line 105 of file TrackSummaryContainer.cxx.

106 {
107 m_surfaces = std::move(mtb.m_surfaces);
108}

◆ 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 "d0"_hash:
223 case "chi2"_hash:
224 case "ndf"_hash:
225 case "nOutliers"_hash:
226 case "hSharedHits"_hash:
227 case "tipIndex"_hash:
228 case "stemIndex"_hash:
229
230 return true;
231 }
232 for (auto& d : m_decorations) {
233 if (d.hash == key) {
234 return true;
235 }
236 }
237 return false;
238}

◆ 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 160 of file TrackSummaryContainer.cxx.

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

◆ parameters() [1/2]

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

write access to parameters

Definition at line 233 of file TrackSummaryContainer.cxx.

234 {
235 return m_mutableTrackBackend->at(itrack)->paramsEigen();
236}

◆ parameters() [2/2]

ActsTrk::ConstParameters ActsTrk::TrackSummaryContainer::parameters ( ActsTrk::IndexType itrack) const

parameters of the track

Definition at line 92 of file TrackSummaryContainer.cxx.

96 {
97 return m_trackBackend->at(itrack)->paramsEigen();
98}

◆ 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 195 of file TrackSummaryContainer.cxx.

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

◆ reserve()

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

preallocate number of track objects

Definition at line 257 of file TrackSummaryContainer.cxx.

257 {
258 m_mutableTrackBackend->reserve(size);
259}

◆ restoreDecorations()

void ActsTrk::TrackSummaryContainer::restoreDecorations ( )
inherited

Definition at line 110 of file TrackSummaryContainer.cxx.

110 {
112}
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 288 of file TrackSummaryContainer.cxx.

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

◆ 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 266 of file TrackSummaryContainer.cxx.

267 {
268 m_surfaces[itrack] = std::move(surface);
269}

◆ 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::MultiTrajectoryTraits::kInvalid
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", "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: