Skip to content

Commit

Permalink
feat: Add parameter getters to TrackProxy (#1869)
Browse files Browse the repository at this point in the history
This allows accessing the raw parameter elements by named methods, and to derive properties like absolute and transverse momentum.

Anything else that comes to mind we should add at this point?
  • Loading branch information
paulgessinger committed Feb 17, 2023
1 parent eff1a08 commit 2c2c0fc
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions Core/include/Acts/EventData/Track.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@

#pragma once

#include "Acts/Definitions/Algebra.hpp"
#include "Acts/Definitions/TrackParametrization.hpp"
#include "Acts/Definitions/Units.hpp"
#include "Acts/EventData/Charge.hpp"
#include "Acts/EventData/MultiTrajectory.hpp"
#include "Acts/Utilities/HashedString.hpp"
#include "Acts/Utilities/UnitVectors.hpp"

#include <any>
#include <cstddef>
Expand Down Expand Up @@ -206,6 +211,58 @@ class TrackProxy {
return m_container->covariance(m_index);
}

ActsScalar charge() const {
// Currently, neutral tracks are not supported here
// @TODO: Evaluate if/how neutral 'tracks' should be accounted for
return SinglyCharged{}.extractCharge(parameters()[eBoundQOverP]);
}

/// Access the theta parameter of the track at the reference surface
/// @return The theta parameter
ActsScalar theta() const { return parameters()[eBoundTheta]; }

/// Access the phi parameter of the track at the reference surface
/// @return The phi parameter
ActsScalar phi() const { return parameters()[eBoundPhi]; }

/// Access the loc0 parameter of the track at the reference surface
/// @return The loc0 parameter
ActsScalar loc0() const { return parameters()[eBoundLoc0]; }

/// Access the loc1 parameter of the track at the reference surface
/// @return The loc1 parameter
ActsScalar loc1() const { return parameters()[eBoundLoc1]; }

/// Access the time parameter of the track at the reference surface
/// @return The time parameter
ActsScalar time() const { return parameters()[eBoundTime]; }

/// Access the q/p (curvature) parameter of the track at the reference surface
/// @return The q/p parameter
ActsScalar qOverP() const { return parameters()[eBoundQOverP]; }

/// Get the absolute momentum of the tack
/// @return The absolute track momentum
ActsScalar absoluteMomentum() const {
return SinglyCharged{}.extractMomentum(qOverP());
}

/// Get the transverse momentum of the track
/// @return The track transverse momentum value
ActsScalar transverseMomentum() const {
return std::sin(theta()) * absoluteMomentum();
}

/// Get a unit vector along the track direction at the reference surface
/// @return The direction unit vector
Vector3 unitDirection() const {
return makeDirectionUnitFromPhiTheta(phi(), theta());
}

/// Get the global momentum vector
/// @return the global momentum vector
Vector3 momentum() const { return absoluteMomentum() * unitDirection(); }

/// Get a range over the track states of this track. Return value is
/// compatible with range based for loop. Const version
/// @return Track state range to iterate over
Expand Down

0 comments on commit 2c2c0fc

Please sign in to comment.