ATLAS Offline Software
Loading...
Searching...
No Matches
Acts/ActsEvent/Root/CaloExtension.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
9
10#include "GeoModelKernel/throwExcept.h"
11
12namespace ActsTrk{
14 static const SG::ConstAccessor<ElementLink<CaloExtensionContainer>> acc{"caloExtensionLink"};
15 if (!acc.isAvailable(track)) {
16 return nullptr;
17 }
18 const auto& link = acc(track);
19 if (link.isValid()) {
20 return *link;
21 }
22 return nullptr;
23 }
24
25
28
30 return m_idTrack;
31 }
32 std::optional<Acts::BoundTrackParameters> CaloExtension::lastTrackParameters() const {
33 if (!m_idTrack) {
34 return std::nullopt;
35 }
36 if (auto result = ActsTrk::lastTrackParameters(*m_idTrack); result != std::nullopt){
37 return result;
38 }
40 unsigned int lastMeasIdx = 0;
41 if (!m_idTrack->indexOfParameterAtPosition(lastMeasIdx, xAOD::LastMeasurement)) {
42 return std::nullopt;
43 }
44
45 const Acts::Vector3 lastPos{m_idTrack->parameterX(lastMeasIdx),
46 m_idTrack->parameterY(lastMeasIdx),
47 m_idTrack->parameterZ(lastMeasIdx)};
48
49 const Acts::Vector3 lastMom{m_idTrack->parameterPX(lastMeasIdx),
50 m_idTrack->parameterPY(lastMeasIdx),
51 m_idTrack->parameterPZ(lastMeasIdx)};
52 Acts::BoundMatrix cov{Acts::BoundMatrix::Identity()};
53
54 return Acts::BoundTrackParameters::createCurvilinear(
55 convertPosToActs(lastPos, m_idTrack->hasValidTime() ? m_idTrack->time() : 0.),
56 lastMom.unit(), m_idTrack->charge() / energyToActs(lastMom.mag()),
57 cov, ParticleHypothesis::convert(m_idTrack->particleHypothesis()));
58 }
59 std::optional<Acts::BoundTrackParameters> CaloExtension::lastParameters() const {
60 if (!m_parameters.empty()) {
61 return m_parameters.back();
62 }
63 return lastTrackParameters();
64 }
65
66 void CaloExtension::appendParameters(Acts::BoundTrackParameters&& pars) {
67 m_parameters.emplace_back(std::move(pars));
68 }
70 if (!clust) {
71 THROW_EXCEPTION("The calorimeter cluster not be a nullptr");
72 }
73 if (!Acts::rangeContainsValue(m_clusters, clust)) {
74 m_clusters.push_back(clust);
75 }
76 }
83 std::size_t CaloExtension::size() const {
84 return m_parameters.size();
85 }
86 bool CaloExtension::empty() const {
87 return m_parameters.empty();
88 }
89}
The CaloExtension holds the ID extrapolation states through the calorimeter and the associated CaloCl...
const ClusterVec_t & associatedClusters() const
Returns the view on the asociated clusters.
std::size_t size() const
Number of extensions stored in the instance.
const xAOD::TrackParticle * m_idTrack
Pointer to the associated ID track particle.
CaloExtension(const xAOD::TrackParticle *track)
Constructor taking the pointer to the ID track used for the extrapolations.
ParamVec_t m_parameters
Define the list of bound track parameters.
void appendParameters(Acts::BoundTrackParameters &&pars)
Append a list of recorded hit parameters.
const ParamVec_t & parameters() const
Returns the view onto the cached BoundTackParameters.
ClusterVec_t m_clusters
The list of assoicated clusters.
const xAOD::TrackParticle * track() const
std::vector< const xAOD::CaloCluster * > ClusterVec_t
Abrivation of the calo cluster vector.
std::vector< Acts::BoundTrackParameters > ParamVec_t
Abrivation of the Bound track parameter vector.
void associateCluster(const xAOD::CaloCluster *clust)
Associates a calorimeter cluster with the calo extension.
std::optional< Acts::BoundTrackParameters > lastTrackParameters() const
Returns the track parameters asssociated with the last measurement state of the ID track.
std::optional< Acts::BoundTrackParameters > lastParameters() const
Returns the outermost parameters known to the extension.
Helper class to provide constant type-safe access to aux data.
xAOD::ParticleHypothesis convert(Acts::ParticleHypothesis h)
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
constexpr double energyToActs(const double athenaE)
Converts an energy scalar from Athena to Acts units.
const CaloExtension * getCaloExtension(const xAOD::TrackParticle &track)
Retrieve a pointer to the CaloExtension linked with the passed TrackParticle.
std::optional< Acts::BoundTrackParameters > lastTrackParameters(const xAOD::TrackParticle &trkPart, const bool skipOutlier=true)
Returns the last MeasurementState in form of Acts::BoundTrackParameters.
Acts::Vector4 convertPosToActs(const Amg::Vector3D &athenaPos, const double athenaTime=0.)
Converts a position vector & time from Athena units into Acts units.
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
TrackParticle_v1 TrackParticle
Reference the current persistent version:
@ LastMeasurement
Parameter defined at the position of the last measurement.
#define THROW_EXCEPTION(MESSAGE)
Definition throwExcept.h:10