Skip to content

Commit

Permalink
feat: extract impact parameters and their covariance matrix (#2464)
Browse files Browse the repository at this point in the history
Allow extraction of the 

- impact parameters (i.e., `d0`, `z0`, and, optionally, `t`) and
- the corresponding covariance matrix

from `GenericBoundTrackParameters`
  • Loading branch information
felix-russo committed Sep 26, 2023
1 parent 5d65fd0 commit a23fe6d
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
36 changes: 36 additions & 0 deletions Core/include/Acts/EventData/GenericBoundTrackParameters.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,46 @@ class GenericBoundTrackParameters {
ParametersVector& parameters() { return m_params; }
/// Parameters vector.
const ParametersVector& parameters() const { return m_params; }
/// Vector of spatial impact parameters (i.e., d0 and z0)
ActsVector<2> spatialImpactParameters() const { return m_params.head<2>(); }
/// Vector of spatial and temporal impact parameters (i.e., d0, z0, and t)
ActsVector<3> impactParameters() const {
ActsVector<3> ip;
ip.template head<2>() = m_params.template head<2>();
ip(2) = m_params(eBoundTime);
return ip;
}

/// Optional covariance matrix.
std::optional<CovarianceMatrix>& covariance() { return m_cov; }
/// Optional covariance matrix.
const std::optional<CovarianceMatrix>& covariance() const { return m_cov; }
/// Covariance matrix of the spatial impact parameters (i.e., of d0 and z0)
std::optional<ActsSquareMatrix<2>> spatialImpactParameterCovariance() const {
if (not m_cov.has_value()) {
return std::nullopt;
}

return m_cov.value().template topLeftCorner<2, 2>();
}

/// Covariance matrix of the spatial and temporal impact parameters (i.e., of
/// d0, z0, and t)
std::optional<ActsSquareMatrix<3>> impactParameterCovariance() const {
if (not m_cov.has_value()) {
return std::nullopt;
}

ActsSquareMatrix<3> ipCov;
ipCov.template topLeftCorner<2, 2>() =
m_cov.value().template topLeftCorner<2, 2>();
ipCov.template block<2, 1>(0, 2) =
m_cov.value().template block<2, 1>(0, eBoundTime);
ipCov.template block<1, 2>(2, 0) =
m_cov.value().template block<1, 2>(eBoundTime, 0);
ipCov(2, 2) = m_cov.value()(eBoundTime, eBoundTime);
return ipCov;
}

/// Access a single parameter value identified by its index.
///
Expand Down
2 changes: 1 addition & 1 deletion Core/include/Acts/Vertexing/AdaptiveGridTrackDensity.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ template <int trkGridSize>
typename Acts::AdaptiveGridTrackDensity<trkGridSize>::DensityMap
Acts::AdaptiveGridTrackDensity<trkGridSize>::addTrack(
const Acts::BoundTrackParameters& trk, DensityMap& mainDensityMap) const {
SquareMatrix2 cov = trk.covariance().value().block<2, 2>(0, 0);
SquareMatrix2 cov = trk.spatialImpactParameterCovariance().value();
float d0 = trk.parameters()[0];
float z0 = trk.parameters()[1];

Expand Down
2 changes: 1 addition & 1 deletion Core/include/Acts/Vertexing/GaussianGridTrackDensity.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ std::pair<int, typename Acts::GaussianGridTrackDensity<
mainGridSize, trkGridSize>::TrackGridVector>
Acts::GaussianGridTrackDensity<mainGridSize, trkGridSize>::addTrack(
const Acts::BoundTrackParameters& trk, MainGridVector& mainGrid) const {
SquareMatrix2 cov = trk.covariance().value().block<2, 2>(0, 0);
SquareMatrix2 cov = trk.spatialImpactParameterCovariance().value();
float d0 = trk.parameters()[0];
float z0 = trk.parameters()[1];

Expand Down

0 comments on commit a23fe6d

Please sign in to comment.