Skip to content

Commit

Permalink
refactor!: Untemplate VertexInfo and VertexingOptions (acts-proje…
Browse files Browse the repository at this point in the history
  • Loading branch information
paulgessinger authored and LaraCalic committed Feb 10, 2024
1 parent aba43ba commit 86cc008
Show file tree
Hide file tree
Showing 31 changed files with 118 additions and 162 deletions.
1 change: 0 additions & 1 deletion Core/include/Acts/Vertexing/AMVFInfo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
namespace Acts {

/// @brief Helper struct for storing vertex related information
template <typename input_track_t>
struct VertexInfo {
VertexInfo() = default;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,9 @@ class AdaptiveGridDensityVertexFinder {
///
/// @return Vector of vertices, filled with a single
/// vertex (for consistent interfaces)
Result<std::vector<Vertex>> find(
const std::vector<InputTrack>& trackVector,
const VertexingOptions<InputTrack_t>& vertexingOptions,
State& state) const;
Result<std::vector<Vertex>> find(const std::vector<InputTrack>& trackVector,
const VertexingOptions& vertexingOptions,
State& state) const;

/// @brief Constructor used if InputTrack_t type == BoundTrackParameters
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
template <typename vfitter_t>
auto Acts::AdaptiveGridDensityVertexFinder<vfitter_t>::find(
const std::vector<InputTrack>& trackVector,
const VertexingOptions<InputTrack_t>& vertexingOptions, State& state) const
const VertexingOptions& vertexingOptions, State& state) const
-> Result<std::vector<Vertex>> {
// Remove density contributions from tracks removed from track collection
if (m_cfg.cacheGridStateForTrackRemoval && state.isInitialized &&
Expand Down
19 changes: 9 additions & 10 deletions Core/include/Acts/Vertexing/AdaptiveMultiVertexFinder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,9 @@ class AdaptiveMultiVertexFinder {
/// @param state State for fulfilling interfaces
///
/// @return Vector of all reconstructed vertices
Result<std::vector<Vertex>> find(
const std::vector<InputTrack>& allTracks,
const VertexingOptions<InputTrack_t>& vertexingOptions,
State& state) const;
Result<std::vector<Vertex>> find(const std::vector<InputTrack>& allTracks,
const VertexingOptions& vertexingOptions,
State& state) const;

private:
/// Configuration object
Expand Down Expand Up @@ -245,7 +244,7 @@ class AdaptiveMultiVertexFinder {
/// @return The seed vertex
Result<Vertex> doSeeding(
const std::vector<InputTrack>& trackVector, Vertex& currentConstraint,
const VertexingOptions<InputTrack_t>& vertexingOptions,
const VertexingOptions& vertexingOptions,
SeedFinderState_t& seedFinderState,
const std::vector<InputTrack>& removedSeedTracks) const;

Expand All @@ -267,7 +266,7 @@ class AdaptiveMultiVertexFinder {
/// @return The IP significance
Result<double> getIPSignificance(
const InputTrack& track, const Vertex& vtx,
const VertexingOptions<InputTrack_t>& vertexingOptions) const;
const VertexingOptions& vertexingOptions) const;

/// @brief Adds compatible track to vertex candidate
///
Expand All @@ -278,7 +277,7 @@ class AdaptiveMultiVertexFinder {
Result<void> addCompatibleTracksToVertex(
const std::vector<InputTrack>& tracks, Vertex& vtx,
FitterState_t& fitterState,
const VertexingOptions<InputTrack_t>& vertexingOptions) const;
const VertexingOptions& vertexingOptions) const;

/// @brief Method that tries to recover from cases where no tracks
/// were added to the vertex candidate after seeding
Expand All @@ -296,7 +295,7 @@ class AdaptiveMultiVertexFinder {
const std::vector<InputTrack>& allTracks,
const std::vector<InputTrack>& seedTracks, Vertex& vtx,
const Vertex& currentConstraint, FitterState_t& fitterState,
const VertexingOptions<InputTrack_t>& vertexingOptions) const;
const VertexingOptions& vertexingOptions) const;

/// @brief Method that tries to prepare the vertex for the fit
///
Expand All @@ -313,7 +312,7 @@ class AdaptiveMultiVertexFinder {
const std::vector<InputTrack>& allTracks,
const std::vector<InputTrack>& seedTracks, Vertex& vtx,
const Vertex& currentConstraint, FitterState_t& fitterState,
const VertexingOptions<InputTrack_t>& vertexingOptions) const;
const VertexingOptions& vertexingOptions) const;

/// @brief Method that checks if vertex is a good vertex and if
/// compatible tracks are available
Expand Down Expand Up @@ -390,7 +389,7 @@ class AdaptiveMultiVertexFinder {
Result<void> deleteLastVertex(
Vertex& vtx, std::vector<std::unique_ptr<Vertex>>& allVertices,
std::vector<Vertex*>& allVerticesPtr, FitterState_t& fitterState,
const VertexingOptions<InputTrack_t>& vertexingOptions) const;
const VertexingOptions& vertexingOptions) const;

/// @brief Prepares the output vector of vertices
///
Expand Down
38 changes: 17 additions & 21 deletions Core/include/Acts/Vertexing/AdaptiveMultiVertexFinder.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
template <typename vfitter_t, typename sfinder_t>
auto Acts::AdaptiveMultiVertexFinder<vfitter_t, sfinder_t>::find(
const std::vector<InputTrack>& allTracks,
const VertexingOptions<InputTrack_t>& vertexingOptions,
State& /*state*/) const -> Result<std::vector<Vertex>> {
const VertexingOptions& vertexingOptions, State& /*state*/) const
-> Result<std::vector<Vertex>> {
if (allTracks.empty()) {
ACTS_ERROR("Empty track collection handed to find method");
return VertexingError::EmptyInput;
Expand Down Expand Up @@ -141,10 +141,10 @@ auto Acts::AdaptiveMultiVertexFinder<vfitter_t, sfinder_t>::find(
template <typename vfitter_t, typename sfinder_t>
auto Acts::AdaptiveMultiVertexFinder<vfitter_t, sfinder_t>::doSeeding(
const std::vector<InputTrack>& trackVector, Vertex& currentConstraint,
const VertexingOptions<InputTrack_t>& vertexingOptions,
const VertexingOptions& vertexingOptions,
SeedFinderState_t& seedFinderState,
const std::vector<InputTrack>& removedSeedTracks) const -> Result<Vertex> {
VertexingOptions<InputTrack_t> seedOptions = vertexingOptions;
VertexingOptions seedOptions = vertexingOptions;
seedOptions.constraint = currentConstraint;

if constexpr (NeedsRemovedTracks<typename sfinder_t::State>::value) {
Expand Down Expand Up @@ -191,8 +191,7 @@ auto Acts::AdaptiveMultiVertexFinder<vfitter_t, sfinder_t>::
template <typename vfitter_t, typename sfinder_t>
auto Acts::AdaptiveMultiVertexFinder<vfitter_t, sfinder_t>::getIPSignificance(
const InputTrack& track, const Vertex& vtx,
const VertexingOptions<InputTrack_t>& vertexingOptions) const
-> Result<double> {
const VertexingOptions& vertexingOptions) const -> Result<double> {
// TODO: In original implementation the covariance of the given vertex is set
// to zero. I did the same here now, but consider removing this and just
// passing the vtx object to the estimator without changing its covariance.
Expand Down Expand Up @@ -231,10 +230,9 @@ auto Acts::AdaptiveMultiVertexFinder<vfitter_t, sfinder_t>::getIPSignificance(

template <typename vfitter_t, typename sfinder_t>
auto Acts::AdaptiveMultiVertexFinder<vfitter_t, sfinder_t>::
addCompatibleTracksToVertex(
const std::vector<InputTrack>& tracks, Vertex& vtx,
FitterState_t& fitterState,
const VertexingOptions<InputTrack_t>& vertexingOptions) const
addCompatibleTracksToVertex(const std::vector<InputTrack>& tracks,
Vertex& vtx, FitterState_t& fitterState,
const VertexingOptions& vertexingOptions) const
-> Result<void> {
for (const auto& trk : tracks) {
auto params = m_extractParameters(trk);
Expand Down Expand Up @@ -267,8 +265,7 @@ auto Acts::AdaptiveMultiVertexFinder<vfitter_t, sfinder_t>::
const std::vector<InputTrack>& allTracks,
const std::vector<InputTrack>& seedTracks, Vertex& vtx,
const Vertex& currentConstraint, FitterState_t& fitterState,
const VertexingOptions<InputTrack_t>& vertexingOptions) const
-> Result<bool> {
const VertexingOptions& vertexingOptions) const -> Result<bool> {
// Recover from cases where no compatible tracks to vertex
// candidate were found
// TODO: This is for now how it's done in athena... this look a bit
Expand All @@ -292,7 +289,7 @@ auto Acts::AdaptiveMultiVertexFinder<vfitter_t, sfinder_t>::

// Update vertex info for current vertex
fitterState.vtxInfoMap[&vtx] =
VertexInfo<InputTrack_t>(currentConstraint, vtx.fullPosition());
VertexInfo(currentConstraint, vtx.fullPosition());

// Try to add compatible track with adapted vertex position
auto res = addCompatibleTracksToVertex(allTracks, vtx, fitterState,
Expand All @@ -319,15 +316,15 @@ auto Acts::AdaptiveMultiVertexFinder<vfitter_t, sfinder_t>::

template <typename vfitter_t, typename sfinder_t>
auto Acts::AdaptiveMultiVertexFinder<vfitter_t, sfinder_t>::
canPrepareVertexForFit(
const std::vector<InputTrack>& allTracks,
const std::vector<InputTrack>& seedTracks, Vertex& vtx,
const Vertex& currentConstraint, FitterState_t& fitterState,
const VertexingOptions<InputTrack_t>& vertexingOptions) const
canPrepareVertexForFit(const std::vector<InputTrack>& allTracks,
const std::vector<InputTrack>& seedTracks,
Vertex& vtx, const Vertex& currentConstraint,
FitterState_t& fitterState,
const VertexingOptions& vertexingOptions) const
-> Result<bool> {
// Add vertex info to fitter state
fitterState.vtxInfoMap[&vtx] =
VertexInfo<InputTrack_t>(currentConstraint, vtx.fullPosition());
VertexInfo(currentConstraint, vtx.fullPosition());

// Add all compatible tracks to vertex
auto resComp = addCompatibleTracksToVertex(allTracks, vtx, fitterState,
Expand Down Expand Up @@ -557,8 +554,7 @@ template <typename vfitter_t, typename sfinder_t>
auto Acts::AdaptiveMultiVertexFinder<vfitter_t, sfinder_t>::deleteLastVertex(
Vertex& vtx, std::vector<std::unique_ptr<Vertex>>& allVertices,
std::vector<Vertex*>& allVerticesPtr, FitterState_t& fitterState,
const VertexingOptions<InputTrack_t>& vertexingOptions) const
-> Result<void> {
const VertexingOptions& vertexingOptions) const -> Result<void> {
allVertices.pop_back();
allVerticesPtr.pop_back();

Expand Down
19 changes: 9 additions & 10 deletions Core/include/Acts/Vertexing/AdaptiveMultiVertexFitter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class AdaptiveMultiVertexFitter {

// Map to store vertices information
// @TODO Does this have to be a mutable pointer?
std::map<Vertex*, VertexInfo<InputTrack_t>> vtxInfoMap;
std::map<Vertex*, VertexInfo> vtxInfoMap;

std::multimap<InputTrack, Vertex*> trackToVerticesMultiMap;

Expand Down Expand Up @@ -200,9 +200,9 @@ class AdaptiveMultiVertexFitter {
/// @param vertexingOptions Vertexing options
///
/// @return Result<void> object
Result<void> addVtxToFit(
State& state, Vertex& newVertex, const Linearizer_t& linearizer,
const VertexingOptions<InputTrack_t>& vertexingOptions) const;
Result<void> addVtxToFit(State& state, Vertex& newVertex,
const Linearizer_t& linearizer,
const VertexingOptions& vertexingOptions) const;

/// @brief Performs a simultaneous fit of all vertices in
/// state.vertexCollection
Expand All @@ -212,9 +212,8 @@ class AdaptiveMultiVertexFitter {
/// @param vertexingOptions Vertexing options
///
/// @return Result<void> object
Result<void> fit(
State& state, const Linearizer_t& linearizer,
const VertexingOptions<InputTrack_t>& vertexingOptions) const;
Result<void> fit(State& state, const Linearizer_t& linearizer,
const VertexingOptions& vertexingOptions) const;

private:
/// Configuration object
Expand Down Expand Up @@ -250,7 +249,7 @@ class AdaptiveMultiVertexFitter {
/// @param vertexingOptions Vertexing options
Result<void> prepareVertexForFit(
State& state, Vertex* vtx,
const VertexingOptions<InputTrack_t>& vertexingOptions) const;
const VertexingOptions& vertexingOptions) const;

/// @brief Sets the vertexCompatibility for all TrackAtVertex objects
/// at the current vertex
Expand All @@ -260,7 +259,7 @@ class AdaptiveMultiVertexFitter {
/// @param vertexingOptions Vertexing options
Result<void> setAllVertexCompatibilities(
State& state, Vertex* currentVtx,
const VertexingOptions<input_track_t>& vertexingOptions) const;
const VertexingOptions& vertexingOptions) const;

/// @brief Sets weights to the track according to Eq.(5.46) in Ref.(1)
/// and updates the vertices by calling the VertexUpdater
Expand All @@ -270,7 +269,7 @@ class AdaptiveMultiVertexFitter {
/// @param vertexingOptions Vertexing options
Result<void> setWeightsAndUpdate(
State& state, const Linearizer_t& linearizer,
const VertexingOptions<input_track_t>& vertexingOptions) const;
const VertexingOptions& vertexingOptions) const;

/// @brief Collects the compatibility values of the track `trk`
/// wrt to all of its associated vertices
Expand Down
24 changes: 12 additions & 12 deletions Core/include/Acts/Vertexing/AdaptiveMultiVertexFitter.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ template <typename input_track_t, typename linearizer_t>
Acts::Result<void>
Acts::AdaptiveMultiVertexFitter<input_track_t, linearizer_t>::fit(
State& state, const linearizer_t& linearizer,
const VertexingOptions<input_track_t>& vertexingOptions) const {
const VertexingOptions& vertexingOptions) const {
// Reset annealing tool
state.annealingState = AnnealingUtility::State();

Expand All @@ -33,7 +33,7 @@ Acts::AdaptiveMultiVertexFitter<input_track_t, linearizer_t>::fit(
(!state.annealingState.equilibriumReached || !isSmallShift)) {
// Initial loop over all vertices in state.vertexCollection
for (auto vtx : state.vertexCollection) {
VertexInfo<input_track_t>& vtxInfo = state.vtxInfoMap[vtx];
VertexInfo& vtxInfo = state.vtxInfoMap[vtx];
vtxInfo.relinearize = false;
// Store old position of vertex, i.e. seed position
// in case of first iteration or position determined
Expand Down Expand Up @@ -120,7 +120,7 @@ template <typename input_track_t, typename linearizer_t>
Acts::Result<void>
Acts::AdaptiveMultiVertexFitter<input_track_t, linearizer_t>::addVtxToFit(
State& state, Vertex& newVertex, const linearizer_t& linearizer,
const VertexingOptions<input_track_t>& vertexingOptions) const {
const VertexingOptions& vertexingOptions) const {
if (state.vtxInfoMap[&newVertex].trackLinks.empty()) {
ACTS_ERROR(
"newVertex does not have any associated tracks (i.e., its trackLinks "
Expand Down Expand Up @@ -201,7 +201,7 @@ template <typename input_track_t, typename linearizer_t>
Acts::Result<void> Acts::
AdaptiveMultiVertexFitter<input_track_t, linearizer_t>::prepareVertexForFit(
State& state, Vertex* vtx,
const VertexingOptions<input_track_t>& vertexingOptions) const {
const VertexingOptions& vertexingOptions) const {
// Vertex info object
auto& vtxInfo = state.vtxInfoMap[vtx];
// Vertex seed position
Expand All @@ -222,12 +222,12 @@ Acts::Result<void> Acts::
}

template <typename input_track_t, typename linearizer_t>
Acts::Result<void>
Acts::AdaptiveMultiVertexFitter<input_track_t, linearizer_t>::
setAllVertexCompatibilities(
State& state, Vertex* vtx,
const VertexingOptions<input_track_t>& vertexingOptions) const {
VertexInfo<input_track_t>& vtxInfo = state.vtxInfoMap[vtx];
Acts::Result<void> Acts::AdaptiveMultiVertexFitter<
input_track_t,
linearizer_t>::setAllVertexCompatibilities(State& state, Vertex* vtx,
const VertexingOptions&
vertexingOptions) const {
VertexInfo& vtxInfo = state.vtxInfoMap[vtx];

// Loop over all tracks that are associated with vtx and estimate their
// compatibility
Expand Down Expand Up @@ -269,9 +269,9 @@ template <typename input_track_t, typename linearizer_t>
Acts::Result<void> Acts::
AdaptiveMultiVertexFitter<input_track_t, linearizer_t>::setWeightsAndUpdate(
State& state, const linearizer_t& linearizer,
const VertexingOptions<input_track_t>& vertexingOptions) const {
const VertexingOptions& vertexingOptions) const {
for (auto vtx : state.vertexCollection) {
VertexInfo<input_track_t>& vtxInfo = state.vtxInfoMap[vtx];
VertexInfo& vtxInfo = state.vtxInfoMap[vtx];

if (vtxInfo.relinearize) {
vtxInfo.linPoint = vtxInfo.oldPosition;
Expand Down
2 changes: 1 addition & 1 deletion Core/include/Acts/Vertexing/DummyVertexFitter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class DummyVertexFitter {

/// @brief Dummy fit method
Result<Vertex> fit(const std::vector<input_track_t>&, const linearizer_t&,
const VertexingOptions<input_track_t>&) const;
const VertexingOptions&) const;
};

} // namespace Acts
2 changes: 1 addition & 1 deletion Core/include/Acts/Vertexing/FullBilloirVertexFitter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class FullBilloirVertexFitter {
/// @return Fitted vertex
Result<Vertex> fit(const std::vector<InputTrack>& paramVector,
const linearizer_t& linearizer,
const VertexingOptions<input_track_t>& vertexingOptions,
const VertexingOptions& vertexingOptions,
State& state) const;

private:
Expand Down
3 changes: 1 addition & 2 deletions Core/include/Acts/Vertexing/FullBilloirVertexFitter.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ template <typename input_track_t, typename linearizer_t>
Acts::Result<Acts::Vertex>
Acts::FullBilloirVertexFitter<input_track_t, linearizer_t>::fit(
const std::vector<InputTrack>& paramVector, const linearizer_t& linearizer,
const VertexingOptions<input_track_t>& vertexingOptions,
State& state) const {
const VertexingOptions& vertexingOptions, State& state) const {
unsigned int nTracks = paramVector.size();
double chi2 = std::numeric_limits<double>::max();

Expand Down
7 changes: 3 additions & 4 deletions Core/include/Acts/Vertexing/GridDensityVertexFinder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,9 @@ class GridDensityVertexFinder {
///
/// @return Vector of vertices, filled with a single
/// vertex (for consistent interfaces)
Result<std::vector<Vertex>> find(
const std::vector<InputTrack>& trackVector,
const VertexingOptions<InputTrack_t>& vertexingOptions,
State& state) const;
Result<std::vector<Vertex>> find(const std::vector<InputTrack>& trackVector,
const VertexingOptions& vertexingOptions,
State& state) const;

/// @brief Constructor used if InputTrack_t type == BoundTrackParameters
///
Expand Down
2 changes: 1 addition & 1 deletion Core/include/Acts/Vertexing/GridDensityVertexFinder.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
template <int mainGridSize, int trkGridSize, typename vfitter_t>
auto Acts::GridDensityVertexFinder<mainGridSize, trkGridSize, vfitter_t>::find(
const std::vector<InputTrack>& trackVector,
const VertexingOptions<InputTrack_t>& vertexingOptions, State& state) const
const VertexingOptions& vertexingOptions, State& state) const
-> Result<std::vector<Vertex>> {
// Remove density contributions from tracks removed from track collection
if (m_cfg.cacheGridStateForTrackRemoval && state.isInitialized &&
Expand Down
Loading

0 comments on commit 86cc008

Please sign in to comment.