Skip to content

Commit

Permalink
Merge branch 'main' into ci/bump-histcmp-0.6.5
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored Feb 19, 2024
2 parents adb2087 + 84c039f commit b1199f4
Show file tree
Hide file tree
Showing 37 changed files with 649 additions and 625 deletions.
2 changes: 1 addition & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ build_exatrkx:
-DACTS_ENABLE_LOG_FAILURE_THRESHOLD=ON
- ccache -z
- cmake --build build -- -j3
- cmake --build build -- -j2
- ccache -s

test_exatrkx_unittests:
Expand Down
10 changes: 5 additions & 5 deletions Core/include/Acts/Seeding/HoughTransformUtils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ struct HoughAxisRanges {
/// @return the bin number.
/// No special logic to prevent over-/underflow, checking these is
/// left to the caller
int binIndex(double min, double max, unsigned nSteps, double val) {
inline int binIndex(double min, double max, unsigned nSteps, double val) {
return static_cast<int>((val - min) / (max - min) * nSteps);
}
// Returns the lower bound of the bin specified by step
Expand All @@ -73,8 +73,8 @@ int binIndex(double min, double max, unsigned nSteps, double val) {
/// @return the parameter value at the lower bin edge.
/// No special logic to prevent over-/underflow, checking these is
/// left to the caller
double lowerBinEdge(double min, double max, unsigned nSteps,
std::size_t binIndex) {
inline double lowerBinEdge(double min, double max, unsigned nSteps,
std::size_t binIndex) {
return min + (max - min) * binIndex / nSteps;
}
// Returns the lower bound of the bin specified by step
Expand All @@ -85,8 +85,8 @@ double lowerBinEdge(double min, double max, unsigned nSteps,
/// @return the parameter value at the bin center.
/// No special logic to prevent over-/underflow, checking these is
/// left to the caller
double binCenter(double min, double max, unsigned nSteps,
std::size_t binIndex) {
inline double binCenter(double min, double max, unsigned nSteps,
std::size_t binIndex) {
return min + (max - min) * 0.5 * (2 * binIndex + 1) / nSteps;
}

Expand Down
28 changes: 20 additions & 8 deletions Core/include/Acts/Vertexing/AdaptiveGridDensityVertexFinder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
#pragma once

#include "Acts/EventData/TrackParameters.hpp"
#include "Acts/MagneticField/MagneticFieldContext.hpp"
#include "Acts/Utilities/Result.hpp"
#include "Acts/Vertexing/AdaptiveGridTrackDensity.hpp"
#include "Acts/Vertexing/DummyVertexFitter.hpp"
#include "Acts/Vertexing/IVertexFinder.hpp"
#include "Acts/Vertexing/Vertex.hpp"
#include "Acts/Vertexing/VertexingOptions.hpp"

Expand All @@ -28,10 +30,7 @@ namespace Acts {
/// with the highest track density is returned as a vertex candidate.
/// Unlike the GridDensityVertexFinder, this seeder implements an adaptive
/// version where the density grid grows bigger with added tracks.
///
/// @tparam vfitter_t Vertex fitter type
template <typename vfitter_t = DummyVertexFitter<>>
class AdaptiveGridDensityVertexFinder {
class AdaptiveGridDensityVertexFinder final : public IVertexFinder {
using GridDensity = AdaptiveGridTrackDensity;

public:
Expand Down Expand Up @@ -87,15 +86,28 @@ class AdaptiveGridDensityVertexFinder {
///
/// @param trackVector Input track collection
/// @param vertexingOptions Vertexing options
/// @param state The state object to cache the density grid
/// @param anyState The state object to cache the density grid
/// and density contributions of each track, to be used
/// if cacheGridStateForTrackRemoval == true
///
/// @return Vector of vertices, filled with a single
/// vertex (for consistent interfaces)
Result<std::vector<Vertex>> find(const std::vector<InputTrack>& trackVector,
const VertexingOptions& vertexingOptions,
State& state) const;
Result<std::vector<Vertex>> find(
const std::vector<InputTrack>& trackVector,
const VertexingOptions& vertexingOptions,
IVertexFinder::State& anyState) const override;

IVertexFinder::State makeState(
const Acts::MagneticFieldContext& /*mctx*/) const override {
return IVertexFinder::State{State{}};
}

void setTracksToRemove(
IVertexFinder::State& anyState,
const std::vector<InputTrack>& removedTracks) const override {
auto& state = anyState.template as<State>();
state.tracksToRemove = removedTracks;
}

/// @brief Constructor for user-defined InputTrack type
///
Expand Down
11 changes: 5 additions & 6 deletions Core/include/Acts/Vertexing/AdaptiveGridDensityVertexFinder.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

template <typename vfitter_t>
auto Acts::AdaptiveGridDensityVertexFinder<vfitter_t>::find(
inline auto Acts::AdaptiveGridDensityVertexFinder::find(
const std::vector<InputTrack>& trackVector,
const VertexingOptions& vertexingOptions, State& state) const
-> Result<std::vector<Vertex>> {
const VertexingOptions& vertexingOptions,
IVertexFinder::State& anyState) const -> Result<std::vector<Vertex>> {
auto& state = anyState.as<State>();
// Remove density contributions from tracks removed from track collection
if (m_cfg.cacheGridStateForTrackRemoval && state.isInitialized &&
!state.tracksToRemove.empty()) {
Expand Down Expand Up @@ -95,8 +95,7 @@ auto Acts::AdaptiveGridDensityVertexFinder<vfitter_t>::find(
return seedVec;
}

template <typename vfitter_t>
auto Acts::AdaptiveGridDensityVertexFinder<vfitter_t>::doesPassTrackSelection(
inline auto Acts::AdaptiveGridDensityVertexFinder::doesPassTrackSelection(
const BoundTrackParameters& trk) const -> bool {
// Get required track parameters
const double d0 = trk.parameters()[BoundIndices::eBoundLoc0];
Expand Down
67 changes: 37 additions & 30 deletions Core/include/Acts/Vertexing/AdaptiveMultiVertexFinder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,16 @@
#include "Acts/Definitions/Algebra.hpp"
#include "Acts/Definitions/Units.hpp"
#include "Acts/EventData/TrackParameters.hpp"
#include "Acts/MagneticField/MagneticFieldContext.hpp"
#include "Acts/Utilities/Logger.hpp"
#include "Acts/Utilities/Result.hpp"
#include "Acts/Vertexing/AMVFInfo.hpp"
#include "Acts/Vertexing/IVertexFinder.hpp"
#include "Acts/Vertexing/ImpactPointEstimator.hpp"
#include "Acts/Vertexing/TrackLinearizer.hpp"
#include "Acts/Vertexing/VertexingOptions.hpp"

#include <functional>
#include <type_traits>

namespace Acts {
Expand All @@ -31,20 +35,9 @@ namespace Acts {
///
/// @tparam vfitter_t Vertex fitter type
/// @tparam sfinder_t Seed finder type
template <typename vfitter_t, typename sfinder_t>
class AdaptiveMultiVertexFinder {
using Linearizer_t = typename vfitter_t::Linearizer_t;
template <typename vfitter_t>
class AdaptiveMultiVertexFinder final : public IVertexFinder {
using FitterState_t = typename vfitter_t::State;
using SeedFinderState_t = typename sfinder_t::State;

template <typename T, typename = int>
struct NeedsRemovedTracks : std::false_type {};

#ifndef DOXYGEN
template <typename T>
struct NeedsRemovedTracks<T, decltype((void)T::tracksToRemove, 0)>
: std::true_type {};
#endif

public:
/// Configuration struct
Expand All @@ -54,28 +47,24 @@ class AdaptiveMultiVertexFinder {
/// @param fitter The vertex fitter
/// @param sfinder The seed finder
/// @param ipEst ImpactPointEstimator
/// @param lin Track linearizer
/// @param bIn Input magnetic field
Config(vfitter_t fitter, sfinder_t sfinder, ImpactPointEstimator ipEst,
Linearizer_t lin, std::shared_ptr<const MagneticFieldProvider> bIn)
Config(vfitter_t fitter, std::shared_ptr<const IVertexFinder> sfinder,
ImpactPointEstimator ipEst,
std::shared_ptr<const MagneticFieldProvider> bIn)
: vertexFitter(std::move(fitter)),
seedFinder(std::move(sfinder)),
ipEstimator(std::move(ipEst)),
linearizer(std::move(lin)),
bField{std::move(bIn)} {}

// Vertex fitter
vfitter_t vertexFitter;

// Vertex seed finder
sfinder_t seedFinder;
std::shared_ptr<const IVertexFinder> seedFinder;

// ImpactPointEstimator
ImpactPointEstimator ipEstimator;

// Track linearizer
Linearizer_t linearizer;

std::shared_ptr<const MagneticFieldProvider> bField;

// Max z interval used for adding tracks to fit:
Expand Down Expand Up @@ -166,7 +155,9 @@ class AdaptiveMultiVertexFinder {
}; // Config struct

/// State struct for fulfilling interface
struct State {};
struct State {
std::reference_wrapper<const MagneticFieldContext> magContext;
};

/// @brief Constructor for user-defined InputTrack_t type !=
/// BoundTrackParameters
Expand All @@ -184,6 +175,12 @@ class AdaptiveMultiVertexFinder {
"No function to extract parameters "
"from InputTrack provided.");
}

if (!m_cfg.seedFinder) {
throw std::invalid_argument(
"AdaptiveMultiVertexFinder: "
"No vertex fitter provided.");
}
}

AdaptiveMultiVertexFinder(AdaptiveMultiVertexFinder&&) = default;
Expand All @@ -193,12 +190,24 @@ class AdaptiveMultiVertexFinder {
///
/// @param allTracks Input track collection
/// @param vertexingOptions Vertexing options
/// @param state State for fulfilling interfaces
/// @param anyState The state object
///
/// @return Vector of all reconstructed vertices
Result<std::vector<Vertex>> find(const std::vector<InputTrack>& allTracks,
const VertexingOptions& vertexingOptions,
State& state) const;
Result<std::vector<Vertex>> find(
const std::vector<InputTrack>& allTracks,
const VertexingOptions& vertexingOptions,
IVertexFinder::State& anyState) const override;

IVertexFinder::State makeState(
const Acts::MagneticFieldContext& mctx) const override {
return IVertexFinder::State{State{mctx}};
}

void setTracksToRemove(
IVertexFinder::State& /*state*/,
const std::vector<InputTrack>& /*removedTracks*/) const override {
// Nothing to do here
}

private:
/// Configuration object
Expand All @@ -208,9 +217,7 @@ class AdaptiveMultiVertexFinder {
std::unique_ptr<const Logger> m_logger;

/// Private access to logging instance
const Logger& logger() const {
return *m_logger;
}
const Logger& logger() const { return *m_logger; }

/// @brief Calls the seed finder and sets constraints on the found seed
/// vertex if desired
Expand All @@ -226,7 +233,7 @@ class AdaptiveMultiVertexFinder {
Result<Vertex> doSeeding(
const std::vector<InputTrack>& trackVector, Vertex& currentConstraint,
const VertexingOptions& vertexingOptions,
SeedFinderState_t& seedFinderState,
IVertexFinder::State& seedFinderState,
const std::vector<InputTrack>& removedSeedTracks) const;

/// @brief Sets constraint vertex after seeding
Expand Down
Loading

0 comments on commit b1199f4

Please sign in to comment.